@sudocode-ai/local-server 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/README.md +19 -0
  2. package/dist/cli.d.ts +7 -0
  3. package/dist/cli.d.ts.map +1 -0
  4. package/dist/cli.js +105 -0
  5. package/dist/cli.js.map +7 -0
  6. package/dist/execution/engine/engine.d.ts +103 -0
  7. package/dist/execution/engine/engine.d.ts.map +1 -0
  8. package/dist/execution/engine/simple-engine.d.ts +190 -0
  9. package/dist/execution/engine/simple-engine.d.ts.map +1 -0
  10. package/dist/execution/engine/types.d.ts +116 -0
  11. package/dist/execution/engine/types.d.ts.map +1 -0
  12. package/dist/execution/output/ag-ui-adapter.d.ts +176 -0
  13. package/dist/execution/output/ag-ui-adapter.d.ts.map +1 -0
  14. package/dist/execution/output/ag-ui-integration.d.ts +96 -0
  15. package/dist/execution/output/ag-ui-integration.d.ts.map +1 -0
  16. package/dist/execution/output/claude-code-output-processor.d.ts +321 -0
  17. package/dist/execution/output/claude-code-output-processor.d.ts.map +1 -0
  18. package/dist/execution/output/index.d.ts +18 -0
  19. package/dist/execution/output/index.d.ts.map +1 -0
  20. package/dist/execution/output/types.d.ts +421 -0
  21. package/dist/execution/output/types.d.ts.map +1 -0
  22. package/dist/execution/process/builders/claude.d.ts +86 -0
  23. package/dist/execution/process/builders/claude.d.ts.map +1 -0
  24. package/dist/execution/process/index.d.ts +15 -0
  25. package/dist/execution/process/index.d.ts.map +1 -0
  26. package/dist/execution/process/manager.d.ts +133 -0
  27. package/dist/execution/process/manager.d.ts.map +1 -0
  28. package/dist/execution/process/simple-manager.d.ts +102 -0
  29. package/dist/execution/process/simple-manager.d.ts.map +1 -0
  30. package/dist/execution/process/types.d.ts +105 -0
  31. package/dist/execution/process/types.d.ts.map +1 -0
  32. package/dist/execution/process/utils.d.ts +53 -0
  33. package/dist/execution/process/utils.d.ts.map +1 -0
  34. package/dist/execution/resilience/circuit-breaker.d.ts +170 -0
  35. package/dist/execution/resilience/circuit-breaker.d.ts.map +1 -0
  36. package/dist/execution/resilience/executor.d.ts +109 -0
  37. package/dist/execution/resilience/executor.d.ts.map +1 -0
  38. package/dist/execution/resilience/index.d.ts +14 -0
  39. package/dist/execution/resilience/index.d.ts.map +1 -0
  40. package/dist/execution/resilience/resilient-executor.d.ts +86 -0
  41. package/dist/execution/resilience/resilient-executor.d.ts.map +1 -0
  42. package/dist/execution/resilience/retry.d.ts +161 -0
  43. package/dist/execution/resilience/retry.d.ts.map +1 -0
  44. package/dist/execution/resilience/types.d.ts +226 -0
  45. package/dist/execution/resilience/types.d.ts.map +1 -0
  46. package/dist/execution/transport/event-buffer.d.ts +119 -0
  47. package/dist/execution/transport/event-buffer.d.ts.map +1 -0
  48. package/dist/execution/transport/index.d.ts +10 -0
  49. package/dist/execution/transport/index.d.ts.map +1 -0
  50. package/dist/execution/transport/sse-transport.d.ts +146 -0
  51. package/dist/execution/transport/sse-transport.d.ts.map +1 -0
  52. package/dist/execution/transport/transport-manager.d.ts +176 -0
  53. package/dist/execution/transport/transport-manager.d.ts.map +1 -0
  54. package/dist/execution/workflow/index.d.ts +13 -0
  55. package/dist/execution/workflow/index.d.ts.map +1 -0
  56. package/dist/execution/workflow/linear-orchestrator.d.ts +216 -0
  57. package/dist/execution/workflow/linear-orchestrator.d.ts.map +1 -0
  58. package/dist/execution/workflow/memory-storage.d.ts +54 -0
  59. package/dist/execution/workflow/memory-storage.d.ts.map +1 -0
  60. package/dist/execution/workflow/orchestrator.d.ts +158 -0
  61. package/dist/execution/workflow/orchestrator.d.ts.map +1 -0
  62. package/dist/execution/workflow/types.d.ts +172 -0
  63. package/dist/execution/workflow/types.d.ts.map +1 -0
  64. package/dist/execution/workflow/utils.d.ts +89 -0
  65. package/dist/execution/workflow/utils.d.ts.map +1 -0
  66. package/dist/execution/worktree/config.d.ts +74 -0
  67. package/dist/execution/worktree/config.d.ts.map +1 -0
  68. package/dist/execution/worktree/git-cli.d.ts +151 -0
  69. package/dist/execution/worktree/git-cli.d.ts.map +1 -0
  70. package/dist/execution/worktree/index.d.ts +16 -0
  71. package/dist/execution/worktree/index.d.ts.map +1 -0
  72. package/dist/execution/worktree/manager.d.ts +184 -0
  73. package/dist/execution/worktree/manager.d.ts.map +1 -0
  74. package/dist/execution/worktree/types.d.ts +90 -0
  75. package/dist/execution/worktree/types.d.ts.map +1 -0
  76. package/dist/index.d.ts +8 -0
  77. package/dist/index.d.ts.map +1 -0
  78. package/dist/index.js +104 -0
  79. package/dist/index.js.map +7 -0
  80. package/dist/public/assets/index-C4SmlXoo.js +568 -0
  81. package/dist/public/assets/index-C4SmlXoo.js.map +1 -0
  82. package/dist/public/assets/index-DE59j7ti.css +1 -0
  83. package/dist/public/assets/react-vendor-LX0UoTxg.js +60 -0
  84. package/dist/public/assets/react-vendor-LX0UoTxg.js.map +1 -0
  85. package/dist/public/assets/ui-vendor-_cxVHaqZ.js +54 -0
  86. package/dist/public/assets/ui-vendor-_cxVHaqZ.js.map +1 -0
  87. package/dist/public/favicon.ico +0 -0
  88. package/dist/public/index.html +16 -0
  89. package/dist/public/logo.png +0 -0
  90. package/dist/routes/executions-stream.d.ts +24 -0
  91. package/dist/routes/executions-stream.d.ts.map +1 -0
  92. package/dist/routes/executions.d.ts +19 -0
  93. package/dist/routes/executions.d.ts.map +1 -0
  94. package/dist/routes/feedback.d.ts +7 -0
  95. package/dist/routes/feedback.d.ts.map +1 -0
  96. package/dist/routes/issues.d.ts +7 -0
  97. package/dist/routes/issues.d.ts.map +1 -0
  98. package/dist/routes/relationships.d.ts +7 -0
  99. package/dist/routes/relationships.d.ts.map +1 -0
  100. package/dist/routes/specs.d.ts +7 -0
  101. package/dist/routes/specs.d.ts.map +1 -0
  102. package/dist/services/db.d.ts +33 -0
  103. package/dist/services/db.d.ts.map +1 -0
  104. package/dist/services/execution-lifecycle.d.ts +108 -0
  105. package/dist/services/execution-lifecycle.d.ts.map +1 -0
  106. package/dist/services/execution-service.d.ts +185 -0
  107. package/dist/services/execution-service.d.ts.map +1 -0
  108. package/dist/services/executions.d.ts +59 -0
  109. package/dist/services/executions.d.ts.map +1 -0
  110. package/dist/services/export.d.ts +24 -0
  111. package/dist/services/export.d.ts.map +1 -0
  112. package/dist/services/feedback.d.ts +40 -0
  113. package/dist/services/feedback.d.ts.map +1 -0
  114. package/dist/services/issues.d.ts +27 -0
  115. package/dist/services/issues.d.ts.map +1 -0
  116. package/dist/services/prompt-template-engine.d.ts +108 -0
  117. package/dist/services/prompt-template-engine.d.ts.map +1 -0
  118. package/dist/services/prompt-templates.d.ts +97 -0
  119. package/dist/services/prompt-templates.d.ts.map +1 -0
  120. package/dist/services/relationships.d.ts +35 -0
  121. package/dist/services/relationships.d.ts.map +1 -0
  122. package/dist/services/specs.d.ts +27 -0
  123. package/dist/services/specs.d.ts.map +1 -0
  124. package/dist/services/watcher.d.ts +50 -0
  125. package/dist/services/watcher.d.ts.map +1 -0
  126. package/dist/services/websocket.d.ts +127 -0
  127. package/dist/services/websocket.d.ts.map +1 -0
  128. package/dist/utils/sudocode-dir.d.ts +6 -0
  129. package/dist/utils/sudocode-dir.d.ts.map +1 -0
  130. package/package.json +74 -0
