import { StreamLike } from "./stream-to-sse.mjs"; import { IncomingMessage, ServerResponse } from "node:http"; //#region ../ai/src/serve/serve.d.ts /** * Anything `serve` can expose: a primitive whose `stream(input, options)` * returns a {@link StreamLike}. Agents, supervisors, and orchestrators all * satisfy it. */ type ServableExecutable = { stream(input: TInput, options?: Record): StreamLike<{ type: string; }, unknown>; }; /** Options for {@link serve}. */ type ServeOptions = { /** * Bearer token required on every request. When set, a request must send * `Authorization: Bearer `, else `401` (S4-style auth, the same * control the dashboard uses — fold this in for a production deploy). */ authToken?: string; /** * Map the parsed JSON request body to the executable's input. Default: * `body.input`. Override to accept a different request shape. */ toInput?: (body: Record) => TInput; /** * Map the parsed body to per-call stream options (e.g. an orchestrator * `{ sessionId, history }` so a turn resumes the right session — A3 * wiring). Default: pass `sessionId` / `history` straight through. */ toOptions?: (body: Record) => Record; }; /** * Turn an executable into a `node:http` request handler that streams its * run to the client as Server-Sent Events (A3) — the production-serving * primitive. POST a JSON body (`{ input, sessionId?, history? }`); the * response is an `text/event-stream` of the primitive's events, the final * `result`, then `[DONE]`. Absorbs the auth-token control; pair with a * `sessionLock` + an orchestrator for durable multi-turn serving. * * @example * import { createServer } from "node:http"; * createServer(ai.serve(myAgent, { authToken: process.env.TOKEN })).listen(8787); */ declare function serve(executable: ServableExecutable, options?: ServeOptions): (req: IncomingMessage, res: ServerResponse) => void; //#endregion export { ServableExecutable, ServeOptions, serve }; //# sourceMappingURL=serve.d.mts.map