DEVELOPER DOCUMENTATION · 0.2.0

AIReachable library documentation

A practical reference for integrating the framework-independent capability runtime into your application. Model selection, state, backend and permissions stay with your host.

Architecture & packages

AIReachable is a library, not a model or a UI agent. It executes only the host functions registered as capabilities. A planner proposes actions; the runtime validates them before they reach application state.

instruction + catalog + context → Planner → plan → CapabilityRuntime → host execute

The planner receives public action descriptions and a context snapshot, but never executable callbacks, schemas, live authorization code, components or the DOM. Your app owns its data, routing, network requests and confirmation UI.

  • Core: @aireachable/core provides CapabilityRuntime, types, strict authoring helpers and status utilities.
  • Vue: @aireachable/vue provides a headless composable exposing runtime outcomes as refs; no components are bundled.
  • Provider: supply any Planner implementation. An OpenAI-compatible HTTP adapter exists separately; the core does not fetch models.

Quick start

Install the published core package. The Vue adapter is optional. A deterministic planner lets you test integration without a model:

corepack pnpm add @aireachable/core
# optional Vue 3.5+ integration:
corepack pnpm add @aireachable/vue

The snippet below is self-contained and framework-independent:

import { CapabilityRuntime, defineCapability } from '@aireachable/core'
import type { Planner } from '@aireachable/core'

let count = 0
const add = defineCapability({
  name: 'counter.add',
  description: 'Add a positive integer',
  args: { amount: { type: 'integer', minimum: 1 } },
  effect: 'local',
  confirmation: 'none', // explicit opt-out
  available: ({ amount }) => Number.isSafeInteger(count + amount),
  execute: ({ amount }) => { count += amount },
})

const planner: Planner = {
  async propose() {
    return { steps: [{ capability: 'counter.add', args: { amount: 2 } }] }
  },
}
const runtime = new CapabilityRuntime({
  planner,
  capabilities: [add],
  getContext: () => ({ count }),
})
const result = await runtime.request('Add two')
// result.status === 'completed'; count === 2

Default confirmation is required even for local actions. The example deliberately opts out. For operations with real consequences, keep confirmation and enforce authorization in the host and backend.

Capability contract

Each capability is a host-owned function with a unique name, planner guidance, argument parser, effect classification and optional live checks.

FieldContract
nameUnique registered identifier. Only names present in the catalog can run.
description / parameters?Public hints for the planner. Parameters are descriptive, not a substitute for runtime argument validation.
schema.parse(input)Host parser. Reject invalid or extra fields; no coercion or defaults. Return the same JSON representation as the proposed arguments.
available? / authorize?Live precondition and permission checks. If present, only an explicit true permits execution; permissions are rechecked after confirmation.
execute(args)Host-owned synchronous or asynchronous function. Its return value is not part of the status.
effect / confirmation?Required effect: local, backend or unknown. Confirmation is required by default; none is an explicit opt-out.

For simple arguments, defineCapability({ args }) derives both strict parsing and matching planner hints. defineArguments and createCapabilityBuilder help compose larger catalogs. A custom schema plus parameters remains available for more complex constraints.

const action = defineCapability({
  name: 'note.update',
  description: 'Update a note',
  args: {
    note: {
      type: 'object',
      properties: {
        id: { type: 'string', minLength: 1 },
        tags: { type: 'array', items: { type: 'string' }, maxItems: 5 },
      },
    },
  },
  effect: 'backend', // confirmation required by default
  execute: ({ note }) => saveNote(note),
})

Inline args support strings, booleans, safe integers, nested objects and homogeneous arrays, with documented length/range bounds. Optional fields, unions, transforms and mixed arrays require a custom parser.

Planner & plan format

Planner is a small interface; the library does not choose a model. Its propose method may return any value, because the runtime treats the model response as untrusted.

type Planner = {
  propose(request: {
    instruction: string
    capabilities: { name: string; description: string; parameters?: unknown }[]
    context: unknown
    signal?: AbortSignal
  }): Promise<unknown>
}

// Standard proposal:
{ "steps": [{ "capability": "counter.add", "args": { "amount": 2 } }] }
// No action: { "steps": [] }

At request time, the runtime supplies the instruction, all registered names/descriptions/optional parameters and a fresh plain JSON context. It checks each proposed step against fresh host state; it does not ask the model to replan between steps.

