import { AIError } from "../../errors/ai-error.mjs"; import { Usage } from "../result/usage.type.mjs"; import { SupervisorResult } from "../result/supervisor-result.type.mjs"; import { SupervisorInput } from "../supervisor/supervisor-input.type.mjs"; import { Next } from "../supervisor/next.type.mjs"; import { EvaluateResult } from "../supervisor/evaluate-context.type.mjs"; import { IterationSnapshot } from "../supervisor/iteration-snapshot.type.mjs"; //#region ../ai/src/contracts/events/supervisor-events.type.d.ts /** Fires once at the start of every `supervisor.execute()` call. */ type SupervisorStartingPayload = { supervisorName: string; input: SupervisorInput; }; /** Fires at the top of each iteration, before routing decides. */ type SupervisorIterationStartingPayload = { iteration: number; }; /** Router mode only — emitted just before the router agent is invoked. */ type SupervisorRouterDecidingPayload = { iteration: number; }; /** Emitted after the route callback or router agent resolves. */ type SupervisorRouterDecidedPayload = { iteration: number; next: Next; reasoning?: string; durationMs: number; }; /** A dispatched agent/workflow is about to start this iteration. */ type SupervisorAgentStartingPayload = { iteration: number; intent: string; input: string; }; /** * Child-agent streaming token bubbled up through the supervisor so UI * consumers can render per-agent output in real time without wiring * into every child agent individually. */ type SupervisorAgentStreamingPayload = { iteration: number; intent: string; delta: string; }; /** A dispatched branch completed successfully. */ type SupervisorAgentCompletedPayload = { iteration: number; intent: string; output: unknown; usage: { input: number; output: number; total: number; }; duration: number; }; /** * A dispatched branch failed. Siblings continue — the supervisor * captures the error on the branch snapshot and lets `evaluate` * (or the default termination logic) decide the response. */ type SupervisorAgentFailedPayload = { iteration: number; intent: string; error: AIError; }; /** * Classifier (Phase 7 / decisions §37) is about to run on iter 0. * Fires once per fresh run when `SupervisorConfig.classifier` is * configured. */ type SupervisorClassifierStartingPayload = { iteration: 0; }; /** * Classifier streamed a token. Fires only when the classifier is * an LLM agent AND the supervisor is being streamed at the top * level. Distinct from `supervisor.agent.streaming` so UI consumers * can render classifier tokens (or hide them) separately from * dispatched specialist tokens. */ type SupervisorClassifierStreamingPayload = { delta: string; }; /** * Classifier settled — `output` carries the final classifier output * (post-refine if a refine hook was configured); `intent` is the * dispatched intent name (absent when refine returned `END`); * `refined` indicates whether the refine hook changed the output. */ type SupervisorClassifierCompletedPayload = { output: { intent?: string; reasoning?: string; confidence?: number; }; intent?: string; refined: boolean; halted: boolean; duration: number; usage?: Usage; }; /** * Classifier failed (the agent / callback threw, or refine threw, * or refine returned an invalid intent). Run aborts with this error * surfaced on `result.error`. */ type SupervisorClassifierFailedPayload = { error: AIError; }; /** * Receptionist agent emitted a token. Fires only when an `ackAgent` * is configured AND iteration 0 is in progress. Semantically distinct * from `supervisor.agent.streaming` so UIs can render ack tokens as * the user-facing first reply without filtering by intent name. */ type SupervisorAckStreamingPayload = { delta: string; }; /** * Receptionist agent settled. Fires once per run when an `ackAgent` * is configured. `output` is the raw agent output (pre-strip-merge); * `error` is set when the ack agent failed (run continues either way). */ type SupervisorAckCompletedPayload = { output?: unknown; usage?: Usage; duration: number; error?: AIError; }; /** The `evaluate` callback returned — verdict may be `undefined`. */ type SupervisorEvaluateVerdictPayload = { iteration: number; verdict: EvaluateResult; }; /** * An iteration settled — `snapshot` is the frozen forensic record * written to history and (when `store` is set) the KV snapshot. */ type SupervisorIterationCompletedPayload = { iteration: number; snapshot: IterationSnapshot; }; /** The run was aborted via `AbortSignal`. */ type SupervisorCancelledPayload = { cancelledAt: string; reason?: string; }; /** The run terminated successfully — result is the final value. */ type SupervisorCompletedPayload = { result: SupervisorResult; }; /** * The run terminated with a typed error surfaced on `result.error`. * Cancellation emits `supervisor.cancelled` instead. */ type SupervisorErrorPayload = { error: AIError; }; //#endregion export { SupervisorAckCompletedPayload, SupervisorAckStreamingPayload, SupervisorAgentCompletedPayload, SupervisorAgentFailedPayload, SupervisorAgentStartingPayload, SupervisorAgentStreamingPayload, SupervisorCancelledPayload, SupervisorClassifierCompletedPayload, SupervisorClassifierFailedPayload, SupervisorClassifierStartingPayload, SupervisorClassifierStreamingPayload, SupervisorCompletedPayload, SupervisorErrorPayload, SupervisorEvaluateVerdictPayload, SupervisorIterationCompletedPayload, SupervisorIterationStartingPayload, SupervisorRouterDecidedPayload, SupervisorRouterDecidingPayload, SupervisorStartingPayload }; //# sourceMappingURL=supervisor-events.type.d.mts.map