import type { Readable, Writable } from "node:stream"; import type { H2AWorkspaceRef } from "@sentropic/h2a"; import { type H2ADriver } from "../drive/index.js"; import type { H2aRunExecutor } from "./agent-launch.js"; export interface RunMcpStdioOptions { /** Filesystem root for the local-files store. */ root: string; /** Workspace boundary for h2a_run; defaults to the server startup cwd. */ workspaceRoot?: string; /** Test seam for h2a_run; production uses the argv-only subprocess bridge. */ runExecutor?: H2aRunExecutor; /** Readable stream of newline-delimited JSON-RPC requests. */ stdin: Readable; /** Writable stream for newline-delimited JSON-RPC responses. */ stdout: Writable; /** Writable stream for diagnostics (never used for protocol traffic). */ stderr: Writable; /** * Optional override for the SessionRegistry heartbeat interval in ms. * Defaults to H2A_SESSION_DEFAULT_HEARTBEAT_INTERVAL_MS or, if set, the * H2A_HEARTBEAT_INTERVAL_MS environment variable. */ heartbeatIntervalMs?: number; /** * Optional override for the NotificationDispatcher poll interval in ms. * Defaults to the heartbeat interval or, if set, the * H2A_NOTIFY_INTERVAL_MS environment variable. */ notifyIntervalMs?: number; /** * Optional override for session expiry in ms. Defaults to * H2A_SESSION_DEFAULT_EXPIRY_MS or, if set, H2A_SESSION_EXPIRY_MS. */ expiryMs?: number; /** * DEC-105 (EVO-6): open a presence session automatically when the server * boots, so the host is on the bus at startup without an explicit * `/h2a connect`. The session auto-closes on shutdown (DEC-051); the agent * can still close it early with `h2a_session_close` (`/h2a disconnect`). */ autoOpen?: { readonly instance: string; readonly host?: string; readonly workspace?: H2AWorkspaceRef; readonly name?: string; readonly scopes?: readonly string[]; /** * Re-reads the host-native display title on each heartbeat (spec * 2026-07-25-h2a-lane-addressing §D1b). Omit to freeze the name — which is * what an explicit `--name` does. */ readonly refreshDisplayName?: () => string | undefined; /** Set only for a locally-derived sidecar identity (not --instance). */ readonly delegationEligible?: true; }; /** * Internal structured-launch readiness handshake. When present, auto-open is * mandatory and this process atomically publishes the correlated ACK only * after the presence session is open. It is never an MCP/CLI public option. */ readiness?: { readonly file: string; readonly nonce: string; }; /** * EVO-1 inbox wake (bug #3): when set (with `autoOpen`), inject a signed, * h2a-tagged wake line into the host via `driver` whenever a new inbox * envelope arrives for the auto-opened instance. The host is woken to run * `/h2a receive`. Driver-injected so it's testable; `nativeBackchannelDriver` * is the real wake. */ wake?: { readonly driver: H2ADriver; readonly privateKeyPem: string; }; /** * Optional abort signal for graceful shutdown. When it aborts, the server * closes its sessions (presence → `closed`, so peers no longer see a * false-live) and resolves. The real entry (bin.ts) wires SIGTERM/SIGINT/ * SIGHUP to an AbortController so a host kill cleans presence immediately * instead of leaving it to expire. Tests omit it (no process listeners). */ signal?: AbortSignal; } export declare const H2A_MCP_READY_FILE_ENV = "H2A_MCP_READY_FILE"; export declare const H2A_MCP_READY_NONCE_ENV = "H2A_MCP_READY_NONCE"; export declare const H2A_MCP_READY_KIND = "h2a.mcp.ready"; /** * Run the MCP server over a JSON-RPC 2.0 newline-delimited stdio transport. * * Reads requests from `stdin`, writes responses to `stdout` (one per line), * uses `stderr` for diagnostics only. Resolves once `stdin` reaches EOF. * A malformed line or a tool-dispatch throw never crashes the loop: each * is reported as a structured JSON-RPC error response. */ export declare function runMcpStdio(options: RunMcpStdioOptions): Promise; //# sourceMappingURL=stdio.d.ts.map