sessiongraph 1.0.13 → 1.0.15
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 +1 -1
- package/README.md +1 -1
- package/dist/assets/external-links-BmBkCsrt.js +1 -0
- package/dist/assets/index-B1kyvo41.js +175 -0
- package/dist/assets/index-BLM-0yG6.js +1 -0
- package/dist/assets/{index-CJb-F0VY.js → index-D4P4hbvc.js} +1 -1
- package/dist/assets/index-Du0_nVjH.css +1 -0
- package/dist/assets/{index-HzUuskn3.js → index-Kotmn42s.js} +1 -1
- package/dist/assets/publishing-CEvQPkO1.css +1 -0
- package/dist/assets/publishing-D9CqkbeB.js +23 -0
- package/dist/assets/scene-CTHyYtma.js +139 -0
- package/dist/assets/share-Cw1E-ED9.js +7 -0
- package/dist/index.html +2 -2
- package/dist/sources/NOTICE.txt +4 -4
- package/dist-server/cli.mjs +780 -449
- package/dist-server/server.mjs +643 -325
- package/docs/cli.md +16 -0
- package/docs/guide.md +16 -4
- package/docs/import-coverage.md +84 -2
- package/docs/session-artifacts-audit.md +176 -0
- package/package.json +7 -7
- package/dist/assets/external-links-BcKDmn29.js +0 -1
- package/dist/assets/index-CDA8pT1Q.js +0 -170
- package/dist/assets/index-DYhIhreE.js +0 -1
- package/dist/assets/index-cVgPCrFV.css +0 -1
- package/dist/assets/publishing-CpVLG7_B.js +0 -25
- package/dist/assets/publishing-VJhUmdPH.css +0 -1
- package/dist/assets/scene-BkoCsbA8.js +0 -139
- package/dist/assets/share-CS1dKayZ.js +0 -7
- package/dist/sources/hindsight.svg +0 -1
- package/dist/sources/lmstudio.svg +0 -1
- package/dist/sources/reasonix.svg +0 -1
- package/dist/sources/trae.svg +0 -1
- package/dist/sources/warp.svg +0 -1
package/dist-server/cli.mjs
CHANGED
|
@@ -80,13 +80,13 @@ var init_common = __esm({
|
|
|
80
80
|
"use strict";
|
|
81
81
|
digest = (value) => createHash("sha256").update(JSON.stringify(value)).digest("hex");
|
|
82
82
|
identity = (source, native) => `${source}:${native}`;
|
|
83
|
-
project = (source,
|
|
84
|
-
blankSession = (source, nativeID,
|
|
83
|
+
project = (source, directory3) => ({ id: identity(source, digest(directory3).slice(0, 24)), name: basename(directory3) || "Global", directory: directory3, worktrees: [] });
|
|
84
|
+
blankSession = (source, nativeID, directory3 = "") => ({
|
|
85
85
|
source,
|
|
86
86
|
nativeID,
|
|
87
87
|
id: identity(source, nativeID),
|
|
88
|
-
projectID: project(source,
|
|
89
|
-
directory:
|
|
88
|
+
projectID: project(source, directory3).id,
|
|
89
|
+
directory: directory3,
|
|
90
90
|
title: "Untitled session",
|
|
91
91
|
created: 0,
|
|
92
92
|
updated: 0,
|
|
@@ -151,9 +151,9 @@ function boundEventPayloads(message2, budget2) {
|
|
|
151
151
|
return [];
|
|
152
152
|
}
|
|
153
153
|
const bounded = { ...event };
|
|
154
|
-
for (const key of ["text", "input", "output", "name", "id", "nativeID", "nativeType", "callID", "parentID"]) {
|
|
154
|
+
for (const key of ["text", "input", "output", "name", "id", "nativeID", "nativeType", "callID", "parentID", "cwd"]) {
|
|
155
155
|
if (bounded[key] === void 0) continue;
|
|
156
|
-
const value = String(bounded[key]), size = key === "text" || key === "output" ? 64e3 : key === "input" ? 32e3 : 512;
|
|
156
|
+
const value = String(bounded[key]), size = key === "text" || key === "output" ? 64e3 : key === "input" ? 32e3 : key === "cwd" ? 4096 : 512;
|
|
157
157
|
bounded[key] = value.slice(0, Math.max(0, Math.min(remaining, size)));
|
|
158
158
|
remaining -= bounded[key].length;
|
|
159
159
|
if (bounded[key].length < value.length) {
|
|
@@ -201,7 +201,7 @@ function normalizedEvents(message2, sessionID) {
|
|
|
201
201
|
}
|
|
202
202
|
const files = message2.files.map((file, i) => eventFor(message2, `file:${i}`, "file_change", file.path, `${file.source} \xB7 ${file.steps} recorded step(s)`, { nativeType: file.source }));
|
|
203
203
|
return [...events, ...files].slice(0, 200).map((event) => {
|
|
204
|
-
const text3 = String(event.text || "").slice(0, 64e3), input = event.input?.slice(0, 32e3),
|
|
204
|
+
const text3 = String(event.text || "").slice(0, 64e3), input = event.input?.slice(0, 32e3), output2 = event.output?.slice(0, 64e3);
|
|
205
205
|
const time3 = messageTime(event.time || 0);
|
|
206
206
|
return {
|
|
207
207
|
...event,
|
|
@@ -218,8 +218,8 @@ function normalizedEvents(message2, sessionID) {
|
|
|
218
218
|
timeSource: time3 ? event.timeSource : "unknown",
|
|
219
219
|
text: text3,
|
|
220
220
|
input,
|
|
221
|
-
output,
|
|
222
|
-
partial: Boolean(event.partial || message2.partial || text3.length < (event.text?.length || 0) || input?.length !== event.input?.length ||
|
|
221
|
+
output: output2,
|
|
222
|
+
partial: Boolean(event.partial || message2.partial || text3.length < (event.text?.length || 0) || input?.length !== event.input?.length || output2?.length !== event.output?.length || events.length + files.length > 200)
|
|
223
223
|
};
|
|
224
224
|
});
|
|
225
225
|
}
|
|
@@ -231,6 +231,167 @@ var init_events = __esm({
|
|
|
231
231
|
}
|
|
232
232
|
});
|
|
233
233
|
|
|
234
|
+
// server/commit-extraction.ts
|
|
235
|
+
import { posix, win32 } from "node:path";
|
|
236
|
+
function executionFields(input, metadata2 = {}) {
|
|
237
|
+
const args = object(input), meta = object(metadata2);
|
|
238
|
+
return { cwd: string(args.workdir ?? args.cwd ?? args.working_directory ?? meta.cwd), exitCode: exitCode(meta.exitCode ?? meta.exit_code ?? meta.exit) };
|
|
239
|
+
}
|
|
240
|
+
function nativeCommit(value) {
|
|
241
|
+
const v3 = object(value), operation2 = v3.kind === "committed" ? "created" : v3.kind === "amended" ? "amended" : v3.kind === "cherry-picked" ? "cherry-picked" : void 0;
|
|
242
|
+
return operation2 && typeof v3.sha === "string" && /^(?:[a-f0-9]{40}|[a-f0-9]{64})$/i.test(v3.sha) ? { sha: v3.sha.toLowerCase(), operation: operation2 } : void 0;
|
|
243
|
+
}
|
|
244
|
+
function json(value) {
|
|
245
|
+
try {
|
|
246
|
+
return JSON.parse(value);
|
|
247
|
+
} catch {
|
|
248
|
+
return value;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
function absolute(path) {
|
|
252
|
+
if (!path || /[\0\r\n]/.test(path)) return;
|
|
253
|
+
return posix.isAbsolute(path) ? posix : win32.isAbsolute(path) && /^[a-z]:[\\/]/i.test(path) ? win32 : void 0;
|
|
254
|
+
}
|
|
255
|
+
function directory(path, base) {
|
|
256
|
+
if (!path || /[\0\r\n$`~]/.test(path)) return;
|
|
257
|
+
const flavor = absolute(path) || absolute(base);
|
|
258
|
+
return flavor ? flavor.resolve(base || path, path) : void 0;
|
|
259
|
+
}
|
|
260
|
+
function commands(command) {
|
|
261
|
+
const result = [], words2 = [];
|
|
262
|
+
let word = "", active = false, quote = "";
|
|
263
|
+
const flush = () => {
|
|
264
|
+
if (active) words2.push(word);
|
|
265
|
+
word = "";
|
|
266
|
+
active = false;
|
|
267
|
+
};
|
|
268
|
+
for (let i = 0; i < command.length; i++) {
|
|
269
|
+
const c = command[i];
|
|
270
|
+
if (quote) {
|
|
271
|
+
if (c === quote) {
|
|
272
|
+
quote = "";
|
|
273
|
+
continue;
|
|
274
|
+
}
|
|
275
|
+
if (quote === '"' && /[$`\\]/.test(c)) return;
|
|
276
|
+
word += c;
|
|
277
|
+
continue;
|
|
278
|
+
}
|
|
279
|
+
if (c === '"' || c === "'") {
|
|
280
|
+
quote = c;
|
|
281
|
+
active = true;
|
|
282
|
+
continue;
|
|
283
|
+
}
|
|
284
|
+
if (/[|<>$`(){}\\#\0;\n\r*?\[\]]/.test(c)) return;
|
|
285
|
+
if (c === "&" && command[i + 1] !== "&") return;
|
|
286
|
+
if (c === "&") {
|
|
287
|
+
flush();
|
|
288
|
+
if (!words2.length) return;
|
|
289
|
+
result.push(words2.splice(0));
|
|
290
|
+
i++;
|
|
291
|
+
} else if (/\s/.test(c)) flush();
|
|
292
|
+
else {
|
|
293
|
+
word += c;
|
|
294
|
+
active = true;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
if (quote) return;
|
|
298
|
+
flush();
|
|
299
|
+
if (!words2.length && result.length) return;
|
|
300
|
+
if (words2.length) result.push(words2);
|
|
301
|
+
return result;
|
|
302
|
+
}
|
|
303
|
+
function invocation(input, cwd2) {
|
|
304
|
+
const value = json(input || ""), args = object(value);
|
|
305
|
+
const command = typeof value === "string" ? value : string(args.command ?? args.cmd);
|
|
306
|
+
const explicit = string(args.workdir ?? args.cwd ?? args.working_directory);
|
|
307
|
+
return { command, cwd: explicit !== void 0 ? directory(explicit) : directory(cwd2) };
|
|
308
|
+
}
|
|
309
|
+
function operation(words2) {
|
|
310
|
+
const [verb, ...args] = words2;
|
|
311
|
+
if (verb === "commit") {
|
|
312
|
+
let amend = false;
|
|
313
|
+
for (let i = 0; i < args.length; i++) {
|
|
314
|
+
const arg = args[i];
|
|
315
|
+
if (["-m", "--message", "-F", "--file", "--author", "--date", "--fixup", "--squash", "-C", "--reuse-message", "-c", "--reedit-message"].includes(arg)) {
|
|
316
|
+
if (++i >= args.length) return;
|
|
317
|
+
continue;
|
|
318
|
+
}
|
|
319
|
+
if (/^--(?:message|file|author|date|fixup|squash|reuse-message|reedit-message)=/.test(arg) || /^-m.+/.test(arg)) continue;
|
|
320
|
+
if (arg === "--amend") {
|
|
321
|
+
amend = true;
|
|
322
|
+
continue;
|
|
323
|
+
}
|
|
324
|
+
if (["-a", "--all", "--no-edit", "--allow-empty", "--allow-empty-message", "-n", "--no-verify", "-s", "--signoff", "-q", "--quiet", "--no-gpg-sign", "--gpg-sign", "-S"].includes(arg)) continue;
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
return amend ? "amended" : "created";
|
|
328
|
+
}
|
|
329
|
+
if (verb === "cherry-pick" && args.length && args.every((arg) => /^(?:[a-f0-9]{7,64}|-x|--continue)$/i.test(arg))) return "cherry-picked";
|
|
330
|
+
}
|
|
331
|
+
function plan(command, cwd2) {
|
|
332
|
+
const parts = commands(command);
|
|
333
|
+
if (!parts?.length) return;
|
|
334
|
+
let found;
|
|
335
|
+
for (const part of parts) {
|
|
336
|
+
const [program, ...args] = part;
|
|
337
|
+
if (program === "cd" && args.length === 1 && !/^[+-]/.test(args[0]) && !found) {
|
|
338
|
+
cwd2 = directory(args[0], cwd2);
|
|
339
|
+
if (!cwd2) return;
|
|
340
|
+
continue;
|
|
341
|
+
}
|
|
342
|
+
if (program !== "git") return;
|
|
343
|
+
let path = cwd2;
|
|
344
|
+
while (args[0] === "-C") {
|
|
345
|
+
args.shift();
|
|
346
|
+
path = directory(args.shift(), path);
|
|
347
|
+
if (!path) return;
|
|
348
|
+
}
|
|
349
|
+
const op = operation(args);
|
|
350
|
+
if (op) {
|
|
351
|
+
if (found || !path) return;
|
|
352
|
+
found = { operation: op, repositoryPath: path, trailing: false };
|
|
353
|
+
} else if (!["add", "push"].includes(args[0]) || args.some((arg) => /^(?:--exec-path|--git-dir|--work-tree|--config-env)/.test(arg))) return;
|
|
354
|
+
else if (found) found.trailing = true;
|
|
355
|
+
}
|
|
356
|
+
return found;
|
|
357
|
+
}
|
|
358
|
+
function output(value) {
|
|
359
|
+
const parsed = json(value || "");
|
|
360
|
+
if (typeof parsed === "string") {
|
|
361
|
+
const code = parsed.match(/(?:^|\n)Process exited with code (-?\d+)\r?\n/);
|
|
362
|
+
return { text: parsed, code: code ? Number(code[1]) : void 0 };
|
|
363
|
+
}
|
|
364
|
+
if (Array.isArray(parsed)) return { text: parsed.filter((p) => p?.type === "text" && typeof p.text === "string").map((p) => p.text).join("\n") };
|
|
365
|
+
const obj = object(parsed);
|
|
366
|
+
return { text: string(obj.stdout) ?? string(obj.output) ?? "", code: exitCode(obj.exit_code ?? obj.exitCode ?? obj.metadata?.exit_code) };
|
|
367
|
+
}
|
|
368
|
+
function extractCommit(call, result) {
|
|
369
|
+
const shell = /^(?:shell|bash|exec_command|shell_command|run_shell_command|terminal|command execution)$/i.test(call.name) || call.nativeType === "command_execution";
|
|
370
|
+
const input = invocation(call.input, call.cwd ?? result.cwd);
|
|
371
|
+
const candidate = Boolean(result.gitCommit || shell && /\bgit\b[\s\S]*\b(?:commit|cherry-pick)\b/.test(input.command || ""));
|
|
372
|
+
if (!candidate) return { candidate: false };
|
|
373
|
+
if (call.partial || result.partial || !input.command || !shell || ["running", "pending"].includes(result.status || "")) return { candidate };
|
|
374
|
+
const parsed = plan(input.command, input.cwd);
|
|
375
|
+
if (!parsed) return { candidate };
|
|
376
|
+
const recorded = output(result.output), code = result.exitCode ?? recorded.code;
|
|
377
|
+
if (code !== void 0 && code !== 0 && !parsed.trailing || result.status === "failed" && !parsed.trailing) return { candidate };
|
|
378
|
+
const summary = [...recorded.text.matchAll(/^\[(?:[^\]\r\n]+ )([a-f0-9]{7,64})\] [^\r\n]*$/gmi)];
|
|
379
|
+
const native = result.gitCommit;
|
|
380
|
+
if (native && native.operation !== parsed.operation) return { candidate };
|
|
381
|
+
const sha = native && native.operation === parsed.operation ? native.sha : summary.length === 1 && (code !== void 0 || ["completed", "failed"].includes(result.status || "")) ? summary[0][1].toLowerCase() : void 0;
|
|
382
|
+
return { candidate, commit: sha ? { sha, repositoryPath: parsed.repositoryPath, operation: parsed.operation } : void 0 };
|
|
383
|
+
}
|
|
384
|
+
var COMMIT_EXTRACTOR_VERSION, object, string, exitCode;
|
|
385
|
+
var init_commit_extraction = __esm({
|
|
386
|
+
"server/commit-extraction.ts"() {
|
|
387
|
+
"use strict";
|
|
388
|
+
COMMIT_EXTRACTOR_VERSION = 1;
|
|
389
|
+
object = (v3) => v3 && typeof v3 === "object" && !Array.isArray(v3) ? v3 : {};
|
|
390
|
+
string = (v3) => typeof v3 === "string" ? v3 : void 0;
|
|
391
|
+
exitCode = (v3) => typeof v3 === "number" && Number.isSafeInteger(v3) ? v3 : void 0;
|
|
392
|
+
}
|
|
393
|
+
});
|
|
394
|
+
|
|
234
395
|
// server/source-paths.ts
|
|
235
396
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
236
397
|
function withSourcePaths(adapter, configured) {
|
|
@@ -735,7 +896,7 @@ function make6(options) {
|
|
|
735
896
|
};
|
|
736
897
|
const responseError = async (response, descriptor) => {
|
|
737
898
|
if (descriptor.declaredStatuses.includes(response.status))
|
|
738
|
-
throw declared(await
|
|
899
|
+
throw declared(await json2(response));
|
|
739
900
|
try {
|
|
740
901
|
await response.body?.cancel();
|
|
741
902
|
} catch {
|
|
@@ -755,7 +916,7 @@ function make6(options) {
|
|
|
755
916
|
}
|
|
756
917
|
return;
|
|
757
918
|
}
|
|
758
|
-
return await
|
|
919
|
+
return await json2(response);
|
|
759
920
|
};
|
|
760
921
|
const sse2 = (descriptor, requestOptions) => ({
|
|
761
922
|
async *[Symbol.asyncIterator]() {
|
|
@@ -2378,7 +2539,7 @@ function appendQuery(params, key, value) {
|
|
|
2378
2539
|
}
|
|
2379
2540
|
params.append(key, String(value));
|
|
2380
2541
|
}
|
|
2381
|
-
async function
|
|
2542
|
+
async function json2(response) {
|
|
2382
2543
|
if (!isContentType(response, "application/json") && !response.headers.get("content-type")?.includes("+json")) {
|
|
2383
2544
|
try {
|
|
2384
2545
|
await response.body?.cancel();
|
|
@@ -2906,7 +3067,7 @@ var init_service = __esm({
|
|
|
2906
3067
|
}
|
|
2907
3068
|
});
|
|
2908
3069
|
|
|
2909
|
-
// src/playback-tokens.ts
|
|
3070
|
+
// packages/core/src/playback-tokens.ts
|
|
2910
3071
|
function sumRecordedTokens(values) {
|
|
2911
3072
|
if (!values.length || !values.every(validTokenCount)) return null;
|
|
2912
3073
|
const total = values.reduce((sum, value) => sum + value, 0);
|
|
@@ -2914,12 +3075,20 @@ function sumRecordedTokens(values) {
|
|
|
2914
3075
|
}
|
|
2915
3076
|
var validTokenCount;
|
|
2916
3077
|
var init_playback_tokens = __esm({
|
|
2917
|
-
"src/playback-tokens.ts"() {
|
|
3078
|
+
"packages/core/src/playback-tokens.ts"() {
|
|
2918
3079
|
"use strict";
|
|
2919
3080
|
validTokenCount = (value) => typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
|
|
2920
3081
|
}
|
|
2921
3082
|
});
|
|
2922
3083
|
|
|
3084
|
+
// src/playback-tokens.ts
|
|
3085
|
+
var init_playback_tokens2 = __esm({
|
|
3086
|
+
"src/playback-tokens.ts"() {
|
|
3087
|
+
"use strict";
|
|
3088
|
+
init_playback_tokens();
|
|
3089
|
+
}
|
|
3090
|
+
});
|
|
3091
|
+
|
|
2923
3092
|
// server/opencode.ts
|
|
2924
3093
|
import { basename as basename2 } from "node:path";
|
|
2925
3094
|
import { createHash as createHash3 } from "node:crypto";
|
|
@@ -3058,7 +3227,7 @@ var init_opencode = __esm({
|
|
|
3058
3227
|
"use strict";
|
|
3059
3228
|
init_service();
|
|
3060
3229
|
init_config();
|
|
3061
|
-
|
|
3230
|
+
init_playback_tokens2();
|
|
3062
3231
|
}
|
|
3063
3232
|
});
|
|
3064
3233
|
|
|
@@ -3162,7 +3331,7 @@ function opencodeEvents(raw, message2) {
|
|
|
3162
3331
|
else if (part.type === "tool") {
|
|
3163
3332
|
const state2 = part.state || {}, endTime = messageTime(part.time?.completed);
|
|
3164
3333
|
const status2 = state2.status === "error" ? "failed" : state2.status === "streaming" ? "pending" : ["running", "completed"].includes(state2.status) ? state2.status : "unknown";
|
|
3165
|
-
const common = { ...native, callID: part.id, status: status2, endTime };
|
|
3334
|
+
const common = { ...native, callID: part.id, status: status2, endTime, ...executionFields(state2.input, state2.metadata), partial: Boolean(state2.metadata?.truncated) };
|
|
3166
3335
|
events.push(eventFor(message2, `${id2}:call`, "tool_call", part.name || "Tool call", "", { ...common, ...timing, input: eventText(state2.input) }));
|
|
3167
3336
|
if (["completed", "error"].includes(state2.status)) events.push(eventFor(message2, `${id2}:result`, "tool_result", part.name || "Tool result", "", { ...common, role: "tool", ...endTime ? { time: endTime, timeSource: "recorded" } : {}, output: eventText(state2.error ?? state2.content, 64e3) }));
|
|
3168
3337
|
} else events.push(eventFor(message2, id2, "event", `${part.type || "Unknown"} content`, "Unsupported content.", { ...native, ...timing, partial: true }));
|
|
@@ -3177,6 +3346,7 @@ var init_opencode_events = __esm({
|
|
|
3177
3346
|
"use strict";
|
|
3178
3347
|
init_events();
|
|
3179
3348
|
init_activity();
|
|
3349
|
+
init_commit_extraction();
|
|
3180
3350
|
}
|
|
3181
3351
|
});
|
|
3182
3352
|
|
|
@@ -3207,7 +3377,7 @@ var init_opencode2 = __esm({
|
|
|
3207
3377
|
return {
|
|
3208
3378
|
projects: data.projects.map((p) => ({ ...p, id: identity("opencode", p.id) })),
|
|
3209
3379
|
warnings: data.warnings,
|
|
3210
|
-
sessions: data.sessions.map((s) => ({ locator: {}, revision: digest([
|
|
3380
|
+
sessions: data.sessions.map((s) => ({ locator: {}, revision: digest([4, s.updated, s.created, s.directory]), session: {
|
|
3211
3381
|
...s,
|
|
3212
3382
|
source: "opencode",
|
|
3213
3383
|
nativeID: s.id,
|
|
@@ -30524,7 +30694,7 @@ async function metadataState(path) {
|
|
|
30524
30694
|
}
|
|
30525
30695
|
}
|
|
30526
30696
|
async function claudeRevision(path) {
|
|
30527
|
-
return digest([
|
|
30697
|
+
return digest([7, (await state(path)).signature, (await metadataState(path))?.signature]);
|
|
30528
30698
|
}
|
|
30529
30699
|
async function bytes(path, max) {
|
|
30530
30700
|
const before = await state(path);
|
|
@@ -30578,7 +30748,8 @@ async function claudeTranscript(path, revision2) {
|
|
|
30578
30748
|
}
|
|
30579
30749
|
}
|
|
30580
30750
|
if (await claudeRevision(path) !== revision2) throw new Error("Claude transcript changed during import; import again.");
|
|
30581
|
-
const
|
|
30751
|
+
const byID = new Map(entries2.filter((row) => typeof row.uuid === "string").map((row) => [String(row.uuid), row]));
|
|
30752
|
+
const { size, modified } = await state(path), transcript = { entries: entries2, times, byID, partial, size, modified };
|
|
30582
30753
|
cached = { path, revision: revision2, transcript };
|
|
30583
30754
|
return transcript;
|
|
30584
30755
|
}
|
|
@@ -30683,7 +30854,7 @@ async function historyFiles(roots2, match2) {
|
|
|
30683
30854
|
if (limited) warnings.push("History discovery reached its file, directory, or depth limit.");
|
|
30684
30855
|
return { files: [...new Set(files)].sort(), warnings };
|
|
30685
30856
|
}
|
|
30686
|
-
function
|
|
30857
|
+
function json3(value) {
|
|
30687
30858
|
return JSON.parse(value);
|
|
30688
30859
|
}
|
|
30689
30860
|
function jsonLines(value) {
|
|
@@ -30694,7 +30865,7 @@ function jsonLines(value) {
|
|
|
30694
30865
|
if (rows2.length >= MAX_RECORDS) throw new Error("History exceeds the 50,000-record limit.");
|
|
30695
30866
|
if (line.length > 2e6) throw new Error("History contains a record larger than 2 MB.");
|
|
30696
30867
|
try {
|
|
30697
|
-
const row =
|
|
30868
|
+
const row = json3(line);
|
|
30698
30869
|
if (!row || typeof row !== "object" || Array.isArray(row)) partial = true;
|
|
30699
30870
|
else rows2.push(row);
|
|
30700
30871
|
} catch {
|
|
@@ -30762,7 +30933,11 @@ function localFileAdapter(source) {
|
|
|
30762
30933
|
let candidate = metadata2.get(path);
|
|
30763
30934
|
if (!candidate || candidate.revision !== rev) {
|
|
30764
30935
|
const history = await load(path, rev, before);
|
|
30765
|
-
if (!history)
|
|
30936
|
+
if (!history) {
|
|
30937
|
+
const nativeID = source.authoritativeIdentity?.(path);
|
|
30938
|
+
if (nativeID) blocked.add(identity(source.id, nativeID));
|
|
30939
|
+
continue;
|
|
30940
|
+
}
|
|
30766
30941
|
const session = { ...blankSession(source.id, history.nativeID), ...history.session };
|
|
30767
30942
|
session.id = identity(source.id, history.nativeID);
|
|
30768
30943
|
session.nativeID = history.nativeID;
|
|
@@ -30812,13 +30987,13 @@ function localFileAdapter(source) {
|
|
|
30812
30987
|
}
|
|
30813
30988
|
};
|
|
30814
30989
|
}
|
|
30815
|
-
var
|
|
30990
|
+
var object2, text2, time, MAX_BYTES2, MAX_RECORDS, MAX_FILES;
|
|
30816
30991
|
var init_local_files = __esm({
|
|
30817
30992
|
"server/adapters/local-files.ts"() {
|
|
30818
30993
|
"use strict";
|
|
30819
30994
|
init_common();
|
|
30820
30995
|
init_compressed();
|
|
30821
|
-
|
|
30996
|
+
object2 = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
30822
30997
|
text2 = (value) => typeof value === "string" ? value : "";
|
|
30823
30998
|
time = (value) => {
|
|
30824
30999
|
const n = typeof value === "number" ? value : typeof value === "string" ? /^\d{13}$/.test(value) ? Number(value) : Date.parse(value) : 0;
|
|
@@ -30836,7 +31011,7 @@ function conversationMessage(raw, fallbackID) {
|
|
|
30836
31011
|
const message2 = blankMessage(text2(raw.id) || fallbackID, time(raw.timestamp ?? raw.ts), role);
|
|
30837
31012
|
let content = raw.content;
|
|
30838
31013
|
if (Array.isArray(content)) content = content.map((part) => {
|
|
30839
|
-
const p =
|
|
31014
|
+
const p = object2(part);
|
|
30840
31015
|
return p.type === "toolCall" ? { ...p, type: "tool_use", input: p.arguments } : p.type === "reasoning" ? { ...p, type: "thinking", thinking: p.text } : p;
|
|
30841
31016
|
});
|
|
30842
31017
|
if (raw.role === "thinking") content = [{ type: "thinking", thinking: raw.content }];
|
|
@@ -30857,7 +31032,7 @@ function conversationMessage(raw, fallbackID) {
|
|
|
30857
31032
|
else if (event.kind === "reasoning") addText(message2, event.text, "Assistant");
|
|
30858
31033
|
}
|
|
30859
31034
|
for (const call of Array.isArray(raw.toolCalls) ? raw.toolCalls : []) {
|
|
30860
|
-
const f =
|
|
31035
|
+
const f = object2(call.function);
|
|
30861
31036
|
if (!text2(f.name)) continue;
|
|
30862
31037
|
message2.tools.push(f.name);
|
|
30863
31038
|
message2.events.push(eventFor(message2, `call:${text2(call.id) || message2.events.length}`, "tool_call", f.name, "", { callID: text2(call.id) || void 0, input: eventText(f.arguments), status: "unknown" }));
|
|
@@ -30871,7 +31046,7 @@ function googleMessage(raw, fallbackID) {
|
|
|
30871
31046
|
const parts = Array.isArray(raw.content) ? raw.content : raw.content != null ? [raw.content] : [];
|
|
30872
31047
|
const content = parts.map((part) => {
|
|
30873
31048
|
if (typeof part === "string") return { type: "text", text: part };
|
|
30874
|
-
const p =
|
|
31049
|
+
const p = object2(part);
|
|
30875
31050
|
if (typeof p.text === "string") return p.thought ? { type: "thinking", thinking: p.text } : { type: "text", text: p.text };
|
|
30876
31051
|
if (p.functionCall) return { type: "tool_use", ...p.functionCall, input: p.functionCall.args };
|
|
30877
31052
|
if (p.functionResponse) return { type: "tool_result", tool_use_id: p.functionResponse.id || raw.toolCallId, name: p.functionResponse.name, content: p.functionResponse.response, is_error: p.functionResponse.response?.error != null };
|
|
@@ -30885,7 +31060,7 @@ function successfulEdits(messages, editNames) {
|
|
|
30885
31060
|
if (event.kind === "tool_call" && event.callID) {
|
|
30886
31061
|
let input = {};
|
|
30887
31062
|
try {
|
|
30888
|
-
input =
|
|
31063
|
+
input = object2(JSON.parse(event.input || "{}"));
|
|
30889
31064
|
} catch {
|
|
30890
31065
|
}
|
|
30891
31066
|
calls.set(event.callID, { name: event.name, input });
|
|
@@ -30988,7 +31163,7 @@ function envelopeHistory(path, value) {
|
|
|
30988
31163
|
const header = rows2.find((r) => r.type === "session" || r.type === "session_start" || r.type === "session_startup") || {};
|
|
30989
31164
|
const nativeID = [...nativeIDs][0] || text2(header.id || header.sessionId) || fileID(path);
|
|
30990
31165
|
const messages = rows2.flatMap((r, i) => {
|
|
30991
|
-
const body =
|
|
31166
|
+
const body = object2(r.message), role = body.role || r.role || (["user", "assistant", "system"].includes(r.type) ? r.type : void 0);
|
|
30992
31167
|
const m = message({ ...body, id: text2(r.uuid || r.id) || body.id, role, content: body.content ?? r.content ?? r.text }, `record:${i}`, r.timestamp ?? body.timestamp);
|
|
30993
31168
|
return m ? [m] : [];
|
|
30994
31169
|
});
|
|
@@ -31004,7 +31179,7 @@ function envelopeHistory(path, value) {
|
|
|
31004
31179
|
};
|
|
31005
31180
|
}
|
|
31006
31181
|
function ampHistory(path, files) {
|
|
31007
|
-
const raw =
|
|
31182
|
+
const raw = object2(json3(files.get(path)));
|
|
31008
31183
|
if (!text2(raw.id) || !Array.isArray(raw.messages)) throw new Error("Unsupported Amp thread.");
|
|
31009
31184
|
const messages = raw.messages.flatMap((m, i) => {
|
|
31010
31185
|
const result = message(m, nativeText(m.messageId) || `message:${i}`, m.timestamp ?? m.usage?.timestamp);
|
|
@@ -31013,14 +31188,14 @@ function ampHistory(path, files) {
|
|
|
31013
31188
|
return { nativeID: raw.id, messages, partial: true, session: { created: time(raw.created), title: text2(raw.title), directory: text2(raw.cwd) }, note: "Amp local/exported thread messages. Usage-ledger ranges are not message timestamps. Export-only and missing content remain partial." };
|
|
31014
31189
|
}
|
|
31015
31190
|
function jcodeHistory(path, files) {
|
|
31016
|
-
const raw =
|
|
31191
|
+
const raw = object2(json3(files.get(path)));
|
|
31017
31192
|
if (!text2(raw.id) || !Array.isArray(raw.messages)) throw new Error("Unsupported Jcode session.");
|
|
31018
31193
|
const journal = path.replace(/\.json$/, ".journal.jsonl");
|
|
31019
31194
|
const appended = files.has(journal) ? jsonLines(files.get(journal)) : { rows: [], partial: false };
|
|
31020
31195
|
const records = [...raw.messages];
|
|
31021
31196
|
for (const row of appended.rows) {
|
|
31022
31197
|
if (Array.isArray(row.append_messages)) records.push(...row.append_messages);
|
|
31023
|
-
if (row.meta) Object.assign(raw,
|
|
31198
|
+
if (row.meta) Object.assign(raw, object2(row.meta));
|
|
31024
31199
|
}
|
|
31025
31200
|
const seen = /* @__PURE__ */ new Set();
|
|
31026
31201
|
const messages = records.flatMap((r, i) => {
|
|
@@ -31033,7 +31208,7 @@ function jcodeHistory(path, files) {
|
|
|
31033
31208
|
return { nativeID: raw.id, messages, partial: appended.partial, session: { title: text2(raw.title), directory: text2(raw.working_dir), created: time(raw.created_at), model: text2(raw.model) || "Unknown model", provider: text2(raw.provider_key) }, note: "Jcode session snapshot and append journal; replayed native message IDs count once. Absent message times remain unknown." };
|
|
31034
31209
|
}
|
|
31035
31210
|
function codebuffHistory(path, files, free) {
|
|
31036
|
-
const records =
|
|
31211
|
+
const records = json3(files.get(path));
|
|
31037
31212
|
if (!Array.isArray(records)) throw new Error("Unsupported Codebuff chat.");
|
|
31038
31213
|
const isFree = records.some((m) => text2(m.metadata?.runState?.sessionState?.mainAgentState?.agentType).startsWith("base2-free"));
|
|
31039
31214
|
if (isFree !== free) return;
|
|
@@ -31046,8 +31221,8 @@ function codebuffHistory(path, files, free) {
|
|
|
31046
31221
|
return { nativeID: `${project2}/${chat}`, messages, partial: true, note: "Codebuff/Freebuff persisted chat messages. Freebuff requires a recorded base2-free root-agent marker. Shared storage is attributed once; token counts are not estimated from text." };
|
|
31047
31222
|
}
|
|
31048
31223
|
function vibeHistory(path, files) {
|
|
31049
|
-
const raw =
|
|
31050
|
-
const meta = legacy ?
|
|
31224
|
+
const raw = object2(json3(files.get(path))), legacy = basename4(path) !== "meta.json";
|
|
31225
|
+
const meta = legacy ? object2(raw.metadata) : raw;
|
|
31051
31226
|
const transcript = join6(dirname3(path), "messages.jsonl");
|
|
31052
31227
|
const parsed = files.has(transcript) ? jsonLines(files.get(transcript)) : { rows: [], partial: false };
|
|
31053
31228
|
const records = legacy ? raw.messages : parsed.rows;
|
|
@@ -31074,7 +31249,7 @@ function acpHistory(path, value) {
|
|
|
31074
31249
|
}
|
|
31075
31250
|
};
|
|
31076
31251
|
for (const [i, row] of rows2.entries()) {
|
|
31077
|
-
const p =
|
|
31252
|
+
const p = object2(row.params), u2 = object2(p.update), kind = text2(u2.sessionUpdate);
|
|
31078
31253
|
if (text2(p.sessionId)) ids.add(p.sessionId);
|
|
31079
31254
|
const timestamp = time(p._meta?.agentTimestampMs) || time(row.timestamp);
|
|
31080
31255
|
const role = kind === "user_message_chunk" ? "user" : kind === "agent_message_chunk" ? "assistant" : "";
|
|
@@ -31100,7 +31275,7 @@ function dshHistory(value) {
|
|
|
31100
31275
|
if (!text2(header?.id)) throw new Error("Unsupported DeepSeek Harness session.");
|
|
31101
31276
|
const messages = rows2.flatMap((r, i) => {
|
|
31102
31277
|
if (!["user/message", "assistant/message", "tool/message"].includes(r.type)) return [];
|
|
31103
|
-
const body =
|
|
31278
|
+
const body = object2(r.data?.message);
|
|
31104
31279
|
const m = message({ ...body, role: body.role || r.type.split("/")[0] }, text2(body.id) || `record:${i}`, r.time);
|
|
31105
31280
|
return m ? [m] : [];
|
|
31106
31281
|
});
|
|
@@ -31118,7 +31293,7 @@ var init_harness_formats = __esm({
|
|
|
31118
31293
|
nativeText = (v3) => typeof v3 === "number" && Number.isSafeInteger(v3) ? String(v3) : text2(v3);
|
|
31119
31294
|
seconds = (v3) => typeof v3 === "number" && Number.isFinite(v3) && v3 > 0 ? v3 * 1e3 : time(v3);
|
|
31120
31295
|
fileID = (path) => basename4(path).replace(/\.jsonl(?:\..*)?$|\.json$/, "");
|
|
31121
|
-
sidecar2 = (files, path) =>
|
|
31296
|
+
sidecar2 = (files, path) => object2(files.has(path) ? json3(files.get(path)) : void 0);
|
|
31122
31297
|
roles = ["user", "assistant", "system", "tool", "toolResult", "model"];
|
|
31123
31298
|
}
|
|
31124
31299
|
});
|
|
@@ -31149,11 +31324,11 @@ function withSqliteSnapshot(path, read3, expected, pinned = false) {
|
|
|
31149
31324
|
if (copy?.revision !== revision2) {
|
|
31150
31325
|
close(path);
|
|
31151
31326
|
while (copies.size >= 2) close(copies.keys().next().value);
|
|
31152
|
-
const
|
|
31327
|
+
const directory3 = mkdtempSync(join7(tmpdir(), "sessiongraph-history-"));
|
|
31153
31328
|
let db2;
|
|
31154
31329
|
try {
|
|
31155
|
-
chmodSync2(
|
|
31156
|
-
const destination = join7(
|
|
31330
|
+
chmodSync2(directory3, 448);
|
|
31331
|
+
const destination = join7(directory3, "history.db");
|
|
31157
31332
|
for (const suffix of ["", "-wal"]) {
|
|
31158
31333
|
try {
|
|
31159
31334
|
copyFileSync(path + suffix, destination + suffix, constants4.COPYFILE_FICLONE);
|
|
@@ -31166,13 +31341,13 @@ function withSqliteSnapshot(path, read3, expected, pinned = false) {
|
|
|
31166
31341
|
if (sqliteRevision(path) !== revision2) throw new SqliteSnapshotChangedError("History database changed while copying; import again.");
|
|
31167
31342
|
db2 = new DatabaseSync2(destination, { readOnly: true, enableDoubleQuotedStringLiterals: false, allowExtension: false });
|
|
31168
31343
|
db2.exec("PRAGMA query_only=ON; PRAGMA trusted_schema=OFF; PRAGMA busy_timeout=1000; BEGIN;");
|
|
31169
|
-
copy = { revision: revision2, directory:
|
|
31344
|
+
copy = { revision: revision2, directory: directory3, db: db2 };
|
|
31170
31345
|
copies.set(path, copy);
|
|
31171
31346
|
} catch (error) {
|
|
31172
31347
|
try {
|
|
31173
31348
|
db2?.close();
|
|
31174
31349
|
} finally {
|
|
31175
|
-
rmSync2(
|
|
31350
|
+
rmSync2(directory3, { recursive: true, force: true });
|
|
31176
31351
|
}
|
|
31177
31352
|
throw error;
|
|
31178
31353
|
}
|
|
@@ -31416,7 +31591,7 @@ var init_sqlite_histories = __esm({
|
|
|
31416
31591
|
import { readdir as readdir2, stat } from "node:fs/promises";
|
|
31417
31592
|
import { homedir as homedir5 } from "node:os";
|
|
31418
31593
|
import { join as join8 } from "node:path";
|
|
31419
|
-
function claudeMessages(rows2, candidate, times) {
|
|
31594
|
+
function claudeMessages(rows2, candidate, times, entries2) {
|
|
31420
31595
|
const calls = /* @__PURE__ */ new Map();
|
|
31421
31596
|
return rows2.map((row) => {
|
|
31422
31597
|
const raw = row.message;
|
|
@@ -31441,7 +31616,18 @@ function claudeMessages(rows2, candidate, times) {
|
|
|
31441
31616
|
}
|
|
31442
31617
|
}
|
|
31443
31618
|
}
|
|
31444
|
-
|
|
31619
|
+
const entry = entries2?.get(row.uuid), structured = entry?.tool_use_result ?? entry?.toolUseResult;
|
|
31620
|
+
const results = Array.isArray(raw?.content) ? raw.content.filter((p) => p.type === "tool_result") : [];
|
|
31621
|
+
msg.events = blockEvents(msg, raw?.content).map((event) => {
|
|
31622
|
+
const result = event.kind === "tool_result" && results.length === 1 ? structured : void 0;
|
|
31623
|
+
return {
|
|
31624
|
+
...event,
|
|
31625
|
+
parentID: row.parent_tool_use_id || void 0,
|
|
31626
|
+
...executionFields({}, { ...result, cwd: entry?.cwd }),
|
|
31627
|
+
gitCommit: nativeCommit(result?.gitOperation?.commit),
|
|
31628
|
+
partial: Boolean(event.partial || result?.interrupted || result?.backgroundTaskId || result?.backgroundedByUser || result?.timedOutAfterMs || entry?.sessionId && entry.sessionId !== (candidate.locator.parent || candidate.session.nativeID))
|
|
31629
|
+
};
|
|
31630
|
+
});
|
|
31445
31631
|
if (!msg.events.length) msg.events = [eventFor(msg, "event", raw?.subtype === "compact_boundary" ? "compaction" : "event", raw?.subtype || `${row.type} event`, eventText(raw), { nativeType: raw?.subtype || row.type, partial: true })];
|
|
31446
31632
|
return msg;
|
|
31447
31633
|
});
|
|
@@ -31458,6 +31644,7 @@ var init_claude = __esm({
|
|
|
31458
31644
|
init_harness_formats();
|
|
31459
31645
|
init_sqlite_histories();
|
|
31460
31646
|
init_source_paths();
|
|
31647
|
+
init_commit_extraction();
|
|
31461
31648
|
root = () => join8(sourcePath("claude-code") || process.env.CLAUDE_CONFIG_DIR || join8(homedir5(), ".claude"), "projects");
|
|
31462
31649
|
sdkClaudeAdapter = {
|
|
31463
31650
|
id: "claude-code",
|
|
@@ -31555,7 +31742,7 @@ var init_claude = __esm({
|
|
|
31555
31742
|
const options = { dir: candidate.locator.dir || void 0, offset: start, limit: count + 1, sessionStore: claudeTranscriptStore(transcript, sessionId, candidate.locator.agent) };
|
|
31556
31743
|
const rows2 = candidate.locator.parent ? await U1t(candidate.locator.parent, candidate.locator.agent, options) : await P1t(candidate.session.nativeID, options);
|
|
31557
31744
|
const more = rows2.length > count;
|
|
31558
|
-
const messages = claudeMessages(rows2.slice(0, count), candidate, transcript.times).slice(offset - start);
|
|
31745
|
+
const messages = claudeMessages(rows2.slice(0, count), candidate, transcript.times, transcript.byID).slice(offset - start);
|
|
31559
31746
|
if (!offset && !messages.length && transcript.size > 100) throw new Error("SDK returned no readable conversation for this transcript.");
|
|
31560
31747
|
if (!more && await claudeRevision(candidate.locator.path) !== candidate.revision) throw new Error("Session changed during import; import again to capture the latest messages.");
|
|
31561
31748
|
return { messages, cursor: more ? String(offset + 120) : void 0, partial: transcript.partial, note: `SDK-visible conversation chain from the local CLI/VS Code transcript; pre-compaction text and unsupported message types may be absent. Fork ancestry is unavailable.${transcript.partial ? " Some transcript records or subagent metadata were unreadable." : ""}` };
|
|
@@ -31713,6 +31900,7 @@ async function sessionNames() {
|
|
|
31713
31900
|
function codexRecord(raw, offset, candidate) {
|
|
31714
31901
|
const p = raw.payload;
|
|
31715
31902
|
if (!p || typeof p !== "object") return;
|
|
31903
|
+
if (raw.type === "session_meta" || raw.type === "turn_context") candidate.locator.executionCwd = typeof p.cwd === "string" ? p.cwd : "";
|
|
31716
31904
|
if (raw.type === "turn_context" && typeof p.model === "string") candidate.session.model = p.model;
|
|
31717
31905
|
if (raw.type === "event_msg" && p.type === "item_completed" && ["FileChange", "fileChange"].includes(p.item?.type)) {
|
|
31718
31906
|
const msg2 = blankMessage(`event:${p.item.id || raw.ordinal || offset}`, p.completed_at_ms || Date.parse(raw.timestamp) || 0, "tool");
|
|
@@ -31744,7 +31932,14 @@ function codexRecord(raw, offset, candidate) {
|
|
|
31744
31932
|
}
|
|
31745
31933
|
const role = p.role === "user" ? "user" : p.role === "assistant" ? "assistant" : p.type === "message" ? "system" : "tool";
|
|
31746
31934
|
const msg = blankMessage(`item:${raw.ordinal ?? offset}`, Date.parse(raw.timestamp) || 0, role);
|
|
31747
|
-
|
|
31935
|
+
let input = p.arguments ?? p.input;
|
|
31936
|
+
if (typeof input === "string") {
|
|
31937
|
+
try {
|
|
31938
|
+
input = JSON.parse(input);
|
|
31939
|
+
} catch {
|
|
31940
|
+
}
|
|
31941
|
+
}
|
|
31942
|
+
const fields2 = { nativeID: p.id, nativeType: p.type, callID: p.call_id, ...executionFields(input, { cwd: candidate.locator.executionCwd }) };
|
|
31748
31943
|
msg.events = p.type === "message" ? role === "user" ? userBlockEvents(msg, p.content, codexUserText) : blockEvents(msg, p.content) : ["function_call", "custom_tool_call"].includes(p.type) ? [eventFor(msg, "call", "tool_call", p.name || "Tool call", "", { ...fields2, role: "assistant", input: eventText(p.arguments ?? p.input), status: "unknown" })] : ["function_call_output", "custom_tool_call_output"].includes(p.type) ? [eventFor(msg, "result", "tool_result", "Tool result", "", { ...fields2, output: eventText(p.output, 64e3), status: "unknown" })] : [eventFor(msg, "event", p.type === "reasoning" ? "reasoning" : "event", p.type === "reasoning" ? "Recorded reasoning summary" : p.type || "Unknown event", eventText(p.type === "reasoning" ? p.summary : p), { ...fields2, partial: p.type === "reasoning" })];
|
|
31749
31944
|
if (p.type === "message") {
|
|
31750
31945
|
for (const part of Array.isArray(p.content) ? p.content : []) if (["input_text", "output_text", "text"].includes(part.type)) addText(msg, role === "user" ? codexUserText(part.text) : part.text, role === "user" ? "You" : "Assistant");
|
|
@@ -31769,10 +31964,11 @@ var init_codex = __esm({
|
|
|
31769
31964
|
init_jsonl();
|
|
31770
31965
|
init_events();
|
|
31771
31966
|
init_source_paths();
|
|
31967
|
+
init_commit_extraction();
|
|
31772
31968
|
root2 = () => sourcePath("codex") || process.env.CODEX_HOME || join10(homedir6(), ".codex");
|
|
31773
31969
|
revision = async (path) => {
|
|
31774
31970
|
const s = await stat2(path);
|
|
31775
|
-
return digest([
|
|
31971
|
+
return digest([10, s.mtimeMs, s.size]);
|
|
31776
31972
|
};
|
|
31777
31973
|
codexAdapter = {
|
|
31778
31974
|
id: "codex",
|
|
@@ -31832,6 +32028,7 @@ var init_codex = __esm({
|
|
|
31832
32028
|
})).values()], warnings };
|
|
31833
32029
|
},
|
|
31834
32030
|
async read(candidate, cursor) {
|
|
32031
|
+
if (!cursor) candidate.locator.executionCwd = "";
|
|
31835
32032
|
const page2 = await readJSONL(candidate.locator.path, Number(cursor || 0));
|
|
31836
32033
|
if (page2.cursor === void 0 && await revision(candidate.locator.path) !== candidate.revision) throw new Error("Session changed during import; import again to capture the latest messages.");
|
|
31837
32034
|
return { messages: page2.rows.flatMap((r) => {
|
|
@@ -31861,7 +32058,7 @@ function time2(value) {
|
|
|
31861
32058
|
return Number.isFinite(parsed) && parsed > 0 && parsed <= 864e13 ? parsed : 0;
|
|
31862
32059
|
}
|
|
31863
32060
|
function status(value) {
|
|
31864
|
-
return ["pending", "running", "completed", "failed"].includes(
|
|
32061
|
+
return ["pending", "running", "completed", "failed"].includes(string2(value)) ? value : "unknown";
|
|
31865
32062
|
}
|
|
31866
32063
|
async function databasePath2() {
|
|
31867
32064
|
const root3 = sourcePath("t3-code") || process.env.SESSIONGRAPH_T3_CODE_HISTORY_DIR || process.env.T3CODE_HOME || join11(homedir7(), ".t3");
|
|
@@ -31890,7 +32087,7 @@ function projectRoots(db2, ids) {
|
|
|
31890
32087
|
for (const batch of batches([...new Set(ids.filter(Boolean))])) {
|
|
31891
32088
|
const placeholders = batch.map(() => "?").join(",");
|
|
31892
32089
|
for (const row of db2.prepare(`SELECT project_id, substr(workspace_root,1,4096) AS workspace_root FROM projection_projects WHERE deleted_at IS NULL AND project_id IN (${placeholders})`).all(...batch))
|
|
31893
|
-
roots2.set(
|
|
32090
|
+
roots2.set(string2(row.project_id), string2(row.workspace_root));
|
|
31894
32091
|
}
|
|
31895
32092
|
return roots2;
|
|
31896
32093
|
}
|
|
@@ -31900,7 +32097,7 @@ function aggregates(db2, table2, ids) {
|
|
|
31900
32097
|
for (const batch of batches(ids)) {
|
|
31901
32098
|
const placeholders = batch.map(() => "?").join(",");
|
|
31902
32099
|
for (const row of db2.prepare(`SELECT thread_id, COUNT(*) AS n, MAX(updated_at) AS latest FROM ${table2} WHERE thread_id IN (${placeholders}) GROUP BY thread_id`).all(...batch))
|
|
31903
|
-
result.set(
|
|
32100
|
+
result.set(string2(row.thread_id), [Number(row.n), string2(row.latest)]);
|
|
31904
32101
|
}
|
|
31905
32102
|
return result;
|
|
31906
32103
|
}
|
|
@@ -31914,10 +32111,10 @@ function linkedSessions(db2, ids) {
|
|
|
31914
32111
|
CASE WHEN json_valid(payload_json) THEN json_extract(payload_json,'$.nativeThreadRef.strength') END AS strength,
|
|
31915
32112
|
CASE WHEN json_valid(payload_json) THEN json_extract(payload_json,'$.nativeThreadRef.driver') END AS driver
|
|
31916
32113
|
FROM orchestration_v2_projection_provider_threads WHERE thread_id IN (${placeholders})`).all(...batch)) {
|
|
31917
|
-
const source = providerSource[
|
|
31918
|
-
const nativeID =
|
|
32114
|
+
const source = providerSource[string2(row.provider)];
|
|
32115
|
+
const nativeID = string2(row.native_id);
|
|
31919
32116
|
if (!source || row.strength !== "strong" || row.driver && row.driver !== row.provider || !nativeID || nativeID.length > 512) continue;
|
|
31920
|
-
const id2 =
|
|
32117
|
+
const id2 = string2(row.thread_id);
|
|
31921
32118
|
links.set(id2, [.../* @__PURE__ */ new Set([...links.get(id2) || [], identity(source, nativeID)])]);
|
|
31922
32119
|
}
|
|
31923
32120
|
}
|
|
@@ -31932,8 +32129,8 @@ function discoverV2(db2, path, databaseRevision) {
|
|
|
31932
32129
|
CASE WHEN json_valid(payload_json) THEN json_extract(payload_json,'$.lineage.relationshipToParent') END AS relationship,
|
|
31933
32130
|
json_valid(payload_json) AS valid_payload
|
|
31934
32131
|
FROM orchestration_v2_projection_threads WHERE deleted_at IS NULL ORDER BY created_at, thread_id LIMIT ?`).all(MAX_THREADS + 1);
|
|
31935
|
-
const selected = rows2.slice(0, MAX_THREADS), ids = selected.map((row) =>
|
|
31936
|
-
const roots2 = projectRoots(db2, selected.map((row) =>
|
|
32132
|
+
const selected = rows2.slice(0, MAX_THREADS), ids = selected.map((row) => string2(row.thread_id));
|
|
32133
|
+
const roots2 = projectRoots(db2, selected.map((row) => string2(row.project_id)));
|
|
31937
32134
|
const counts = aggregates(db2, "orchestration_v2_projection_messages", ids);
|
|
31938
32135
|
const items = aggregates(db2, "orchestration_v2_projection_turn_items", ids);
|
|
31939
32136
|
const links = linkedSessions(db2, ids);
|
|
@@ -31941,28 +32138,28 @@ function discoverV2(db2, path, databaseRevision) {
|
|
|
31941
32138
|
if (rows2.length > MAX_THREADS) warnings.push(`T3 Code discovery is limited to ${MAX_THREADS.toLocaleString()} threads.`);
|
|
31942
32139
|
let unreadableMetadata = 0;
|
|
31943
32140
|
for (const row of selected) {
|
|
31944
|
-
const nativeID =
|
|
32141
|
+
const nativeID = string2(row.thread_id), created = time2(row.created_at);
|
|
31945
32142
|
if (!nativeID || nativeID.length > 512 || !created) continue;
|
|
31946
32143
|
if (!row.valid_payload) unreadableMetadata++;
|
|
31947
|
-
const
|
|
31948
|
-
const p = project(SOURCE,
|
|
32144
|
+
const directory3 = string2(row.worktree_path) || roots2.get(string2(row.project_id)) || "";
|
|
32145
|
+
const p = project(SOURCE, directory3);
|
|
31949
32146
|
projects.set(p.id, p);
|
|
31950
|
-
const session = blankSession(SOURCE, nativeID,
|
|
31951
|
-
const parent =
|
|
32147
|
+
const session = blankSession(SOURCE, nativeID, directory3);
|
|
32148
|
+
const parent = string2(row.parent_thread_id);
|
|
31952
32149
|
session.parentID = row.relationship === "subagent" && parent ? identity(SOURCE, parent) : void 0;
|
|
31953
32150
|
session.forkID = row.relationship === "fork" && parent ? identity(SOURCE, parent) : void 0;
|
|
31954
32151
|
Object.assign(session, {
|
|
31955
|
-
title:
|
|
32152
|
+
title: string2(row.title) || "T3 Code thread",
|
|
31956
32153
|
projectID: p.id,
|
|
31957
32154
|
created,
|
|
31958
32155
|
updated: time2(row.updated_at) || created,
|
|
31959
32156
|
archived: Boolean(row.archived_at),
|
|
31960
|
-
model:
|
|
31961
|
-
provider:
|
|
32157
|
+
model: string2(row.model) || "Unknown model",
|
|
32158
|
+
provider: string2(row.default_provider),
|
|
31962
32159
|
agent: "T3 Code",
|
|
31963
32160
|
linkedSessionIDs: links.get(nativeID) || []
|
|
31964
32161
|
});
|
|
31965
|
-
const revision2 = digest([row.updated_at, counts.get(nativeID), items.get(nativeID), links.get(nativeID)]);
|
|
32162
|
+
const revision2 = digest([3, row.updated_at, counts.get(nativeID), items.get(nativeID), links.get(nativeID)]);
|
|
31966
32163
|
sessions.push({ session, revision: revision2, locator: { path, databaseRevision, threadID: nativeID, format: "v2", metadataPartial: row.valid_payload ? "" : "1" } });
|
|
31967
32164
|
}
|
|
31968
32165
|
if (unreadableMetadata) warnings.push(`${unreadableMetadata} T3 Code threads had unreadable metadata; model or lineage may be unavailable.`);
|
|
@@ -31975,23 +32172,23 @@ function discoverV1(db2, path, databaseRevision) {
|
|
|
31975
32172
|
CASE WHEN json_valid(model_selection_json) THEN substr(json_extract(model_selection_json,'$.model'),1,200) END AS model
|
|
31976
32173
|
FROM projection_threads WHERE deleted_at IS NULL ORDER BY created_at, thread_id LIMIT ?`).all(MAX_THREADS + 1);
|
|
31977
32174
|
const selected = rows2.slice(0, MAX_THREADS);
|
|
31978
|
-
const roots2 = projectRoots(db2, selected.map((row) =>
|
|
31979
|
-
const counts = aggregates(db2, "projection_thread_messages", selected.map((row) =>
|
|
32175
|
+
const roots2 = projectRoots(db2, selected.map((row) => string2(row.project_id)));
|
|
32176
|
+
const counts = aggregates(db2, "projection_thread_messages", selected.map((row) => string2(row.thread_id)));
|
|
31980
32177
|
const sessions = [], projects = /* @__PURE__ */ new Map();
|
|
31981
32178
|
for (const row of selected) {
|
|
31982
|
-
const nativeID =
|
|
32179
|
+
const nativeID = string2(row.thread_id), created = time2(row.created_at);
|
|
31983
32180
|
if (!nativeID || nativeID.length > 512 || !created) continue;
|
|
31984
|
-
const
|
|
31985
|
-
const p = project(SOURCE,
|
|
32181
|
+
const directory3 = string2(row.worktree_path) || roots2.get(string2(row.project_id)) || "";
|
|
32182
|
+
const p = project(SOURCE, directory3);
|
|
31986
32183
|
projects.set(p.id, p);
|
|
31987
|
-
const session = blankSession(SOURCE, nativeID,
|
|
32184
|
+
const session = blankSession(SOURCE, nativeID, directory3);
|
|
31988
32185
|
Object.assign(session, {
|
|
31989
|
-
title:
|
|
32186
|
+
title: string2(row.title) || "T3 Code thread",
|
|
31990
32187
|
projectID: p.id,
|
|
31991
32188
|
created,
|
|
31992
32189
|
updated: time2(row.updated_at) || created,
|
|
31993
32190
|
archived: Boolean(row.archived_at),
|
|
31994
|
-
model:
|
|
32191
|
+
model: string2(row.model) || "Unknown model",
|
|
31995
32192
|
agent: "T3 Code"
|
|
31996
32193
|
});
|
|
31997
32194
|
sessions.push({ session, revision: digest([row.updated_at, counts.get(nativeID)]), locator: { path, databaseRevision, threadID: nativeID, format: "v1" } });
|
|
@@ -32000,15 +32197,15 @@ function discoverV1(db2, path, databaseRevision) {
|
|
|
32000
32197
|
if (rows2.length > MAX_THREADS) warnings.push(`T3 Code discovery is limited to ${MAX_THREADS.toLocaleString()} threads.`);
|
|
32001
32198
|
return { sessions, projects: [...projects.values()], warnings };
|
|
32002
32199
|
}
|
|
32003
|
-
function v2Message(row,
|
|
32004
|
-
const parsed = parsedObject(row.payload_json), item = parsed || {}, type =
|
|
32200
|
+
function v2Message(row, directory3) {
|
|
32201
|
+
const parsed = parsedObject(row.payload_json), item = parsed || {}, type = string2(row.type), id2 = string2(row.turn_item_id);
|
|
32005
32202
|
const role = type === "user_message" ? "user" : type === "assistant_message" ? "assistant" : type === "reasoning" ? "assistant" : "tool";
|
|
32006
32203
|
const message2 = blankMessage(`item:${id2}`, time2(item.startedAt || item.createdAt), role);
|
|
32007
|
-
const recorded = Boolean(message2.time), name =
|
|
32204
|
+
const recorded = Boolean(message2.time), name = string2(item.title || item.toolName) || type.replaceAll("_", " ");
|
|
32008
32205
|
const fields2 = {
|
|
32009
32206
|
nativeID: id2,
|
|
32010
32207
|
nativeType: type,
|
|
32011
|
-
parentID:
|
|
32208
|
+
parentID: string2(item.parentItemId) || void 0,
|
|
32012
32209
|
status: status(row.status),
|
|
32013
32210
|
endTime: time2(item.completedAt) || null,
|
|
32014
32211
|
timeSource: recorded ? "recorded" : "unknown"
|
|
@@ -32019,34 +32216,42 @@ function v2Message(row, directory2) {
|
|
|
32019
32216
|
return message2;
|
|
32020
32217
|
}
|
|
32021
32218
|
if (type === "user_message" || type === "assistant_message") {
|
|
32022
|
-
const body =
|
|
32219
|
+
const body = string2(item.text);
|
|
32023
32220
|
if (body) addText(message2, body, role === "user" ? "You" : "Assistant");
|
|
32024
32221
|
message2.events = [{ ...messageEvent(message2, body, id2), ...fields2 }];
|
|
32025
32222
|
if (Array.isArray(item.attachments) && item.attachments.length) message2.partial = true;
|
|
32026
32223
|
return message2;
|
|
32027
32224
|
}
|
|
32028
32225
|
if (type === "reasoning") {
|
|
32029
|
-
message2.events = [eventFor(message2, id2, "reasoning", "Recorded reasoning",
|
|
32226
|
+
message2.events = [eventFor(message2, id2, "reasoning", "Recorded reasoning", string2(item.text), fields2)];
|
|
32030
32227
|
return message2;
|
|
32031
32228
|
}
|
|
32032
32229
|
if (type === "file_change") {
|
|
32033
|
-
const file =
|
|
32034
|
-
|
|
32230
|
+
const file = string2(item.fileName), completed = status(row.status) === "completed";
|
|
32231
|
+
const native = item.nativeItemRef;
|
|
32232
|
+
if (native?.driver === "opencode" && openCodeEditTools.has(file.toLowerCase())) {
|
|
32233
|
+
message2.tools.push(file);
|
|
32234
|
+
const kind2 = completed || fields2.status === "failed" ? "tool_result" : "tool_call";
|
|
32235
|
+
message2.events = [eventFor(message2, id2, kind2, file, "", { ...fields2, callID: string2(native.nativeId) || void 0 })];
|
|
32236
|
+
return message2;
|
|
32237
|
+
}
|
|
32238
|
+
if (file && completed) message2.files.push({ path: isAbsolute3(file) ? file : join11(directory3, file), source: "file change", steps: 1 });
|
|
32035
32239
|
message2.events = [eventFor(message2, id2, "file_change", file || name, "", fields2)];
|
|
32036
32240
|
return message2;
|
|
32037
32241
|
}
|
|
32038
32242
|
if (["command_execution", "dynamic_tool", "file_search", "web_search"].includes(type)) {
|
|
32039
32243
|
const input = eventText(item.input ?? item.pattern ?? item.patterns, 32e3);
|
|
32040
|
-
const
|
|
32244
|
+
const output2 = eventText(item.output ?? item.results, 64e3);
|
|
32041
32245
|
const kind2 = fields2.status === "completed" || fields2.status === "failed" ? "tool_result" : "tool_call";
|
|
32042
32246
|
message2.tools.push(name);
|
|
32043
32247
|
if (input) addText(message2, input, "Tool");
|
|
32044
|
-
if (
|
|
32045
|
-
|
|
32248
|
+
if (output2) addText(message2, output2, "Tool");
|
|
32249
|
+
const native = item.nativeItemRef;
|
|
32250
|
+
message2.events = [eventFor(message2, id2, kind2, name, "", { ...fields2, input, output: output2, ...executionFields(parsedObject(item.input) || item.input, item), callID: string2(native?.nativeId) || void 0 })];
|
|
32046
32251
|
return message2;
|
|
32047
32252
|
}
|
|
32048
32253
|
const kind = type === "compaction" ? "compaction" : type === "error" ? "error" : "event";
|
|
32049
|
-
message2.events = [eventFor(message2, id2, kind, name,
|
|
32254
|
+
message2.events = [eventFor(message2, id2, kind, name, string2(item.text), fields2)];
|
|
32050
32255
|
return message2;
|
|
32051
32256
|
}
|
|
32052
32257
|
function readV2(db2, candidate, cursor) {
|
|
@@ -32079,9 +32284,9 @@ function readV1(db2, candidate, cursor) {
|
|
|
32079
32284
|
const messages = rows2.slice(0, PAGE).map((row) => {
|
|
32080
32285
|
const role = row.role === "user" ? "user" : row.role === "assistant" ? "assistant" : "system";
|
|
32081
32286
|
const message2 = blankMessage(`message:${row.message_id}`, time2(row.created_at), role);
|
|
32082
|
-
const body =
|
|
32287
|
+
const body = string2(row.text);
|
|
32083
32288
|
if (body) addText(message2, body, role === "user" ? "You" : "Assistant");
|
|
32084
|
-
message2.events = [{ ...messageEvent(message2, body), nativeID:
|
|
32289
|
+
message2.events = [{ ...messageEvent(message2, body), nativeID: string2(row.message_id), nativeType: "legacy-message" }];
|
|
32085
32290
|
message2.partial = row.text == null;
|
|
32086
32291
|
return message2;
|
|
32087
32292
|
});
|
|
@@ -32092,7 +32297,7 @@ function readV1(db2, candidate, cursor) {
|
|
|
32092
32297
|
note: "Legacy T3 Code text messages only. Tool activity, attachments, and provider links are unavailable."
|
|
32093
32298
|
};
|
|
32094
32299
|
}
|
|
32095
|
-
var SOURCE, PAGE, MAX_THREADS, MAX_ITEM_JSON, providerSource,
|
|
32300
|
+
var SOURCE, PAGE, MAX_THREADS, MAX_ITEM_JSON, providerSource, openCodeEditTools, string2, t3CodeAdapter;
|
|
32096
32301
|
var init_t3_code = __esm({
|
|
32097
32302
|
"server/adapters/t3-code.ts"() {
|
|
32098
32303
|
"use strict";
|
|
@@ -32100,12 +32305,14 @@ var init_t3_code = __esm({
|
|
|
32100
32305
|
init_common();
|
|
32101
32306
|
init_sqlite_snapshot();
|
|
32102
32307
|
init_events();
|
|
32308
|
+
init_commit_extraction();
|
|
32103
32309
|
SOURCE = "t3-code";
|
|
32104
32310
|
PAGE = 100;
|
|
32105
32311
|
MAX_THREADS = 2e4;
|
|
32106
32312
|
MAX_ITEM_JSON = 256e3;
|
|
32107
32313
|
providerSource = { codex: "codex", claudeAgent: "claude-code", opencode: "opencode" };
|
|
32108
|
-
|
|
32314
|
+
openCodeEditTools = /* @__PURE__ */ new Set(["patch", "apply_patch", "edit", "write", "multiedit"]);
|
|
32315
|
+
string2 = (value) => typeof value === "string" ? value : "";
|
|
32109
32316
|
t3CodeAdapter = {
|
|
32110
32317
|
id: SOURCE,
|
|
32111
32318
|
name: "T3 Code",
|
|
@@ -32250,11 +32457,11 @@ function withStore(path, read3) {
|
|
|
32250
32457
|
throw error;
|
|
32251
32458
|
}
|
|
32252
32459
|
});
|
|
32253
|
-
const before = stats(),
|
|
32460
|
+
const before = stats(), directory3 = mkdtempSync2(join12(tmpdir2(), "sessiongraph-cursor-"));
|
|
32254
32461
|
let db2;
|
|
32255
32462
|
try {
|
|
32256
|
-
chmodSync3(
|
|
32257
|
-
const copy = join12(
|
|
32463
|
+
chmodSync3(directory3, 448);
|
|
32464
|
+
const copy = join12(directory3, "store.db");
|
|
32258
32465
|
files.forEach((file, index) => {
|
|
32259
32466
|
if (before[index]) {
|
|
32260
32467
|
const target = index ? `${copy}-wal` : copy;
|
|
@@ -32270,7 +32477,7 @@ function withStore(path, read3) {
|
|
|
32270
32477
|
try {
|
|
32271
32478
|
db2?.close();
|
|
32272
32479
|
} finally {
|
|
32273
|
-
rmSync3(
|
|
32480
|
+
rmSync3(directory3, { recursive: true, force: true });
|
|
32274
32481
|
}
|
|
32275
32482
|
}
|
|
32276
32483
|
}
|
|
@@ -32342,12 +32549,12 @@ function readCursorStore(path) {
|
|
|
32342
32549
|
bytes2 += data.length;
|
|
32343
32550
|
try {
|
|
32344
32551
|
if (item.leaf) {
|
|
32345
|
-
const
|
|
32346
|
-
if (!
|
|
32552
|
+
const json5 = data[0] === 123 ? data : fields(data).find((v3) => v3.field === 4)?.data;
|
|
32553
|
+
if (!json5) {
|
|
32347
32554
|
partial = true;
|
|
32348
32555
|
continue;
|
|
32349
32556
|
}
|
|
32350
|
-
const raw = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(
|
|
32557
|
+
const raw = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(json5));
|
|
32351
32558
|
const msg = cursorMessage(raw, `blob:${item.id}:${ordinal++}`);
|
|
32352
32559
|
if (!msg) {
|
|
32353
32560
|
partial = true;
|
|
@@ -32406,9 +32613,9 @@ var init_cursor_store = __esm({
|
|
|
32406
32613
|
import { isAbsolute as isAbsolute4 } from "node:path";
|
|
32407
32614
|
import { fileURLToPath } from "node:url";
|
|
32408
32615
|
function decode(value) {
|
|
32409
|
-
return
|
|
32616
|
+
return object2(JSON.parse(typeof value === "string" ? value : value instanceof Uint8Array ? Buffer.from(value).toString("utf8") : "{}"));
|
|
32410
32617
|
}
|
|
32411
|
-
function
|
|
32618
|
+
function directory2(raw) {
|
|
32412
32619
|
const value = text2(raw.workspaceIdentifier?.uri?.path) || text2(raw.workspaceIdentifier?.uri) || text2(raw.cwd);
|
|
32413
32620
|
try {
|
|
32414
32621
|
return value.startsWith("file:") ? fileURLToPath(value) : isAbsolute4(value) ? value : "";
|
|
@@ -32435,7 +32642,7 @@ function discoverComposers(path, workspace = "") {
|
|
|
32435
32642
|
if (!nativeID || row.key !== `composerData:${nativeID}`) throw new Error("Composer identity mismatch.");
|
|
32436
32643
|
const headers = Array.isArray(data.fullConversationHeadersOnly) ? data.fullConversationHeadersOnly : Array.isArray(data.conversation) ? data.conversation : [];
|
|
32437
32644
|
if (!headers.length) continue;
|
|
32438
|
-
const session = blankSession("cursor", nativeID,
|
|
32645
|
+
const session = blankSession("cursor", nativeID, directory2(data) || workspace);
|
|
32439
32646
|
session.created = cursorTime(data.createdAt);
|
|
32440
32647
|
if (!session.created) continue;
|
|
32441
32648
|
session.updated = cursorTime(data.lastUpdatedAt) || session.created;
|
|
@@ -32486,7 +32693,7 @@ function readComposer(candidate) {
|
|
|
32486
32693
|
const id2 = text2(header.bubbleId);
|
|
32487
32694
|
const stored = id2 ? get.get(`bubbleId:${nativeID}:${id2}`, MAX_BUBBLE) : void 0;
|
|
32488
32695
|
if (stored) bytes2 += typeof stored.value === "string" ? Buffer.byteLength(stored.value) : stored.value.byteLength;
|
|
32489
|
-
const raw = stored ? { ...header, ...decode(stored.value) } : { ...header, ...
|
|
32696
|
+
const raw = stored ? { ...header, ...decode(stored.value) } : { ...header, ...object2(data.conversationMap?.[id2]) };
|
|
32490
32697
|
if (![1, 2].includes(raw.type)) {
|
|
32491
32698
|
partial = true;
|
|
32492
32699
|
continue;
|
|
@@ -32545,7 +32752,7 @@ async function stamp(path) {
|
|
|
32545
32752
|
async function snapshot(locator) {
|
|
32546
32753
|
return digest(await Promise.all([stamp(locator.path), locator.kind === "transcript" ? null : stamp(`${locator.path}-wal`), locator.meta ? stamp(locator.meta) : null]));
|
|
32547
32754
|
}
|
|
32548
|
-
async function
|
|
32755
|
+
async function json4(path) {
|
|
32549
32756
|
const s = await fileStats(path);
|
|
32550
32757
|
if (!s) return {};
|
|
32551
32758
|
if (s.size > 128e3) throw new Error("Cursor metadata exceeds the 128 KB limit.");
|
|
@@ -32575,7 +32782,7 @@ async function workspacePaths(root3, warnings) {
|
|
|
32575
32782
|
const database = join13(storage, entry.name, "state.vscdb");
|
|
32576
32783
|
stores.set(database, "");
|
|
32577
32784
|
try {
|
|
32578
|
-
const info = await
|
|
32785
|
+
const info = await json4(join13(storage, entry.name, "workspace.json"));
|
|
32579
32786
|
if (typeof info.folder === "string" && info.folder.startsWith("file:")) {
|
|
32580
32787
|
const path = cwd(fileURLToPath2(info.folder));
|
|
32581
32788
|
if (path) stores.set(database, path);
|
|
@@ -32635,7 +32842,7 @@ function createCursorAdapter(options = {}) {
|
|
|
32635
32842
|
return matches.length === 1 ? matches[0] : "";
|
|
32636
32843
|
};
|
|
32637
32844
|
let unreadable = 0, legacy = 0, scanned = 0;
|
|
32638
|
-
const add = async (path, id2, kind,
|
|
32845
|
+
const add = async (path, id2, kind, directory3, parent = "", workspaceHash = "") => {
|
|
32639
32846
|
if (!validID(id2) || ++scanned > LIMIT) return;
|
|
32640
32847
|
try {
|
|
32641
32848
|
const stats = await fileStats(path);
|
|
@@ -32644,11 +32851,11 @@ function createCursorAdapter(options = {}) {
|
|
|
32644
32851
|
const locator = { path, kind };
|
|
32645
32852
|
if (kind !== "transcript") locator.meta = join13(path, "..", "meta.json");
|
|
32646
32853
|
const before = await snapshot(locator);
|
|
32647
|
-
const extra2 = locator.meta ? await
|
|
32854
|
+
const extra2 = locator.meta ? await json4(locator.meta) : {};
|
|
32648
32855
|
const meta = kind === "transcript" ? {} : cursorStoreMetadata(path);
|
|
32649
32856
|
if (meta.agentId && meta.agentId !== id2) throw new Error("Cursor native identity mismatch.");
|
|
32650
32857
|
if (kind !== "transcript" && !meta.latestRootBlobId) return;
|
|
32651
|
-
const session = blankSession("cursor", native, cwd(meta.cwd) || cwd(extra2.cwd) ||
|
|
32858
|
+
const session = blankSession("cursor", native, cwd(meta.cwd) || cwd(extra2.cwd) || directory3);
|
|
32652
32859
|
session.agent = kind === "cli" ? "Cursor Agent" : kind === "acp" ? "Cursor ACP" : parent ? "Cursor subagent" : "Cursor IDE";
|
|
32653
32860
|
if (parent) session.parentID = identity("cursor", parent);
|
|
32654
32861
|
session.title = typeof meta.name === "string" && meta.name.trim() ? meta.name : typeof extra2.title === "string" && extra2.title.trim() ? extra2.title : "Cursor session";
|
|
@@ -32705,15 +32912,15 @@ function createCursorAdapter(options = {}) {
|
|
|
32705
32912
|
const projects = join13(root3(), "projects");
|
|
32706
32913
|
for (const dir of await entries(projects, warnings)) {
|
|
32707
32914
|
if (!dir.isDirectory() || scanned >= LIMIT) continue;
|
|
32708
|
-
const transcripts = join13(projects, dir.name, "agent-transcripts"),
|
|
32915
|
+
const transcripts = join13(projects, dir.name, "agent-transcripts"), directory3 = match2(dir.name, slug);
|
|
32709
32916
|
for (const entry of await entries(transcripts, warnings)) {
|
|
32710
32917
|
if (scanned >= LIMIT) break;
|
|
32711
|
-
if (entry.isFile() && entry.name.endsWith(".jsonl")) await add(join13(transcripts, entry.name), entry.name.slice(0, -6), "transcript",
|
|
32918
|
+
if (entry.isFile() && entry.name.endsWith(".jsonl")) await add(join13(transcripts, entry.name), entry.name.slice(0, -6), "transcript", directory3);
|
|
32712
32919
|
else if (entry.isFile() && entry.name.endsWith(".txt")) legacy++;
|
|
32713
32920
|
else if (entry.isDirectory() && validID(entry.name)) {
|
|
32714
|
-
await add(join13(transcripts, entry.name, `${entry.name}.jsonl`), entry.name, "transcript",
|
|
32921
|
+
await add(join13(transcripts, entry.name, `${entry.name}.jsonl`), entry.name, "transcript", directory3);
|
|
32715
32922
|
for (const child of await entries(join13(transcripts, entry.name, "subagents"), warnings)) {
|
|
32716
|
-
if (child.isFile() && child.name.endsWith(".jsonl")) await add(join13(transcripts, entry.name, "subagents", child.name), child.name.slice(0, -6), "transcript",
|
|
32923
|
+
if (child.isFile() && child.name.endsWith(".jsonl")) await add(join13(transcripts, entry.name, "subagents", child.name), child.name.slice(0, -6), "transcript", directory3, entry.name);
|
|
32717
32924
|
if (scanned >= LIMIT) break;
|
|
32718
32925
|
}
|
|
32719
32926
|
}
|
|
@@ -32722,13 +32929,13 @@ function createCursorAdapter(options = {}) {
|
|
|
32722
32929
|
const chats = join13(root3(), "chats");
|
|
32723
32930
|
for (const bucket of await entries(chats, warnings)) {
|
|
32724
32931
|
if (!bucket.isDirectory() || scanned >= LIMIT) continue;
|
|
32725
|
-
const folder = join13(chats, bucket.name),
|
|
32932
|
+
const folder = join13(chats, bucket.name), directory3 = match2(bucket.name, hashCwd);
|
|
32726
32933
|
if (/^[a-f\d]{32}$/i.test(bucket.name) && await fileStats(join13(folder, "store.db"))) {
|
|
32727
32934
|
const id2 = bucket.name.replace(/^(.{8})(.{4})(.{4})(.{4})(.{12})$/, "$1-$2-$3-$4-$5");
|
|
32728
32935
|
await add(join13(folder, "store.db"), id2, "cli", "");
|
|
32729
32936
|
}
|
|
32730
32937
|
for (const entry of await entries(folder, warnings)) {
|
|
32731
|
-
if (entry.isDirectory()) await add(join13(folder, entry.name, "store.db"), entry.name, "cli",
|
|
32938
|
+
if (entry.isDirectory()) await add(join13(folder, entry.name, "store.db"), entry.name, "cli", directory3, "", bucket.name);
|
|
32732
32939
|
if (scanned >= LIMIT) break;
|
|
32733
32940
|
}
|
|
32734
32941
|
}
|
|
@@ -32811,7 +33018,7 @@ function projectRootFile(path) {
|
|
|
32811
33018
|
return join14(parts.slice(0, parts.lastIndexOf("chats")).join(sep4), ".project_root");
|
|
32812
33019
|
}
|
|
32813
33020
|
function geminiConversation(contents, lines) {
|
|
32814
|
-
const parsed = lines ? jsonLines(contents) : { rows: [
|
|
33021
|
+
const parsed = lines ? jsonLines(contents) : { rows: [object2(json3(contents))], partial: false };
|
|
32815
33022
|
let metadata2 = {};
|
|
32816
33023
|
const messages = /* @__PURE__ */ new Map();
|
|
32817
33024
|
const patch = (p) => {
|
|
@@ -32828,9 +33035,9 @@ function geminiConversation(contents, lines) {
|
|
|
32828
33035
|
const ids = [...messages.keys()], index = ids.indexOf(row.$rewindTo);
|
|
32829
33036
|
for (const id2 of index < 0 ? ids : ids.slice(index)) messages.delete(id2);
|
|
32830
33037
|
} else if (row.$patch) {
|
|
32831
|
-
const p =
|
|
33038
|
+
const p = object2(row.$patch);
|
|
32832
33039
|
if (p.id) patch(p);
|
|
32833
|
-
for (const update of Array.isArray(p.updates) ? p.updates : []) patch(
|
|
33040
|
+
for (const update of Array.isArray(p.updates) ? p.updates : []) patch(object2(update));
|
|
32834
33041
|
for (const id2 of Array.isArray(p.removeIds) ? p.removeIds : []) messages.delete(id2);
|
|
32835
33042
|
for (const id2 of Array.isArray(p.orderIds) ? p.orderIds : []) {
|
|
32836
33043
|
const value = messages.get(id2);
|
|
@@ -32840,7 +33047,7 @@ function geminiConversation(contents, lines) {
|
|
|
32840
33047
|
}
|
|
32841
33048
|
}
|
|
32842
33049
|
} else if (row.$set || row.sessionId) {
|
|
32843
|
-
const update = row.$set ?
|
|
33050
|
+
const update = row.$set ? object2(row.$set) : row;
|
|
32844
33051
|
metadata2 = { ...metadata2, ...update };
|
|
32845
33052
|
if (Array.isArray(update.messages)) {
|
|
32846
33053
|
if (row.$set) messages.clear();
|
|
@@ -32871,7 +33078,7 @@ var init_gemini = __esm({
|
|
|
32871
33078
|
parse(path, files) {
|
|
32872
33079
|
const { metadata: meta, records, partial } = geminiConversation(files.get(path), path.endsWith(".jsonl"));
|
|
32873
33080
|
if (!text2(meta.sessionId)) throw new Error("Unsupported Gemini history.");
|
|
32874
|
-
const
|
|
33081
|
+
const directory3 = (files.get(projectRootFile(path)) || "").trim().slice(0, 4096);
|
|
32875
33082
|
const messages = records.map((raw, index) => {
|
|
32876
33083
|
const message2 = googleMessage({ id: raw.id, timestamp: raw.timestamp, role: raw.type === "user" ? "user" : raw.type === "gemini" ? "assistant" : "system", content: raw.content }, `record:${index}`);
|
|
32877
33084
|
for (const [i, thought] of (Array.isArray(raw.thoughts) ? raw.thoughts : []).entries()) message2.events.push(eventFor(message2, `thought:${i}`, "reasoning", text2(thought.subject) || "Recorded reasoning", text2(thought.description), { time: time(thought.timestamp) || null, timeSource: time(thought.timestamp) ? "recorded" : "unknown" }));
|
|
@@ -32880,9 +33087,9 @@ var init_gemini = __esm({
|
|
|
32880
33087
|
message2.tools.push(name);
|
|
32881
33088
|
message2.events.push(eventFor(message2, `call:${id2}`, "tool_call", name, "", { callID: id2, input: eventText(call.args), status: "unknown" }));
|
|
32882
33089
|
if (call.result != null || ["success", "error", "cancelled"].includes(call.status)) {
|
|
32883
|
-
const
|
|
32884
|
-
message2.events.push(eventFor(message2, `result:${id2}`, "tool_result", name, "", { role: "tool", callID: id2, output, nativeType: text2(call.status), time: time(call.timestamp) || null, timeSource: time(call.timestamp) ? "recorded" : "unknown", status: call.status === "success" ? "completed" : call.status === "error" ? "failed" : "unknown" }));
|
|
32885
|
-
addText(message2,
|
|
33090
|
+
const output2 = eventText(call.result);
|
|
33091
|
+
message2.events.push(eventFor(message2, `result:${id2}`, "tool_result", name, "", { role: "tool", callID: id2, output: output2, nativeType: text2(call.status), time: time(call.timestamp) || null, timeSource: time(call.timestamp) ? "recorded" : "unknown", status: call.status === "success" ? "completed" : call.status === "error" ? "failed" : "unknown" }));
|
|
33092
|
+
addText(message2, output2, "Tool");
|
|
32886
33093
|
}
|
|
32887
33094
|
}
|
|
32888
33095
|
return message2;
|
|
@@ -32894,7 +33101,7 @@ var init_gemini = __esm({
|
|
|
32894
33101
|
messages,
|
|
32895
33102
|
parent,
|
|
32896
33103
|
partial,
|
|
32897
|
-
session: { directory:
|
|
33104
|
+
session: { directory: directory3, created: time(meta.startTime), title: text2(meta.summary), model: text2([...records].reverse().find((r) => r.model)?.model) || "Unknown model", provider: "Google", nativeResume: !parent && Boolean(directory3) && !sourcePath("gemini") && !process.env.SESSIONGRAPH_GEMINI_HOME && !path.includes(`${sep4}.cache${sep4}`) },
|
|
32898
33105
|
note: "Local Gemini chat records with rewind and patch reconstruction. Only explicit subagent directories form parent links; workspace paths come from the project-root marker. Binary content is omitted."
|
|
32899
33106
|
};
|
|
32900
33107
|
}
|
|
@@ -32929,7 +33136,7 @@ var init_qwen = __esm({
|
|
|
32929
33136
|
const messages = rows2.map((raw, index) => {
|
|
32930
33137
|
const id2 = text2(raw.uuid) || `record:${index}`;
|
|
32931
33138
|
if (raw.message && !["agent_message", "agent_mention", "notification"].includes(raw.subtype)) {
|
|
32932
|
-
const message3 = googleMessage({ id: id2, timestamp: raw.timestamp, role: raw.type === "assistant" ? "assistant" : raw.type === "user" ? "user" : "tool", toolCallId: raw.toolCallResult?.callId, content:
|
|
33139
|
+
const message3 = googleMessage({ id: id2, timestamp: raw.timestamp, role: raw.type === "assistant" ? "assistant" : raw.type === "user" ? "user" : "tool", toolCallId: raw.toolCallResult?.callId, content: object2(raw.message).parts }, id2);
|
|
32933
33140
|
for (const event of message3.events || []) if (event.kind === "tool_result") {
|
|
32934
33141
|
event.status = raw.toolCallResult?.status === "success" ? "completed" : raw.toolCallResult?.status === "error" ? "failed" : "unknown";
|
|
32935
33142
|
event.nativeType = text2(raw.toolCallResult?.status);
|
|
@@ -32977,11 +33184,11 @@ var init_copilot = __esm({
|
|
|
32977
33184
|
match: (path) => /(?:^|\/)events\.jsonl$/.test(path),
|
|
32978
33185
|
parse(path, files) {
|
|
32979
33186
|
const { rows: rows2, partial } = jsonLines(files.get(path));
|
|
32980
|
-
const start = rows2.find((r) => r.type === "session.start"), meta =
|
|
33187
|
+
const start = rows2.find((r) => r.type === "session.start"), meta = object2(start?.data);
|
|
32981
33188
|
if (!text2(meta.sessionId)) throw new Error("Unsupported Copilot event log.");
|
|
32982
33189
|
const toolNames = new Map(rows2.filter((r) => r.type === "tool.execution_start").map((r) => [r.data?.toolCallId, text2(r.data?.toolName)]));
|
|
32983
33190
|
const messages = rows2.filter((r) => !r.ephemeral && !["assistant.message_delta", "assistant.reasoning_delta"].includes(r.type)).map((raw, index) => {
|
|
32984
|
-
const data =
|
|
33191
|
+
const data = object2(raw.data), kind = text2(raw.type), human2 = kind === "user.message" && !data.isAutopilotContinuation && !data.source;
|
|
32985
33192
|
const message2 = blankMessage(text2(raw.id) || `record:${index}`, time(raw.timestamp), human2 ? "user" : kind === "assistant.message" ? "assistant" : kind.startsWith("tool.") ? "tool" : "system");
|
|
32986
33193
|
if (["user.message", "assistant.message"].includes(kind)) {
|
|
32987
33194
|
const content = text2(data.content);
|
|
@@ -33027,7 +33234,7 @@ function vscodeChatLog(content) {
|
|
|
33027
33234
|
for (const line of content.split("\n")) {
|
|
33028
33235
|
if (!line.trim()) continue;
|
|
33029
33236
|
if (++records > 5e4) throw new Error("Chat log exceeds the 50,000-operation limit.");
|
|
33030
|
-
const entry =
|
|
33237
|
+
const entry = object2(JSON.parse(line));
|
|
33031
33238
|
if (entry.kind === 0) {
|
|
33032
33239
|
if (records !== 1 || !entry.v || typeof entry.v !== "object" || Array.isArray(entry.v)) throw new Error("Invalid chat log initial state.");
|
|
33033
33240
|
state2 = entry.v;
|
|
@@ -33072,17 +33279,17 @@ var init_vscode_chat_log = __esm({
|
|
|
33072
33279
|
|
|
33073
33280
|
// server/adapters/copilot-chat.ts
|
|
33074
33281
|
import { homedir as homedir12 } from "node:os";
|
|
33075
|
-
import { basename as basename6, dirname as dirname5, join as join17, posix, win32 as
|
|
33282
|
+
import { basename as basename6, dirname as dirname5, join as join17, posix as posix2, win32 as win323 } from "node:path";
|
|
33076
33283
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
33077
33284
|
function copilotChatRoots(platform = process.platform, home = homedir12(), env = process.env) {
|
|
33078
|
-
const path = platform === "win32" ?
|
|
33285
|
+
const path = platform === "win32" ? win323 : posix2;
|
|
33079
33286
|
const base = platform === "darwin" ? path.join(home, "Library", "Application Support") : platform === "win32" ? env.APPDATA || path.join(home, "AppData", "Roaming") : env.XDG_CONFIG_HOME || path.join(home, ".config");
|
|
33080
33287
|
const override = sourcePath("copilot-chat") || env.SESSIONGRAPH_COPILOT_CHAT_USER_DATA_DIR;
|
|
33081
33288
|
const users = override ? [path.join(override, "User")] : [...["Code", "Code - Insiders"].map((app) => path.join(base, app, "User")), ...[".vscode-server", ".vscode-server-insiders"].map((app) => path.join(home, app, "data", "User"))];
|
|
33082
33289
|
return users.flatMap((user) => [path.join(user, "workspaceStorage"), path.join(user, "globalStorage", "emptyWindowChatSessions")]);
|
|
33083
33290
|
}
|
|
33084
33291
|
function vscodeChatPath(value) {
|
|
33085
|
-
const raw =
|
|
33292
|
+
const raw = object2(value);
|
|
33086
33293
|
if (raw.scheme) {
|
|
33087
33294
|
if (raw.scheme !== "file") return `${text2(raw.scheme)}://${text2(raw.authority)}${text2(raw.path)}`;
|
|
33088
33295
|
const path = text2(raw.path);
|
|
@@ -33098,7 +33305,7 @@ function vscodeChatPath(value) {
|
|
|
33098
33305
|
}
|
|
33099
33306
|
}
|
|
33100
33307
|
function responsePart(message2, value, index) {
|
|
33101
|
-
const part =
|
|
33308
|
+
const part = object2(value), kind = text2(part.kind), id2 = `part:${index}`;
|
|
33102
33309
|
const fields2 = { nativeType: kind || "markdown", nativeID: text2(part.id) || void 0 };
|
|
33103
33310
|
if (typeof value === "string" || !kind && typeof part.value === "string" || kind === "markdownContent" || kind === "markdownVuln") {
|
|
33104
33311
|
const content = markdown(kind ? part.content : value);
|
|
@@ -33109,19 +33316,19 @@ function responsePart(message2, value, index) {
|
|
|
33109
33316
|
message2.events.push(eventFor(message2, id2, "reasoning", "Recorded reasoning", content, { ...fields2, ...recordedTime(part.reasoningStartedAt) }));
|
|
33110
33317
|
addText(message2, content, "Tool");
|
|
33111
33318
|
} else if (kind === "toolInvocationSerialized") {
|
|
33112
|
-
const data =
|
|
33319
|
+
const data = object2(part.toolSpecificData), command = object2(data.commandLine), details = object2(part.resultDetails);
|
|
33113
33320
|
const name = text2(part.toolId) || "Tool", callID = text2(part.toolCallId) || void 0;
|
|
33114
33321
|
const input = eventText(data.rawInput ?? command.userEdited ?? command.toolEdited ?? command.original ?? details.input);
|
|
33115
|
-
const denied = part.isConfirmed === false || [0, 5].includes(
|
|
33322
|
+
const denied = part.isConfirmed === false || [0, 5].includes(object2(part.isConfirmed).type);
|
|
33116
33323
|
const status2 = denied || part.resultError ? "failed" : part.isComplete === true ? "completed" : "unknown";
|
|
33117
33324
|
const correlation = { ...fields2, callID, parentID: text2(part.subAgentInvocationId) || void 0 };
|
|
33118
33325
|
message2.events.push(eventFor(message2, `${id2}:call`, "tool_call", name, markdown(part.invocationMessage), { ...correlation, ...recordedTime(part.startedAt), input, status: "unknown" }));
|
|
33119
33326
|
message2.tools.push(name);
|
|
33120
33327
|
addText(message2, input, "Tool");
|
|
33121
33328
|
if (part.isComplete || part.resultError || denied) {
|
|
33122
|
-
const
|
|
33123
|
-
message2.events.push(eventFor(message2, `${id2}:result`, "tool_result", name, markdown(part.pastTenseMessage), { ...correlation, ...recordedTime(part.completedAt), role: "tool", output, status: status2 }));
|
|
33124
|
-
addText(message2,
|
|
33329
|
+
const output2 = eventText(part.resultError || (denied ? "Tool invocation was denied or skipped." : details.output ?? part.resultDetails ?? markdown(part.pastTenseMessage)));
|
|
33330
|
+
message2.events.push(eventFor(message2, `${id2}:result`, "tool_result", name, markdown(part.pastTenseMessage), { ...correlation, ...recordedTime(part.completedAt), role: "tool", output: output2, status: status2 }));
|
|
33331
|
+
addText(message2, output2, "Tool");
|
|
33125
33332
|
} else message2.partial = true;
|
|
33126
33333
|
} else {
|
|
33127
33334
|
message2.events.push(eventFor(message2, id2, "event", kind || "Unsupported chat content", eventText(part), { ...fields2, partial: true }));
|
|
@@ -33134,7 +33341,7 @@ function chatMessages(requests) {
|
|
|
33134
33341
|
const requestID = text2(request.requestId) || `request:${index}`;
|
|
33135
33342
|
const injected = Boolean(request.isSystemInitiated || request.hiddenFromTranscript || request.requestHiddenFromTranscript);
|
|
33136
33343
|
const user = blankMessage(requestID, time(request.timestamp), injected ? "system" : "user");
|
|
33137
|
-
const content = typeof request.message === "string" ? request.message : text2(
|
|
33344
|
+
const content = typeof request.message === "string" ? request.message : text2(object2(request.message).text);
|
|
33138
33345
|
user.events = [eventFor(user, "message", injected ? "event" : "message", injected ? "Injected message" : "User message", content, { nativeID: requestID, ...recordedTime(request.timestamp) })];
|
|
33139
33346
|
addText(user, content, injected ? "Tool" : "You");
|
|
33140
33347
|
if (request.variableData?.variables?.length) user.partial = true;
|
|
@@ -33173,7 +33380,7 @@ var init_copilot_chat = __esm({
|
|
|
33173
33380
|
init_local_files();
|
|
33174
33381
|
init_vscode_chat_log();
|
|
33175
33382
|
init_source_paths();
|
|
33176
|
-
markdown = (value) => typeof value === "string" ? value : text2(
|
|
33383
|
+
markdown = (value) => typeof value === "string" ? value : text2(object2(value).value);
|
|
33177
33384
|
recordedTime = (value) => ({ time: time(value) || null, timeSource: time(value) ? "recorded" : "unknown" });
|
|
33178
33385
|
match = (path) => /^(?:[^/]+\/chatSessions\/)?[^/]+\.jsonl?$/.test(path) && !["index.json", "workspace.json"].includes(path);
|
|
33179
33386
|
roots = () => copilotChatRoots();
|
|
@@ -33188,13 +33395,13 @@ var init_copilot_chat = __esm({
|
|
|
33188
33395
|
extras: (path) => [...basename6(dirname5(path)) === "chatSessions" ? [join17(dirname5(dirname5(path)), "workspace.json")] : [], ...path.endsWith(".json") ? [`${path}l`] : []],
|
|
33189
33396
|
parse(path, files) {
|
|
33190
33397
|
const log = path.endsWith(".jsonl") ? path : `${path}l`;
|
|
33191
|
-
const data = files.has(log) ? vscodeChatLog(files.get(log)) :
|
|
33398
|
+
const data = files.has(log) ? vscodeChatLog(files.get(log)) : object2(JSON.parse(files.get(path)));
|
|
33192
33399
|
if (!text2(data.sessionId) || !Array.isArray(data.requests) || data.version !== void 0 && ![1, 2, 3].includes(data.version)) throw new Error("Unsupported VS Code chat history.");
|
|
33193
33400
|
if (data.sessionId !== basename6(path).replace(/\.jsonl?$/, "")) throw new Error("VS Code chat identity mismatch.");
|
|
33194
33401
|
if (!data.requests.length) return;
|
|
33195
33402
|
if (data.requests.length > 25e3) throw new Error("Chat exceeds the 50,000-message limit.");
|
|
33196
33403
|
const workspacePath = join17(dirname5(dirname5(path)), "workspace.json");
|
|
33197
|
-
const workspace = files.has(workspacePath) ?
|
|
33404
|
+
const workspace = files.has(workspacePath) ? object2(JSON.parse(files.get(workspacePath))) : {};
|
|
33198
33405
|
const messages = chatMessages(data.requests);
|
|
33199
33406
|
const model = [...data.requests].reverse().find((r) => text2(r.modelId));
|
|
33200
33407
|
return {
|
|
@@ -33231,15 +33438,15 @@ function taskAdapter(id2, name, extension, env) {
|
|
|
33231
33438
|
match: (path) => /^[^/]+\/api_conversation_history\.json$/.test(path) || id2 === "cline" && /^[^/]+\/[^/]+\.messages\.json$/.test(path),
|
|
33232
33439
|
extras: (path) => ["history_item.json", "task_metadata.json", "session.json"].map((file) => join18(dirname6(path), file)),
|
|
33233
33440
|
parse(path, files) {
|
|
33234
|
-
const sdk = path.endsWith(".messages.json"), value =
|
|
33235
|
-
const records = sdk ?
|
|
33441
|
+
const sdk = path.endsWith(".messages.json"), value = json3(files.get(path));
|
|
33442
|
+
const records = sdk ? object2(value).messages : value;
|
|
33236
33443
|
if (!Array.isArray(records) || sdk && !text2(value.sessionId)) throw new Error("Unsupported task history.");
|
|
33237
|
-
const read3 = (name2) =>
|
|
33444
|
+
const read3 = (name2) => object2(files.has(join18(dirname6(path), name2)) ? json3(files.get(join18(dirname6(path), name2))) : void 0);
|
|
33238
33445
|
const history = read3("history_item.json"), info = read3("session.json"), task = read3("task_metadata.json");
|
|
33239
33446
|
const nativeID = sdk ? value.sessionId : basename7(dirname6(path));
|
|
33240
33447
|
if (history.id && history.id !== nativeID || info.session_id && info.session_id !== nativeID) throw new Error("Task metadata identity mismatch.");
|
|
33241
33448
|
const messages = records.map((raw, index) => {
|
|
33242
|
-
const row =
|
|
33449
|
+
const row = object2(raw), message2 = conversationMessage(row, `record:${index}`);
|
|
33243
33450
|
if (row.isSummary || row.isTruncationMarker || row.type === "reasoning") {
|
|
33244
33451
|
message2.role = "system";
|
|
33245
33452
|
message2.events = [eventFor(message2, "summary", row.type === "reasoning" ? "reasoning" : "compaction", row.type === "reasoning" ? "Recorded reasoning" : "Context checkpoint", eventText(row.summary ?? row.content ?? row.text), { partial: Boolean(row.encrypted_content), nativeType: row.type || "summary" })];
|
|
@@ -33269,7 +33476,7 @@ var init_extensions = __esm({
|
|
|
33269
33476
|
init_events();
|
|
33270
33477
|
init_local_files();
|
|
33271
33478
|
init_local_messages();
|
|
33272
|
-
|
|
33479
|
+
init_playback_tokens2();
|
|
33273
33480
|
init_source_paths();
|
|
33274
33481
|
clineAdapter = taskAdapter("cline", "Cline", "saoudrizwan.claude-dev", "SESSIONGRAPH_CLINE_HOME");
|
|
33275
33482
|
rooAdapter = taskAdapter("roo-code", "Roo Code", "rooveterinaryinc.roo-cline", "SESSIONGRAPH_ROO_HOME");
|
|
@@ -33284,17 +33491,17 @@ var init_extensions = __esm({
|
|
|
33284
33491
|
extras: (path) => [join18(dirname6(path), "sessions.json")],
|
|
33285
33492
|
revisionExtras: false,
|
|
33286
33493
|
parse(path, files) {
|
|
33287
|
-
const value =
|
|
33494
|
+
const value = object2(json3(files.get(path)));
|
|
33288
33495
|
if (!text2(value.sessionId) || !Array.isArray(value.history)) throw new Error("Unsupported Continue session.");
|
|
33289
|
-
const indexPath = join18(dirname6(path), "sessions.json"), index = files.has(indexPath) ?
|
|
33290
|
-
const meta = Array.isArray(index) ?
|
|
33496
|
+
const indexPath = join18(dirname6(path), "sessions.json"), index = files.has(indexPath) ? json3(files.get(indexPath)) : [];
|
|
33497
|
+
const meta = Array.isArray(index) ? object2(index.find((r) => r.sessionId === value.sessionId)) : {};
|
|
33291
33498
|
const messages = value.history.map((item, i) => {
|
|
33292
|
-
const row =
|
|
33499
|
+
const row = object2(item), raw = object2(row.message), message2 = conversationMessage(raw, `record:${i}`);
|
|
33293
33500
|
if (row.reasoning?.text) message2.events.push(eventFor(message2, "reasoning", "reasoning", "Recorded reasoning", text2(row.reasoning.text), { time: time(row.reasoning.startAt) || null, timeSource: time(row.reasoning.startAt) ? "recorded" : "unknown" }));
|
|
33294
33501
|
if (row.conversationSummary) message2.events.push(eventFor(message2, "summary", "compaction", "Conversation summary", text2(row.conversationSummary)));
|
|
33295
33502
|
return message2;
|
|
33296
33503
|
});
|
|
33297
|
-
const usage =
|
|
33504
|
+
const usage = object2(value.usage);
|
|
33298
33505
|
return {
|
|
33299
33506
|
nativeID: value.sessionId,
|
|
33300
33507
|
messages,
|
|
@@ -33330,7 +33537,7 @@ var init_harness_paths = __esm({
|
|
|
33330
33537
|
// server/adapters/harness-extra-formats.ts
|
|
33331
33538
|
import { basename as basename8, dirname as dirname7, join as join20 } from "node:path";
|
|
33332
33539
|
function kiroHistory(path, files) {
|
|
33333
|
-
const header =
|
|
33540
|
+
const header = object2(json3(files.get(path)));
|
|
33334
33541
|
const ide2 = basename8(path) === "session.json";
|
|
33335
33542
|
const nativeID = text2(header.session_id || header.sessionId || header.id) || (ide2 ? basename8(dirname7(path)) : "");
|
|
33336
33543
|
if (!nativeID) throw new Error("Unsupported Kiro session header.");
|
|
@@ -33339,12 +33546,12 @@ function kiroHistory(path, files) {
|
|
|
33339
33546
|
const { rows: rows2 } = jsonLines(files.get(side));
|
|
33340
33547
|
const messages = rows2.flatMap((r, i) => {
|
|
33341
33548
|
if (ide2) {
|
|
33342
|
-
const p =
|
|
33549
|
+
const p = object2(r.payload || r);
|
|
33343
33550
|
const role2 = p.type === "human" ? "user" : p.type === "ai" ? "assistant" : p.role || p.type;
|
|
33344
33551
|
const m3 = message({ ...p, role: role2 }, text2(p.id) || `message:${i}`, r.timestamp);
|
|
33345
33552
|
return m3 ? [m3] : [recordEvent(r, `event:${i}`, text2(p.type) || "Kiro event", r.timestamp, p.text)];
|
|
33346
33553
|
}
|
|
33347
|
-
const data =
|
|
33554
|
+
const data = object2(r.data), role = r.kind === "Prompt" ? "user" : r.kind === "AssistantMessage" ? "assistant" : r.kind === "ToolResults" ? "tool" : "";
|
|
33348
33555
|
if (!role) return [];
|
|
33349
33556
|
const content = Array.isArray(data.content) ? data.content.map((p) => p.kind === "text" ? { type: "text", text: p.data } : { type: "unsupported" }) : void 0;
|
|
33350
33557
|
const m = message({ role, content }, text2(data.message_id) || `message:${i}`, seconds(data.meta?.timestamp));
|
|
@@ -33388,7 +33595,7 @@ function muxHistory(path, files) {
|
|
|
33388
33595
|
function devinDesktopHistory(path, files) {
|
|
33389
33596
|
const { rows: rows2 } = jsonLines(files.get(path));
|
|
33390
33597
|
const normalized = rows2.flatMap((r) => {
|
|
33391
|
-
const n =
|
|
33598
|
+
const n = object2(r.notification);
|
|
33392
33599
|
return n.sessionUpdate ? [{ params: { sessionId: text2(r.sessionId || n.sessionId) || fileID(path).replace(/\.ndjson$/, ""), update: n }, timestamp: n.content?.metadata?.created_at ?? n.metadata?.created_at ?? n.timestamp ?? r.timestamp }] : [];
|
|
33393
33600
|
});
|
|
33394
33601
|
const history = acpHistory(path, normalized.map((r) => JSON.stringify(r)).join("\n"));
|
|
@@ -33430,7 +33637,7 @@ function museHistory(path, files) {
|
|
|
33430
33637
|
if (!meta || ids.size > 1) throw new Error("Unsupported Muse stream.");
|
|
33431
33638
|
const nativeID = [...ids][0] || basename9(dirname8(path));
|
|
33432
33639
|
const messages = rows2.flatMap((r, i) => {
|
|
33433
|
-
const event =
|
|
33640
|
+
const event = object2(r.payload?.event), body = object2(event.message);
|
|
33434
33641
|
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);
|
|
33435
33642
|
const m = message(body, nativeText(r.sequence) || `record:${i}`, at2);
|
|
33436
33643
|
if (m) return [m];
|
|
@@ -33447,7 +33654,7 @@ function museHistory(path, files) {
|
|
|
33447
33654
|
function junieHistory(path, files) {
|
|
33448
33655
|
const { rows: rows2 } = jsonLines(files.get(path));
|
|
33449
33656
|
const messages = rows2.flatMap((r, i) => {
|
|
33450
|
-
const e10 =
|
|
33657
|
+
const e10 = object2(r.event?.agentEvent || r.event), kind = text2(e10.kind);
|
|
33451
33658
|
if (!kind || /State|Snapshot/.test(kind)) return [];
|
|
33452
33659
|
return [recordEvent(r, text2(r.id) || `event:${i}`, kind, r.timestampMs, e10.text ?? e10.prompt ?? e10.message)];
|
|
33453
33660
|
});
|
|
@@ -33455,16 +33662,16 @@ function junieHistory(path, files) {
|
|
|
33455
33662
|
return { nativeID: basename9(dirname8(path)), messages, partial: true, note: "Junie recorded agent events. State snapshots and opaque event bodies are omitted; events without an authoritative message role are not counted as user turns." };
|
|
33456
33663
|
}
|
|
33457
33664
|
function augmentHistory(path, files) {
|
|
33458
|
-
const r =
|
|
33665
|
+
const r = object2(json3(files.get(path)));
|
|
33459
33666
|
if (!text2(r.sessionId) || !Array.isArray(r.chatHistory)) throw new Error("Unsupported Augment session.");
|
|
33460
33667
|
const messages = r.chatHistory.flatMap((turn, i) => {
|
|
33461
|
-
const exchange =
|
|
33668
|
+
const exchange = object2(turn.exchange), id2 = nativeText(turn.sequenceId) || `turn:${i}`;
|
|
33462
33669
|
return [recordEvent(turn, id2, turn.completed === true ? "Completed exchange" : "Incomplete exchange", turn.finishedAt, exchange.response_text)];
|
|
33463
33670
|
});
|
|
33464
33671
|
return { nativeID: r.sessionId, messages, partial: true, session: { title: text2(r.title), created: time(r.created), model: text2(r.agentState?.modelId) || "Unknown model" }, note: "Augment saved exchange records. Typed response-node payloads and absent prompts are not reconstructed into conversations." };
|
|
33465
33672
|
}
|
|
33466
33673
|
function fxHistory(path, files) {
|
|
33467
|
-
const usage =
|
|
33674
|
+
const usage = object2(json3(files.get(path))), meta = sidecar2(files, join21(dirname8(path), "session.json"));
|
|
33468
33675
|
const id2 = text2(usage.session_id) || text2(meta.id);
|
|
33469
33676
|
if (!id2 || !usage.snapshot || meta.id && meta.id !== id2) throw new Error("Unsupported Fx session metadata.");
|
|
33470
33677
|
return {
|
|
@@ -33529,7 +33736,7 @@ var init_harness_files = __esm({
|
|
|
33529
33736
|
const value = f.get(p), { rows: rows2 } = jsonLines(value), ids = new Set(rows2.map((r) => text2(r.sessionId)).filter(Boolean));
|
|
33530
33737
|
if (ids.size !== 1) throw new Error("Headless capture needs one explicit session identity.");
|
|
33531
33738
|
const messages = rows2.flatMap((r, i) => {
|
|
33532
|
-
const m = message(
|
|
33739
|
+
const m = message(object2(r.message), text2(r.message?.id) || `record:${i}`);
|
|
33533
33740
|
return m ? [m] : [];
|
|
33534
33741
|
});
|
|
33535
33742
|
return { nativeID: [...ids][0], messages, partial: true, note: "Previously captured MiniMax stream JSON only; no command is executed. User input and transient streaming records may be absent." };
|
|
@@ -33588,7 +33795,7 @@ function forkStore(id2, name, defaultPath, desktop) {
|
|
|
33588
33795
|
parse(db2, r) {
|
|
33589
33796
|
if (desktop !== void 0 && text2(r.version).startsWith("desktop-") !== desktop) return;
|
|
33590
33797
|
const messages = rows(db2, "message", ["id", "data", "time_created"], ["session_id", r.id], "time_created").map((m) => {
|
|
33591
|
-
const body =
|
|
33798
|
+
const body = object2(sqliteJSON(m.data));
|
|
33592
33799
|
let content = body.parts ?? body.content;
|
|
33593
33800
|
if (hasTable(db2, "part")) content = rows(db2, "part", ["id", "data"], ["message_id", m.id], "id").map((p) => sqliteJSON(p.data));
|
|
33594
33801
|
if (Array.isArray(content)) content = content.flatMap((p) => {
|
|
@@ -33665,9 +33872,9 @@ var init_harness_databases = __esm({
|
|
|
33665
33872
|
parse(db2, r) {
|
|
33666
33873
|
const events = rows(db2, "transcript_events", ["seq", "event_json", "event_zstd"], ["session_id", r.session_id], "seq");
|
|
33667
33874
|
const messages = events.flatMap((e10) => {
|
|
33668
|
-
const raw =
|
|
33875
|
+
const raw = object2(sqliteJSON(e10.event_json ?? e10.event_zstd));
|
|
33669
33876
|
if (raw.type !== "message") return [];
|
|
33670
|
-
const m = message(
|
|
33877
|
+
const m = message(object2(raw.message), text2(raw.id) || `event:${e10.seq}`, raw.timestamp ?? raw.message?.timestamp);
|
|
33671
33878
|
return m ? [m] : [];
|
|
33672
33879
|
});
|
|
33673
33880
|
return sessionHistory({ ...r, id: r.session_id, provider: r.model_provider }, messages, "OpenClaw authoritative transcript events, including zstd payloads. Database sessions take precedence over migrated JSONL copies. Session rollover and event-parent links are not session ancestry.");
|
|
@@ -33682,11 +33889,11 @@ var init_harness_databases = __esm({
|
|
|
33682
33889
|
fields: ["id", "summary", "created_at", "updated_at", "data_type", "data", "folder_paths"],
|
|
33683
33890
|
parse(db2, r) {
|
|
33684
33891
|
if (!["json", "zstd"].includes(r.data_type)) throw new Error("Unsupported Zed encoding.");
|
|
33685
|
-
const body =
|
|
33892
|
+
const body = object2(sqliteJSON(r.data));
|
|
33686
33893
|
if (body.imported === true) return;
|
|
33687
33894
|
if (!Array.isArray(body.messages)) throw new Error("Unsupported Zed thread.");
|
|
33688
33895
|
const messages = body.messages.map((raw, i) => {
|
|
33689
|
-
const user =
|
|
33896
|
+
const user = object2(raw.User), agent = object2(raw.Agent), b = raw.User ? user : agent;
|
|
33690
33897
|
if (!raw.User && !raw.Agent) return recordEvent(raw, `message:${i}`, "Context checkpoint", 0, raw.Compaction?.Summary);
|
|
33691
33898
|
const content = (Array.isArray(b.content) ? b.content : []).map((p) => typeof p.Text === "string" ? { type: "text", text: p.Text } : p.Thinking ? { type: "thinking", thinking: p.Thinking.text } : p.ToolUse ? { type: "tool_use", ...p.ToolUse } : { type: "unsupported" });
|
|
33692
33899
|
return conversationMessage({ role: raw.User ? "user" : "assistant", content }, text2(b.id) || `message:${i}`);
|
|
@@ -33704,7 +33911,7 @@ var init_harness_databases = __esm({
|
|
|
33704
33911
|
fields: ["id", "working_directory", "model", "title", "created_at", "last_activity_at"],
|
|
33705
33912
|
parse(db2, r) {
|
|
33706
33913
|
const messages = rows(db2, "message_nodes", ["node_id", "chat_message", "created_at"], ["session_id", r.id], "row_id").flatMap((m) => {
|
|
33707
|
-
const raw =
|
|
33914
|
+
const raw = object2(sqliteJSON(m.chat_message)), result = message(raw, nativeText(m.node_id), millisOrSeconds(m.created_at));
|
|
33708
33915
|
return result ? [result] : [recordEvent(raw, nativeText(m.node_id), "Devin message node", millisOrSeconds(m.created_at))];
|
|
33709
33916
|
});
|
|
33710
33917
|
return sessionHistory({ ...r, created_at: millisOrSeconds(r.created_at), updated_at: millisOrSeconds(r.last_activity_at) }, messages, "Devin saved message nodes. All retained in-session branches are included; node-parent edges are not session ancestry.");
|
|
@@ -33767,9 +33974,9 @@ var init_harness_databases = __esm({
|
|
|
33767
33974
|
const row = rows(db2, "llm_irs", ["json"], ["id", item.llm_ir_id], void 0, 1)[0];
|
|
33768
33975
|
bytes2 += text2(row?.json).length;
|
|
33769
33976
|
if (bytes2 > 32e6) throw new Error("Octofriend session exceeds the snapshot limit.");
|
|
33770
|
-
const payload =
|
|
33977
|
+
const payload = object2(sqliteJSON(row?.json));
|
|
33771
33978
|
if (payload.version !== "octo-llm-ir/v1") throw new Error("Unsupported Octofriend IR version.");
|
|
33772
|
-
const ir =
|
|
33979
|
+
const ir = object2(payload.ir), content = Array.isArray(ir.content) ? ir.content.map((p) => p.type === "text" ? { type: "text", text: p.content } : p) : ir.content;
|
|
33773
33980
|
const m = message({ ...ir, content, role: ir.role === "tool-output" ? "tool" : ir.role }, nativeText(node.id), node.created_at);
|
|
33774
33981
|
messages.push(m || recordEvent(ir, nativeText(node.id), text2(ir.role), node.created_at));
|
|
33775
33982
|
}
|
|
@@ -33803,13 +34010,13 @@ var init_harness_databases = __esm({
|
|
|
33803
34010
|
key: "conversation_id",
|
|
33804
34011
|
fields: ["key", "conversation_id", "value"],
|
|
33805
34012
|
parse(db2, r) {
|
|
33806
|
-
const body =
|
|
34013
|
+
const body = object2(sqliteJSON(r.value));
|
|
33807
34014
|
if (!Array.isArray(body.history)) throw new Error("Unsupported Kiro conversation.");
|
|
33808
34015
|
const messages = body.history.flatMap((turn, i) => {
|
|
33809
|
-
const result = [], input =
|
|
34016
|
+
const result = [], input = object2(turn.user?.content), output2 = object2(turn.assistant?.Response || turn.assistant?.ToolUse);
|
|
33810
34017
|
if (typeof input.Prompt?.prompt === "string") result.push(conversationMessage({ role: "user", content: input.Prompt.prompt }, `turn:${i}:user`));
|
|
33811
34018
|
if (input.ToolUseResults) result.push(conversationMessage({ role: "tool", content: input.ToolUseResults }, `turn:${i}:tool`));
|
|
33812
|
-
if (typeof
|
|
34019
|
+
if (typeof output2.content === "string") result.push(conversationMessage({ role: "assistant", content: output2.content, timestamp: turn.request_metadata?.stream_end_timestamp_ms }, `turn:${i}:assistant`));
|
|
33813
34020
|
return result;
|
|
33814
34021
|
});
|
|
33815
34022
|
const created = body.history.map((t) => time(t.request_metadata?.request_start_timestamp_ms)).find(Boolean);
|
|
@@ -33836,7 +34043,6 @@ var init_harness_databases = __esm({
|
|
|
33836
34043
|
// server/adapters/harness-metadata.ts
|
|
33837
34044
|
import { basename as basename10 } from "node:path";
|
|
33838
34045
|
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
33839
|
-
import { lstat as lstat7 } from "node:fs/promises";
|
|
33840
34046
|
function protoFields(value) {
|
|
33841
34047
|
if (value.length > 2e6) throw new Error("Trajectory metadata exceeds 2 MB.");
|
|
33842
34048
|
const fields2 = /* @__PURE__ */ new Map();
|
|
@@ -33867,7 +34073,7 @@ function protoFields(value) {
|
|
|
33867
34073
|
}
|
|
33868
34074
|
return fields2;
|
|
33869
34075
|
}
|
|
33870
|
-
var nested, antigravityDatabaseAdapters, antigravityCacheAdapter
|
|
34076
|
+
var nested, antigravityDatabaseAdapters, antigravityCacheAdapter;
|
|
33871
34077
|
var init_harness_metadata = __esm({
|
|
33872
34078
|
"server/adapters/harness-metadata.ts"() {
|
|
33873
34079
|
"use strict";
|
|
@@ -33890,15 +34096,15 @@ var init_harness_metadata = __esm({
|
|
|
33890
34096
|
const sec = timestamp.get(1), nano = timestamp.get(2);
|
|
33891
34097
|
const created = typeof sec === "bigint" && sec > 0n && sec < 8640000000000n ? time(Number(sec) * 1e3 + (typeof nano === "bigint" && nano < 1000000000n ? Number(nano) / 1e6 : 0)) : 0;
|
|
33892
34098
|
const uri = nested(fields2.get(1)).get(1);
|
|
33893
|
-
let
|
|
34099
|
+
let directory3 = "";
|
|
33894
34100
|
if (uri instanceof Uint8Array) {
|
|
33895
34101
|
try {
|
|
33896
|
-
|
|
34102
|
+
directory3 = fileURLToPath4(Buffer.from(uri).toString("utf8"));
|
|
33897
34103
|
} catch {
|
|
33898
34104
|
}
|
|
33899
34105
|
}
|
|
33900
34106
|
if (!created) throw new Error("Trajectory creation time is unavailable.");
|
|
33901
|
-
return { nativeID: basename10(path, ".db"), messages: [], partial: true, session: { created, directory:
|
|
34107
|
+
return { nativeID: basename10(path, ".db"), messages: [], partial: true, session: { created, directory: directory3 }, note: "Native Antigravity trajectory identity and creation metadata only. Protobuf conversation/step bodies are opaque; no message text, generation-time guesses, or usage-derived turns are imported." };
|
|
33902
34108
|
}
|
|
33903
34109
|
}));
|
|
33904
34110
|
antigravityCacheAdapter = localFileAdapter({
|
|
@@ -33917,28 +34123,6 @@ var init_harness_metadata = __esm({
|
|
|
33917
34123
|
return { nativeID: [...ids][0], messages: [], partial: true, session: { created, model: text2(rows2.find((r) => r.modelId)?.modelId) || "Unknown model" }, note: "Previously synced Antigravity session identity; placement uses earliest recorded usage date. This cache has no conversation bodies. SessionGraph never runs sync or contacts the language server." };
|
|
33918
34124
|
}
|
|
33919
34125
|
});
|
|
33920
|
-
usageOnlyAdapters = [
|
|
33921
|
-
{ id: "reasonix", name: "Reasonix", roots: () => [envHome("REASONIX_STATE_HOME", ".reasonix", "stats"), envHome("REASONIX_HOME", ".reasonix", "stats")], note: "Request statistics lack conversation identities and text. Reasonix transcript import is not yet supported." },
|
|
33922
|
-
{ id: "trae", name: "Trae / Trae Solo", roots: () => [tokscalePath("trae-cache/sessions")], note: "The Tokscale cache contains account usage, not local conversations." },
|
|
33923
|
-
{ id: "warp", name: "Warp / Oz", roots: () => [tokscalePath("warp-cache")], note: "The Tokscale cache contains aggregate requests and spend, not local conversations." },
|
|
33924
|
-
{ id: "lm-studio", name: "LM Studio", roots: () => [envHome("LM_STUDIO_HOME", ".lmstudio", "server-logs")], note: "Server logs contain final-response usage, not retained prompts or responses." },
|
|
33925
|
-
{ id: "hindsight", name: "Hindsight", roots: () => [envHome("HINDSIGHT_HOME", ".hindsight", "usage")], note: "Synced memory-operation usage is not agent conversation history." }
|
|
33926
|
-
].map((source) => ({
|
|
33927
|
-
id: source.id,
|
|
33928
|
-
name: source.name,
|
|
33929
|
-
description: `Detection only \xB7 ${source.note}`,
|
|
33930
|
-
capabilities: { history: false, forks: false, children: false, files: false },
|
|
33931
|
-
async detect() {
|
|
33932
|
-
for (const p of harnessRoots(source.id, source.roots)()) if ((await lstat7(p).catch(() => void 0))?.isDirectory()) return true;
|
|
33933
|
-
return false;
|
|
33934
|
-
},
|
|
33935
|
-
async discover() {
|
|
33936
|
-
return { sessions: [], projects: [], warnings: [source.note] };
|
|
33937
|
-
},
|
|
33938
|
-
async read() {
|
|
33939
|
-
throw new Error(source.note);
|
|
33940
|
-
}
|
|
33941
|
-
}));
|
|
33942
34126
|
}
|
|
33943
34127
|
});
|
|
33944
34128
|
|
|
@@ -33966,7 +34150,7 @@ var init_adapters = __esm({
|
|
|
33966
34150
|
init_harness_databases();
|
|
33967
34151
|
init_harness_metadata();
|
|
33968
34152
|
init_sqlite_histories();
|
|
33969
|
-
extra = [...databaseHarnessAdapters, ...fileHarnessAdapters, antigravityCacheAdapter, ...antigravityDatabaseAdapters
|
|
34153
|
+
extra = [...databaseHarnessAdapters, ...fileHarnessAdapters, antigravityCacheAdapter, ...antigravityDatabaseAdapters];
|
|
33970
34154
|
grouped = /* @__PURE__ */ new Map();
|
|
33971
34155
|
for (const adapter of extra) grouped.set(adapter.id, [...grouped.get(adapter.id) || [], adapter]);
|
|
33972
34156
|
adapters = [opencodeAdapter, claudeAdapter, codexAdapter, t3CodeAdapter, cursorAdapter, geminiAdapter, qwenAdapter, piAdapter, copilotAdapter, copilotChatAdapter, clineAdapter, rooAdapter, kiloAdapter, continueAdapter, ...[...grouped.values()].map((parts) => parts.length === 1 ? parts[0] : combineAdapters(parts))];
|
|
@@ -34011,197 +34195,12 @@ init_activity();
|
|
|
34011
34195
|
// server/event-store.ts
|
|
34012
34196
|
init_events();
|
|
34013
34197
|
import { randomUUID } from "node:crypto";
|
|
34014
|
-
var EVENT_SCHEMA = `CREATE TABLE IF NOT EXISTS timeline_items (
|
|
34015
|
-
session_id TEXT NOT NULL REFERENCES sessions(id) ON DELETE CASCADE, id TEXT NOT NULL, message_id TEXT NOT NULL,
|
|
34016
|
-
ordinal INTEGER NOT NULL, kind TEXT NOT NULL, role TEXT, time REAL, call_id TEXT, name TEXT NOT NULL, preview TEXT NOT NULL, data TEXT NOT NULL,
|
|
34017
|
-
PRIMARY KEY(session_id,id));
|
|
34018
|
-
CREATE INDEX IF NOT EXISTS timeline_order ON timeline_items(session_id,ordinal);
|
|
34019
|
-
CREATE INDEX IF NOT EXISTS timeline_time ON timeline_items(session_id,time);
|
|
34020
|
-
CREATE INDEX IF NOT EXISTS timeline_calls ON timeline_items(session_id,call_id);
|
|
34021
|
-
CREATE TABLE IF NOT EXISTS timeline_coverage (session_id TEXT PRIMARY KEY REFERENCES sessions(id) ON DELETE CASCADE, partial INTEGER NOT NULL, note TEXT, revision TEXT NOT NULL);`;
|
|
34022
|
-
function writeEvents(db2, id2, rows2) {
|
|
34023
|
-
db2.prepare("DELETE FROM timeline_items WHERE session_id=?").run(id2);
|
|
34024
|
-
const insert = db2.prepare("INSERT OR IGNORE INTO timeline_items VALUES (?,?,?,?,?,?,?,?,?,?,?)");
|
|
34025
|
-
let ordinal = 0, bytes2 = 0, partial = false, legacy = false, limited = false;
|
|
34026
|
-
for (const row of rows2) {
|
|
34027
|
-
const message2 = JSON.parse(String(row.data));
|
|
34028
|
-
legacy ||= !message2.events;
|
|
34029
|
-
for (const event of normalizedEvents(message2, id2)) {
|
|
34030
|
-
const item = { ...event, ordinal: ordinal++ }, data = JSON.stringify(item);
|
|
34031
|
-
bytes2 += Buffer.byteLength(data);
|
|
34032
|
-
if (ordinal > 2e5 || bytes2 > 32e6) {
|
|
34033
|
-
limited = true;
|
|
34034
|
-
break;
|
|
34035
|
-
}
|
|
34036
|
-
partial ||= Boolean(item.partial);
|
|
34037
|
-
const preview = (item.text || item.input || item.output || item.name).replace(/\s+/g, " ").slice(0, 180);
|
|
34038
|
-
insert.run(id2, item.id, item.messageID, item.ordinal, item.kind, item.role || null, item.time, item.callID || null, item.name, preview, data);
|
|
34039
|
-
}
|
|
34040
|
-
if (limited) break;
|
|
34041
|
-
}
|
|
34042
|
-
const note = [legacy ? "Some items were reconstructed from an older flattened import; tool inputs/results cannot be paired there. Refresh sources to import structured events." : "", limited ? "Event history limited to 200,000 items / 32 MB per session." : "", partial ? "Some event content is missing, unsupported, or shortened." : ""].filter(Boolean).join(" ");
|
|
34043
|
-
db2.prepare("INSERT OR REPLACE INTO timeline_coverage VALUES (?,?,?,?)").run(id2, Number(partial || legacy || limited), note || null, randomUUID());
|
|
34044
|
-
}
|
|
34045
|
-
var summaryColumns = "id,kind,role,name,time,ordinal,preview,json_extract(data,'$.timeSource') AS timeSource,json_extract(data,'$.status') AS status,json_extract(data,'$.partial') AS partial";
|
|
34046
|
-
function eventSummary(row) {
|
|
34047
|
-
return { id: String(row.id), kind: row.kind, role: row.role, name: String(row.name), time: row.time === null ? null : Number(row.time), timeSource: row.timeSource, ordinal: Number(row.ordinal), preview: String(row.preview), status: row.status, partial: Boolean(row.partial) };
|
|
34048
|
-
}
|
|
34049
|
-
var EventReadError = class extends Error {
|
|
34050
|
-
constructor(message2, status2) {
|
|
34051
|
-
super(message2);
|
|
34052
|
-
this.status = status2;
|
|
34053
|
-
}
|
|
34054
|
-
status;
|
|
34055
|
-
};
|
|
34056
|
-
var filters = { all: "1", messages: "kind='message' AND role IN ('user','assistant')", tools: "kind IN ('tool_call','tool_result')", events: "kind NOT IN ('message','tool_call','tool_result')", untimed: "time IS NULL" };
|
|
34057
|
-
function coverage(db2, session) {
|
|
34058
|
-
const row = db2.prepare("SELECT * FROM timeline_coverage WHERE session_id=?").get(session.id);
|
|
34059
|
-
return { revision: String(row?.revision || "pending"), partial: Boolean(row?.partial) || session.coverage?.history !== "complete", note: [row?.note, session.coverage?.note].filter(Boolean).join(" ") || void 0 };
|
|
34060
|
-
}
|
|
34061
|
-
function readEventMarkers(db2, session) {
|
|
34062
|
-
const end = Math.max(session.created, session.activity?.lastMessageAt || session.created);
|
|
34063
|
-
const totals = db2.prepare(`SELECT count(*) AS total, count(*) FILTER (WHERE time IS NULL) AS untimed, count(*) FILTER (WHERE time<? OR time>?) AS outside FROM timeline_items WHERE session_id=? AND (${filters.messages})`).get(session.created, end, session.id);
|
|
34064
|
-
const rows2 = db2.prepare(`SELECT ${summaryColumns} FROM timeline_items WHERE session_id=? AND (${filters.messages}) AND time>=? AND time<=? ORDER BY time DESC,ordinal DESC`).all(session.id, session.created, end);
|
|
34065
|
-
return { sessionID: session.id, ...coverage(db2, session), items: rows2.reverse().map(eventSummary), total: Number(totals.total), untimed: Number(totals.untimed), outsideLifetime: Number(totals.outside), limited: Number(totals.total) - Number(totals.untimed) - Number(totals.outside) > rows2.length };
|
|
34066
|
-
}
|
|
34067
|
-
function readEvents(db2, session, options = {}) {
|
|
34068
|
-
const state2 = coverage(db2, session), filter = options.filter || "all", size = 60;
|
|
34069
|
-
if (!Object.hasOwn(filters, filter)) throw new EventReadError("Invalid event filter.", 400);
|
|
34070
|
-
const where = filters[filter];
|
|
34071
|
-
if (options.revision && options.revision !== state2.revision) throw new EventReadError("Saved history changed. Reload the event explorer.", 409);
|
|
34072
|
-
let offset = 0;
|
|
34073
|
-
if (options.cursor) {
|
|
34074
|
-
try {
|
|
34075
|
-
if (options.cursor.length > 512) throw new Error();
|
|
34076
|
-
const cursor2 = JSON.parse(Buffer.from(options.cursor, "base64url").toString());
|
|
34077
|
-
if (!Number.isSafeInteger(cursor2.offset) || cursor2.offset < 0 || cursor2.offset > 2e5 || cursor2.filter !== filter || typeof cursor2.revision !== "string") throw new Error();
|
|
34078
|
-
if (cursor2.revision !== state2.revision) throw new EventReadError("Saved history changed. Reload the event explorer.", 409);
|
|
34079
|
-
offset = cursor2.offset;
|
|
34080
|
-
} catch (error) {
|
|
34081
|
-
if (error instanceof EventReadError) throw error;
|
|
34082
|
-
throw new EventReadError("Invalid event cursor.", 400);
|
|
34083
|
-
}
|
|
34084
|
-
}
|
|
34085
|
-
let selected;
|
|
34086
|
-
if (options.item) {
|
|
34087
|
-
const row = db2.prepare(`SELECT data FROM timeline_items WHERE session_id=? AND id=? AND (${where})`).get(session.id, options.item);
|
|
34088
|
-
if (!row) throw new EventReadError("This event is not in the saved session or current filter.", 404);
|
|
34089
|
-
selected = JSON.parse(String(row.data));
|
|
34090
|
-
const before = Number(db2.prepare(`SELECT count(*) AS n FROM timeline_items WHERE session_id=? AND ordinal<? AND (${where})`).get(session.id, selected.ordinal).n);
|
|
34091
|
-
offset = Math.floor(before / size) * size;
|
|
34092
|
-
}
|
|
34093
|
-
const total = Number(db2.prepare(`SELECT count(*) AS n FROM timeline_items WHERE session_id=? AND (${where})`).get(session.id).n);
|
|
34094
|
-
const items = db2.prepare(`SELECT ${summaryColumns} FROM timeline_items WHERE session_id=? AND (${where}) ORDER BY ordinal LIMIT ? OFFSET ?`).all(session.id, size, offset).map(eventSummary);
|
|
34095
|
-
if (!selected && items.length) selected = JSON.parse(String(db2.prepare("SELECT data FROM timeline_items WHERE session_id=? AND id=?").get(session.id, items[0].id).data));
|
|
34096
|
-
const related = selected?.callID ? db2.prepare(`SELECT ${summaryColumns} FROM timeline_items WHERE session_id=? AND call_id=? AND id<>? ORDER BY ordinal LIMIT 21`).all(session.id, selected.callID, selected.id).map(eventSummary) : [];
|
|
34097
|
-
const previousItem = selected ? db2.prepare(`SELECT id FROM timeline_items WHERE session_id=? AND ordinal<? AND (${where}) ORDER BY ordinal DESC LIMIT 1`).get(session.id, selected.ordinal)?.id : void 0;
|
|
34098
|
-
const nextItem = selected ? db2.prepare(`SELECT id FROM timeline_items WHERE session_id=? AND ordinal>? AND (${where}) ORDER BY ordinal LIMIT 1`).get(session.id, selected.ordinal)?.id : void 0;
|
|
34099
|
-
const cursor = (position) => Buffer.from(JSON.stringify({ revision: state2.revision, filter, offset: position })).toString("base64url");
|
|
34100
|
-
return {
|
|
34101
|
-
sessionID: session.id,
|
|
34102
|
-
...state2,
|
|
34103
|
-
items,
|
|
34104
|
-
total,
|
|
34105
|
-
offset,
|
|
34106
|
-
selected,
|
|
34107
|
-
related: related.slice(0, 20),
|
|
34108
|
-
relatedPartial: related.length > 20,
|
|
34109
|
-
previousItem: previousItem ? String(previousItem) : void 0,
|
|
34110
|
-
nextItem: nextItem ? String(nextItem) : void 0,
|
|
34111
|
-
nextCursor: offset + size < total ? cursor(offset + size) : null,
|
|
34112
|
-
previousCursor: offset > 0 ? cursor(Math.max(0, offset - size)) : null
|
|
34113
|
-
};
|
|
34114
|
-
}
|
|
34115
34198
|
|
|
34116
|
-
// packages/core/src/
|
|
34117
|
-
var
|
|
34118
|
-
autoImport: true,
|
|
34119
|
-
muted: false,
|
|
34120
|
-
clickSounds: true,
|
|
34121
|
-
clickVolume: 35,
|
|
34122
|
-
motion: "system",
|
|
34123
|
-
view: "3d",
|
|
34124
|
-
density: "comfortable",
|
|
34125
|
-
panelOpacity: 90,
|
|
34126
|
-
quality: "balanced",
|
|
34127
|
-
bloom: 32,
|
|
34128
|
-
stars: true,
|
|
34129
|
-
labels: true,
|
|
34130
|
-
nodeScale: 100,
|
|
34131
|
-
focusDimming: true,
|
|
34132
|
-
trails: "all",
|
|
34133
|
-
trailOpacity: 34,
|
|
34134
|
-
trailFlow: false,
|
|
34135
|
-
trailSpeed: 25,
|
|
34136
|
-
relationships: true,
|
|
34137
|
-
messageDots: true,
|
|
34138
|
-
playbackSpeed: 1
|
|
34139
|
-
});
|
|
34140
|
-
var choices = { motion: ["system", "on", "off"], view: ["3d", "2d"], density: ["comfortable", "compact"], quality: ["performance", "balanced", "high"], trails: ["all", "selected", "off"] };
|
|
34141
|
-
var ranges = { clickVolume: [0, 100], panelOpacity: [55, 100], bloom: [0, 75], nodeScale: [60, 180], trailOpacity: [0, 100], trailSpeed: [10, 100], playbackSpeed: [0.25, 3] };
|
|
34142
|
-
function normalizePreferences(value) {
|
|
34143
|
-
const result = { ...DEFAULT_PREFERENCES };
|
|
34144
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) return result;
|
|
34145
|
-
const input = value;
|
|
34146
|
-
for (const key of Object.keys(result)) {
|
|
34147
|
-
const item = input[key];
|
|
34148
|
-
if (key in choices) {
|
|
34149
|
-
if (choices[key].includes(item)) Object.assign(result, { [key]: item });
|
|
34150
|
-
} else if (key in ranges) {
|
|
34151
|
-
const [min, max] = ranges[key];
|
|
34152
|
-
if (typeof item === "number" && Number.isFinite(item)) Object.assign(result, { [key]: Math.max(min, Math.min(max, item)) });
|
|
34153
|
-
} else if (typeof item === "boolean") Object.assign(result, { [key]: item });
|
|
34154
|
-
}
|
|
34155
|
-
return result;
|
|
34156
|
-
}
|
|
34199
|
+
// packages/core/src/commits.ts
|
|
34200
|
+
var abbreviatedSHA = (sha) => sha.length !== 40 && sha.length !== 64;
|
|
34157
34201
|
|
|
34158
|
-
//
|
|
34159
|
-
|
|
34160
|
-
sourceID: "",
|
|
34161
|
-
projectID: "",
|
|
34162
|
-
directory: "",
|
|
34163
|
-
days: 0,
|
|
34164
|
-
fromDate: "",
|
|
34165
|
-
toDate: "",
|
|
34166
|
-
includeChildren: true,
|
|
34167
|
-
includeArchived: false
|
|
34168
|
-
});
|
|
34169
|
-
var validDate = (value) => typeof value === "string" && /^\d{4}-\d{2}-\d{2}$/.test(value) && Number.isFinite(Date.parse(value)) && new Date(value).toISOString().slice(0, 10) === value;
|
|
34170
|
-
function normalizeViewState(value) {
|
|
34171
|
-
const result = { ...DEFAULT_VIEW_STATE };
|
|
34172
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) return result;
|
|
34173
|
-
const input = value;
|
|
34174
|
-
for (const key of ["sourceID", "projectID", "directory"]) if (typeof input[key] === "string" && input[key].length <= 4096) result[key] = input[key];
|
|
34175
|
-
if ([0, 7, 30, 90].includes(input.days)) result.days = input.days;
|
|
34176
|
-
for (const key of ["includeChildren", "includeArchived"]) if (typeof input[key] === "boolean") result[key] = input[key];
|
|
34177
|
-
for (const key of ["fromDate", "toDate"]) if (validDate(input[key])) result[key] = input[key];
|
|
34178
|
-
if (result.fromDate && result.toDate && result.fromDate > result.toDate) {
|
|
34179
|
-
result.fromDate = "";
|
|
34180
|
-
result.toDate = "";
|
|
34181
|
-
}
|
|
34182
|
-
return result;
|
|
34183
|
-
}
|
|
34184
|
-
|
|
34185
|
-
// src/session-links.ts
|
|
34186
|
-
function visibleSessions(sessions) {
|
|
34187
|
-
const owners = /* @__PURE__ */ new Map();
|
|
34188
|
-
for (const session of sessions) {
|
|
34189
|
-
if (session.source !== "t3-code") continue;
|
|
34190
|
-
for (const id2 of new Set(session.linkedSessionIDs || [])) owners.set(id2, [...owners.get(id2) || [], session]);
|
|
34191
|
-
}
|
|
34192
|
-
const unique = new Map([...owners].flatMap(([native, claims]) => {
|
|
34193
|
-
const owner = claims[0];
|
|
34194
|
-
return claims.length === 1 && ["complete", "partial"].includes(owner.coverage?.history || "") && owner.activity?.userMessages ? [[native, owner.id]] : [];
|
|
34195
|
-
}));
|
|
34196
|
-
return sessions.filter((session) => !unique.has(session.id)).map((session) => ({
|
|
34197
|
-
...session,
|
|
34198
|
-
parentID: session.parentID ? unique.get(session.parentID) || session.parentID : void 0,
|
|
34199
|
-
forkID: session.forkID ? unique.get(session.forkID) || session.forkID : void 0
|
|
34200
|
-
}));
|
|
34201
|
-
}
|
|
34202
|
-
function sessionMatchesSource(session, source) {
|
|
34203
|
-
return !source || session.source === source || Boolean(session.source === "t3-code" && session.linkedSessionIDs?.some((id2) => id2.startsWith(`${source}:`)));
|
|
34204
|
-
}
|
|
34202
|
+
// server/commit-store.ts
|
|
34203
|
+
init_commit_extraction();
|
|
34205
34204
|
|
|
34206
34205
|
// server/library-query.ts
|
|
34207
34206
|
import { createHash as createHash2 } from "node:crypto";
|
|
@@ -34218,10 +34217,10 @@ function hash(text3) {
|
|
|
34218
34217
|
value ^= value >>> 16;
|
|
34219
34218
|
return (value >>> 0) / 4294967295;
|
|
34220
34219
|
}
|
|
34221
|
-
function directoryLabel(
|
|
34222
|
-
return directoryPath(
|
|
34220
|
+
function directoryLabel(directory3) {
|
|
34221
|
+
return directoryPath(directory3).split("/").at(-1) || "/";
|
|
34223
34222
|
}
|
|
34224
|
-
var directoryPath = (
|
|
34223
|
+
var directoryPath = (directory3) => (/^(?:[a-z]:[\\/]|\\\\)/i.test(directory3) ? directory3.replace(/\\/g, "/") : directory3).replace(/\/+$/, "") || (directory3.startsWith("/") ? "/" : "");
|
|
34225
34224
|
var laneKey = (session) => session.directory ? JSON.stringify(["directory", directoryPath(session.directory)]) : JSON.stringify(["project", session.source || "opencode", session.projectID || session.id]);
|
|
34226
34225
|
var sessionEnd = (session) => Math.max(session.created, session.activity?.lastMessageAt || session.created);
|
|
34227
34226
|
var timeX = (time3, graph) => {
|
|
@@ -34258,13 +34257,13 @@ function makeGraph(sessions, projects, previous) {
|
|
|
34258
34257
|
const z4 = Math.sin(angle) * distance * 0.7;
|
|
34259
34258
|
const color = PALETTE[index % PALETTE.length];
|
|
34260
34259
|
const project2 = projects.find((p) => p.id === group[0].projectID);
|
|
34261
|
-
const
|
|
34260
|
+
const directory3 = group[0].directory;
|
|
34262
34261
|
const lane = {
|
|
34263
34262
|
key,
|
|
34264
34263
|
slot: index,
|
|
34265
|
-
label:
|
|
34264
|
+
label: directory3 ? directoryLabel(directory3) : project2?.name || group[0].projectID || "Unknown directory",
|
|
34266
34265
|
color,
|
|
34267
|
-
kind:
|
|
34266
|
+
kind: directory3 && worktrees.has(directoryPath(directory3)) ? "worktree" : "directory",
|
|
34268
34267
|
y,
|
|
34269
34268
|
z: z4,
|
|
34270
34269
|
nodes: []
|
|
@@ -34335,12 +34334,33 @@ function makeGraph(sessions, projects, previous) {
|
|
|
34335
34334
|
return { nodes, edges, lanes, start, end, timeFrame };
|
|
34336
34335
|
}
|
|
34337
34336
|
|
|
34337
|
+
// src/session-links.ts
|
|
34338
|
+
function visibleSessions(sessions) {
|
|
34339
|
+
const owners = /* @__PURE__ */ new Map();
|
|
34340
|
+
for (const session of sessions) {
|
|
34341
|
+
if (session.source !== "t3-code") continue;
|
|
34342
|
+
for (const id2 of new Set(session.linkedSessionIDs || [])) owners.set(id2, [...owners.get(id2) || [], session]);
|
|
34343
|
+
}
|
|
34344
|
+
const unique = new Map([...owners].flatMap(([native, claims]) => {
|
|
34345
|
+
const owner = claims[0];
|
|
34346
|
+
return claims.length === 1 && ["complete", "partial"].includes(owner.coverage?.history || "") && owner.activity?.userMessages ? [[native, owner.id]] : [];
|
|
34347
|
+
}));
|
|
34348
|
+
return sessions.filter((session) => !unique.has(session.id)).map((session) => ({
|
|
34349
|
+
...session,
|
|
34350
|
+
parentID: session.parentID ? unique.get(session.parentID) || session.parentID : void 0,
|
|
34351
|
+
forkID: session.forkID ? unique.get(session.forkID) || session.forkID : void 0
|
|
34352
|
+
}));
|
|
34353
|
+
}
|
|
34354
|
+
function sessionMatchesSource(session, source) {
|
|
34355
|
+
return !source || session.source === source || Boolean(session.source === "t3-code" && session.linkedSessionIDs?.some((id2) => id2.startsWith(`${source}:`)));
|
|
34356
|
+
}
|
|
34357
|
+
|
|
34338
34358
|
// server/library-query.ts
|
|
34339
34359
|
var LibraryError = class extends Error {
|
|
34340
|
-
constructor(code, message2,
|
|
34360
|
+
constructor(code, message2, exitCode2 = 1) {
|
|
34341
34361
|
super(message2);
|
|
34342
34362
|
this.code = code;
|
|
34343
|
-
this.exitCode =
|
|
34363
|
+
this.exitCode = exitCode2;
|
|
34344
34364
|
}
|
|
34345
34365
|
code;
|
|
34346
34366
|
exitCode;
|
|
@@ -34406,7 +34426,272 @@ function parseDate(value, now, endOfDay = false) {
|
|
|
34406
34426
|
return time3 + (dateOnly && endOfDay ? 864e5 - 1 : 0);
|
|
34407
34427
|
}
|
|
34408
34428
|
|
|
34429
|
+
// server/commit-store.ts
|
|
34430
|
+
var COMMIT_SCHEMA = `CREATE TABLE IF NOT EXISTS session_commits (
|
|
34431
|
+
session_id TEXT NOT NULL REFERENCES sessions(id) ON DELETE CASCADE,
|
|
34432
|
+
sha TEXT NOT NULL, repository_path TEXT NOT NULL, operation TEXT NOT NULL,
|
|
34433
|
+
occurred_at REAL, evidence_event_id TEXT NOT NULL,
|
|
34434
|
+
PRIMARY KEY(session_id,repository_path,sha,operation),
|
|
34435
|
+
FOREIGN KEY(session_id,evidence_event_id) REFERENCES timeline_items(session_id,id) ON DELETE CASCADE);
|
|
34436
|
+
CREATE INDEX IF NOT EXISTS session_commits_time ON session_commits(session_id,occurred_at);`;
|
|
34437
|
+
var supported = /* @__PURE__ */ new Set(["opencode", "t3-code", "codex", "claude-code"]);
|
|
34438
|
+
var pendingCommits = () => ({ version: 0, state: "pending", count: null, note: "Refresh sources to index recorded commit operations." });
|
|
34439
|
+
function writeCommits(db2, session) {
|
|
34440
|
+
db2.prepare("DELETE FROM session_commits WHERE session_id=?").run(session.id);
|
|
34441
|
+
const base = { version: COMMIT_EXTRACTOR_VERSION, indexedAt: Date.now() };
|
|
34442
|
+
if (!supported.has(session.source || "")) return { ...base, state: "unavailable", count: null, note: "Commit attribution is not validated for this source format." };
|
|
34443
|
+
const calls = /* @__PURE__ */ new Map();
|
|
34444
|
+
const results = /* @__PURE__ */ new Map();
|
|
34445
|
+
const rows2 = () => db2.prepare("SELECT data FROM timeline_items WHERE session_id=? AND kind IN ('tool_call','tool_result') ORDER BY ordinal").iterate(session.id);
|
|
34446
|
+
let tools = 0, partial = session.coverage?.history !== "complete" || Boolean(db2.prepare("SELECT partial FROM timeline_coverage WHERE session_id=?").get(session.id)?.partial);
|
|
34447
|
+
for (const row of rows2()) {
|
|
34448
|
+
const item = JSON.parse(String(row.data));
|
|
34449
|
+
tools++;
|
|
34450
|
+
if (item.kind === "tool_result" && item.callID) {
|
|
34451
|
+
const signature = fingerprint([item.output, item.exitCode, item.status, item.gitCommit]);
|
|
34452
|
+
results.set(item.callID, results.has(item.callID) && results.get(item.callID) !== signature ? null : signature);
|
|
34453
|
+
}
|
|
34454
|
+
if (item.kind !== "tool_call" || !item.callID) continue;
|
|
34455
|
+
calls.set(item.callID, calls.has(item.callID) ? null : item);
|
|
34456
|
+
}
|
|
34457
|
+
const completed = /* @__PURE__ */ new Set();
|
|
34458
|
+
const insert = db2.prepare("INSERT OR IGNORE INTO session_commits VALUES (?,?,?,?,?,?)");
|
|
34459
|
+
for (const row of rows2()) {
|
|
34460
|
+
const item = JSON.parse(String(row.data));
|
|
34461
|
+
if (item.kind !== "tool_result") continue;
|
|
34462
|
+
const call = item.input ? item : item.callID ? calls.get(item.callID) : void 0;
|
|
34463
|
+
if (!call || call !== item && call.ordinal >= item.ordinal || item.callID && results.get(item.callID) === null) {
|
|
34464
|
+
partial = true;
|
|
34465
|
+
continue;
|
|
34466
|
+
}
|
|
34467
|
+
if (item.callID) completed.add(item.callID);
|
|
34468
|
+
const extracted = extractCommit(call, item);
|
|
34469
|
+
if (!extracted.candidate) continue;
|
|
34470
|
+
const time3 = item.endTime ?? item.time;
|
|
34471
|
+
if (time3 !== null && time3 < session.created || session.forkID && (time3 === null || time3 <= session.created || call.time === null || call.time < session.created)) {
|
|
34472
|
+
partial = true;
|
|
34473
|
+
continue;
|
|
34474
|
+
}
|
|
34475
|
+
if (!extracted.commit) {
|
|
34476
|
+
partial = true;
|
|
34477
|
+
continue;
|
|
34478
|
+
}
|
|
34479
|
+
const { sha, repositoryPath, operation: operation2 } = extracted.commit;
|
|
34480
|
+
insert.run(session.id, sha, repositoryPath, operation2, time3, item.id);
|
|
34481
|
+
}
|
|
34482
|
+
for (const [id2, call] of calls) if (call && !completed.has(id2) && /\bgit\b[\s\S]*\b(?:commit|cherry-pick)\b/.test(call.input || "")) partial = true;
|
|
34483
|
+
const count = Number(db2.prepare("SELECT count(*) AS n FROM session_commits WHERE session_id=?").get(session.id).n);
|
|
34484
|
+
return {
|
|
34485
|
+
...base,
|
|
34486
|
+
state: !tools ? "unavailable" : partial ? "partial" : "indexed",
|
|
34487
|
+
count: !tools ? null : count,
|
|
34488
|
+
note: !tools ? "No usable tool executions recorded; commit history is unknown." : `${partial ? "Some execution evidence is missing, ambiguous, inherited, or unsupported. " : ""}Confirmed recorded operations only; absence is not proof that no commits occurred. Paths are execution directories; abbreviated SHAs remain unresolved. Linked provider histories retain their own attribution.`
|
|
34489
|
+
};
|
|
34490
|
+
}
|
|
34491
|
+
function commit(row) {
|
|
34492
|
+
return { sessionID: String(row.session_id), sha: String(row.sha), repositoryPath: String(row.repository_path), operation: row.operation, occurredAt: row.occurred_at === null ? null : Number(row.occurred_at), evidenceEventID: String(row.evidence_event_id) };
|
|
34493
|
+
}
|
|
34494
|
+
function readCommits(db2, session, options = {}) {
|
|
34495
|
+
let coverage2 = session.commits || pendingCommits();
|
|
34496
|
+
if (session.coverage?.note?.startsWith("Latest import failed:")) coverage2 = { ...coverage2, state: coverage2.count === null ? coverage2.state : "partial", note: `${session.coverage.note} ${coverage2.note}` };
|
|
34497
|
+
const revision2 = String(db2.prepare("SELECT revision FROM timeline_coverage WHERE session_id=?").get(session.id)?.revision || "pending");
|
|
34498
|
+
const key = fingerprint(["commits", session.id, revision2, coverage2]), offset = pageOffset(options.cursor, key), limit = pageLimit(options.limit);
|
|
34499
|
+
const total = Number(db2.prepare("SELECT count(*) AS n FROM session_commits WHERE session_id=?").get(session.id).n);
|
|
34500
|
+
const items = db2.prepare("SELECT * FROM session_commits WHERE session_id=? ORDER BY occurred_at IS NULL,occurred_at,repository_path,sha,operation LIMIT ? OFFSET ?").all(session.id, limit, offset).map(commit);
|
|
34501
|
+
return { sessionID: session.id, revision: revision2, coverage: coverage2, items, total, nextCursor: offset + limit < total ? nextCursor(key, offset + limit) : null };
|
|
34502
|
+
}
|
|
34503
|
+
function commitMarkers(db2, session) {
|
|
34504
|
+
const end = Math.max(session.created, session.activity?.lastMessageAt || session.created);
|
|
34505
|
+
return db2.prepare("SELECT * FROM session_commits WHERE session_id=? AND occurred_at>=? AND occurred_at<=? ORDER BY occurred_at,sha LIMIT 2000").all(session.id, session.created, end).map((row, ordinal) => {
|
|
34506
|
+
const value = commit(row);
|
|
34507
|
+
return {
|
|
34508
|
+
id: value.evidenceEventID,
|
|
34509
|
+
kind: "commit",
|
|
34510
|
+
name: `${value.operation} ${value.sha}`,
|
|
34511
|
+
time: value.occurredAt,
|
|
34512
|
+
timeSource: "recorded",
|
|
34513
|
+
ordinal,
|
|
34514
|
+
preview: `${value.repositoryPath}
|
|
34515
|
+
${abbreviatedSHA(value.sha) ? "Abbreviated SHA \xB7 " : ""}Open recorded execution evidence`
|
|
34516
|
+
};
|
|
34517
|
+
});
|
|
34518
|
+
}
|
|
34519
|
+
|
|
34520
|
+
// server/event-store.ts
|
|
34521
|
+
var EVENT_SCHEMA = `CREATE TABLE IF NOT EXISTS timeline_items (
|
|
34522
|
+
session_id TEXT NOT NULL REFERENCES sessions(id) ON DELETE CASCADE, id TEXT NOT NULL, message_id TEXT NOT NULL,
|
|
34523
|
+
ordinal INTEGER NOT NULL, kind TEXT NOT NULL, role TEXT, time REAL, call_id TEXT, name TEXT NOT NULL, preview TEXT NOT NULL, data TEXT NOT NULL,
|
|
34524
|
+
PRIMARY KEY(session_id,id));
|
|
34525
|
+
CREATE INDEX IF NOT EXISTS timeline_order ON timeline_items(session_id,ordinal);
|
|
34526
|
+
CREATE INDEX IF NOT EXISTS timeline_time ON timeline_items(session_id,time);
|
|
34527
|
+
CREATE INDEX IF NOT EXISTS timeline_calls ON timeline_items(session_id,call_id);
|
|
34528
|
+
CREATE TABLE IF NOT EXISTS timeline_coverage (session_id TEXT PRIMARY KEY REFERENCES sessions(id) ON DELETE CASCADE, partial INTEGER NOT NULL, note TEXT, revision TEXT NOT NULL);`;
|
|
34529
|
+
function writeEvents(db2, id2, rows2) {
|
|
34530
|
+
db2.prepare("DELETE FROM timeline_items WHERE session_id=?").run(id2);
|
|
34531
|
+
const insert = db2.prepare("INSERT OR IGNORE INTO timeline_items VALUES (?,?,?,?,?,?,?,?,?,?,?)");
|
|
34532
|
+
let ordinal = 0, bytes2 = 0, partial = false, legacy = false, limited = false;
|
|
34533
|
+
for (const row of rows2) {
|
|
34534
|
+
const message2 = JSON.parse(String(row.data));
|
|
34535
|
+
legacy ||= !message2.events;
|
|
34536
|
+
for (const event of normalizedEvents(message2, id2)) {
|
|
34537
|
+
const item = { ...event, ordinal: ordinal++ }, data = JSON.stringify(item);
|
|
34538
|
+
bytes2 += Buffer.byteLength(data);
|
|
34539
|
+
if (ordinal > 2e5 || bytes2 > 32e6) {
|
|
34540
|
+
limited = true;
|
|
34541
|
+
break;
|
|
34542
|
+
}
|
|
34543
|
+
partial ||= Boolean(item.partial);
|
|
34544
|
+
const preview = (item.text || item.input || item.output || item.name).replace(/\s+/g, " ").slice(0, 180);
|
|
34545
|
+
insert.run(id2, item.id, item.messageID, item.ordinal, item.kind, item.role || null, item.time, item.callID || null, item.name, preview, data);
|
|
34546
|
+
}
|
|
34547
|
+
if (limited) break;
|
|
34548
|
+
}
|
|
34549
|
+
const note = [legacy ? "Some items were reconstructed from an older flattened import; tool inputs/results cannot be paired there. Refresh sources to import structured events." : "", limited ? "Event history limited to 200,000 items / 32 MB per session." : "", partial ? "Some event content is missing, unsupported, or shortened." : ""].filter(Boolean).join(" ");
|
|
34550
|
+
db2.prepare("INSERT OR REPLACE INTO timeline_coverage VALUES (?,?,?,?)").run(id2, Number(partial || legacy || limited), note || null, randomUUID());
|
|
34551
|
+
}
|
|
34552
|
+
var summaryColumns = "id,kind,role,name,time,ordinal,preview,json_extract(data,'$.timeSource') AS timeSource,json_extract(data,'$.status') AS status,json_extract(data,'$.partial') AS partial";
|
|
34553
|
+
function eventSummary(row) {
|
|
34554
|
+
return { id: String(row.id), kind: row.kind, role: row.role, name: String(row.name), time: row.time === null ? null : Number(row.time), timeSource: row.timeSource, ordinal: Number(row.ordinal), preview: String(row.preview), status: row.status, partial: Boolean(row.partial) };
|
|
34555
|
+
}
|
|
34556
|
+
var EventReadError = class extends Error {
|
|
34557
|
+
constructor(message2, status2) {
|
|
34558
|
+
super(message2);
|
|
34559
|
+
this.status = status2;
|
|
34560
|
+
}
|
|
34561
|
+
status;
|
|
34562
|
+
};
|
|
34563
|
+
var filters = { all: "1", messages: "kind='message' AND role IN ('user','assistant')", tools: "kind IN ('tool_call','tool_result')", events: "kind NOT IN ('message','tool_call','tool_result')", untimed: "time IS NULL" };
|
|
34564
|
+
function coverage(db2, session) {
|
|
34565
|
+
const row = db2.prepare("SELECT * FROM timeline_coverage WHERE session_id=?").get(session.id);
|
|
34566
|
+
return { revision: String(row?.revision || "pending"), partial: Boolean(row?.partial) || session.coverage?.history !== "complete", note: [row?.note, session.coverage?.note].filter(Boolean).join(" ") || void 0 };
|
|
34567
|
+
}
|
|
34568
|
+
function readEventMarkers(db2, session) {
|
|
34569
|
+
const end = Math.max(session.created, session.activity?.lastMessageAt || session.created);
|
|
34570
|
+
const totals = db2.prepare(`SELECT count(*) AS total, count(*) FILTER (WHERE time IS NULL) AS untimed, count(*) FILTER (WHERE time<? OR time>?) AS outside FROM timeline_items WHERE session_id=? AND (${filters.messages})`).get(session.created, end, session.id);
|
|
34571
|
+
const rows2 = db2.prepare(`SELECT ${summaryColumns} FROM timeline_items WHERE session_id=? AND (${filters.messages}) AND time>=? AND time<=? ORDER BY time DESC,ordinal DESC`).all(session.id, session.created, end);
|
|
34572
|
+
const commits = commitMarkers(db2, session);
|
|
34573
|
+
return { sessionID: session.id, ...coverage(db2, session), commits: session.commits, items: [...rows2.reverse().map(eventSummary), ...commits].sort((a, b) => a.time - b.time || a.ordinal - b.ordinal), total: Number(totals.total), untimed: Number(totals.untimed), outsideLifetime: Number(totals.outside), limited: Number(totals.total) - Number(totals.untimed) - Number(totals.outside) > rows2.length || commits.length === 2e3 };
|
|
34574
|
+
}
|
|
34575
|
+
function readEvents(db2, session, options = {}) {
|
|
34576
|
+
const state2 = coverage(db2, session), filter = options.filter || "all", size = 60;
|
|
34577
|
+
if (!Object.hasOwn(filters, filter)) throw new EventReadError("Invalid event filter.", 400);
|
|
34578
|
+
const where = filters[filter];
|
|
34579
|
+
if (options.revision && options.revision !== state2.revision) throw new EventReadError("Saved history changed. Reload the event explorer.", 409);
|
|
34580
|
+
let offset = 0;
|
|
34581
|
+
if (options.cursor) {
|
|
34582
|
+
try {
|
|
34583
|
+
if (options.cursor.length > 512) throw new Error();
|
|
34584
|
+
const cursor2 = JSON.parse(Buffer.from(options.cursor, "base64url").toString());
|
|
34585
|
+
if (!Number.isSafeInteger(cursor2.offset) || cursor2.offset < 0 || cursor2.offset > 2e5 || cursor2.filter !== filter || typeof cursor2.revision !== "string") throw new Error();
|
|
34586
|
+
if (cursor2.revision !== state2.revision) throw new EventReadError("Saved history changed. Reload the event explorer.", 409);
|
|
34587
|
+
offset = cursor2.offset;
|
|
34588
|
+
} catch (error) {
|
|
34589
|
+
if (error instanceof EventReadError) throw error;
|
|
34590
|
+
throw new EventReadError("Invalid event cursor.", 400);
|
|
34591
|
+
}
|
|
34592
|
+
}
|
|
34593
|
+
let selected;
|
|
34594
|
+
if (options.item) {
|
|
34595
|
+
const row = db2.prepare(`SELECT data FROM timeline_items WHERE session_id=? AND id=? AND (${where})`).get(session.id, options.item);
|
|
34596
|
+
if (!row) throw new EventReadError("This event is not in the saved session or current filter.", 404);
|
|
34597
|
+
selected = JSON.parse(String(row.data));
|
|
34598
|
+
const before = Number(db2.prepare(`SELECT count(*) AS n FROM timeline_items WHERE session_id=? AND ordinal<? AND (${where})`).get(session.id, selected.ordinal).n);
|
|
34599
|
+
offset = Math.floor(before / size) * size;
|
|
34600
|
+
}
|
|
34601
|
+
const total = Number(db2.prepare(`SELECT count(*) AS n FROM timeline_items WHERE session_id=? AND (${where})`).get(session.id).n);
|
|
34602
|
+
const items = db2.prepare(`SELECT ${summaryColumns} FROM timeline_items WHERE session_id=? AND (${where}) ORDER BY ordinal LIMIT ? OFFSET ?`).all(session.id, size, offset).map(eventSummary);
|
|
34603
|
+
if (!selected && items.length) selected = JSON.parse(String(db2.prepare("SELECT data FROM timeline_items WHERE session_id=? AND id=?").get(session.id, items[0].id).data));
|
|
34604
|
+
const related = selected?.callID ? db2.prepare(`SELECT ${summaryColumns} FROM timeline_items WHERE session_id=? AND call_id=? AND id<>? ORDER BY ordinal LIMIT 21`).all(session.id, selected.callID, selected.id).map(eventSummary) : [];
|
|
34605
|
+
const previousItem = selected ? db2.prepare(`SELECT id FROM timeline_items WHERE session_id=? AND ordinal<? AND (${where}) ORDER BY ordinal DESC LIMIT 1`).get(session.id, selected.ordinal)?.id : void 0;
|
|
34606
|
+
const nextItem = selected ? db2.prepare(`SELECT id FROM timeline_items WHERE session_id=? AND ordinal>? AND (${where}) ORDER BY ordinal LIMIT 1`).get(session.id, selected.ordinal)?.id : void 0;
|
|
34607
|
+
const cursor = (position) => Buffer.from(JSON.stringify({ revision: state2.revision, filter, offset: position })).toString("base64url");
|
|
34608
|
+
return {
|
|
34609
|
+
sessionID: session.id,
|
|
34610
|
+
...state2,
|
|
34611
|
+
items,
|
|
34612
|
+
total,
|
|
34613
|
+
offset,
|
|
34614
|
+
selected,
|
|
34615
|
+
related: related.slice(0, 20),
|
|
34616
|
+
relatedPartial: related.length > 20,
|
|
34617
|
+
previousItem: previousItem ? String(previousItem) : void 0,
|
|
34618
|
+
nextItem: nextItem ? String(nextItem) : void 0,
|
|
34619
|
+
nextCursor: offset + size < total ? cursor(offset + size) : null,
|
|
34620
|
+
previousCursor: offset > 0 ? cursor(Math.max(0, offset - size)) : null
|
|
34621
|
+
};
|
|
34622
|
+
}
|
|
34623
|
+
|
|
34624
|
+
// packages/core/src/preferences.ts
|
|
34625
|
+
var DEFAULT_PREFERENCES = Object.freeze({
|
|
34626
|
+
autoImport: true,
|
|
34627
|
+
muted: false,
|
|
34628
|
+
clickSounds: true,
|
|
34629
|
+
clickVolume: 35,
|
|
34630
|
+
motion: "system",
|
|
34631
|
+
view: "3d",
|
|
34632
|
+
density: "comfortable",
|
|
34633
|
+
panelOpacity: 90,
|
|
34634
|
+
quality: "balanced",
|
|
34635
|
+
bloom: 32,
|
|
34636
|
+
stars: true,
|
|
34637
|
+
labels: true,
|
|
34638
|
+
nodeScale: 100,
|
|
34639
|
+
focusDimming: true,
|
|
34640
|
+
trails: "all",
|
|
34641
|
+
trailOpacity: 34,
|
|
34642
|
+
trailFlow: false,
|
|
34643
|
+
trailSpeed: 25,
|
|
34644
|
+
relationships: true,
|
|
34645
|
+
messageDots: true,
|
|
34646
|
+
playbackSpeed: 1
|
|
34647
|
+
});
|
|
34648
|
+
var choices = { motion: ["system", "on", "off"], view: ["3d", "2d"], density: ["comfortable", "compact"], quality: ["performance", "balanced", "high"], trails: ["all", "selected", "off"] };
|
|
34649
|
+
var ranges = { clickVolume: [0, 100], panelOpacity: [55, 100], bloom: [0, 75], nodeScale: [60, 180], trailOpacity: [0, 100], trailSpeed: [10, 100], playbackSpeed: [0.25, 3] };
|
|
34650
|
+
function normalizePreferences(value) {
|
|
34651
|
+
const result = { ...DEFAULT_PREFERENCES };
|
|
34652
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return result;
|
|
34653
|
+
const input = value;
|
|
34654
|
+
for (const key of Object.keys(result)) {
|
|
34655
|
+
const item = input[key];
|
|
34656
|
+
if (key in choices) {
|
|
34657
|
+
if (choices[key].includes(item)) Object.assign(result, { [key]: item });
|
|
34658
|
+
} else if (key in ranges) {
|
|
34659
|
+
const [min, max] = ranges[key];
|
|
34660
|
+
if (typeof item === "number" && Number.isFinite(item)) Object.assign(result, { [key]: Math.max(min, Math.min(max, item)) });
|
|
34661
|
+
} else if (typeof item === "boolean") Object.assign(result, { [key]: item });
|
|
34662
|
+
}
|
|
34663
|
+
return result;
|
|
34664
|
+
}
|
|
34665
|
+
|
|
34666
|
+
// packages/core/src/view-state.ts
|
|
34667
|
+
var DEFAULT_VIEW_STATE = Object.freeze({
|
|
34668
|
+
sourceID: "",
|
|
34669
|
+
projectID: "",
|
|
34670
|
+
directory: "",
|
|
34671
|
+
days: 0,
|
|
34672
|
+
fromDate: "",
|
|
34673
|
+
toDate: "",
|
|
34674
|
+
includeChildren: true,
|
|
34675
|
+
includeArchived: false
|
|
34676
|
+
});
|
|
34677
|
+
var validDate = (value) => typeof value === "string" && /^\d{4}-\d{2}-\d{2}$/.test(value) && Number.isFinite(Date.parse(value)) && new Date(value).toISOString().slice(0, 10) === value;
|
|
34678
|
+
function normalizeViewState(value) {
|
|
34679
|
+
const result = { ...DEFAULT_VIEW_STATE };
|
|
34680
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return result;
|
|
34681
|
+
const input = value;
|
|
34682
|
+
for (const key of ["sourceID", "projectID", "directory"]) if (typeof input[key] === "string" && input[key].length <= 4096) result[key] = input[key];
|
|
34683
|
+
if ([0, 7, 30, 90].includes(input.days)) result.days = input.days;
|
|
34684
|
+
for (const key of ["includeChildren", "includeArchived"]) if (typeof input[key] === "boolean") result[key] = input[key];
|
|
34685
|
+
for (const key of ["fromDate", "toDate"]) if (validDate(input[key])) result[key] = input[key];
|
|
34686
|
+
if (result.fromDate && result.toDate && result.fromDate > result.toDate) {
|
|
34687
|
+
result.fromDate = "";
|
|
34688
|
+
result.toDate = "";
|
|
34689
|
+
}
|
|
34690
|
+
return result;
|
|
34691
|
+
}
|
|
34692
|
+
|
|
34409
34693
|
// server/store.ts
|
|
34694
|
+
init_commit_extraction();
|
|
34410
34695
|
var SessionGraphStore = class {
|
|
34411
34696
|
constructor(path = databasePath()) {
|
|
34412
34697
|
this.path = path;
|
|
@@ -34415,7 +34700,7 @@ var SessionGraphStore = class {
|
|
|
34415
34700
|
if (path !== ":memory:") chmodSync(path, 384);
|
|
34416
34701
|
this.db.exec("PRAGMA journal_mode=WAL; PRAGMA foreign_keys=ON; PRAGMA busy_timeout=5000;");
|
|
34417
34702
|
const version = Number(this.db.prepare("PRAGMA user_version").get().user_version);
|
|
34418
|
-
if (version >
|
|
34703
|
+
if (version > 6) throw new Error("This SessionGraph database requires a newer version of the app.");
|
|
34419
34704
|
this.db.exec(`
|
|
34420
34705
|
CREATE TABLE IF NOT EXISTS settings (key TEXT PRIMARY KEY, value TEXT NOT NULL);
|
|
34421
34706
|
CREATE TABLE IF NOT EXISTS sources (id TEXT PRIMARY KEY, last_import INTEGER, error TEXT);
|
|
@@ -34463,6 +34748,35 @@ var SessionGraphStore = class {
|
|
|
34463
34748
|
throw error;
|
|
34464
34749
|
}
|
|
34465
34750
|
}
|
|
34751
|
+
if (version < 5) {
|
|
34752
|
+
this.db.exec("BEGIN IMMEDIATE");
|
|
34753
|
+
try {
|
|
34754
|
+
this.db.exec(COMMIT_SCHEMA);
|
|
34755
|
+
this.db.prepare("UPDATE sessions SET metadata=json_set(metadata,'$.commits',json(?))").run(JSON.stringify(pendingCommits()));
|
|
34756
|
+
this.db.exec("PRAGMA user_version=5; COMMIT");
|
|
34757
|
+
} catch (error) {
|
|
34758
|
+
this.db.exec("ROLLBACK");
|
|
34759
|
+
throw error;
|
|
34760
|
+
}
|
|
34761
|
+
}
|
|
34762
|
+
if (version < 6) {
|
|
34763
|
+
this.db.exec("BEGIN IMMEDIATE");
|
|
34764
|
+
try {
|
|
34765
|
+
const retired = /* @__PURE__ */ new Set(["reasonix", "trae", "warp", "lm-studio", "hindsight"]);
|
|
34766
|
+
const selected = this.setting("selected");
|
|
34767
|
+
if (selected) this.setting("selected", selected.filter((id2) => !retired.has(id2)));
|
|
34768
|
+
const paths2 = this.setting("sourcePaths");
|
|
34769
|
+
if (paths2) this.setting("sourcePaths", Object.fromEntries(Object.entries(paths2).filter(([id2]) => !retired.has(id2))));
|
|
34770
|
+
const view = this.setting("viewState");
|
|
34771
|
+
if (view && typeof view.sourceID === "string" && retired.has(view.sourceID)) this.setting("viewState", { ...view, sourceID: "" });
|
|
34772
|
+
const remove2 = this.db.prepare("DELETE FROM sources WHERE id=?");
|
|
34773
|
+
for (const id2 of retired) remove2.run(id2);
|
|
34774
|
+
this.db.exec("PRAGMA user_version=6; COMMIT");
|
|
34775
|
+
} catch (error) {
|
|
34776
|
+
this.db.exec("ROLLBACK");
|
|
34777
|
+
throw error;
|
|
34778
|
+
}
|
|
34779
|
+
}
|
|
34466
34780
|
if (!this.setting("libraryID")) this.setting("libraryID", randomUUID2());
|
|
34467
34781
|
}
|
|
34468
34782
|
path;
|
|
@@ -34516,6 +34830,9 @@ var SessionGraphStore = class {
|
|
|
34516
34830
|
revision(id2) {
|
|
34517
34831
|
return this.db.prepare("SELECT imported_revision FROM sessions WHERE id=?").get(id2)?.imported_revision;
|
|
34518
34832
|
}
|
|
34833
|
+
commitsCurrent(id2) {
|
|
34834
|
+
return this.getSession(id2)?.commits?.version === COMMIT_EXTRACTOR_VERSION;
|
|
34835
|
+
}
|
|
34519
34836
|
upsert(candidate) {
|
|
34520
34837
|
const s = candidate.session, previous = this.getSession(s.id);
|
|
34521
34838
|
const metadata2 = {
|
|
@@ -34523,6 +34840,7 @@ var SessionGraphStore = class {
|
|
|
34523
34840
|
model: s.model === "Unknown model" ? previous?.model || s.model : s.model,
|
|
34524
34841
|
parentID: previous?.parentID && candidate.locator.agent ? previous.parentID : s.parentID,
|
|
34525
34842
|
activity: previous?.activity,
|
|
34843
|
+
commits: previous?.commits || pendingCommits(),
|
|
34526
34844
|
revision: previous?.revision || "",
|
|
34527
34845
|
coverage: previous?.coverage || { history: "pending" }
|
|
34528
34846
|
};
|
|
@@ -34537,8 +34855,9 @@ var SessionGraphStore = class {
|
|
|
34537
34855
|
const insert = this.db.prepare("INSERT INTO messages (session_id,id,ordinal,data,time,is_user) VALUES (?,?,?,?,?,?) ON CONFLICT(session_id,id) DO UPDATE SET ordinal=excluded.ordinal,data=excluded.data,time=excluded.time,is_user=excluded.is_user");
|
|
34538
34856
|
messages.forEach((message2, i) => insert.run(s.id, message2.id, i, JSON.stringify(message2), messageTime(message2.time), Number(isUserMessage(message2))));
|
|
34539
34857
|
writeEvents(this.db, s.id, this.db.prepare("SELECT data FROM messages WHERE session_id=? ORDER BY ordinal").iterate(s.id));
|
|
34858
|
+
const commits = writeCommits(this.db, s);
|
|
34540
34859
|
const activity = this.db.prepare(activitySQL).get(s.id);
|
|
34541
|
-
this.db.prepare("UPDATE sessions SET metadata=?, imported_revision=? WHERE id=?").run(JSON.stringify({ ...s, activity }), candidate.revision, s.id);
|
|
34860
|
+
this.db.prepare("UPDATE sessions SET metadata=?, imported_revision=?, locator=? WHERE id=?").run(JSON.stringify({ ...s, activity, commits }), candidate.revision, JSON.stringify(candidate.locator), s.id);
|
|
34542
34861
|
this.db.prepare("DELETE FROM search_cache WHERE id=?").run(s.id);
|
|
34543
34862
|
this.db.exec("COMMIT");
|
|
34544
34863
|
} catch (error) {
|
|
@@ -34627,6 +34946,9 @@ var SessionGraphStore = class {
|
|
|
34627
34946
|
eventMarkers(id2) {
|
|
34628
34947
|
return this.readSnapshot(id2, (session) => readEventMarkers(this.db, session));
|
|
34629
34948
|
}
|
|
34949
|
+
commits(id2, options = {}) {
|
|
34950
|
+
return this.readSnapshot(id2, (session) => readCommits(this.db, session, options));
|
|
34951
|
+
}
|
|
34630
34952
|
readSnapshot(id2, read3) {
|
|
34631
34953
|
this.db.exec("BEGIN");
|
|
34632
34954
|
try {
|
|
@@ -34830,13 +35152,14 @@ var Importer = class {
|
|
|
34830
35152
|
this.status.errors.push(...discovery.warnings);
|
|
34831
35153
|
for (const project2 of discovery.projects) this.store.db.prepare("INSERT INTO projects VALUES (?,?,?) ON CONFLICT(id) DO UPDATE SET data=excluded.data").run(project2.id, adapter.id, JSON.stringify(project2));
|
|
34832
35154
|
for (const candidate of seen.values()) {
|
|
34833
|
-
this.store.upsert(candidate);
|
|
34834
35155
|
const saved = this.store.getSession(candidate.session.id);
|
|
34835
|
-
const retry = !saved?.coverage?.importedAt || saved.coverage.note?.startsWith("Latest import failed:");
|
|
35156
|
+
const retry = !saved?.coverage?.importedAt || saved.coverage.note?.startsWith("Latest import failed:") || !this.store.commitsCurrent(candidate.session.id);
|
|
34836
35157
|
if (!retry && saved?.revision === candidate.revision && this.store.revision(candidate.session.id) === candidate.revision) {
|
|
35158
|
+
this.store.upsert(candidate);
|
|
34837
35159
|
this.status.unchanged++;
|
|
34838
35160
|
continue;
|
|
34839
35161
|
}
|
|
35162
|
+
if (!saved) this.store.upsert(candidate);
|
|
34840
35163
|
try {
|
|
34841
35164
|
const messages = /* @__PURE__ */ new Map();
|
|
34842
35165
|
const cursors = /* @__PURE__ */ new Set();
|
|
@@ -35279,8 +35602,8 @@ var SearchableMap = class _SearchableMap {
|
|
|
35279
35602
|
* @param object Object of entries for the {@link SearchableMap}
|
|
35280
35603
|
* @return A new {@link SearchableMap} with the given entries
|
|
35281
35604
|
*/
|
|
35282
|
-
static fromObject(
|
|
35283
|
-
return _SearchableMap.from(Object.entries(
|
|
35605
|
+
static fromObject(object3) {
|
|
35606
|
+
return _SearchableMap.from(Object.entries(object3));
|
|
35284
35607
|
}
|
|
35285
35608
|
};
|
|
35286
35609
|
var trackDown = (tree, key, path = []) => {
|
|
@@ -36172,11 +36495,11 @@ var MiniSearch = class _MiniSearch {
|
|
|
36172
36495
|
* @param options configuration options, same as the constructor
|
|
36173
36496
|
* @return An instance of MiniSearch deserialized from the given JSON.
|
|
36174
36497
|
*/
|
|
36175
|
-
static loadJSON(
|
|
36498
|
+
static loadJSON(json5, options) {
|
|
36176
36499
|
if (options == null) {
|
|
36177
36500
|
throw new Error("MiniSearch: loadJSON should be given the same options used when serializing the index");
|
|
36178
36501
|
}
|
|
36179
|
-
return this.loadJS(JSON.parse(
|
|
36502
|
+
return this.loadJS(JSON.parse(json5), options);
|
|
36180
36503
|
}
|
|
36181
36504
|
/**
|
|
36182
36505
|
* Async equivalent of {@link MiniSearch.loadJSON}
|
|
@@ -36191,11 +36514,11 @@ var MiniSearch = class _MiniSearch {
|
|
|
36191
36514
|
* @param options configuration options, same as the constructor
|
|
36192
36515
|
* @return A Promise that will resolve to an instance of MiniSearch deserialized from the given JSON.
|
|
36193
36516
|
*/
|
|
36194
|
-
static async loadJSONAsync(
|
|
36517
|
+
static async loadJSONAsync(json5, options) {
|
|
36195
36518
|
if (options == null) {
|
|
36196
36519
|
throw new Error("MiniSearch: loadJSON should be given the same options used when serializing the index");
|
|
36197
36520
|
}
|
|
36198
|
-
return this.loadJSAsync(JSON.parse(
|
|
36521
|
+
return this.loadJSAsync(JSON.parse(json5), options);
|
|
36199
36522
|
}
|
|
36200
36523
|
/**
|
|
36201
36524
|
* Returns the default value of an option. It will throw an error if no option
|
|
@@ -36596,7 +36919,7 @@ var MiniSearch = class _MiniSearch {
|
|
|
36596
36919
|
}
|
|
36597
36920
|
};
|
|
36598
36921
|
MiniSearch.wildcard = /* @__PURE__ */ Symbol("*");
|
|
36599
|
-
var getOwnProperty = (
|
|
36922
|
+
var getOwnProperty = (object3, property) => Object.prototype.hasOwnProperty.call(object3, property) ? object3[property] : void 0;
|
|
36600
36923
|
var combinators = {
|
|
36601
36924
|
[OR]: (a, b) => {
|
|
36602
36925
|
for (const docId of b.keys()) {
|
|
@@ -36689,18 +37012,18 @@ var assignUniqueTerms = (target, source) => {
|
|
|
36689
37012
|
};
|
|
36690
37013
|
var byScore = ({ score: a }, { score: b }) => b - a;
|
|
36691
37014
|
var createMap = () => /* @__PURE__ */ new Map();
|
|
36692
|
-
var objectToNumericMap = (
|
|
37015
|
+
var objectToNumericMap = (object3) => {
|
|
36693
37016
|
const map = /* @__PURE__ */ new Map();
|
|
36694
|
-
for (const key of Object.keys(
|
|
36695
|
-
map.set(parseInt(key, 10),
|
|
37017
|
+
for (const key of Object.keys(object3)) {
|
|
37018
|
+
map.set(parseInt(key, 10), object3[key]);
|
|
36696
37019
|
}
|
|
36697
37020
|
return map;
|
|
36698
37021
|
};
|
|
36699
|
-
var objectToNumericMapAsync = async (
|
|
37022
|
+
var objectToNumericMapAsync = async (object3) => {
|
|
36700
37023
|
const map = /* @__PURE__ */ new Map();
|
|
36701
37024
|
let count = 0;
|
|
36702
|
-
for (const key of Object.keys(
|
|
36703
|
-
map.set(parseInt(key, 10),
|
|
37025
|
+
for (const key of Object.keys(object3)) {
|
|
37026
|
+
map.set(parseInt(key, 10), object3[key]);
|
|
36704
37027
|
if (++count % 1e3 === 0) {
|
|
36705
37028
|
await wait(0);
|
|
36706
37029
|
}
|
|
@@ -36715,7 +37038,7 @@ var normalize = (text3) => text3.normalize("NFKD").replace(new RegExp("\\p{M}",
|
|
|
36715
37038
|
var words = (text3) => normalize(text3).match(/[\p{L}\p{N}]+/gu) || [];
|
|
36716
37039
|
var phrase = (text3) => words(text3).join(" ");
|
|
36717
37040
|
function parseQuery(input) {
|
|
36718
|
-
const
|
|
37041
|
+
const plan2 = { text: "", terms: [], phrases: [], filters: [] };
|
|
36719
37042
|
const parts = [];
|
|
36720
37043
|
for (const token of input.slice(0, 300).match(/(?:[^\s"]+|"[^"]*")+/g) || []) {
|
|
36721
37044
|
const filter = /^(source|project|dir|model|is|after|before|in):(.+)$/i.exec(token);
|
|
@@ -36723,21 +37046,21 @@ function parseQuery(input) {
|
|
|
36723
37046
|
const key = filter[1].toLowerCase(), value2 = normalize(filter[2].replace(/^"|"$/g, ""));
|
|
36724
37047
|
if (key === "in") {
|
|
36725
37048
|
const fields2 = { title: ["title"], files: ["files"], messages: ["body"], tools: ["tools"] };
|
|
36726
|
-
|
|
36727
|
-
if (!
|
|
36728
|
-
} else if (key === "is" && !["fork", "child", "root", "archived"].includes(value2))
|
|
36729
|
-
else if (["after", "before"].includes(key) && (!/^\d{4}-\d{2}-\d{2}$/.test(value2) || !Number.isFinite(Date.parse(value2)) || new Date(value2).toISOString().slice(0, 10) !== value2))
|
|
36730
|
-
else
|
|
37049
|
+
plan2.fields = fields2[value2];
|
|
37050
|
+
if (!plan2.fields) plan2.error = "Use in:title, in:files, in:messages, or in:tools.";
|
|
37051
|
+
} else if (key === "is" && !["fork", "child", "root", "archived"].includes(value2)) plan2.error = "Use is:fork, is:child, is:root, or is:archived.";
|
|
37052
|
+
else if (["after", "before"].includes(key) && (!/^\d{4}-\d{2}-\d{2}$/.test(value2) || !Number.isFinite(Date.parse(value2)) || new Date(value2).toISOString().slice(0, 10) !== value2)) plan2.error = "Use a valid date in YYYY-MM-DD format.";
|
|
37053
|
+
else plan2.filters.push([key, value2]);
|
|
36731
37054
|
continue;
|
|
36732
37055
|
}
|
|
36733
37056
|
const value = token.replace(/^"|"$/g, "");
|
|
36734
|
-
if (token.startsWith('"') && token.endsWith('"'))
|
|
37057
|
+
if (token.startsWith('"') && token.endsWith('"')) plan2.phrases.push(phrase(value));
|
|
36735
37058
|
parts.push(value);
|
|
36736
37059
|
}
|
|
36737
|
-
|
|
36738
|
-
|
|
36739
|
-
|
|
36740
|
-
return
|
|
37060
|
+
plan2.text = parts.join(" ");
|
|
37061
|
+
plan2.terms = words(plan2.text).slice(0, 12);
|
|
37062
|
+
plan2.text = plan2.terms.join(" ");
|
|
37063
|
+
return plan2;
|
|
36741
37064
|
}
|
|
36742
37065
|
function excerpt(text3, terms, length = 220) {
|
|
36743
37066
|
const value = normalize(text3);
|
|
@@ -36805,12 +37128,12 @@ ${fragment.text}`;
|
|
|
36805
37128
|
const key = `${input}\0${viewOnly}\0${limit}\0${offset}`;
|
|
36806
37129
|
const cached2 = this.cache.get(key);
|
|
36807
37130
|
if (cached2) return cached2;
|
|
36808
|
-
const
|
|
36809
|
-
if (
|
|
37131
|
+
const plan2 = parseQuery(input);
|
|
37132
|
+
if (plan2.error) return { hits: [], total: 0, error: plan2.error };
|
|
36810
37133
|
const accepts = (entry) => {
|
|
36811
37134
|
const { session, doc } = entry;
|
|
36812
37135
|
if (viewOnly && !this.scope.has(session.id)) return false;
|
|
36813
|
-
for (const [key2, value] of
|
|
37136
|
+
for (const [key2, value] of plan2.filters) {
|
|
36814
37137
|
if (key2 === "source" && ![session.source || "opencode", ...(session.linkedSessionIDs || []).map((id2) => id2.split(":")[0])].some((source) => normalize(source).includes(value))) return false;
|
|
36815
37138
|
if (key2 === "project" && !normalize(doc.project).includes(value) && !normalize(session.projectID).includes(value)) return false;
|
|
36816
37139
|
if (key2 === "dir" && !normalize(session.directory).includes(value)) return false;
|
|
@@ -36824,14 +37147,14 @@ ${fragment.text}`;
|
|
|
36824
37147
|
if (value === "archived" && !session.archived) return false;
|
|
36825
37148
|
}
|
|
36826
37149
|
}
|
|
36827
|
-
if (
|
|
36828
|
-
const fields2 =
|
|
36829
|
-
if (!
|
|
37150
|
+
if (plan2.phrases.length) {
|
|
37151
|
+
const fields2 = plan2.fields || ["title", "body", "files", "tools", "project", "directory", "model"];
|
|
37152
|
+
if (!plan2.phrases.every((p) => fields2.some((field) => phrase(doc[field]).includes(p)))) return false;
|
|
36830
37153
|
}
|
|
36831
37154
|
return true;
|
|
36832
37155
|
};
|
|
36833
|
-
const matches =
|
|
36834
|
-
fields:
|
|
37156
|
+
const matches = plan2.terms.length ? this.index.search(plan2.text, {
|
|
37157
|
+
fields: plan2.fields,
|
|
36835
37158
|
fuzzy: (term) => term.length < 4 ? false : term.length > 7 ? 2 : 1,
|
|
36836
37159
|
filter: (result2) => accepts(this.entries.get(String(result2.id)))
|
|
36837
37160
|
}) : [...this.entries.values()].filter(accepts).map((entry) => ({ id: entry.session.id, score: 0, terms: [], match: {} }));
|
|
@@ -36839,12 +37162,12 @@ ${fragment.text}`;
|
|
|
36839
37162
|
const entry = this.entries.get(String(match2.id));
|
|
36840
37163
|
const title = phrase(entry.doc.title);
|
|
36841
37164
|
const fields2 = new Set(Object.values(match2.match).flat());
|
|
36842
|
-
const tier = !
|
|
37165
|
+
const tier = !plan2.text ? 0 : title.includes(plan2.text) && (!plan2.fields || plan2.fields.includes("title")) ? 5 : fields2.has("title") ? 4 : fields2.has("sessionID") ? 4 : fields2.has("files") ? 3 : fields2.has("body") ? 2 : 1;
|
|
36843
37166
|
return { match: match2, entry, tier };
|
|
36844
37167
|
}).sort((a, b) => b.tier - a.tier || b.match.score - a.match.score || b.entry.session.updated - a.entry.session.updated || a.entry.session.id.localeCompare(b.entry.session.id));
|
|
36845
37168
|
const hits = ranked.slice(offset, offset + Math.min(250, Math.max(1, limit))).map(({ match: match2, entry, tier }) => {
|
|
36846
|
-
const terms = match2.terms.length ? match2.terms :
|
|
36847
|
-
const candidates = entry.fragments.filter((f) => !
|
|
37169
|
+
const terms = match2.terms.length ? match2.terms : plan2.terms;
|
|
37170
|
+
const candidates = entry.fragments.filter((f) => !plan2.fields || plan2.fields.includes(f.kind === "File" ? "files" : f.kind === "Tool" ? "tools" : "body"));
|
|
36848
37171
|
let best, bestCount = 0;
|
|
36849
37172
|
for (const fragment of candidates) {
|
|
36850
37173
|
const text3 = normalize(fragment.text);
|
|
@@ -36856,7 +37179,7 @@ ${fragment.text}`;
|
|
|
36856
37179
|
if (count === terms.length && count > 0) break;
|
|
36857
37180
|
}
|
|
36858
37181
|
const fields2 = new Set(Object.values(match2.match).flat());
|
|
36859
|
-
const source = tier >= 4 ? fields2.has("sessionID") && !fields2.has("title") ? "Session ID" : "Title" : best ? best.kind === "File" ? "File" : best.kind === "Tool" ? "Tool" : "Message" :
|
|
37182
|
+
const source = tier >= 4 ? fields2.has("sessionID") && !fields2.has("title") ? "Session ID" : "Title" : best ? best.kind === "File" ? "File" : best.kind === "Tool" ? "Tool" : "Message" : plan2.text ? "Metadata" : "Recent";
|
|
36860
37183
|
return { id: entry.session.id, score: match2.score, source, excerpt: best ? excerpt(best.text, terms) : "", terms };
|
|
36861
37184
|
});
|
|
36862
37185
|
const result = { hits, total: ranked.length };
|
|
@@ -37003,6 +37326,10 @@ var LibraryService = class {
|
|
|
37003
37326
|
this.getSession(id2);
|
|
37004
37327
|
return this.store.timeline(id2);
|
|
37005
37328
|
}
|
|
37329
|
+
getCommits(id2, options = {}) {
|
|
37330
|
+
this.getSession(id2);
|
|
37331
|
+
return this.store.commits(id2, options);
|
|
37332
|
+
}
|
|
37006
37333
|
getEvents(id2, options = {}) {
|
|
37007
37334
|
this.getSession(id2);
|
|
37008
37335
|
return this.store.events(id2, options);
|
|
@@ -37031,8 +37358,8 @@ var LibraryService = class {
|
|
|
37031
37358
|
}
|
|
37032
37359
|
searchSessions(query, filters3 = {}, options = {}) {
|
|
37033
37360
|
if (!query.trim() || query.length > 300) invalid("Search query must contain 1\u2013300 characters.");
|
|
37034
|
-
const
|
|
37035
|
-
if (
|
|
37361
|
+
const plan2 = parseQuery(query);
|
|
37362
|
+
if (plan2.error) invalid(plan2.error);
|
|
37036
37363
|
return this.snapshot(() => {
|
|
37037
37364
|
const { sessions, projects } = this.sessions(filters3);
|
|
37038
37365
|
const index = new SessionSearchIndex();
|
|
@@ -37142,7 +37469,7 @@ var filters2 = [
|
|
|
37142
37469
|
];
|
|
37143
37470
|
var globalOptions = [flag("help", "Show command help without opening the library (-h)."), flag("json", "Emit one versioned JSON envelope on stdout. No interactive prompts."), text("data-dir", "Use a separate library directory; otherwise use SESSIONGRAPH_DATA_DIR and existing storage precedence.")];
|
|
37144
37471
|
var sessionArg = { name: "session-id", required: true };
|
|
37145
|
-
var
|
|
37472
|
+
var commands2 = [
|
|
37146
37473
|
{ name: "sources list", aliases: ["sources"], summary: "Discover supported sources, saved selection, custom paths, and import coverage.", options: [], effect: "read", result: "{ sources: SourceStatus[] with path/pathHint, configured, autoImport }", examples: ["sources --json"] },
|
|
37147
37474
|
{ name: "sources setup", summary: "Enable import sources and optionally set a persistent history path. Does not import.", args: { name: "source", variadic: true }, options: [flag("detected", "Add all currently detected sources to the saved selection."), text("path", "Persist a custom source directory; requires exactly one filesystem source. Overrides environment/default paths."), flag("default-path", "Clear the saved path for one source and use environment/default detection."), text("auto-import", "Enable/disable the app\u2019s automatic refresh. No background daemon is installed.", { values: ["on", "off"] })], effect: "configure", result: "{ selected, paths, autoImport, historyRetained }", examples: ["sources setup claude-code codex", "sources setup codex --path ~/.codex", "sources setup --detected", "sources setup --auto-import off"] },
|
|
37148
37475
|
{ name: "sources remove", summary: "Disable sources and clear their saved paths. Keep all previously imported history.", args: { name: "source", variadic: true }, options: [flag("all", "Disable all sources.")], effect: "configure", result: "{ selected, paths, autoImport, historyRetained }", examples: ["sources remove codex", "sources remove --all"] },
|
|
@@ -37154,6 +37481,7 @@ var commands = [
|
|
|
37154
37481
|
{ name: "timeline", summary: "Read recorded user-message times and untimed/partial coverage (up to 2,000 markers).", args: sessionArg, options: [], effect: "read", result: "SessionTimeline { id, userMessages, totalUserMessages, untimedUserMessages, earlierUserMessages, partial, note }", examples: ["timeline codex:SESSION_ID --json"] },
|
|
37155
37482
|
{ name: "events", summary: "Inspect structured messages, tool calls/results, and events with revision-bound pagination.", args: sessionArg, options: [text("filter", "Event category.", { values: ["all", "messages", "tools", "events", "untimed"], default: "all" }), text("cursor", "Event nextCursor; pages contain up to 60 summaries."), text("item", "Select an event ID to retrieve its bounded full payload."), text("revision", "Require the saved event revision from a previous response.")], effect: "read", result: "TimelinePage { sessionID, revision, items, selected, related, total, nextCursor, previousCursor, partial, note }", examples: ["events codex:SESSION_ID --filter tools --json", "events codex:SESSION_ID --item EVENT_ID --json"] },
|
|
37156
37483
|
{ name: "files", summary: "Read verified file-change evidence and tool counts from 120 saved messages per page.", args: sessionArg, options: [text("cursor", "Numeric nextCursor from the previous file-evidence page.")], effect: "read", result: "SessionDetail { id, revision, files, tools, messagesScanned, snapshotSteps, nextCursor, partial, note }. Not a diff or file snapshot.", examples: ["files codex:SESSION_ID --json"] },
|
|
37484
|
+
{ name: "commits", summary: "Read indexed, evidence-linked commit creation actions without scanning messages. SHAs may be abbreviated.", args: sessionArg, options: paging, effect: "read", result: "SessionCommits { sessionID, revision, coverage, items: [{ sessionID, sha, repositoryPath, operation, occurredAt, evidenceEventID }], total, nextCursor }. Paths are recorded execution directories; unknown coverage is not zero commits.", examples: ["commits codex:SESSION_ID --json", "events codex:SESSION_ID --item EVIDENCE_EVENT_ID --json"] },
|
|
37157
37485
|
{ name: "relationships", summary: "Read explicit parents, forks, children, and provider links; no inferred ancestry.", args: sessionArg, options: paging, effect: "read", result: "{ sessionID, items: [{ id, kind, direction, imported }], total, nextCursor }", examples: ["relationships codex:SESSION_ID --json"] },
|
|
37158
37486
|
{ name: "stats", summary: "Summarize saved sessions and known lifetime usage, with unknown/partial coverage.", options: [...filters2, text("group-by", "Group by one recorded field.", { values: ["source", "model", "project", "directory"], default: "source" }), ...paging], effect: "read", result: "{ totals, groupBy, groups: { items, total, nextCursor }, filters, note }. Usage: { knownTotal, knownSessions, unknownSessions }.", examples: ["stats --since 7d --group-by source --json"] },
|
|
37159
37487
|
{ name: "graph", summary: "Return the shared graph layout for up to 5,000 filtered sessions.", options: filters2, effect: "read", result: "{ graph: { nodes, edges, lanes, start, end }, filters }. Contains local metadata, not an anonymized publication.", examples: ["graph --directory . --json"] },
|
|
@@ -37162,14 +37490,14 @@ var commands = [
|
|
|
37162
37490
|
{ name: "docs", summary: "Print the full command reference or one command as Markdown.", args: { name: "command", variadic: true }, options: [], effect: "read", result: "Markdown documentation; with --json: { markdown }.", examples: ["docs", "docs sources setup"] },
|
|
37163
37491
|
{ name: "help", summary: "Show general or command-specific help; --json returns the command schema.", args: { name: "command", variadic: true }, options: [], effect: "read", result: "Help text or command manifest. No library access.", examples: ["help sources setup", "help search --json"] }
|
|
37164
37492
|
];
|
|
37165
|
-
var resolveCommand = (name) =>
|
|
37493
|
+
var resolveCommand = (name) => commands2.find((command) => command.name === name || command.aliases?.includes(name));
|
|
37166
37494
|
function manifest(command) {
|
|
37167
37495
|
return {
|
|
37168
37496
|
schemaVersion: 1,
|
|
37169
37497
|
executable: "sessiongraph",
|
|
37170
37498
|
node: ">=24",
|
|
37171
37499
|
globalOptions,
|
|
37172
|
-
commands: command ? [command] :
|
|
37500
|
+
commands: command ? [command] : commands2,
|
|
37173
37501
|
launch: { desktop: "sessiongraph", browser: "sessiongraph --browser" },
|
|
37174
37502
|
output: { success: "{ schemaVersion: 1, command, data }", failure: "{ schemaVersion: 1, command, error: { code, message } }", pagination: "Follow nextCursor with identical filters; stale cursors fail. Empty results are successful." },
|
|
37175
37503
|
exitCodes: { 0: "Success (including no matches)", 1: "Operation failed, unhealthy doctor checks, or import with failures; inspect data/errors", 2: "Invalid command or arguments", 130: "Interrupted" },
|
|
@@ -37185,7 +37513,7 @@ Usage: sessiongraph <command> [options]
|
|
|
37185
37513
|
sessiongraph --version
|
|
37186
37514
|
|
|
37187
37515
|
Commands:
|
|
37188
|
-
${
|
|
37516
|
+
${commands2.map((c) => ` ${c.name.padEnd(18)} ${c.summary}`).join("\n")}
|
|
37189
37517
|
|
|
37190
37518
|
Options: --help (-h), --json, --data-dir <directory>
|
|
37191
37519
|
|
|
@@ -37219,14 +37547,14 @@ Node.js 24+. Local, noninteractive data commands. Use \`--json\` for structured
|
|
|
37219
37547
|
|
|
37220
37548
|
${manifest().rules.map((rule) => `- ${rule}`).join("\n")}
|
|
37221
37549
|
|
|
37222
|
-
${(command ? [command] :
|
|
37550
|
+
${(command ? [command] : commands2).map((c) => `## ${c.name}
|
|
37223
37551
|
|
|
37224
37552
|
\`\`\`text
|
|
37225
37553
|
${help(c)}\`\`\``).join("\n\n")}
|
|
37226
37554
|
`;
|
|
37227
37555
|
function parseCLI(argv) {
|
|
37228
37556
|
const options = {}, positionals = [];
|
|
37229
|
-
const known = new Map([...globalOptions, ...
|
|
37557
|
+
const known = new Map([...globalOptions, ...commands2.flatMap((c) => c.options), flag("version", "Version")].map((o) => [o.name, o]));
|
|
37230
37558
|
let literal = false;
|
|
37231
37559
|
for (let i = 0; i < argv.length; i++) {
|
|
37232
37560
|
let token = argv[i];
|
|
@@ -37313,7 +37641,7 @@ ${m.fragments.map((f) => `${cell(f.kind)}: ${cell(f.text)}${f.truncated ? " [tru
|
|
|
37313
37641
|
if (command === "doctor") return `${data.ok ? "OK" : "Needs attention"} \u2014 ${cell(data.database)}
|
|
37314
37642
|
${table(["CHECK", "STATUS", "DETAIL"], data.checks.map((c) => [c.name, c.ok ? "ok" : "failed", c.message]))}
|
|
37315
37643
|
${data.next}`;
|
|
37316
|
-
if (command === "commands") return table(["COMMAND", "EFFECT", "DESCRIPTION"],
|
|
37644
|
+
if (command === "commands") return table(["COMMAND", "EFFECT", "DESCRIPTION"], commands2.map((c) => [c.name, c.effect, c.summary]));
|
|
37317
37645
|
return JSON.stringify(data, null, 2).replace(/[\u007f-\u009f\u202a-\u202e\u2066-\u2069]/g, cell);
|
|
37318
37646
|
}
|
|
37319
37647
|
async function runCli(argv, io = {}) {
|
|
@@ -37322,11 +37650,11 @@ async function runCli(argv, io = {}) {
|
|
|
37322
37650
|
}), stderr = io.stderr || ((text3) => {
|
|
37323
37651
|
process.stderr.write(text3);
|
|
37324
37652
|
});
|
|
37325
|
-
let command = "cli",
|
|
37326
|
-
const emit = (data, text3) => stdout((
|
|
37653
|
+
let command = "cli", json5 = argv.includes("--json"), library;
|
|
37654
|
+
const emit = (data, text3) => stdout((json5 ? JSON.stringify({ schemaVersion: 1, command, data }) : text3 ?? human(command, data)) + "\n");
|
|
37327
37655
|
try {
|
|
37328
37656
|
const parsed = parseCLI(argv), options = parsed.options, args = parsed.args;
|
|
37329
|
-
|
|
37657
|
+
json5 = options.json === true;
|
|
37330
37658
|
const definition = parsed.command;
|
|
37331
37659
|
command = definition?.name || (options.version ? "version" : "help");
|
|
37332
37660
|
if (options.version) {
|
|
@@ -37376,8 +37704,8 @@ async function runCli(argv, io = {}) {
|
|
|
37376
37704
|
};
|
|
37377
37705
|
if (filters3.since !== void 0 && filters3.until !== void 0 && filters3.since > filters3.until) invalid("--since must not be later than --until.");
|
|
37378
37706
|
const paging2 = { limit: text3("limit") ? pageLimit(Number(text3("limit"))) : void 0, cursor };
|
|
37379
|
-
const
|
|
37380
|
-
const path = databasePath(
|
|
37707
|
+
const directory3 = text3("data-dir");
|
|
37708
|
+
const path = databasePath(directory3 ? { ...process.env, SESSIONGRAPH_DATA_DIR: localPath(directory3) } : process.env);
|
|
37381
37709
|
library = io.openLibrary ? await io.openLibrary(path) : new LibraryService(new SessionGraphStore(path), (await Promise.resolve().then(() => (init_adapters(), adapters_exports))).adapters);
|
|
37382
37710
|
let data;
|
|
37383
37711
|
switch (command) {
|
|
@@ -37391,7 +37719,7 @@ async function runCli(argv, io = {}) {
|
|
|
37391
37719
|
data = library.removeSources(args, options.all === true);
|
|
37392
37720
|
break;
|
|
37393
37721
|
case "sources sync":
|
|
37394
|
-
if (!
|
|
37722
|
+
if (!json5) stderr("Syncing local sources\u2026\n");
|
|
37395
37723
|
data = await library.importSessions(args);
|
|
37396
37724
|
break;
|
|
37397
37725
|
case "sessions":
|
|
@@ -37409,6 +37737,9 @@ async function runCli(argv, io = {}) {
|
|
|
37409
37737
|
case "timeline":
|
|
37410
37738
|
data = library.getTimeline(args[0]);
|
|
37411
37739
|
break;
|
|
37740
|
+
case "commits":
|
|
37741
|
+
data = library.getCommits(args[0], paging2);
|
|
37742
|
+
break;
|
|
37412
37743
|
case "events":
|
|
37413
37744
|
data = library.getEvents(args[0], { cursor: text3("cursor"), item: text3("item"), filter: text3("filter"), revision: text3("revision") });
|
|
37414
37745
|
break;
|
|
@@ -37438,7 +37769,7 @@ async function runCli(argv, io = {}) {
|
|
|
37438
37769
|
return command === "sources sync" && data.failed > 0 || command === "doctor" && !data.ok ? 1 : 0;
|
|
37439
37770
|
} catch (error) {
|
|
37440
37771
|
const failure = error instanceof LibraryError ? error : error instanceof EventReadError ? new LibraryError(error.status === 409 ? "STALE_CURSOR" : error.status === 404 ? "NOT_FOUND" : "INVALID_ARGUMENT", error.message, error.status === 400 ? 2 : 1) : new LibraryError("OPERATION_FAILED", error instanceof Error ? error.message : "Local operation failed.");
|
|
37441
|
-
if (
|
|
37772
|
+
if (json5) stdout(JSON.stringify({ schemaVersion: 1, command, error: { code: failure.code, message: failure.message } }) + "\n");
|
|
37442
37773
|
else stderr(`sessiongraph: ${cell(failure.message)}
|
|
37443
37774
|
`);
|
|
37444
37775
|
return failure.exitCode;
|