@sideboard-ai/core 0.1.207 → 0.1.209
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/{abletime-I4IYZBKU.js → abletime-G3MWSZVM.js} +4 -4
- package/dist/{abletime-UWSSLXH3.js → abletime-SQREWITG.js} +4 -4
- package/dist/{abletime-oauth-UZHPB3W2.js → abletime-oauth-7AOE4KJL.js} +3 -3
- package/dist/{abletime-oauth-C3BQXKW3.js → abletime-oauth-SQD6K47H.js} +3 -3
- package/dist/{abletime-rest-5YPPEOKK.js → abletime-rest-BXL7QHCX.js} +3 -3
- package/dist/{abletime-rest-HYNYDYK3.js → abletime-rest-QRTJH42S.js} +3 -3
- package/dist/agents/cursor-runner.js +3 -3
- package/dist/{agents-7MULGRPU.js → agents-KA6HDNNP.js} +6 -5
- package/dist/{agents-KCBCFMFW.js → agents-U2NVCYGC.js} +6 -5
- package/dist/{app-settings-R2KNCT37.js → app-settings-6SZLZNA7.js} +7 -1
- package/dist/{app-settings-GJ6KDYEF.js → app-settings-VBQHGX5Z.js} +7 -1
- package/dist/{chunk-6KH4OBEW.js → chunk-22A45QOI.js} +2 -2
- package/dist/{chunk-N4A4NWFO.js → chunk-42VGWRSE.js} +2 -2
- package/dist/{chunk-X45BV4VX.js → chunk-5LFD3KCJ.js} +5 -5
- package/dist/{chunk-F4LZUEIO.js → chunk-B2RPIHNJ.js} +2 -2
- package/dist/{chunk-6YZLSZLK.js → chunk-CQZCXRVG.js} +3 -3
- package/dist/{chunk-4EGK47WV.js → chunk-FUC3XFE2.js} +215 -0
- package/dist/{chunk-5UQTT4S7.js → chunk-HBL7ILQA.js} +154 -31
- package/dist/{chunk-TEDEVD4O.js → chunk-IIENQFJ6.js} +2 -2
- package/dist/{chunk-6J4OQ6TF.js → chunk-IOOL3T7Q.js} +3 -3
- package/dist/{chunk-A2BRWIEM.js → chunk-KJAHVQL6.js} +51 -94
- package/dist/{chunk-ZU7R35NY.js → chunk-MS2P5GXL.js} +49 -87
- package/dist/{chunk-2GPZ4BAU.js → chunk-MZP2C4KE.js} +158 -31
- package/dist/{chunk-ARR4OGLY.js → chunk-OY7THBLG.js} +12 -2
- package/dist/{chunk-QOJB5PC7.js → chunk-PTOIWKDU.js} +3 -3
- package/dist/{chunk-W6X4GZJG.js → chunk-QVVJO4GN.js} +3 -3
- package/dist/{chunk-DWGEBZ3C.js → chunk-RPZFNKND.js} +12 -2
- package/dist/{chunk-PAQPT3JO.js → chunk-TZCWNRMC.js} +3 -3
- package/dist/{chunk-Y4CF7LHH.js → chunk-VJQDUD24.js} +230 -0
- package/dist/chunk-X5B3OS5I.js +34 -0
- package/dist/{chunk-WXWJ5MJ4.js → chunk-XRIF6M5H.js} +5 -5
- package/dist/{coordinator-prompt-6NV2IHEX.js → coordinator-prompt-2YCOE5R4.js} +5 -4
- package/dist/{coordinator-prompt-6A3D7BV3.js → coordinator-prompt-EO2X2EYW.js} +5 -4
- package/dist/{cursor-recover-TXVTLAMA.js → cursor-recover-4PQAADAU.js} +3 -28
- package/dist/{global-workspace-I2X6UQMX.js → global-workspace-H2ANUSGR.js} +5 -4
- package/dist/{global-workspace-VS6HZF2I.js → global-workspace-JEKMVE42.js} +5 -4
- package/dist/index.cjs +752 -391
- package/dist/index.d.cts +127 -5
- package/dist/index.d.ts +127 -5
- package/dist/index.js +63 -19
- package/dist/mcp/run-stdio.cjs +706 -391
- package/dist/mcp/run-stdio.js +12 -11
- package/dist/{orchestrator-CXQY5YRG.js → orchestrator-N7LLTK5O.js} +7 -6
- package/dist/{orchestrator-7WF32ZXJ.js → orchestrator-RUQXDYM7.js} +7 -6
- package/dist/{thread-store-XGYWXR2P.js → thread-store-55X2JYDT.js} +2 -1
- package/dist/{thread-store-LS2T6RVH.js → thread-store-CMZWM5NY.js} +2 -1
- package/dist/{workspaces-CEU25ANO.js → workspaces-2YNYLSPV.js} +5 -4
- package/dist/{workspaces-7PM7UGLG.js → workspaces-SVDORZEI.js} +5 -4
- package/dist/{worktree-YD7Y6NRY.js → worktree-5CPGB4D2.js} +4 -3
- package/dist/{worktree-T6PCOIHZ.js → worktree-YQ6XUSR2.js} +4 -3
- package/package.json +1 -1
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
cursorSdkStoreDir
|
|
3
|
+
} from "./chunk-7J72QJOM.js";
|
|
1
4
|
import {
|
|
2
5
|
normalizeThinkingEffort
|
|
3
6
|
} from "./chunk-77WWLBCI.js";
|
|
@@ -13,6 +16,7 @@ import {
|
|
|
13
16
|
existsSync,
|
|
14
17
|
readFileSync,
|
|
15
18
|
renameSync,
|
|
19
|
+
rmSync,
|
|
16
20
|
statSync,
|
|
17
21
|
unlinkSync,
|
|
18
22
|
writeFileSync,
|
|
@@ -41,6 +45,7 @@ function normalizeThread(raw) {
|
|
|
41
45
|
lastError: raw.lastError ?? null,
|
|
42
46
|
agentPid: raw.agentPid ?? null,
|
|
43
47
|
attachments: Array.isArray(raw.attachments) ? raw.attachments : [],
|
|
48
|
+
pendingTurnAttachments: Array.isArray(raw.pendingTurnAttachments) ? raw.pendingTurnAttachments : [],
|
|
44
49
|
prTitle: raw.prTitle ?? null,
|
|
45
50
|
prState: raw.prState ?? null,
|
|
46
51
|
prIsDraft: Boolean(raw.prIsDraft),
|
|
@@ -83,6 +88,7 @@ function createEmptyThread(partial) {
|
|
|
83
88
|
userSetTitle: partial.userSetTitle ?? false,
|
|
84
89
|
messages: partial.messages ?? [],
|
|
85
90
|
attachments: partial.attachments ?? [],
|
|
91
|
+
pendingTurnAttachments: partial.pendingTurnAttachments ?? [],
|
|
86
92
|
createdAt: ts,
|
|
87
93
|
updatedAt: ts,
|
|
88
94
|
title: partial.title,
|
|
@@ -157,10 +163,10 @@ function readThread(id) {
|
|
|
157
163
|
rememberThread(thread, mtimeMs);
|
|
158
164
|
return thread;
|
|
159
165
|
}
|
|
160
|
-
function writeThread(thread) {
|
|
166
|
+
function writeThread(thread, opts) {
|
|
161
167
|
const path = threadFilePath(idPath(thread.id));
|
|
162
168
|
const tmp = `${path}.${process.pid}.tmp`;
|
|
163
|
-
const next = { ...thread, updatedAt: nowIso() };
|
|
169
|
+
const next = opts?.touch === false ? { ...thread } : { ...thread, updatedAt: nowIso() };
|
|
164
170
|
writeFileSync(tmp, JSON.stringify(next, null, 2), "utf8");
|
|
165
171
|
renameSync(tmp, path);
|
|
166
172
|
rememberThread(next, fileMtimeMs(path) ?? Date.now());
|
|
@@ -205,6 +211,10 @@ function deleteThreadRecord(id) {
|
|
|
205
211
|
} catch {
|
|
206
212
|
}
|
|
207
213
|
}
|
|
214
|
+
try {
|
|
215
|
+
rmSync(cursorSdkStoreDir(id), { recursive: true, force: true });
|
|
216
|
+
} catch {
|
|
217
|
+
}
|
|
208
218
|
}
|
|
209
219
|
function updateThread(id, patch) {
|
|
210
220
|
const current = readThread(id);
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
resolveRepoRoot,
|
|
8
8
|
takenSlugsFromThread,
|
|
9
9
|
teamSlugFromName
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-42VGWRSE.js";
|
|
11
11
|
import {
|
|
12
12
|
ATTACHMENTS_DIR,
|
|
13
13
|
attachmentsGitignoreBody
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
listThreads,
|
|
18
18
|
updateThread,
|
|
19
19
|
writeThread
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-RPZFNKND.js";
|
|
21
21
|
import {
|
|
22
22
|
assertOrchestratorCapableAgent,
|
|
23
23
|
formatAccountProfilePlaybookLine,
|
|
@@ -30,7 +30,7 @@ import {
|
|
|
30
30
|
resolveThreadDefaults,
|
|
31
31
|
resolveViewerProfile,
|
|
32
32
|
resolveViewerProfileForRepo
|
|
33
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-FUC3XFE2.js";
|
|
34
34
|
import {
|
|
35
35
|
appDataDir,
|
|
36
36
|
globalAgentCwd,
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
textFromAbleTimeDoc
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-B2RPIHNJ.js";
|
|
4
4
|
import {
|
|
5
5
|
assertAbleTimeCredential,
|
|
6
6
|
callAbleTimeTool,
|
|
7
7
|
normalizeAbleTimeHost,
|
|
8
8
|
rewriteAbleTimeError
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-5LFD3KCJ.js";
|
|
10
10
|
import {
|
|
11
11
|
isAbleTimeConnected,
|
|
12
12
|
saveAbleTimeConnection
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-VJQDUD24.js";
|
|
14
14
|
|
|
15
15
|
// src/integrations/abletime.ts
|
|
16
16
|
var CLOSED_STATES = /* @__PURE__ */ new Set([
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
+
import {
|
|
4
|
+
cursorSdkStoreDir
|
|
5
|
+
} from "./chunk-X5B3OS5I.js";
|
|
3
6
|
import {
|
|
4
7
|
normalizeThinkingEffort
|
|
5
8
|
} from "./chunk-KGZBYWZ3.js";
|
|
@@ -15,6 +18,7 @@ import {
|
|
|
15
18
|
existsSync,
|
|
16
19
|
readFileSync,
|
|
17
20
|
renameSync,
|
|
21
|
+
rmSync,
|
|
18
22
|
statSync,
|
|
19
23
|
unlinkSync,
|
|
20
24
|
writeFileSync,
|
|
@@ -43,6 +47,7 @@ function normalizeThread(raw) {
|
|
|
43
47
|
lastError: raw.lastError ?? null,
|
|
44
48
|
agentPid: raw.agentPid ?? null,
|
|
45
49
|
attachments: Array.isArray(raw.attachments) ? raw.attachments : [],
|
|
50
|
+
pendingTurnAttachments: Array.isArray(raw.pendingTurnAttachments) ? raw.pendingTurnAttachments : [],
|
|
46
51
|
prTitle: raw.prTitle ?? null,
|
|
47
52
|
prState: raw.prState ?? null,
|
|
48
53
|
prIsDraft: Boolean(raw.prIsDraft),
|
|
@@ -85,6 +90,7 @@ function createEmptyThread(partial) {
|
|
|
85
90
|
userSetTitle: partial.userSetTitle ?? false,
|
|
86
91
|
messages: partial.messages ?? [],
|
|
87
92
|
attachments: partial.attachments ?? [],
|
|
93
|
+
pendingTurnAttachments: partial.pendingTurnAttachments ?? [],
|
|
88
94
|
createdAt: ts,
|
|
89
95
|
updatedAt: ts,
|
|
90
96
|
title: partial.title,
|
|
@@ -159,10 +165,10 @@ function readThread(id) {
|
|
|
159
165
|
rememberThread(thread, mtimeMs);
|
|
160
166
|
return thread;
|
|
161
167
|
}
|
|
162
|
-
function writeThread(thread) {
|
|
168
|
+
function writeThread(thread, opts) {
|
|
163
169
|
const path = threadFilePath(idPath(thread.id));
|
|
164
170
|
const tmp = `${path}.${process.pid}.tmp`;
|
|
165
|
-
const next = { ...thread, updatedAt: nowIso() };
|
|
171
|
+
const next = opts?.touch === false ? { ...thread } : { ...thread, updatedAt: nowIso() };
|
|
166
172
|
writeFileSync(tmp, JSON.stringify(next, null, 2), "utf8");
|
|
167
173
|
renameSync(tmp, path);
|
|
168
174
|
rememberThread(next, fileMtimeMs(path) ?? Date.now());
|
|
@@ -207,6 +213,10 @@ function deleteThreadRecord(id) {
|
|
|
207
213
|
} catch {
|
|
208
214
|
}
|
|
209
215
|
}
|
|
216
|
+
try {
|
|
217
|
+
rmSync(cursorSdkStoreDir(id), { recursive: true, force: true });
|
|
218
|
+
} catch {
|
|
219
|
+
}
|
|
210
220
|
}
|
|
211
221
|
function updateThread(id, patch) {
|
|
212
222
|
const current = readThread(id);
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
resolveRepoRoot,
|
|
6
6
|
takenSlugsFromThread,
|
|
7
7
|
teamSlugFromName
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-22A45QOI.js";
|
|
9
9
|
import {
|
|
10
10
|
ATTACHMENTS_DIR,
|
|
11
11
|
attachmentsGitignoreBody
|
|
@@ -22,13 +22,13 @@ import {
|
|
|
22
22
|
resolveThreadDefaults,
|
|
23
23
|
resolveViewerProfile,
|
|
24
24
|
resolveViewerProfileForRepo
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-VJQDUD24.js";
|
|
26
26
|
import {
|
|
27
27
|
createEmptyThread,
|
|
28
28
|
listThreads,
|
|
29
29
|
updateThread,
|
|
30
30
|
writeThread
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-OY7THBLG.js";
|
|
32
32
|
import {
|
|
33
33
|
appDataDir,
|
|
34
34
|
globalAgentCwd,
|
|
@@ -355,6 +355,168 @@ function normalizeVault(raw) {
|
|
|
355
355
|
return out;
|
|
356
356
|
}
|
|
357
357
|
|
|
358
|
+
// src/agents/usage.ts
|
|
359
|
+
function sumOptional(a, b) {
|
|
360
|
+
if (a == null && b == null) return void 0;
|
|
361
|
+
return (a ?? 0) + (b ?? 0);
|
|
362
|
+
}
|
|
363
|
+
function fromInclusiveInputUsage(opts) {
|
|
364
|
+
const totalInput = Number(opts.inputTokens) || 0;
|
|
365
|
+
const outputTokens = Number(opts.outputTokens) || 0;
|
|
366
|
+
const cached = Number(opts.cachedInputTokens) || 0;
|
|
367
|
+
if (!totalInput && !outputTokens) return null;
|
|
368
|
+
const cacheReadTokens = cached > 0 ? Math.min(cached, totalInput) : 0;
|
|
369
|
+
return {
|
|
370
|
+
inputTokens: Math.max(0, totalInput - cacheReadTokens),
|
|
371
|
+
outputTokens,
|
|
372
|
+
cacheReadTokens: cacheReadTokens || void 0
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
function requestOccupancy(u) {
|
|
376
|
+
return u.inputTokens + (u.cacheReadTokens ?? 0) + (u.cacheWriteTokens ?? 0);
|
|
377
|
+
}
|
|
378
|
+
function mergeUsage(a, b) {
|
|
379
|
+
return {
|
|
380
|
+
inputTokens: (a?.inputTokens ?? 0) + b.inputTokens,
|
|
381
|
+
outputTokens: (a?.outputTokens ?? 0) + b.outputTokens,
|
|
382
|
+
cacheReadTokens: sumOptional(a?.cacheReadTokens, b.cacheReadTokens),
|
|
383
|
+
cacheWriteTokens: sumOptional(a?.cacheWriteTokens, b.cacheWriteTokens),
|
|
384
|
+
costUsd: sumOptional(a?.costUsd, b.costUsd),
|
|
385
|
+
lastRequestTokens: b.lastRequestTokens ?? a?.lastRequestTokens
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
function sumUsageList(list) {
|
|
389
|
+
let acc = null;
|
|
390
|
+
for (const u of list) {
|
|
391
|
+
if (!u) continue;
|
|
392
|
+
acc = mergeUsage(acc, {
|
|
393
|
+
inputTokens: u.inputTokens,
|
|
394
|
+
outputTokens: u.outputTokens,
|
|
395
|
+
cacheReadTokens: u.cacheReadTokens,
|
|
396
|
+
cacheWriteTokens: u.cacheWriteTokens,
|
|
397
|
+
costUsd: u.costUsd
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
if (!acc) return null;
|
|
401
|
+
return {
|
|
402
|
+
inputTokens: acc.inputTokens,
|
|
403
|
+
outputTokens: acc.outputTokens,
|
|
404
|
+
...acc.cacheReadTokens != null ? { cacheReadTokens: acc.cacheReadTokens } : {},
|
|
405
|
+
...acc.cacheWriteTokens != null ? { cacheWriteTokens: acc.cacheWriteTokens } : {},
|
|
406
|
+
...acc.costUsd != null ? { costUsd: acc.costUsd } : {}
|
|
407
|
+
};
|
|
408
|
+
}
|
|
409
|
+
function hasBilledTokens(u) {
|
|
410
|
+
return Boolean(
|
|
411
|
+
u.inputTokens || u.outputTokens || u.cacheReadTokens || u.cacheWriteTokens
|
|
412
|
+
);
|
|
413
|
+
}
|
|
414
|
+
function applyTurnUsage(current, incoming, scope = "request") {
|
|
415
|
+
if (scope === "turn") {
|
|
416
|
+
if (!hasBilledTokens(incoming) && current && incoming.costUsd != null) {
|
|
417
|
+
return { ...current, costUsd: incoming.costUsd };
|
|
418
|
+
}
|
|
419
|
+
return {
|
|
420
|
+
...incoming,
|
|
421
|
+
costUsd: incoming.costUsd ?? current?.costUsd,
|
|
422
|
+
lastRequestTokens: current?.lastRequestTokens ?? requestOccupancy(incoming)
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
const merged = mergeUsage(current, incoming);
|
|
426
|
+
const occ = incoming.lastRequestTokens != null && incoming.lastRequestTokens > 0 ? incoming.lastRequestTokens : requestOccupancy(incoming);
|
|
427
|
+
return {
|
|
428
|
+
...merged,
|
|
429
|
+
lastRequestTokens: occ > 0 ? occ : current?.lastRequestTokens ?? occ
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
function totalTokens(u) {
|
|
433
|
+
return u.inputTokens + u.outputTokens + (u.cacheReadTokens ?? 0) + (u.cacheWriteTokens ?? 0);
|
|
434
|
+
}
|
|
435
|
+
function contextTokens(u) {
|
|
436
|
+
if (u.lastRequestTokens != null && u.lastRequestTokens > 0) return u.lastRequestTokens;
|
|
437
|
+
return requestOccupancy(u);
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
// src/store/history-retention.ts
|
|
441
|
+
var HISTORY_MAX_COUNT_DEFAULT = 200;
|
|
442
|
+
var HISTORY_MAX_COUNT_MIN = 1;
|
|
443
|
+
var HISTORY_MAX_COUNT_MAX = 2e3;
|
|
444
|
+
var HISTORY_MAX_DAYS_DEFAULT = 0;
|
|
445
|
+
var HISTORY_MAX_DAYS_MAX = 3650;
|
|
446
|
+
var HISTORY_CLEANUP_INTERVAL_HOURS_DEFAULT = 6;
|
|
447
|
+
var HISTORY_DISCARDED_TEXT = "Transcript discarded by History retention.";
|
|
448
|
+
function clampHistoryMaxCount(value) {
|
|
449
|
+
return Math.max(HISTORY_MAX_COUNT_MIN, Math.min(HISTORY_MAX_COUNT_MAX, Math.floor(value)));
|
|
450
|
+
}
|
|
451
|
+
function clampHistoryMaxDays(value) {
|
|
452
|
+
if (!Number.isFinite(value) || value <= 0) return 0;
|
|
453
|
+
return Math.min(HISTORY_MAX_DAYS_MAX, Math.floor(value));
|
|
454
|
+
}
|
|
455
|
+
function archivedUpdatedMs(thread) {
|
|
456
|
+
const updated = Date.parse(thread.updatedAt);
|
|
457
|
+
if (Number.isFinite(updated)) return updated;
|
|
458
|
+
const created = Date.parse(thread.createdAt);
|
|
459
|
+
return Number.isFinite(created) ? created : 0;
|
|
460
|
+
}
|
|
461
|
+
function isHistoryRetentionStub(thread) {
|
|
462
|
+
if ((thread.attachments?.length ?? 0) > 0) return false;
|
|
463
|
+
const messages = thread.messages ?? [];
|
|
464
|
+
if (messages.length === 0) return true;
|
|
465
|
+
if (messages.length > 1) return false;
|
|
466
|
+
const only = messages[0];
|
|
467
|
+
if (only.parts?.length) return false;
|
|
468
|
+
if ((only.attachments?.length ?? 0) > 0) return false;
|
|
469
|
+
const text = (only.text ?? "").trim();
|
|
470
|
+
return text === "" || text === HISTORY_DISCARDED_TEXT;
|
|
471
|
+
}
|
|
472
|
+
function historyRetentionStubMessage(thread) {
|
|
473
|
+
const usage = sumUsageList((thread.messages ?? []).map((m) => m.usage));
|
|
474
|
+
return {
|
|
475
|
+
role: "summary",
|
|
476
|
+
text: HISTORY_DISCARDED_TEXT,
|
|
477
|
+
ts: thread.updatedAt,
|
|
478
|
+
...usage ? { usage } : {}
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
function sortArchivedOldestFirst(threads) {
|
|
482
|
+
return [...threads].sort((a, b) => archivedUpdatedMs(a) - archivedUpdatedMs(b));
|
|
483
|
+
}
|
|
484
|
+
function planHistoryRetention(archived, thresholds = {}) {
|
|
485
|
+
const maxCount = clampHistoryMaxCount(thresholds.maxCount ?? HISTORY_MAX_COUNT_DEFAULT);
|
|
486
|
+
const maxDays = clampHistoryMaxDays(thresholds.maxDays ?? HISTORY_MAX_DAYS_DEFAULT);
|
|
487
|
+
const nowMs = thresholds.nowMs ?? Date.now();
|
|
488
|
+
const oldestFirst = sortArchivedOldestFirst(archived);
|
|
489
|
+
const expiredIds = /* @__PURE__ */ new Set();
|
|
490
|
+
if (maxDays > 0) {
|
|
491
|
+
const cutoff = nowMs - maxDays * 864e5;
|
|
492
|
+
for (const thread of oldestFirst) {
|
|
493
|
+
if (archivedUpdatedMs(thread) < cutoff) expiredIds.add(thread.id);
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
const remaining = oldestFirst.filter((t) => !expiredIds.has(t.id));
|
|
497
|
+
const overflow = remaining.length > maxCount ? remaining.slice(0, remaining.length - maxCount) : [];
|
|
498
|
+
const stripIds = [];
|
|
499
|
+
const purgeIds = [...expiredIds];
|
|
500
|
+
const seenPurge = new Set(purgeIds);
|
|
501
|
+
for (const thread of overflow) {
|
|
502
|
+
if (isHistoryRetentionStub(thread)) {
|
|
503
|
+
if (!seenPurge.has(thread.id)) {
|
|
504
|
+
seenPurge.add(thread.id);
|
|
505
|
+
purgeIds.push(thread.id);
|
|
506
|
+
}
|
|
507
|
+
} else {
|
|
508
|
+
stripIds.push(thread.id);
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
return { stripIds, purgeIds };
|
|
512
|
+
}
|
|
513
|
+
function planHistoryAgePurge(archived, olderThanDays, nowMs = Date.now()) {
|
|
514
|
+
const days = clampHistoryMaxDays(olderThanDays);
|
|
515
|
+
if (days <= 0) return [];
|
|
516
|
+
const cutoff = nowMs - days * 864e5;
|
|
517
|
+
return sortArchivedOldestFirst(archived).filter((t) => archivedUpdatedMs(t) < cutoff).map((t) => t.id);
|
|
518
|
+
}
|
|
519
|
+
|
|
358
520
|
// src/store/usage-on-limit.ts
|
|
359
521
|
var USAGE_ON_LIMIT_VALUES = [
|
|
360
522
|
"keep_going",
|
|
@@ -815,6 +977,24 @@ function normalizeAdvanced(raw) {
|
|
|
815
977
|
if (typeof source.autoCleanupOrphans === "boolean") {
|
|
816
978
|
out.autoCleanupOrphans = source.autoCleanupOrphans;
|
|
817
979
|
}
|
|
980
|
+
if (typeof source.autoCleanupHistory === "boolean") {
|
|
981
|
+
out.autoCleanupHistory = source.autoCleanupHistory;
|
|
982
|
+
}
|
|
983
|
+
if (typeof source.historyMaxCount === "number" && Number.isFinite(source.historyMaxCount)) {
|
|
984
|
+
out.historyMaxCount = clampHistoryMaxCount(source.historyMaxCount);
|
|
985
|
+
}
|
|
986
|
+
if (typeof source.historyMaxDays === "number" && Number.isFinite(source.historyMaxDays)) {
|
|
987
|
+
out.historyMaxDays = clampHistoryMaxDays(source.historyMaxDays);
|
|
988
|
+
}
|
|
989
|
+
if (typeof source.historyCleanupIntervalHours === "number" && Number.isFinite(source.historyCleanupIntervalHours)) {
|
|
990
|
+
out.historyCleanupIntervalHours = Math.max(
|
|
991
|
+
1,
|
|
992
|
+
Math.min(168, Math.floor(source.historyCleanupIntervalHours))
|
|
993
|
+
);
|
|
994
|
+
}
|
|
995
|
+
if (typeof source.historyLastCleanupAt === "string" && source.historyLastCleanupAt.trim()) {
|
|
996
|
+
out.historyLastCleanupAt = source.historyLastCleanupAt.trim();
|
|
997
|
+
}
|
|
818
998
|
if (source.orchestrationQuotaOnLimit === "switch_agent" || source.orchestrationQuotaOnLimit === "wait_reset") {
|
|
819
999
|
out.orchestrationQuotaOnLimit = source.orchestrationQuotaOnLimit;
|
|
820
1000
|
}
|
|
@@ -1720,6 +1900,24 @@ function updateAdvancedSettings(patch) {
|
|
|
1720
1900
|
if (typeof patch.autoCleanupOrphans === "boolean") {
|
|
1721
1901
|
advanced.autoCleanupOrphans = patch.autoCleanupOrphans;
|
|
1722
1902
|
}
|
|
1903
|
+
if (typeof patch.autoCleanupHistory === "boolean") {
|
|
1904
|
+
advanced.autoCleanupHistory = patch.autoCleanupHistory;
|
|
1905
|
+
}
|
|
1906
|
+
if (typeof patch.historyMaxCount === "number" && Number.isFinite(patch.historyMaxCount)) {
|
|
1907
|
+
advanced.historyMaxCount = clampHistoryMaxCount(patch.historyMaxCount);
|
|
1908
|
+
}
|
|
1909
|
+
if (typeof patch.historyMaxDays === "number" && Number.isFinite(patch.historyMaxDays)) {
|
|
1910
|
+
advanced.historyMaxDays = clampHistoryMaxDays(patch.historyMaxDays);
|
|
1911
|
+
}
|
|
1912
|
+
if (typeof patch.historyCleanupIntervalHours === "number" && Number.isFinite(patch.historyCleanupIntervalHours)) {
|
|
1913
|
+
advanced.historyCleanupIntervalHours = Math.max(
|
|
1914
|
+
1,
|
|
1915
|
+
Math.min(168, Math.floor(patch.historyCleanupIntervalHours))
|
|
1916
|
+
);
|
|
1917
|
+
}
|
|
1918
|
+
if (typeof patch.historyLastCleanupAt === "string") {
|
|
1919
|
+
advanced.historyLastCleanupAt = patch.historyLastCleanupAt;
|
|
1920
|
+
}
|
|
1723
1921
|
if (patch.orchestrationQuotaOnLimit === "switch_agent" || patch.orchestrationQuotaOnLimit === "wait_reset") {
|
|
1724
1922
|
advanced.orchestrationQuotaOnLimit = patch.orchestrationQuotaOnLimit;
|
|
1725
1923
|
}
|
|
@@ -1770,6 +1968,15 @@ function autoArchiveOnMergeEnabled(settings = loadAppSettings()) {
|
|
|
1770
1968
|
function autoCleanupOrphansEnabled(settings = loadAppSettings()) {
|
|
1771
1969
|
return Boolean(settings.advanced.autoCleanupOrphans);
|
|
1772
1970
|
}
|
|
1971
|
+
function autoCleanupHistoryEnabled(settings = loadAppSettings()) {
|
|
1972
|
+
return settings.advanced.autoCleanupHistory !== false;
|
|
1973
|
+
}
|
|
1974
|
+
function historyMaxCount(settings = loadAppSettings()) {
|
|
1975
|
+
return clampHistoryMaxCount(settings.advanced.historyMaxCount ?? HISTORY_MAX_COUNT_DEFAULT);
|
|
1976
|
+
}
|
|
1977
|
+
function historyMaxDays(settings = loadAppSettings()) {
|
|
1978
|
+
return clampHistoryMaxDays(settings.advanced.historyMaxDays ?? HISTORY_MAX_DAYS_DEFAULT);
|
|
1979
|
+
}
|
|
1773
1980
|
function usageOnLimit(settings = loadAppSettings()) {
|
|
1774
1981
|
return resolveUsageOnLimit(settings.advanced);
|
|
1775
1982
|
}
|
|
@@ -1903,6 +2110,26 @@ export {
|
|
|
1903
2110
|
writeSecureJson,
|
|
1904
2111
|
isSecureFileEncrypted,
|
|
1905
2112
|
secureFileUnlocksWith,
|
|
2113
|
+
fromInclusiveInputUsage,
|
|
2114
|
+
requestOccupancy,
|
|
2115
|
+
mergeUsage,
|
|
2116
|
+
sumUsageList,
|
|
2117
|
+
applyTurnUsage,
|
|
2118
|
+
totalTokens,
|
|
2119
|
+
contextTokens,
|
|
2120
|
+
HISTORY_MAX_COUNT_DEFAULT,
|
|
2121
|
+
HISTORY_MAX_COUNT_MIN,
|
|
2122
|
+
HISTORY_MAX_COUNT_MAX,
|
|
2123
|
+
HISTORY_MAX_DAYS_DEFAULT,
|
|
2124
|
+
HISTORY_MAX_DAYS_MAX,
|
|
2125
|
+
HISTORY_CLEANUP_INTERVAL_HOURS_DEFAULT,
|
|
2126
|
+
HISTORY_DISCARDED_TEXT,
|
|
2127
|
+
clampHistoryMaxCount,
|
|
2128
|
+
clampHistoryMaxDays,
|
|
2129
|
+
isHistoryRetentionStub,
|
|
2130
|
+
historyRetentionStubMessage,
|
|
2131
|
+
planHistoryRetention,
|
|
2132
|
+
planHistoryAgePurge,
|
|
1906
2133
|
USAGE_ON_LIMIT_VALUES,
|
|
1907
2134
|
isUsageOnLimit,
|
|
1908
2135
|
resolveUsageOnLimit,
|
|
@@ -1972,6 +2199,9 @@ export {
|
|
|
1972
2199
|
confirmClaudeUsageOverLimitEnabled,
|
|
1973
2200
|
autoArchiveOnMergeEnabled,
|
|
1974
2201
|
autoCleanupOrphansEnabled,
|
|
2202
|
+
autoCleanupHistoryEnabled,
|
|
2203
|
+
historyMaxCount,
|
|
2204
|
+
historyMaxDays,
|
|
1975
2205
|
usageOnLimit,
|
|
1976
2206
|
orchestrationQuotaOnLimit,
|
|
1977
2207
|
orchestrationQuotaFallbackAgent,
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
appDataDir
|
|
5
|
+
} from "./chunk-EQNRWDLN.js";
|
|
6
|
+
|
|
7
|
+
// src/agents/cursor-store.ts
|
|
8
|
+
import { join } from "path";
|
|
9
|
+
var CURSOR_SDK_STORE_DIR = "cursor-sdk-store";
|
|
10
|
+
function cursorSdkStoreDir(threadId) {
|
|
11
|
+
const root = join(appDataDir(), CURSOR_SDK_STORE_DIR);
|
|
12
|
+
const id = sanitizeCursorStoreSegment(threadId);
|
|
13
|
+
if (!id) return root;
|
|
14
|
+
return join(root, "threads", id);
|
|
15
|
+
}
|
|
16
|
+
function cursorSdkRunsNdjsonPath(threadId) {
|
|
17
|
+
return join(cursorSdkStoreDir(threadId), "runs.ndjson");
|
|
18
|
+
}
|
|
19
|
+
function cursorSdkRunsNdjsonSearchPaths(threadId) {
|
|
20
|
+
const scoped = cursorSdkRunsNdjsonPath(threadId);
|
|
21
|
+
const shared = cursorSdkRunsNdjsonPath(null);
|
|
22
|
+
if (!threadId || !sanitizeCursorStoreSegment(threadId) || scoped === shared) {
|
|
23
|
+
return [shared];
|
|
24
|
+
}
|
|
25
|
+
return [scoped, shared];
|
|
26
|
+
}
|
|
27
|
+
function sanitizeCursorStoreSegment(threadId) {
|
|
28
|
+
return (threadId ?? "").trim().replace(/[^a-zA-Z0-9._-]/g, "_");
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export {
|
|
32
|
+
cursorSdkStoreDir,
|
|
33
|
+
cursorSdkRunsNdjsonSearchPaths
|
|
34
|
+
};
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
import {
|
|
7
7
|
getAbleTimeHost,
|
|
8
8
|
isAbleTimeConnected
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-FUC3XFE2.js";
|
|
10
10
|
|
|
11
11
|
// src/integrations/abletime-mcp.ts
|
|
12
12
|
var DEFAULT_ABLETIME_HOST = "https://track.abletime.com";
|
|
@@ -155,7 +155,7 @@ function textsFromUnknown(value) {
|
|
|
155
155
|
return "";
|
|
156
156
|
}
|
|
157
157
|
async function abletimeMcpRequest(method, params, opts) {
|
|
158
|
-
const rawToken = opts?.token ?? await import("./abletime-oauth-
|
|
158
|
+
const rawToken = opts?.token ?? await import("./abletime-oauth-7AOE4KJL.js").then((m) => m.ensureAbleTimeAccessToken());
|
|
159
159
|
if (!rawToken?.trim()) {
|
|
160
160
|
throw new Error("AbleTime is not connected \u2014 paste a personal access token in Account settings");
|
|
161
161
|
}
|
|
@@ -226,9 +226,9 @@ async function callAbleTimeTool(name, args = {}, opts) {
|
|
|
226
226
|
if (!opts?.token && !isAbleTimeConnected()) {
|
|
227
227
|
throw new Error("AbleTime is not connected \u2014 paste a personal access token in Account settings");
|
|
228
228
|
}
|
|
229
|
-
const rawToken = opts?.token ?? await import("./abletime-oauth-
|
|
229
|
+
const rawToken = opts?.token ?? await import("./abletime-oauth-7AOE4KJL.js").then((m) => m.ensureAbleTimeAccessToken());
|
|
230
230
|
if (rawToken && ableTimeUsesRest(rawToken)) {
|
|
231
|
-
const { callAbleTimeRestTool } = await import("./abletime-rest-
|
|
231
|
+
const { callAbleTimeRestTool } = await import("./abletime-rest-QRTJH42S.js");
|
|
232
232
|
return callAbleTimeRestTool(name, args, { ...opts, token: rawToken });
|
|
233
233
|
}
|
|
234
234
|
const requestOpts = { ...opts, pm: opts?.pm ?? abletimeToolUsesPm(name) };
|
|
@@ -244,7 +244,7 @@ async function callAbleTimeTool(name, args = {}, opts) {
|
|
|
244
244
|
return await call();
|
|
245
245
|
}
|
|
246
246
|
if (rawToken && ableTimeUsesRest(rawToken) && isAbleTimeRejectedCredential(message)) {
|
|
247
|
-
const { callAbleTimeRestTool } = await import("./abletime-rest-
|
|
247
|
+
const { callAbleTimeRestTool } = await import("./abletime-rest-QRTJH42S.js");
|
|
248
248
|
return callAbleTimeRestTool(name, args, { ...opts, token: rawToken });
|
|
249
249
|
}
|
|
250
250
|
throw err instanceof Error ? new Error(rewriteAbleTimeError(err.message)) : err;
|
|
@@ -9,13 +9,14 @@ import {
|
|
|
9
9
|
enrichWorkspacesWithGithub,
|
|
10
10
|
ensureGlobalCoordinatorCwd,
|
|
11
11
|
formatWorkspaceInventory
|
|
12
|
-
} from "./chunk-
|
|
13
|
-
import "./chunk-
|
|
12
|
+
} from "./chunk-PTOIWKDU.js";
|
|
13
|
+
import "./chunk-42VGWRSE.js";
|
|
14
14
|
import "./chunk-D6JWYJ4P.js";
|
|
15
|
-
import "./chunk-
|
|
15
|
+
import "./chunk-RPZFNKND.js";
|
|
16
|
+
import "./chunk-X5B3OS5I.js";
|
|
16
17
|
import "./chunk-SYFVUF2C.js";
|
|
17
18
|
import "./chunk-FNQNJOHY.js";
|
|
18
|
-
import "./chunk-
|
|
19
|
+
import "./chunk-FUC3XFE2.js";
|
|
19
20
|
import "./chunk-NSTQ6QKD.js";
|
|
20
21
|
import "./chunk-KGZBYWZ3.js";
|
|
21
22
|
import "./chunk-EQNRWDLN.js";
|
|
@@ -7,15 +7,16 @@ import {
|
|
|
7
7
|
enrichWorkspacesWithGithub,
|
|
8
8
|
ensureGlobalCoordinatorCwd,
|
|
9
9
|
formatWorkspaceInventory
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import "./chunk-
|
|
10
|
+
} from "./chunk-TZCWNRMC.js";
|
|
11
|
+
import "./chunk-22A45QOI.js";
|
|
12
12
|
import "./chunk-6K64FJDD.js";
|
|
13
13
|
import "./chunk-QQKDGPUI.js";
|
|
14
|
-
import "./chunk-
|
|
14
|
+
import "./chunk-VJQDUD24.js";
|
|
15
15
|
import "./chunk-4TR3HZFT.js";
|
|
16
16
|
import "./chunk-WDRMZKVB.js";
|
|
17
17
|
import "./chunk-JT7R45JB.js";
|
|
18
|
-
import "./chunk-
|
|
18
|
+
import "./chunk-OY7THBLG.js";
|
|
19
|
+
import "./chunk-7J72QJOM.js";
|
|
19
20
|
import "./chunk-77WWLBCI.js";
|
|
20
21
|
import "./chunk-WFUDY6PC.js";
|
|
21
22
|
import "./chunk-UFHNSFAS.js";
|
|
@@ -1,37 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
|
-
|
|
5
|
-
} from "./chunk-
|
|
4
|
+
cursorSdkRunsNdjsonSearchPaths
|
|
5
|
+
} from "./chunk-X5B3OS5I.js";
|
|
6
|
+
import "./chunk-EQNRWDLN.js";
|
|
6
7
|
|
|
7
8
|
// src/agents/cursor-recover.ts
|
|
8
9
|
import { existsSync, readFileSync } from "fs";
|
|
9
|
-
|
|
10
|
-
// src/agents/cursor-store.ts
|
|
11
|
-
import { join } from "path";
|
|
12
|
-
var CURSOR_SDK_STORE_DIR = "cursor-sdk-store";
|
|
13
|
-
function cursorSdkStoreDir(threadId) {
|
|
14
|
-
const root = join(appDataDir(), CURSOR_SDK_STORE_DIR);
|
|
15
|
-
const id = sanitizeCursorStoreSegment(threadId);
|
|
16
|
-
if (!id) return root;
|
|
17
|
-
return join(root, "threads", id);
|
|
18
|
-
}
|
|
19
|
-
function cursorSdkRunsNdjsonPath(threadId) {
|
|
20
|
-
return join(cursorSdkStoreDir(threadId), "runs.ndjson");
|
|
21
|
-
}
|
|
22
|
-
function cursorSdkRunsNdjsonSearchPaths(threadId) {
|
|
23
|
-
const scoped = cursorSdkRunsNdjsonPath(threadId);
|
|
24
|
-
const shared = cursorSdkRunsNdjsonPath(null);
|
|
25
|
-
if (!threadId || !sanitizeCursorStoreSegment(threadId) || scoped === shared) {
|
|
26
|
-
return [shared];
|
|
27
|
-
}
|
|
28
|
-
return [scoped, shared];
|
|
29
|
-
}
|
|
30
|
-
function sanitizeCursorStoreSegment(threadId) {
|
|
31
|
-
return (threadId ?? "").trim().replace(/[^a-zA-Z0-9._-]/g, "_");
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// src/agents/cursor-recover.ts
|
|
35
10
|
function recoverFinishedCursorRun(opts) {
|
|
36
11
|
const agentId = opts.agentId.trim();
|
|
37
12
|
if (!agentId) return null;
|
|
@@ -17,13 +17,14 @@ import {
|
|
|
17
17
|
orchestratorSessionPoisonedByBuiltins,
|
|
18
18
|
slackCoordinatorSourceRef,
|
|
19
19
|
takenTeamSlugsForOrchestration
|
|
20
|
-
} from "./chunk-
|
|
21
|
-
import "./chunk-
|
|
20
|
+
} from "./chunk-PTOIWKDU.js";
|
|
21
|
+
import "./chunk-42VGWRSE.js";
|
|
22
22
|
import "./chunk-D6JWYJ4P.js";
|
|
23
|
-
import "./chunk-
|
|
23
|
+
import "./chunk-RPZFNKND.js";
|
|
24
|
+
import "./chunk-X5B3OS5I.js";
|
|
24
25
|
import "./chunk-SYFVUF2C.js";
|
|
25
26
|
import "./chunk-FNQNJOHY.js";
|
|
26
|
-
import "./chunk-
|
|
27
|
+
import "./chunk-FUC3XFE2.js";
|
|
27
28
|
import "./chunk-NSTQ6QKD.js";
|
|
28
29
|
import "./chunk-KGZBYWZ3.js";
|
|
29
30
|
import {
|
|
@@ -15,15 +15,16 @@ import {
|
|
|
15
15
|
orchestratorSessionPoisonedByBuiltins,
|
|
16
16
|
slackCoordinatorSourceRef,
|
|
17
17
|
takenTeamSlugsForOrchestration
|
|
18
|
-
} from "./chunk-
|
|
19
|
-
import "./chunk-
|
|
18
|
+
} from "./chunk-TZCWNRMC.js";
|
|
19
|
+
import "./chunk-22A45QOI.js";
|
|
20
20
|
import "./chunk-6K64FJDD.js";
|
|
21
21
|
import "./chunk-QQKDGPUI.js";
|
|
22
|
-
import "./chunk-
|
|
22
|
+
import "./chunk-VJQDUD24.js";
|
|
23
23
|
import "./chunk-4TR3HZFT.js";
|
|
24
24
|
import "./chunk-WDRMZKVB.js";
|
|
25
25
|
import "./chunk-JT7R45JB.js";
|
|
26
|
-
import "./chunk-
|
|
26
|
+
import "./chunk-OY7THBLG.js";
|
|
27
|
+
import "./chunk-7J72QJOM.js";
|
|
27
28
|
import "./chunk-77WWLBCI.js";
|
|
28
29
|
import {
|
|
29
30
|
globalAgentCwd
|