import { type SpawnParallelOptions } from "../../../agent-spawn/dist/parallel.js"; import { type SpawnUsage } from "../../../agent-spawn/dist/types.js"; import { type OtelSink } from "../observability/otel.js"; export type AgentSpawnMode = "read" | "edit" | "auto" | "yolo"; export type AgentModuleMcpServer = { command: string; args?: string[]; env?: Record; timeout?: number; }; export type AgentModuleMcpConfig = Record; export type AgentModuleDefinition = string | { agent: string; prompt?: string; model?: string; mode?: AgentSpawnMode; cwd?: string; mcp?: AgentModuleMcpConfig; }; export type AgentModuleSpawnOptions = { prompt: string; label?: string; mcp?: AgentModuleMcpConfig; model?: string; mode?: AgentSpawnMode; cwd?: string; otelSink?: OtelSink; timeoutMs?: number; signal?: AbortSignal; }; export type SpawnAgentInput = Omit & { agent: string; }; export type SpawnAgentResult = { exitCode: number; stdout: string; stderr: string; summary: string; durationMs: number; usage?: SpawnUsage; }; export type SpawnAgent = (input: SpawnAgentInput) => Promise; export type AgentModuleOptions = { defaultRetry?: AgentModuleRetryOptions; onEvent?: (event: AgentSpawnEvent) => void | Promise; otelSink?: OtelSink; }; export type AgentSpawnEvent = { type: "spawn.started"; spawnId: number; agent: string; task: string; attempt: number; maxAttempts: number; } | { type: "spawn.retry"; spawnId: number; agent: string; task: string; attempt: number; maxAttempts: number; delayMs: number; error: string; } | { type: "spawn.succeeded"; spawnId: number; agent: string; task: string; attempt: number; maxAttempts: number; durationMs: number; } | { type: "spawn.failed"; spawnId: number; agent: string; task: string; attempt: number; maxAttempts: number; durationMs: number; error: string; } | { type: "spawn.cancelled"; spawnId: number; agent: string; task: string; attempt: number; maxAttempts: number; durationMs: number; reason: string; }; export type SpawnUsageTotal = { inputTokens: number; outputTokens: number; cachedTokens: number; costUsd?: number; spawnCount: number; attemptCount?: number; }; export type SpawnUsageAccumulator = { beginAttempt?(): void; beginSpawn?(): void; record(usage: SpawnUsage | undefined): void; reset(): void; snapshot(): SpawnUsageTotal; }; export declare function createSpawnUsageAccumulator(): SpawnUsageAccumulator; export declare function runWithSpawnUsageAccumulator(accumulator: SpawnUsageAccumulator, operation: () => Promise): Promise; export type AgentModuleRetryOptions = { maxAttempts: number; backoffMs: number; isErrorRetryable?: (error: unknown) => boolean; isRetryable?: (result: SpawnAgentResult) => boolean; }; export type AgentModuleParallelCall = readonly [agentDef: AgentModuleDefinition, options: AgentModuleSpawnOptions] | ((signal?: AbortSignal) => { events: AsyncIterable; result: Promise; }); type AgentModuleSpawn = { (agentDef: AgentModuleDefinition, options: AgentModuleSpawnOptions): Promise; retry(agentDef: AgentModuleDefinition, options: AgentModuleSpawnOptions, retryOptions: AgentModuleRetryOptions): Promise; parallel(calls: AgentModuleParallelCall[], options?: SpawnParallelOptions): Promise; }; export declare function makeAgentModule(spawnAgent: SpawnAgent, moduleOptions?: AgentModuleOptions): { spawn: AgentModuleSpawn; }; export {};