import { Message } from "../contracts/conversation-message.type.mjs"; import { AgentContract } from "../contracts/agent/agent.contract.mjs"; import { EndSentinel } from "../contracts/end.type.mjs"; import { WorkflowInstance } from "../contracts/workflow/workflow.contract.mjs"; import { RouteContext } from "../contracts/supervisor/route-context.type.mjs"; import { IntentCallback, SupervisorIntentValue } from "../contracts/supervisor/intent-entry.type.mjs"; import { DispatchContext } from "../contracts/supervisor/dispatch-context.type.mjs"; import { StandardSchemaV1 } from "@standard-schema/spec"; //#region ../ai/src/supervisor/entries.d.ts /** * Normalized internal representation of one entry in a supervisor's * `intents` map — resolved at factory time from one of the accepted * value forms (bare agent / workflow / callback / object entry). * * Carrying the explicit `type` discriminator keeps downstream code * (execution, signature, router-prompt) from having to re-detect * shape on every dispatch. The discriminated union below replaces * the flat-shape used in Phase 3 so callbacks can carry their own * function reference + dispatch-context-shaped resolvers. * * Discriminator renamed `kind` → `type` (Q12) for codebase-wide * consistency — every other discriminated result/report shape uses * `type`. */ type ResolvedIntentEntry = ResolvedAgentEntry | ResolvedWorkflowEntry | ResolvedCallbackEntry; /** * Successor directive function type — the resolver-time projection of * `IntentEntry.next` / `IntentRunEntry.next`. Single source of truth * across the three resolved variants. */ type IntentNext = (ctx: DispatchContext) => string | string[] | EndSentinel | undefined; /** * Resolver-time projection of `IntentEntry.history` / * `RouterEntry.history` / `AckEntry.history`. Custom slicer that * REPLACES the default `historyWindow.` slice. */ type EntryHistorySlicer = (ctx: RouteContext) => Message[] | ReadonlyArray; type ResolvedAgentEntry = { intent: string; type: "agent"; unit: AgentContract; description: string; input?: (ctx: RouteContext) => string; /** * Per-dispatch placeholder values for the agent's systemPrompt * template. Forwarded as `agent.execute(input, { placeholders })`. * Phase 3.4 (Stage 4b) — replaces the dropped `composeAgentInput` * mechanism for threading state into agents. */ placeholders?: (ctx: DispatchContext) => Record; /** * Schema declaring this intent's slice of supervisor state. Agent * output is strip-merged against it; only validated keys appear on * `IterationSnapshot.result[intent].output` AND merge into * supervisor `state`. */ output?: StandardSchemaV1; /** * Successor directive (Stage 4d / Q24). When present, runs after * this branch's slice merges into state to choose the next dispatch * (or terminate) without invoking the router. */ next?: IntentNext; /** * Custom history slicer — replaces the default * `historyWindow.agents` slice when supplied. See `IntentEntry.history`. */ history?: EntryHistorySlicer; /** * Phase 5 / decisions §34. `"stream"` runs the agent without * structured-output coercion and writes the assembled prose into * `state[streamTo]`; `"structured"` is the default. Resolved at * factory time — `undefined` here is treated as `"structured"`. */ mode?: "structured" | "stream"; /** State key the assembled stream-mode prose writes into. Set iff `mode === "stream"`. */ streamTo?: string; }; type ResolvedWorkflowEntry = { intent: string; type: "workflow"; unit: WorkflowInstance; description: string; input?: (ctx: RouteContext) => string; placeholders?: (ctx: DispatchContext) => Record; output?: StandardSchemaV1; next?: IntentNext; history?: EntryHistorySlicer; }; type ResolvedCallbackEntry = { intent: string; type: "callback"; /** * The callback that actually runs at dispatch time. Always present * regardless of whether the user passed bare-function shorthand or * the `{ run, ... }` entry form. */ callback: IntentCallback; /** * Description is required only when the supervisor uses a router. * Callback intents under a router are validated separately * (see {@link assertRouterDescriptions}); under deterministic * `route` mode this field is `undefined`. */ description?: string; /** * Per-intent input resolver. Receives the upcoming * `DispatchContext` and returns the value forwarded as * `ctx.input` to the callback. */ input?: (ctx: DispatchContext) => unknown; placeholders?: (ctx: DispatchContext) => Record; /** * Schema declaring this callback's slice of state. Without it, the * full return value shallow-merges; with it, return is strip-merged * to declared keys before merging. */ output?: StandardSchemaV1; next?: IntentNext; }; /** * Validate and normalize the `intents` map into resolved entries. * Runs at factory time — throws `SupervisorFailedError` on the first * malformed entry so author-time bugs surface immediately rather * than mid-run. * * Validation rules: * - Every value must be an agent, a workflow, a callback function, * or an object entry with `agent` / `workflow` / `run`. * - Object entries with more than one of `{ agent, workflow, run }` * throw with code `SUPERVISOR_INTENT_MIXED_DISPATCH`. * - Agent / workflow / agent-shaped entries must resolve to a * non-empty description from the underlying unit or the entry's * `description` override. Bare callback shorthand has no * description source — that's enforced separately by * {@link assertRouterDescriptions} when a router is configured. */ declare function resolveIntentEntries(rawIntents: Record, supervisorName: string): Map; //#endregion export { ResolvedIntentEntry, resolveIntentEntries }; //# sourceMappingURL=entries.d.mts.map