/** * Worker Types * Type definitions for the Local Autonomous Worker */ import type { TodoItem } from '../api/todo.js'; /** * Worker configuration options */ export interface WorkerConfig { /** Interval between task polling (ms) */ pollInterval: number; /** Maximum retry attempts per task */ maxRetries: number; /** Timeout for single task execution (ms) */ taskTimeout: number; /** Cooldown period after error (ms) */ cooldownOnError: number; /** Enable verification step after task completion */ verificationEnabled: boolean; /** Working directory for agent execution */ workingDirectory?: string; /** Enable debug logging */ debug?: boolean; /** Autonomous mode (auto-execute whitelisted commands) */ autonomousMode?: boolean; } /** * Default worker configuration */ export declare const DEFAULT_WORKER_CONFIG: WorkerConfig; /** * Task execution context */ export interface TaskContext { /** The task being executed */ task: TodoItem; /** Current attempt number (1-based) */ attempt: number; /** Summary from previous failure (for retry context) */ previousFailureSummary?: string; /** Timestamp when task execution started */ startedAt: Date; /** Conversation ID for agent session */ conversationId?: string; /** Outputs from previous chain steps (keyed by stepId) */ chainOutputs?: Map; } /** * Worker execution state */ export type WorkerStatus = 'idle' | 'running' | 'paused' | 'stopping' | 'error'; /** * Worker state snapshot */ export interface WorkerState { /** Current worker status */ status: WorkerStatus; /** Currently executing task context */ currentTask?: TaskContext; /** Number of successfully completed tasks */ completedCount: number; /** Number of failed tasks (after all retries) */ failedCount: number; /** Timestamp when worker started */ startedAt?: Date; /** Last error message */ lastError?: string; /** Last poll timestamp */ lastPollAt?: Date; } /** * Task execution result */ export interface TaskResult { success: boolean; message?: string; verificationPassed?: boolean; error?: string; durationMs?: number; } /** * Worker event types */ export type WorkerEvent = { type: 'started'; } | { type: 'stopped'; } | { type: 'paused'; } | { type: 'resumed'; } | { type: 'task_claimed'; task: TodoItem; } | { type: 'task_started'; task: TodoItem; attempt: number; } | { type: 'task_completed'; task: TodoItem; duration: number; } | { type: 'task_failed'; task: TodoItem; error: string; willRetry: boolean; } | { type: 'task_verification_failed'; task: TodoItem; } | { type: 'poll_empty'; } | { type: 'error'; error: string; } | { type: 'worker_content'; text: string; partial: boolean; } | { type: 'worker_tool_call'; id: string; name: string; isMcp: boolean; serverName?: string; } | { type: 'worker_tool_result'; id: string; name: string; status: 'completed' | 'error'; } | { type: 'worker_done'; taskId: string; success: boolean; output?: string; cancelled?: boolean; }; /** * Worker event handler */ export type WorkerEventHandler = (event: WorkerEvent) => void; /** * Executor types for multi-agent dispatch */ export type ExecutorType = 'internal' | 'claude' | 'gemini' | 'cursor' | 'codex' | 'opencode' | 'droid' | 'articulate' | 'paeanclaw' | 'shell'; /** * Executor configuration */ export interface ExecutorConfig { type: ExecutorType; enabled: boolean; /** Custom binary path */ path?: string; /** Default CLI arguments */ defaultArgs?: string[]; /** Override default timeout (ms) */ timeout?: number; /** User has explicitly disabled this executor */ userDisabled?: boolean; /** Last availability check result */ lastCheck?: { available: boolean; authStatus?: AvailabilityAuthStatus; checkedAt: string; error?: string; }; /** Session timeout override (ms) */ sessionTimeout?: number; /** Retry on session timeout */ retryOnTimeout?: boolean; } /** * Authentication status for CLI executors */ export type AvailabilityAuthStatus = 'authenticated' | 'unauthenticated' | 'expired' | 'unknown'; /** * Deep availability status for CLI executors */ export interface AvailabilityStatus { /** Whether the executor is available for use */ available: boolean; /** Whether the binary exists in PATH */ binaryExists: boolean; /** Resolved binary path */ binaryPath?: string; /** Authentication/login status */ authStatus: AvailabilityAuthStatus; /** Human-readable auth status message */ authMessage?: string; /** Detected CLI version */ version?: string; /** Error message if check failed */ error?: string; /** Whether user has disabled this executor */ userDisabled?: boolean; } /** * Executor execution options */ export interface ExecutorOptions { /** Working directory */ cwd?: string; /** Execution timeout (ms) */ timeout?: number; /** Additional CLI arguments */ args?: string[]; /** Environment variables */ env?: Record; /** Skip permission prompts (dangerous mode) */ skipPermissions?: boolean; /** Capture output for parsing */ captureOutput?: boolean; /** Real-time output callback for streaming display */ onOutput?: (text: string, stream: 'stdout' | 'stderr') => void; /** Progress message callback */ onProgress?: (message: string) => void; } /** * Executor execution result */ export interface ExecutorResult { success: boolean; output: string; error?: string; exitCode?: number; durationMs: number; /** Parsed structured output if available */ structured?: Record; } /** * Supervisor decision for task routing */ export interface SupervisorDecision { /** Selected executor for the task */ selectedExecutor: ExecutorType; /** Confidence score (0-1) */ confidence: number; /** Reasoning for the selection */ reasoning: string; /** Groomed/structured prompt for the executor */ groomedPrompt: string; /** Subtasks for complex task breakdown */ subtasks?: string[]; /** Suggested verification strategy */ verificationStrategy?: 'test' | 'lint' | 'build' | 'diff' | 'manual' | 'none'; /** Task tags for routing hints */ tags?: string[]; } /** * Verification result from semantic analysis */ export interface VerificationResult { passed: boolean; /** Confidence in the verification (0-1) */ confidence: number; /** Summary of what was verified */ summary: string; /** Specific issues found */ issues?: string[]; /** Suggestions for improvement */ suggestions?: string[]; /** Verification commands that were executed */ executedCommands?: string[]; } /** * Context for intelligent verification */ export interface VerificationContext { /** The task being verified */ task: import('../api/todo.js').TodoItem; /** Output from executor execution */ executorOutput: string; /** Type of executor used */ executorType: ExecutorType; /** Working directory */ workingDirectory: string; /** Files that were changed (if detectable) */ changedFiles?: string[]; /** Duration of execution in ms */ durationMs?: number; } /** * Recovery strategy after task failure */ export interface RecoveryStrategy { /** Recommended action */ action: 'retry' | 'rewrite' | 'switch_executor' | 'split_task' | 'escalate' | 'abort'; /** Target executor if switching */ targetExecutor?: ExecutorType; /** Modified prompt for retry (kept for backward compat) */ modifiedPrompt?: string; /** Rewritten prompt with LLM analysis */ rewrittenPrompt?: string; /** Additional context for the rewritten prompt */ additionalContext?: string; /** Subtasks if splitting */ subtasks?: string[]; /** Reason for the recommendation */ reason: string; /** Confidence in the recovery strategy */ confidence?: number; } /** * Subtask definition for batch decomposition */ export interface SubtaskDefinition { /** Task content/prompt */ content: string; /** Priority level */ priority: 'high' | 'medium' | 'low'; /** IDs of tasks this depends on (executed after those complete) */ dependsOn?: string[]; /** Hint for verification approach */ verificationHint?: string; /** Suggested executor */ suggestedExecutor?: ExecutorType; /** Tags for routing */ tags?: string[]; } /** * Result of task decomposition */ export interface TaskDecomposition { /** Whether the task should be decomposed */ shouldDecompose: boolean; /** Reasoning for decomposition decision */ reasoning: string; /** Original task as single unit (if not decomposed) */ singleTask?: SubtaskDefinition; /** Subtasks (if decomposed) */ subtasks?: SubtaskDefinition[]; /** Estimated total duration */ estimatedDurationMinutes?: number; } /** * Task artifact output - file or context produced by a task */ export interface TaskArtifact { /** Type of artifact */ type: 'file' | 'context' | 'data'; /** File path for file artifacts */ path?: string; /** Content summary or data */ content?: string; /** Description of the artifact */ description?: string; /** Created timestamp */ createdAt: string; } /** * Expected output definition for chain tasks */ export interface ExpectedOutput { /** Name of the output (e.g., "project_analysis.md") */ name: string; /** Type of output */ type: 'file' | 'context'; /** Description of what this output contains */ description?: string; } /** * Input reference from a previous chain step */ export interface InputReference { /** Step ID to get input from */ stepId: string; /** Name of the artifact to use */ artifactName: string; } /** * Chain task step definition */ export interface ChainStepDefinition { /** Unique step ID within chain */ stepId: string; /** Task content/prompt */ content: string; /** IDs of steps this depends on (executed after those complete) */ dependsOn?: string[]; /** Expected output artifacts this step produces */ expectedOutputs?: ExpectedOutput[]; /** Input artifacts from previous steps */ inputFrom?: InputReference[]; /** Suggested executor */ suggestedExecutor?: ExecutorType; /** Priority level */ priority?: 'high' | 'medium' | 'low'; } /** * Result of chain decomposition */ export interface ChainDecomposition { /** Whether this is a chain task */ isChain: boolean; /** Reasoning for the decision */ reasoning: string; /** Chain steps (if it's a chain) */ chain?: ChainStepDefinition[]; /** Estimated total duration */ estimatedDurationMinutes?: number; } /** * Chain execution status */ export interface ChainStatus { /** Chain ID */ chainId: string; /** Total steps in chain */ totalSteps: number; /** Number of completed steps */ completedSteps: number; /** Current step being executed */ currentStepId?: string; /** All artifacts produced so far */ artifacts: Record; /** Overall chain status */ status: 'pending' | 'running' | 'completed' | 'failed' | 'paused'; /** Error if failed */ error?: string; } /** * Prompt command options */ export interface PromptCommandOptions { /** Natural language prompt */ prompt: string; /** Force specific executor */ executor?: ExecutorType; /** Skip confirmation prompts */ autoApprove?: boolean; /** Show plan without execution */ dryRun?: boolean; /** Enable verbose logging */ verbose?: boolean; /** Working directory */ workspace?: string; /** Create as persistent task */ createTask?: boolean; /** Task priority if creating */ priority?: 'high' | 'medium' | 'low'; } /** * Prompt execution result */ export interface PromptResult { success: boolean; /** Supervisor decision */ decision: SupervisorDecision; /** Execution result if executed */ execution?: ExecutorResult; /** Created task ID if applicable */ taskId?: string; /** Total duration */ durationMs: number; } /** * Extended worker configuration with executor support */ export interface WorkerExecutorConfig { /** Default executor to use */ defaultExecutor: ExecutorType; /** Per-executor configurations */ executors: Partial>; /** Supervisor configuration */ supervisor: { /** LLM model for supervisor */ model?: string; /** Use cloud-based supervisor */ cloudEnabled?: boolean; /** Auto-approve executor switches */ autoSwitch?: boolean; }; } /** * Default executor configuration */ export declare const DEFAULT_EXECUTOR_CONFIG: WorkerExecutorConfig; /** * Prompt template for autonomous task execution * * DESIGN NOTE: The CLI Worker Agent is essentially the main Agent * with access to local tools. The prompt should enable autonomous * decision-making, not prescribe specific workflows. */ export declare function buildTaskPrompt(ctx: TaskContext): string; //# sourceMappingURL=types.d.ts.map