import type { Provider } from "@kenkaiiii/gg-ai"; import type { AgentSession } from "../core/agent-session.js"; import type { RunLifecycle } from "../core/run-lifecycle.js"; import { type AutopilotVerdict } from "../core/autopilot-verdict.js"; import { type WorkflowCommandSpec } from "../core/autopilot-gate.js"; import type { RunOutcome } from "../core/session-manager.js"; /** Closure state of one session that the autopilot / stranded-queue / task runners use. */ export interface AutopilotRunnerContext { autopilotReviewing: boolean; readonly broadcast: (type: string, data: unknown) => void; readonly ensureKenAutoSession: () => Promise; readonly cwd: string; gitBranch: string | null; session: AgentSession; injectedAutopilotPrompts: string[]; readonly loadWorkflowCommandSpecs: () => Promise; autopilotCancelled: boolean; readonly broadcastError: (type: "error" | "ken_error" | "autopilot_error", logLabel: string, err: unknown) => void; pendingKenAutoModel: { provider: Provider; model: string; } | null; readonly syncKenAutoModel: (provider: Provider, model: string) => Promise; pendingPlanPath: string | null; planGeneration: number; pendingPlanContent: string; autopilot: boolean; readonly runLifecycle: RunLifecycle; readonly abortOwnedWork: () => void; pendingCancelDrain: { generation: number; text: string; } | null; autopilotActive: boolean; readonly MAX_AUTOPILOT_ROUNDS: number; readonly activateApprovedPlan: (planPath: string | undefined) => Promise; readonly clearPendingPlan: () => void; readonly planProgressPayload: () => { total: number; completed: number[]; }; readonly IMPLEMENT_PLAN_PROMPT: string; readonly runAgent: (label: string, run: () => Promise, reviewPending?: () => boolean) => Promise; kenAutoSession: AgentSession | null; readonly reenterPlanModeForRevision: () => Promise; readonly finishOwnedGeneration: (generation: number, emitCancelledFallback: boolean, outcome?: RunOutcome) => boolean; drainingStrandedQueue: boolean; running: boolean; readonly offerPendingPlan: () => void; readonly deactivateApprovedPlan: () => void; taskRunAll: boolean; } export interface AutopilotRunnerContextApi { runAutopilotReview: (originalRequest: string) => Promise; runAutopilotPlanReview: (originalRequest: string) => Promise; runAutopilotCycle: (originalRequest: string) => Promise; runStrandedQueue: () => Promise; runTaskById: (taskId: string) => Promise; runTasks: (startId: string | null, all: boolean) => Promise; } export declare function createAutopilotRunner(ctx: AutopilotRunnerContext): AutopilotRunnerContextApi;