@sudocode-ai/local-server 0.1.7 → 0.1.9
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 +6 -0
- package/dist/errors/agent-errors.d.ts +43 -0
- package/dist/errors/agent-errors.d.ts.map +1 -0
- package/dist/errors/agent-errors.js +69 -0
- package/dist/errors/agent-errors.js.map +1 -0
- package/dist/execution/adapters/claude-adapter.d.ts +63 -0
- package/dist/execution/adapters/claude-adapter.d.ts.map +1 -0
- package/dist/execution/adapters/claude-adapter.js +82 -0
- package/dist/execution/adapters/claude-adapter.js.map +1 -0
- package/dist/execution/adapters/codex-adapter.d.ts +67 -0
- package/dist/execution/adapters/codex-adapter.d.ts.map +1 -0
- package/dist/execution/adapters/codex-adapter.js +183 -0
- package/dist/execution/adapters/codex-adapter.js.map +1 -0
- package/dist/execution/adapters/codex-config-builder.d.ts +30 -0
- package/dist/execution/adapters/codex-config-builder.d.ts.map +1 -0
- package/dist/execution/adapters/codex-config-builder.js +110 -0
- package/dist/execution/adapters/codex-config-builder.js.map +1 -0
- package/dist/execution/adapters/copilot-adapter.d.ts +94 -0
- package/dist/execution/adapters/copilot-adapter.d.ts.map +1 -0
- package/dist/execution/adapters/copilot-adapter.js +163 -0
- package/dist/execution/adapters/copilot-adapter.js.map +1 -0
- package/dist/execution/adapters/copilot-config-builder.d.ts +48 -0
- package/dist/execution/adapters/copilot-config-builder.d.ts.map +1 -0
- package/dist/execution/adapters/copilot-config-builder.js +125 -0
- package/dist/execution/adapters/copilot-config-builder.js.map +1 -0
- package/dist/execution/adapters/cursor-adapter.d.ts +66 -0
- package/dist/execution/adapters/cursor-adapter.d.ts.map +1 -0
- package/dist/execution/adapters/cursor-adapter.js +121 -0
- package/dist/execution/adapters/cursor-adapter.js.map +1 -0
- package/dist/execution/adapters/cursor-config-builder.d.ts +29 -0
- package/dist/execution/adapters/cursor-config-builder.d.ts.map +1 -0
- package/dist/execution/adapters/cursor-config-builder.js +49 -0
- package/dist/execution/adapters/cursor-config-builder.js.map +1 -0
- package/dist/execution/adapters/shared/config-presets.d.ts +102 -0
- package/dist/execution/adapters/shared/config-presets.d.ts.map +1 -0
- package/dist/execution/adapters/shared/config-presets.js +205 -0
- package/dist/execution/adapters/shared/config-presets.js.map +1 -0
- package/dist/execution/adapters/shared/config-utils.d.ts +95 -0
- package/dist/execution/adapters/shared/config-utils.d.ts.map +1 -0
- package/dist/execution/adapters/shared/config-utils.js +163 -0
- package/dist/execution/adapters/shared/config-utils.js.map +1 -0
- package/dist/execution/adapters/shared/index.d.ts +8 -0
- package/dist/execution/adapters/shared/index.d.ts.map +1 -0
- package/dist/execution/adapters/shared/index.js +8 -0
- package/dist/execution/adapters/shared/index.js.map +1 -0
- package/dist/execution/executors/agent-executor-wrapper.d.ts +153 -0
- package/dist/execution/executors/agent-executor-wrapper.d.ts.map +1 -0
- package/dist/execution/executors/agent-executor-wrapper.js +652 -0
- package/dist/execution/executors/agent-executor-wrapper.js.map +1 -0
- package/dist/execution/executors/executor-factory.d.ts +95 -0
- package/dist/execution/executors/executor-factory.d.ts.map +1 -0
- package/dist/execution/executors/executor-factory.js +120 -0
- package/dist/execution/executors/executor-factory.js.map +1 -0
- package/dist/execution/output/ag-ui-adapter.d.ts +0 -2
- package/dist/execution/output/ag-ui-adapter.d.ts.map +1 -1
- package/dist/execution/output/ag-ui-adapter.js +0 -2
- package/dist/execution/output/ag-ui-adapter.js.map +1 -1
- package/dist/execution/output/index.d.ts +0 -3
- package/dist/execution/output/index.d.ts.map +1 -1
- package/dist/execution/output/index.js +0 -2
- package/dist/execution/output/index.js.map +1 -1
- package/dist/execution/output/normalized-to-ag-ui-adapter.d.ts +108 -0
- package/dist/execution/output/normalized-to-ag-ui-adapter.d.ts.map +1 -0
- package/dist/execution/output/normalized-to-ag-ui-adapter.js +321 -0
- package/dist/execution/output/normalized-to-ag-ui-adapter.js.map +1 -0
- package/dist/execution/process/builders/claude.d.ts +24 -57
- package/dist/execution/process/builders/claude.d.ts.map +1 -1
- package/dist/execution/process/builders/claude.js +153 -19
- package/dist/execution/process/builders/claude.js.map +1 -1
- package/dist/execution/transport/ipc-transport-manager.d.ts +74 -0
- package/dist/execution/transport/ipc-transport-manager.d.ts.map +1 -0
- package/dist/execution/transport/ipc-transport-manager.js +104 -0
- package/dist/execution/transport/ipc-transport-manager.js.map +1 -0
- package/dist/execution/transport/transport-manager.d.ts.map +1 -1
- package/dist/execution/transport/transport-manager.js +3 -0
- package/dist/execution/transport/transport-manager.js.map +1 -1
- package/dist/execution/worktree/conflict-detector.d.ts +85 -0
- package/dist/execution/worktree/conflict-detector.d.ts.map +1 -0
- package/dist/execution/worktree/conflict-detector.js +129 -0
- package/dist/execution/worktree/conflict-detector.js.map +1 -0
- package/dist/execution/worktree/git-cli.d.ts +9 -0
- package/dist/execution/worktree/git-cli.d.ts.map +1 -1
- package/dist/execution/worktree/git-cli.js +10 -0
- package/dist/execution/worktree/git-cli.js.map +1 -1
- package/dist/execution/worktree/git-sync-cli.d.ts +198 -0
- package/dist/execution/worktree/git-sync-cli.d.ts.map +1 -0
- package/dist/execution/worktree/git-sync-cli.js +401 -0
- package/dist/execution/worktree/git-sync-cli.js.map +1 -0
- package/dist/execution/worktree/manager.d.ts +18 -0
- package/dist/execution/worktree/manager.d.ts.map +1 -1
- package/dist/execution/worktree/manager.js +9 -3
- package/dist/execution/worktree/manager.js.map +1 -1
- package/dist/index.d.ts +1 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +124 -229
- package/dist/index.js.map +1 -1
- package/dist/middleware/project-context.d.ts +37 -0
- package/dist/middleware/project-context.d.ts.map +1 -0
- package/dist/middleware/project-context.js +91 -0
- package/dist/middleware/project-context.js.map +1 -0
- package/dist/public/assets/index-DV9Tbujb.css +1 -0
- package/dist/public/assets/index-DcDX9-Ad.js +740 -0
- package/dist/public/assets/index-DcDX9-Ad.js.map +1 -0
- package/dist/public/assets/{react-vendor-ByUx1V_q.js → react-vendor-DiL5hC7l.js} +2 -2
- package/dist/public/assets/{react-vendor-ByUx1V_q.js.map → react-vendor-DiL5hC7l.js.map} +1 -1
- package/dist/public/assets/ui-vendor-B4WMPEfa.js +54 -0
- package/dist/public/assets/ui-vendor-B4WMPEfa.js.map +1 -0
- package/dist/public/index.html +4 -4
- package/dist/routes/agents.d.ts +3 -0
- package/dist/routes/agents.d.ts.map +1 -0
- package/dist/routes/agents.js +62 -0
- package/dist/routes/agents.js.map +1 -0
- package/dist/routes/config.d.ts +3 -0
- package/dist/routes/config.d.ts.map +1 -0
- package/dist/routes/config.js +25 -0
- package/dist/routes/config.js.map +1 -0
- package/dist/routes/editors.d.ts +15 -0
- package/dist/routes/editors.d.ts.map +1 -0
- package/dist/routes/editors.js +98 -0
- package/dist/routes/editors.js.map +1 -0
- package/dist/routes/executions-stream.d.ts +8 -5
- package/dist/routes/executions-stream.d.ts.map +1 -1
- package/dist/routes/executions-stream.js +10 -6
- package/dist/routes/executions-stream.js.map +1 -1
- package/dist/routes/executions.d.ts +6 -10
- package/dist/routes/executions.d.ts.map +1 -1
- package/dist/routes/executions.js +792 -37
- package/dist/routes/executions.js.map +1 -1
- package/dist/routes/feedback.d.ts +3 -2
- package/dist/routes/feedback.d.ts.map +1 -1
- package/dist/routes/feedback.js +12 -10
- package/dist/routes/feedback.js.map +1 -1
- package/dist/routes/files.d.ts +18 -0
- package/dist/routes/files.d.ts.map +1 -0
- package/dist/routes/files.js +89 -0
- package/dist/routes/files.js.map +1 -0
- package/dist/routes/issues.d.ts +3 -2
- package/dist/routes/issues.d.ts.map +1 -1
- package/dist/routes/issues.js +19 -18
- package/dist/routes/issues.js.map +1 -1
- package/dist/routes/projects.d.ts +11 -0
- package/dist/routes/projects.d.ts.map +1 -0
- package/dist/routes/projects.js +447 -0
- package/dist/routes/projects.js.map +1 -0
- package/dist/routes/relationships.d.ts +3 -2
- package/dist/routes/relationships.d.ts.map +1 -1
- package/dist/routes/relationships.js +12 -10
- package/dist/routes/relationships.js.map +1 -1
- package/dist/routes/repo-info.d.ts +3 -0
- package/dist/routes/repo-info.d.ts.map +1 -0
- package/dist/routes/repo-info.js +203 -0
- package/dist/routes/repo-info.js.map +1 -0
- package/dist/routes/specs.d.ts +3 -2
- package/dist/routes/specs.d.ts.map +1 -1
- package/dist/routes/specs.js +19 -18
- package/dist/routes/specs.js.map +1 -1
- package/dist/routes/version.d.ts +3 -0
- package/dist/routes/version.d.ts.map +1 -0
- package/dist/routes/version.js +25 -0
- package/dist/routes/version.js.map +1 -0
- package/dist/services/agent-registry.d.ts +140 -0
- package/dist/services/agent-registry.d.ts.map +1 -0
- package/dist/services/agent-registry.js +272 -0
- package/dist/services/agent-registry.js.map +1 -0
- package/dist/services/editor-service.d.ts +57 -0
- package/dist/services/editor-service.d.ts.map +1 -0
- package/dist/services/editor-service.js +204 -0
- package/dist/services/editor-service.js.map +1 -0
- package/dist/services/execution-changes-service.d.ts +110 -0
- package/dist/services/execution-changes-service.d.ts.map +1 -0
- package/dist/services/execution-changes-service.js +700 -0
- package/dist/services/execution-changes-service.js.map +1 -0
- package/dist/services/execution-lifecycle.d.ts +1 -0
- package/dist/services/execution-lifecycle.d.ts.map +1 -1
- package/dist/services/execution-lifecycle.js +37 -7
- package/dist/services/execution-lifecycle.js.map +1 -1
- package/dist/services/execution-logs-store.d.ts +75 -0
- package/dist/services/execution-logs-store.d.ts.map +1 -1
- package/dist/services/execution-logs-store.js +142 -2
- package/dist/services/execution-logs-store.js.map +1 -1
- package/dist/services/execution-service.d.ts +82 -59
- package/dist/services/execution-service.d.ts.map +1 -1
- package/dist/services/execution-service.js +514 -469
- package/dist/services/execution-service.js.map +1 -1
- package/dist/services/execution-worker-pool.d.ts +116 -0
- package/dist/services/execution-worker-pool.d.ts.map +1 -0
- package/dist/services/execution-worker-pool.js +326 -0
- package/dist/services/execution-worker-pool.js.map +1 -0
- package/dist/services/executions.d.ts +3 -0
- package/dist/services/executions.d.ts.map +1 -1
- package/dist/services/executions.js +11 -17
- package/dist/services/executions.js.map +1 -1
- package/dist/services/export.d.ts +8 -2
- package/dist/services/export.d.ts.map +1 -1
- package/dist/services/export.js +29 -23
- package/dist/services/export.js.map +1 -1
- package/dist/services/file-search/git-ls-files-strategy.d.ts +72 -0
- package/dist/services/file-search/git-ls-files-strategy.d.ts.map +1 -0
- package/dist/services/file-search/git-ls-files-strategy.js +176 -0
- package/dist/services/file-search/git-ls-files-strategy.js.map +1 -0
- package/dist/services/file-search/index.d.ts +9 -0
- package/dist/services/file-search/index.d.ts.map +1 -0
- package/dist/services/file-search/index.js +10 -0
- package/dist/services/file-search/index.js.map +1 -0
- package/dist/services/file-search/registry.d.ts +97 -0
- package/dist/services/file-search/registry.d.ts.map +1 -0
- package/dist/services/file-search/registry.js +140 -0
- package/dist/services/file-search/registry.js.map +1 -0
- package/dist/services/file-search/strategy.d.ts +58 -0
- package/dist/services/file-search/strategy.d.ts.map +1 -0
- package/dist/services/file-search/strategy.js +8 -0
- package/dist/services/file-search/strategy.js.map +1 -0
- package/dist/services/project-context.d.ts +69 -0
- package/dist/services/project-context.d.ts.map +1 -0
- package/dist/services/project-context.js +113 -0
- package/dist/services/project-context.js.map +1 -0
- package/dist/services/project-manager.d.ts +95 -0
- package/dist/services/project-manager.d.ts.map +1 -0
- package/dist/services/project-manager.js +388 -0
- package/dist/services/project-manager.js.map +1 -0
- package/dist/services/project-registry.d.ts +98 -0
- package/dist/services/project-registry.d.ts.map +1 -0
- package/dist/services/project-registry.js +289 -0
- package/dist/services/project-registry.js.map +1 -0
- package/dist/services/prompt-resolver.d.ts +97 -0
- package/dist/services/prompt-resolver.d.ts.map +1 -0
- package/dist/services/prompt-resolver.js +377 -0
- package/dist/services/prompt-resolver.js.map +1 -0
- package/dist/services/repo-info.d.ts +12 -0
- package/dist/services/repo-info.d.ts.map +1 -1
- package/dist/services/repo-info.js +46 -0
- package/dist/services/repo-info.js.map +1 -1
- package/dist/services/version-service.d.ts +14 -0
- package/dist/services/version-service.d.ts.map +1 -0
- package/dist/services/version-service.js +57 -0
- package/dist/services/version-service.js.map +1 -0
- package/dist/services/watcher.d.ts +3 -4
- package/dist/services/watcher.d.ts.map +1 -1
- package/dist/services/watcher.js +18 -35
- package/dist/services/watcher.js.map +1 -1
- package/dist/services/websocket.d.ts +30 -16
- package/dist/services/websocket.d.ts.map +1 -1
- package/dist/services/websocket.js +102 -37
- package/dist/services/websocket.js.map +1 -1
- package/dist/services/worktree-sync-service.d.ts +326 -0
- package/dist/services/worktree-sync-service.d.ts.map +1 -0
- package/dist/services/worktree-sync-service.js +1091 -0
- package/dist/services/worktree-sync-service.js.map +1 -0
- package/dist/types/editor.d.ts +49 -0
- package/dist/types/editor.d.ts.map +1 -0
- package/dist/types/editor.js +50 -0
- package/dist/types/editor.js.map +1 -0
- package/dist/types/project.d.ts +58 -0
- package/dist/types/project.d.ts.map +1 -0
- package/dist/types/project.js +10 -0
- package/dist/types/project.js.map +1 -0
- package/dist/utils/executable-check.d.ts +36 -0
- package/dist/utils/executable-check.d.ts.map +1 -0
- package/dist/utils/executable-check.js +79 -0
- package/dist/utils/executable-check.js.map +1 -0
- package/dist/workers/execution-worker.d.ts +18 -0
- package/dist/workers/execution-worker.d.ts.map +1 -0
- package/dist/workers/execution-worker.js +340 -0
- package/dist/workers/execution-worker.js.map +1 -0
- package/dist/workers/worker-ipc.d.ts +84 -0
- package/dist/workers/worker-ipc.d.ts.map +1 -0
- package/dist/workers/worker-ipc.js +29 -0
- package/dist/workers/worker-ipc.js.map +1 -0
- package/package.json +6 -5
- package/dist/execution/output/ag-ui-integration.d.ts +0 -96
- package/dist/execution/output/ag-ui-integration.d.ts.map +0 -1
- package/dist/execution/output/ag-ui-integration.js +0 -96
- package/dist/execution/output/ag-ui-integration.js.map +0 -1
- package/dist/execution/output/claude-code-output-processor.d.ts +0 -321
- package/dist/execution/output/claude-code-output-processor.d.ts.map +0 -1
- package/dist/execution/output/claude-code-output-processor.js +0 -769
- package/dist/execution/output/claude-code-output-processor.js.map +0 -1
- package/dist/public/assets/index-B3SEMufD.js +0 -580
- package/dist/public/assets/index-B3SEMufD.js.map +0 -1
- package/dist/public/assets/index-D2YGL3gX.css +0 -1
- package/dist/public/assets/ui-vendor-CotR6bx9.js +0 -54
- package/dist/public/assets/ui-vendor-CotR6bx9.js.map +0 -1
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Execution Worker Process Entry Point
|
|
3
|
+
*
|
|
4
|
+
* Standalone Node.js process that runs Claude Code executions in isolation.
|
|
5
|
+
* Communicates with main process via IPC (Inter-Process Communication).
|
|
6
|
+
*
|
|
7
|
+
* Environment Variables:
|
|
8
|
+
* - EXECUTION_ID: Execution record ID
|
|
9
|
+
* - PROJECT_ID: Project identifier
|
|
10
|
+
* - REPO_PATH: Path to git repository
|
|
11
|
+
* - DB_PATH: Path to SQLite database
|
|
12
|
+
* - WORKER_ID: Unique worker identifier
|
|
13
|
+
* - MAX_MEMORY_MB: Memory limit (for logging)
|
|
14
|
+
*
|
|
15
|
+
* @module workers/execution-worker
|
|
16
|
+
*/
|
|
17
|
+
import Database from "better-sqlite3";
|
|
18
|
+
import { isMainMessage } from "./worker-ipc.js";
|
|
19
|
+
import { createExecutorForAgent } from "../execution/executors/executor-factory.js";
|
|
20
|
+
import { ExecutionLifecycleService } from "../services/execution-lifecycle.js";
|
|
21
|
+
import { ExecutionLogsStore } from "../services/execution-logs-store.js";
|
|
22
|
+
import { IpcTransportManager } from "../execution/transport/ipc-transport-manager.js";
|
|
23
|
+
import { getExecution, updateExecution } from "../services/executions.js";
|
|
24
|
+
// Validate required environment variables
|
|
25
|
+
const EXECUTION_ID = process.env.EXECUTION_ID;
|
|
26
|
+
const PROJECT_ID = process.env.PROJECT_ID;
|
|
27
|
+
const REPO_PATH = process.env.REPO_PATH;
|
|
28
|
+
const DB_PATH = process.env.DB_PATH;
|
|
29
|
+
const WORKER_ID = process.env.WORKER_ID;
|
|
30
|
+
const MAX_MEMORY_MB = process.env.MAX_MEMORY_MB;
|
|
31
|
+
if (!EXECUTION_ID || !PROJECT_ID || !REPO_PATH || !DB_PATH || !WORKER_ID) {
|
|
32
|
+
console.error("[Worker] Missing required environment variables");
|
|
33
|
+
process.exit(1);
|
|
34
|
+
}
|
|
35
|
+
console.log(`[Worker:${WORKER_ID}] Starting execution worker for ${EXECUTION_ID}`);
|
|
36
|
+
/**
|
|
37
|
+
* Send IPC message to main process
|
|
38
|
+
*/
|
|
39
|
+
function sendToMain(message) {
|
|
40
|
+
if (!process.send) {
|
|
41
|
+
console.error("[Worker] IPC not available (process.send is undefined)");
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
try {
|
|
45
|
+
process.send(message);
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
console.error("[Worker] Failed to send IPC message:", error);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Send log event to main process
|
|
53
|
+
* Note: Currently unused as AgentExecutorWrapper handles log storage directly.
|
|
54
|
+
* Kept for backward compatibility with IPC protocol.
|
|
55
|
+
*/
|
|
56
|
+
// function sendLog(data: OutputEvent): void {
|
|
57
|
+
// sendToMain({
|
|
58
|
+
// type: "log",
|
|
59
|
+
// executionId: EXECUTION_ID!,
|
|
60
|
+
// data,
|
|
61
|
+
// });
|
|
62
|
+
// }
|
|
63
|
+
/**
|
|
64
|
+
* Send status update to main process
|
|
65
|
+
*/
|
|
66
|
+
function sendStatus(status) {
|
|
67
|
+
sendToMain({
|
|
68
|
+
type: "status",
|
|
69
|
+
executionId: EXECUTION_ID,
|
|
70
|
+
status: status,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Send completion result to main process
|
|
75
|
+
*/
|
|
76
|
+
function sendComplete(result) {
|
|
77
|
+
sendToMain({
|
|
78
|
+
type: "complete",
|
|
79
|
+
executionId: EXECUTION_ID,
|
|
80
|
+
result,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Send error to main process
|
|
85
|
+
*/
|
|
86
|
+
function sendError(error, fatal = false) {
|
|
87
|
+
sendToMain({
|
|
88
|
+
type: "error",
|
|
89
|
+
executionId: EXECUTION_ID,
|
|
90
|
+
error,
|
|
91
|
+
fatal,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Flag to track if execution should be canceled
|
|
96
|
+
*/
|
|
97
|
+
let cancelRequested = false;
|
|
98
|
+
/**
|
|
99
|
+
* Listen for messages from main process
|
|
100
|
+
*/
|
|
101
|
+
process.on("message", (message) => {
|
|
102
|
+
if (!isMainMessage(message)) {
|
|
103
|
+
console.warn("[Worker] Received invalid message from main:", message);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
switch (message.type) {
|
|
107
|
+
case "cancel":
|
|
108
|
+
console.log(`[Worker:${WORKER_ID}] Cancel requested`);
|
|
109
|
+
cancelRequested = true;
|
|
110
|
+
// Orchestrator will handle graceful cancellation
|
|
111
|
+
break;
|
|
112
|
+
case "ping":
|
|
113
|
+
// Health check - just acknowledge
|
|
114
|
+
console.log(`[Worker:${WORKER_ID}] Ping received`);
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
/**
|
|
119
|
+
* Main execution function
|
|
120
|
+
*/
|
|
121
|
+
async function runExecution() {
|
|
122
|
+
let db = null;
|
|
123
|
+
try {
|
|
124
|
+
// 1. Initialize database connection
|
|
125
|
+
console.log(`[Worker:${WORKER_ID}] Connecting to database: ${DB_PATH}`);
|
|
126
|
+
db = new Database(DB_PATH);
|
|
127
|
+
// 2. Load execution record
|
|
128
|
+
const execution = getExecution(db, EXECUTION_ID);
|
|
129
|
+
if (!execution) {
|
|
130
|
+
throw new Error(`Execution ${EXECUTION_ID} not found in database`);
|
|
131
|
+
}
|
|
132
|
+
console.log(`[Worker:${WORKER_ID}] Loaded execution:`, {
|
|
133
|
+
id: execution.id,
|
|
134
|
+
issueId: execution.issue_id,
|
|
135
|
+
mode: execution.mode,
|
|
136
|
+
status: execution.status,
|
|
137
|
+
});
|
|
138
|
+
// 3. Parse execution config
|
|
139
|
+
const config = execution.config ? JSON.parse(execution.config) : {};
|
|
140
|
+
const prompt = execution.prompt || "";
|
|
141
|
+
if (!prompt.trim()) {
|
|
142
|
+
throw new Error("Execution prompt is empty");
|
|
143
|
+
}
|
|
144
|
+
// 4. Determine work directory
|
|
145
|
+
const workDir = execution.mode === "worktree"
|
|
146
|
+
? execution.worktree_path || REPO_PATH
|
|
147
|
+
: REPO_PATH;
|
|
148
|
+
console.log(`[Worker:${WORKER_ID}] Work directory: ${workDir}`);
|
|
149
|
+
// 4.5. Validate worktree exists for worktree mode
|
|
150
|
+
if (execution.mode === "worktree" && execution.worktree_path) {
|
|
151
|
+
const fs = await import("fs/promises");
|
|
152
|
+
const path = await import("path");
|
|
153
|
+
try {
|
|
154
|
+
// Check if worktree path exists
|
|
155
|
+
const stats = await fs.stat(execution.worktree_path);
|
|
156
|
+
if (!stats.isDirectory()) {
|
|
157
|
+
throw new Error(`Worktree path is not a directory: ${execution.worktree_path}`);
|
|
158
|
+
}
|
|
159
|
+
// Check if it's a valid git directory
|
|
160
|
+
const gitPath = path.join(execution.worktree_path, ".git");
|
|
161
|
+
await fs.access(gitPath);
|
|
162
|
+
console.log(`[Worker:${WORKER_ID}] Worktree validation passed`);
|
|
163
|
+
}
|
|
164
|
+
catch (error) {
|
|
165
|
+
// Provide clear error messages based on error code
|
|
166
|
+
let errorMessage;
|
|
167
|
+
if (error.code === "ENOENT") {
|
|
168
|
+
errorMessage = `Worktree was deleted or does not exist at: ${execution.worktree_path}`;
|
|
169
|
+
}
|
|
170
|
+
else if (error.code === "ENOTDIR") {
|
|
171
|
+
errorMessage = `Worktree path is not a valid directory: ${execution.worktree_path}`;
|
|
172
|
+
}
|
|
173
|
+
else if (error.code === "EACCES") {
|
|
174
|
+
errorMessage = `Permission denied accessing worktree: ${execution.worktree_path}`;
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
errorMessage = `Failed to access worktree: ${error.message}`;
|
|
178
|
+
}
|
|
179
|
+
console.error(`[Worker:${WORKER_ID}] ${errorMessage}`);
|
|
180
|
+
// Attempt to recreate worktree
|
|
181
|
+
console.log(`[Worker:${WORKER_ID}] Attempting to recreate worktree...`);
|
|
182
|
+
try {
|
|
183
|
+
const lifecycleService = new ExecutionLifecycleService(db, REPO_PATH);
|
|
184
|
+
const worktreeManager = lifecycleService.worktreeManager;
|
|
185
|
+
await worktreeManager.createWorktree({
|
|
186
|
+
repoPath: REPO_PATH,
|
|
187
|
+
branchName: execution.branch_name,
|
|
188
|
+
worktreePath: execution.worktree_path,
|
|
189
|
+
baseBranch: execution.target_branch,
|
|
190
|
+
createBranch: false, // Branch should already exist
|
|
191
|
+
});
|
|
192
|
+
console.log(`[Worker:${WORKER_ID}] Successfully recreated worktree`);
|
|
193
|
+
}
|
|
194
|
+
catch (recreateError) {
|
|
195
|
+
// Failed to recreate - this is a fatal error
|
|
196
|
+
throw new Error(`${errorMessage}. Failed to recreate worktree: ${recreateError.message}`);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
// 5. Send ready signal
|
|
201
|
+
sendToMain({
|
|
202
|
+
type: "ready",
|
|
203
|
+
executionId: EXECUTION_ID,
|
|
204
|
+
workerId: WORKER_ID,
|
|
205
|
+
});
|
|
206
|
+
// 6. Create services for AgentExecutorWrapper
|
|
207
|
+
const lifecycleService = new ExecutionLifecycleService(db, REPO_PATH);
|
|
208
|
+
const logsStore = new ExecutionLogsStore(db);
|
|
209
|
+
// 7. Create IPC transport manager to forward AG-UI events
|
|
210
|
+
const ipcTransport = new IpcTransportManager(EXECUTION_ID);
|
|
211
|
+
// 8. Determine agent type (default to claude-code for backwards compatibility)
|
|
212
|
+
const agentType = config.agentType || "claude-code";
|
|
213
|
+
// 9. Create executor using factory
|
|
214
|
+
const wrapper = createExecutorForAgent(agentType, { workDir: REPO_PATH, ...config }, {
|
|
215
|
+
workDir: REPO_PATH,
|
|
216
|
+
lifecycleService,
|
|
217
|
+
logsStore,
|
|
218
|
+
projectId: PROJECT_ID,
|
|
219
|
+
db,
|
|
220
|
+
transportManager: ipcTransport, // IpcTransportManager matches interface
|
|
221
|
+
});
|
|
222
|
+
// 10. Build execution task
|
|
223
|
+
const task = {
|
|
224
|
+
id: execution.id,
|
|
225
|
+
type: "issue",
|
|
226
|
+
entityId: execution.issue_id || undefined,
|
|
227
|
+
prompt: prompt,
|
|
228
|
+
workDir: workDir,
|
|
229
|
+
config: {
|
|
230
|
+
timeout: config.timeout,
|
|
231
|
+
},
|
|
232
|
+
metadata: {
|
|
233
|
+
model: config.model || "claude-sonnet-4",
|
|
234
|
+
captureFileChanges: config.captureFileChanges ?? true,
|
|
235
|
+
captureToolCalls: config.captureToolCalls ?? true,
|
|
236
|
+
issueId: execution.issue_id,
|
|
237
|
+
executionId: execution.id,
|
|
238
|
+
},
|
|
239
|
+
priority: 0,
|
|
240
|
+
dependencies: [],
|
|
241
|
+
createdAt: new Date(),
|
|
242
|
+
};
|
|
243
|
+
// 11. Update status to running
|
|
244
|
+
console.log(`[Worker:${WORKER_ID}] Starting execution with AgentExecutorWrapper (${agentType})`);
|
|
245
|
+
sendStatus("running");
|
|
246
|
+
// 12. Execute with lifecycle management (blocking)
|
|
247
|
+
const startTime = Date.now();
|
|
248
|
+
await wrapper.executeWithLifecycle(execution.id, task, workDir);
|
|
249
|
+
const duration = Date.now() - startTime;
|
|
250
|
+
console.log(`[Worker:${WORKER_ID}] Execution completed in ${duration}ms`);
|
|
251
|
+
// 13. Check if cancellation was requested
|
|
252
|
+
if (cancelRequested) {
|
|
253
|
+
console.log(`[Worker:${WORKER_ID}] Execution was cancelled`);
|
|
254
|
+
updateExecution(db, execution.id, {
|
|
255
|
+
status: "cancelled",
|
|
256
|
+
completed_at: new Date().toISOString(),
|
|
257
|
+
});
|
|
258
|
+
sendComplete({
|
|
259
|
+
status: "cancelled",
|
|
260
|
+
exitCode: 0,
|
|
261
|
+
completedAt: new Date().toISOString(),
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
else {
|
|
265
|
+
// Send completion (wrapper already updated DB and broadcast)
|
|
266
|
+
sendComplete({
|
|
267
|
+
status: "completed",
|
|
268
|
+
exitCode: 0,
|
|
269
|
+
completedAt: new Date().toISOString(),
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
console.log(`[Worker:${WORKER_ID}] Execution completed successfully`);
|
|
273
|
+
}
|
|
274
|
+
catch (error) {
|
|
275
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
276
|
+
console.error(`[Worker:${WORKER_ID}] Execution failed:`, errorMessage);
|
|
277
|
+
// Wrapper already updated DB and broadcast, just send IPC message
|
|
278
|
+
sendError(errorMessage, true);
|
|
279
|
+
// Exit with failure code
|
|
280
|
+
process.exit(1);
|
|
281
|
+
}
|
|
282
|
+
finally {
|
|
283
|
+
// Clean up database connection
|
|
284
|
+
if (db) {
|
|
285
|
+
try {
|
|
286
|
+
db.close();
|
|
287
|
+
console.log(`[Worker:${WORKER_ID}] Database connection closed`);
|
|
288
|
+
}
|
|
289
|
+
catch (error) {
|
|
290
|
+
console.error(`[Worker:${WORKER_ID}] Error closing database:`, error);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Global error handlers
|
|
297
|
+
*/
|
|
298
|
+
process.on("uncaughtException", (error) => {
|
|
299
|
+
console.error(`[Worker:${WORKER_ID}] Uncaught exception:`, error);
|
|
300
|
+
sendError(`Uncaught exception: ${error.message}`, true);
|
|
301
|
+
process.exit(1);
|
|
302
|
+
});
|
|
303
|
+
process.on("unhandledRejection", (reason) => {
|
|
304
|
+
console.error(`[Worker:${WORKER_ID}] Unhandled rejection:`, reason);
|
|
305
|
+
sendError(`Unhandled rejection: ${String(reason)}`, true);
|
|
306
|
+
process.exit(1);
|
|
307
|
+
});
|
|
308
|
+
/**
|
|
309
|
+
* Graceful shutdown handlers
|
|
310
|
+
*/
|
|
311
|
+
process.on("SIGTERM", () => {
|
|
312
|
+
console.log(`[Worker:${WORKER_ID}] Received SIGTERM, shutting down gracefully`);
|
|
313
|
+
cancelRequested = true;
|
|
314
|
+
// Let the orchestrator handle graceful shutdown
|
|
315
|
+
setTimeout(() => {
|
|
316
|
+
console.log(`[Worker:${WORKER_ID}] Force exit after grace period`);
|
|
317
|
+
process.exit(0);
|
|
318
|
+
}, 5000);
|
|
319
|
+
});
|
|
320
|
+
process.on("SIGINT", () => {
|
|
321
|
+
console.log(`[Worker:${WORKER_ID}] Received SIGINT, shutting down gracefully`);
|
|
322
|
+
cancelRequested = true;
|
|
323
|
+
setTimeout(() => {
|
|
324
|
+
process.exit(0);
|
|
325
|
+
}, 5000);
|
|
326
|
+
});
|
|
327
|
+
// Start execution
|
|
328
|
+
console.log(`[Worker:${WORKER_ID}] Worker process initialized`);
|
|
329
|
+
console.log(`[Worker:${WORKER_ID}] Memory limit: ${MAX_MEMORY_MB || "default"} MB`);
|
|
330
|
+
console.log(`[Worker:${WORKER_ID}] PID: ${process.pid}`);
|
|
331
|
+
runExecution()
|
|
332
|
+
.then(() => {
|
|
333
|
+
console.log(`[Worker:${WORKER_ID}] Worker exiting normally`);
|
|
334
|
+
process.exit(0);
|
|
335
|
+
})
|
|
336
|
+
.catch((error) => {
|
|
337
|
+
console.error(`[Worker:${WORKER_ID}] Worker exiting with error:`, error);
|
|
338
|
+
process.exit(1);
|
|
339
|
+
});
|
|
340
|
+
//# sourceMappingURL=execution-worker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execution-worker.js","sourceRoot":"","sources":["../../src/workers/execution-worker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AAMtC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEh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AAG,EAAE;IACxB,OAAO,CAAC,GAAG,CACT,WAAW,SAAS,6CAA6C,CAClE,CAAC;IACF,eAAe,GAAG,IAAI,CAAC;IACvB,UAAU,CAAC,GAAG,EAAE;QACd,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,EAAE,IAAI,CAAC,CAAC;AACX,CAAC,CAAC,CAAC;AAEH,kBAAkB;AAClB,OAAO,CAAC,GAAG,CAAC,WAAW,SAAS,8BAA8B,CAAC,CAAC;AAChE,OAAO,CAAC,GAAG,CACT,WAAW,SAAS,mBAAmB,aAAa,IAAI,SAAS,KAAK,CACvE,CAAC;AACF,OAAO,CAAC,GAAG,CAAC,WAAW,SAAS,UAAU,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;AAEzD,YAAY,EAAE;KACX,IAAI,CAAC,GAAG,EAAE;IACT,OAAO,CAAC,GAAG,CAAC,WAAW,SAAS,2BAA2B,CAAC,CAAC;IAC7D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC;KACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACf,OAAO,CAAC,KAAK,CAAC,WAAW,SAAS,8BAA8B,EAAE,KAAK,CAAC,CAAC;IACzE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IPC Message Type Definitions for Worker Pool
|
|
3
|
+
*
|
|
4
|
+
* Defines the message protocol for bidirectional communication between
|
|
5
|
+
* main server process and worker processes.
|
|
6
|
+
*
|
|
7
|
+
* @module workers/worker-ipc
|
|
8
|
+
*/
|
|
9
|
+
import type { ExecutionStatus } from "@sudocode-ai/types";
|
|
10
|
+
/**
|
|
11
|
+
* Output event from worker (logs, status updates)
|
|
12
|
+
*/
|
|
13
|
+
export interface OutputEvent {
|
|
14
|
+
type: "stdout" | "stderr" | "log";
|
|
15
|
+
data: string;
|
|
16
|
+
timestamp: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Execution result upon completion
|
|
20
|
+
*/
|
|
21
|
+
export interface ExecutionResult {
|
|
22
|
+
status: ExecutionStatus;
|
|
23
|
+
exitCode?: number;
|
|
24
|
+
error?: string;
|
|
25
|
+
completedAt: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Messages sent from Worker → Main Process
|
|
29
|
+
*/
|
|
30
|
+
export type WorkerToMainMessage = {
|
|
31
|
+
type: "ready";
|
|
32
|
+
executionId: string;
|
|
33
|
+
workerId: string;
|
|
34
|
+
} | {
|
|
35
|
+
type: "log";
|
|
36
|
+
executionId: string;
|
|
37
|
+
data: OutputEvent;
|
|
38
|
+
} | {
|
|
39
|
+
type: "agui-event";
|
|
40
|
+
executionId: string;
|
|
41
|
+
event: any;
|
|
42
|
+
} | {
|
|
43
|
+
type: "status";
|
|
44
|
+
executionId: string;
|
|
45
|
+
status: ExecutionStatus;
|
|
46
|
+
} | {
|
|
47
|
+
type: "complete";
|
|
48
|
+
executionId: string;
|
|
49
|
+
result: ExecutionResult;
|
|
50
|
+
} | {
|
|
51
|
+
type: "error";
|
|
52
|
+
executionId: string;
|
|
53
|
+
error: string;
|
|
54
|
+
fatal?: boolean;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Messages sent from Main Process → Worker
|
|
58
|
+
*/
|
|
59
|
+
export type MainToWorkerMessage = {
|
|
60
|
+
type: "cancel";
|
|
61
|
+
executionId: string;
|
|
62
|
+
} | {
|
|
63
|
+
type: "ping";
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Worker environment configuration
|
|
67
|
+
*/
|
|
68
|
+
export interface WorkerEnv {
|
|
69
|
+
EXECUTION_ID: string;
|
|
70
|
+
PROJECT_ID: string;
|
|
71
|
+
REPO_PATH: string;
|
|
72
|
+
DB_PATH: string;
|
|
73
|
+
MAX_MEMORY_MB?: string;
|
|
74
|
+
WORKER_ID: string;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Type guard for WorkerToMainMessage
|
|
78
|
+
*/
|
|
79
|
+
export declare function isWorkerMessage(msg: any): msg is WorkerToMainMessage;
|
|
80
|
+
/**
|
|
81
|
+
* Type guard for MainToWorkerMessage
|
|
82
|
+
*/
|
|
83
|
+
export declare function isMainMessage(msg: any): msg is MainToWorkerMessage;
|
|
84
|
+
//# sourceMappingURL=worker-ipc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker-ipc.d.ts","sourceRoot":"","sources":["../../src/workers/worker-ipc.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAI1D;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,KAAK,CAAC;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,eAAe,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAC3B;IACE,IAAI,EAAE,OAAO,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB,GACD;IACE,IAAI,EAAE,KAAK,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,WAAW,CAAC;CACnB,GAED;IACE,IAAI,EAAE,YAAY,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,GAAG,CAAC;CACZ,GACD;IACE,IAAI,EAAE,QAAQ,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,eAAe,CAAC;CACzB,GACD;IACE,IAAI,EAAE,UAAU,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,eAAe,CAAC;CACzB,GACD;IACE,IAAI,EAAE,OAAO,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEN;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAC3B;IACE,IAAI,EAAE,QAAQ,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;CACrB,GACD;IACE,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEN;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,mBAAmB,CAUpE;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,mBAAmB,CAQlE"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IPC Message Type Definitions for Worker Pool
|
|
3
|
+
*
|
|
4
|
+
* Defines the message protocol for bidirectional communication between
|
|
5
|
+
* main server process and worker processes.
|
|
6
|
+
*
|
|
7
|
+
* @module workers/worker-ipc
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Type guard for WorkerToMainMessage
|
|
11
|
+
*/
|
|
12
|
+
export function isWorkerMessage(msg) {
|
|
13
|
+
return (msg &&
|
|
14
|
+
typeof msg === "object" &&
|
|
15
|
+
"type" in msg &&
|
|
16
|
+
typeof msg.type === "string" &&
|
|
17
|
+
["ready", "log", "agui-event", "status", "complete", "error"].includes(msg.type));
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Type guard for MainToWorkerMessage
|
|
21
|
+
*/
|
|
22
|
+
export function isMainMessage(msg) {
|
|
23
|
+
return (msg &&
|
|
24
|
+
typeof msg === "object" &&
|
|
25
|
+
"type" in msg &&
|
|
26
|
+
typeof msg.type === "string" &&
|
|
27
|
+
["cancel", "ping"].includes(msg.type));
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=worker-ipc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker-ipc.js","sourceRoot":"","sources":["../../src/workers/worker-ipc.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAsFH;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,GAAQ;IACtC,OAAO,CACL,GAAG;QACH,OAAO,GAAG,KAAK,QAAQ;QACvB,MAAM,IAAI,GAAG;QACb,OAAO,GAAG,CAAC,IAAI,KAAK,QAAQ;QAC5B,CAAC,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC,QAAQ,CACpE,GAAG,CAAC,IAAI,CACT,CACF,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,GAAQ;IACpC,OAAO,CACL,GAAG;QACH,OAAO,GAAG,KAAK,QAAQ;QACvB,MAAM,IAAI,GAAG;QACb,OAAO,GAAG,CAAC,IAAI,KAAK,QAAQ;QAC5B,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CACtC,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sudocode-ai/local-server",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"description": "Local backend server for sudocode - provides REST API and WebSocket endpoints",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -41,17 +41,17 @@
|
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@ag-ui/core": "^0.0.39",
|
|
44
|
-
"@sudocode-ai/cli": "^0.1.
|
|
45
|
-
"@sudocode-ai/types": "^0.1.
|
|
44
|
+
"@sudocode-ai/cli": "^0.1.9",
|
|
45
|
+
"@sudocode-ai/types": "^0.1.9",
|
|
46
46
|
"@types/ws": "^8.18.1",
|
|
47
|
-
"agent-execution-engine": "^0.0.
|
|
47
|
+
"agent-execution-engine": "^0.0.12",
|
|
48
48
|
"async-mutex": "^0.5.0",
|
|
49
49
|
"better-sqlite3": "^11.10.0",
|
|
50
50
|
"cors": "^2.8.5",
|
|
51
|
-
"dotenv": "^16.4.5",
|
|
52
51
|
"express": "^4.18.2",
|
|
53
52
|
"glob": "^10.4.5",
|
|
54
53
|
"node-fetch": "^2.7.0",
|
|
54
|
+
"which": "^6.0.0",
|
|
55
55
|
"ws": "^8.18.3",
|
|
56
56
|
"zod": "^3.22.4"
|
|
57
57
|
},
|
|
@@ -61,6 +61,7 @@
|
|
|
61
61
|
"@types/express": "^4.17.21",
|
|
62
62
|
"@types/node": "^20.11.19",
|
|
63
63
|
"@types/supertest": "^6.0.3",
|
|
64
|
+
"@types/which": "^3.0.4",
|
|
64
65
|
"esbuild": "^0.27.0",
|
|
65
66
|
"supertest": "^7.1.4",
|
|
66
67
|
"tsx": "^4.7.1",
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* AG-UI Integration Helpers
|
|
3
|
-
*
|
|
4
|
-
* Factory functions and helpers to wire SPEC-007 output processing with SPEC-009 AG-UI streaming.
|
|
5
|
-
* Simplifies the integration between ClaudeCodeOutputProcessor and AgUiEventAdapter.
|
|
6
|
-
*
|
|
7
|
-
* @module execution/output/ag-ui-integration
|
|
8
|
-
*/
|
|
9
|
-
import { AgUiEventAdapter } from './ag-ui-adapter.js';
|
|
10
|
-
import type { IOutputProcessor } from './types.js';
|
|
11
|
-
/**
|
|
12
|
-
* AG-UI System containing processor and adapter
|
|
13
|
-
*
|
|
14
|
-
* The processor handles parsing Claude Code output and emitting events.
|
|
15
|
-
* The adapter transforms those events into AG-UI protocol events.
|
|
16
|
-
*/
|
|
17
|
-
export interface AgUiSystem {
|
|
18
|
-
/** Output processor for parsing Claude Code stream-json */
|
|
19
|
-
processor: IOutputProcessor;
|
|
20
|
-
/** AG-UI event adapter for broadcasting events */
|
|
21
|
-
adapter: AgUiEventAdapter;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Create a complete AG-UI system with processor and adapter pre-wired
|
|
25
|
-
*
|
|
26
|
-
* This is the recommended way to create an AG-UI streaming system.
|
|
27
|
-
* It automatically:
|
|
28
|
-
* - Creates a ClaudeCodeOutputProcessor
|
|
29
|
-
* - Creates an AgUiEventAdapter with the provided runId
|
|
30
|
-
* - Wires the processor to emit events through the adapter
|
|
31
|
-
*
|
|
32
|
-
* @param runId - Unique identifier for this execution run
|
|
33
|
-
* @param threadId - Optional thread ID (defaults to runId)
|
|
34
|
-
* @returns Complete AG-UI system ready to process output
|
|
35
|
-
*
|
|
36
|
-
* @example
|
|
37
|
-
* ```typescript
|
|
38
|
-
* const { processor, adapter } = createAgUiSystem('run-123');
|
|
39
|
-
*
|
|
40
|
-
* // Wire adapter to transport for SSE streaming
|
|
41
|
-
* transportManager.connectAdapter(adapter, 'run-123');
|
|
42
|
-
*
|
|
43
|
-
* // Process Claude Code output
|
|
44
|
-
* await processor.processLine('{"type":"assistant",...}');
|
|
45
|
-
*
|
|
46
|
-
* // Events automatically flow: processor -> adapter -> transport -> SSE clients
|
|
47
|
-
* ```
|
|
48
|
-
*/
|
|
49
|
-
export declare function createAgUiSystem(runId: string, threadId?: string): AgUiSystem;
|
|
50
|
-
/**
|
|
51
|
-
* Manually wire an output processor to an AG-UI adapter
|
|
52
|
-
*
|
|
53
|
-
* Use this when you need more control over processor/adapter creation.
|
|
54
|
-
* This function handles all the event handler registration.
|
|
55
|
-
*
|
|
56
|
-
* @param processor - Output processor to wire
|
|
57
|
-
* @param adapter - AG-UI adapter to receive events
|
|
58
|
-
*
|
|
59
|
-
* @example
|
|
60
|
-
* ```typescript
|
|
61
|
-
* const processor = new ClaudeCodeOutputProcessor();
|
|
62
|
-
* const adapter = new AgUiEventAdapter('run-123');
|
|
63
|
-
*
|
|
64
|
-
* // Manually wire them together
|
|
65
|
-
* wireManually(processor, adapter);
|
|
66
|
-
*
|
|
67
|
-
* // Now processor events will flow to adapter
|
|
68
|
-
* ```
|
|
69
|
-
*/
|
|
70
|
-
export declare function wireManually(processor: IOutputProcessor, adapter: AgUiEventAdapter): void;
|
|
71
|
-
/**
|
|
72
|
-
* Create an AG-UI system with custom processor implementation
|
|
73
|
-
*
|
|
74
|
-
* Use this when you have a custom output processor that implements IOutputProcessor.
|
|
75
|
-
* The processor will be wired to a new AgUiEventAdapter.
|
|
76
|
-
*
|
|
77
|
-
* @param processor - Custom output processor implementation
|
|
78
|
-
* @param runId - Unique identifier for this execution run
|
|
79
|
-
* @param threadId - Optional thread ID (defaults to runId)
|
|
80
|
-
* @returns AG-UI system with your custom processor
|
|
81
|
-
*
|
|
82
|
-
* @example
|
|
83
|
-
* ```typescript
|
|
84
|
-
* class CustomProcessor implements IOutputProcessor {
|
|
85
|
-
* // ... your implementation
|
|
86
|
-
* }
|
|
87
|
-
*
|
|
88
|
-
* const processor = new CustomProcessor();
|
|
89
|
-
* const { processor, adapter } = createAgUiSystemWithProcessor(
|
|
90
|
-
* processor,
|
|
91
|
-
* 'run-123'
|
|
92
|
-
* );
|
|
93
|
-
* ```
|
|
94
|
-
*/
|
|
95
|
-
export declare function createAgUiSystemWithProcessor(processor: IOutputProcessor, runId: string, threadId?: string): AgUiSystem;
|
|
96
|
-
//# sourceMappingURL=ag-ui-integration.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ag-ui-integration.d.ts","sourceRoot":"","sources":["../../../src/execution/output/ag-ui-integration.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB,2DAA2D;IAC3D,SAAS,EAAE,gBAAgB,CAAC;IAC5B,kDAAkD;IAClD,OAAO,EAAE,gBAAgB,CAAC;CAC3B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,MAAM,EACb,QAAQ,CAAC,EAAE,MAAM,GAChB,UAAU,CAQZ;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,YAAY,CAC1B,SAAS,EAAE,gBAAgB,EAC3B,OAAO,EAAE,gBAAgB,GACxB,IAAI,CAEN;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,6BAA6B,CAC3C,SAAS,EAAE,gBAAgB,EAC3B,KAAK,EAAE,MAAM,EACb,QAAQ,CAAC,EAAE,MAAM,GAChB,UAAU,CAKZ"}
|