@greppleai/grip 0.1.5 → 0.1.6

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.
Files changed (565) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +1 -1
  3. package/dist/bun/cli.d.ts.map +1 -1
  4. package/dist/bun/cli.js.map +1 -1
  5. package/dist/bun/embedded-assets.d.ts.map +1 -1
  6. package/dist/bun/embedded-assets.js.map +1 -1
  7. package/dist/bun/register-bedrock.d.ts.map +1 -1
  8. package/dist/bun/restore-sandbox-env.d.ts.map +1 -1
  9. package/dist/bun/restore-sandbox-env.js.map +1 -1
  10. package/dist/cli/args.d.ts.map +1 -1
  11. package/dist/cli/args.js.map +1 -1
  12. package/dist/cli/config-selector.d.ts.map +1 -1
  13. package/dist/cli/config-selector.js.map +1 -1
  14. package/dist/cli/file-processor.d.ts.map +1 -1
  15. package/dist/cli/file-processor.js.map +1 -1
  16. package/dist/cli/initial-message.d.ts +1 -1
  17. package/dist/cli/initial-message.d.ts.map +1 -1
  18. package/dist/cli/initial-message.js.map +1 -1
  19. package/dist/cli/list-models.d.ts.map +1 -1
  20. package/dist/cli/list-models.js.map +1 -1
  21. package/dist/cli/session-picker.d.ts.map +1 -1
  22. package/dist/cli/session-picker.js.map +1 -1
  23. package/dist/cli.d.ts.map +1 -1
  24. package/dist/cli.js.map +1 -1
  25. package/dist/config.d.ts.map +1 -1
  26. package/dist/config.js.map +1 -1
  27. package/dist/core/agent-session.d.ts +27 -0
  28. package/dist/core/agent-session.d.ts.map +1 -1
  29. package/dist/core/agent-session.js +117 -152
  30. package/dist/core/agent-session.js.map +1 -1
  31. package/dist/core/auth-guidance.d.ts.map +1 -1
  32. package/dist/core/auth-guidance.js.map +1 -1
  33. package/dist/core/auth-storage.d.ts +4 -0
  34. package/dist/core/auth-storage.d.ts.map +1 -1
  35. package/dist/core/auth-storage.js +3 -10
  36. package/dist/core/auth-storage.js.map +1 -1
  37. package/dist/core/bash-executor.d.ts.map +1 -1
  38. package/dist/core/bash-executor.js +19 -23
  39. package/dist/core/bash-executor.js.map +1 -1
  40. package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
  41. package/dist/core/compaction/branch-summarization.js.map +1 -1
  42. package/dist/core/compaction/compaction.d.ts.map +1 -1
  43. package/dist/core/compaction/compaction.js.map +1 -1
  44. package/dist/core/compaction/compression-detection-ledger.d.ts.map +1 -1
  45. package/dist/core/compaction/compression-detection-ledger.js.map +1 -1
  46. package/dist/core/compaction/compression-detector.d.ts +1 -0
  47. package/dist/core/compaction/compression-detector.d.ts.map +1 -1
  48. package/dist/core/compaction/compression-detector.js +10 -21
  49. package/dist/core/compaction/compression-detector.js.map +1 -1
  50. package/dist/core/compaction/compression-economics.d.ts.map +1 -1
  51. package/dist/core/compaction/compression-economics.js.map +1 -1
  52. package/dist/core/compaction/utils.d.ts.map +1 -1
  53. package/dist/core/compaction/utils.js.map +1 -1
  54. package/dist/core/defaults.d.ts.map +1 -1
  55. package/dist/core/diagnostics.d.ts.map +1 -1
  56. package/dist/core/event-bus.d.ts.map +1 -1
  57. package/dist/core/event-bus.js.map +1 -1
  58. package/dist/core/exec.d.ts.map +1 -1
  59. package/dist/core/exec.js.map +1 -1
  60. package/dist/core/export-html/ansi-to-html.d.ts.map +1 -1
  61. package/dist/core/export-html/ansi-to-html.js.map +1 -1
  62. package/dist/core/export-html/index.d.ts.map +1 -1
  63. package/dist/core/export-html/index.js.map +1 -1
  64. package/dist/core/export-html/tool-renderer.d.ts.map +1 -1
  65. package/dist/core/export-html/tool-renderer.js.map +1 -1
  66. package/dist/core/extensions/loader.d.ts.map +1 -1
  67. package/dist/core/extensions/loader.js.map +1 -1
  68. package/dist/core/extensions/runner.d.ts.map +1 -1
  69. package/dist/core/extensions/runner.js +18 -30
  70. package/dist/core/extensions/runner.js.map +1 -1
  71. package/dist/core/extensions/types.d.ts.map +1 -1
  72. package/dist/core/extensions/types.js.map +1 -1
  73. package/dist/core/extensions/wrapper.d.ts.map +1 -1
  74. package/dist/core/extensions/wrapper.js.map +1 -1
  75. package/dist/core/footer-data-provider.d.ts.map +1 -1
  76. package/dist/core/footer-data-provider.js +15 -16
  77. package/dist/core/footer-data-provider.js.map +1 -1
  78. package/dist/core/grip-agent.d.ts.map +1 -1
  79. package/dist/core/grip-agent.js +7 -21
  80. package/dist/core/grip-agent.js.map +1 -1
  81. package/dist/core/grip-manifest.d.ts.map +1 -1
  82. package/dist/core/grip-manifest.js.map +1 -1
  83. package/dist/core/hooks/aggregate.d.ts.map +1 -1
  84. package/dist/core/hooks/aggregate.js.map +1 -1
  85. package/dist/core/hooks/config.d.ts.map +1 -1
  86. package/dist/core/hooks/config.js.map +1 -1
  87. package/dist/core/hooks/executor.d.ts.map +1 -1
  88. package/dist/core/hooks/executor.js.map +1 -1
  89. package/dist/core/hooks/index.d.ts.map +1 -1
  90. package/dist/core/hooks/index.js.map +1 -1
  91. package/dist/core/hooks/matcher.d.ts.map +1 -1
  92. package/dist/core/hooks/matcher.js.map +1 -1
  93. package/dist/core/hooks/trust-store.d.ts.map +1 -1
  94. package/dist/core/hooks/trust-store.js +0 -3
  95. package/dist/core/hooks/trust-store.js.map +1 -1
  96. package/dist/core/hooks/types.d.ts.map +1 -1
  97. package/dist/core/hooks/types.js.map +1 -1
  98. package/dist/core/http-dispatcher.d.ts.map +1 -1
  99. package/dist/core/http-dispatcher.js.map +1 -1
  100. package/dist/core/instruction-resource-loader.d.ts.map +1 -1
  101. package/dist/core/instruction-resource-loader.js +0 -3
  102. package/dist/core/instruction-resource-loader.js.map +1 -1
  103. package/dist/core/keybindings.d.ts.map +1 -1
  104. package/dist/core/keybindings.js +0 -1
  105. package/dist/core/keybindings.js.map +1 -1
  106. package/dist/core/lsp/abort.d.ts.map +1 -1
  107. package/dist/core/lsp/abort.js.map +1 -1
  108. package/dist/core/lsp/client.d.ts.map +1 -1
  109. package/dist/core/lsp/client.js +8 -22
  110. package/dist/core/lsp/client.js.map +1 -1
  111. package/dist/core/lsp/config-loader.d.ts.map +1 -1
  112. package/dist/core/lsp/config-loader.js.map +1 -1
  113. package/dist/core/lsp/config.d.ts.map +1 -1
  114. package/dist/core/lsp/config.js.map +1 -1
  115. package/dist/core/lsp/diagnostics.d.ts.map +1 -1
  116. package/dist/core/lsp/diagnostics.js.map +1 -1
  117. package/dist/core/lsp/file-sync.d.ts.map +1 -1
  118. package/dist/core/lsp/file-sync.js +7 -9
  119. package/dist/core/lsp/file-sync.js.map +1 -1
  120. package/dist/core/lsp/integration.d.ts.map +1 -1
  121. package/dist/core/lsp/integration.js.map +1 -1
  122. package/dist/core/lsp/language-map.d.ts.map +1 -1
  123. package/dist/core/lsp/language-map.js +2 -7
  124. package/dist/core/lsp/language-map.js.map +1 -1
  125. package/dist/core/lsp/manager.d.ts.map +1 -1
  126. package/dist/core/lsp/manager.js +18 -29
  127. package/dist/core/lsp/manager.js.map +1 -1
  128. package/dist/core/lsp/navigation.d.ts.map +1 -1
  129. package/dist/core/lsp/navigation.js.map +1 -1
  130. package/dist/core/lsp/portable-path.d.ts.map +1 -1
  131. package/dist/core/lsp/portable-path.js.map +1 -1
  132. package/dist/core/lsp/refactor.d.ts.map +1 -1
  133. package/dist/core/lsp/refactor.js.map +1 -1
  134. package/dist/core/lsp/transport.d.ts.map +1 -1
  135. package/dist/core/lsp/transport.js.map +1 -1
  136. package/dist/core/messages.d.ts.map +1 -1
  137. package/dist/core/messages.js.map +1 -1
  138. package/dist/core/model-registry.d.ts.map +1 -1
  139. package/dist/core/model-registry.js +5 -7
  140. package/dist/core/model-registry.js.map +1 -1
  141. package/dist/core/model-resolver.d.ts.map +1 -1
  142. package/dist/core/model-resolver.js.map +1 -1
  143. package/dist/core/output-guard.d.ts.map +1 -1
  144. package/dist/core/output-guard.js.map +1 -1
  145. package/dist/core/package-manager.d.ts.map +1 -1
  146. package/dist/core/package-manager.js +0 -6
  147. package/dist/core/package-manager.js.map +1 -1
  148. package/dist/core/prompt-templates.d.ts.map +1 -1
  149. package/dist/core/prompt-templates.js.map +1 -1
  150. package/dist/core/provider-display-names.d.ts.map +1 -1
  151. package/dist/core/remote-workspace-protocol/contract.d.ts.map +1 -1
  152. package/dist/core/remote-workspace-protocol/contract.js +4 -2
  153. package/dist/core/remote-workspace-protocol/contract.js.map +1 -1
  154. package/dist/core/remote-workspace-protocol/guest-shared-client.d.ts.map +1 -1
  155. package/dist/core/remote-workspace-protocol/guest-shared-client.js +1 -5
  156. package/dist/core/remote-workspace-protocol/guest-shared-client.js.map +1 -1
  157. package/dist/core/remote-workspace-protocol/guest-shared-outbound-scheduler.d.ts.map +1 -1
  158. package/dist/core/remote-workspace-protocol/guest-shared-outbound-scheduler.js +5 -10
  159. package/dist/core/remote-workspace-protocol/guest-shared-outbound-scheduler.js.map +1 -1
  160. package/dist/core/remote-workspace-protocol/guest-shared-uplink.d.ts.map +1 -1
  161. package/dist/core/remote-workspace-protocol/guest-shared-uplink.js +2 -9
  162. package/dist/core/remote-workspace-protocol/guest-shared-uplink.js.map +1 -1
  163. package/dist/core/remote-workspace-protocol/lima-owner-directory.d.ts.map +1 -1
  164. package/dist/core/remote-workspace-protocol/lima-owner-directory.js.map +1 -1
  165. package/dist/core/remote-workspace-protocol/lima-owner-lock.d.ts.map +1 -1
  166. package/dist/core/remote-workspace-protocol/lima-owner-lock.js.map +1 -1
  167. package/dist/core/remote-workspace-protocol/session.d.ts.map +1 -1
  168. package/dist/core/remote-workspace-protocol/session.js +27 -65
  169. package/dist/core/remote-workspace-protocol/session.js.map +1 -1
  170. package/dist/core/remote-workspace-protocol/shared-transport.d.ts.map +1 -1
  171. package/dist/core/remote-workspace-protocol/shared-transport.js.map +1 -1
  172. package/dist/core/resolve-config-value.d.ts.map +1 -1
  173. package/dist/core/resolve-config-value.js.map +1 -1
  174. package/dist/core/resource-loader.d.ts.map +1 -1
  175. package/dist/core/resource-loader.js +0 -48
  176. package/dist/core/resource-loader.js.map +1 -1
  177. package/dist/core/rules.d.ts.map +1 -1
  178. package/dist/core/rules.js.map +1 -1
  179. package/dist/core/sandbox/command.d.ts.map +1 -1
  180. package/dist/core/sandbox/command.js.map +1 -1
  181. package/dist/core/sandbox/config.d.ts.map +1 -1
  182. package/dist/core/sandbox/config.js.map +1 -1
  183. package/dist/core/sandbox/lima-guest-binary.d.ts.map +1 -1
  184. package/dist/core/sandbox/lima-guest-binary.js.map +1 -1
  185. package/dist/core/sandbox/lima.d.ts +2 -0
  186. package/dist/core/sandbox/lima.d.ts.map +1 -1
  187. package/dist/core/sandbox/lima.js +3 -9
  188. package/dist/core/sandbox/lima.js.map +1 -1
  189. package/dist/core/sandbox/shared-lima-roots.d.ts.map +1 -1
  190. package/dist/core/sandbox/shared-lima-roots.js.map +1 -1
  191. package/dist/core/sandbox/update-shared-guest-binary.d.ts.map +1 -1
  192. package/dist/core/sandbox/update-shared-guest-binary.js.map +1 -1
  193. package/dist/core/session/constants.d.ts.map +1 -1
  194. package/dist/core/session/context-metadata.d.ts.map +1 -1
  195. package/dist/core/session/context-metadata.js.map +1 -1
  196. package/dist/core/session/context.d.ts.map +1 -1
  197. package/dist/core/session/context.js.map +1 -1
  198. package/dist/core/session/ids.d.ts.map +1 -1
  199. package/dist/core/session/ids.js.map +1 -1
  200. package/dist/core/session/in-memory-session-manager.d.ts.map +1 -1
  201. package/dist/core/session/in-memory-session-manager.js +0 -1
  202. package/dist/core/session/in-memory-session-manager.js.map +1 -1
  203. package/dist/core/session/in-memory-session.d.ts.map +1 -1
  204. package/dist/core/session/in-memory-session.js.map +1 -1
  205. package/dist/core/session/jsonl-errors.d.ts.map +1 -1
  206. package/dist/core/session/jsonl-errors.js +0 -11
  207. package/dist/core/session/jsonl-errors.js.map +1 -1
  208. package/dist/core/session/jsonl-helpers.d.ts.map +1 -1
  209. package/dist/core/session/jsonl-helpers.js.map +1 -1
  210. package/dist/core/session/local-session-manager.d.ts.map +1 -1
  211. package/dist/core/session/local-session-manager.js +4 -6
  212. package/dist/core/session/local-session-manager.js.map +1 -1
  213. package/dist/core/session/local-session.d.ts.map +1 -1
  214. package/dist/core/session/local-session.js.map +1 -1
  215. package/dist/core/session/migrations.d.ts.map +1 -1
  216. package/dist/core/session/migrations.js.map +1 -1
  217. package/dist/core/session/remote-session-client.d.ts.map +1 -1
  218. package/dist/core/session/remote-session-client.js +0 -6
  219. package/dist/core/session/remote-session-client.js.map +1 -1
  220. package/dist/core/session/remote-session-manager.d.ts.map +1 -1
  221. package/dist/core/session/remote-session-manager.js +0 -3
  222. package/dist/core/session/remote-session-manager.js.map +1 -1
  223. package/dist/core/session/remote-session.d.ts.map +1 -1
  224. package/dist/core/session/remote-session.js +0 -1
  225. package/dist/core/session/remote-session.js.map +1 -1
  226. package/dist/core/session/session-manager.d.ts.map +1 -1
  227. package/dist/core/session/session.d.ts.map +1 -1
  228. package/dist/core/session/session.js +1 -5
  229. package/dist/core/session/session.js.map +1 -1
  230. package/dist/core/session/stores/in-memory-session-store.d.ts.map +1 -1
  231. package/dist/core/session/stores/in-memory-session-store.js +7 -6
  232. package/dist/core/session/stores/in-memory-session-store.js.map +1 -1
  233. package/dist/core/session/stores/jsonl-session-store.d.ts.map +1 -1
  234. package/dist/core/session/stores/jsonl-session-store.js +6 -14
  235. package/dist/core/session/stores/jsonl-session-store.js.map +1 -1
  236. package/dist/core/session/stores/remote-session-store.d.ts.map +1 -1
  237. package/dist/core/session/stores/remote-session-store.js +3 -8
  238. package/dist/core/session/stores/remote-session-store.js.map +1 -1
  239. package/dist/core/session/stores/session-store.d.ts.map +1 -1
  240. package/dist/core/session/types.d.ts.map +1 -1
  241. package/dist/core/session/usage-ledger.d.ts.map +1 -1
  242. package/dist/core/session/usage-ledger.js.map +1 -1
  243. package/dist/core/session-cwd.d.ts.map +1 -1
  244. package/dist/core/session-cwd.js +0 -1
  245. package/dist/core/session-cwd.js.map +1 -1
  246. package/dist/core/settings-manager.d.ts.map +1 -1
  247. package/dist/core/settings-manager.js +9 -17
  248. package/dist/core/settings-manager.js.map +1 -1
  249. package/dist/core/skills.d.ts.map +1 -1
  250. package/dist/core/skills.js.map +1 -1
  251. package/dist/core/slash-commands.d.ts.map +1 -1
  252. package/dist/core/source-info.d.ts.map +1 -1
  253. package/dist/core/source-info.js.map +1 -1
  254. package/dist/core/system-prompt.d.ts.map +1 -1
  255. package/dist/core/system-prompt.js.map +1 -1
  256. package/dist/core/telemetry.d.ts.map +1 -1
  257. package/dist/core/telemetry.js.map +1 -1
  258. package/dist/core/timings.d.ts.map +1 -1
  259. package/dist/core/timings.js.map +1 -1
  260. package/dist/core/tools/bash.d.ts.map +1 -1
  261. package/dist/core/tools/bash.js +8 -5
  262. package/dist/core/tools/bash.js.map +1 -1
  263. package/dist/core/tools/compress-context.d.ts.map +1 -1
  264. package/dist/core/tools/compress-context.js.map +1 -1
  265. package/dist/core/tools/edit-diff.d.ts.map +1 -1
  266. package/dist/core/tools/edit-diff.js.map +1 -1
  267. package/dist/core/tools/edit.d.ts.map +1 -1
  268. package/dist/core/tools/edit.js.map +1 -1
  269. package/dist/core/tools/file-mutation-queue.d.ts.map +1 -1
  270. package/dist/core/tools/file-mutation-queue.js.map +1 -1
  271. package/dist/core/tools/find.d.ts.map +1 -1
  272. package/dist/core/tools/find.js.map +1 -1
  273. package/dist/core/tools/grep.d.ts.map +1 -1
  274. package/dist/core/tools/grep.js.map +1 -1
  275. package/dist/core/tools/hash-store.d.ts.map +1 -1
  276. package/dist/core/tools/hash-store.js.map +1 -1
  277. package/dist/core/tools/hashline/apply.d.ts.map +1 -1
  278. package/dist/core/tools/hashline/apply.js.map +1 -1
  279. package/dist/core/tools/hashline/hash.d.ts.map +1 -1
  280. package/dist/core/tools/hashline/hash.js.map +1 -1
  281. package/dist/core/tools/hashline/parse.d.ts.map +1 -1
  282. package/dist/core/tools/hashline/parse.js.map +1 -1
  283. package/dist/core/tools/hashline/resolve.d.ts.map +1 -1
  284. package/dist/core/tools/hashline/resolve.js.map +1 -1
  285. package/dist/core/tools/hashline-utils.d.ts.map +1 -1
  286. package/dist/core/tools/hashline-utils.js.map +1 -1
  287. package/dist/core/tools/index.d.ts.map +1 -1
  288. package/dist/core/tools/index.js.map +1 -1
  289. package/dist/core/tools/ls.d.ts.map +1 -1
  290. package/dist/core/tools/ls.js.map +1 -1
  291. package/dist/core/tools/operations.d.ts +5 -0
  292. package/dist/core/tools/operations.d.ts.map +1 -1
  293. package/dist/core/tools/operations.js +26 -24
  294. package/dist/core/tools/operations.js.map +1 -1
  295. package/dist/core/tools/output-accumulator.d.ts.map +1 -1
  296. package/dist/core/tools/output-accumulator.js +12 -18
  297. package/dist/core/tools/output-accumulator.js.map +1 -1
  298. package/dist/core/tools/path-utils.d.ts.map +1 -1
  299. package/dist/core/tools/path-utils.js.map +1 -1
  300. package/dist/core/tools/read.d.ts.map +1 -1
  301. package/dist/core/tools/read.js.map +1 -1
  302. package/dist/core/tools/render-utils.d.ts.map +1 -1
  303. package/dist/core/tools/render-utils.js.map +1 -1
  304. package/dist/core/tools/replace-diff.d.ts.map +1 -1
  305. package/dist/core/tools/replace-diff.js.map +1 -1
  306. package/dist/core/tools/replace-normalize.d.ts.map +1 -1
  307. package/dist/core/tools/replace-normalize.js.map +1 -1
  308. package/dist/core/tools/replace-render.d.ts +1 -1
  309. package/dist/core/tools/replace-render.d.ts.map +1 -1
  310. package/dist/core/tools/replace-render.js.map +1 -1
  311. package/dist/core/tools/runtime.d.ts.map +1 -1
  312. package/dist/core/tools/runtime.js.map +1 -1
  313. package/dist/core/tools/session-history.d.ts.map +1 -1
  314. package/dist/core/tools/session-history.js.map +1 -1
  315. package/dist/core/tools/subagent-agents.d.ts.map +1 -1
  316. package/dist/core/tools/subagent-agents.js.map +1 -1
  317. package/dist/core/tools/subagent.d.ts.map +1 -1
  318. package/dist/core/tools/subagent.js.map +1 -1
  319. package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
  320. package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
  321. package/dist/core/tools/truncate.d.ts.map +1 -1
  322. package/dist/core/tools/truncate.js.map +1 -1
  323. package/dist/core/tools/websearch.d.ts.map +1 -1
  324. package/dist/core/tools/websearch.js.map +1 -1
  325. package/dist/core/tools/workspace-tool-host.d.ts +1 -0
  326. package/dist/core/tools/workspace-tool-host.d.ts.map +1 -1
  327. package/dist/core/tools/workspace-tool-host.js +36 -22
  328. package/dist/core/tools/workspace-tool-host.js.map +1 -1
  329. package/dist/core/tools/write.d.ts.map +1 -1
  330. package/dist/core/tools/write.js +0 -1
  331. package/dist/core/tools/write.js.map +1 -1
  332. package/dist/core/workspace-identity.d.ts.map +1 -1
  333. package/dist/daemon/activity-budget.d.ts.map +1 -1
  334. package/dist/daemon/activity-budget.js +2 -3
  335. package/dist/daemon/activity-budget.js.map +1 -1
  336. package/dist/daemon/command.d.ts.map +1 -1
  337. package/dist/daemon/command.js.map +1 -1
  338. package/dist/daemon/config.d.ts +2 -0
  339. package/dist/daemon/config.d.ts.map +1 -1
  340. package/dist/daemon/config.js +4 -0
  341. package/dist/daemon/config.js.map +1 -1
  342. package/dist/daemon/help.d.ts.map +1 -1
  343. package/dist/daemon/help.js +4 -3
  344. package/dist/daemon/help.js.map +1 -1
  345. package/dist/daemon/lsp-config.d.ts.map +1 -1
  346. package/dist/daemon/lsp-config.js.map +1 -1
  347. package/dist/daemon/outbound-budget.d.ts.map +1 -1
  348. package/dist/daemon/outbound-budget.js +2 -4
  349. package/dist/daemon/outbound-budget.js.map +1 -1
  350. package/dist/daemon/security.d.ts.map +1 -1
  351. package/dist/daemon/security.js.map +1 -1
  352. package/dist/daemon/server.d.ts.map +1 -1
  353. package/dist/daemon/server.js.map +1 -1
  354. package/dist/daemon/shared-connection.d.ts.map +1 -1
  355. package/dist/daemon/shared-connection.js +10 -15
  356. package/dist/daemon/shared-connection.js.map +1 -1
  357. package/dist/daemon/shared-revision.d.ts.map +1 -1
  358. package/dist/daemon/shared-revision.js +2 -1
  359. package/dist/daemon/shared-revision.js.map +1 -1
  360. package/dist/daemon/shared-roots.d.ts.map +1 -1
  361. package/dist/daemon/shared-roots.js +0 -1
  362. package/dist/daemon/shared-roots.js.map +1 -1
  363. package/dist/daemon/workspace-runtime.d.ts +2 -0
  364. package/dist/daemon/workspace-runtime.d.ts.map +1 -1
  365. package/dist/daemon/workspace-runtime.js +43 -15
  366. package/dist/daemon/workspace-runtime.js.map +1 -1
  367. package/dist/index.d.ts.map +1 -1
  368. package/dist/main.d.ts.map +1 -1
  369. package/dist/main.js.map +1 -1
  370. package/dist/migrations.d.ts.map +1 -1
  371. package/dist/migrations.js.map +1 -1
  372. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  373. package/dist/modes/interactive/components/assistant-message.js +3 -10
  374. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  375. package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
  376. package/dist/modes/interactive/components/bash-execution.js +4 -9
  377. package/dist/modes/interactive/components/bash-execution.js.map +1 -1
  378. package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -1
  379. package/dist/modes/interactive/components/bordered-loader.js +0 -3
  380. package/dist/modes/interactive/components/bordered-loader.js.map +1 -1
  381. package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
  382. package/dist/modes/interactive/components/branch-summary-message.js +1 -3
  383. package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
  384. package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
  385. package/dist/modes/interactive/components/compaction-summary-message.js +1 -3
  386. package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
  387. package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
  388. package/dist/modes/interactive/components/config-selector.js +6 -16
  389. package/dist/modes/interactive/components/config-selector.js.map +1 -1
  390. package/dist/modes/interactive/components/countdown-timer.d.ts.map +1 -1
  391. package/dist/modes/interactive/components/countdown-timer.js +0 -5
  392. package/dist/modes/interactive/components/countdown-timer.js.map +1 -1
  393. package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
  394. package/dist/modes/interactive/components/custom-editor.js +1 -8
  395. package/dist/modes/interactive/components/custom-editor.js.map +1 -1
  396. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
  397. package/dist/modes/interactive/components/custom-message.js +1 -6
  398. package/dist/modes/interactive/components/custom-message.js.map +1 -1
  399. package/dist/modes/interactive/components/diff.d.ts.map +1 -1
  400. package/dist/modes/interactive/components/diff.js.map +1 -1
  401. package/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -1
  402. package/dist/modes/interactive/components/dynamic-border.js +0 -1
  403. package/dist/modes/interactive/components/dynamic-border.js.map +1 -1
  404. package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
  405. package/dist/modes/interactive/components/extension-editor.js +1 -7
  406. package/dist/modes/interactive/components/extension-editor.js.map +1 -1
  407. package/dist/modes/interactive/components/extension-input.d.ts.map +1 -1
  408. package/dist/modes/interactive/components/extension-input.js +2 -8
  409. package/dist/modes/interactive/components/extension-input.js.map +1 -1
  410. package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -1
  411. package/dist/modes/interactive/components/extension-selector.js +1 -9
  412. package/dist/modes/interactive/components/extension-selector.js.map +1 -1
  413. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  414. package/dist/modes/interactive/components/footer.js +1 -3
  415. package/dist/modes/interactive/components/footer.js.map +1 -1
  416. package/dist/modes/interactive/components/hook-execution.d.ts.map +1 -1
  417. package/dist/modes/interactive/components/hook-execution.js +2 -5
  418. package/dist/modes/interactive/components/hook-execution.js.map +1 -1
  419. package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -1
  420. package/dist/modes/interactive/components/keybinding-hints.js.map +1 -1
  421. package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
  422. package/dist/modes/interactive/components/login-dialog.js +3 -9
  423. package/dist/modes/interactive/components/login-dialog.js.map +1 -1
  424. package/dist/modes/interactive/components/markdown-transform.d.ts.map +1 -1
  425. package/dist/modes/interactive/components/markdown-transform.js.map +1 -1
  426. package/dist/modes/interactive/components/mermaid.d.ts.map +1 -1
  427. package/dist/modes/interactive/components/mermaid.js.map +1 -1
  428. package/dist/modes/interactive/components/message-card.d.ts.map +1 -1
  429. package/dist/modes/interactive/components/message-card.js +0 -1
  430. package/dist/modes/interactive/components/message-card.js.map +1 -1
  431. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  432. package/dist/modes/interactive/components/model-selector.js +13 -28
  433. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  434. package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
  435. package/dist/modes/interactive/components/oauth-selector.js +3 -12
  436. package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
  437. package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
  438. package/dist/modes/interactive/components/scoped-models-selector.js +9 -13
  439. package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
  440. package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -1
  441. package/dist/modes/interactive/components/session-selector-search.js.map +1 -1
  442. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
  443. package/dist/modes/interactive/components/session-selector.js +33 -58
  444. package/dist/modes/interactive/components/session-selector.js.map +1 -1
  445. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  446. package/dist/modes/interactive/components/settings-selector.js +0 -4
  447. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  448. package/dist/modes/interactive/components/show-images-selector.d.ts.map +1 -1
  449. package/dist/modes/interactive/components/show-images-selector.js +0 -1
  450. package/dist/modes/interactive/components/show-images-selector.js.map +1 -1
  451. package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
  452. package/dist/modes/interactive/components/skill-invocation-message.js +1 -3
  453. package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
  454. package/dist/modes/interactive/components/theme-selector.d.ts.map +1 -1
  455. package/dist/modes/interactive/components/theme-selector.js +0 -2
  456. package/dist/modes/interactive/components/theme-selector.js.map +1 -1
  457. package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
  458. package/dist/modes/interactive/components/thinking-selector.js +0 -1
  459. package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
  460. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  461. package/dist/modes/interactive/components/tool-execution.js +9 -24
  462. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  463. package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
  464. package/dist/modes/interactive/components/tree-selector.js +18 -34
  465. package/dist/modes/interactive/components/tree-selector.js.map +1 -1
  466. package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -1
  467. package/dist/modes/interactive/components/user-message-selector.js +3 -6
  468. package/dist/modes/interactive/components/user-message-selector.js.map +1 -1
  469. package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
  470. package/dist/modes/interactive/components/user-message.js +0 -4
  471. package/dist/modes/interactive/components/user-message.js.map +1 -1
  472. package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -1
  473. package/dist/modes/interactive/components/visual-truncate.js.map +1 -1
  474. package/dist/modes/interactive/interactive-mode.d.ts +14 -0
  475. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  476. package/dist/modes/interactive/interactive-mode.js +159 -135
  477. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  478. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  479. package/dist/modes/interactive/theme/theme.js +0 -7
  480. package/dist/modes/interactive/theme/theme.js.map +1 -1
  481. package/dist/modes/json-event.d.ts.map +1 -1
  482. package/dist/modes/json-event.js.map +1 -1
  483. package/dist/modes/print-mode.d.ts.map +1 -1
  484. package/dist/modes/print-mode.js.map +1 -1
  485. package/dist/modes/rpc/jsonl.d.ts.map +1 -1
  486. package/dist/modes/rpc/jsonl.js.map +1 -1
  487. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  488. package/dist/modes/rpc/rpc-client.js +10 -11
  489. package/dist/modes/rpc/rpc-client.js.map +1 -1
  490. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  491. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  492. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  493. package/dist/package-manager-cli.d.ts.map +1 -1
  494. package/dist/package-manager-cli.js.map +1 -1
  495. package/dist/utils/ansi.d.ts.map +1 -1
  496. package/dist/utils/ansi.js.map +1 -1
  497. package/dist/utils/changelog.d.ts.map +1 -1
  498. package/dist/utils/changelog.js.map +1 -1
  499. package/dist/utils/child-process.d.ts.map +1 -1
  500. package/dist/utils/child-process.js.map +1 -1
  501. package/dist/utils/clipboard-image.d.ts.map +1 -1
  502. package/dist/utils/clipboard-image.js.map +1 -1
  503. package/dist/utils/clipboard-native.d.ts.map +1 -1
  504. package/dist/utils/clipboard-native.js.map +1 -1
  505. package/dist/utils/clipboard.d.ts.map +1 -1
  506. package/dist/utils/clipboard.js.map +1 -1
  507. package/dist/utils/deprecation.d.ts.map +1 -1
  508. package/dist/utils/deprecation.js.map +1 -1
  509. package/dist/utils/directory-completions.d.ts.map +1 -1
  510. package/dist/utils/directory-completions.js.map +1 -1
  511. package/dist/utils/exif-orientation.d.ts.map +1 -1
  512. package/dist/utils/exif-orientation.js.map +1 -1
  513. package/dist/utils/frontmatter.d.ts.map +1 -1
  514. package/dist/utils/frontmatter.js.map +1 -1
  515. package/dist/utils/fs-watch.d.ts.map +1 -1
  516. package/dist/utils/fs-watch.js.map +1 -1
  517. package/dist/utils/git.d.ts.map +1 -1
  518. package/dist/utils/git.js.map +1 -1
  519. package/dist/utils/grip-user-agent.d.ts.map +1 -1
  520. package/dist/utils/grip-user-agent.js.map +1 -1
  521. package/dist/utils/html.d.ts.map +1 -1
  522. package/dist/utils/html.js.map +1 -1
  523. package/dist/utils/image-convert.d.ts.map +1 -1
  524. package/dist/utils/image-convert.js.map +1 -1
  525. package/dist/utils/image-process.d.ts.map +1 -1
  526. package/dist/utils/image-process.js.map +1 -1
  527. package/dist/utils/image-resize-core.d.ts.map +1 -1
  528. package/dist/utils/image-resize-core.js.map +1 -1
  529. package/dist/utils/image-resize-worker.d.ts.map +1 -1
  530. package/dist/utils/image-resize-worker.js.map +1 -1
  531. package/dist/utils/image-resize.d.ts.map +1 -1
  532. package/dist/utils/image-resize.js.map +1 -1
  533. package/dist/utils/json.d.ts.map +1 -1
  534. package/dist/utils/json.js.map +1 -1
  535. package/dist/utils/mime.d.ts.map +1 -1
  536. package/dist/utils/mime.js.map +1 -1
  537. package/dist/utils/open-browser.d.ts.map +1 -1
  538. package/dist/utils/open-browser.js.map +1 -1
  539. package/dist/utils/paths.d.ts.map +1 -1
  540. package/dist/utils/paths.js.map +1 -1
  541. package/dist/utils/photon.d.ts.map +1 -1
  542. package/dist/utils/photon.js +10 -5
  543. package/dist/utils/photon.js.map +1 -1
  544. package/dist/utils/shell.d.ts.map +1 -1
  545. package/dist/utils/shell.js.map +1 -1
  546. package/dist/utils/sleep.d.ts.map +1 -1
  547. package/dist/utils/sleep.js.map +1 -1
  548. package/dist/utils/syntax-highlight.d.ts.map +1 -1
  549. package/dist/utils/syntax-highlight.js +1 -1
  550. package/dist/utils/syntax-highlight.js.map +1 -1
  551. package/dist/utils/tools-manager.d.ts.map +1 -1
  552. package/dist/utils/tools-manager.js.map +1 -1
  553. package/dist/utils/version-check.d.ts.map +1 -1
  554. package/dist/utils/version-check.js.map +1 -1
  555. package/dist/utils/windows-self-update.d.ts.map +1 -1
  556. package/dist/utils/windows-self-update.js.map +1 -1
  557. package/docs/sandbox.md +6 -0
  558. package/docs/sessions.md +1 -1
  559. package/docs/usage.md +2 -1
  560. package/examples/extensions/custom-provider-anthropic/package.json +2 -2
  561. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  562. package/examples/extensions/sandbox/package.json +2 -2
  563. package/examples/extensions/with-deps/package.json +1 -1
  564. package/npm-shrinkwrap.json +601 -833
  565. package/package.json +20 -21
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/core/session/context.ts"],"names":[],"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AAE,KAAK,EAAE,IAAI,EAAE,CAAC;IAEhF,MAAM,WAAW,GAAG,IAAI,IAAI,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IAC/E,MAAM,aAAa,GAAG,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACnE,MAAM,IAAI,GAAG,aAAa,IAAI,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAC1D,IAAI,CAAC,IAAI;QAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;IAEtE,MAAM,IAAI,GAAG,gBAAgB,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;IACjD,MAAM,EAAE,aAAa,EAAE,KAAK,EAAE,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAC;IAC1D,MAAM,QAAQ,GAAG,4BAA4B,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,6BAA6B,CAAC,CAAC;IAC3F,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC;AAAA,CAC1C","sourcesContent":["import type { AgentMessage } from \"@greppleai/grip-agent-core\";\nimport {\n\tcreateBranchSummaryMessage,\n\tcreateCompactionSummaryMessage,\n\tcreateCustomMessage,\n\tnormalizeMessageContent,\n} from \"../messages.ts\";\nimport type { CompactionEntry, SessionContext, SessionEntry } from \"./types.ts\";\n\nexport function getLatestCompactionEntry(entries: SessionEntry[]): CompactionEntry | null {\n\tfor (let i = entries.length - 1; i >= 0; i--) {\n\t\tif (entries[i].type === \"compaction\") {\n\t\t\treturn entries[i] as CompactionEntry;\n\t\t}\n\t}\n\treturn null;\n}\n\n/** Project one persisted session entry into runtime context messages. */\nexport function sessionEntryToContextMessages(entry: SessionEntry): AgentMessage[] {\n\tif (entry.type === \"message\") {\n\t\treturn [normalizeMessageContent(entry.message)];\n\t}\n\tif (entry.type === \"custom_message\") {\n\t\treturn [createCustomMessage(entry.customType, entry.content, entry.display, entry.details, entry.timestamp)];\n\t}\n\tif (entry.type === \"branch_summary\" && entry.summary) {\n\t\treturn [createBranchSummaryMessage(entry.summary, entry.fromId, entry.timestamp)];\n\t}\n\tif (entry.type === \"compaction\" && entry.summary) {\n\t\treturn [createCompactionSummaryMessage(entry.summary, entry.tokensBefore, entry.timestamp)];\n\t}\n\treturn [];\n}\n\n// grip-ignore noNearIdenticalDataStructures: Coding-agent persisted entries and agent harness storage entries use package-owned context pipelines that evolve independently.\ninterface SessionPathState {\n\tthinkingLevel: string;\n\tmodel: SessionContext[\"model\"];\n}\n\nfunction traceSessionPath(leaf: SessionEntry, byId: Map<string, SessionEntry>): SessionEntry[] {\n\tconst path: SessionEntry[] = [];\n\tlet current: SessionEntry | undefined = leaf;\n\twhile (current) {\n\t\tpath.unshift(current);\n\t\tcurrent = current.parentId ? byId.get(current.parentId) : undefined;\n\t}\n\treturn path;\n}\n\nfunction inspectSessionPath(path: SessionEntry[]): SessionPathState {\n\tlet thinkingLevel = \"off\";\n\tlet model: SessionContext[\"model\"] = null;\n\tfor (const entry of path) {\n\t\tswitch (entry.type) {\n\t\t\tcase \"thinking_level_change\":\n\t\t\t\tthinkingLevel = entry.thinkingLevel;\n\t\t\t\tbreak;\n\t\t\tcase \"model_change\":\n\t\t\t\tmodel = { provider: entry.provider, modelId: entry.modelId };\n\t\t\t\tbreak;\n\t\t\tcase \"message\":\n\t\t\t\tif (entry.message.role === \"assistant\") {\n\t\t\t\t\tmodel = { provider: entry.message.provider, modelId: entry.message.model };\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t}\n\t}\n\treturn { thinkingLevel, model };\n}\nfunction applyCompressionReplacement(visible: SessionEntry[], entry: SessionEntry): boolean {\n\tif (entry.type !== \"custom_message\" || entry.customType !== \"compress_context\") return false;\n\tconst details = entry.details;\n\tif (\n\t\t!details ||\n\t\ttypeof details !== \"object\" ||\n\t\t!(\"replacementVersion\" in details) ||\n\t\tdetails.replacementVersion !== 1\n\t)\n\t\treturn false;\n\tconst startEntryId = \"startEntryId\" in details ? details.startEntryId : undefined;\n\tconst endEntryId = \"endEntryId\" in details ? details.endEntryId : undefined;\n\tif (typeof startEntryId !== \"string\" || typeof endEntryId !== \"string\") return false;\n\tconst startIndex = visible.findIndex((candidate) => candidate.id === startEntryId);\n\tconst endIndex = visible.findIndex((candidate) => candidate.id === endEntryId);\n\tif (startIndex < 0 || endIndex < startIndex) return false;\n\tvisible.splice(startIndex, endIndex - startIndex + 1, entry);\n\treturn true;\n}\n\n/** Return entries in model-visible order, applying append-only range replacements at their declared positions. */\nexport function projectSessionContextEntries(path: SessionEntry[]): SessionEntry[] {\n\tconst compaction = getLatestCompactionEntry(path);\n\tconst compactionIndex = compaction ? path.findIndex((entry) => entry.id === compaction.id) : -1;\n\tconst firstKeptIndex = compaction\n\t\t? path.findIndex((entry, index) => index < compactionIndex && entry.id === compaction.firstKeptEntryId)\n\t\t: -1;\n\tconst ordered = compaction\n\t\t? [\n\t\t\t\tcompaction,\n\t\t\t\t...(firstKeptIndex < 0 ? [] : path.slice(firstKeptIndex, compactionIndex)),\n\t\t\t\t...path.slice(compactionIndex + 1),\n\t\t\t]\n\t\t: path;\n\tconst visible: SessionEntry[] = [];\n\tfor (const entry of ordered) {\n\t\tif (entry.type === \"compaction\" && entry.id !== compaction?.id) continue;\n\t\tif (applyCompressionReplacement(visible, entry)) continue;\n\t\tvisible.push(entry);\n\t}\n\treturn visible;\n}\n\n/**\n * Build the session context from entries using tree traversal.\n * If leafId is provided, walks from that entry to root.\n * Handles compaction and branch summaries along the path.\n */\nexport function buildSessionContext(\n\tentries: SessionEntry[],\n\tleafId?: string | null,\n\tbyId?: Map<string, SessionEntry>,\n): SessionContext {\n\tif (leafId === null) return { messages: [], thinkingLevel: \"off\", model: null };\n\n\tconst entriesById = byId ?? new Map(entries.map((entry) => [entry.id, entry]));\n\tconst requestedLeaf = leafId ? entriesById.get(leafId) : undefined;\n\tconst leaf = requestedLeaf ?? entries[entries.length - 1];\n\tif (!leaf) return { messages: [], thinkingLevel: \"off\", model: null };\n\n\tconst path = traceSessionPath(leaf, entriesById);\n\tconst { thinkingLevel, model } = inspectSessionPath(path);\n\tconst messages = projectSessionContextEntries(path).flatMap(sessionEntryToContextMessages);\n\treturn { messages, thinkingLevel, model };\n}\n"]}
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/core/session/context.ts"],"names":[],"mappings":"AACA,OAAO,EACN,0BAA0B,EAC1B,8BAA8B,EAC9B,mBAAmB,EACnB,uBAAuB,GACvB,MAAM,gBAAgB,CAAC;AAGxB,MAAM,UAAU,wBAAwB,CAAC,OAAuB;IAC/D,KAAK,IAAI,CAAC,GAAG,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC9C,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;YACtC,OAAO,OAAO,CAAC,CAAC,CAAoB,CAAC;QACtC,CAAC;IACF,CAAC;IACD,OAAO,IAAI,CAAC;AACb,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,6BAA6B,CAAC,KAAmB;IAChE,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAC9B,OAAO,CAAC,uBAAuB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;IACjD,CAAC;IACD,IAAI,KAAK,CAAC,IAAI,KAAK,gBAAgB,EAAE,CAAC;QACrC,OAAO,CAAC,mBAAmB,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC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{ AgentMessage } from \"@greppleai/grip-agent-core\";\nimport {\n\tcreateBranchSummaryMessage,\n\tcreateCompactionSummaryMessage,\n\tcreateCustomMessage,\n\tnormalizeMessageContent,\n} from \"../messages.ts\";\nimport type { CompactionEntry, SessionContext, SessionEntry } from \"./types.ts\";\n\nexport function getLatestCompactionEntry(entries: SessionEntry[]): CompactionEntry | null {\n\tfor (let i = entries.length - 1; i >= 0; i--) {\n\t\tif (entries[i].type === \"compaction\") {\n\t\t\treturn entries[i] as CompactionEntry;\n\t\t}\n\t}\n\treturn null;\n}\n\n/** Project one persisted session entry into runtime context messages. */\nexport function sessionEntryToContextMessages(entry: SessionEntry): AgentMessage[] {\n\tif (entry.type === \"message\") {\n\t\treturn [normalizeMessageContent(entry.message)];\n\t}\n\tif (entry.type === \"custom_message\") {\n\t\treturn [createCustomMessage(entry.customType, entry.content, entry.display, entry.details, entry.timestamp)];\n\t}\n\tif (entry.type === \"branch_summary\" && entry.summary) {\n\t\treturn [createBranchSummaryMessage(entry.summary, entry.fromId, entry.timestamp)];\n\t}\n\tif (entry.type === \"compaction\" && entry.summary) {\n\t\treturn [createCompactionSummaryMessage(entry.summary, entry.tokensBefore, entry.timestamp)];\n\t}\n\treturn [];\n}\n\n// grip-ignore noNearIdenticalDataStructures: Coding-agent persisted entries and agent harness storage entries use package-owned context pipelines that evolve independently.\ninterface SessionPathState {\n\tthinkingLevel: string;\n\tmodel: SessionContext[\"model\"];\n}\n\nfunction traceSessionPath(leaf: SessionEntry, byId: Map<string, SessionEntry>): SessionEntry[] {\n\tconst path: SessionEntry[] = [];\n\tlet current: SessionEntry | undefined = leaf;\n\twhile (current) {\n\t\tpath.unshift(current);\n\t\tcurrent = current.parentId ? byId.get(current.parentId) : undefined;\n\t}\n\treturn path;\n}\n\nfunction inspectSessionPath(path: SessionEntry[]): SessionPathState {\n\tlet thinkingLevel = \"off\";\n\tlet model: SessionContext[\"model\"] = null;\n\tfor (const entry of path) {\n\t\tswitch (entry.type) {\n\t\t\tcase \"thinking_level_change\":\n\t\t\t\tthinkingLevel = entry.thinkingLevel;\n\t\t\t\tbreak;\n\t\t\tcase \"model_change\":\n\t\t\t\tmodel = { provider: entry.provider, modelId: entry.modelId };\n\t\t\t\tbreak;\n\t\t\tcase \"message\":\n\t\t\t\tif (entry.message.role === \"assistant\") {\n\t\t\t\t\tmodel = { provider: entry.message.provider, modelId: entry.message.model };\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t}\n\t}\n\treturn { thinkingLevel, model };\n}\nfunction applyCompressionReplacement(visible: SessionEntry[], entry: SessionEntry): boolean {\n\tif (entry.type !== \"custom_message\" || entry.customType !== \"compress_context\") return false;\n\tconst details = entry.details;\n\tif (\n\t\t!details ||\n\t\ttypeof details !== \"object\" ||\n\t\t!(\"replacementVersion\" in details) ||\n\t\tdetails.replacementVersion !== 1\n\t)\n\t\treturn false;\n\tconst startEntryId = \"startEntryId\" in details ? details.startEntryId : undefined;\n\tconst endEntryId = \"endEntryId\" in details ? details.endEntryId : undefined;\n\tif (typeof startEntryId !== \"string\" || typeof endEntryId !== \"string\") return false;\n\tconst startIndex = visible.findIndex((candidate) => candidate.id === startEntryId);\n\tconst endIndex = visible.findIndex((candidate) => candidate.id === endEntryId);\n\tif (startIndex < 0 || endIndex < startIndex) return false;\n\tvisible.splice(startIndex, endIndex - startIndex + 1, entry);\n\treturn true;\n}\n\n/** Return entries in model-visible order, applying append-only range replacements at their declared positions. */\nexport function projectSessionContextEntries(path: SessionEntry[]): SessionEntry[] {\n\tconst compaction = getLatestCompactionEntry(path);\n\tconst compactionIndex = compaction ? path.findIndex((entry) => entry.id === compaction.id) : -1;\n\tconst firstKeptIndex = compaction\n\t\t? path.findIndex((entry, index) => index < compactionIndex && entry.id === compaction.firstKeptEntryId)\n\t\t: -1;\n\tconst ordered = compaction\n\t\t? [\n\t\t\t\tcompaction,\n\t\t\t\t...(firstKeptIndex < 0 ? [] : path.slice(firstKeptIndex, compactionIndex)),\n\t\t\t\t...path.slice(compactionIndex + 1),\n\t\t\t]\n\t\t: path;\n\tconst visible: SessionEntry[] = [];\n\tfor (const entry of ordered) {\n\t\tif (entry.type === \"compaction\" && entry.id !== compaction?.id) continue;\n\t\tif (applyCompressionReplacement(visible, entry)) continue;\n\t\tvisible.push(entry);\n\t}\n\treturn visible;\n}\n\n/**\n * Build the session context from entries using tree traversal.\n * If leafId is provided, walks from that entry to root.\n * Handles compaction and branch summaries along the path.\n */\nexport function buildSessionContext(\n\tentries: SessionEntry[],\n\tleafId?: string | null,\n\tbyId?: Map<string, SessionEntry>,\n): SessionContext {\n\tif (leafId === null) return { messages: [], thinkingLevel: \"off\", model: null };\n\n\tconst entriesById = byId ?? new Map(entries.map((entry) => [entry.id, entry]));\n\tconst requestedLeaf = leafId ? entriesById.get(leafId) : undefined;\n\tconst leaf = requestedLeaf ?? entries[entries.length - 1];\n\tif (!leaf) return { messages: [], thinkingLevel: \"off\", model: null };\n\n\tconst path = traceSessionPath(leaf, entriesById);\n\tconst { thinkingLevel, model } = inspectSessionPath(path);\n\tconst messages = projectSessionContextEntries(path).flatMap(sessionEntryToContextMessages);\n\treturn { messages, thinkingLevel, model };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ids.d.ts","sourceRoot":"","sources":["../../../src/core/session/ids.ts"],"names":[],"mappings":"AAKA,UAAU,oBAAoB;IAC7B,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;CACzB;AAED,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAMlD;AAED,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAED,mEAAmE;AACnE,wBAAgB,UAAU,CAAC,IAAI,EAAE,oBAAoB,GAAG,MAAM,CAM7D","sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport { uuidv7 } from \"@greppleai/grip-agent-core\";\n\nconst SESSION_ID_PATTERN = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;\n\ninterface SessionEntryIdLookup {\n\thas(id: string): boolean;\n}\n\nexport function validateSessionId(id: string): void {\n\tif (!SESSION_ID_PATTERN.test(id)) {\n\t\tthrow new Error(\n\t\t\t\"Session id must be non-empty, contain only alphanumeric characters, '-', '_', and '.', and start and end with an alphanumeric character\",\n\t\t);\n\t}\n}\n\nexport function createSessionId(): string {\n\treturn uuidv7();\n}\n\n/** Generate a unique short ID (8 hex chars, collision-checked). */\nexport function generateId(byId: SessionEntryIdLookup): string {\n\tfor (let i = 0; i < 100; i++) {\n\t\tconst id = randomUUID().slice(0, 8);\n\t\tif (!byId.has(id)) return id;\n\t}\n\treturn randomUUID();\n}\n"]}
1
+ {"version":3,"file":"ids.d.ts","sourceRoot":"","sources":["../../../src/core/session/ids.ts"],"names":[],"mappings":"AAKA,UAAU,oBAAoB;IAC7B,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;CACzB;AAED,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAMlD;AAED,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAED,mEAAmE;AACnE,wBAAgB,UAAU,CAAC,IAAI,EAAE,oBAAoB,GAAG,MAAM,CAM7D"}
@@ -1 +1 @@
1
- {"version":3,"file":"ids.js","sourceRoot":"","sources":["../../../src/core/session/ids.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAEpD,MAAM,kBAAkB,GAAG,8CAA8C,CAAC;AAM1E,MAAM,UAAU,iBAAiB,CAAC,EAAU,EAAQ;IACnD,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;QAClC,MAAM,IAAI,KAAK,CACd,yIAAyI,CACzI,CAAC;IACH,CAAC;AAAA,CACD;AAED,MAAM,UAAU,eAAe,GAAW;IACzC,OAAO,MAAM,EAAE,CAAC;AAAA,CAChB;AAED,mEAAmE;AACnE,MAAM,UAAU,UAAU,CAAC,IAA0B,EAAU;IAC9D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC;QAC9B,MAAM,EAAE,GAAG,UAAU,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACpC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YAAE,OAAO,EAAE,CAAC;IAC9B,CAAC;IACD,OAAO,UAAU,EAAE,CAAC;AAAA,CACpB","sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport { uuidv7 } from \"@greppleai/grip-agent-core\";\n\nconst SESSION_ID_PATTERN = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;\n\ninterface SessionEntryIdLookup {\n\thas(id: string): boolean;\n}\n\nexport function validateSessionId(id: string): void {\n\tif (!SESSION_ID_PATTERN.test(id)) {\n\t\tthrow new Error(\n\t\t\t\"Session id must be non-empty, contain only alphanumeric characters, '-', '_', and '.', and start and end with an alphanumeric character\",\n\t\t);\n\t}\n}\n\nexport function createSessionId(): string {\n\treturn uuidv7();\n}\n\n/** Generate a unique short ID (8 hex chars, collision-checked). */\nexport function generateId(byId: SessionEntryIdLookup): string {\n\tfor (let i = 0; i < 100; i++) {\n\t\tconst id = randomUUID().slice(0, 8);\n\t\tif (!byId.has(id)) return id;\n\t}\n\treturn randomUUID();\n}\n"]}
1
+ {"version":3,"file":"ids.js","sourceRoot":"","sources":["../../../src/core/session/ids.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAEpD,MAAM,kBAAkB,GAAG,8CAA8C,CAAC;AAM1E,MAAM,UAAU,iBAAiB,CAAC,EAAU;IAC3C,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;QAClC,MAAM,IAAI,KAAK,CACd,yIAAyI,CACzI,CAAC;IACH,CAAC;AACF,CAAC;AAED,MAAM,UAAU,eAAe;IAC9B,OAAO,MAAM,EAAE,CAAC;AACjB,CAAC;AAED,mEAAmE;AACnE,MAAM,UAAU,UAAU,CAAC,IAA0B;IACpD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC;QAC9B,MAAM,EAAE,GAAG,UAAU,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACpC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YAAE,OAAO,EAAE,CAAC;IAC9B,CAAC;IACD,OAAO,UAAU,EAAE,CAAC;AACrB,CAAC","sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport { uuidv7 } from \"@greppleai/grip-agent-core\";\n\nconst SESSION_ID_PATTERN = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;\n\ninterface SessionEntryIdLookup {\n\thas(id: string): boolean;\n}\n\nexport function validateSessionId(id: string): void {\n\tif (!SESSION_ID_PATTERN.test(id)) {\n\t\tthrow new Error(\n\t\t\t\"Session id must be non-empty, contain only alphanumeric characters, '-', '_', and '.', and start and end with an alphanumeric character\",\n\t\t);\n\t}\n}\n\nexport function createSessionId(): string {\n\treturn uuidv7();\n}\n\n/** Generate a unique short ID (8 hex chars, collision-checked). */\nexport function generateId(byId: SessionEntryIdLookup): string {\n\tfor (let i = 0; i < 100; i++) {\n\t\tconst id = randomUUID().slice(0, 8);\n\t\tif (!byId.has(id)) return id;\n\t}\n\treturn randomUUID();\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"in-memory-session-manager.d.ts","sourceRoot":"","sources":["../../../src/core/session/in-memory-session-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEtF,qBAAa,sBAAuB,YAAW,cAAc;IAC5D,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAS;IAE7B,YAAY,GAAG,GAAE,MAAsB,EAEtC;IAED,MAAM,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,eAAe,CAMnD;IAED,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,kBAAkB,GAAG,eAAe,CAEhF;IAED,cAAc,IAAI,eAAe,CAEhC;IAED,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,eAAe,CAE5C;IAED,WAAW,CAAC,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAMjE;IAED,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,kBAAkB,GAAG,eAAe,CAE9E;IAEK,IAAI,CAAC,WAAW,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAEpE;IAEK,OAAO,CAAC,WAAW,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAEvE;CACD","sourcesContent":["import { InMemorySession } from \"./in-memory-session.ts\";\nimport type { Session } from \"./session.ts\";\nimport type { OpenSessionOptions, SessionManager } from \"./session-manager.ts\";\nimport type { NewSessionOptions, SessionInfo, SessionListProgress } from \"./types.ts\";\n\nexport class InMemorySessionManager implements SessionManager {\n\tprivate readonly cwd: string;\n\n\tconstructor(cwd: string = process.cwd()) {\n\t\tthis.cwd = cwd;\n\t}\n\n\tcreate(options?: NewSessionOptions): InMemorySession {\n\t\tconst session = new InMemorySession(this.cwd, this);\n\t\tif (options?.id || options?.parentSession) {\n\t\t\tsession.newSession(options);\n\t\t}\n\t\treturn session;\n\t}\n\n\topenReference(_reference: string, _options?: OpenSessionOptions): InMemorySession {\n\t\treturn this.create();\n\t}\n\n\tcontinueRecent(): InMemorySession {\n\t\treturn this.create();\n\t}\n\n\tforkFrom(_reference: string): InMemorySession {\n\t\treturn this.create();\n\t}\n\n\tforkSession(source: Session, targetLeafId: string | null): Session {\n\t\tconst session = this.create({ parentSession: source.getSessionReference() });\n\t\tif (targetLeafId) {\n\t\t\tsession.copyBranchFrom(source, targetLeafId, source.getSessionReference());\n\t\t}\n\t\treturn session;\n\t}\n\n\timportJsonl(_inputPath: string, _options?: OpenSessionOptions): InMemorySession {\n\t\tthrow new Error(\"Importing JSONL sessions is not supported by in-memory sessions\");\n\t}\n\n\tasync list(_onProgress?: SessionListProgress): Promise<SessionInfo[]> {\n\t\treturn [];\n\t}\n\n\tasync listAll(_onProgress?: SessionListProgress): Promise<SessionInfo[]> {\n\t\treturn [];\n\t}\n}\n"]}
1
+ {"version":3,"file":"in-memory-session-manager.d.ts","sourceRoot":"","sources":["../../../src/core/session/in-memory-session-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEtF,qBAAa,sBAAuB,YAAW,cAAc;IAC5D,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAS;IAE7B,YAAY,GAAG,GAAE,MAAsB,EAEtC;IAED,MAAM,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,eAAe,CAMnD;IAED,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,kBAAkB,GAAG,eAAe,CAEhF;IAED,cAAc,IAAI,eAAe,CAEhC;IAED,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,eAAe,CAE5C;IAED,WAAW,CAAC,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAMjE;IAED,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,kBAAkB,GAAG,eAAe,CAE9E;IAEK,IAAI,CAAC,WAAW,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAEpE;IAEK,OAAO,CAAC,WAAW,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAEvE;CACD"}
@@ -1,6 +1,5 @@
1
1
  import { InMemorySession } from "./in-memory-session.js";
2
2
  export class InMemorySessionManager {
3
- cwd;
4
3
  constructor(cwd = process.cwd()) {
5
4
  this.cwd = cwd;
6
5
  }
@@ -1 +1 @@
1
- {"version":3,"file":"in-memory-session-manager.js","sourceRoot":"","sources":["../../../src/core/session/in-memory-session-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAKzD,MAAM,OAAO,sBAAsB;IACjB,GAAG,CAAS;IAE7B,YAAY,GAAG,GAAW,OAAO,CAAC,GAAG,EAAE,EAAE;QACxC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IAAA,CACf;IAED,MAAM,CAAC,OAA2B,EAAmB;QACpD,MAAM,OAAO,GAAG,IAAI,eAAe,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QACpD,IAAI,OAAO,EAAE,EAAE,IAAI,OAAO,EAAE,aAAa,EAAE,CAAC;YAC3C,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QAC7B,CAAC;QACD,OAAO,OAAO,CAAC;IAAA,CACf;IAED,aAAa,CAAC,UAAkB,EAAE,QAA6B,EAAmB;QACjF,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC;IAAA,CACrB;IAED,cAAc,GAAoB;QACjC,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC;IAAA,CACrB;IAED,QAAQ,CAAC,UAAkB,EAAmB;QAC7C,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC;IAAA,CACrB;IAED,WAAW,CAAC,MAAe,EAAE,YAA2B,EAAW;QAClE,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,EAAE,aAAa,EAAE,MAAM,CAAC,mBAAmB,EAAE,EAAE,CAAC,CAAC;QAC7E,IAAI,YAAY,EAAE,CAAC;YAClB,OAAO,CAAC,cAAc,CAAC,MAAM,EAAE,YAAY,EAAE,MAAM,CAAC,mBAAmB,EAAE,CAAC,CAAC;QAC5E,CAAC;QACD,OAAO,OAAO,CAAC;IAAA,CACf;IAED,WAAW,CAAC,UAAkB,EAAE,QAA6B,EAAmB;QAC/E,MAAM,IAAI,KAAK,CAAC,iEAAiE,CAAC,CAAC;IAAA,CACnF;IAED,KAAK,CAAC,IAAI,CAAC,WAAiC,EAA0B;QACrE,OAAO,EAAE,CAAC;IAAA,CACV;IAED,KAAK,CAAC,OAAO,CAAC,WAAiC,EAA0B;QACxE,OAAO,EAAE,CAAC;IAAA,CACV;CACD","sourcesContent":["import { InMemorySession } from \"./in-memory-session.ts\";\nimport type { Session } from \"./session.ts\";\nimport type { OpenSessionOptions, SessionManager } from \"./session-manager.ts\";\nimport type { NewSessionOptions, SessionInfo, SessionListProgress } from \"./types.ts\";\n\nexport class InMemorySessionManager implements SessionManager {\n\tprivate readonly cwd: string;\n\n\tconstructor(cwd: string = process.cwd()) {\n\t\tthis.cwd = cwd;\n\t}\n\n\tcreate(options?: NewSessionOptions): InMemorySession {\n\t\tconst session = new InMemorySession(this.cwd, this);\n\t\tif (options?.id || options?.parentSession) {\n\t\t\tsession.newSession(options);\n\t\t}\n\t\treturn session;\n\t}\n\n\topenReference(_reference: string, _options?: OpenSessionOptions): InMemorySession {\n\t\treturn this.create();\n\t}\n\n\tcontinueRecent(): InMemorySession {\n\t\treturn this.create();\n\t}\n\n\tforkFrom(_reference: string): InMemorySession {\n\t\treturn this.create();\n\t}\n\n\tforkSession(source: Session, targetLeafId: string | null): Session {\n\t\tconst session = this.create({ parentSession: source.getSessionReference() });\n\t\tif (targetLeafId) {\n\t\t\tsession.copyBranchFrom(source, targetLeafId, source.getSessionReference());\n\t\t}\n\t\treturn session;\n\t}\n\n\timportJsonl(_inputPath: string, _options?: OpenSessionOptions): InMemorySession {\n\t\tthrow new Error(\"Importing JSONL sessions is not supported by in-memory sessions\");\n\t}\n\n\tasync list(_onProgress?: SessionListProgress): Promise<SessionInfo[]> {\n\t\treturn [];\n\t}\n\n\tasync listAll(_onProgress?: SessionListProgress): Promise<SessionInfo[]> {\n\t\treturn [];\n\t}\n}\n"]}
1
+ {"version":3,"file":"in-memory-session-manager.js","sourceRoot":"","sources":["../../../src/core/session/in-memory-session-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAKzD,MAAM,OAAO,sBAAsB;IAGlC,YAAY,GAAG,GAAW,OAAO,CAAC,GAAG,EAAE;QACtC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IAChB,CAAC;IAED,MAAM,CAAC,OAA2B;QACjC,MAAM,OAAO,GAAG,IAAI,eAAe,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QACpD,IAAI,OAAO,EAAE,EAAE,IAAI,OAAO,EAAE,aAAa,EAAE,CAAC;YAC3C,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QAC7B,CAAC;QACD,OAAO,OAAO,CAAC;IAChB,CAAC;IAED,aAAa,CAAC,UAAkB,EAAE,QAA6B;QAC9D,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC;IACtB,CAAC;IAED,cAAc;QACb,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC;IACtB,CAAC;IAED,QAAQ,CAAC,UAAkB;QAC1B,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC;IACtB,CAAC;IAED,WAAW,CAAC,MAAe,EAAE,YAA2B;QACvD,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,EAAE,aAAa,EAAE,MAAM,CAAC,mBAAmB,EAAE,EAAE,CAAC,CAAC;QAC7E,IAAI,YAAY,EAAE,CAAC;YAClB,OAAO,CAAC,cAAc,CAAC,MAAM,EAAE,YAAY,EAAE,MAAM,CAAC,mBAAmB,EAAE,CAAC,CAAC;QAC5E,CAAC;QACD,OAAO,OAAO,CAAC;IAChB,CAAC;IAED,WAAW,CAAC,UAAkB,EAAE,QAA6B;QAC5D,MAAM,IAAI,KAAK,CAAC,iEAAiE,CAAC,CAAC;IACpF,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,WAAiC;QAC3C,OAAO,EAAE,CAAC;IACX,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,WAAiC;QAC9C,OAAO,EAAE,CAAC;IACX,CAAC;CACD","sourcesContent":["import { InMemorySession } from \"./in-memory-session.ts\";\nimport type { Session } from \"./session.ts\";\nimport type { OpenSessionOptions, SessionManager } from \"./session-manager.ts\";\nimport type { NewSessionOptions, SessionInfo, SessionListProgress } from \"./types.ts\";\n\nexport class InMemorySessionManager implements SessionManager {\n\tprivate readonly cwd: string;\n\n\tconstructor(cwd: string = process.cwd()) {\n\t\tthis.cwd = cwd;\n\t}\n\n\tcreate(options?: NewSessionOptions): InMemorySession {\n\t\tconst session = new InMemorySession(this.cwd, this);\n\t\tif (options?.id || options?.parentSession) {\n\t\t\tsession.newSession(options);\n\t\t}\n\t\treturn session;\n\t}\n\n\topenReference(_reference: string, _options?: OpenSessionOptions): InMemorySession {\n\t\treturn this.create();\n\t}\n\n\tcontinueRecent(): InMemorySession {\n\t\treturn this.create();\n\t}\n\n\tforkFrom(_reference: string): InMemorySession {\n\t\treturn this.create();\n\t}\n\n\tforkSession(source: Session, targetLeafId: string | null): Session {\n\t\tconst session = this.create({ parentSession: source.getSessionReference() });\n\t\tif (targetLeafId) {\n\t\t\tsession.copyBranchFrom(source, targetLeafId, source.getSessionReference());\n\t\t}\n\t\treturn session;\n\t}\n\n\timportJsonl(_inputPath: string, _options?: OpenSessionOptions): InMemorySession {\n\t\tthrow new Error(\"Importing JSONL sessions is not supported by in-memory sessions\");\n\t}\n\n\tasync list(_onProgress?: SessionListProgress): Promise<SessionInfo[]> {\n\t\treturn [];\n\t}\n\n\tasync listAll(_onProgress?: SessionListProgress): Promise<SessionInfo[]> {\n\t\treturn [];\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"in-memory-session.d.ts","sourceRoot":"","sources":["../../../src/core/session/in-memory-session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAG3D,qBAAa,eAAgB,SAAQ,OAAO;IAC3C,YAAY,GAAG,GAAE,MAAsB,EAAE,cAAc,CAAC,EAAE,cAAc,EAEvE;IAED,SAAS,CAAC,0BAA0B,CACnC,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,GAChB,MAAM,GAAG,SAAS,CAEpB;CACD","sourcesContent":["import { Session } from \"./session.ts\";\nimport type { SessionManager } from \"./session-manager.ts\";\nimport { InMemorySessionStore } from \"./stores/in-memory-session-store.ts\";\n\nexport class InMemorySession extends Session {\n\tconstructor(cwd: string = process.cwd(), sessionManager?: SessionManager) {\n\t\tsuper(cwd, \"\", undefined, new InMemorySessionStore(), sessionManager);\n\t}\n\n\tprotected prepareNewSessionReference(\n\t\t_sessionDir: string,\n\t\tsessionId: string,\n\t\t_timestamp: string,\n\t): string | undefined {\n\t\treturn `memory:${sessionId}`;\n\t}\n}\n"]}
1
+ {"version":3,"file":"in-memory-session.d.ts","sourceRoot":"","sources":["../../../src/core/session/in-memory-session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAG3D,qBAAa,eAAgB,SAAQ,OAAO;IAC3C,YAAY,GAAG,GAAE,MAAsB,EAAE,cAAc,CAAC,EAAE,cAAc,EAEvE;IAED,SAAS,CAAC,0BAA0B,CACnC,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,GAChB,MAAM,GAAG,SAAS,CAEpB;CACD"}
@@ -1 +1 @@
1
- {"version":3,"file":"in-memory-session.js","sourceRoot":"","sources":["../../../src/core/session/in-memory-session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAE3E,MAAM,OAAO,eAAgB,SAAQ,OAAO;IAC3C,YAAY,GAAG,GAAW,OAAO,CAAC,GAAG,EAAE,EAAE,cAA+B,EAAE;QACzE,KAAK,CAAC,GAAG,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,oBAAoB,EAAE,EAAE,cAAc,CAAC,CAAC;IAAA,CACtE;IAES,0BAA0B,CACnC,WAAmB,EACnB,SAAiB,EACjB,UAAkB,EACG;QACrB,OAAO,UAAU,SAAS,EAAE,CAAC;IAAA,CAC7B;CACD","sourcesContent":["import { Session } from \"./session.ts\";\nimport type { SessionManager } from \"./session-manager.ts\";\nimport { InMemorySessionStore } from \"./stores/in-memory-session-store.ts\";\n\nexport class InMemorySession extends Session {\n\tconstructor(cwd: string = process.cwd(), sessionManager?: SessionManager) {\n\t\tsuper(cwd, \"\", undefined, new InMemorySessionStore(), sessionManager);\n\t}\n\n\tprotected prepareNewSessionReference(\n\t\t_sessionDir: string,\n\t\tsessionId: string,\n\t\t_timestamp: string,\n\t): string | undefined {\n\t\treturn `memory:${sessionId}`;\n\t}\n}\n"]}
1
+ {"version":3,"file":"in-memory-session.js","sourceRoot":"","sources":["../../../src/core/session/in-memory-session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAE3E,MAAM,OAAO,eAAgB,SAAQ,OAAO;IAC3C,YAAY,GAAG,GAAW,OAAO,CAAC,GAAG,EAAE,EAAE,cAA+B;QACvE,KAAK,CAAC,GAAG,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,oBAAoB,EAAE,EAAE,cAAc,CAAC,CAAC;IACvE,CAAC;IAES,0BAA0B,CACnC,WAAmB,EACnB,SAAiB,EACjB,UAAkB;QAElB,OAAO,UAAU,SAAS,EAAE,CAAC;IAC9B,CAAC;CACD","sourcesContent":["import { Session } from \"./session.ts\";\nimport type { SessionManager } from \"./session-manager.ts\";\nimport { InMemorySessionStore } from \"./stores/in-memory-session-store.ts\";\n\nexport class InMemorySession extends Session {\n\tconstructor(cwd: string = process.cwd(), sessionManager?: SessionManager) {\n\t\tsuper(cwd, \"\", undefined, new InMemorySessionStore(), sessionManager);\n\t}\n\n\tprotected prepareNewSessionReference(\n\t\t_sessionDir: string,\n\t\tsessionId: string,\n\t\t_timestamp: string,\n\t): string | undefined {\n\t\treturn `memory:${sessionId}`;\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"jsonl-errors.d.ts","sourceRoot":"","sources":["../../../src/core/session/jsonl-errors.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAC;AAErE,MAAM,MAAM,eAAe,GACxB,QAAQ,GACR,QAAQ,GACR,MAAM,GACN,MAAM,GACN,QAAQ,GACR,SAAS,GACT,MAAM,GACN,QAAQ,GACR,SAAS,GACT,MAAM,CAAC;AAEV,MAAM,M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,EACjB,KAAK,EAAE,eAAe,EACtB,UAAU,EAAE,eAAe,EAC3B,OAAO,EAAE,MAAM,EACf,IAAI,SAAI,EACR,UAAU,SAAI,GACZ,iBAAiB,CAYnB","sourcesContent":["export type JsonlDecodeKind = \"utf8\" | \"syntax\" | \"schema\" | \"state\";\n\nexport type JsonlErrorPhase =\n\t| \"create\"\n\t| \"append\"\n\t| \"fork\"\n\t| \"open\"\n\t| \"repair\"\n\t| \"migrate\"\n\t| \"list\"\n\t| \"import\"\n\t| \"replace\"\n\t| \"sync\";\n\nexport type JsonlWriteOutcome = \"not_written\" | \"unknown\" | \"published\";\n\n/** Path-independent JSONL decoding failure. Storage boundaries attach location and operation context. */\nexport class JsonlDecodeError extends Error {\n\treadonly decodeKind: JsonlDecodeKind;\n\t/** Compatibility alias for path-independent codec consumers. */\n\treadonly kind: JsonlDecodeKind;\n\n\tconstructor(decodeKind: JsonlDecodeKind, message: string, cause?: Error) {\n\t\tsuper(message, cause === undefined ? undefined : { cause });\n\t\tthis.name = \"JsonlDecodeError\";\n\t\tthis.decodeKind = decodeKind;\n\t\tthis.kind = decodeKind;\n\t}\n}\n\nexport type JsonlSessionErrorCode = \"invalid_jsonl\" | \"storage\" | \"fenced\";\n\nexport interface JsonlSessionErrorOptions {\n\tcode: JsonlSessionErrorCode;\n\treference: string;\n\tphase: JsonlErrorPhase;\n\tmessage: string;\n\tline?: number;\n\tbyteOffset?: number;\n\tdecodeKind?: JsonlDecodeKind;\n\toutcome?: JsonlWriteOutcome;\n\tcause?: Error;\n}\n\n/** Actionable local JSONL error with location, phase, decoding, and write-outcome context. */\nexport class JsonlSessionError extends Error {\n\treadonly code: JsonlSessionErrorCode;\n\treadonly reference: string;\n\treadonly path: string;\n\treadonly phase: JsonlErrorPhase;\n\treadonly line?: number;\n\treadonly byteOffset?: number;\n\treadonly decodeKind?: JsonlDecodeKind;\n\treadonly outcome?: JsonlWriteOutcome;\n\n\tconstructor(options: JsonlSessionErrorOptions) {\n\t\tsuper(options.message, options.cause === undefined ? undefined : { cause: options.cause });\n\t\tthis.name = \"JsonlSessionError\";\n\t\tthis.code = options.code;\n\t\tthis.reference = options.reference;\n\t\tthis.path = options.reference;\n\t\tthis.phase = options.phase;\n\t\tthis.line = options.line;\n\t\tthis.byteOffset = options.byteOffset;\n\t\tthis.decodeKind = options.decodeKind;\n\t\tthis.outcome = options.outcome;\n\t}\n}\n\nexport function createJsonlSessionDecodeError(\n\treference: string,\n\tphase: JsonlErrorPhase,\n\tdecodeKind: JsonlDecodeKind,\n\tmessage: string,\n\tline = 1,\n\tbyteOffset = 0,\n): JsonlSessionError {\n\tconst cause = new JsonlDecodeError(decodeKind, message);\n\treturn new JsonlSessionError({\n\t\tcode: \"invalid_jsonl\",\n\t\treference,\n\t\tphase,\n\t\tline,\n\t\tbyteOffset,\n\t\tdecodeKind,\n\t\tmessage,\n\t\tcause,\n\t});\n}\n"]}
1
+ {"version":3,"file":"jsonl-errors.d.ts","sourceRoot":"","sources":["../../../src/core/session/jsonl-errors.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAC;AAErE,MAAM,MAAM,eAAe,GACxB,QAAQ,GACR,QAAQ,GACR,MAAM,GACN,MAAM,GACN,QAAQ,GACR,SAAS,GACT,MAAM,GACN,QAAQ,GACR,SAAS,GACT,MAAM,CAAC;AAEV,MAAM,MAAM,iBAAiB,GAAG,aAAa,GAAG,SAAS,GAAG,WAAW,CAAC;AAExE,yGAAyG;AACzG,qBAAa,gBAAiB,SAAQ,KAAK;IAC1C,QAAQ,CAAC,UAAU,EAAE,eAAe,CAAC;IACrC,gEAAgE;IAChE,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAE/B,YAAY,UAAU,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK,EAKtE;CACD;AAED,MAAM,MAAM,qBAAqB,GAAG,eAAe,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE3E,MAAM,WAAW,wBAAwB;IACxC,IAAI,EAAE,qBAAqB,CAAC;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,eAAe,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,eAAe,CAAC;IAC7B,OAAO,CAAC,EAAE,iBAAiB,CAAC;IAC5B,KAAK,CAAC,EAAE,KAAK,CAAC;CACd;AAED,8FAA8F;AAC9F,qBAAa,iBAAkB,SAAQ,KAAK;IAC3C,QAAQ,CAAC,IAAI,EAAE,qBAAqB,CAAC;IACrC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,eAAe,CAAC;IAChC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,UAAU,CAAC,EAAE,eAAe,CAAC;IACtC,QAAQ,CAAC,OAAO,CAAC,EAAE,iBAAiB,CAAC;IAErC,YAAY,OAAO,EAAE,wBAAwB,EAW5C;CACD;AAED,wBAAgB,6BAA6B,CAC5C,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,eAAe,EACtB,UAAU,EAAE,eAAe,EAC3B,OAAO,EAAE,MAAM,EACf,IAAI,SAAI,EACR,UAAU,SAAI,GACZ,iBAAiB,CAYnB"}
@@ -1,8 +1,5 @@
1
1
  /** Path-independent JSONL decoding failure. Storage boundaries attach location and operation context. */
2
2
  export class JsonlDecodeError extends Error {
3
- decodeKind;
4
- /** Compatibility alias for path-independent codec consumers. */
5
- kind;
6
3
  constructor(decodeKind, message, cause) {
7
4
  super(message, cause === undefined ? undefined : { cause });
8
5
  this.name = "JsonlDecodeError";
@@ -12,14 +9,6 @@ export class JsonlDecodeError extends Error {
12
9
  }
13
10
  /** Actionable local JSONL error with location, phase, decoding, and write-outcome context. */
14
11
  export class JsonlSessionError extends Error {
15
- code;
16
- reference;
17
- path;
18
- phase;
19
- line;
20
- byteOffset;
21
- decodeKind;
22
- outcome;
23
12
  constructor(options) {
24
13
  super(options.message, options.cause === undefined ? undefined : { cause: options.cause });
25
14
  this.name = "JsonlSessionError";
@@ -1 +1 @@
1
- {"version":3,"file":"jsonl-errors.js","sourceRoot":"","sources":["../../../src/core/session/jsonl-errors.ts"],"names":[],"mappings":"AAgBA,yGAAyG;AACzG,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IACjC,UAAU,CAAkB;IACrC,gEAAgE;IACvD,IAAI,CAAkB;IAE/B,YAAY,UAA2B,EAAE,OAAe,EAAE,KAAa,EAAE;QACxE,KAAK,CAAC,OAAO,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QAC5D,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;QAC/B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;IAAA,CACvB;CACD;AAgBD,8FAA8F;AAC9F,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IAClC,IAAI,CAAwB;IAC5B,SAAS,CAAS;IAClB,IAAI,CAAS;IACb,KAAK,CAAkB;IACvB,IAAI,CAAU;IACd,UAAU,CAAU;IACpB,UAAU,CAAmB;IAC7B,OAAO,CAAqB;IAErC,YAAY,OAAiC,EAAE;QAC9C,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;QAC3F,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;QAChC,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QACzB,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;QACnC,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,SAAS,CAAC;QAC9B,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC3B,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QACzB,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;QACrC,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;QACrC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAAA,CAC/B;CACD;AAED,MAAM,UAAU,6BAA6B,CAC5C,SAAiB,EACjB,KAAsB,EACtB,UAA2B,EAC3B,OAAe,EACf,IAAI,GAAG,CAAC,EACR,UAAU,GAAG,CAAC,EACM;IACpB,MAAM,KAAK,GAAG,IAAI,gBAAgB,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IACxD,OAAO,IAAI,iBAAiB,CAAC;QAC5B,IAAI,EAAE,eAAe;QACrB,SAAS;QACT,KAAK;QACL,IAAI;QACJ,UAAU;QACV,UAAU;QACV,OAAO;QACP,KAAK;KACL,CAAC,CAAC;AAAA,CACH","sourcesContent":["export type JsonlDecodeKind = \"utf8\" | \"syntax\" | \"schema\" | \"state\";\n\nexport type JsonlErrorPhase =\n\t| \"create\"\n\t| \"append\"\n\t| \"fork\"\n\t| \"open\"\n\t| \"repair\"\n\t| \"migrate\"\n\t| \"list\"\n\t| \"import\"\n\t| \"replace\"\n\t| \"sync\";\n\nexport type JsonlWriteOutcome = \"not_written\" | \"unknown\" | \"published\";\n\n/** Path-independent JSONL decoding failure. Storage boundaries attach location and operation context. */\nexport class JsonlDecodeError extends Error {\n\treadonly decodeKind: JsonlDecodeKind;\n\t/** Compatibility alias for path-independent codec consumers. */\n\treadonly kind: JsonlDecodeKind;\n\n\tconstructor(decodeKind: JsonlDecodeKind, message: string, cause?: Error) {\n\t\tsuper(message, cause === undefined ? undefined : { cause });\n\t\tthis.name = \"JsonlDecodeError\";\n\t\tthis.decodeKind = decodeKind;\n\t\tthis.kind = decodeKind;\n\t}\n}\n\nexport type JsonlSessionErrorCode = \"invalid_jsonl\" | \"storage\" | \"fenced\";\n\nexport interface JsonlSessionErrorOptions {\n\tcode: JsonlSessionErrorCode;\n\treference: string;\n\tphase: JsonlErrorPhase;\n\tmessage: string;\n\tline?: number;\n\tbyteOffset?: number;\n\tdecodeKind?: JsonlDecodeKind;\n\toutcome?: JsonlWriteOutcome;\n\tcause?: Error;\n}\n\n/** Actionable local JSONL error with location, phase, decoding, and write-outcome context. */\nexport class JsonlSessionError extends Error {\n\treadonly code: JsonlSessionErrorCode;\n\treadonly reference: string;\n\treadonly path: string;\n\treadonly phase: JsonlErrorPhase;\n\treadonly line?: number;\n\treadonly byteOffset?: number;\n\treadonly decodeKind?: JsonlDecodeKind;\n\treadonly outcome?: JsonlWriteOutcome;\n\n\tconstructor(options: JsonlSessionErrorOptions) {\n\t\tsuper(options.message, options.cause === undefined ? undefined : { cause: options.cause });\n\t\tthis.name = \"JsonlSessionError\";\n\t\tthis.code = options.code;\n\t\tthis.reference = options.reference;\n\t\tthis.path = options.reference;\n\t\tthis.phase = options.phase;\n\t\tthis.line = options.line;\n\t\tthis.byteOffset = options.byteOffset;\n\t\tthis.decodeKind = options.decodeKind;\n\t\tthis.outcome = options.outcome;\n\t}\n}\n\nexport function createJsonlSessionDecodeError(\n\treference: string,\n\tphase: JsonlErrorPhase,\n\tdecodeKind: JsonlDecodeKind,\n\tmessage: string,\n\tline = 1,\n\tbyteOffset = 0,\n): JsonlSessionError {\n\tconst cause = new JsonlDecodeError(decodeKind, message);\n\treturn new JsonlSessionError({\n\t\tcode: \"invalid_jsonl\",\n\t\treference,\n\t\tphase,\n\t\tline,\n\t\tbyteOffset,\n\t\t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C,CAAC;CACD;AAED,MAAM,UAAU,6BAA6B,CAC5C,SAAiB,EACjB,KAAsB,EACtB,UAA2B,EAC3B,OAAe,EACf,IAAI,GAAG,CAAC,EACR,UAAU,GAAG,CAAC;IAEd,MAAM,KAAK,GAAG,IAAI,gBAAgB,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IACxD,OAAO,IAAI,iBAAiB,CAAC;QAC5B,IAAI,EAAE,eAAe;QACrB,SAAS;QACT,KAAK;QACL,IAAI;QACJ,UAAU;QACV,UAAU;QACV,OAAO;QACP,KAAK;KACL,CAAC,CAAC;AACJ,CAAC","sourcesContent":["export type JsonlDecodeKind = \"utf8\" | \"syntax\" | \"schema\" | \"state\";\n\nexport type JsonlErrorPhase =\n\t| \"create\"\n\t| \"append\"\n\t| \"fork\"\n\t| \"open\"\n\t| \"repair\"\n\t| \"migrate\"\n\t| \"list\"\n\t| \"import\"\n\t| \"replace\"\n\t| \"sync\";\n\nexport type JsonlWriteOutcome = \"not_written\" | \"unknown\" | \"published\";\n\n/** Path-independent JSONL decoding failure. Storage boundaries attach location and operation context. */\nexport class JsonlDecodeError extends Error {\n\treadonly decodeKind: JsonlDecodeKind;\n\t/** Compatibility alias for path-independent codec consumers. */\n\treadonly kind: JsonlDecodeKind;\n\n\tconstructor(decodeKind: JsonlDecodeKind, message: string, cause?: Error) {\n\t\tsuper(message, cause === undefined ? undefined : { cause });\n\t\tthis.name = \"JsonlDecodeError\";\n\t\tthis.decodeKind = decodeKind;\n\t\tthis.kind = decodeKind;\n\t}\n}\n\nexport type JsonlSessionErrorCode = \"invalid_jsonl\" | \"storage\" | \"fenced\";\n\nexport interface JsonlSessionErrorOptions {\n\tcode: JsonlSessionErrorCode;\n\treference: string;\n\tphase: JsonlErrorPhase;\n\tmessage: string;\n\tline?: number;\n\tbyteOffset?: number;\n\tdecodeKind?: JsonlDecodeKind;\n\toutcome?: JsonlWriteOutcome;\n\tcause?: Error;\n}\n\n/** Actionable local JSONL error with location, phase, decoding, and write-outcome context. */\nexport class JsonlSessionError extends Error {\n\treadonly code: JsonlSessionErrorCode;\n\treadonly reference: string;\n\treadonly path: string;\n\treadonly phase: JsonlErrorPhase;\n\treadonly line?: number;\n\treadonly byteOffset?: number;\n\treadonly decodeKind?: JsonlDecodeKind;\n\treadonly outcome?: JsonlWriteOutcome;\n\n\tconstructor(options: JsonlSessionErrorOptions) {\n\t\tsuper(options.message, options.cause === undefined ? undefined : { cause: options.cause });\n\t\tthis.name = \"JsonlSessionError\";\n\t\tthis.code = options.code;\n\t\tthis.reference = options.reference;\n\t\tthis.path = options.reference;\n\t\tthis.phase = options.phase;\n\t\tthis.line = options.line;\n\t\tthis.byteOffset = options.byteOffset;\n\t\tthis.decodeKind = options.decodeKind;\n\t\tthis.outcome = options.outcome;\n\t}\n}\n\nexport function createJsonlSessionDecodeError(\n\treference: string,\n\tphase: JsonlErrorPhase,\n\tdecodeKind: JsonlDecodeKind,\n\tmessage: string,\n\tline = 1,\n\tbyteOffset = 0,\n): JsonlSessionError {\n\tconst cause = new JsonlDecodeError(decodeKind, message);\n\treturn new JsonlSessionError({\n\t\tcode: \"invalid_jsonl\",\n\t\treference,\n\t\tphase,\n\t\tline,\n\t\tbyteOffset,\n\t\tdecodeKind,\n\t\tmessage,\n\t\tcause,\n\t});\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"jsonl-helpers.d.ts","sourceRoot":"","sources":["../../../src/core/session/jsonl-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAIN,iBAAiB,EAEjB,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,eAAO,MAAM,iBAAiB,mBAA0B,CAAC;AAEzD;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAE3E;AAED,KAAK,0BAA0B,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,GAAG,SAAS,CAAC;AAEzE,UAAU,yBAAyB;IAClC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,0BAA0B,CAAC;CACnC;AAED,4BAA4B;AAC5B,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,yBAA8B,GAAG,SAAS,EAAE,CAE1G;AAED,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAE/E;AAED,4BAA4B;AAC5B,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAErF","sourcesContent":["import {\n\tfindMostRecent,\n\tgetDefaultSessionDir as getDefaultJsonlSessionDir,\n\tgetDefaultSessionDirPath as getDefaultJsonlSessionDirPath,\n\tJsonlSessionStore,\n\tload,\n} from \"./stores/jsonl-session-store.ts\";\nimport type { FileEntry } from \"./types.ts\";\n\nexport const jsonlSessionStore = new JsonlSessionStore();\n\n/**\n * Compute the default session directory for a cwd.\n * Encodes cwd into a safe directory name under ~/.grip/agent/sessions/.\n */\nexport function getDefaultSessionDir(cwd: string, agentDir?: string): string {\n\treturn getDefaultJsonlSessionDir(cwd, agentDir);\n}\n\ntype JsonlSessionEntryLoadPhase = \"fork\" | \"open\" | \"import\" | \"migrate\";\n\ninterface LoadSessionEntriesOptions {\n\trepair?: boolean;\n\tphase?: JsonlSessionEntryLoadPhase;\n}\n\n/** Exported for testing. */\nexport function loadEntriesFromFile(filePath: string, options: LoadSessionEntriesOptions = {}): FileEntry[] {\n\treturn load(filePath, {}, options.repair ?? true, options.phase ?? \"open\");\n}\n\nexport function getDefaultSessionDirPath(cwd: string, agentDir?: string): string {\n\treturn getDefaultJsonlSessionDirPath(cwd, agentDir);\n}\n\n/** Exported for testing. */\nexport function findMostRecentSession(sessionDir: string, cwd?: string): string | null {\n\treturn findMostRecent(sessionDir, cwd);\n}\n"]}
1
+ {"version":3,"file":"jsonl-helpers.d.ts","sourceRoot":"","sources":["../../../src/core/session/jsonl-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAIN,iBAAiB,EAEjB,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,eAAO,MAAM,iBAAiB,mBAA0B,CAAC;AAEzD;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAE3E;AAED,KAAK,0BAA0B,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,GAAG,SAAS,CAAC;AAEzE,UAAU,yBAAyB;IAClC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,0BAA0B,CAAC;CACnC;AAED,4BAA4B;AAC5B,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,yBAA8B,GAAG,SAAS,EAAE,CAE1G;AAED,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAE/E;AAED,4BAA4B;AAC5B,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAErF"}
@@ -1 +1 @@
1
- {"version":3,"file":"jsonl-helpers.js","sourceRoot":"","sources":["../../../src/core/session/jsonl-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,cAAc,EACd,oBAAoB,IAAI,yBAAyB,EACjD,wBAAwB,IAAI,6BAA6B,EACzD,iBAAiB,EACjB,IAAI,GACJ,MAAM,iCAAiC,CAAC;AAGzC,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,iBAAiB,EAAE,CAAC;AAEzD;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,GAAW,EAAE,QAAiB,EAAU;IAC5E,OAAO,yBAAyB,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;AAAA,CAChD;AASD,4BAA4B;AAC5B,MAAM,UAAU,mBAAmB,CAAC,QAAgB,EAAE,OAAO,GAA8B,EAAE,EAAe;IAC3G,OAAO,IAAI,CAAC,QAAQ,EAAE,EAAE,EAAE,OAAO,CAAC,MAAM,IAAI,IAAI,EAAE,OAAO,CAAC,KAAK,IAAI,MAAM,CAAC,CAAC;AAAA,CAC3E;AAED,MAAM,UAAU,wBAAwB,CAAC,GAAW,EAAE,QAAiB,EAAU;IAChF,OAAO,6BAA6B,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;AAAA,CACpD;AAED,4BAA4B;AAC5B,MAAM,UAAU,qBAAqB,CAAC,UAAkB,EAAE,GAAY,EAAiB;IACtF,OAAO,cAAc,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;AAAA,CACvC","sourcesContent":["import {\n\tfindMostRecent,\n\tgetDefaultSessionDir as getDefaultJsonlSessionDir,\n\tgetDefaultSessionDirPath as getDefaultJsonlSessionDirPath,\n\tJsonlSessionStore,\n\tload,\n} from \"./stores/jsonl-session-store.ts\";\nimport type { FileEntry } from \"./types.ts\";\n\nexport const jsonlSessionStore = new JsonlSessionStore();\n\n/**\n * Compute the default session directory for a cwd.\n * Encodes cwd into a safe directory name under ~/.grip/agent/sessions/.\n */\nexport function getDefaultSessionDir(cwd: string, agentDir?: string): string {\n\treturn getDefaultJsonlSessionDir(cwd, agentDir);\n}\n\ntype JsonlSessionEntryLoadPhase = \"fork\" | \"open\" | \"import\" | \"migrate\";\n\ninterface LoadSessionEntriesOptions {\n\trepair?: boolean;\n\tphase?: JsonlSessionEntryLoadPhase;\n}\n\n/** Exported for testing. */\nexport function loadEntriesFromFile(filePath: string, options: LoadSessionEntriesOptions = {}): FileEntry[] {\n\treturn load(filePath, {}, options.repair ?? true, options.phase ?? \"open\");\n}\n\nexport function getDefaultSessionDirPath(cwd: string, agentDir?: string): string {\n\treturn getDefaultJsonlSessionDirPath(cwd, agentDir);\n}\n\n/** Exported for testing. */\nexport function findMostRecentSession(sessionDir: string, cwd?: string): string | null {\n\treturn findMostRecent(sessionDir, cwd);\n}\n"]}
1
+ {"version":3,"file":"jsonl-helpers.js","sourceRoot":"","sources":["../../../src/core/session/jsonl-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,cAAc,EACd,oBAAoB,IAAI,yBAAyB,EACjD,wBAAwB,IAAI,6BAA6B,EACzD,iBAAiB,EACjB,IAAI,GACJ,MAAM,iCAAiC,CAAC;AAGzC,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,iBAAiB,EAAE,CAAC;AAEzD;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,GAAW,EAAE,QAAiB;IAClE,OAAO,yBAAyB,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;AACjD,CAAC;AASD,4BAA4B;AAC5B,MAAM,UAAU,mBAAmB,CAAC,QAAgB,EAAE,OAAO,GAA8B,EAAE;IAC5F,OAAO,IAAI,CAAC,QAAQ,EAAE,EAAE,EAAE,OAAO,CAAC,MAAM,IAAI,IAAI,EAAE,OAAO,CAAC,KAAK,IAAI,MAAM,CAAC,CAAC;AAC5E,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,GAAW,EAAE,QAAiB;IACtE,OAAO,6BAA6B,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;AACrD,CAAC;AAED,4BAA4B;AAC5B,MAAM,UAAU,qBAAqB,CAAC,UAAkB,EAAE,GAAY;IACrE,OAAO,cAAc,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;AACxC,CAAC","sourcesContent":["import {\n\tfindMostRecent,\n\tgetDefaultSessionDir as getDefaultJsonlSessionDir,\n\tgetDefaultSessionDirPath as getDefaultJsonlSessionDirPath,\n\tJsonlSessionStore,\n\tload,\n} from \"./stores/jsonl-session-store.ts\";\nimport type { FileEntry } from \"./types.ts\";\n\nexport const jsonlSessionStore = new JsonlSessionStore();\n\n/**\n * Compute the default session directory for a cwd.\n * Encodes cwd into a safe directory name under ~/.grip/agent/sessions/.\n */\nexport function getDefaultSessionDir(cwd: string, agentDir?: string): string {\n\treturn getDefaultJsonlSessionDir(cwd, agentDir);\n}\n\ntype JsonlSessionEntryLoadPhase = \"fork\" | \"open\" | \"import\" | \"migrate\";\n\ninterface LoadSessionEntriesOptions {\n\trepair?: boolean;\n\tphase?: JsonlSessionEntryLoadPhase;\n}\n\n/** Exported for testing. */\nexport function loadEntriesFromFile(filePath: string, options: LoadSessionEntriesOptions = {}): FileEntry[] {\n\treturn load(filePath, {}, options.repair ?? true, options.phase ?? \"open\");\n}\n\nexport function getDefaultSessionDirPath(cwd: string, agentDir?: string): string {\n\treturn getDefaultJsonlSessionDirPath(cwd, agentDir);\n}\n\n/** Exported for testing. */\nexport function findMostRecentSession(sessionDir: string, cwd?: string): string | null {\n\treturn findMostRecent(sessionDir, cwd);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"local-session-manager.d.ts","sourceRoot":"","sources":["../../../src/core/session/local-session-manager.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAiB/E,OAAO,KAAK,EAAa,iBAAiB,EAAiB,WAAW,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEhH,MAAM,WAAW,0BAA0B;IAC1C,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,CAAC,EAAE,MAAM,CAAC;CACpB;AASD,qBAAa,mBAAoB,YAAW,cAAc;IACzD,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAS;IAC7B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,6BAA6B,CAAqB;IACnE,OAAO,CAAC,QAAQ,CAAC,2BAA2B,CAG1C;IAEF,YAAY,OAAO,EAAE,0BAA0B,EAG9C;IAED,MAAM,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,YAAY,CAOhD;IAED,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,YAAY,CAmB3E;IAED,cAAc,IAAI,YAAY,CAQ7B;IAED,qBAAqB,IAAI,OAAO,CAE/B;IAED,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,YAAY,CAqCxC;IAED,OAAO,CAAC,oBAAoB;IAS5B,OAAO,CAAC,qBAAqB;IAwB7B,OAAO,CAAC,qCAAqC;IA0B7C,OAAO,CAAC,qBAAqB;IAa7B,OAAO,CAAC,YAAY;IAOpB,WAAW,CAAC,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI,GAAG,YAAY,CAYtE;IAED,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,YAAY,CAiCzE;IAEK,IAAI,CAAC,UAAU,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CASnE;IAEK,OAAO,CAAC,UAAU,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAMtE;CACD","sourcesContent":["import { existsSync, lstatSync, readdirSync } from \"node:fs\";\nimport { basename, dirname, join, resolve } from \"node:path\";\nimport { CURRENT_SESSION_VERSION } from \"./constants.ts\";\nimport { createSessionId } from \"./ids.ts\";\nimport { createJsonlSessionDecodeError } from \"./jsonl-errors.ts\";\nimport {\n\tfindMostRecentSession,\n\tgetDefaultSessionDir,\n\tgetDefaultSessionDirPath,\n\tloadEntriesFromFile,\n} from \"./jsonl-helpers.ts\";\nimport { LocalSession } from \"./local-session.ts\";\nimport { migrateToCurrentVersion } from \"./migrations.ts\";\nimport type { Session } from \"./session.ts\";\nimport type { OpenSessionOptions, SessionManager } from \"./session-manager.ts\";\nimport {\n\tensureDir,\n\tforkSession as forkJsonlSession,\n\tgetJsonlEntryLocations,\n\tgetSessionDirForReference,\n\tgetSessionsRoot,\n\ttype JsonlFirstPublicationCoordinator,\n\tlistAll as listAllJsonlSessions,\n\tlist as listJsonlSessions,\n\tprepareSessionReference,\n\tpublishJsonlAtomically,\n\treadSessionHeader,\n\tSessionAlreadyExistsError,\n\tSessionHeaderScanLimitError,\n\tvalidateCurrentSessionEntries,\n} from \"./stores/jsonl-session-store.ts\";\nimport type { FileEntry, NewSessionOptions, SessionHeader, SessionInfo, SessionListProgress } from \"./types.ts\";\n\nexport interface LocalSessionManagerOptions {\n\tcwd: string;\n\tsessionDir?: string;\n}\n\ntype SessionPublicationPhase = \"create\" | \"fork\" | \"import\";\n\ninterface SessionPublicationClaimOptions {\n\tallowExistingEmptyFile: boolean;\n\tphase: SessionPublicationPhase;\n}\n\nexport class LocalSessionManager implements SessionManager {\n\tprivate readonly cwd: string;\n\tprivate readonly sessionDir?: string;\n\tprivate readonly activePublicationDestinations = new Set<string>();\n\tprivate readonly firstPublicationCoordinator: JsonlFirstPublicationCoordinator = {\n\t\tpublish: (filePath, entries, operation, options) =>\n\t\t\tthis.publishFirstSnapshot(filePath, entries, operation, options),\n\t};\n\n\tconstructor(options: LocalSessionManagerOptions) {\n\t\tthis.cwd = options.cwd;\n\t\tthis.sessionDir = options.sessionDir;\n\t}\n\n\tcreate(options?: NewSessionOptions): LocalSession {\n\t\tconst dir = this.sessionDir ?? getDefaultSessionDir(this.cwd);\n\t\tconst session = new LocalSession(this.cwd, dir, undefined, this, undefined, this.firstPublicationCoordinator);\n\t\tif (options?.id || options?.parentSession) {\n\t\t\tsession.newSession(options);\n\t\t}\n\t\treturn session;\n\t}\n\n\topenReference(reference: string, options?: OpenSessionOptions): LocalSession {\n\t\tlet header: SessionHeader | null = null;\n\t\tlet preloadedFileEntries: FileEntry[] | undefined;\n\t\tif (options?.cwdOverride === undefined && existsSync(reference)) {\n\t\t\ttry {\n\t\t\t\theader = readSessionHeader(reference);\n\t\t\t} catch (error) {\n\t\t\t\tif (!(error instanceof SessionHeaderScanLimitError)) throw error;\n\t\t\t\t// The bounded scan is only a discovery optimization. A full load remains\n\t\t\t\t// authoritative for legacy files with very large headers or prefixes.\n\t\t\t\tpreloadedFileEntries = loadEntriesFromFile(reference);\n\t\t\t\tconst firstEntry = preloadedFileEntries[0];\n\t\t\t\theader = firstEntry?.type === \"session\" ? firstEntry : null;\n\t\t\t}\n\t\t}\n\t\tconst storedCwd = typeof header?.cwd === \"string\" ? header.cwd : undefined;\n\t\tconst cwd = options?.cwdOverride ?? storedCwd ?? this.cwd;\n\t\tconst dir = this.sessionDir ?? getSessionDirForReference(reference);\n\t\treturn new LocalSession(cwd, dir, reference, this, preloadedFileEntries, this.firstPublicationCoordinator);\n\t}\n\n\tcontinueRecent(): LocalSession {\n\t\tconst dir = this.sessionDir ?? getDefaultSessionDir(this.cwd);\n\t\tconst filterCwd = this.sessionDir !== undefined && dir !== getDefaultSessionDirPath(this.cwd);\n\t\tconst mostRecent = findMostRecentSession(dir, filterCwd ? this.cwd : undefined);\n\t\tif (mostRecent) {\n\t\t\treturn new LocalSession(this.cwd, dir, mostRecent, this, undefined, this.firstPublicationCoordinator);\n\t\t}\n\t\treturn new LocalSession(this.cwd, dir, undefined, this, undefined, this.firstPublicationCoordinator);\n\t}\n\n\tusesDefaultSessionDir(): boolean {\n\t\treturn (this.sessionDir ?? getDefaultSessionDir(this.cwd)) === getDefaultSessionDirPath(this.cwd);\n\t}\n\n\tforkFrom(reference: string): LocalSession {\n\t\tconst sourceEntries = loadEntriesFromFile(reference, { repair: false, phase: \"fork\" });\n\t\tif (sourceEntries.length === 0) {\n\t\t\tthrow createJsonlSessionDecodeError(reference, \"fork\", \"schema\", `Cannot fork empty session: ${reference}`);\n\t\t}\n\t\tmigrateToCurrentVersion(sourceEntries);\n\t\tvalidateCurrentSessionEntries(sourceEntries, reference, {\n\t\t\tphase: \"fork\",\n\t\t\tlocations: getJsonlEntryLocations(sourceEntries),\n\t\t});\n\t\tconst sourceHeader = sourceEntries[0];\n\t\tif (sourceHeader?.type !== \"session\") {\n\t\t\tthrow new Error(`Cannot fork: source session has no header: ${reference}`);\n\t\t}\n\n\t\tconst dir = this.sessionDir ?? getDefaultSessionDir(this.cwd);\n\t\tensureDir(dir);\n\n\t\tconst newSessionId = createSessionId();\n\t\tconst timestamp = new Date().toISOString();\n\t\tconst newHeader: SessionHeader = {\n\t\t\ttype: \"session\",\n\t\t\tversion: CURRENT_SESSION_VERSION,\n\t\t\tid: newSessionId,\n\t\t\ttimestamp,\n\t\t\tcwd: this.cwd,\n\t\t\tparentSession: reference,\n\t\t};\n\t\tconst expectedReference = prepareSessionReference(dir, newHeader.id, newHeader.timestamp);\n\t\tconst newSessionReference = this.claimFirstPublication(\n\t\t\texpectedReference,\n\t\t\t[newHeader, ...sourceEntries],\n\t\t\t() => forkJsonlSession(dir, newHeader, sourceEntries),\n\t\t\t{ allowExistingEmptyFile: false, phase: \"fork\" },\n\t\t);\n\n\t\treturn new LocalSession(this.cwd, dir, newSessionReference, this, undefined, this.firstPublicationCoordinator);\n\t}\n\n\tprivate publishFirstSnapshot(\n\t\tfilePath: string,\n\t\tentries: FileEntry[],\n\t\toperation: () => void,\n\t\toptions: SessionPublicationClaimOptions,\n\t): void {\n\t\tthis.claimFirstPublication(filePath, entries, operation, options);\n\t}\n\n\tprivate claimFirstPublication<T>(\n\t\tfilePath: string,\n\t\tentries: FileEntry[],\n\t\toperation: () => T,\n\t\toptions: SessionPublicationClaimOptions = {\n\t\t\tallowExistingEmptyFile: false,\n\t\t\tphase: \"create\",\n\t\t},\n\t): T {\n\t\tconst header = entries.find((entry): entry is SessionHeader => entry.type === \"session\");\n\t\tif (!header) throw new Error(`Cannot publish session without a header: ${filePath}`);\n\t\tconst key = `${this.canonicalCwd(header.cwd)}\\0${header.id}`;\n\t\tif (this.activePublicationDestinations.has(key)) {\n\t\t\tthrow new SessionAlreadyExistsError(filePath, header.id, options.phase);\n\t\t}\n\t\tthis.activePublicationDestinations.add(key);\n\t\ttry {\n\t\t\tthis.rejectExistingSession(filePath, header, options);\n\t\t\treturn operation();\n\t\t} finally {\n\t\t\tthis.activePublicationDestinations.delete(key);\n\t\t}\n\t}\n\n\tprivate rejectConflictingPublicationCandidate(\n\t\tcandidate: string,\n\t\tresolvedTarget: string,\n\t\theader: SessionHeader,\n\t\toptions: SessionPublicationClaimOptions,\n\t): void {\n\t\tif (candidate === resolvedTarget) {\n\t\t\tif (options.allowExistingEmptyFile && lstatSync(candidate).isFile() && lstatSync(candidate).size === 0) return;\n\t\t\tthrow new SessionAlreadyExistsError(candidate, header.id, options.phase);\n\t\t}\n\t\ttry {\n\t\t\tconst existing = readSessionHeader(candidate);\n\t\t\tif (\n\t\t\t\texisting?.id === header.id &&\n\t\t\t\ttypeof existing.cwd === \"string\" &&\n\t\t\t\tthis.canonicalCwd(existing.cwd) === this.canonicalCwd(header.cwd)\n\t\t\t) {\n\t\t\t\tthrow new SessionAlreadyExistsError(candidate, header.id, options.phase);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tif (error instanceof SessionAlreadyExistsError) throw error;\n\t\t\tif (error instanceof SessionHeaderScanLimitError) return;\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tprivate rejectExistingSession(\n\t\tfilePath: string,\n\t\theader: SessionHeader,\n\t\toptions: SessionPublicationClaimOptions,\n\t): void {\n\t\tconst resolvedTarget = resolve(filePath);\n\t\tfor (const name of readdirSync(dirname(resolvedTarget))) {\n\t\t\tif (!name.endsWith(\".jsonl\")) continue;\n\t\t\tconst candidate = resolve(dirname(resolvedTarget), name);\n\t\t\tthis.rejectConflictingPublicationCandidate(candidate, resolvedTarget, header, options);\n\t\t}\n\t}\n\n\tprivate canonicalCwd(cwd: string): string {\n\t\tconst canonical = resolve(cwd);\n\t\treturn process.platform === \"win32\"\n\t\t\t? canonical.replace(/^([A-Z]):/, (_, drive: string) => `${drive.toLowerCase()}:`)\n\t\t\t: canonical;\n\t}\n\n\tforkSession(source: Session, targetLeafId: string | null): LocalSession {\n\t\tconst parentSession = source.getSessionReference();\n\t\tif (!targetLeafId) {\n\t\t\tconst session = this.create();\n\t\t\tsession.newSession({ parentSession });\n\t\t\treturn session;\n\t\t}\n\n\t\tconst branchSource = parentSession && existsSync(parentSession) ? this.openReference(parentSession) : source;\n\t\tconst target = this.create({ parentSession });\n\t\ttarget.copyBranchFrom(branchSource, targetLeafId, parentSession);\n\t\treturn target;\n\t}\n\n\timportJsonl(inputPath: string, options?: OpenSessionOptions): LocalSession {\n\t\tconst resolvedPath = resolve(inputPath);\n\t\tif (!existsSync(resolvedPath)) throw new Error(`File not found: ${resolvedPath}`);\n\n\t\tconst entries = loadEntriesFromFile(resolvedPath, { repair: false, phase: \"import\" });\n\t\tif (entries.length === 0) {\n\t\t\tthrow createJsonlSessionDecodeError(\n\t\t\t\tresolvedPath,\n\t\t\t\t\"import\",\n\t\t\t\t\"schema\",\n\t\t\t\t`Cannot import empty session JSONL: ${resolvedPath}`,\n\t\t\t);\n\t\t}\n\t\tmigrateToCurrentVersion(entries);\n\t\tvalidateCurrentSessionEntries(entries, resolvedPath, {\n\t\t\tphase: \"import\",\n\t\t\tlocations: getJsonlEntryLocations(entries),\n\t\t});\n\n\t\tconst dir = this.sessionDir ?? getDefaultSessionDir(this.cwd);\n\t\tensureDir(dir);\n\t\tconst destinationPath = join(dir, basename(resolvedPath));\n\t\tif (resolve(destinationPath) === resolvedPath) return this.openReference(resolvedPath, options);\n\n\t\tconst header = entries[0];\n\t\tif (header?.type !== \"session\") throw new Error(`Cannot import session without a header: ${resolvedPath}`);\n\t\tthis.claimFirstPublication(\n\t\t\tdestinationPath,\n\t\t\tentries,\n\t\t\t() => publishJsonlAtomically(destinationPath, entries, { phase: \"import\" }),\n\t\t\t{ allowExistingEmptyFile: false, phase: \"import\" },\n\t\t);\n\t\treturn this.openReference(destinationPath, options);\n\t}\n\n\tasync list(onProgress?: SessionListProgress): Promise<SessionInfo[]> {\n\t\tconst dir = this.sessionDir ?? getDefaultSessionDir(this.cwd);\n\t\tconst filterCwd = this.sessionDir !== undefined && dir !== getDefaultSessionDirPath(this.cwd);\n\t\tconst resolvedCwd = resolve(this.cwd);\n\t\tconst sessions = (await listJsonlSessions(dir, onProgress)).filter(\n\t\t\t(session) => !filterCwd || (session.cwd !== undefined && resolve(session.cwd) === resolvedCwd),\n\t\t);\n\t\tsessions.sort((a, b) => b.modified.getTime() - a.modified.getTime());\n\t\treturn sessions;\n\t}\n\n\tasync listAll(onProgress?: SessionListProgress): Promise<SessionInfo[]> {\n\t\tconst sessions = this.sessionDir\n\t\t\t? await listJsonlSessions(this.sessionDir, onProgress)\n\t\t\t: await listAllJsonlSessions(getSessionsRoot(), onProgress);\n\t\tsessions.sort((a, b) => b.modified.getTime() - a.modified.getTime());\n\t\treturn sessions;\n\t}\n}\n"]}
1
+ {"version":3,"file":"local-session-manager.d.ts","sourceRoot":"","sources":["../../../src/core/session/local-session-manager.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAiB/E,OAAO,KAAK,EAAa,iBAAiB,EAAiB,WAAW,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEhH,MAAM,WAAW,0BAA0B;IAC1C,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,CAAC,EAAE,MAAM,CAAC;CACpB;AASD,qBAAa,mBAAoB,YAAW,cAAc;IACzD,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAS;IAC7B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,6BAA6B,CAAqB;IACnE,OAAO,CAAC,QAAQ,CAAC,2BAA2B,CAG1C;IAEF,YAAY,OAAO,EAAE,0BAA0B,EAG9C;IAED,MAAM,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,YAAY,CAOhD;IAED,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,YAAY,CAmB3E;IAED,cAAc,IAAI,YAAY,CAQ7B;IAED,qBAAqB,IAAI,OAAO,CAE/B;IAED,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,YAAY,CAqCxC;IAED,OAAO,CAAC,oBAAoB;IAS5B,OAAO,CAAC,qBAAqB;IAwB7B,OAAO,CAAC,qCAAqC;IA0B7C,OAAO,CAAC,qBAAqB;IAa7B,OAAO,CAAC,YAAY;IAOpB,WAAW,CAAC,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI,GAAG,YAAY,CAYtE;IAED,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,YAAY,CAiCzE;IAEK,IAAI,CAAC,UAAU,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CASnE;IAEK,OAAO,CAAC,UAAU,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAMtE;CACD"}
@@ -8,13 +8,11 @@ import { LocalSession } from "./local-session.js";
8
8
  import { migrateToCurrentVersion } from "./migrations.js";
9
9
  import { ensureDir, forkSession as forkJsonlSession, getJsonlEntryLocations, getSessionDirForReference, getSessionsRoot, listAll as listAllJsonlSessions, list as listJsonlSessions, prepareSessionReference, publishJsonlAtomically, readSessionHeader, SessionAlreadyExistsError, SessionHeaderScanLimitError, validateCurrentSessionEntries, } from "./stores/jsonl-session-store.js";
10
10
  export class LocalSessionManager {
11
- cwd;
12
- sessionDir;
13
- activePublicationDestinations = new Set();
14
- firstPublicationCoordinator = {
15
- publish: (filePath, entries, operation, options) => this.publishFirstSnapshot(filePath, entries, operation, options),
16
- };
17
11
  constructor(options) {
12
+ this.activePublicationDestinations = new Set();
13
+ this.firstPublicationCoordinator = {
14
+ publish: (filePath, entries, operation, options) => this.publishFirstSnapshot(filePath, entries, operation, options),
15
+ };
18
16
  this.cwd = options.cwd;
19
17
  this.sessionDir = options.sessionDir;
20
18
  }
@@ -1 +1 @@
1
- {"version":3,"file":"local-session-manager.js","sourceRoot":"","sources":["../../../src/core/session/local-session-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EACN,qBAAqB,EACrB,oBAAoB,EACpB,wBAAwB,EACxB,mBAAmB,GACnB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAG1D,OAAO,EACN,SAAS,EACT,WAAW,IAAI,gBAAgB,EAC/B,sBAAsB,EACtB,yBAAyB,EACzB,eAAe,EAEf,OAAO,IAAI,oBAAoB,EAC/B,IAAI,IAAI,iBAAiB,EACzB,uBAAuB,EACvB,sBAAsB,EACtB,iBAAiB,EACjB,yBAAyB,EACzB,2BAA2B,EAC3B,6BAA6B,GAC7B,MAAM,iCAAiC,CAAC;AAezC,MAAM,OAAO,mBAAmB;IACd,GAAG,CAAS;IACZ,UAAU,CAAU;IACpB,6BAA6B,GAAG,IAAI,GAAG,EAAU,CAAC;IAClD,2BA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,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;QACrE,OAAO,QAAQ,CAAC;IAAA,CAChB;IAED,KAAK,CAAC,OAAO,CAAC,UAAgC,EAA0B;QACvE,MAAM,QAAQ,GAAG,IAAI,CAAC,UAAU;YAC/B,CAAC,CAAC,MAAM,iBAAiB,CAAC,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC;YACtD,CAAC,CAAC,MAAM,oBAAoB,CAAC,eAAe,EAAE,EAAE,UAAU,CAAC,CAAC;QAC7D,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;QACrE,OAAO,QAAQ,CAAC;IAAA,CAChB;CACD","sourcesContent":["import { existsSync, lstatSync, readdirSync } from \"node:fs\";\nimport { basename, dirname, join, resolve } from \"node:path\";\nimport { CURRENT_SESSION_VERSION } from \"./constants.ts\";\nimport { createSessionId } from \"./ids.ts\";\nimport { createJsonlSessionDecodeError } from \"./jsonl-errors.ts\";\nimport {\n\tfindMostRecentSession,\n\tgetDefaultSessionDir,\n\tgetDefaultSessionDirPath,\n\tloadEntriesFromFile,\n} from \"./jsonl-helpers.ts\";\nimport { LocalSession } from \"./local-session.ts\";\nimport { migrateToCurrentVersion } from \"./migrations.ts\";\nimport type { Session } from \"./session.ts\";\nimport type { OpenSessionOptions, SessionManager } from \"./session-manager.ts\";\nimport {\n\tensureDir,\n\tforkSession as forkJsonlSession,\n\tgetJsonlEntryLocations,\n\tgetSessionDirForReference,\n\tgetSessionsRoot,\n\ttype JsonlFirstPublicationCoordinator,\n\tlistAll as listAllJsonlSessions,\n\tlist as listJsonlSessions,\n\tprepareSessionReference,\n\tpublishJsonlAtomically,\n\treadSessionHeader,\n\tSessionAlreadyExistsError,\n\tSessionHeaderScanLimitError,\n\tvalidateCurrentSessionEntries,\n} from \"./stores/jsonl-session-store.ts\";\nimport type { FileEntry, NewSessionOptions, SessionHeader, SessionInfo, SessionListProgress } from \"./types.ts\";\n\nexport interface LocalSessionManagerOptions {\n\tcwd: string;\n\tsessionDir?: string;\n}\n\ntype SessionPublicationPhase = \"create\" | \"fork\" | \"import\";\n\ninterface SessionPublicationClaimOptions {\n\tallowExistingEmptyFile: boolean;\n\tphase: SessionPublicationPhase;\n}\n\nexport class LocalSessionManager implements SessionManager {\n\tprivate readonly cwd: string;\n\tprivate readonly sessionDir?: string;\n\tprivate readonly activePublicationDestinations = new Set<string>();\n\tprivate readonly firstPublicationCoordinator: JsonlFirstPublicationCoordinator = {\n\t\tpublish: (filePath, entries, operation, options) =>\n\t\t\tthis.publishFirstSnapshot(filePath, entries, operation, options),\n\t};\n\n\tconstructor(options: LocalSessionManagerOptions) {\n\t\tthis.cwd = options.cwd;\n\t\tthis.sessionDir = options.sessionDir;\n\t}\n\n\tcreate(options?: NewSessionOptions): LocalSession {\n\t\tconst dir = this.sessionDir ?? getDefaultSessionDir(this.cwd);\n\t\tconst session = new LocalSession(this.cwd, dir, undefined, this, undefined, this.firstPublicationCoordinator);\n\t\tif (options?.id || options?.parentSession) {\n\t\t\tsession.newSession(options);\n\t\t}\n\t\treturn session;\n\t}\n\n\topenReference(reference: string, options?: OpenSessionOptions): LocalSession {\n\t\tlet header: SessionHeader | null = null;\n\t\tlet preloadedFileEntries: FileEntry[] | undefined;\n\t\tif (options?.cwdOverride === undefined && existsSync(reference)) {\n\t\t\ttry {\n\t\t\t\theader = readSessionHeader(reference);\n\t\t\t} catch (error) {\n\t\t\t\tif (!(error instanceof SessionHeaderScanLimitError)) throw error;\n\t\t\t\t// The bounded scan is only a discovery optimization. A full load remains\n\t\t\t\t// authoritative for legacy files with very large headers or prefixes.\n\t\t\t\tpreloadedFileEntries = loadEntriesFromFile(reference);\n\t\t\t\tconst firstEntry = preloadedFileEntries[0];\n\t\t\t\theader = firstEntry?.type === \"session\" ? firstEntry : null;\n\t\t\t}\n\t\t}\n\t\tconst storedCwd = typeof header?.cwd === \"string\" ? header.cwd : undefined;\n\t\tconst cwd = options?.cwdOverride ?? storedCwd ?? this.cwd;\n\t\tconst dir = this.sessionDir ?? getSessionDirForReference(reference);\n\t\treturn new LocalSession(cwd, dir, reference, this, preloadedFileEntries, this.firstPublicationCoordinator);\n\t}\n\n\tcontinueRecent(): LocalSession {\n\t\tconst dir = this.sessionDir ?? getDefaultSessionDir(this.cwd);\n\t\tconst filterCwd = this.sessionDir !== undefined && dir !== getDefaultSessionDirPath(this.cwd);\n\t\tconst mostRecent = findMostRecentSession(dir, filterCwd ? this.cwd : undefined);\n\t\tif (mostRecent) {\n\t\t\treturn new LocalSession(this.cwd, dir, mostRecent, this, undefined, this.firstPublicationCoordinator);\n\t\t}\n\t\treturn new LocalSession(this.cwd, dir, undefined, this, undefined, this.firstPublicationCoordinator);\n\t}\n\n\tusesDefaultSessionDir(): boolean {\n\t\treturn (this.sessionDir ?? getDefaultSessionDir(this.cwd)) === getDefaultSessionDirPath(this.cwd);\n\t}\n\n\tforkFrom(reference: string): LocalSession {\n\t\tconst sourceEntries = loadEntriesFromFile(reference, { repair: false, phase: \"fork\" });\n\t\tif (sourceEntries.length === 0) {\n\t\t\tthrow createJsonlSessionDecodeError(reference, \"fork\", \"schema\", `Cannot fork empty session: ${reference}`);\n\t\t}\n\t\tmigrateToCurrentVersion(sourceEntries);\n\t\tvalidateCurrentSessionEntries(sourceEntries, reference, {\n\t\t\tphase: \"fork\",\n\t\t\tlocations: getJsonlEntryLocations(sourceEntries),\n\t\t});\n\t\tconst sourceHeader = sourceEntries[0];\n\t\tif (sourceHeader?.type !== \"session\") {\n\t\t\tthrow new Error(`Cannot fork: source session has no header: ${reference}`);\n\t\t}\n\n\t\tconst dir = this.sessionDir ?? getDefaultSessionDir(this.cwd);\n\t\tensureDir(dir);\n\n\t\tconst newSessionId = createSessionId();\n\t\tconst timestamp = new Date().toISOString();\n\t\tconst newHeader: SessionHeader = {\n\t\t\ttype: \"session\",\n\t\t\tversion: CURRENT_SESSION_VERSION,\n\t\t\tid: newSessionId,\n\t\t\ttimestamp,\n\t\t\tcwd: this.cwd,\n\t\t\tparentSession: reference,\n\t\t};\n\t\tconst expectedReference = prepareSessionReference(dir, newHeader.id, newHeader.timestamp);\n\t\tconst newSessionReference = this.claimFirstPublication(\n\t\t\texpectedReference,\n\t\t\t[newHeader, ...sourceEntries],\n\t\t\t() => forkJsonlSession(dir, newHeader, sourceEntries),\n\t\t\t{ allowExistingEmptyFile: false, phase: \"fork\" },\n\t\t);\n\n\t\treturn new LocalSession(this.cwd, dir, newSessionReference, this, undefined, this.firstPublicationCoordinator);\n\t}\n\n\tprivate publishFirstSnapshot(\n\t\tfilePath: string,\n\t\tentries: FileEntry[],\n\t\toperation: () => void,\n\t\toptions: SessionPublicationClaimOptions,\n\t): void {\n\t\tthis.claimFirstPublication(filePath, entries, operation, options);\n\t}\n\n\tprivate claimFirstPublication<T>(\n\t\tfilePath: string,\n\t\tentries: FileEntry[],\n\t\toperation: () => T,\n\t\toptions: SessionPublicationClaimOptions = {\n\t\t\tallowExistingEmptyFile: false,\n\t\t\tphase: \"create\",\n\t\t},\n\t): T {\n\t\tconst header = entries.find((entry): entry is SessionHeader => entry.type === \"session\");\n\t\tif (!header) throw new Error(`Cannot publish session without a header: ${filePath}`);\n\t\tconst key = `${this.canonicalCwd(header.cwd)}\\0${header.id}`;\n\t\tif (this.activePublicationDestinations.has(key)) {\n\t\t\tthrow new SessionAlreadyExistsError(filePath, header.id, options.phase);\n\t\t}\n\t\tthis.activePublicationDestinations.add(key);\n\t\ttry {\n\t\t\tthis.rejectExistingSession(filePath, header, options);\n\t\t\treturn operation();\n\t\t} finally {\n\t\t\tthis.activePublicationDestinations.delete(key);\n\t\t}\n\t}\n\n\tprivate rejectConflictingPublicationCandidate(\n\t\tcandidate: string,\n\t\tresolvedTarget: string,\n\t\theader: SessionHeader,\n\t\toptions: SessionPublicationClaimOptions,\n\t): void {\n\t\tif (candidate === resolvedTarget) {\n\t\t\tif (options.allowExistingEmptyFile && lstatSync(candidate).isFile() && lstatSync(candidate).size === 0) return;\n\t\t\tthrow new SessionAlreadyExistsError(candidate, header.id, options.phase);\n\t\t}\n\t\ttry {\n\t\t\tconst existing = readSessionHeader(candidate);\n\t\t\tif (\n\t\t\t\texisting?.id === header.id &&\n\t\t\t\ttypeof existing.cwd === \"string\" &&\n\t\t\t\tthis.canonicalCwd(existing.cwd) === this.canonicalCwd(header.cwd)\n\t\t\t) {\n\t\t\t\tthrow new SessionAlreadyExistsError(candidate, header.id, options.phase);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tif (error instanceof SessionAlreadyExistsError) throw error;\n\t\t\tif (error instanceof SessionHeaderScanLimitError) return;\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tprivate rejectExistingSession(\n\t\tfilePath: string,\n\t\theader: SessionHeader,\n\t\toptions: SessionPublicationClaimOptions,\n\t): void {\n\t\tconst resolvedTarget = resolve(filePath);\n\t\tfor (const name of readdirSync(dirname(resolvedTarget))) {\n\t\t\tif (!name.endsWith(\".jsonl\")) continue;\n\t\t\tconst candidate = resolve(dirname(resolvedTarget), name);\n\t\t\tthis.rejectConflictingPublicationCandidate(candidate, resolvedTarget, header, options);\n\t\t}\n\t}\n\n\tprivate canonicalCwd(cwd: string): string {\n\t\tconst canonical = resolve(cwd);\n\t\treturn process.platform === \"win32\"\n\t\t\t? canonical.replace(/^([A-Z]):/, (_, drive: string) => `${drive.toLowerCase()}:`)\n\t\t\t: canonical;\n\t}\n\n\tforkSession(source: Session, targetLeafId: string | null): LocalSession {\n\t\tconst parentSession = source.getSessionReference();\n\t\tif (!targetLeafId) {\n\t\t\tconst session = this.create();\n\t\t\tsession.newSession({ parentSession });\n\t\t\treturn session;\n\t\t}\n\n\t\tconst branchSource = parentSession && existsSync(parentSession) ? this.openReference(parentSession) : source;\n\t\tconst target = this.create({ parentSession });\n\t\ttarget.copyBranchFrom(branchSource, targetLeafId, parentSession);\n\t\treturn target;\n\t}\n\n\timportJsonl(inputPath: string, options?: OpenSessionOptions): LocalSession {\n\t\tconst resolvedPath = resolve(inputPath);\n\t\tif (!existsSync(resolvedPath)) throw new Error(`File not found: ${resolvedPath}`);\n\n\t\tconst entries = loadEntriesFromFile(resolvedPath, { repair: false, phase: \"import\" });\n\t\tif (entries.length === 0) {\n\t\t\tthrow createJsonlSessionDecodeError(\n\t\t\t\tresolvedPath,\n\t\t\t\t\"import\",\n\t\t\t\t\"schema\",\n\t\t\t\t`Cannot import empty session JSONL: ${resolvedPath}`,\n\t\t\t);\n\t\t}\n\t\tmigrateToCurrentVersion(entries);\n\t\tvalidateCurrentSessionEntries(entries, resolvedPath, {\n\t\t\tphase: \"import\",\n\t\t\tlocations: getJsonlEntryLocations(entries),\n\t\t});\n\n\t\tconst dir = this.sessionDir ?? getDefaultSessionDir(this.cwd);\n\t\tensureDir(dir);\n\t\tconst destinationPath = join(dir, basename(resolvedPath));\n\t\tif (resolve(destinationPath) === resolvedPath) return this.openReference(resolvedPath, options);\n\n\t\tconst header = entries[0];\n\t\tif (header?.type !== \"session\") throw new Error(`Cannot import session without a header: ${resolvedPath}`);\n\t\tthis.claimFirstPublication(\n\t\t\tdestinationPath,\n\t\t\tentries,\n\t\t\t() => publishJsonlAtomically(destinationPath, entries, { phase: \"import\" }),\n\t\t\t{ allowExistingEmptyFile: false, phase: \"import\" },\n\t\t);\n\t\treturn this.openReference(destinationPath, options);\n\t}\n\n\tasync list(onProgress?: SessionListProgress): Promise<SessionInfo[]> {\n\t\tconst dir = this.sessionDir ?? getDefaultSessionDir(this.cwd);\n\t\tconst filterCwd = this.sessionDir !== undefined && dir !== getDefaultSessionDirPath(this.cwd);\n\t\tconst resolvedCwd = resolve(this.cwd);\n\t\tconst sessions = (await listJsonlSessions(dir, onProgress)).filter(\n\t\t\t(session) => !filterCwd || (session.cwd !== undefined && resolve(session.cwd) === resolvedCwd),\n\t\t);\n\t\tsessions.sort((a, b) => b.modified.getTime() - a.modified.getTime());\n\t\treturn sessions;\n\t}\n\n\tasync listAll(onProgress?: SessionListProgress): Promise<SessionInfo[]> {\n\t\tconst sessions = this.sessionDir\n\t\t\t? await listJsonlSessions(this.sessionDir, onProgress)\n\t\t\t: await listAllJsonlSessions(getSessionsRoot(), onProgress);\n\t\tsessions.sort((a, b) => b.modified.getTime() - a.modified.getTime());\n\t\treturn sessions;\n\t}\n}\n"]}
1
+ {"version":3,"file":"local-session-manager.js","sourceRoot":"","sources":["../../../src/core/session/local-session-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EACN,qBAAqB,EACrB,oBAAoB,EACpB,wBAAwB,EACxB,mBAAmB,GACnB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAG1D,OAAO,EACN,SAAS,EACT,WAAW,IAAI,gBAAgB,EAC/B,sBAAsB,EACtB,yBAAyB,EACzB,eAAe,EAEf,OAAO,IAAI,oBAAoB,EAC/B,IAAI,IAAI,iBAAiB,EACzB,uBAAuB,EACvB,sBAAsB,EACtB,iBAAiB,EACjB,yBAAyB,EACzB,2BAA2B,EAC3B,6BAA6B,GAC7B,MAAM,iCAAiC,CAAC;AAezC,MAAM,OAAO,mBAAmB;IAS/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AC,QAAQ,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;QACrE,OAAO,QAAQ,CAAC;IACjB,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,UAAgC;QAC7C,MAAM,QAAQ,GAAG,IAAI,CAAC,UAAU;YAC/B,CAAC,CAAC,MAAM,iBAAiB,CAAC,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC;YACtD,CAAC,CAAC,MAAM,oBAAoB,CAAC,eAAe,EAAE,EAAE,UAAU,CAAC,CAAC;QAC7D,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;QACrE,OAAO,QAAQ,CAAC;IACjB,CAAC;CACD","sourcesContent":["import { existsSync, lstatSync, readdirSync } from \"node:fs\";\nimport { basename, dirname, join, resolve } from \"node:path\";\nimport { CURRENT_SESSION_VERSION } from \"./constants.ts\";\nimport { createSessionId } from \"./ids.ts\";\nimport { createJsonlSessionDecodeError } from \"./jsonl-errors.ts\";\nimport {\n\tfindMostRecentSession,\n\tgetDefaultSessionDir,\n\tgetDefaultSessionDirPath,\n\tloadEntriesFromFile,\n} from \"./jsonl-helpers.ts\";\nimport { LocalSession } from \"./local-session.ts\";\nimport { migrateToCurrentVersion } from \"./migrations.ts\";\nimport type { Session } from \"./session.ts\";\nimport type { OpenSessionOptions, SessionManager } from \"./session-manager.ts\";\nimport {\n\tensureDir,\n\tforkSession as forkJsonlSession,\n\tgetJsonlEntryLocations,\n\tgetSessionDirForReference,\n\tgetSessionsRoot,\n\ttype JsonlFirstPublicationCoordinator,\n\tlistAll as listAllJsonlSessions,\n\tlist as listJsonlSessions,\n\tprepareSessionReference,\n\tpublishJsonlAtomically,\n\treadSessionHeader,\n\tSessionAlreadyExistsError,\n\tSessionHeaderScanLimitError,\n\tvalidateCurrentSessionEntries,\n} from \"./stores/jsonl-session-store.ts\";\nimport type { FileEntry, NewSessionOptions, SessionHeader, SessionInfo, SessionListProgress } from \"./types.ts\";\n\nexport interface LocalSessionManagerOptions {\n\tcwd: string;\n\tsessionDir?: string;\n}\n\ntype SessionPublicationPhase = \"create\" | \"fork\" | \"import\";\n\ninterface SessionPublicationClaimOptions {\n\tallowExistingEmptyFile: boolean;\n\tphase: SessionPublicationPhase;\n}\n\nexport class LocalSessionManager implements SessionManager {\n\tprivate readonly cwd: string;\n\tprivate readonly sessionDir?: string;\n\tprivate readonly activePublicationDestinations = new Set<string>();\n\tprivate readonly firstPublicationCoordinator: JsonlFirstPublicationCoordinator = {\n\t\tpublish: (filePath, entries, operation, options) =>\n\t\t\tthis.publishFirstSnapshot(filePath, entries, operation, options),\n\t};\n\n\tconstructor(options: LocalSessionManagerOptions) {\n\t\tthis.cwd = options.cwd;\n\t\tthis.sessionDir = options.sessionDir;\n\t}\n\n\tcreate(options?: NewSessionOptions): LocalSession {\n\t\tconst dir = this.sessionDir ?? getDefaultSessionDir(this.cwd);\n\t\tconst session = new LocalSession(this.cwd, dir, undefined, this, undefined, this.firstPublicationCoordinator);\n\t\tif (options?.id || options?.parentSession) {\n\t\t\tsession.newSession(options);\n\t\t}\n\t\treturn session;\n\t}\n\n\topenReference(reference: string, options?: OpenSessionOptions): LocalSession {\n\t\tlet header: SessionHeader | null = null;\n\t\tlet preloadedFileEntries: FileEntry[] | undefined;\n\t\tif (options?.cwdOverride === undefined && existsSync(reference)) {\n\t\t\ttry {\n\t\t\t\theader = readSessionHeader(reference);\n\t\t\t} catch (error) {\n\t\t\t\tif (!(error instanceof SessionHeaderScanLimitError)) throw error;\n\t\t\t\t// The bounded scan is only a discovery optimization. A full load remains\n\t\t\t\t// authoritative for legacy files with very large headers or prefixes.\n\t\t\t\tpreloadedFileEntries = loadEntriesFromFile(reference);\n\t\t\t\tconst firstEntry = preloadedFileEntries[0];\n\t\t\t\theader = firstEntry?.type === \"session\" ? firstEntry : null;\n\t\t\t}\n\t\t}\n\t\tconst storedCwd = typeof header?.cwd === \"string\" ? header.cwd : undefined;\n\t\tconst cwd = options?.cwdOverride ?? storedCwd ?? this.cwd;\n\t\tconst dir = this.sessionDir ?? getSessionDirForReference(reference);\n\t\treturn new LocalSession(cwd, dir, reference, this, preloadedFileEntries, this.firstPublicationCoordinator);\n\t}\n\n\tcontinueRecent(): LocalSession {\n\t\tconst dir = this.sessionDir ?? getDefaultSessionDir(this.cwd);\n\t\tconst filterCwd = this.sessionDir !== undefined && dir !== getDefaultSessionDirPath(this.cwd);\n\t\tconst mostRecent = findMostRecentSession(dir, filterCwd ? this.cwd : undefined);\n\t\tif (mostRecent) {\n\t\t\treturn new LocalSession(this.cwd, dir, mostRecent, this, undefined, this.firstPublicationCoordinator);\n\t\t}\n\t\treturn new LocalSession(this.cwd, dir, undefined, this, undefined, this.firstPublicationCoordinator);\n\t}\n\n\tusesDefaultSessionDir(): boolean {\n\t\treturn (this.sessionDir ?? getDefaultSessionDir(this.cwd)) === getDefaultSessionDirPath(this.cwd);\n\t}\n\n\tforkFrom(reference: string): LocalSession {\n\t\tconst sourceEntries = loadEntriesFromFile(reference, { repair: false, phase: \"fork\" });\n\t\tif (sourceEntries.length === 0) {\n\t\t\tthrow createJsonlSessionDecodeError(reference, \"fork\", \"schema\", `Cannot fork empty session: ${reference}`);\n\t\t}\n\t\tmigrateToCurrentVersion(sourceEntries);\n\t\tvalidateCurrentSessionEntries(sourceEntries, reference, {\n\t\t\tphase: \"fork\",\n\t\t\tlocations: getJsonlEntryLocations(sourceEntries),\n\t\t});\n\t\tconst sourceHeader = sourceEntries[0];\n\t\tif (sourceHeader?.type !== \"session\") {\n\t\t\tthrow new Error(`Cannot fork: source session has no header: ${reference}`);\n\t\t}\n\n\t\tconst dir = this.sessionDir ?? getDefaultSessionDir(this.cwd);\n\t\tensureDir(dir);\n\n\t\tconst newSessionId = createSessionId();\n\t\tconst timestamp = new Date().toISOString();\n\t\tconst newHeader: SessionHeader = {\n\t\t\ttype: \"session\",\n\t\t\tversion: CURRENT_SESSION_VERSION,\n\t\t\tid: newSessionId,\n\t\t\ttimestamp,\n\t\t\tcwd: this.cwd,\n\t\t\tparentSession: reference,\n\t\t};\n\t\tconst expectedReference = prepareSessionReference(dir, newHeader.id, newHeader.timestamp);\n\t\tconst newSessionReference = this.claimFirstPublication(\n\t\t\texpectedReference,\n\t\t\t[newHeader, ...sourceEntries],\n\t\t\t() => forkJsonlSession(dir, newHeader, sourceEntries),\n\t\t\t{ allowExistingEmptyFile: false, phase: \"fork\" },\n\t\t);\n\n\t\treturn new LocalSession(this.cwd, dir, newSessionReference, this, undefined, this.firstPublicationCoordinator);\n\t}\n\n\tprivate publishFirstSnapshot(\n\t\tfilePath: string,\n\t\tentries: FileEntry[],\n\t\toperation: () => void,\n\t\toptions: SessionPublicationClaimOptions,\n\t): void {\n\t\tthis.claimFirstPublication(filePath, entries, operation, options);\n\t}\n\n\tprivate claimFirstPublication<T>(\n\t\tfilePath: string,\n\t\tentries: FileEntry[],\n\t\toperation: () => T,\n\t\toptions: SessionPublicationClaimOptions = {\n\t\t\tallowExistingEmptyFile: false,\n\t\t\tphase: \"create\",\n\t\t},\n\t): T {\n\t\tconst header = entries.find((entry): entry is SessionHeader => entry.type === \"session\");\n\t\tif (!header) throw new Error(`Cannot publish session without a header: ${filePath}`);\n\t\tconst key = `${this.canonicalCwd(header.cwd)}\\0${header.id}`;\n\t\tif (this.activePublicationDestinations.has(key)) {\n\t\t\tthrow new SessionAlreadyExistsError(filePath, header.id, options.phase);\n\t\t}\n\t\tthis.activePublicationDestinations.add(key);\n\t\ttry {\n\t\t\tthis.rejectExistingSession(filePath, header, options);\n\t\t\treturn operation();\n\t\t} finally {\n\t\t\tthis.activePublicationDestinations.delete(key);\n\t\t}\n\t}\n\n\tprivate rejectConflictingPublicationCandidate(\n\t\tcandidate: string,\n\t\tresolvedTarget: string,\n\t\theader: SessionHeader,\n\t\toptions: SessionPublicationClaimOptions,\n\t): void {\n\t\tif (candidate === resolvedTarget) {\n\t\t\tif (options.allowExistingEmptyFile && lstatSync(candidate).isFile() && lstatSync(candidate).size === 0) return;\n\t\t\tthrow new SessionAlreadyExistsError(candidate, header.id, options.phase);\n\t\t}\n\t\ttry {\n\t\t\tconst existing = readSessionHeader(candidate);\n\t\t\tif (\n\t\t\t\texisting?.id === header.id &&\n\t\t\t\ttypeof existing.cwd === \"string\" &&\n\t\t\t\tthis.canonicalCwd(existing.cwd) === this.canonicalCwd(header.cwd)\n\t\t\t) {\n\t\t\t\tthrow new SessionAlreadyExistsError(candidate, header.id, options.phase);\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tif (error instanceof SessionAlreadyExistsError) throw error;\n\t\t\tif (error instanceof SessionHeaderScanLimitError) return;\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tprivate rejectExistingSession(\n\t\tfilePath: string,\n\t\theader: SessionHeader,\n\t\toptions: SessionPublicationClaimOptions,\n\t): void {\n\t\tconst resolvedTarget = resolve(filePath);\n\t\tfor (const name of readdirSync(dirname(resolvedTarget))) {\n\t\t\tif (!name.endsWith(\".jsonl\")) continue;\n\t\t\tconst candidate = resolve(dirname(resolvedTarget), name);\n\t\t\tthis.rejectConflictingPublicationCandidate(candidate, resolvedTarget, header, options);\n\t\t}\n\t}\n\n\tprivate canonicalCwd(cwd: string): string {\n\t\tconst canonical = resolve(cwd);\n\t\treturn process.platform === \"win32\"\n\t\t\t? canonical.replace(/^([A-Z]):/, (_, drive: string) => `${drive.toLowerCase()}:`)\n\t\t\t: canonical;\n\t}\n\n\tforkSession(source: Session, targetLeafId: string | null): LocalSession {\n\t\tconst parentSession = source.getSessionReference();\n\t\tif (!targetLeafId) {\n\t\t\tconst session = this.create();\n\t\t\tsession.newSession({ parentSession });\n\t\t\treturn session;\n\t\t}\n\n\t\tconst branchSource = parentSession && existsSync(parentSession) ? this.openReference(parentSession) : source;\n\t\tconst target = this.create({ parentSession });\n\t\ttarget.copyBranchFrom(branchSource, targetLeafId, parentSession);\n\t\treturn target;\n\t}\n\n\timportJsonl(inputPath: string, options?: OpenSessionOptions): LocalSession {\n\t\tconst resolvedPath = resolve(inputPath);\n\t\tif (!existsSync(resolvedPath)) throw new Error(`File not found: ${resolvedPath}`);\n\n\t\tconst entries = loadEntriesFromFile(resolvedPath, { repair: false, phase: \"import\" });\n\t\tif (entries.length === 0) {\n\t\t\tthrow createJsonlSessionDecodeError(\n\t\t\t\tresolvedPath,\n\t\t\t\t\"import\",\n\t\t\t\t\"schema\",\n\t\t\t\t`Cannot import empty session JSONL: ${resolvedPath}`,\n\t\t\t);\n\t\t}\n\t\tmigrateToCurrentVersion(entries);\n\t\tvalidateCurrentSessionEntries(entries, resolvedPath, {\n\t\t\tphase: \"import\",\n\t\t\tlocations: getJsonlEntryLocations(entries),\n\t\t});\n\n\t\tconst dir = this.sessionDir ?? getDefaultSessionDir(this.cwd);\n\t\tensureDir(dir);\n\t\tconst destinationPath = join(dir, basename(resolvedPath));\n\t\tif (resolve(destinationPath) === resolvedPath) return this.openReference(resolvedPath, options);\n\n\t\tconst header = entries[0];\n\t\tif (header?.type !== \"session\") throw new Error(`Cannot import session without a header: ${resolvedPath}`);\n\t\tthis.claimFirstPublication(\n\t\t\tdestinationPath,\n\t\t\tentries,\n\t\t\t() => publishJsonlAtomically(destinationPath, entries, { phase: \"import\" }),\n\t\t\t{ allowExistingEmptyFile: false, phase: \"import\" },\n\t\t);\n\t\treturn this.openReference(destinationPath, options);\n\t}\n\n\tasync list(onProgress?: SessionListProgress): Promise<SessionInfo[]> {\n\t\tconst dir = this.sessionDir ?? getDefaultSessionDir(this.cwd);\n\t\tconst filterCwd = this.sessionDir !== undefined && dir !== getDefaultSessionDirPath(this.cwd);\n\t\tconst resolvedCwd = resolve(this.cwd);\n\t\tconst sessions = (await listJsonlSessions(dir, onProgress)).filter(\n\t\t\t(session) => !filterCwd || (session.cwd !== undefined && resolve(session.cwd) === resolvedCwd),\n\t\t);\n\t\tsessions.sort((a, b) => b.modified.getTime() - a.modified.getTime());\n\t\treturn sessions;\n\t}\n\n\tasync listAll(onProgress?: SessionListProgress): Promise<SessionInfo[]> {\n\t\tconst sessions = this.sessionDir\n\t\t\t? await listJsonlSessions(this.sessionDir, onProgress)\n\t\t\t: await listAllJsonlSessions(getSessionsRoot(), onProgress);\n\t\tsessions.sort((a, b) => b.modified.getTime() - a.modified.getTime());\n\t\treturn sessions;\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"local-session.d.ts","sourceRoot":"","sources":["../../../src/core/session/local-session.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,KAAK,gCAAgC,EAAqB,MAAM,iCAAiC,CAAC;AAC3G,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,qBAAa,YAAa,SAAQ,OAAO;IACxC,YACC,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,MAAM,EAClB,gBAAgB,EAAE,MAAM,GAAG,SAAS,EACpC,cAAc,CAAC,EAAE,cAAc,EAC/B,oBAAoB,CAAC,EAAE,SAAS,EAAE,EAClC,2BAA2B,CAAC,EAAE,gCAAgC,EAe9D;IAED,SAAS,CAAC,0BAA0B,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAGjH;CACD","sourcesContent":["import { join } from \"node:path\";\nimport { Session } from \"./session.ts\";\nimport type { SessionManager } from \"./session-manager.ts\";\nimport { type JsonlFirstPublicationCoordinator, JsonlSessionStore } from \"./stores/jsonl-session-store.ts\";\nimport type { FileEntry } from \"./types.ts\";\n\nexport class LocalSession extends Session {\n\tconstructor(\n\t\tcwd: string,\n\t\tsessionDir: string,\n\t\tsessionReference: string | undefined,\n\t\tsessionManager?: SessionManager,\n\t\tpreloadedFileEntries?: FileEntry[],\n\t\tfirstPublicationCoordinator?: JsonlFirstPublicationCoordinator,\n\t) {\n\t\tsuper(\n\t\t\tcwd,\n\t\t\tsessionDir,\n\t\t\tsessionReference,\n\t\t\tnew JsonlSessionStore(\n\t\t\t\tsessionReference && preloadedFileEntries\n\t\t\t\t\t? { reference: sessionReference, entries: preloadedFileEntries }\n\t\t\t\t\t: undefined,\n\t\t\t\tundefined,\n\t\t\t\tfirstPublicationCoordinator,\n\t\t\t),\n\t\t\tsessionManager,\n\t\t);\n\t}\n\n\tprotected prepareNewSessionReference(sessionDir: string, sessionId: string, timestamp: string): string | undefined {\n\t\tconst fileTimestamp = timestamp.replace(/[:.]/g, \"-\");\n\t\treturn join(sessionDir, `${fileTimestamp}_${sessionId}.jsonl`);\n\t}\n}\n"]}
1
+ {"version":3,"file":"local-session.d.ts","sourceRoot":"","sources":["../../../src/core/session/local-session.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,KAAK,gCAAgC,EAAqB,MAAM,iCAAiC,CAAC;AAC3G,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,qBAAa,YAAa,SAAQ,OAAO;IACxC,YACC,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,MAAM,EAClB,gBAAgB,EAAE,MAAM,GAAG,SAAS,EACpC,cAAc,CAAC,EAAE,cAAc,EAC/B,oBAAoB,CAAC,EAAE,SAAS,EAAE,EAClC,2BAA2B,CAAC,EAAE,gCAAgC,EAe9D;IAED,SAAS,CAAC,0BAA0B,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAGjH;CACD"}
@@ -1 +1 @@
1
- {"version":3,"file":"local-session.js","sourceRoot":"","sources":["../../../src/core/session/local-session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAyC,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAG3G,MAAM,OAAO,YAAa,SAAQ,OAAO;IACxC,YACC,GAAW,EACX,UAAkB,EAClB,gBAAoC,EACpC,cAA+B,EAC/B,oBAAkC,EAClC,2BAA8D,EAC7D;QACD,KAAK,CACJ,GAAG,EACH,UAAU,EACV,gBAAgB,EAChB,IAAI,iBAAiB,CACpB,gBAAgB,IAAI,oBAAoB;YACvC,CAAC,CAAC,EAAE,SAAS,EAAE,gBAAgB,EAAE,OAAO,EAAE,oBAAoB,EAAE;YAChE,CAAC,CAAC,SAAS,EACZ,SAAS,EACT,2BAA2B,CAC3B,EACD,cAAc,CACd,CAAC;IAAA,CACF;IAES,0BAA0B,CAAC,UAAkB,EAAE,SAAiB,EAAE,SAAiB,EAAsB;QAClH,MAAM,aAAa,GAAG,SAAS,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QACtD,OAAO,IAAI,CAAC,UAAU,EAAE,GAAG,aAAa,IAAI,SAAS,QAAQ,CAAC,CAAC;IAAA,CAC/D;CACD","sourcesContent":["import { join } from \"node:path\";\nimport { Session } from \"./session.ts\";\nimport type { SessionManager } from \"./session-manager.ts\";\nimport { type JsonlFirstPublicationCoordinator, JsonlSessionStore } from \"./stores/jsonl-session-store.ts\";\nimport type { FileEntry } from \"./types.ts\";\n\nexport class LocalSession extends Session {\n\tconstructor(\n\t\tcwd: string,\n\t\tsessionDir: string,\n\t\tsessionReference: string | undefined,\n\t\tsessionManager?: SessionManager,\n\t\tpreloadedFileEntries?: FileEntry[],\n\t\tfirstPublicationCoordinator?: JsonlFirstPublicationCoordinator,\n\t) {\n\t\tsuper(\n\t\t\tcwd,\n\t\t\tsessionDir,\n\t\t\tsessionReference,\n\t\t\tnew JsonlSessionStore(\n\t\t\t\tsessionReference && preloadedFileEntries\n\t\t\t\t\t? { reference: sessionReference, entries: preloadedFileEntries }\n\t\t\t\t\t: undefined,\n\t\t\t\tundefined,\n\t\t\t\tfirstPublicationCoordinator,\n\t\t\t),\n\t\t\tsessionManager,\n\t\t);\n\t}\n\n\tprotected prepareNewSessionReference(sessionDir: string, sessionId: string, timestamp: string): string | undefined {\n\t\tconst fileTimestamp = timestamp.replace(/[:.]/g, \"-\");\n\t\treturn join(sessionDir, `${fileTimestamp}_${sessionId}.jsonl`);\n\t}\n}\n"]}
1
+ {"version":3,"file":"local-session.js","sourceRoot":"","sources":["../../../src/core/session/local-session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAyC,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAG3G,MAAM,OAAO,YAAa,SAAQ,OAAO;IACxC,YACC,GAAW,EACX,UAAkB,EAClB,gBAAoC,EACpC,cAA+B,EAC/B,oBAAkC,EAClC,2BAA8D;QAE9D,KAAK,CACJ,GAAG,EACH,UAAU,EACV,gBAAgB,EAChB,IAAI,iBAAiB,CACpB,gBAAgB,IAAI,oBAAoB;YACvC,CAAC,CAAC,EAAE,SAAS,EAAE,gBAAgB,EAAE,OAAO,EAAE,oBAAoB,EAAE;YAChE,CAAC,CAAC,SAAS,EACZ,SAAS,EACT,2BAA2B,CAC3B,EACD,cAAc,CACd,CAAC;IACH,CAAC;IAES,0BAA0B,CAAC,UAAkB,EAAE,SAAiB,EAAE,SAAiB;QAC5F,MAAM,aAAa,GAAG,SAAS,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QACtD,OAAO,IAAI,CAAC,UAAU,EAAE,GAAG,aAAa,IAAI,SAAS,QAAQ,CAAC,CAAC;IAChE,CAAC;CACD","sourcesContent":["import { join } from \"node:path\";\nimport { Session } from \"./session.ts\";\nimport type { SessionManager } from \"./session-manager.ts\";\nimport { type JsonlFirstPublicationCoordinator, JsonlSessionStore } from \"./stores/jsonl-session-store.ts\";\nimport type { FileEntry } from \"./types.ts\";\n\nexport class LocalSession extends Session {\n\tconstructor(\n\t\tcwd: string,\n\t\tsessionDir: string,\n\t\tsessionReference: string | undefined,\n\t\tsessionManager?: SessionManager,\n\t\tpreloadedFileEntries?: FileEntry[],\n\t\tfirstPublicationCoordinator?: JsonlFirstPublicationCoordinator,\n\t) {\n\t\tsuper(\n\t\t\tcwd,\n\t\t\tsessionDir,\n\t\t\tsessionReference,\n\t\t\tnew JsonlSessionStore(\n\t\t\t\tsessionReference && preloadedFileEntries\n\t\t\t\t\t? { reference: sessionReference, entries: preloadedFileEntries }\n\t\t\t\t\t: undefined,\n\t\t\t\tundefined,\n\t\t\t\tfirstPublicationCoordinator,\n\t\t\t),\n\t\t\tsessionManager,\n\t\t);\n\t}\n\n\tprotected prepareNewSessionReference(sessionDir: string, sessionId: string, timestamp: string): string | undefined {\n\t\tconst fileTimestamp = timestamp.replace(/[:.]/g, \"-\");\n\t\treturn join(sessionDir, `${fileTimestamp}_${sessionId}.jsonl`);\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["../../../src/core/session/migrations.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAmB,SAAS,EAAsC,MAAM,YAAY,CAAC;AA+CjG;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,SAAS,EAAE,GAAG,OAAO,CAUrE;AAED,4BAA4B;AAC5B,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,SAAS,EAAE,GAAG,IAAI,CAEhE;AAED,qCAAqC;AACrC,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,EAAE,CAehE","sourcesContent":["import { CURRENT_SESSION_VERSION } from \"./constants.ts\";\nimport { generateId } from \"./ids.ts\";\nimport type { CompactionEntry, FileEntry, SessionHeader, SessionMessageEntry } from \"./types.ts\";\n\n/** Migrate v1 → v2: add id/parentId tree structure. Mutates in place. */\nfunction migrateV1ToV2(entries: FileEntry[]): void {\n\tconst ids = new Set<string>();\n\tlet prevId: string | null = null;\n\n\tfor (const entry of entries) {\n\t\tif (entry.type === \"session\") {\n\t\t\tentry.version = 2;\n\t\t\tcontinue;\n\t\t}\n\n\t\tentry.id = generateId(ids);\n\t\tentry.parentId = prevId;\n\t\tprevId = entry.id;\n\n\t\tif (entry.type === \"compaction\") {\n\t\t\tconst comp = entry as CompactionEntry & { firstKeptEntryIndex?: number };\n\t\t\tif (typeof comp.firstKeptEntryIndex === \"number\") {\n\t\t\t\tconst targetEntry = entries[comp.firstKeptEntryIndex];\n\t\t\t\tif (targetEntry && targetEntry.type !== \"session\") {\n\t\t\t\t\tcomp.firstKeptEntryId = targetEntry.id;\n\t\t\t\t}\n\t\t\t\tdelete comp.firstKeptEntryIndex;\n\t\t\t}\n\t\t}\n\t}\n}\n\n/** Migrate v2 → v3: rename hookMessage role to custom. Mutates in place. */\nfunction migrateV2ToV3(entries: FileEntry[]): void {\n\tfor (const entry of entries) {\n\t\tif (entry.type === \"session\") {\n\t\t\tentry.version = 3;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (entry.type === \"message\") {\n\t\t\tconst msgEntry = entry as SessionMessageEntry;\n\t\t\tif (msgEntry.message && (msgEntry.message as { role: string }).role === \"hookMessage\") {\n\t\t\t\t(msgEntry.message as { role: string }).role = \"custom\";\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Run all necessary migrations to bring entries to current version.\n * Mutates entries in place. Returns true if any migration was applied.\n */\nexport function migrateToCurrentVersion(entries: FileEntry[]): boolean {\n\tconst header = entries.find((entry) => entry.type === \"session\") as SessionHeader | undefined;\n\tconst version = header?.version ?? 1;\n\n\tif (version >= CURRENT_SESSION_VERSION) return false;\n\n\tif (version < 2) migrateV1ToV2(entries);\n\tif (version < 3) migrateV2ToV3(entries);\n\n\treturn true;\n}\n\n/** Exported for testing. */\nexport function migrateSessionEntries(entries: FileEntry[]): void {\n\tmigrateToCurrentVersion(entries);\n}\n\n/** Exported for compaction tests. */\nexport function parseSessionEntries(content: string): FileEntry[] {\n\tconst entries: FileEntry[] = [];\n\tconst lines = content.trim().split(\"\\n\");\n\n\tfor (const line of lines) {\n\t\tif (!line.trim()) continue;\n\t\ttry {\n\t\t\tconst entry = JSON.parse(line) as FileEntry;\n\t\t\tentries.push(entry);\n\t\t} catch {\n\t\t\t// Skip malformed lines.\n\t\t}\n\t}\n\n\treturn entries;\n}\n"]}
1
+ {"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["../../../src/core/session/migrations.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAmB,SAAS,EAAsC,MAAM,YAAY,CAAC;AA+CjG;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,SAAS,EAAE,GAAG,OAAO,CAUrE;AAED,4BAA4B;AAC5B,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,SAAS,EAAE,GAAG,IAAI,CAEhE;AAED,qCAAqC;AACrC,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,EAAE,CAehE"}
@@ -1 +1 @@
1
- {"version":3,"file":"migrations.js","sourceRoot":"","sources":["../../../src/core/session/migrations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAGtC,2EAAyE;AACzE,SAAS,aAAa,CAAC,OAAoB,EAAQ;IAClD,MAAM,GAAG,GAAG,IAAI,GAAG,EAAU,CAAC;IAC9B,IAAI,MAAM,GAAkB,IAAI,CAAC;IAEjC,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC7B,IAAI,KAAK,CAAC,I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BAAuB,CAAC,OAAoB,EAAW;IACtE,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS,CAA8B,CAAC;IAC9F,MAAM,OAAO,GAAG,MAAM,EAAE,OAAO,IAAI,CAAC,CAAC;IAErC,IAAI,OAAO,IAAI,uBAAuB;QAAE,OAAO,KAAK,CAAC;IAErD,IAAI,OAAO,GAAG,CAAC;QAAE,aAAa,CAAC,OAAO,CAAC,CAAC;IACxC,IAAI,OAAO,GAAG,CAAC;QAAE,aAAa,CAAC,OAAO,CAAC,CAAC;IAExC,OAAO,IAAI,CAAC;AAAA,CACZ;AAED,4BAA4B;AAC5B,MAAM,UAAU,qBAAqB,CAAC,OAAoB,EAAQ;IACjE,uBAAuB,CAAC,OAAO,CAAC,CAAC;AAAA,CACjC;AAED,qCAAqC;AACrC,MAAM,UAAU,mBAAmB,CAAC,OAAe,EAAe;IACjE,MAAM,OAAO,GAAgB,EAAE,CAAC;IAChC,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAEzC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QAC1B,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;YAAE,SAAS;QAC3B,IAAI,CAAC;YACJ,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAc,CAAC;YAC5C,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACrB,CAAC;QAAC,MAAM,CAAC;YACR,wBAAwB;QACzB,CAAC;IACF,CAAC;IAED,OAAO,OAAO,CAAC;AAAA,CACf","sourcesContent":["import { CURRENT_SESSION_VERSION } from \"./constants.ts\";\nimport { generateId } from \"./ids.ts\";\nimport type { CompactionEntry, FileEntry, SessionHeader, SessionMessageEntry } from \"./types.ts\";\n\n/** Migrate v1 → v2: add id/parentId tree structure. Mutates in place. */\nfunction migrateV1ToV2(entries: FileEntry[]): void {\n\tconst ids = new Set<string>();\n\tlet prevId: string | null = null;\n\n\tfor (const entry of entries) {\n\t\tif (entry.type === \"session\") {\n\t\t\tentry.version = 2;\n\t\t\tcontinue;\n\t\t}\n\n\t\tentry.id = generateId(ids);\n\t\tentry.parentId = prevId;\n\t\tprevId = entry.id;\n\n\t\tif (entry.type === \"compaction\") {\n\t\t\tconst comp = entry as CompactionEntry & { firstKeptEntryIndex?: number };\n\t\t\tif (typeof comp.firstKeptEntryIndex === \"number\") {\n\t\t\t\tconst targetEntry = entries[comp.firstKeptEntryIndex];\n\t\t\t\tif (targetEntry && targetEntry.type !== \"session\") {\n\t\t\t\t\tcomp.firstKeptEntryId = targetEntry.id;\n\t\t\t\t}\n\t\t\t\tdelete comp.firstKeptEntryIndex;\n\t\t\t}\n\t\t}\n\t}\n}\n\n/** Migrate v2 → v3: rename hookMessage role to custom. Mutates in place. */\nfunction migrateV2ToV3(entries: FileEntry[]): void {\n\tfor (const entry of entries) {\n\t\tif (entry.type === \"session\") {\n\t\t\tentry.version = 3;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (entry.type === \"message\") {\n\t\t\tconst msgEntry = entry as SessionMessageEntry;\n\t\t\tif (msgEntry.message && (msgEntry.message as { role: string }).role === \"hookMessage\") {\n\t\t\t\t(msgEntry.message as { role: string }).role = \"custom\";\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Run all necessary migrations to bring entries to current version.\n * Mutates entries in place. Returns true if any migration was applied.\n */\nexport function migrateToCurrentVersion(entries: FileEntry[]): boolean {\n\tconst header = entries.find((entry) => entry.type === \"session\") as SessionHeader | undefined;\n\tconst version = header?.version ?? 1;\n\n\tif (version >= CURRENT_SESSION_VERSION) return false;\n\n\tif (version < 2) migrateV1ToV2(entries);\n\tif (version < 3) migrateV2ToV3(entries);\n\n\treturn true;\n}\n\n/** Exported for testing. */\nexport function migrateSessionEntries(entries: FileEntry[]): void {\n\tmigrateToCurrentVersion(entries);\n}\n\n/** Exported for compaction tests. */\nexport function parseSessionEntries(content: string): FileEntry[] {\n\tconst entries: FileEntry[] = [];\n\tconst lines = content.trim().split(\"\\n\");\n\n\tfor (const line of lines) {\n\t\tif (!line.trim()) continue;\n\t\ttry {\n\t\t\tconst entry = JSON.parse(line) as FileEntry;\n\t\t\tentries.push(entry);\n\t\t} catch {\n\t\t\t// Skip malformed lines.\n\t\t}\n\t}\n\n\treturn entries;\n}\n"]}
1
+ {"version":3,"file":"migrations.js","sourceRoot":"","sources":["../../../src/core/session/migrations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAGtC,yEAAyE;AACzE,SAAS,aAAa,CAAC,OAAoB;IAC1C,MAAM,GAAG,GAAG,IAAI,GAAG,EAAU,CAAC;IAC9B,IAAI,MAAM,GAAkB,IAAI,CAAC;IAEjC,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC7B,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;YAC9B,KAAK,CAAC,OAAO,GAAG,CAAC,CAAC;YAClB,SAAS;QACV,CAAC;QAED,KAAK,CAAC,EAAE,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC;QAC3B,KAAK,CAAC,QAAQ,GAAG,MAAM,CAAC;QACxB,MAAM,GAAG,KAAK,CAAC,EAAE,CAAC;QAElB,IAAI,KAAK,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;YACjC,MAAM,IAAI,GAAG,KAA2D,CAAC;YACzE,IAAI,OAAO,IAAI,CAAC,mBAAmB,KAAK,QAAQ,EAAE,CAAC;gBAClD,MAAM,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;gBACtD,IAAI,WAAW,IAAI,WAAW,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;oBACnD,IAAI,CAAC,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UAAU,mBAAmB,CAAC,OAAe;IAClD,MAAM,OAAO,GAAgB,EAAE,CAAC;IAChC,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAEzC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QAC1B,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;YAAE,SAAS;QAC3B,IAAI,CAAC;YACJ,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAc,CAAC;YAC5C,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACrB,CAAC;QAAC,MAAM,CAAC;YACR,wBAAwB;QACzB,CAAC;IACF,CAAC;IAED,OAAO,OAAO,CAAC;AAChB,CAAC","sourcesContent":["import { CURRENT_SESSION_VERSION } from \"./constants.ts\";\nimport { generateId } from \"./ids.ts\";\nimport type { CompactionEntry, FileEntry, SessionHeader, SessionMessageEntry } from \"./types.ts\";\n\n/** Migrate v1 → v2: add id/parentId tree structure. Mutates in place. */\nfunction migrateV1ToV2(entries: FileEntry[]): void {\n\tconst ids = new Set<string>();\n\tlet prevId: string | null = null;\n\n\tfor (const entry of entries) {\n\t\tif (entry.type === \"session\") {\n\t\t\tentry.version = 2;\n\t\t\tcontinue;\n\t\t}\n\n\t\tentry.id = generateId(ids);\n\t\tentry.parentId = prevId;\n\t\tprevId = entry.id;\n\n\t\tif (entry.type === \"compaction\") {\n\t\t\tconst comp = entry as CompactionEntry & { firstKeptEntryIndex?: number };\n\t\t\tif (typeof comp.firstKeptEntryIndex === \"number\") {\n\t\t\t\tconst targetEntry = entries[comp.firstKeptEntryIndex];\n\t\t\t\tif (targetEntry && targetEntry.type !== \"session\") {\n\t\t\t\t\tcomp.firstKeptEntryId = targetEntry.id;\n\t\t\t\t}\n\t\t\t\tdelete comp.firstKeptEntryIndex;\n\t\t\t}\n\t\t}\n\t}\n}\n\n/** Migrate v2 → v3: rename hookMessage role to custom. Mutates in place. */\nfunction migrateV2ToV3(entries: FileEntry[]): void {\n\tfor (const entry of entries) {\n\t\tif (entry.type === \"session\") {\n\t\t\tentry.version = 3;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (entry.type === \"message\") {\n\t\t\tconst msgEntry = entry as SessionMessageEntry;\n\t\t\tif (msgEntry.message && (msgEntry.message as { role: string }).role === \"hookMessage\") {\n\t\t\t\t(msgEntry.message as { role: string }).role = \"custom\";\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Run all necessary migrations to bring entries to current version.\n * Mutates entries in place. Returns true if any migration was applied.\n */\nexport function migrateToCurrentVersion(entries: FileEntry[]): boolean {\n\tconst header = entries.find((entry) => entry.type === \"session\") as SessionHeader | undefined;\n\tconst version = header?.version ?? 1;\n\n\tif (version >= CURRENT_SESSION_VERSION) return false;\n\n\tif (version < 2) migrateV1ToV2(entries);\n\tif (version < 3) migrateV2ToV3(entries);\n\n\treturn true;\n}\n\n/** Exported for testing. */\nexport function migrateSessionEntries(entries: FileEntry[]): void {\n\tmigrateToCurrentVersion(entries);\n}\n\n/** Exported for compaction tests. */\nexport function parseSessionEntries(content: string): FileEntry[] {\n\tconst entries: FileEntry[] = [];\n\tconst lines = content.trim().split(\"\\n\");\n\n\tfor (const line of lines) {\n\t\tif (!line.trim()) continue;\n\t\ttry {\n\t\t\tconst entry = JSON.parse(line) as FileEntry;\n\t\t\tentries.push(entry);\n\t\t} catch {\n\t\t\t// Skip malformed lines.\n\t\t}\n\t}\n\n\treturn entries;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"remote-session-client.d.ts","sourceRoot":"","sources":["../../../src/core/session/remote-session-client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzD,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,CAAC,GAAG;IACpF,IAAI,CAAC,E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,eAAe,CACd,oBAAoB,EAAE,MAAM,EAC5B,OAAO,EAAE,mCAAmC,GAC1C,OAAO,CAAC,oCAAoC,CAAC,CAQ/C;IAED,YAAY,IAAI,OAAO,CAAC,0BAA0B,CAAC,CAElD;IAED,gBAAgB,IAAI,OAAO,CAAC,qBAAqB,CAAC,CAIjD;IAED,WAAW,CAAC,oBAAoB,EAAE,MAAM,EAAE,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAK3G;IAED,WAAW,CAAC,OAAO,EAAE,+BAA+B,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAIpF;YAEa,OAAO;CAgCrB;AAED,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAE9D;AAED,wBAAgB,4BAA4B,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAEtE","sourcesContent":["import { validateSessionId } from \"./ids.ts\";\nimport type { FileEntry, SessionInfo } from \"./types.ts\";\n\nexport type RemoteSessionInfo = Omit<SessionInfo, \"path\" | \"created\" | \"modified\"> & {\n\tpath?: string;\n\tcreated: Date | string;\n\tmodified: Date | string;\n};\n\nexport interface RemoteSessionClientOptions {\n\tbaseUrl: string;\n\ttoken: string;\n\tfetch?: typeof fetch;\n}\n\nexport interface RemoteSessionSnapshot {\n\treference: string;\n\tid: string;\n\tversion?: number;\n\tentries: FileEntry[];\n\tetag?: string;\n}\n\nexport interface CreateRemoteSessionRequest {\n\tid?: string;\n\tcwd: string;\n\tprojectId?: string;\n\tparentSession?: string;\n\tmetadata?: Record<string, unknown>;\n}\n\nexport interface AppendRemoteSessionEntriesRequest {\n\tbaseEtag?: string;\n\tentries: FileEntry[];\n}\n\nexport interface AppendRemoteSessionEntriesResponse {\n\tetag?: string;\n\taccepted: number;\n}\n\n// grip-ignore noNearIdenticalDataStructures: Snapshot replacement atomically rewrites complete state, while append applies incremental entries; their endpoint validation and concurrency contracts evolve independently.\nexport interface ReplaceRemoteSessionSnapshotRequest {\n\tbaseEtag?: string;\n\tentries: FileEntry[];\n}\n\nexport interface ReplaceRemoteSessionSnapshotResponse {\n\tetag?: string;\n}\n\nexport interface ForkRemoteSessionRequest {\n\tcwd: string;\n\tprojectId?: string;\n\tleafId?: string;\n}\n\nexport interface ImportRemoteSessionJsonlRequest {\n\tcwd: string;\n\tprojectId?: string;\n\tsourceName?: string;\n\tentries: FileEntry[];\n\tmetadata?: Record<string, unknown>;\n}\n\nexport interface ListRemoteSessionsResponse {\n\tsessions: RemoteSessionInfo[];\n}\n\nexport type RemoteSessionOperation = \"create\" | \"open\" | \"recent\" | \"fork\" | \"import\" | \"list\" | \"append\" | \"replace\";\n\nexport class RemoteSessionClientError extends Error {\n\treadonly status: number;\n\treadonly responseText: string;\n\n\tconstructor(status: number, responseText: string) {\n\t\tsuper(`Remote session request failed with status ${status}: ${responseText}`);\n\t\tthis.name = \"RemoteSessionClientError\";\n\t\tthis.status = status;\n\t\tthis.responseText = responseText;\n\t}\n}\n\nexport class RemoteSessionProtocolError extends Error {\n\treadonly operation: RemoteSessionOperation;\n\n\tconstructor(operation: RemoteSessionOperation, message: string, cause?: unknown) {\n\t\tsuper(`Invalid remote session ${operation} response: ${message}`, { cause });\n\t\tthis.name = \"RemoteSessionProtocolError\";\n\t\tthis.operation = operation;\n\t}\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction requiredString(record: Record<string, unknown>, key: string, operation: RemoteSessionOperation): string {\n\tconst value = record[key];\n\tif (typeof value !== \"string\" || value.length === 0) {\n\t\tthrow new RemoteSessionProtocolError(operation, `${key} must be a non-empty string`);\n\t}\n\treturn value;\n}\n\nfunction stringValue(record: Record<string, unknown>, key: string, operation: RemoteSessionOperation): string {\n\tconst value = record[key];\n\tif (typeof value !== \"string\") {\n\t\tthrow new RemoteSessionProtocolError(operation, `${key} must be a string`);\n\t}\n\treturn value;\n}\n\nfunction requiredSessionId(record: Record<string, unknown>, operation: RemoteSessionOperation): string {\n\tconst id = requiredString(record, \"id\", operation);\n\ttry {\n\t\tvalidateSessionId(id);\n\t} catch (error) {\n\t\tthrow new RemoteSessionProtocolError(operation, \"id is not a valid session id\", error);\n\t}\n\treturn id;\n}\n\nfunction optionalString(\n\trecord: Record<string, unknown>,\n\tkey: string,\n\toperation: RemoteSessionOperation,\n): string | undefined {\n\tconst value = record[key];\n\tif (value === undefined) return undefined;\n\tif (typeof value !== \"string\" || value.length === 0) {\n\t\tthrow new RemoteSessionProtocolError(operation, `${key} must be a non-empty string when present`);\n\t}\n\treturn value;\n}\n\nfunction decodeSnapshot(value: unknown, operation: RemoteSessionOperation, expectedId?: string): RemoteSessionSnapshot {\n\tif (!isRecord(value)) throw new RemoteSessionProtocolError(operation, \"snapshot must be an object\");\n\tconst id = requiredSessionId(value, operation);\n\tconst reference = requiredString(value, \"reference\", operation);\n\tif (parseRemoteSessionId(reference) !== id) {\n\t\tthrow new RemoteSessionProtocolError(operation, `reference ${reference} does not identify snapshot id ${id}`);\n\t}\n\tif (expectedId !== undefined && id !== expectedId) {\n\t\tthrow new RemoteSessionProtocolError(operation, `snapshot id ${id} does not match requested id ${expectedId}`);\n\t}\n\tif (!Array.isArray(value.entries) || value.entries.length === 0 || value.entries.some((entry) => !isRecord(entry))) {\n\t\tthrow new RemoteSessionProtocolError(operation, \"entries must be a non-empty array of objects\");\n\t}\n\tconst header = value.entries[0];\n\tif (\n\t\t!isRecord(header) ||\n\t\theader.type !== \"session\" ||\n\t\theader.id !== id ||\n\t\ttypeof header.cwd !== \"string\" ||\n\t\ttypeof header.timestamp !== \"string\"\n\t) {\n\t\tthrow new RemoteSessionProtocolError(operation, \"entries must begin with a matching session header\");\n\t}\n\tconst version = value.version;\n\tif (\n\t\tversion !== undefined &&\n\t\t(typeof version !== \"number\" || !Number.isInteger(version) || version < 1 || version !== header.version)\n\t) {\n\t\tthrow new RemoteSessionProtocolError(operation, \"version must be a positive integer matching the session header\");\n\t}\n\treturn {\n\t\treference,\n\t\tid,\n\t\tversion: version as number | undefined,\n\t\tentries: value.entries as FileEntry[],\n\t\tetag: optionalString(value, \"etag\", operation),\n\t};\n}\n\nfunction decodeForkSnapshot(value: unknown, sourceId: string): RemoteSessionSnapshot {\n\tconst snapshot = decodeSnapshot(value, \"fork\");\n\tif (snapshot.id === sourceId) {\n\t\tthrow new RemoteSessionProtocolError(\"fork\", \"fork snapshot must have a new session id\");\n\t}\n\tconst header = snapshot.entries[0];\n\tif (header?.type !== \"session\" || !header.parentSession || parseRemoteSessionId(header.parentSession) !== sourceId) {\n\t\tthrow new RemoteSessionProtocolError(\"fork\", `fork header must reference source session ${sourceId}`);\n\t}\n\treturn snapshot;\n}\n\nfunction decodeAppendResponse(value: unknown): AppendRemoteSessionEntriesResponse {\n\tconst operation = \"append\";\n\tif (!isRecord(value)) throw new RemoteSessionProtocolError(operation, \"response must be an object\");\n\tif (!Number.isInteger(value.accepted)) {\n\t\tthrow new RemoteSessionProtocolError(operation, \"accepted must be an integer\");\n\t}\n\treturn { accepted: value.accepted as number, etag: optionalString(value, \"etag\", operation) };\n}\n\nfunction decodeReplaceResponse(value: unknown): ReplaceRemoteSessionSnapshotResponse {\n\tconst operation = \"replace\";\n\tif (!isRecord(value)) throw new RemoteSessionProtocolError(operation, \"response must be an object\");\n\treturn { etag: optionalString(value, \"etag\", operation) };\n}\n\nfunction decodeSessionInfo(value: unknown): RemoteSessionInfo {\n\tconst operation = \"list\";\n\tif (!isRecord(value)) throw new RemoteSessionProtocolError(operation, \"each session must be an object\");\n\tconst id = requiredSessionId(value, operation);\n\tconst reference = optionalString(value, \"reference\", operation);\n\tconst path = optionalString(value, \"path\", operation);\n\tfor (const candidate of [reference, path]) {\n\t\tif (candidate !== undefined && parseRemoteSessionId(candidate) !== id) {\n\t\t\tthrow new RemoteSessionProtocolError(operation, `reference ${candidate} does not identify session id ${id}`);\n\t\t}\n\t}\n\tconst created = requiredString(value, \"created\", operation);\n\tconst modified = requiredString(value, \"modified\", operation);\n\tif (!Number.isFinite(Date.parse(created)) || !Number.isFinite(Date.parse(modified))) {\n\t\tthrow new RemoteSessionProtocolError(operation, \"created and modified must be valid date strings\");\n\t}\n\tif (!Number.isInteger(value.messageCount) || (value.messageCount as number) < 0) {\n\t\tthrow new RemoteSessionProtocolError(operation, \"messageCount must be a non-negative integer\");\n\t}\n\treturn {\n\t\treference,\n\t\tpath,\n\t\tid,\n\t\tcwd: stringValue(value, \"cwd\", operation),\n\t\tname: optionalString(value, \"name\", operation),\n\t\tparentSessionPath: optionalString(value, \"parentSessionPath\", operation),\n\t\tcreated,\n\t\tmodified,\n\t\tmessageCount: value.messageCount as number,\n\t\tfirstMessage: stringValue(value, \"firstMessage\", operation),\n\t\tallMessagesText: stringValue(value, \"allMessagesText\", operation),\n\t};\n}\n\nfunction decodeListResponse(value: unknown): ListRemoteSessionsResponse {\n\tif (!isRecord(value) || !Array.isArray(value.sessions)) {\n\t\tthrow new RemoteSessionProtocolError(\"list\", \"sessions must be an array\");\n\t}\n\treturn { sessions: value.sessions.map((session) => decodeSessionInfo(session)) };\n}\n\nexport class RemoteSessionClient {\n\tprivate readonly baseUrl: string;\n\tprivate readonly token: string;\n\tprivate readonly fetchImpl: typeof fetch;\n\n\tconstructor(options: RemoteSessionClientOptions) {\n\t\tthis.baseUrl = options.baseUrl.replace(/\\/+$/, \"\");\n\t\tthis.token = options.token;\n\t\tthis.fetchImpl = options.fetch ?? fetch;\n\t}\n\n\tcreateSession(request: CreateRemoteSessionRequest): Promise<RemoteSessionSnapshot> {\n\t\treturn this.request(\"POST\", \"/v1/sessions\", request, \"create\", (value) =>\n\t\t\tdecodeSnapshot(value, \"create\", request.id),\n\t\t);\n\t}\n\n\topenSession(sessionIdOrReference: string): Promise<RemoteSessionSnapshot> {\n\t\tconst id = parseRemoteSessionId(sessionIdOrReference);\n\t\treturn this.request(\"GET\", `/v1/sessions/${encodeURIComponent(id)}`, undefined, \"open\", (value) =>\n\t\t\tdecodeSnapshot(value, \"open\", id),\n\t\t);\n\t}\n\n\tappendEntries(\n\t\tsessionIdOrReference: string,\n\t\trequest: AppendRemoteSessionEntriesRequest,\n\t): Promise<AppendRemoteSessionEntriesResponse> {\n\t\treturn this.request(\n\t\t\t\"POST\",\n\t\t\t`/v1/sessions/${encodeURIComponent(parseRemoteSessionId(sessionIdOrReference))}/entries`,\n\t\t\trequest,\n\t\t\t\"append\",\n\t\t\tdecodeAppendResponse,\n\t\t);\n\t}\n\n\treplaceSnapshot(\n\t\tsessionIdOrReference: string,\n\t\trequest: ReplaceRemoteSessionSnapshotRequest,\n\t): Promise<ReplaceRemoteSessionSnapshotResponse> {\n\t\treturn this.request(\n\t\t\t\"PUT\",\n\t\t\t`/v1/sessions/${encodeURIComponent(parseRemoteSessionId(sessionIdOrReference))}/snapshot`,\n\t\t\trequest,\n\t\t\t\"replace\",\n\t\t\tdecodeReplaceResponse,\n\t\t);\n\t}\n\n\tlistSessions(): Promise<ListRemoteSessionsResponse> {\n\t\treturn this.request(\"GET\", \"/v1/sessions\", undefined, \"list\", decodeListResponse);\n\t}\n\n\tgetRecentSession(): Promise<RemoteSessionSnapshot> {\n\t\treturn this.request(\"GET\", \"/v1/sessions/recent\", undefined, \"recent\", (value) =>\n\t\t\tdecodeSnapshot(value, \"recent\"),\n\t\t);\n\t}\n\n\tforkSession(sessionIdOrReference: string, request: ForkRemoteSessionRequest): Promise<RemoteSessionSnapshot> {\n\t\tconst sourceId = parseRemoteSessionId(sessionIdOrReference);\n\t\treturn this.request(\"POST\", `/v1/sessions/${encodeURIComponent(sourceId)}/fork`, request, \"fork\", (value) =>\n\t\t\tdecodeForkSnapshot(value, sourceId),\n\t\t);\n\t}\n\n\timportJsonl(request: ImportRemoteSessionJsonlRequest): Promise<RemoteSessionSnapshot> {\n\t\treturn this.request(\"POST\", \"/v1/sessions/import-jsonl\", request, \"import\", (value) =>\n\t\t\tdecodeSnapshot(value, \"import\"),\n\t\t);\n\t}\n\n\tprivate async request<T>(\n\t\tmethod: string,\n\t\tpath: string,\n\t\tbody: unknown,\n\t\toperation: RemoteSessionOperation,\n\t\tdecode: (value: unknown) => T,\n\t): Promise<T> {\n\t\tconst response = await this.fetchImpl(`${this.baseUrl}${path}`, {\n\t\t\tmethod,\n\t\t\theaders: {\n\t\t\t\tAuthorization: `Bearer ${this.token}`,\n\t\t\t\tAccept: \"application/json\",\n\t\t\t\t...(body === undefined ? {} : { \"Content-Type\": \"application/json\" }),\n\t\t\t},\n\t\t\tbody: body === undefined ? undefined : JSON.stringify(body),\n\t\t});\n\n\t\tif (!response.ok) {\n\t\t\tthrow new RemoteSessionClientError(response.status, await response.text());\n\t\t}\n\t\tif (response.status === 204) {\n\t\t\tthrow new RemoteSessionProtocolError(operation, \"response body is required\");\n\t\t}\n\n\t\tlet value: unknown;\n\t\ttry {\n\t\t\tvalue = await response.json();\n\t\t} catch (error) {\n\t\t\tthrow new RemoteSessionProtocolError(operation, \"body is not valid JSON\", error);\n\t\t}\n\t\treturn decode(value);\n\t}\n}\n\nexport function parseRemoteSessionId(reference: string): string {\n\treturn reference.startsWith(\"remote:\") ? reference.slice(\"remote:\".length) : reference;\n}\n\nexport function formatRemoteSessionReference(sessionId: string): string {\n\treturn sessionId.startsWith(\"remote:\") ? sessionId : `remote:${sessionId}`;\n}\n"]}
1
+ {"version":3,"file":"remote-session-client.d.ts","sourceRoot":"","sources":["../../../src/core/session/remote-session-client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzD,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,CAAC,GAAG;IACpF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,IAAI,GAAG,MAAM,CAAC;IACvB,QAAQ,EAAE,IAAI,GAAG,MAAM,CAAC;CACxB,CAAC;AAEF,MAAM,WAAW,0BAA0B;IAC1C,OAAO,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AED,gBAAgB,IAAI,OAAO,CAAC,qBAAqB,CAAC,CAIjD;IAED,WAAW,CAAC,oBAAoB,EAAE,MAAM,EAAE,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAK3G;IAED,WAAW,CAAC,OAAO,EAAE,+BAA+B,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAIpF;YAEa,OAAO;CAgCrB;AAED,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAE9D;AAED,wBAAgB,4BAA4B,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAEtE"}
@@ -1,7 +1,5 @@
1
1
  import { validateSessionId } from "./ids.js";
2
2
  export class RemoteSessionClientError extends Error {
3
- status;
4
- responseText;
5
3
  constructor(status, responseText) {
6
4
  super(`Remote session request failed with status ${status}: ${responseText}`);
7
5
  this.name = "RemoteSessionClientError";
@@ -10,7 +8,6 @@ export class RemoteSessionClientError extends Error {
10
8
  }
11
9
  }
12
10
  export class RemoteSessionProtocolError extends Error {
13
- operation;
14
11
  constructor(operation, message, cause) {
15
12
  super(`Invalid remote session ${operation} response: ${message}`, { cause });
16
13
  this.name = "RemoteSessionProtocolError";
@@ -155,9 +152,6 @@ function decodeListResponse(value) {
155
152
  return { sessions: value.sessions.map((session) => decodeSessionInfo(session)) };
156
153
  }
157
154
  export class RemoteSessionClient {
158
- baseUrl;
159
- token;
160
- fetchImpl;
161
155
  constructor(options) {
162
156
  this.baseUrl = options.baseUrl.replace(/\/+$/, "");
163
157
  this.token = options.token;