@ashx-j/lunr-dev 0.2.16-dev.9.1 → 0.2.19-dev.10.1
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/CHANGELOG.md +32 -1
- package/README.md +7 -1
- package/dist/builtin-extensions/ashxj-thinking.d.ts +1 -0
- package/dist/builtin-extensions/ashxj-thinking.d.ts.map +1 -1
- package/dist/builtin-extensions/ashxj-thinking.js +44 -19
- package/dist/builtin-extensions/ashxj-thinking.js.map +1 -1
- package/dist/builtin-extensions/index.d.ts.map +1 -1
- package/dist/builtin-extensions/index.js +1 -0
- package/dist/builtin-extensions/index.js.map +1 -1
- package/dist/builtin-extensions/lunr-computer-use.d.ts +3 -0
- package/dist/builtin-extensions/lunr-computer-use.d.ts.map +1 -0
- package/dist/builtin-extensions/lunr-computer-use.js +157 -0
- package/dist/builtin-extensions/lunr-computer-use.js.map +1 -0
- package/dist/builtin-extensions/pi-lsp-extension/src/index.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/index.js +10 -3
- package/dist/builtin-extensions/pi-lsp-extension/src/index.js.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/runtime.d.ts +5 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/runtime.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-lsp-extension/src/runtime.js +26 -4
- package/dist/builtin-extensions/pi-lsp-extension/src/runtime.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/index.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/index.js +37 -27
- package/dist/builtin-extensions/pi-mcp-adapter/index.js.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/server-manager.d.ts +6 -1
- package/dist/builtin-extensions/pi-mcp-adapter/server-manager.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-mcp-adapter/server-manager.js +33 -8
- package/dist/builtin-extensions/pi-mcp-adapter/server-manager.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/index.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/index.js +52 -23
- package/dist/builtin-extensions/pi-subagents/src/extension/index.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/schemas.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/extension/schemas.js +6 -2
- package/dist/builtin-extensions/pi-subagents/src/extension/schemas.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-tool.d.ts +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-tool.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-tool.js +5 -2
- package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-tool.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/request-params.d.ts +10 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/request-params.d.ts.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/request-params.js +38 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/request-params.js.map +1 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.js +3 -16
- package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/child-tools.d.ts +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/child-tools.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/child-tools.js +2 -0
- package/dist/builtin-extensions/pi-subagents/src/runs/shared/child-tools.js.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/tui/render.d.ts +1 -0
- package/dist/builtin-extensions/pi-subagents/src/tui/render.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-subagents/src/tui/render.js +70 -30
- package/dist/builtin-extensions/pi-subagents/src/tui/render.js.map +1 -1
- package/dist/builtin-extensions/pi-web-access/index.d.ts.map +1 -1
- package/dist/builtin-extensions/pi-web-access/index.js +103 -102
- package/dist/builtin-extensions/pi-web-access/index.js.map +1 -1
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +1 -1
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/computer-use/adapter.d.ts +23 -0
- package/dist/core/computer-use/adapter.d.ts.map +1 -0
- package/dist/core/computer-use/adapter.js +116 -0
- package/dist/core/computer-use/adapter.js.map +1 -0
- package/dist/core/computer-use/lease.d.ts +18 -0
- package/dist/core/computer-use/lease.d.ts.map +1 -0
- package/dist/core/computer-use/lease.js +129 -0
- package/dist/core/computer-use/lease.js.map +1 -0
- package/dist/core/computer-use/macos-runtime.d.ts +14 -0
- package/dist/core/computer-use/macos-runtime.d.ts.map +1 -0
- package/dist/core/computer-use/macos-runtime.js +148 -0
- package/dist/core/computer-use/macos-runtime.js.map +1 -0
- package/dist/core/computer-use/policy.d.ts +19 -0
- package/dist/core/computer-use/policy.d.ts.map +1 -0
- package/dist/core/computer-use/policy.js +66 -0
- package/dist/core/computer-use/policy.js.map +1 -0
- package/dist/core/computer-use/release.generated.d.ts +31 -0
- package/dist/core/computer-use/release.generated.d.ts.map +1 -0
- package/dist/core/computer-use/release.generated.js +36 -0
- package/dist/core/computer-use/release.generated.js.map +1 -0
- package/dist/core/computer-use/runtime.d.ts +13 -0
- package/dist/core/computer-use/runtime.d.ts.map +1 -0
- package/dist/core/computer-use/runtime.js +158 -0
- package/dist/core/computer-use/runtime.js.map +1 -0
- package/dist/core/computer-use/schemas.d.ts +88 -0
- package/dist/core/computer-use/schemas.d.ts.map +1 -0
- package/dist/core/computer-use/schemas.js +80 -0
- package/dist/core/computer-use/schemas.js.map +1 -0
- package/dist/core/computer-use/windows-desktop.d.ts +3 -0
- package/dist/core/computer-use/windows-desktop.d.ts.map +1 -0
- package/dist/core/computer-use/windows-desktop.js +48 -0
- package/dist/core/computer-use/windows-desktop.js.map +1 -0
- package/dist/core/computer-use/workflow.d.ts +24 -0
- package/dist/core/computer-use/workflow.d.ts.map +1 -0
- package/dist/core/computer-use/workflow.js +330 -0
- package/dist/core/computer-use/workflow.js.map +1 -0
- package/dist/core/keybindings.d.ts +2 -2
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +2 -2
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/model-runtime.d.ts +0 -3
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +1 -10
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +1 -1
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/permissions.d.ts +1 -1
- package/dist/core/permissions.d.ts.map +1 -1
- package/dist/core/permissions.js +23 -7
- package/dist/core/permissions.js.map +1 -1
- package/dist/core/plan-mode.d.ts.map +1 -1
- package/dist/core/plan-mode.js +9 -0
- package/dist/core/plan-mode.js.map +1 -1
- package/dist/core/rollback.d.ts.map +1 -1
- package/dist/core/rollback.js +13 -90
- package/dist/core/rollback.js.map +1 -1
- package/dist/core/session-manager.d.ts +0 -1
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +21 -79
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-manager.d.ts +6 -0
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +19 -0
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/dev-cli.js +0 -0
- package/dist/gateway/agent-bridge.d.ts +6 -1
- package/dist/gateway/agent-bridge.d.ts.map +1 -1
- package/dist/gateway/agent-bridge.js +23 -6
- package/dist/gateway/agent-bridge.js.map +1 -1
- package/dist/gateway/cron.d.ts +1 -1
- package/dist/gateway/cron.d.ts.map +1 -1
- package/dist/gateway/cron.js +23 -7
- package/dist/gateway/cron.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts +4 -2
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +23 -32
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/processes-selector.d.ts +2 -3
- package/dist/modes/interactive/components/processes-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/processes-selector.js +5 -10
- package/dist/modes/interactive/components/processes-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts +4 -0
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +20 -0
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +18 -8
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/thinking-level-slash.d.ts +4 -0
- package/dist/modes/interactive/thinking-level-slash.d.ts.map +1 -0
- package/dist/modes/interactive/thinking-level-slash.js +23 -0
- package/dist/modes/interactive/thinking-level-slash.js.map +1 -0
- package/dist/node-runtime/adapter-AZMY335J.js +279 -0
- package/dist/node-runtime/{agent-session-services-IFJMSX7Z.js → agent-session-services-RSGP5GDN.js} +15 -12
- package/dist/node-runtime/{builtin-extensions-LYZ3BFWQ.js → builtin-extensions-7STLFW3A.js} +4 -3
- package/dist/node-runtime/chunk-2IDTZAG5.js +1415 -0
- package/dist/node-runtime/{chunk-7NBZ5P7I.js → chunk-4SJWFTUP.js} +1 -1
- package/dist/node-runtime/{chunk-AJX357CL.js → chunk-5NWQCSKR.js} +20 -1013
- package/dist/node-runtime/chunk-5OLJGVCB.js +68 -0
- package/dist/node-runtime/chunk-5Q45AVQG.js +108 -0
- package/dist/node-runtime/{chunk-TQNSPERU.js → chunk-5SQDLSZJ.js} +1 -1
- package/dist/node-runtime/{chunk-F4VQFJI2.js → chunk-6SPPH4FY.js} +4 -4
- package/dist/node-runtime/{chunk-PBC2Y6GS.js → chunk-6UB6NKA3.js} +29 -72
- package/dist/node-runtime/{chunk-A2KQXUJD.js → chunk-7AFOFSDY.js} +1 -1
- package/dist/node-runtime/chunk-BKAZ6BKX.js +2185 -0
- package/dist/node-runtime/{chunk-AHSTJBIB.js → chunk-EH2LJQPM.js} +4 -4
- package/dist/node-runtime/{chunk-N77MY65L.js → chunk-FLYMHKCS.js} +25 -25
- package/dist/node-runtime/{chunk-5P7PZMRU.js → chunk-HRS4HMDX.js} +1 -1
- package/dist/node-runtime/{chunk-IPA627GP.js → chunk-ISQDQIZN.js} +4 -4
- package/dist/node-runtime/{chunk-WJVFOIB5.js → chunk-J7QGQD45.js} +1 -1
- package/dist/node-runtime/{chunk-WOVTOV5P.js → chunk-JT6YCS5B.js} +29 -34
- package/dist/node-runtime/chunk-JZHEUQRL.js +180 -0
- package/dist/node-runtime/{chunk-ZKMFUD3Q.js → chunk-K72NVGUB.js} +3 -3
- package/dist/node-runtime/{chunk-ECD5L7YI.js → chunk-LCACDWHJ.js} +389 -15
- package/dist/node-runtime/{chunk-2QKLKMKC.js → chunk-LTXUQJI4.js} +1 -1
- package/dist/node-runtime/{chunk-MKKH27PH.js → chunk-LWJXTA6Z.js} +274 -2416
- package/dist/node-runtime/{chunk-EDBJNRSM.js → chunk-MGSB2C3M.js} +1 -1
- package/dist/node-runtime/{chunk-CDFZEWPU.js → chunk-MUMMMTW4.js} +6 -2
- package/dist/node-runtime/{chunk-YF63P5ZT.js → chunk-OTT6JMPU.js} +10 -67
- package/dist/node-runtime/{chunk-PGAJ5MO5.js → chunk-T5GM5BFH.js} +1 -1
- package/dist/node-runtime/{chunk-PCGNAY2O.js → chunk-TAP7QTUT.js} +38 -16
- package/dist/node-runtime/{chunk-4TLO4PO2.js → chunk-U6C7VTR5.js} +7 -1401
- package/dist/node-runtime/chunk-URD2SLIT.js +1019 -0
- package/dist/node-runtime/{chunk-QH42CDX3.js → chunk-W7S2REEG.js} +111 -84
- package/dist/node-runtime/{chunk-LZAW4ZX3.js → chunk-ZRDIMBEQ.js} +27 -9
- package/dist/node-runtime/{chunk-AD6VXAO7.js → chunk-ZSEZY3II.js} +5 -100
- package/dist/node-runtime/cli-runtime.js +1 -1
- package/dist/node-runtime/{command-L3LAHDIH.js → command-6UXQ6XZN.js} +1 -1
- package/dist/node-runtime/{commands-RL5YBW5I.js → commands-LGR5VT5X.js} +6 -4
- package/dist/node-runtime/{direct-tool-executor-JVDXTO7A.js → direct-tool-executor-TDJS7TBD.js} +9 -6
- package/dist/node-runtime/{export-html-KR26FOUZ.js → export-html-E4DT6ZJQ.js} +1 -1
- package/dist/node-runtime/{extract-XLQSJN4V.js → extract-IUCVZCWC.js} +2 -2
- package/dist/node-runtime/{gateway-X2TI5X7F.js → gateway-3OLC4GQN.js} +22 -367
- package/dist/node-runtime/{gemini-search-U7SUMPQA.js → gemini-search-NCIDF7NE.js} +1 -1
- package/dist/node-runtime/{gemini-url-context-PXWCBQHK.js → gemini-url-context-OKIN7AIP.js} +2 -2
- package/dist/node-runtime/image-resize-6ZPBFMWW.js +11 -0
- package/dist/node-runtime/index.js +53 -49
- package/dist/node-runtime/{init-NJV2T55N.js → init-EKE277AG.js} +6 -4
- package/dist/node-runtime/{interactive-mode-KOM35YF2.js → interactive-mode-S5M26CQ7.js} +20 -17
- package/dist/node-runtime/{interactive-view-U6OILKF3.js → interactive-view-N6F4KUIT.js} +3 -5
- package/dist/node-runtime/lunr-computer-use-4X3KUNF4.js +206 -0
- package/dist/node-runtime/{lunr-cron-YJ5UHYRD.js → lunr-cron-KKBOGAEF.js} +7 -1
- package/dist/node-runtime/main.js +24 -21
- package/dist/node-runtime/{mcp-auth-flow-QIXHW6QN.js → mcp-auth-flow-YL6RWPYG.js} +2 -1
- package/dist/node-runtime/{package-manager-cli-TZZHJCVI.js → package-manager-cli-C4EJOO5Q.js} +8 -6
- package/dist/node-runtime/{pi-mcp-adapter-QFB37AVN.js → pi-mcp-adapter-DPTJGAAL.js} +33 -27
- package/dist/node-runtime/{pi-subagents-7XJ4H53P.js → pi-subagents-VKCLYIBY.js} +103 -76
- package/dist/node-runtime/{pi-web-access-DPGAVKOA.js → pi-web-access-BV6DSZOP.js} +72 -69
- package/dist/node-runtime/{proxy-modes-HEEFK4KC.js → proxy-modes-R64LU6WZ.js} +12 -9
- package/dist/node-runtime/rpc-entry.js +24 -21
- package/dist/node-runtime/runtime-3SB5ATHQ.js +21 -0
- package/dist/node-runtime/{runtime-bridges-PPHNBFWL.js → runtime-bridges-UJ5WJJLN.js} +3 -3
- package/dist/node-runtime/{session-manager-MQNBYACL.js → session-manager-QEMZBMTM.js} +3 -5
- package/dist/node-runtime/{session-selector-5AZLJS6U.js → session-selector-URVJLOTK.js} +2 -2
- package/dist/node-runtime/{settings-manager-5LF2VQWC.js → settings-manager-K6IPIQTI.js} +3 -1
- package/dist/node-runtime/{src-Y7JSCK64.js → src-GPFAU3N6.js} +30 -10
- package/dist/node-runtime/{subagent-executor-5RNDEPIJ.js → subagent-executor-EFLTO32A.js} +39 -21
- package/dist/node-runtime/{update-cli-A253SZ7P.js → update-cli-I6OVDRPL.js} +3 -1
- package/dist/node-runtime/{video-extract-OYT5WKS5.js → video-extract-ETA5RA7U.js} +2 -2
- package/dist/node-runtime/workflow-SA34S4VX.js +325 -0
- package/dist/node-runtime/{youtube-extract-TQYKGFGS.js → youtube-extract-SRVGNN26.js} +2 -2
- package/dist/rpc.d.ts +3 -0
- package/dist/rpc.d.ts.map +1 -0
- package/dist/rpc.js +18 -0
- package/dist/rpc.js.map +1 -0
- package/dist/startup/interactive-view.d.ts.map +1 -1
- package/dist/startup/interactive-view.js +1 -2
- package/dist/startup/interactive-view.js.map +1 -1
- package/docs/computer-use.md +277 -0
- package/docs/development.md +0 -32
- package/docs/features.md +2 -2
- package/docs/interactive-startup.md +10 -3
- package/docs/keybindings.md +2 -2
- package/docs/terminal-setup.md +1 -1
- package/docs/usage.md +1 -1
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/hidden-thinking-label.ts +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/install-lock/package-lock.json +3827 -0
- package/install-lock/package.json +18 -0
- package/native/computer-use/LICENSE.md +21 -0
- package/npm-shrinkwrap.json +3808 -0
- package/package.json +16 -10
- package/dist/startup/interactive-shell.d.ts +0 -55
- package/dist/startup/interactive-shell.d.ts.map +0 -1
- package/dist/startup/interactive-shell.js +0 -264
- package/dist/startup/interactive-shell.js.map +0 -1
- package/dist/node-runtime/{chunk-YSKSB3BJ.js → chunk-CH6OL6P2.js} +2 -2
- package/dist/node-runtime/{chunk-VSELYKWU.js → chunk-EHMBW7FA.js} +3 -3
|
@@ -91,12 +91,16 @@ export function migrateSessionEntries(entries) {
|
|
|
91
91
|
export function parseSessionEntries(content) {
|
|
92
92
|
const entries = [];
|
|
93
93
|
const lines = content.trim().split("\n");
|
|
94
|
-
for (const
|
|
94
|
+
for (const line of lines) {
|
|
95
95
|
if (!line.trim())
|
|
96
96
|
continue;
|
|
97
|
-
|
|
98
|
-
|
|
97
|
+
try {
|
|
98
|
+
const entry = JSON.parse(line);
|
|
99
99
|
entries.push(entry);
|
|
100
|
+
}
|
|
101
|
+
catch {
|
|
102
|
+
// Skip malformed lines
|
|
103
|
+
}
|
|
100
104
|
}
|
|
101
105
|
return entries;
|
|
102
106
|
}
|
|
@@ -108,51 +112,14 @@ export function getLatestCompactionEntry(entries) {
|
|
|
108
112
|
}
|
|
109
113
|
return null;
|
|
110
114
|
}
|
|
111
|
-
|
|
115
|
+
function buildEntryIndex(entries, byId) {
|
|
116
|
+
if (byId)
|
|
117
|
+
return byId;
|
|
112
118
|
const index = new Map();
|
|
113
119
|
for (const entry of entries) {
|
|
114
|
-
if (typeof entry.id !== "string" || !entry.id) {
|
|
115
|
-
throw new Error("Session graph is corrupt: every entry must have a non-empty id");
|
|
116
|
-
}
|
|
117
|
-
if (index.has(entry.id)) {
|
|
118
|
-
throw new Error(`Session graph is corrupt: duplicate entry id "${entry.id}"`);
|
|
119
|
-
}
|
|
120
120
|
index.set(entry.id, entry);
|
|
121
121
|
}
|
|
122
|
-
|
|
123
|
-
if (entry.parentId === entry.id) {
|
|
124
|
-
throw new Error(`Session graph is corrupt: entry "${entry.id}" links to itself`);
|
|
125
|
-
}
|
|
126
|
-
if (entry.parentId !== null && !index.has(entry.parentId)) {
|
|
127
|
-
throw new Error(`Session graph is corrupt: entry "${entry.id}" has missing parent "${entry.parentId}"`);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
const complete = new Set();
|
|
131
|
-
for (const entry of entries) {
|
|
132
|
-
if (complete.has(entry.id))
|
|
133
|
-
continue;
|
|
134
|
-
const path = [];
|
|
135
|
-
const positions = new Map();
|
|
136
|
-
let current = entry;
|
|
137
|
-
while (current && !complete.has(current.id)) {
|
|
138
|
-
const position = positions.get(current.id);
|
|
139
|
-
if (position !== undefined) {
|
|
140
|
-
const cycle = [...path.slice(position), current.id].join(" -> ");
|
|
141
|
-
throw new Error(`Session graph is corrupt: parent cycle detected (${cycle})`);
|
|
142
|
-
}
|
|
143
|
-
positions.set(current.id, path.length);
|
|
144
|
-
path.push(current.id);
|
|
145
|
-
current = current.parentId === null ? undefined : index.get(current.parentId);
|
|
146
|
-
}
|
|
147
|
-
for (const id of path)
|
|
148
|
-
complete.add(id);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
function buildEntryIndex(entries, byId) {
|
|
152
|
-
if (byId)
|
|
153
|
-
return byId;
|
|
154
|
-
validateSessionGraph(entries);
|
|
155
|
-
return new Map(entries.map((entry) => [entry.id, entry]));
|
|
122
|
+
return index;
|
|
156
123
|
}
|
|
157
124
|
function buildSessionPath(entries, leafId, byId) {
|
|
158
125
|
const index = buildEntryIndex(entries, byId);
|
|
@@ -168,17 +135,9 @@ function buildSessionPath(entries, leafId, byId) {
|
|
|
168
135
|
return [];
|
|
169
136
|
}
|
|
170
137
|
const path = [];
|
|
171
|
-
const visited = new Set();
|
|
172
138
|
let current = leaf;
|
|
173
139
|
while (current) {
|
|
174
|
-
if (visited.has(current.id)) {
|
|
175
|
-
throw new Error(`Session graph is corrupt: parent cycle detected at entry "${current.id}"`);
|
|
176
|
-
}
|
|
177
|
-
visited.add(current.id);
|
|
178
140
|
path.push(current);
|
|
179
|
-
if (current.parentId && !index.has(current.parentId)) {
|
|
180
|
-
throw new Error(`Session graph is corrupt: entry "${current.id}" has missing parent "${current.parentId}"`);
|
|
181
|
-
}
|
|
182
141
|
current = current.parentId ? index.get(current.parentId) : undefined;
|
|
183
142
|
}
|
|
184
143
|
path.reverse();
|
|
@@ -294,15 +253,15 @@ export function getDefaultSessionDir(cwd, agentDir = getDefaultAgentDir()) {
|
|
|
294
253
|
return sessionDir;
|
|
295
254
|
}
|
|
296
255
|
const SESSION_READ_BUFFER_SIZE = 1024 * 1024;
|
|
297
|
-
function parseSessionEntryLine(line
|
|
298
|
-
|
|
299
|
-
if (!trimmed)
|
|
256
|
+
function parseSessionEntryLine(line) {
|
|
257
|
+
if (!line.trim())
|
|
300
258
|
return null;
|
|
301
259
|
try {
|
|
302
|
-
return JSON.parse(
|
|
260
|
+
return JSON.parse(line);
|
|
303
261
|
}
|
|
304
262
|
catch {
|
|
305
|
-
|
|
263
|
+
// Skip malformed lines
|
|
264
|
+
return null;
|
|
306
265
|
}
|
|
307
266
|
}
|
|
308
267
|
/** Exported for testing */
|
|
@@ -316,7 +275,6 @@ export function loadEntriesFromFile(filePath) {
|
|
|
316
275
|
const decoder = new StringDecoder("utf8");
|
|
317
276
|
const buffer = Buffer.allocUnsafe(SESSION_READ_BUFFER_SIZE);
|
|
318
277
|
let pending = "";
|
|
319
|
-
let lineNumber = 0;
|
|
320
278
|
while (true) {
|
|
321
279
|
const bytesRead = readSync(fd, buffer, 0, buffer.length, null);
|
|
322
280
|
if (bytesRead === 0)
|
|
@@ -325,8 +283,7 @@ export function loadEntriesFromFile(filePath) {
|
|
|
325
283
|
let lineStart = 0;
|
|
326
284
|
let newlineIndex = pending.indexOf("\n", lineStart);
|
|
327
285
|
while (newlineIndex !== -1) {
|
|
328
|
-
|
|
329
|
-
const entry = parseSessionEntryLine(pending.slice(lineStart, newlineIndex), `in ${resolvedFilePath}:${lineNumber}`);
|
|
286
|
+
const entry = parseSessionEntryLine(pending.slice(lineStart, newlineIndex));
|
|
330
287
|
if (entry)
|
|
331
288
|
entries.push(entry);
|
|
332
289
|
lineStart = newlineIndex + 1;
|
|
@@ -335,12 +292,9 @@ export function loadEntriesFromFile(filePath) {
|
|
|
335
292
|
pending = pending.slice(lineStart);
|
|
336
293
|
}
|
|
337
294
|
pending += decoder.end();
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
if (finalEntry)
|
|
342
|
-
entries.push(finalEntry);
|
|
343
|
-
}
|
|
295
|
+
const finalEntry = parseSessionEntryLine(pending);
|
|
296
|
+
if (finalEntry)
|
|
297
|
+
entries.push(finalEntry);
|
|
344
298
|
}
|
|
345
299
|
finally {
|
|
346
300
|
closeSync(fd);
|
|
@@ -614,10 +568,7 @@ export class SessionManager {
|
|
|
614
568
|
return;
|
|
615
569
|
}
|
|
616
570
|
const header = this.fileEntries.find((e) => e.type === "session");
|
|
617
|
-
|
|
618
|
-
throw new Error(`Session file is not a valid pi session: ${this.sessionFile}`);
|
|
619
|
-
}
|
|
620
|
-
this.sessionId = header.id;
|
|
571
|
+
this.sessionId = header?.id ?? createSessionId();
|
|
621
572
|
if (migrateToCurrentVersion(this.fileEntries)) {
|
|
622
573
|
this._rewriteFile();
|
|
623
574
|
}
|
|
@@ -657,7 +608,6 @@ export class SessionManager {
|
|
|
657
608
|
return this.sessionFile;
|
|
658
609
|
}
|
|
659
610
|
_buildIndex() {
|
|
660
|
-
validateSessionGraph(this.fileEntries.filter((entry) => entry.type !== "session"));
|
|
661
611
|
this.byId.clear();
|
|
662
612
|
this.labelsById.clear();
|
|
663
613
|
this.labelTimestampsById.clear();
|
|
@@ -930,18 +880,10 @@ export class SessionManager {
|
|
|
930
880
|
*/
|
|
931
881
|
getBranch(fromId) {
|
|
932
882
|
const path = [];
|
|
933
|
-
const visited = new Set();
|
|
934
883
|
const startId = fromId ?? this.leafId;
|
|
935
884
|
let current = startId ? this.byId.get(startId) : undefined;
|
|
936
885
|
while (current) {
|
|
937
|
-
if (visited.has(current.id)) {
|
|
938
|
-
throw new Error(`Session graph is corrupt: parent cycle detected at entry "${current.id}"`);
|
|
939
|
-
}
|
|
940
|
-
visited.add(current.id);
|
|
941
886
|
path.push(current);
|
|
942
|
-
if (current.parentId && !this.byId.has(current.parentId)) {
|
|
943
|
-
throw new Error(`Session graph is corrupt: entry "${current.id}" has missing parent "${current.parentId}"`);
|
|
944
|
-
}
|
|
945
887
|
current = current.parentId ? this.byId.get(current.parentId) : undefined;
|
|
946
888
|
}
|
|
947
889
|
path.reverse();
|