@kaitranntt/ccs 7.43.0-dev.1 → 7.43.0-dev.11
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/dist/api/services/profile-reader.d.ts.map +1 -1
- package/dist/api/services/profile-reader.js +4 -1
- package/dist/api/services/profile-reader.js.map +1 -1
- package/dist/auth/profile-detector.d.ts +14 -3
- package/dist/auth/profile-detector.d.ts.map +1 -1
- package/dist/auth/profile-detector.js +35 -15
- package/dist/auth/profile-detector.js.map +1 -1
- package/dist/ccs.js +11 -0
- package/dist/ccs.js.map +1 -1
- package/dist/cliproxy/composite-validator.d.ts +20 -0
- package/dist/cliproxy/composite-validator.d.ts.map +1 -0
- package/dist/cliproxy/composite-validator.js +85 -0
- package/dist/cliproxy/composite-validator.js.map +1 -0
- package/dist/cliproxy/config/env-builder.d.ts +24 -0
- package/dist/cliproxy/config/env-builder.d.ts.map +1 -1
- package/dist/cliproxy/config/env-builder.js +72 -1
- package/dist/cliproxy/config/env-builder.js.map +1 -1
- package/dist/cliproxy/config/thinking-config.d.ts +19 -2
- package/dist/cliproxy/config/thinking-config.d.ts.map +1 -1
- package/dist/cliproxy/config/thinking-config.js +59 -9
- package/dist/cliproxy/config/thinking-config.js.map +1 -1
- package/dist/cliproxy/executor/env-resolver.d.ts +16 -0
- package/dist/cliproxy/executor/env-resolver.d.ts.map +1 -1
- package/dist/cliproxy/executor/env-resolver.js +82 -26
- package/dist/cliproxy/executor/env-resolver.js.map +1 -1
- package/dist/cliproxy/executor/index.d.ts.map +1 -1
- package/dist/cliproxy/executor/index.js +147 -34
- package/dist/cliproxy/executor/index.js.map +1 -1
- package/dist/cliproxy/executor/retry-handler.d.ts +11 -0
- package/dist/cliproxy/executor/retry-handler.d.ts.map +1 -1
- package/dist/cliproxy/executor/retry-handler.js +30 -1
- package/dist/cliproxy/executor/retry-handler.js.map +1 -1
- package/dist/cliproxy/provider-capabilities.d.ts +22 -0
- package/dist/cliproxy/provider-capabilities.d.ts.map +1 -0
- package/dist/cliproxy/provider-capabilities.js +95 -0
- package/dist/cliproxy/provider-capabilities.js.map +1 -0
- package/dist/cliproxy/quota-fetcher-codex.d.ts.map +1 -1
- package/dist/cliproxy/quota-fetcher-codex.js +106 -87
- package/dist/cliproxy/quota-fetcher-codex.js.map +1 -1
- package/dist/cliproxy/remote-auth-fetcher.d.ts.map +1 -1
- package/dist/cliproxy/remote-auth-fetcher.js +3 -26
- package/dist/cliproxy/remote-auth-fetcher.js.map +1 -1
- package/dist/cliproxy/services/index.d.ts +1 -1
- package/dist/cliproxy/services/index.d.ts.map +1 -1
- package/dist/cliproxy/services/index.js +3 -1
- package/dist/cliproxy/services/index.js.map +1 -1
- package/dist/cliproxy/services/variant-config-adapter.d.ts +15 -0
- package/dist/cliproxy/services/variant-config-adapter.d.ts.map +1 -1
- package/dist/cliproxy/services/variant-config-adapter.js +84 -11
- package/dist/cliproxy/services/variant-config-adapter.js.map +1 -1
- package/dist/cliproxy/services/variant-service.d.ts +26 -0
- package/dist/cliproxy/services/variant-service.d.ts.map +1 -1
- package/dist/cliproxy/services/variant-service.js +163 -9
- package/dist/cliproxy/services/variant-service.js.map +1 -1
- package/dist/cliproxy/services/variant-settings.d.ts +18 -0
- package/dist/cliproxy/services/variant-settings.d.ts.map +1 -1
- package/dist/cliproxy/services/variant-settings.js +126 -4
- package/dist/cliproxy/services/variant-settings.js.map +1 -1
- package/dist/cliproxy/types.d.ts +13 -0
- package/dist/cliproxy/types.d.ts.map +1 -1
- package/dist/cliproxy/types.js.map +1 -1
- package/dist/commands/cliproxy/auth-subcommand.d.ts.map +1 -1
- package/dist/commands/cliproxy/auth-subcommand.js +2 -1
- package/dist/commands/cliproxy/auth-subcommand.js.map +1 -1
- package/dist/commands/cliproxy/help-subcommand.d.ts.map +1 -1
- package/dist/commands/cliproxy/help-subcommand.js +2 -0
- package/dist/commands/cliproxy/help-subcommand.js.map +1 -1
- package/dist/commands/cliproxy/index.d.ts.map +1 -1
- package/dist/commands/cliproxy/index.js +4 -0
- package/dist/commands/cliproxy/index.js.map +1 -1
- package/dist/commands/cliproxy/quota-subcommand.d.ts.map +1 -1
- package/dist/commands/cliproxy/quota-subcommand.js +106 -4
- package/dist/commands/cliproxy/quota-subcommand.js.map +1 -1
- package/dist/commands/cliproxy/variant-subcommand.d.ts +1 -0
- package/dist/commands/cliproxy/variant-subcommand.d.ts.map +1 -1
- package/dist/commands/cliproxy/variant-subcommand.js +307 -3
- package/dist/commands/cliproxy/variant-subcommand.js.map +1 -1
- package/dist/commands/command-execution-contract.d.ts +23 -0
- package/dist/commands/command-execution-contract.d.ts.map +1 -0
- package/dist/commands/command-execution-contract.js +21 -0
- package/dist/commands/command-execution-contract.js.map +1 -0
- package/dist/commands/cursor-command.d.ts +12 -0
- package/dist/commands/cursor-command.d.ts.map +1 -0
- package/dist/commands/cursor-command.js +225 -0
- package/dist/commands/cursor-command.js.map +1 -0
- package/dist/commands/help-command.d.ts.map +1 -1
- package/dist/commands/help-command.js +14 -0
- package/dist/commands/help-command.js.map +1 -1
- package/dist/commands/shell-completion-command.d.ts +20 -0
- package/dist/commands/shell-completion-command.d.ts.map +1 -1
- package/dist/commands/shell-completion-command.js +45 -30
- package/dist/commands/shell-completion-command.js.map +1 -1
- package/dist/config/reserved-names.d.ts +1 -1
- package/dist/config/reserved-names.d.ts.map +1 -1
- package/dist/config/reserved-names.js +2 -0
- package/dist/config/reserved-names.js.map +1 -1
- package/dist/config/unified-config-loader.d.ts +6 -1
- package/dist/config/unified-config-loader.d.ts.map +1 -1
- package/dist/config/unified-config-loader.js +56 -2
- package/dist/config/unified-config-loader.js.map +1 -1
- package/dist/config/unified-config-types.d.ts +71 -2
- package/dist/config/unified-config-types.d.ts.map +1 -1
- package/dist/config/unified-config-types.js +27 -2
- package/dist/config/unified-config-types.js.map +1 -1
- package/dist/cursor/cursor-daemon.d.ts +47 -0
- package/dist/cursor/cursor-daemon.d.ts.map +1 -0
- package/dist/cursor/cursor-daemon.js +332 -0
- package/dist/cursor/cursor-daemon.js.map +1 -0
- package/dist/cursor/cursor-executor.d.ts +81 -0
- package/dist/cursor/cursor-executor.d.ts.map +1 -0
- package/dist/cursor/cursor-executor.js +821 -0
- package/dist/cursor/cursor-executor.js.map +1 -0
- package/dist/cursor/cursor-models.d.ts +43 -0
- package/dist/cursor/cursor-models.d.ts.map +1 -0
- package/dist/cursor/cursor-models.js +205 -0
- package/dist/cursor/cursor-models.js.map +1 -0
- package/dist/cursor/cursor-protobuf-decoder.d.ts +52 -0
- package/dist/cursor/cursor-protobuf-decoder.d.ts.map +1 -0
- package/dist/cursor/cursor-protobuf-decoder.js +311 -0
- package/dist/cursor/cursor-protobuf-decoder.js.map +1 -0
- package/dist/cursor/cursor-protobuf-encoder.d.ts +54 -0
- package/dist/cursor/cursor-protobuf-encoder.d.ts.map +1 -0
- package/dist/cursor/cursor-protobuf-encoder.js +173 -0
- package/dist/cursor/cursor-protobuf-encoder.js.map +1 -0
- package/dist/cursor/cursor-protobuf-schema.d.ts +215 -0
- package/dist/cursor/cursor-protobuf-schema.d.ts.map +1 -0
- package/dist/cursor/cursor-protobuf-schema.js +120 -0
- package/dist/cursor/cursor-protobuf-schema.js.map +1 -0
- package/dist/cursor/cursor-protobuf.d.ts +21 -0
- package/dist/cursor/cursor-protobuf.d.ts.map +1 -0
- package/dist/cursor/cursor-protobuf.js +116 -0
- package/dist/cursor/cursor-protobuf.js.map +1 -0
- package/dist/cursor/cursor-stream-parser.d.ts +52 -0
- package/dist/cursor/cursor-stream-parser.d.ts.map +1 -0
- package/dist/cursor/cursor-stream-parser.js +142 -0
- package/dist/cursor/cursor-stream-parser.js.map +1 -0
- package/dist/cursor/cursor-translator.d.ts +39 -0
- package/dist/cursor/cursor-translator.d.ts.map +1 -0
- package/dist/cursor/cursor-translator.js +118 -0
- package/dist/cursor/cursor-translator.js.map +1 -0
- package/dist/cursor/index.d.ts +11 -0
- package/dist/cursor/index.d.ts.map +1 -0
- package/dist/cursor/index.js +53 -0
- package/dist/cursor/index.js.map +1 -0
- package/dist/cursor/types.d.ts +33 -1
- package/dist/cursor/types.d.ts.map +1 -1
- package/dist/cursor/types.js +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/ui/assets/{accounts-CkN_roEn.js → accounts-D8ceTwko.js} +1 -1
- package/dist/ui/assets/{alert-dialog-Dy-8Z_Ud.js → alert-dialog-KnsD6NpU.js} +1 -1
- package/dist/ui/assets/{api-2TN7yVwm.js → api-Bp0E7mYy.js} +1 -1
- package/dist/ui/assets/{auth-section-CeKCNzzC.js → auth-section-D4quwqhL.js} +1 -1
- package/dist/ui/assets/{backups-section-CDuqhiZo.js → backups-section-D-oq--M3.js} +1 -1
- package/dist/ui/assets/cliproxy-BsgW2jbH.js +3 -0
- package/dist/ui/assets/{cliproxy-control-panel-DJd_zNR3.js → cliproxy-control-panel-B6xlfLnN.js} +1 -1
- package/dist/ui/assets/{confirm-dialog-DtYrWaa7.js → confirm-dialog-ConYUjNo.js} +1 -1
- package/dist/ui/assets/{copilot-DHdywZ9L.js → copilot-BO0JhNVL.js} +3 -3
- package/dist/ui/assets/{globalenv-section-Cn5ufgRh.js → globalenv-section-CGiUottp.js} +1 -1
- package/dist/ui/assets/{health-BsMhSeFz.js → health-DnkFdo0B.js} +1 -1
- package/dist/ui/assets/index-ByiEOnlQ.css +1 -0
- package/dist/ui/assets/{index-CEF_VhSR.js → index-C_MPOoUZ.js} +1 -1
- package/dist/ui/assets/index-CxWM9Sgz.js +1 -0
- package/dist/ui/assets/index-D4L2ZIJs.js +47 -0
- package/dist/ui/assets/{index-B2GQ_Joi.js → index-DcYq7jVv.js} +1 -1
- package/dist/ui/assets/{index-DkMR3J96.js → index-aB5MHYio.js} +1 -1
- package/dist/ui/assets/{proxy-status-widget-Cb7KfEqq.js → proxy-status-widget-BbZeFxlJ.js} +1 -1
- package/dist/ui/assets/{shared-BsWeldW8.js → shared-B_aV9M2M.js} +1 -1
- package/dist/ui/assets/{switch-D6XSRTo_.js → switch-60ycFRmr.js} +1 -1
- package/dist/ui/index.html +2 -2
- package/dist/utils/config-manager.d.ts.map +1 -1
- package/dist/utils/config-manager.js +17 -6
- package/dist/utils/config-manager.js.map +1 -1
- package/dist/web-server/jsonl-parser.js +1 -1
- package/dist/web-server/jsonl-parser.js.map +1 -1
- package/dist/web-server/routes/account-routes.d.ts.map +1 -1
- package/dist/web-server/routes/account-routes.js +5 -11
- package/dist/web-server/routes/account-routes.js.map +1 -1
- package/dist/web-server/routes/cliproxy-stats-routes.d.ts.map +1 -1
- package/dist/web-server/routes/cliproxy-stats-routes.js +43 -4
- package/dist/web-server/routes/cliproxy-stats-routes.js.map +1 -1
- package/dist/web-server/routes/cursor-routes.d.ts +6 -0
- package/dist/web-server/routes/cursor-routes.d.ts.map +1 -0
- package/dist/web-server/routes/cursor-routes.js +163 -0
- package/dist/web-server/routes/cursor-routes.js.map +1 -0
- package/dist/web-server/routes/cursor-settings-routes.d.ts +6 -0
- package/dist/web-server/routes/cursor-settings-routes.d.ts.map +1 -0
- package/dist/web-server/routes/cursor-settings-routes.js +171 -0
- package/dist/web-server/routes/cursor-settings-routes.js.map +1 -0
- package/dist/web-server/routes/index.d.ts.map +1 -1
- package/dist/web-server/routes/index.js +3 -0
- package/dist/web-server/routes/index.js.map +1 -1
- package/dist/web-server/routes/variant-routes.d.ts.map +1 -1
- package/dist/web-server/routes/variant-routes.js +107 -6
- package/dist/web-server/routes/variant-routes.js.map +1 -1
- package/package.json +5 -2
- package/scripts/hardening-inventory.js +526 -0
- package/scripts/maintainability-baseline.js +309 -0
- package/dist/ui/assets/cliproxy-626zUpA_.js +0 -3
- package/dist/ui/assets/index-Bmgylhgn.js +0 -1
- package/dist/ui/assets/index-Cr6iEc8x.js +0 -47
- package/dist/ui/assets/index-QvMpU4Lc.css +0 -1
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Cursor Daemon Manager
|
|
4
|
+
*
|
|
5
|
+
* Manages the cursor daemon lifecycle (start/stop/status).
|
|
6
|
+
* Uses CursorExecutor for OpenAI-compatible API proxy to Cursor backend.
|
|
7
|
+
*/
|
|
8
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
}) : (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
}));
|
|
19
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
20
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
21
|
+
}) : function(o, v) {
|
|
22
|
+
o["default"] = v;
|
|
23
|
+
});
|
|
24
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
|
+
if (mod && mod.__esModule) return mod;
|
|
26
|
+
var result = {};
|
|
27
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
28
|
+
__setModuleDefault(result, mod);
|
|
29
|
+
return result;
|
|
30
|
+
};
|
|
31
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
+
exports.stopDaemon = exports.startDaemon = exports.removePidFile = exports.writePidToFile = exports.getPidFromFile = exports.getDaemonStatus = exports.isDaemonRunning = void 0;
|
|
33
|
+
const child_process_1 = require("child_process");
|
|
34
|
+
const fs = __importStar(require("fs"));
|
|
35
|
+
const path = __importStar(require("path"));
|
|
36
|
+
const http = __importStar(require("http"));
|
|
37
|
+
const config_manager_1 = require("../utils/config-manager");
|
|
38
|
+
/**
|
|
39
|
+
* Get Cursor directory path.
|
|
40
|
+
*/
|
|
41
|
+
function getCursorDir() {
|
|
42
|
+
return path.join((0, config_manager_1.getCcsDir)(), 'cursor');
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Get PID file path.
|
|
46
|
+
* Computed at runtime to respect CCS_HOME changes (e.g., in tests).
|
|
47
|
+
*/
|
|
48
|
+
function getPidFilePath() {
|
|
49
|
+
return path.join(getCursorDir(), 'daemon.pid');
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Check if cursor daemon is running on the specified port.
|
|
53
|
+
* Uses 127.0.0.1 instead of localhost for more reliable local connections.
|
|
54
|
+
*/
|
|
55
|
+
async function isDaemonRunning(port) {
|
|
56
|
+
return new Promise((resolve) => {
|
|
57
|
+
const req = http.request({
|
|
58
|
+
hostname: '127.0.0.1',
|
|
59
|
+
port,
|
|
60
|
+
path: '/health',
|
|
61
|
+
method: 'GET',
|
|
62
|
+
timeout: 3000,
|
|
63
|
+
}, (res) => {
|
|
64
|
+
res.resume(); // Drain response body
|
|
65
|
+
resolve(res.statusCode === 200);
|
|
66
|
+
});
|
|
67
|
+
req.on('error', () => {
|
|
68
|
+
resolve(false);
|
|
69
|
+
});
|
|
70
|
+
req.on('timeout', () => {
|
|
71
|
+
req.destroy();
|
|
72
|
+
resolve(false);
|
|
73
|
+
});
|
|
74
|
+
req.end();
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
exports.isDaemonRunning = isDaemonRunning;
|
|
78
|
+
/**
|
|
79
|
+
* Get daemon status.
|
|
80
|
+
*/
|
|
81
|
+
async function getDaemonStatus(port) {
|
|
82
|
+
const running = await isDaemonRunning(port);
|
|
83
|
+
const pid = getPidFromFile();
|
|
84
|
+
return {
|
|
85
|
+
running,
|
|
86
|
+
port,
|
|
87
|
+
pid: running ? (pid ?? undefined) : undefined,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
exports.getDaemonStatus = getDaemonStatus;
|
|
91
|
+
/**
|
|
92
|
+
* Read PID from file.
|
|
93
|
+
*/
|
|
94
|
+
function getPidFromFile() {
|
|
95
|
+
const pidFile = getPidFilePath();
|
|
96
|
+
try {
|
|
97
|
+
if (fs.existsSync(pidFile)) {
|
|
98
|
+
const content = fs.readFileSync(pidFile, 'utf8').trim();
|
|
99
|
+
const pid = parseInt(content, 10);
|
|
100
|
+
return isNaN(pid) ? null : pid;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
// Ignore errors
|
|
105
|
+
}
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
exports.getPidFromFile = getPidFromFile;
|
|
109
|
+
/**
|
|
110
|
+
* Write PID to file.
|
|
111
|
+
*/
|
|
112
|
+
function writePidToFile(pid) {
|
|
113
|
+
const pidFile = getPidFilePath();
|
|
114
|
+
try {
|
|
115
|
+
const dir = path.dirname(pidFile);
|
|
116
|
+
if (!fs.existsSync(dir)) {
|
|
117
|
+
fs.mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
118
|
+
}
|
|
119
|
+
fs.writeFileSync(pidFile, pid.toString(), { mode: 0o600 });
|
|
120
|
+
}
|
|
121
|
+
catch {
|
|
122
|
+
// Ignore errors
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
exports.writePidToFile = writePidToFile;
|
|
126
|
+
/**
|
|
127
|
+
* Remove PID file.
|
|
128
|
+
*/
|
|
129
|
+
function removePidFile() {
|
|
130
|
+
const pidFile = getPidFilePath();
|
|
131
|
+
try {
|
|
132
|
+
if (fs.existsSync(pidFile)) {
|
|
133
|
+
fs.unlinkSync(pidFile);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
catch {
|
|
137
|
+
// Ignore errors
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
exports.removePidFile = removePidFile;
|
|
141
|
+
/**
|
|
142
|
+
* Start the cursor daemon.
|
|
143
|
+
*
|
|
144
|
+
* @param config Cursor configuration
|
|
145
|
+
* @returns Promise that resolves when daemon is ready
|
|
146
|
+
*/
|
|
147
|
+
async function startDaemon(config) {
|
|
148
|
+
// Check if already running
|
|
149
|
+
if (await isDaemonRunning(config.port)) {
|
|
150
|
+
return { success: true, pid: getPidFromFile() ?? undefined };
|
|
151
|
+
}
|
|
152
|
+
// Validate port before interpolation (prevents injection)
|
|
153
|
+
if (!Number.isInteger(config.port) || config.port < 1 || config.port > 65535) {
|
|
154
|
+
return { success: false, error: `Invalid port: ${config.port}` };
|
|
155
|
+
}
|
|
156
|
+
// For now, create a simple structure that will be filled in later
|
|
157
|
+
// The actual server implementation will be added in a separate task
|
|
158
|
+
return new Promise((resolve) => {
|
|
159
|
+
let proc;
|
|
160
|
+
let resolved = false;
|
|
161
|
+
const safeResolve = (result) => {
|
|
162
|
+
if (resolved)
|
|
163
|
+
return;
|
|
164
|
+
resolved = true;
|
|
165
|
+
if (checkTimeout)
|
|
166
|
+
clearTimeout(checkTimeout);
|
|
167
|
+
if (!result.success)
|
|
168
|
+
removePidFile();
|
|
169
|
+
resolve(result);
|
|
170
|
+
};
|
|
171
|
+
let checkTimeout = null;
|
|
172
|
+
try {
|
|
173
|
+
// Spawn a placeholder Node.js process
|
|
174
|
+
// TODO: Replace with actual CursorExecutor-based server
|
|
175
|
+
const args = [
|
|
176
|
+
'-e',
|
|
177
|
+
`
|
|
178
|
+
const http = require('http');
|
|
179
|
+
const server = http.createServer((req, res) => {
|
|
180
|
+
if (req.url === '/health') {
|
|
181
|
+
res.writeHead(200);
|
|
182
|
+
res.end('OK');
|
|
183
|
+
} else if (req.url === '/v1/models') {
|
|
184
|
+
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
185
|
+
res.end(JSON.stringify({ data: [] }));
|
|
186
|
+
} else {
|
|
187
|
+
res.writeHead(404);
|
|
188
|
+
res.end('Not found');
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
server.listen(${config.port}, '127.0.0.1');
|
|
192
|
+
`,
|
|
193
|
+
];
|
|
194
|
+
// Append --ccs-daemon marker for PID validation in stopDaemon
|
|
195
|
+
proc = (0, child_process_1.spawn)(process.execPath, [...args, '--ccs-daemon'], {
|
|
196
|
+
stdio: 'ignore',
|
|
197
|
+
detached: true,
|
|
198
|
+
});
|
|
199
|
+
// Unref so parent can exit
|
|
200
|
+
proc.unref();
|
|
201
|
+
if (proc.pid) {
|
|
202
|
+
writePidToFile(proc.pid);
|
|
203
|
+
}
|
|
204
|
+
// Wait for daemon to be ready (poll for up to 30 seconds)
|
|
205
|
+
let attempts = 0;
|
|
206
|
+
const maxAttempts = 30;
|
|
207
|
+
const pollHealth = async () => {
|
|
208
|
+
attempts++;
|
|
209
|
+
if (await isDaemonRunning(config.port)) {
|
|
210
|
+
safeResolve({ success: true, pid: proc.pid });
|
|
211
|
+
}
|
|
212
|
+
else if (attempts >= maxAttempts) {
|
|
213
|
+
// Kill orphaned process
|
|
214
|
+
if (proc.pid) {
|
|
215
|
+
try {
|
|
216
|
+
process.kill(proc.pid, 'SIGTERM');
|
|
217
|
+
}
|
|
218
|
+
catch {
|
|
219
|
+
/* already dead */
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
safeResolve({
|
|
223
|
+
success: false,
|
|
224
|
+
error: 'Daemon did not start within 30 seconds',
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
checkTimeout = setTimeout(pollHealth, 1000);
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
checkTimeout = setTimeout(pollHealth, 1000);
|
|
232
|
+
proc.on('error', (err) => {
|
|
233
|
+
safeResolve({
|
|
234
|
+
success: false,
|
|
235
|
+
error: `Failed to start daemon: ${err.message}`,
|
|
236
|
+
});
|
|
237
|
+
});
|
|
238
|
+
proc.on('exit', (code, signal) => {
|
|
239
|
+
if (code === null) {
|
|
240
|
+
safeResolve({
|
|
241
|
+
success: false,
|
|
242
|
+
error: `Daemon process was killed by signal ${signal}`,
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
else if (code === 0) {
|
|
246
|
+
safeResolve({
|
|
247
|
+
success: false,
|
|
248
|
+
error: 'Daemon process exited unexpectedly with code 0',
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
safeResolve({
|
|
253
|
+
success: false,
|
|
254
|
+
error: `Daemon process exited with code ${code}`,
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
catch (err) {
|
|
260
|
+
safeResolve({
|
|
261
|
+
success: false,
|
|
262
|
+
error: `Failed to spawn daemon: ${err.message}`,
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
exports.startDaemon = startDaemon;
|
|
268
|
+
/**
|
|
269
|
+
* Stop the cursor daemon.
|
|
270
|
+
*/
|
|
271
|
+
async function stopDaemon() {
|
|
272
|
+
const pid = getPidFromFile();
|
|
273
|
+
if (!pid) {
|
|
274
|
+
// No PID file — daemon is not running or was already stopped
|
|
275
|
+
return { success: true };
|
|
276
|
+
}
|
|
277
|
+
try {
|
|
278
|
+
// Verify the PID belongs to our daemon before signaling
|
|
279
|
+
try {
|
|
280
|
+
const cmdline = fs.readFileSync(`/proc/${pid}/cmdline`, 'utf8');
|
|
281
|
+
if (!cmdline.includes('--ccs-daemon')) {
|
|
282
|
+
// PID was reused by an unrelated process
|
|
283
|
+
removePidFile();
|
|
284
|
+
return { success: true };
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
catch {
|
|
288
|
+
// /proc not available (macOS/Windows) or process gone — proceed with kill
|
|
289
|
+
}
|
|
290
|
+
// Send SIGTERM to the process
|
|
291
|
+
process.kill(pid, 'SIGTERM');
|
|
292
|
+
// Wait for process to exit (up to 5 seconds)
|
|
293
|
+
let attempts = 0;
|
|
294
|
+
while (attempts < 10) {
|
|
295
|
+
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
296
|
+
try {
|
|
297
|
+
// Check if process still exists (kill(pid, 0) throws if not)
|
|
298
|
+
process.kill(pid, 0);
|
|
299
|
+
attempts++;
|
|
300
|
+
}
|
|
301
|
+
catch {
|
|
302
|
+
// Process no longer exists
|
|
303
|
+
break;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
// Escalate to SIGKILL only if SIGTERM wait loop exhausted
|
|
307
|
+
if (attempts >= 10) {
|
|
308
|
+
try {
|
|
309
|
+
process.kill(pid, 'SIGKILL');
|
|
310
|
+
}
|
|
311
|
+
catch {
|
|
312
|
+
// Already dead — good
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
removePidFile();
|
|
316
|
+
return { success: true };
|
|
317
|
+
}
|
|
318
|
+
catch (err) {
|
|
319
|
+
const error = err;
|
|
320
|
+
if (error.code === 'ESRCH') {
|
|
321
|
+
// Process doesn't exist
|
|
322
|
+
removePidFile();
|
|
323
|
+
return { success: true };
|
|
324
|
+
}
|
|
325
|
+
return {
|
|
326
|
+
success: false,
|
|
327
|
+
error: `Failed to stop daemon: ${error.message}`,
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
exports.stopDaemon = stopDaemon;
|
|
332
|
+
//# sourceMappingURL=cursor-daemon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cursor-daemon.js","sourceRoot":"","sources":["../../src/cursor/cursor-daemon.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,iDAAoD;AACpD,uCAAyB;AACzB,2CAA6B;AAC7B,2CAA6B;AAE7B,4DAAoD;AAEpD;;GAEG;AACH,SAAS,YAAY;IACnB,OAAO,IAAI,CAAC,IAAI,CAAC,IAAA,0BAAS,GAAE,EAAE,QAAQ,CAAC,CAAC;AAC1C,CAAC;AAED;;;GAGG;AACH,SAAS,cAAc;IACrB,OAAO,IAAI,CAAC,IA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A0B,KAAK,CAAC,OAAO,EAAE;SACjD,CAAC;IACJ,CAAC;AACH,CAAC;AA7DD,gCA6DC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cursor Executor
|
|
3
|
+
* Handles HTTP/2 requests to Cursor API with protobuf encoding/decoding
|
|
4
|
+
*/
|
|
5
|
+
/// <reference types="node" />
|
|
6
|
+
/// <reference types="node" />
|
|
7
|
+
/// <reference types="node" />
|
|
8
|
+
/// <reference types="node" />
|
|
9
|
+
import type { IncomingHttpHeaders } from 'http';
|
|
10
|
+
import type { CursorTool, CursorCredentials } from './cursor-protobuf-schema.js';
|
|
11
|
+
/** Executor parameters */
|
|
12
|
+
interface ExecutorParams {
|
|
13
|
+
model: string;
|
|
14
|
+
body: {
|
|
15
|
+
messages: Array<{
|
|
16
|
+
role: string;
|
|
17
|
+
content: string | Array<{
|
|
18
|
+
type: string;
|
|
19
|
+
text?: string;
|
|
20
|
+
}>;
|
|
21
|
+
name?: string;
|
|
22
|
+
tool_call_id?: string;
|
|
23
|
+
tool_calls?: Array<{
|
|
24
|
+
id: string;
|
|
25
|
+
type: string;
|
|
26
|
+
function: {
|
|
27
|
+
name: string;
|
|
28
|
+
arguments: string;
|
|
29
|
+
};
|
|
30
|
+
}>;
|
|
31
|
+
}>;
|
|
32
|
+
tools?: CursorTool[];
|
|
33
|
+
reasoning_effort?: string;
|
|
34
|
+
};
|
|
35
|
+
stream: boolean;
|
|
36
|
+
credentials: CursorCredentials;
|
|
37
|
+
signal?: AbortSignal;
|
|
38
|
+
}
|
|
39
|
+
/** HTTP/2 response structure */
|
|
40
|
+
interface Http2Response {
|
|
41
|
+
status: number;
|
|
42
|
+
headers: IncomingHttpHeaders;
|
|
43
|
+
body: Buffer;
|
|
44
|
+
}
|
|
45
|
+
export declare class CursorExecutor {
|
|
46
|
+
private readonly baseUrl;
|
|
47
|
+
private readonly chatPath;
|
|
48
|
+
private readonly CURSOR_CLIENT_VERSION;
|
|
49
|
+
private readonly CURSOR_USER_AGENT;
|
|
50
|
+
buildUrl(): string;
|
|
51
|
+
/**
|
|
52
|
+
* Generate checksum using Jyh cipher (time-based XOR with rolling key seed=165)
|
|
53
|
+
*/
|
|
54
|
+
generateChecksum(machineId: string): string;
|
|
55
|
+
buildHeaders(credentials: CursorCredentials): Record<string, string>;
|
|
56
|
+
transformRequest(model: string, body: ExecutorParams['body'], stream: boolean, credentials: CursorCredentials): Uint8Array;
|
|
57
|
+
makeFetchRequest(url: string, headers: Record<string, string>, body: Uint8Array, signal?: AbortSignal): Promise<Http2Response>;
|
|
58
|
+
makeHttp2Request(url: string, headers: Record<string, string>, body: Uint8Array, signal?: AbortSignal): Promise<Http2Response>;
|
|
59
|
+
execute(params: ExecutorParams): Promise<{
|
|
60
|
+
response: Response;
|
|
61
|
+
url: string;
|
|
62
|
+
headers: Record<string, string>;
|
|
63
|
+
transformedBody: ExecutorParams['body'];
|
|
64
|
+
}>;
|
|
65
|
+
/**
|
|
66
|
+
* Execute a streaming request, piping HTTP/2 data events through
|
|
67
|
+
* StreamingFrameParser for incremental SSE output.
|
|
68
|
+
* Falls back to buffered transformProtobufToSSE when http2 is unavailable.
|
|
69
|
+
*/
|
|
70
|
+
private executeStreaming;
|
|
71
|
+
/**
|
|
72
|
+
* Parse protobuf buffer into frames and extract text/toolcalls.
|
|
73
|
+
* Shared logic between JSON and SSE transformers.
|
|
74
|
+
*/
|
|
75
|
+
private parseProtobufFrames;
|
|
76
|
+
transformProtobufToJSON(buffer: Buffer, model: string, _body: ExecutorParams['body']): Response;
|
|
77
|
+
/** @deprecated Use executeStreaming() for real-time SSE. Retained for fetch fallback. */
|
|
78
|
+
transformProtobufToSSE(buffer: Buffer, model: string, _body: ExecutorParams['body']): Response;
|
|
79
|
+
}
|
|
80
|
+
export default CursorExecutor;
|
|
81
|
+
//# sourceMappingURL=cursor-executor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cursor-executor.d.ts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