import { ToolContract } from "../tool/tool.mjs"; import { SupervisorAsToolOptions, SupervisorContract } from "../contracts/supervisor/supervisor.contract.mjs"; //#region ../ai/src/supervisor/as-tool.d.ts /** * Wrap a `SupervisorContract` as a `ToolContract` so an outer agent * can invoke it from its tool-call loop. Mirrors * `workflow.asTool()` / `agent.asTool()` — same composition pattern, * same error-normalization behavior. * * Behavior: * - The tool's `name` mirrors the supervisor's `name` unless the * caller overrides via `options.name`. Supervisors without a * meaningful name throw `SupervisorFailedError` — an outer agent * can't route to an anonymous tool. * - Tool `input` is the supplied schema; the validated value is * coerced to a string (via `String()` for non-string values, or * `JSON.stringify()` for objects) before being forwarded to * `supervisor.execute(input)`. Consumers whose inputs need * richer shaping should pre-format the string themselves. * - On `result.error`, the supervisor error is thrown so the tool * wrapper catches it and produces a `ToolExecutionError` with * `cause` set to the original typed supervisor error — the outer * agent sees one uniform error class regardless of which * primitive failed. * * @example * const support = ai.supervisor({ ... }); * const supportTool = support.asTool({ * name: "handle_support_ticket", * description: "Process a customer support ticket end-to-end.", * inputSchema: z.object({ ticket: z.string() }), * }); * const concierge = ai.agent({ model, tools: [supportTool] }); */ declare function asTool(supervisorInstance: SupervisorContract, options: SupervisorAsToolOptions): ToolContract; //#endregion export { asTool }; //# sourceMappingURL=as-tool.d.mts.map