/** * Integrations bridged into subagent worker threads. * * - **MCP** (`"mcp-manager"`): a main `MCPManager` crosses by reference; the worker gets a * {@link RemoteMCPManager}. Tools come back as plain views ({@link toWorkerCustomTool}), re-sent * only when main's tool views changed since the worker's last read for that view, whose * `execute` runs the main-side MCP tool (streaming `onUpdate` and abort signals cross), tool and * notification subscriptions are held on main per worker and dropped when it exits, and the * worker's `MCPManager.instance()/load()/available()` answer from main's process global. A worker * never connects MCP servers itself (`createAgentSession` skips discovery off the main thread). * - **Tool contexts** (`"custom-tool-context"`, see `./tool-context`): main-thread tools called from a * worker child receive a snapshot context instead of the worker's live objects. * - **`LocalProtocolOptions`** (`"local-protocol-options"`): a main-side options object reaches a * worker with synchronous getters (`rpcSync`), since `resolveLocalRoot` reads them synchronously; * a worker-side one reaches main as a snapshot of its current values. * - **Prepared extensions** (`"prepared-extension"`): a `PreparedExtension` crosses as its module * path; the receiver re-imports the module on first bind, so the factory runs in the receiving * thread against that thread's `ExtensionAPI`. Model providers such factories register in a * worker are dropped by the worker's model-registry mirror: the parent bound the same prepared * extensions to main's registry, which the mirror follows (see `./auth`). * * Main-side values that are plain functions (no type to match a codec on) are converted by * {@link bridgeIntegrationOptions} before an `ExecutorOptions` object crosses a link. */ import type { TSchema } from "@oh-my-pi/pi-ai"; import type { CustomTool } from "../../extensibility/custom-tools/types.js"; import { type MCPManagerGlobal } from "../../mcp/manager.js"; import type { ExecutorOptions } from "../../task/executor.js"; import type { ThreadService } from "../services.js"; /** Codec kind of `LocalProtocolOptions`. */ export declare const LOCAL_PROTOCOL_OPTIONS_KIND = "local-protocol-options"; /** Codec kind of `PreparedExtension`. */ export declare const PREPARED_EXTENSION_KIND = "prepared-extension"; /** Boot globals of {@link integrationsThreadService}. */ export interface IntegrationsThreadGlobals { /** Main's process-global MCP manager accessors; `instance`/`available` are synchronous for the worker. */ readonly mcp: MCPManagerGlobal; } /** * Main side: the cross-thread form of a custom tool — its data fields plus `execute`/`onSession` * running on this thread, with the synchronous approval hooks marked {@link rpcSync}. Render and * describe hooks are dropped: only the main-thread UI renders tool calls. Cached on the tool, so * repeated sends export the same functions. `parameters` must be structured-clone data (JSON * schema); TypeBox symbol metadata does not cross. */ export declare function toWorkerCustomTool(tool: CustomTool): CustomTool; /** * Main side: convert the integration fields of `options` that cannot cross as-is into forms that * behave identically in a worker. Call once on the options a main-thread caller hands to a * worker-hosted `runSubprocess`; returns a shallow copy (other fields are untouched). * * - `extensionRoots`, `preparedSession.promptSuffix`: called synchronously by the child → `rpcSync`. * - `customTools`: {@link toWorkerCustomTool} views. * - `parentTelemetry`: `toWorkerTelemetryConfig` (captures the active span as the child's parent, so * call this inside the parent's `execute_tool task` context). * * Everything else in this module's scope crosses automatically through codecs and exported * classes (`mcpManager`, `localProtocolOptions`, `preloadedPreparedExtensions`, tool contexts); * `perCallModelGrants` crosses intact (its `settings` becomes the worker's live mirror). */ export declare function bridgeIntegrationOptions(options: ExecutorOptions): ExecutorOptions; /** MCP, tool-context, local-protocol and prepared-extension bridging for subagent workers. */ export declare const integrationsThreadService: ThreadService;