upfynai-code 2.9.0 → 2.9.2
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 +91 -66
- package/client/dist/api-docs.html +838 -0
- package/client/dist/assets/AppContent-BXZDeSIC.js +545 -0
- package/client/dist/assets/CanvasFullScreen-mnpCnLZ9.js +1 -0
- package/client/dist/assets/CanvasWorkspace-4CqmjAVQ.js +163 -0
- package/client/dist/assets/DashboardPanel-zFIFlw56.js +1 -0
- package/client/dist/assets/FileTree-B0c_GaB3.js +1 -0
- package/client/dist/assets/GitPanel-DUP4zVU4.js +2 -0
- package/client/dist/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
- package/client/dist/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
- package/client/dist/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
- package/client/dist/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
- package/client/dist/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
- package/client/dist/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
- package/client/dist/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
- package/client/dist/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
- package/client/dist/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
- package/client/dist/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
- package/client/dist/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
- package/client/dist/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
- package/client/dist/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
- package/client/dist/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
- package/client/dist/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
- package/client/dist/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
- package/client/dist/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
- package/client/dist/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
- package/client/dist/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
- package/client/dist/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
- package/client/dist/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
- package/client/dist/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
- package/client/dist/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
- package/client/dist/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
- package/client/dist/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
- package/client/dist/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
- package/client/dist/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
- package/client/dist/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
- package/client/dist/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
- package/client/dist/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
- package/client/dist/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
- package/client/dist/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
- package/client/dist/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
- package/client/dist/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
- package/client/dist/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
- package/client/dist/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
- package/client/dist/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
- package/client/dist/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
- package/client/dist/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
- package/client/dist/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
- package/client/dist/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
- package/client/dist/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
- package/client/dist/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
- package/client/dist/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
- package/client/dist/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
- package/client/dist/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
- package/client/dist/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
- package/client/dist/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
- package/client/dist/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
- package/client/dist/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
- package/client/dist/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
- package/client/dist/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
- package/client/dist/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
- package/client/dist/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
- package/client/dist/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
- package/client/dist/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
- package/client/dist/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
- package/client/dist/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
- package/client/dist/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
- package/client/dist/assets/LoginModal-BRycfsyD.js +13 -0
- package/client/dist/assets/MarkdownPreview-DHmk3qzu.js +1 -0
- package/client/dist/assets/MermaidBlock-BuBc_G-F.js +2 -0
- package/client/dist/assets/Onboarding-BcnaZZ0o.js +1 -0
- package/client/dist/assets/PreviewPanel-CqCa92Tf.js +32 -0
- package/client/dist/assets/SetupForm-S0g6u5yT.js +1 -0
- package/client/dist/assets/WorkflowsPanel-CouH9JDO.js +1 -0
- package/client/dist/assets/index-BFuqS0tY.css +1 -0
- package/client/dist/assets/index-CNDcVl2g.js +68 -0
- package/client/dist/assets/pdf-CE_K4jFx.js +12 -0
- package/client/dist/assets/vendor-canvas-BZV40eAE.css +1 -0
- package/client/dist/assets/vendor-canvas-D39yWul6.js +49 -0
- package/client/dist/assets/vendor-codemirror-CbtmxxaB.js +35 -0
- package/client/dist/assets/vendor-diff-DNQpbhrT.js +69 -0
- package/client/dist/assets/vendor-i18n-DCFGyhQR.js +1 -0
- package/client/dist/assets/vendor-icons-BaD0x9SL.js +711 -0
- package/client/dist/assets/vendor-markdown-CimbIo6Y.js +296 -0
- package/client/dist/assets/vendor-mermaid-CH7SGc99.js +2556 -0
- package/client/dist/assets/vendor-react-96lCPsRK.js +67 -0
- package/client/dist/assets/vendor-syntax-DuHI9Ok6.js +16 -0
- package/client/dist/assets/vendor-xterm-CZq1hqo1.js +66 -0
- package/client/dist/assets/vendor-xterm-qxJ8_QYu.css +32 -0
- package/client/dist/clear-cache.html +85 -0
- package/client/dist/convert-icons.md +53 -0
- package/client/dist/favicon.png +0 -0
- package/client/dist/favicon.svg +5 -0
- package/client/dist/generate-icons.js +49 -0
- package/client/dist/icons/claude-ai-icon.svg +1 -0
- package/client/dist/icons/codex-white.svg +3 -0
- package/client/dist/icons/codex.svg +3 -0
- package/client/dist/icons/cursor-white.svg +12 -0
- package/client/dist/icons/cursor.svg +1 -0
- package/client/dist/icons/icon-128x128.png +0 -0
- package/client/dist/icons/icon-128x128.svg +5 -0
- package/client/dist/icons/icon-144x144.png +0 -0
- package/client/dist/icons/icon-144x144.svg +5 -0
- package/client/dist/icons/icon-152x152.png +0 -0
- package/client/dist/icons/icon-152x152.svg +5 -0
- package/client/dist/icons/icon-192x192.png +0 -0
- package/client/dist/icons/icon-192x192.svg +5 -0
- package/client/dist/icons/icon-384x384.png +0 -0
- package/client/dist/icons/icon-384x384.svg +5 -0
- package/client/dist/icons/icon-512x512.png +0 -0
- package/client/dist/icons/icon-512x512.svg +5 -0
- package/client/dist/icons/icon-72x72.png +0 -0
- package/client/dist/icons/icon-72x72.svg +5 -0
- package/client/dist/icons/icon-96x96.png +0 -0
- package/client/dist/icons/icon-96x96.svg +5 -0
- package/client/dist/icons/icon-template.svg +5 -0
- package/client/dist/index.html +119 -0
- package/client/dist/logo-128.png +0 -0
- package/client/dist/logo-256.png +0 -0
- package/client/dist/logo-32.png +0 -0
- package/client/dist/logo-512.png +0 -0
- package/client/dist/logo-64.png +0 -0
- package/client/dist/logo.svg +14 -0
- package/client/dist/manifest.json +61 -0
- package/client/dist/mcp-docs.html +108 -0
- package/client/dist/offline.html +84 -0
- package/client/dist/screenshots/cli-selection.png +0 -0
- package/client/dist/screenshots/desktop-main.png +0 -0
- package/client/dist/screenshots/mobile-chat.png +0 -0
- package/client/dist/screenshots/tools-modal.png +0 -0
- package/client/dist/sw.js +82 -0
- package/commands/upfynai-connect.md +59 -0
- package/commands/upfynai-disconnect.md +31 -0
- package/commands/upfynai-doctor.md +99 -0
- package/commands/upfynai-export.md +49 -0
- package/commands/upfynai-local.md +82 -0
- package/commands/upfynai-status.md +75 -0
- package/commands/upfynai-stop.md +49 -0
- package/commands/upfynai-uninstall.md +58 -0
- package/commands/upfynai.md +69 -0
- package/package.json +143 -82
- package/scripts/build-client.js +17 -0
- package/scripts/fix-node-pty.js +67 -0
- package/scripts/install-commands.js +78 -0
- package/server/agent-loop.js +242 -0
- package/server/auto-compact.js +99 -0
- package/server/claude-sdk.js +797 -0
- package/server/cli-ui.js +785 -0
- package/server/cli.js +596 -0
- package/server/constants/config.js +31 -0
- package/server/cursor-cli.js +270 -0
- package/server/database/auth.db +0 -0
- package/server/database/db.js +1391 -0
- package/server/database/init.sql +70 -0
- package/server/index.js +3799 -0
- package/server/load-env.js +26 -0
- package/server/mcp-server.js +621 -0
- package/server/middleware/auth.js +176 -0
- package/server/middleware/relayHelpers.js +44 -0
- package/server/middleware/sandboxRouter.js +174 -0
- package/server/openai-codex.js +403 -0
- package/server/openrouter.js +137 -0
- package/server/projects.js +1807 -0
- package/server/provider-factory.js +174 -0
- package/server/relay-client.js +379 -0
- package/server/routes/agent.js +1226 -0
- package/server/routes/auth.js +554 -0
- package/server/routes/canvas.js +53 -0
- package/server/routes/cli-auth.js +263 -0
- package/server/routes/codex.js +396 -0
- package/server/routes/commands.js +707 -0
- package/server/routes/composio.js +176 -0
- package/server/routes/cursor.js +770 -0
- package/server/routes/dashboard.js +295 -0
- package/server/routes/git.js +1208 -0
- package/server/routes/keys.js +34 -0
- package/server/routes/mcp-utils.js +48 -0
- package/server/routes/mcp.js +661 -0
- package/server/routes/payments.js +227 -0
- package/server/routes/projects.js +655 -0
- package/server/routes/sessions.js +146 -0
- package/server/routes/settings.js +261 -0
- package/server/routes/taskmaster.js +1928 -0
- package/server/routes/user.js +106 -0
- package/server/routes/vapi-chat.js +624 -0
- package/server/routes/voice.js +235 -0
- package/server/routes/webhooks.js +166 -0
- package/server/routes/workflows.js +312 -0
- package/server/sandbox.js +120 -0
- package/server/services/composio.js +204 -0
- package/server/services/sessionRegistry.js +139 -0
- package/server/services/whisperService.js +84 -0
- package/server/services/workflowScheduler.js +206 -0
- package/server/tests/relay-flow.test.js +570 -0
- package/server/tests/sessions.test.js +259 -0
- package/server/utils/commandParser.js +303 -0
- package/server/utils/email.js +61 -0
- package/server/utils/gitConfig.js +24 -0
- package/server/utils/mcp-detector.js +198 -0
- package/server/utils/taskmaster-websocket.js +129 -0
- package/shared/integrationCatalog.d.ts +12 -0
- package/shared/integrationCatalog.js +172 -0
- package/shared/modelConstants.js +96 -0
- package/bin/cli.js +0 -97
- package/dist/agents/claude.js +0 -229
- package/dist/agents/codex.js +0 -48
- package/dist/agents/cursor.js +0 -48
- package/dist/agents/detect.js +0 -51
- package/dist/agents/exec.js +0 -31
- package/dist/agents/files.js +0 -105
- package/dist/agents/git.js +0 -18
- package/dist/agents/gitagent.js +0 -67
- package/dist/agents/index.js +0 -88
- package/dist/agents/shell.js +0 -38
- package/dist/agents/utils.js +0 -136
- package/scripts/postinstall.js +0 -9
- package/scripts/prepublish.js +0 -58
- package/src/animation.js +0 -228
- package/src/auth.js +0 -122
- package/src/config.js +0 -40
- package/src/connect.js +0 -416
- package/src/launch.js +0 -78
- package/src/mcp.js +0 -57
- package/src/permissions.js +0 -140
- package/src/persistent-shell.js +0 -261
- package/src/server.js +0 -54
- /package/{dist → shared}/gitagent/index.js +0 -0
- /package/{dist → shared}/gitagent/parser.js +0 -0
- /package/{dist → shared}/gitagent/prompt-builder.js +0 -0
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
import { spawn } from 'child_process';
|
|
2
|
+
import crossSpawn from 'cross-spawn';
|
|
3
|
+
import { promises as fs } from 'fs';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import os from 'os';
|
|
6
|
+
|
|
7
|
+
// Use cross-spawn on Windows for better command execution
|
|
8
|
+
const spawnFunction = process.platform === 'win32' ? crossSpawn : spawn;
|
|
9
|
+
|
|
10
|
+
let activeCursorProcesses = new Map(); // Track active processes by session ID
|
|
11
|
+
|
|
12
|
+
async function spawnCursor(command, options = {}, ws) {
|
|
13
|
+
return new Promise(async (resolve, reject) => {
|
|
14
|
+
const { sessionId, projectPath, cwd, resume, toolsSettings, skipPermissions, model, images } = options;
|
|
15
|
+
let capturedSessionId = sessionId; // Track session ID throughout the process
|
|
16
|
+
let sessionCreatedSent = false; // Track if we've already sent session-created event
|
|
17
|
+
let messageBuffer = ''; // Buffer for accumulating assistant messages
|
|
18
|
+
|
|
19
|
+
// Use tools settings passed from frontend, or defaults
|
|
20
|
+
const settings = toolsSettings || {
|
|
21
|
+
allowedShellCommands: [],
|
|
22
|
+
skipPermissions: false
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// Build Cursor CLI command
|
|
26
|
+
const args = [];
|
|
27
|
+
|
|
28
|
+
// Build flags allowing both resume and prompt together (reply in existing session)
|
|
29
|
+
// Treat presence of sessionId as intention to resume, regardless of resume flag
|
|
30
|
+
if (sessionId) {
|
|
31
|
+
args.push('--resume=' + sessionId);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (command && command.trim()) {
|
|
35
|
+
// Provide a prompt (works for both new and resumed sessions)
|
|
36
|
+
args.push('-p', command);
|
|
37
|
+
|
|
38
|
+
// Add model flag if specified (only meaningful for new sessions; harmless on resume)
|
|
39
|
+
if (!sessionId && model) {
|
|
40
|
+
args.push('--model', model);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Request streaming JSON when we are providing a prompt
|
|
44
|
+
args.push('--output-format', 'stream-json');
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Add skip permissions flag if enabled
|
|
48
|
+
if (skipPermissions || settings.skipPermissions) {
|
|
49
|
+
args.push('-f');
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Use cwd (actual project directory) instead of projectPath
|
|
53
|
+
const workingDir = cwd || projectPath || process.cwd();
|
|
54
|
+
|
|
55
|
+
const cursorProcess = spawnFunction('cursor-agent', args, {
|
|
56
|
+
cwd: workingDir,
|
|
57
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
58
|
+
env: { ...process.env } // Inherit all environment variables
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// Store process reference for potential abort
|
|
62
|
+
const processKey = capturedSessionId || Date.now().toString();
|
|
63
|
+
activeCursorProcesses.set(processKey, cursorProcess);
|
|
64
|
+
|
|
65
|
+
// Handle stdout (streaming JSON responses)
|
|
66
|
+
cursorProcess.stdout.on('data', (data) => {
|
|
67
|
+
const rawOutput = data.toString();
|
|
68
|
+
// stdout received
|
|
69
|
+
|
|
70
|
+
const lines = rawOutput.split('\n').filter(line => line.trim());
|
|
71
|
+
|
|
72
|
+
for (const line of lines) {
|
|
73
|
+
try {
|
|
74
|
+
const response = JSON.parse(line);
|
|
75
|
+
// parsed response
|
|
76
|
+
|
|
77
|
+
// Handle different message types
|
|
78
|
+
switch (response.type) {
|
|
79
|
+
case 'system':
|
|
80
|
+
if (response.subtype === 'init') {
|
|
81
|
+
// Capture session ID
|
|
82
|
+
if (response.session_id && !capturedSessionId) {
|
|
83
|
+
capturedSessionId = response.session_id;
|
|
84
|
+
// session ID captured
|
|
85
|
+
|
|
86
|
+
// Update process key with captured session ID
|
|
87
|
+
if (processKey !== capturedSessionId) {
|
|
88
|
+
activeCursorProcesses.delete(processKey);
|
|
89
|
+
activeCursorProcesses.set(capturedSessionId, cursorProcess);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Set session ID on writer (for API endpoint compatibility)
|
|
93
|
+
if (ws.setSessionId && typeof ws.setSessionId === 'function') {
|
|
94
|
+
ws.setSessionId(capturedSessionId);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Send session-created event only once for new sessions
|
|
98
|
+
if (!sessionId && !sessionCreatedSent) {
|
|
99
|
+
sessionCreatedSent = true;
|
|
100
|
+
ws.send({
|
|
101
|
+
type: 'session-created',
|
|
102
|
+
sessionId: capturedSessionId,
|
|
103
|
+
model: response.model,
|
|
104
|
+
cwd: response.cwd
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Send system info to frontend
|
|
110
|
+
ws.send({
|
|
111
|
+
type: 'cursor-system',
|
|
112
|
+
data: response,
|
|
113
|
+
sessionId: capturedSessionId || sessionId || null
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
break;
|
|
117
|
+
|
|
118
|
+
case 'user':
|
|
119
|
+
// Forward user message
|
|
120
|
+
ws.send({
|
|
121
|
+
type: 'cursor-user',
|
|
122
|
+
data: response,
|
|
123
|
+
sessionId: capturedSessionId || sessionId || null
|
|
124
|
+
});
|
|
125
|
+
break;
|
|
126
|
+
|
|
127
|
+
case 'assistant':
|
|
128
|
+
// Accumulate assistant message chunks
|
|
129
|
+
if (response.message && response.message.content && response.message.content.length > 0) {
|
|
130
|
+
const textContent = response.message.content[0].text;
|
|
131
|
+
messageBuffer += textContent;
|
|
132
|
+
|
|
133
|
+
// Send as Claude-compatible format for frontend
|
|
134
|
+
ws.send({
|
|
135
|
+
type: 'claude-response',
|
|
136
|
+
data: {
|
|
137
|
+
type: 'content_block_delta',
|
|
138
|
+
delta: {
|
|
139
|
+
type: 'text_delta',
|
|
140
|
+
text: textContent
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
sessionId: capturedSessionId || sessionId || null
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
break;
|
|
147
|
+
|
|
148
|
+
case 'result':
|
|
149
|
+
// Session complete
|
|
150
|
+
// session result received
|
|
151
|
+
|
|
152
|
+
// Send final message if we have buffered content
|
|
153
|
+
if (messageBuffer) {
|
|
154
|
+
ws.send({
|
|
155
|
+
type: 'claude-response',
|
|
156
|
+
data: {
|
|
157
|
+
type: 'content_block_stop'
|
|
158
|
+
},
|
|
159
|
+
sessionId: capturedSessionId || sessionId || null
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// Send completion event
|
|
164
|
+
ws.send({
|
|
165
|
+
type: 'cursor-result',
|
|
166
|
+
sessionId: capturedSessionId || sessionId,
|
|
167
|
+
data: response,
|
|
168
|
+
success: response.subtype === 'success'
|
|
169
|
+
});
|
|
170
|
+
break;
|
|
171
|
+
|
|
172
|
+
default:
|
|
173
|
+
// Forward any other message types
|
|
174
|
+
ws.send({
|
|
175
|
+
type: 'cursor-response',
|
|
176
|
+
data: response,
|
|
177
|
+
sessionId: capturedSessionId || sessionId || null
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
} catch (parseError) {
|
|
181
|
+
// non-JSON response skipped
|
|
182
|
+
// If not JSON, send as raw text
|
|
183
|
+
ws.send({
|
|
184
|
+
type: 'cursor-output',
|
|
185
|
+
data: line,
|
|
186
|
+
sessionId: capturedSessionId || sessionId || null
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
// Handle stderr
|
|
193
|
+
cursorProcess.stderr.on('data', (data) => {
|
|
194
|
+
// stderr output received
|
|
195
|
+
ws.send({
|
|
196
|
+
type: 'cursor-error',
|
|
197
|
+
error: data.toString(),
|
|
198
|
+
sessionId: capturedSessionId || sessionId || null
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
// Handle process completion
|
|
203
|
+
cursorProcess.on('close', async (code) => {
|
|
204
|
+
// process exited
|
|
205
|
+
|
|
206
|
+
// Clean up process reference
|
|
207
|
+
const finalSessionId = capturedSessionId || sessionId || processKey;
|
|
208
|
+
activeCursorProcesses.delete(finalSessionId);
|
|
209
|
+
|
|
210
|
+
ws.send({
|
|
211
|
+
type: 'claude-complete',
|
|
212
|
+
sessionId: finalSessionId,
|
|
213
|
+
exitCode: code,
|
|
214
|
+
isNewSession: !sessionId && !!command // Flag to indicate this was a new session
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
if (code === 0) {
|
|
218
|
+
resolve();
|
|
219
|
+
} else {
|
|
220
|
+
reject(new Error(`Cursor CLI exited with code ${code}`));
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
// Handle process errors
|
|
225
|
+
cursorProcess.on('error', (error) => {
|
|
226
|
+
// process error occurred
|
|
227
|
+
|
|
228
|
+
// Clean up process reference on error
|
|
229
|
+
const finalSessionId = capturedSessionId || sessionId || processKey;
|
|
230
|
+
activeCursorProcesses.delete(finalSessionId);
|
|
231
|
+
|
|
232
|
+
ws.send({
|
|
233
|
+
type: 'cursor-error',
|
|
234
|
+
error: error.message,
|
|
235
|
+
sessionId: capturedSessionId || sessionId || null
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
reject(error);
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
// Close stdin since Cursor doesn't need interactive input
|
|
242
|
+
cursorProcess.stdin.end();
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
function abortCursorSession(sessionId) {
|
|
247
|
+
const process = activeCursorProcesses.get(sessionId);
|
|
248
|
+
if (process) {
|
|
249
|
+
// aborting session
|
|
250
|
+
process.kill('SIGTERM');
|
|
251
|
+
activeCursorProcesses.delete(sessionId);
|
|
252
|
+
return true;
|
|
253
|
+
}
|
|
254
|
+
return false;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
function isCursorSessionActive(sessionId) {
|
|
258
|
+
return activeCursorProcesses.has(sessionId);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
function getActiveCursorSessions() {
|
|
262
|
+
return Array.from(activeCursorProcesses.keys());
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
export {
|
|
266
|
+
spawnCursor,
|
|
267
|
+
abortCursorSession,
|
|
268
|
+
isCursorSessionActive,
|
|
269
|
+
getActiveCursorSessions
|
|
270
|
+
};
|
|
Binary file
|