import { Message } from "../contracts/conversation-message.type.mjs"; import { SupervisorInput } from "../contracts/supervisor/supervisor-input.type.mjs"; import { OrchestratorResult } from "../contracts/result/orchestrator-result.type.mjs"; import { OrchestratorCommands } from "../contracts/orchestrator/orchestrator-commands.type.mjs"; import { OrchestratorExecuteOptions, OrchestratorResumeOptions } from "../contracts/orchestrator/orchestrator-execute-options.type.mjs"; import { OrchestratorConfig } from "../contracts/orchestrator/orchestrator-config.type.mjs"; import { OrchestratorEmitter } from "./emitter.mjs"; import { ResolvedIntentEntry } from "../supervisor/entries.mjs"; import { OrchestratorEngineContext } from "./engine-context.type.mjs"; import { OrchestratorStreamController } from "./orchestrator-stream.mjs"; //#region ../ai/src/orchestrator/execution.d.ts /** * Constructor params the C1 factory passes when building an * {@link OrchestratorExecution} per call. The factory owns author-time * validation, intent-entry resolution, and signature computation; it * hands the engine the validated `config`, the resolved `entries`, the * computed `signature`, and the shared three-tier `emitter`. The * per-call inputs vary by entry point: * * - `execute` / `stream` — `input` + `options` (and `streamController` * for `stream`). * - `resume` — `resumeSessionId` + `resumeOptions`. * - `command("compact")` — neither; `compact(args)` carries its own. */ type OrchestratorExecutionParams = { config: OrchestratorConfig; /** Resolved intent entries (validated by C1; the engine delegates dispatch to the supervisor). */ entries?: Map; signature: string; emitter: OrchestratorEmitter; input?: SupervisorInput; options?: OrchestratorExecuteOptions; streamController?: OrchestratorStreamController>; resumeSessionId?: string; resumeOptions?: OrchestratorResumeOptions; }; /** * Per-call lifecycle engine — the single object the C1 factory * constructs and drives. Owns the 7-phase lifecycle (orchestrator.md §3: * load → drift → lock → window → dispatch → persist → compaction), * resolving the durable stores (own config field → `ai.config` default) * and adapting C1's three-tier {@link OrchestratorEmitter} to the * {@link OrchestratorEmitterLike} port the phase modules call. * * The factory creates a fresh instance per `execute` / `stream` / * `resume` / `command` call (single-call lifecycle invariant — §18.8); * the heavy lifting lives in the standalone phase functions * ({@link runTurn} / {@link runResume}) which this class delegates to. * * @example * const execution = new OrchestratorExecution({ * config, entries, signature, emitter, input, options, * }); * const result = await execution.run(); */ declare class OrchestratorExecution { private readonly params; private readonly ctx; private readonly streamController?; constructor(params: OrchestratorExecutionParams); /** * `execute()` / `stream()` entry — run one turn through the 7-phase * lifecycle. When a `streamController` was supplied, the adapter mirrors * every emitted event into the stream and the controller is settled * (`end` / `fail`) once the result resolves. */ run(): Promise>; /** * `resume()` entry — drain an interrupted `iterate: true` turn (§9). * Returns `null` when nothing is in flight. */ resume(): Promise | null>; /** * `command("compact")` entry — run a manual compaction on demand (§11 / * §12.1). Reuses the post-turn compaction code path against the * caller-supplied history and returns the raw {@link CompactionResult}. */ compact(args: OrchestratorCommands["compact"]["args"]): Promise; } /** * Run one turn end-to-end through the 7-phase lifecycle (orchestrator * .md §3). The single entry the C1 factory's `execute()` delegates to. * * Phase order is the diagram's contract: load → drift → lock → window * → dispatch → persist → compaction. Drift / config misuse throw; * every other failure surfaces on `result.error` (the contract: the * orchestrator never throws on runtime failure). Cancellation and * failure do NOT persist a fresh checkpoint (§17 — state reverts to the * pre-turn checkpoint). */ declare function runTurn(ctx: OrchestratorEngineContext, input: SupervisorInput, options: OrchestratorExecuteOptions): Promise>; /** * §9 resume protocol entry the C1 factory's `resume()` delegates to. * Returns `null` when no in-flight `iterate: true` turn is detected; * otherwise drains the interrupted supervisor run, persists a fresh * checkpoint for the resumed turn, and returns the completed result. * * Runs the same Phase 2 drift check as `runTurn` (§9.4). The heavy * lifting lives in `resume.ts`; this wrapper threads the engine * context. */ declare function runResume(ctx: OrchestratorEngineContext, sessionId: string, options?: OrchestratorResumeOptions): Promise | null>; /** * The `stream()` entry. The orchestrator's streaming surface bubbles * child agent/supervisor events under their own namespace (§14.2); the * C1 stream controller owns the `StreamContract` wiring. This engine * entry runs the same lifecycle as `runTurn` — the C1 factory passes a * per-call `on` bag wired to the stream controller, so the engine needs * no streaming-specific branch. Exposed as a distinct name for the * factory to call, returning the same `OrchestratorResult` the stream's * `.result` resolves to. */ declare function streamTurn(ctx: OrchestratorEngineContext, input: SupervisorInput, options: OrchestratorExecuteOptions): Promise>; //#endregion export { OrchestratorExecution, OrchestratorExecutionParams, runResume, runTurn, streamTurn }; //# sourceMappingURL=execution.d.mts.map