/** * The one path an orchestrator turn takes: build the prompt, announce it, send it. * * Every flow turn rebuilds the full `# Flow Execution Context` prompt and hands * it to an agent driver. There are four such call sites — the stimulus bus and * the inline sub-flow runner, once each in the runner's `serve.ts` (hosted * sessions) and in `run-flow.ts` (CLI runs) — and nothing about the prompt used * to reach the event stream, so a consumer saw the agent replying to input it * could not read. Routing all four through {@link driveOrchestratorTurn} is what * keeps the announcement from drifting away from what is actually sent. * * Lives with the flow connector rather than the runner because the CLI entry in * this same directory is one of the four callers, and `factory-assets` must not * take a static import on `runner`. * * @docLink packages/factory-assets/flow#orchestrator-turn */ import type { FlowExecution, FlowPromptEvent } from "@skaile/workspaces/types"; import type { FlowDefinition } from "./engine/types.js"; import { type TurnStimulus } from "./prompt-fragments.js"; /** What one orchestrator turn is about — the inputs both the prompt and the event derive from. */ export interface FlowTurnContext { /** Definition of the flow being driven — the child definition for an inline sub-flow turn. */ flow: FlowDefinition; /** Live snapshot the prompt is built from. */ execution: FlowExecution; /** Why the runner is driving this turn. */ stimulus: TurnStimulus; } /** Host seams {@link driveOrchestratorTurn} needs to announce and deliver a turn. */ export interface FlowTurnSinks { /** Puts the announcement on the session's event stream. */ emit: (event: FlowPromptEvent) => void; /** Hands the prompt to the driver and resolves when the turn ends. */ deliver: (prompt: string) => Promise; } /** * Build the `flow_prompt` event describing one orchestrator turn. * * `prompt` is stored verbatim — callers must pass the same string they hand to * the driver, never a re-rendered one, or the host renders something the agent * never saw. The stimulus is reduced to its kind plus the node it concerns * because its payload (user text, node input) is already inside `prompt`. * * Pure so the field mapping is unit-testable without booting a session. * * @docLink packages/factory-assets/flow#orchestrator-turn */ export declare function buildFlowPromptEvent(input: FlowTurnContext & { prompt: string; }): FlowPromptEvent; /** * Build one orchestrator prompt, announce it, then deliver it to the agent. * * The prompt is built once and the same binding is both put on the event and * passed to `deliver`, which is what makes the emitted `prompt` byte-identical * to what the driver receives. * * `emit` runs before `deliver` is even called, so the announcement always * precedes that turn's reply events. A caller that must not prompt at all * (turn gated off, run already terminal) has to return before calling this — * reaching here means the prompt is going out. * * @docLink packages/factory-assets/flow#orchestrator-turn */ export declare function driveOrchestratorTurn(input: FlowTurnContext & FlowTurnSinks): Promise; //# sourceMappingURL=orchestrator-turn.d.ts.map