import type { RegistryAgnosticEngine } from '../core/engine.ts'; import { type McpSessionManagerOptions } from './session.ts'; /** * Admission modes for local MCP stdio sessions. * * @example * ```ts * import { type McpStdioAdmission } from '@lostgradient/weft/mcp'; * * const admission: McpStdioAdmission = { * kind: 'startup-token', * token: 'change-me', * }; * void admission; * ``` */ export type McpStdioAdmission = { readonly kind: 'allow-unauthenticated-local-admin'; } | { readonly kind: 'startup-token'; readonly token: string; } | { readonly kind: 'require-one'; }; /** * Options for running a local MCP stdio session. * * @example * ```ts * import { type McpStdioSessionOptions } from '@lostgradient/weft/mcp'; * import { Engine, MemoryStorage } from '@lostgradient/weft'; * * await using storage = new MemoryStorage(); * await using engine = new Engine({ storage }); * * const options: McpStdioSessionOptions = { * input: new ReadableStream(), * output: new WritableStream(), * engine, * admission: { kind: 'require-one' }, * sessionManagerOptions: { maximumSessions: 1 }, * }; * void options; * ``` */ export type McpStdioSessionOptions = { readonly input: ReadableStream; readonly output: WritableStream; /** * Typed as {@link RegistryAgnosticEngine} (see its JSDoc) rather than the * plain default `Engine`, so both `new Engine({ storage })` and * `Engine.create({ workflows })` type-check here directly. */ readonly engine: RegistryAgnosticEngine; readonly admission: McpStdioAdmission; readonly maxFrameBytes?: number; readonly sessionManagerOptions?: McpSessionManagerOptions; }; /** * Result of a completed MCP stdio session. * * @example * ```ts * import { type McpStdioSessionResult } from '@lostgradient/weft/mcp'; * * const result: McpStdioSessionResult = { exitCode: 0 }; * process.exitCode = result.exitCode; * ``` */ export type McpStdioSessionResult = { readonly exitCode: number; readonly reason?: string; }; /** * Run a newline-delimited MCP JSON-RPC stdio session against a local engine. * * @example * ```ts * import { runMcpStdioSession } from '@lostgradient/weft/mcp'; * import { Engine, MemoryStorage } from '@lostgradient/weft'; * * await using storage = new MemoryStorage(); * await using engine = new Engine({ storage }); * * const result = await runMcpStdioSession({ * input: new ReadableStream(), * output: new WritableStream(), * engine, * admission: { kind: 'require-one' }, * }); * void result; * ``` */ export declare function runMcpStdioSession(options: McpStdioSessionOptions): Promise;