@sudocode-ai/local-server 0.1.6 → 0.1.7

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 (116) hide show
  1. package/dist/execution/process/builders/claude.d.ts +1 -1
  2. package/dist/execution/process/builders/claude.d.ts.map +1 -1
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +70 -11
  5. package/dist/index.js.map +1 -1
  6. package/dist/public/assets/index-B3SEMufD.js +580 -0
  7. package/dist/public/assets/{index-BvlblDHK.js.map → index-B3SEMufD.js.map} +1 -1
  8. package/dist/public/assets/index-D2YGL3gX.css +1 -0
  9. package/dist/public/index.html +2 -2
  10. package/dist/routes/feedback.d.ts.map +1 -1
  11. package/dist/routes/feedback.js +20 -12
  12. package/dist/routes/feedback.js.map +1 -1
  13. package/dist/services/db.d.ts.map +1 -1
  14. package/dist/services/db.js +19 -14
  15. package/dist/services/db.js.map +1 -1
  16. package/dist/services/execution-service.d.ts.map +1 -1
  17. package/dist/services/execution-service.js +43 -22
  18. package/dist/services/execution-service.js.map +1 -1
  19. package/dist/services/executions.d.ts.map +1 -1
  20. package/dist/services/executions.js +15 -0
  21. package/dist/services/executions.js.map +1 -1
  22. package/dist/services/feedback.d.ts +16 -0
  23. package/dist/services/feedback.d.ts.map +1 -1
  24. package/dist/services/feedback.js +25 -1
  25. package/dist/services/feedback.js.map +1 -1
  26. package/dist/services/repo-info.d.ts +17 -0
  27. package/dist/services/repo-info.d.ts.map +1 -0
  28. package/dist/services/repo-info.js +53 -0
  29. package/dist/services/repo-info.js.map +1 -0
  30. package/dist/services/websocket.d.ts +25 -3
  31. package/dist/services/websocket.d.ts.map +1 -1
  32. package/dist/services/websocket.js +71 -7
  33. package/dist/services/websocket.js.map +1 -1
  34. package/package.json +4 -3
  35. package/dist/execution/engine/engine.d.ts +0 -103
  36. package/dist/execution/engine/engine.d.ts.map +0 -1
  37. package/dist/execution/engine/engine.js +0 -10
  38. package/dist/execution/engine/engine.js.map +0 -1
  39. package/dist/execution/engine/simple-engine.d.ts +0 -190
  40. package/dist/execution/engine/simple-engine.d.ts.map +0 -1
  41. package/dist/execution/engine/simple-engine.js +0 -611
  42. package/dist/execution/engine/simple-engine.js.map +0 -1
  43. package/dist/execution/engine/types.d.ts +0 -116
  44. package/dist/execution/engine/types.d.ts.map +0 -1
  45. package/dist/execution/engine/types.js +0 -10
  46. package/dist/execution/engine/types.js.map +0 -1
  47. package/dist/execution/process/index.d.ts +0 -15
  48. package/dist/execution/process/index.d.ts.map +0 -1
  49. package/dist/execution/process/index.js +0 -15
  50. package/dist/execution/process/index.js.map +0 -1
  51. package/dist/execution/process/manager.d.ts +0 -133
  52. package/dist/execution/process/manager.d.ts.map +0 -1
  53. package/dist/execution/process/manager.js +0 -10
  54. package/dist/execution/process/manager.js.map +0 -1
  55. package/dist/execution/process/simple-manager.d.ts +0 -102
  56. package/dist/execution/process/simple-manager.d.ts.map +0 -1
  57. package/dist/execution/process/simple-manager.js +0 -336
  58. package/dist/execution/process/simple-manager.js.map +0 -1
  59. package/dist/execution/process/types.d.ts +0 -105
  60. package/dist/execution/process/types.d.ts.map +0 -1
  61. package/dist/execution/process/types.js +0 -10
  62. package/dist/execution/process/types.js.map +0 -1
  63. package/dist/execution/process/utils.d.ts +0 -53
  64. package/dist/execution/process/utils.d.ts.map +0 -1
  65. package/dist/execution/process/utils.js +0 -97
  66. package/dist/execution/process/utils.js.map +0 -1
  67. package/dist/execution/resilience/circuit-breaker.d.ts +0 -170
  68. package/dist/execution/resilience/circuit-breaker.d.ts.map +0 -1
  69. package/dist/execution/resilience/circuit-breaker.js +0 -291
  70. package/dist/execution/resilience/circuit-breaker.js.map +0 -1
  71. package/dist/execution/resilience/executor.d.ts +0 -109
  72. package/dist/execution/resilience/executor.d.ts.map +0 -1
  73. package/dist/execution/resilience/executor.js +0 -10
  74. package/dist/execution/resilience/executor.js.map +0 -1
  75. package/dist/execution/resilience/index.d.ts +0 -14
  76. package/dist/execution/resilience/index.d.ts.map +0 -1
  77. package/dist/execution/resilience/index.js +0 -15
  78. package/dist/execution/resilience/index.js.map +0 -1
  79. package/dist/execution/resilience/resilient-executor.d.ts +0 -86
  80. package/dist/execution/resilience/resilient-executor.d.ts.map +0 -1
  81. package/dist/execution/resilience/resilient-executor.js +0 -261
  82. package/dist/execution/resilience/resilient-executor.js.map +0 -1
  83. package/dist/execution/resilience/retry.d.ts +0 -161
  84. package/dist/execution/resilience/retry.d.ts.map +0 -1
  85. package/dist/execution/resilience/retry.js +0 -234
  86. package/dist/execution/resilience/retry.js.map +0 -1
  87. package/dist/execution/resilience/types.d.ts +0 -226
  88. package/dist/execution/resilience/types.d.ts.map +0 -1
  89. package/dist/execution/resilience/types.js +0 -30
  90. package/dist/execution/resilience/types.js.map +0 -1
  91. package/dist/execution/workflow/index.d.ts +0 -13
  92. package/dist/execution/workflow/index.d.ts.map +0 -1
  93. package/dist/execution/workflow/index.js +0 -13
  94. package/dist/execution/workflow/index.js.map +0 -1
  95. package/dist/execution/workflow/linear-orchestrator.d.ts +0 -216
  96. package/dist/execution/workflow/linear-orchestrator.d.ts.map +0 -1
  97. package/dist/execution/workflow/linear-orchestrator.js +0 -683
  98. package/dist/execution/workflow/linear-orchestrator.js.map +0 -1
  99. package/dist/execution/workflow/memory-storage.d.ts +0 -54
  100. package/dist/execution/workflow/memory-storage.d.ts.map +0 -1
  101. package/dist/execution/workflow/memory-storage.js +0 -68
  102. package/dist/execution/workflow/memory-storage.js.map +0 -1
  103. package/dist/execution/workflow/orchestrator.d.ts +0 -158
  104. package/dist/execution/workflow/orchestrator.d.ts.map +0 -1
  105. package/dist/execution/workflow/orchestrator.js +0 -9
  106. package/dist/execution/workflow/orchestrator.js.map +0 -1
  107. package/dist/execution/workflow/types.d.ts +0 -172
  108. package/dist/execution/workflow/types.d.ts.map +0 -1
  109. package/dist/execution/workflow/types.js +0 -9
  110. package/dist/execution/workflow/types.js.map +0 -1
  111. package/dist/execution/workflow/utils.d.ts +0 -89
  112. package/dist/execution/workflow/utils.d.ts.map +0 -1
  113. package/dist/execution/workflow/utils.js +0 -152
  114. package/dist/execution/workflow/utils.js.map +0 -1
  115. package/dist/public/assets/index-BvlblDHK.js +0 -570
  116. package/dist/public/assets/index-BwuKdLgN.css +0 -1
