sessiongraph-app-darwin-arm64 1.0.22 → 1.0.24
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/package.json +2 -2
- package/payload/SessionGraph.app/Contents/Info.plist +2 -2
- package/payload/SessionGraph.app/Contents/MacOS/sessiongraph +0 -0
- package/payload/SessionGraph.app/Contents/Resources/resources/cli-package.json +1 -1
- package/payload/SessionGraph.app/Contents/Resources/resources/cli.mjs +368 -200
- package/payload/SessionGraph.app/Contents/Resources/resources/server.mjs +217 -17
- package/payload/SessionGraph.app/Contents/Resources/resources/web/assets/{index-tIWYckIn.js → index-B05th82t.js} +1 -1
- package/payload/SessionGraph.app/Contents/Resources/resources/web/assets/{index-ClDHxy66.js → index-D4p45n7i.js} +1 -1
- package/payload/SessionGraph.app/Contents/Resources/resources/web/assets/{index-DWWZZL6C.js → index-DFcP_XK3.js} +1 -1
- package/payload/SessionGraph.app/Contents/Resources/resources/web/assets/{index-DK0pBf-7.js → index-YT1ntRdY.js} +23 -23
- package/payload/SessionGraph.app/Contents/Resources/resources/web/assets/{public-viewer-B1aKDYpa.js → public-viewer-DZqNLaJW.js} +4 -4
- package/payload/SessionGraph.app/Contents/Resources/resources/web/assets/{scene-BCuZ73oU.js → scene-BkT0QJrf.js} +6 -6
- package/payload/SessionGraph.app/Contents/Resources/resources/web/assets/{share-mJrTMarx.js → share-jfnlc0aB.js} +3 -3
- package/payload/SessionGraph.app/Contents/Resources/resources/web/index.html +1 -1
- package/payload/SessionGraph.app/Contents/_CodeSignature/CodeResources +44 -44
|
@@ -2833,12 +2833,12 @@ function summarizeUsage(session, messages, historyPartial) {
|
|
|
2833
2833
|
const lastSnapshot = cumulative.at(-1);
|
|
2834
2834
|
if (lastSnapshot?.usage) return sessionUsage(lastSnapshot.usage, true);
|
|
2835
2835
|
const unique = /* @__PURE__ */ new Map();
|
|
2836
|
-
let
|
|
2836
|
+
let missing2 = 0;
|
|
2837
2837
|
for (const message2 of messages) {
|
|
2838
2838
|
if (message2.usage?.scope === "message") {
|
|
2839
2839
|
const key = message2.usage.id || message2.id, previous = unique.get(key);
|
|
2840
2840
|
unique.set(key, previous ? mergeUsage(previous, message2.usage) : message2.usage);
|
|
2841
|
-
} else if (message2.role === "assistant")
|
|
2841
|
+
} else if (message2.role === "assistant") missing2++;
|
|
2842
2842
|
}
|
|
2843
2843
|
const records = [...unique.values()], known = records.filter((value) => value.total !== null);
|
|
2844
2844
|
if (!known.length && native) return { ...native, partial: true };
|
|
@@ -2852,8 +2852,8 @@ function summarizeUsage(session, messages, historyPartial) {
|
|
|
2852
2852
|
costEstimated: totals.cost !== null ? totals.costEstimated : native?.cost != null ? native.costEstimated : void 0,
|
|
2853
2853
|
source: records.length ? "messages" : "unavailable",
|
|
2854
2854
|
reportedMessages: known.length,
|
|
2855
|
-
missingMessages:
|
|
2856
|
-
partial: historyPartial || total === null ||
|
|
2855
|
+
missingMessages: missing2 + records.length - known.length,
|
|
2856
|
+
partial: historyPartial || total === null || missing2 > 0 || known.length !== records.length || !records.length
|
|
2857
2857
|
};
|
|
2858
2858
|
}
|
|
2859
2859
|
|
|
@@ -34783,6 +34783,40 @@ var SessionGraphStore = class {
|
|
|
34783
34783
|
autoImportEnabled() {
|
|
34784
34784
|
return this.setting("autoImport") === true;
|
|
34785
34785
|
}
|
|
34786
|
+
savedSources() {
|
|
34787
|
+
return [.../* @__PURE__ */ new Set([
|
|
34788
|
+
...this.selected(),
|
|
34789
|
+
...Object.keys(this.setting("sourcePaths") || {}),
|
|
34790
|
+
...this.db.prepare("SELECT source FROM sessions UNION SELECT source FROM projects UNION SELECT id AS source FROM sources").all().map((row) => String(row.source))
|
|
34791
|
+
])];
|
|
34792
|
+
}
|
|
34793
|
+
/** Called under the import lock and a caller-owned IMMEDIATE transaction.
|
|
34794
|
+
* Match native source ownership, never linked-provider display filters. */
|
|
34795
|
+
purgeSources(sources2, dryRun) {
|
|
34796
|
+
const ids = JSON.stringify(sources2), selected = "SELECT value FROM json_each(?)";
|
|
34797
|
+
const sessions = `SELECT id FROM sessions WHERE source IN (${selected})`;
|
|
34798
|
+
const count = (table, column) => Number(this.db.prepare(`SELECT COUNT(*) AS n FROM ${table} WHERE ${column} IN (${sessions})`).get(ids).n);
|
|
34799
|
+
const orphanProjects = `source IN (${selected}) AND NOT EXISTS (
|
|
34800
|
+
SELECT 1 FROM sessions WHERE json_extract(metadata,'$.projectID')=projects.id AND source NOT IN (${selected}))`;
|
|
34801
|
+
const deleted = {
|
|
34802
|
+
sessions: Number(this.db.prepare(`SELECT COUNT(*) AS n FROM sessions WHERE source IN (${selected})`).get(ids).n),
|
|
34803
|
+
messages: count("messages", "session_id"),
|
|
34804
|
+
events: count("timeline_items", "session_id"),
|
|
34805
|
+
commits: count("session_commits", "session_id"),
|
|
34806
|
+
pullRequests: count("session_pull_requests", "session_id"),
|
|
34807
|
+
searchCheckpoints: count("search_cache", "id"),
|
|
34808
|
+
projects: Number(this.db.prepare(`SELECT COUNT(*) AS n FROM projects WHERE ${orphanProjects}`).get(ids, ids).n)
|
|
34809
|
+
};
|
|
34810
|
+
if (!dryRun) {
|
|
34811
|
+
this.setting("selected", this.selected().filter((source) => !sources2.includes(source)));
|
|
34812
|
+
this.setting("sourcePaths", Object.fromEntries(Object.entries(this.setting("sourcePaths") || {}).filter(([source]) => !sources2.includes(source))));
|
|
34813
|
+
this.db.prepare(`DELETE FROM sessions WHERE source IN (${selected})`).run(ids);
|
|
34814
|
+
this.db.prepare(`DELETE FROM projects WHERE ${orphanProjects}`).run(ids, ids);
|
|
34815
|
+
this.db.prepare(`DELETE FROM sources WHERE id IN (${selected})`).run(ids);
|
|
34816
|
+
this.setting("indexEpoch", (this.setting("indexEpoch") || 0) + 1);
|
|
34817
|
+
}
|
|
34818
|
+
return deleted;
|
|
34819
|
+
}
|
|
34786
34820
|
acquireImport() {
|
|
34787
34821
|
this.db.exec("BEGIN IMMEDIATE");
|
|
34788
34822
|
try {
|
|
@@ -35360,6 +35394,7 @@ function launchCommand(binary, args, directory3, platform = process.platform) {
|
|
|
35360
35394
|
// server/handoff.ts
|
|
35361
35395
|
import { createHash as createHash4, randomUUID as randomUUID3 } from "node:crypto";
|
|
35362
35396
|
import { mkdir, writeFile as writeFile2, rename as rename2, rm as rm4 } from "node:fs/promises";
|
|
35397
|
+
import { renameSync as renameSync2 } from "node:fs";
|
|
35363
35398
|
import { join as join26 } from "node:path";
|
|
35364
35399
|
function handoffDocument(snapshot2) {
|
|
35365
35400
|
const { session, messages, firstUser, totalMessages } = snapshot2;
|
|
@@ -35423,7 +35458,8 @@ This handoff transfers saved text and file-change evidence, not files, credentia
|
|
|
35423
35458
|
` + chunks.map((c) => c.text).join("\n");
|
|
35424
35459
|
return { text: text2, messages: chunks.length, totalMessages, partial, note };
|
|
35425
35460
|
}
|
|
35426
|
-
async function saveHandoff(snapshot2, directory3) {
|
|
35461
|
+
async function saveHandoff(snapshot2, directory3, store) {
|
|
35462
|
+
const epoch = store?.setting("indexEpoch") || 0;
|
|
35427
35463
|
const { text: text2, ...coverage2 } = handoffDocument(snapshot2);
|
|
35428
35464
|
const digest2 = createHash4("sha256").update(text2).digest("hex");
|
|
35429
35465
|
const root2 = join26(directory3, "handoffs");
|
|
@@ -35431,7 +35467,17 @@ async function saveHandoff(snapshot2, directory3) {
|
|
|
35431
35467
|
const path = join26(root2, `${digest2}.md`), temporary = join26(root2, `.${randomUUID3()}.tmp`);
|
|
35432
35468
|
try {
|
|
35433
35469
|
await writeFile2(temporary, text2, { mode: 384, flag: "wx" });
|
|
35434
|
-
|
|
35470
|
+
if (store) {
|
|
35471
|
+
store.db.exec("BEGIN IMMEDIATE");
|
|
35472
|
+
try {
|
|
35473
|
+
if (!store.getSession(snapshot2.session.id) || epoch !== (store.setting("indexEpoch") || 0)) throw new LibraryError("STALE_CURSOR", "Saved history changed. Reload the session before preparing a handoff.");
|
|
35474
|
+
renameSync2(temporary, path);
|
|
35475
|
+
store.db.exec("COMMIT");
|
|
35476
|
+
} catch (error) {
|
|
35477
|
+
store.db.exec("ROLLBACK");
|
|
35478
|
+
throw error;
|
|
35479
|
+
}
|
|
35480
|
+
} else await rename2(temporary, path);
|
|
35435
35481
|
} finally {
|
|
35436
35482
|
await rm4(temporary, { force: true });
|
|
35437
35483
|
}
|
|
@@ -35475,7 +35521,7 @@ async function prepareLaunch(store, session, target, directory3 = session.direct
|
|
|
35475
35521
|
}
|
|
35476
35522
|
const mode = args ? "resume" : "handoff";
|
|
35477
35523
|
if (mode === "handoff" && store.path === ":memory:") invalid("Save this library before creating a context handoff.");
|
|
35478
|
-
const context2 = mode === "handoff" ? await saveHandoff(store.handoff(session.id), dirname11(store.path)).catch((error) => {
|
|
35524
|
+
const context2 = mode === "handoff" ? await saveHandoff(store.handoff(session.id), dirname11(store.path), store).catch((error) => {
|
|
35479
35525
|
throw storageFailure(error, true) ?? new LibraryError("HANDOFF_FAILED", "Could not save the session handoff.");
|
|
35480
35526
|
}) : void 0;
|
|
35481
35527
|
if (context2) {
|
|
@@ -35594,6 +35640,52 @@ var isKnownSource = (id2) => typeof id2 === "string" && Object.hasOwn(sources, i
|
|
|
35594
35640
|
var adjectives = "Cosmic Wobbly Disco Sneaky Bouncy Galactic Crispy Dizzy Fuzzy Noodle Groovy Sleepy Spicy Jolly Loopy Squishy Turbo Giggly Velvet Soggy Zippy Fluffy Moonwalking Wiggly Fizzy Snazzy Goofy Jazzy Tiny Chunky Dapper Wacky".split(" ");
|
|
35595
35641
|
var nouns = "Wombat Pickle Pancake Badger Potato Narwhal Noodle Goblin Otter Turnip Hamster Comet Dumpling Goose Biscuit Llama Muffin Squid Raccoon Toaster Waffle Penguin Yeti Pudding Walrus Taco Jellybean Platypus Sloth Cactus Donut Mongoose".split(" ");
|
|
35596
35642
|
|
|
35643
|
+
// packages/core/src/public-model.ts
|
|
35644
|
+
var patterns = [
|
|
35645
|
+
/^gpt-[3-6](?:\.[0-9])?(?:-(?:turbo|mini|nano|pro|codex|astra|sol|terra|luna|instant|thinking|chat|latest|preview|fast|ultrafast|max|spark|[0-9]{4,8}))*$/,
|
|
35646
|
+
/^o[1-4](?:-(?:mini|pro|preview|[0-9]{4,8}))*$/,
|
|
35647
|
+
/^claude-(?:(?:sonnet|opus|haiku|fable)-[3-5](?:[.-][0-9])?|[3-5](?:[.-][0-9])?-(?:sonnet|opus|haiku))(?:-(?:latest|thinking|low|medium|high|max|[0-9]{8}))*$/,
|
|
35648
|
+
/^gemini-[1-4](?:\.[0-9])?-(?:pro|flash)(?:-(?:lite|preview|exp|latest|[0-9]{2,4}))*$/,
|
|
35649
|
+
/^deepseek-(?:chat|reasoner|v[3-4](?:\.[0-9])?|r1)(?:-(?:flash|pro|free))*$/,
|
|
35650
|
+
/^grok-(?:[2-5](?:\.[0-9])?|code)(?:-(?:fast|code|reasoning|non-reasoning|[0-9]))*$/,
|
|
35651
|
+
/^kimi-k[1-3](?:\.[0-9])?(?:-(?:thinking|free))*$/,
|
|
35652
|
+
/^minimax-m[1-3](?:\.[0-9])?$/,
|
|
35653
|
+
/^composer-[1-3](?:\.[0-9])?(?:-fast)?$/,
|
|
35654
|
+
/^qwen[2-4](?:\.[0-9])?-(?:plus|coder)(?:-free)?$/
|
|
35655
|
+
];
|
|
35656
|
+
var aliases = /* @__PURE__ */ new Set([
|
|
35657
|
+
"opus",
|
|
35658
|
+
"sonic",
|
|
35659
|
+
"big-pickle",
|
|
35660
|
+
"space-bunny-free",
|
|
35661
|
+
"codex-auto-review",
|
|
35662
|
+
"gpt-daybreak-blue",
|
|
35663
|
+
"gpt-daybreak-blue-latest",
|
|
35664
|
+
"muse-spark-1.3-contributor-free"
|
|
35665
|
+
]);
|
|
35666
|
+
var canonicalAliases = {
|
|
35667
|
+
"gpt5.4-mini": "gpt-5.4-mini",
|
|
35668
|
+
"opus-4.6": "claude-opus-4-6"
|
|
35669
|
+
};
|
|
35670
|
+
function publicModel(value) {
|
|
35671
|
+
if (value.length > 1e3) return null;
|
|
35672
|
+
const parts = value.split(",");
|
|
35673
|
+
if (parts.length > 4) return null;
|
|
35674
|
+
const models = [];
|
|
35675
|
+
for (const part of parts) {
|
|
35676
|
+
const raw = (part.trim().split("/").at(-1) || "").toLowerCase();
|
|
35677
|
+
const name = Object.hasOwn(canonicalAliases, raw) ? canonicalAliases[raw] : raw;
|
|
35678
|
+
if (!aliases.has(name) && !patterns.some((pattern) => pattern.test(name))) return null;
|
|
35679
|
+
if (!models.includes(name)) models.push(name);
|
|
35680
|
+
}
|
|
35681
|
+
const result = models.join(",");
|
|
35682
|
+
return result.length <= 100 ? result : null;
|
|
35683
|
+
}
|
|
35684
|
+
function unavailableModelStatus(value) {
|
|
35685
|
+
const name = value.trim().split("/").at(-1) || "";
|
|
35686
|
+
return /^(?:|unknown(?: model)?|default|auto|<synthetic>)$/i.test(name) ? "not-recorded" : "not-recognized";
|
|
35687
|
+
}
|
|
35688
|
+
|
|
35597
35689
|
// packages/core/src/public-graph.ts
|
|
35598
35690
|
var DEFAULT_PUBLISHING = { tokens: true, timestamps: true, messageCounts: true, messageTimestamps: true, model: true, harness: true };
|
|
35599
35691
|
function publishingSettings(value) {
|
|
@@ -35607,11 +35699,6 @@ function publishingSettings(value) {
|
|
|
35607
35699
|
var PUBLIC_GRAPH_MAX_SESSIONS = 1e4;
|
|
35608
35700
|
var PUBLIC_GRAPH_MAX_BYTES = 2e6;
|
|
35609
35701
|
var PUBLIC_GRAPH_MAX_MESSAGE_TIMES = 1e5;
|
|
35610
|
-
var modelPattern = /^(?:gpt-[3-6](?:\.[0-9])?(?:-(?:turbo|mini|nano|pro|codex|astra|instant|thinking|chat|latest|preview|[0-9]{4,8}))*|o[1-4](?:-(?:mini|pro|preview|[0-9]{4,8}))*|claude-(?:(?:sonnet|opus|haiku)-[3-5](?:[.-][0-9])?|[3-5](?:-[0-9])?-(?:sonnet|opus|haiku))(?:-(?:latest|thinking|[0-9]{8}))*|gemini-[1-4](?:\.[0-9])?-(?:pro|flash)(?:-(?:lite|preview|exp|latest|[0-9]{2,4}))*|deepseek-(?:chat|reasoner|v[3-4](?:\.[0-9])?|r1)|grok-[2-5](?:\.[0-9])?(?:-(?:fast|code|reasoning|non-reasoning|[0-9]))*|kimi-k[1-3](?:\.[0-9])?(?:-thinking)?|minimax-m[1-3](?:\.[0-9])?)$/i;
|
|
35611
|
-
var publicModel = (value) => {
|
|
35612
|
-
const name = value.split("/").at(-1) || "";
|
|
35613
|
-
return name.length <= 100 && modelPattern.test(name) ? name.toLowerCase() : null;
|
|
35614
|
-
};
|
|
35615
35702
|
function publishableGraph(sessions, settings, messages = /* @__PURE__ */ new Map()) {
|
|
35616
35703
|
const fields3 = publishingSettings(settings);
|
|
35617
35704
|
const ordered = [...sessions].sort((a, b) => a.created - b.created || a.id.localeCompare(b.id));
|
|
@@ -35631,7 +35718,10 @@ function publishableGraph(sessions, settings, messages = /* @__PURE__ */ new Map
|
|
|
35631
35718
|
const stats = messages.get(session.id);
|
|
35632
35719
|
if (fields3.messageCounts) result.messages = { count: stats?.count ?? null, untimed: stats?.untimed ?? null, partial: stats?.partial ?? true };
|
|
35633
35720
|
if (fields3.messageTimestamps) result.messageTimes = { values: [], limited: stats?.timesLimited ?? true };
|
|
35634
|
-
if (fields3.model)
|
|
35721
|
+
if (fields3.model) {
|
|
35722
|
+
result.model = publicModel(session.model);
|
|
35723
|
+
if (result.model === null) result.modelStatus = unavailableModelStatus(session.model);
|
|
35724
|
+
}
|
|
35635
35725
|
if (fields3.harness) result.harness = isKnownSource(session.source) ? session.source : null;
|
|
35636
35726
|
return result;
|
|
35637
35727
|
}) };
|
|
@@ -35670,7 +35760,10 @@ function validatePublicGraph(value) {
|
|
|
35670
35760
|
let times = 0;
|
|
35671
35761
|
for (let index = 0; index < value.sessions.length; index++) {
|
|
35672
35762
|
const s = value.sessions[index];
|
|
35673
|
-
if (!
|
|
35763
|
+
if (!object4(s)) return fail2();
|
|
35764
|
+
const hasModelStatus = Object.hasOwn(s, "modelStatus");
|
|
35765
|
+
if (!exact(s, hasModelStatus ? [...keys, "modelStatus"] : keys) || s.id !== index || !integer(s.group, value.sessions.length - 1)) return fail2();
|
|
35766
|
+
if (hasModelStatus && (!settings.model || s.model !== null || !["not-recorded", "not-recognized"].includes(s.modelStatus))) return fail2();
|
|
35674
35767
|
for (const key of ["parent", "fork"]) if (s[key] !== null && (!integer(s[key], value.sessions.length - 1) || s[key] === index)) return fail2();
|
|
35675
35768
|
if (settings.timestamps && (!exact(s.timestamps, ["created", "lastMessageAt"]) || !time3(s.timestamps.created) || s.timestamps.lastMessageAt !== null && !time3(s.timestamps.lastMessageAt))) return fail2();
|
|
35676
35769
|
if (settings.tokens && !nullableCount(s.tokens)) return fail2();
|
|
@@ -35948,7 +36041,7 @@ async function annotateGitCheckouts(sessions) {
|
|
|
35948
36041
|
}
|
|
35949
36042
|
|
|
35950
36043
|
// server/library-service.ts
|
|
35951
|
-
import { basename as
|
|
36044
|
+
import { basename as basename15, dirname as dirname13, isAbsolute as isAbsolute10 } from "node:path";
|
|
35952
36045
|
|
|
35953
36046
|
// node_modules/.pnpm/minisearch@7.2.0/node_modules/minisearch/dist/es/index.js
|
|
35954
36047
|
var ENTRIES = "ENTRIES";
|
|
@@ -37935,6 +38028,73 @@ function sampleContent(page2, budget2) {
|
|
|
37935
38028
|
return { fragments, characters: Math.max(0, budget2) - remaining, partial: page2.truncated || sampled };
|
|
37936
38029
|
}
|
|
37937
38030
|
|
|
38031
|
+
// server/purge-handoffs.ts
|
|
38032
|
+
import { closeSync as closeSync2, constants as constants7, fstatSync, lstatSync as lstatSync4, openSync as openSync2, opendirSync, readSync as readSync2, unlinkSync as unlinkSync2 } from "node:fs";
|
|
38033
|
+
import { basename as basename14, join as join28 } from "node:path";
|
|
38034
|
+
var MAX_ENTRIES = 2e4;
|
|
38035
|
+
var HEADER_BYTES = 64 * 1024;
|
|
38036
|
+
var generatedName = /^(?:[a-f0-9]{64}\.md|\.[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}\.tmp)$/;
|
|
38037
|
+
var missing = (error) => error.code === "ENOENT";
|
|
38038
|
+
function findPurgeHandoffs(directory3, sources2, all = false) {
|
|
38039
|
+
const root2 = join28(directory3, "handoffs"), paths2 = [], warnings = [], foundSources = /* @__PURE__ */ new Set();
|
|
38040
|
+
try {
|
|
38041
|
+
if (!lstatSync4(root2).isDirectory()) return { paths: paths2, sources: [], warnings: ["Handoff cleanup skipped: handoffs is not a regular directory."] };
|
|
38042
|
+
const entries2 = opendirSync(root2);
|
|
38043
|
+
try {
|
|
38044
|
+
let count = 0;
|
|
38045
|
+
for (let entry = entries2.readSync(); entry; entry = entries2.readSync()) {
|
|
38046
|
+
if (++count > MAX_ENTRIES) {
|
|
38047
|
+
warnings.push("Handoff scan limited to 20,000 entries. Retry purge after cleaning this directory.");
|
|
38048
|
+
break;
|
|
38049
|
+
}
|
|
38050
|
+
if (!generatedName.test(entry.name)) continue;
|
|
38051
|
+
if (!entry.isFile()) {
|
|
38052
|
+
warnings.push(`Handoff cleanup skipped non-regular file ${entry.name}.`);
|
|
38053
|
+
continue;
|
|
38054
|
+
}
|
|
38055
|
+
const path = join28(root2, entry.name);
|
|
38056
|
+
let fd2;
|
|
38057
|
+
try {
|
|
38058
|
+
fd2 = openSync2(path, constants7.O_RDONLY | (constants7.O_NOFOLLOW || 0) | (constants7.O_NONBLOCK || 0));
|
|
38059
|
+
if (!fstatSync(fd2).isFile()) throw new Error("Not a regular file");
|
|
38060
|
+
const buffer = Buffer.alloc(HEADER_BYTES);
|
|
38061
|
+
const header = buffer.subarray(0, readSync2(fd2, buffer, 0, buffer.length, 0)).toString("utf8");
|
|
38062
|
+
const match2 = header.startsWith("# SessionGraph handoff\n\n") && /\nTitle: [^\n]*\nSource: ([^\n]+)\nNative session: /.exec(header);
|
|
38063
|
+
const source = match2 ? JSON.parse(match2[1]) : void 0;
|
|
38064
|
+
if (typeof source !== "string") {
|
|
38065
|
+
warnings.push(`Could not identify handoff ${entry.name}; it was not removed.`);
|
|
38066
|
+
continue;
|
|
38067
|
+
}
|
|
38068
|
+
foundSources.add(source);
|
|
38069
|
+
if (all || sources2.includes(source)) paths2.push(path);
|
|
38070
|
+
} catch (error) {
|
|
38071
|
+
if (!missing(error)) warnings.push(`Could not inspect handoff ${entry.name}; it was not removed.`);
|
|
38072
|
+
} finally {
|
|
38073
|
+
if (fd2 !== void 0) closeSync2(fd2);
|
|
38074
|
+
}
|
|
38075
|
+
}
|
|
38076
|
+
} finally {
|
|
38077
|
+
entries2.closeSync();
|
|
38078
|
+
}
|
|
38079
|
+
} catch (error) {
|
|
38080
|
+
if (!missing(error)) warnings.push("Could not inspect the handoffs directory. Check permissions and retry purge.");
|
|
38081
|
+
}
|
|
38082
|
+
return { paths: paths2, sources: [...foundSources], warnings };
|
|
38083
|
+
}
|
|
38084
|
+
function removePurgeHandoffs(paths2) {
|
|
38085
|
+
let removed = 0;
|
|
38086
|
+
const warnings = [];
|
|
38087
|
+
for (const path of paths2) {
|
|
38088
|
+
try {
|
|
38089
|
+
unlinkSync2(path);
|
|
38090
|
+
removed++;
|
|
38091
|
+
} catch (error) {
|
|
38092
|
+
if (!missing(error)) warnings.push(`Could not delete handoff ${basename14(path)}. Check permissions and retry purge.`);
|
|
38093
|
+
}
|
|
38094
|
+
}
|
|
38095
|
+
return { removed, warnings };
|
|
38096
|
+
}
|
|
38097
|
+
|
|
37938
38098
|
// server/library-service.ts
|
|
37939
38099
|
var utc = (ms) => ms > 0 && ms <= 864e13 ? new Date(ms).toISOString() : null;
|
|
37940
38100
|
var LibraryService = class {
|
|
@@ -38038,6 +38198,37 @@ var LibraryService = class {
|
|
|
38038
38198
|
this.store.setting("sourcePaths", paths2);
|
|
38039
38199
|
});
|
|
38040
38200
|
}
|
|
38201
|
+
purgeSources(ids, options = {}) {
|
|
38202
|
+
if (!!options.all === !!ids.length) invalid("Choose source IDs or --all.");
|
|
38203
|
+
if (options.dryRun && options.confirmed) invalid("Choose a dry run or a confirmed purge, not both.");
|
|
38204
|
+
if (!options.dryRun && options.confirmed !== true) invalid("Purging saved history requires confirmation. Use --dry-run to preview, or --yes to delete.");
|
|
38205
|
+
if (this.importer.status.running || !this.store.acquireImport()) throw new LibraryError("IMPORT_BUSY", "Another import is running. Try again when it finishes.");
|
|
38206
|
+
try {
|
|
38207
|
+
this.store.db.exec("BEGIN IMMEDIATE");
|
|
38208
|
+
let result;
|
|
38209
|
+
try {
|
|
38210
|
+
const handoffs = this.store.path === ":memory:" ? { paths: [], sources: [], warnings: [] } : findPurgeHandoffs(dirname13(this.store.path), ids, options.all);
|
|
38211
|
+
const known = [.../* @__PURE__ */ new Set([...this.importer.adapters.map((adapter) => adapter.id), ...this.store.savedSources(), ...handoffs.sources])];
|
|
38212
|
+
for (const id2 of ids) if (!known.includes(id2)) invalid(`Unknown source "${id2}". Run sessiongraph sources list.`);
|
|
38213
|
+
const sources2 = [...new Set(options.all ? known : ids)];
|
|
38214
|
+
result = { sources: sources2, handoffs, deleted: this.store.purgeSources(sources2, options.dryRun === true) };
|
|
38215
|
+
this.store.db.exec("COMMIT");
|
|
38216
|
+
} catch (error) {
|
|
38217
|
+
this.store.db.exec("ROLLBACK");
|
|
38218
|
+
throw error;
|
|
38219
|
+
}
|
|
38220
|
+
const cleanup2 = options.dryRun ? { removed: result.handoffs.paths.length, warnings: [] } : removePurgeHandoffs(result.handoffs.paths);
|
|
38221
|
+
if (!options.dryRun) this.searchCache = void 0;
|
|
38222
|
+
return {
|
|
38223
|
+
dryRun: options.dryRun === true,
|
|
38224
|
+
sources: result.sources,
|
|
38225
|
+
deleted: { ...result.deleted, handoffFiles: cleanup2.removed },
|
|
38226
|
+
warnings: [...result.handoffs.warnings, ...cleanup2.warnings]
|
|
38227
|
+
};
|
|
38228
|
+
} finally {
|
|
38229
|
+
this.store.releaseImport();
|
|
38230
|
+
}
|
|
38231
|
+
}
|
|
38041
38232
|
async importSessions(ids) {
|
|
38042
38233
|
const selected = this.store.selected(), sources2 = ids?.length ? ids : selected;
|
|
38043
38234
|
this.validateSources(sources2);
|
|
@@ -38063,7 +38254,7 @@ var LibraryService = class {
|
|
|
38063
38254
|
title: s.title,
|
|
38064
38255
|
source: s.source,
|
|
38065
38256
|
projectID: s.projectID,
|
|
38066
|
-
projectLabel: names.get(s.projectID) ||
|
|
38257
|
+
projectLabel: names.get(s.projectID) || basename15(s.directory) || "Unknown project",
|
|
38067
38258
|
created: utc(s.created),
|
|
38068
38259
|
lastActivity: utc(sessionEnd(s)),
|
|
38069
38260
|
relationship: relationshipOf(s),
|
|
@@ -38190,7 +38381,7 @@ var LibraryService = class {
|
|
|
38190
38381
|
}
|
|
38191
38382
|
const groups = [...grouped2].sort(([a], [b]) => a.localeCompare(b)).map(([key, values]) => ({
|
|
38192
38383
|
key,
|
|
38193
|
-
label: groupBy === "project" ? names.get(key) ||
|
|
38384
|
+
label: groupBy === "project" ? names.get(key) || basename15(values[0].directory) || "Unknown project" : groupBy === "repository" ? values[0].checkout?.repositoryLabel || "Unverified repository" : key,
|
|
38194
38385
|
...groupBy === "repository" ? { worktrees: [...new Set(values.flatMap((s) => s.checkout?.worktree || []))].sort() } : {},
|
|
38195
38386
|
...groupBy === "relationship" ? { origins: values.reduce((counts, s) => {
|
|
38196
38387
|
counts[s.origin ?? "unknown"]++;
|
|
@@ -38343,6 +38534,15 @@ async function sessionGraphMiddleware(req, res, next) {
|
|
|
38343
38534
|
const result = await service.discoverSources([value.source]);
|
|
38344
38535
|
return json5(200, { saved: true, source: result.sources[0] });
|
|
38345
38536
|
}
|
|
38537
|
+
if (url.pathname === "/api/sessiongraph/sources/purge") {
|
|
38538
|
+
if (req.method !== "POST") {
|
|
38539
|
+
res.setHeader("Allow", "POST");
|
|
38540
|
+
return json5(405, { error: "Method not allowed." });
|
|
38541
|
+
}
|
|
38542
|
+
const value = await body(req);
|
|
38543
|
+
if (!value || typeof value !== "object" || Array.isArray(value) || Object.keys(value).some((key) => !["sources", "all", "dryRun", "confirmed"].includes(key)) || value.sources !== void 0 && (!Array.isArray(value.sources) || value.sources.some((source) => typeof source !== "string")) || ["all", "dryRun", "confirmed"].some((key) => value[key] !== void 0 && typeof value[key] !== "boolean")) return json5(400, { error: "Choose source IDs or all, and a dry run or confirmed purge." });
|
|
38544
|
+
return json5(200, new LibraryService(store, importer).purgeSources(value.sources || [], { all: value.all, dryRun: value.dryRun, confirmed: value.confirmed }));
|
|
38545
|
+
}
|
|
38346
38546
|
if (url.pathname === "/api/sessiongraph/import") {
|
|
38347
38547
|
if (req.method === "GET") return json5(200, importer.status);
|
|
38348
38548
|
if (req.method === "POST") {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as a,R as i,C as o}from"./index-
|
|
1
|
+
import{j as a,R as i,C as o}from"./index-YT1ntRdY.js";class l extends i{constructor(e){super(e.rid),this.available=!0,this.currentVersion=e.currentVersion,this.version=e.version,this.date=e.date,this.body=e.body,this.rawJson=e.rawJson}async download(e,n){const d=new o;e&&(d.onmessage=e);const r=await a("plugin:updater|download",{onEvent:d,rid:this.rid,...n,headers:t(n?.headers)});await this.downloadedBytes?.close().catch(()=>{}),this.downloadedBytes=new i(r)}async install(e){if(!this.downloadedBytes)throw new Error("Update.install called before Update.download");await a("plugin:updater|install",{updateRid:this.rid,bytesRid:this.downloadedBytes.rid,...e}),this.downloadedBytes=void 0}async downloadAndInstall(e,n){const d=new o;e&&(d.onmessage=e),await a("plugin:updater|download_and_install",{onEvent:d,rid:this.rid,...n,headers:t(n?.headers)})}async close(){await this.downloadedBytes?.close(),await super.close()}}async function w(s){const e=await a("plugin:updater|check",{...s,headers:t(s?.headers)});return e?new l(e):null}function t(s){return s?Array.from(new Headers(s).entries()):void 0}export{l as Update,w as check};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as i}from"./index-
|
|
1
|
+
import{j as i}from"./index-YT1ntRdY.js";function r(e){if(e!==void 0){if(typeof e=="string")return e;if("ok"in e&&"cancel"in e)return{OkCancelCustom:[e.ok,e.cancel]};if("yes"in e&&"no"in e&&"cancel"in e)return{YesNoCancelCustom:[e.yes,e.no,e.cancel]};if("ok"in e)return{OkCustom:e.ok}}}async function f(e={}){return typeof e=="object"&&Object.freeze(e),await i("plugin:dialog|open",{options:e})}async function k(e={}){return typeof e=="object"&&Object.freeze(e),await i("plugin:dialog|save",{options:e})}async function l(e,a){return await i("plugin:dialog|message",{message:e,title:a?.title,kind:a?.kind,buttons:r(a?.buttons)})}async function s(e,a){const n=typeof a=="string"?{title:a}:a;return n&&!n.buttons&&n.okLabel&&(n.buttons={ok:n.okLabel}),l(e,n)}async function u(e,a){const n=typeof a=="string"?{title:a}:a,c=n?.okLabel||n?.cancelLabel,t=n?.okLabel??"Yes";return await l(e,{title:n?.title,kind:n?.kind,buttons:c?{ok:t,cancel:n.cancelLabel??"No"}:"YesNo"})===t}async function d(e,a){const n=typeof a=="string"?{title:a}:a,c=n?.okLabel||n?.cancelLabel,t=n?.okLabel??"Ok";return await l(e,{title:n?.title,kind:n?.kind,buttons:c?{ok:t,cancel:n.cancelLabel??"Cancel"}:"OkCancel"})===t}export{u as ask,d as confirm,s as message,f as open,k as save};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{R as a,j as i,C as R}from"./index-
|
|
1
|
+
import{R as a,j as i,C as R}from"./index-YT1ntRdY.js";var w;(function(n){n[n.Audio=1]="Audio",n[n.Cache=2]="Cache",n[n.Config=3]="Config",n[n.Data=4]="Data",n[n.LocalData=5]="LocalData",n[n.Document=6]="Document",n[n.Download=7]="Download",n[n.Picture=8]="Picture",n[n.Public=9]="Public",n[n.Video=10]="Video",n[n.Resource=11]="Resource",n[n.Temp=12]="Temp",n[n.AppConfig=13]="AppConfig",n[n.AppData=14]="AppData",n[n.AppLocalData=15]="AppLocalData",n[n.AppCache=16]="AppCache",n[n.AppLog=17]="AppLog",n[n.Desktop=18]="Desktop",n[n.Executable=19]="Executable",n[n.Font=20]="Font",n[n.Home=21]="Home",n[n.Runtime=22]="Runtime",n[n.Template=23]="Template"})(w||(w={}));var d;(function(n){n[n.Start=0]="Start",n[n.Current=1]="Current",n[n.End=2]="End"})(d||(d={}));function u(n){return{isFile:n.isFile,isDirectory:n.isDirectory,isSymlink:n.isSymlink,size:n.size,mtime:n.mtime!==null?new Date(n.mtime):null,atime:n.atime!==null?new Date(n.atime):null,birthtime:n.birthtime!==null?new Date(n.birthtime):null,readonly:n.readonly,fileAttributes:n.fileAttributes,dev:n.dev,ino:n.ino,mode:n.mode,nlink:n.nlink,uid:n.uid,gid:n.gid,rdev:n.rdev,blksize:n.blksize,blocks:n.blocks}}function U(n){const e=new Uint8ClampedArray(n),t=e.byteLength;let o=0;for(let r=0;r<t;r++){const s=e[r];o*=256,o+=s}return o}class g extends a{async read(e){if(e.byteLength===0)return 0;const t=await i("plugin:fs|read",{rid:this.rid,len:e.byteLength}),o=U(t.slice(-8)),r=t instanceof ArrayBuffer?new Uint8Array(t):t;return e.set(r.slice(0,r.length-8)),o===0?null:o}async seek(e,t){return await i("plugin:fs|seek",{rid:this.rid,offset:e,whence:t})}async stat(){const e=await i("plugin:fs|fstat",{rid:this.rid});return u(e)}async truncate(e){await i("plugin:fs|ftruncate",{rid:this.rid,len:e})}async write(e){return await i("plugin:fs|write",{rid:this.rid,data:e})}}async function b(n,e){if(n instanceof URL&&n.protocol!=="file:")throw new TypeError("Must be a file URL.");const t=await i("plugin:fs|create",{path:n instanceof URL?n.toString():n,options:e});return new g(t)}async function p(n,e){if(n instanceof URL&&n.protocol!=="file:")throw new TypeError("Must be a file URL.");const t=await i("plugin:fs|open",{path:n instanceof URL?n.toString():n,options:e});return new g(t)}async function S(n,e,t){if(n instanceof URL&&n.protocol!=="file:"||e instanceof URL&&e.protocol!=="file:")throw new TypeError("Must be a file URL.");await i("plugin:fs|copy_file",{fromPath:n instanceof URL?n.toString():n,toPath:e instanceof URL?e.toString():e,options:t})}async function A(n,e){if(n instanceof URL&&n.protocol!=="file:")throw new TypeError("Must be a file URL.");await i("plugin:fs|mkdir",{path:n instanceof URL?n.toString():n,options:e})}async function T(n,e){if(n instanceof URL&&n.protocol!=="file:")throw new TypeError("Must be a file URL.");return await i("plugin:fs|read_dir",{path:n instanceof URL?n.toString():n,options:e})}async function E(n,e){if(n instanceof URL&&n.protocol!=="file:")throw new TypeError("Must be a file URL.");const t=await i("plugin:fs|read_file",{path:n instanceof URL?n.toString():n,options:e});return t instanceof ArrayBuffer?new Uint8Array(t):Uint8Array.from(t)}async function _(n,e){if(n instanceof URL&&n.protocol!=="file:")throw new TypeError("Must be a file URL.");const t=await i("plugin:fs|read_text_file",{path:n instanceof URL?n.toString():n,options:e}),o=t instanceof ArrayBuffer?t:Uint8Array.from(t);return new TextDecoder(e?.encoding??"utf-8").decode(o)}async function x(n,e){if(n instanceof URL&&n.protocol!=="file:")throw new TypeError("Must be a file URL.");const t=n instanceof URL?n.toString():n;return await Promise.resolve({path:t,rid:null,async next(){const o=new TextDecoder(e?.encoding??"utf-8");if(this.rid===null){const l=o.encoding;this.rid=await i("plugin:fs|read_text_file_lines",{path:t,options:e!=null?{...e,encoding:l}:void 0})}let r;try{r=await i("plugin:fs|read_text_file_lines_next",{rid:this.rid})}catch(l){throw this.rid=null,l}const s=r instanceof ArrayBuffer?new Uint8Array(r):Uint8Array.from(r),f=s[s.byteLength-1]===1;return f?(this.rid=null,{value:null,done:f}):{value:o.decode(s.slice(0,s.byteLength-1)),done:f}},async return(){if(this.rid!==null){const o=this.rid;this.rid=null,await new a(o).close()}return{value:null,done:!0}},[Symbol.asyncIterator](){return this}})}async function v(n,e){if(n instanceof URL&&n.protocol!=="file:")throw new TypeError("Must be a file URL.");await i("plugin:fs|remove",{path:n instanceof URL?n.toString():n,options:e})}async function M(n,e,t){if(n instanceof URL&&n.protocol!=="file:"||e instanceof URL&&e.protocol!=="file:")throw new TypeError("Must be a file URL.");await i("plugin:fs|rename",{oldPath:n instanceof URL?n.toString():n,newPath:e instanceof URL?e.toString():e,options:t})}async function C(n,e){const t=await i("plugin:fs|stat",{path:n instanceof URL?n.toString():n,options:e});return u(t)}async function k(n,e){const t=await i("plugin:fs|lstat",{path:n instanceof URL?n.toString():n,options:e});return u(t)}async function F(n,e,t){if(n instanceof URL&&n.protocol!=="file:")throw new TypeError("Must be a file URL.");await i("plugin:fs|truncate",{path:n instanceof URL?n.toString():n,len:e,options:t})}async function z(n,e,t){if(n instanceof URL&&n.protocol!=="file:")throw new TypeError("Must be a file URL.");if(e instanceof ReadableStream){const o=await p(n,{read:!1,create:!0,write:!0,...t,truncate:!t?.append}),r=e.getReader();try{for(;;){const{done:s,value:f}=await r.read();if(s)break;await o.write(f)}}finally{r.releaseLock(),await o.close()}}else await i("plugin:fs|write_file",e,{headers:{path:encodeURIComponent(n instanceof URL?n.toString():n),options:JSON.stringify(t)}})}async function I(n,e,t){if(n instanceof URL&&n.protocol!=="file:")throw new TypeError("Must be a file URL.");const o=new TextEncoder;await i("plugin:fs|write_text_file",o.encode(e),{headers:{path:encodeURIComponent(n instanceof URL?n.toString():n),options:JSON.stringify(t)}})}async function H(n,e){if(n instanceof URL&&n.protocol!=="file:")throw new TypeError("Must be a file URL.");return await i("plugin:fs|exists",{path:n instanceof URL?n.toString():n,options:e})}class y extends a{}async function L(n,e,t){const o=Array.isArray(n)?n:[n];for(const c of o)if(c instanceof URL&&c.protocol!=="file:")throw new TypeError("Must be a file URL.");const r=new R;r.onmessage=e;const s=await i("plugin:fs|watch",{paths:o.map(c=>c instanceof URL?c.toString():c),options:t,onEvent:r}),f=new y(s);return()=>{f.close()}}async function J(n,e,t){return await L(n,e,{delayMs:2e3,...t})}async function N(n,e,t){return await L(n,e,{...t,delayMs:void 0})}async function O(n,e){if(n instanceof URL&&n.protocol!=="file:")throw new TypeError("Must be a file URL.");return await i("plugin:fs|size",{path:n instanceof URL?n.toString():n,options:e})}async function V(n){if(n instanceof URL&&n.protocol!=="file:")throw new TypeError("Must be a file URL.");await i("plugin:fs|start_accessing_security_scoped_resource",{path:n instanceof URL?n.toString():n})}async function h(n){if(n instanceof URL&&n.protocol!=="file:")throw new TypeError("Must be a file URL.");await i("plugin:fs|stop_accessing_security_scoped_resource",{path:n instanceof URL?n.toString():n})}export{w as BaseDirectory,g as FileHandle,d as SeekMode,S as copyFile,b as create,H as exists,k as lstat,A as mkdir,p as open,T as readDir,E as readFile,_ as readTextFile,x as readTextFileLines,v as remove,M as rename,O as size,V as startAccessingSecurityScopedResource,C as stat,h as stopAccessingSecurityScopedResource,F as truncate,J as watch,N as watchImmediate,z as writeFile,I as writeTextFile};
|