/** * Runtime JSON-RPC stdio session. * * `runStdioSession({ input, output, admission, registry, engine, feed, ... })` * drives the `weft rpc-stdio` CLI subcommand. It implements the stable * JSON-RPC stdio transport: reading newline-delimited JSON frames from * `input`, running each through the JSON-RPC dispatcher, and writing * responses to `output`. * * Admission is mandatory: * - `{ kind: 'startup-token', token }` — the first frame must be a * `weft.authenticate` call whose `params.token` matches. On match, * the session principal is `stdio-local` with admin scopes. On * mismatch, the session returns `exit 2` without starting. * - `{ kind: 'allow-unauthenticated-local-admin' }` — session starts * immediately with a `stdio-local` principal. The CLI flag that * enables this reads "grants full engine access to any local * process that can spawn this binary" in both the help text and * the startup log. * - `{ kind: 'require-one' }` — neither flag supplied → exit 2. * * The session is a thin wrapper over the WS session: the only real * difference is the transport (newline-delimited stdin/stdout instead * of a socket) and the admission gate. Subscribe / unsubscribe and all * the JSON-RPC semantics come from the shared session. */ import type { OperationRegistry } from './operation-catalog.ts'; import type { WorkflowEventFeed } from './workflow-event-feed.ts'; export type StdioAdmission = { readonly kind: 'require-one'; } | { readonly kind: 'startup-token'; readonly token: string; } | { readonly kind: 'allow-unauthenticated-local-admin'; }; export type StdioSessionOptions = { readonly input: ReadableStream; readonly output: WritableStream; readonly admission: StdioAdmission; readonly registry: OperationRegistry; readonly engine: unknown; readonly feed: WorkflowEventFeed; readonly maxFrameBytes?: number; readonly maxSubscriptions?: number; }; export type StdioSessionResult = { readonly exitCode: number; readonly reason?: string; }; export declare function runStdioSession(options: StdioSessionOptions): Promise;