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:

  1. aixa.start() is called — The SDK initializes and begins the discovery phase.
  2. inferTools() walks the DOM — The scanner traverses the document, matching elements against known semantic patterns.
  3. Each matching element becomes a ToolSchema — The SDK extracts the element's label, parameters, and behavior to build a complete JSON-RPC tool definition.
  4. Tools are broadcast via CustomEvent — The aixa:tools-ready event fires on window, 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:

Limitations

Auto-inference is powerful but has some important caveats:

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"
}
Try it live: The demo application showcases auto-inference in action. Inspect the page source to see how semantic HTML maps to tool definitions.