/** * Prompt fragments for the flow connector. * * Pure functions that translate a {@link TurnStimulus} into the strings the * runner's flow orchestrator splices into the per-turn agent prompt. * Extracted from `runner/src/flow-orchestrator.ts` in Phase 3 of the * flow-connector extraction (2026-05-08) so the connector owns its * prompt-rendering surface without a runtime dep on the orchestrator. * * The contract is byte-identical to the previous inline implementation — * any divergence is a regression. * * @docLink packages/factory-assets/flow#prompt-fragments */ import type { FlowExecution } from "@skaile/workspaces/types"; import type { FlowDefinition } from "./engine/types.js"; /** * Reasons why a new turn is starting. The flow orchestrator's prompt template * renders a stimulus-specific paragraph (via {@link renderStimulusPrompt}) so * the agent knows exactly why it has been invoked. * * @docLink packages/factory-assets/flow#turn-stimulus */ export type TurnStimulus = { kind: "flow_started"; } | { kind: "approval_received"; nodeId: string; decision: "approved" | "rejected"; feedback?: string; decidedBy: string; } | { kind: "input_received"; nodeId: string; response: unknown; providedBy: string; } | { kind: "retry_requested"; nodeId: string; requestedBy: string; } | { kind: "user_message"; text: string; senderId: string; } | { kind: "resumed_after_hibernation"; } | { kind: "cancelled"; } | { kind: "state_changed"; }; /** * Render the stimulus paragraph the agent sees at turn start. * * The output is a single paragraph (one or more sentences, no surrounding * whitespace) describing why the runner has woken the agent. Spliced into * the orchestrator prompt under the `## Why this turn is happening` heading. * * @docLink packages/factory-assets/flow#render-stimulus-prompt */ export declare function renderStimulusPrompt(stimulus: TurnStimulus): string; /** * Build the full agent-orchestrator prompt for a flow turn. * * Reassembles the five-section prompt from the current FlowExecution snapshot * and the supplied stimulus: * * 1. Flow definition (markdown table of nodes) * 2. Current state (progress, available/blocked, interaction pointers) * 3. Why this turn is happening (stimulus-specific paragraph) * 4. Flow tools available (static documentation) * 5. Rules * * Originally a byte-identical lift of the (since-deleted) * `FlowOrchestrator.buildOrchestratorPrompt`; the contract now is simply * this function's own output. When strict v2 defaults or legacy globals are * non-empty, a `## Flow globals` section exposes those run-scoped values. The * flow-wide active-node table stays bounded to selection metadata; `build_handoff` * supplies a selected agent node's execution payload. First-class gates appear * as runtime-owned state but never as agent-executable work. * Pure — depends only on its inputs. * * @docLink packages/factory-assets/flow#build-orchestrator-prompt * @since 2.2.0 */ export declare function buildOrchestratorPrompt(flowDef: FlowDefinition, state: FlowExecution, stimulus: TurnStimulus): string; /** * Render the full prompt sent to a subprompt node's isolated driver instance. * * `instruction` is already interpolated with the node's resolved bindings * (the same `interpolateNodeInstruction` step an agent handoff uses) — this * function only adds the typed-response directive when the node declares an * output contract. There is no corrective reprompt for a subprompt (it has no * conversation to reprompt in), so the directive is the runtime's only lever * for getting parseable JSON back; a malformed or non-conforming reply is an * ordinary node failure handled by the caller, never retried in-band here. * * The object-only constraint is therefore stated twice, before and after the * schema: the serialized schema is a large blob, so a directive placed only * ahead of it is not the last thing the model reads. * * @docLink packages/factory-assets/flow#render-subprompt-prompt */ export declare function renderSubpromptPrompt(instruction: string, outputSchema: Record | undefined): string; /** * Single-line tag suitable for telemetry / logging. Derives a short, stable * summary of a stimulus that's safe to attach to spans, log entries, and * trace events. The kind is always included; node-specific stimuli also * include their `nodeId` so log queries can pivot on it. * * @docLink packages/factory-assets/flow#describe-stimulus */ export declare function describeStimulus(stimulus: TurnStimulus): string; //# sourceMappingURL=prompt-fragments.d.ts.map