import type { PendingRuntimeParentAction } from "./runtime.js"; export type AutonomousGateMode = "none" | "phase" | "all"; export type WorkflowRunMode = "new" | "redo" | "sign-off"; export type WorkflowPhaseExecutionMode = "auto" | "subagents" | "single-agent"; export type WorkflowStopReason = "success" | "human_gate" | "external_blocker" | "no_progress" | "timeout" | "idle_timeout" | "blocked_review" | "risk_accepted"; export interface WorkflowContinuationPolicy { kind: "acceptance-criteria"; continueWhile: "acceptance_criteria_unmet_and_progress_evident"; noHardAttemptLimit: boolean; stopReasons: WorkflowStopReason[]; legacyMaxIterations: number; } export interface WorkflowPhaseExecutorProvenance { mode: WorkflowPhaseExecutionMode; executor: "parent-agent" | "provider-backed-phase" | "runtime-native-subagent" | "queued-runtime-subagent"; runtime?: string; provider?: string; model?: string; fallbacks?: string[]; role: string; phase: string; sessionId?: string; artifact?: string; completionMode?: "blocking" | "detached"; fallbackReason?: string; directProviderApiAllowed: boolean; plannedAt: string; } export type AutonomousPhaseStatus = "pending" | "running" | "done" | "skipped" | "failed" | "gate_paused" | "qa_failed" | "blocked" | "awaiting_clarification" | "canceled"; export interface AutonomousPhase { phase: string; role: string; status: AutonomousPhaseStatus; taskId: string; executor?: WorkflowPhaseExecutorProvenance; providerProgress?: PhaseProviderProgress; gateId?: string; handoffArtifact?: string; reviewArtifact?: string; approvedBy?: string; approvedAt?: string; approvalRationale?: string; startedAt: string; completedAt?: string; skippedAt?: string; notes?: string; } export interface PhaseProviderProgress { provider: string; model: string; fallbacks: string[]; status: "running" | "completed" | "failed"; startedAt: string; updatedAt: string; elapsedMs: number; message?: string; } export interface WorkflowGateApprovalInput { runId: string; gateId: string; approver: string; rationale: string; } export interface WorkflowGateApprovalResult { run: AutonomousRun; gateId: string; approver: string; approvedAt: string; alreadyApproved: boolean; } export type WorkflowGateDecisionResult = "approve" | "block" | "changes"; export interface WorkflowGateDecisionInput { runId: string; gateId: string; reviewer: string; rationale: string; result: WorkflowGateDecisionResult; returnRole?: string; returnPhase?: string; } export interface WorkflowGateDecisionRecord { run: AutonomousRun; gateId: string; reviewer: string; rationale: string; result: WorkflowGateDecisionResult; decidedAt: string; alreadyApproved: boolean; } export interface AutonomousRun { id: string; taskId: string; gates: AutonomousGateMode; mode?: WorkflowRunMode; phaseExecutionMode?: WorkflowPhaseExecutionMode; continuationPolicy?: WorkflowContinuationPolicy | undefined; stopReason?: WorkflowStopReason | undefined; stopSummary?: string | undefined; verifierStatus?: "unknown" | "passed" | "failed" | "blocked" | undefined; acceptanceCriteriaStatus?: "unknown" | "met" | "unmet" | "risk_accepted" | undefined; nextAction?: string | undefined; maxIterations: number; phaseSequence?: string[]; phaseDefinitions?: Array<{ phase: string; role: string; summary: string; }>; qaIterations: number; phases: AutonomousPhase[]; status: "running" | "paused" | "done" | "failed" | "canceled"; createdAt: string; updatedAt: string; } export interface AutonomousRunResult { run: AutonomousRun; file: string; cwd: string; parentActions?: PendingRuntimeParentAction[]; } export interface BenchmarkPhaseDuration { phase: string; startedAt: string; completedAt?: string; durationMs: number | null; } export type ClarificationStatus = "open" | "answered"; export type ClarificationTarget = string; export interface ClarificationRecord { id: string; runId: string; taskId: string; fromRole: string; toRole: string; question: string; answer?: string; status: ClarificationStatus; createdAt: string; answeredAt?: string; } export interface ClarificationInput { runId: string; taskId: string; fromRole: string; to: ClarificationTarget; question: string; } export interface ClarificationAnswerInput { id: string; answer: string; }