Auto-Inference
Auto-inference is the zero-configuration mode of aixa.js. When enabled, the SDK walks the DOM at startup and automatically generates JSON-RPC tool schemas from semantic HTML elements. You get agent-accessible tools with no manual registration — perfect for server-rendered pages, static sites, and simple SPAs.
Enable it by passing { autoInfer: true } to the AIXA
constructor and calling aixa.start().
How It Works
The auto-inference pipeline runs through four stages:
-
aixa.start()is called — The SDK initializes and begins the discovery phase. -
inferTools()walks the DOM — The scanner traverses the document, matching elements against known semantic patterns. -
Each matching element becomes a
ToolSchema— The SDK extracts the element's label, parameters, and behavior to build a complete JSON-RPC tool definition. -
Tools are broadcast via
CustomEvent— Theaixa:tools-readyevent fires onwindow, carrying the full tool registry. AI agents listening on the page can then query and invoke these tools.
Elements Detected
The DOM scanner recognizes the following element patterns. Each generates a tool with a name prefix and a risk level:
| Element | Selector Pattern | Generated Tool | Risk Level |
|---|---|---|---|
<input type="search"> |
input[type="search"] |
search_* |
SAFE |
<select> with filter/sort names |
select[name*="filter"], select[name*="sort"] |
filter_* / sort_* |
SAFE |
<form role="search"> inputs |
form[role="search"] input |
search_* |
SAFE |
Links <a> |
a[href] |
navigate_* |
SAFE |
<button type="submit"> |
button[type="submit"] |
mutation_* |
HIGH_RISK |
<form action="*/cart/*"> buttons |
form[action*="/cart/"] button |
mutation_* |
HIGH_RISK |
Elements with data-aixa-confirm |
[data-aixa-confirm] |
mutation_* |
HIGH_RISK |
data-aixa-* Attributes
Use these data-aixa-* attributes to annotate your HTML and give the
auto-inference engine richer context. They're optional — the scanner works fine
without them — but they improve the quality of generated tool schemas.
| Attribute | Purpose | Example |
|---|---|---|
data-aixa-search |
Marks a form or input as a search endpoint | <form data-aixa-search="product-search"> |
data-aixa-filter |
Marks a <select> as a filter control |
<select data-aixa-filter="category"> |
data-aixa-sort |
Marks a <select> as a sort control |
<select data-aixa-sort="price-order"> |
data-aixa-confirm |
Requires human confirmation before this tool is invoked | <button data-aixa-confirm>Delete</button> |
data-aixa-name |
Overrides the auto-generated tool name | <input data-aixa-name="find-products"> |
data-aixa-description |
Provides a human-readable description for the tool | <form data-aixa-description="Search the product catalog by keyword"> |
data-aixa-category |
Assigns the tool to a logical category | <div data-aixa-category="shopping"> |
data-aixa-risk |
Explicitly sets the risk level (safe or high) |
<button data-aixa-risk="high"> |
data-aixa-params |
JSON string defining additional or override parameters | <input data-aixa-params='{"limit":{"type":"number"}}'> |
ARIA Support
The scanner uses ARIA attributes to generate human-readable labels and improve tool descriptions. The following ARIA features are recognized:
-
aria-label— Used as the primary label for tool names and descriptions. Takes precedence over text content. -
role— The element's ARIA role refines the tool's purpose and behavior classification:role="search"— Form or region is a search toolrole="searchbox"— Input is a search fieldrole="combobox"— Input is a filterable selection
-
Associated
<label>elements — Labels connected viaforattributes are used as parameter descriptions.
Limitations
Auto-inference is powerful but has some important caveats:
- Standard HTML only — The scanner recognizes semantic HTML patterns. Custom Web Components and framework-specific syntax (JSX, Svelte templates, etc.) are not detected unless they render standard DOM elements.
-
Dynamic content — Content loaded after
aixa.start()(e.g., infinite scroll, lazy-loaded sections) is not automatically discovered. Callaixa.refreshTools()to re-scan the DOM after dynamic updates. -
Shadow DOM — Elements inside shadow roots are not traversed
by default. To scan shadow DOM content, pass an explicit
rootoption referencing the shadow host. -
Overlapping tools — Multiple elements matching the same
pattern may produce duplicate tool names. Use
data-aixa-nameto disambiguate.
Example
Given this search form in your HTML:
<form role="search" aria-label="Product search">
<input type="search" name="q" placeholder="Search products...">
<select name="category">
<option value="">All Categories</option>
<option value="electronics">Electronics</option>
<option value="clothing">Clothing</option>
</select>
<input type="number" name="minPrice" placeholder="Min price">
<input type="number" name="maxPrice" placeholder="Max price">
<button type="submit">Search</button>
</form>
The auto-inference engine generates this JSON-RPC tool schema:
{
"name": "search_product_search",
"description": "Search for products by keyword, category, and price range",
"parameters": {
"type": "object",
"properties": {
"q": {
"type": "string",
"description": "Search query"
},
"category": {
"type": "string",
"description": "Filter by product category",
"enum": ["", "electronics", "clothing"]
},
"minPrice": {
"type": "number",
"description": "Minimum price filter"
},
"maxPrice": {
"type": "number",
"description": "Maximum price filter"
}
},
"required": ["q"]
},
"riskLevel": "safe",
"category": "search"
}