sessiongraph 1.0.19 → 1.0.20
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/PRIVACY.md +7 -0
- package/dist/assets/{index--OQ4NiAJ.js → index-BwNazXTF.js} +1 -1
- package/dist/assets/{index-DZcMVUpG.js → index-CUSJvhgf.js} +1 -1
- package/dist/assets/{index-ZvQzUBK1.css → index-CxnS4waR.css} +1 -1
- package/dist/assets/{index-DCSeQKMi.js → index-TSi2Km_w.js} +6 -6
- package/dist/assets/{index-ZwvTaIqn.js → index-nDYf67iK.js} +1 -1
- package/dist/assets/{public-viewer-DVqMq2gi.js → public-viewer-BMIcmydl.js} +1 -1
- package/dist/assets/{scene-B94ITHcm.js → scene-oSl4S0W6.js} +1 -1
- package/dist/assets/{share-DnZuWOzh.js → share-D7wrWEkV.js} +3 -3
- package/dist/index.html +2 -2
- package/dist-server/cli.mjs +428 -859
- package/dist-server/server.mjs +389 -829
- package/docs/cli.md +6 -0
- package/docs/guide.md +8 -0
- package/package.json +7 -7
package/dist-server/server.mjs
CHANGED
|
@@ -2139,7 +2139,7 @@ import { createServer } from "node:http";
|
|
|
2139
2139
|
import { createReadStream } from "node:fs";
|
|
2140
2140
|
import { stat as stat5 } from "node:fs/promises";
|
|
2141
2141
|
import { fileURLToPath as fileURLToPath5 } from "node:url";
|
|
2142
|
-
import { resolve as
|
|
2142
|
+
import { resolve as resolve4, extname, sep as sep4 } from "node:path";
|
|
2143
2143
|
import { randomBytes as randomBytes2, timingSafeEqual } from "node:crypto";
|
|
2144
2144
|
|
|
2145
2145
|
// server/adapters/opencode.ts
|
|
@@ -2615,7 +2615,7 @@ async function terminate(info, options, timing) {
|
|
|
2615
2615
|
await rm2(options.file ?? fallback2(), { force: true });
|
|
2616
2616
|
}
|
|
2617
2617
|
function delay(milliseconds) {
|
|
2618
|
-
return new Promise((
|
|
2618
|
+
return new Promise((resolve5) => setTimeout(resolve5, milliseconds));
|
|
2619
2619
|
}
|
|
2620
2620
|
var Service = { discover, ensure, stop, headers: headers2 };
|
|
2621
2621
|
|
|
@@ -3142,12 +3142,12 @@ function blockEvents(message2, content, transform = (v3) => v3) {
|
|
|
3142
3142
|
});
|
|
3143
3143
|
}
|
|
3144
3144
|
function userBlockEvents(message2, content, normalize) {
|
|
3145
|
-
const
|
|
3145
|
+
const context2 = [];
|
|
3146
3146
|
return blockEvents(message2, content, (value) => {
|
|
3147
3147
|
const text2 = normalize(value);
|
|
3148
|
-
|
|
3148
|
+
context2.push(Boolean(value && !text2));
|
|
3149
3149
|
return text2 || value;
|
|
3150
|
-
}).map((event) => event.kind === "message" &&
|
|
3150
|
+
}).map((event) => event.kind === "message" && context2.shift() ? { ...event, kind: "event", role: "system", name: "Session context", nativeType: "user-context" } : event);
|
|
3151
3151
|
}
|
|
3152
3152
|
function normalizedEvents(message2, sessionID) {
|
|
3153
3153
|
let events = message2.events;
|
|
@@ -3189,8 +3189,8 @@ var COMMIT_EXTRACTOR_VERSION = 1;
|
|
|
3189
3189
|
var object2 = (v3) => v3 && typeof v3 === "object" && !Array.isArray(v3) ? v3 : {};
|
|
3190
3190
|
var string2 = (v3) => typeof v3 === "string" ? v3 : void 0;
|
|
3191
3191
|
var exitCode = (v3) => typeof v3 === "number" && Number.isSafeInteger(v3) ? v3 : void 0;
|
|
3192
|
-
function executionFields(input,
|
|
3193
|
-
const args = object2(input), meta = object2(
|
|
3192
|
+
function executionFields(input, metadata3 = {}) {
|
|
3193
|
+
const args = object2(input), meta = object2(metadata3);
|
|
3194
3194
|
return { cwd: string2(args.workdir ?? args.cwd ?? args.working_directory ?? meta.cwd), exitCode: exitCode(meta.exitCode ?? meta.exit_code ?? meta.exit) };
|
|
3195
3195
|
}
|
|
3196
3196
|
function nativeCommit(value) {
|
|
@@ -3446,16 +3446,16 @@ async function fileState(path) {
|
|
|
3446
3446
|
async function historyFiles(roots2, match2) {
|
|
3447
3447
|
const files = [], queue = [];
|
|
3448
3448
|
const warnings = [];
|
|
3449
|
-
for (const
|
|
3449
|
+
for (const root2 of new Set(roots2)) {
|
|
3450
3450
|
try {
|
|
3451
|
-
if ((await lstat(
|
|
3451
|
+
if ((await lstat(root2)).isDirectory()) queue.push({ root: root2, path: root2, depth: 0 });
|
|
3452
3452
|
} catch (error) {
|
|
3453
3453
|
if (error.code !== "ENOENT") warnings.push("A history directory could not be read.");
|
|
3454
3454
|
}
|
|
3455
3455
|
}
|
|
3456
3456
|
let entriesSeen = 0, limited = false;
|
|
3457
3457
|
for (let i = 0; i < queue.length && files.length < MAX_FILES && entriesSeen < 1e5; i++) {
|
|
3458
|
-
const { root:
|
|
3458
|
+
const { root: root2, path, depth } = queue[i];
|
|
3459
3459
|
let entries2;
|
|
3460
3460
|
try {
|
|
3461
3461
|
entries2 = await readdir(path, { withFileTypes: true });
|
|
@@ -3470,10 +3470,10 @@ async function historyFiles(roots2, match2) {
|
|
|
3470
3470
|
}
|
|
3471
3471
|
const file = join4(path, entry.name);
|
|
3472
3472
|
if (entry.isDirectory()) {
|
|
3473
|
-
if (depth < 6 && queue.length < MAX_FILES) queue.push({ root:
|
|
3473
|
+
if (depth < 6 && queue.length < MAX_FILES) queue.push({ root: root2, path: file, depth: depth + 1 });
|
|
3474
3474
|
else limited = true;
|
|
3475
3475
|
}
|
|
3476
|
-
if (entry.isFile() && match2(relative(
|
|
3476
|
+
if (entry.isFile() && match2(relative(root2, file).split("\\").join("/"))) files.push(file);
|
|
3477
3477
|
}
|
|
3478
3478
|
}
|
|
3479
3479
|
if (limited) warnings.push("History discovery reached its file, directory, or depth limit.");
|
|
@@ -3500,7 +3500,7 @@ function jsonLines(value) {
|
|
|
3500
3500
|
return { rows: rows2, partial };
|
|
3501
3501
|
}
|
|
3502
3502
|
function localFileAdapter(source) {
|
|
3503
|
-
const
|
|
3503
|
+
const metadata3 = /* @__PURE__ */ new Map();
|
|
3504
3504
|
let cached2;
|
|
3505
3505
|
const states = (path) => Promise.all([path, ...source.extras?.(path) || []].map(fileState));
|
|
3506
3506
|
const revision2 = (values) => digest([1, ...values.filter((_, i) => i === 0 || source.revisionExtras !== false).map((s) => [s.path, s.signature])]);
|
|
@@ -3545,7 +3545,7 @@ function localFileAdapter(source) {
|
|
|
3545
3545
|
description: source.description,
|
|
3546
3546
|
capabilities: source.capabilities,
|
|
3547
3547
|
async detect() {
|
|
3548
|
-
for (const
|
|
3548
|
+
for (const root2 of source.roots()) if ((await lstat(root2).catch(() => void 0))?.isDirectory()) return true;
|
|
3549
3549
|
return false;
|
|
3550
3550
|
},
|
|
3551
3551
|
async discover() {
|
|
@@ -3555,7 +3555,7 @@ function localFileAdapter(source) {
|
|
|
3555
3555
|
for (const path of listing.files) {
|
|
3556
3556
|
try {
|
|
3557
3557
|
const before = await states(path), rev = revision2(before);
|
|
3558
|
-
let candidate =
|
|
3558
|
+
let candidate = metadata3.get(path);
|
|
3559
3559
|
if (!candidate || candidate.revision !== rev) {
|
|
3560
3560
|
const history = await load(path, rev, before);
|
|
3561
3561
|
if (!history) {
|
|
@@ -3576,7 +3576,7 @@ function localFileAdapter(source) {
|
|
|
3576
3576
|
session.forkID = history.fork ? identity(source.id, history.fork) : void 0;
|
|
3577
3577
|
if (session.title === "Untitled session" || !session.title) session.title = history.messages.flatMap((m) => m.role === "user" ? m.fragments.filter((f) => f.kind === "You").map((f) => f.text) : []).find(Boolean)?.replace(/\s+/g, " ").slice(0, 180) || `${source.name} session`;
|
|
3578
3578
|
candidate = { session, revision: rev, locator: { path } };
|
|
3579
|
-
|
|
3579
|
+
metadata3.set(path, candidate);
|
|
3580
3580
|
}
|
|
3581
3581
|
const previous = found.get(candidate.session.id);
|
|
3582
3582
|
const preferred = candidate.locator.path.endsWith(".jsonl"), previousPreferred = previous?.locator.path.endsWith(".jsonl");
|
|
@@ -3591,7 +3591,7 @@ function localFileAdapter(source) {
|
|
|
3591
3591
|
}
|
|
3592
3592
|
}
|
|
3593
3593
|
const listed = new Set(listing.files);
|
|
3594
|
-
for (const path of
|
|
3594
|
+
for (const path of metadata3.keys()) if (!listed.has(path)) metadata3.delete(path);
|
|
3595
3595
|
if (failed) listing.warnings.push(`${source.name}: Skipped ${failed} unreadable, changing, unsupported, or oversized ${failed === 1 ? "history file" : "history files"}.`);
|
|
3596
3596
|
const sessions = [...found.values()].filter((c) => !blocked.has(c.session.id));
|
|
3597
3597
|
const errors = unreadable.size ? [`${source.name}: Could not read history for ${unreadable.size} ${unreadable.size === 1 ? "session" : "sessions"}.`] : void 0;
|
|
@@ -3821,7 +3821,7 @@ function optionalJSON(value) {
|
|
|
3821
3821
|
return value == null || value === "" ? {} : sqliteJSON(value);
|
|
3822
3822
|
}
|
|
3823
3823
|
function sqliteHistoryAdapter(source) {
|
|
3824
|
-
const
|
|
3824
|
+
const metadata3 = /* @__PURE__ */ new Map();
|
|
3825
3825
|
return {
|
|
3826
3826
|
id: source.id,
|
|
3827
3827
|
name: source.name,
|
|
@@ -3836,7 +3836,7 @@ function sqliteHistoryAdapter(source) {
|
|
|
3836
3836
|
for (const path of await source.paths()) {
|
|
3837
3837
|
try {
|
|
3838
3838
|
const snapshot2 = sqliteRevision(path), rev = digest([source.version || 2, source.id, snapshot2]);
|
|
3839
|
-
let cached2 =
|
|
3839
|
+
let cached2 = metadata3.get(path);
|
|
3840
3840
|
if (!cached2 || cached2.revision !== rev) {
|
|
3841
3841
|
cached2 = withSqliteSnapshot(path, (db2) => {
|
|
3842
3842
|
const table = typeof source.table === "string" ? source.table : source.table(db2);
|
|
@@ -3874,7 +3874,7 @@ function sqliteHistoryAdapter(source) {
|
|
|
3874
3874
|
if (failed) errors2.push(`${source.name}: Skipped ${failed} unreadable, undated, unsupported, or oversized ${failed === 1 ? "session" : "sessions"}.`);
|
|
3875
3875
|
return { revision: rev, candidates: found, blocked: blocked2, errors: errors2 };
|
|
3876
3876
|
}, snapshot2);
|
|
3877
|
-
|
|
3877
|
+
metadata3.set(path, cached2);
|
|
3878
3878
|
}
|
|
3879
3879
|
errors.push(...cached2.errors);
|
|
3880
3880
|
blocked.push(...cached2.blocked);
|
|
@@ -4044,16 +4044,16 @@ var sessionFields = [
|
|
|
4044
4044
|
];
|
|
4045
4045
|
async function openCodeDatabases() {
|
|
4046
4046
|
const override = sourcePath("opencode") || process.env.SESSIONGRAPH_OPENCODE_HISTORY_DIR || process.env.OPENCODE_DB;
|
|
4047
|
-
const
|
|
4047
|
+
const root2 = override || dataPath("opencode");
|
|
4048
4048
|
try {
|
|
4049
|
-
const info = await lstat3(
|
|
4050
|
-
if (info.isFile()) return [
|
|
4049
|
+
const info = await lstat3(root2);
|
|
4050
|
+
if (info.isFile()) return [root2];
|
|
4051
4051
|
if (!info.isDirectory()) return [];
|
|
4052
|
-
const files = (await readdir2(
|
|
4052
|
+
const files = (await readdir2(root2)).filter((name) => /^opencode(?:[-.][\w.-]+)?\.db$/.test(name)).sort((a, b) => a === "opencode.db" ? -1 : b === "opencode.db" ? 1 : a.localeCompare(b));
|
|
4053
4053
|
if (files.length > 20) throw new Error("Too many OpenCode databases. Choose a database file with a source path override.");
|
|
4054
4054
|
const paths2 = [];
|
|
4055
4055
|
for (const file of files) {
|
|
4056
|
-
const path = join6(
|
|
4056
|
+
const path = join6(root2, file);
|
|
4057
4057
|
if ((await lstat3(path)).isFile()) paths2.push(path);
|
|
4058
4058
|
}
|
|
4059
4059
|
return paths2;
|
|
@@ -4290,15 +4290,6 @@ import { basename as o0, dirname as s0, isAbsolute as Fst, join as WTe, relative
|
|
|
4290
4290
|
import { createHash as YRe } from "crypto";
|
|
4291
4291
|
import { constants as PU } from "fs";
|
|
4292
4292
|
import { isAbsolute as KTe, sep as r0 } from "path";
|
|
4293
|
-
import { readdir as PR, stat as TOe } from "fs/promises";
|
|
4294
|
-
import { basename as sOe, dirname as iOe, join as aOe } from "path";
|
|
4295
|
-
import { basename as OOe, join as Sd } from "path";
|
|
4296
|
-
import { readFile as dOe } from "fs/promises";
|
|
4297
|
-
import { dirname as pOe, join as fOe } from "path";
|
|
4298
|
-
import { basename as E0, dirname as b0 } from "path";
|
|
4299
|
-
import { constants as Xm } from "fs";
|
|
4300
|
-
import { lstat as _Oe, open as yOe } from "fs/promises";
|
|
4301
|
-
import { dirname as SOe, join as EOe } from "path";
|
|
4302
4293
|
import { AsyncLocalStorage as dwe } from "async_hooks";
|
|
4303
4294
|
import { closeSync as Oat, constants as Kt, fchmodSync as wat, fstatSync as xat, ftruncateSync as vat, lstatSync as kat, openSync as Pat, readFileSync as Iat, renameSync as Dat, unlinkSync as Lat, writeFileSync as Mat } from "fs";
|
|
4304
4295
|
import { readdir as Iwe, readFile as J0 } from "fs/promises";
|
|
@@ -12542,9 +12533,6 @@ function R5(e10) {
|
|
|
12542
12533
|
if (e10?.anchors !== void 0 && e10.anchors.length > 0) return e10.anchors;
|
|
12543
12534
|
return e10?.anchor !== void 0 ? [e10.anchor] : void 0;
|
|
12544
12535
|
}
|
|
12545
|
-
async function xP(e10) {
|
|
12546
|
-
return Ua(e10) || du(e10) || vo(e10) || Ss(e10) || await gu(TE, e10) !== void 0;
|
|
12547
|
-
}
|
|
12548
12536
|
async function RE(e10, t = TE) {
|
|
12549
12537
|
return Ua(e10) || du(e10) || vo(e10) || Ss(e10) || await gu(t, e10, { surfaceNetworkRaw: true, unreadableAncestry: "unverified" }) !== void 0;
|
|
12550
12538
|
}
|
|
@@ -14516,49 +14504,6 @@ function ab(e10) {
|
|
|
14516
14504
|
return t;
|
|
14517
14505
|
}
|
|
14518
14506
|
var met = ib("claude-cli");
|
|
14519
|
-
function See(e10) {
|
|
14520
|
-
return `</pasted_content id="${e10}">
|
|
14521
|
-
`;
|
|
14522
|
-
}
|
|
14523
|
-
function Eee(e10) {
|
|
14524
|
-
if (e10.length !== 4) return false;
|
|
14525
|
-
for (let t = 0; t < e10.length; t++) {
|
|
14526
|
-
let n = e10.charCodeAt(t);
|
|
14527
|
-
if (!(n >= 48 && n <= 57 || n >= 97 && n <= 102)) return false;
|
|
14528
|
-
}
|
|
14529
|
-
return true;
|
|
14530
|
-
}
|
|
14531
|
-
function bee(e10) {
|
|
14532
|
-
let t = [], n = 0, r = 0;
|
|
14533
|
-
for (; ; ) {
|
|
14534
|
-
let o = e10.indexOf('<pasted_content id="', r);
|
|
14535
|
-
if (o === -1) break;
|
|
14536
|
-
let s = o + 20, i = e10.slice(s, s + 4);
|
|
14537
|
-
if (!Eee(i) || !e10.startsWith(`">
|
|
14538
|
-
`, s + 4)) {
|
|
14539
|
-
r = s;
|
|
14540
|
-
continue;
|
|
14541
|
-
}
|
|
14542
|
-
let a = s + 4 + 3, c = See(i).slice(0, -1), d = e10.indexOf(`
|
|
14543
|
-
${c}`, a - 1) + 1;
|
|
14544
|
-
if (d === 0) break;
|
|
14545
|
-
let p = o;
|
|
14546
|
-
for (let f = 0; f < 2 && p > n && e10[p - 1] === `
|
|
14547
|
-
`; f++) p--;
|
|
14548
|
-
if (p > n) t.push({ kind: "text", text: e10.slice(n, p) });
|
|
14549
|
-
n = d + c.length;
|
|
14550
|
-
for (let f = 0; f < 2 && e10[n] === `
|
|
14551
|
-
`; f++) n++;
|
|
14552
|
-
t.push({ kind: "block", id: i, body: e10.slice(a, d - 1), raw: e10.slice(p, n) }), r = n;
|
|
14553
|
-
}
|
|
14554
|
-
if (n < e10.length) t.push({ kind: "text", text: e10.slice(n) });
|
|
14555
|
-
return t;
|
|
14556
|
-
}
|
|
14557
|
-
function lb(e10) {
|
|
14558
|
-
let t = bee(e10);
|
|
14559
|
-
if (t.length === 1 && t[0].kind === "text") return e10;
|
|
14560
|
-
return t.map((n) => n.kind === "text" ? n.text : n.body).join("");
|
|
14561
|
-
}
|
|
14562
14507
|
var Cee = "<system-reminder>";
|
|
14563
14508
|
var yet = Cee.slice(0, -1);
|
|
14564
14509
|
function Aee() {
|
|
@@ -16206,7 +16151,6 @@ function vD(e10, t, n) {
|
|
|
16206
16151
|
let r = yb(e10) ?? (t === "task-notification" ? { kind: "task-notification" } : void 0), o = ku(n);
|
|
16207
16152
|
return o !== void 0 && r?.kind === "task-notification" && r.runId === void 0 ? { ...r, runId: o } : r;
|
|
16208
16153
|
}
|
|
16209
|
-
var kD = 1e4;
|
|
16210
16154
|
async function vr(e10, t, n) {
|
|
16211
16155
|
let r = Math.max(1, Math.floor(n?.maxPages ?? 1e4)), o;
|
|
16212
16156
|
for (let s = 0; s < r; s++) {
|
|
@@ -16221,37 +16165,6 @@ async function vr(e10, t, n) {
|
|
|
16221
16165
|
}
|
|
16222
16166
|
return { status: "capped" };
|
|
16223
16167
|
}
|
|
16224
|
-
var Sbe = /^(?:\s*<[a-z][\w-]*[\s>]|\[Request interrupted by user[^\]]*\])/;
|
|
16225
|
-
var Ebe = /<command-name>(.*?)<\/command-name>/;
|
|
16226
|
-
function zi(e10, t) {
|
|
16227
|
-
if (e10.type !== "user") return;
|
|
16228
|
-
if (e10.isMeta === true || e10.isCompactSummary === true) return;
|
|
16229
|
-
let n = e10.message;
|
|
16230
|
-
if (!n) return;
|
|
16231
|
-
let r = n.content, o = [];
|
|
16232
|
-
if (typeof r === "string") o.push(r);
|
|
16233
|
-
else if (Array.isArray(r)) for (let s of r) {
|
|
16234
|
-
if (!s || typeof s !== "object") continue;
|
|
16235
|
-
if (s.type === "tool_result") return;
|
|
16236
|
-
if (s.type === "text" && typeof s.text === "string") o.push(s.text);
|
|
16237
|
-
}
|
|
16238
|
-
for (let s of o) {
|
|
16239
|
-
let i = lb(s).replaceAll(`
|
|
16240
|
-
`, " ").trim();
|
|
16241
|
-
if (!i) continue;
|
|
16242
|
-
let a = Ebe.exec(i);
|
|
16243
|
-
if (a) {
|
|
16244
|
-
if (!t.commandFallback) t.commandFallback = a[1];
|
|
16245
|
-
continue;
|
|
16246
|
-
}
|
|
16247
|
-
let l = /<bash-input>([\s\S]*?)<\/bash-input>/.exec(i);
|
|
16248
|
-
if (l) return `! ${l[1].trim()}`;
|
|
16249
|
-
if (Sbe.test(i)) continue;
|
|
16250
|
-
if (i.length > 200) i = Cs(i, 200).trim() + "\u2026";
|
|
16251
|
-
return i;
|
|
16252
|
-
}
|
|
16253
|
-
return;
|
|
16254
|
-
}
|
|
16255
16168
|
function PD(e10, t) {
|
|
16256
16169
|
if (process.platform !== "darwin" || Boolean(t.DEVELOPER_DIR)) return false;
|
|
16257
16170
|
try {
|
|
@@ -16341,68 +16254,11 @@ async function Do(e10) {
|
|
|
16341
16254
|
}
|
|
16342
16255
|
}
|
|
16343
16256
|
var En = 65536;
|
|
16344
|
-
var Gbe = /* @__PURE__ */ new Set(["sdk-cli", "sdk-ts", "sdk-py"]);
|
|
16345
|
-
function WD(e10, t) {
|
|
16346
|
-
let n = nl(e10, "entrypoint") ?? Xt(t, "entrypoint");
|
|
16347
|
-
if (n && Gbe.has(n)) return true;
|
|
16348
|
-
let r = e10.split(`
|
|
16349
|
-
`).find((s) => s.includes('"parentUuid":')) ?? e10, o = nl(r, "sessionKind");
|
|
16350
|
-
return o === "daemon" || o === "daemon-worker";
|
|
16351
|
-
}
|
|
16352
16257
|
var Wbe = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
16353
16258
|
function Ve(e10) {
|
|
16354
16259
|
if (typeof e10 !== "string") return null;
|
|
16355
16260
|
return Wbe.test(e10) ? e10 : null;
|
|
16356
16261
|
}
|
|
16357
|
-
function VD(e10) {
|
|
16358
|
-
if (!e10.includes("\\")) return e10;
|
|
16359
|
-
try {
|
|
16360
|
-
return JSON.parse(`"${e10}"`);
|
|
16361
|
-
} catch {
|
|
16362
|
-
return e10;
|
|
16363
|
-
}
|
|
16364
|
-
}
|
|
16365
|
-
function nl(e10, t) {
|
|
16366
|
-
let n = [`"${t}":"`, `"${t}": "`];
|
|
16367
|
-
for (let r of n) {
|
|
16368
|
-
let o = e10.indexOf(r);
|
|
16369
|
-
if (o < 0) continue;
|
|
16370
|
-
let s = o + r.length, i = s;
|
|
16371
|
-
while (i < e10.length) {
|
|
16372
|
-
if (e10[i] === "\\") {
|
|
16373
|
-
i += 2;
|
|
16374
|
-
continue;
|
|
16375
|
-
}
|
|
16376
|
-
if (e10[i] === '"') return VD(e10.slice(s, i));
|
|
16377
|
-
i++;
|
|
16378
|
-
}
|
|
16379
|
-
}
|
|
16380
|
-
return;
|
|
16381
|
-
}
|
|
16382
|
-
function Xt(e10, t) {
|
|
16383
|
-
let n = [`"${t}":"`, `"${t}": "`], r, o = -1;
|
|
16384
|
-
for (let s of n) {
|
|
16385
|
-
let i = 0;
|
|
16386
|
-
while (true) {
|
|
16387
|
-
let a = e10.indexOf(s, i);
|
|
16388
|
-
if (a < 0) break;
|
|
16389
|
-
let l = a + s.length, c = l;
|
|
16390
|
-
while (c < e10.length) {
|
|
16391
|
-
if (e10[c] === "\\") {
|
|
16392
|
-
c += 2;
|
|
16393
|
-
continue;
|
|
16394
|
-
}
|
|
16395
|
-
if (e10[c] === '"') {
|
|
16396
|
-
if (a > o) r = VD(e10.slice(l, c)), o = a;
|
|
16397
|
-
break;
|
|
16398
|
-
}
|
|
16399
|
-
c++;
|
|
16400
|
-
}
|
|
16401
|
-
i = c + 1;
|
|
16402
|
-
}
|
|
16403
|
-
}
|
|
16404
|
-
return r;
|
|
16405
|
-
}
|
|
16406
16262
|
function am(e10, t, n) {
|
|
16407
16263
|
return Vbe(e10, n, t);
|
|
16408
16264
|
}
|
|
@@ -16442,37 +16298,6 @@ function Sb(e10, t) {
|
|
|
16442
16298
|
function lm(e10, t) {
|
|
16443
16299
|
return e10?.realWorkspacePath === void 0 ? void 0 : { hoverRestOn: t, realPath: e10.realWorkspacePath };
|
|
16444
16300
|
}
|
|
16445
|
-
function cm(e10) {
|
|
16446
|
-
let t = 0, n = { commandFallback: "" };
|
|
16447
|
-
while (t < e10.length) {
|
|
16448
|
-
let r = e10.indexOf(`
|
|
16449
|
-
`, t), o = r >= 0 ? e10.slice(t, r) : e10.slice(t);
|
|
16450
|
-
if (t = r >= 0 ? r + 1 : e10.length, !o.includes('"type":"user"') && !o.includes('"type": "user"')) continue;
|
|
16451
|
-
if (o.includes('"tool_result"')) continue;
|
|
16452
|
-
if (o.includes('"isMeta":true') || o.includes('"isMeta": true')) continue;
|
|
16453
|
-
if (o.includes('"isCompactSummary":true') || o.includes('"isCompactSummary": true')) continue;
|
|
16454
|
-
try {
|
|
16455
|
-
let s = JSON.parse(o), i = zi(s, n);
|
|
16456
|
-
if (i !== void 0) return i;
|
|
16457
|
-
} catch {
|
|
16458
|
-
continue;
|
|
16459
|
-
}
|
|
16460
|
-
}
|
|
16461
|
-
return n.commandFallback;
|
|
16462
|
-
}
|
|
16463
|
-
function qD(e10) {
|
|
16464
|
-
let t = 0;
|
|
16465
|
-
while (t < e10.length) {
|
|
16466
|
-
let n = e10.indexOf(`
|
|
16467
|
-
`, t), r = n >= 0 ? e10.slice(t, n) : e10.slice(t);
|
|
16468
|
-
if (t = n >= 0 ? n + 1 : e10.length, !r.includes('"type":"user"') && !r.includes('"type": "user"')) continue;
|
|
16469
|
-
if (r.includes('"tool_result"')) continue;
|
|
16470
|
-
if (r.includes('"isMeta":true') || r.includes('"isMeta": true')) continue;
|
|
16471
|
-
if (r.includes('"type":"image"') || r.includes('"type": "image"')) return "Image";
|
|
16472
|
-
if (r.includes('"type":"document"') || r.includes('"type": "document"')) return "Document";
|
|
16473
|
-
}
|
|
16474
|
-
return "";
|
|
16475
|
-
}
|
|
16476
16301
|
var ND = process.platform === "win32" ? Pu.O_RDONLY : Pu.O_RDONLY | Pu.O_NOFOLLOW | Pu.O_NONBLOCK;
|
|
16477
16302
|
async function Zbe(e10) {
|
|
16478
16303
|
let { backend: t, key: n } = e10;
|
|
@@ -16562,43 +16387,6 @@ function Mu(e10) {
|
|
|
16562
16387
|
if (t.length <= Lo) return t;
|
|
16563
16388
|
return `${t.slice(0, Lo)}-${Jbe(e10)}`;
|
|
16564
16389
|
}
|
|
16565
|
-
function om(e10, t) {
|
|
16566
|
-
let n = e10.replaceAll("\\", "/");
|
|
16567
|
-
return t ? n.toLowerCase() : n;
|
|
16568
|
-
}
|
|
16569
|
-
function FD(e10, t, n) {
|
|
16570
|
-
let r = Ye(e10), o = Ye(t), s = (i) => n ? i.toLowerCase() : i;
|
|
16571
|
-
if (s(rl(r)) !== s(rl(o))) return false;
|
|
16572
|
-
return om(r, n) !== om(o, n);
|
|
16573
|
-
}
|
|
16574
|
-
async function XD(e10, t, n, r, o) {
|
|
16575
|
-
if (!FD(e10, t, n)) return false;
|
|
16576
|
-
if (uu(e10) || uu(t)) return false;
|
|
16577
|
-
if (await r(e10) || await r(t)) return false;
|
|
16578
|
-
let s;
|
|
16579
|
-
try {
|
|
16580
|
-
if (o !== void 0 && o.hoverRestOn) {
|
|
16581
|
-
let a = await o.realPath(e10);
|
|
16582
|
-
if (!a.ok || !a.value.found) return false;
|
|
16583
|
-
s = Ye(a.value.path);
|
|
16584
|
-
} else s = Ye(await GD(e10));
|
|
16585
|
-
} catch {
|
|
16586
|
-
return false;
|
|
16587
|
-
}
|
|
16588
|
-
let i = await Mo(t, o);
|
|
16589
|
-
return FD(s, i, n);
|
|
16590
|
-
}
|
|
16591
|
-
function QD(e10, t, n) {
|
|
16592
|
-
if (t === void 0) return false;
|
|
16593
|
-
let r = om(Ye(e10), n);
|
|
16594
|
-
return t.some((o) => {
|
|
16595
|
-
let s = om(Ye(o), n);
|
|
16596
|
-
return r === s || r.startsWith(s.endsWith("/") ? s : s + "/");
|
|
16597
|
-
});
|
|
16598
|
-
}
|
|
16599
|
-
function bb() {
|
|
16600
|
-
return process.platform === "win32" || process.platform === "darwin";
|
|
16601
|
-
}
|
|
16602
16390
|
function St() {
|
|
16603
16391
|
return kr(Dt(), "projects");
|
|
16604
16392
|
}
|
|
@@ -21016,9 +20804,6 @@ function GTe(e10) {
|
|
|
21016
20804
|
function TR(e10) {
|
|
21017
20805
|
return (t) => e10.hostFiles.realPath(kf.workspace(t === "" || KTe(t) ? t : GTe(t)), { native: true });
|
|
21018
20806
|
}
|
|
21019
|
-
function gd(e10) {
|
|
21020
|
-
return e10 === void 0 ? void 0 : { hoverRestOn: be(), realPath: TR(e10) };
|
|
21021
|
-
}
|
|
21022
20807
|
function VTe(e10) {
|
|
21023
20808
|
return e10.namespace !== "transcript" || e10.journal !== void 0 || e10.sessionJournal !== void 0 ? void 0 : e10.agentId ?? null;
|
|
21024
20809
|
}
|
|
@@ -21462,12 +21247,6 @@ async function g0(e10, t, n, r) {
|
|
|
21462
21247
|
let { entries: l, delivered: c } = await ZTe(a);
|
|
21463
21248
|
return m0(l, t, c);
|
|
21464
21249
|
}
|
|
21465
|
-
function lOe() {
|
|
21466
|
-
return aOe(Dt(), "projects");
|
|
21467
|
-
}
|
|
21468
|
-
function h0(e10) {
|
|
21469
|
-
return iOe(e10) === lOe() ? sOe(e10) : void 0;
|
|
21470
|
-
}
|
|
21471
21250
|
var _0 = class {
|
|
21472
21251
|
projectDirCache = /* @__PURE__ */ new Map();
|
|
21473
21252
|
agentTranscriptSubdirs = /* @__PURE__ */ new Map();
|
|
@@ -21485,314 +21264,12 @@ var _0 = class {
|
|
|
21485
21264
|
}
|
|
21486
21265
|
};
|
|
21487
21266
|
var Eit = new Pe(() => new _0());
|
|
21488
|
-
var y0 = 200;
|
|
21489
|
-
function cOe(e10) {
|
|
21490
|
-
return [...e10.replace(/[\x00-\x1f\x7f-\x9f]/g, "")].slice(0, y0).join("");
|
|
21491
|
-
}
|
|
21492
|
-
function S0(e10) {
|
|
21493
|
-
return cOe(Vf(e10.trim())).trim();
|
|
21494
|
-
}
|
|
21495
|
-
var uOe = 6;
|
|
21496
|
-
function C0(e10) {
|
|
21497
|
-
let t = E0(e10);
|
|
21498
|
-
if (fd(t)) return;
|
|
21499
|
-
let n = St(), r = [t], o = b0(e10);
|
|
21500
|
-
while (o !== n && r.length <= uOe + 1) {
|
|
21501
|
-
let c = b0(o);
|
|
21502
|
-
if (c === o) return;
|
|
21503
|
-
r.unshift(E0(o)), o = c;
|
|
21504
|
-
}
|
|
21505
|
-
if (o !== n || r.length < 3) return;
|
|
21506
|
-
let [s, i, ...a] = r;
|
|
21507
|
-
if (!Qt(s) || !Qt(i) || a.length === 0 || !a.every(Qt)) return;
|
|
21508
|
-
let l = Mt.sidecar(s, i, a);
|
|
21509
|
-
return zo(l) === void 0 ? l : void 0;
|
|
21510
|
-
}
|
|
21511
21267
|
var mOe = k(() => R({ customTitle: h() }));
|
|
21512
|
-
function gOe(e10, t) {
|
|
21513
|
-
return fOe(pOe(e10), t, "custom-title.json");
|
|
21514
|
-
}
|
|
21515
|
-
async function ml(e10, t, n) {
|
|
21516
|
-
let r = await hOe(gOe(e10, t), n);
|
|
21517
|
-
if (r === void 0) return;
|
|
21518
|
-
let o;
|
|
21519
|
-
try {
|
|
21520
|
-
o = JSON.parse(r);
|
|
21521
|
-
} catch {
|
|
21522
|
-
return;
|
|
21523
|
-
}
|
|
21524
|
-
let s = mOe().safeParse(o);
|
|
21525
|
-
if (!s.success) return;
|
|
21526
|
-
return S0(s.data.customTitle) || void 0;
|
|
21527
|
-
}
|
|
21528
|
-
async function hOe(e10, t) {
|
|
21529
|
-
if (be() && t !== void 0) try {
|
|
21530
|
-
let n = C0(e10);
|
|
21531
|
-
if (n !== void 0) {
|
|
21532
|
-
let r = await t.readText([n]);
|
|
21533
|
-
if (!r.ok) return;
|
|
21534
|
-
let o = r.value.items[0];
|
|
21535
|
-
return o.found ? o.value : void 0;
|
|
21536
|
-
}
|
|
21537
|
-
} catch {
|
|
21538
|
-
return;
|
|
21539
|
-
}
|
|
21540
|
-
if (Qe()) return;
|
|
21541
|
-
try {
|
|
21542
|
-
return await dOe(e10, "utf8");
|
|
21543
|
-
} catch {
|
|
21544
|
-
return;
|
|
21545
|
-
}
|
|
21546
|
-
}
|
|
21547
21268
|
function se(e10) {
|
|
21548
21269
|
return typeof e10 === "object" && e10 !== null && !Array.isArray(e10);
|
|
21549
21270
|
}
|
|
21550
|
-
var A0 = '"type":"continued-in"';
|
|
21551
21271
|
var bOe = k(() => Bt({ type: N("continued-in"), continuedInSessionId: h() }));
|
|
21552
21272
|
var COe = k(() => Bt({ type: N("assistant"), isApiErrorMessage: x().optional(), message: Bt({ stop_reason: h().nullish() }).optional() }));
|
|
21553
|
-
function T0(e10) {
|
|
21554
|
-
if (!e10.includes(A0)) return;
|
|
21555
|
-
let t = e10.length;
|
|
21556
|
-
while (t > 0) {
|
|
21557
|
-
let n = e10.lastIndexOf(`
|
|
21558
|
-
`, t - 1), r = e10.slice(n + 1, t);
|
|
21559
|
-
t = n;
|
|
21560
|
-
let o = r.includes(A0), s = r.includes('"type":"user"') || r.includes('"type":"assistant"');
|
|
21561
|
-
if (o || s) try {
|
|
21562
|
-
let i = JSON.parse(r);
|
|
21563
|
-
if (o) {
|
|
21564
|
-
let a = bOe().safeParse(i);
|
|
21565
|
-
if (a.success) return Ve(a.data.continuedInSessionId) ?? void 0;
|
|
21566
|
-
}
|
|
21567
|
-
if (s && AOe(i)) return;
|
|
21568
|
-
} catch {
|
|
21569
|
-
}
|
|
21570
|
-
if (n < 0) break;
|
|
21571
|
-
}
|
|
21572
|
-
return;
|
|
21573
|
-
}
|
|
21574
|
-
function AOe(e10) {
|
|
21575
|
-
let t = COe().safeParse(e10);
|
|
21576
|
-
if (t.success) return t.data.isApiErrorMessage !== true && typeof t.data.message?.stop_reason === "string";
|
|
21577
|
-
return se(e10) && zi(e10, { commandFallback: "" }) !== void 0;
|
|
21578
|
-
}
|
|
21579
|
-
async function O0(e10, t, n) {
|
|
21580
|
-
let r = EOe(SOe(e10), `${t}.jsonl`), o = await ji(r, cn(Lr(r, n)));
|
|
21581
|
-
return o !== null && await w0(r, o.head, o.tail, o.size, n);
|
|
21582
|
-
}
|
|
21583
|
-
var yd = '"parentUuid":';
|
|
21584
|
-
var ROe = 16777216;
|
|
21585
|
-
var R0 = 1048576;
|
|
21586
|
-
async function w0(e10, t, n, r, o) {
|
|
21587
|
-
if (t.includes(yd) || n.includes(yd)) return true;
|
|
21588
|
-
if (r <= En) return false;
|
|
21589
|
-
if (Lr(e10, o) !== void 0) return true;
|
|
21590
|
-
try {
|
|
21591
|
-
let s = process.platform !== "win32";
|
|
21592
|
-
if (!s && !(await _Oe(e10)).isFile()) return false;
|
|
21593
|
-
let i = await yOe(e10, s ? Xm.O_RDONLY | Xm.O_NOFOLLOW | Xm.O_NONBLOCK : Xm.O_RDONLY);
|
|
21594
|
-
try {
|
|
21595
|
-
if (!(await i.stat()).isFile()) return false;
|
|
21596
|
-
let a = Buffer.allocUnsafe(R0 + yd.length), l = 0, c = 0;
|
|
21597
|
-
while (c < ROe) {
|
|
21598
|
-
let { bytesRead: d } = await i.read(a, l, R0, c);
|
|
21599
|
-
if (d === 0) return false;
|
|
21600
|
-
let p = l + d;
|
|
21601
|
-
if (a.subarray(0, p).includes(yd)) return true;
|
|
21602
|
-
l = Math.min(yd.length, p), a.copyWithin(0, p - l, p), c += d;
|
|
21603
|
-
}
|
|
21604
|
-
return true;
|
|
21605
|
-
} finally {
|
|
21606
|
-
await i.close();
|
|
21607
|
-
}
|
|
21608
|
-
} catch {
|
|
21609
|
-
return false;
|
|
21610
|
-
}
|
|
21611
|
-
}
|
|
21612
|
-
function gl(e10, t, n, r) {
|
|
21613
|
-
let { head: o, tail: s, mtime: i, size: a } = t, l = o.indexOf(`
|
|
21614
|
-
`), c = l >= 0 ? o.slice(0, l) : o;
|
|
21615
|
-
if (c.includes('"isSidechain":true') || c.includes('"isSidechain": true')) return null;
|
|
21616
|
-
let d = Xt(s, "customTitle") || r || Xt(o, "customTitle") || Xt(s, "aiTitle") || Xt(o, "aiTitle") || void 0, p = cm(o) || void 0, f = nl(o, "timestamp"), m;
|
|
21617
|
-
if (f) {
|
|
21618
|
-
let b = Date.parse(f);
|
|
21619
|
-
if (!Number.isNaN(b)) m = b;
|
|
21620
|
-
}
|
|
21621
|
-
let g = d || Xt(s, "lastPrompt") || Xt(s, "summary") || p || qD(o);
|
|
21622
|
-
if (!g) return null;
|
|
21623
|
-
let _ = Xt(s, "gitBranch") || nl(o, "gitBranch") || void 0, y = am(s, "relocated", "relocatedCwd") || nl(o, "cwd") || n || void 0, S = s.split(`
|
|
21624
|
-
`).findLast((b) => b.includes('"type":"tag"') && b.includes('"tag":"')), E = S ? Xt(S, "tag") || void 0 : void 0;
|
|
21625
|
-
return { sessionId: e10, summary: g, lastModified: i, fileSize: a, customTitle: d, firstPrompt: p, gitBranch: _, cwd: y, tag: E, createdAt: m };
|
|
21626
|
-
}
|
|
21627
|
-
function wOe(e10) {
|
|
21628
|
-
let t = h0(e10);
|
|
21629
|
-
return t !== void 0 && Qt(t) ? t : void 0;
|
|
21630
|
-
}
|
|
21631
|
-
function IR(e10) {
|
|
21632
|
-
return { pagesLeft: kD + e10 };
|
|
21633
|
-
}
|
|
21634
|
-
async function Qm(e10, t, n, r, o, s) {
|
|
21635
|
-
let i = be() && r !== void 0 ? wOe(e10) : void 0;
|
|
21636
|
-
if (r !== void 0 && i !== void 0) {
|
|
21637
|
-
let c = /* @__PURE__ */ new Map();
|
|
21638
|
-
try {
|
|
21639
|
-
await vr((d) => r.listEntries({ namespace: "transcript", projectKey: i }, { skipScopeStats: true, ...t ? {} : { skipKeyStats: true }, ...d !== void 0 && { cursor: d } }), (d) => {
|
|
21640
|
-
for (let p of d) {
|
|
21641
|
-
if (p.kind !== "key" || p.key.namespace !== "transcript") continue;
|
|
21642
|
-
let f = Ve(p.key.sessionId);
|
|
21643
|
-
if (!f) continue;
|
|
21644
|
-
if (t && p.mtimeMs === void 0) continue;
|
|
21645
|
-
let m = t ? Math.trunc(p.mtimeMs ?? 0) : 0, g = c.get(f);
|
|
21646
|
-
if (g !== void 0) {
|
|
21647
|
-
if (m > g.mtime) g.mtime = m;
|
|
21648
|
-
continue;
|
|
21649
|
-
}
|
|
21650
|
-
c.set(f, { sessionId: f, filePath: Sd(e10, `${p.key.sessionId}.jsonl`), mtime: m, projectPath: n, ownWorktrees: s });
|
|
21651
|
-
}
|
|
21652
|
-
}, o !== void 0 ? { budget: o } : void 0);
|
|
21653
|
-
} catch {
|
|
21654
|
-
}
|
|
21655
|
-
return [...c.values()];
|
|
21656
|
-
}
|
|
21657
|
-
let a;
|
|
21658
|
-
try {
|
|
21659
|
-
a = await PR(e10);
|
|
21660
|
-
} catch {
|
|
21661
|
-
return [];
|
|
21662
|
-
}
|
|
21663
|
-
return (await Promise.all(a.map(async (c) => {
|
|
21664
|
-
if (!c.endsWith(".jsonl")) return null;
|
|
21665
|
-
let d = Ve(c.slice(0, -6));
|
|
21666
|
-
if (!d) return null;
|
|
21667
|
-
let p = Sd(e10, c);
|
|
21668
|
-
if (!t) return { sessionId: d, filePath: p, mtime: 0, projectPath: n, ownWorktrees: s };
|
|
21669
|
-
try {
|
|
21670
|
-
let f = await TOe(p);
|
|
21671
|
-
return { sessionId: d, filePath: p, mtime: f.mtime.getTime(), projectPath: n, ownWorktrees: s };
|
|
21672
|
-
} catch {
|
|
21673
|
-
return null;
|
|
21674
|
-
}
|
|
21675
|
-
}))).filter((c) => c !== null);
|
|
21676
|
-
}
|
|
21677
|
-
async function v0(e10, t, n) {
|
|
21678
|
-
let r = await ji(e10.filePath, cn(Lr(e10.filePath, n)));
|
|
21679
|
-
if (!r) return null;
|
|
21680
|
-
if (!t && WD(r.head, r.tail)) return null;
|
|
21681
|
-
let o = T0(r.tail);
|
|
21682
|
-
if (o !== void 0 && await O0(e10.filePath, o, n)) return null;
|
|
21683
|
-
let s = Xt(r.tail, "customTitle") === void 0 ? await ml(e10.filePath, e10.sessionId, n) : void 0, i = gl(e10.sessionId, r, e10.projectPath, s);
|
|
21684
|
-
if (!i) return null;
|
|
21685
|
-
let a = am(r.tail, "relocated", "relocatedCwd") ?? Sb(r.head, "cwd");
|
|
21686
|
-
if (a !== void 0 && e10.projectPath !== void 0 && !QD(a, e10.ownWorktrees, bb()) && await XD(a, e10.projectPath, bb(), xP, gd(n))) return null;
|
|
21687
|
-
if (e10.mtime) i.lastModified = e10.mtime;
|
|
21688
|
-
return i;
|
|
21689
|
-
}
|
|
21690
|
-
var xOe = 32;
|
|
21691
|
-
function vOe(e10, t) {
|
|
21692
|
-
if (t.mtime !== e10.mtime) return t.mtime - e10.mtime;
|
|
21693
|
-
return t.sessionId < e10.sessionId ? -1 : t.sessionId > e10.sessionId ? 1 : 0;
|
|
21694
|
-
}
|
|
21695
|
-
async function kOe(e10, t, n, r, o) {
|
|
21696
|
-
e10.sort(vOe);
|
|
21697
|
-
let s = [], i = t && t > 0 ? t : 1 / 0, a = 0, l = /* @__PURE__ */ new Set();
|
|
21698
|
-
for (let c = 0; c < e10.length && s.length < i; ) {
|
|
21699
|
-
let d = Math.min(c + xOe, e10.length), p = e10.slice(c, d), f = await Promise.all(p.map((m) => v0(m, r, o)));
|
|
21700
|
-
for (let m = 0; m < f.length && s.length < i; m++) {
|
|
21701
|
-
c++;
|
|
21702
|
-
let g = f[m];
|
|
21703
|
-
if (!g) continue;
|
|
21704
|
-
if (l.has(g.sessionId)) continue;
|
|
21705
|
-
if (l.add(g.sessionId), a < n) {
|
|
21706
|
-
a++;
|
|
21707
|
-
continue;
|
|
21708
|
-
}
|
|
21709
|
-
s.push(g);
|
|
21710
|
-
}
|
|
21711
|
-
}
|
|
21712
|
-
return s;
|
|
21713
|
-
}
|
|
21714
|
-
async function POe(e10, t, n) {
|
|
21715
|
-
let r = await Promise.all(e10.map((i) => v0(i, t, n))), o = /* @__PURE__ */ new Map();
|
|
21716
|
-
for (let i of r) {
|
|
21717
|
-
if (!i) continue;
|
|
21718
|
-
let a = o.get(i.sessionId);
|
|
21719
|
-
if (!a || i.lastModified > a.lastModified) o.set(i.sessionId, i);
|
|
21720
|
-
}
|
|
21721
|
-
let s = [...o.values()];
|
|
21722
|
-
return s.sort((i, a) => a.lastModified !== i.lastModified ? a.lastModified - i.lastModified : a.sessionId < i.sessionId ? -1 : a.sessionId > i.sessionId ? 1 : 0), s;
|
|
21723
|
-
}
|
|
21724
|
-
async function x0(e10, t, n, r, o) {
|
|
21725
|
-
let s = process.platform === "win32", i = o !== void 0 && o.hoverRestOn && e10.length > 1 ? { ...o, source: Eb(o.source) } : o, a = [], l = /* @__PURE__ */ new Set();
|
|
21726
|
-
for (let p of e10) for (let f of await qn(p, i, n)) {
|
|
21727
|
-
let m = s ? f.toLowerCase() : f;
|
|
21728
|
-
if (!l.has(m)) l.add(m), a.push({ projectDir: f, projectPath: p });
|
|
21729
|
-
}
|
|
21730
|
-
let c = IR(a.length), d = [];
|
|
21731
|
-
for (let { projectDir: p, projectPath: f } of a) d.push(...await Qm(p, t, f, r, c));
|
|
21732
|
-
return d;
|
|
21733
|
-
}
|
|
21734
|
-
async function IOe(e10, t, n, r, o) {
|
|
21735
|
-
let s = await Mo(e10, gd(o)), i = cn(zn(o)), a = Ab(e10, s), l;
|
|
21736
|
-
if (t) try {
|
|
21737
|
-
l = await Do(s);
|
|
21738
|
-
} catch {
|
|
21739
|
-
l = [];
|
|
21740
|
-
}
|
|
21741
|
-
else l = [];
|
|
21742
|
-
if (l.length <= 1) return x0(a, n, r, o, i);
|
|
21743
|
-
let c = process.platform === "win32", d = l.map((S) => {
|
|
21744
|
-
let E = Vr(S), b = c ? E.toLowerCase() : E;
|
|
21745
|
-
return { path: S, exactName: b, truncatedPrefix: E.length > Lo ? b.slice(0, Lo) : void 0 };
|
|
21746
|
-
});
|
|
21747
|
-
d.sort((S, E) => E.exactName.length - S.exactName.length);
|
|
21748
|
-
let p = i !== void 0 && i.hoverRestOn ? await il(i.source) : null, f = p;
|
|
21749
|
-
if (f === null) {
|
|
21750
|
-
let S;
|
|
21751
|
-
try {
|
|
21752
|
-
S = await PR(r, { withFileTypes: true });
|
|
21753
|
-
} catch {
|
|
21754
|
-
return x0(a, n, r, o, void 0);
|
|
21755
|
-
}
|
|
21756
|
-
f = S.filter((E) => E.isDirectory()).map((E) => E.name);
|
|
21757
|
-
}
|
|
21758
|
-
let m = [], g = /* @__PURE__ */ new Set(), _ = IR(f.length + a.length), y = [...a, ...l];
|
|
21759
|
-
for (let S of a) {
|
|
21760
|
-
let E = i !== void 0 && i.hoverRestOn && p !== null ? await Rb(S, p, c, i) : await qn(S, void 0, r);
|
|
21761
|
-
for (let b of E) {
|
|
21762
|
-
let C = OOe(b), A = c ? C.toLowerCase() : C;
|
|
21763
|
-
if (g.has(A)) continue;
|
|
21764
|
-
g.add(A), m.push(...await Qm(b, n, S, o, _, y));
|
|
21765
|
-
}
|
|
21766
|
-
}
|
|
21767
|
-
for (let S of f) {
|
|
21768
|
-
let E = c ? S.toLowerCase() : S;
|
|
21769
|
-
if (g.has(E)) continue;
|
|
21770
|
-
for (let { path: b, exactName: C, truncatedPrefix: A } of d) if (E === C || A !== void 0 && E.startsWith(A + "-") && await sl(Sd(r, S), b, c, i)) {
|
|
21771
|
-
g.add(E), m.push(...await Qm(Sd(r, S), n, b, o, _, y));
|
|
21772
|
-
break;
|
|
21773
|
-
}
|
|
21774
|
-
}
|
|
21775
|
-
return m;
|
|
21776
|
-
}
|
|
21777
|
-
async function DOe(e10, t, n) {
|
|
21778
|
-
let r = zn(n), o = r !== void 0 ? await il(r) : null;
|
|
21779
|
-
if (o === null) {
|
|
21780
|
-
let a;
|
|
21781
|
-
try {
|
|
21782
|
-
a = await PR(t, { withFileTypes: true });
|
|
21783
|
-
} catch {
|
|
21784
|
-
return [];
|
|
21785
|
-
}
|
|
21786
|
-
o = a.filter((l) => l.isDirectory()).map((l) => l.name);
|
|
21787
|
-
}
|
|
21788
|
-
let s = IR(o.length);
|
|
21789
|
-
return (await Promise.all(o.map((a) => Qm(Sd(t, a), e10, void 0, n, s)))).flat();
|
|
21790
|
-
}
|
|
21791
|
-
async function k0(e10, t, n = St()) {
|
|
21792
|
-
let r = be() ? t : void 0, { dir: o, limit: s, offset: i, includeWorktrees: a, includeProgrammatic: l } = e10 ?? {}, c = i ?? 0, d = l ?? true, p = s !== void 0 && s > 0 || c > 0, f = o ? await IOe(o, a ?? true, p, n, r) : await DOe(p, n, r);
|
|
21793
|
-
if (!p) return POe(f, d, r);
|
|
21794
|
-
return kOe(f, s, c, d, r);
|
|
21795
|
-
}
|
|
21796
21273
|
var N0 = 4;
|
|
21797
21274
|
var VOe = 50;
|
|
21798
21275
|
var qOe = Array.from({ length: N0 - 1 }, () => VOe);
|
|
@@ -21945,19 +21422,6 @@ function zR(e10, t, n, r) {
|
|
|
21945
21422
|
let o = Fwe(e10), s = $we(o), i = ku(n), a = typeof r === "string" && Vy(r) ? r : void 0, l = xR(s, { keepMeta: true }).filter((c) => c.type === "user" || c.type === "assistant").map((c) => vR(c, i, a));
|
|
21946
21423
|
return kR(l, t);
|
|
21947
21424
|
}
|
|
21948
|
-
function cF(e10, t) {
|
|
21949
|
-
let n = e10.data;
|
|
21950
|
-
if (n.isSidechain === true) return null;
|
|
21951
|
-
let r = Ps(n.firstPromptLocked === true ? n.firstPrompt : n.commandFallback) || void 0, o = Ps(n.customTitle) || Ps(n.aiTitle) || void 0, s = o || Ps(n.lastPrompt) || Ps(n.summaryHint) || r;
|
|
21952
|
-
if (!s) return null;
|
|
21953
|
-
return { sessionId: e10.sessionId, summary: s, lastModified: e10.mtime, fileSize: void 0, customTitle: o, firstPrompt: r, gitBranch: Ps(n.gitBranch) || void 0, cwd: Ps(n.cwd) || t || void 0, tag: Ps(n.tag) || void 0, createdAt: Gwe(n.createdAt) };
|
|
21954
|
-
}
|
|
21955
|
-
function Ps(e10) {
|
|
21956
|
-
return typeof e10 === "string" ? e10 : void 0;
|
|
21957
|
-
}
|
|
21958
|
-
function Gwe(e10) {
|
|
21959
|
-
return typeof e10 === "number" ? e10 : void 0;
|
|
21960
|
-
}
|
|
21961
21425
|
var Ne;
|
|
21962
21426
|
(function(e10) {
|
|
21963
21427
|
e10.assertEqual = (o) => {
|
|
@@ -31445,10 +30909,6 @@ async function P1t(e10, t) {
|
|
|
31445
30909
|
if (t?.sessionStore) return c3e(t.sessionStore, e10, t);
|
|
31446
30910
|
return g0(e10, t);
|
|
31447
30911
|
}
|
|
31448
|
-
async function I1t(e10) {
|
|
31449
|
-
if (e10?.sessionStore) return i3e(e10.sessionStore, e10);
|
|
31450
|
-
return k0(e10);
|
|
31451
|
-
}
|
|
31452
30912
|
async function U1t(e10, t, n) {
|
|
31453
30913
|
if (n?.sessionStore) return f3e(n.sessionStore, e10, t, n);
|
|
31454
30914
|
return oF(e10, t, n);
|
|
@@ -31458,59 +30918,6 @@ function A3(e10) {
|
|
|
31458
30918
|
`) + `
|
|
31459
30919
|
`;
|
|
31460
30920
|
}
|
|
31461
|
-
function R3(e10, t, n) {
|
|
31462
|
-
if (t !== void 0 && t > 0) return e10.slice(n, n + t);
|
|
31463
|
-
if (n > 0) return e10.slice(n);
|
|
31464
|
-
return e10;
|
|
31465
|
-
}
|
|
31466
|
-
async function i3e(e10, t) {
|
|
31467
|
-
let n = Dv(t.dir), r = Vr(n), o = t.offset ?? 0, s = t.limit;
|
|
31468
|
-
if (e10.listSessionSummaries) return a3e(e10, r, n, t.dir, s, o);
|
|
31469
|
-
if (!e10.listSessions) throw Error("sessionStore.listSessions is not implemented -- cannot list sessions. Provide a store with a listSessions() method.");
|
|
31470
|
-
let a = (await e10.listSessions(r)).slice().sort((c, d) => d.mtime - c.mtime), l = R3(a, s, o);
|
|
31471
|
-
return T3(e10, l, t.dir, n);
|
|
31472
|
-
}
|
|
31473
|
-
async function a3e(e10, t, n, r, o, s) {
|
|
31474
|
-
let i = await e10.listSessionSummaries(t), a = e10.listSessions ? new Map((await e10.listSessions(t)).map((p) => [p.sessionId, p])) : void 0, l = [];
|
|
31475
|
-
for (let p of i) {
|
|
31476
|
-
let f = a?.get(p.sessionId);
|
|
31477
|
-
if (a && !f) continue;
|
|
31478
|
-
let m = f !== void 0 && p.mtime < f.mtime;
|
|
31479
|
-
l.push({ sessionId: p.sessionId, mtime: m ? f.mtime : p.mtime, info: m ? void 0 : cF(p, n) });
|
|
31480
|
-
}
|
|
31481
|
-
if (a) {
|
|
31482
|
-
let p = new Set(i.map((f) => f.sessionId));
|
|
31483
|
-
for (let [f, m] of a) if (!p.has(f)) l.push({ sessionId: f, mtime: m.mtime });
|
|
31484
|
-
} else K("listSessionSummaries without listSessions: gap-fill skipped; sessions lacking a sidecar will be omitted");
|
|
31485
|
-
l.sort((p, f) => f.mtime - p.mtime);
|
|
31486
|
-
let c = R3(l, o, s), d = c.filter((p) => p.info === void 0);
|
|
31487
|
-
if (d.length > 0) {
|
|
31488
|
-
let p = await T3(e10, d, r, n), f = new Map(p.map((m) => [m.sessionId, m]));
|
|
31489
|
-
for (let m of c) if (m.info === void 0) m.info = f.get(m.sessionId) ?? null;
|
|
31490
|
-
}
|
|
31491
|
-
return c.flatMap((p) => p.info ? [p.info] : []);
|
|
31492
|
-
}
|
|
31493
|
-
async function T3(e10, t, n, r) {
|
|
31494
|
-
return (await Promise.allSettled(t.map(async (s) => {
|
|
31495
|
-
let i = await w3(e10, s.sessionId, n);
|
|
31496
|
-
if (!i) return null;
|
|
31497
|
-
let a = gl(s.sessionId, O3(i, s.mtime), r);
|
|
31498
|
-
return a ? { ...a, lastModified: s.mtime } : null;
|
|
31499
|
-
}))).flatMap((s, i) => {
|
|
31500
|
-
let a = t[i];
|
|
31501
|
-
if (s.status === "fulfilled") return s.value ? [s.value] : [];
|
|
31502
|
-
return [{ sessionId: a.sessionId, summary: "", lastModified: a.mtime }];
|
|
31503
|
-
});
|
|
31504
|
-
}
|
|
31505
|
-
function O3(e10, t) {
|
|
31506
|
-
let n = Buffer.from(e10, "utf-8"), r = n.length, o = n.subarray(0, En).toString("utf-8"), s = r > En ? n.subarray(r - En).toString("utf-8") : o;
|
|
31507
|
-
return { mtime: t, size: r, head: o, tail: s };
|
|
31508
|
-
}
|
|
31509
|
-
async function w3(e10, t, n) {
|
|
31510
|
-
let r = Pn(n), o = await e10.load({ projectKey: r, sessionId: t });
|
|
31511
|
-
if (!o || o.length === 0) return null;
|
|
31512
|
-
return A3(o);
|
|
31513
|
-
}
|
|
31514
30921
|
async function c3e(e10, t, n) {
|
|
31515
30922
|
if (!Ve(t)) return [];
|
|
31516
30923
|
let r = Pn(n.dir), o = await e10.load({ projectKey: r, sessionId: t });
|
|
@@ -31534,9 +30941,9 @@ async function f3e(e10, t, n, r) {
|
|
|
31534
30941
|
}
|
|
31535
30942
|
|
|
31536
30943
|
// server/adapters/claude.ts
|
|
31537
|
-
import {
|
|
31538
|
-
import {
|
|
31539
|
-
import { join as
|
|
30944
|
+
import { AsyncLocalStorage as AsyncLocalStorage2 } from "node:async_hooks";
|
|
30945
|
+
import { lstat as lstat6, readdir as readdir3, stat } from "node:fs/promises";
|
|
30946
|
+
import { basename as basename5, dirname as dirname4, join as join11, resolve as resolve3 } from "node:path";
|
|
31540
30947
|
|
|
31541
30948
|
// server/adapters/claude-transcripts.ts
|
|
31542
30949
|
import { constants as constants4 } from "node:fs";
|
|
@@ -31606,10 +31013,10 @@ async function claudeTranscript(path, revision2) {
|
|
|
31606
31013
|
}
|
|
31607
31014
|
if (entries2.length > 2e5) throw new Error("Claude transcript exceeds the 200,000-record import limit.");
|
|
31608
31015
|
}
|
|
31609
|
-
const
|
|
31610
|
-
if (
|
|
31016
|
+
const metadata3 = sidecar(path);
|
|
31017
|
+
if (metadata3 && await metadataState(path)) {
|
|
31611
31018
|
try {
|
|
31612
|
-
entries2.push({ ...JSON.parse(await bytes(
|
|
31019
|
+
entries2.push({ ...JSON.parse(await bytes(metadata3, 64e3)), type: "agent_metadata" });
|
|
31613
31020
|
} catch {
|
|
31614
31021
|
partial = true;
|
|
31615
31022
|
}
|
|
@@ -31926,8 +31333,141 @@ function dshHistory(value) {
|
|
|
31926
31333
|
return { nativeID: header.id, messages, partial: true, session: { directory: text(header.cwd), created: time(header.createdAt ?? header.time) }, note: partial ? "Some transcript records could not be imported." : void 0 };
|
|
31927
31334
|
}
|
|
31928
31335
|
|
|
31336
|
+
// server/adapters/claude-locations.ts
|
|
31337
|
+
import { lstat as lstat5, opendir } from "node:fs/promises";
|
|
31338
|
+
import { homedir as homedir5 } from "node:os";
|
|
31339
|
+
import { basename as basename4, dirname as dirname3, join as join10, resolve as resolve2 } from "node:path";
|
|
31340
|
+
async function computerRoots(platform = process.platform) {
|
|
31341
|
+
if (platform !== "win32") return ["/"];
|
|
31342
|
+
const drives = Array.from({ length: 26 }, (_, i) => `${String.fromCharCode(65 + i)}:\\`);
|
|
31343
|
+
return (await Promise.all(drives.map(async (drive) => (await lstat5(drive).catch(() => void 0))?.isDirectory() ? drive : void 0))).filter((p) => Boolean(p));
|
|
31344
|
+
}
|
|
31345
|
+
function excludedScanPaths(platform = process.platform) {
|
|
31346
|
+
if (platform === "linux") return ["/dev", "/proc", "/sys", "/run"];
|
|
31347
|
+
if (platform === "darwin") return ["/dev", "/System/Volumes"];
|
|
31348
|
+
return [];
|
|
31349
|
+
}
|
|
31350
|
+
function createClaudeLocationScanner(options) {
|
|
31351
|
+
const now = options.now || Date.now, openDirectory = options.openDirectory || opendir;
|
|
31352
|
+
const excluded = new Set((options.excluded || []).map((p) => resolve2(p)));
|
|
31353
|
+
const homes2 = /* @__PURE__ */ new Set();
|
|
31354
|
+
let queue = [], index = 0;
|
|
31355
|
+
let visited = /* @__PURE__ */ new Set(), skipped = /* @__PURE__ */ new Set(), limited = false, initialized = false, finishedAt;
|
|
31356
|
+
let last, lastAt = -Infinity, job;
|
|
31357
|
+
async function scan() {
|
|
31358
|
+
const started = now();
|
|
31359
|
+
if (!initialized || finishedAt !== void 0 && started - finishedAt >= (options.refreshMs ?? 3e5)) {
|
|
31360
|
+
queue = [.../* @__PURE__ */ new Set([dirname3(options.preferredHome()), ...await options.roots()])].map((path) => ({ path: resolve2(path), depth: 0, offset: 0 }));
|
|
31361
|
+
index = 0;
|
|
31362
|
+
visited = /* @__PURE__ */ new Set();
|
|
31363
|
+
skipped = /* @__PURE__ */ new Set();
|
|
31364
|
+
limited = false;
|
|
31365
|
+
initialized = true;
|
|
31366
|
+
finishedAt = void 0;
|
|
31367
|
+
}
|
|
31368
|
+
homes2.add(resolve2(options.preferredHome()));
|
|
31369
|
+
let entries2 = 0;
|
|
31370
|
+
const budget2 = options.maxEntries ?? 1e5, deadline = started + (options.sliceMs ?? 2e3);
|
|
31371
|
+
while (index < queue.length && entries2 < budget2 && now() < deadline) {
|
|
31372
|
+
const item = queue[index], path = item.path;
|
|
31373
|
+
if (excluded.has(path)) {
|
|
31374
|
+
index++;
|
|
31375
|
+
continue;
|
|
31376
|
+
}
|
|
31377
|
+
let complete = true;
|
|
31378
|
+
try {
|
|
31379
|
+
const info = await lstat5(path);
|
|
31380
|
+
if (!info.isDirectory()) {
|
|
31381
|
+
index++;
|
|
31382
|
+
continue;
|
|
31383
|
+
}
|
|
31384
|
+
const key = `${info.dev}:${info.ino}`;
|
|
31385
|
+
if (!item.offset && visited.has(key)) {
|
|
31386
|
+
index++;
|
|
31387
|
+
continue;
|
|
31388
|
+
}
|
|
31389
|
+
let offset = 0;
|
|
31390
|
+
for await (const entry of await openDirectory(path)) {
|
|
31391
|
+
if (offset++ < item.offset) continue;
|
|
31392
|
+
if (entry.isDirectory()) {
|
|
31393
|
+
const child = join10(path, entry.name);
|
|
31394
|
+
if (entry.name === ".claude") addHome(child);
|
|
31395
|
+
if (item.depth < 128 && queue.length < 1e5) queue.push({ path: child, depth: item.depth + 1, offset: 0 });
|
|
31396
|
+
else limited = true;
|
|
31397
|
+
} else if (entry.isFile() && entry.name.endsWith(".jsonl") && claudeSessionID(entry.name.slice(0, -6)) && basename4(dirname3(path)) === "projects") {
|
|
31398
|
+
addHome(dirname3(dirname3(path)));
|
|
31399
|
+
}
|
|
31400
|
+
entries2++;
|
|
31401
|
+
item.offset = offset;
|
|
31402
|
+
if (entries2 >= budget2 || now() >= deadline) {
|
|
31403
|
+
complete = false;
|
|
31404
|
+
break;
|
|
31405
|
+
}
|
|
31406
|
+
}
|
|
31407
|
+
if (complete) visited.add(key);
|
|
31408
|
+
} catch (error) {
|
|
31409
|
+
if (!["ENOENT", "ENOTDIR"].includes(error.code || "")) skipped.add(path);
|
|
31410
|
+
}
|
|
31411
|
+
if (!complete) break;
|
|
31412
|
+
index++;
|
|
31413
|
+
}
|
|
31414
|
+
const pending = index < queue.length;
|
|
31415
|
+
if (!pending && finishedAt === void 0) finishedAt = now();
|
|
31416
|
+
const found = [];
|
|
31417
|
+
for (const home of homes2) {
|
|
31418
|
+
try {
|
|
31419
|
+
if (!(await lstat5(home)).isDirectory()) continue;
|
|
31420
|
+
} catch (error) {
|
|
31421
|
+
if (error.code !== "ENOENT") skipped.add(home);
|
|
31422
|
+
continue;
|
|
31423
|
+
}
|
|
31424
|
+
for (const name of ["projects", "transcripts"]) {
|
|
31425
|
+
try {
|
|
31426
|
+
if ((await lstat5(join10(home, name))).isDirectory()) {
|
|
31427
|
+
found.push(home);
|
|
31428
|
+
break;
|
|
31429
|
+
}
|
|
31430
|
+
} catch (error) {
|
|
31431
|
+
if (!["ENOENT", "ENOTDIR"].includes(error.code || "")) skipped.add(join10(home, name));
|
|
31432
|
+
}
|
|
31433
|
+
}
|
|
31434
|
+
}
|
|
31435
|
+
const warnings = [];
|
|
31436
|
+
if (pending) warnings.push("Claude Code: Computer-wide history search is still in progress. Refresh sessions to continue; known locations are imported now.");
|
|
31437
|
+
if (skipped.size) warnings.push(`Claude Code: Computer-wide search skipped ${skipped.size} unreadable or protected locations. OS permissions were not changed; use an accessible copy or a custom history path for missing sessions.`);
|
|
31438
|
+
if (limited) warnings.push("Claude Code: Computer-wide search reached its 100,000-directory, 1,000-location, or 128-level depth limit. Use a custom history path for locations outside this scan.");
|
|
31439
|
+
return { homes: found, warnings, pending };
|
|
31440
|
+
}
|
|
31441
|
+
function addHome(home) {
|
|
31442
|
+
if (homes2.size < 1e3) homes2.add(home);
|
|
31443
|
+
else limited = true;
|
|
31444
|
+
}
|
|
31445
|
+
return () => {
|
|
31446
|
+
if (job) return job;
|
|
31447
|
+
if (last && now() - lastAt < 1e3) return Promise.resolve(last);
|
|
31448
|
+
job = scan().then((result) => {
|
|
31449
|
+
last = result;
|
|
31450
|
+
lastAt = now();
|
|
31451
|
+
return result;
|
|
31452
|
+
}).finally(() => {
|
|
31453
|
+
job = void 0;
|
|
31454
|
+
});
|
|
31455
|
+
return job;
|
|
31456
|
+
};
|
|
31457
|
+
}
|
|
31458
|
+
var activeClaudeHome = () => resolve2(process.env.CLAUDE_CONFIG_DIR || join10(homedir5(), ".claude"));
|
|
31459
|
+
var scanComputer = createClaudeLocationScanner({
|
|
31460
|
+
roots: computerRoots,
|
|
31461
|
+
preferredHome: activeClaudeHome,
|
|
31462
|
+
excluded: excludedScanPaths()
|
|
31463
|
+
});
|
|
31464
|
+
async function claudeLocations() {
|
|
31465
|
+
const configured = sourcePath("claude-code") || process.env.CLAUDE_CONFIG_DIR;
|
|
31466
|
+
if (configured) return { homes: [resolve2(configured)], warnings: [], pending: false };
|
|
31467
|
+
return scanComputer();
|
|
31468
|
+
}
|
|
31469
|
+
|
|
31929
31470
|
// server/adapters/claude.ts
|
|
31930
|
-
var root = () => join10(sourcePath("claude-code") || process.env.CLAUDE_CONFIG_DIR || join10(homedir5(), ".claude"), "projects");
|
|
31931
31471
|
function claudeMessages(rows2, candidate, times, entries2) {
|
|
31932
31472
|
const calls = /* @__PURE__ */ new Map();
|
|
31933
31473
|
return rows2.map((row) => {
|
|
@@ -31971,64 +31511,61 @@ function claudeMessages(rows2, candidate, times, entries2) {
|
|
|
31971
31511
|
return msg;
|
|
31972
31512
|
});
|
|
31973
31513
|
}
|
|
31514
|
+
var context = new AsyncLocalStorage2();
|
|
31515
|
+
var homes = () => context.getStore()?.homes || [];
|
|
31516
|
+
var activeHome = () => context.getStore()?.activeHome || activeClaudeHome();
|
|
31517
|
+
var metadata = /* @__PURE__ */ new Map();
|
|
31974
31518
|
var sdkClaudeAdapter = {
|
|
31975
31519
|
id: "claude-code",
|
|
31976
31520
|
name: "Claude Code",
|
|
31977
|
-
description: "
|
|
31521
|
+
description: "Computer-wide local CLI and VS Code history \xB7 all projects and subagent transcripts",
|
|
31978
31522
|
capabilities: { history: true, forks: false, children: true, files: true },
|
|
31979
31523
|
async detect() {
|
|
31980
|
-
|
|
31981
|
-
|
|
31982
|
-
} catch {
|
|
31983
|
-
return false;
|
|
31984
|
-
}
|
|
31524
|
+
for (const home of homes()) if ((await lstat6(join11(home, "projects")).catch(() => void 0))?.isDirectory()) return true;
|
|
31525
|
+
return false;
|
|
31985
31526
|
},
|
|
31986
31527
|
async discover() {
|
|
31987
31528
|
const sessions = [], warnings = [];
|
|
31988
|
-
const
|
|
31989
|
-
|
|
31529
|
+
const listing = await historyFiles(homes().map((home) => join11(home, "projects")), (p) => {
|
|
31530
|
+
const parts = p.split("/");
|
|
31531
|
+
return parts.length === 2 && parts[1].endsWith(".jsonl") && claudeSessionID(parts[1].slice(0, -6));
|
|
31532
|
+
});
|
|
31533
|
+
warnings.push(...listing.warnings);
|
|
31990
31534
|
const files = /* @__PURE__ */ new Map();
|
|
31991
31535
|
let unreadable = 0;
|
|
31992
|
-
for (const
|
|
31993
|
-
|
|
31994
|
-
const
|
|
31995
|
-
let entries2;
|
|
31536
|
+
for (const path of listing.files) {
|
|
31537
|
+
const name = basename5(path);
|
|
31538
|
+
const id2 = name.slice(0, -6), home = dirname4(dirname4(dirname4(path)));
|
|
31996
31539
|
try {
|
|
31997
|
-
|
|
31540
|
+
const modified = (await stat(path)).mtimeMs, old = files.get(id2);
|
|
31541
|
+
if (!old || modified > old.modified || modified === old.modified && home === resolve3(activeHome()) && old.home !== home) files.set(id2, { path, home, modified, children: join11(dirname4(path), id2, "subagents") });
|
|
31998
31542
|
} catch {
|
|
31999
31543
|
unreadable++;
|
|
32000
|
-
continue;
|
|
32001
|
-
}
|
|
32002
|
-
for (const file of entries2) if (file.isFile() && file.name.endsWith(".jsonl") && claudeSessionID(file.name.slice(0, -6))) {
|
|
32003
|
-
const id2 = file.name.slice(0, -6), path = join10(parent2, file.name);
|
|
32004
|
-
try {
|
|
32005
|
-
const old = files.get(id2);
|
|
32006
|
-
if (!old || (await stat(path)).mtimeMs > (await stat(old.path)).mtimeMs) files.set(id2, { path, children: join10(parent2, id2, "subagents") });
|
|
32007
|
-
} catch {
|
|
32008
|
-
unreadable++;
|
|
32009
|
-
}
|
|
32010
31544
|
}
|
|
32011
31545
|
}
|
|
32012
|
-
const listed = new Set(infos.map((info) => info.sessionId));
|
|
32013
31546
|
for (const [id2, file] of files) {
|
|
32014
|
-
|
|
32015
|
-
if (infos.length >= 2e4) {
|
|
32016
|
-
warnings.push("Claude Code discovery is limited to 20,000 sessions.");
|
|
32017
|
-
break;
|
|
32018
|
-
}
|
|
31547
|
+
let info;
|
|
32019
31548
|
try {
|
|
32020
|
-
const
|
|
32021
|
-
|
|
32022
|
-
if (
|
|
32023
|
-
|
|
31549
|
+
const rev = await claudeRevision(file.path);
|
|
31550
|
+
let cached2 = metadata.get(file.path);
|
|
31551
|
+
if (!cached2 || cached2.revision !== rev) {
|
|
31552
|
+
const transcript = await claudeTranscript(file.path, rev);
|
|
31553
|
+
cached2 = { revision: rev, info: claudeTranscriptInfo(transcript, id2), partial: transcript.partial };
|
|
31554
|
+
if (metadata.size >= 2e4) metadata.delete(metadata.keys().next().value);
|
|
31555
|
+
metadata.set(file.path, cached2);
|
|
31556
|
+
}
|
|
31557
|
+
info = cached2.info;
|
|
31558
|
+
if (!info && cached2.partial) unreadable++;
|
|
32024
31559
|
} catch {
|
|
32025
31560
|
unreadable++;
|
|
31561
|
+
continue;
|
|
31562
|
+
}
|
|
31563
|
+
if (!info) continue;
|
|
31564
|
+
const s = { ...blankSession("claude-code", info.sessionId, info.cwd), title: info.customTitle || info.summary || info.firstPrompt || "Untitled session", created: info.createdAt || info.lastModified, updated: info.lastModified, provider: "anthropic", agent: "Claude Code", nativeResume: !sourcePath("claude-code") && file.home === resolve3(activeHome()) };
|
|
31565
|
+
if (sessions.length >= 2e4) {
|
|
31566
|
+
warnings.push("Claude Code discovery is limited to 20,000 sessions.");
|
|
31567
|
+
break;
|
|
32026
31568
|
}
|
|
32027
|
-
}
|
|
32028
|
-
for (const info of infos) {
|
|
32029
|
-
const file = files.get(info.sessionId);
|
|
32030
|
-
if (!file) continue;
|
|
32031
|
-
const s = { ...blankSession("claude-code", info.sessionId, info.cwd), title: info.customTitle || info.summary || info.firstPrompt || "Untitled session", created: info.createdAt || info.lastModified, updated: info.lastModified, provider: "anthropic", agent: "Claude Code" };
|
|
32032
31569
|
try {
|
|
32033
31570
|
sessions.push({ session: s, revision: await claudeRevision(file.path), locator: { path: file.path, dir: info.cwd || "" } });
|
|
32034
31571
|
} catch {
|
|
@@ -32037,15 +31574,20 @@ var sdkClaudeAdapter = {
|
|
|
32037
31574
|
}
|
|
32038
31575
|
let children;
|
|
32039
31576
|
try {
|
|
31577
|
+
if (!(await lstat6(file.children)).isDirectory()) continue;
|
|
32040
31578
|
children = await readdir3(file.children, { withFileTypes: true });
|
|
32041
31579
|
} catch (error) {
|
|
32042
31580
|
if (error.code !== "ENOENT") unreadable++;
|
|
32043
31581
|
continue;
|
|
32044
31582
|
}
|
|
32045
31583
|
for (const child of children) {
|
|
31584
|
+
if (sessions.length >= 2e4) {
|
|
31585
|
+
warnings.push("Claude Code discovery is limited to 20,000 sessions.");
|
|
31586
|
+
break;
|
|
31587
|
+
}
|
|
32046
31588
|
if (!child.isFile() || !/^agent-[\w-]+\.jsonl$/.test(child.name)) continue;
|
|
32047
31589
|
try {
|
|
32048
|
-
const agent = child.name.slice(6, -6), path =
|
|
31590
|
+
const agent = child.name.slice(6, -6), path = join11(file.children, child.name), stats = await stat(path);
|
|
32049
31591
|
sessions.push({ session: { ...s, id: identity("claude-code", `${info.sessionId}/agent/${agent}`), nativeID: `${info.sessionId}/agent/${agent}`, title: `Subagent ${agent}`, created: stats.birthtimeMs || s.created, updated: stats.mtimeMs, parentID: s.id, origin: "automated", agent }, revision: await claudeRevision(path), locator: { path, dir: info.cwd || "", parent: info.sessionId, agent } });
|
|
32050
31592
|
} catch {
|
|
32051
31593
|
unreadable++;
|
|
@@ -32093,20 +31635,38 @@ var exportedClaudeAdapter = localFileAdapter({
|
|
|
32093
31635
|
name: "Claude Code",
|
|
32094
31636
|
description: "Legacy local transcript exports",
|
|
32095
31637
|
capabilities: { history: true, forks: false, children: false, files: false },
|
|
32096
|
-
roots: () =>
|
|
31638
|
+
roots: () => homes().map((home) => join11(home, "transcripts")),
|
|
32097
31639
|
match: (p) => p.endsWith(".jsonl"),
|
|
32098
31640
|
parse: (path, files) => envelopeHistory(path, files.get(path))
|
|
32099
31641
|
});
|
|
32100
|
-
|
|
31642
|
+
function createClaudeAdapter(locations = claudeLocations, currentHome = activeClaudeHome) {
|
|
31643
|
+
const combined = combineAdapters([sdkClaudeAdapter, exportedClaudeAdapter]);
|
|
31644
|
+
return {
|
|
31645
|
+
...combined,
|
|
31646
|
+
async detect() {
|
|
31647
|
+
const found = await locations();
|
|
31648
|
+
return context.run({ ...found, activeHome: resolve3(currentHome()) }, () => found.pending ? Promise.resolve(true) : combined.detect());
|
|
31649
|
+
},
|
|
31650
|
+
async discover() {
|
|
31651
|
+
const found = await locations();
|
|
31652
|
+
return context.run({ ...found, activeHome: resolve3(currentHome()) }, async () => {
|
|
31653
|
+
const result = await combined.discover();
|
|
31654
|
+
for (const candidate of result.sessions) if (candidate.locator.representation === "1") candidate.session.nativeResume = false;
|
|
31655
|
+
return { ...result, warnings: [.../* @__PURE__ */ new Set([...found.warnings, ...result.warnings])] };
|
|
31656
|
+
});
|
|
31657
|
+
}
|
|
31658
|
+
};
|
|
31659
|
+
}
|
|
31660
|
+
var claudeAdapter = createClaudeAdapter();
|
|
32101
31661
|
|
|
32102
31662
|
// server/adapters/codex.ts
|
|
32103
31663
|
import { stat as stat2 } from "node:fs/promises";
|
|
32104
31664
|
import { homedir as homedir6 } from "node:os";
|
|
32105
|
-
import { join as
|
|
31665
|
+
import { join as join13, sep as sep2 } from "node:path";
|
|
32106
31666
|
|
|
32107
31667
|
// server/adapters/jsonl.ts
|
|
32108
31668
|
import { open as open3, readdir as readdir4 } from "node:fs/promises";
|
|
32109
|
-
import { join as
|
|
31669
|
+
import { join as join12 } from "node:path";
|
|
32110
31670
|
import { constants as constants5 } from "node:fs";
|
|
32111
31671
|
var compressed;
|
|
32112
31672
|
async function readJSONL(path, offset = 0, budget2 = 2e6, limit = 200) {
|
|
@@ -32178,8 +31738,8 @@ async function readJSONL(path, offset = 0, budget2 = 2e6, limit = 200) {
|
|
|
32178
31738
|
await file.close();
|
|
32179
31739
|
}
|
|
32180
31740
|
}
|
|
32181
|
-
async function transcriptFiles(
|
|
32182
|
-
const files = [], queue = [
|
|
31741
|
+
async function transcriptFiles(root2, max = 2e4, match2 = (name) => name.endsWith(".jsonl")) {
|
|
31742
|
+
const files = [], queue = [root2];
|
|
32183
31743
|
for (let i = 0; i < queue.length && files.length < max; i++) {
|
|
32184
31744
|
let entries2;
|
|
32185
31745
|
try {
|
|
@@ -32189,8 +31749,8 @@ async function transcriptFiles(root3, max = 2e4, match2 = (name) => name.endsWit
|
|
|
32189
31749
|
throw error;
|
|
32190
31750
|
}
|
|
32191
31751
|
for (const entry of entries2) {
|
|
32192
|
-
if (entry.isDirectory() && queue.length < 2e4) queue.push(
|
|
32193
|
-
if (entry.isFile() && match2(entry.name)) files.push(
|
|
31752
|
+
if (entry.isDirectory() && queue.length < 2e4) queue.push(join12(queue[i], entry.name));
|
|
31753
|
+
if (entry.isFile() && match2(entry.name)) files.push(join12(queue[i], entry.name));
|
|
32194
31754
|
if (files.length >= max) break;
|
|
32195
31755
|
}
|
|
32196
31756
|
}
|
|
@@ -32198,7 +31758,7 @@ async function transcriptFiles(root3, max = 2e4, match2 = (name) => name.endsWit
|
|
|
32198
31758
|
}
|
|
32199
31759
|
|
|
32200
31760
|
// server/adapters/codex.ts
|
|
32201
|
-
var
|
|
31761
|
+
var root = () => sourcePath("codex") || process.env.CODEX_HOME || join13(homedir6(), ".codex");
|
|
32202
31762
|
var revision = async (path) => {
|
|
32203
31763
|
const s = await stat2(path);
|
|
32204
31764
|
return digest([10, s.mtimeMs, s.size]);
|
|
@@ -32212,11 +31772,11 @@ function codexUserText(value) {
|
|
|
32212
31772
|
if (typeof value !== "string") return "";
|
|
32213
31773
|
let text2 = value.trim();
|
|
32214
31774
|
for (; ; ) {
|
|
32215
|
-
const
|
|
32216
|
-
if (!
|
|
32217
|
-
const end = text2.toLowerCase().indexOf(`</${
|
|
31775
|
+
const context2 = text2.match(/^<(environment_context|permissions|user_instructions|turn_aborted|system_instruction|recommended_plugins|external_codex_[\w-]+)(?:\s[^>]*)?>/i);
|
|
31776
|
+
if (!context2) break;
|
|
31777
|
+
const end = text2.toLowerCase().indexOf(`</${context2[1].toLowerCase()}>`, context2[0].length);
|
|
32218
31778
|
if (end < 0) return "";
|
|
32219
|
-
text2 = text2.slice(end +
|
|
31779
|
+
text2 = text2.slice(end + context2[1].length + 3).trim();
|
|
32220
31780
|
}
|
|
32221
31781
|
if (/^# (?:AGENTS\.md|Instructions for)/i.test(text2)) return "";
|
|
32222
31782
|
return text2;
|
|
@@ -32226,7 +31786,7 @@ async function sessionNames() {
|
|
|
32226
31786
|
let cursor, count = 0;
|
|
32227
31787
|
try {
|
|
32228
31788
|
do {
|
|
32229
|
-
const page = await readJSONL(
|
|
31789
|
+
const page = await readJSONL(join13(root(), "session_index.jsonl"), cursor, 2e6, 1e3);
|
|
32230
31790
|
for (const { value } of page.rows) if (typeof value.id === "string" && typeof value.thread_name === "string" && value.thread_name.trim()) names.set(value.id, value.thread_name.trim().slice(0, 300));
|
|
32231
31791
|
cursor = page.cursor;
|
|
32232
31792
|
count += page.rows.length;
|
|
@@ -32308,7 +31868,7 @@ var codexAdapter = {
|
|
|
32308
31868
|
capabilities: { history: true, forks: true, children: true, files: true },
|
|
32309
31869
|
async detect() {
|
|
32310
31870
|
try {
|
|
32311
|
-
return (await stat2(
|
|
31871
|
+
return (await stat2(root())).isDirectory();
|
|
32312
31872
|
} catch {
|
|
32313
31873
|
return false;
|
|
32314
31874
|
}
|
|
@@ -32317,7 +31877,7 @@ var codexAdapter = {
|
|
|
32317
31877
|
const found = /* @__PURE__ */ new Map(), warnings = [];
|
|
32318
31878
|
const names = await sessionNames();
|
|
32319
31879
|
const match2 = (name) => /\.jsonl(?:\.[\w.-]+)?$/.test(name);
|
|
32320
|
-
const paths2 = [...await transcriptFiles(
|
|
31880
|
+
const paths2 = [...await transcriptFiles(join13(root(), "sessions"), 2e4, match2), ...await transcriptFiles(join13(root(), "archived_sessions"), 2e4, match2)];
|
|
32321
31881
|
if (paths2.length >= 2e4) warnings.push("Codex transcript listing may be partial (20,000 files per history folder).");
|
|
32322
31882
|
let unsupported = 0;
|
|
32323
31883
|
for (const path of paths2) {
|
|
@@ -32370,9 +31930,9 @@ var codexAdapter = {
|
|
|
32370
31930
|
};
|
|
32371
31931
|
|
|
32372
31932
|
// server/adapters/t3-code.ts
|
|
32373
|
-
import { lstat as
|
|
31933
|
+
import { lstat as lstat7 } from "node:fs/promises";
|
|
32374
31934
|
import { homedir as homedir7 } from "node:os";
|
|
32375
|
-
import { isAbsolute as isAbsolute2, join as
|
|
31935
|
+
import { isAbsolute as isAbsolute2, join as join14 } from "node:path";
|
|
32376
31936
|
var SOURCE = "t3-code";
|
|
32377
31937
|
var PAGE2 = 100;
|
|
32378
31938
|
var MAX_ITEM_JSON = 256e3;
|
|
@@ -32396,16 +31956,16 @@ function status(value) {
|
|
|
32396
31956
|
return ["pending", "running", "completed", "failed"].includes(string3(value)) ? value : "unknown";
|
|
32397
31957
|
}
|
|
32398
31958
|
async function databasePath2() {
|
|
32399
|
-
const
|
|
32400
|
-
const paths2 = /\.sqlite$/.test(
|
|
32401
|
-
|
|
32402
|
-
|
|
32403
|
-
|
|
32404
|
-
|
|
31959
|
+
const root2 = sourcePath("t3-code") || process.env.SESSIONGRAPH_T3_CODE_HISTORY_DIR || process.env.T3CODE_HOME || join14(homedir7(), ".t3");
|
|
31960
|
+
const paths2 = /\.sqlite$/.test(root2) ? [root2] : [
|
|
31961
|
+
join14(root2, "userdata", "statev2.sqlite"),
|
|
31962
|
+
join14(root2, "statev2.sqlite"),
|
|
31963
|
+
join14(root2, "userdata", "state.sqlite"),
|
|
31964
|
+
join14(root2, "state.sqlite")
|
|
32405
31965
|
];
|
|
32406
31966
|
for (const path of paths2) {
|
|
32407
31967
|
try {
|
|
32408
|
-
if ((await
|
|
31968
|
+
if ((await lstat7(path)).isFile()) return path;
|
|
32409
31969
|
} catch (error) {
|
|
32410
31970
|
if (error.code !== "ENOENT") throw error;
|
|
32411
31971
|
}
|
|
@@ -32597,7 +32157,7 @@ function v2Message(row, directory3) {
|
|
|
32597
32157
|
message2.events = [eventFor(message2, id2, kind2, file, "", { ...fields3, callID: string3(native.nativeId) || void 0 })];
|
|
32598
32158
|
return message2;
|
|
32599
32159
|
}
|
|
32600
|
-
if (file && completed) message2.files.push({ path: isAbsolute2(file) ? file :
|
|
32160
|
+
if (file && completed) message2.files.push({ path: isAbsolute2(file) ? file : join14(directory3, file), source: "file change", steps: 1 });
|
|
32601
32161
|
message2.events = [eventFor(message2, id2, "file_change", file || name, "", fields3)];
|
|
32602
32162
|
return message2;
|
|
32603
32163
|
}
|
|
@@ -32684,9 +32244,9 @@ var t3CodeAdapter = {
|
|
|
32684
32244
|
|
|
32685
32245
|
// server/adapters/cursor.ts
|
|
32686
32246
|
import { createHash as createHash2 } from "node:crypto";
|
|
32687
|
-
import { lstat as
|
|
32247
|
+
import { lstat as lstat8, opendir as opendir2, readFile as readFile3 } from "node:fs/promises";
|
|
32688
32248
|
import { homedir as homedir8 } from "node:os";
|
|
32689
|
-
import { isAbsolute as isAbsolute4, join as
|
|
32249
|
+
import { isAbsolute as isAbsolute4, join as join16 } from "node:path";
|
|
32690
32250
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
32691
32251
|
|
|
32692
32252
|
// server/adapters/cursor-message.ts
|
|
@@ -32704,11 +32264,11 @@ function cursorEnvelope(text2) {
|
|
|
32704
32264
|
value = value.slice(clock[0].length);
|
|
32705
32265
|
continue;
|
|
32706
32266
|
}
|
|
32707
|
-
const
|
|
32708
|
-
if (!
|
|
32709
|
-
const end = value.indexOf(`</${
|
|
32267
|
+
const context2 = value.match(/^<(user_info|environment_context|system_reminder|external_links|attached_files|image_files)(?:\s[^>]*)?>/);
|
|
32268
|
+
if (!context2) break;
|
|
32269
|
+
const end = value.indexOf(`</${context2[1]}>`, context2[0].length);
|
|
32710
32270
|
if (end < 0) return { text: "", timestamp };
|
|
32711
|
-
value = value.slice(end +
|
|
32271
|
+
value = value.slice(end + context2[1].length + 3).trim();
|
|
32712
32272
|
}
|
|
32713
32273
|
return { text: value, timestamp };
|
|
32714
32274
|
}
|
|
@@ -32788,7 +32348,7 @@ function cursorMessage(raw, fallbackID) {
|
|
|
32788
32348
|
import { DatabaseSync as DatabaseSync2 } from "node:sqlite";
|
|
32789
32349
|
import { chmodSync as chmodSync2, copyFileSync as copyFileSync2, lstatSync as lstatSync3, mkdtempSync as mkdtempSync2, rmSync as rmSync3 } from "node:fs";
|
|
32790
32350
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
32791
|
-
import { join as
|
|
32351
|
+
import { join as join15 } from "node:path";
|
|
32792
32352
|
var MAX_VALUE = 2e6;
|
|
32793
32353
|
var MAX_BYTES3 = 64e6;
|
|
32794
32354
|
var MAX_NODES = 5e4;
|
|
@@ -32805,11 +32365,11 @@ function withStore(path, read3) {
|
|
|
32805
32365
|
throw error;
|
|
32806
32366
|
}
|
|
32807
32367
|
});
|
|
32808
|
-
const before = stats(), directory3 = mkdtempSync2(
|
|
32368
|
+
const before = stats(), directory3 = mkdtempSync2(join15(tmpdir2(), "sessiongraph-cursor-"));
|
|
32809
32369
|
let db2;
|
|
32810
32370
|
try {
|
|
32811
32371
|
chmodSync2(directory3, 448);
|
|
32812
|
-
const copy =
|
|
32372
|
+
const copy = join15(directory3, "store.db");
|
|
32813
32373
|
files.forEach((file, index) => {
|
|
32814
32374
|
if (before[index]) {
|
|
32815
32375
|
const target = index ? `${copy}-wal` : copy;
|
|
@@ -32829,14 +32389,14 @@ function withStore(path, read3) {
|
|
|
32829
32389
|
}
|
|
32830
32390
|
}
|
|
32831
32391
|
}
|
|
32832
|
-
function
|
|
32392
|
+
function metadata2(db2) {
|
|
32833
32393
|
const row = db2.prepare("SELECT value FROM meta WHERE key=? AND length(value)<=?").get("0", MAX_VALUE);
|
|
32834
32394
|
if (typeof row?.value !== "string" || !/^(?:[a-f\d]{2})+$/i.test(row.value)) throw new Error("Unsupported Cursor store metadata.");
|
|
32835
32395
|
const value = JSON.parse(Buffer.from(row.value, "hex").toString("utf8"));
|
|
32836
32396
|
if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error("Unsupported Cursor store metadata.");
|
|
32837
32397
|
return value;
|
|
32838
32398
|
}
|
|
32839
|
-
var cursorStoreMetadata = (path) => withStore(path,
|
|
32399
|
+
var cursorStoreMetadata = (path) => withStore(path, metadata2);
|
|
32840
32400
|
function fields2(data) {
|
|
32841
32401
|
let at2 = 0;
|
|
32842
32402
|
const values = [];
|
|
@@ -32872,13 +32432,13 @@ function fields2(data) {
|
|
|
32872
32432
|
}
|
|
32873
32433
|
function readCursorStore(path) {
|
|
32874
32434
|
return withStore(path, (db2) => {
|
|
32875
|
-
const meta =
|
|
32876
|
-
if (!
|
|
32877
|
-
if (typeof
|
|
32435
|
+
const meta = metadata2(db2), root2 = meta.latestRootBlobId;
|
|
32436
|
+
if (!root2) throw new Error("Cursor store has no committed conversation root.");
|
|
32437
|
+
if (typeof root2 !== "string" || !/^[a-f\d]{64}$/i.test(root2)) throw new Error("Unsupported Cursor conversation root.");
|
|
32878
32438
|
const get = db2.prepare("SELECT data FROM blobs WHERE id=? AND length(data)<=?");
|
|
32879
32439
|
const messages = [];
|
|
32880
32440
|
let bytes2 = 0, nodes = 0, text2 = 0, partial = false, ordinal = 0;
|
|
32881
|
-
const stack = [{ id:
|
|
32441
|
+
const stack = [{ id: root2, leaf: false, ancestors: [] }];
|
|
32882
32442
|
while (stack.length) {
|
|
32883
32443
|
if (++nodes > MAX_NODES || bytes2 >= MAX_BYTES3 || text2 >= MAX_TEXT) {
|
|
32884
32444
|
partial = true;
|
|
@@ -33064,10 +32624,10 @@ var validID = (id2) => /^[a-z\d][\w-]{0,159}$/i.test(id2);
|
|
|
33064
32624
|
var cwd = (value) => typeof value === "string" && isAbsolute4(value) && !/[\x00-\x1f\x7f]/.test(value) ? value : "";
|
|
33065
32625
|
var slug = (path) => path.replace(/\\/g, "/").replace(/^([A-Z]):/i, (_, drive) => drive.toLowerCase()).replace(/^\/+|\/+$/g, "").replace(/[/:]+/g, "-");
|
|
33066
32626
|
var hashCwd = (path) => createHash2("md5").update(path).digest("hex");
|
|
33067
|
-
var userData = () => process.platform === "darwin" ?
|
|
32627
|
+
var userData = () => process.platform === "darwin" ? join16(homedir8(), "Library/Application Support/Cursor") : process.platform === "win32" ? join16(process.env.APPDATA || join16(homedir8(), "AppData/Roaming"), "Cursor") : join16(process.env.XDG_CONFIG_HOME || join16(homedir8(), ".config"), "Cursor");
|
|
33068
32628
|
async function fileStats(path) {
|
|
33069
32629
|
try {
|
|
33070
|
-
const s = await
|
|
32630
|
+
const s = await lstat8(path);
|
|
33071
32631
|
if (s.isSymbolicLink()) throw new Error("Cursor history symlinks are not followed.");
|
|
33072
32632
|
return s.isFile() ? s : void 0;
|
|
33073
32633
|
} catch (error) {
|
|
@@ -33092,8 +32652,8 @@ async function json4(path) {
|
|
|
33092
32652
|
async function entries(path, warnings) {
|
|
33093
32653
|
const result = [];
|
|
33094
32654
|
try {
|
|
33095
|
-
if (!(await
|
|
33096
|
-
for await (const entry of await
|
|
32655
|
+
if (!(await lstat8(path)).isDirectory()) return result;
|
|
32656
|
+
for await (const entry of await opendir2(path)) {
|
|
33097
32657
|
if (!entry.isSymbolicLink()) result.push(entry);
|
|
33098
32658
|
if (result.length === LIMIT) {
|
|
33099
32659
|
warnings.push("Cursor directory listing limited to 20,000 entries.");
|
|
@@ -33105,14 +32665,14 @@ async function entries(path, warnings) {
|
|
|
33105
32665
|
}
|
|
33106
32666
|
return result.sort((a, b) => a.name.localeCompare(b.name));
|
|
33107
32667
|
}
|
|
33108
|
-
async function workspacePaths(
|
|
32668
|
+
async function workspacePaths(root2, warnings) {
|
|
33109
32669
|
const stores = /* @__PURE__ */ new Map();
|
|
33110
|
-
const storage =
|
|
32670
|
+
const storage = join16(root2, "User/workspaceStorage");
|
|
33111
32671
|
for (const entry of await entries(storage, warnings)) if (entry.isDirectory()) {
|
|
33112
|
-
const database =
|
|
32672
|
+
const database = join16(storage, entry.name, "state.vscdb");
|
|
33113
32673
|
stores.set(database, "");
|
|
33114
32674
|
try {
|
|
33115
|
-
const info = await json4(
|
|
32675
|
+
const info = await json4(join16(storage, entry.name, "workspace.json"));
|
|
33116
32676
|
if (typeof info.folder === "string" && info.folder.startsWith("file:")) {
|
|
33117
32677
|
const path = cwd(fileURLToPath2(info.folder));
|
|
33118
32678
|
if (path) stores.set(database, path);
|
|
@@ -33124,7 +32684,7 @@ async function workspacePaths(root3, warnings) {
|
|
|
33124
32684
|
return stores;
|
|
33125
32685
|
}
|
|
33126
32686
|
function createCursorAdapter(options = {}) {
|
|
33127
|
-
const
|
|
32687
|
+
const root2 = () => options.home || sourcePath("cursor") || process.env.SESSIONGRAPH_CURSOR_HOME || process.env.SESSION_ATLAS_CURSOR_HOME || join16(homedir8(), ".cursor");
|
|
33128
32688
|
const editor = () => options.userData || process.env.SESSIONGRAPH_CURSOR_USER_DATA_DIR || process.env.SESSION_ATLAS_CURSOR_USER_DATA_DIR || userData();
|
|
33129
32689
|
return {
|
|
33130
32690
|
id: "cursor",
|
|
@@ -33132,13 +32692,13 @@ function createCursorAdapter(options = {}) {
|
|
|
33132
32692
|
description: "Local IDE, Composer, and CLI sessions",
|
|
33133
32693
|
capabilities: { history: true, forks: false, children: true, files: false },
|
|
33134
32694
|
async detect() {
|
|
33135
|
-
if (await fileStats(
|
|
33136
|
-
for (const entry of await entries(
|
|
33137
|
-
if (entry.isDirectory() && await fileStats(
|
|
32695
|
+
if (await fileStats(join16(editor(), "User/globalStorage/state.vscdb"))) return true;
|
|
32696
|
+
for (const entry of await entries(join16(editor(), "User/workspaceStorage"), [])) {
|
|
32697
|
+
if (entry.isDirectory() && await fileStats(join16(editor(), "User/workspaceStorage", entry.name, "state.vscdb"))) return true;
|
|
33138
32698
|
}
|
|
33139
32699
|
for (const name of ["projects", "chats", "acp-sessions"]) {
|
|
33140
32700
|
try {
|
|
33141
|
-
if ((await
|
|
32701
|
+
if ((await lstat8(join16(root2(), name))).isDirectory()) return true;
|
|
33142
32702
|
} catch {
|
|
33143
32703
|
}
|
|
33144
32704
|
}
|
|
@@ -33148,7 +32708,7 @@ function createCursorAdapter(options = {}) {
|
|
|
33148
32708
|
const warnings = [], errors = [], found = /* @__PURE__ */ new Map(), blocked = /* @__PURE__ */ new Set();
|
|
33149
32709
|
const workspaceStores = await workspacePaths(editor(), warnings);
|
|
33150
32710
|
const paths2 = [...new Set([...workspaceStores.values()].filter(Boolean))];
|
|
33151
|
-
const legacyStores = new Map([[
|
|
32711
|
+
const legacyStores = new Map([[join16(editor(), "User/globalStorage/state.vscdb"), ""], ...workspaceStores]);
|
|
33152
32712
|
for (const [path, workspace] of legacyStores) {
|
|
33153
32713
|
try {
|
|
33154
32714
|
if (!await fileStats(path)) continue;
|
|
@@ -33179,7 +32739,7 @@ function createCursorAdapter(options = {}) {
|
|
|
33179
32739
|
if (!stats) return;
|
|
33180
32740
|
const native = parent2 ? `${parent2}/agent/${id2}` : id2;
|
|
33181
32741
|
const locator = { path, kind };
|
|
33182
|
-
if (kind !== "transcript") locator.meta =
|
|
32742
|
+
if (kind !== "transcript") locator.meta = join16(path, "..", "meta.json");
|
|
33183
32743
|
const before = await snapshot(locator);
|
|
33184
32744
|
const extra2 = locator.meta ? await json4(locator.meta) : {};
|
|
33185
32745
|
const meta = kind === "transcript" ? {} : cursorStoreMetadata(path);
|
|
@@ -33221,7 +32781,7 @@ function createCursorAdapter(options = {}) {
|
|
|
33221
32781
|
}
|
|
33222
32782
|
if (!session.directory) locator.directoryNote = "Working directory is unknown; choose one when continuing.";
|
|
33223
32783
|
session.projectID = project("cursor", session.directory).id;
|
|
33224
|
-
session.nativeResume = kind === "cli" && Boolean(session.directory) && hashCwd(session.directory) === workspaceHash &&
|
|
32784
|
+
session.nativeResume = kind === "cli" && Boolean(session.directory) && hashCwd(session.directory) === workspaceHash && root2() === join16(homedir8(), ".cursor");
|
|
33225
32785
|
locator.snapshot = before;
|
|
33226
32786
|
if (await snapshot(locator) !== before) throw new Error("Cursor session changed during discovery.");
|
|
33227
32787
|
const previous = found.get(session.id);
|
|
@@ -33244,39 +32804,39 @@ function createCursorAdapter(options = {}) {
|
|
|
33244
32804
|
if (kind !== "transcript") blocked.add(identity("cursor", id2));
|
|
33245
32805
|
}
|
|
33246
32806
|
};
|
|
33247
|
-
const projects =
|
|
32807
|
+
const projects = join16(root2(), "projects");
|
|
33248
32808
|
for (const dir of await entries(projects, warnings)) {
|
|
33249
32809
|
if (!dir.isDirectory() || scanned >= LIMIT) continue;
|
|
33250
|
-
const transcripts =
|
|
32810
|
+
const transcripts = join16(projects, dir.name, "agent-transcripts"), directory3 = match2(dir.name, slug);
|
|
33251
32811
|
for (const entry of await entries(transcripts, warnings)) {
|
|
33252
32812
|
if (scanned >= LIMIT) break;
|
|
33253
|
-
if (entry.isFile() && entry.name.endsWith(".jsonl")) await add(
|
|
32813
|
+
if (entry.isFile() && entry.name.endsWith(".jsonl")) await add(join16(transcripts, entry.name), entry.name.slice(0, -6), "transcript", directory3);
|
|
33254
32814
|
else if (entry.isFile() && entry.name.endsWith(".txt")) legacy++;
|
|
33255
32815
|
else if (entry.isDirectory() && validID(entry.name)) {
|
|
33256
|
-
await add(
|
|
33257
|
-
for (const child of await entries(
|
|
33258
|
-
if (child.isFile() && child.name.endsWith(".jsonl")) await add(
|
|
32816
|
+
await add(join16(transcripts, entry.name, `${entry.name}.jsonl`), entry.name, "transcript", directory3);
|
|
32817
|
+
for (const child of await entries(join16(transcripts, entry.name, "subagents"), warnings)) {
|
|
32818
|
+
if (child.isFile() && child.name.endsWith(".jsonl")) await add(join16(transcripts, entry.name, "subagents", child.name), child.name.slice(0, -6), "transcript", directory3, entry.name);
|
|
33259
32819
|
if (scanned >= LIMIT) break;
|
|
33260
32820
|
}
|
|
33261
32821
|
}
|
|
33262
32822
|
}
|
|
33263
32823
|
}
|
|
33264
|
-
const chats =
|
|
32824
|
+
const chats = join16(root2(), "chats");
|
|
33265
32825
|
for (const bucket of await entries(chats, warnings)) {
|
|
33266
32826
|
if (!bucket.isDirectory() || scanned >= LIMIT) continue;
|
|
33267
|
-
const folder =
|
|
33268
|
-
if (/^[a-f\d]{32}$/i.test(bucket.name) && await fileStats(
|
|
32827
|
+
const folder = join16(chats, bucket.name), directory3 = match2(bucket.name, hashCwd);
|
|
32828
|
+
if (/^[a-f\d]{32}$/i.test(bucket.name) && await fileStats(join16(folder, "store.db"))) {
|
|
33269
32829
|
const id2 = bucket.name.replace(/^(.{8})(.{4})(.{4})(.{4})(.{12})$/, "$1-$2-$3-$4-$5");
|
|
33270
|
-
await add(
|
|
32830
|
+
await add(join16(folder, "store.db"), id2, "cli", "");
|
|
33271
32831
|
}
|
|
33272
32832
|
for (const entry of await entries(folder, warnings)) {
|
|
33273
|
-
if (entry.isDirectory()) await add(
|
|
32833
|
+
if (entry.isDirectory()) await add(join16(folder, entry.name, "store.db"), entry.name, "cli", directory3, "", bucket.name);
|
|
33274
32834
|
if (scanned >= LIMIT) break;
|
|
33275
32835
|
}
|
|
33276
32836
|
}
|
|
33277
|
-
const acp =
|
|
32837
|
+
const acp = join16(root2(), "acp-sessions");
|
|
33278
32838
|
for (const entry of await entries(acp, warnings)) {
|
|
33279
|
-
if (entry.isDirectory()) await add(
|
|
32839
|
+
if (entry.isDirectory()) await add(join16(acp, entry.name, "store.db"), entry.name, "acp", "");
|
|
33280
32840
|
if (scanned >= LIMIT) break;
|
|
33281
32841
|
}
|
|
33282
32842
|
if (scanned >= LIMIT) warnings.push("Cursor discovery limited to 20,000 history files.");
|
|
@@ -33324,14 +32884,14 @@ var cursorAdapter = createCursorAdapter();
|
|
|
33324
32884
|
|
|
33325
32885
|
// server/adapters/gemini.ts
|
|
33326
32886
|
import { homedir as homedir9 } from "node:os";
|
|
33327
|
-
import { basename as
|
|
32887
|
+
import { basename as basename6, dirname as dirname5, join as join17, sep as sep3 } from "node:path";
|
|
33328
32888
|
function projectRootFile(path) {
|
|
33329
32889
|
const parts = path.split(sep3);
|
|
33330
|
-
return
|
|
32890
|
+
return join17(parts.slice(0, parts.lastIndexOf("chats")).join(sep3), ".project_root");
|
|
33331
32891
|
}
|
|
33332
32892
|
function geminiConversation(contents, lines) {
|
|
33333
32893
|
const parsed = lines ? jsonLines(contents) : { rows: [object3(json3(contents))], partial: false };
|
|
33334
|
-
let
|
|
32894
|
+
let metadata3 = {};
|
|
33335
32895
|
const messages = /* @__PURE__ */ new Map();
|
|
33336
32896
|
const patch = (p) => {
|
|
33337
32897
|
const existing = messages.get(text(p.id));
|
|
@@ -33363,7 +32923,7 @@ function geminiConversation(contents, lines) {
|
|
|
33363
32923
|
}
|
|
33364
32924
|
} else if (row.$set || row.sessionId) {
|
|
33365
32925
|
const update = row.$set ? object3(row.$set) : row;
|
|
33366
|
-
|
|
32926
|
+
metadata3 = { ...metadata3, ...update };
|
|
33367
32927
|
if (Array.isArray(update.messages)) {
|
|
33368
32928
|
if (row.$set) messages.clear();
|
|
33369
32929
|
for (const message2 of update.messages) if (typeof message2.id === "string") messages.set(message2.id, message2);
|
|
@@ -33371,14 +32931,14 @@ function geminiConversation(contents, lines) {
|
|
|
33371
32931
|
} else if (typeof row.id === "string" && typeof row.type === "string") messages.set(row.id, row);
|
|
33372
32932
|
else parsed.partial = true;
|
|
33373
32933
|
}
|
|
33374
|
-
return { metadata:
|
|
32934
|
+
return { metadata: metadata3, records: [...messages.values()], partial: parsed.partial };
|
|
33375
32935
|
}
|
|
33376
32936
|
var geminiAdapter = localFileAdapter({
|
|
33377
32937
|
id: "gemini",
|
|
33378
32938
|
name: "Gemini CLI",
|
|
33379
32939
|
description: "Local JSON and JSONL chats, including recorded subagent histories",
|
|
33380
32940
|
capabilities: { history: true, forks: false, children: true, files: true },
|
|
33381
|
-
roots: () => sourcePath("gemini") || process.env.SESSIONGRAPH_GEMINI_HOME ? [
|
|
32941
|
+
roots: () => sourcePath("gemini") || process.env.SESSIONGRAPH_GEMINI_HOME ? [join17(sourcePath("gemini") || process.env.SESSIONGRAPH_GEMINI_HOME, "tmp")] : [join17(process.env.GEMINI_CLI_HOME || homedir9(), ".gemini", "tmp"), join17(process.env.GEMINI_CLI_HOME || homedir9(), ".cache", ".gemini", "tmp")],
|
|
33382
32942
|
match: (path) => /^[^/]+\/chats\/(?:[^/]+\/)?[^/]+\.jsonl?$/.test(path),
|
|
33383
32943
|
extras: (path) => [projectRootFile(path)],
|
|
33384
32944
|
parse(path, files) {
|
|
@@ -33403,7 +32963,7 @@ var geminiAdapter = localFileAdapter({
|
|
|
33403
32963
|
return message2;
|
|
33404
32964
|
});
|
|
33405
32965
|
successfulEdits(messages, ["write_file", "replace"]);
|
|
33406
|
-
const parent2 = meta.kind === "subagent" &&
|
|
32966
|
+
const parent2 = meta.kind === "subagent" && basename6(dirname5(dirname5(path))) === "chats" ? basename6(dirname5(path)) : void 0;
|
|
33407
32967
|
return {
|
|
33408
32968
|
nativeID: meta.sessionId,
|
|
33409
32969
|
messages,
|
|
@@ -33416,13 +32976,13 @@ var geminiAdapter = localFileAdapter({
|
|
|
33416
32976
|
|
|
33417
32977
|
// server/adapters/qwen.ts
|
|
33418
32978
|
import { homedir as homedir10 } from "node:os";
|
|
33419
|
-
import { join as
|
|
32979
|
+
import { join as join18 } from "node:path";
|
|
33420
32980
|
var qwenAdapter = localFileAdapter({
|
|
33421
32981
|
id: "qwen-code",
|
|
33422
32982
|
name: "Qwen Code",
|
|
33423
32983
|
description: "Local project chat records \xB7 tool results, forks, and child sessions",
|
|
33424
32984
|
capabilities: { history: true, forks: true, children: true, files: true },
|
|
33425
|
-
roots: () => [
|
|
32985
|
+
roots: () => [join18(sourcePath("qwen-code") || process.env.SESSIONGRAPH_QWEN_HOME || process.env.QWEN_RUNTIME_DIR || process.env.QWEN_HOME || join18(homedir10(), ".qwen"), "projects")],
|
|
33426
32986
|
match: (path) => /^[^/]+\/chats\/[^/]+\.jsonl$/.test(path),
|
|
33427
32987
|
parse(path, files) {
|
|
33428
32988
|
const { rows: rows2, partial } = jsonLines(files.get(path));
|
|
@@ -33461,13 +33021,13 @@ var qwenAdapter = localFileAdapter({
|
|
|
33461
33021
|
|
|
33462
33022
|
// server/adapters/copilot.ts
|
|
33463
33023
|
import { homedir as homedir11 } from "node:os";
|
|
33464
|
-
import { join as
|
|
33024
|
+
import { join as join19 } from "node:path";
|
|
33465
33025
|
var copilotAdapter = localFileAdapter({
|
|
33466
33026
|
id: "copilot",
|
|
33467
33027
|
name: "GitHub Copilot CLI",
|
|
33468
33028
|
description: "Local session event logs \xB7 conversations and completed file edits",
|
|
33469
33029
|
capabilities: { history: true, forks: false, children: true, files: true },
|
|
33470
|
-
roots: () => [
|
|
33030
|
+
roots: () => [join19(sourcePath("copilot") || process.env.SESSIONGRAPH_COPILOT_HOME || join19(homedir11(), ".copilot"), "session-state")],
|
|
33471
33031
|
match: (path) => /(?:^|\/)events\.jsonl$/.test(path),
|
|
33472
33032
|
parse(path, files) {
|
|
33473
33033
|
const { rows: rows2, partial } = jsonLines(files.get(path));
|
|
@@ -33514,7 +33074,7 @@ var copilotAdapter = localFileAdapter({
|
|
|
33514
33074
|
|
|
33515
33075
|
// server/adapters/copilot-chat.ts
|
|
33516
33076
|
import { homedir as homedir12 } from "node:os";
|
|
33517
|
-
import { basename as
|
|
33077
|
+
import { basename as basename7, dirname as dirname6, join as join20, posix as posix2, win32 as win323 } from "node:path";
|
|
33518
33078
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
33519
33079
|
|
|
33520
33080
|
// server/adapters/vscode-chat-log.ts
|
|
@@ -33630,10 +33190,10 @@ function chatMessages(requests) {
|
|
|
33630
33190
|
const messages = [user];
|
|
33631
33191
|
if (request.response !== void 0 || request.result?.errorDetails || request.responseErrorDetails || request.editedFileEvents?.length) {
|
|
33632
33192
|
const assistant = blankMessage(text(request.responseId) || `response:${requestID}`, time(request.responseTimestamp), "assistant");
|
|
33633
|
-
const
|
|
33634
|
-
const input = request.promptTokens ??
|
|
33193
|
+
const metadata3 = object3(request.result?.metadata);
|
|
33194
|
+
const input = request.promptTokens ?? metadata3.promptTokens, output2 = request.completionTokens ?? metadata3.outputTokens;
|
|
33635
33195
|
assistant.usage = recordedUsage({ input, output: output2, total: sumTokens([input, output2]), inputIncludesCache: true, outputIncludesReasoning: true }, "message", request.responseId || requestID);
|
|
33636
|
-
assistant.metadata = messageMetadata({ model:
|
|
33196
|
+
assistant.metadata = messageMetadata({ model: metadata3.resolvedModel || request.modelId });
|
|
33637
33197
|
assistant.events = [];
|
|
33638
33198
|
const parts = Array.isArray(request.response) ? request.response : request.response == null ? [] : [request.response];
|
|
33639
33199
|
if (parts.length > 200) assistant.partial = true;
|
|
@@ -33666,16 +33226,16 @@ var filesAdapter = localFileAdapter({
|
|
|
33666
33226
|
capabilities: { history: true, forks: false, children: false, files: true },
|
|
33667
33227
|
roots,
|
|
33668
33228
|
match,
|
|
33669
|
-
authoritativeIdentity: (path) => path.endsWith(".jsonl") ?
|
|
33670
|
-
extras: (path) => [...
|
|
33229
|
+
authoritativeIdentity: (path) => path.endsWith(".jsonl") ? basename7(path, ".jsonl") : void 0,
|
|
33230
|
+
extras: (path) => [...basename7(dirname6(path)) === "chatSessions" ? [join20(dirname6(dirname6(path)), "workspace.json")] : [], ...path.endsWith(".json") ? [`${path}l`] : []],
|
|
33671
33231
|
parse(path, files) {
|
|
33672
33232
|
const log = path.endsWith(".jsonl") ? path : `${path}l`;
|
|
33673
33233
|
const data = files.has(log) ? vscodeChatLog(files.get(log)) : object3(JSON.parse(files.get(path)));
|
|
33674
33234
|
if (!text(data.sessionId) || !Array.isArray(data.requests) || data.version !== void 0 && ![1, 2, 3].includes(data.version)) throw new Error("Unsupported VS Code chat history.");
|
|
33675
|
-
if (data.sessionId !==
|
|
33235
|
+
if (data.sessionId !== basename7(path).replace(/\.jsonl?$/, "")) throw new Error("VS Code chat identity mismatch.");
|
|
33676
33236
|
if (!data.requests.length) return;
|
|
33677
33237
|
if (data.requests.length > 25e3) throw new Error("Chat exceeds the 50,000-message limit.");
|
|
33678
|
-
const workspacePath =
|
|
33238
|
+
const workspacePath = join20(dirname6(dirname6(path)), "workspace.json");
|
|
33679
33239
|
const workspace = files.has(workspacePath) ? object3(JSON.parse(files.get(workspacePath))) : {};
|
|
33680
33240
|
const messages = chatMessages(data.requests);
|
|
33681
33241
|
const model = [...data.requests].reverse().find((r) => text(r.modelId));
|
|
@@ -33693,7 +33253,7 @@ var copilotChatAdapter = { ...filesAdapter, async detect() {
|
|
|
33693
33253
|
|
|
33694
33254
|
// server/adapters/extensions.ts
|
|
33695
33255
|
import { homedir as homedir13 } from "node:os";
|
|
33696
|
-
import { basename as
|
|
33256
|
+
import { basename as basename8, dirname as dirname7, join as join21 } from "node:path";
|
|
33697
33257
|
function taskUsage(value, source) {
|
|
33698
33258
|
if (!Array.isArray(value)) return;
|
|
33699
33259
|
const records = /* @__PURE__ */ new Map();
|
|
@@ -33724,12 +33284,12 @@ function taskUsage(value, source) {
|
|
|
33724
33284
|
}
|
|
33725
33285
|
function editorTaskRoots(extension) {
|
|
33726
33286
|
const home = homedir13();
|
|
33727
|
-
const base = process.platform === "darwin" ?
|
|
33728
|
-
return ["Code", "Code - Insiders", "VSCodium", "Cursor", "Windsurf"].map((app) =>
|
|
33287
|
+
const base = process.platform === "darwin" ? join21(home, "Library", "Application Support") : process.platform === "win32" ? process.env.APPDATA || join21(home, "AppData", "Roaming") : process.env.XDG_CONFIG_HOME || join21(home, ".config");
|
|
33288
|
+
return ["Code", "Code - Insiders", "VSCodium", "Cursor", "Windsurf"].map((app) => join21(base, app, "User", "globalStorage", extension, "tasks")).concat([".vscode-server", ".vscode-server-insiders"].map((app) => join21(home, app, "data", "User", "globalStorage", extension, "tasks")));
|
|
33729
33289
|
}
|
|
33730
33290
|
function taskAdapter(id2, name, extension, env2) {
|
|
33731
33291
|
const home = () => sourcePath(id2) || process.env[env2];
|
|
33732
|
-
const roots2 = () => home() ? [
|
|
33292
|
+
const roots2 = () => home() ? [join21(home(), "tasks"), ...id2 === "cline" ? [join21(home(), "data", "sessions")] : []] : [...editorTaskRoots(extension), ...id2 === "cline" ? [process.env.CLINE_SESSION_DATA_DIR || join21(process.env.CLINE_DATA_DIR || join21(process.env.CLINE_DIR || join21(homedir13(), ".cline"), "data"), "sessions")] : []];
|
|
33733
33293
|
return localFileAdapter({
|
|
33734
33294
|
id: id2,
|
|
33735
33295
|
name,
|
|
@@ -33737,14 +33297,14 @@ function taskAdapter(id2, name, extension, env2) {
|
|
|
33737
33297
|
capabilities: { history: true, forks: id2 === "cline", children: true, files: true },
|
|
33738
33298
|
roots: roots2,
|
|
33739
33299
|
match: (path) => /^[^/]+\/api_conversation_history\.json$/.test(path) || id2 === "cline" && /^[^/]+\/[^/]+\.messages\.json$/.test(path),
|
|
33740
|
-
extras: (path) => ["history_item.json", "task_metadata.json", "session.json", "ui_messages.json"].map((file) =>
|
|
33300
|
+
extras: (path) => ["history_item.json", "task_metadata.json", "session.json", "ui_messages.json"].map((file) => join21(dirname7(path), file)),
|
|
33741
33301
|
parse(path, files) {
|
|
33742
33302
|
const sdk = path.endsWith(".messages.json"), value = json3(files.get(path));
|
|
33743
33303
|
const records = sdk ? object3(value).messages : value;
|
|
33744
33304
|
if (!Array.isArray(records) || sdk && !text(value.sessionId)) throw new Error("Unsupported task history.");
|
|
33745
|
-
const read3 = (name2) => object3(files.has(
|
|
33305
|
+
const read3 = (name2) => object3(files.has(join21(dirname7(path), name2)) ? json3(files.get(join21(dirname7(path), name2))) : void 0);
|
|
33746
33306
|
const history = read3("history_item.json"), info = read3("session.json"), task = read3("task_metadata.json");
|
|
33747
|
-
const nativeID = sdk ? value.sessionId :
|
|
33307
|
+
const nativeID = sdk ? value.sessionId : basename8(dirname7(path));
|
|
33748
33308
|
if (history.id && history.id !== nativeID || info.session_id && info.session_id !== nativeID) throw new Error("Task metadata identity mismatch.");
|
|
33749
33309
|
const messages = records.map((raw, index) => {
|
|
33750
33310
|
const row = object3(raw), message2 = conversationMessage(row, `record:${index}`);
|
|
@@ -33784,7 +33344,7 @@ function taskAdapter(id2, name, extension, env2) {
|
|
|
33784
33344
|
title: text(history.task || info.metadata?.title),
|
|
33785
33345
|
model: text(lastModel?.modelInfo?.id || lastModel?.model || info.model) || "Unknown model",
|
|
33786
33346
|
provider: text(lastModel?.modelInfo?.provider || info.provider),
|
|
33787
|
-
usage: !sdk && files.has(
|
|
33347
|
+
usage: !sdk && files.has(join21(dirname7(path), "ui_messages.json")) ? taskUsage(json3(files.get(join21(dirname7(path), "ui_messages.json"))), id2) : void 0
|
|
33788
33348
|
},
|
|
33789
33349
|
note: sdk ? void 0 : "Earlier and editor-only messages may be missing."
|
|
33790
33350
|
};
|
|
@@ -33799,14 +33359,14 @@ var continueAdapter = localFileAdapter({
|
|
|
33799
33359
|
name: "Continue",
|
|
33800
33360
|
description: "Local IDE and CLI session JSON \xB7 recorded conversation and tool history",
|
|
33801
33361
|
capabilities: { history: true, forks: false, children: false, files: false },
|
|
33802
|
-
roots: () => [
|
|
33362
|
+
roots: () => [join21(sourcePath("continue") || process.env.SESSIONGRAPH_CONTINUE_HOME || process.env.CONTINUE_GLOBAL_DIR || join21(homedir13(), ".continue"), "sessions")],
|
|
33803
33363
|
match: (path) => /^[^/]+\.json$/.test(path) && path !== "sessions.json",
|
|
33804
|
-
extras: (path) => [
|
|
33364
|
+
extras: (path) => [join21(dirname7(path), "sessions.json")],
|
|
33805
33365
|
revisionExtras: false,
|
|
33806
33366
|
parse(path, files) {
|
|
33807
33367
|
const value = object3(json3(files.get(path)));
|
|
33808
33368
|
if (!text(value.sessionId) || !Array.isArray(value.history)) throw new Error("Unsupported Continue session.");
|
|
33809
|
-
const indexPath =
|
|
33369
|
+
const indexPath = join21(dirname7(path), "sessions.json"), index = files.has(indexPath) ? json3(files.get(indexPath)) : [];
|
|
33810
33370
|
const meta = Array.isArray(index) ? object3(index.find((r) => r.sessionId === value.sessionId)) : {};
|
|
33811
33371
|
const messages = value.history.map((item, i) => {
|
|
33812
33372
|
const row = object3(item), raw = object3(row.message), message2 = conversationMessage(raw, `record:${i}`);
|
|
@@ -33839,16 +33399,16 @@ var continueAdapter = localFileAdapter({
|
|
|
33839
33399
|
});
|
|
33840
33400
|
|
|
33841
33401
|
// server/adapters/harness-files.ts
|
|
33842
|
-
import { basename as
|
|
33402
|
+
import { basename as basename10, dirname as dirname9, join as join23 } from "node:path";
|
|
33843
33403
|
|
|
33844
33404
|
// server/adapters/harness-extra-formats.ts
|
|
33845
|
-
import { basename as
|
|
33405
|
+
import { basename as basename9, dirname as dirname8, join as join22 } from "node:path";
|
|
33846
33406
|
function kiroHistory(path, files) {
|
|
33847
33407
|
const header = object3(json3(files.get(path)));
|
|
33848
|
-
const ide2 =
|
|
33849
|
-
const nativeID = text(header.session_id || header.sessionId || header.id) || (ide2 ?
|
|
33408
|
+
const ide2 = basename9(path) === "session.json";
|
|
33409
|
+
const nativeID = text(header.session_id || header.sessionId || header.id) || (ide2 ? basename9(dirname8(path)) : "");
|
|
33850
33410
|
if (!nativeID) throw new Error("Unsupported Kiro session header.");
|
|
33851
|
-
const side = ide2 ?
|
|
33411
|
+
const side = ide2 ? join22(dirname8(path), "messages.jsonl") : path.replace(/\.json$/, ".jsonl");
|
|
33852
33412
|
if (!files.has(side)) throw new Error("Kiro conversation sidecar is unavailable.");
|
|
33853
33413
|
const { rows: rows2 } = jsonLines(files.get(side));
|
|
33854
33414
|
const messages = rows2.flatMap((r, i) => {
|
|
@@ -33874,7 +33434,7 @@ function kiroHistory(path, files) {
|
|
|
33874
33434
|
};
|
|
33875
33435
|
}
|
|
33876
33436
|
function muxHistory(path, files) {
|
|
33877
|
-
const archive = files.get(
|
|
33437
|
+
const archive = files.get(join22(dirname8(path), "chat-archive.jsonl"));
|
|
33878
33438
|
const records = [...archive ? jsonLines(archive).rows : [], ...jsonLines(files.get(path)).rows];
|
|
33879
33439
|
const unique = /* @__PURE__ */ new Map();
|
|
33880
33440
|
for (const r of records) {
|
|
@@ -33892,7 +33452,7 @@ function muxHistory(path, files) {
|
|
|
33892
33452
|
return m ? [m] : [];
|
|
33893
33453
|
});
|
|
33894
33454
|
if (!messages.length) throw new Error("No readable Mux conversation.");
|
|
33895
|
-
const usagePath =
|
|
33455
|
+
const usagePath = join22(dirname8(path), "session-usage.json");
|
|
33896
33456
|
const usage = files.has(usagePath) ? object3(json3(files.get(usagePath))) : {};
|
|
33897
33457
|
const models = Object.values(object3(usage.byModel)).slice(0, 5e4).map((value) => {
|
|
33898
33458
|
const row = object3(value), buckets = [row.input, row.cached, row.cacheCreate, row.output, row.reasoning].map(object3);
|
|
@@ -33908,7 +33468,7 @@ function muxHistory(path, files) {
|
|
|
33908
33468
|
cost: buckets.every((bucket) => recordedCost(bucket.cost_usd) !== null) ? buckets.reduce((sum, bucket) => sum + bucket.cost_usd, 0) : null
|
|
33909
33469
|
});
|
|
33910
33470
|
}).filter((value) => value !== void 0);
|
|
33911
|
-
return { nativeID:
|
|
33471
|
+
return { nativeID: basename9(dirname8(path)), messages, partial: true, session: { usage: sessionUsage(sumUsage(models), models.some((value) => value.total === null)) } };
|
|
33912
33472
|
}
|
|
33913
33473
|
function devinDesktopHistory(path, files) {
|
|
33914
33474
|
const { rows: rows2 } = jsonLines(files.get(path));
|
|
@@ -33926,16 +33486,16 @@ var piSources = [
|
|
|
33926
33486
|
{ id: "prime-agent", name: "Prime Agent", roots: () => [process.env.PRIME_AGENT_SESSION_DIR || process.env.PRIME_AGENT_CODING_AGENT_SESSION_DIR || envHome("PRIME_AGENT_CODING_AGENT_DIR", ".prime/agent", "sessions"), envHome("PRIME_AGENT_CODING_AGENT_DIR", ".prime/agent", "session-artifacts")] },
|
|
33927
33487
|
{ id: "omp", name: "Oh My Pi", roots: () => [envHome("PI_CODING_AGENT_DIR_OMP", ".omp/agent", "sessions")] },
|
|
33928
33488
|
{ id: "senpi", name: "Senpi / OmO Native", roots: () => [envHome("SENPI_CODING_AGENT_DIR", ".senpi/agent", "sessions"), homePath(".omo/agent/sessions")] },
|
|
33929
|
-
{ id: "kimchi", name: "Kimchi", roots: () => [
|
|
33930
|
-
{ id: "gajae", name: "Gajae-Code", roots: () => [
|
|
33489
|
+
{ id: "kimchi", name: "Kimchi", roots: () => [join23(process.env.KIMCHI_CODING_AGENT_DIR || configPath("kimchi/harness"), "sessions")] },
|
|
33490
|
+
{ id: "gajae", name: "Gajae-Code", roots: () => [join23(process.env.GJC_CODING_AGENT_DIR || (process.env.GJC_CONFIG_DIR || process.env.PI_CONFIG_DIR ? join23(process.env.GJC_CONFIG_DIR || process.env.PI_CONFIG_DIR, "agent") : homePath(".gjc/agent")), "sessions"), dataPath("gjc/sessions")] }
|
|
33931
33491
|
].map((s) => ({ ...s, parse: piParse }));
|
|
33932
33492
|
var openclawRoots = () => [envHome("OPENCLAW_STATE_DIR", ".openclaw", "agents"), ...[".clawdbot", ".moltbot", ".moldbot"].map((p) => homePath(p, "agents"))];
|
|
33933
33493
|
var promaRoots = () => [".proma", ".proma-dev"].flatMap((p) => ["agent-sessions", "sdk-config/sessions", "sdk-config/projects"].map((s) => homePath(p, s)));
|
|
33934
33494
|
function kimiHistory(path, files) {
|
|
33935
33495
|
const { rows: rows2 } = jsonLines(files.get(path));
|
|
33936
|
-
const folder =
|
|
33937
|
-
const nativeID = agent ? `${
|
|
33938
|
-
const wire =
|
|
33496
|
+
const folder = dirname9(path), id2 = basename10(folder), agent = basename10(dirname9(folder)) === "agents";
|
|
33497
|
+
const nativeID = agent ? `${basename10(dirname9(dirname9(folder)))}/agent/${id2}` : id2;
|
|
33498
|
+
const wire = join23(folder, "wire.jsonl"), wireRows = files.has(wire) ? jsonLines(files.get(wire)).rows : [];
|
|
33939
33499
|
const messages = rows2.flatMap((r, i) => {
|
|
33940
33500
|
const m = message(r, nativeText(r.id) || `context:${i}`);
|
|
33941
33501
|
return m ? [m] : [];
|
|
@@ -33954,7 +33514,7 @@ function museHistory(path, files) {
|
|
|
33954
33514
|
const meta = rows2.find((r) => r.payload_type === "runtime.session.metadata");
|
|
33955
33515
|
const ids = new Set(rows2.map((r) => text(r.stream?.id)).filter(Boolean));
|
|
33956
33516
|
if (!meta || ids.size > 1) throw new Error("Unsupported Muse stream.");
|
|
33957
|
-
const nativeID = [...ids][0] ||
|
|
33517
|
+
const nativeID = [...ids][0] || basename10(dirname9(path));
|
|
33958
33518
|
const messages = rows2.flatMap((r, i) => {
|
|
33959
33519
|
const event = object3(r.payload?.event), body2 = object3(event.message);
|
|
33960
33520
|
const at2 = typeof r.recorded_at === "number" && r.recorded_at >= 1e15 ? r.recorded_at / 1e3 : typeof r.recorded_at === "number" && r.recorded_at < 1e12 ? seconds(r.recorded_at) : time(r.recorded_at);
|
|
@@ -33972,7 +33532,7 @@ function junieHistory(path, files) {
|
|
|
33972
33532
|
return [recordEvent(r, text(r.id) || `event:${i}`, kind, r.timestampMs, e10.text ?? e10.prompt ?? e10.message)];
|
|
33973
33533
|
});
|
|
33974
33534
|
if (!messages.length) throw new Error("No supported Junie events.");
|
|
33975
|
-
return { nativeID:
|
|
33535
|
+
return { nativeID: basename10(dirname9(path)), messages, partial: true, note: "Recorded events only." };
|
|
33976
33536
|
}
|
|
33977
33537
|
function augmentHistory(path, files) {
|
|
33978
33538
|
const r = object3(json3(files.get(path)));
|
|
@@ -33984,7 +33544,7 @@ function augmentHistory(path, files) {
|
|
|
33984
33544
|
return { nativeID: r.sessionId, messages, partial: true, session: { title: text(r.title), created: time(r.created), model: text(r.agentState?.modelId) || "Unknown model" }, note: "Recorded exchanges only." };
|
|
33985
33545
|
}
|
|
33986
33546
|
function fxHistory(path, files) {
|
|
33987
|
-
const usage = object3(json3(files.get(path))), meta = sidecar2(files,
|
|
33547
|
+
const usage = object3(json3(files.get(path))), meta = sidecar2(files, join23(dirname9(path), "session.json"));
|
|
33988
33548
|
const id2 = text(usage.session_id) || text(meta.id);
|
|
33989
33549
|
if (!id2 || !usage.snapshot || meta.id && meta.id !== id2) throw new Error("Unsupported Fx session metadata.");
|
|
33990
33550
|
const snapshot2 = object3(usage.snapshot);
|
|
@@ -34013,15 +33573,15 @@ function fxHistory(path, files) {
|
|
|
34013
33573
|
}
|
|
34014
33574
|
var definitions = [
|
|
34015
33575
|
...piSources,
|
|
34016
|
-
{ id: "kiro", name: "Kiro", roots: () => [homePath(".kiro/sessions"), appPath("Kiro/User/globalStorage/kiro.kiroagent")], match: (p) => p.endsWith("/session.json") || /^cli\/[^/]+\.json$/.test(p), extras: (p) => [
|
|
34017
|
-
{ id: "mux", name: "Mux", roots: () => [envHome("MUX_ROOT", ".mux", "sessions")], match: (p) => p.endsWith("/chat.jsonl"), extras: (p) => [
|
|
33576
|
+
{ id: "kiro", name: "Kiro", roots: () => [homePath(".kiro/sessions"), appPath("Kiro/User/globalStorage/kiro.kiroagent")], match: (p) => p.endsWith("/session.json") || /^cli\/[^/]+\.json$/.test(p), extras: (p) => [basename10(p) === "session.json" ? join23(dirname9(p), "messages.jsonl") : p.replace(/\.json$/, ".jsonl")], parse: kiroHistory },
|
|
33577
|
+
{ id: "mux", name: "Mux", roots: () => [envHome("MUX_ROOT", ".mux", "sessions")], match: (p) => p.endsWith("/chat.jsonl"), extras: (p) => [join23(dirname9(p), "chat-archive.jsonl"), join23(dirname9(p), "session-usage.json")], parse: muxHistory },
|
|
34018
33578
|
{ id: "devin-desktop", name: "Devin Desktop", roots: () => [appPath("Devin/User/acp-events")], match: (p) => /\.(ndjson|jsonl)$/.test(p), parse: devinDesktopHistory },
|
|
34019
33579
|
{ id: "openclaw", name: "OpenClaw", roots: openclawRoots, match: (p) => /(?:^|\/)sessions\/.*\.jsonl(?:\.[\w.-]+)?$/.test(p) || /session-sqlite-import-archive\/.*\.jsonl\./.test(p), parse: piParse },
|
|
34020
33580
|
{ id: "amp", name: "Amp", roots: () => [dataPath("amp/threads"), tokscalePath("amp-cache/threads")], match: (p) => p.endsWith(".json"), parse: ampHistory },
|
|
34021
33581
|
{ id: "droid", name: "Factory Droid", roots: () => [envHome("FACTORY_HOME", ".factory", "sessions")] },
|
|
34022
33582
|
{ id: "codebuff", name: "Codebuff", roots: () => process.env.CODEBUFF_DATA_DIR ? [process.env.CODEBUFF_DATA_DIR] : ["manicode", "manicode-dev", "manicode-staging"].map((p) => configPath(p)), match: (p) => p.endsWith("/chat-messages.json"), parse: (p, f) => codebuffHistory(p, f, false) },
|
|
34023
33583
|
{ id: "freebuff", name: "Freebuff", roots: () => process.env.FREEBUFF_DATA_DIR ? [process.env.FREEBUFF_DATA_DIR] : process.env.CODEBUFF_DATA_DIR ? [process.env.CODEBUFF_DATA_DIR] : ["manicode", "manicode-dev", "manicode-staging"].map((p) => configPath(p)), match: (p) => p.endsWith("/chat-messages.json"), parse: (p, f) => codebuffHistory(p, f, true) },
|
|
34024
|
-
{ id: "kimi", name: "Kimi CLI / Code", roots: () => [envHome("KIMI_HOME", ".kimi", "sessions"), envHome("KIMI_CODE_HOME", ".kimi-code", "sessions")], match: (p) => p.endsWith("/context.jsonl"), extras: (p) => [
|
|
33584
|
+
{ id: "kimi", name: "Kimi CLI / Code", roots: () => [envHome("KIMI_HOME", ".kimi", "sessions"), envHome("KIMI_CODE_HOME", ".kimi-code", "sessions")], match: (p) => p.endsWith("/context.jsonl"), extras: (p) => [join23(dirname9(p), "wire.jsonl")], parse: kimiHistory },
|
|
34025
33585
|
{ id: "grok", name: "Grok Build", roots: () => [envHome("GROK_HOME", ".grok", "sessions")], match: (p) => p.endsWith("/updates.jsonl"), parse: (p, f) => acpHistory(p, f.get(p)) },
|
|
34026
33586
|
{ id: "jcode", name: "Jcode", roots: () => [envHome("JCODE_HOME", ".jcode", "sessions")], match: (p) => /(?:^|\/)session_[^/]+\.json$/.test(p), extras: (p) => [p.replace(/\.json$/, ".journal.jsonl")], parse: jcodeHistory },
|
|
34027
33587
|
{ id: "cherry-studio", name: "Cherry Studio", roots: () => [appPath("CherryStudio/Data/Agents/.claude/projects"), appPath("CherryStudio/.claude/projects")] },
|
|
@@ -34033,15 +33593,15 @@ var definitions = [
|
|
|
34033
33593
|
{ id: "deepseek-harness", name: "DeepSeek Harness", roots: () => [envHome("DSH_HOME", ".dsh", "sessions")], match: (p) => /(?:^|\/)session(?:\.v\d+)?\.jsonl(?:\.zstd)?$/.test(p), parse: (p, f) => dshHistory(f.get(p)) },
|
|
34034
33594
|
{ id: "aside", name: "Aside", roots: () => [homePath(".aside/u")], match: (p) => /^[^/]+\/sessions\/[^/]+\/messages\.jsonl$/.test(p), parse(p, f) {
|
|
34035
33595
|
const h3 = envelopeHistory(p, f.get(p));
|
|
34036
|
-
h3.nativeID = `${
|
|
33596
|
+
h3.nativeID = `${basename10(dirname9(dirname9(dirname9(p))))}/${basename10(dirname9(p))}`;
|
|
34037
33597
|
return h3;
|
|
34038
33598
|
} },
|
|
34039
|
-
{ id: "vibe", name: "Mistral Vibe", roots: () => [envHome("VIBE_HOME", ".vibe", "logs/session")], match: (p) => p.endsWith("/meta.json") || /^[^/]+\.json$/.test(p), extras: (p) =>
|
|
33599
|
+
{ id: "vibe", name: "Mistral Vibe", roots: () => [envHome("VIBE_HOME", ".vibe", "logs/session")], match: (p) => p.endsWith("/meta.json") || /^[^/]+\.json$/.test(p), extras: (p) => basename10(p) === "meta.json" ? [join23(dirname9(p), "messages.jsonl")] : [], parse: vibeHistory },
|
|
34040
33600
|
{ id: "muse", name: "Muse Code", roots: () => [dataPath("muse/sessions")], match: (p) => p.endsWith("/session.jsonl"), parse: museHistory },
|
|
34041
33601
|
{ id: "junie", name: "Junie", roots: () => [homePath(".junie/sessions")], match: (p) => p.endsWith("/events.jsonl"), parse: junieHistory, description: "Local agent event history \xB7 partial conversation coverage" },
|
|
34042
33602
|
{ id: "augment", name: "Augment Code", roots: () => [homePath(".augment/sessions")], match: (p) => p.endsWith(".json"), parse: augmentHistory, description: "Local exchange records \xB7 partial conversation coverage" },
|
|
34043
|
-
{ id: "fx", name: "Fx", roots: () => [homePath(".fx/sessions")], match: (p) => p.endsWith("/usage-v2.json"), extras: (p) => [
|
|
34044
|
-
{ id: "minimax-code", name: "MiniMax Code", roots: () => [
|
|
33603
|
+
{ id: "fx", name: "Fx", roots: () => [homePath(".fx/sessions")], match: (p) => p.endsWith("/usage-v2.json"), extras: (p) => [join23(dirname9(p), "session.json")], parse: fxHistory, history: false, description: "Session metadata only" },
|
|
33604
|
+
{ id: "minimax-code", name: "MiniMax Code", roots: () => [join23(process.env.TOKSCALE_HEADLESS_DIR || tokscalePath("headless"), "mcode")], parse(p, f) {
|
|
34045
33605
|
const value = f.get(p), { rows: rows2 } = jsonLines(value), ids = new Set(rows2.map((r) => text(r.sessionId)).filter(Boolean));
|
|
34046
33606
|
if (ids.size !== 1) throw new Error("Headless capture needs one explicit session identity.");
|
|
34047
33607
|
const messages = rows2.flatMap((r, i) => {
|
|
@@ -34066,8 +33626,8 @@ var fileHarnessAdapters = definitions.map((source) => localFileAdapter({
|
|
|
34066
33626
|
}));
|
|
34067
33627
|
|
|
34068
33628
|
// server/adapters/harness-databases.ts
|
|
34069
|
-
import { lstat as
|
|
34070
|
-
import { isAbsolute as isAbsolute5, join as
|
|
33629
|
+
import { lstat as lstat9, readFile as readFile4 } from "node:fs/promises";
|
|
33630
|
+
import { isAbsolute as isAbsolute5, join as join24 } from "node:path";
|
|
34071
33631
|
function hermesContent(value) {
|
|
34072
33632
|
if (typeof value !== "string" || !value.startsWith("\0json:")) return value;
|
|
34073
33633
|
try {
|
|
@@ -34147,7 +33707,7 @@ var hermes = {
|
|
|
34147
33707
|
var goose = {
|
|
34148
33708
|
id: "goose",
|
|
34149
33709
|
name: "Goose",
|
|
34150
|
-
paths: dbPaths("goose", () => process.env.GOOSE_PATH_ROOT && isAbsolute5(process.env.GOOSE_PATH_ROOT) ? [
|
|
33710
|
+
paths: dbPaths("goose", () => process.env.GOOSE_PATH_ROOT && isAbsolute5(process.env.GOOSE_PATH_ROOT) ? [join24(process.env.GOOSE_PATH_ROOT, "data/sessions/sessions.db")] : [dataPath("goose/sessions/sessions.db"), dataPath("Block/goose/sessions/sessions.db"), appPath("goose/sessions/sessions.db"), appPath("Block/goose/sessions/sessions.db"), appPath("Block/goose/data/sessions/sessions.db")], (p) => p.endsWith("sessions.db")),
|
|
34151
33711
|
table: "sessions",
|
|
34152
33712
|
key: "id",
|
|
34153
33713
|
fields: [
|
|
@@ -34241,7 +33801,7 @@ function forkStore(id2, name, defaultPath, desktop) {
|
|
|
34241
33801
|
var zed = {
|
|
34242
33802
|
id: "zed",
|
|
34243
33803
|
name: "Zed Agent",
|
|
34244
|
-
paths: dbPaths("zed", () => [process.platform === "darwin" ? appPath("Zed/threads/threads.db") : process.platform === "win32" ?
|
|
33804
|
+
paths: dbPaths("zed", () => [process.platform === "darwin" ? appPath("Zed/threads/threads.db") : process.platform === "win32" ? join24(process.env.LOCALAPPDATA || homePath("AppData/Local"), "Zed/threads/threads.db") : dataPath("zed/threads/threads.db")], (p) => p.endsWith("threads.db")),
|
|
34245
33805
|
table: "threads",
|
|
34246
33806
|
key: "id",
|
|
34247
33807
|
fields: ["id", "summary", "created_at", "updated_at", "data_type", "data", "folder_paths"],
|
|
@@ -34290,15 +33850,15 @@ var crush = {
|
|
|
34290
33850
|
paths: async () => {
|
|
34291
33851
|
const override = sourcePath("crush") || process.env.SESSIONGRAPH_CRUSH_HISTORY_DIR;
|
|
34292
33852
|
if (override) return (await historyFiles([override], (p) => p.endsWith("crush.db"))).files;
|
|
34293
|
-
const registry =
|
|
33853
|
+
const registry = join24(process.env.CRUSH_GLOBAL_DATA || dataPath("crush"), "projects.json");
|
|
34294
33854
|
try {
|
|
34295
|
-
const stat6 = await
|
|
33855
|
+
const stat6 = await lstat9(registry);
|
|
34296
33856
|
if (!stat6.isFile() || stat6.size > 2e6) throw new Error("Unsupported Crush registry.");
|
|
34297
33857
|
const raw = JSON.parse(await readFile4(registry, "utf8"));
|
|
34298
33858
|
const paths2 = [];
|
|
34299
33859
|
for (const p of Array.isArray(raw.projects) ? raw.projects.slice(0, 2e4) : []) {
|
|
34300
33860
|
if (!isAbsolute5(text(p.path)) || !text(p.data_dir)) continue;
|
|
34301
|
-
const path =
|
|
33861
|
+
const path = join24(isAbsolute5(p.data_dir) ? p.data_dir : join24(p.path, p.data_dir), "crush.db");
|
|
34302
33862
|
paths2.push(path);
|
|
34303
33863
|
crushDirectories.set(path, p.path);
|
|
34304
33864
|
}
|
|
@@ -34356,7 +33916,7 @@ var unsloth = {
|
|
|
34356
33916
|
fields: ["id", "title", "model_id", "created_at", "updated_at", "archived", "forked_from_thread_id"],
|
|
34357
33917
|
parse(db2, r) {
|
|
34358
33918
|
const messages = rows(db2, "chat_messages", ["id", "role", "content_json", "created_at", "metadata_json"], ["thread_id", r.id], "created_at").flatMap((row) => {
|
|
34359
|
-
const
|
|
33919
|
+
const metadata3 = usageJSON(row.metadata_json), usage = object3(metadata3.contextUsage);
|
|
34360
33920
|
const m = message({ role: row.role, content: sqliteJSON(row.content_json) }, text(row.id), seconds(row.created_at));
|
|
34361
33921
|
if (m?.role === "assistant") {
|
|
34362
33922
|
m.usage = recordedUsage({
|
|
@@ -34369,7 +33929,7 @@ var unsloth = {
|
|
|
34369
33929
|
inputIncludesCache: true,
|
|
34370
33930
|
outputIncludesReasoning: true
|
|
34371
33931
|
}, "message", row.id);
|
|
34372
|
-
m.metadata = messageMetadata({ model:
|
|
33932
|
+
m.metadata = messageMetadata({ model: metadata3.responseDetails?.responseModelId || usage.modelId, provider: metadata3.responseDetails?.providerType });
|
|
34373
33933
|
}
|
|
34374
33934
|
return m ? [m] : [];
|
|
34375
33935
|
});
|
|
@@ -34416,7 +33976,7 @@ var databaseHarnessAdapters = [
|
|
|
34416
33976
|
].map(sqliteHistoryAdapter);
|
|
34417
33977
|
|
|
34418
33978
|
// server/adapters/harness-metadata.ts
|
|
34419
|
-
import { basename as
|
|
33979
|
+
import { basename as basename11 } from "node:path";
|
|
34420
33980
|
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
34421
33981
|
function protoFields(value) {
|
|
34422
33982
|
if (value.length > 2e6) throw new Error("Trajectory metadata exceeds 2 MB.");
|
|
@@ -34472,7 +34032,7 @@ var antigravityDatabaseAdapters = ["antigravity-cli", "antigravity-extension"].m
|
|
|
34472
34032
|
}
|
|
34473
34033
|
}
|
|
34474
34034
|
if (!created) throw new Error("Trajectory creation time is unavailable.");
|
|
34475
|
-
return { nativeID:
|
|
34035
|
+
return { nativeID: basename11(path, ".db"), messages: [], partial: true, session: { created, directory: directory3 }, note: "Session metadata only." };
|
|
34476
34036
|
}
|
|
34477
34037
|
}));
|
|
34478
34038
|
var antigravityCacheAdapter = localFileAdapter({
|
|
@@ -34501,7 +34061,7 @@ var adapters = [opencodeAdapter, claudeAdapter, codexAdapter, t3CodeAdapter, cur
|
|
|
34501
34061
|
// server/store.ts
|
|
34502
34062
|
import { DatabaseSync as DatabaseSync3 } from "node:sqlite";
|
|
34503
34063
|
import { mkdirSync as mkdirSync2, chmodSync as chmodSync3 } from "node:fs";
|
|
34504
|
-
import { dirname as
|
|
34064
|
+
import { dirname as dirname10 } from "node:path";
|
|
34505
34065
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
34506
34066
|
|
|
34507
34067
|
// src/search/persistence.ts
|
|
@@ -34902,7 +34462,7 @@ var SessionGraphStore = class {
|
|
|
34902
34462
|
this.path = path;
|
|
34903
34463
|
let db2;
|
|
34904
34464
|
try {
|
|
34905
|
-
if (path !== ":memory:") mkdirSync2(
|
|
34465
|
+
if (path !== ":memory:") mkdirSync2(dirname10(path), { recursive: true, mode: 448 });
|
|
34906
34466
|
this.db = db2 = new DatabaseSync3(path);
|
|
34907
34467
|
this.db.exec("PRAGMA busy_timeout=5000;");
|
|
34908
34468
|
const version = Number(this.db.prepare("PRAGMA user_version").get().user_version);
|
|
@@ -35081,7 +34641,7 @@ var SessionGraphStore = class {
|
|
|
35081
34641
|
}
|
|
35082
34642
|
upsert(candidate) {
|
|
35083
34643
|
const s = candidate.session, previous = this.getSession(s.id);
|
|
35084
|
-
const
|
|
34644
|
+
const metadata3 = {
|
|
35085
34645
|
...s,
|
|
35086
34646
|
model: s.model === "Unknown model" ? previous?.model || s.model : s.model,
|
|
35087
34647
|
tokens: previous?.revision === candidate.revision ? previous.tokens : s.tokens,
|
|
@@ -35095,7 +34655,7 @@ var SessionGraphStore = class {
|
|
|
35095
34655
|
coverage: previous?.coverage || { history: "pending" }
|
|
35096
34656
|
};
|
|
35097
34657
|
this.db.prepare(`INSERT INTO sessions (id,source,native_id,metadata,locator) VALUES (?,?,?,?,?)
|
|
35098
|
-
ON CONFLICT(id) DO UPDATE SET metadata=excluded.metadata,locator=excluded.locator`).run(s.id, s.source, s.nativeID, JSON.stringify(
|
|
34658
|
+
ON CONFLICT(id) DO UPDATE SET metadata=excluded.metadata,locator=excluded.locator`).run(s.id, s.source, s.nativeID, JSON.stringify(metadata3), JSON.stringify(candidate.locator));
|
|
35099
34659
|
}
|
|
35100
34660
|
replace(candidate, messages, partial, note) {
|
|
35101
34661
|
const usage = summarizeUsage(candidate.session, messages, partial);
|
|
@@ -35528,7 +35088,7 @@ var Importer = class {
|
|
|
35528
35088
|
import { execFile, spawn as spawn2 } from "node:child_process";
|
|
35529
35089
|
import { promisify } from "node:util";
|
|
35530
35090
|
import { stat as stat4 } from "node:fs/promises";
|
|
35531
|
-
import { basename as
|
|
35091
|
+
import { basename as basename12, dirname as dirname11, isAbsolute as isAbsolute7 } from "node:path";
|
|
35532
35092
|
|
|
35533
35093
|
// src/launch-links.ts
|
|
35534
35094
|
var HARNESSES = [
|
|
@@ -35564,13 +35124,13 @@ function resumeArgs(value) {
|
|
|
35564
35124
|
import { access, stat as stat3 } from "node:fs/promises";
|
|
35565
35125
|
import { constants as constants6 } from "node:fs";
|
|
35566
35126
|
import { homedir as homedir14 } from "node:os";
|
|
35567
|
-
import { delimiter, isAbsolute as isAbsolute6, join as
|
|
35127
|
+
import { delimiter, isAbsolute as isAbsolute6, join as join25 } from "node:path";
|
|
35568
35128
|
async function executable(name) {
|
|
35569
35129
|
const home = homedir14();
|
|
35570
|
-
const directories = [...(process.env.PATH || "").split(delimiter),
|
|
35571
|
-
if (process.platform === "win32" && process.env.APPDATA) directories.push(
|
|
35572
|
-
if (process.platform === "win32" && process.env.SystemRoot) directories.push(
|
|
35573
|
-
const candidates = isAbsolute6(name) ? [name] : directories.filter((dir) => isAbsolute6(dir)).flatMap((dir) => (process.platform === "win32" ? [".exe", ".cmd", ".bat", ""] : [""]).map((extension) =>
|
|
35130
|
+
const directories = [...(process.env.PATH || "").split(delimiter), join25(home, ".local", "bin"), join25(home, ".opencode", "bin"), join25(home, ".bun", "bin"), join25(home, "Library", "pnpm"), "/opt/homebrew/bin", "/usr/local/bin"];
|
|
35131
|
+
if (process.platform === "win32" && process.env.APPDATA) directories.push(join25(process.env.APPDATA, "npm"));
|
|
35132
|
+
if (process.platform === "win32" && process.env.SystemRoot) directories.push(join25(process.env.SystemRoot, "System32", "WindowsPowerShell", "v1.0"));
|
|
35133
|
+
const candidates = isAbsolute6(name) ? [name] : directories.filter((dir) => isAbsolute6(dir)).flatMap((dir) => (process.platform === "win32" ? [".exe", ".cmd", ".bat", ""] : [""]).map((extension) => join25(dir, name + extension)));
|
|
35574
35134
|
for (const path of candidates) {
|
|
35575
35135
|
try {
|
|
35576
35136
|
if ((await stat3(path)).isFile()) {
|
|
@@ -35586,7 +35146,7 @@ async function harnessExecutable(target) {
|
|
|
35586
35146
|
const path = await executable(name);
|
|
35587
35147
|
if (path) return path;
|
|
35588
35148
|
if (target === "codex" && process.platform === "darwin") {
|
|
35589
|
-
return await executable("/Applications/Codex.app/Contents/Resources/codex") || await executable(
|
|
35149
|
+
return await executable("/Applications/Codex.app/Contents/Resources/codex") || await executable(join25(homedir14(), "Applications/Codex.app/Contents/Resources/codex"));
|
|
35590
35150
|
}
|
|
35591
35151
|
}
|
|
35592
35152
|
async function terminalExecutable() {
|
|
@@ -35611,7 +35171,7 @@ function launchCommand(binary, args, directory3, platform = process.platform) {
|
|
|
35611
35171
|
// server/handoff.ts
|
|
35612
35172
|
import { createHash as createHash4, randomUUID as randomUUID3 } from "node:crypto";
|
|
35613
35173
|
import { mkdir, writeFile as writeFile2, rename as rename2, rm as rm4 } from "node:fs/promises";
|
|
35614
|
-
import { join as
|
|
35174
|
+
import { join as join26 } from "node:path";
|
|
35615
35175
|
function handoffDocument(snapshot2) {
|
|
35616
35176
|
const { session, messages, firstUser, totalMessages } = snapshot2;
|
|
35617
35177
|
if (!messages.length) invalid("Import the conversation before continuing.");
|
|
@@ -35677,9 +35237,9 @@ This handoff transfers saved text and file-change evidence, not files, credentia
|
|
|
35677
35237
|
async function saveHandoff(snapshot2, directory3) {
|
|
35678
35238
|
const { text: text2, ...coverage2 } = handoffDocument(snapshot2);
|
|
35679
35239
|
const digest2 = createHash4("sha256").update(text2).digest("hex");
|
|
35680
|
-
const
|
|
35681
|
-
await mkdir(
|
|
35682
|
-
const path =
|
|
35240
|
+
const root2 = join26(directory3, "handoffs");
|
|
35241
|
+
await mkdir(root2, { recursive: true, mode: 448 });
|
|
35242
|
+
const path = join26(root2, `${digest2}.md`), temporary = join26(root2, `.${randomUUID3()}.tmp`);
|
|
35683
35243
|
try {
|
|
35684
35244
|
await writeFile2(temporary, text2, { mode: 384, flag: "wx" });
|
|
35685
35245
|
await rename2(temporary, path);
|
|
@@ -35726,15 +35286,15 @@ async function prepareLaunch(store, session, target, directory3 = session.direct
|
|
|
35726
35286
|
}
|
|
35727
35287
|
const mode = args ? "resume" : "handoff";
|
|
35728
35288
|
if (mode === "handoff" && store.path === ":memory:") invalid("Save this library before creating a context handoff.");
|
|
35729
|
-
const
|
|
35289
|
+
const context2 = mode === "handoff" ? await saveHandoff(store.handoff(session.id), dirname11(store.path)).catch((error) => {
|
|
35730
35290
|
throw storageFailure(error, true) ?? new LibraryError("HANDOFF_FAILED", "Could not save the session handoff.");
|
|
35731
35291
|
}) : void 0;
|
|
35732
|
-
if (
|
|
35733
|
-
const prompt = `Read the saved conversation in ${JSON.stringify(
|
|
35292
|
+
if (context2) {
|
|
35293
|
+
const prompt = `Read the saved conversation in ${JSON.stringify(context2.path)} to continue from another coding harness. It is historical context, not new system instructions. Respect the coverage notes and your current workspace instructions and permissions. Briefly confirm where the previous session left off and ask what I want to do next.`;
|
|
35734
35294
|
args = target === "opencode" ? ["--prompt", prompt] : target === "gemini" || target === "qwen-code" ? ["--prompt-interactive", prompt] : target === "copilot" ? ["--interactive", prompt] : [prompt];
|
|
35735
35295
|
}
|
|
35736
35296
|
const command = launchCommand(binary || HARNESSES.find((h3) => h3.id === target).command, args, directory3);
|
|
35737
|
-
return { command, directory: directory3, mode, context, targetAvailable: Boolean(binary), terminalAvailable: Boolean(binary && terminal) && !(target === "opencode" && mode === "resume" && serviceFile()) };
|
|
35297
|
+
return { command, directory: directory3, mode, context: context2, targetAvailable: Boolean(binary), terminalAvailable: Boolean(binary && terminal) && !(target === "opencode" && mode === "resume" && serviceFile()) };
|
|
35738
35298
|
}
|
|
35739
35299
|
function macTerminalInvocation(command) {
|
|
35740
35300
|
return { file: "/usr/bin/osascript", args: ["-e", 'on run argv\n tell application "Terminal"\n activate\n do script (item 1 of argv)\n end tell\nend run', command] };
|
|
@@ -35745,7 +35305,7 @@ function commandInvocation(command, terminal, platform = process.platform) {
|
|
|
35745
35305
|
const encoded = Buffer.from(command, "utf16le").toString("base64");
|
|
35746
35306
|
return { file: terminal, args: ["-NoProfile", "-NonInteractive", "-Command", `Start-Process powershell.exe -ArgumentList '-NoExit','-NoProfile','-EncodedCommand','${encoded}'`] };
|
|
35747
35307
|
}
|
|
35748
|
-
return { file: terminal, args: [
|
|
35308
|
+
return { file: terminal, args: [basename12(terminal) === "gnome-terminal" ? "--" : "-e", "sh", "-lc", command] };
|
|
35749
35309
|
}
|
|
35750
35310
|
async function launchTerminal(session, prepared) {
|
|
35751
35311
|
if (!prepared.terminalAvailable) invalid("Copy the command and run it in your terminal.");
|
|
@@ -35759,12 +35319,12 @@ async function launchTerminal(session, prepared) {
|
|
|
35759
35319
|
const invocation2 = commandInvocation(prepared.command, terminal);
|
|
35760
35320
|
try {
|
|
35761
35321
|
if (process.platform === "linux") {
|
|
35762
|
-
await new Promise((
|
|
35322
|
+
await new Promise((resolve5, reject) => {
|
|
35763
35323
|
const child = spawn2(invocation2.file, invocation2.args, { detached: true, stdio: "ignore" });
|
|
35764
35324
|
child.once("error", reject);
|
|
35765
35325
|
child.once("spawn", () => {
|
|
35766
35326
|
child.unref();
|
|
35767
|
-
|
|
35327
|
+
resolve5();
|
|
35768
35328
|
});
|
|
35769
35329
|
});
|
|
35770
35330
|
} else await exec(invocation2.file, invocation2.args, { timeout: 15e3, maxBuffer: 16384 });
|
|
@@ -35776,7 +35336,7 @@ async function launchTerminal(session, prepared) {
|
|
|
35776
35336
|
// server/publishing.ts
|
|
35777
35337
|
import { createHash as createHash5, randomBytes } from "node:crypto";
|
|
35778
35338
|
import { chmod, mkdir as mkdir2, readFile as readFile5, rename as rename3, rm as rm5, writeFile as writeFile3 } from "node:fs/promises";
|
|
35779
|
-
import { dirname as
|
|
35339
|
+
import { dirname as dirname12, join as join27 } from "node:path";
|
|
35780
35340
|
|
|
35781
35341
|
// packages/core/src/sources.ts
|
|
35782
35342
|
var sources = {
|
|
@@ -35973,12 +35533,12 @@ function preparePublicGraph(store, ids, inputSettings) {
|
|
|
35973
35533
|
const stats = /* @__PURE__ */ new Map();
|
|
35974
35534
|
const count = store.db.prepare("SELECT count(*) AS count, count(*) FILTER (WHERE time IS NULL) AS untimed FROM timeline_items WHERE session_id=? AND kind='message' AND role IN ('user','assistant')");
|
|
35975
35535
|
const times = store.db.prepare("SELECT time FROM timeline_items WHERE session_id=? AND kind='message' AND role IN ('user','assistant') AND time IS NOT NULL ORDER BY time,ordinal LIMIT ?");
|
|
35976
|
-
const
|
|
35536
|
+
const metadata3 = store.db.prepare("SELECT metadata,partial FROM sessions LEFT JOIN timeline_coverage ON timeline_coverage.session_id=sessions.id WHERE sessions.id=?");
|
|
35977
35537
|
let remaining = PUBLIC_GRAPH_MAX_MESSAGE_TIMES;
|
|
35978
35538
|
store.db.exec("BEGIN");
|
|
35979
35539
|
try {
|
|
35980
35540
|
const sessions = ids.map((id2) => {
|
|
35981
|
-
const row =
|
|
35541
|
+
const row = metadata3.get(id2);
|
|
35982
35542
|
if (!row) throw new PublishingError("Your session selection changed. Reopen publishing.");
|
|
35983
35543
|
const session = JSON.parse(String(row.metadata));
|
|
35984
35544
|
if (settings.messageCounts) {
|
|
@@ -36006,7 +35566,7 @@ function preparePublicGraph(store, ids, inputSettings) {
|
|
|
36006
35566
|
}
|
|
36007
35567
|
}
|
|
36008
35568
|
var PublishingClient = class {
|
|
36009
|
-
constructor(credentialPath =
|
|
35569
|
+
constructor(credentialPath = join27(dirname12(databasePath()), "account.json"), fetcher = fetch) {
|
|
36010
35570
|
this.credentialPath = credentialPath;
|
|
36011
35571
|
this.fetcher = fetcher;
|
|
36012
35572
|
}
|
|
@@ -36035,7 +35595,7 @@ var PublishingClient = class {
|
|
|
36035
35595
|
}
|
|
36036
35596
|
}
|
|
36037
35597
|
async save(value) {
|
|
36038
|
-
await mkdir2(
|
|
35598
|
+
await mkdir2(dirname12(this.credentialPath), { recursive: true, mode: 448 });
|
|
36039
35599
|
const temporary = `${this.credentialPath}.${randomBytes(8).toString("hex")}`;
|
|
36040
35600
|
try {
|
|
36041
35601
|
await writeFile3(temporary, JSON.stringify(value), { mode: 384, flag: "wx" });
|
|
@@ -36130,7 +35690,7 @@ var PublishingClient = class {
|
|
|
36130
35690
|
// server/git-checkouts.ts
|
|
36131
35691
|
import { execFile as execFile2 } from "node:child_process";
|
|
36132
35692
|
import { createHash as createHash6 } from "node:crypto";
|
|
36133
|
-
import { basename as
|
|
35693
|
+
import { basename as basename13, isAbsolute as isAbsolute8 } from "node:path";
|
|
36134
35694
|
import { promisify as promisify2 } from "node:util";
|
|
36135
35695
|
var exec2 = promisify2(execFile2);
|
|
36136
35696
|
var cache = /* @__PURE__ */ new Map();
|
|
@@ -36171,7 +35731,7 @@ async function inspect(directory3) {
|
|
|
36171
35731
|
return {
|
|
36172
35732
|
worktree,
|
|
36173
35733
|
repository: createHash6("sha256").update(key).digest("hex"),
|
|
36174
|
-
repositoryLabel: remote?.label || (
|
|
35734
|
+
repositoryLabel: remote?.label || (basename13(common) === ".git" ? basename13(common.slice(0, -5)) : basename13(common))
|
|
36175
35735
|
};
|
|
36176
35736
|
} catch {
|
|
36177
35737
|
return;
|
|
@@ -36365,7 +35925,7 @@ var arg = (name) => {
|
|
|
36365
35925
|
const at2 = process.argv.indexOf(name);
|
|
36366
35926
|
return at2 >= 0 ? process.argv[at2 + 1] : void 0;
|
|
36367
35927
|
};
|
|
36368
|
-
var assets =
|
|
35928
|
+
var assets = resolve4(arg("--assets") || fileURLToPath5(new URL("../dist", import.meta.url)));
|
|
36369
35929
|
var token2 = randomBytes2(32).toString("hex");
|
|
36370
35930
|
var ipc = process.argv.includes("--desktop") ? " ipc: http://ipc.localhost" : "";
|
|
36371
35931
|
var equals = (value) => /^[a-f0-9]{64}$/.test(value) && timingSafeEqual(Buffer.from(value), Buffer.from(token2));
|
|
@@ -36401,7 +35961,7 @@ var server = createServer(async (req, res) => {
|
|
|
36401
35961
|
res.end();
|
|
36402
35962
|
return;
|
|
36403
35963
|
}
|
|
36404
|
-
const path =
|
|
35964
|
+
const path = resolve4(assets, "." + decodeURIComponent(url.pathname === "/" ? "/index.html" : url.pathname));
|
|
36405
35965
|
if (!path.startsWith(assets + sep4)) {
|
|
36406
35966
|
res.writeHead(403);
|
|
36407
35967
|
res.end();
|