@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.
- package/README.md +19 -0
- package/dist/cli.d.ts +7 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +105 -0
- package/dist/cli.js.map +7 -0
- package/dist/execution/engine/engine.d.ts +103 -0
- package/dist/execution/engine/engine.d.ts.map +1 -0
- package/dist/execution/engine/simple-engine.d.ts +190 -0
- package/dist/execution/engine/simple-engine.d.ts.map +1 -0
- package/dist/execution/engine/types.d.ts +116 -0
- package/dist/execution/engine/types.d.ts.map +1 -0
- package/dist/execution/output/ag-ui-adapter.d.ts +176 -0
- package/dist/execution/output/ag-ui-adapter.d.ts.map +1 -0
- package/dist/execution/output/ag-ui-integration.d.ts +96 -0
- package/dist/execution/output/ag-ui-integration.d.ts.map +1 -0
- package/dist/execution/output/claude-code-output-processor.d.ts +321 -0
- package/dist/execution/output/claude-code-output-processor.d.ts.map +1 -0
- package/dist/execution/output/index.d.ts +18 -0
- package/dist/execution/output/index.d.ts.map +1 -0
- package/dist/execution/output/types.d.ts +421 -0
- package/dist/execution/output/types.d.ts.map +1 -0
- package/dist/execution/process/builders/claude.d.ts +86 -0
- package/dist/execution/process/builders/claude.d.ts.map +1 -0
- package/dist/execution/process/index.d.ts +15 -0
- package/dist/execution/process/index.d.ts.map +1 -0
- package/dist/execution/process/manager.d.ts +133 -0
- package/dist/execution/process/manager.d.ts.map +1 -0
- package/dist/execution/process/simple-manager.d.ts +102 -0
- package/dist/execution/process/simple-manager.d.ts.map +1 -0
- package/dist/execution/process/types.d.ts +105 -0
- package/dist/execution/process/types.d.ts.map +1 -0
- package/dist/execution/process/utils.d.ts +53 -0
- package/dist/execution/process/utils.d.ts.map +1 -0
- package/dist/execution/resilience/circuit-breaker.d.ts +170 -0
- package/dist/execution/resilience/circuit-breaker.d.ts.map +1 -0
- package/dist/execution/resilience/executor.d.ts +109 -0
- package/dist/execution/resilience/executor.d.ts.map +1 -0
- package/dist/execution/resilience/index.d.ts +14 -0
- package/dist/execution/resilience/index.d.ts.map +1 -0
- package/dist/execution/resilience/resilient-executor.d.ts +86 -0
- package/dist/execution/resilience/resilient-executor.d.ts.map +1 -0
- package/dist/execution/resilience/retry.d.ts +161 -0
- package/dist/execution/resilience/retry.d.ts.map +1 -0
- package/dist/execution/resilience/types.d.ts +226 -0
- package/dist/execution/resilience/types.d.ts.map +1 -0
- package/dist/execution/transport/event-buffer.d.ts +119 -0
- package/dist/execution/transport/event-buffer.d.ts.map +1 -0
- package/dist/execution/transport/index.d.ts +10 -0
- package/dist/execution/transport/index.d.ts.map +1 -0
- package/dist/execution/transport/sse-transport.d.ts +146 -0
- package/dist/execution/transport/sse-transport.d.ts.map +1 -0
- package/dist/execution/transport/transport-manager.d.ts +176 -0
- package/dist/execution/transport/transport-manager.d.ts.map +1 -0
- package/dist/execution/workflow/index.d.ts +13 -0
- package/dist/execution/workflow/index.d.ts.map +1 -0
- package/dist/execution/workflow/linear-orchestrator.d.ts +216 -0
- package/dist/execution/workflow/linear-orchestrator.d.ts.map +1 -0
- package/dist/execution/workflow/memory-storage.d.ts +54 -0
- package/dist/execution/workflow/memory-storage.d.ts.map +1 -0
- package/dist/execution/workflow/orchestrator.d.ts +158 -0
- package/dist/execution/workflow/orchestrator.d.ts.map +1 -0
- package/dist/execution/workflow/types.d.ts +172 -0
- package/dist/execution/workflow/types.d.ts.map +1 -0
- package/dist/execution/workflow/utils.d.ts +89 -0
- package/dist/execution/workflow/utils.d.ts.map +1 -0
- package/dist/execution/worktree/config.d.ts +74 -0
- package/dist/execution/worktree/config.d.ts.map +1 -0
- package/dist/execution/worktree/git-cli.d.ts +151 -0
- package/dist/execution/worktree/git-cli.d.ts.map +1 -0
- package/dist/execution/worktree/index.d.ts +16 -0
- package/dist/execution/worktree/index.d.ts.map +1 -0
- package/dist/execution/worktree/manager.d.ts +184 -0
- package/dist/execution/worktree/manager.d.ts.map +1 -0
- package/dist/execution/worktree/types.d.ts +90 -0
- package/dist/execution/worktree/types.d.ts.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +104 -0
- package/dist/index.js.map +7 -0
- package/dist/public/assets/index-C4SmlXoo.js +568 -0
- package/dist/public/assets/index-C4SmlXoo.js.map +1 -0
- package/dist/public/assets/index-DE59j7ti.css +1 -0
- package/dist/public/assets/react-vendor-LX0UoTxg.js +60 -0
- package/dist/public/assets/react-vendor-LX0UoTxg.js.map +1 -0
- package/dist/public/assets/ui-vendor-_cxVHaqZ.js +54 -0
- package/dist/public/assets/ui-vendor-_cxVHaqZ.js.map +1 -0
- package/dist/public/favicon.ico +0 -0
- package/dist/public/index.html +16 -0
- package/dist/public/logo.png +0 -0
- package/dist/routes/executions-stream.d.ts +24 -0
- package/dist/routes/executions-stream.d.ts.map +1 -0
- package/dist/routes/executions.d.ts +19 -0
- package/dist/routes/executions.d.ts.map +1 -0
- package/dist/routes/feedback.d.ts +7 -0
- package/dist/routes/feedback.d.ts.map +1 -0
- package/dist/routes/issues.d.ts +7 -0
- package/dist/routes/issues.d.ts.map +1 -0
- package/dist/routes/relationships.d.ts +7 -0
- package/dist/routes/relationships.d.ts.map +1 -0
- package/dist/routes/specs.d.ts +7 -0
- package/dist/routes/specs.d.ts.map +1 -0
- package/dist/services/db.d.ts +33 -0
- package/dist/services/db.d.ts.map +1 -0
- package/dist/services/execution-lifecycle.d.ts +108 -0
- package/dist/services/execution-lifecycle.d.ts.map +1 -0
- package/dist/services/execution-service.d.ts +185 -0
- package/dist/services/execution-service.d.ts.map +1 -0
- package/dist/services/executions.d.ts +59 -0
- package/dist/services/executions.d.ts.map +1 -0
- package/dist/services/export.d.ts +24 -0
- package/dist/services/export.d.ts.map +1 -0
- package/dist/services/feedback.d.ts +40 -0
- package/dist/services/feedback.d.ts.map +1 -0
- package/dist/services/issues.d.ts +27 -0
- package/dist/services/issues.d.ts.map +1 -0
- package/dist/services/prompt-template-engine.d.ts +108 -0
- package/dist/services/prompt-template-engine.d.ts.map +1 -0
- package/dist/services/prompt-templates.d.ts +97 -0
- package/dist/services/prompt-templates.d.ts.map +1 -0
- package/dist/services/relationships.d.ts +35 -0
- package/dist/services/relationships.d.ts.map +1 -0
- package/dist/services/specs.d.ts +27 -0
- package/dist/services/specs.d.ts.map +1 -0
- package/dist/services/watcher.d.ts +50 -0
- package/dist/services/watcher.d.ts.map +1 -0
- package/dist/services/websocket.d.ts +127 -0
- package/dist/services/websocket.d.ts.map +1 -0
- package/dist/utils/sudocode-dir.d.ts +6 -0
- package/dist/utils/sudocode-dir.d.ts.map +1 -0
- package/package.json +74 -0
|
@@ -0,0 +1,421 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Output Processing Layer Types
|
|
3
|
+
*
|
|
4
|
+
* Core types for the Output Processing Layer (Layer 5) that handles
|
|
5
|
+
* real-time parsing and processing of coding agent output.
|
|
6
|
+
*
|
|
7
|
+
* Currently optimized for Claude Code's stream-json format, but designed
|
|
8
|
+
* with extension points for future multi-agent support (Aider, Gemini, Codex, etc.)
|
|
9
|
+
*
|
|
10
|
+
* @module execution/output/types
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* MessageType - Types of messages in agent output
|
|
14
|
+
*
|
|
15
|
+
* These types represent common semantic operations across coding agents.
|
|
16
|
+
* Agent-specific adapters map their output to these standard types.
|
|
17
|
+
*/
|
|
18
|
+
export type MessageType = "text" | "tool_use" | "tool_result" | "usage" | "error" | "unknown";
|
|
19
|
+
/**
|
|
20
|
+
* FileOperation - Type of file operation performed
|
|
21
|
+
*
|
|
22
|
+
* Extended to support operations from various agents:
|
|
23
|
+
* - read: File read operations
|
|
24
|
+
* - write: File write (create or overwrite)
|
|
25
|
+
* - edit: In-place file edits (e.g., Aider's inline edits)
|
|
26
|
+
* - delete: File deletion
|
|
27
|
+
* - create: Explicit file creation (vs overwrite)
|
|
28
|
+
*/
|
|
29
|
+
export type FileOperation = "read" | "write" | "edit" | "delete" | "create";
|
|
30
|
+
/**
|
|
31
|
+
* ToolCallStatus - Status of a tool invocation
|
|
32
|
+
*/
|
|
33
|
+
export type ToolCallStatus = "pending" | "success" | "error";
|
|
34
|
+
/**
|
|
35
|
+
* OutputMessage - Discriminated union for all message types
|
|
36
|
+
*
|
|
37
|
+
* Represents a parsed message from agent output.
|
|
38
|
+
* Uses a discriminated union pattern for type-safe message handling.
|
|
39
|
+
*
|
|
40
|
+
* The `metadata` field on each variant provides an extension point for
|
|
41
|
+
* agent-specific data without breaking the core type structure.
|
|
42
|
+
*/
|
|
43
|
+
export type OutputMessage = {
|
|
44
|
+
type: "text";
|
|
45
|
+
content: string;
|
|
46
|
+
timestamp: Date;
|
|
47
|
+
/** Agent-specific metadata (e.g., formatting, styling) */
|
|
48
|
+
metadata?: Record<string, any>;
|
|
49
|
+
} | {
|
|
50
|
+
type: "tool_use";
|
|
51
|
+
id: string;
|
|
52
|
+
name: string;
|
|
53
|
+
input: Record<string, any>;
|
|
54
|
+
timestamp: Date;
|
|
55
|
+
/** Agent-specific metadata (e.g., execution context, permissions) */
|
|
56
|
+
metadata?: Record<string, any>;
|
|
57
|
+
} | {
|
|
58
|
+
type: "tool_result";
|
|
59
|
+
toolUseId: string;
|
|
60
|
+
result: any;
|
|
61
|
+
isError: boolean;
|
|
62
|
+
timestamp: Date;
|
|
63
|
+
/** Agent-specific metadata (e.g., exit codes, duration) */
|
|
64
|
+
metadata?: Record<string, any>;
|
|
65
|
+
} | {
|
|
66
|
+
type: "usage";
|
|
67
|
+
tokens: {
|
|
68
|
+
input: number;
|
|
69
|
+
output: number;
|
|
70
|
+
cache: number;
|
|
71
|
+
};
|
|
72
|
+
timestamp: Date;
|
|
73
|
+
/** Agent-specific metadata (e.g., model name, pricing tier) */
|
|
74
|
+
metadata?: Record<string, any>;
|
|
75
|
+
} | {
|
|
76
|
+
type: "error";
|
|
77
|
+
message: string;
|
|
78
|
+
details?: any;
|
|
79
|
+
timestamp: Date;
|
|
80
|
+
/** Agent-specific metadata (e.g., error codes, stack traces) */
|
|
81
|
+
metadata?: Record<string, any>;
|
|
82
|
+
} | {
|
|
83
|
+
type: "unknown";
|
|
84
|
+
raw: string;
|
|
85
|
+
timestamp: Date;
|
|
86
|
+
/** Agent-specific metadata (e.g., original format, parsing hints) */
|
|
87
|
+
metadata?: Record<string, any>;
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* FileChange - Track file modifications during execution
|
|
91
|
+
*/
|
|
92
|
+
export interface FileChange {
|
|
93
|
+
/**
|
|
94
|
+
* Path to the file that was changed
|
|
95
|
+
*/
|
|
96
|
+
path: string;
|
|
97
|
+
/**
|
|
98
|
+
* Type of operation performed on the file
|
|
99
|
+
*/
|
|
100
|
+
operation: FileOperation;
|
|
101
|
+
/**
|
|
102
|
+
* When the change occurred
|
|
103
|
+
*/
|
|
104
|
+
timestamp: Date;
|
|
105
|
+
/**
|
|
106
|
+
* Tool call ID that caused this change (optional)
|
|
107
|
+
*/
|
|
108
|
+
toolCallId?: string;
|
|
109
|
+
/**
|
|
110
|
+
* Additional change details (e.g., line numbers, diffs)
|
|
111
|
+
* Useful for agents that provide inline diff information
|
|
112
|
+
*/
|
|
113
|
+
changes?: {
|
|
114
|
+
linesAdded?: number;
|
|
115
|
+
linesDeleted?: number;
|
|
116
|
+
diff?: string;
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* Agent-specific metadata (e.g., Git integration, review status)
|
|
120
|
+
*/
|
|
121
|
+
metadata?: Record<string, any>;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* ToolCall - Represents a tool invocation and its result
|
|
125
|
+
*/
|
|
126
|
+
export interface ToolCall {
|
|
127
|
+
/**
|
|
128
|
+
* Unique identifier for this tool call
|
|
129
|
+
*/
|
|
130
|
+
id: string;
|
|
131
|
+
/**
|
|
132
|
+
* Name of the tool (e.g., 'Bash', 'Read', 'Write', 'Edit')
|
|
133
|
+
*/
|
|
134
|
+
name: string;
|
|
135
|
+
/**
|
|
136
|
+
* Input parameters passed to the tool
|
|
137
|
+
*/
|
|
138
|
+
input: Record<string, any>;
|
|
139
|
+
/**
|
|
140
|
+
* Current status of the tool call
|
|
141
|
+
*/
|
|
142
|
+
status: ToolCallStatus;
|
|
143
|
+
/**
|
|
144
|
+
* Result from the tool execution (if completed)
|
|
145
|
+
*/
|
|
146
|
+
result?: any;
|
|
147
|
+
/**
|
|
148
|
+
* Error message (if status is 'error')
|
|
149
|
+
*/
|
|
150
|
+
error?: string;
|
|
151
|
+
/**
|
|
152
|
+
* When the tool was invoked
|
|
153
|
+
*/
|
|
154
|
+
timestamp: Date;
|
|
155
|
+
/**
|
|
156
|
+
* When the tool completed (if finished)
|
|
157
|
+
*/
|
|
158
|
+
completedAt?: Date;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* UsageMetrics - Token usage and cost tracking
|
|
162
|
+
*/
|
|
163
|
+
export interface UsageMetrics {
|
|
164
|
+
/**
|
|
165
|
+
* Input tokens consumed
|
|
166
|
+
*/
|
|
167
|
+
inputTokens: number;
|
|
168
|
+
/**
|
|
169
|
+
* Output tokens generated
|
|
170
|
+
*/
|
|
171
|
+
outputTokens: number;
|
|
172
|
+
/**
|
|
173
|
+
* Cache tokens used (optional, for agents that support caching)
|
|
174
|
+
*/
|
|
175
|
+
cacheTokens: number;
|
|
176
|
+
/**
|
|
177
|
+
* Total tokens (input + output)
|
|
178
|
+
*/
|
|
179
|
+
totalTokens: number;
|
|
180
|
+
/**
|
|
181
|
+
* Estimated cost in USD (if available)
|
|
182
|
+
*/
|
|
183
|
+
cost?: number;
|
|
184
|
+
/**
|
|
185
|
+
* Provider/model information for multi-agent scenarios
|
|
186
|
+
*/
|
|
187
|
+
provider?: string;
|
|
188
|
+
model?: string;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* ProcessingMetrics - Aggregate statistics from output processing
|
|
192
|
+
*/
|
|
193
|
+
export interface ProcessingMetrics {
|
|
194
|
+
/**
|
|
195
|
+
* Total number of messages processed
|
|
196
|
+
*/
|
|
197
|
+
totalMessages: number;
|
|
198
|
+
/**
|
|
199
|
+
* All tool calls tracked during execution
|
|
200
|
+
*/
|
|
201
|
+
toolCalls: ToolCall[];
|
|
202
|
+
/**
|
|
203
|
+
* All file changes detected during execution
|
|
204
|
+
*/
|
|
205
|
+
fileChanges: FileChange[];
|
|
206
|
+
/**
|
|
207
|
+
* Token usage and cost metrics
|
|
208
|
+
*/
|
|
209
|
+
usage: UsageMetrics;
|
|
210
|
+
/**
|
|
211
|
+
* Errors encountered during execution
|
|
212
|
+
*/
|
|
213
|
+
errors: Array<{
|
|
214
|
+
message: string;
|
|
215
|
+
timestamp: Date;
|
|
216
|
+
details?: any;
|
|
217
|
+
}>;
|
|
218
|
+
/**
|
|
219
|
+
* When processing started
|
|
220
|
+
*/
|
|
221
|
+
startedAt: Date;
|
|
222
|
+
/**
|
|
223
|
+
* When processing last updated
|
|
224
|
+
*/
|
|
225
|
+
lastUpdate: Date;
|
|
226
|
+
/**
|
|
227
|
+
* When processing ended (if finished)
|
|
228
|
+
*/
|
|
229
|
+
endedAt?: Date;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* ExecutionSummary - High-level summary of execution
|
|
233
|
+
*
|
|
234
|
+
* Provides an aggregate view of the execution including counts,
|
|
235
|
+
* success rates, and cost information. Useful for dashboards and reporting.
|
|
236
|
+
*/
|
|
237
|
+
export interface ExecutionSummary {
|
|
238
|
+
/**
|
|
239
|
+
* Total number of messages processed
|
|
240
|
+
*/
|
|
241
|
+
totalMessages: number;
|
|
242
|
+
/**
|
|
243
|
+
* Tool call counts grouped by tool name
|
|
244
|
+
* Example: { "Bash": 5, "Read": 3, "Write": 2 }
|
|
245
|
+
*/
|
|
246
|
+
toolCallsByType: Record<string, number>;
|
|
247
|
+
/**
|
|
248
|
+
* File operation counts grouped by operation type
|
|
249
|
+
* Example: { "read": 3, "write": 2, "edit": 1 }
|
|
250
|
+
*/
|
|
251
|
+
fileOperationsByType: Record<string, number>;
|
|
252
|
+
/**
|
|
253
|
+
* Success rate of tool calls (percentage 0-100)
|
|
254
|
+
*/
|
|
255
|
+
successRate: number;
|
|
256
|
+
/**
|
|
257
|
+
* Total tokens used
|
|
258
|
+
*/
|
|
259
|
+
totalTokens: {
|
|
260
|
+
input: number;
|
|
261
|
+
output: number;
|
|
262
|
+
cache: number;
|
|
263
|
+
};
|
|
264
|
+
/**
|
|
265
|
+
* Total cost in USD
|
|
266
|
+
*/
|
|
267
|
+
totalCost: number;
|
|
268
|
+
/**
|
|
269
|
+
* Processing duration in milliseconds
|
|
270
|
+
*/
|
|
271
|
+
duration: number;
|
|
272
|
+
/**
|
|
273
|
+
* When processing started
|
|
274
|
+
*/
|
|
275
|
+
startTime: Date;
|
|
276
|
+
/**
|
|
277
|
+
* When processing ended (if finished)
|
|
278
|
+
*/
|
|
279
|
+
endTime?: Date;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* ToolCallHandler - Callback invoked when a tool is called
|
|
283
|
+
*/
|
|
284
|
+
export type ToolCallHandler = (toolCall: ToolCall) => void;
|
|
285
|
+
/**
|
|
286
|
+
* FileChangeHandler - Callback invoked when a file is changed
|
|
287
|
+
*/
|
|
288
|
+
export type FileChangeHandler = (change: FileChange) => void;
|
|
289
|
+
/**
|
|
290
|
+
* ProgressHandler - Callback invoked when metrics are updated
|
|
291
|
+
*/
|
|
292
|
+
export type ProgressHandler = (metrics: ProcessingMetrics) => void;
|
|
293
|
+
/**
|
|
294
|
+
* ErrorHandler - Callback invoked when an error occurs
|
|
295
|
+
*/
|
|
296
|
+
export type ErrorHandler = (error: {
|
|
297
|
+
message: string;
|
|
298
|
+
timestamp: Date;
|
|
299
|
+
details?: any;
|
|
300
|
+
}) => void;
|
|
301
|
+
/**
|
|
302
|
+
* MessageHandler - Callback invoked when a text message is received
|
|
303
|
+
*/
|
|
304
|
+
export type MessageHandler = (message: OutputMessage) => void;
|
|
305
|
+
/**
|
|
306
|
+
* UsageHandler - Callback invoked when usage metrics are updated
|
|
307
|
+
*/
|
|
308
|
+
export type UsageHandler = (usage: UsageMetrics) => void;
|
|
309
|
+
/**
|
|
310
|
+
* IOutputProcessor - Interface for output processing implementations
|
|
311
|
+
*
|
|
312
|
+
* Defines the contract for parsing coding agent output in real-time,
|
|
313
|
+
* extracting structured data, and providing event-driven updates.
|
|
314
|
+
*
|
|
315
|
+
* Current implementations focus on Claude Code's stream-json format,
|
|
316
|
+
* but the interface is designed to support future agent adapters.
|
|
317
|
+
*/
|
|
318
|
+
export interface IOutputProcessor {
|
|
319
|
+
/**
|
|
320
|
+
* Process a single line of output
|
|
321
|
+
*
|
|
322
|
+
* The format depends on the agent (stream-json, JSON, text, etc.)
|
|
323
|
+
*
|
|
324
|
+
* @param line - Raw output line from the agent
|
|
325
|
+
* @returns Promise that resolves when line is processed
|
|
326
|
+
*/
|
|
327
|
+
processLine(line: string): Promise<void>;
|
|
328
|
+
/**
|
|
329
|
+
* Get current processing metrics
|
|
330
|
+
*
|
|
331
|
+
* @returns Current aggregate metrics
|
|
332
|
+
*/
|
|
333
|
+
getMetrics(): ProcessingMetrics;
|
|
334
|
+
/**
|
|
335
|
+
* Get all tool calls recorded during processing
|
|
336
|
+
*
|
|
337
|
+
* @returns Array of all tool calls
|
|
338
|
+
*/
|
|
339
|
+
getToolCalls(): ToolCall[];
|
|
340
|
+
/**
|
|
341
|
+
* Get all file changes detected during processing
|
|
342
|
+
*
|
|
343
|
+
* @returns Array of all file changes
|
|
344
|
+
*/
|
|
345
|
+
getFileChanges(): FileChange[];
|
|
346
|
+
/**
|
|
347
|
+
* Register a callback for tool call events
|
|
348
|
+
*
|
|
349
|
+
* @param handler - Function to call when a tool is invoked
|
|
350
|
+
*/
|
|
351
|
+
onToolCall(handler: ToolCallHandler): void;
|
|
352
|
+
/**
|
|
353
|
+
* Register a callback for file change events
|
|
354
|
+
*
|
|
355
|
+
* @param handler - Function to call when a file is modified
|
|
356
|
+
*/
|
|
357
|
+
onFileChange(handler: FileChangeHandler): void;
|
|
358
|
+
/**
|
|
359
|
+
* Register a callback for progress update events
|
|
360
|
+
*
|
|
361
|
+
* @param handler - Function to call when metrics are updated
|
|
362
|
+
*/
|
|
363
|
+
onProgress(handler: ProgressHandler): void;
|
|
364
|
+
/**
|
|
365
|
+
* Register a callback for error events
|
|
366
|
+
*
|
|
367
|
+
* @param handler - Function to call when an error occurs
|
|
368
|
+
*/
|
|
369
|
+
onError(handler: ErrorHandler): void;
|
|
370
|
+
/**
|
|
371
|
+
* Register a callback for message events
|
|
372
|
+
*
|
|
373
|
+
* @param handler - Function to call when a text message is received
|
|
374
|
+
*/
|
|
375
|
+
onMessage(handler: MessageHandler): void;
|
|
376
|
+
/**
|
|
377
|
+
* Register a callback for usage metric updates
|
|
378
|
+
*
|
|
379
|
+
* @param handler - Function to call when usage metrics are updated
|
|
380
|
+
*/
|
|
381
|
+
onUsage(handler: UsageHandler): void;
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* IAgentAdapter - Interface for agent-specific output parsing
|
|
385
|
+
*
|
|
386
|
+
* This interface is the extension point for supporting multiple coding agents.
|
|
387
|
+
* Each agent (Claude Code, Aider, Gemini, Codex) can have its own adapter
|
|
388
|
+
* that translates agent-specific output to OutputMessage[].
|
|
389
|
+
*
|
|
390
|
+
* Future implementation will move agent-specific parsing logic into adapters,
|
|
391
|
+
* keeping the core IOutputProcessor implementation agent-agnostic.
|
|
392
|
+
*
|
|
393
|
+
* @example
|
|
394
|
+
* ```typescript
|
|
395
|
+
* class ClaudeCodeAdapter implements IAgentAdapter {
|
|
396
|
+
* name = 'claude-code';
|
|
397
|
+
* parse(line: string): OutputMessage[] {
|
|
398
|
+
* // Parse Claude's stream-json format
|
|
399
|
+
* }
|
|
400
|
+
* }
|
|
401
|
+
* ```
|
|
402
|
+
*/
|
|
403
|
+
export interface IAgentAdapter {
|
|
404
|
+
/**
|
|
405
|
+
* Unique identifier for this agent
|
|
406
|
+
* Examples: 'claude-code', 'aider', 'gemini-code-assist', 'codex-cli'
|
|
407
|
+
*/
|
|
408
|
+
readonly name: string;
|
|
409
|
+
/**
|
|
410
|
+
* Parse a line of agent output into structured messages
|
|
411
|
+
*
|
|
412
|
+
* @param line - Raw output line from the agent
|
|
413
|
+
* @returns Array of parsed messages (may be empty for unparseable lines)
|
|
414
|
+
*/
|
|
415
|
+
parse(line: string): OutputMessage[];
|
|
416
|
+
}
|
|
417
|
+
/**
|
|
418
|
+
* Default usage metrics (empty state)
|
|
419
|
+
*/
|
|
420
|
+
export declare const DEFAULT_USAGE_METRICS: UsageMetrics;
|
|
421
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/execution/output/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH;;;;;GAKG;AACH,MAAM,MAAM,WAAW,GACnB,MAAM,GACN,UAAU,GACV,aAAa,GACb,OAAO,GACP,OAAO,GACP,SAAS,CAAC;AAEd;;;;;;;;;GASG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAE5E;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;AAE7D;;;;;;;;GAQG;AACH,MAAM,MAAM,aAAa,GACrB;IACE,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;IAChB,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAChC,GACD;IACE,IAAI,EAAE,UAAU,CAAC;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,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EG;AACH,eAAO,MAAM,qBAAqB,EAAE,YAMnC,CAAC"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude Code Configuration Builder
|
|
3
|
+
*
|
|
4
|
+
* Utility for building ProcessConfig specific to Claude Code CLI.
|
|
5
|
+
* Provides type-safe configuration for Claude Code's flags and options.
|
|
6
|
+
*
|
|
7
|
+
* @module execution/process/builders/claude
|
|
8
|
+
*/
|
|
9
|
+
import type { ProcessConfig } from '../types.js';
|
|
10
|
+
/**
|
|
11
|
+
* Configuration options specific to Claude Code CLI
|
|
12
|
+
*/
|
|
13
|
+
export interface ClaudeCodeConfig {
|
|
14
|
+
/**
|
|
15
|
+
* Path to Claude Code CLI executable
|
|
16
|
+
* @default 'claude'
|
|
17
|
+
*/
|
|
18
|
+
claudePath?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Working directory for the process
|
|
21
|
+
*/
|
|
22
|
+
workDir: string;
|
|
23
|
+
/**
|
|
24
|
+
* Run in non-interactive print mode
|
|
25
|
+
* @default false
|
|
26
|
+
*/
|
|
27
|
+
print?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Output format (stream-json recommended for parsing)
|
|
30
|
+
* @default 'text'
|
|
31
|
+
*/
|
|
32
|
+
outputFormat?: 'stream-json' | 'json' | 'text';
|
|
33
|
+
/**
|
|
34
|
+
* Enable verbose output (required for stream-json with print mode)
|
|
35
|
+
* @default false
|
|
36
|
+
*/
|
|
37
|
+
verbose?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Skip permission prompts
|
|
40
|
+
* @default false
|
|
41
|
+
*/
|
|
42
|
+
dangerouslySkipPermissions?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Permission mode setting
|
|
45
|
+
*/
|
|
46
|
+
permissionMode?: string;
|
|
47
|
+
/**
|
|
48
|
+
* Environment variables to pass to the process
|
|
49
|
+
*/
|
|
50
|
+
env?: Record<string, string>;
|
|
51
|
+
/**
|
|
52
|
+
* Maximum execution time in milliseconds
|
|
53
|
+
*/
|
|
54
|
+
timeout?: number;
|
|
55
|
+
/**
|
|
56
|
+
* Maximum idle time before cleanup (pool only)
|
|
57
|
+
*/
|
|
58
|
+
idleTimeout?: number;
|
|
59
|
+
/**
|
|
60
|
+
* Retry configuration for failed spawns
|
|
61
|
+
*/
|
|
62
|
+
retry?: {
|
|
63
|
+
maxAttempts: number;
|
|
64
|
+
backoffMs: number;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Build a generic ProcessConfig from Claude Code specific configuration
|
|
69
|
+
*
|
|
70
|
+
* @param config - Claude Code specific configuration
|
|
71
|
+
* @returns Generic ProcessConfig that can be used with any ProcessManager
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```typescript
|
|
75
|
+
* const config = buildClaudeConfig({
|
|
76
|
+
* workDir: '/path/to/project',
|
|
77
|
+
* print: true,
|
|
78
|
+
* outputFormat: 'stream-json',
|
|
79
|
+
* dangerouslySkipPermissions: true,
|
|
80
|
+
* });
|
|
81
|
+
*
|
|
82
|
+
* const process = await manager.acquireProcess(config);
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
export declare function buildClaudeConfig(config: ClaudeCodeConfig): ProcessConfig;
|
|
86
|
+
//# sourceMappingURL=claude.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claude.d.ts","sourceRoot":"","sources":["../../../../src/execution/process/builders/claude.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB;;;OAGG;IACH,YAAY,CAAC,EAAE,aAAa,GAAG,MAAM,GAAG,MAAM,CAAC;IAE/C;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;;OAGG;IACH,0BAA0B,CAAC,EAAE,OAAO,CAAC;IAErC;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAE7B;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,KAAK,CAAC,EAAE;QACN,WAAW,EAAE,MAAM,CAAC;QACpB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;CACH;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,gBAAgB,GAAG,aAAa,CAqCzE"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Process Layer - Public API
|
|
3
|
+
*
|
|
4
|
+
* Barrel export for the Process Layer (Layer 1) of the execution system.
|
|
5
|
+
* Exports all public types, interfaces, and implementations.
|
|
6
|
+
*
|
|
7
|
+
* @module execution/process
|
|
8
|
+
*/
|
|
9
|
+
export type { ProcessStatus, ProcessConfig, ManagedProcess, OutputHandler, ErrorHandler, ProcessMetrics, } from './types.js';
|
|
10
|
+
export type { IProcessManager } from './manager.js';
|
|
11
|
+
export { SimpleProcessManager } from './simple-manager.js';
|
|
12
|
+
export { generateId, formatDuration, isValidSignal, formatProcessError, } from './utils.js';
|
|
13
|
+
export { buildClaudeConfig } from './builders/claude.js';
|
|
14
|
+
export type { ClaudeCodeConfig } from './builders/claude.js';
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/execution/process/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,YAAY,EACV,aAAa,EACb,aAAa,EACb,cAAc,EACd,aAAa,EACb,YAAY,EACZ,cAAc,GACf,MAAM,YAAY,CAAC;AAGpB,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAGpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAG3D,OAAO,EACL,UAAU,EACV,cAAc,EACd,aAAa,EACb,kBAAkB,GACnB,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,YAAY,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Process Manager Interface
|
|
3
|
+
*
|
|
4
|
+
* Defines the contract for all process managers in the Process Layer.
|
|
5
|
+
* Process managers handle spawning, monitoring, and terminating Claude Code processes.
|
|
6
|
+
*
|
|
7
|
+
* @module execution/process/manager
|
|
8
|
+
*/
|
|
9
|
+
import type { ManagedProcess, ProcessConfig, ProcessMetrics, OutputHandler, ErrorHandler } from './types.js';
|
|
10
|
+
/**
|
|
11
|
+
* Core abstraction for managing Claude Code CLI processes
|
|
12
|
+
*
|
|
13
|
+
* This interface defines the contract that all process manager implementations
|
|
14
|
+
* must follow. It provides methods for:
|
|
15
|
+
* - Process lifecycle management (acquire, release, terminate)
|
|
16
|
+
* - Process communication (I/O)
|
|
17
|
+
* - Monitoring and metrics
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* const manager: IProcessManager = new SimpleProcessManager();
|
|
22
|
+
* const process = await manager.acquireProcess({
|
|
23
|
+
* claudePath: 'claude',
|
|
24
|
+
* workDir: '/path/to/project',
|
|
25
|
+
* args: {
|
|
26
|
+
* print: true,
|
|
27
|
+
* outputFormat: 'stream-json',
|
|
28
|
+
* dangerouslySkipPermissions: true,
|
|
29
|
+
* },
|
|
30
|
+
* });
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export interface IProcessManager {
|
|
34
|
+
/**
|
|
35
|
+
* Acquire a new Claude Code process
|
|
36
|
+
*
|
|
37
|
+
* Spawns a new process with the given configuration and returns a managed
|
|
38
|
+
* process handle. The process will be tracked until it exits or is terminated.
|
|
39
|
+
*
|
|
40
|
+
* @param config - Configuration for the process
|
|
41
|
+
* @returns Promise resolving to the managed process
|
|
42
|
+
* @throws Error if process fails to spawn
|
|
43
|
+
*/
|
|
44
|
+
acquireProcess(config: ProcessConfig): Promise<ManagedProcess>;
|
|
45
|
+
/**
|
|
46
|
+
* Release a process (terminate it gracefully)
|
|
47
|
+
*
|
|
48
|
+
* Sends SIGTERM to the process and waits for it to exit. If it doesn't exit
|
|
49
|
+
* within a grace period, SIGKILL is sent.
|
|
50
|
+
*
|
|
51
|
+
* @param processId - ID of the process to release
|
|
52
|
+
* @returns Promise that resolves when process is terminated
|
|
53
|
+
*/
|
|
54
|
+
releaseProcess(processId: string): Promise<void>;
|
|
55
|
+
/**
|
|
56
|
+
* Terminate a process with a specific signal
|
|
57
|
+
*
|
|
58
|
+
* Sends the specified signal to the process. Uses graceful shutdown with
|
|
59
|
+
* SIGTERM by default, followed by SIGKILL if needed.
|
|
60
|
+
*
|
|
61
|
+
* @param processId - ID of the process to terminate
|
|
62
|
+
* @param signal - Signal to send (defaults to SIGTERM)
|
|
63
|
+
* @returns Promise that resolves when process is terminated
|
|
64
|
+
*/
|
|
65
|
+
terminateProcess(processId: string, signal?: NodeJS.Signals): Promise<void>;
|
|
66
|
+
/**
|
|
67
|
+
* Send input to a process's stdin
|
|
68
|
+
*
|
|
69
|
+
* @param processId - ID of the process
|
|
70
|
+
* @param input - Input string to send
|
|
71
|
+
* @returns Promise that resolves when input is written
|
|
72
|
+
* @throws Error if process is not found
|
|
73
|
+
*/
|
|
74
|
+
sendInput(processId: string, input: string): Promise<void>;
|
|
75
|
+
/**
|
|
76
|
+
* Close stdin stream for a process
|
|
77
|
+
*
|
|
78
|
+
* Signals EOF to the process. This is useful for programs like Claude Code
|
|
79
|
+
* in --print mode that wait for stdin to close before processing input.
|
|
80
|
+
*
|
|
81
|
+
* @param processId - ID of the process
|
|
82
|
+
* @throws Error if process is not found
|
|
83
|
+
*/
|
|
84
|
+
closeInput(processId: string): void;
|
|
85
|
+
/**
|
|
86
|
+
* Register a handler for process output (stdout/stderr)
|
|
87
|
+
*
|
|
88
|
+
* The handler will be called whenever the process produces output.
|
|
89
|
+
* Multiple handlers can be registered for the same process.
|
|
90
|
+
*
|
|
91
|
+
* @param processId - ID of the process
|
|
92
|
+
* @param handler - Handler function to call on output
|
|
93
|
+
*/
|
|
94
|
+
onOutput(processId: string, handler: OutputHandler): void;
|
|
95
|
+
/**
|
|
96
|
+
* Register a handler for process errors
|
|
97
|
+
*
|
|
98
|
+
* The handler will be called when the process encounters an error.
|
|
99
|
+
*
|
|
100
|
+
* @param processId - ID of the process
|
|
101
|
+
* @param handler - Handler function to call on error
|
|
102
|
+
*/
|
|
103
|
+
onError(processId: string, handler: ErrorHandler): void;
|
|
104
|
+
/**
|
|
105
|
+
* Get a managed process by ID
|
|
106
|
+
*
|
|
107
|
+
* @param processId - ID of the process
|
|
108
|
+
* @returns The managed process or null if not found
|
|
109
|
+
*/
|
|
110
|
+
getProcess(processId: string): ManagedProcess | null;
|
|
111
|
+
/**
|
|
112
|
+
* Get all currently active processes
|
|
113
|
+
*
|
|
114
|
+
* @returns Array of all active managed processes
|
|
115
|
+
*/
|
|
116
|
+
getActiveProcesses(): ManagedProcess[];
|
|
117
|
+
/**
|
|
118
|
+
* Get aggregate metrics for all processes
|
|
119
|
+
*
|
|
120
|
+
* @returns Process metrics summary
|
|
121
|
+
*/
|
|
122
|
+
getMetrics(): ProcessMetrics;
|
|
123
|
+
/**
|
|
124
|
+
* Shutdown the process manager
|
|
125
|
+
*
|
|
126
|
+
* Terminates all active processes and cleans up resources.
|
|
127
|
+
* This should be called before the application exits.
|
|
128
|
+
*
|
|
129
|
+
* @returns Promise that resolves when all processes are terminated
|
|
130
|
+
*/
|
|
131
|
+
shutdown(): Promise<void>;
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../../src/execution/process/manager.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACb,cAAc,EACd,aAAa,EACb,YAAY,EACb,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,WAAW,eAAe;IAK9B;;;;;;;;;OASG;IACH,cAAc,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IAE/D;;;;;;;;OAQG;IACH,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjD;;;;;;;;;OASG;IACH,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAM5E;;;;;;;OAOG;IACH,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE3D;;;;;;;;OAQG;IACH,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAEpC;;;;;;;;OAQG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,GAAG,IAAI,CAAC;IAE1D;;;;;;;OAOG;IACH,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,GAAG,IAAI,CAAC;IAMxD;;;;;OAKG;IACH,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI,CAAC;IAErD;;;;OAIG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