sessiongraph 1.0.13 → 1.0.14
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/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 +773 -447
- package/dist-server/server.mjs +636 -323
- package/docs/cli.md +16 -0
- package/docs/guide.md +15 -3
- 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 {
|
|
@@ -30812,13 +30983,13 @@ function localFileAdapter(source) {
|
|
|
30812
30983
|
}
|
|
30813
30984
|
};
|
|
30814
30985
|
}
|
|
30815
|
-
var
|
|
30986
|
+
var object2, text2, time, MAX_BYTES2, MAX_RECORDS, MAX_FILES;
|
|
30816
30987
|
var init_local_files = __esm({
|
|
30817
30988
|
"server/adapters/local-files.ts"() {
|
|
30818
30989
|
"use strict";
|
|
30819
30990
|
init_common();
|
|
30820
30991
|
init_compressed();
|
|
30821
|
-
|
|
30992
|
+
object2 = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
30822
30993
|
text2 = (value) => typeof value === "string" ? value : "";
|
|
30823
30994
|
time = (value) => {
|
|
30824
30995
|
const n = typeof value === "number" ? value : typeof value === "string" ? /^\d{13}$/.test(value) ? Number(value) : Date.parse(value) : 0;
|
|
@@ -30836,7 +31007,7 @@ function conversationMessage(raw, fallbackID) {
|
|
|
30836
31007
|
const message2 = blankMessage(text2(raw.id) || fallbackID, time(raw.timestamp ?? raw.ts), role);
|
|
30837
31008
|
let content = raw.content;
|
|
30838
31009
|
if (Array.isArray(content)) content = content.map((part) => {
|
|
30839
|
-
const p =
|
|
31010
|
+
const p = object2(part);
|
|
30840
31011
|
return p.type === "toolCall" ? { ...p, type: "tool_use", input: p.arguments } : p.type === "reasoning" ? { ...p, type: "thinking", thinking: p.text } : p;
|
|
30841
31012
|
});
|
|
30842
31013
|
if (raw.role === "thinking") content = [{ type: "thinking", thinking: raw.content }];
|
|
@@ -30857,7 +31028,7 @@ function conversationMessage(raw, fallbackID) {
|
|
|
30857
31028
|
else if (event.kind === "reasoning") addText(message2, event.text, "Assistant");
|
|
30858
31029
|
}
|
|
30859
31030
|
for (const call of Array.isArray(raw.toolCalls) ? raw.toolCalls : []) {
|
|
30860
|
-
const f =
|
|
31031
|
+
const f = object2(call.function);
|
|
30861
31032
|
if (!text2(f.name)) continue;
|
|
30862
31033
|
message2.tools.push(f.name);
|
|
30863
31034
|
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 +31042,7 @@ function googleMessage(raw, fallbackID) {
|
|
|
30871
31042
|
const parts = Array.isArray(raw.content) ? raw.content : raw.content != null ? [raw.content] : [];
|
|
30872
31043
|
const content = parts.map((part) => {
|
|
30873
31044
|
if (typeof part === "string") return { type: "text", text: part };
|
|
30874
|
-
const p =
|
|
31045
|
+
const p = object2(part);
|
|
30875
31046
|
if (typeof p.text === "string") return p.thought ? { type: "thinking", thinking: p.text } : { type: "text", text: p.text };
|
|
30876
31047
|
if (p.functionCall) return { type: "tool_use", ...p.functionCall, input: p.functionCall.args };
|
|
30877
31048
|
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 +31056,7 @@ function successfulEdits(messages, editNames) {
|
|
|
30885
31056
|
if (event.kind === "tool_call" && event.callID) {
|
|
30886
31057
|
let input = {};
|
|
30887
31058
|
try {
|
|
30888
|
-
input =
|
|
31059
|
+
input = object2(JSON.parse(event.input || "{}"));
|
|
30889
31060
|
} catch {
|
|
30890
31061
|
}
|
|
30891
31062
|
calls.set(event.callID, { name: event.name, input });
|
|
@@ -30988,7 +31159,7 @@ function envelopeHistory(path, value) {
|
|
|
30988
31159
|
const header = rows2.find((r) => r.type === "session" || r.type === "session_start" || r.type === "session_startup") || {};
|
|
30989
31160
|
const nativeID = [...nativeIDs][0] || text2(header.id || header.sessionId) || fileID(path);
|
|
30990
31161
|
const messages = rows2.flatMap((r, i) => {
|
|
30991
|
-
const body =
|
|
31162
|
+
const body = object2(r.message), role = body.role || r.role || (["user", "assistant", "system"].includes(r.type) ? r.type : void 0);
|
|
30992
31163
|
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
31164
|
return m ? [m] : [];
|
|
30994
31165
|
});
|
|
@@ -31004,7 +31175,7 @@ function envelopeHistory(path, value) {
|
|
|
31004
31175
|
};
|
|
31005
31176
|
}
|
|
31006
31177
|
function ampHistory(path, files) {
|
|
31007
|
-
const raw =
|
|
31178
|
+
const raw = object2(json3(files.get(path)));
|
|
31008
31179
|
if (!text2(raw.id) || !Array.isArray(raw.messages)) throw new Error("Unsupported Amp thread.");
|
|
31009
31180
|
const messages = raw.messages.flatMap((m, i) => {
|
|
31010
31181
|
const result = message(m, nativeText(m.messageId) || `message:${i}`, m.timestamp ?? m.usage?.timestamp);
|
|
@@ -31013,14 +31184,14 @@ function ampHistory(path, files) {
|
|
|
31013
31184
|
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
31185
|
}
|
|
31015
31186
|
function jcodeHistory(path, files) {
|
|
31016
|
-
const raw =
|
|
31187
|
+
const raw = object2(json3(files.get(path)));
|
|
31017
31188
|
if (!text2(raw.id) || !Array.isArray(raw.messages)) throw new Error("Unsupported Jcode session.");
|
|
31018
31189
|
const journal = path.replace(/\.json$/, ".journal.jsonl");
|
|
31019
31190
|
const appended = files.has(journal) ? jsonLines(files.get(journal)) : { rows: [], partial: false };
|
|
31020
31191
|
const records = [...raw.messages];
|
|
31021
31192
|
for (const row of appended.rows) {
|
|
31022
31193
|
if (Array.isArray(row.append_messages)) records.push(...row.append_messages);
|
|
31023
|
-
if (row.meta) Object.assign(raw,
|
|
31194
|
+
if (row.meta) Object.assign(raw, object2(row.meta));
|
|
31024
31195
|
}
|
|
31025
31196
|
const seen = /* @__PURE__ */ new Set();
|
|
31026
31197
|
const messages = records.flatMap((r, i) => {
|
|
@@ -31033,7 +31204,7 @@ function jcodeHistory(path, files) {
|
|
|
31033
31204
|
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
31205
|
}
|
|
31035
31206
|
function codebuffHistory(path, files, free) {
|
|
31036
|
-
const records =
|
|
31207
|
+
const records = json3(files.get(path));
|
|
31037
31208
|
if (!Array.isArray(records)) throw new Error("Unsupported Codebuff chat.");
|
|
31038
31209
|
const isFree = records.some((m) => text2(m.metadata?.runState?.sessionState?.mainAgentState?.agentType).startsWith("base2-free"));
|
|
31039
31210
|
if (isFree !== free) return;
|
|
@@ -31046,8 +31217,8 @@ function codebuffHistory(path, files, free) {
|
|
|
31046
31217
|
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
31218
|
}
|
|
31048
31219
|
function vibeHistory(path, files) {
|
|
31049
|
-
const raw =
|
|
31050
|
-
const meta = legacy ?
|
|
31220
|
+
const raw = object2(json3(files.get(path))), legacy = basename4(path) !== "meta.json";
|
|
31221
|
+
const meta = legacy ? object2(raw.metadata) : raw;
|
|
31051
31222
|
const transcript = join6(dirname3(path), "messages.jsonl");
|
|
31052
31223
|
const parsed = files.has(transcript) ? jsonLines(files.get(transcript)) : { rows: [], partial: false };
|
|
31053
31224
|
const records = legacy ? raw.messages : parsed.rows;
|
|
@@ -31074,7 +31245,7 @@ function acpHistory(path, value) {
|
|
|
31074
31245
|
}
|
|
31075
31246
|
};
|
|
31076
31247
|
for (const [i, row] of rows2.entries()) {
|
|
31077
|
-
const p =
|
|
31248
|
+
const p = object2(row.params), u2 = object2(p.update), kind = text2(u2.sessionUpdate);
|
|
31078
31249
|
if (text2(p.sessionId)) ids.add(p.sessionId);
|
|
31079
31250
|
const timestamp = time(p._meta?.agentTimestampMs) || time(row.timestamp);
|
|
31080
31251
|
const role = kind === "user_message_chunk" ? "user" : kind === "agent_message_chunk" ? "assistant" : "";
|
|
@@ -31100,7 +31271,7 @@ function dshHistory(value) {
|
|
|
31100
31271
|
if (!text2(header?.id)) throw new Error("Unsupported DeepSeek Harness session.");
|
|
31101
31272
|
const messages = rows2.flatMap((r, i) => {
|
|
31102
31273
|
if (!["user/message", "assistant/message", "tool/message"].includes(r.type)) return [];
|
|
31103
|
-
const body =
|
|
31274
|
+
const body = object2(r.data?.message);
|
|
31104
31275
|
const m = message({ ...body, role: body.role || r.type.split("/")[0] }, text2(body.id) || `record:${i}`, r.time);
|
|
31105
31276
|
return m ? [m] : [];
|
|
31106
31277
|
});
|
|
@@ -31118,7 +31289,7 @@ var init_harness_formats = __esm({
|
|
|
31118
31289
|
nativeText = (v3) => typeof v3 === "number" && Number.isSafeInteger(v3) ? String(v3) : text2(v3);
|
|
31119
31290
|
seconds = (v3) => typeof v3 === "number" && Number.isFinite(v3) && v3 > 0 ? v3 * 1e3 : time(v3);
|
|
31120
31291
|
fileID = (path) => basename4(path).replace(/\.jsonl(?:\..*)?$|\.json$/, "");
|
|
31121
|
-
sidecar2 = (files, path) =>
|
|
31292
|
+
sidecar2 = (files, path) => object2(files.has(path) ? json3(files.get(path)) : void 0);
|
|
31122
31293
|
roles = ["user", "assistant", "system", "tool", "toolResult", "model"];
|
|
31123
31294
|
}
|
|
31124
31295
|
});
|
|
@@ -31149,11 +31320,11 @@ function withSqliteSnapshot(path, read3, expected, pinned = false) {
|
|
|
31149
31320
|
if (copy?.revision !== revision2) {
|
|
31150
31321
|
close(path);
|
|
31151
31322
|
while (copies.size >= 2) close(copies.keys().next().value);
|
|
31152
|
-
const
|
|
31323
|
+
const directory3 = mkdtempSync(join7(tmpdir(), "sessiongraph-history-"));
|
|
31153
31324
|
let db2;
|
|
31154
31325
|
try {
|
|
31155
|
-
chmodSync2(
|
|
31156
|
-
const destination = join7(
|
|
31326
|
+
chmodSync2(directory3, 448);
|
|
31327
|
+
const destination = join7(directory3, "history.db");
|
|
31157
31328
|
for (const suffix of ["", "-wal"]) {
|
|
31158
31329
|
try {
|
|
31159
31330
|
copyFileSync(path + suffix, destination + suffix, constants4.COPYFILE_FICLONE);
|
|
@@ -31166,13 +31337,13 @@ function withSqliteSnapshot(path, read3, expected, pinned = false) {
|
|
|
31166
31337
|
if (sqliteRevision(path) !== revision2) throw new SqliteSnapshotChangedError("History database changed while copying; import again.");
|
|
31167
31338
|
db2 = new DatabaseSync2(destination, { readOnly: true, enableDoubleQuotedStringLiterals: false, allowExtension: false });
|
|
31168
31339
|
db2.exec("PRAGMA query_only=ON; PRAGMA trusted_schema=OFF; PRAGMA busy_timeout=1000; BEGIN;");
|
|
31169
|
-
copy = { revision: revision2, directory:
|
|
31340
|
+
copy = { revision: revision2, directory: directory3, db: db2 };
|
|
31170
31341
|
copies.set(path, copy);
|
|
31171
31342
|
} catch (error) {
|
|
31172
31343
|
try {
|
|
31173
31344
|
db2?.close();
|
|
31174
31345
|
} finally {
|
|
31175
|
-
rmSync2(
|
|
31346
|
+
rmSync2(directory3, { recursive: true, force: true });
|
|
31176
31347
|
}
|
|
31177
31348
|
throw error;
|
|
31178
31349
|
}
|
|
@@ -31416,7 +31587,7 @@ var init_sqlite_histories = __esm({
|
|
|
31416
31587
|
import { readdir as readdir2, stat } from "node:fs/promises";
|
|
31417
31588
|
import { homedir as homedir5 } from "node:os";
|
|
31418
31589
|
import { join as join8 } from "node:path";
|
|
31419
|
-
function claudeMessages(rows2, candidate, times) {
|
|
31590
|
+
function claudeMessages(rows2, candidate, times, entries2) {
|
|
31420
31591
|
const calls = /* @__PURE__ */ new Map();
|
|
31421
31592
|
return rows2.map((row) => {
|
|
31422
31593
|
const raw = row.message;
|
|
@@ -31441,7 +31612,18 @@ function claudeMessages(rows2, candidate, times) {
|
|
|
31441
31612
|
}
|
|
31442
31613
|
}
|
|
31443
31614
|
}
|
|
31444
|
-
|
|
31615
|
+
const entry = entries2?.get(row.uuid), structured = entry?.tool_use_result ?? entry?.toolUseResult;
|
|
31616
|
+
const results = Array.isArray(raw?.content) ? raw.content.filter((p) => p.type === "tool_result") : [];
|
|
31617
|
+
msg.events = blockEvents(msg, raw?.content).map((event) => {
|
|
31618
|
+
const result = event.kind === "tool_result" && results.length === 1 ? structured : void 0;
|
|
31619
|
+
return {
|
|
31620
|
+
...event,
|
|
31621
|
+
parentID: row.parent_tool_use_id || void 0,
|
|
31622
|
+
...executionFields({}, { ...result, cwd: entry?.cwd }),
|
|
31623
|
+
gitCommit: nativeCommit(result?.gitOperation?.commit),
|
|
31624
|
+
partial: Boolean(event.partial || result?.interrupted || result?.backgroundTaskId || result?.backgroundedByUser || result?.timedOutAfterMs || entry?.sessionId && entry.sessionId !== (candidate.locator.parent || candidate.session.nativeID))
|
|
31625
|
+
};
|
|
31626
|
+
});
|
|
31445
31627
|
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
31628
|
return msg;
|
|
31447
31629
|
});
|
|
@@ -31458,6 +31640,7 @@ var init_claude = __esm({
|
|
|
31458
31640
|
init_harness_formats();
|
|
31459
31641
|
init_sqlite_histories();
|
|
31460
31642
|
init_source_paths();
|
|
31643
|
+
init_commit_extraction();
|
|
31461
31644
|
root = () => join8(sourcePath("claude-code") || process.env.CLAUDE_CONFIG_DIR || join8(homedir5(), ".claude"), "projects");
|
|
31462
31645
|
sdkClaudeAdapter = {
|
|
31463
31646
|
id: "claude-code",
|
|
@@ -31555,7 +31738,7 @@ var init_claude = __esm({
|
|
|
31555
31738
|
const options = { dir: candidate.locator.dir || void 0, offset: start, limit: count + 1, sessionStore: claudeTranscriptStore(transcript, sessionId, candidate.locator.agent) };
|
|
31556
31739
|
const rows2 = candidate.locator.parent ? await U1t(candidate.locator.parent, candidate.locator.agent, options) : await P1t(candidate.session.nativeID, options);
|
|
31557
31740
|
const more = rows2.length > count;
|
|
31558
|
-
const messages = claudeMessages(rows2.slice(0, count), candidate, transcript.times).slice(offset - start);
|
|
31741
|
+
const messages = claudeMessages(rows2.slice(0, count), candidate, transcript.times, transcript.byID).slice(offset - start);
|
|
31559
31742
|
if (!offset && !messages.length && transcript.size > 100) throw new Error("SDK returned no readable conversation for this transcript.");
|
|
31560
31743
|
if (!more && await claudeRevision(candidate.locator.path) !== candidate.revision) throw new Error("Session changed during import; import again to capture the latest messages.");
|
|
31561
31744
|
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 +31896,7 @@ async function sessionNames() {
|
|
|
31713
31896
|
function codexRecord(raw, offset, candidate) {
|
|
31714
31897
|
const p = raw.payload;
|
|
31715
31898
|
if (!p || typeof p !== "object") return;
|
|
31899
|
+
if (raw.type === "session_meta" || raw.type === "turn_context") candidate.locator.executionCwd = typeof p.cwd === "string" ? p.cwd : "";
|
|
31716
31900
|
if (raw.type === "turn_context" && typeof p.model === "string") candidate.session.model = p.model;
|
|
31717
31901
|
if (raw.type === "event_msg" && p.type === "item_completed" && ["FileChange", "fileChange"].includes(p.item?.type)) {
|
|
31718
31902
|
const msg2 = blankMessage(`event:${p.item.id || raw.ordinal || offset}`, p.completed_at_ms || Date.parse(raw.timestamp) || 0, "tool");
|
|
@@ -31744,7 +31928,14 @@ function codexRecord(raw, offset, candidate) {
|
|
|
31744
31928
|
}
|
|
31745
31929
|
const role = p.role === "user" ? "user" : p.role === "assistant" ? "assistant" : p.type === "message" ? "system" : "tool";
|
|
31746
31930
|
const msg = blankMessage(`item:${raw.ordinal ?? offset}`, Date.parse(raw.timestamp) || 0, role);
|
|
31747
|
-
|
|
31931
|
+
let input = p.arguments ?? p.input;
|
|
31932
|
+
if (typeof input === "string") {
|
|
31933
|
+
try {
|
|
31934
|
+
input = JSON.parse(input);
|
|
31935
|
+
} catch {
|
|
31936
|
+
}
|
|
31937
|
+
}
|
|
31938
|
+
const fields2 = { nativeID: p.id, nativeType: p.type, callID: p.call_id, ...executionFields(input, { cwd: candidate.locator.executionCwd }) };
|
|
31748
31939
|
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
31940
|
if (p.type === "message") {
|
|
31750
31941
|
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 +31960,11 @@ var init_codex = __esm({
|
|
|
31769
31960
|
init_jsonl();
|
|
31770
31961
|
init_events();
|
|
31771
31962
|
init_source_paths();
|
|
31963
|
+
init_commit_extraction();
|
|
31772
31964
|
root2 = () => sourcePath("codex") || process.env.CODEX_HOME || join10(homedir6(), ".codex");
|
|
31773
31965
|
revision = async (path) => {
|
|
31774
31966
|
const s = await stat2(path);
|
|
31775
|
-
return digest([
|
|
31967
|
+
return digest([10, s.mtimeMs, s.size]);
|
|
31776
31968
|
};
|
|
31777
31969
|
codexAdapter = {
|
|
31778
31970
|
id: "codex",
|
|
@@ -31832,6 +32024,7 @@ var init_codex = __esm({
|
|
|
31832
32024
|
})).values()], warnings };
|
|
31833
32025
|
},
|
|
31834
32026
|
async read(candidate, cursor) {
|
|
32027
|
+
if (!cursor) candidate.locator.executionCwd = "";
|
|
31835
32028
|
const page2 = await readJSONL(candidate.locator.path, Number(cursor || 0));
|
|
31836
32029
|
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
32030
|
return { messages: page2.rows.flatMap((r) => {
|
|
@@ -31861,7 +32054,7 @@ function time2(value) {
|
|
|
31861
32054
|
return Number.isFinite(parsed) && parsed > 0 && parsed <= 864e13 ? parsed : 0;
|
|
31862
32055
|
}
|
|
31863
32056
|
function status(value) {
|
|
31864
|
-
return ["pending", "running", "completed", "failed"].includes(
|
|
32057
|
+
return ["pending", "running", "completed", "failed"].includes(string2(value)) ? value : "unknown";
|
|
31865
32058
|
}
|
|
31866
32059
|
async function databasePath2() {
|
|
31867
32060
|
const root3 = sourcePath("t3-code") || process.env.SESSIONGRAPH_T3_CODE_HISTORY_DIR || process.env.T3CODE_HOME || join11(homedir7(), ".t3");
|
|
@@ -31890,7 +32083,7 @@ function projectRoots(db2, ids) {
|
|
|
31890
32083
|
for (const batch of batches([...new Set(ids.filter(Boolean))])) {
|
|
31891
32084
|
const placeholders = batch.map(() => "?").join(",");
|
|
31892
32085
|
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(
|
|
32086
|
+
roots2.set(string2(row.project_id), string2(row.workspace_root));
|
|
31894
32087
|
}
|
|
31895
32088
|
return roots2;
|
|
31896
32089
|
}
|
|
@@ -31900,7 +32093,7 @@ function aggregates(db2, table2, ids) {
|
|
|
31900
32093
|
for (const batch of batches(ids)) {
|
|
31901
32094
|
const placeholders = batch.map(() => "?").join(",");
|
|
31902
32095
|
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(
|
|
32096
|
+
result.set(string2(row.thread_id), [Number(row.n), string2(row.latest)]);
|
|
31904
32097
|
}
|
|
31905
32098
|
return result;
|
|
31906
32099
|
}
|
|
@@ -31914,10 +32107,10 @@ function linkedSessions(db2, ids) {
|
|
|
31914
32107
|
CASE WHEN json_valid(payload_json) THEN json_extract(payload_json,'$.nativeThreadRef.strength') END AS strength,
|
|
31915
32108
|
CASE WHEN json_valid(payload_json) THEN json_extract(payload_json,'$.nativeThreadRef.driver') END AS driver
|
|
31916
32109
|
FROM orchestration_v2_projection_provider_threads WHERE thread_id IN (${placeholders})`).all(...batch)) {
|
|
31917
|
-
const source = providerSource[
|
|
31918
|
-
const nativeID =
|
|
32110
|
+
const source = providerSource[string2(row.provider)];
|
|
32111
|
+
const nativeID = string2(row.native_id);
|
|
31919
32112
|
if (!source || row.strength !== "strong" || row.driver && row.driver !== row.provider || !nativeID || nativeID.length > 512) continue;
|
|
31920
|
-
const id2 =
|
|
32113
|
+
const id2 = string2(row.thread_id);
|
|
31921
32114
|
links.set(id2, [.../* @__PURE__ */ new Set([...links.get(id2) || [], identity(source, nativeID)])]);
|
|
31922
32115
|
}
|
|
31923
32116
|
}
|
|
@@ -31932,8 +32125,8 @@ function discoverV2(db2, path, databaseRevision) {
|
|
|
31932
32125
|
CASE WHEN json_valid(payload_json) THEN json_extract(payload_json,'$.lineage.relationshipToParent') END AS relationship,
|
|
31933
32126
|
json_valid(payload_json) AS valid_payload
|
|
31934
32127
|
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) =>
|
|
32128
|
+
const selected = rows2.slice(0, MAX_THREADS), ids = selected.map((row) => string2(row.thread_id));
|
|
32129
|
+
const roots2 = projectRoots(db2, selected.map((row) => string2(row.project_id)));
|
|
31937
32130
|
const counts = aggregates(db2, "orchestration_v2_projection_messages", ids);
|
|
31938
32131
|
const items = aggregates(db2, "orchestration_v2_projection_turn_items", ids);
|
|
31939
32132
|
const links = linkedSessions(db2, ids);
|
|
@@ -31941,28 +32134,28 @@ function discoverV2(db2, path, databaseRevision) {
|
|
|
31941
32134
|
if (rows2.length > MAX_THREADS) warnings.push(`T3 Code discovery is limited to ${MAX_THREADS.toLocaleString()} threads.`);
|
|
31942
32135
|
let unreadableMetadata = 0;
|
|
31943
32136
|
for (const row of selected) {
|
|
31944
|
-
const nativeID =
|
|
32137
|
+
const nativeID = string2(row.thread_id), created = time2(row.created_at);
|
|
31945
32138
|
if (!nativeID || nativeID.length > 512 || !created) continue;
|
|
31946
32139
|
if (!row.valid_payload) unreadableMetadata++;
|
|
31947
|
-
const
|
|
31948
|
-
const p = project(SOURCE,
|
|
32140
|
+
const directory3 = string2(row.worktree_path) || roots2.get(string2(row.project_id)) || "";
|
|
32141
|
+
const p = project(SOURCE, directory3);
|
|
31949
32142
|
projects.set(p.id, p);
|
|
31950
|
-
const session = blankSession(SOURCE, nativeID,
|
|
31951
|
-
const parent =
|
|
32143
|
+
const session = blankSession(SOURCE, nativeID, directory3);
|
|
32144
|
+
const parent = string2(row.parent_thread_id);
|
|
31952
32145
|
session.parentID = row.relationship === "subagent" && parent ? identity(SOURCE, parent) : void 0;
|
|
31953
32146
|
session.forkID = row.relationship === "fork" && parent ? identity(SOURCE, parent) : void 0;
|
|
31954
32147
|
Object.assign(session, {
|
|
31955
|
-
title:
|
|
32148
|
+
title: string2(row.title) || "T3 Code thread",
|
|
31956
32149
|
projectID: p.id,
|
|
31957
32150
|
created,
|
|
31958
32151
|
updated: time2(row.updated_at) || created,
|
|
31959
32152
|
archived: Boolean(row.archived_at),
|
|
31960
|
-
model:
|
|
31961
|
-
provider:
|
|
32153
|
+
model: string2(row.model) || "Unknown model",
|
|
32154
|
+
provider: string2(row.default_provider),
|
|
31962
32155
|
agent: "T3 Code",
|
|
31963
32156
|
linkedSessionIDs: links.get(nativeID) || []
|
|
31964
32157
|
});
|
|
31965
|
-
const revision2 = digest([row.updated_at, counts.get(nativeID), items.get(nativeID), links.get(nativeID)]);
|
|
32158
|
+
const revision2 = digest([3, row.updated_at, counts.get(nativeID), items.get(nativeID), links.get(nativeID)]);
|
|
31966
32159
|
sessions.push({ session, revision: revision2, locator: { path, databaseRevision, threadID: nativeID, format: "v2", metadataPartial: row.valid_payload ? "" : "1" } });
|
|
31967
32160
|
}
|
|
31968
32161
|
if (unreadableMetadata) warnings.push(`${unreadableMetadata} T3 Code threads had unreadable metadata; model or lineage may be unavailable.`);
|
|
@@ -31975,23 +32168,23 @@ function discoverV1(db2, path, databaseRevision) {
|
|
|
31975
32168
|
CASE WHEN json_valid(model_selection_json) THEN substr(json_extract(model_selection_json,'$.model'),1,200) END AS model
|
|
31976
32169
|
FROM projection_threads WHERE deleted_at IS NULL ORDER BY created_at, thread_id LIMIT ?`).all(MAX_THREADS + 1);
|
|
31977
32170
|
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) =>
|
|
32171
|
+
const roots2 = projectRoots(db2, selected.map((row) => string2(row.project_id)));
|
|
32172
|
+
const counts = aggregates(db2, "projection_thread_messages", selected.map((row) => string2(row.thread_id)));
|
|
31980
32173
|
const sessions = [], projects = /* @__PURE__ */ new Map();
|
|
31981
32174
|
for (const row of selected) {
|
|
31982
|
-
const nativeID =
|
|
32175
|
+
const nativeID = string2(row.thread_id), created = time2(row.created_at);
|
|
31983
32176
|
if (!nativeID || nativeID.length > 512 || !created) continue;
|
|
31984
|
-
const
|
|
31985
|
-
const p = project(SOURCE,
|
|
32177
|
+
const directory3 = string2(row.worktree_path) || roots2.get(string2(row.project_id)) || "";
|
|
32178
|
+
const p = project(SOURCE, directory3);
|
|
31986
32179
|
projects.set(p.id, p);
|
|
31987
|
-
const session = blankSession(SOURCE, nativeID,
|
|
32180
|
+
const session = blankSession(SOURCE, nativeID, directory3);
|
|
31988
32181
|
Object.assign(session, {
|
|
31989
|
-
title:
|
|
32182
|
+
title: string2(row.title) || "T3 Code thread",
|
|
31990
32183
|
projectID: p.id,
|
|
31991
32184
|
created,
|
|
31992
32185
|
updated: time2(row.updated_at) || created,
|
|
31993
32186
|
archived: Boolean(row.archived_at),
|
|
31994
|
-
model:
|
|
32187
|
+
model: string2(row.model) || "Unknown model",
|
|
31995
32188
|
agent: "T3 Code"
|
|
31996
32189
|
});
|
|
31997
32190
|
sessions.push({ session, revision: digest([row.updated_at, counts.get(nativeID)]), locator: { path, databaseRevision, threadID: nativeID, format: "v1" } });
|
|
@@ -32000,15 +32193,15 @@ function discoverV1(db2, path, databaseRevision) {
|
|
|
32000
32193
|
if (rows2.length > MAX_THREADS) warnings.push(`T3 Code discovery is limited to ${MAX_THREADS.toLocaleString()} threads.`);
|
|
32001
32194
|
return { sessions, projects: [...projects.values()], warnings };
|
|
32002
32195
|
}
|
|
32003
|
-
function v2Message(row,
|
|
32004
|
-
const parsed = parsedObject(row.payload_json), item = parsed || {}, type =
|
|
32196
|
+
function v2Message(row, directory3) {
|
|
32197
|
+
const parsed = parsedObject(row.payload_json), item = parsed || {}, type = string2(row.type), id2 = string2(row.turn_item_id);
|
|
32005
32198
|
const role = type === "user_message" ? "user" : type === "assistant_message" ? "assistant" : type === "reasoning" ? "assistant" : "tool";
|
|
32006
32199
|
const message2 = blankMessage(`item:${id2}`, time2(item.startedAt || item.createdAt), role);
|
|
32007
|
-
const recorded = Boolean(message2.time), name =
|
|
32200
|
+
const recorded = Boolean(message2.time), name = string2(item.title || item.toolName) || type.replaceAll("_", " ");
|
|
32008
32201
|
const fields2 = {
|
|
32009
32202
|
nativeID: id2,
|
|
32010
32203
|
nativeType: type,
|
|
32011
|
-
parentID:
|
|
32204
|
+
parentID: string2(item.parentItemId) || void 0,
|
|
32012
32205
|
status: status(row.status),
|
|
32013
32206
|
endTime: time2(item.completedAt) || null,
|
|
32014
32207
|
timeSource: recorded ? "recorded" : "unknown"
|
|
@@ -32019,34 +32212,42 @@ function v2Message(row, directory2) {
|
|
|
32019
32212
|
return message2;
|
|
32020
32213
|
}
|
|
32021
32214
|
if (type === "user_message" || type === "assistant_message") {
|
|
32022
|
-
const body =
|
|
32215
|
+
const body = string2(item.text);
|
|
32023
32216
|
if (body) addText(message2, body, role === "user" ? "You" : "Assistant");
|
|
32024
32217
|
message2.events = [{ ...messageEvent(message2, body, id2), ...fields2 }];
|
|
32025
32218
|
if (Array.isArray(item.attachments) && item.attachments.length) message2.partial = true;
|
|
32026
32219
|
return message2;
|
|
32027
32220
|
}
|
|
32028
32221
|
if (type === "reasoning") {
|
|
32029
|
-
message2.events = [eventFor(message2, id2, "reasoning", "Recorded reasoning",
|
|
32222
|
+
message2.events = [eventFor(message2, id2, "reasoning", "Recorded reasoning", string2(item.text), fields2)];
|
|
32030
32223
|
return message2;
|
|
32031
32224
|
}
|
|
32032
32225
|
if (type === "file_change") {
|
|
32033
|
-
const file =
|
|
32034
|
-
|
|
32226
|
+
const file = string2(item.fileName), completed = status(row.status) === "completed";
|
|
32227
|
+
const native = item.nativeItemRef;
|
|
32228
|
+
if (native?.driver === "opencode" && openCodeEditTools.has(file.toLowerCase())) {
|
|
32229
|
+
message2.tools.push(file);
|
|
32230
|
+
const kind2 = completed || fields2.status === "failed" ? "tool_result" : "tool_call";
|
|
32231
|
+
message2.events = [eventFor(message2, id2, kind2, file, "", { ...fields2, callID: string2(native.nativeId) || void 0 })];
|
|
32232
|
+
return message2;
|
|
32233
|
+
}
|
|
32234
|
+
if (file && completed) message2.files.push({ path: isAbsolute3(file) ? file : join11(directory3, file), source: "file change", steps: 1 });
|
|
32035
32235
|
message2.events = [eventFor(message2, id2, "file_change", file || name, "", fields2)];
|
|
32036
32236
|
return message2;
|
|
32037
32237
|
}
|
|
32038
32238
|
if (["command_execution", "dynamic_tool", "file_search", "web_search"].includes(type)) {
|
|
32039
32239
|
const input = eventText(item.input ?? item.pattern ?? item.patterns, 32e3);
|
|
32040
|
-
const
|
|
32240
|
+
const output2 = eventText(item.output ?? item.results, 64e3);
|
|
32041
32241
|
const kind2 = fields2.status === "completed" || fields2.status === "failed" ? "tool_result" : "tool_call";
|
|
32042
32242
|
message2.tools.push(name);
|
|
32043
32243
|
if (input) addText(message2, input, "Tool");
|
|
32044
|
-
if (
|
|
32045
|
-
|
|
32244
|
+
if (output2) addText(message2, output2, "Tool");
|
|
32245
|
+
const native = item.nativeItemRef;
|
|
32246
|
+
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
32247
|
return message2;
|
|
32047
32248
|
}
|
|
32048
32249
|
const kind = type === "compaction" ? "compaction" : type === "error" ? "error" : "event";
|
|
32049
|
-
message2.events = [eventFor(message2, id2, kind, name,
|
|
32250
|
+
message2.events = [eventFor(message2, id2, kind, name, string2(item.text), fields2)];
|
|
32050
32251
|
return message2;
|
|
32051
32252
|
}
|
|
32052
32253
|
function readV2(db2, candidate, cursor) {
|
|
@@ -32079,9 +32280,9 @@ function readV1(db2, candidate, cursor) {
|
|
|
32079
32280
|
const messages = rows2.slice(0, PAGE).map((row) => {
|
|
32080
32281
|
const role = row.role === "user" ? "user" : row.role === "assistant" ? "assistant" : "system";
|
|
32081
32282
|
const message2 = blankMessage(`message:${row.message_id}`, time2(row.created_at), role);
|
|
32082
|
-
const body =
|
|
32283
|
+
const body = string2(row.text);
|
|
32083
32284
|
if (body) addText(message2, body, role === "user" ? "You" : "Assistant");
|
|
32084
|
-
message2.events = [{ ...messageEvent(message2, body), nativeID:
|
|
32285
|
+
message2.events = [{ ...messageEvent(message2, body), nativeID: string2(row.message_id), nativeType: "legacy-message" }];
|
|
32085
32286
|
message2.partial = row.text == null;
|
|
32086
32287
|
return message2;
|
|
32087
32288
|
});
|
|
@@ -32092,7 +32293,7 @@ function readV1(db2, candidate, cursor) {
|
|
|
32092
32293
|
note: "Legacy T3 Code text messages only. Tool activity, attachments, and provider links are unavailable."
|
|
32093
32294
|
};
|
|
32094
32295
|
}
|
|
32095
|
-
var SOURCE, PAGE, MAX_THREADS, MAX_ITEM_JSON, providerSource,
|
|
32296
|
+
var SOURCE, PAGE, MAX_THREADS, MAX_ITEM_JSON, providerSource, openCodeEditTools, string2, t3CodeAdapter;
|
|
32096
32297
|
var init_t3_code = __esm({
|
|
32097
32298
|
"server/adapters/t3-code.ts"() {
|
|
32098
32299
|
"use strict";
|
|
@@ -32100,12 +32301,14 @@ var init_t3_code = __esm({
|
|
|
32100
32301
|
init_common();
|
|
32101
32302
|
init_sqlite_snapshot();
|
|
32102
32303
|
init_events();
|
|
32304
|
+
init_commit_extraction();
|
|
32103
32305
|
SOURCE = "t3-code";
|
|
32104
32306
|
PAGE = 100;
|
|
32105
32307
|
MAX_THREADS = 2e4;
|
|
32106
32308
|
MAX_ITEM_JSON = 256e3;
|
|
32107
32309
|
providerSource = { codex: "codex", claudeAgent: "claude-code", opencode: "opencode" };
|
|
32108
|
-
|
|
32310
|
+
openCodeEditTools = /* @__PURE__ */ new Set(["patch", "apply_patch", "edit", "write", "multiedit"]);
|
|
32311
|
+
string2 = (value) => typeof value === "string" ? value : "";
|
|
32109
32312
|
t3CodeAdapter = {
|
|
32110
32313
|
id: SOURCE,
|
|
32111
32314
|
name: "T3 Code",
|
|
@@ -32250,11 +32453,11 @@ function withStore(path, read3) {
|
|
|
32250
32453
|
throw error;
|
|
32251
32454
|
}
|
|
32252
32455
|
});
|
|
32253
|
-
const before = stats(),
|
|
32456
|
+
const before = stats(), directory3 = mkdtempSync2(join12(tmpdir2(), "sessiongraph-cursor-"));
|
|
32254
32457
|
let db2;
|
|
32255
32458
|
try {
|
|
32256
|
-
chmodSync3(
|
|
32257
|
-
const copy = join12(
|
|
32459
|
+
chmodSync3(directory3, 448);
|
|
32460
|
+
const copy = join12(directory3, "store.db");
|
|
32258
32461
|
files.forEach((file, index) => {
|
|
32259
32462
|
if (before[index]) {
|
|
32260
32463
|
const target = index ? `${copy}-wal` : copy;
|
|
@@ -32270,7 +32473,7 @@ function withStore(path, read3) {
|
|
|
32270
32473
|
try {
|
|
32271
32474
|
db2?.close();
|
|
32272
32475
|
} finally {
|
|
32273
|
-
rmSync3(
|
|
32476
|
+
rmSync3(directory3, { recursive: true, force: true });
|
|
32274
32477
|
}
|
|
32275
32478
|
}
|
|
32276
32479
|
}
|
|
@@ -32342,12 +32545,12 @@ function readCursorStore(path) {
|
|
|
32342
32545
|
bytes2 += data.length;
|
|
32343
32546
|
try {
|
|
32344
32547
|
if (item.leaf) {
|
|
32345
|
-
const
|
|
32346
|
-
if (!
|
|
32548
|
+
const json5 = data[0] === 123 ? data : fields(data).find((v3) => v3.field === 4)?.data;
|
|
32549
|
+
if (!json5) {
|
|
32347
32550
|
partial = true;
|
|
32348
32551
|
continue;
|
|
32349
32552
|
}
|
|
32350
|
-
const raw = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(
|
|
32553
|
+
const raw = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(json5));
|
|
32351
32554
|
const msg = cursorMessage(raw, `blob:${item.id}:${ordinal++}`);
|
|
32352
32555
|
if (!msg) {
|
|
32353
32556
|
partial = true;
|
|
@@ -32406,9 +32609,9 @@ var init_cursor_store = __esm({
|
|
|
32406
32609
|
import { isAbsolute as isAbsolute4 } from "node:path";
|
|
32407
32610
|
import { fileURLToPath } from "node:url";
|
|
32408
32611
|
function decode(value) {
|
|
32409
|
-
return
|
|
32612
|
+
return object2(JSON.parse(typeof value === "string" ? value : value instanceof Uint8Array ? Buffer.from(value).toString("utf8") : "{}"));
|
|
32410
32613
|
}
|
|
32411
|
-
function
|
|
32614
|
+
function directory2(raw) {
|
|
32412
32615
|
const value = text2(raw.workspaceIdentifier?.uri?.path) || text2(raw.workspaceIdentifier?.uri) || text2(raw.cwd);
|
|
32413
32616
|
try {
|
|
32414
32617
|
return value.startsWith("file:") ? fileURLToPath(value) : isAbsolute4(value) ? value : "";
|
|
@@ -32435,7 +32638,7 @@ function discoverComposers(path, workspace = "") {
|
|
|
32435
32638
|
if (!nativeID || row.key !== `composerData:${nativeID}`) throw new Error("Composer identity mismatch.");
|
|
32436
32639
|
const headers = Array.isArray(data.fullConversationHeadersOnly) ? data.fullConversationHeadersOnly : Array.isArray(data.conversation) ? data.conversation : [];
|
|
32437
32640
|
if (!headers.length) continue;
|
|
32438
|
-
const session = blankSession("cursor", nativeID,
|
|
32641
|
+
const session = blankSession("cursor", nativeID, directory2(data) || workspace);
|
|
32439
32642
|
session.created = cursorTime(data.createdAt);
|
|
32440
32643
|
if (!session.created) continue;
|
|
32441
32644
|
session.updated = cursorTime(data.lastUpdatedAt) || session.created;
|
|
@@ -32486,7 +32689,7 @@ function readComposer(candidate) {
|
|
|
32486
32689
|
const id2 = text2(header.bubbleId);
|
|
32487
32690
|
const stored = id2 ? get.get(`bubbleId:${nativeID}:${id2}`, MAX_BUBBLE) : void 0;
|
|
32488
32691
|
if (stored) bytes2 += typeof stored.value === "string" ? Buffer.byteLength(stored.value) : stored.value.byteLength;
|
|
32489
|
-
const raw = stored ? { ...header, ...decode(stored.value) } : { ...header, ...
|
|
32692
|
+
const raw = stored ? { ...header, ...decode(stored.value) } : { ...header, ...object2(data.conversationMap?.[id2]) };
|
|
32490
32693
|
if (![1, 2].includes(raw.type)) {
|
|
32491
32694
|
partial = true;
|
|
32492
32695
|
continue;
|
|
@@ -32545,7 +32748,7 @@ async function stamp(path) {
|
|
|
32545
32748
|
async function snapshot(locator) {
|
|
32546
32749
|
return digest(await Promise.all([stamp(locator.path), locator.kind === "transcript" ? null : stamp(`${locator.path}-wal`), locator.meta ? stamp(locator.meta) : null]));
|
|
32547
32750
|
}
|
|
32548
|
-
async function
|
|
32751
|
+
async function json4(path) {
|
|
32549
32752
|
const s = await fileStats(path);
|
|
32550
32753
|
if (!s) return {};
|
|
32551
32754
|
if (s.size > 128e3) throw new Error("Cursor metadata exceeds the 128 KB limit.");
|
|
@@ -32575,7 +32778,7 @@ async function workspacePaths(root3, warnings) {
|
|
|
32575
32778
|
const database = join13(storage, entry.name, "state.vscdb");
|
|
32576
32779
|
stores.set(database, "");
|
|
32577
32780
|
try {
|
|
32578
|
-
const info = await
|
|
32781
|
+
const info = await json4(join13(storage, entry.name, "workspace.json"));
|
|
32579
32782
|
if (typeof info.folder === "string" && info.folder.startsWith("file:")) {
|
|
32580
32783
|
const path = cwd(fileURLToPath2(info.folder));
|
|
32581
32784
|
if (path) stores.set(database, path);
|
|
@@ -32635,7 +32838,7 @@ function createCursorAdapter(options = {}) {
|
|
|
32635
32838
|
return matches.length === 1 ? matches[0] : "";
|
|
32636
32839
|
};
|
|
32637
32840
|
let unreadable = 0, legacy = 0, scanned = 0;
|
|
32638
|
-
const add = async (path, id2, kind,
|
|
32841
|
+
const add = async (path, id2, kind, directory3, parent = "", workspaceHash = "") => {
|
|
32639
32842
|
if (!validID(id2) || ++scanned > LIMIT) return;
|
|
32640
32843
|
try {
|
|
32641
32844
|
const stats = await fileStats(path);
|
|
@@ -32644,11 +32847,11 @@ function createCursorAdapter(options = {}) {
|
|
|
32644
32847
|
const locator = { path, kind };
|
|
32645
32848
|
if (kind !== "transcript") locator.meta = join13(path, "..", "meta.json");
|
|
32646
32849
|
const before = await snapshot(locator);
|
|
32647
|
-
const extra2 = locator.meta ? await
|
|
32850
|
+
const extra2 = locator.meta ? await json4(locator.meta) : {};
|
|
32648
32851
|
const meta = kind === "transcript" ? {} : cursorStoreMetadata(path);
|
|
32649
32852
|
if (meta.agentId && meta.agentId !== id2) throw new Error("Cursor native identity mismatch.");
|
|
32650
32853
|
if (kind !== "transcript" && !meta.latestRootBlobId) return;
|
|
32651
|
-
const session = blankSession("cursor", native, cwd(meta.cwd) || cwd(extra2.cwd) ||
|
|
32854
|
+
const session = blankSession("cursor", native, cwd(meta.cwd) || cwd(extra2.cwd) || directory3);
|
|
32652
32855
|
session.agent = kind === "cli" ? "Cursor Agent" : kind === "acp" ? "Cursor ACP" : parent ? "Cursor subagent" : "Cursor IDE";
|
|
32653
32856
|
if (parent) session.parentID = identity("cursor", parent);
|
|
32654
32857
|
session.title = typeof meta.name === "string" && meta.name.trim() ? meta.name : typeof extra2.title === "string" && extra2.title.trim() ? extra2.title : "Cursor session";
|
|
@@ -32705,15 +32908,15 @@ function createCursorAdapter(options = {}) {
|
|
|
32705
32908
|
const projects = join13(root3(), "projects");
|
|
32706
32909
|
for (const dir of await entries(projects, warnings)) {
|
|
32707
32910
|
if (!dir.isDirectory() || scanned >= LIMIT) continue;
|
|
32708
|
-
const transcripts = join13(projects, dir.name, "agent-transcripts"),
|
|
32911
|
+
const transcripts = join13(projects, dir.name, "agent-transcripts"), directory3 = match2(dir.name, slug);
|
|
32709
32912
|
for (const entry of await entries(transcripts, warnings)) {
|
|
32710
32913
|
if (scanned >= LIMIT) break;
|
|
32711
|
-
if (entry.isFile() && entry.name.endsWith(".jsonl")) await add(join13(transcripts, entry.name), entry.name.slice(0, -6), "transcript",
|
|
32914
|
+
if (entry.isFile() && entry.name.endsWith(".jsonl")) await add(join13(transcripts, entry.name), entry.name.slice(0, -6), "transcript", directory3);
|
|
32712
32915
|
else if (entry.isFile() && entry.name.endsWith(".txt")) legacy++;
|
|
32713
32916
|
else if (entry.isDirectory() && validID(entry.name)) {
|
|
32714
|
-
await add(join13(transcripts, entry.name, `${entry.name}.jsonl`), entry.name, "transcript",
|
|
32917
|
+
await add(join13(transcripts, entry.name, `${entry.name}.jsonl`), entry.name, "transcript", directory3);
|
|
32715
32918
|
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",
|
|
32919
|
+
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
32920
|
if (scanned >= LIMIT) break;
|
|
32718
32921
|
}
|
|
32719
32922
|
}
|
|
@@ -32722,13 +32925,13 @@ function createCursorAdapter(options = {}) {
|
|
|
32722
32925
|
const chats = join13(root3(), "chats");
|
|
32723
32926
|
for (const bucket of await entries(chats, warnings)) {
|
|
32724
32927
|
if (!bucket.isDirectory() || scanned >= LIMIT) continue;
|
|
32725
|
-
const folder = join13(chats, bucket.name),
|
|
32928
|
+
const folder = join13(chats, bucket.name), directory3 = match2(bucket.name, hashCwd);
|
|
32726
32929
|
if (/^[a-f\d]{32}$/i.test(bucket.name) && await fileStats(join13(folder, "store.db"))) {
|
|
32727
32930
|
const id2 = bucket.name.replace(/^(.{8})(.{4})(.{4})(.{4})(.{12})$/, "$1-$2-$3-$4-$5");
|
|
32728
32931
|
await add(join13(folder, "store.db"), id2, "cli", "");
|
|
32729
32932
|
}
|
|
32730
32933
|
for (const entry of await entries(folder, warnings)) {
|
|
32731
|
-
if (entry.isDirectory()) await add(join13(folder, entry.name, "store.db"), entry.name, "cli",
|
|
32934
|
+
if (entry.isDirectory()) await add(join13(folder, entry.name, "store.db"), entry.name, "cli", directory3, "", bucket.name);
|
|
32732
32935
|
if (scanned >= LIMIT) break;
|
|
32733
32936
|
}
|
|
32734
32937
|
}
|
|
@@ -32811,7 +33014,7 @@ function projectRootFile(path) {
|
|
|
32811
33014
|
return join14(parts.slice(0, parts.lastIndexOf("chats")).join(sep4), ".project_root");
|
|
32812
33015
|
}
|
|
32813
33016
|
function geminiConversation(contents, lines) {
|
|
32814
|
-
const parsed = lines ? jsonLines(contents) : { rows: [
|
|
33017
|
+
const parsed = lines ? jsonLines(contents) : { rows: [object2(json3(contents))], partial: false };
|
|
32815
33018
|
let metadata2 = {};
|
|
32816
33019
|
const messages = /* @__PURE__ */ new Map();
|
|
32817
33020
|
const patch = (p) => {
|
|
@@ -32828,9 +33031,9 @@ function geminiConversation(contents, lines) {
|
|
|
32828
33031
|
const ids = [...messages.keys()], index = ids.indexOf(row.$rewindTo);
|
|
32829
33032
|
for (const id2 of index < 0 ? ids : ids.slice(index)) messages.delete(id2);
|
|
32830
33033
|
} else if (row.$patch) {
|
|
32831
|
-
const p =
|
|
33034
|
+
const p = object2(row.$patch);
|
|
32832
33035
|
if (p.id) patch(p);
|
|
32833
|
-
for (const update of Array.isArray(p.updates) ? p.updates : []) patch(
|
|
33036
|
+
for (const update of Array.isArray(p.updates) ? p.updates : []) patch(object2(update));
|
|
32834
33037
|
for (const id2 of Array.isArray(p.removeIds) ? p.removeIds : []) messages.delete(id2);
|
|
32835
33038
|
for (const id2 of Array.isArray(p.orderIds) ? p.orderIds : []) {
|
|
32836
33039
|
const value = messages.get(id2);
|
|
@@ -32840,7 +33043,7 @@ function geminiConversation(contents, lines) {
|
|
|
32840
33043
|
}
|
|
32841
33044
|
}
|
|
32842
33045
|
} else if (row.$set || row.sessionId) {
|
|
32843
|
-
const update = row.$set ?
|
|
33046
|
+
const update = row.$set ? object2(row.$set) : row;
|
|
32844
33047
|
metadata2 = { ...metadata2, ...update };
|
|
32845
33048
|
if (Array.isArray(update.messages)) {
|
|
32846
33049
|
if (row.$set) messages.clear();
|
|
@@ -32871,7 +33074,7 @@ var init_gemini = __esm({
|
|
|
32871
33074
|
parse(path, files) {
|
|
32872
33075
|
const { metadata: meta, records, partial } = geminiConversation(files.get(path), path.endsWith(".jsonl"));
|
|
32873
33076
|
if (!text2(meta.sessionId)) throw new Error("Unsupported Gemini history.");
|
|
32874
|
-
const
|
|
33077
|
+
const directory3 = (files.get(projectRootFile(path)) || "").trim().slice(0, 4096);
|
|
32875
33078
|
const messages = records.map((raw, index) => {
|
|
32876
33079
|
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
33080
|
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 +33083,9 @@ var init_gemini = __esm({
|
|
|
32880
33083
|
message2.tools.push(name);
|
|
32881
33084
|
message2.events.push(eventFor(message2, `call:${id2}`, "tool_call", name, "", { callID: id2, input: eventText(call.args), status: "unknown" }));
|
|
32882
33085
|
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,
|
|
33086
|
+
const output2 = eventText(call.result);
|
|
33087
|
+
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" }));
|
|
33088
|
+
addText(message2, output2, "Tool");
|
|
32886
33089
|
}
|
|
32887
33090
|
}
|
|
32888
33091
|
return message2;
|
|
@@ -32894,7 +33097,7 @@ var init_gemini = __esm({
|
|
|
32894
33097
|
messages,
|
|
32895
33098
|
parent,
|
|
32896
33099
|
partial,
|
|
32897
|
-
session: { directory:
|
|
33100
|
+
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
33101
|
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
33102
|
};
|
|
32900
33103
|
}
|
|
@@ -32929,7 +33132,7 @@ var init_qwen = __esm({
|
|
|
32929
33132
|
const messages = rows2.map((raw, index) => {
|
|
32930
33133
|
const id2 = text2(raw.uuid) || `record:${index}`;
|
|
32931
33134
|
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:
|
|
33135
|
+
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
33136
|
for (const event of message3.events || []) if (event.kind === "tool_result") {
|
|
32934
33137
|
event.status = raw.toolCallResult?.status === "success" ? "completed" : raw.toolCallResult?.status === "error" ? "failed" : "unknown";
|
|
32935
33138
|
event.nativeType = text2(raw.toolCallResult?.status);
|
|
@@ -32977,11 +33180,11 @@ var init_copilot = __esm({
|
|
|
32977
33180
|
match: (path) => /(?:^|\/)events\.jsonl$/.test(path),
|
|
32978
33181
|
parse(path, files) {
|
|
32979
33182
|
const { rows: rows2, partial } = jsonLines(files.get(path));
|
|
32980
|
-
const start = rows2.find((r) => r.type === "session.start"), meta =
|
|
33183
|
+
const start = rows2.find((r) => r.type === "session.start"), meta = object2(start?.data);
|
|
32981
33184
|
if (!text2(meta.sessionId)) throw new Error("Unsupported Copilot event log.");
|
|
32982
33185
|
const toolNames = new Map(rows2.filter((r) => r.type === "tool.execution_start").map((r) => [r.data?.toolCallId, text2(r.data?.toolName)]));
|
|
32983
33186
|
const messages = rows2.filter((r) => !r.ephemeral && !["assistant.message_delta", "assistant.reasoning_delta"].includes(r.type)).map((raw, index) => {
|
|
32984
|
-
const data =
|
|
33187
|
+
const data = object2(raw.data), kind = text2(raw.type), human2 = kind === "user.message" && !data.isAutopilotContinuation && !data.source;
|
|
32985
33188
|
const message2 = blankMessage(text2(raw.id) || `record:${index}`, time(raw.timestamp), human2 ? "user" : kind === "assistant.message" ? "assistant" : kind.startsWith("tool.") ? "tool" : "system");
|
|
32986
33189
|
if (["user.message", "assistant.message"].includes(kind)) {
|
|
32987
33190
|
const content = text2(data.content);
|
|
@@ -33027,7 +33230,7 @@ function vscodeChatLog(content) {
|
|
|
33027
33230
|
for (const line of content.split("\n")) {
|
|
33028
33231
|
if (!line.trim()) continue;
|
|
33029
33232
|
if (++records > 5e4) throw new Error("Chat log exceeds the 50,000-operation limit.");
|
|
33030
|
-
const entry =
|
|
33233
|
+
const entry = object2(JSON.parse(line));
|
|
33031
33234
|
if (entry.kind === 0) {
|
|
33032
33235
|
if (records !== 1 || !entry.v || typeof entry.v !== "object" || Array.isArray(entry.v)) throw new Error("Invalid chat log initial state.");
|
|
33033
33236
|
state2 = entry.v;
|
|
@@ -33072,17 +33275,17 @@ var init_vscode_chat_log = __esm({
|
|
|
33072
33275
|
|
|
33073
33276
|
// server/adapters/copilot-chat.ts
|
|
33074
33277
|
import { homedir as homedir12 } from "node:os";
|
|
33075
|
-
import { basename as basename6, dirname as dirname5, join as join17, posix, win32 as
|
|
33278
|
+
import { basename as basename6, dirname as dirname5, join as join17, posix as posix2, win32 as win323 } from "node:path";
|
|
33076
33279
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
33077
33280
|
function copilotChatRoots(platform = process.platform, home = homedir12(), env = process.env) {
|
|
33078
|
-
const path = platform === "win32" ?
|
|
33281
|
+
const path = platform === "win32" ? win323 : posix2;
|
|
33079
33282
|
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
33283
|
const override = sourcePath("copilot-chat") || env.SESSIONGRAPH_COPILOT_CHAT_USER_DATA_DIR;
|
|
33081
33284
|
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
33285
|
return users.flatMap((user) => [path.join(user, "workspaceStorage"), path.join(user, "globalStorage", "emptyWindowChatSessions")]);
|
|
33083
33286
|
}
|
|
33084
33287
|
function vscodeChatPath(value) {
|
|
33085
|
-
const raw =
|
|
33288
|
+
const raw = object2(value);
|
|
33086
33289
|
if (raw.scheme) {
|
|
33087
33290
|
if (raw.scheme !== "file") return `${text2(raw.scheme)}://${text2(raw.authority)}${text2(raw.path)}`;
|
|
33088
33291
|
const path = text2(raw.path);
|
|
@@ -33098,7 +33301,7 @@ function vscodeChatPath(value) {
|
|
|
33098
33301
|
}
|
|
33099
33302
|
}
|
|
33100
33303
|
function responsePart(message2, value, index) {
|
|
33101
|
-
const part =
|
|
33304
|
+
const part = object2(value), kind = text2(part.kind), id2 = `part:${index}`;
|
|
33102
33305
|
const fields2 = { nativeType: kind || "markdown", nativeID: text2(part.id) || void 0 };
|
|
33103
33306
|
if (typeof value === "string" || !kind && typeof part.value === "string" || kind === "markdownContent" || kind === "markdownVuln") {
|
|
33104
33307
|
const content = markdown(kind ? part.content : value);
|
|
@@ -33109,19 +33312,19 @@ function responsePart(message2, value, index) {
|
|
|
33109
33312
|
message2.events.push(eventFor(message2, id2, "reasoning", "Recorded reasoning", content, { ...fields2, ...recordedTime(part.reasoningStartedAt) }));
|
|
33110
33313
|
addText(message2, content, "Tool");
|
|
33111
33314
|
} else if (kind === "toolInvocationSerialized") {
|
|
33112
|
-
const data =
|
|
33315
|
+
const data = object2(part.toolSpecificData), command = object2(data.commandLine), details = object2(part.resultDetails);
|
|
33113
33316
|
const name = text2(part.toolId) || "Tool", callID = text2(part.toolCallId) || void 0;
|
|
33114
33317
|
const input = eventText(data.rawInput ?? command.userEdited ?? command.toolEdited ?? command.original ?? details.input);
|
|
33115
|
-
const denied = part.isConfirmed === false || [0, 5].includes(
|
|
33318
|
+
const denied = part.isConfirmed === false || [0, 5].includes(object2(part.isConfirmed).type);
|
|
33116
33319
|
const status2 = denied || part.resultError ? "failed" : part.isComplete === true ? "completed" : "unknown";
|
|
33117
33320
|
const correlation = { ...fields2, callID, parentID: text2(part.subAgentInvocationId) || void 0 };
|
|
33118
33321
|
message2.events.push(eventFor(message2, `${id2}:call`, "tool_call", name, markdown(part.invocationMessage), { ...correlation, ...recordedTime(part.startedAt), input, status: "unknown" }));
|
|
33119
33322
|
message2.tools.push(name);
|
|
33120
33323
|
addText(message2, input, "Tool");
|
|
33121
33324
|
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,
|
|
33325
|
+
const output2 = eventText(part.resultError || (denied ? "Tool invocation was denied or skipped." : details.output ?? part.resultDetails ?? markdown(part.pastTenseMessage)));
|
|
33326
|
+
message2.events.push(eventFor(message2, `${id2}:result`, "tool_result", name, markdown(part.pastTenseMessage), { ...correlation, ...recordedTime(part.completedAt), role: "tool", output: output2, status: status2 }));
|
|
33327
|
+
addText(message2, output2, "Tool");
|
|
33125
33328
|
} else message2.partial = true;
|
|
33126
33329
|
} else {
|
|
33127
33330
|
message2.events.push(eventFor(message2, id2, "event", kind || "Unsupported chat content", eventText(part), { ...fields2, partial: true }));
|
|
@@ -33134,7 +33337,7 @@ function chatMessages(requests) {
|
|
|
33134
33337
|
const requestID = text2(request.requestId) || `request:${index}`;
|
|
33135
33338
|
const injected = Boolean(request.isSystemInitiated || request.hiddenFromTranscript || request.requestHiddenFromTranscript);
|
|
33136
33339
|
const user = blankMessage(requestID, time(request.timestamp), injected ? "system" : "user");
|
|
33137
|
-
const content = typeof request.message === "string" ? request.message : text2(
|
|
33340
|
+
const content = typeof request.message === "string" ? request.message : text2(object2(request.message).text);
|
|
33138
33341
|
user.events = [eventFor(user, "message", injected ? "event" : "message", injected ? "Injected message" : "User message", content, { nativeID: requestID, ...recordedTime(request.timestamp) })];
|
|
33139
33342
|
addText(user, content, injected ? "Tool" : "You");
|
|
33140
33343
|
if (request.variableData?.variables?.length) user.partial = true;
|
|
@@ -33173,7 +33376,7 @@ var init_copilot_chat = __esm({
|
|
|
33173
33376
|
init_local_files();
|
|
33174
33377
|
init_vscode_chat_log();
|
|
33175
33378
|
init_source_paths();
|
|
33176
|
-
markdown = (value) => typeof value === "string" ? value : text2(
|
|
33379
|
+
markdown = (value) => typeof value === "string" ? value : text2(object2(value).value);
|
|
33177
33380
|
recordedTime = (value) => ({ time: time(value) || null, timeSource: time(value) ? "recorded" : "unknown" });
|
|
33178
33381
|
match = (path) => /^(?:[^/]+\/chatSessions\/)?[^/]+\.jsonl?$/.test(path) && !["index.json", "workspace.json"].includes(path);
|
|
33179
33382
|
roots = () => copilotChatRoots();
|
|
@@ -33188,13 +33391,13 @@ var init_copilot_chat = __esm({
|
|
|
33188
33391
|
extras: (path) => [...basename6(dirname5(path)) === "chatSessions" ? [join17(dirname5(dirname5(path)), "workspace.json")] : [], ...path.endsWith(".json") ? [`${path}l`] : []],
|
|
33189
33392
|
parse(path, files) {
|
|
33190
33393
|
const log = path.endsWith(".jsonl") ? path : `${path}l`;
|
|
33191
|
-
const data = files.has(log) ? vscodeChatLog(files.get(log)) :
|
|
33394
|
+
const data = files.has(log) ? vscodeChatLog(files.get(log)) : object2(JSON.parse(files.get(path)));
|
|
33192
33395
|
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
33396
|
if (data.sessionId !== basename6(path).replace(/\.jsonl?$/, "")) throw new Error("VS Code chat identity mismatch.");
|
|
33194
33397
|
if (!data.requests.length) return;
|
|
33195
33398
|
if (data.requests.length > 25e3) throw new Error("Chat exceeds the 50,000-message limit.");
|
|
33196
33399
|
const workspacePath = join17(dirname5(dirname5(path)), "workspace.json");
|
|
33197
|
-
const workspace = files.has(workspacePath) ?
|
|
33400
|
+
const workspace = files.has(workspacePath) ? object2(JSON.parse(files.get(workspacePath))) : {};
|
|
33198
33401
|
const messages = chatMessages(data.requests);
|
|
33199
33402
|
const model = [...data.requests].reverse().find((r) => text2(r.modelId));
|
|
33200
33403
|
return {
|
|
@@ -33231,15 +33434,15 @@ function taskAdapter(id2, name, extension, env) {
|
|
|
33231
33434
|
match: (path) => /^[^/]+\/api_conversation_history\.json$/.test(path) || id2 === "cline" && /^[^/]+\/[^/]+\.messages\.json$/.test(path),
|
|
33232
33435
|
extras: (path) => ["history_item.json", "task_metadata.json", "session.json"].map((file) => join18(dirname6(path), file)),
|
|
33233
33436
|
parse(path, files) {
|
|
33234
|
-
const sdk = path.endsWith(".messages.json"), value =
|
|
33235
|
-
const records = sdk ?
|
|
33437
|
+
const sdk = path.endsWith(".messages.json"), value = json3(files.get(path));
|
|
33438
|
+
const records = sdk ? object2(value).messages : value;
|
|
33236
33439
|
if (!Array.isArray(records) || sdk && !text2(value.sessionId)) throw new Error("Unsupported task history.");
|
|
33237
|
-
const read3 = (name2) =>
|
|
33440
|
+
const read3 = (name2) => object2(files.has(join18(dirname6(path), name2)) ? json3(files.get(join18(dirname6(path), name2))) : void 0);
|
|
33238
33441
|
const history = read3("history_item.json"), info = read3("session.json"), task = read3("task_metadata.json");
|
|
33239
33442
|
const nativeID = sdk ? value.sessionId : basename7(dirname6(path));
|
|
33240
33443
|
if (history.id && history.id !== nativeID || info.session_id && info.session_id !== nativeID) throw new Error("Task metadata identity mismatch.");
|
|
33241
33444
|
const messages = records.map((raw, index) => {
|
|
33242
|
-
const row =
|
|
33445
|
+
const row = object2(raw), message2 = conversationMessage(row, `record:${index}`);
|
|
33243
33446
|
if (row.isSummary || row.isTruncationMarker || row.type === "reasoning") {
|
|
33244
33447
|
message2.role = "system";
|
|
33245
33448
|
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 +33472,7 @@ var init_extensions = __esm({
|
|
|
33269
33472
|
init_events();
|
|
33270
33473
|
init_local_files();
|
|
33271
33474
|
init_local_messages();
|
|
33272
|
-
|
|
33475
|
+
init_playback_tokens2();
|
|
33273
33476
|
init_source_paths();
|
|
33274
33477
|
clineAdapter = taskAdapter("cline", "Cline", "saoudrizwan.claude-dev", "SESSIONGRAPH_CLINE_HOME");
|
|
33275
33478
|
rooAdapter = taskAdapter("roo-code", "Roo Code", "rooveterinaryinc.roo-cline", "SESSIONGRAPH_ROO_HOME");
|
|
@@ -33284,17 +33487,17 @@ var init_extensions = __esm({
|
|
|
33284
33487
|
extras: (path) => [join18(dirname6(path), "sessions.json")],
|
|
33285
33488
|
revisionExtras: false,
|
|
33286
33489
|
parse(path, files) {
|
|
33287
|
-
const value =
|
|
33490
|
+
const value = object2(json3(files.get(path)));
|
|
33288
33491
|
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) ?
|
|
33492
|
+
const indexPath = join18(dirname6(path), "sessions.json"), index = files.has(indexPath) ? json3(files.get(indexPath)) : [];
|
|
33493
|
+
const meta = Array.isArray(index) ? object2(index.find((r) => r.sessionId === value.sessionId)) : {};
|
|
33291
33494
|
const messages = value.history.map((item, i) => {
|
|
33292
|
-
const row =
|
|
33495
|
+
const row = object2(item), raw = object2(row.message), message2 = conversationMessage(raw, `record:${i}`);
|
|
33293
33496
|
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
33497
|
if (row.conversationSummary) message2.events.push(eventFor(message2, "summary", "compaction", "Conversation summary", text2(row.conversationSummary)));
|
|
33295
33498
|
return message2;
|
|
33296
33499
|
});
|
|
33297
|
-
const usage =
|
|
33500
|
+
const usage = object2(value.usage);
|
|
33298
33501
|
return {
|
|
33299
33502
|
nativeID: value.sessionId,
|
|
33300
33503
|
messages,
|
|
@@ -33330,7 +33533,7 @@ var init_harness_paths = __esm({
|
|
|
33330
33533
|
// server/adapters/harness-extra-formats.ts
|
|
33331
33534
|
import { basename as basename8, dirname as dirname7, join as join20 } from "node:path";
|
|
33332
33535
|
function kiroHistory(path, files) {
|
|
33333
|
-
const header =
|
|
33536
|
+
const header = object2(json3(files.get(path)));
|
|
33334
33537
|
const ide2 = basename8(path) === "session.json";
|
|
33335
33538
|
const nativeID = text2(header.session_id || header.sessionId || header.id) || (ide2 ? basename8(dirname7(path)) : "");
|
|
33336
33539
|
if (!nativeID) throw new Error("Unsupported Kiro session header.");
|
|
@@ -33339,12 +33542,12 @@ function kiroHistory(path, files) {
|
|
|
33339
33542
|
const { rows: rows2 } = jsonLines(files.get(side));
|
|
33340
33543
|
const messages = rows2.flatMap((r, i) => {
|
|
33341
33544
|
if (ide2) {
|
|
33342
|
-
const p =
|
|
33545
|
+
const p = object2(r.payload || r);
|
|
33343
33546
|
const role2 = p.type === "human" ? "user" : p.type === "ai" ? "assistant" : p.role || p.type;
|
|
33344
33547
|
const m3 = message({ ...p, role: role2 }, text2(p.id) || `message:${i}`, r.timestamp);
|
|
33345
33548
|
return m3 ? [m3] : [recordEvent(r, `event:${i}`, text2(p.type) || "Kiro event", r.timestamp, p.text)];
|
|
33346
33549
|
}
|
|
33347
|
-
const data =
|
|
33550
|
+
const data = object2(r.data), role = r.kind === "Prompt" ? "user" : r.kind === "AssistantMessage" ? "assistant" : r.kind === "ToolResults" ? "tool" : "";
|
|
33348
33551
|
if (!role) return [];
|
|
33349
33552
|
const content = Array.isArray(data.content) ? data.content.map((p) => p.kind === "text" ? { type: "text", text: p.data } : { type: "unsupported" }) : void 0;
|
|
33350
33553
|
const m = message({ role, content }, text2(data.message_id) || `message:${i}`, seconds(data.meta?.timestamp));
|
|
@@ -33388,7 +33591,7 @@ function muxHistory(path, files) {
|
|
|
33388
33591
|
function devinDesktopHistory(path, files) {
|
|
33389
33592
|
const { rows: rows2 } = jsonLines(files.get(path));
|
|
33390
33593
|
const normalized = rows2.flatMap((r) => {
|
|
33391
|
-
const n =
|
|
33594
|
+
const n = object2(r.notification);
|
|
33392
33595
|
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
33596
|
});
|
|
33394
33597
|
const history = acpHistory(path, normalized.map((r) => JSON.stringify(r)).join("\n"));
|
|
@@ -33430,7 +33633,7 @@ function museHistory(path, files) {
|
|
|
33430
33633
|
if (!meta || ids.size > 1) throw new Error("Unsupported Muse stream.");
|
|
33431
33634
|
const nativeID = [...ids][0] || basename9(dirname8(path));
|
|
33432
33635
|
const messages = rows2.flatMap((r, i) => {
|
|
33433
|
-
const event =
|
|
33636
|
+
const event = object2(r.payload?.event), body = object2(event.message);
|
|
33434
33637
|
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
33638
|
const m = message(body, nativeText(r.sequence) || `record:${i}`, at2);
|
|
33436
33639
|
if (m) return [m];
|
|
@@ -33447,7 +33650,7 @@ function museHistory(path, files) {
|
|
|
33447
33650
|
function junieHistory(path, files) {
|
|
33448
33651
|
const { rows: rows2 } = jsonLines(files.get(path));
|
|
33449
33652
|
const messages = rows2.flatMap((r, i) => {
|
|
33450
|
-
const e10 =
|
|
33653
|
+
const e10 = object2(r.event?.agentEvent || r.event), kind = text2(e10.kind);
|
|
33451
33654
|
if (!kind || /State|Snapshot/.test(kind)) return [];
|
|
33452
33655
|
return [recordEvent(r, text2(r.id) || `event:${i}`, kind, r.timestampMs, e10.text ?? e10.prompt ?? e10.message)];
|
|
33453
33656
|
});
|
|
@@ -33455,16 +33658,16 @@ function junieHistory(path, files) {
|
|
|
33455
33658
|
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
33659
|
}
|
|
33457
33660
|
function augmentHistory(path, files) {
|
|
33458
|
-
const r =
|
|
33661
|
+
const r = object2(json3(files.get(path)));
|
|
33459
33662
|
if (!text2(r.sessionId) || !Array.isArray(r.chatHistory)) throw new Error("Unsupported Augment session.");
|
|
33460
33663
|
const messages = r.chatHistory.flatMap((turn, i) => {
|
|
33461
|
-
const exchange =
|
|
33664
|
+
const exchange = object2(turn.exchange), id2 = nativeText(turn.sequenceId) || `turn:${i}`;
|
|
33462
33665
|
return [recordEvent(turn, id2, turn.completed === true ? "Completed exchange" : "Incomplete exchange", turn.finishedAt, exchange.response_text)];
|
|
33463
33666
|
});
|
|
33464
33667
|
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
33668
|
}
|
|
33466
33669
|
function fxHistory(path, files) {
|
|
33467
|
-
const usage =
|
|
33670
|
+
const usage = object2(json3(files.get(path))), meta = sidecar2(files, join21(dirname8(path), "session.json"));
|
|
33468
33671
|
const id2 = text2(usage.session_id) || text2(meta.id);
|
|
33469
33672
|
if (!id2 || !usage.snapshot || meta.id && meta.id !== id2) throw new Error("Unsupported Fx session metadata.");
|
|
33470
33673
|
return {
|
|
@@ -33529,7 +33732,7 @@ var init_harness_files = __esm({
|
|
|
33529
33732
|
const value = f.get(p), { rows: rows2 } = jsonLines(value), ids = new Set(rows2.map((r) => text2(r.sessionId)).filter(Boolean));
|
|
33530
33733
|
if (ids.size !== 1) throw new Error("Headless capture needs one explicit session identity.");
|
|
33531
33734
|
const messages = rows2.flatMap((r, i) => {
|
|
33532
|
-
const m = message(
|
|
33735
|
+
const m = message(object2(r.message), text2(r.message?.id) || `record:${i}`);
|
|
33533
33736
|
return m ? [m] : [];
|
|
33534
33737
|
});
|
|
33535
33738
|
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 +33791,7 @@ function forkStore(id2, name, defaultPath, desktop) {
|
|
|
33588
33791
|
parse(db2, r) {
|
|
33589
33792
|
if (desktop !== void 0 && text2(r.version).startsWith("desktop-") !== desktop) return;
|
|
33590
33793
|
const messages = rows(db2, "message", ["id", "data", "time_created"], ["session_id", r.id], "time_created").map((m) => {
|
|
33591
|
-
const body =
|
|
33794
|
+
const body = object2(sqliteJSON(m.data));
|
|
33592
33795
|
let content = body.parts ?? body.content;
|
|
33593
33796
|
if (hasTable(db2, "part")) content = rows(db2, "part", ["id", "data"], ["message_id", m.id], "id").map((p) => sqliteJSON(p.data));
|
|
33594
33797
|
if (Array.isArray(content)) content = content.flatMap((p) => {
|
|
@@ -33665,9 +33868,9 @@ var init_harness_databases = __esm({
|
|
|
33665
33868
|
parse(db2, r) {
|
|
33666
33869
|
const events = rows(db2, "transcript_events", ["seq", "event_json", "event_zstd"], ["session_id", r.session_id], "seq");
|
|
33667
33870
|
const messages = events.flatMap((e10) => {
|
|
33668
|
-
const raw =
|
|
33871
|
+
const raw = object2(sqliteJSON(e10.event_json ?? e10.event_zstd));
|
|
33669
33872
|
if (raw.type !== "message") return [];
|
|
33670
|
-
const m = message(
|
|
33873
|
+
const m = message(object2(raw.message), text2(raw.id) || `event:${e10.seq}`, raw.timestamp ?? raw.message?.timestamp);
|
|
33671
33874
|
return m ? [m] : [];
|
|
33672
33875
|
});
|
|
33673
33876
|
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 +33885,11 @@ var init_harness_databases = __esm({
|
|
|
33682
33885
|
fields: ["id", "summary", "created_at", "updated_at", "data_type", "data", "folder_paths"],
|
|
33683
33886
|
parse(db2, r) {
|
|
33684
33887
|
if (!["json", "zstd"].includes(r.data_type)) throw new Error("Unsupported Zed encoding.");
|
|
33685
|
-
const body =
|
|
33888
|
+
const body = object2(sqliteJSON(r.data));
|
|
33686
33889
|
if (body.imported === true) return;
|
|
33687
33890
|
if (!Array.isArray(body.messages)) throw new Error("Unsupported Zed thread.");
|
|
33688
33891
|
const messages = body.messages.map((raw, i) => {
|
|
33689
|
-
const user =
|
|
33892
|
+
const user = object2(raw.User), agent = object2(raw.Agent), b = raw.User ? user : agent;
|
|
33690
33893
|
if (!raw.User && !raw.Agent) return recordEvent(raw, `message:${i}`, "Context checkpoint", 0, raw.Compaction?.Summary);
|
|
33691
33894
|
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
33895
|
return conversationMessage({ role: raw.User ? "user" : "assistant", content }, text2(b.id) || `message:${i}`);
|
|
@@ -33704,7 +33907,7 @@ var init_harness_databases = __esm({
|
|
|
33704
33907
|
fields: ["id", "working_directory", "model", "title", "created_at", "last_activity_at"],
|
|
33705
33908
|
parse(db2, r) {
|
|
33706
33909
|
const messages = rows(db2, "message_nodes", ["node_id", "chat_message", "created_at"], ["session_id", r.id], "row_id").flatMap((m) => {
|
|
33707
|
-
const raw =
|
|
33910
|
+
const raw = object2(sqliteJSON(m.chat_message)), result = message(raw, nativeText(m.node_id), millisOrSeconds(m.created_at));
|
|
33708
33911
|
return result ? [result] : [recordEvent(raw, nativeText(m.node_id), "Devin message node", millisOrSeconds(m.created_at))];
|
|
33709
33912
|
});
|
|
33710
33913
|
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 +33970,9 @@ var init_harness_databases = __esm({
|
|
|
33767
33970
|
const row = rows(db2, "llm_irs", ["json"], ["id", item.llm_ir_id], void 0, 1)[0];
|
|
33768
33971
|
bytes2 += text2(row?.json).length;
|
|
33769
33972
|
if (bytes2 > 32e6) throw new Error("Octofriend session exceeds the snapshot limit.");
|
|
33770
|
-
const payload =
|
|
33973
|
+
const payload = object2(sqliteJSON(row?.json));
|
|
33771
33974
|
if (payload.version !== "octo-llm-ir/v1") throw new Error("Unsupported Octofriend IR version.");
|
|
33772
|
-
const ir =
|
|
33975
|
+
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
33976
|
const m = message({ ...ir, content, role: ir.role === "tool-output" ? "tool" : ir.role }, nativeText(node.id), node.created_at);
|
|
33774
33977
|
messages.push(m || recordEvent(ir, nativeText(node.id), text2(ir.role), node.created_at));
|
|
33775
33978
|
}
|
|
@@ -33803,13 +34006,13 @@ var init_harness_databases = __esm({
|
|
|
33803
34006
|
key: "conversation_id",
|
|
33804
34007
|
fields: ["key", "conversation_id", "value"],
|
|
33805
34008
|
parse(db2, r) {
|
|
33806
|
-
const body =
|
|
34009
|
+
const body = object2(sqliteJSON(r.value));
|
|
33807
34010
|
if (!Array.isArray(body.history)) throw new Error("Unsupported Kiro conversation.");
|
|
33808
34011
|
const messages = body.history.flatMap((turn, i) => {
|
|
33809
|
-
const result = [], input =
|
|
34012
|
+
const result = [], input = object2(turn.user?.content), output2 = object2(turn.assistant?.Response || turn.assistant?.ToolUse);
|
|
33810
34013
|
if (typeof input.Prompt?.prompt === "string") result.push(conversationMessage({ role: "user", content: input.Prompt.prompt }, `turn:${i}:user`));
|
|
33811
34014
|
if (input.ToolUseResults) result.push(conversationMessage({ role: "tool", content: input.ToolUseResults }, `turn:${i}:tool`));
|
|
33812
|
-
if (typeof
|
|
34015
|
+
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
34016
|
return result;
|
|
33814
34017
|
});
|
|
33815
34018
|
const created = body.history.map((t) => time(t.request_metadata?.request_start_timestamp_ms)).find(Boolean);
|
|
@@ -33836,7 +34039,6 @@ var init_harness_databases = __esm({
|
|
|
33836
34039
|
// server/adapters/harness-metadata.ts
|
|
33837
34040
|
import { basename as basename10 } from "node:path";
|
|
33838
34041
|
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
33839
|
-
import { lstat as lstat7 } from "node:fs/promises";
|
|
33840
34042
|
function protoFields(value) {
|
|
33841
34043
|
if (value.length > 2e6) throw new Error("Trajectory metadata exceeds 2 MB.");
|
|
33842
34044
|
const fields2 = /* @__PURE__ */ new Map();
|
|
@@ -33867,7 +34069,7 @@ function protoFields(value) {
|
|
|
33867
34069
|
}
|
|
33868
34070
|
return fields2;
|
|
33869
34071
|
}
|
|
33870
|
-
var nested, antigravityDatabaseAdapters, antigravityCacheAdapter
|
|
34072
|
+
var nested, antigravityDatabaseAdapters, antigravityCacheAdapter;
|
|
33871
34073
|
var init_harness_metadata = __esm({
|
|
33872
34074
|
"server/adapters/harness-metadata.ts"() {
|
|
33873
34075
|
"use strict";
|
|
@@ -33890,15 +34092,15 @@ var init_harness_metadata = __esm({
|
|
|
33890
34092
|
const sec = timestamp.get(1), nano = timestamp.get(2);
|
|
33891
34093
|
const created = typeof sec === "bigint" && sec > 0n && sec < 8640000000000n ? time(Number(sec) * 1e3 + (typeof nano === "bigint" && nano < 1000000000n ? Number(nano) / 1e6 : 0)) : 0;
|
|
33892
34094
|
const uri = nested(fields2.get(1)).get(1);
|
|
33893
|
-
let
|
|
34095
|
+
let directory3 = "";
|
|
33894
34096
|
if (uri instanceof Uint8Array) {
|
|
33895
34097
|
try {
|
|
33896
|
-
|
|
34098
|
+
directory3 = fileURLToPath4(Buffer.from(uri).toString("utf8"));
|
|
33897
34099
|
} catch {
|
|
33898
34100
|
}
|
|
33899
34101
|
}
|
|
33900
34102
|
if (!created) throw new Error("Trajectory creation time is unavailable.");
|
|
33901
|
-
return { nativeID: basename10(path, ".db"), messages: [], partial: true, session: { created, directory:
|
|
34103
|
+
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
34104
|
}
|
|
33903
34105
|
}));
|
|
33904
34106
|
antigravityCacheAdapter = localFileAdapter({
|
|
@@ -33917,28 +34119,6 @@ var init_harness_metadata = __esm({
|
|
|
33917
34119
|
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
34120
|
}
|
|
33919
34121
|
});
|
|
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
34122
|
}
|
|
33943
34123
|
});
|
|
33944
34124
|
|
|
@@ -33966,7 +34146,7 @@ var init_adapters = __esm({
|
|
|
33966
34146
|
init_harness_databases();
|
|
33967
34147
|
init_harness_metadata();
|
|
33968
34148
|
init_sqlite_histories();
|
|
33969
|
-
extra = [...databaseHarnessAdapters, ...fileHarnessAdapters, antigravityCacheAdapter, ...antigravityDatabaseAdapters
|
|
34149
|
+
extra = [...databaseHarnessAdapters, ...fileHarnessAdapters, antigravityCacheAdapter, ...antigravityDatabaseAdapters];
|
|
33970
34150
|
grouped = /* @__PURE__ */ new Map();
|
|
33971
34151
|
for (const adapter of extra) grouped.set(adapter.id, [...grouped.get(adapter.id) || [], adapter]);
|
|
33972
34152
|
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 +34191,12 @@ init_activity();
|
|
|
34011
34191
|
// server/event-store.ts
|
|
34012
34192
|
init_events();
|
|
34013
34193
|
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
34194
|
|
|
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
|
-
}
|
|
34195
|
+
// packages/core/src/commits.ts
|
|
34196
|
+
var abbreviatedSHA = (sha) => sha.length !== 40 && sha.length !== 64;
|
|
34157
34197
|
|
|
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
|
-
}
|
|
34198
|
+
// server/commit-store.ts
|
|
34199
|
+
init_commit_extraction();
|
|
34205
34200
|
|
|
34206
34201
|
// server/library-query.ts
|
|
34207
34202
|
import { createHash as createHash2 } from "node:crypto";
|
|
@@ -34218,10 +34213,10 @@ function hash(text3) {
|
|
|
34218
34213
|
value ^= value >>> 16;
|
|
34219
34214
|
return (value >>> 0) / 4294967295;
|
|
34220
34215
|
}
|
|
34221
|
-
function directoryLabel(
|
|
34222
|
-
return directoryPath(
|
|
34216
|
+
function directoryLabel(directory3) {
|
|
34217
|
+
return directoryPath(directory3).split("/").at(-1) || "/";
|
|
34223
34218
|
}
|
|
34224
|
-
var directoryPath = (
|
|
34219
|
+
var directoryPath = (directory3) => (/^(?:[a-z]:[\\/]|\\\\)/i.test(directory3) ? directory3.replace(/\\/g, "/") : directory3).replace(/\/+$/, "") || (directory3.startsWith("/") ? "/" : "");
|
|
34225
34220
|
var laneKey = (session) => session.directory ? JSON.stringify(["directory", directoryPath(session.directory)]) : JSON.stringify(["project", session.source || "opencode", session.projectID || session.id]);
|
|
34226
34221
|
var sessionEnd = (session) => Math.max(session.created, session.activity?.lastMessageAt || session.created);
|
|
34227
34222
|
var timeX = (time3, graph) => {
|
|
@@ -34258,13 +34253,13 @@ function makeGraph(sessions, projects, previous) {
|
|
|
34258
34253
|
const z4 = Math.sin(angle) * distance * 0.7;
|
|
34259
34254
|
const color = PALETTE[index % PALETTE.length];
|
|
34260
34255
|
const project2 = projects.find((p) => p.id === group[0].projectID);
|
|
34261
|
-
const
|
|
34256
|
+
const directory3 = group[0].directory;
|
|
34262
34257
|
const lane = {
|
|
34263
34258
|
key,
|
|
34264
34259
|
slot: index,
|
|
34265
|
-
label:
|
|
34260
|
+
label: directory3 ? directoryLabel(directory3) : project2?.name || group[0].projectID || "Unknown directory",
|
|
34266
34261
|
color,
|
|
34267
|
-
kind:
|
|
34262
|
+
kind: directory3 && worktrees.has(directoryPath(directory3)) ? "worktree" : "directory",
|
|
34268
34263
|
y,
|
|
34269
34264
|
z: z4,
|
|
34270
34265
|
nodes: []
|
|
@@ -34335,12 +34330,33 @@ function makeGraph(sessions, projects, previous) {
|
|
|
34335
34330
|
return { nodes, edges, lanes, start, end, timeFrame };
|
|
34336
34331
|
}
|
|
34337
34332
|
|
|
34333
|
+
// src/session-links.ts
|
|
34334
|
+
function visibleSessions(sessions) {
|
|
34335
|
+
const owners = /* @__PURE__ */ new Map();
|
|
34336
|
+
for (const session of sessions) {
|
|
34337
|
+
if (session.source !== "t3-code") continue;
|
|
34338
|
+
for (const id2 of new Set(session.linkedSessionIDs || [])) owners.set(id2, [...owners.get(id2) || [], session]);
|
|
34339
|
+
}
|
|
34340
|
+
const unique = new Map([...owners].flatMap(([native, claims]) => {
|
|
34341
|
+
const owner = claims[0];
|
|
34342
|
+
return claims.length === 1 && ["complete", "partial"].includes(owner.coverage?.history || "") && owner.activity?.userMessages ? [[native, owner.id]] : [];
|
|
34343
|
+
}));
|
|
34344
|
+
return sessions.filter((session) => !unique.has(session.id)).map((session) => ({
|
|
34345
|
+
...session,
|
|
34346
|
+
parentID: session.parentID ? unique.get(session.parentID) || session.parentID : void 0,
|
|
34347
|
+
forkID: session.forkID ? unique.get(session.forkID) || session.forkID : void 0
|
|
34348
|
+
}));
|
|
34349
|
+
}
|
|
34350
|
+
function sessionMatchesSource(session, source) {
|
|
34351
|
+
return !source || session.source === source || Boolean(session.source === "t3-code" && session.linkedSessionIDs?.some((id2) => id2.startsWith(`${source}:`)));
|
|
34352
|
+
}
|
|
34353
|
+
|
|
34338
34354
|
// server/library-query.ts
|
|
34339
34355
|
var LibraryError = class extends Error {
|
|
34340
|
-
constructor(code, message2,
|
|
34356
|
+
constructor(code, message2, exitCode2 = 1) {
|
|
34341
34357
|
super(message2);
|
|
34342
34358
|
this.code = code;
|
|
34343
|
-
this.exitCode =
|
|
34359
|
+
this.exitCode = exitCode2;
|
|
34344
34360
|
}
|
|
34345
34361
|
code;
|
|
34346
34362
|
exitCode;
|
|
@@ -34406,7 +34422,272 @@ function parseDate(value, now, endOfDay = false) {
|
|
|
34406
34422
|
return time3 + (dateOnly && endOfDay ? 864e5 - 1 : 0);
|
|
34407
34423
|
}
|
|
34408
34424
|
|
|
34425
|
+
// server/commit-store.ts
|
|
34426
|
+
var COMMIT_SCHEMA = `CREATE TABLE IF NOT EXISTS session_commits (
|
|
34427
|
+
session_id TEXT NOT NULL REFERENCES sessions(id) ON DELETE CASCADE,
|
|
34428
|
+
sha TEXT NOT NULL, repository_path TEXT NOT NULL, operation TEXT NOT NULL,
|
|
34429
|
+
occurred_at REAL, evidence_event_id TEXT NOT NULL,
|
|
34430
|
+
PRIMARY KEY(session_id,repository_path,sha,operation),
|
|
34431
|
+
FOREIGN KEY(session_id,evidence_event_id) REFERENCES timeline_items(session_id,id) ON DELETE CASCADE);
|
|
34432
|
+
CREATE INDEX IF NOT EXISTS session_commits_time ON session_commits(session_id,occurred_at);`;
|
|
34433
|
+
var supported = /* @__PURE__ */ new Set(["opencode", "t3-code", "codex", "claude-code"]);
|
|
34434
|
+
var pendingCommits = () => ({ version: 0, state: "pending", count: null, note: "Refresh sources to index recorded commit operations." });
|
|
34435
|
+
function writeCommits(db2, session) {
|
|
34436
|
+
db2.prepare("DELETE FROM session_commits WHERE session_id=?").run(session.id);
|
|
34437
|
+
const base = { version: COMMIT_EXTRACTOR_VERSION, indexedAt: Date.now() };
|
|
34438
|
+
if (!supported.has(session.source || "")) return { ...base, state: "unavailable", count: null, note: "Commit attribution is not validated for this source format." };
|
|
34439
|
+
const calls = /* @__PURE__ */ new Map();
|
|
34440
|
+
const results = /* @__PURE__ */ new Map();
|
|
34441
|
+
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);
|
|
34442
|
+
let tools = 0, partial = session.coverage?.history !== "complete" || Boolean(db2.prepare("SELECT partial FROM timeline_coverage WHERE session_id=?").get(session.id)?.partial);
|
|
34443
|
+
for (const row of rows2()) {
|
|
34444
|
+
const item = JSON.parse(String(row.data));
|
|
34445
|
+
tools++;
|
|
34446
|
+
if (item.kind === "tool_result" && item.callID) {
|
|
34447
|
+
const signature = fingerprint([item.output, item.exitCode, item.status, item.gitCommit]);
|
|
34448
|
+
results.set(item.callID, results.has(item.callID) && results.get(item.callID) !== signature ? null : signature);
|
|
34449
|
+
}
|
|
34450
|
+
if (item.kind !== "tool_call" || !item.callID) continue;
|
|
34451
|
+
calls.set(item.callID, calls.has(item.callID) ? null : item);
|
|
34452
|
+
}
|
|
34453
|
+
const completed = /* @__PURE__ */ new Set();
|
|
34454
|
+
const insert = db2.prepare("INSERT OR IGNORE INTO session_commits VALUES (?,?,?,?,?,?)");
|
|
34455
|
+
for (const row of rows2()) {
|
|
34456
|
+
const item = JSON.parse(String(row.data));
|
|
34457
|
+
if (item.kind !== "tool_result") continue;
|
|
34458
|
+
const call = item.input ? item : item.callID ? calls.get(item.callID) : void 0;
|
|
34459
|
+
if (!call || call !== item && call.ordinal >= item.ordinal || item.callID && results.get(item.callID) === null) {
|
|
34460
|
+
partial = true;
|
|
34461
|
+
continue;
|
|
34462
|
+
}
|
|
34463
|
+
if (item.callID) completed.add(item.callID);
|
|
34464
|
+
const extracted = extractCommit(call, item);
|
|
34465
|
+
if (!extracted.candidate) continue;
|
|
34466
|
+
const time3 = item.endTime ?? item.time;
|
|
34467
|
+
if (time3 !== null && time3 < session.created || session.forkID && (time3 === null || time3 <= session.created || call.time === null || call.time < session.created)) {
|
|
34468
|
+
partial = true;
|
|
34469
|
+
continue;
|
|
34470
|
+
}
|
|
34471
|
+
if (!extracted.commit) {
|
|
34472
|
+
partial = true;
|
|
34473
|
+
continue;
|
|
34474
|
+
}
|
|
34475
|
+
const { sha, repositoryPath, operation: operation2 } = extracted.commit;
|
|
34476
|
+
insert.run(session.id, sha, repositoryPath, operation2, time3, item.id);
|
|
34477
|
+
}
|
|
34478
|
+
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;
|
|
34479
|
+
const count = Number(db2.prepare("SELECT count(*) AS n FROM session_commits WHERE session_id=?").get(session.id).n);
|
|
34480
|
+
return {
|
|
34481
|
+
...base,
|
|
34482
|
+
state: !tools ? "unavailable" : partial ? "partial" : "indexed",
|
|
34483
|
+
count: !tools ? null : count,
|
|
34484
|
+
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.`
|
|
34485
|
+
};
|
|
34486
|
+
}
|
|
34487
|
+
function commit(row) {
|
|
34488
|
+
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) };
|
|
34489
|
+
}
|
|
34490
|
+
function readCommits(db2, session, options = {}) {
|
|
34491
|
+
let coverage2 = session.commits || pendingCommits();
|
|
34492
|
+
if (session.coverage?.note?.startsWith("Latest import failed:")) coverage2 = { ...coverage2, state: coverage2.count === null ? coverage2.state : "partial", note: `${session.coverage.note} ${coverage2.note}` };
|
|
34493
|
+
const revision2 = String(db2.prepare("SELECT revision FROM timeline_coverage WHERE session_id=?").get(session.id)?.revision || "pending");
|
|
34494
|
+
const key = fingerprint(["commits", session.id, revision2, coverage2]), offset = pageOffset(options.cursor, key), limit = pageLimit(options.limit);
|
|
34495
|
+
const total = Number(db2.prepare("SELECT count(*) AS n FROM session_commits WHERE session_id=?").get(session.id).n);
|
|
34496
|
+
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);
|
|
34497
|
+
return { sessionID: session.id, revision: revision2, coverage: coverage2, items, total, nextCursor: offset + limit < total ? nextCursor(key, offset + limit) : null };
|
|
34498
|
+
}
|
|
34499
|
+
function commitMarkers(db2, session) {
|
|
34500
|
+
const end = Math.max(session.created, session.activity?.lastMessageAt || session.created);
|
|
34501
|
+
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) => {
|
|
34502
|
+
const value = commit(row);
|
|
34503
|
+
return {
|
|
34504
|
+
id: value.evidenceEventID,
|
|
34505
|
+
kind: "commit",
|
|
34506
|
+
name: `${value.operation} ${value.sha}`,
|
|
34507
|
+
time: value.occurredAt,
|
|
34508
|
+
timeSource: "recorded",
|
|
34509
|
+
ordinal,
|
|
34510
|
+
preview: `${value.repositoryPath}
|
|
34511
|
+
${abbreviatedSHA(value.sha) ? "Abbreviated SHA \xB7 " : ""}Open recorded execution evidence`
|
|
34512
|
+
};
|
|
34513
|
+
});
|
|
34514
|
+
}
|
|
34515
|
+
|
|
34516
|
+
// server/event-store.ts
|
|
34517
|
+
var EVENT_SCHEMA = `CREATE TABLE IF NOT EXISTS timeline_items (
|
|
34518
|
+
session_id TEXT NOT NULL REFERENCES sessions(id) ON DELETE CASCADE, id TEXT NOT NULL, message_id TEXT NOT NULL,
|
|
34519
|
+
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,
|
|
34520
|
+
PRIMARY KEY(session_id,id));
|
|
34521
|
+
CREATE INDEX IF NOT EXISTS timeline_order ON timeline_items(session_id,ordinal);
|
|
34522
|
+
CREATE INDEX IF NOT EXISTS timeline_time ON timeline_items(session_id,time);
|
|
34523
|
+
CREATE INDEX IF NOT EXISTS timeline_calls ON timeline_items(session_id,call_id);
|
|
34524
|
+
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);`;
|
|
34525
|
+
function writeEvents(db2, id2, rows2) {
|
|
34526
|
+
db2.prepare("DELETE FROM timeline_items WHERE session_id=?").run(id2);
|
|
34527
|
+
const insert = db2.prepare("INSERT OR IGNORE INTO timeline_items VALUES (?,?,?,?,?,?,?,?,?,?,?)");
|
|
34528
|
+
let ordinal = 0, bytes2 = 0, partial = false, legacy = false, limited = false;
|
|
34529
|
+
for (const row of rows2) {
|
|
34530
|
+
const message2 = JSON.parse(String(row.data));
|
|
34531
|
+
legacy ||= !message2.events;
|
|
34532
|
+
for (const event of normalizedEvents(message2, id2)) {
|
|
34533
|
+
const item = { ...event, ordinal: ordinal++ }, data = JSON.stringify(item);
|
|
34534
|
+
bytes2 += Buffer.byteLength(data);
|
|
34535
|
+
if (ordinal > 2e5 || bytes2 > 32e6) {
|
|
34536
|
+
limited = true;
|
|
34537
|
+
break;
|
|
34538
|
+
}
|
|
34539
|
+
partial ||= Boolean(item.partial);
|
|
34540
|
+
const preview = (item.text || item.input || item.output || item.name).replace(/\s+/g, " ").slice(0, 180);
|
|
34541
|
+
insert.run(id2, item.id, item.messageID, item.ordinal, item.kind, item.role || null, item.time, item.callID || null, item.name, preview, data);
|
|
34542
|
+
}
|
|
34543
|
+
if (limited) break;
|
|
34544
|
+
}
|
|
34545
|
+
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(" ");
|
|
34546
|
+
db2.prepare("INSERT OR REPLACE INTO timeline_coverage VALUES (?,?,?,?)").run(id2, Number(partial || legacy || limited), note || null, randomUUID());
|
|
34547
|
+
}
|
|
34548
|
+
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";
|
|
34549
|
+
function eventSummary(row) {
|
|
34550
|
+
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) };
|
|
34551
|
+
}
|
|
34552
|
+
var EventReadError = class extends Error {
|
|
34553
|
+
constructor(message2, status2) {
|
|
34554
|
+
super(message2);
|
|
34555
|
+
this.status = status2;
|
|
34556
|
+
}
|
|
34557
|
+
status;
|
|
34558
|
+
};
|
|
34559
|
+
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" };
|
|
34560
|
+
function coverage(db2, session) {
|
|
34561
|
+
const row = db2.prepare("SELECT * FROM timeline_coverage WHERE session_id=?").get(session.id);
|
|
34562
|
+
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 };
|
|
34563
|
+
}
|
|
34564
|
+
function readEventMarkers(db2, session) {
|
|
34565
|
+
const end = Math.max(session.created, session.activity?.lastMessageAt || session.created);
|
|
34566
|
+
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);
|
|
34567
|
+
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);
|
|
34568
|
+
const commits = commitMarkers(db2, session);
|
|
34569
|
+
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 };
|
|
34570
|
+
}
|
|
34571
|
+
function readEvents(db2, session, options = {}) {
|
|
34572
|
+
const state2 = coverage(db2, session), filter = options.filter || "all", size = 60;
|
|
34573
|
+
if (!Object.hasOwn(filters, filter)) throw new EventReadError("Invalid event filter.", 400);
|
|
34574
|
+
const where = filters[filter];
|
|
34575
|
+
if (options.revision && options.revision !== state2.revision) throw new EventReadError("Saved history changed. Reload the event explorer.", 409);
|
|
34576
|
+
let offset = 0;
|
|
34577
|
+
if (options.cursor) {
|
|
34578
|
+
try {
|
|
34579
|
+
if (options.cursor.length > 512) throw new Error();
|
|
34580
|
+
const cursor2 = JSON.parse(Buffer.from(options.cursor, "base64url").toString());
|
|
34581
|
+
if (!Number.isSafeInteger(cursor2.offset) || cursor2.offset < 0 || cursor2.offset > 2e5 || cursor2.filter !== filter || typeof cursor2.revision !== "string") throw new Error();
|
|
34582
|
+
if (cursor2.revision !== state2.revision) throw new EventReadError("Saved history changed. Reload the event explorer.", 409);
|
|
34583
|
+
offset = cursor2.offset;
|
|
34584
|
+
} catch (error) {
|
|
34585
|
+
if (error instanceof EventReadError) throw error;
|
|
34586
|
+
throw new EventReadError("Invalid event cursor.", 400);
|
|
34587
|
+
}
|
|
34588
|
+
}
|
|
34589
|
+
let selected;
|
|
34590
|
+
if (options.item) {
|
|
34591
|
+
const row = db2.prepare(`SELECT data FROM timeline_items WHERE session_id=? AND id=? AND (${where})`).get(session.id, options.item);
|
|
34592
|
+
if (!row) throw new EventReadError("This event is not in the saved session or current filter.", 404);
|
|
34593
|
+
selected = JSON.parse(String(row.data));
|
|
34594
|
+
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);
|
|
34595
|
+
offset = Math.floor(before / size) * size;
|
|
34596
|
+
}
|
|
34597
|
+
const total = Number(db2.prepare(`SELECT count(*) AS n FROM timeline_items WHERE session_id=? AND (${where})`).get(session.id).n);
|
|
34598
|
+
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);
|
|
34599
|
+
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));
|
|
34600
|
+
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) : [];
|
|
34601
|
+
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;
|
|
34602
|
+
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;
|
|
34603
|
+
const cursor = (position) => Buffer.from(JSON.stringify({ revision: state2.revision, filter, offset: position })).toString("base64url");
|
|
34604
|
+
return {
|
|
34605
|
+
sessionID: session.id,
|
|
34606
|
+
...state2,
|
|
34607
|
+
items,
|
|
34608
|
+
total,
|
|
34609
|
+
offset,
|
|
34610
|
+
selected,
|
|
34611
|
+
related: related.slice(0, 20),
|
|
34612
|
+
relatedPartial: related.length > 20,
|
|
34613
|
+
previousItem: previousItem ? String(previousItem) : void 0,
|
|
34614
|
+
nextItem: nextItem ? String(nextItem) : void 0,
|
|
34615
|
+
nextCursor: offset + size < total ? cursor(offset + size) : null,
|
|
34616
|
+
previousCursor: offset > 0 ? cursor(Math.max(0, offset - size)) : null
|
|
34617
|
+
};
|
|
34618
|
+
}
|
|
34619
|
+
|
|
34620
|
+
// packages/core/src/preferences.ts
|
|
34621
|
+
var DEFAULT_PREFERENCES = Object.freeze({
|
|
34622
|
+
autoImport: true,
|
|
34623
|
+
muted: false,
|
|
34624
|
+
clickSounds: true,
|
|
34625
|
+
clickVolume: 35,
|
|
34626
|
+
motion: "system",
|
|
34627
|
+
view: "3d",
|
|
34628
|
+
density: "comfortable",
|
|
34629
|
+
panelOpacity: 90,
|
|
34630
|
+
quality: "balanced",
|
|
34631
|
+
bloom: 32,
|
|
34632
|
+
stars: true,
|
|
34633
|
+
labels: true,
|
|
34634
|
+
nodeScale: 100,
|
|
34635
|
+
focusDimming: true,
|
|
34636
|
+
trails: "all",
|
|
34637
|
+
trailOpacity: 34,
|
|
34638
|
+
trailFlow: false,
|
|
34639
|
+
trailSpeed: 25,
|
|
34640
|
+
relationships: true,
|
|
34641
|
+
messageDots: true,
|
|
34642
|
+
playbackSpeed: 1
|
|
34643
|
+
});
|
|
34644
|
+
var choices = { motion: ["system", "on", "off"], view: ["3d", "2d"], density: ["comfortable", "compact"], quality: ["performance", "balanced", "high"], trails: ["all", "selected", "off"] };
|
|
34645
|
+
var ranges = { clickVolume: [0, 100], panelOpacity: [55, 100], bloom: [0, 75], nodeScale: [60, 180], trailOpacity: [0, 100], trailSpeed: [10, 100], playbackSpeed: [0.25, 3] };
|
|
34646
|
+
function normalizePreferences(value) {
|
|
34647
|
+
const result = { ...DEFAULT_PREFERENCES };
|
|
34648
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return result;
|
|
34649
|
+
const input = value;
|
|
34650
|
+
for (const key of Object.keys(result)) {
|
|
34651
|
+
const item = input[key];
|
|
34652
|
+
if (key in choices) {
|
|
34653
|
+
if (choices[key].includes(item)) Object.assign(result, { [key]: item });
|
|
34654
|
+
} else if (key in ranges) {
|
|
34655
|
+
const [min, max] = ranges[key];
|
|
34656
|
+
if (typeof item === "number" && Number.isFinite(item)) Object.assign(result, { [key]: Math.max(min, Math.min(max, item)) });
|
|
34657
|
+
} else if (typeof item === "boolean") Object.assign(result, { [key]: item });
|
|
34658
|
+
}
|
|
34659
|
+
return result;
|
|
34660
|
+
}
|
|
34661
|
+
|
|
34662
|
+
// packages/core/src/view-state.ts
|
|
34663
|
+
var DEFAULT_VIEW_STATE = Object.freeze({
|
|
34664
|
+
sourceID: "",
|
|
34665
|
+
projectID: "",
|
|
34666
|
+
directory: "",
|
|
34667
|
+
days: 0,
|
|
34668
|
+
fromDate: "",
|
|
34669
|
+
toDate: "",
|
|
34670
|
+
includeChildren: true,
|
|
34671
|
+
includeArchived: false
|
|
34672
|
+
});
|
|
34673
|
+
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;
|
|
34674
|
+
function normalizeViewState(value) {
|
|
34675
|
+
const result = { ...DEFAULT_VIEW_STATE };
|
|
34676
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return result;
|
|
34677
|
+
const input = value;
|
|
34678
|
+
for (const key of ["sourceID", "projectID", "directory"]) if (typeof input[key] === "string" && input[key].length <= 4096) result[key] = input[key];
|
|
34679
|
+
if ([0, 7, 30, 90].includes(input.days)) result.days = input.days;
|
|
34680
|
+
for (const key of ["includeChildren", "includeArchived"]) if (typeof input[key] === "boolean") result[key] = input[key];
|
|
34681
|
+
for (const key of ["fromDate", "toDate"]) if (validDate(input[key])) result[key] = input[key];
|
|
34682
|
+
if (result.fromDate && result.toDate && result.fromDate > result.toDate) {
|
|
34683
|
+
result.fromDate = "";
|
|
34684
|
+
result.toDate = "";
|
|
34685
|
+
}
|
|
34686
|
+
return result;
|
|
34687
|
+
}
|
|
34688
|
+
|
|
34409
34689
|
// server/store.ts
|
|
34690
|
+
init_commit_extraction();
|
|
34410
34691
|
var SessionGraphStore = class {
|
|
34411
34692
|
constructor(path = databasePath()) {
|
|
34412
34693
|
this.path = path;
|
|
@@ -34415,7 +34696,7 @@ var SessionGraphStore = class {
|
|
|
34415
34696
|
if (path !== ":memory:") chmodSync(path, 384);
|
|
34416
34697
|
this.db.exec("PRAGMA journal_mode=WAL; PRAGMA foreign_keys=ON; PRAGMA busy_timeout=5000;");
|
|
34417
34698
|
const version = Number(this.db.prepare("PRAGMA user_version").get().user_version);
|
|
34418
|
-
if (version >
|
|
34699
|
+
if (version > 6) throw new Error("This SessionGraph database requires a newer version of the app.");
|
|
34419
34700
|
this.db.exec(`
|
|
34420
34701
|
CREATE TABLE IF NOT EXISTS settings (key TEXT PRIMARY KEY, value TEXT NOT NULL);
|
|
34421
34702
|
CREATE TABLE IF NOT EXISTS sources (id TEXT PRIMARY KEY, last_import INTEGER, error TEXT);
|
|
@@ -34463,6 +34744,35 @@ var SessionGraphStore = class {
|
|
|
34463
34744
|
throw error;
|
|
34464
34745
|
}
|
|
34465
34746
|
}
|
|
34747
|
+
if (version < 5) {
|
|
34748
|
+
this.db.exec("BEGIN IMMEDIATE");
|
|
34749
|
+
try {
|
|
34750
|
+
this.db.exec(COMMIT_SCHEMA);
|
|
34751
|
+
this.db.prepare("UPDATE sessions SET metadata=json_set(metadata,'$.commits',json(?))").run(JSON.stringify(pendingCommits()));
|
|
34752
|
+
this.db.exec("PRAGMA user_version=5; COMMIT");
|
|
34753
|
+
} catch (error) {
|
|
34754
|
+
this.db.exec("ROLLBACK");
|
|
34755
|
+
throw error;
|
|
34756
|
+
}
|
|
34757
|
+
}
|
|
34758
|
+
if (version < 6) {
|
|
34759
|
+
this.db.exec("BEGIN IMMEDIATE");
|
|
34760
|
+
try {
|
|
34761
|
+
const retired = /* @__PURE__ */ new Set(["reasonix", "trae", "warp", "lm-studio", "hindsight"]);
|
|
34762
|
+
const selected = this.setting("selected");
|
|
34763
|
+
if (selected) this.setting("selected", selected.filter((id2) => !retired.has(id2)));
|
|
34764
|
+
const paths2 = this.setting("sourcePaths");
|
|
34765
|
+
if (paths2) this.setting("sourcePaths", Object.fromEntries(Object.entries(paths2).filter(([id2]) => !retired.has(id2))));
|
|
34766
|
+
const view = this.setting("viewState");
|
|
34767
|
+
if (view && typeof view.sourceID === "string" && retired.has(view.sourceID)) this.setting("viewState", { ...view, sourceID: "" });
|
|
34768
|
+
const remove2 = this.db.prepare("DELETE FROM sources WHERE id=?");
|
|
34769
|
+
for (const id2 of retired) remove2.run(id2);
|
|
34770
|
+
this.db.exec("PRAGMA user_version=6; COMMIT");
|
|
34771
|
+
} catch (error) {
|
|
34772
|
+
this.db.exec("ROLLBACK");
|
|
34773
|
+
throw error;
|
|
34774
|
+
}
|
|
34775
|
+
}
|
|
34466
34776
|
if (!this.setting("libraryID")) this.setting("libraryID", randomUUID2());
|
|
34467
34777
|
}
|
|
34468
34778
|
path;
|
|
@@ -34516,6 +34826,9 @@ var SessionGraphStore = class {
|
|
|
34516
34826
|
revision(id2) {
|
|
34517
34827
|
return this.db.prepare("SELECT imported_revision FROM sessions WHERE id=?").get(id2)?.imported_revision;
|
|
34518
34828
|
}
|
|
34829
|
+
commitsCurrent(id2) {
|
|
34830
|
+
return this.getSession(id2)?.commits?.version === COMMIT_EXTRACTOR_VERSION;
|
|
34831
|
+
}
|
|
34519
34832
|
upsert(candidate) {
|
|
34520
34833
|
const s = candidate.session, previous = this.getSession(s.id);
|
|
34521
34834
|
const metadata2 = {
|
|
@@ -34523,6 +34836,7 @@ var SessionGraphStore = class {
|
|
|
34523
34836
|
model: s.model === "Unknown model" ? previous?.model || s.model : s.model,
|
|
34524
34837
|
parentID: previous?.parentID && candidate.locator.agent ? previous.parentID : s.parentID,
|
|
34525
34838
|
activity: previous?.activity,
|
|
34839
|
+
commits: previous?.commits || pendingCommits(),
|
|
34526
34840
|
revision: previous?.revision || "",
|
|
34527
34841
|
coverage: previous?.coverage || { history: "pending" }
|
|
34528
34842
|
};
|
|
@@ -34537,8 +34851,9 @@ var SessionGraphStore = class {
|
|
|
34537
34851
|
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
34852
|
messages.forEach((message2, i) => insert.run(s.id, message2.id, i, JSON.stringify(message2), messageTime(message2.time), Number(isUserMessage(message2))));
|
|
34539
34853
|
writeEvents(this.db, s.id, this.db.prepare("SELECT data FROM messages WHERE session_id=? ORDER BY ordinal").iterate(s.id));
|
|
34854
|
+
const commits = writeCommits(this.db, s);
|
|
34540
34855
|
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);
|
|
34856
|
+
this.db.prepare("UPDATE sessions SET metadata=?, imported_revision=? WHERE id=?").run(JSON.stringify({ ...s, activity, commits }), candidate.revision, s.id);
|
|
34542
34857
|
this.db.prepare("DELETE FROM search_cache WHERE id=?").run(s.id);
|
|
34543
34858
|
this.db.exec("COMMIT");
|
|
34544
34859
|
} catch (error) {
|
|
@@ -34627,6 +34942,9 @@ var SessionGraphStore = class {
|
|
|
34627
34942
|
eventMarkers(id2) {
|
|
34628
34943
|
return this.readSnapshot(id2, (session) => readEventMarkers(this.db, session));
|
|
34629
34944
|
}
|
|
34945
|
+
commits(id2, options = {}) {
|
|
34946
|
+
return this.readSnapshot(id2, (session) => readCommits(this.db, session, options));
|
|
34947
|
+
}
|
|
34630
34948
|
readSnapshot(id2, read3) {
|
|
34631
34949
|
this.db.exec("BEGIN");
|
|
34632
34950
|
try {
|
|
@@ -34832,7 +35150,7 @@ var Importer = class {
|
|
|
34832
35150
|
for (const candidate of seen.values()) {
|
|
34833
35151
|
this.store.upsert(candidate);
|
|
34834
35152
|
const saved = this.store.getSession(candidate.session.id);
|
|
34835
|
-
const retry = !saved?.coverage?.importedAt || saved.coverage.note?.startsWith("Latest import failed:");
|
|
35153
|
+
const retry = !saved?.coverage?.importedAt || saved.coverage.note?.startsWith("Latest import failed:") || !this.store.commitsCurrent(candidate.session.id);
|
|
34836
35154
|
if (!retry && saved?.revision === candidate.revision && this.store.revision(candidate.session.id) === candidate.revision) {
|
|
34837
35155
|
this.status.unchanged++;
|
|
34838
35156
|
continue;
|
|
@@ -35279,8 +35597,8 @@ var SearchableMap = class _SearchableMap {
|
|
|
35279
35597
|
* @param object Object of entries for the {@link SearchableMap}
|
|
35280
35598
|
* @return A new {@link SearchableMap} with the given entries
|
|
35281
35599
|
*/
|
|
35282
|
-
static fromObject(
|
|
35283
|
-
return _SearchableMap.from(Object.entries(
|
|
35600
|
+
static fromObject(object3) {
|
|
35601
|
+
return _SearchableMap.from(Object.entries(object3));
|
|
35284
35602
|
}
|
|
35285
35603
|
};
|
|
35286
35604
|
var trackDown = (tree, key, path = []) => {
|
|
@@ -36172,11 +36490,11 @@ var MiniSearch = class _MiniSearch {
|
|
|
36172
36490
|
* @param options configuration options, same as the constructor
|
|
36173
36491
|
* @return An instance of MiniSearch deserialized from the given JSON.
|
|
36174
36492
|
*/
|
|
36175
|
-
static loadJSON(
|
|
36493
|
+
static loadJSON(json5, options) {
|
|
36176
36494
|
if (options == null) {
|
|
36177
36495
|
throw new Error("MiniSearch: loadJSON should be given the same options used when serializing the index");
|
|
36178
36496
|
}
|
|
36179
|
-
return this.loadJS(JSON.parse(
|
|
36497
|
+
return this.loadJS(JSON.parse(json5), options);
|
|
36180
36498
|
}
|
|
36181
36499
|
/**
|
|
36182
36500
|
* Async equivalent of {@link MiniSearch.loadJSON}
|
|
@@ -36191,11 +36509,11 @@ var MiniSearch = class _MiniSearch {
|
|
|
36191
36509
|
* @param options configuration options, same as the constructor
|
|
36192
36510
|
* @return A Promise that will resolve to an instance of MiniSearch deserialized from the given JSON.
|
|
36193
36511
|
*/
|
|
36194
|
-
static async loadJSONAsync(
|
|
36512
|
+
static async loadJSONAsync(json5, options) {
|
|
36195
36513
|
if (options == null) {
|
|
36196
36514
|
throw new Error("MiniSearch: loadJSON should be given the same options used when serializing the index");
|
|
36197
36515
|
}
|
|
36198
|
-
return this.loadJSAsync(JSON.parse(
|
|
36516
|
+
return this.loadJSAsync(JSON.parse(json5), options);
|
|
36199
36517
|
}
|
|
36200
36518
|
/**
|
|
36201
36519
|
* Returns the default value of an option. It will throw an error if no option
|
|
@@ -36596,7 +36914,7 @@ var MiniSearch = class _MiniSearch {
|
|
|
36596
36914
|
}
|
|
36597
36915
|
};
|
|
36598
36916
|
MiniSearch.wildcard = /* @__PURE__ */ Symbol("*");
|
|
36599
|
-
var getOwnProperty = (
|
|
36917
|
+
var getOwnProperty = (object3, property) => Object.prototype.hasOwnProperty.call(object3, property) ? object3[property] : void 0;
|
|
36600
36918
|
var combinators = {
|
|
36601
36919
|
[OR]: (a, b) => {
|
|
36602
36920
|
for (const docId of b.keys()) {
|
|
@@ -36689,18 +37007,18 @@ var assignUniqueTerms = (target, source) => {
|
|
|
36689
37007
|
};
|
|
36690
37008
|
var byScore = ({ score: a }, { score: b }) => b - a;
|
|
36691
37009
|
var createMap = () => /* @__PURE__ */ new Map();
|
|
36692
|
-
var objectToNumericMap = (
|
|
37010
|
+
var objectToNumericMap = (object3) => {
|
|
36693
37011
|
const map = /* @__PURE__ */ new Map();
|
|
36694
|
-
for (const key of Object.keys(
|
|
36695
|
-
map.set(parseInt(key, 10),
|
|
37012
|
+
for (const key of Object.keys(object3)) {
|
|
37013
|
+
map.set(parseInt(key, 10), object3[key]);
|
|
36696
37014
|
}
|
|
36697
37015
|
return map;
|
|
36698
37016
|
};
|
|
36699
|
-
var objectToNumericMapAsync = async (
|
|
37017
|
+
var objectToNumericMapAsync = async (object3) => {
|
|
36700
37018
|
const map = /* @__PURE__ */ new Map();
|
|
36701
37019
|
let count = 0;
|
|
36702
|
-
for (const key of Object.keys(
|
|
36703
|
-
map.set(parseInt(key, 10),
|
|
37020
|
+
for (const key of Object.keys(object3)) {
|
|
37021
|
+
map.set(parseInt(key, 10), object3[key]);
|
|
36704
37022
|
if (++count % 1e3 === 0) {
|
|
36705
37023
|
await wait(0);
|
|
36706
37024
|
}
|
|
@@ -36715,7 +37033,7 @@ var normalize = (text3) => text3.normalize("NFKD").replace(new RegExp("\\p{M}",
|
|
|
36715
37033
|
var words = (text3) => normalize(text3).match(/[\p{L}\p{N}]+/gu) || [];
|
|
36716
37034
|
var phrase = (text3) => words(text3).join(" ");
|
|
36717
37035
|
function parseQuery(input) {
|
|
36718
|
-
const
|
|
37036
|
+
const plan2 = { text: "", terms: [], phrases: [], filters: [] };
|
|
36719
37037
|
const parts = [];
|
|
36720
37038
|
for (const token of input.slice(0, 300).match(/(?:[^\s"]+|"[^"]*")+/g) || []) {
|
|
36721
37039
|
const filter = /^(source|project|dir|model|is|after|before|in):(.+)$/i.exec(token);
|
|
@@ -36723,21 +37041,21 @@ function parseQuery(input) {
|
|
|
36723
37041
|
const key = filter[1].toLowerCase(), value2 = normalize(filter[2].replace(/^"|"$/g, ""));
|
|
36724
37042
|
if (key === "in") {
|
|
36725
37043
|
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
|
|
37044
|
+
plan2.fields = fields2[value2];
|
|
37045
|
+
if (!plan2.fields) plan2.error = "Use in:title, in:files, in:messages, or in:tools.";
|
|
37046
|
+
} else if (key === "is" && !["fork", "child", "root", "archived"].includes(value2)) plan2.error = "Use is:fork, is:child, is:root, or is:archived.";
|
|
37047
|
+
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.";
|
|
37048
|
+
else plan2.filters.push([key, value2]);
|
|
36731
37049
|
continue;
|
|
36732
37050
|
}
|
|
36733
37051
|
const value = token.replace(/^"|"$/g, "");
|
|
36734
|
-
if (token.startsWith('"') && token.endsWith('"'))
|
|
37052
|
+
if (token.startsWith('"') && token.endsWith('"')) plan2.phrases.push(phrase(value));
|
|
36735
37053
|
parts.push(value);
|
|
36736
37054
|
}
|
|
36737
|
-
|
|
36738
|
-
|
|
36739
|
-
|
|
36740
|
-
return
|
|
37055
|
+
plan2.text = parts.join(" ");
|
|
37056
|
+
plan2.terms = words(plan2.text).slice(0, 12);
|
|
37057
|
+
plan2.text = plan2.terms.join(" ");
|
|
37058
|
+
return plan2;
|
|
36741
37059
|
}
|
|
36742
37060
|
function excerpt(text3, terms, length = 220) {
|
|
36743
37061
|
const value = normalize(text3);
|
|
@@ -36805,12 +37123,12 @@ ${fragment.text}`;
|
|
|
36805
37123
|
const key = `${input}\0${viewOnly}\0${limit}\0${offset}`;
|
|
36806
37124
|
const cached2 = this.cache.get(key);
|
|
36807
37125
|
if (cached2) return cached2;
|
|
36808
|
-
const
|
|
36809
|
-
if (
|
|
37126
|
+
const plan2 = parseQuery(input);
|
|
37127
|
+
if (plan2.error) return { hits: [], total: 0, error: plan2.error };
|
|
36810
37128
|
const accepts = (entry) => {
|
|
36811
37129
|
const { session, doc } = entry;
|
|
36812
37130
|
if (viewOnly && !this.scope.has(session.id)) return false;
|
|
36813
|
-
for (const [key2, value] of
|
|
37131
|
+
for (const [key2, value] of plan2.filters) {
|
|
36814
37132
|
if (key2 === "source" && ![session.source || "opencode", ...(session.linkedSessionIDs || []).map((id2) => id2.split(":")[0])].some((source) => normalize(source).includes(value))) return false;
|
|
36815
37133
|
if (key2 === "project" && !normalize(doc.project).includes(value) && !normalize(session.projectID).includes(value)) return false;
|
|
36816
37134
|
if (key2 === "dir" && !normalize(session.directory).includes(value)) return false;
|
|
@@ -36824,14 +37142,14 @@ ${fragment.text}`;
|
|
|
36824
37142
|
if (value === "archived" && !session.archived) return false;
|
|
36825
37143
|
}
|
|
36826
37144
|
}
|
|
36827
|
-
if (
|
|
36828
|
-
const fields2 =
|
|
36829
|
-
if (!
|
|
37145
|
+
if (plan2.phrases.length) {
|
|
37146
|
+
const fields2 = plan2.fields || ["title", "body", "files", "tools", "project", "directory", "model"];
|
|
37147
|
+
if (!plan2.phrases.every((p) => fields2.some((field) => phrase(doc[field]).includes(p)))) return false;
|
|
36830
37148
|
}
|
|
36831
37149
|
return true;
|
|
36832
37150
|
};
|
|
36833
|
-
const matches =
|
|
36834
|
-
fields:
|
|
37151
|
+
const matches = plan2.terms.length ? this.index.search(plan2.text, {
|
|
37152
|
+
fields: plan2.fields,
|
|
36835
37153
|
fuzzy: (term) => term.length < 4 ? false : term.length > 7 ? 2 : 1,
|
|
36836
37154
|
filter: (result2) => accepts(this.entries.get(String(result2.id)))
|
|
36837
37155
|
}) : [...this.entries.values()].filter(accepts).map((entry) => ({ id: entry.session.id, score: 0, terms: [], match: {} }));
|
|
@@ -36839,12 +37157,12 @@ ${fragment.text}`;
|
|
|
36839
37157
|
const entry = this.entries.get(String(match2.id));
|
|
36840
37158
|
const title = phrase(entry.doc.title);
|
|
36841
37159
|
const fields2 = new Set(Object.values(match2.match).flat());
|
|
36842
|
-
const tier = !
|
|
37160
|
+
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
37161
|
return { match: match2, entry, tier };
|
|
36844
37162
|
}).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
37163
|
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) => !
|
|
37164
|
+
const terms = match2.terms.length ? match2.terms : plan2.terms;
|
|
37165
|
+
const candidates = entry.fragments.filter((f) => !plan2.fields || plan2.fields.includes(f.kind === "File" ? "files" : f.kind === "Tool" ? "tools" : "body"));
|
|
36848
37166
|
let best, bestCount = 0;
|
|
36849
37167
|
for (const fragment of candidates) {
|
|
36850
37168
|
const text3 = normalize(fragment.text);
|
|
@@ -36856,7 +37174,7 @@ ${fragment.text}`;
|
|
|
36856
37174
|
if (count === terms.length && count > 0) break;
|
|
36857
37175
|
}
|
|
36858
37176
|
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" :
|
|
37177
|
+
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
37178
|
return { id: entry.session.id, score: match2.score, source, excerpt: best ? excerpt(best.text, terms) : "", terms };
|
|
36861
37179
|
});
|
|
36862
37180
|
const result = { hits, total: ranked.length };
|
|
@@ -37003,6 +37321,10 @@ var LibraryService = class {
|
|
|
37003
37321
|
this.getSession(id2);
|
|
37004
37322
|
return this.store.timeline(id2);
|
|
37005
37323
|
}
|
|
37324
|
+
getCommits(id2, options = {}) {
|
|
37325
|
+
this.getSession(id2);
|
|
37326
|
+
return this.store.commits(id2, options);
|
|
37327
|
+
}
|
|
37006
37328
|
getEvents(id2, options = {}) {
|
|
37007
37329
|
this.getSession(id2);
|
|
37008
37330
|
return this.store.events(id2, options);
|
|
@@ -37031,8 +37353,8 @@ var LibraryService = class {
|
|
|
37031
37353
|
}
|
|
37032
37354
|
searchSessions(query, filters3 = {}, options = {}) {
|
|
37033
37355
|
if (!query.trim() || query.length > 300) invalid("Search query must contain 1\u2013300 characters.");
|
|
37034
|
-
const
|
|
37035
|
-
if (
|
|
37356
|
+
const plan2 = parseQuery(query);
|
|
37357
|
+
if (plan2.error) invalid(plan2.error);
|
|
37036
37358
|
return this.snapshot(() => {
|
|
37037
37359
|
const { sessions, projects } = this.sessions(filters3);
|
|
37038
37360
|
const index = new SessionSearchIndex();
|
|
@@ -37142,7 +37464,7 @@ var filters2 = [
|
|
|
37142
37464
|
];
|
|
37143
37465
|
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
37466
|
var sessionArg = { name: "session-id", required: true };
|
|
37145
|
-
var
|
|
37467
|
+
var commands2 = [
|
|
37146
37468
|
{ 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
37469
|
{ 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
37470
|
{ 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 +37476,7 @@ var commands = [
|
|
|
37154
37476
|
{ 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
37477
|
{ 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
37478
|
{ 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"] },
|
|
37479
|
+
{ 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
37480
|
{ 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
37481
|
{ 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
37482
|
{ 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 +37485,14 @@ var commands = [
|
|
|
37162
37485
|
{ 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
37486
|
{ 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
37487
|
];
|
|
37165
|
-
var resolveCommand = (name) =>
|
|
37488
|
+
var resolveCommand = (name) => commands2.find((command) => command.name === name || command.aliases?.includes(name));
|
|
37166
37489
|
function manifest(command) {
|
|
37167
37490
|
return {
|
|
37168
37491
|
schemaVersion: 1,
|
|
37169
37492
|
executable: "sessiongraph",
|
|
37170
37493
|
node: ">=24",
|
|
37171
37494
|
globalOptions,
|
|
37172
|
-
commands: command ? [command] :
|
|
37495
|
+
commands: command ? [command] : commands2,
|
|
37173
37496
|
launch: { desktop: "sessiongraph", browser: "sessiongraph --browser" },
|
|
37174
37497
|
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
37498
|
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 +37508,7 @@ Usage: sessiongraph <command> [options]
|
|
|
37185
37508
|
sessiongraph --version
|
|
37186
37509
|
|
|
37187
37510
|
Commands:
|
|
37188
|
-
${
|
|
37511
|
+
${commands2.map((c) => ` ${c.name.padEnd(18)} ${c.summary}`).join("\n")}
|
|
37189
37512
|
|
|
37190
37513
|
Options: --help (-h), --json, --data-dir <directory>
|
|
37191
37514
|
|
|
@@ -37219,14 +37542,14 @@ Node.js 24+. Local, noninteractive data commands. Use \`--json\` for structured
|
|
|
37219
37542
|
|
|
37220
37543
|
${manifest().rules.map((rule) => `- ${rule}`).join("\n")}
|
|
37221
37544
|
|
|
37222
|
-
${(command ? [command] :
|
|
37545
|
+
${(command ? [command] : commands2).map((c) => `## ${c.name}
|
|
37223
37546
|
|
|
37224
37547
|
\`\`\`text
|
|
37225
37548
|
${help(c)}\`\`\``).join("\n\n")}
|
|
37226
37549
|
`;
|
|
37227
37550
|
function parseCLI(argv) {
|
|
37228
37551
|
const options = {}, positionals = [];
|
|
37229
|
-
const known = new Map([...globalOptions, ...
|
|
37552
|
+
const known = new Map([...globalOptions, ...commands2.flatMap((c) => c.options), flag("version", "Version")].map((o) => [o.name, o]));
|
|
37230
37553
|
let literal = false;
|
|
37231
37554
|
for (let i = 0; i < argv.length; i++) {
|
|
37232
37555
|
let token = argv[i];
|
|
@@ -37313,7 +37636,7 @@ ${m.fragments.map((f) => `${cell(f.kind)}: ${cell(f.text)}${f.truncated ? " [tru
|
|
|
37313
37636
|
if (command === "doctor") return `${data.ok ? "OK" : "Needs attention"} \u2014 ${cell(data.database)}
|
|
37314
37637
|
${table(["CHECK", "STATUS", "DETAIL"], data.checks.map((c) => [c.name, c.ok ? "ok" : "failed", c.message]))}
|
|
37315
37638
|
${data.next}`;
|
|
37316
|
-
if (command === "commands") return table(["COMMAND", "EFFECT", "DESCRIPTION"],
|
|
37639
|
+
if (command === "commands") return table(["COMMAND", "EFFECT", "DESCRIPTION"], commands2.map((c) => [c.name, c.effect, c.summary]));
|
|
37317
37640
|
return JSON.stringify(data, null, 2).replace(/[\u007f-\u009f\u202a-\u202e\u2066-\u2069]/g, cell);
|
|
37318
37641
|
}
|
|
37319
37642
|
async function runCli(argv, io = {}) {
|
|
@@ -37322,11 +37645,11 @@ async function runCli(argv, io = {}) {
|
|
|
37322
37645
|
}), stderr = io.stderr || ((text3) => {
|
|
37323
37646
|
process.stderr.write(text3);
|
|
37324
37647
|
});
|
|
37325
|
-
let command = "cli",
|
|
37326
|
-
const emit = (data, text3) => stdout((
|
|
37648
|
+
let command = "cli", json5 = argv.includes("--json"), library;
|
|
37649
|
+
const emit = (data, text3) => stdout((json5 ? JSON.stringify({ schemaVersion: 1, command, data }) : text3 ?? human(command, data)) + "\n");
|
|
37327
37650
|
try {
|
|
37328
37651
|
const parsed = parseCLI(argv), options = parsed.options, args = parsed.args;
|
|
37329
|
-
|
|
37652
|
+
json5 = options.json === true;
|
|
37330
37653
|
const definition = parsed.command;
|
|
37331
37654
|
command = definition?.name || (options.version ? "version" : "help");
|
|
37332
37655
|
if (options.version) {
|
|
@@ -37376,8 +37699,8 @@ async function runCli(argv, io = {}) {
|
|
|
37376
37699
|
};
|
|
37377
37700
|
if (filters3.since !== void 0 && filters3.until !== void 0 && filters3.since > filters3.until) invalid("--since must not be later than --until.");
|
|
37378
37701
|
const paging2 = { limit: text3("limit") ? pageLimit(Number(text3("limit"))) : void 0, cursor };
|
|
37379
|
-
const
|
|
37380
|
-
const path = databasePath(
|
|
37702
|
+
const directory3 = text3("data-dir");
|
|
37703
|
+
const path = databasePath(directory3 ? { ...process.env, SESSIONGRAPH_DATA_DIR: localPath(directory3) } : process.env);
|
|
37381
37704
|
library = io.openLibrary ? await io.openLibrary(path) : new LibraryService(new SessionGraphStore(path), (await Promise.resolve().then(() => (init_adapters(), adapters_exports))).adapters);
|
|
37382
37705
|
let data;
|
|
37383
37706
|
switch (command) {
|
|
@@ -37391,7 +37714,7 @@ async function runCli(argv, io = {}) {
|
|
|
37391
37714
|
data = library.removeSources(args, options.all === true);
|
|
37392
37715
|
break;
|
|
37393
37716
|
case "sources sync":
|
|
37394
|
-
if (!
|
|
37717
|
+
if (!json5) stderr("Syncing local sources\u2026\n");
|
|
37395
37718
|
data = await library.importSessions(args);
|
|
37396
37719
|
break;
|
|
37397
37720
|
case "sessions":
|
|
@@ -37409,6 +37732,9 @@ async function runCli(argv, io = {}) {
|
|
|
37409
37732
|
case "timeline":
|
|
37410
37733
|
data = library.getTimeline(args[0]);
|
|
37411
37734
|
break;
|
|
37735
|
+
case "commits":
|
|
37736
|
+
data = library.getCommits(args[0], paging2);
|
|
37737
|
+
break;
|
|
37412
37738
|
case "events":
|
|
37413
37739
|
data = library.getEvents(args[0], { cursor: text3("cursor"), item: text3("item"), filter: text3("filter"), revision: text3("revision") });
|
|
37414
37740
|
break;
|
|
@@ -37438,7 +37764,7 @@ async function runCli(argv, io = {}) {
|
|
|
37438
37764
|
return command === "sources sync" && data.failed > 0 || command === "doctor" && !data.ok ? 1 : 0;
|
|
37439
37765
|
} catch (error) {
|
|
37440
37766
|
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 (
|
|
37767
|
+
if (json5) stdout(JSON.stringify({ schemaVersion: 1, command, error: { code: failure.code, message: failure.message } }) + "\n");
|
|
37442
37768
|
else stderr(`sessiongraph: ${cell(failure.message)}
|
|
37443
37769
|
`);
|
|
37444
37770
|
return failure.exitCode;
|