import { type LanguageModel } from "ai"; import type { BudgetCaps, SessionResult } from "./types.js"; import type { EventSink as _EventSinkPathReexport } from "./log.js"; /** * Loose type for the tool registry. The AI SDK's `Tool` is invariant * in its generics, so a heterogeneous map of tools with distinct schemas * can't be statically typed as `Record>`. * We accept the unsoundness at this single boundary — every individual tool * is type-safe at definition site (via `defineTool`), and the AI SDK * validates inputs at runtime via Zod regardless. */ type AnyDefinedTool = { name: string; toAiTool: () => any; }; export interface RunOrchestratorOptions { domain: string; userId: string; model: LanguageModel; /** Provider id for cost estimation (e.g. "anthropic"). */ providerId: string; /** Model id for cost estimation (e.g. "claude-opus-4-7"). */ modelId: string; /** Override default budget caps. Defaults from DEFAULT_BUDGET. */ budget?: Partial; /** Optional path for durable NDJSON session log. */ ndjsonPath?: string; /** Optional event sink (e.g. SSE / R2 fanout). */ onEvent?: EventSink; /** External abort signal — aborting flips the session to `aborted`. */ signal?: AbortSignal; /** * Override the tool registry. Default = full `orchestratorTools` plus * `finish_audit`. Tests pass a smaller subset; production passes the full * registry. */ tools?: Record; /** * Per-model-call retry budget for transient errors (5xx, rate limits, * network failures). The AI SDK handles the retry loop internally and * respects `retry-after` headers from the provider, so each retry waits * the rate-limit window when the provider asks. * * Default 5: tier-1 Anthropic accounts have a 30K input-tokens-per-minute * cap that burst-friendly orchestrator sessions can hit. Five retries * with exponential backoff (~1s/2s/4s/8s/16s base) span a full 60s TPM * refresh, so the next retry usually succeeds. Lower this only if the * caller has tier-2+ keys (no TPM cap) or cares more about fail-fast. */ maxRetries?: number; } /** * Run a single orchestrator session end-to-end. Returns the final * `SessionResult` once the LLM calls `finish_audit`, the budget is * exhausted, the abort signal fires, or the model errors out. * * No streaming yet — uses `generateText` for simpler test ergonomics with * the existing `MockModel` (which only implements `doGenerate`). Phase 2 * follow-up swaps to `streamText` once we have a stream-capable mock and a * web-app SSE endpoint to wire up. */ export declare function runOrchestrator(opts: RunOrchestratorOptions): Promise; export type EventSink = _EventSinkPathReexport; export {}; //# sourceMappingURL=runner.d.ts.map