Do not put secrets in capability descriptions or getContext(): a remote planner will receive them. Context must be a plain JSON-safe snapshot, not a reactive proxy or a permission source.

Execution & confirmation

Construct CapabilityRuntime with a planner, a catalog and getContext. request() returns a status instead of executing untrusted JSON without checks. A runtime may have only one pending plan at a time.

const result = await runtime.request('Save the record')
if (result.status === 'pending') {
  // Display result.pending.step and result.effect before approval.
  const next = approved
    ? await runtime.confirm()
    : runtime.reject()
  // Inspect next.status: the next step may also require confirmation.
}
  • request(instruction, signal?) snapshots context, awaits the planner and runs steps until completion, confirmation or failure. Concurrent requests and unresolved pending plans throw.
  • confirm(signal?) resumes one pending step after rechecking context, arguments, availability and authorization. It may return pending again for a later step.
  • reject() declines the pending step. Earlier completed steps remain applied; later steps do not run.
  • AbortSignal is cooperative: it can stop planning or future steps but cannot interrupt an in-flight execute function or undo earlier effects.

For backend effects, the application backend must independently authorize and validate every request. Library checks and a confirmation dialog are not a server-side security boundary.

Statuses & failures

Inspect the discriminated result.status; do not assume an all-or-nothing transaction.

statusMeaning
completedAll steps completed; completed lists them.
no_changesThe planner returned an empty steps array.
pendingAwait confirmation; pending.step, effect, completed and unattempted are available.
rejectedThe declined step did not run; earlier completed steps remain applied.
failedExecution or a step check failed. Inspect failed.reason, outcomeUnknown and unattempted.
invalid_planInvalid or excessive proposal (including an unknown capability); no steps ran.
planner_errorThe planner failed before execution.
context_errorThe host returned an invalid context snapshot.
stale_planningContext changed while planning; no steps ran.
cancelledPlanning was cancelled before execution.

Step failure reasons: invalid_args, unavailable, denied, stale, cancelled, execution_error and check_error. Only execution_error may set outcomeUnknown: an external effect might have happened before throwing.

No automatic rollback, atomicity or guaranteed retry/idempotency. Check actual backend state before retrying an operation with outcomeUnknown.

Vue adapter

useCapabilityRuntime(options) is a headless Vue 3.5+ adapter. It creates a separate core runtime per invocation; call it inside component setup and pass the same planner, capabilities and getContext.

import { useCapabilityRuntime } from '@aireachable/vue'

// Call inside component setup:
const assistant = useCapabilityRuntime({ planner, capabilities, getContext })
await assistant.request('Add a task')
// assistant.status.value, assistant.pending.value,
// assistant.busy.value, assistant.error.value
// assistant.confirm(), assistant.reject(), assistant.cancel()

status, pending, busy and error are readonly refs. request/confirm return core statuses; reject returns a status; cancel aborts active work, not a pending confirmation. Scope disposal aborts active operations.

Model providers

Any object satisfying Planner can be used. The optional OpenAI-compatible provider targets an application-selected Chat Completions endpoint and model; it does not start a server or add authentication.

import { createOpenAICompatibleProvider } from
  '@aireachable/provider-openai-compatible'

const planner = createOpenAICompatibleProvider({
  baseUrl: '/api/llm/v1', // your same-origin proxy
  model: 'your-model-name',
  protocol: 'standard', // optional: 'compact'
})

The optional compact protocol sends catalog indices rather than capability names in generated steps and expands them before core validation. It does not bypass argument checks or guarantee faster overall execution.

The OpenAI-compatible provider 0.2.0 is described upstream as prepared for publication. Check package availability before installing it; the code fragment above applies when that package is available.

The browser example on this site supplies a custom Transformers.js Planner. It is not part of core or the Vue adapter, and its model-loading details are not required to integrate the library.

Limits & security

Core has built-in bounds to constrain planning and JSON-safe inputs. They are fixed limits, not knobs to tune in the constructor:

  • Up to 64 registered capabilities; up to 32 KiB combined public guidance.
  • Up to 16 steps per plan; instruction up to 4 KiB.
  • JSON-safe data up to 64 KiB with nesting depth at most 32.

The library cannot guarantee model quality, correct identifier resolution, idempotency, transaction rollback or backend authorization. Keep effects accurately classified and recheck permissions on the server.

Package references

For exact public exports, full result shapes, helper overloads and change history, use the package references maintained in the library repository:

The landing’s Project desk is a consumer example; it is not the library API.

View the example →