import { PluridApi } from '@plurid/plurid-data'; /** * The subset of JSON Schema the agent's tools are written in: objects that name every field * (`additionalProperties: false`), strings, numbers, booleans, arrays and enums. Deliberately no * numeric or length constraints — a model provider's strict mode rejects them — so a tool checks * its ranges itself and answers with a reason. */ interface PluridAgentSchema { type: 'object' | 'string' | 'number' | 'integer' | 'boolean' | 'array'; description?: string; properties?: Record; required?: string[]; additionalProperties?: false; enum?: (string | number | boolean)[]; items?: PluridAgentSchema; } /** * The first way `value` breaks `schema`, as a path and a reason a model can act on * (`input.planeID must be a string, got a number`), or `null` when it holds. */ declare const validateAgentInput: (schema: PluridAgentSchema, value: unknown, path?: string) => string | null; /** A link inside a plane: its text, the route it opens, and whether the plane it opens is shown. */ interface PluridAgentLink { text: string; route: string; /** the plane it opened is in the space and shown */ open: boolean; } /** One plane, as a model reads it. */ interface PluridAgentPlane { /** the plane's id: what every tool takes */ id: string; /** its path (`/about`) */ route: string; /** its declared document title, else its path */ title: string; /** the plane it was opened from (a link's parent), `null` for a root */ parent: string | null; /** the planes opened from it */ children: string[]; /** shown (a closed plane stays in the tree, hidden, until it is removed) */ shown: boolean; /** the page the camera is docked on (the page presentation), or the one a docking swing lands on */ docked: boolean; /** selected */ selected: boolean; /** part of it is inside the view (the browser's layout) */ onScreen: boolean; /** its text, whitespace collapsed, cut at the excerpt length (`…` when cut) */ text: string; /** the links inside it */ links: PluridAgentLink[]; /** pinned to the screen, above the space, wherever the camera is (2026-10-31) */ pinned: boolean; /** pinned and collapsed to its title bar */ collapsed: boolean; /** the stack it is in (`plurid_stack`), `null` for none */ stack: string | null; /** faded: it stands between the camera and the plane the camera rests on */ occluding: boolean; } /** The space, as a model reads it: what is there, what is in view, what can be done next. */ interface PluridAgentObservation { /** `page`: one plane at a time, docked, a site; `space`: planes arranged in 3D */ presentation: 'page' | 'space'; /** the docked page's id, `null` when the camera is off every page */ docked: string | null; /** the plane in focus: the one keyboard commands (`plurid_command`) act on, `null` for none */ active: string | null; /** how the roots are arranged (`COLUMNS`, `ROWS`, …) */ layout: string; /** the camera: angles in degrees, the zoom, and whether it is moving */ camera: { yaw: number; pitch: number; scale: number; moving: boolean; }; view: { width: number; height: number; }; planes: PluridAgentPlane[]; selection: string[]; history: { canUndo: boolean; canRedo: boolean; }; bookmarks: string[]; /** the stacks: each one's id and its planes, front first */ stacks: { id: string; planes: string[]; }[]; } interface PluridAgentObserveOptions { /** characters of each plane's text (default 600; 0 leaves the text out) */ textLength?: number; /** one plane only, with its whole text */ planeID?: string; } type PluridAgentToolName = 'plurid_observe' | 'plurid_follow_link' | 'plurid_open_plane' | 'plurid_go_to_plane' | 'plurid_close_plane' | 'plurid_remove_plane' | 'plurid_scroll_plane' | 'plurid_camera' | 'plurid_select' | 'plurid_arrange' | 'plurid_history' | 'plurid_bookmark' | 'plurid_command' | 'plurid_configure' | 'plurid_tour' | 'plurid_pin' | 'plurid_stack'; type PluridAgentErrorCode = 'unknown_tool' | 'invalid_input' | 'not_found' | 'ambiguous' | 'not_allowed' | 'unavailable' | 'no_effect' | 'failed'; /** A failure a model can act on: what went wrong, and what to do instead. */ declare class PluridAgentError extends Error { readonly code: PluridAgentErrorCode; constructor(code: PluridAgentErrorCode, message: string); } /** A tool as WebMCP registers it: the MCP shape, plus the function the browser's agent calls. */ interface PluridWebMCPTool { name: string; description: string; inputSchema: PluridAgentSchema; annotations?: { readOnlyHint?: boolean; destructiveHint?: boolean; }; execute: (input: unknown) => Promise<{ content: { type: 'text'; text: string; }[]; isError?: boolean; }>; } interface ModelContext { registerTool: (tool: PluridWebMCPTool, options?: { signal?: AbortSignal; }) => unknown; /** earlier drafts unregistered by name */ unregisterTool?: (name: string) => unknown; } /** * The page's WebMCP context, where the browser offers one: `document.modelContext` (the proposal's * current home), else `navigator.modelContext` (its earlier drafts). `undefined` in a browser * without it, and on a server. */ declare const webMCPContext: () => ModelContext | undefined; interface PluridWebMCPRegistration { /** whether the page has a WebMCP context at all */ available: boolean; /** the tools registered */ registered: string[]; /** the tools the context refused (a name already taken, a context that threw), with its reason */ refused: { name: string; reason: string; }[]; /** unregister every tool registered here */ dispose: () => void; } interface PluridAgentOptions { /** * Where this application's planes are in the page: an element, or a function returning one (the * view, or anything around it). Default: the document — enough for one application per page; * with several, give each agent its own (`[data-plurid-application="…"]`). */ root?: ParentNode | (() => ParentNode | null | undefined); /** The tools offered, by name (default: all of them). */ tools?: PluridAgentToolName[]; /** Offer only the tools that read (`plurid_observe`). */ readOnly?: boolean; /** Asked before every call that passed validation: return `false` to refuse it (the model is told so). */ onCall?: (call: { name: PluridAgentToolName; input: Record; }) => boolean | void | Promise; /** How long a call waits for the space to come to rest before answering, ms (default 4000). */ settleTimeout?: number; /** Characters of each plane's text in an observation (default 600). */ textLength?: number; } /** What changed in the space during a call, by plane id. */ interface PluridAgentChanges { opened: string[]; closed: string[]; removed: string[]; /** the docked page before and after, when it changed */ docked?: { from: string | null; to: string | null; }; } interface PluridAgentResult { ok: boolean; tool: string; /** what was done, in a sentence */ summary?: string; changes?: PluridAgentChanges; /** `false` when the space was still moving when the answer was given */ settled?: boolean; /** the space after the call */ observation?: PluridAgentObservation; error?: { code: PluridAgentErrorCode; message: string; }; } /** A tool as the MCP (and WebMCP) catalog lists it. */ interface PluridAgentMCPTool { name: PluridAgentToolName; description: string; inputSchema: PluridAgentSchema; annotations: { readOnlyHint: boolean; destructiveHint: boolean; }; } /** A tool as the Claude Messages API takes it (`tools`); `strict` guarantees schema-valid input. */ interface PluridAgentAnthropicTool { name: PluridAgentToolName; description: string; input_schema: PluridAgentSchema; strict?: true; } interface PluridAgent { /** The tools offered, in the MCP / WebMCP shape (`inputSchema`). */ tools: () => PluridAgentMCPTool[]; /** The tools in the Claude Messages API shape (`input_schema`), `strict` when asked. */ anthropicTools: (options?: { strict?: boolean; }) => PluridAgentAnthropicTool[]; /** * Run a tool: the input is validated against its schema, `onCall` is asked, the action runs, * the answer waits for the space to come to rest and carries the space as it is then. Never * throws: a failure is `{ ok: false, error }`, written for the model to act on. Calls run one * at a time, in the order they were made. */ call: (name: string, input?: unknown) => Promise; /** The space as a model reads it, now. */ observe: (options?: PluridAgentObserveOptions) => PluridAgentObservation; /** Register the tools with the browser's WebMCP context, where there is one. */ exposeToWebMCP: () => Promise; /** * Put `{ tools, call, observe }` on `window[name]` (default `__PLURID_AGENT__`) for an agent that * drives the page from outside (a browser-automation agent evaluating script in it). Opt-in: * anything the page runs can then call the tools. Returns the undo. */ exposeGlobal: (name?: string) => () => void; /** Withdraw every registration this agent made. */ dispose: () => void; } /** * AGENT CONTROL: a plurid application operated by an AI agent, through the same bus its host uses. * `api` is what `onReady` gives (or the `ref` handle, which extends it). The agent observes the * space as a reader would read it and acts on it with a small set of tools, each described for a * model and validated before it runs; it depends on no model provider — hand `tools()` or * `anthropicTools()` to whichever runs the model, and route its tool calls to `call`. */ declare const createPluridAgent: (api: PluridApi, options?: PluridAgentOptions) => PluridAgent; interface UsePluridAgentOptions extends PluridAgentOptions { /** Register the tools with the browser's WebMCP context while mounted, where there is one. */ webmcp?: boolean; /** Put the agent on `window` while mounted: `true` for `__PLURID_AGENT__`, or a name. */ global?: boolean | string; } /** * The agent of an application in React: created once `api` exists (`onReady`), exposed to WebMCP * or on `window` as asked, withdrawn on unmount. `undefined` until the application is ready. */ declare const usePluridAgent: (api: PluridApi | undefined, options?: UsePluridAgentOptions) => PluridAgent | undefined; export { type PluridAgent, type PluridAgentAnthropicTool, type PluridAgentChanges, PluridAgentError, type PluridAgentErrorCode, type PluridAgentLink, type PluridAgentMCPTool, type PluridAgentObservation, type PluridAgentObserveOptions, type PluridAgentOptions, type PluridAgentPlane, type PluridAgentResult, type PluridAgentSchema, type PluridAgentToolName, type PluridWebMCPRegistration, type UsePluridAgentOptions, createPluridAgent, usePluridAgent, validateAgentInput, webMCPContext };