import type { LanguageModel } from "ai"; import type { AgentProvider, AgentTarget, ExecutableTarget, ExecutorResult, Loop, LoopMachineRef, LoopRun, PersistGuardOptions } from "../types.js"; export interface SpawnedProcessInfo { pid: number; pgid: number; processStartedAt: string; } export interface AgentProgressInfo { provider: AgentProvider; agentId?: string; status?: string; summary?: string; statusReason?: string; threadId?: string; rolloutPath?: string; pid?: number; lastEventSeq?: number; } export interface ExecuteOptions extends PersistGuardOptions { maxOutputBytes?: number; env?: NodeJS.ProcessEnv; goalModel?: LanguageModel; log?: (message: string) => void; signal?: AbortSignal; onSpawn?: (pid: number) => void; /** Children are spawned detached in their own process group, so pgid === pid. */ onSpawnProcess?: (info: SpawnedProcessInfo) => void; /** Progress from durable provider controllers, for example Codewith background agents. */ onAgentProgress?: (info: AgentProgressInfo) => void; machine?: LoopMachineRef; machineResolver?: (machine: LoopMachineRef) => LoopMachineRef; machineCommandResolver?: (machineId: string, command: string) => MachineCommandPlan; } export interface ExecutionMetadata { loopId?: string; loopName?: string; runId?: string; scheduledFor?: string; workflowId?: string; workflowName?: string; workflowRunId?: string; workflowStepId?: string; goalId?: string; goalObjective?: string; goalNodeKey?: string; } export interface PreflightResult { command: string; accountProfile?: string; accountTool?: string; } interface MachineCommandPlan { command: string; args: string[]; source: string; } /** Exported for tests: resolves the default idle watchdog for agent targets. */ export declare function defaultAgentIdleTimeoutMs(target: AgentTarget, opts: ExecuteOptions): number | undefined; /** * Detects git's "missing but already registered worktree" error: the target * path is recorded in `.git/worktrees/` but its directory was deleted out from * under it, so `git worktree add` refuses. git's own prescribed remedy is * `git worktree prune` (or `add -f`). Left unhandled this terminal-fails worktree * prep on every attempt and the drain dedupes the failed item into a silent * wedge — historically the single biggest burner of the redispatch cap. */ export declare function isStaleWorktreeRegistration(detail: string | undefined): boolean; export declare function preflightTarget(target: ExecutableTarget, metadata?: ExecutionMetadata, opts?: ExecuteOptions): PreflightResult; export declare function executeTarget(target: ExecutableTarget, metadata?: ExecutionMetadata, opts?: ExecuteOptions): Promise; export declare function executeLoop(loop: Loop, run: LoopRun, opts?: ExecuteOptions): Promise; export {};