import type { CodaliEvidenceItem, CodaliContextPackContradiction, CodaliGatewayPlannerOutput, CodaliGatewayRequest, CodaliGatewayVerifierIssue, CodaliGatewayVerifierOutput, CodaliGatewayWorkerTask } from "./CodaliGatewayTypes.js"; import { type CodaliGatewayRunTrace, type CodaliGatewayStore, type CodaliGatewayStoredArtifact, type CodaliGatewayStoredModelStatus, type CodaliGatewayStoredToolStatus } from "./CodaliGatewayStore.js"; import { type GatewayPolicyCompilation } from "./GatewayPolicyCompiler.js"; export type CodaliGatewayWorkerTaskStatus = "succeeded" | "failed" | "skipped"; export type CodaliGatewayWorkerExecutionStatus = "succeeded" | "failed" | "partial"; export interface CodaliGatewayWorkerToolCallRecord { tool: string; status: CodaliGatewayStoredToolStatus; latencyMs?: number; args?: unknown; result?: unknown; errorCode?: string; errorMessage?: string; metadata?: Record; } export interface CodaliGatewayWorkerModelCallRecord { role: string; status: CodaliGatewayStoredModelStatus; latencyMs?: number; agentSlug?: string; model?: string; provider?: string; input?: unknown; output?: unknown; errorCode?: string; errorMessage?: string; metadata?: Record; } export interface CodaliGatewayWorkerTaskRunInput { runId: string; task: CodaliGatewayWorkerTask; prompt: string; allowedTools: string[]; remainingToolCalls: number; remainingModelCalls?: number; timeoutMs: number; request: CodaliGatewayRequest; policyCompilation: GatewayPolicyCompilation; } export interface CodaliGatewayWorkerTaskRunResult { status: "succeeded" | "failed"; output?: unknown; evidence?: CodaliEvidenceItem[]; toolCalls?: CodaliGatewayWorkerToolCallRecord[]; modelCalls?: CodaliGatewayWorkerModelCallRecord[]; artifacts?: Array & { id?: string; runId?: string; createdAt?: string; }>; errorCode?: string; errorMessage?: string; metadata?: Record; } export interface CodaliGatewayWorkerTaskRunner { run(input: CodaliGatewayWorkerTaskRunInput): Promise; } export interface CodaliGatewayVerifierRunInput { runId: string; request: CodaliGatewayRequest; planner: CodaliGatewayPlannerOutput; iteration: number; evidence: CodaliEvidenceItem[]; taskResults: CodaliGatewayWorkerTaskExecutionResult[]; remainingToolCalls: number; policyCompilation: GatewayPolicyCompilation; } export interface CodaliGatewayVerifierRunner { verify(input: CodaliGatewayVerifierRunInput): Promise; } export interface CodaliGatewayStateMachineInput { runId: string; request: CodaliGatewayRequest; planner: CodaliGatewayPlannerOutput; policyCompilation?: GatewayPolicyCompilation; } export interface CodaliGatewayStateMachineOptions { store?: CodaliGatewayStore; taskRunner: CodaliGatewayWorkerTaskRunner; verifierRunner?: CodaliGatewayVerifierRunner; maxParallelWorkers?: number; maxRuntimeMs?: number; perTaskTimeoutMs?: number; maxToolCalls?: number; maxModelCalls?: number; maxImageArtifacts?: number; now?: () => number; } export interface CodaliGatewayWorkerTaskExecutionResult { taskId: string; workerRole: string; status: CodaliGatewayWorkerTaskStatus; required: boolean; allowedTools: string[]; removedTools: string[]; durationMs: number; evidenceCount: number; toolCallCount: number; calledTools: string[]; modelCallCount: number; output?: unknown; skippedReason?: string; errorCode?: string; errorMessage?: string; metadata?: Record; } export interface CodaliGatewayWorkerExecutionResult { runId: string; status: CodaliGatewayWorkerExecutionStatus; taskResults: CodaliGatewayWorkerTaskExecutionResult[]; verification?: CodaliGatewayVerificationLoopResult; warnings: string[]; errors: string[]; toolCallCount: number; calledTools: string[]; modelCallCount: number; trace?: CodaliGatewayRunTrace; } export interface CodaliGatewayRejectedFollowUpTask { taskId?: string; reason: string; tools?: string[]; } export interface CodaliGatewayVerificationIteration { iteration: number; output: CodaliGatewayVerifierOutput; acceptedFollowUpTaskIds: string[]; rejectedFollowUpTasks: CodaliGatewayRejectedFollowUpTask[]; stopReason?: string; } export interface CodaliGatewayVerificationLoopResult { passed: boolean; stopReason: string; iterations: CodaliGatewayVerificationIteration[]; missingInformation: string[]; contradictions: CodaliContextPackContradiction[]; issues: CodaliGatewayVerifierIssue[]; followUpTaskCount: number; rejectedFollowUpTasks: CodaliGatewayRejectedFollowUpTask[]; } export declare const defaultPerTaskTimeoutMs: (maxRuntimeMs: number) => number; export declare const buildCodaliGatewayWorkerPrompt: (input: { request: CodaliGatewayRequest; task: CodaliGatewayWorkerTask; allowedTools: string[]; remainingToolCalls: number; remainingModelCalls: number; }) => string; export declare class CodaliGatewayStateMachine { private readonly options; readonly store: CodaliGatewayStore; private readonly now; constructor(options: CodaliGatewayStateMachineOptions); execute(input: CodaliGatewayStateMachineInput): Promise; private runVerifierIteration; private filterVerifierFollowUpTasks; private resolveVerificationStopReason; private buildVerificationLoopResult; private prepareTasks; private dispatchAssignedAppGatewayTools; private runTask; private persistWorkerResult; private skipTask; private resolveStatus; } export declare const createCodaliGatewayStateMachine: (options: CodaliGatewayStateMachineOptions) => CodaliGatewayStateMachine; //# sourceMappingURL=GatewayStateMachine.d.ts.map