import { ToolDefinition as ToolDefinition$1 } from "./_chunks/index.mjs"; import { ExtensionAPI, ToolDefinition } from "@earendil-works/pi-coding-agent"; type Component = ReturnType>; /** The `Text` component of `@earendil-works/pi-tui`, which Pi resolves for every extension. */ export type PiTextComponent = new (text: string, paddingX: number, paddingY: number) => Component; export interface PiToolOptions { /** * How a returned `isError` result reaches Pi. * * `throw` (default) raises the result text: `pi-agent-core` up to 0.98 marks * every returned object as a success and records an error only after a throw. * `return` hands the result over unchanged and keeps its `details`; use it * only with a peer range of `>=0.99.0`, since Pi does not check peer ranges. */ readonly failures?: "throw" | "return"; /** Host `Text` from `@earendil-works/pi-tui`, which `describeCall` draws with. */ readonly Text?: PiTextComponent; /** Renderers by tool name. */ readonly renderers?: Readonly>; /** Questions to ask before a call runs, by tool name. A name off the tool list throws. */ readonly confirm?: Readonly>; /** Pi's argument repair by tool name, run before validation. A name off the list throws. */ readonly prepareArguments?: Readonly>; /** How the model reaches the tools, for all or by name. Left out, Pi's `direct`. */ readonly exposure?: PiToolExposure | PiExposures; /** Group the tools share, as Pi groups the tools of one MCP server. */ readonly namespace?: PiToolNamespace; } /** Pi's `ToolExposure`, spelled out so older Pi types still compile. */ export type PiToolExposure = "direct" | "model-only" | "codemode" | "deferred" | "hidden"; /** Exposure by tool name, with a fallback for the rest. A name off the list throws. */ export interface PiExposures { readonly default?: PiToolExposure; readonly tools?: Readonly>; } /** Pi's `ToolNamespace`: what `describeNamespace()` and `tool_search` read. */ export interface PiToolNamespace { readonly name: string; readonly description?: string; readonly instructions?: string; } /** Repairs raw model input before validation. Hand back what it doesn't recognise untouched. */ export type PiPrepareArguments = (args: unknown) => unknown; /** Builds the question for one call from its validated input; `undefined` skips it. */ export type PiConfirm = (input: Readonly>) => PiQuestion | undefined | Promise; /** What `ctx.ui.confirm` shows. The adapter sanitizes both and keeps the message's lines. */ export interface PiQuestion { readonly title: string; readonly message: string; } /** Renderers for one tool: Pi's own, passed unchanged, or a one-line call summary. */ export interface PiRenderers extends Readonly> { /** One-line summary of the arguments after the title, sanitized here. A `renderCall` wins. */ readonly describeCall?: (args: Readonly>) => unknown; } /** * Registers every tool on the Pi extension API. * * @param pi - Pi extension API. * @param tools - Tools to register. * @param options - Failure policy, host `Text`, renderers, questions, repairs and exposure. * @throws {ToolDefinitionError} When two tools share a name, a tool has `describeCall` but no * `Text` came with it, `confirm`, `prepareArguments` or `exposure` names a tool that isn't in * the list, or an exposure isn't one Pi knows. */ export declare function registerPiTools(pi: ExtensionAPI, tools: readonly ToolDefinition$1[], options?: PiToolOptions): void;