import type { RegisterWebMcpBespokeToolOptions, WebMcpBespokeToolSpec, WebMcpToolEffect } from '@happyvertical/smrt-web'; /** A tool exposed to the browser's WebMCP model context. */ export type WebMcpToolSpec = WebMcpBespokeToolSpec; export interface UseWebMcpToolOptions { /** * This tool's own `effects` exposure-policy fallback, used only when no * Provider ancestor supplies an explicit `webmcp.effects` policy. A * Provider's explicit policy always wins over this default — even a * narrower one — so a component cannot use its own default to grant * itself more than an ancestor Provider allows (#2586). Omit to keep the * registrar's own read-only default as the no-Provider fallback. */ effects?: readonly WebMcpToolEffect[]; /** * Which path this tool belongs to, for the tool-name lock's collision * diagnostic only (#2613). Defaults to `bespoke`, which is right for every * hand-written component tool. `useViewIntent` passes `intent` because it * routes a declared view intent through this same hook rather than * duplicating the WebMCP lifecycle — see * `RegisterWebMcpBespokeToolOptions['owner']`. It grants nothing. */ owner?: RegisterWebMcpBespokeToolOptions['owner']; } declare global { interface Document { modelContext?: WebMcpModelContext; } interface WebMcpModelContext { registerTool(tool: WebMcpToolSpec, options?: { signal?: AbortSignal; }): Promise; } } /** * Register a component-owned WebMCP intent for exactly that component's * lifetime. The factory runs inside the effect so rune dependencies used by a * bespoke intent cause the tool to be replaced when its spec changes. * * Routes through `@happyvertical/smrt-web`'s `registerWebMcpBespokeTool` so a * bespoke tool is subject to the same fail-closed `effects` exposure policy * as generated model tools (#2586): a spec with no `annotations`, or with * annotations that leave its effect undeclared, classifies destructive, * non-idempotent, open-world, and is excluded unless policy allows * `destructive`. The policy is the nearest Provider's `webmcp.effects` (read * from context so a bespoke and a generated tool share one policy); absent a * Provider ancestor, it falls back to the registrar's own read-only default. * `namespace` and `maxTools` deliberately do not apply to a bespoke tool. * * `@happyvertical/smrt-web` loads lazily, on first use, so a page that only * calls `useWebMcpTool` never bundles the client-data engine. * * @param options.effects a fallback exposure policy applied only when no * Provider ancestor declares one — see {@link UseWebMcpToolOptions}. * @param options.owner the tool-name lock's diagnostic label for this * registration (#2613); `useViewIntent` passes `intent`, everything else * leaves the `bespoke` default. */ export declare function useWebMcpTool(factory: () => WebMcpToolSpec | null | undefined, options?: UseWebMcpToolOptions): void; //# sourceMappingURL=webmcp.svelte.d.ts.map