@cmdctrl/cursor-ide 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapter/cdp-client.d.ts +66 -0
- package/dist/adapter/cdp-client.d.ts.map +1 -0
- package/dist/adapter/cdp-client.js +304 -0
- package/dist/adapter/cdp-client.js.map +1 -0
- package/dist/adapter/cursor-db.d.ts +114 -0
- package/dist/adapter/cursor-db.d.ts.map +1 -0
- package/dist/adapter/cursor-db.js +438 -0
- package/dist/adapter/cursor-db.js.map +1 -0
- package/dist/client/messages.d.ts +98 -0
- package/dist/client/messages.d.ts.map +1 -0
- package/dist/client/messages.js +6 -0
- package/dist/client/messages.js.map +1 -0
- package/dist/client/websocket.d.ts +103 -0
- package/dist/client/websocket.d.ts.map +1 -0
- package/dist/client/websocket.js +428 -0
- package/dist/client/websocket.js.map +1 -0
- package/dist/commands/register.d.ts +10 -0
- package/dist/commands/register.d.ts.map +1 -0
- package/dist/commands/register.js +175 -0
- package/dist/commands/register.js.map +1 -0
- package/dist/commands/start.d.ts +9 -0
- package/dist/commands/start.d.ts.map +1 -0
- package/dist/commands/start.js +86 -0
- package/dist/commands/start.js.map +1 -0
- package/dist/commands/status.d.ts +5 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +75 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/stop.d.ts +5 -0
- package/dist/commands/stop.d.ts.map +1 -0
- package/dist/commands/stop.js +59 -0
- package/dist/commands/stop.js.map +1 -0
- package/dist/config/config.d.ts +68 -0
- package/dist/config/config.d.ts.map +1 -0
- package/dist/config/config.js +189 -0
- package/dist/config/config.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +34 -0
- package/dist/index.js.map +1 -0
- package/dist/session-discovery.d.ts +22 -0
- package/dist/session-discovery.d.ts.map +1 -0
- package/dist/session-discovery.js +90 -0
- package/dist/session-discovery.js.map +1 -0
- package/dist/session-watcher.d.ts +62 -0
- package/dist/session-watcher.d.ts.map +1 -0
- package/dist/session-watcher.js +210 -0
- package/dist/session-watcher.js.map +1 -0
- package/package.json +40 -0
- package/src/adapter/cdp-client.ts +296 -0
- package/src/adapter/cursor-db.ts +486 -0
- package/src/client/messages.ts +138 -0
- package/src/client/websocket.ts +486 -0
- package/src/commands/register.ts +201 -0
- package/src/commands/start.ts +106 -0
- package/src/commands/status.ts +83 -0
- package/src/commands/stop.ts +58 -0
- package/src/config/config.ts +167 -0
- package/src/index.ts +39 -0
- package/src/session-discovery.ts +115 -0
- package/src/session-watcher.ts +253 -0
- package/tsconfig.json +19 -0
|
@@ -0,0 +1,438 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.CursorDB = void 0;
|
|
40
|
+
exports.getCursorDB = getCursorDB;
|
|
41
|
+
const better_sqlite3_1 = __importDefault(require("better-sqlite3"));
|
|
42
|
+
const fs = __importStar(require("fs"));
|
|
43
|
+
const path = __importStar(require("path"));
|
|
44
|
+
const config_1 = require("../config/config");
|
|
45
|
+
/**
|
|
46
|
+
* Cursor SQLite Database Reader
|
|
47
|
+
* Reads conversation data from Cursor's local storage
|
|
48
|
+
*/
|
|
49
|
+
class CursorDB {
|
|
50
|
+
globalDb = null;
|
|
51
|
+
lastOpenAttempt = 0;
|
|
52
|
+
lastRefresh = 0;
|
|
53
|
+
RETRY_INTERVAL = 5000; // 5 seconds between retries
|
|
54
|
+
REFRESH_INTERVAL = 2000; // 2s - refresh connection to see WAL updates
|
|
55
|
+
/**
|
|
56
|
+
* Check if the Cursor database exists
|
|
57
|
+
*/
|
|
58
|
+
static exists() {
|
|
59
|
+
return fs.existsSync(config_1.CURSOR_GLOBAL_STORAGE);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Open the global storage database (read-only)
|
|
63
|
+
* Periodically refreshes the connection to see WAL updates from Cursor
|
|
64
|
+
*/
|
|
65
|
+
openGlobalDb() {
|
|
66
|
+
const now = Date.now();
|
|
67
|
+
// If we have a connection but it's stale, refresh it to see WAL updates
|
|
68
|
+
if (this.globalDb && now - this.lastRefresh > this.REFRESH_INTERVAL) {
|
|
69
|
+
this.globalDb.close();
|
|
70
|
+
this.globalDb = null;
|
|
71
|
+
// Reset lastOpenAttempt so we don't hit the retry cooldown after refresh
|
|
72
|
+
this.lastOpenAttempt = 0;
|
|
73
|
+
}
|
|
74
|
+
if (this.globalDb) {
|
|
75
|
+
return this.globalDb;
|
|
76
|
+
}
|
|
77
|
+
// Don't retry too frequently after FAILED open attempts (not refreshes)
|
|
78
|
+
if (this.lastOpenAttempt > 0 && now - this.lastOpenAttempt < this.RETRY_INTERVAL) {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
if (!CursorDB.exists()) {
|
|
82
|
+
console.warn('[CursorDB] Database not found:', config_1.CURSOR_GLOBAL_STORAGE);
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
try {
|
|
86
|
+
this.globalDb = new better_sqlite3_1.default(config_1.CURSOR_GLOBAL_STORAGE, {
|
|
87
|
+
readonly: true,
|
|
88
|
+
fileMustExist: true,
|
|
89
|
+
});
|
|
90
|
+
// Force WAL checkpoint to see latest changes
|
|
91
|
+
try {
|
|
92
|
+
this.globalDb.pragma('wal_checkpoint(PASSIVE)');
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
// Checkpoint may fail on readonly, that's ok
|
|
96
|
+
}
|
|
97
|
+
this.lastRefresh = now;
|
|
98
|
+
this.lastOpenAttempt = now;
|
|
99
|
+
return this.globalDb;
|
|
100
|
+
}
|
|
101
|
+
catch (err) {
|
|
102
|
+
console.error('[CursorDB] Failed to open database:', err);
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Close database connections
|
|
108
|
+
*/
|
|
109
|
+
close() {
|
|
110
|
+
if (this.globalDb) {
|
|
111
|
+
this.globalDb.close();
|
|
112
|
+
this.globalDb = null;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Extract project path from composer context
|
|
117
|
+
* Looks at fileSelections and folderSelections for path info
|
|
118
|
+
*/
|
|
119
|
+
extractProjectPath(context) {
|
|
120
|
+
if (!context || typeof context !== 'object') {
|
|
121
|
+
return undefined;
|
|
122
|
+
}
|
|
123
|
+
const ctx = context;
|
|
124
|
+
// Try folderSelections first
|
|
125
|
+
const folderSelections = ctx.folderSelections;
|
|
126
|
+
if (folderSelections?.length) {
|
|
127
|
+
const firstFolder = folderSelections[0]?.uri?.fsPath;
|
|
128
|
+
if (firstFolder) {
|
|
129
|
+
return firstFolder;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
// Try fileSelections - extract directory from first file
|
|
133
|
+
const fileSelections = ctx.fileSelections;
|
|
134
|
+
if (fileSelections?.length) {
|
|
135
|
+
const firstFile = fileSelections[0]?.uri?.fsPath;
|
|
136
|
+
if (firstFile) {
|
|
137
|
+
// Find a reasonable project root (go up to find common patterns)
|
|
138
|
+
return this.findProjectRoot(firstFile);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return undefined;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Find project root from a file path
|
|
145
|
+
* Looks for common project markers (package.json, .git, go.mod, etc.)
|
|
146
|
+
*/
|
|
147
|
+
findProjectRoot(filePath) {
|
|
148
|
+
let dir = path.dirname(filePath);
|
|
149
|
+
const markers = ['package.json', '.git', 'go.mod', 'Cargo.toml', 'pyproject.toml', 'pom.xml'];
|
|
150
|
+
// Walk up max 10 levels
|
|
151
|
+
for (let i = 0; i < 10 && dir !== '/'; i++) {
|
|
152
|
+
for (const marker of markers) {
|
|
153
|
+
if (fs.existsSync(path.join(dir, marker))) {
|
|
154
|
+
return dir;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
dir = path.dirname(dir);
|
|
158
|
+
}
|
|
159
|
+
// If no marker found, return the parent of the file
|
|
160
|
+
return path.dirname(filePath);
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Get all composers (conversation sessions)
|
|
164
|
+
*/
|
|
165
|
+
getComposers() {
|
|
166
|
+
const db = this.openGlobalDb();
|
|
167
|
+
if (!db)
|
|
168
|
+
return [];
|
|
169
|
+
try {
|
|
170
|
+
const stmt = db.prepare(`
|
|
171
|
+
SELECT key, value FROM cursorDiskKV
|
|
172
|
+
WHERE key LIKE 'composerData:%'
|
|
173
|
+
`);
|
|
174
|
+
const rows = stmt.all();
|
|
175
|
+
const allComposers = [];
|
|
176
|
+
for (const row of rows) {
|
|
177
|
+
try {
|
|
178
|
+
const valueStr = typeof row.value === 'string'
|
|
179
|
+
? row.value
|
|
180
|
+
: row.value.toString('utf-8');
|
|
181
|
+
const data = JSON.parse(valueStr);
|
|
182
|
+
// Each composerData:* key contains ONE composer directly
|
|
183
|
+
// Format: { _v, composerId, name, createdAt, lastUpdatedAt, context, ... }
|
|
184
|
+
if (data.composerId) {
|
|
185
|
+
const composerId = data.composerId;
|
|
186
|
+
const createdAt = data.createdAt || Date.now();
|
|
187
|
+
// Use lastUpdatedAt if present, otherwise fall back to createdAt
|
|
188
|
+
const lastUpdatedAt = data.lastUpdatedAt || createdAt;
|
|
189
|
+
// Try to extract project path from file context
|
|
190
|
+
const projectPath = this.extractProjectPath(data.context);
|
|
191
|
+
allComposers.push({
|
|
192
|
+
composerId,
|
|
193
|
+
name: data.name || 'Untitled Session',
|
|
194
|
+
createdAt,
|
|
195
|
+
lastUpdatedAt,
|
|
196
|
+
unifiedMode: data.unifiedMode || 'unknown',
|
|
197
|
+
contextUsagePercent: data.contextUsagePercent || 0,
|
|
198
|
+
projectPath,
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
catch {
|
|
203
|
+
// Skip malformed entries
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
return allComposers.sort((a, b) => b.lastUpdatedAt - a.lastUpdatedAt);
|
|
207
|
+
}
|
|
208
|
+
catch (err) {
|
|
209
|
+
console.error('[CursorDB] Error getting composers:', err);
|
|
210
|
+
return [];
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Get composer data including conversation headers
|
|
215
|
+
*/
|
|
216
|
+
getComposerData(composerId) {
|
|
217
|
+
const db = this.openGlobalDb();
|
|
218
|
+
if (!db)
|
|
219
|
+
return null;
|
|
220
|
+
try {
|
|
221
|
+
const stmt = db.prepare(`
|
|
222
|
+
SELECT value FROM cursorDiskKV
|
|
223
|
+
WHERE key = ?
|
|
224
|
+
`);
|
|
225
|
+
const row = stmt.get(`composerData:${composerId}`);
|
|
226
|
+
if (!row)
|
|
227
|
+
return null;
|
|
228
|
+
const valueStr = typeof row.value === 'string'
|
|
229
|
+
? row.value
|
|
230
|
+
: row.value.toString('utf-8');
|
|
231
|
+
return JSON.parse(valueStr);
|
|
232
|
+
}
|
|
233
|
+
catch (err) {
|
|
234
|
+
console.error('[CursorDB] Error getting composer data:', err);
|
|
235
|
+
return null;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Get all bubbles (messages) for a composer
|
|
240
|
+
*/
|
|
241
|
+
getBubbles(composerId) {
|
|
242
|
+
const db = this.openGlobalDb();
|
|
243
|
+
if (!db)
|
|
244
|
+
return [];
|
|
245
|
+
try {
|
|
246
|
+
const stmt = db.prepare(`
|
|
247
|
+
SELECT key, value FROM cursorDiskKV
|
|
248
|
+
WHERE key LIKE ?
|
|
249
|
+
`);
|
|
250
|
+
const pattern = `bubbleId:${composerId}:%`;
|
|
251
|
+
const rows = stmt.all(pattern);
|
|
252
|
+
const bubbles = [];
|
|
253
|
+
for (const row of rows) {
|
|
254
|
+
try {
|
|
255
|
+
const valueStr = typeof row.value === 'string'
|
|
256
|
+
? row.value
|
|
257
|
+
: row.value.toString('utf-8');
|
|
258
|
+
const bubble = JSON.parse(valueStr);
|
|
259
|
+
bubbles.push(bubble);
|
|
260
|
+
}
|
|
261
|
+
catch {
|
|
262
|
+
// Skip malformed entries
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
// Sort by creation time
|
|
266
|
+
return bubbles.sort((a, b) => new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime());
|
|
267
|
+
}
|
|
268
|
+
catch (err) {
|
|
269
|
+
console.error('[CursorDB] Error getting bubbles:', err);
|
|
270
|
+
return [];
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Get the latest bubble for a composer (optimized - uses SQL sorting)
|
|
275
|
+
*/
|
|
276
|
+
getLatestBubble(composerId) {
|
|
277
|
+
const db = this.openGlobalDb();
|
|
278
|
+
if (!db)
|
|
279
|
+
return null;
|
|
280
|
+
try {
|
|
281
|
+
// Use json_extract to sort by createdAt directly in SQL
|
|
282
|
+
const stmt = db.prepare(`
|
|
283
|
+
SELECT key, value FROM cursorDiskKV
|
|
284
|
+
WHERE key LIKE ?
|
|
285
|
+
ORDER BY json_extract(value, '$.createdAt') DESC
|
|
286
|
+
LIMIT 1
|
|
287
|
+
`);
|
|
288
|
+
const pattern = `bubbleId:${composerId}:%`;
|
|
289
|
+
const row = stmt.get(pattern);
|
|
290
|
+
if (!row || !row.value)
|
|
291
|
+
return null;
|
|
292
|
+
const valueStr = typeof row.value === 'string'
|
|
293
|
+
? row.value
|
|
294
|
+
: row.value.toString('utf-8');
|
|
295
|
+
return JSON.parse(valueStr);
|
|
296
|
+
}
|
|
297
|
+
catch (err) {
|
|
298
|
+
console.error('[CursorDB] Error getting latest bubble:', err);
|
|
299
|
+
return null;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Get messages for a session in a format compatible with CmdCtrl API
|
|
304
|
+
* @param composerId The composer/session ID
|
|
305
|
+
* @param limit Maximum number of messages to return
|
|
306
|
+
* @param beforeUuid Return messages before this UUID (for backward pagination)
|
|
307
|
+
* @param afterUuid Return messages after this UUID (for incremental/forward fetches)
|
|
308
|
+
*/
|
|
309
|
+
getMessages(composerId, limit = 30, beforeUuid, afterUuid) {
|
|
310
|
+
const bubbles = this.getBubbles(composerId);
|
|
311
|
+
// Handle afterUuid for incremental fetches (messages AFTER the given UUID)
|
|
312
|
+
if (afterUuid) {
|
|
313
|
+
const afterIdx = bubbles.findIndex(b => b.bubbleId === afterUuid);
|
|
314
|
+
if (afterIdx !== -1) {
|
|
315
|
+
// Get all bubbles after the cursor
|
|
316
|
+
const rawSlice = bubbles.slice(afterIdx + 1, afterIdx + 1 + limit);
|
|
317
|
+
// Filter out empty bubbles - Cursor creates entries BEFORE populating text
|
|
318
|
+
const slice = rawSlice.filter(b => b.text && b.text.trim().length > 0);
|
|
319
|
+
const messages = slice.map(b => ({
|
|
320
|
+
uuid: b.bubbleId,
|
|
321
|
+
role: b.type === 1 ? 'USER' : 'AGENT',
|
|
322
|
+
content: b.text || '',
|
|
323
|
+
timestamp: b.createdAt,
|
|
324
|
+
}));
|
|
325
|
+
return {
|
|
326
|
+
messages,
|
|
327
|
+
hasMore: afterIdx + 1 + limit < bubbles.length,
|
|
328
|
+
oldestUuid: slice.length > 0 ? slice[0].bubbleId : undefined,
|
|
329
|
+
newestUuid: slice.length > 0 ? slice[slice.length - 1].bubbleId : undefined,
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
// If afterUuid not found, fall through to return all messages
|
|
333
|
+
}
|
|
334
|
+
// Handle beforeUuid for backward pagination
|
|
335
|
+
let startIndex = bubbles.length;
|
|
336
|
+
if (beforeUuid) {
|
|
337
|
+
const idx = bubbles.findIndex(b => b.bubbleId === beforeUuid);
|
|
338
|
+
if (idx !== -1) {
|
|
339
|
+
startIndex = idx;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
// Get messages before the cursor, limited to `limit`
|
|
343
|
+
// Filter out empty bubbles (Cursor creates entries before text is populated)
|
|
344
|
+
const startFrom = Math.max(0, startIndex - limit);
|
|
345
|
+
const slice = bubbles
|
|
346
|
+
.slice(startFrom, startIndex)
|
|
347
|
+
.filter(b => b.text && b.text.trim().length > 0);
|
|
348
|
+
const messages = slice.map(b => ({
|
|
349
|
+
uuid: b.bubbleId,
|
|
350
|
+
role: b.type === 1 ? 'USER' : 'AGENT',
|
|
351
|
+
content: b.text || '',
|
|
352
|
+
timestamp: b.createdAt,
|
|
353
|
+
}));
|
|
354
|
+
// Return oldest-first (chronological order) to match Claude Code daemon
|
|
355
|
+
return {
|
|
356
|
+
messages,
|
|
357
|
+
hasMore: startFrom > 0,
|
|
358
|
+
oldestUuid: slice.length > 0 ? slice[0].bubbleId : undefined,
|
|
359
|
+
newestUuid: slice.length > 0 ? slice[slice.length - 1].bubbleId : undefined,
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Get the count of bubbles for a composer
|
|
364
|
+
*/
|
|
365
|
+
getBubbleCount(composerId) {
|
|
366
|
+
const db = this.openGlobalDb();
|
|
367
|
+
if (!db)
|
|
368
|
+
return 0;
|
|
369
|
+
try {
|
|
370
|
+
const stmt = db.prepare(`
|
|
371
|
+
SELECT COUNT(*) as count FROM cursorDiskKV
|
|
372
|
+
WHERE key LIKE ?
|
|
373
|
+
`);
|
|
374
|
+
const pattern = `bubbleId:${composerId}:%`;
|
|
375
|
+
const row = stmt.get(pattern);
|
|
376
|
+
return row.count;
|
|
377
|
+
}
|
|
378
|
+
catch (err) {
|
|
379
|
+
console.error('[CursorDB] Error counting bubbles:', err);
|
|
380
|
+
return 0;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Get workspace storage paths that contain state.vscdb files
|
|
385
|
+
*/
|
|
386
|
+
getWorkspaceStoragePaths() {
|
|
387
|
+
const paths = [];
|
|
388
|
+
if (!fs.existsSync(config_1.CURSOR_WORKSPACE_STORAGE)) {
|
|
389
|
+
return paths;
|
|
390
|
+
}
|
|
391
|
+
try {
|
|
392
|
+
const entries = fs.readdirSync(config_1.CURSOR_WORKSPACE_STORAGE);
|
|
393
|
+
for (const entry of entries) {
|
|
394
|
+
const dbPath = path.join(config_1.CURSOR_WORKSPACE_STORAGE, entry, 'state.vscdb');
|
|
395
|
+
if (fs.existsSync(dbPath)) {
|
|
396
|
+
paths.push(dbPath);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
catch (err) {
|
|
401
|
+
console.error('[CursorDB] Error reading workspace storage:', err);
|
|
402
|
+
}
|
|
403
|
+
return paths;
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* Try to determine the project path for a workspace storage hash
|
|
407
|
+
* This is a best-effort attempt based on workspace.json if it exists
|
|
408
|
+
*/
|
|
409
|
+
getWorkspaceProjectPath(workspaceHash) {
|
|
410
|
+
const workspaceJsonPath = path.join(config_1.CURSOR_WORKSPACE_STORAGE, workspaceHash, 'workspace.json');
|
|
411
|
+
if (!fs.existsSync(workspaceJsonPath)) {
|
|
412
|
+
return null;
|
|
413
|
+
}
|
|
414
|
+
try {
|
|
415
|
+
const content = fs.readFileSync(workspaceJsonPath, 'utf-8');
|
|
416
|
+
const data = JSON.parse(content);
|
|
417
|
+
// workspace.json typically contains a "folder" property with the URI
|
|
418
|
+
if (data.folder) {
|
|
419
|
+
// Convert file:// URI to path
|
|
420
|
+
return data.folder.replace('file://', '');
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
catch {
|
|
424
|
+
// Ignore errors
|
|
425
|
+
}
|
|
426
|
+
return null;
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
exports.CursorDB = CursorDB;
|
|
430
|
+
// Singleton instance
|
|
431
|
+
let cursorDbInstance = null;
|
|
432
|
+
function getCursorDB() {
|
|
433
|
+
if (!cursorDbInstance) {
|
|
434
|
+
cursorDbInstance = new CursorDB();
|
|
435
|
+
}
|
|
436
|
+
return cursorDbInstance;
|
|
437
|
+
}
|
|
438
|
+
//# sourceMappingURL=cursor-db.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3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O,CAAC,CAAC;YACjC,qEAAqE;YACrE,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;gBAChB,8BAA8B;gBAC9B,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;YAC5C,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,gBAAgB;QAClB,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AA1aD,4BA0aC;AAED,qBAAqB;AACrB,IAAI,gBAAgB,GAAoB,IAAI,CAAC;AAE7C,SAAgB,WAAW;IACzB,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACtB,gBAAgB,GAAG,IAAI,QAAQ,EAAE,CAAC;IACpC,CAAC;IACD,OAAO,gBAAgB,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Message types for daemon <-> server communication
|
|
3
|
+
*/
|
|
4
|
+
export interface PingMessage {
|
|
5
|
+
type: 'ping';
|
|
6
|
+
}
|
|
7
|
+
export interface TaskStartMessage {
|
|
8
|
+
type: 'task_start';
|
|
9
|
+
task_id: string;
|
|
10
|
+
instruction: string;
|
|
11
|
+
project_path?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface TaskResumeMessage {
|
|
14
|
+
type: 'task_resume';
|
|
15
|
+
task_id: string;
|
|
16
|
+
session_id: string;
|
|
17
|
+
message: string;
|
|
18
|
+
project_path?: string;
|
|
19
|
+
}
|
|
20
|
+
export interface TaskCancelMessage {
|
|
21
|
+
type: 'task_cancel';
|
|
22
|
+
task_id: string;
|
|
23
|
+
}
|
|
24
|
+
export interface GetMessagesMessage {
|
|
25
|
+
type: 'get_messages';
|
|
26
|
+
request_id: string;
|
|
27
|
+
session_id: string;
|
|
28
|
+
limit: number;
|
|
29
|
+
before_uuid?: string;
|
|
30
|
+
after_uuid?: string;
|
|
31
|
+
}
|
|
32
|
+
export interface WatchSessionMessage {
|
|
33
|
+
type: 'watch_session';
|
|
34
|
+
session_id: string;
|
|
35
|
+
file_path: string;
|
|
36
|
+
}
|
|
37
|
+
export interface UnwatchSessionMessage {
|
|
38
|
+
type: 'unwatch_session';
|
|
39
|
+
session_id: string;
|
|
40
|
+
}
|
|
41
|
+
export type ServerMessage = PingMessage | TaskStartMessage | TaskResumeMessage | TaskCancelMessage | GetMessagesMessage | WatchSessionMessage | UnwatchSessionMessage;
|
|
42
|
+
export interface PongMessage {
|
|
43
|
+
type: 'pong';
|
|
44
|
+
}
|
|
45
|
+
export interface StatusMessage {
|
|
46
|
+
type: 'status';
|
|
47
|
+
running_tasks: string[];
|
|
48
|
+
}
|
|
49
|
+
export interface EventMessage {
|
|
50
|
+
type: 'event';
|
|
51
|
+
task_id: string;
|
|
52
|
+
event_type: string;
|
|
53
|
+
[key: string]: unknown;
|
|
54
|
+
}
|
|
55
|
+
export interface SessionInfo {
|
|
56
|
+
session_id: string;
|
|
57
|
+
slug: string;
|
|
58
|
+
title: string;
|
|
59
|
+
project: string;
|
|
60
|
+
project_name: string;
|
|
61
|
+
file_path: string;
|
|
62
|
+
last_message: string;
|
|
63
|
+
last_activity: string;
|
|
64
|
+
is_active: boolean;
|
|
65
|
+
message_count: number;
|
|
66
|
+
}
|
|
67
|
+
export interface ReportSessionsMessage {
|
|
68
|
+
type: 'report_sessions';
|
|
69
|
+
sessions: SessionInfo[];
|
|
70
|
+
}
|
|
71
|
+
export interface MessageEntry {
|
|
72
|
+
uuid: string;
|
|
73
|
+
role: 'USER' | 'AGENT';
|
|
74
|
+
content: string;
|
|
75
|
+
timestamp: string;
|
|
76
|
+
}
|
|
77
|
+
export interface MessagesResponseMessage {
|
|
78
|
+
type: 'messages';
|
|
79
|
+
request_id: string;
|
|
80
|
+
session_id: string;
|
|
81
|
+
messages: MessageEntry[];
|
|
82
|
+
has_more: boolean;
|
|
83
|
+
oldest_uuid?: string;
|
|
84
|
+
newest_uuid?: string;
|
|
85
|
+
error?: string;
|
|
86
|
+
}
|
|
87
|
+
export interface SessionActivityMessage {
|
|
88
|
+
type: 'session_activity';
|
|
89
|
+
session_id: string;
|
|
90
|
+
file_path: string;
|
|
91
|
+
last_message: string;
|
|
92
|
+
message_count: number;
|
|
93
|
+
is_completion: boolean;
|
|
94
|
+
user_message_uuid?: string;
|
|
95
|
+
}
|
|
96
|
+
export type DaemonMessage = PongMessage | StatusMessage | EventMessage | ReportSessionsMessage | MessagesResponseMessage | SessionActivityMessage;
|
|
97
|
+
export type EventType = 'WAIT_FOR_USER' | 'TASK_COMPLETE' | 'OUTPUT' | 'PROGRESS' | 'ERROR';
|
|
98
|
+
//# sourceMappingURL=messages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/client/messages.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,YAAY,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,aAAa,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,aAAa,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,cAAc,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,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;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,UAAU,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,YAAY,EAAE,CAAC;IACzB,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,kBAAkB,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,OAAO,CAAC;IACvB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,MAAM,aAAa,GACrB,WAAW,GACX,aAAa,GACb,YAAY,GACZ,qBAAqB,GACrB,uBAAuB,GACvB,sBAAsB,CAAC;AAG3B,MAAM,MAAM,SAAS,GACjB,eAAe,GACf,eAAe,GACf,QAAQ,GACR,UAAU,GACV,OAAO,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../../src/client/messages.ts"],"names":[],"mappings":";AAAA;;GAEG"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { CmdCtrlConfig, Credentials } from '../config/config';
|
|
2
|
+
export declare class DaemonClient {
|
|
3
|
+
private ws;
|
|
4
|
+
private config;
|
|
5
|
+
private credentials;
|
|
6
|
+
private reconnectDelay;
|
|
7
|
+
private reconnectTimer;
|
|
8
|
+
private pingTimer;
|
|
9
|
+
private sessionRefreshTimer;
|
|
10
|
+
private shouldReconnect;
|
|
11
|
+
private managedSessionIds;
|
|
12
|
+
private runningTasks;
|
|
13
|
+
constructor(config: CmdCtrlConfig, credentials: Credentials);
|
|
14
|
+
/**
|
|
15
|
+
* Handle session activity from the watcher and forward to server
|
|
16
|
+
*/
|
|
17
|
+
private handleSessionActivity;
|
|
18
|
+
/**
|
|
19
|
+
* Connect to the CmdCtrl server via WebSocket
|
|
20
|
+
*/
|
|
21
|
+
connect(): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Disconnect from server
|
|
24
|
+
*/
|
|
25
|
+
disconnect(): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* Send a message to the server
|
|
28
|
+
*/
|
|
29
|
+
private send;
|
|
30
|
+
/**
|
|
31
|
+
* Send an event for a task
|
|
32
|
+
*/
|
|
33
|
+
private sendEvent;
|
|
34
|
+
/**
|
|
35
|
+
* Send current status to server
|
|
36
|
+
*/
|
|
37
|
+
private sendStatus;
|
|
38
|
+
/**
|
|
39
|
+
* Handle incoming message from server
|
|
40
|
+
*/
|
|
41
|
+
private handleMessage;
|
|
42
|
+
/**
|
|
43
|
+
* Handle task_start message - send message to Cursor via CDP
|
|
44
|
+
*/
|
|
45
|
+
private handleTaskStart;
|
|
46
|
+
/**
|
|
47
|
+
* Handle task_resume message - send follow-up message to Cursor
|
|
48
|
+
*/
|
|
49
|
+
private handleTaskResume;
|
|
50
|
+
/**
|
|
51
|
+
* Handle get_messages request - read from Cursor SQLite database
|
|
52
|
+
*/
|
|
53
|
+
private handleGetMessages;
|
|
54
|
+
/**
|
|
55
|
+
* Handle watch_session request
|
|
56
|
+
*/
|
|
57
|
+
private handleWatchSession;
|
|
58
|
+
/**
|
|
59
|
+
* Handle unwatch_session request
|
|
60
|
+
*/
|
|
61
|
+
private handleUnwatchSession;
|
|
62
|
+
/**
|
|
63
|
+
* Schedule reconnection with exponential backoff
|
|
64
|
+
*/
|
|
65
|
+
private scheduleReconnect;
|
|
66
|
+
/**
|
|
67
|
+
* Start ping interval
|
|
68
|
+
*/
|
|
69
|
+
private startPingInterval;
|
|
70
|
+
/**
|
|
71
|
+
* Stop ping interval
|
|
72
|
+
*/
|
|
73
|
+
private stopPingInterval;
|
|
74
|
+
/**
|
|
75
|
+
* Start the session watcher
|
|
76
|
+
*/
|
|
77
|
+
private startSessionWatcher;
|
|
78
|
+
/**
|
|
79
|
+
* Stop the session watcher
|
|
80
|
+
*/
|
|
81
|
+
private stopSessionWatcher;
|
|
82
|
+
/**
|
|
83
|
+
* Report discovered external sessions to server
|
|
84
|
+
*/
|
|
85
|
+
private reportSessions;
|
|
86
|
+
/**
|
|
87
|
+
* Start periodic session refresh
|
|
88
|
+
*/
|
|
89
|
+
private startSessionRefreshInterval;
|
|
90
|
+
/**
|
|
91
|
+
* Stop session refresh interval
|
|
92
|
+
*/
|
|
93
|
+
private stopSessionRefreshInterval;
|
|
94
|
+
/**
|
|
95
|
+
* Add a session ID to the managed set
|
|
96
|
+
*/
|
|
97
|
+
addManagedSession(sessionId: string): void;
|
|
98
|
+
/**
|
|
99
|
+
* Remove a session ID from the managed set
|
|
100
|
+
*/
|
|
101
|
+
removeManagedSession(sessionId: string): void;
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=websocket.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"websocket.d.ts","sourceRoot":"","sources":["../../src/client/websocket.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAqB9D,qBAAa,YAAY;IACvB,OAAO,CAAC,EAAE,CAA0B;IACpC,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,cAAc,CAA2B;IACjD,OAAO,CAAC,cAAc,CAA+B;IACrD,OAAO,CAAC,SAAS,CAA+B;IAChD,OAAO,CAAC,mBAAmB,CAA+B;IAC1D,OAAO,CAAC,eAAe,CAAQ;IAC/B,OAAO,CAAC,iBAAiB,CAA0B;IACnD,OAAO,CAAC,YAAY,CAA0B;gBAElC,MAAM,EAAE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