JavaScript Custom Tools

Register narrow JavaScript-backed Ansight tools for app-specific Cordova/Capacitor state and actions.

const registration = Ansight.registerTool(
  {
    id: "app.get_state",
    name: "Get app state",
    category: "app",
    scope: "read",
  },
  async () => ({
    success: true,
    result: { ready: true },
  }),
);

await registration.ready;
await registration.unregister();

Use stable ids, structured inputs and results, explicit scopes, and the least-permissive tool guard. Prefer a small app-specific tool over broad DOM actions or native reflection when the app can provide a precise answer.

Native tool entries report dynamic runtime availability and remediation through the shared catalog. JavaScript-backed custom tools are advertised as available while registered; when one becomes unusable, unregister it or return a stable failure errorCode from the handler. The Capacitor registration API does not currently expose a pre-invocation availability callback.