/** * UltraWork Manager * * Manages autonomous multi-step work sessions that combine * delegation and task continuation for extended workflows. * * Supports two modes: * 1. **Phased Loop** (Ralph Loop, default): Plan -> Build -> Retrospective * - File-based state persist for crash recovery * - Council integration at plan and retrospective phases * - Structured task execution from plan * 2. **Freeform Loop** (legacy): Lead agent freely delegates and continues * * Constraints: * - max_duration (default 60 min) * - max_steps (default 50) * - Lead agent must be Tier 1 with can_delegate */ import type { UltraWorkConfig, AgentPersonaConfig } from './types.js'; import { ToolPermissionManager } from './tool-permission-manager.js'; import { type DelegationExecuteCallback, type DelegationNotifyCallback } from './delegation-manager.js'; import { UltraWorkStateManager } from './ultrawork-state.js'; /** * Callback to intercept agent responses for workflow/council plan execution. * Returns the processed result if a plan was found, or null to continue normal processing. */ export type ResponseInterceptor = (agentResponse: string, channelId: string) => Promise<{ result: string; type: 'workflow' | 'council'; } | null>; /** * UltraWork session state */ export interface UltraWorkSession { /** Unique session ID */ id: string; /** Channel where session is running */ channelId: string; /** Lead agent ID (Tier 1) */ leadAgentId: string; /** Task description */ task: string; /** Current step number */ currentStep: number; /** Maximum steps allowed */ maxSteps: number; /** Session start time */ startTime: number; /** Maximum duration in ms */ maxDuration: number; /** Whether session is active */ active: boolean; /** Steps log */ steps: UltraWorkStep[]; } /** * Individual step in an UltraWork session */ export interface UltraWorkStep { /** Step number */ stepNumber: number; /** Agent that performed the step */ agentId: string; /** What was done */ action: string; /** Response summary */ responseSummary: string; /** Whether the step was a delegation */ isDelegation: boolean; /** Duration in ms */ duration: number; /** Timestamp */ timestamp: number; } /** * UltraWork Manager */ export declare class UltraWorkManager { private config; private permissionManager; private stateManager; /** Active sessions per channel */ private sessions; /** Session counter for unique IDs */ private sessionCounter; /** Sessions DB for agent_activity logging in delegations */ private sessionsDb; setSessionsDb(db: import('../sqlite.js').default): void; constructor(config: UltraWorkConfig, permissionManager?: ToolPermissionManager); /** * Check if a message contains UltraWork trigger keywords. */ isUltraWorkTrigger(content: string): boolean; /** * Start a new UltraWork session. */ startSession(channelId: string, leadAgentId: string, task: string, agents: AgentPersonaConfig[], executeCallback: DelegationExecuteCallback, notifyCallback: DelegationNotifyCallback, responseInterceptor?: ResponseInterceptor): Promise; /** * Check if a session should continue. */ shouldContinue(session: UltraWorkSession): boolean; /** * Stop an active session. */ stopSession(channelId: string): UltraWorkSession | null; /** * Get active session for a channel. */ getSession(channelId: string): UltraWorkSession | null; /** * Get all active sessions. */ getActiveSessions(): UltraWorkSession[]; /** * Check if UltraWork is enabled. */ isEnabled(): boolean; /** * Update configuration. */ updateConfig(config: UltraWorkConfig): void; /** * Get the state manager (for testing). */ getStateManager(): UltraWorkStateManager | null; /** * Override state manager (for testing with temp dirs). */ setStateManager(sm: UltraWorkStateManager | null): void; /** * Execute callback with timeout protection. */ private executeWithTimeout; /** * Run the autonomous session loop — dispatches to phased or freeform mode. */ private runSessionLoop; private runPlanningPhase; private runBuildingPhase; private runRetrospectivePhase; private runPhasedLoop; private runFreeformLoop; private buildPlanningPrompt; private buildBuildingPrompt; private buildRetrospectivePrompt; private buildInitialPrompt; private buildContinuationAfterDelegation; private isBuildComplete; private isRetroComplete; private endSession; } //# sourceMappingURL=ultrawork.d.ts.map