Register host functions
Describe arguments, availability checks, effects, and execution for each operation your application is willing to expose.
Register application functions as named capabilities. A planner receives the allowed actions and current context, returns a JSON plan, and the runtime checks each step before invoking host code.
// Registered by the host application
const search = defineCapability({
name: 'project.search',
args: { query: { type: 'string' } },
effect: 'local',
confirmation: 'none',
available: canSearch,
execute: searchTable,
})
// Model output: proposal, not executable code
const plan = {
steps: [{
capability: 'project.search',
args: { query: 'Harbor' },
}],
}named capabilitiesvalidated argumentsexplicit approvalFind Leo’s projects, select Planning, open Harbor migration, and return to the project list.
| Method | Total time | Included in the measurement |
|---|---|---|
| OpenCode via browser UI | 51.76 s | 3.10 s browser commands + 48.66 s between commands |
| AIReachable · regular JSON | 7.56 s | Model response + execution of four app actions |
| AIReachable · compact format | 5.83 s | Model response + execution of four app actions |
Setup. Test with qwen3.8-flash-next-q2_0, RTX 3060 (12 GB VRAM) and 96 GB RAM. This is not the Qwen2.5 0.5B browser-model demo above.
Observed result. AIReachable completed this scenario 44.20 s sooner with regular JSON and 45.93 s sooner with the compact format. Gaps between commands accounted for about 94% of the OpenCode total.
What it does not prove. OpenCode’s 3.10 s covers browser commands only; AIReachable’s 7.56 s and 5.83 s also include model response. Those figures cannot be compared as execution-only times. One run per AIReachable format is not enough to establish a general speedup or a protocol advantage.
The application supplies a capability catalog and a context snapshot. The planner proposes steps; the runtime checks names, arguments, availability, and confirmation policy.
Describe arguments, availability checks, effects, and execution for each operation your application is willing to expose.
A planner returns capability names and arguments. The model never gets to run arbitrary code or manipulate page elements.
The runtime checks each step against the catalog and current state. Consequential actions pause for confirmation.
{
"steps": [
{
"capability": "project.search",
"args": { "query": "Harbor" }
}
]
}A planner can be replaced without changing registered actions. The host supplies the state snapshot and implements the functions; the runtime mediates execution.
DocumentationThe demo registers eight actions: navigate, search, filter, show list, create, edit, delete, and add task. The runtime resolves each name against this catalog.
Arguments are parsed against the capability schema; actions with availability checks must pass against current state. Unknown names do not run.
Create, edit, and delete wait for approval. Navigation, search, filters, and task addition explicitly opt out in this local demo.
An error stops the plan and reports completed steps. Previous changes are not automatically rolled back.
Vue table, filters, forms, and assistant actions share application state. The optional browser model downloads only after you select “Load demo model”.
The action contract is independent of the model. The demo uses a browser planner; a different planner can return the same plan format without changing host operations.
The demo connects a Planner, capability catalog, and getContext callback. The model proposes action names and arguments; it does not receive JavaScript to run.
Both approaches need to interpret the instruction, but these measured runs used different execution paths and do not isolate the cost of either path.
Often inspects page markup, identifies an element, clicks or types, then checks the result. A multi-step task may repeat this loop.
The model selects a registered application function; the runtime validates its arguments and calls the same host logic used by the UI.
Follow a search request through the Project desk demo. Each component has a separate job; a JSON response is only the input to the checks, not permission to change state.
The host supplies the user instruction, descriptions of registered capabilities, and a snapshot of current project state. The planner can be replaced without changing host functions.
planner.propose({ instruction, capabilities, context })The response names capabilities and supplies arguments. A malformed response is rejected; parsing valid JSON does not make an action authorized.
steps: [{ capability, args }]The runtime resolves the name, parses the capability arguments, and applies availability and confirmation rules before invoking the host function.
name → args → available → confirmation → executeThe search capability calls the same searchTable function used by the UI. The library does not query page elements or manipulate the DOM to find a search box.
execute: searchTableIn this demo, create, edit, and delete wait for approval. Navigation, search, filters, and task addition explicitly opt out. When integrating real services, the host must also enforce its own authorization rules.
If a later step fails or is rejected, earlier completed steps remain applied. The runtime reports the outcome; rollback or compensation must be implemented by the host if needed.
Direct function calls can avoid repeated DOM inspection and simulated clicks in multi-step tasks. The single-scenario measurements below show faster end-to-end completion in those runs, not an isolated improvement in runtime or model speed.
Inspect the core package and the project-desk integration: planner wiring, host functions, availability checks, and confirmation policy.