@@ -0,0 +1,103 @@
1
+ /**
2
+ * Execution Engine Interface
3
+ *
4
+ * Core abstraction for task execution engines. Provides methods for
5
+ * submitting, controlling, monitoring, and waiting for task execution.
6
+ *
7
+ * @module execution/engine/engine
8
+ */
9
+ import type { ExecutionTask, ExecutionResult, TaskStatus, EngineMetrics, TaskCompleteHandler, TaskFailedHandler } from './types.js';
10
+ /**
11
+ * IExecutionEngine - Interface for task execution engines
12
+ *
13
+ * Defines the contract for engines that manage Claude Code agent execution.
14
+ * Implementations may use different strategies (queue-based, pool-based, etc.)
15
+ * but must provide these core capabilities.
16
+ */
17
+ export interface IExecutionEngine {
18
+ /**
19
+ * Submit a single task for execution
20
+ *
21
+ * @param task - The task to execute
22
+ * @returns Promise resolving to the task ID
23
+ */
24
+ submitTask(task: ExecutionTask): Promise<string>;
25
+ /**
26
+ * Submit multiple tasks for execution
27
+ *
28
+ * @param tasks - Array of tasks to execute
29
+ * @returns Promise resolving to array of task IDs
30
+ */
31
+ submitTasks(tasks: ExecutionTask[]): Promise<string[]>;
32
+ /**
33
+ * Cancel a queued or running task
34
+ *
35
+ * For queued tasks, removes from queue without execution.
36
+ * For running tasks, terminates the process.
37
+ *
38
+ * @param taskId - ID of task to cancel
39
+ * @returns Promise that resolves when cancellation complete
40
+ */
41
+ cancelTask(taskId: string): Promise<void>;
42
+ /**
43
+ * Get current status of a task
44
+ *
45
+ * @param taskId - ID of task to query
46
+ * @returns Current task status or null if task not found
47
+ */
48
+ getTaskStatus(taskId: string): TaskStatus | null;
49
+ /**
50
+ * Wait for a task to complete
51
+ *
52
+ * Returns immediately if task already completed, otherwise
53
+ * waits for completion and returns result.
54
+ *
55
+ * @param taskId - ID of task to wait for
56
+ * @returns Promise resolving to execution result
57
+ * @throws Error if task fails
58
+ */
59
+ waitForTask(taskId: string): Promise<ExecutionResult>;
60
+ /**
61
+ * Wait for multiple tasks to complete
62
+ *
63
+ * @param taskIds - IDs of tasks to wait for
64
+ * @returns Promise resolving to array of execution results
65
+ * @throws Error if any task fails
66
+ */
67
+ waitForTasks(taskIds: string[]): Promise<ExecutionResult[]>;
68
+ /**
69
+ * Get current engine metrics
70
+ *
71
+ * Returns real-time statistics about engine performance
72
+ * and resource utilization.
73
+ *
74
+ * @returns Current engine metrics (defensive copy)
75
+ */
76
+ getMetrics(): EngineMetrics;
77
+ /**
78
+ * Register handler for task completion events
79
+ *
80
+ * Called when any task completes successfully.
81
+ *
82
+ * @param handler - Callback function to invoke on completion
83
+ */
84
+ onTaskComplete(handler: TaskCompleteHandler): void;
85
+ /**
86
+ * Register handler for task failure events
87
+ *
88
+ * Called when any task fails after all retries exhausted.
89
+ *
90
+ * @param handler - Callback function to invoke on failure
91
+ */
92
+ onTaskFailed(handler: TaskFailedHandler): void;
93
+ /**
94
+ * Gracefully shutdown the engine
95
+ *
96
+ * Stops accepting new tasks, cancels queued tasks,
97
+ * terminates running tasks, and releases all resources.
98
+ *
99
+ * @returns Promise that resolves when shutdown complete
100
+ */
101
+ shutdown(): Promise<void>;
102
+ }
103
+ //# sourceMappingURL=engine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../../../src/execution/engine/engine.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EACf,UAAU,EACV,aAAa,EACb,mBAAmB,EACnB,iBAAiB,EAClB,MAAM,YAAY,CAAC;AAEpB;;;;;;GAMG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;;;OAKG;IACH,UAAU,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAEjD;;;;;OAKG;IACH,WAAW,CAAC,KAAK,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAEvD;;;;;;;;OAQG;IACH,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE1C;;;;;OAKG;IACH,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CAAC;IAEjD;;;;;;;;;OASG;IACH,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAEtD;;;;;;OAMG;IACH,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;IAE5D;;;;;;;OAOG;IACH,UAAU,IAAI,aAAa,CAAC;IAE5B;;;;;;OAMG;IACH,cAAc,CAAC,OAAO,EAAE,mBAAmB,GAAG,IAAI,CAAC;IAEnD;;;;;;OAMG;IACH,YAAY,CAAC,OAAO,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAE/C;;;;;;;OAOG;IACH,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3B"}
@@ -0,0 +1,190 @@
1
+ /**
2
+ * Simple Execution Engine
3
+ *
4
+ * Queue-based execution engine that spawns a process per task
5
+ * with concurrency limits. Implements the "simple first" approach.
6
+ *
7
+ * @module execution/engine/simple-engine
8
+ */
9
+ import type { IExecutionEngine } from "./engine.js";
10
+ import type { ExecutionTask, ExecutionResult, TaskStatus, EngineMetrics, TaskCompleteHandler, TaskFailedHandler, EngineConfig } from "./types.js";
11
+ import type { IProcessManager } from "../process/manager.js";
12
+ /**
13
+ * SimpleExecutionEngine - Queue-based task execution with concurrency control
14
+ *
15
+ * Key features:
16
+ * - FIFO queue for task ordering
17
+ * - Configurable concurrency limit (default: 3)
18
+ * - Automatic retry on failure
19
+ * - Event emission for task lifecycle
20
+ * - Promise-based waiting
21
+ * - Graceful shutdown
22
+ */
23
+ export declare class SimpleExecutionEngine implements IExecutionEngine {
24
+ private _processManager;
25
+ private _config;
26
+ private taskQueue;
27
+ private runningTasks;
28
+ private completedResults;
29
+ private taskResolvers;
30
+ private metrics;
31
+ private completeHandlers;
32
+ private failedHandlers;
33
+ private pollingIntervals;
34
+ /**
35
+ * Create a new SimpleExecutionEngine
36
+ *
37
+ * @param processManager - Process manager for spawning Claude processes
38
+ * @param config - Engine configuration options
39
+ */
40
+ constructor(_processManager: IProcessManager, _config?: EngineConfig);
41
+ /**
42
+ * Submit a single task for execution
43
+ *
44
+ * Adds task to queue and attempts to start execution if capacity available.
45
+ *
46
+ * @param task - The task to execute
47
+ * @returns Promise resolving to the task ID
48
+ */
49
+ submitTask(task: ExecutionTask): Promise<string>;
50
+ /**
51
+ * Submit multiple tasks for execution
52
+ *
53
+ * @param tasks - Array of tasks to execute
54
+ * @returns Promise resolving to array of task IDs
55
+ */
56
+ submitTasks(tasks: ExecutionTask[]): Promise<string[]>;
57
+ /**
58
+ * Process the task queue
59
+ *
60
+ * Dequeues tasks and starts execution while capacity is available.
61
+ * Checks dependencies before execution and re-queues if not met.
62
+ *
63
+ * @private
64
+ */
65
+ private processQueue;
66
+ /**
67
+ * Check if all task dependencies are met
68
+ *
69
+ * @param task - Task to check
70
+ * @returns True if all dependencies completed successfully
71
+ * @private
72
+ */
73
+ private areDependenciesMet;
74
+ /**
75
+ * Check if any task dependency has failed
76
+ *
77
+ * @param task - Task to check
78
+ * @returns True if any dependency failed
79
+ * @private
80
+ */
81
+ private hasFailedDependency;
82
+ /**
83
+ * Track task as running and update capacity metrics
84
+ *
85
+ * @param task - Task to start tracking
86
+ * @private
87
+ */
88
+ private trackTaskStart;
89
+ /**
90
+ * Track task completion and release capacity
91
+ *
92
+ * @param taskId - ID of completed task
93
+ * @private
94
+ */
95
+ private trackTaskComplete;
96
+ /**
97
+ * Execute a task
98
+ *
99
+ * Acquires a process, sends the prompt, collects output, and builds the result.
100
+ *
101
+ * @param task - Task to execute
102
+ * @private
103
+ */
104
+ private executeTask;
105
+ /**
106
+ * Wait for a process to exit
107
+ *
108
+ * @param process - The managed process to wait for
109
+ * @param timeoutMs - Optional timeout in milliseconds
110
+ * @private
111
+ */
112
+ private waitForProcessExit;
113
+ /**
114
+ * Parse metadata from stream-json output
115
+ *
116
+ * Extracts tools used, files changed, tokens, etc. from the output.
117
+ *
118
+ * @param output - Raw output from Claude Code
119
+ * @returns Parsed metadata
120
+ * @private
121
+ */
122
+ private parseMetadata;
123
+ /**
124
+ * Handle task failure
125
+ *
126
+ * Implements automatic retry logic if maxRetries is configured.
127
+ * Re-queues failed tasks at front of queue for priority retry.
128
+ *
129
+ * @param taskId - ID of failed task
130
+ * @param error - Error that occurred
131
+ * @private
132
+ */
133
+ private handleTaskFailure;
134
+ /**
135
+ * Cancel a queued or running task
136
+ *
137
+ * Removes task from queue if still queued, or terminates process if running.
138
+ * Idempotent - safe to call multiple times or for non-existent tasks.
139
+ *
140
+ * @param taskId - ID of task to cancel
141
+ */
142
+ cancelTask(taskId: string): Promise<void>;
143
+ /**
144
+ * Get current status of a task
145
+ */
146
+ getTaskStatus(taskId: string): TaskStatus | null;
147
+ /**
148
+ * Wait for a task to complete
149
+ *
150
+ * Returns a promise that resolves with the task result when complete.
151
+ * Supports multiple concurrent waiters for the same task.
152
+ *
153
+ * @param taskId - ID of the task to wait for
154
+ * @returns Promise resolving to the execution result
155
+ */
156
+ waitForTask(taskId: string): Promise<ExecutionResult>;
157
+ /**
158
+ * Wait for multiple tasks to complete
159
+ *
160
+ * Returns a promise that resolves when all tasks complete.
161
+ *
162
+ * @param taskIds - Array of task IDs to wait for
163
+ * @returns Promise resolving to array of execution results
164
+ */
165
+ waitForTasks(taskIds: string[]): Promise<ExecutionResult[]>;
166
+ /**
167
+ * Get current engine metrics
168
+ *
169
+ * Returns defensive copy of current metrics.
170
+ *
171
+ * @returns Current engine metrics
172
+ */
173
+ getMetrics(): EngineMetrics;
174
+ /**
175
+ * Register handler for task completion events
176
+ */
177
+ onTaskComplete(handler: TaskCompleteHandler): void;
178
+ /**
179
+ * Register handler for task failure events
180
+ */
181
+ onTaskFailed(handler: TaskFailedHandler): void;
182
+ /**
183
+ * Gracefully shutdown the engine
184
+ *
185
+ * Cancels all running tasks, clears the queue, and shuts down the process manager.
186
+ * Idempotent - safe to call multiple times.
187
+ */
188
+ shutdown(): Promise<void>;
189
+ }
190
+ //# sourceMappingURL=simple-engine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"simple-engine.d.ts","sourceRoot":"","sources":["../../../src/execution/engine/simple-engine.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EACf,UAAU,EACV,aAAa,EACb,mBAAmB,EACnB,iBAAiB,EACjB,YAAY,EAGb,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAI7D;;;;;;;;;;GAUG;AACH,qBAAa,qBAA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IACG,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IAIjE;;;;;;OAMG;IACH,UAAU,IAAI,aAAa;IAK3B;;OAEG;IACH,cAAc,CAAC,OAAO,EAAE,mBAAmB,GAAG,IAAI;IAIlD;;OAEG;IACH,YAAY,CAAC,OAAO,EAAE,iBAAiB,GAAG,IAAI;IAI9C;;;;;OAKG;IACG,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CA6BhC"}
@@ -0,0 +1,116 @@
1
+ /**
2
+ * Engine Layer Types
3
+ *
4
+ * Core types for the Execution Engine (Layer 2) that manages
5
+ * task queueing, concurrency, and multi-agent execution.
6
+ *
7
+ * @module execution/engine/types
8
+ */
9
+ /**
10
+ * ExecutionTask - Represents a unit of work to be executed by a Claude Code agent
11
+ */
12
+ export interface ExecutionTask {
13
+ id: string;
14
+ type: 'issue' | 'spec' | 'custom';
15
+ entityId?: string;
16
+ prompt: string;
17
+ workDir: string;
18
+ priority: number;
19
+ dependencies: string[];
20
+ createdAt: Date;
21
+ config: {
22
+ timeout?: number;
23
+ maxRetries?: number;
24
+ env?: Record<string, string>;
25
+ };
26
+ metadata?: Record<string, any>;
27
+ }
28
+ /**
29
+ * ExecutionResult - The outcome of executing a task
30
+ */
31
+ export interface ExecutionResult {
32
+ taskId: string;
33
+ executionId: string;
34
+ success: boolean;
35
+ exitCode: number;
36
+ output: string;
37
+ error?: string;
38
+ startedAt: Date;
39
+ completedAt: Date;
40
+ duration: number;
41
+ metadata?: {
42
+ toolsUsed?: string[];
43
+ filesChanged?: string[];
44
+ tokensUsed?: number;
45
+ cost?: number;
46
+ };
47
+ }
48
+ /**
49
+ * EngineMetrics - Real-time engine performance statistics
50
+ */
51
+ export interface EngineMetrics {
52
+ maxConcurrent: number;
53
+ currentlyRunning: number;
54
+ availableSlots: number;
55
+ queuedTasks: number;
56
+ completedTasks: number;
57
+ failedTasks: number;
58
+ averageDuration: number;
59
+ successRate: number;
60
+ throughput: number;
61
+ totalProcessesSpawned: number;
62
+ activeProcesses: number;
63
+ }
64
+ /**
65
+ * TaskStatus - Discriminated union for task state tracking
66
+ */
67
+ export type TaskStatus = {
68
+ state: 'queued';
69
+ position: number;
70
+ } | {
71
+ state: 'running';
72
+ processId: string;
73
+ startedAt: Date;
74
+ } | {
75
+ state: 'completed';
76
+ result: ExecutionResult;
77
+ } | {
78
+ state: 'failed';
79
+ error: string;
80
+ } | {
81
+ state: 'cancelled';
82
+ cancelledAt: Date;
83
+ };
84
+ /**
85
+ * TaskCompleteHandler - Callback for task completion events
86
+ */
87
+ export type TaskCompleteHandler = (result: ExecutionResult) => void;
88
+ /**
89
+ * TaskFailedHandler - Callback for task failure events
90
+ */
91
+ export type TaskFailedHandler = (taskId: string, error: Error) => void;
92
+ /**
93
+ * EngineConfig - Configuration options for execution engines
94
+ */
95
+ export interface EngineConfig {
96
+ maxConcurrent?: number;
97
+ claudePath?: string;
98
+ onOutput?: (data: Buffer, type: 'stdout' | 'stderr') => void;
99
+ }
100
+ /**
101
+ * RunningTask - Internal tracking for currently executing tasks
102
+ */
103
+ export interface RunningTask {
104
+ task: ExecutionTask;
105
+ process: any;
106
+ startedAt: Date;
107
+ attempt: number;
108
+ }
109
+ /**
110
+ * TaskResolver - Promise resolver for async task waiting
111
+ */
112
+ export interface TaskResolver {
113
+ resolve: (result: ExecutionResult) => void;
114
+ reject: (error: Error) => void;
115
+ }
116
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/execution/engine/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;GAEG;AACH,MAAM,WAAW,aAAa;IAE5B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC;IAClC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAGlB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO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
+ /**
2
+ * AG-UI Event Adapter
3
+ *
4
+ * Transforms SPEC-007 output processing events into AG-UI protocol events.
5
+ * This adapter subscribes to events from IOutputProcessor and emits standardized
6
+ * AG-UI events that can be consumed by frontends via SSE or WebSocket transports.
7
+ *
8
+ * @module execution/output/ag-ui-adapter
9
+ */
10
+ import { type RunStartedEvent, type RunFinishedEvent, type RunErrorEvent, type StepStartedEvent, type StepFinishedEvent, type ToolCallStartEvent, type ToolCallArgsEvent, type ToolCallEndEvent, type ToolCallResultEvent, type TextMessageStartEvent, type TextMessageContentEvent, type TextMessageEndEvent, type StateDeltaEvent, type StateSnapshotEvent, type CustomEvent, type State } from "@ag-ui/core";
11
+ import { IOutputProcessor } from "./types.js";
12
+ /**
13
+ * Event listener callback type
14
+ *
15
+ * Accepts any AG-UI event type from @ag-ui/core
16
+ */
17
+ export type AgUiEventListener = (event: RunStartedEvent | RunFinishedEvent | RunErrorEvent | StepStartedEvent | StepFinishedEvent | ToolCallStartEvent | ToolCallArgsEvent | ToolCallEndEvent | ToolCallResultEvent | TextMessageStartEvent | TextMessageContentEvent | TextMessageEndEvent | StateDeltaEvent | StateSnapshotEvent | CustomEvent) => void;
18
+ /**
19
+ * AgUiEventAdapter - Transforms SPEC-007 events to AG-UI events
20
+ *
21
+ * This adapter bridges the gap between the Output Processing Layer (SPEC-007)
22
+ * and the AG-UI protocol (SPEC-009). It subscribes to output processor events
23
+ * and emits corresponding AG-UI protocol events.
24
+ *
25
+ * @example
26
+ * ```typescript
27
+ * const adapter = new AgUiEventAdapter('run-123');
28
+ * adapter.onEvent((event) => {
29
+ * console.log('AG-UI event:', event);
30
+ * // Send to SSE transport or WebSocket
31
+ * });
32
+ *
33
+ * const processor = new ClaudeCodeOutputProcessor();
34
+ * adapter.connectToProcessor(processor);
35
+ * adapter.emitRunStarted({ model: 'claude-sonnet-4' });
36
+ * ```
37
+ */
38
+ export declare class AgUiEventAdapter {
39
+ private runId;
40
+ private threadId;
41
+ private listeners;
42
+ private processor;
43
+ private currentState;
44
+ private activeToolCalls;
45
+ private messageCounter;
46
+ /**
47
+ * Create a new AG-UI event adapter
48
+ *
49
+ * @param runId - Unique identifier for this execution run
50
+ * @param threadId - Thread identifier (defaults to runId if not provided)
51
+ */
52
+ constructor(runId: string, threadId?: string);
53
+ /**
54
+ * Connect to an output processor and subscribe to its events
55
+ *
56
+ * @param processor - The output processor to subscribe to
57
+ */
58
+ connectToProcessor(processor: IOutputProcessor): void;
59
+ /**
60
+ * Register an event listener
61
+ *
62
+ * @param listener - Callback to invoke when AG-UI events are emitted
63
+ */
64
+ onEvent(listener: AgUiEventListener): void;
65
+ /**
66
+ * Remove an event listener
67
+ *
68
+ * @param listener - Callback to remove
69
+ */
70
+ offEvent(listener: AgUiEventListener): void;
71
+ /**
72
+ * Emit RUN_STARTED event
73
+ *
74
+ * @param metadata - Optional run metadata (model, config, etc.)
75
+ */
76
+ emitRunStarted(metadata?: Record<string, any>): void;
77
+ /**
78
+ * Emit RUN_FINISHED event
79
+ *
80
+ * @param result - Optional result data
81
+ */
82
+ emitRunFinished(result?: any): void;
83
+ /**
84
+ * Emit a state snapshot with current execution state
85
+ */
86
+ emitStateSnapshot(): void;
87
+ /**
88
+ * Handle tool call events from SPEC-007
89
+ *
90
+ * Transforms a single ToolCall into a sequence of AG-UI events:
91
+ * - TOOL_CALL_START (when tool is invoked)
92
+ * - TOOL_CALL_ARGS (with input parameters)
93
+ * - TOOL_CALL_END (when tool completes)
94
+ * - TOOL_CALL_RESULT (with result/error)
95
+ */
96
+ private handleToolCall;
97
+ /**
98
+ * Handle file change events from SPEC-007
99
+ *
100
+ * Transforms FileChange into a CUSTOM event with file operation details
101
+ */
102
+ private handleFileChange;
103
+ /**
104
+ * Handle progress updates from SPEC-007
105
+ *
106
+ * Transforms ProcessingMetrics into STATE_DELTA events
107
+ */
108
+ private handleProgress;
109
+ /**
110
+ * Handle error events from SPEC-007
111
+ *
112
+ * Transforms errors into RUN_ERROR events
113
+ */
114
+ private handleError;
115
+ /**
116
+ * Handle message events
117
+ *
118
+ * Transforms text messages into TEXT_MESSAGE_* AG-UI events.
119
+ * For now, we emit the full message content in a single event.
120
+ */
121
+ private handleMessage;
122
+ /**
123
+ * Handle usage metric updates
124
+ *
125
+ * Transforms usage metrics into CUSTOM usage events and updates state.
126
+ */
127
+ private handleUsage;
128
+ /**
129
+ * Emit a state delta with partial state updates
130
+ *
131
+ * @param updates - Partial state updates to apply
132
+ */
133
+ private emitStateDelta;
134
+ /**
135
+ * Emit an AG-UI event to all registered listeners
136
+ *
137
+ * @param event - The event to emit
138
+ */
139
+ private emit;
140
+ /**
141
+ * Emit STEP_STARTED event for workflow step execution
142
+ *
143
+ * @param stepId - Unique identifier for the step (stored in rawEvent)
144
+ * @param stepName - Human-readable name of the step
145
+ */
146
+ emitStepStarted(stepId: string, stepName: string): void;
147
+ /**
148
+ * Emit STEP_FINISHED event for workflow step completion
149
+ *
150
+ * @param stepId - Unique identifier for the step (stored in rawEvent)
151
+ * @param status - Status of the step ('success' or 'error', stored in rawEvent)
152
+ * @param output - Optional output data from the step (stored in rawEvent)
153
+ */
154
+ emitStepFinished(stepId: string, status: "success" | "error", output?: any): void;
155
+ /**
156
+ * Emit RUN_ERROR event when workflow execution fails
157
+ *
158
+ * @param message - Error message
159
+ * @param stack - Optional error stack trace
160
+ * @param code - Optional error code
161
+ */
162
+ emitRunError(message: string, stack?: string, code?: string): void;
163
+ /**
164
+ * Get current adapter state
165
+ *
166
+ * @returns Current state object
167
+ */
168
+ getState(): State;
169
+ /**
170
+ * Get the run ID
171
+ *
172
+ * @returns The run ID this adapter is tracking
173
+ */
174
+ getRunId(): string;
175
+ }
176
+ //# sourceMappingURL=ag-ui-adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ag-ui-adapter.d.ts","sourceRoot":"","sources":["../../../src/execution/output/ag-ui-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAEL,KAAK,eAAe,EACpB,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