@@ -1,336 +0,0 @@
1
- /**
2
- * Simple Process Manager Implementation
3
- *
4
- * A straightforward implementation of IProcessManager that spawns a fresh
5
- * process for each task. This is the "simple first" approach that will later
6
- * be upgraded to support process pooling.
7
- *
8
- * Supports any CLI tool/agent (Claude Code, Codex, Gemini CLI, etc.)
9
- *
10
- * Key features:
11
- * - One process per task (no pooling)
12
- * - Event-based I/O streaming
13
- * - Graceful termination (SIGTERM → SIGKILL)
14
- * - Automatic cleanup
15
- * - Metrics tracking
16
- * - Agent-agnostic design
17
- *
18
- * @module execution/process/simple-manager
19
- */
20
- import { spawn } from "child_process";
21
- import { generateId } from "./utils.js";
22
- /**
23
- * Simple process manager that spawns one process per task
24
- *
25
- * This implementation follows the "simple first" principle - it provides
26
- * a production-ready process manager without the complexity of pooling.
27
- *
28
- * Works with any CLI tool/agent by accepting executable path and args.
29
- *
30
- * @example
31
- * ```typescript
32
- * // Claude Code example
33
- * const manager = new SimpleProcessManager({
34
- * executablePath: 'claude',
35
- * args: ['--print', '--output-format', 'stream-json'],
36
- * });
37
- *
38
- * const process = await manager.acquireProcess({
39
- * executablePath: 'claude',
40
- * args: ['--print', '--output-format', 'stream-json'],
41
- * workDir: '/path/to/project',
42
- * timeout: 300000,
43
- * });
44
- *
45
- * // Codex example
46
- * const codexProcess = await manager.acquireProcess({
47
- * executablePath: 'codex',
48
- * args: ['--mode', 'agent', '--json'],
49
- * workDir: '/path/to/project',
50
- * });
51
- * ```
52
- */
53
- export class SimpleProcessManager {
54
- _defaultConfig;
55
- _activeProcesses = new Map();
56
- _cleanupTimers = new Map();
57
- _metrics = {
58
- totalSpawned: 0,
59
- currentlyActive: 0,
60
- totalCompleted: 0,
61
- totalFailed: 0,
62
- averageDuration: 0,
63
- };
64
- /**
65
- * Create a new SimpleProcessManager
66
- *
67
- * @param defaultConfig - Default configuration to merge with per-process config
68
- */
69
- constructor(_defaultConfig = {}) {
70
- this._defaultConfig = _defaultConfig;
71
- }
72
- async acquireProcess(config) {
73
- // Merge with default config
74
- const mergedConfig = { ...this._defaultConfig, ...config };
75
- // Spawn the process
76
- const childProcess = this.spawnProcess(mergedConfig);
77
- // Validate process spawned successfully
78
- if (!childProcess.pid) {
79
- // Suppress error event to prevent uncaughtException
80
- childProcess.once("error", () => {
81
- // Error is expected when process fails to spawn
82
- });
83
- throw new Error("Failed to spawn process: no PID assigned");
84
- }
85
- // Generate unique ID for this process
86
- const id = generateId("process");
87
- // Create managed process object
88
- const managedProcess = {
89
- id,
90
- pid: childProcess.pid,
91
- status: "busy",
92
- spawnedAt: new Date(),
93
- lastActivity: new Date(),
94
- exitCode: null,
95
- signal: null,
96
- process: childProcess,
97
- streams: {
98
- stdout: childProcess.stdout,
99
- stderr: childProcess.stderr,
100
- stdin: childProcess.stdin,
101
- },
102
- metrics: {
103
- totalDuration: 0,
104
- tasksCompleted: 0,
105
- successRate: 1.0,
106
- },
107
- };
108
- // Track the process
109
- this._activeProcesses.set(id, managedProcess);
110
- // Update metrics
111
- this._metrics.totalSpawned++;
112
- this._metrics.currentlyActive++;
113
- // Set up event handlers for lifecycle management
114
- this.setupProcessHandlers(managedProcess, mergedConfig);
115
- return managedProcess;
116
- }
117
- /**
118
- * Spawn a process with the given configuration
119
- *
120
- * @param config - Process configuration
121
- * @returns ChildProcess instance
122
- */
123
- spawnProcess(config) {
124
- const childProcess = spawn(config.executablePath, config.args, {
125
- cwd: config.workDir,
126
- stdio: ["pipe", "pipe", "pipe"],
127
- env: {
128
- ...process.env,
129
- ...config.env,
130
- },
131
- });
132
- return childProcess;
133
- }
134
- /**
135
- * Set up event handlers for a managed process
136
- *
137
- * Handles lifecycle events:
138
- * - exit: Process terminated normally or abnormally
139
- * - error: Process encountered an error
140
- * - stdout/stderr data: Track activity for idle detection
141
- *
142
- * @param managedProcess - The managed process to set up handlers for
143
- * @param config - Process configuration (for timeout)
144
- */
145
- setupProcessHandlers(managedProcess, config) {
146
- const { process: childProcess, id } = managedProcess;
147
- let timeoutHandle = null;
148
- // Set up timeout if configured
149
- if (config.timeout) {
150
- timeoutHandle = setTimeout(() => {
151
- // Terminate process on timeout using graceful termination
152
- if (managedProcess.status === "busy") {
153
- this.terminateProcess(id).catch(() => {
154
- // Ignore errors during timeout termination
155
- });
156
- }
157
- }, config.timeout);
158
- }
159
- // Exit event handler
160
- childProcess.once("exit", (code, signal) => {
161
- // Clear timeout
162
- if (timeoutHandle) {
163
- clearTimeout(timeoutHandle);
164
- }
165
- // Update process state
166
- managedProcess.exitCode = code;
167
- managedProcess.signal = signal;
168
- managedProcess.status = code === 0 ? "completed" : "crashed";
169
- // Calculate duration
170
- const duration = Date.now() - managedProcess.spawnedAt.getTime();
171
- managedProcess.metrics.totalDuration = duration;
172
- // Update global metrics
173
- this._metrics.currentlyActive--;
174
- if (code === 0) {
175
- this._metrics.totalCompleted++;
176
- }
177
- else {
178
- this._metrics.totalFailed++;
179
- }
180
- // Calculate average duration
181
- const totalProcesses = this._metrics.totalCompleted + this._metrics.totalFailed;
182
- if (totalProcesses > 0) {
183
- const currentTotal = this._metrics.averageDuration * (totalProcesses - 1);
184
- this._metrics.averageDuration =
185
- (currentTotal + duration) / totalProcesses;
186
- }
187
- // Clean up stdio streams to prevent event loop hang
188
- managedProcess.streams.stdin.destroy();
189
- managedProcess.streams.stdout.destroy();
190
- managedProcess.streams.stderr.destroy();
191
- // Schedule cleanup (delete from activeProcesses after 5s delay)
192
- const cleanupTimer = setTimeout(() => {
193
- this._activeProcesses.delete(id);
194
- this._cleanupTimers.delete(id);
195
- }, 5000);
196
- this._cleanupTimers.set(id, cleanupTimer);
197
- });
198
- // Error event handler
199
- childProcess.once("error", (error) => {
200
- void error; // Error is logged but not used here
201
- // Clear timeout
202
- if (timeoutHandle) {
203
- clearTimeout(timeoutHandle);
204
- }
205
- // Update process state
206
- managedProcess.status = "crashed";
207
- // Update global metrics
208
- this._metrics.currentlyActive--;
209
- this._metrics.totalFailed++;
210
- });
211
- // stdout data handler - track activity
212
- childProcess.stdout?.on("data", () => {
213
- managedProcess.lastActivity = new Date();
214
- });
215
- // stderr data handler - track activity
216
- childProcess.stderr?.on("data", () => {
217
- managedProcess.lastActivity = new Date();
218
- });
219
- }
220
- async releaseProcess(processId) {
221
- await this.terminateProcess(processId);
222
- }
223
- async terminateProcess(processId, signal = "SIGTERM") {
224
- const managed = this._activeProcesses.get(processId);
225
- if (!managed) {
226
- return; // Process not found, nothing to terminate
227
- }
228
- // If already terminated, do nothing (idempotent)
229
- if (managed.exitCode !== null) {
230
- return;
231
- }
232
- // Update status to terminating
233
- managed.status = "terminating";
234
- // Try graceful shutdown first
235
- managed.process.kill(signal);
236
- // Wait for process to exit (with 2 second timeout)
237
- const exitPromise = new Promise((resolve) => {
238
- if (managed.exitCode !== null) {
239
- resolve();
240
- }
241
- else {
242
- managed.process.once("exit", () => resolve());
243
- }
244
- });
245
- const timeoutPromise = new Promise((resolve) => {
246
- setTimeout(resolve, 2000);
247
- });
248
- await Promise.race([exitPromise, timeoutPromise]);
249
- // Force kill if still running
250
- if (managed.exitCode === null) {
251
- managed.process.kill("SIGKILL");
252
- // Wait for SIGKILL to take effect (with timeout)
253
- await Promise.race([
254
- new Promise((resolve) => {
255
- if (managed.exitCode !== null) {
256
- resolve();
257
- }
258
- else {
259
- managed.process.once("exit", () => resolve());
260
- }
261
- }),
262
- new Promise((resolve) => setTimeout(resolve, 1000)),
263
- ]);
264
- }
265
- }
266
- async sendInput(processId, input) {
267
- const managed = this._activeProcesses.get(processId);
268
- if (!managed) {
269
- throw new Error(`Process ${processId} not found`);
270
- }
271
- return new Promise((resolve, reject) => {
272
- managed.streams.stdin.write(input, (error) => {
273
- if (error)
274
- reject(error);
275
- else
276
- resolve();
277
- });
278
- });
279
- }
280
- /**
281
- * Close stdin stream for a process
282
- *
283
- * Signals EOF to the process, useful for programs that wait for stdin to close.
284
- *
285
- * @param processId - ID of the process
286
- */
287
- closeInput(processId) {
288
- const managed = this._activeProcesses.get(processId);
289
- if (!managed) {
290
- throw new Error(`Process ${processId} not found`);
291
- }
292
- managed.streams.stdin.end();
293
- }
294
- onOutput(processId, handler) {
295
- const managed = this._activeProcesses.get(processId);
296
- if (!managed) {
297
- throw new Error(`Process ${processId} not found`);
298
- }
299
- managed.streams.stdout.on("data", (data) => {
300
- handler(data, "stdout");
301
- });
302
- managed.streams.stderr.on("data", (data) => {
303
- handler(data, "stderr");
304
- });
305
- }
306
- onError(processId, handler) {
307
- const managed = this._activeProcesses.get(processId);
308
- if (!managed) {
309
- throw new Error(`Process ${processId} not found`);
310
- }
311
- managed.process.on("error", (error) => {
312
- handler(error);
313
- });
314
- }
315
- getProcess(processId) {
316
- return this._activeProcesses.get(processId) || null;
317
- }
318
- getActiveProcesses() {
319
- return Array.from(this._activeProcesses.values());
320
- }
321
- getMetrics() {
322
- // Return a copy to prevent external mutation
323
- return { ...this._metrics };
324
- }
325
- async shutdown() {
326
- // Terminate all active processes first
327
- const processIds = Array.from(this._activeProcesses.keys());
328
- await Promise.all(processIds.map((id) => this.terminateProcess(id, "SIGTERM")));
329
- // Clear all pending cleanup timers (including ones scheduled by exit handlers)
330
- for (const [id, timer] of this._cleanupTimers.entries()) {
331
- clearTimeout(timer);
332
- this._cleanupTimers.delete(id);
333
- }
334
- }
335
- }
336
- //# sourceMappingURL=simple-manager.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"simple-manager.js","sourceRoot":"","sources":["../../../src/execution/process/simple-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAStC,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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QAChB,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,CAAC,CAAC;IACpD,CAAC;IAED,UAAU;QACR,6CAA6C;QAC7C,OAAO,EAAE,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;IAC9B,CAAC;IAED,KAAK,CAAC,QAAQ;QACZ,uCAAuC;QACvC,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,IAAI,EAAE,CAAC,CAAC;QAC5D,MAAM,OAAO,CAAC,GAAG,CACf,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,gBAAgB,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC,CAC7D,CAAC;QAEF,+EAA+E;QAC/E,KAAK,MAAM,CAAC,EAAE,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,EAAE,CAAC;YACxD,YAAY,CAAC,KAAK,CAAC,CAAC;YACpB,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACjC,CAAC;IACH,CAAC;CACF"}
@@ -1,105 +0,0 @@
1
- /**
2
- * Process Layer Types
3
- *
4
- * Core types and interfaces for the Process Layer (Layer 1) of the execution system.
5
- * Defines generic types for managing any CLI tool/agent process lifecycle.
6
- *
7
- * @module execution/process/types
8
- */
9
- import type { ChildProcess } from 'child_process';
10
- import type { Readable, Writable } from 'stream';
11
- /**
12
- * Status of a managed process throughout its lifecycle
13
- */
14
- export type ProcessStatus = 'spawning' | 'idle' | 'busy' | 'terminating' | 'crashed' | 'completed';
15
- /**
16
- * Configuration for spawning a new process
17
- * Generic interface that works with any CLI tool/agent
18
- */
19
- export interface ProcessConfig {
20
- /** Path to the executable (e.g., 'claude', 'codex', 'node') */
21
- executablePath: string;
22
- /** Command-line arguments to pass to the executable */
23
- args: string[];
24
- /** Working directory for the process */
25
- workDir: string;
26
- /** Environment variables to pass to the process */
27
- env?: Record<string, string>;
28
- /** Maximum execution time in milliseconds */
29
- timeout?: number;
30
- /** Maximum idle time before cleanup (pool only) */
31
- idleTimeout?: number;
32
- /** Retry configuration for failed spawns */
33
- retry?: {
34
- /** Maximum number of retry attempts */
35
- maxAttempts: number;
36
- /** Initial backoff delay in milliseconds */
37
- backoffMs: number;
38
- };
39
- }
40
- /**
41
- * Represents a single managed process instance with its lifecycle state
42
- * Can be any CLI tool/agent (Claude Code, Codex, Gemini CLI, etc.)
43
- */
44
- export interface ManagedProcess {
45
- /** Unique process identifier */
46
- id: string;
47
- /** Operating system process ID */
48
- pid: number;
49
- /** Current status of the process */
50
- status: ProcessStatus;
51
- /** When the process was spawned */
52
- spawnedAt: Date;
53
- /** Last I/O activity timestamp */
54
- lastActivity: Date;
55
- /** Exit code if process has exited */
56
- exitCode: number | null;
57
- /** Signal that terminated the process if applicable */
58
- signal: string | null;
59
- /** Node.js ChildProcess handle */
60
- process: ChildProcess;
61
- /** Process I/O streams */
62
- streams: {
63
- stdout: Readable;
64
- stderr: Readable;
65
- stdin: Writable;
66
- };
67
- /** Process execution metrics */
68
- metrics: {
69
- /** Total duration in milliseconds */
70
- totalDuration: number;
71
- /** Number of tasks completed */
72
- tasksCompleted: number;
73
- /** Success rate (0-1) */
74
- successRate: number;
75
- };
76
- }
77
- /**
78
- * Handler for process output (stdout/stderr)
79
- *
80
- * @param data - Output data buffer
81
- * @param type - Stream type
82
- */
83
- export type OutputHandler = (data: Buffer, type: 'stdout' | 'stderr') => void;
84
- /**
85
- * Handler for process errors
86
- *
87
- * @param error - Error that occurred
88
- */
89
- export type ErrorHandler = (error: Error) => void;
90
- /**
91
- * Aggregate metrics for all processes managed by a ProcessManager
92
- */
93
- export interface ProcessMetrics {
94
- /** Total number of processes spawned */
95
- totalSpawned: number;
96
- /** Number of currently active processes */
97
- currentlyActive: number;
98
- /** Total number of successfully completed processes */
99
- totalCompleted: number;
100
- /** Total number of failed processes */
101
- totalFailed: number;
102
- /** Average process duration in milliseconds */
103
- averageDuration: number;
104
- }
105
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/execution/process/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAEjD;;GAEG;AACH,MAAM,MAAM,aAAa,GACrB,UAAU,GACV,MAAM,GACN,MAAM,GACN,aAAa,GACb,SAAS,GACT,WAAW,CAAC;AAEhB;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,+DAA+D;IAC/D,cAAc,EAAE,MAAM,CAAC;IAEvB,uDAAuD;IACvD,IAAI,EAAE,MAAM,EAAE,CAAC;IAEf,wCAAwC;IACxC,OAAO,EAAE,MAAM,CAAC;IAEhB,mDAAmD;IACnD,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAE7B,6CAA6C;IAC7C,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,mDAAmD;IACnD,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,4CAA4C;IAC5C,KAAK,CAAC,EAAE;QACN,uCAAuC;QACvC,WAAW,EAAE,MAAM,CAAC;QACpB,4CAA4C;QAC5C,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;CACH;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAE7B,gCAAgC;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,kCAAkC;IAClC,GAAG,EAAE,MAAM,CAAC;IAGZ,oCAAoC;IACpC,MAAM,EAAE,aAAa,CAAC;IACtB,mCAAmC;IACnC,SAAS,EAAE,IAAI,CAAC;IAChB,kCAAkC;IAClC,YAAY,EAAE,IAAI,CAAC;IACnB,sCAAsC;IACtC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,uDAAuD;IACvD,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAGtB,kCAAkC;IAClC,OAAO,EAAE,YAAY,CAAC;IACtB,0BAA0B;IAC1B,OAAO,EAAE;QACP,MAAM,EAAE,QAAQ,CAAC;QACjB,MAAM,EAAE,QAAQ,CAAC;QACjB,KAAK,EAAE,QAAQ,CAAC;KACjB,CAAC;IAGF,gCAAgC;IAChC,OAAO,EAAE;QACP,qCAAqC;QACrC,aAAa,EAAE,MAAM,CAAC;QACtB,gCAAgC;QAChC,cAAc,EAAE,MAAM,CAAC;QACvB,yBAAyB;QACzB,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;CACH;AAED;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,QAAQ,KAAK,IAAI,CAAC;AAE9E;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;AAElD;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,wCAAwC;IACxC,YAAY,EAAE,MAAM,CAAC;IACrB,2CAA2C;IAC3C,eAAe,EAAE,MAAM,CAAC;IACxB,uDAAuD;IACvD,cAAc,EAAE,MAAM,CAAC;IACvB,uCAAuC;IACvC,WAAW,EAAE,MAAM,CAAC;IACpB,+CAA+C;IAC/C,eAAe,EAAE,MAAM,CAAC;CACzB"}
@@ -1,10 +0,0 @@
1
- /**
2
- * Process Layer Types
3
- *
4
- * Core types and interfaces for the Process Layer (Layer 1) of the execution system.
5
- * Defines generic types for managing any CLI tool/agent process lifecycle.
6
- *
7
- * @module execution/process/types
8
- */
9
- export {};
10
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/execution/process/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG"}
@@ -1,53 +0,0 @@
1
- /**
2
- * Process Layer Utilities
3
- *
4
- * Helper functions for the Process Layer including ID generation,
5
- * formatting, and validation utilities.
6
- *
7
- * @module execution/process/utils
8
- */
9
- /**
10
- * Generate a unique process ID with a prefix
11
- *
12
- * Creates URL-safe, unique identifiers for processes. Uses nanoid for
13
- * cryptographically strong random IDs.
14
- *
15
- * @param prefix - Prefix for the ID (e.g., 'process', 'task')
16
- * @returns Unique ID string in format: `{prefix}-{randomId}`
17
- *
18
- * @example
19
- * ```typescript
20
- * const id = generateId('process');
21
- * // Returns: 'process-a1b2c3d4'
22
- * ```
23
- */
24
- export declare function generateId(prefix: string): string;
25
- /**
26
- * Format duration in milliseconds to human-readable string
27
- *
28
- * @param ms - Duration in milliseconds
29
- * @returns Formatted duration string
30
- *
31
- * @example
32
- * ```typescript
33
- * formatDuration(1500); // "1.5s"
34
- * formatDuration(65000); // "1m 5s"
35
- * ```
36
- */
37
- export declare function formatDuration(ms: number): string;
38
- /**
39
- * Validate that a signal name is valid for Node.js
40
- *
41
- * @param signal - Signal name to validate
42
- * @returns True if signal is valid
43
- */
44
- export declare function isValidSignal(signal: string): boolean;
45
- /**
46
- * Format error message from process exit
47
- *
48
- * @param exitCode - Process exit code
49
- * @param signal - Signal that terminated the process
50
- * @returns Formatted error message
51
- */
52
- export declare function formatProcessError(exitCode: number | null, signal: string | null): string;
53
- //# sourceMappingURL=utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/execution/process/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAKjD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAuBjD;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAUrD;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,MAAM,GAAG,IAAI,EACvB,MAAM,EAAE,MAAM,GAAG,IAAI,GACpB,MAAM,CAQR"}
@@ -1,97 +0,0 @@
1
- /**
2
- * Process Layer Utilities
3
- *
4
- * Helper functions for the Process Layer including ID generation,
5
- * formatting, and validation utilities.
6
- *
7
- * @module execution/process/utils
8
- */
9
- import { customAlphabet } from 'nanoid';
10
- /**
11
- * Generate a unique process ID with a prefix
12
- *
13
- * Creates URL-safe, unique identifiers for processes. Uses nanoid for
14
- * cryptographically strong random IDs.
15
- *
16
- * @param prefix - Prefix for the ID (e.g., 'process', 'task')
17
- * @returns Unique ID string in format: `{prefix}-{randomId}`
18
- *
19
- * @example
20
- * ```typescript
21
- * const id = generateId('process');
22
- * // Returns: 'process-a1b2c3d4'
23
- * ```
24
- */
25
- export function generateId(prefix) {
26
- // Use nanoid with custom alphabet (alphanumeric, lowercase)
27
- // 10 characters gives us ~1.5 million years to collision at 1000 IDs/hour
28
- const nanoid = customAlphabet('0123456789abcdefghijklmnopqrstuvwxyz', 10);
29
- return `${prefix}-${nanoid()}`;
30
- }
31
- /**
32
- * Format duration in milliseconds to human-readable string
33
- *
34
- * @param ms - Duration in milliseconds
35
- * @returns Formatted duration string
36
- *
37
- * @example
38
- * ```typescript
39
- * formatDuration(1500); // "1.5s"
40
- * formatDuration(65000); // "1m 5s"
41
- * ```
42
- */
43
- export function formatDuration(ms) {
44
- if (ms < 1000) {
45
- return `${ms}ms`;
46
- }
47
- const seconds = Math.floor(ms / 1000);
48
- if (seconds < 60) {
49
- return `${seconds}s`;
50
- }
51
- const minutes = Math.floor(seconds / 60);
52
- const remainingSeconds = seconds % 60;
53
- if (minutes < 60) {
54
- return remainingSeconds > 0
55
- ? `${minutes}m ${remainingSeconds}s`
56
- : `${minutes}m`;
57
- }
58
- const hours = Math.floor(minutes / 60);
59
- const remainingMinutes = minutes % 60;
60
- return remainingMinutes > 0
61
- ? `${hours}h ${remainingMinutes}m`
62
- : `${hours}h`;
63
- }
64
- /**
65
- * Validate that a signal name is valid for Node.js
66
- *
67
- * @param signal - Signal name to validate
68
- * @returns True if signal is valid
69
- */
70
- export function isValidSignal(signal) {
71
- const validSignals = [
72
- 'SIGTERM',
73
- 'SIGKILL',
74
- 'SIGINT',
75
- 'SIGHUP',
76
- 'SIGQUIT',
77
- 'SIGABRT',
78
- ];
79
- return validSignals.includes(signal);
80
- }
81
- /**
82
- * Format error message from process exit
83
- *
84
- * @param exitCode - Process exit code
85
- * @param signal - Signal that terminated the process
86
- * @returns Formatted error message
87
- */
88
- export function formatProcessError(exitCode, signal) {
89
- if (signal) {
90
- return `Process terminated by signal: ${signal}`;
91
- }
92
- if (exitCode !== null && exitCode !== 0) {
93
- return `Process exited with code: ${exitCode}`;
94
- }
95
- return 'Process exited unexpectedly';
96
- }
97
- //# sourceMappingURL=utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/execution/process/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAExC;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,UAAU,CAAC,MAAc;IACvC,4DAA4D;IAC5D,0EAA0E;IAC1E,MAAM,MAAM,GAAG,cAAc,CAAC,sCAAsC,EAAE,EAAE,CAAC,CAAC;IAC1E,OAAO,GAAG,MAAM,IAAI,MAAM,EAAE,EAAE,CAAC;AACjC,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,cAAc,CAAC,EAAU;IACvC,IAAI,EAAE,GAAG,IAAI,EAAE,CAAC;QACd,OAAO,GAAG,EAAE,IAAI,CAAC;IACnB,CAAC;IAED,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC;IACtC,IAAI,OAAO,GAAG,EAAE,EAAE,CAAC;QACjB,OA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