@entelligentsia/forgecli 0.15.0 → 0.20.0

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 (1202) hide show
  1. package/CHANGELOG.md +105 -0
  2. package/dist/CHANGELOG-pi.md +55 -0
  3. package/dist/bin/argv.d.ts +2 -0
  4. package/dist/bin/argv.js +3 -1
  5. package/dist/bin/argv.js.map +1 -1
  6. package/dist/bin/config.d.ts +5 -0
  7. package/dist/bin/config.js +34 -13
  8. package/dist/bin/config.js.map +1 -1
  9. package/dist/bin/forge.js +14 -58
  10. package/dist/bin/forge.js.map +1 -1
  11. package/dist/bin/shared-parser.d.ts +23 -0
  12. package/dist/bin/shared-parser.js +12 -0
  13. package/dist/bin/shared-parser.js.map +1 -0
  14. package/dist/bin/update-cli.js +7 -1
  15. package/dist/bin/update-cli.js.map +1 -1
  16. package/dist/extensions/forgecli/add-pipeline.js.map +1 -1
  17. package/dist/extensions/forgecli/add-task.js.map +1 -1
  18. package/dist/extensions/forgecli/approve.d.ts +4 -6
  19. package/dist/extensions/forgecli/approve.js +8 -73
  20. package/dist/extensions/forgecli/approve.js.map +1 -1
  21. package/dist/extensions/forgecli/ask-user-tool.js.map +1 -1
  22. package/dist/extensions/forgecli/audience-gate.d.ts +1 -1
  23. package/dist/extensions/forgecli/audience-gate.js.map +1 -1
  24. package/dist/extensions/forgecli/calibrate.d.ts +4 -1
  25. package/dist/extensions/forgecli/calibrate.js +10 -20
  26. package/dist/extensions/forgecli/calibrate.js.map +1 -1
  27. package/dist/extensions/forgecli/collate.d.ts +4 -6
  28. package/dist/extensions/forgecli/collate.js +8 -73
  29. package/dist/extensions/forgecli/collate.js.map +1 -1
  30. package/dist/extensions/forgecli/commit.d.ts +4 -6
  31. package/dist/extensions/forgecli/commit.js +8 -73
  32. package/dist/extensions/forgecli/commit.js.map +1 -1
  33. package/dist/extensions/forgecli/config-command.js.map +1 -1
  34. package/dist/extensions/forgecli/config-layer.js +4 -2
  35. package/dist/extensions/forgecli/config-layer.js.map +1 -1
  36. package/dist/extensions/forgecli/config-tui/component.d.ts +1 -1
  37. package/dist/extensions/forgecli/config-tui/component.js +25 -21
  38. package/dist/extensions/forgecli/config-tui/component.js.map +1 -1
  39. package/dist/extensions/forgecli/config-tui/handler.js +3 -6
  40. package/dist/extensions/forgecli/config-tui/handler.js.map +1 -1
  41. package/dist/extensions/forgecli/config-tui/keys.js.map +1 -1
  42. package/dist/extensions/forgecli/config-tui/plugin-config-reader.js.map +1 -1
  43. package/dist/extensions/forgecli/config-tui/screens/advanced-menu.d.ts +2 -2
  44. package/dist/extensions/forgecli/config-tui/screens/advanced-menu.js +10 -8
  45. package/dist/extensions/forgecli/config-tui/screens/advanced-menu.js.map +1 -1
  46. package/dist/extensions/forgecli/config-tui/screens/confirm-quit.d.ts +2 -2
  47. package/dist/extensions/forgecli/config-tui/screens/confirm-quit.js +2 -5
  48. package/dist/extensions/forgecli/config-tui/screens/confirm-quit.js.map +1 -1
  49. package/dist/extensions/forgecli/config-tui/screens/override-editor.d.ts +2 -2
  50. package/dist/extensions/forgecli/config-tui/screens/override-editor.js +15 -11
  51. package/dist/extensions/forgecli/config-tui/screens/override-editor.js.map +1 -1
  52. package/dist/extensions/forgecli/config-tui/screens/overrides-list-phases.d.ts +2 -2
  53. package/dist/extensions/forgecli/config-tui/screens/overrides-list-phases.js +15 -11
  54. package/dist/extensions/forgecli/config-tui/screens/overrides-list-phases.js.map +1 -1
  55. package/dist/extensions/forgecli/config-tui/screens/overrides-list.d.ts +2 -2
  56. package/dist/extensions/forgecli/config-tui/screens/overrides-list.js +7 -4
  57. package/dist/extensions/forgecli/config-tui/screens/overrides-list.js.map +1 -1
  58. package/dist/extensions/forgecli/config-tui/screens/persona-editor.d.ts +2 -2
  59. package/dist/extensions/forgecli/config-tui/screens/persona-editor.js +6 -12
  60. package/dist/extensions/forgecli/config-tui/screens/persona-editor.js.map +1 -1
  61. package/dist/extensions/forgecli/config-tui/screens/persona-picker.d.ts +2 -2
  62. package/dist/extensions/forgecli/config-tui/screens/persona-picker.js +3 -6
  63. package/dist/extensions/forgecli/config-tui/screens/persona-picker.js.map +1 -1
  64. package/dist/extensions/forgecli/config-tui/screens/personas-list.d.ts +2 -2
  65. package/dist/extensions/forgecli/config-tui/screens/personas-list.js +2 -2
  66. package/dist/extensions/forgecli/config-tui/screens/personas-list.js.map +1 -1
  67. package/dist/extensions/forgecli/config-tui/screens/shared.d.ts +1 -1
  68. package/dist/extensions/forgecli/config-tui/screens/shared.js +4 -5
  69. package/dist/extensions/forgecli/config-tui/screens/shared.js.map +1 -1
  70. package/dist/extensions/forgecli/config-tui/screens/show-resolved.d.ts +2 -2
  71. package/dist/extensions/forgecli/config-tui/screens/show-resolved.js +9 -11
  72. package/dist/extensions/forgecli/config-tui/screens/show-resolved.js.map +1 -1
  73. package/dist/extensions/forgecli/config-tui/screens/tier-menu.d.ts +2 -2
  74. package/dist/extensions/forgecli/config-tui/screens/tier-menu.js +9 -2
  75. package/dist/extensions/forgecli/config-tui/screens/tier-menu.js.map +1 -1
  76. package/dist/extensions/forgecli/config-tui/screens/tier-picker.d.ts +2 -2
  77. package/dist/extensions/forgecli/config-tui/screens/tier-picker.js +12 -3
  78. package/dist/extensions/forgecli/config-tui/screens/tier-picker.js.map +1 -1
  79. package/dist/extensions/forgecli/config-tui/screens/types.d.ts +1 -1
  80. package/dist/extensions/forgecli/config-tui/screens.d.ts +10 -10
  81. package/dist/extensions/forgecli/config-tui/screens.js +16 -16
  82. package/dist/extensions/forgecli/config-tui/screens.js.map +1 -1
  83. package/dist/extensions/forgecli/config-tui/state/buffer.d.ts +2 -2
  84. package/dist/extensions/forgecli/config-tui/state/buffer.js +1 -2
  85. package/dist/extensions/forgecli/config-tui/state/buffer.js.map +1 -1
  86. package/dist/extensions/forgecli/config-tui/state/constants.js.map +1 -1
  87. package/dist/extensions/forgecli/config-tui/state/index.d.ts +3 -3
  88. package/dist/extensions/forgecli/config-tui/state/index.js +2 -2
  89. package/dist/extensions/forgecli/config-tui/state/index.js.map +1 -1
  90. package/dist/extensions/forgecli/config-tui/state/init.js +1 -0
  91. package/dist/extensions/forgecli/config-tui/state/init.js.map +1 -1
  92. package/dist/extensions/forgecli/config-tui/state/model.d.ts +4 -0
  93. package/dist/extensions/forgecli/config-tui/state/reducer.js +2 -4
  94. package/dist/extensions/forgecli/config-tui/state/reducer.js.map +1 -1
  95. package/dist/extensions/forgecli/config-tui/state/selectors.d.ts +1 -1
  96. package/dist/extensions/forgecli/config-tui/state/selectors.js +7 -6
  97. package/dist/extensions/forgecli/config-tui/state/selectors.js.map +1 -1
  98. package/dist/extensions/forgecli/config-tui/state.d.ts +3 -3
  99. package/dist/extensions/forgecli/config-tui/state.js +2 -2
  100. package/dist/extensions/forgecli/config-tui/state.js.map +1 -1
  101. package/dist/extensions/forgecli/config-tui/theme.js +1 -1
  102. package/dist/extensions/forgecli/config-tui/theme.js.map +1 -1
  103. package/dist/extensions/forgecli/config-tui/tier-meta.js.map +1 -1
  104. package/dist/extensions/forgecli/config-writer.js +4 -2
  105. package/dist/extensions/forgecli/config-writer.js.map +1 -1
  106. package/dist/extensions/forgecli/enhance.d.ts +4 -6
  107. package/dist/extensions/forgecli/enhance.js +9 -74
  108. package/dist/extensions/forgecli/enhance.js.map +1 -1
  109. package/dist/extensions/forgecli/fix-bug.d.ts +4 -1
  110. package/dist/extensions/forgecli/fix-bug.js +202 -100
  111. package/dist/extensions/forgecli/fix-bug.js.map +1 -1
  112. package/dist/extensions/forgecli/forge-artifact-tool.d.ts +9 -0
  113. package/dist/extensions/forgecli/forge-artifact-tool.js +255 -0
  114. package/dist/extensions/forgecli/forge-artifact-tool.js.map +1 -0
  115. package/dist/extensions/forgecli/forge-commands.js.map +1 -1
  116. package/dist/extensions/forgecli/forge-header.d.ts +1 -1
  117. package/dist/extensions/forgecli/forge-header.js +1 -1
  118. package/dist/extensions/forgecli/forge-header.js.map +1 -1
  119. package/dist/extensions/forgecli/forge-init/phase-descriptors.d.ts +72 -0
  120. package/dist/extensions/forgecli/forge-init/phase-descriptors.js +359 -0
  121. package/dist/extensions/forgecli/forge-init/phase-descriptors.js.map +1 -0
  122. package/dist/extensions/forgecli/forge-init/phase4-register.d.ts +20 -0
  123. package/dist/extensions/forgecli/forge-init/phase4-register.js +353 -0
  124. package/dist/extensions/forgecli/forge-init/phase4-register.js.map +1 -0
  125. package/dist/extensions/forgecli/forge-init/prompts.d.ts +10 -0
  126. package/dist/extensions/forgecli/forge-init/prompts.js +91 -0
  127. package/dist/extensions/forgecli/forge-init/prompts.js.map +1 -0
  128. package/dist/extensions/forgecli/forge-init/verifiers.d.ts +20 -0
  129. package/dist/extensions/forgecli/forge-init/verifiers.js +81 -0
  130. package/dist/extensions/forgecli/forge-init/verifiers.js.map +1 -0
  131. package/dist/extensions/forgecli/forge-init.js +107 -751
  132. package/dist/extensions/forgecli/forge-init.js.map +1 -1
  133. package/dist/extensions/forgecli/forge-root.d.ts +0 -1
  134. package/dist/extensions/forgecli/forge-root.js +1 -11
  135. package/dist/extensions/forgecli/forge-root.js.map +1 -1
  136. package/dist/extensions/forgecli/forge-subagent.d.ts +11 -1
  137. package/dist/extensions/forgecli/forge-subagent.js +9 -2
  138. package/dist/extensions/forgecli/forge-subagent.js.map +1 -1
  139. package/dist/extensions/forgecli/forge-tools.d.ts +27 -7
  140. package/dist/extensions/forgecli/forge-tools.js +116 -71
  141. package/dist/extensions/forgecli/forge-tools.js.map +1 -1
  142. package/dist/extensions/forgecli/forge-update-command.d.ts +32 -11
  143. package/dist/extensions/forgecli/forge-update-command.js +207 -150
  144. package/dist/extensions/forgecli/forge-update-command.js.map +1 -1
  145. package/dist/extensions/forgecli/friction-emit.d.ts +4 -2
  146. package/dist/extensions/forgecli/friction-emit.js +15 -16
  147. package/dist/extensions/forgecli/friction-emit.js.map +1 -1
  148. package/dist/extensions/forgecli/health-check.js +11 -7
  149. package/dist/extensions/forgecli/health-check.js.map +1 -1
  150. package/dist/extensions/forgecli/hook-dispatcher.d.ts +1 -0
  151. package/dist/extensions/forgecli/hook-dispatcher.js +7 -2
  152. package/dist/extensions/forgecli/hook-dispatcher.js.map +1 -1
  153. package/dist/extensions/forgecli/hooks/check-update.js.map +1 -1
  154. package/dist/extensions/forgecli/hooks/forge-permissions.js.map +1 -1
  155. package/dist/extensions/forgecli/hooks/post-init-hook.js +2 -2
  156. package/dist/extensions/forgecli/hooks/post-init-hook.js.map +1 -1
  157. package/dist/extensions/forgecli/hooks/post-sprint-hook.js +2 -2
  158. package/dist/extensions/forgecli/hooks/post-sprint-hook.js.map +1 -1
  159. package/dist/extensions/forgecli/hooks/write-guard.js +6 -4
  160. package/dist/extensions/forgecli/hooks/write-guard.js.map +1 -1
  161. package/dist/extensions/forgecli/implement.d.ts +4 -6
  162. package/dist/extensions/forgecli/implement.js +8 -73
  163. package/dist/extensions/forgecli/implement.js.map +1 -1
  164. package/dist/extensions/forgecli/index.js +59 -76
  165. package/dist/extensions/forgecli/index.js.map +1 -1
  166. package/dist/extensions/forgecli/input-router.js +4 -1
  167. package/dist/extensions/forgecli/input-router.js.map +1 -1
  168. package/dist/extensions/forgecli/lib/catalog-helpers.d.ts +13 -0
  169. package/dist/extensions/forgecli/lib/catalog-helpers.js +52 -0
  170. package/dist/extensions/forgecli/lib/catalog-helpers.js.map +1 -0
  171. package/dist/extensions/forgecli/lib/catalog-loader.d.ts +46 -0
  172. package/dist/extensions/forgecli/lib/catalog-loader.js +176 -0
  173. package/dist/extensions/forgecli/lib/catalog-loader.js.map +1 -0
  174. package/dist/extensions/forgecli/lib/catalog-types.d.ts +16 -0
  175. package/dist/extensions/forgecli/lib/catalog-types.js +156 -0
  176. package/dist/extensions/forgecli/lib/catalog-types.js.map +1 -0
  177. package/dist/extensions/forgecli/lib/exec-helpers.d.ts +25 -0
  178. package/dist/extensions/forgecli/lib/exec-helpers.js +52 -0
  179. package/dist/extensions/forgecli/lib/exec-helpers.js.map +1 -0
  180. package/dist/extensions/forgecli/lib/forge-config.d.ts +20 -0
  181. package/dist/extensions/forgecli/lib/forge-config.js +43 -0
  182. package/dist/extensions/forgecli/lib/forge-config.js.map +1 -0
  183. package/dist/extensions/forgecli/lib/frontmatter-parser.d.ts +13 -0
  184. package/dist/extensions/forgecli/lib/frontmatter-parser.js +56 -0
  185. package/dist/extensions/forgecli/lib/frontmatter-parser.js.map +1 -0
  186. package/dist/extensions/forgecli/lib/manifest-checker.d.ts +22 -0
  187. package/dist/extensions/forgecli/lib/manifest-checker.js +64 -0
  188. package/dist/extensions/forgecli/lib/manifest-checker.js.map +1 -0
  189. package/dist/extensions/forgecli/lib/orchestrator-preflight.d.ts +46 -0
  190. package/dist/extensions/forgecli/lib/orchestrator-preflight.js +64 -0
  191. package/dist/extensions/forgecli/lib/orchestrator-preflight.js.map +1 -0
  192. package/dist/extensions/forgecli/lib/orchestrator-types.d.ts +20 -0
  193. package/dist/extensions/forgecli/lib/orchestrator-types.js +14 -0
  194. package/dist/extensions/forgecli/lib/orchestrator-types.js.map +1 -0
  195. package/dist/extensions/forgecli/lib/parsers.d.ts +25 -0
  196. package/dist/extensions/forgecli/lib/parsers.js +164 -0
  197. package/dist/extensions/forgecli/lib/parsers.js.map +1 -0
  198. package/dist/extensions/forgecli/lib/shared-fs-utils.d.ts +12 -0
  199. package/dist/extensions/forgecli/lib/shared-fs-utils.js +37 -0
  200. package/dist/extensions/forgecli/lib/shared-fs-utils.js.map +1 -0
  201. package/dist/extensions/forgecli/lib/spawn-store-cli.d.ts +44 -0
  202. package/dist/extensions/forgecli/lib/spawn-store-cli.js +103 -0
  203. package/dist/extensions/forgecli/lib/spawn-store-cli.js.map +1 -0
  204. package/dist/extensions/forgecli/lib/state-helpers.d.ts +33 -0
  205. package/dist/extensions/forgecli/lib/state-helpers.js +69 -0
  206. package/dist/extensions/forgecli/lib/state-helpers.js.map +1 -0
  207. package/dist/extensions/forgecli/lib/store-cli-timeouts.d.ts +4 -0
  208. package/dist/extensions/forgecli/lib/store-cli-timeouts.js +10 -0
  209. package/dist/extensions/forgecli/lib/store-cli-timeouts.js.map +1 -0
  210. package/dist/extensions/forgecli/lib/versions.d.ts +56 -0
  211. package/dist/extensions/forgecli/lib/versions.js +116 -0
  212. package/dist/extensions/forgecli/lib/versions.js.map +1 -0
  213. package/dist/extensions/forgecli/loaders/persona-skill-loader.js +2 -2
  214. package/dist/extensions/forgecli/loaders/persona-skill-loader.js.map +1 -1
  215. package/dist/extensions/forgecli/materialize.js.map +1 -1
  216. package/dist/extensions/forgecli/migrate.js +1 -1
  217. package/dist/extensions/forgecli/migrate.js.map +1 -1
  218. package/dist/extensions/forgecli/migration-engine.d.ts +6 -0
  219. package/dist/extensions/forgecli/migration-engine.js +62 -45
  220. package/dist/extensions/forgecli/migration-engine.js.map +1 -1
  221. package/dist/extensions/forgecli/model-resolver.js.map +1 -1
  222. package/dist/extensions/forgecli/model-validator.js.map +1 -1
  223. package/dist/extensions/forgecli/parsers/persona-skill-loader.d.ts +45 -0
  224. package/dist/extensions/forgecli/parsers/persona-skill-loader.js +201 -0
  225. package/dist/extensions/forgecli/parsers/persona-skill-loader.js.map +1 -0
  226. package/dist/extensions/forgecli/parsers/workflow-loader.d.ts +41 -0
  227. package/dist/extensions/forgecli/parsers/workflow-loader.js +83 -0
  228. package/dist/extensions/forgecli/parsers/workflow-loader.js.map +1 -0
  229. package/dist/extensions/forgecli/paths/migrator.js +2 -7
  230. package/dist/extensions/forgecli/paths/migrator.js.map +1 -1
  231. package/dist/extensions/forgecli/plan.d.ts +4 -6
  232. package/dist/extensions/forgecli/plan.js +9 -73
  233. package/dist/extensions/forgecli/plan.js.map +1 -1
  234. package/dist/extensions/forgecli/quiz-agent.js.map +1 -1
  235. package/dist/extensions/forgecli/read-command.js +1 -1
  236. package/dist/extensions/forgecli/read-command.js.map +1 -1
  237. package/dist/extensions/forgecli/regenerate.js +1 -3
  238. package/dist/extensions/forgecli/regenerate.js.map +1 -1
  239. package/dist/extensions/forgecli/remove-command.js.map +1 -1
  240. package/dist/extensions/forgecli/report-bug.js +2 -2
  241. package/dist/extensions/forgecli/report-bug.js.map +1 -1
  242. package/dist/extensions/forgecli/retrospective.d.ts +2 -1
  243. package/dist/extensions/forgecli/retrospective.js +6 -36
  244. package/dist/extensions/forgecli/retrospective.js.map +1 -1
  245. package/dist/extensions/forgecli/review-code.d.ts +4 -6
  246. package/dist/extensions/forgecli/review-code.js +8 -73
  247. package/dist/extensions/forgecli/review-code.js.map +1 -1
  248. package/dist/extensions/forgecli/review-plan.d.ts +4 -6
  249. package/dist/extensions/forgecli/review-plan.js +8 -73
  250. package/dist/extensions/forgecli/review-plan.js.map +1 -1
  251. package/dist/extensions/forgecli/review-server.js +3 -5
  252. package/dist/extensions/forgecli/review-server.js.map +1 -1
  253. package/dist/extensions/forgecli/run-sprint.d.ts +3 -1
  254. package/dist/extensions/forgecli/run-sprint.js +74 -67
  255. package/dist/extensions/forgecli/run-sprint.js.map +1 -1
  256. package/dist/extensions/forgecli/run-task.d.ts +3 -0
  257. package/dist/extensions/forgecli/run-task.js +136 -105
  258. package/dist/extensions/forgecli/run-task.js.map +1 -1
  259. package/dist/extensions/forgecli/session-registry.js.map +1 -1
  260. package/dist/extensions/forgecli/skill-curation-flag.js +5 -5
  261. package/dist/extensions/forgecli/skill-curation-flag.js.map +1 -1
  262. package/dist/extensions/forgecli/skill-curator-subagent.js +4 -8
  263. package/dist/extensions/forgecli/skill-curator-subagent.js.map +1 -1
  264. package/dist/extensions/forgecli/skill-retriever.js +5 -5
  265. package/dist/extensions/forgecli/skill-retriever.js.map +1 -1
  266. package/dist/extensions/forgecli/skill-usage-tracker.js +5 -5
  267. package/dist/extensions/forgecli/skill-usage-tracker.js.map +1 -1
  268. package/dist/extensions/forgecli/status-command.js.map +1 -1
  269. package/dist/extensions/forgecli/store-error-remediation.d.ts +65 -0
  270. package/dist/extensions/forgecli/store-error-remediation.js +307 -0
  271. package/dist/extensions/forgecli/store-error-remediation.js.map +1 -0
  272. package/dist/extensions/forgecli/store-query.js.map +1 -1
  273. package/dist/extensions/forgecli/store-repair.js.map +1 -1
  274. package/dist/extensions/forgecli/store-resolver.js +4 -13
  275. package/dist/extensions/forgecli/store-resolver.js.map +1 -1
  276. package/dist/extensions/forgecli/store-validator.js +6 -11
  277. package/dist/extensions/forgecli/store-validator.js.map +1 -1
  278. package/dist/extensions/forgecli/subagent/agents.d.ts +4 -0
  279. package/dist/extensions/forgecli/subagent/agents.js +5 -8
  280. package/dist/extensions/forgecli/subagent/agents.js.map +1 -1
  281. package/dist/extensions/forgecli/subagent/index.js +1 -1
  282. package/dist/extensions/forgecli/subagent/index.js.map +1 -1
  283. package/dist/extensions/forgecli/test-orchestrate.js +1 -1
  284. package/dist/extensions/forgecli/test-orchestrate.js.map +1 -1
  285. package/dist/extensions/forgecli/thread-switcher.js +8 -18
  286. package/dist/extensions/forgecli/thread-switcher.js.map +1 -1
  287. package/dist/extensions/forgecli/transition-guard.js +20 -61
  288. package/dist/extensions/forgecli/transition-guard.js.map +1 -1
  289. package/dist/extensions/forgecli/update-tools.js +1 -2
  290. package/dist/extensions/forgecli/update-tools.js.map +1 -1
  291. package/dist/extensions/forgecli/validate.d.ts +4 -6
  292. package/dist/extensions/forgecli/validate.js +8 -73
  293. package/dist/extensions/forgecli/validate.js.map +1 -1
  294. package/dist/extensions/forgecli/viewport-events.js +2 -2
  295. package/dist/extensions/forgecli/viewport-events.js.map +1 -1
  296. package/dist/extensions/forgecli/wf-engine/engine.d.ts +1 -1
  297. package/dist/extensions/forgecli/wf-engine/engine.js +52 -32
  298. package/dist/extensions/forgecli/wf-engine/engine.js.map +1 -1
  299. package/dist/extensions/forgecli/wf-engine/event-parser.js.map +1 -1
  300. package/dist/extensions/forgecli/wf-engine/id-gen.js +4 -1
  301. package/dist/extensions/forgecli/wf-engine/id-gen.js.map +1 -1
  302. package/dist/extensions/forgecli/wf-engine/loader.d.ts +1 -1
  303. package/dist/extensions/forgecli/wf-engine/loader.js +8 -8
  304. package/dist/extensions/forgecli/wf-engine/loader.js.map +1 -1
  305. package/dist/extensions/forgecli/wf-engine/predicate.js +14 -7
  306. package/dist/extensions/forgecli/wf-engine/predicate.js.map +1 -1
  307. package/dist/extensions/forgecli/wf-engine/prompt-compiler.js.map +1 -1
  308. package/dist/extensions/forgecli/wf-engine/register.js +1 -1
  309. package/dist/extensions/forgecli/wf-engine/register.js.map +1 -1
  310. package/dist/extensions/forgecli/wf-engine/remit-check.js +3 -3
  311. package/dist/extensions/forgecli/wf-engine/remit-check.js.map +1 -1
  312. package/dist/extensions/forgecli/wf-engine/state-store.js +7 -3
  313. package/dist/extensions/forgecli/wf-engine/state-store.js.map +1 -1
  314. package/dist/extensions/forgecli/wf-engine/worker.js +3 -3
  315. package/dist/extensions/forgecli/wf-engine/worker.js.map +1 -1
  316. package/dist/extensions/forgecli/whats-new-widget.js +8 -6
  317. package/dist/extensions/forgecli/whats-new-widget.js.map +1 -1
  318. package/dist/extensions/forgecli/whats-new.js +1 -2
  319. package/dist/extensions/forgecli/whats-new.js.map +1 -1
  320. package/dist/forge-payload/.base-pack/skills/architect-skills.md +1 -0
  321. package/dist/forge-payload/.base-pack/skills/bug-fixer-skills.md +1 -0
  322. package/dist/forge-payload/.base-pack/skills/collator-skills.md +1 -0
  323. package/dist/forge-payload/.base-pack/skills/engineer-skills.md +1 -0
  324. package/dist/forge-payload/.base-pack/skills/generic-skills.md +1 -0
  325. package/dist/forge-payload/.base-pack/skills/qa-engineer-skills.md +1 -0
  326. package/dist/forge-payload/.base-pack/skills/supervisor-skills.md +1 -0
  327. package/dist/forge-payload/.base-pack/workflows/_fragments/generation-instructions.md +81 -0
  328. package/dist/forge-payload/.base-pack/workflows/_fragments/iron-laws.md +72 -0
  329. package/dist/forge-payload/.base-pack/workflows/_fragments/store-cli-verbs.md +11 -1
  330. package/dist/forge-payload/.base-pack/workflows/_fragments/store-write-verification.md +11 -0
  331. package/dist/forge-payload/.base-pack/workflows/architect_approve.md +11 -12
  332. package/dist/forge-payload/.base-pack/workflows/architect_review_sprint_completion.md +4 -1
  333. package/dist/forge-payload/.base-pack/workflows/architect_sprint_intake.md +10 -1
  334. package/dist/forge-payload/.base-pack/workflows/architect_sprint_plan.md +8 -1
  335. package/dist/forge-payload/.base-pack/workflows/collator_agent.md +18 -1
  336. package/dist/forge-payload/.base-pack/workflows/commit_task.md +5 -10
  337. package/dist/forge-payload/.base-pack/workflows/enhance.md +7 -0
  338. package/dist/forge-payload/.base-pack/workflows/fix_bug.md +9 -2
  339. package/dist/forge-payload/.base-pack/workflows/implement_plan.md +22 -35
  340. package/dist/forge-payload/.base-pack/workflows/migrate_structural.md +9 -0
  341. package/dist/forge-payload/.base-pack/workflows/orchestrate_task.md +4 -0
  342. package/dist/forge-payload/.base-pack/workflows/plan_task.md +17 -21
  343. package/dist/forge-payload/.base-pack/workflows/review_code.md +13 -20
  344. package/dist/forge-payload/.base-pack/workflows/review_plan.md +10 -21
  345. package/dist/forge-payload/.base-pack/workflows/sprint_retrospective.md +10 -1
  346. package/dist/forge-payload/.base-pack/workflows/update_implementation.md +5 -10
  347. package/dist/forge-payload/.base-pack/workflows/update_plan.md +5 -10
  348. package/dist/forge-payload/.base-pack/workflows/validate_task.md +11 -12
  349. package/dist/forge-payload/.claude-plugin/plugin.json +5 -5
  350. package/dist/forge-payload/.schemas/_defs/phaseSummary.schema.json +18 -0
  351. package/dist/forge-payload/.schemas/bug.schema.json +8 -24
  352. package/dist/forge-payload/.schemas/config.schema.json +165 -33
  353. package/dist/forge-payload/.schemas/enum-catalog.json +71 -0
  354. package/dist/forge-payload/.schemas/migrations.json +371 -149
  355. package/dist/forge-payload/.schemas/task.schema.json +6 -21
  356. package/dist/forge-payload/.schemas/transitions/bug.json +31 -0
  357. package/dist/forge-payload/.schemas/transitions/sprint.json +46 -0
  358. package/dist/forge-payload/.schemas/transitions/task.json +109 -0
  359. package/dist/forge-payload/commands/health.md +3 -3
  360. package/dist/forge-payload/hooks/check-update.cjs +255 -0
  361. package/dist/forge-payload/hooks/forge-permissions.cjs +171 -0
  362. package/dist/forge-payload/hooks/forge-permissions.js +6 -0
  363. package/dist/forge-payload/hooks/post-init.cjs +120 -0
  364. package/dist/forge-payload/hooks/post-sprint.cjs +108 -0
  365. package/dist/forge-payload/hooks/triage-error.cjs +104 -0
  366. package/dist/forge-payload/hooks/triage-error.js +6 -0
  367. package/dist/forge-payload/hooks/validate-write.cjs +250 -0
  368. package/dist/forge-payload/hooks/validate-write.js +25 -11
  369. package/dist/forge-payload/integrity.json +13 -7
  370. package/dist/forge-payload/meta/workflows/_fragments/generation-instructions.md +81 -0
  371. package/dist/forge-payload/meta/workflows/_fragments/iron-laws.md +72 -0
  372. package/dist/forge-payload/meta/workflows/_fragments/store-cli-verbs.md +11 -1
  373. package/dist/forge-payload/meta/workflows/_fragments/store-write-verification.md +11 -0
  374. package/dist/forge-payload/meta/workflows/meta-approve.md +9 -11
  375. package/dist/forge-payload/meta/workflows/meta-collate.md +16 -0
  376. package/dist/forge-payload/meta/workflows/meta-commit.md +3 -9
  377. package/dist/forge-payload/meta/workflows/meta-enhance.md +16 -1
  378. package/dist/forge-payload/meta/workflows/meta-fix-bug.md +8 -2
  379. package/dist/forge-payload/meta/workflows/meta-implement.md +20 -35
  380. package/dist/forge-payload/meta/workflows/meta-migrate.md +18 -0
  381. package/dist/forge-payload/meta/workflows/meta-orchestrate.md +2 -0
  382. package/dist/forge-payload/meta/workflows/meta-plan-task.md +15 -21
  383. package/dist/forge-payload/meta/workflows/meta-quiz-agent.md +4 -1
  384. package/dist/forge-payload/meta/workflows/meta-retrospective.md +8 -0
  385. package/dist/forge-payload/meta/workflows/meta-review-implementation.md +11 -19
  386. package/dist/forge-payload/meta/workflows/meta-review-plan.md +10 -16
  387. package/dist/forge-payload/meta/workflows/meta-review-sprint-completion.md +3 -0
  388. package/dist/forge-payload/meta/workflows/meta-sprint-intake.md +8 -0
  389. package/dist/forge-payload/meta/workflows/meta-sprint-plan.md +5 -0
  390. package/dist/forge-payload/meta/workflows/meta-update-implementation.md +3 -9
  391. package/dist/forge-payload/meta/workflows/meta-update-plan.md +3 -9
  392. package/dist/forge-payload/meta/workflows/meta-validate.md +9 -11
  393. package/dist/forge-payload/schemas/structure-manifest.json +8 -6
  394. package/dist/forge-payload/tools/build-context-pack.cjs +3 -2
  395. package/dist/forge-payload/tools/friction-emit.cjs +2 -1
  396. package/dist/forge-payload/tools/lib/frontmatter.cjs +62 -0
  397. package/dist/forge-payload/tools/lib/fsutil.cjs +61 -0
  398. package/dist/forge-payload/tools/lib/json-io.cjs +43 -0
  399. package/dist/forge-payload/tools/lib/schema-loader.cjs +139 -0
  400. package/dist/forge-payload/tools/lib/slug.cjs +39 -0
  401. package/dist/forge-payload/tools/lib/store-facade.cjs +6 -5
  402. package/dist/forge-payload/tools/preflight-gate.cjs +55 -7
  403. package/dist/forge-payload/tools/seed-store.cjs +1 -13
  404. package/dist/forge-payload/tools/store-cli.cjs +55 -108
  405. package/dist/forge-payload/tools/store.cjs +26 -37
  406. package/dist/forge-payload/tools/substitute-placeholders.cjs +74 -35
  407. package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.d.ts +1 -1
  408. package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.d.ts.map +1 -1
  409. package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js +23 -0
  410. package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js.map +1 -1
  411. package/node_modules/@earendil-works/pi-agent-core/dist/agent.d.ts +2 -2
  412. package/node_modules/@earendil-works/pi-agent-core/dist/agent.d.ts.map +1 -1
  413. package/node_modules/@earendil-works/pi-agent-core/dist/agent.js +1 -1
  414. package/node_modules/@earendil-works/pi-agent-core/dist/agent.js.map +1 -1
  415. package/node_modules/@earendil-works/pi-agent-core/dist/harness/agent-harness.d.ts +2 -2
  416. package/node_modules/@earendil-works/pi-agent-core/dist/harness/agent-harness.d.ts.map +1 -1
  417. package/node_modules/@earendil-works/pi-agent-core/dist/harness/agent-harness.js.map +1 -1
  418. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/branch-summarization.d.ts +5 -5
  419. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/branch-summarization.d.ts.map +1 -1
  420. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/branch-summarization.js.map +1 -1
  421. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/compaction.d.ts +4 -4
  422. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/compaction.d.ts.map +1 -1
  423. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/compaction.js.map +1 -1
  424. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/utils.d.ts +1 -1
  425. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/utils.d.ts.map +1 -1
  426. package/node_modules/@earendil-works/pi-agent-core/dist/harness/compaction/utils.js.map +1 -1
  427. package/node_modules/@earendil-works/pi-agent-core/dist/harness/env/nodejs.d.ts +1 -1
  428. package/node_modules/@earendil-works/pi-agent-core/dist/harness/env/nodejs.d.ts.map +1 -1
  429. package/node_modules/@earendil-works/pi-agent-core/dist/harness/env/nodejs.js.map +1 -1
  430. package/node_modules/@earendil-works/pi-agent-core/dist/harness/execution-env.d.ts +4 -0
  431. package/node_modules/@earendil-works/pi-agent-core/dist/harness/execution-env.d.ts.map +1 -0
  432. package/node_modules/@earendil-works/pi-agent-core/dist/harness/execution-env.js +3 -0
  433. package/node_modules/@earendil-works/pi-agent-core/dist/harness/execution-env.js.map +1 -0
  434. package/node_modules/@earendil-works/pi-agent-core/dist/harness/messages.d.ts +2 -2
  435. package/node_modules/@earendil-works/pi-agent-core/dist/harness/messages.d.ts.map +1 -1
  436. package/node_modules/@earendil-works/pi-agent-core/dist/harness/messages.js.map +1 -1
  437. package/node_modules/@earendil-works/pi-agent-core/dist/harness/prompt-templates.d.ts +1 -1
  438. package/node_modules/@earendil-works/pi-agent-core/dist/harness/prompt-templates.d.ts.map +1 -1
  439. package/node_modules/@earendil-works/pi-agent-core/dist/harness/prompt-templates.js.map +1 -1
  440. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-repo.d.ts +1 -1
  441. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-repo.d.ts.map +1 -1
  442. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-repo.js.map +1 -1
  443. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-storage.d.ts +1 -1
  444. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-storage.d.ts.map +1 -1
  445. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/jsonl-storage.js.map +1 -1
  446. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-repo.d.ts +1 -1
  447. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-repo.d.ts.map +1 -1
  448. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-repo.js.map +1 -1
  449. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-storage.d.ts +1 -1
  450. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-storage.d.ts.map +1 -1
  451. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/memory-storage.js.map +1 -1
  452. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repo/jsonl.d.ts +20 -0
  453. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repo/jsonl.d.ts.map +1 -0
  454. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repo/jsonl.js +92 -0
  455. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repo/jsonl.js.map +1 -0
  456. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repo/memory.d.ts +18 -0
  457. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repo/memory.d.ts.map +1 -0
  458. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repo/memory.js +42 -0
  459. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repo/memory.js.map +1 -0
  460. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repo/shared.d.ts +10 -0
  461. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repo/shared.d.ts.map +1 -0
  462. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repo/shared.js +31 -0
  463. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repo/shared.js.map +1 -0
  464. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repo-utils.d.ts +2 -2
  465. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repo-utils.d.ts.map +1 -1
  466. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/repo-utils.js.map +1 -1
  467. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/session.d.ts +2 -2
  468. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/session.d.ts.map +1 -1
  469. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/session.js.map +1 -1
  470. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/storage/jsonl.d.ts +30 -0
  471. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/storage/jsonl.d.ts.map +1 -0
  472. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/storage/jsonl.js +170 -0
  473. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/storage/jsonl.js.map +1 -0
  474. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/storage/memory.d.ts +26 -0
  475. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/storage/memory.d.ts.map +1 -0
  476. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/storage/memory.js +90 -0
  477. package/node_modules/@earendil-works/pi-agent-core/dist/harness/session/storage/memory.js.map +1 -0
  478. package/node_modules/@earendil-works/pi-agent-core/dist/harness/skills.d.ts +1 -1
  479. package/node_modules/@earendil-works/pi-agent-core/dist/harness/skills.d.ts.map +1 -1
  480. package/node_modules/@earendil-works/pi-agent-core/dist/harness/skills.js.map +1 -1
  481. package/node_modules/@earendil-works/pi-agent-core/dist/harness/system-prompt.d.ts +1 -1
  482. package/node_modules/@earendil-works/pi-agent-core/dist/harness/system-prompt.d.ts.map +1 -1
  483. package/node_modules/@earendil-works/pi-agent-core/dist/harness/system-prompt.js.map +1 -1
  484. package/node_modules/@earendil-works/pi-agent-core/dist/harness/types.d.ts +10 -22
  485. package/node_modules/@earendil-works/pi-agent-core/dist/harness/types.d.ts.map +1 -1
  486. package/node_modules/@earendil-works/pi-agent-core/dist/harness/types.js +17 -23
  487. package/node_modules/@earendil-works/pi-agent-core/dist/harness/types.js.map +1 -1
  488. package/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/shell-output.d.ts +1 -1
  489. package/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/shell-output.d.ts.map +1 -1
  490. package/node_modules/@earendil-works/pi-agent-core/dist/harness/utils/shell-output.js.map +1 -1
  491. package/node_modules/@earendil-works/pi-agent-core/dist/index.d.ts +19 -19
  492. package/node_modules/@earendil-works/pi-agent-core/dist/index.d.ts.map +1 -1
  493. package/node_modules/@earendil-works/pi-agent-core/dist/index.js.map +1 -1
  494. package/node_modules/@earendil-works/pi-agent-core/dist/node.d.ts +2 -2
  495. package/node_modules/@earendil-works/pi-agent-core/dist/node.d.ts.map +1 -1
  496. package/node_modules/@earendil-works/pi-agent-core/dist/node.js.map +1 -1
  497. package/node_modules/@earendil-works/pi-agent-core/package.json +9 -10
  498. package/node_modules/@earendil-works/pi-ai/dist/api-registry.d.ts +1 -1
  499. package/node_modules/@earendil-works/pi-ai/dist/api-registry.d.ts.map +1 -1
  500. package/node_modules/@earendil-works/pi-ai/dist/api-registry.js.map +1 -1
  501. package/node_modules/@earendil-works/pi-ai/dist/bedrock-provider.d.ts +2 -2
  502. package/node_modules/@earendil-works/pi-ai/dist/bedrock-provider.d.ts.map +1 -1
  503. package/node_modules/@earendil-works/pi-ai/dist/bedrock-provider.js.map +1 -1
  504. package/node_modules/@earendil-works/pi-ai/dist/cli.d.ts.map +1 -1
  505. package/node_modules/@earendil-works/pi-ai/dist/cli.js +14 -0
  506. package/node_modules/@earendil-works/pi-ai/dist/cli.js.map +1 -1
  507. package/node_modules/@earendil-works/pi-ai/dist/env-api-keys.d.ts +1 -1
  508. package/node_modules/@earendil-works/pi-ai/dist/env-api-keys.d.ts.map +1 -1
  509. package/node_modules/@earendil-works/pi-ai/dist/env-api-keys.js +10 -2
  510. package/node_modules/@earendil-works/pi-ai/dist/env-api-keys.js.map +1 -1
  511. package/node_modules/@earendil-works/pi-ai/dist/image-models.d.ts +2 -2
  512. package/node_modules/@earendil-works/pi-ai/dist/image-models.d.ts.map +1 -1
  513. package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.d.ts.map +1 -1
  514. package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.js.map +1 -1
  515. package/node_modules/@earendil-works/pi-ai/dist/image-models.js.map +1 -1
  516. package/node_modules/@earendil-works/pi-ai/dist/images-api-registry.d.ts +1 -1
  517. package/node_modules/@earendil-works/pi-ai/dist/images-api-registry.d.ts.map +1 -1
  518. package/node_modules/@earendil-works/pi-ai/dist/images-api-registry.js.map +1 -1
  519. package/node_modules/@earendil-works/pi-ai/dist/images.d.ts +2 -2
  520. package/node_modules/@earendil-works/pi-ai/dist/images.d.ts.map +1 -1
  521. package/node_modules/@earendil-works/pi-ai/dist/images.js.map +1 -1
  522. package/node_modules/@earendil-works/pi-ai/dist/index.d.ts +29 -29
  523. package/node_modules/@earendil-works/pi-ai/dist/index.d.ts.map +1 -1
  524. package/node_modules/@earendil-works/pi-ai/dist/index.js.map +1 -1
  525. package/node_modules/@earendil-works/pi-ai/dist/models.d.ts +2 -2
  526. package/node_modules/@earendil-works/pi-ai/dist/models.d.ts.map +1 -1
  527. package/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts +317 -509
  528. package/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts.map +1 -1
  529. package/node_modules/@earendil-works/pi-ai/dist/models.generated.js +400 -620
  530. package/node_modules/@earendil-works/pi-ai/dist/models.generated.js.map +1 -1
  531. package/node_modules/@earendil-works/pi-ai/dist/models.js.map +1 -1
  532. package/node_modules/@earendil-works/pi-ai/dist/oauth.d.ts +1 -1
  533. package/node_modules/@earendil-works/pi-ai/dist/oauth.d.ts.map +1 -1
  534. package/node_modules/@earendil-works/pi-ai/dist/oauth.js.map +1 -1
  535. package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.d.ts +1 -1
  536. package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.d.ts.map +1 -1
  537. package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.js +5 -2
  538. package/node_modules/@earendil-works/pi-ai/dist/providers/amazon-bedrock.js.map +1 -1
  539. package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.d.ts +23 -6
  540. package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.d.ts.map +1 -1
  541. package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.js +11 -23
  542. package/node_modules/@earendil-works/pi-ai/dist/providers/anthropic.js.map +1 -1
  543. package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.d.ts +1 -1
  544. package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.d.ts.map +1 -1
  545. package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.js +2 -1
  546. package/node_modules/@earendil-works/pi-ai/dist/providers/azure-openai-responses.js.map +1 -1
  547. package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare.d.ts +1 -1
  548. package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare.d.ts.map +1 -1
  549. package/node_modules/@earendil-works/pi-ai/dist/providers/cloudflare.js.map +1 -1
  550. package/node_modules/@earendil-works/pi-ai/dist/providers/faux.d.ts +1 -1
  551. package/node_modules/@earendil-works/pi-ai/dist/providers/faux.d.ts.map +1 -1
  552. package/node_modules/@earendil-works/pi-ai/dist/providers/faux.js.map +1 -1
  553. package/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot-headers.d.ts +1 -1
  554. package/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot-headers.d.ts.map +1 -1
  555. package/node_modules/@earendil-works/pi-ai/dist/providers/github-copilot-headers.js.map +1 -1
  556. package/node_modules/@earendil-works/pi-ai/dist/providers/google-shared.d.ts +1 -1
  557. package/node_modules/@earendil-works/pi-ai/dist/providers/google-shared.d.ts.map +1 -1
  558. package/node_modules/@earendil-works/pi-ai/dist/providers/google-shared.js.map +1 -1
  559. package/node_modules/@earendil-works/pi-ai/dist/providers/google-vertex.d.ts +2 -2
  560. package/node_modules/@earendil-works/pi-ai/dist/providers/google-vertex.d.ts.map +1 -1
  561. package/node_modules/@earendil-works/pi-ai/dist/providers/google-vertex.js.map +1 -1
  562. package/node_modules/@earendil-works/pi-ai/dist/providers/google.d.ts +2 -2
  563. package/node_modules/@earendil-works/pi-ai/dist/providers/google.d.ts.map +1 -1
  564. package/node_modules/@earendil-works/pi-ai/dist/providers/google.js.map +1 -1
  565. package/node_modules/@earendil-works/pi-ai/dist/providers/images/openrouter.d.ts +1 -1
  566. package/node_modules/@earendil-works/pi-ai/dist/providers/images/openrouter.d.ts.map +1 -1
  567. package/node_modules/@earendil-works/pi-ai/dist/providers/images/openrouter.js.map +1 -1
  568. package/node_modules/@earendil-works/pi-ai/dist/providers/images/register-builtins.d.ts +1 -1
  569. package/node_modules/@earendil-works/pi-ai/dist/providers/images/register-builtins.d.ts.map +1 -1
  570. package/node_modules/@earendil-works/pi-ai/dist/providers/images/register-builtins.js.map +1 -1
  571. package/node_modules/@earendil-works/pi-ai/dist/providers/mistral.d.ts +1 -1
  572. package/node_modules/@earendil-works/pi-ai/dist/providers/mistral.d.ts.map +1 -1
  573. package/node_modules/@earendil-works/pi-ai/dist/providers/mistral.js.map +1 -1
  574. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex-responses.d.ts +1 -1
  575. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex-responses.d.ts.map +1 -1
  576. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex-responses.js +12 -3
  577. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-codex-responses.js.map +1 -1
  578. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-completions.d.ts +1 -1
  579. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-completions.d.ts.map +1 -1
  580. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-completions.js +2 -1
  581. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-completions.js.map +1 -1
  582. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-prompt-cache.d.ts +3 -0
  583. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-prompt-cache.d.ts.map +1 -0
  584. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-prompt-cache.js +10 -0
  585. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-prompt-cache.js.map +1 -0
  586. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-responses-shared.d.ts +2 -2
  587. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-responses-shared.d.ts.map +1 -1
  588. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-responses-shared.js.map +1 -1
  589. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-responses.d.ts +1 -1
  590. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-responses.d.ts.map +1 -1
  591. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-responses.js +2 -1
  592. package/node_modules/@earendil-works/pi-ai/dist/providers/openai-responses.js.map +1 -1
  593. package/node_modules/@earendil-works/pi-ai/dist/providers/register-builtins.d.ts +10 -10
  594. package/node_modules/@earendil-works/pi-ai/dist/providers/register-builtins.d.ts.map +1 -1
  595. package/node_modules/@earendil-works/pi-ai/dist/providers/register-builtins.js +13 -2
  596. package/node_modules/@earendil-works/pi-ai/dist/providers/register-builtins.js.map +1 -1
  597. package/node_modules/@earendil-works/pi-ai/dist/providers/simple-options.d.ts +3 -3
  598. package/node_modules/@earendil-works/pi-ai/dist/providers/simple-options.d.ts.map +1 -1
  599. package/node_modules/@earendil-works/pi-ai/dist/providers/simple-options.js +6 -11
  600. package/node_modules/@earendil-works/pi-ai/dist/providers/simple-options.js.map +1 -1
  601. package/node_modules/@earendil-works/pi-ai/dist/providers/transform-messages.d.ts +1 -1
  602. package/node_modules/@earendil-works/pi-ai/dist/providers/transform-messages.d.ts.map +1 -1
  603. package/node_modules/@earendil-works/pi-ai/dist/providers/transform-messages.js.map +1 -1
  604. package/node_modules/@earendil-works/pi-ai/dist/stream.d.ts +3 -3
  605. package/node_modules/@earendil-works/pi-ai/dist/stream.d.ts.map +1 -1
  606. package/node_modules/@earendil-works/pi-ai/dist/stream.js.map +1 -1
  607. package/node_modules/@earendil-works/pi-ai/dist/types.d.ts +13 -3
  608. package/node_modules/@earendil-works/pi-ai/dist/types.d.ts.map +1 -1
  609. package/node_modules/@earendil-works/pi-ai/dist/types.js.map +1 -1
  610. package/node_modules/@earendil-works/pi-ai/dist/utils/event-stream.d.ts +3 -3
  611. package/node_modules/@earendil-works/pi-ai/dist/utils/event-stream.d.ts.map +1 -1
  612. package/node_modules/@earendil-works/pi-ai/dist/utils/event-stream.js +2 -2
  613. package/node_modules/@earendil-works/pi-ai/dist/utils/event-stream.js.map +1 -1
  614. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/anthropic.d.ts +1 -1
  615. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/anthropic.d.ts.map +1 -1
  616. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/anthropic.js.map +1 -1
  617. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/device-code.d.ts +19 -0
  618. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/device-code.d.ts.map +1 -0
  619. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/device-code.js +55 -0
  620. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/device-code.js.map +1 -0
  621. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/github-copilot.d.ts +3 -3
  622. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/github-copilot.d.ts.map +1 -1
  623. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/github-copilot.js +45 -69
  624. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/github-copilot.js.map +1 -1
  625. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/index.d.ts +6 -5
  626. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/index.d.ts.map +1 -1
  627. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/index.js +1 -0
  628. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/index.js.map +1 -1
  629. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/openai-codex.d.ts +1 -1
  630. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/openai-codex.d.ts.map +1 -1
  631. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/openai-codex.js +1 -1
  632. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/openai-codex.js.map +1 -1
  633. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/types.d.ts +9 -2
  634. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/types.d.ts.map +1 -1
  635. package/node_modules/@earendil-works/pi-ai/dist/utils/oauth/types.js.map +1 -1
  636. package/node_modules/@earendil-works/pi-ai/dist/utils/overflow.d.ts +1 -1
  637. package/node_modules/@earendil-works/pi-ai/dist/utils/overflow.d.ts.map +1 -1
  638. package/node_modules/@earendil-works/pi-ai/dist/utils/overflow.js.map +1 -1
  639. package/node_modules/@earendil-works/pi-ai/dist/utils/validation.d.ts +1 -1
  640. package/node_modules/@earendil-works/pi-ai/dist/utils/validation.d.ts.map +1 -1
  641. package/node_modules/@earendil-works/pi-ai/dist/utils/validation.js.map +1 -1
  642. package/node_modules/@earendil-works/pi-ai/package.json +15 -16
  643. package/node_modules/@earendil-works/pi-coding-agent/CHANGELOG.md +55 -0
  644. package/node_modules/@earendil-works/pi-coding-agent/README.md +6 -4
  645. package/node_modules/@earendil-works/pi-coding-agent/dist/bun/cli.d.ts.map +1 -1
  646. package/node_modules/@earendil-works/pi-coding-agent/dist/bun/cli.js.map +1 -1
  647. package/node_modules/@earendil-works/pi-coding-agent/dist/cli/args.d.ts +1 -1
  648. package/node_modules/@earendil-works/pi-coding-agent/dist/cli/args.d.ts.map +1 -1
  649. package/node_modules/@earendil-works/pi-coding-agent/dist/cli/args.js.map +1 -1
  650. package/node_modules/@earendil-works/pi-coding-agent/dist/cli/config-selector.d.ts +2 -2
  651. package/node_modules/@earendil-works/pi-coding-agent/dist/cli/config-selector.d.ts.map +1 -1
  652. package/node_modules/@earendil-works/pi-coding-agent/dist/cli/config-selector.js.map +1 -1
  653. package/node_modules/@earendil-works/pi-coding-agent/dist/cli/file-processor.d.ts.map +1 -1
  654. package/node_modules/@earendil-works/pi-coding-agent/dist/cli/file-processor.js.map +1 -1
  655. package/node_modules/@earendil-works/pi-coding-agent/dist/cli/initial-message.d.ts +1 -1
  656. package/node_modules/@earendil-works/pi-coding-agent/dist/cli/initial-message.d.ts.map +1 -1
  657. package/node_modules/@earendil-works/pi-coding-agent/dist/cli/initial-message.js.map +1 -1
  658. package/node_modules/@earendil-works/pi-coding-agent/dist/cli/list-models.d.ts +1 -1
  659. package/node_modules/@earendil-works/pi-coding-agent/dist/cli/list-models.d.ts.map +1 -1
  660. package/node_modules/@earendil-works/pi-coding-agent/dist/cli/list-models.js.map +1 -1
  661. package/node_modules/@earendil-works/pi-coding-agent/dist/cli/session-picker.d.ts +1 -1
  662. package/node_modules/@earendil-works/pi-coding-agent/dist/cli/session-picker.d.ts.map +1 -1
  663. package/node_modules/@earendil-works/pi-coding-agent/dist/cli/session-picker.js.map +1 -1
  664. package/node_modules/@earendil-works/pi-coding-agent/dist/cli.d.ts.map +1 -1
  665. package/node_modules/@earendil-works/pi-coding-agent/dist/cli.js +4 -10
  666. package/node_modules/@earendil-works/pi-coding-agent/dist/cli.js.map +1 -1
  667. package/node_modules/@earendil-works/pi-coding-agent/dist/config.d.ts.map +1 -1
  668. package/node_modules/@earendil-works/pi-coding-agent/dist/config.js +13 -14
  669. package/node_modules/@earendil-works/pi-coding-agent/dist/config.js.map +1 -1
  670. package/node_modules/@earendil-works/pi-coding-agent/dist/core/agent-session-runtime.d.ts +9 -9
  671. package/node_modules/@earendil-works/pi-coding-agent/dist/core/agent-session-runtime.d.ts.map +1 -1
  672. package/node_modules/@earendil-works/pi-coding-agent/dist/core/agent-session-runtime.js +6 -6
  673. package/node_modules/@earendil-works/pi-coding-agent/dist/core/agent-session-runtime.js.map +1 -1
  674. package/node_modules/@earendil-works/pi-coding-agent/dist/core/agent-session-services.d.ts +7 -7
  675. package/node_modules/@earendil-works/pi-coding-agent/dist/core/agent-session-services.d.ts.map +1 -1
  676. package/node_modules/@earendil-works/pi-coding-agent/dist/core/agent-session-services.js +3 -2
  677. package/node_modules/@earendil-works/pi-coding-agent/dist/core/agent-session-services.js.map +1 -1
  678. package/node_modules/@earendil-works/pi-coding-agent/dist/core/agent-session.d.ts +23 -21
  679. package/node_modules/@earendil-works/pi-coding-agent/dist/core/agent-session.d.ts.map +1 -1
  680. package/node_modules/@earendil-works/pi-coding-agent/dist/core/agent-session.js +99 -137
  681. package/node_modules/@earendil-works/pi-coding-agent/dist/core/agent-session.js.map +1 -1
  682. package/node_modules/@earendil-works/pi-coding-agent/dist/core/auth-guidance.d.ts.map +1 -1
  683. package/node_modules/@earendil-works/pi-coding-agent/dist/core/auth-guidance.js.map +1 -1
  684. package/node_modules/@earendil-works/pi-coding-agent/dist/core/auth-storage.d.ts +1 -1
  685. package/node_modules/@earendil-works/pi-coding-agent/dist/core/auth-storage.d.ts.map +1 -1
  686. package/node_modules/@earendil-works/pi-coding-agent/dist/core/auth-storage.js +3 -2
  687. package/node_modules/@earendil-works/pi-coding-agent/dist/core/auth-storage.js.map +1 -1
  688. package/node_modules/@earendil-works/pi-coding-agent/dist/core/bash-executor.d.ts +1 -1
  689. package/node_modules/@earendil-works/pi-coding-agent/dist/core/bash-executor.d.ts.map +1 -1
  690. package/node_modules/@earendil-works/pi-coding-agent/dist/core/bash-executor.js.map +1 -1
  691. package/node_modules/@earendil-works/pi-coding-agent/dist/core/compaction/branch-summarization.d.ts +3 -3
  692. package/node_modules/@earendil-works/pi-coding-agent/dist/core/compaction/branch-summarization.d.ts.map +1 -1
  693. package/node_modules/@earendil-works/pi-coding-agent/dist/core/compaction/branch-summarization.js.map +1 -1
  694. package/node_modules/@earendil-works/pi-coding-agent/dist/core/compaction/compaction.d.ts +2 -2
  695. package/node_modules/@earendil-works/pi-coding-agent/dist/core/compaction/compaction.d.ts.map +1 -1
  696. package/node_modules/@earendil-works/pi-coding-agent/dist/core/compaction/compaction.js.map +1 -1
  697. package/node_modules/@earendil-works/pi-coding-agent/dist/core/compaction/index.d.ts +3 -3
  698. package/node_modules/@earendil-works/pi-coding-agent/dist/core/compaction/index.d.ts.map +1 -1
  699. package/node_modules/@earendil-works/pi-coding-agent/dist/core/compaction/index.js.map +1 -1
  700. package/node_modules/@earendil-works/pi-coding-agent/dist/core/exec.d.ts.map +1 -1
  701. package/node_modules/@earendil-works/pi-coding-agent/dist/core/exec.js.map +1 -1
  702. package/node_modules/@earendil-works/pi-coding-agent/dist/core/export-html/index.d.ts +1 -1
  703. package/node_modules/@earendil-works/pi-coding-agent/dist/core/export-html/index.d.ts.map +1 -1
  704. package/node_modules/@earendil-works/pi-coding-agent/dist/core/export-html/index.js +8 -6
  705. package/node_modules/@earendil-works/pi-coding-agent/dist/core/export-html/index.js.map +1 -1
  706. package/node_modules/@earendil-works/pi-coding-agent/dist/core/export-html/template.js +6 -3
  707. package/node_modules/@earendil-works/pi-coding-agent/dist/core/export-html/tool-renderer.d.ts +2 -2
  708. package/node_modules/@earendil-works/pi-coding-agent/dist/core/export-html/tool-renderer.d.ts.map +1 -1
  709. package/node_modules/@earendil-works/pi-coding-agent/dist/core/export-html/tool-renderer.js.map +1 -1
  710. package/node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/index.d.ts +8 -8
  711. package/node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/index.d.ts.map +1 -1
  712. package/node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/index.js.map +1 -1
  713. package/node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/loader.d.ts +2 -2
  714. package/node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/loader.d.ts.map +1 -1
  715. package/node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/loader.js +12 -29
  716. package/node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/loader.js.map +1 -1
  717. package/node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/runner.d.ts +6 -6
  718. package/node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/runner.d.ts.map +1 -1
  719. package/node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/runner.js.map +1 -1
  720. package/node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/types.d.ts +19 -19
  721. package/node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/types.d.ts.map +1 -1
  722. package/node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/types.js.map +1 -1
  723. package/node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/wrapper.d.ts +2 -2
  724. package/node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/wrapper.d.ts.map +1 -1
  725. package/node_modules/@earendil-works/pi-coding-agent/dist/core/extensions/wrapper.js.map +1 -1
  726. package/node_modules/@earendil-works/pi-coding-agent/dist/core/footer-data-provider.d.ts.map +1 -1
  727. package/node_modules/@earendil-works/pi-coding-agent/dist/core/footer-data-provider.js.map +1 -1
  728. package/node_modules/@earendil-works/pi-coding-agent/dist/core/http-dispatcher.d.ts +21 -0
  729. package/node_modules/@earendil-works/pi-coding-agent/dist/core/http-dispatcher.d.ts.map +1 -0
  730. package/node_modules/@earendil-works/pi-coding-agent/dist/core/http-dispatcher.js +48 -0
  731. package/node_modules/@earendil-works/pi-coding-agent/dist/core/http-dispatcher.js.map +1 -0
  732. package/node_modules/@earendil-works/pi-coding-agent/dist/core/index.d.ts +8 -8
  733. package/node_modules/@earendil-works/pi-coding-agent/dist/core/index.d.ts.map +1 -1
  734. package/node_modules/@earendil-works/pi-coding-agent/dist/core/index.js.map +1 -1
  735. package/node_modules/@earendil-works/pi-coding-agent/dist/core/keybindings.d.ts.map +1 -1
  736. package/node_modules/@earendil-works/pi-coding-agent/dist/core/keybindings.js.map +1 -1
  737. package/node_modules/@earendil-works/pi-coding-agent/dist/core/model-registry.d.ts +4 -4
  738. package/node_modules/@earendil-works/pi-coding-agent/dist/core/model-registry.d.ts.map +1 -1
  739. package/node_modules/@earendil-works/pi-coding-agent/dist/core/model-registry.js +7 -3
  740. package/node_modules/@earendil-works/pi-coding-agent/dist/core/model-registry.js.map +1 -1
  741. package/node_modules/@earendil-works/pi-coding-agent/dist/core/model-resolver.d.ts +1 -1
  742. package/node_modules/@earendil-works/pi-coding-agent/dist/core/model-resolver.d.ts.map +1 -1
  743. package/node_modules/@earendil-works/pi-coding-agent/dist/core/model-resolver.js.map +1 -1
  744. package/node_modules/@earendil-works/pi-coding-agent/dist/core/package-manager.d.ts +2 -1
  745. package/node_modules/@earendil-works/pi-coding-agent/dist/core/package-manager.d.ts.map +1 -1
  746. package/node_modules/@earendil-works/pi-coding-agent/dist/core/package-manager.js +48 -32
  747. package/node_modules/@earendil-works/pi-coding-agent/dist/core/package-manager.js.map +1 -1
  748. package/node_modules/@earendil-works/pi-coding-agent/dist/core/prompt-templates.d.ts +1 -1
  749. package/node_modules/@earendil-works/pi-coding-agent/dist/core/prompt-templates.d.ts.map +1 -1
  750. package/node_modules/@earendil-works/pi-coding-agent/dist/core/prompt-templates.js +6 -20
  751. package/node_modules/@earendil-works/pi-coding-agent/dist/core/prompt-templates.js.map +1 -1
  752. package/node_modules/@earendil-works/pi-coding-agent/dist/core/resolve-config-value.d.ts.map +1 -1
  753. package/node_modules/@earendil-works/pi-coding-agent/dist/core/resolve-config-value.js.map +1 -1
  754. package/node_modules/@earendil-works/pi-coding-agent/dist/core/resource-loader.d.ts +9 -9
  755. package/node_modules/@earendil-works/pi-coding-agent/dist/core/resource-loader.d.ts.map +1 -1
  756. package/node_modules/@earendil-works/pi-coding-agent/dist/core/resource-loader.js +38 -31
  757. package/node_modules/@earendil-works/pi-coding-agent/dist/core/resource-loader.js.map +1 -1
  758. package/node_modules/@earendil-works/pi-coding-agent/dist/core/sdk.d.ts +13 -13
  759. package/node_modules/@earendil-works/pi-coding-agent/dist/core/sdk.d.ts.map +1 -1
  760. package/node_modules/@earendil-works/pi-coding-agent/dist/core/sdk.js +9 -4
  761. package/node_modules/@earendil-works/pi-coding-agent/dist/core/sdk.js.map +1 -1
  762. package/node_modules/@earendil-works/pi-coding-agent/dist/core/session-manager.d.ts +1 -1
  763. package/node_modules/@earendil-works/pi-coding-agent/dist/core/session-manager.d.ts.map +1 -1
  764. package/node_modules/@earendil-works/pi-coding-agent/dist/core/session-manager.js +32 -24
  765. package/node_modules/@earendil-works/pi-coding-agent/dist/core/session-manager.js.map +1 -1
  766. package/node_modules/@earendil-works/pi-coding-agent/dist/core/settings-manager.d.ts +3 -0
  767. package/node_modules/@earendil-works/pi-coding-agent/dist/core/settings-manager.d.ts.map +1 -1
  768. package/node_modules/@earendil-works/pi-coding-agent/dist/core/settings-manager.js +26 -13
  769. package/node_modules/@earendil-works/pi-coding-agent/dist/core/settings-manager.js.map +1 -1
  770. package/node_modules/@earendil-works/pi-coding-agent/dist/core/skills.d.ts +2 -2
  771. package/node_modules/@earendil-works/pi-coding-agent/dist/core/skills.d.ts.map +1 -1
  772. package/node_modules/@earendil-works/pi-coding-agent/dist/core/skills.js +8 -22
  773. package/node_modules/@earendil-works/pi-coding-agent/dist/core/skills.js.map +1 -1
  774. package/node_modules/@earendil-works/pi-coding-agent/dist/core/slash-commands.d.ts +1 -1
  775. package/node_modules/@earendil-works/pi-coding-agent/dist/core/slash-commands.d.ts.map +1 -1
  776. package/node_modules/@earendil-works/pi-coding-agent/dist/core/slash-commands.js.map +1 -1
  777. package/node_modules/@earendil-works/pi-coding-agent/dist/core/source-info.d.ts +1 -1
  778. package/node_modules/@earendil-works/pi-coding-agent/dist/core/source-info.d.ts.map +1 -1
  779. package/node_modules/@earendil-works/pi-coding-agent/dist/core/source-info.js.map +1 -1
  780. package/node_modules/@earendil-works/pi-coding-agent/dist/core/system-prompt.d.ts +1 -1
  781. package/node_modules/@earendil-works/pi-coding-agent/dist/core/system-prompt.d.ts.map +1 -1
  782. package/node_modules/@earendil-works/pi-coding-agent/dist/core/system-prompt.js +1 -0
  783. package/node_modules/@earendil-works/pi-coding-agent/dist/core/system-prompt.js.map +1 -1
  784. package/node_modules/@earendil-works/pi-coding-agent/dist/core/telemetry.d.ts +1 -1
  785. package/node_modules/@earendil-works/pi-coding-agent/dist/core/telemetry.d.ts.map +1 -1
  786. package/node_modules/@earendil-works/pi-coding-agent/dist/core/telemetry.js.map +1 -1
  787. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/bash.d.ts +2 -2
  788. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/bash.d.ts.map +1 -1
  789. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/bash.js +9 -3
  790. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/bash.js.map +1 -1
  791. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/edit-diff.d.ts +3 -1
  792. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/edit-diff.d.ts.map +1 -1
  793. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/edit-diff.js +8 -1
  794. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/edit-diff.js.map +1 -1
  795. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/edit.d.ts +5 -3
  796. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/edit.d.ts.map +1 -1
  797. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/edit.js +3 -2
  798. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/edit.js.map +1 -1
  799. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/find.d.ts +2 -2
  800. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/find.d.ts.map +1 -1
  801. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/find.js.map +1 -1
  802. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/grep.d.ts +2 -2
  803. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/grep.d.ts.map +1 -1
  804. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/grep.js.map +1 -1
  805. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/index.d.ts +17 -17
  806. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/index.d.ts.map +1 -1
  807. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/index.js.map +1 -1
  808. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/ls.d.ts +2 -2
  809. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/ls.d.ts.map +1 -1
  810. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/ls.js.map +1 -1
  811. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/output-accumulator.d.ts +3 -1
  812. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/output-accumulator.d.ts.map +1 -1
  813. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/output-accumulator.js +9 -3
  814. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/output-accumulator.js.map +1 -1
  815. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/path-utils.d.ts.map +1 -1
  816. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/path-utils.js +3 -22
  817. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/path-utils.js.map +1 -1
  818. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/read.d.ts +2 -2
  819. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/read.d.ts.map +1 -1
  820. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/read.js.map +1 -1
  821. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/render-utils.d.ts.map +1 -1
  822. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/render-utils.js.map +1 -1
  823. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/tool-definition-wrapper.d.ts +1 -1
  824. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
  825. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/tool-definition-wrapper.js.map +1 -1
  826. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/truncate.d.ts.map +1 -1
  827. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/truncate.js +12 -2
  828. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/truncate.js.map +1 -1
  829. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/write.d.ts +1 -1
  830. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/write.d.ts.map +1 -1
  831. package/node_modules/@earendil-works/pi-coding-agent/dist/core/tools/write.js.map +1 -1
  832. package/node_modules/@earendil-works/pi-coding-agent/dist/index.d.ts +30 -29
  833. package/node_modules/@earendil-works/pi-coding-agent/dist/index.d.ts.map +1 -1
  834. package/node_modules/@earendil-works/pi-coding-agent/dist/index.js +2 -1
  835. package/node_modules/@earendil-works/pi-coding-agent/dist/index.js.map +1 -1
  836. package/node_modules/@earendil-works/pi-coding-agent/dist/main.d.ts +1 -1
  837. package/node_modules/@earendil-works/pi-coding-agent/dist/main.d.ts.map +1 -1
  838. package/node_modules/@earendil-works/pi-coding-agent/dist/main.js +7 -6
  839. package/node_modules/@earendil-works/pi-coding-agent/dist/main.js.map +1 -1
  840. package/node_modules/@earendil-works/pi-coding-agent/dist/migrations.d.ts.map +1 -1
  841. package/node_modules/@earendil-works/pi-coding-agent/dist/migrations.js.map +1 -1
  842. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/index.d.ts +5 -5
  843. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/index.d.ts.map +1 -1
  844. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/index.js.map +1 -1
  845. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/armin.d.ts.map +1 -1
  846. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/armin.js.map +1 -1
  847. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  848. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/assistant-message.js.map +1 -1
  849. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/bash-execution.d.ts +1 -1
  850. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
  851. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/bash-execution.js.map +1 -1
  852. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/bordered-loader.d.ts +1 -1
  853. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -1
  854. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/bordered-loader.js.map +1 -1
  855. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/branch-summary-message.d.ts +1 -1
  856. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
  857. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
  858. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/compaction-summary-message.d.ts +1 -1
  859. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
  860. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
  861. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/config-selector.d.ts +2 -2
  862. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
  863. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/config-selector.js +1 -1
  864. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/config-selector.js.map +1 -1
  865. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/countdown-timer.d.ts +2 -2
  866. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/countdown-timer.d.ts.map +1 -1
  867. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/countdown-timer.js +2 -2
  868. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/countdown-timer.js.map +1 -1
  869. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/custom-editor.d.ts +1 -1
  870. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
  871. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/custom-editor.js.map +1 -1
  872. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/custom-message.d.ts +2 -2
  873. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
  874. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/custom-message.js.map +1 -1
  875. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/daxnuts.d.ts.map +1 -1
  876. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/daxnuts.js.map +1 -1
  877. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/diff.d.ts.map +1 -1
  878. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/diff.js.map +1 -1
  879. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -1
  880. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/dynamic-border.js.map +1 -1
  881. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/earendil-announcement.d.ts.map +1 -1
  882. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/earendil-announcement.js.map +1 -1
  883. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/extension-editor.d.ts +1 -1
  884. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
  885. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/extension-editor.js.map +1 -1
  886. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/extension-input.d.ts.map +1 -1
  887. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/extension-input.js.map +1 -1
  888. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/extension-selector.d.ts.map +1 -1
  889. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/extension-selector.js.map +1 -1
  890. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/footer.d.ts +4 -3
  891. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/footer.d.ts.map +1 -1
  892. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/footer.js +16 -7
  893. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/footer.js.map +1 -1
  894. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/index.d.ts +31 -31
  895. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/index.d.ts.map +1 -1
  896. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/index.js.map +1 -1
  897. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -1
  898. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/keybinding-hints.js.map +1 -1
  899. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/login-dialog.d.ts +10 -2
  900. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
  901. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/login-dialog.js +31 -6
  902. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/login-dialog.js.map +1 -1
  903. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/model-selector.d.ts +2 -2
  904. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  905. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/model-selector.js.map +1 -1
  906. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/oauth-selector.d.ts +1 -1
  907. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
  908. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/oauth-selector.js.map +1 -1
  909. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
  910. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
  911. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/session-selector-search.d.ts +1 -1
  912. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -1
  913. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/session-selector-search.js.map +1 -1
  914. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/session-selector.d.ts +3 -3
  915. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
  916. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/session-selector.js.map +1 -1
  917. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/settings-selector.d.ts +3 -1
  918. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  919. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/settings-selector.js +15 -0
  920. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/settings-selector.js.map +1 -1
  921. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/show-images-selector.d.ts.map +1 -1
  922. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/show-images-selector.js.map +1 -1
  923. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/skill-invocation-message.d.ts +1 -1
  924. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
  925. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
  926. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/theme-selector.d.ts.map +1 -1
  927. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/theme-selector.js.map +1 -1
  928. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
  929. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/thinking-selector.js.map +1 -1
  930. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/tool-execution.d.ts +1 -1
  931. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  932. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/tool-execution.js.map +1 -1
  933. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/tree-selector.d.ts +1 -1
  934. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
  935. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/tree-selector.js.map +1 -1
  936. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -1
  937. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/user-message-selector.js.map +1 -1
  938. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/user-message.d.ts.map +1 -1
  939. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/components/user-message.js.map +1 -1
  940. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts +4 -3
  941. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  942. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/interactive-mode.js +37 -14
  943. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/interactive-mode.js.map +1 -1
  944. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/theme/theme.d.ts +1 -1
  945. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  946. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/theme/theme.js +37 -28
  947. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/interactive/theme/theme.js.map +1 -1
  948. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/print-mode.d.ts +1 -1
  949. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/print-mode.d.ts.map +1 -1
  950. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/print-mode.js.map +1 -1
  951. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/rpc/rpc-client.d.ts +5 -5
  952. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  953. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/rpc/rpc-client.js +1 -1
  954. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/rpc/rpc-client.js.map +1 -1
  955. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/rpc/rpc-mode.d.ts +2 -2
  956. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  957. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/rpc/rpc-mode.js.map +1 -1
  958. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/rpc/rpc-types.d.ts +4 -4
  959. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  960. package/node_modules/@earendil-works/pi-coding-agent/dist/modes/rpc/rpc-types.js.map +1 -1
  961. package/node_modules/@earendil-works/pi-coding-agent/dist/package-manager-cli.d.ts.map +1 -1
  962. package/node_modules/@earendil-works/pi-coding-agent/dist/package-manager-cli.js +40 -1
  963. package/node_modules/@earendil-works/pi-coding-agent/dist/package-manager-cli.js.map +1 -1
  964. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/changelog.d.ts +1 -1
  965. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/changelog.d.ts.map +1 -1
  966. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/changelog.js.map +1 -1
  967. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/clipboard-image.d.ts.map +1 -1
  968. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/clipboard-image.js.map +1 -1
  969. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/clipboard.d.ts.map +1 -1
  970. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/clipboard.js.map +1 -1
  971. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/exif-orientation.d.ts +1 -1
  972. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/exif-orientation.d.ts.map +1 -1
  973. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/exif-orientation.js.map +1 -1
  974. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/image-convert.d.ts.map +1 -1
  975. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/image-convert.js.map +1 -1
  976. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/image-resize.d.ts.map +1 -1
  977. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/image-resize.js.map +1 -1
  978. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/paths.d.ts +16 -1
  979. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/paths.d.ts.map +1 -1
  980. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/paths.js +49 -7
  981. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/paths.js.map +1 -1
  982. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/shell.d.ts.map +1 -1
  983. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/shell.js.map +1 -1
  984. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/syntax-highlight.d.ts.map +1 -1
  985. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/syntax-highlight.js.map +1 -1
  986. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/tools-manager.d.ts.map +1 -1
  987. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/tools-manager.js.map +1 -1
  988. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/version-check.d.ts +2 -1
  989. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/version-check.d.ts.map +1 -1
  990. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/version-check.js +9 -4
  991. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/version-check.js.map +1 -1
  992. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/windows-self-update.d.ts.map +1 -1
  993. package/node_modules/@earendil-works/pi-coding-agent/dist/utils/windows-self-update.js.map +1 -1
  994. package/node_modules/@earendil-works/pi-coding-agent/docs/custom-provider.md +44 -12
  995. package/node_modules/@earendil-works/pi-coding-agent/docs/index.md +6 -4
  996. package/node_modules/@earendil-works/pi-coding-agent/docs/models.md +8 -2
  997. package/node_modules/@earendil-works/pi-coding-agent/docs/packages.md +5 -4
  998. package/node_modules/@earendil-works/pi-coding-agent/docs/quickstart.md +3 -1
  999. package/node_modules/@earendil-works/pi-coding-agent/docs/sdk.md +2 -0
  1000. package/node_modules/@earendil-works/pi-coding-agent/docs/termux.md +1 -1
  1001. package/node_modules/@earendil-works/pi-coding-agent/docs/usage.md +2 -2
  1002. package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/custom-provider-anthropic/package.json +2 -2
  1003. package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  1004. package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/custom-provider-gitlab-duo/test.ts +1 -1
  1005. package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/doom-overlay/doom-component.ts +2 -2
  1006. package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/doom-overlay/index.ts +3 -3
  1007. package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/overlay-qa-tests.ts +97 -66
  1008. package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/overlay-test.ts +7 -4
  1009. package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/plan-mode/index.ts +1 -1
  1010. package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/sandbox/package.json +2 -2
  1011. package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/subagent/index.ts +1 -1
  1012. package/node_modules/@earendil-works/pi-coding-agent/examples/extensions/with-deps/package.json +3 -3
  1013. package/node_modules/@earendil-works/pi-coding-agent/npm-shrinkwrap.json +1425 -0
  1014. package/node_modules/@earendil-works/pi-coding-agent/package.json +32 -31
  1015. package/node_modules/@earendil-works/pi-tui/dist/autocomplete.d.ts.map +1 -1
  1016. package/node_modules/@earendil-works/pi-tui/dist/autocomplete.js.map +1 -1
  1017. package/node_modules/@earendil-works/pi-tui/dist/components/box.d.ts +1 -1
  1018. package/node_modules/@earendil-works/pi-tui/dist/components/box.d.ts.map +1 -1
  1019. package/node_modules/@earendil-works/pi-tui/dist/components/box.js.map +1 -1
  1020. package/node_modules/@earendil-works/pi-tui/dist/components/cancellable-loader.d.ts +1 -1
  1021. package/node_modules/@earendil-works/pi-tui/dist/components/cancellable-loader.d.ts.map +1 -1
  1022. package/node_modules/@earendil-works/pi-tui/dist/components/cancellable-loader.js.map +1 -1
  1023. package/node_modules/@earendil-works/pi-tui/dist/components/editor.d.ts +3 -3
  1024. package/node_modules/@earendil-works/pi-tui/dist/components/editor.d.ts.map +1 -1
  1025. package/node_modules/@earendil-works/pi-tui/dist/components/editor.js.map +1 -1
  1026. package/node_modules/@earendil-works/pi-tui/dist/components/image.d.ts +2 -2
  1027. package/node_modules/@earendil-works/pi-tui/dist/components/image.d.ts.map +1 -1
  1028. package/node_modules/@earendil-works/pi-tui/dist/components/image.js.map +1 -1
  1029. package/node_modules/@earendil-works/pi-tui/dist/components/input.d.ts +1 -1
  1030. package/node_modules/@earendil-works/pi-tui/dist/components/input.d.ts.map +1 -1
  1031. package/node_modules/@earendil-works/pi-tui/dist/components/input.js.map +1 -1
  1032. package/node_modules/@earendil-works/pi-tui/dist/components/loader.d.ts +5 -5
  1033. package/node_modules/@earendil-works/pi-tui/dist/components/loader.d.ts.map +1 -1
  1034. package/node_modules/@earendil-works/pi-tui/dist/components/loader.js +4 -4
  1035. package/node_modules/@earendil-works/pi-tui/dist/components/loader.js.map +1 -1
  1036. package/node_modules/@earendil-works/pi-tui/dist/components/markdown.d.ts +1 -1
  1037. package/node_modules/@earendil-works/pi-tui/dist/components/markdown.d.ts.map +1 -1
  1038. package/node_modules/@earendil-works/pi-tui/dist/components/markdown.js.map +1 -1
  1039. package/node_modules/@earendil-works/pi-tui/dist/components/select-list.d.ts +1 -1
  1040. package/node_modules/@earendil-works/pi-tui/dist/components/select-list.d.ts.map +1 -1
  1041. package/node_modules/@earendil-works/pi-tui/dist/components/select-list.js.map +1 -1
  1042. package/node_modules/@earendil-works/pi-tui/dist/components/settings-list.d.ts +1 -1
  1043. package/node_modules/@earendil-works/pi-tui/dist/components/settings-list.d.ts.map +1 -1
  1044. package/node_modules/@earendil-works/pi-tui/dist/components/settings-list.js.map +1 -1
  1045. package/node_modules/@earendil-works/pi-tui/dist/components/spacer.d.ts +1 -1
  1046. package/node_modules/@earendil-works/pi-tui/dist/components/spacer.d.ts.map +1 -1
  1047. package/node_modules/@earendil-works/pi-tui/dist/components/spacer.js.map +1 -1
  1048. package/node_modules/@earendil-works/pi-tui/dist/components/text.d.ts +1 -1
  1049. package/node_modules/@earendil-works/pi-tui/dist/components/text.d.ts.map +1 -1
  1050. package/node_modules/@earendil-works/pi-tui/dist/components/text.js.map +1 -1
  1051. package/node_modules/@earendil-works/pi-tui/dist/components/truncated-text.d.ts +1 -1
  1052. package/node_modules/@earendil-works/pi-tui/dist/components/truncated-text.d.ts.map +1 -1
  1053. package/node_modules/@earendil-works/pi-tui/dist/components/truncated-text.js.map +1 -1
  1054. package/node_modules/@earendil-works/pi-tui/dist/editor-component.d.ts +2 -2
  1055. package/node_modules/@earendil-works/pi-tui/dist/editor-component.d.ts.map +1 -1
  1056. package/node_modules/@earendil-works/pi-tui/dist/editor-component.js.map +1 -1
  1057. package/node_modules/@earendil-works/pi-tui/dist/index.d.ts +22 -22
  1058. package/node_modules/@earendil-works/pi-tui/dist/index.d.ts.map +1 -1
  1059. package/node_modules/@earendil-works/pi-tui/dist/index.js.map +1 -1
  1060. package/node_modules/@earendil-works/pi-tui/dist/keybindings.d.ts +1 -1
  1061. package/node_modules/@earendil-works/pi-tui/dist/keybindings.d.ts.map +1 -1
  1062. package/node_modules/@earendil-works/pi-tui/dist/keybindings.js.map +1 -1
  1063. package/node_modules/@earendil-works/pi-tui/dist/terminal.d.ts.map +1 -1
  1064. package/node_modules/@earendil-works/pi-tui/dist/terminal.js +25 -15
  1065. package/node_modules/@earendil-works/pi-tui/dist/terminal.js.map +1 -1
  1066. package/node_modules/@earendil-works/pi-tui/dist/tui.d.ts +2 -2
  1067. package/node_modules/@earendil-works/pi-tui/dist/tui.d.ts.map +1 -1
  1068. package/node_modules/@earendil-works/pi-tui/dist/tui.js.map +1 -1
  1069. package/node_modules/@earendil-works/pi-tui/native/win32/prebuilds/win32-arm64/win32-console-mode.node +0 -0
  1070. package/node_modules/@earendil-works/pi-tui/native/win32/prebuilds/win32-x64/win32-console-mode.node +0 -0
  1071. package/node_modules/@earendil-works/pi-tui/package.json +8 -11
  1072. package/package.json +13 -8
  1073. package/dist/bin/forgecli.d.ts +0 -2
  1074. package/dist/bin/forgecli.js +0 -6
  1075. package/dist/bin/forgecli.js.map +0 -1
  1076. package/node_modules/koffi/CHANGELOG.md +0 -1093
  1077. package/node_modules/koffi/LICENSE.txt +0 -22
  1078. package/node_modules/koffi/README.md +0 -43
  1079. package/node_modules/koffi/build/koffi/darwin_arm64/koffi.node +0 -0
  1080. package/node_modules/koffi/build/koffi/darwin_x64/koffi.node +0 -0
  1081. package/node_modules/koffi/build/koffi/freebsd_arm64/koffi.node +0 -0
  1082. package/node_modules/koffi/build/koffi/freebsd_ia32/koffi.node +0 -0
  1083. package/node_modules/koffi/build/koffi/freebsd_x64/koffi.node +0 -0
  1084. package/node_modules/koffi/build/koffi/linux_arm64/koffi.node +0 -0
  1085. package/node_modules/koffi/build/koffi/linux_armhf/koffi.node +0 -0
  1086. package/node_modules/koffi/build/koffi/linux_ia32/koffi.node +0 -0
  1087. package/node_modules/koffi/build/koffi/linux_loong64/koffi.node +0 -0
  1088. package/node_modules/koffi/build/koffi/linux_riscv64d/koffi.node +0 -0
  1089. package/node_modules/koffi/build/koffi/linux_x64/koffi.node +0 -0
  1090. package/node_modules/koffi/build/koffi/musl_arm64/koffi.node +0 -0
  1091. package/node_modules/koffi/build/koffi/musl_x64/koffi.node +0 -0
  1092. package/node_modules/koffi/build/koffi/openbsd_ia32/koffi.node +0 -0
  1093. package/node_modules/koffi/build/koffi/openbsd_x64/koffi.node +0 -0
  1094. package/node_modules/koffi/build/koffi/win32_arm64/koffi.exp +0 -0
  1095. package/node_modules/koffi/build/koffi/win32_arm64/koffi.lib +0 -0
  1096. package/node_modules/koffi/build/koffi/win32_arm64/koffi.node +0 -0
  1097. package/node_modules/koffi/build/koffi/win32_ia32/koffi.exp +0 -0
  1098. package/node_modules/koffi/build/koffi/win32_ia32/koffi.lib +0 -0
  1099. package/node_modules/koffi/build/koffi/win32_ia32/koffi.node +0 -0
  1100. package/node_modules/koffi/build/koffi/win32_x64/koffi.exp +0 -0
  1101. package/node_modules/koffi/build/koffi/win32_x64/koffi.lib +0 -0
  1102. package/node_modules/koffi/build/koffi/win32_x64/koffi.node +0 -0
  1103. package/node_modules/koffi/doc/benchmarks.md +0 -126
  1104. package/node_modules/koffi/doc/callbacks.md +0 -210
  1105. package/node_modules/koffi/doc/contribute.md +0 -148
  1106. package/node_modules/koffi/doc/functions.md +0 -250
  1107. package/node_modules/koffi/doc/index.md +0 -61
  1108. package/node_modules/koffi/doc/input.md +0 -471
  1109. package/node_modules/koffi/doc/migration.md +0 -159
  1110. package/node_modules/koffi/doc/misc.md +0 -180
  1111. package/node_modules/koffi/doc/output.md +0 -305
  1112. package/node_modules/koffi/doc/packaging.md +0 -88
  1113. package/node_modules/koffi/doc/platforms.md +0 -36
  1114. package/node_modules/koffi/doc/pointers.md +0 -328
  1115. package/node_modules/koffi/doc/start.md +0 -118
  1116. package/node_modules/koffi/doc/unions.md +0 -186
  1117. package/node_modules/koffi/doc/variables.md +0 -102
  1118. package/node_modules/koffi/index.d.ts +0 -288
  1119. package/node_modules/koffi/index.js +0 -634
  1120. package/node_modules/koffi/indirect.js +0 -533
  1121. package/node_modules/koffi/lib/native/base/base.cc +0 -11015
  1122. package/node_modules/koffi/lib/native/base/base.hh +0 -6003
  1123. package/node_modules/koffi/lib/native/base/crc.inc +0 -2214
  1124. package/node_modules/koffi/lib/native/base/crc_gen.py +0 -72
  1125. package/node_modules/koffi/lib/native/base/mimetypes.inc +0 -1248
  1126. package/node_modules/koffi/lib/native/base/mimetypes_gen.py +0 -58
  1127. package/node_modules/koffi/lib/native/base/tower.cc +0 -821
  1128. package/node_modules/koffi/lib/native/base/tower.hh +0 -81
  1129. package/node_modules/koffi/lib/native/base/unicode.inc +0 -408
  1130. package/node_modules/koffi/lib/native/base/unicode_gen.py +0 -152
  1131. package/node_modules/koffi/package.json +0 -38
  1132. package/node_modules/koffi/src/cnoke/LICENSE.txt +0 -22
  1133. package/node_modules/koffi/src/cnoke/README.md +0 -99
  1134. package/node_modules/koffi/src/cnoke/assets/FindCNoke.cmake +0 -127
  1135. package/node_modules/koffi/src/cnoke/assets/toolchains.json +0 -126
  1136. package/node_modules/koffi/src/cnoke/assets/win_delay_hook.c +0 -36
  1137. package/node_modules/koffi/src/cnoke/cnoke.js +0 -170
  1138. package/node_modules/koffi/src/cnoke/package.json +0 -24
  1139. package/node_modules/koffi/src/cnoke/src/builder.js +0 -511
  1140. package/node_modules/koffi/src/cnoke/src/index.js +0 -10
  1141. package/node_modules/koffi/src/cnoke/src/tools.js +0 -407
  1142. package/node_modules/koffi/src/koffi/CMakeLists.txt +0 -182
  1143. package/node_modules/koffi/src/koffi/src/abi_arm32.cc +0 -1018
  1144. package/node_modules/koffi/src/koffi/src/abi_arm32_asm.S +0 -169
  1145. package/node_modules/koffi/src/koffi/src/abi_arm64.cc +0 -1295
  1146. package/node_modules/koffi/src/koffi/src/abi_arm64_asm.S +0 -195
  1147. package/node_modules/koffi/src/koffi/src/abi_arm64_asm.asm +0 -174
  1148. package/node_modules/koffi/src/koffi/src/abi_loong64.cc +0 -5
  1149. package/node_modules/koffi/src/koffi/src/abi_loong64_asm.S +0 -204
  1150. package/node_modules/koffi/src/koffi/src/abi_riscv64.cc +0 -915
  1151. package/node_modules/koffi/src/koffi/src/abi_riscv64_asm.S +0 -203
  1152. package/node_modules/koffi/src/koffi/src/abi_x64_sysv.cc +0 -939
  1153. package/node_modules/koffi/src/koffi/src/abi_x64_sysv_asm.S +0 -231
  1154. package/node_modules/koffi/src/koffi/src/abi_x64_win.cc +0 -715
  1155. package/node_modules/koffi/src/koffi/src/abi_x64_win_asm.S +0 -166
  1156. package/node_modules/koffi/src/koffi/src/abi_x64_win_asm.asm +0 -192
  1157. package/node_modules/koffi/src/koffi/src/abi_x86.cc +0 -860
  1158. package/node_modules/koffi/src/koffi/src/abi_x86_asm.S +0 -193
  1159. package/node_modules/koffi/src/koffi/src/abi_x86_asm.asm +0 -177
  1160. package/node_modules/koffi/src/koffi/src/call.cc +0 -1326
  1161. package/node_modules/koffi/src/koffi/src/call.hh +0 -179
  1162. package/node_modules/koffi/src/koffi/src/errno.inc +0 -462
  1163. package/node_modules/koffi/src/koffi/src/ffi.cc +0 -2702
  1164. package/node_modules/koffi/src/koffi/src/ffi.hh +0 -354
  1165. package/node_modules/koffi/src/koffi/src/init.js +0 -105
  1166. package/node_modules/koffi/src/koffi/src/parser.cc +0 -220
  1167. package/node_modules/koffi/src/koffi/src/parser.hh +0 -54
  1168. package/node_modules/koffi/src/koffi/src/util.cc +0 -1807
  1169. package/node_modules/koffi/src/koffi/src/util.hh +0 -221
  1170. package/node_modules/koffi/src/koffi/src/uv.cc +0 -193
  1171. package/node_modules/koffi/src/koffi/src/uv.def +0 -10
  1172. package/node_modules/koffi/src/koffi/src/uv.hh +0 -40
  1173. package/node_modules/koffi/src/koffi/src/win32.cc +0 -198
  1174. package/node_modules/koffi/src/koffi/src/win32.hh +0 -119
  1175. package/node_modules/koffi/src/koffi/tools/write_trampolines.js +0 -77
  1176. package/node_modules/koffi/vendor/node-addon-api/LICENSE.md +0 -9
  1177. package/node_modules/koffi/vendor/node-addon-api/README.md +0 -95
  1178. package/node_modules/koffi/vendor/node-addon-api/napi-inl.deprecated.h +0 -186
  1179. package/node_modules/koffi/vendor/node-addon-api/napi-inl.h +0 -7033
  1180. package/node_modules/koffi/vendor/node-addon-api/napi.h +0 -3309
  1181. package/node_modules/koffi/vendor/node-api-headers/LICENSE +0 -21
  1182. package/node_modules/koffi/vendor/node-api-headers/README.md +0 -95
  1183. package/node_modules/koffi/vendor/node-api-headers/def/js_native_api.def +0 -125
  1184. package/node_modules/koffi/vendor/node-api-headers/def/node_api.def +0 -157
  1185. package/node_modules/koffi/vendor/node-api-headers/include/js_native_api.h +0 -591
  1186. package/node_modules/koffi/vendor/node-api-headers/include/js_native_api_types.h +0 -210
  1187. package/node_modules/koffi/vendor/node-api-headers/include/node_api.h +0 -265
  1188. package/node_modules/koffi/vendor/node-api-headers/include/node_api_types.h +0 -58
  1189. package/node_modules/koffi/vendor/node-api-headers/include/uv/aix.h +0 -32
  1190. package/node_modules/koffi/vendor/node-api-headers/include/uv/bsd.h +0 -34
  1191. package/node_modules/koffi/vendor/node-api-headers/include/uv/darwin.h +0 -61
  1192. package/node_modules/koffi/vendor/node-api-headers/include/uv/errno.h +0 -483
  1193. package/node_modules/koffi/vendor/node-api-headers/include/uv/linux.h +0 -34
  1194. package/node_modules/koffi/vendor/node-api-headers/include/uv/os390.h +0 -33
  1195. package/node_modules/koffi/vendor/node-api-headers/include/uv/posix.h +0 -31
  1196. package/node_modules/koffi/vendor/node-api-headers/include/uv/sunos.h +0 -44
  1197. package/node_modules/koffi/vendor/node-api-headers/include/uv/threadpool.h +0 -37
  1198. package/node_modules/koffi/vendor/node-api-headers/include/uv/tree.h +0 -521
  1199. package/node_modules/koffi/vendor/node-api-headers/include/uv/unix.h +0 -512
  1200. package/node_modules/koffi/vendor/node-api-headers/include/uv/version.h +0 -43
  1201. package/node_modules/koffi/vendor/node-api-headers/include/uv/win.h +0 -698
  1202. package/node_modules/koffi/vendor/node-api-headers/include/uv.h +0 -1990
@@ -1 +1 @@
1
- {"version":3,"file":"jsonl-storage.d.ts","sourceRoot":"","sources":["../../../src/harness/session/jsonl-storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,oBAAoB,EAAa,cAAc,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAKjH,KAAK,6BAA6B,GAAG,IAAI,CAAC,UAAU,EAAE,cAAc,GAAG,eAAe,GAAG,WAAW,GAAG,YAAY,CAAC,CAAC;AAqHrH,wBAAsB,wBAAwB,CAC7C,EAAE,EAAE,6BAA6B,EACjC,QAAQ,EAAE,MAAM,GACd,OAAO,CAAC,oBAAoB,CAAC,CAQ/B;AA2BD,qB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AK,CAAA;KAAE,CAAC,CAAC,CAAC,CAE5D;IAEK,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAEtD;IAEK,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAatE;IAEK,UAAU,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAE9C;CACD","sourcesContent":["import type { FileSystem, JsonlSessionMetadata, LeafEntry, SessionStorage, SessionTreeEntry } from \"../types.js\";\nimport { SessionError, toError } from \"../types.js\";\nimport { getFileSystemResultOrThrow } from \"./repo-utils.js\";\nimport { uuidv7 } from \"./uuid.js\";\n\ntype JsonlSessionStorageFileSystem = Pick<FileSystem, \"readTextFile\" | \"readTextLines\" | \"writeFile\" | \"appendFile\">;\n\ninterface SessionHeader {\n\ttype: \"session\";\n\tversion: 3;\n\tid: string;\n\ttimestamp: string;\n\tcwd: string;\n\tparentSession?: string;\n}\n\nfunction updateLabelCache(labelsById: Map<string, string>, entry: SessionTreeEntry): void {\n\tif (entry.type !== \"label\") return;\n\tconst label = entry.label?.trim();\n\tif (label) {\n\t\tlabelsById.set(entry.targetId, label);\n\t} else {\n\t\tlabelsById.delete(entry.targetId);\n\t}\n}\n\nfunction buildLabelsById(entries: SessionTreeEntry[]): Map<string, string> {\n\tconst labelsById = new Map<string, string>();\n\tfor (const entry of entries) {\n\t\tupdateLabelCache(labelsById, entry);\n\t}\n\treturn labelsById;\n}\n\nfunction generateEntryId(byId: { has(id: string): boolean }): string {\n\tfor (let i = 0; i < 100; i++) {\n\t\tconst id = uuidv7().slice(0, 8);\n\t\tif (!byId.has(id)) return id;\n\t}\n\treturn uuidv7();\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null;\n}\n\nfunction invalidSession(filePath: string, message: string, cause?: Error): SessionError {\n\treturn new SessionError(\"invalid_session\", `Invalid JSONL session file ${filePath}: ${message}`, cause);\n}\n\nfunction invalidEntry(filePath: string, lineNumber: number, message: string, cause?: Error): SessionError {\n\treturn new SessionError(\n\t\t\"invalid_entry\",\n\t\t`Invalid JSONL session file ${filePath}: line ${lineNumber} ${message}`,\n\t\tcause,\n\t);\n}\n\nfunction parseHeaderLine(line: string, filePath: string): SessionHeader {\n\tlet parsed: unknown;\n\ttry {\n\t\tparsed = JSON.parse(line);\n\t} catch (error) {\n\t\tthrow invalidSession(filePath, \"first line is not a valid session header\", toError(error));\n\t}\n\tif (!isRecord(parsed)) throw invalidSession(filePath, \"first line is not a valid session header\");\n\tif (parsed.type !== \"session\") throw invalidSession(filePath, \"first line is not a valid session header\");\n\tif (parsed.version !== 3) throw invalidSession(filePath, \"unsupported session version\");\n\tif (typeof parsed.id !== \"string\" || !parsed.id) throw invalidSession(filePath, \"session header is missing id\");\n\tif (typeof parsed.timestamp !== \"string\" || !parsed.timestamp) {\n\t\tthrow invalidSession(filePath, \"session header is missing timestamp\");\n\t}\n\tif (typeof parsed.cwd !== \"string\" || !parsed.cwd) throw invalidSession(filePath, \"session header is missing cwd\");\n\tif (parsed.parentSession !== undefined && typeof parsed.parentSession !== \"string\") {\n\t\tthrow invalidSession(filePath, \"session header parentSession must be a string\");\n\t}\n\treturn {\n\t\ttype: \"session\",\n\t\tversion: 3,\n\t\tid: parsed.id,\n\t\ttimestamp: parsed.timestamp,\n\t\tcwd: parsed.cwd,\n\t\tparentSession: parsed.parentSession,\n\t};\n}\n\nfunction parseEntryLine(line: string, filePath: string, lineNumber: number): SessionTreeEntry {\n\tlet parsed: unknown;\n\ttry {\n\t\tparsed = JSON.parse(line);\n\t} catch (error) {\n\t\tthrow invalidEntry(filePath, lineNumber, \"is not valid JSON\", toError(error));\n\t}\n\tif (!isRecord(parsed)) throw invalidEntry(filePath, lineNumber, \"is not a valid session entry\");\n\tif (typeof parsed.type !== \"string\") throw invalidEntry(filePath, lineNumber, \"is missing entry type\");\n\tif (typeof parsed.id !== \"string\" || !parsed.id) throw invalidEntry(filePath, lineNumber, \"is missing entry id\");\n\tif (parsed.parentId !== null && typeof parsed.parentId !== \"string\") {\n\t\tthrow invalidEntry(filePath, lineNumber, \"has invalid parentId\");\n\t}\n\tif (typeof parsed.timestamp !== \"string\" || !parsed.timestamp) {\n\t\tthrow invalidEntry(filePath, lineNumber, \"is missing timestamp\");\n\t}\n\tif (parsed.type === \"leaf\" && parsed.targetId !== null && typeof parsed.targetId !== \"string\") {\n\t\tthrow invalidEntry(filePath, lineNumber, \"has invalid targetId\");\n\t}\n\treturn parsed as unknown as SessionTreeEntry;\n}\n\nfunction leafIdAfterEntry(entry: SessionTreeEntry): string | null {\n\treturn entry.type === \"leaf\" ? entry.targetId : entry.id;\n}\n\nfunction headerToSessionMetadata(header: SessionHeader, path: string): JsonlSessionMetadata {\n\treturn {\n\t\tid: header.id,\n\t\tcreatedAt: header.timestamp,\n\t\tcwd: header.cwd,\n\t\tpath,\n\t\tparentSessionPath: header.parentSession,\n\t};\n}\n\nexport async function loadJsonlSessionMetadata(\n\tfs: JsonlSessionStorageFileSystem,\n\tfilePath: string,\n): Promise<JsonlSessionMetadata> {\n\tconst lines = getFileSystemResultOrThrow(\n\t\tawait fs.readTextLines(filePath, { maxLines: 1 }),\n\t\t`Failed to read session header ${filePath}`,\n\t);\n\tconst line = lines[0];\n\tif (line?.trim()) return headerToSessionMetadata(parseHeaderLine(line, filePath), filePath);\n\tthrow invalidSession(filePath, \"missing session header\");\n}\n\nasync function loadJsonlStorage(\n\tfs: JsonlSessionStorageFileSystem,\n\tfilePath: string,\n): Promise<{\n\theader: SessionHeader;\n\tentries: SessionTreeEntry[];\n\tleafId: string | null;\n}> {\n\tconst content = getFileSystemResultOrThrow(await fs.readTextFile(filePath), `Failed to read session ${filePath}`);\n\tconst lines = content.split(\"\\n\").filter((line) => line.trim());\n\tif (lines.length === 0) {\n\t\tthrow invalidSession(filePath, \"missing session header\");\n\t}\n\n\tconst header = parseHeaderLine(lines[0]!, filePath);\n\tconst entries: SessionTreeEntry[] = [];\n\tlet leafId: string | null = null;\n\tfor (let i = 1; i < lines.length; i++) {\n\t\tconst entry = parseEntryLine(lines[i]!, filePath, i + 1);\n\t\tentries.push(entry);\n\t\tleafId = leafIdAfterEntry(entry);\n\t}\n\treturn { header, entries, leafId };\n}\n\nexport class JsonlSessionStorage implements SessionStorage<JsonlSessionMetadata> {\n\tprivate readonly fs: JsonlSessionStorageFileSystem;\n\tprivate readonly filePath: string;\n\tprivate readonly metadata: JsonlSessionMetadata;\n\tprivate entries: SessionTreeEntry[];\n\tprivate byId: Map<string, SessionTreeEntry>;\n\tprivate labelsById: Map<string, string>;\n\tprivate currentLeafId: string | null;\n\n\tprivate constructor(\n\t\tfs: JsonlSessionStorageFileSystem,\n\t\tfilePath: string,\n\t\theader: SessionHeader,\n\t\tentries: SessionTreeEntry[],\n\t\tleafId: string | null,\n\t) {\n\t\tthis.fs = fs;\n\t\tthis.filePath = filePath;\n\t\tthis.metadata = headerToSessionMetadata(header, this.filePath);\n\t\tthis.entries = entries;\n\t\tthis.byId = new Map(entries.map((entry) => [entry.id, entry]));\n\t\tthis.labelsById = buildLabelsById(entries);\n\t\tthis.currentLeafId = leafId;\n\t}\n\n\tstatic async open(fs: JsonlSessionStorageFileSystem, filePath: string): Promise<JsonlSessionStorage> {\n\t\tconst loaded = await loadJsonlStorage(fs, filePath);\n\t\treturn new JsonlSessionStorage(fs, filePath, loaded.header, loaded.entries, loaded.leafId);\n\t}\n\n\tstatic async create(\n\t\tfs: JsonlSessionStorageFileSystem,\n\t\tfilePath: string,\n\t\toptions: {\n\t\t\tcwd: string;\n\t\t\tsessionId: string;\n\t\t\tparentSessionPath?: string;\n\t\t},\n\t): Promise<JsonlSessionStorage> {\n\t\tconst header: SessionHeader = {\n\t\t\ttype: \"session\",\n\t\t\tversion: 3,\n\t\t\tid: options.sessionId,\n\t\t\ttimestamp: new Date().toISOString(),\n\t\t\tcwd: options.cwd,\n\t\t\tparentSession: options.parentSessionPath,\n\t\t};\n\t\tgetFileSystemResultOrThrow(\n\t\t\tawait fs.writeFile(filePath, `${JSON.stringify(header)}\\n`),\n\t\t\t`Failed to create session ${filePath}`,\n\t\t);\n\t\treturn new JsonlSessionStorage(fs, filePath, header, [], null);\n\t}\n\n\tasync getMetadata(): Promise<JsonlSessionMetadata> {\n\t\treturn this.metadata;\n\t}\n\n\tasync getLeafId(): Promise<string | null> {\n\t\tif (this.currentLeafId !== null && !this.byId.has(this.currentLeafId)) {\n\t\t\tthrow new SessionError(\"invalid_session\", `Entry ${this.currentLeafId} not found`);\n\t\t}\n\t\treturn this.currentLeafId;\n\t}\n\n\tasync setLeafId(leafId: string | null): Promise<void> {\n\t\tif (leafId !== null && !this.byId.has(leafId)) {\n\t\t\tthrow new SessionError(\"not_found\", `Entry ${leafId} not found`);\n\t\t}\n\t\tconst entry: LeafEntry = {\n\t\t\ttype: \"leaf\",\n\t\t\tid: generateEntryId(this.byId),\n\t\t\tparentId: this.currentLeafId,\n\t\t\ttimestamp: new Date().toISOString(),\n\t\t\ttargetId: leafId,\n\t\t};\n\t\tgetFileSystemResultOrThrow(\n\t\t\tawait this.fs.appendFile(this.filePath, `${JSON.stringify(entry)}\\n`),\n\t\t\t`Failed to append session leaf ${entry.id}`,\n\t\t);\n\t\tthis.entries.push(entry);\n\t\tthis.byId.set(entry.id, entry);\n\t\tthis.currentLeafId = leafId;\n\t}\n\n\tasync createEntryId(): Promise<string> {\n\t\treturn generateEntryId(this.byId);\n\t}\n\n\tasync appendEntry(entry: SessionTreeEntry): Promise<void> {\n\t\tgetFileSystemResultOrThrow(\n\t\t\tawait this.fs.appendFile(this.filePath, `${JSON.stringify(entry)}\\n`),\n\t\t\t`Failed to append session entry ${entry.id}`,\n\t\t);\n\t\tthis.entries.push(entry);\n\t\tthis.byId.set(entry.id, entry);\n\t\tupdateLabelCache(this.labelsById, entry);\n\t\tthis.currentLeafId = leafIdAfterEntry(entry);\n\t}\n\n\tasync getEntry(id: string): Promise<SessionTreeEntry | undefined> {\n\t\treturn this.byId.get(id);\n\t}\n\n\tasync findEntries<TType extends SessionTreeEntry[\"type\"]>(\n\t\ttype: TType,\n\t): Promise<Array<Extract<SessionTreeEntry, { type: TType }>>> {\n\t\treturn this.entries.filter((entry): entry is Extract<SessionTreeEntry, { type: TType }> => entry.type === type);\n\t}\n\n\tasync getLabel(id: string): Promise<string | undefined> {\n\t\treturn this.labelsById.get(id);\n\t}\n\n\tasync getPathToRoot(leafId: string | null): Promise<SessionTreeEntry[]> {\n\t\tif (leafId === null) return [];\n\t\tconst path: SessionTreeEntry[] = [];\n\t\tlet current = this.byId.get(leafId);\n\t\tif (!current) throw new SessionError(\"not_found\", `Entry ${leafId} not found`);\n\t\twhile (current) {\n\t\t\tpath.unshift(current);\n\t\t\tif (!current.parentId) break;\n\t\t\tconst parent = this.byId.get(current.parentId);\n\t\t\tif (!parent) throw new SessionError(\"invalid_session\", `Entry ${current.parentId} not found`);\n\t\t\tcurrent = parent;\n\t\t}\n\t\treturn path;\n\t}\n\n\tasync getEntries(): Promise<SessionTreeEntry[]> {\n\t\treturn [...this.entries];\n\t}\n}\n"]}
1
+ {"version":3,"file":"jsonl-storage.d.ts","sourceRoot":"","sources":["../../../src/harness/session/jsonl-storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,oBAAoB,EAAa,cAAc,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAKjH,KAAK,6BAA6B,GAAG,IAAI,CAAC,UAAU,EAAE,cAAc,GAAG,eAAe,GAAG,WAAW,GAAG,YAAY,CAAC,CAAC;AAqHrH,wBAAsB,wBAAwB,CAC7C,EAAE,EAAE,6BAA6B,EACjC,QAAQ,EAAE,MAAM,GACd,OAAO,CAAC,oBAAoB,CAAC,CAQ/B;AA2BD,qBAAa,mBAAoB,YAAW,cAAc,CAAC,oBAAoB,CAAC;IAC/E,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAgC;IACnD,O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AM,GAAG,SAAS,CAAC,CAEtD;IAEK,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAatE;IAEK,UAAU,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAE9C;CACD","sourcesContent":["import type { FileSystem, JsonlSessionMetadata, LeafEntry, SessionStorage, SessionTreeEntry } from \"../types.ts\";\nimport { SessionError, toError } from \"../types.ts\";\nimport { getFileSystemResultOrThrow } from \"./repo-utils.ts\";\nimport { uuidv7 } from \"./uuid.ts\";\n\ntype JsonlSessionStorageFileSystem = Pick<FileSystem, \"readTextFile\" | \"readTextLines\" | \"writeFile\" | \"appendFile\">;\n\ninterface SessionHeader {\n\ttype: \"session\";\n\tversion: 3;\n\tid: string;\n\ttimestamp: string;\n\tcwd: string;\n\tparentSession?: string;\n}\n\nfunction updateLabelCache(labelsById: Map<string, string>, entry: SessionTreeEntry): void {\n\tif (entry.type !== \"label\") return;\n\tconst label = entry.label?.trim();\n\tif (label) {\n\t\tlabelsById.set(entry.targetId, label);\n\t} else {\n\t\tlabelsById.delete(entry.targetId);\n\t}\n}\n\nfunction buildLabelsById(entries: SessionTreeEntry[]): Map<string, string> {\n\tconst labelsById = new Map<string, string>();\n\tfor (const entry of entries) {\n\t\tupdateLabelCache(labelsById, entry);\n\t}\n\treturn labelsById;\n}\n\nfunction generateEntryId(byId: { has(id: string): boolean }): string {\n\tfor (let i = 0; i < 100; i++) {\n\t\tconst id = uuidv7().slice(0, 8);\n\t\tif (!byId.has(id)) return id;\n\t}\n\treturn uuidv7();\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null;\n}\n\nfunction invalidSession(filePath: string, message: string, cause?: Error): SessionError {\n\treturn new SessionError(\"invalid_session\", `Invalid JSONL session file ${filePath}: ${message}`, cause);\n}\n\nfunction invalidEntry(filePath: string, lineNumber: number, message: string, cause?: Error): SessionError {\n\treturn new SessionError(\n\t\t\"invalid_entry\",\n\t\t`Invalid JSONL session file ${filePath}: line ${lineNumber} ${message}`,\n\t\tcause,\n\t);\n}\n\nfunction parseHeaderLine(line: string, filePath: string): SessionHeader {\n\tlet parsed: unknown;\n\ttry {\n\t\tparsed = JSON.parse(line);\n\t} catch (error) {\n\t\tthrow invalidSession(filePath, \"first line is not a valid session header\", toError(error));\n\t}\n\tif (!isRecord(parsed)) throw invalidSession(filePath, \"first line is not a valid session header\");\n\tif (parsed.type !== \"session\") throw invalidSession(filePath, \"first line is not a valid session header\");\n\tif (parsed.version !== 3) throw invalidSession(filePath, \"unsupported session version\");\n\tif (typeof parsed.id !== \"string\" || !parsed.id) throw invalidSession(filePath, \"session header is missing id\");\n\tif (typeof parsed.timestamp !== \"string\" || !parsed.timestamp) {\n\t\tthrow invalidSession(filePath, \"session header is missing timestamp\");\n\t}\n\tif (typeof parsed.cwd !== \"string\" || !parsed.cwd) throw invalidSession(filePath, \"session header is missing cwd\");\n\tif (parsed.parentSession !== undefined && typeof parsed.parentSession !== \"string\") {\n\t\tthrow invalidSession(filePath, \"session header parentSession must be a string\");\n\t}\n\treturn {\n\t\ttype: \"session\",\n\t\tversion: 3,\n\t\tid: parsed.id,\n\t\ttimestamp: parsed.timestamp,\n\t\tcwd: parsed.cwd,\n\t\tparentSession: parsed.parentSession,\n\t};\n}\n\nfunction parseEntryLine(line: string, filePath: string, lineNumber: number): SessionTreeEntry {\n\tlet parsed: unknown;\n\ttry {\n\t\tparsed = JSON.parse(line);\n\t} catch (error) {\n\t\tthrow invalidEntry(filePath, lineNumber, \"is not valid JSON\", toError(error));\n\t}\n\tif (!isRecord(parsed)) throw invalidEntry(filePath, lineNumber, \"is not a valid session entry\");\n\tif (typeof parsed.type !== \"string\") throw invalidEntry(filePath, lineNumber, \"is missing entry type\");\n\tif (typeof parsed.id !== \"string\" || !parsed.id) throw invalidEntry(filePath, lineNumber, \"is missing entry id\");\n\tif (parsed.parentId !== null && typeof parsed.parentId !== \"string\") {\n\t\tthrow invalidEntry(filePath, lineNumber, \"has invalid parentId\");\n\t}\n\tif (typeof parsed.timestamp !== \"string\" || !parsed.timestamp) {\n\t\tthrow invalidEntry(filePath, lineNumber, \"is missing timestamp\");\n\t}\n\tif (parsed.type === \"leaf\" && parsed.targetId !== null && typeof parsed.targetId !== \"string\") {\n\t\tthrow invalidEntry(filePath, lineNumber, \"has invalid targetId\");\n\t}\n\treturn parsed as unknown as SessionTreeEntry;\n}\n\nfunction leafIdAfterEntry(entry: SessionTreeEntry): string | null {\n\treturn entry.type === \"leaf\" ? entry.targetId : entry.id;\n}\n\nfunction headerToSessionMetadata(header: SessionHeader, path: string): JsonlSessionMetadata {\n\treturn {\n\t\tid: header.id,\n\t\tcreatedAt: header.timestamp,\n\t\tcwd: header.cwd,\n\t\tpath,\n\t\tparentSessionPath: header.parentSession,\n\t};\n}\n\nexport async function loadJsonlSessionMetadata(\n\tfs: JsonlSessionStorageFileSystem,\n\tfilePath: string,\n): Promise<JsonlSessionMetadata> {\n\tconst lines = getFileSystemResultOrThrow(\n\t\tawait fs.readTextLines(filePath, { maxLines: 1 }),\n\t\t`Failed to read session header ${filePath}`,\n\t);\n\tconst line = lines[0];\n\tif (line?.trim()) return headerToSessionMetadata(parseHeaderLine(line, filePath), filePath);\n\tthrow invalidSession(filePath, \"missing session header\");\n}\n\nasync function loadJsonlStorage(\n\tfs: JsonlSessionStorageFileSystem,\n\tfilePath: string,\n): Promise<{\n\theader: SessionHeader;\n\tentries: SessionTreeEntry[];\n\tleafId: string | null;\n}> {\n\tconst content = getFileSystemResultOrThrow(await fs.readTextFile(filePath), `Failed to read session ${filePath}`);\n\tconst lines = content.split(\"\\n\").filter((line) => line.trim());\n\tif (lines.length === 0) {\n\t\tthrow invalidSession(filePath, \"missing session header\");\n\t}\n\n\tconst header = parseHeaderLine(lines[0]!, filePath);\n\tconst entries: SessionTreeEntry[] = [];\n\tlet leafId: string | null = null;\n\tfor (let i = 1; i < lines.length; i++) {\n\t\tconst entry = parseEntryLine(lines[i]!, filePath, i + 1);\n\t\tentries.push(entry);\n\t\tleafId = leafIdAfterEntry(entry);\n\t}\n\treturn { header, entries, leafId };\n}\n\nexport class JsonlSessionStorage implements SessionStorage<JsonlSessionMetadata> {\n\tprivate readonly fs: JsonlSessionStorageFileSystem;\n\tprivate readonly filePath: string;\n\tprivate readonly metadata: JsonlSessionMetadata;\n\tprivate entries: SessionTreeEntry[];\n\tprivate byId: Map<string, SessionTreeEntry>;\n\tprivate labelsById: Map<string, string>;\n\tprivate currentLeafId: string | null;\n\n\tprivate constructor(\n\t\tfs: JsonlSessionStorageFileSystem,\n\t\tfilePath: string,\n\t\theader: SessionHeader,\n\t\tentries: SessionTreeEntry[],\n\t\tleafId: string | null,\n\t) {\n\t\tthis.fs = fs;\n\t\tthis.filePath = filePath;\n\t\tthis.metadata = headerToSessionMetadata(header, this.filePath);\n\t\tthis.entries = entries;\n\t\tthis.byId = new Map(entries.map((entry) => [entry.id, entry]));\n\t\tthis.labelsById = buildLabelsById(entries);\n\t\tthis.currentLeafId = leafId;\n\t}\n\n\tstatic async open(fs: JsonlSessionStorageFileSystem, filePath: string): Promise<JsonlSessionStorage> {\n\t\tconst loaded = await loadJsonlStorage(fs, filePath);\n\t\treturn new JsonlSessionStorage(fs, filePath, loaded.header, loaded.entries, loaded.leafId);\n\t}\n\n\tstatic async create(\n\t\tfs: JsonlSessionStorageFileSystem,\n\t\tfilePath: string,\n\t\toptions: {\n\t\t\tcwd: string;\n\t\t\tsessionId: string;\n\t\t\tparentSessionPath?: string;\n\t\t},\n\t): Promise<JsonlSessionStorage> {\n\t\tconst header: SessionHeader = {\n\t\t\ttype: \"session\",\n\t\t\tversion: 3,\n\t\t\tid: options.sessionId,\n\t\t\ttimestamp: new Date().toISOString(),\n\t\t\tcwd: options.cwd,\n\t\t\tparentSession: options.parentSessionPath,\n\t\t};\n\t\tgetFileSystemResultOrThrow(\n\t\t\tawait fs.writeFile(filePath, `${JSON.stringify(header)}\\n`),\n\t\t\t`Failed to create session ${filePath}`,\n\t\t);\n\t\treturn new JsonlSessionStorage(fs, filePath, header, [], null);\n\t}\n\n\tasync getMetadata(): Promise<JsonlSessionMetadata> {\n\t\treturn this.metadata;\n\t}\n\n\tasync getLeafId(): Promise<string | null> {\n\t\tif (this.currentLeafId !== null && !this.byId.has(this.currentLeafId)) {\n\t\t\tthrow new SessionError(\"invalid_session\", `Entry ${this.currentLeafId} not found`);\n\t\t}\n\t\treturn this.currentLeafId;\n\t}\n\n\tasync setLeafId(leafId: string | null): Promise<void> {\n\t\tif (leafId !== null && !this.byId.has(leafId)) {\n\t\t\tthrow new SessionError(\"not_found\", `Entry ${leafId} not found`);\n\t\t}\n\t\tconst entry: LeafEntry = {\n\t\t\ttype: \"leaf\",\n\t\t\tid: generateEntryId(this.byId),\n\t\t\tparentId: this.currentLeafId,\n\t\t\ttimestamp: new Date().toISOString(),\n\t\t\ttargetId: leafId,\n\t\t};\n\t\tgetFileSystemResultOrThrow(\n\t\t\tawait this.fs.appendFile(this.filePath, `${JSON.stringify(entry)}\\n`),\n\t\t\t`Failed to append session leaf ${entry.id}`,\n\t\t);\n\t\tthis.entries.push(entry);\n\t\tthis.byId.set(entry.id, entry);\n\t\tthis.currentLeafId = leafId;\n\t}\n\n\tasync createEntryId(): Promise<string> {\n\t\treturn generateEntryId(this.byId);\n\t}\n\n\tasync appendEntry(entry: SessionTreeEntry): Promise<void> {\n\t\tgetFileSystemResultOrThrow(\n\t\t\tawait this.fs.appendFile(this.filePath, `${JSON.stringify(entry)}\\n`),\n\t\t\t`Failed to append session entry ${entry.id}`,\n\t\t);\n\t\tthis.entries.push(entry);\n\t\tthis.byId.set(entry.id, entry);\n\t\tupdateLabelCache(this.labelsById, entry);\n\t\tthis.currentLeafId = leafIdAfterEntry(entry);\n\t}\n\n\tasync getEntry(id: string): Promise<SessionTreeEntry | undefined> {\n\t\treturn this.byId.get(id);\n\t}\n\n\tasync findEntries<TType extends SessionTreeEntry[\"type\"]>(\n\t\ttype: TType,\n\t): Promise<Array<Extract<SessionTreeEntry, { type: TType }>>> {\n\t\treturn this.entries.filter((entry): entry is Extract<SessionTreeEntry, { type: TType }> => entry.type === type);\n\t}\n\n\tasync getLabel(id: string): Promise<string | undefined> {\n\t\treturn this.labelsById.get(id);\n\t}\n\n\tasync getPathToRoot(leafId: string | null): Promise<SessionTreeEntry[]> {\n\t\tif (leafId === null) return [];\n\t\tconst path: SessionTreeEntry[] = [];\n\t\tlet current = this.byId.get(leafId);\n\t\tif (!current) throw new SessionError(\"not_found\", `Entry ${leafId} not found`);\n\t\twhile (current) {\n\t\t\tpath.unshift(current);\n\t\t\tif (!current.parentId) break;\n\t\t\tconst parent = this.byId.get(current.parentId);\n\t\t\tif (!parent) throw new SessionError(\"invalid_session\", `Entry ${current.parentId} not found`);\n\t\t\tcurrent = parent;\n\t\t}\n\t\treturn path;\n\t}\n\n\tasync getEntries(): Promise<SessionTreeEntry[]> {\n\t\treturn [...this.entries];\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"jsonl-storage.js","sourceRoot":"","sources":["../../../src/harness/session/jsonl-storage.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAanC,SAAS,gBAAgB,CAAC,UAA+B,EAAE,KAAuB,EAAQ;IACzF,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO;QAAE,OAAO;IACnC,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC;IAClC,IAAI,KAAK,EAAE,CAAC;QACX,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IACvC,CAAC;SAAM,CAAC;QACP,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,C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,IAAI,CAAC,OAAO;YAAE,MAAM,IAAI,YAAY,CAAC,WAAW,EAAE,SAAS,MAAM,YAAY,CAAC,CAAC;QAC/E,OAAO,OAAO,EAAE,CAAC;YAChB,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;YACtB,IAAI,CAAC,OAAO,CAAC,QAAQ;gBAAE,MAAM;YAC7B,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;YAC/C,IAAI,CAAC,MAAM;gBAAE,MAAM,IAAI,YAAY,CAAC,iBAAiB,EAAE,SAAS,OAAO,CAAC,QAAQ,YAAY,CAAC,CAAC;YAC9F,OAAO,GAAG,MAAM,CAAC;QAClB,CAAC;QACD,OAAO,IAAI,CAAC;IAAA,CACZ;IAED,KAAK,CAAC,UAAU,GAAgC;QAC/C,OAAO,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC;IAAA,CACzB;CACD","sourcesContent":["import type { FileSystem, JsonlSessionMetadata, LeafEntry, SessionStorage, SessionTreeEntry } from \"../types.js\";\nimport { SessionError, toError } from \"../types.js\";\nimport { getFileSystemResultOrThrow } from \"./repo-utils.js\";\nimport { uuidv7 } from \"./uuid.js\";\n\ntype JsonlSessionStorageFileSystem = Pick<FileSystem, \"readTextFile\" | \"readTextLines\" | \"writeFile\" | \"appendFile\">;\n\ninterface SessionHeader {\n\ttype: \"session\";\n\tversion: 3;\n\tid: string;\n\ttimestamp: string;\n\tcwd: string;\n\tparentSession?: string;\n}\n\nfunction updateLabelCache(labelsById: Map<string, string>, entry: SessionTreeEntry): void {\n\tif (entry.type !== \"label\") return;\n\tconst label = entry.label?.trim();\n\tif (label) {\n\t\tlabelsById.set(entry.targetId, label);\n\t} else {\n\t\tlabelsById.delete(entry.targetId);\n\t}\n}\n\nfunction buildLabelsById(entries: SessionTreeEntry[]): Map<string, string> {\n\tconst labelsById = new Map<string, string>();\n\tfor (const entry of entries) {\n\t\tupdateLabelCache(labelsById, entry);\n\t}\n\treturn labelsById;\n}\n\nfunction generateEntryId(byId: { has(id: string): boolean }): string {\n\tfor (let i = 0; i < 100; i++) {\n\t\tconst id = uuidv7().slice(0, 8);\n\t\tif (!byId.has(id)) return id;\n\t}\n\treturn uuidv7();\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null;\n}\n\nfunction invalidSession(filePath: string, message: string, cause?: Error): SessionError {\n\treturn new SessionError(\"invalid_session\", `Invalid JSONL session file ${filePath}: ${message}`, cause);\n}\n\nfunction invalidEntry(filePath: string, lineNumber: number, message: string, cause?: Error): SessionError {\n\treturn new SessionError(\n\t\t\"invalid_entry\",\n\t\t`Invalid JSONL session file ${filePath}: line ${lineNumber} ${message}`,\n\t\tcause,\n\t);\n}\n\nfunction parseHeaderLine(line: string, filePath: string): SessionHeader {\n\tlet parsed: unknown;\n\ttry {\n\t\tparsed = JSON.parse(line);\n\t} catch (error) {\n\t\tthrow invalidSession(filePath, \"first line is not a valid session header\", toError(error));\n\t}\n\tif (!isRecord(parsed)) throw invalidSession(filePath, \"first line is not a valid session header\");\n\tif (parsed.type !== \"session\") throw invalidSession(filePath, \"first line is not a valid session header\");\n\tif (parsed.version !== 3) throw invalidSession(filePath, \"unsupported session version\");\n\tif (typeof parsed.id !== \"string\" || !parsed.id) throw invalidSession(filePath, \"session header is missing id\");\n\tif (typeof parsed.timestamp !== \"string\" || !parsed.timestamp) {\n\t\tthrow invalidSession(filePath, \"session header is missing timestamp\");\n\t}\n\tif (typeof parsed.cwd !== \"string\" || !parsed.cwd) throw invalidSession(filePath, \"session header is missing cwd\");\n\tif (parsed.parentSession !== undefined && typeof parsed.parentSession !== \"string\") {\n\t\tthrow invalidSession(filePath, \"session header parentSession must be a string\");\n\t}\n\treturn {\n\t\ttype: \"session\",\n\t\tversion: 3,\n\t\tid: parsed.id,\n\t\ttimestamp: parsed.timestamp,\n\t\tcwd: parsed.cwd,\n\t\tparentSession: parsed.parentSession,\n\t};\n}\n\nfunction parseEntryLine(line: string, filePath: string, lineNumber: number): SessionTreeEntry {\n\tlet parsed: unknown;\n\ttry {\n\t\tparsed = JSON.parse(line);\n\t} catch (error) {\n\t\tthrow invalidEntry(filePath, lineNumber, \"is not valid JSON\", toError(error));\n\t}\n\tif (!isRecord(parsed)) throw invalidEntry(filePath, lineNumber, \"is not a valid session entry\");\n\tif (typeof parsed.type !== \"string\") throw invalidEntry(filePath, lineNumber, \"is missing entry type\");\n\tif (typeof parsed.id !== \"string\" || !parsed.id) throw invalidEntry(filePath, lineNumber, \"is missing entry id\");\n\tif (parsed.parentId !== null && typeof parsed.parentId !== \"string\") {\n\t\tthrow invalidEntry(filePath, lineNumber, \"has invalid parentId\");\n\t}\n\tif (typeof parsed.timestamp !== \"string\" || !parsed.timestamp) {\n\t\tthrow invalidEntry(filePath, lineNumber, \"is missing timestamp\");\n\t}\n\tif (parsed.type === \"leaf\" && parsed.targetId !== null && typeof parsed.targetId !== \"string\") {\n\t\tthrow invalidEntry(filePath, lineNumber, \"has invalid targetId\");\n\t}\n\treturn parsed as unknown as SessionTreeEntry;\n}\n\nfunction leafIdAfterEntry(entry: SessionTreeEntry): string | null {\n\treturn entry.type === \"leaf\" ? entry.targetId : entry.id;\n}\n\nfunction headerToSessionMetadata(header: SessionHeader, path: string): JsonlSessionMetadata {\n\treturn {\n\t\tid: header.id,\n\t\tcreatedAt: header.timestamp,\n\t\tcwd: header.cwd,\n\t\tpath,\n\t\tparentSessionPath: header.parentSession,\n\t};\n}\n\nexport async function loadJsonlSessionMetadata(\n\tfs: JsonlSessionStorageFileSystem,\n\tfilePath: string,\n): Promise<JsonlSessionMetadata> {\n\tconst lines = getFileSystemResultOrThrow(\n\t\tawait fs.readTextLines(filePath, { maxLines: 1 }),\n\t\t`Failed to read session header ${filePath}`,\n\t);\n\tconst line = lines[0];\n\tif (line?.trim()) return headerToSessionMetadata(parseHeaderLine(line, filePath), filePath);\n\tthrow invalidSession(filePath, \"missing session header\");\n}\n\nasync function loadJsonlStorage(\n\tfs: JsonlSessionStorageFileSystem,\n\tfilePath: string,\n): Promise<{\n\theader: SessionHeader;\n\tentries: SessionTreeEntry[];\n\tleafId: string | null;\n}> {\n\tconst content = getFileSystemResultOrThrow(await fs.readTextFile(filePath), `Failed to read session ${filePath}`);\n\tconst lines = content.split(\"\\n\").filter((line) => line.trim());\n\tif (lines.length === 0) {\n\t\tthrow invalidSession(filePath, \"missing session header\");\n\t}\n\n\tconst header = parseHeaderLine(lines[0]!, filePath);\n\tconst entries: SessionTreeEntry[] = [];\n\tlet leafId: string | null = null;\n\tfor (let i = 1; i < lines.length; i++) {\n\t\tconst entry = parseEntryLine(lines[i]!, filePath, i + 1);\n\t\tentries.push(entry);\n\t\tleafId = leafIdAfterEntry(entry);\n\t}\n\treturn { header, entries, leafId };\n}\n\nexport class JsonlSessionStorage implements SessionStorage<JsonlSessionMetadata> {\n\tprivate readonly fs: JsonlSessionStorageFileSystem;\n\tprivate readonly filePath: string;\n\tprivate readonly metadata: JsonlSessionMetadata;\n\tprivate entries: SessionTreeEntry[];\n\tprivate byId: Map<string, SessionTreeEntry>;\n\tprivate labelsById: Map<string, string>;\n\tprivate currentLeafId: string | null;\n\n\tprivate constructor(\n\t\tfs: JsonlSessionStorageFileSystem,\n\t\tfilePath: string,\n\t\theader: SessionHeader,\n\t\tentries: SessionTreeEntry[],\n\t\tleafId: string | null,\n\t) {\n\t\tthis.fs = fs;\n\t\tthis.filePath = filePath;\n\t\tthis.metadata = headerToSessionMetadata(header, this.filePath);\n\t\tthis.entries = entries;\n\t\tthis.byId = new Map(entries.map((entry) => [entry.id, entry]));\n\t\tthis.labelsById = buildLabelsById(entries);\n\t\tthis.currentLeafId = leafId;\n\t}\n\n\tstatic async open(fs: JsonlSessionStorageFileSystem, filePath: string): Promise<JsonlSessionStorage> {\n\t\tconst loaded = await loadJsonlStorage(fs, filePath);\n\t\treturn new JsonlSessionStorage(fs, filePath, loaded.header, loaded.entries, loaded.leafId);\n\t}\n\n\tstatic async create(\n\t\tfs: JsonlSessionStorageFileSystem,\n\t\tfilePath: string,\n\t\toptions: {\n\t\t\tcwd: string;\n\t\t\tsessionId: string;\n\t\t\tparentSessionPath?: string;\n\t\t},\n\t): Promise<JsonlSessionStorage> {\n\t\tconst header: SessionHeader = {\n\t\t\ttype: \"session\",\n\t\t\tversion: 3,\n\t\t\tid: options.sessionId,\n\t\t\ttimestamp: new Date().toISOString(),\n\t\t\tcwd: options.cwd,\n\t\t\tparentSession: options.parentSessionPath,\n\t\t};\n\t\tgetFileSystemResultOrThrow(\n\t\t\tawait fs.writeFile(filePath, `${JSON.stringify(header)}\\n`),\n\t\t\t`Failed to create session ${filePath}`,\n\t\t);\n\t\treturn new JsonlSessionStorage(fs, filePath, header, [], null);\n\t}\n\n\tasync getMetadata(): Promise<JsonlSessionMetadata> {\n\t\treturn this.metadata;\n\t}\n\n\tasync getLeafId(): Promise<string | null> {\n\t\tif (this.currentLeafId !== null && !this.byId.has(this.currentLeafId)) {\n\t\t\tthrow new SessionError(\"invalid_session\", `Entry ${this.currentLeafId} not found`);\n\t\t}\n\t\treturn this.currentLeafId;\n\t}\n\n\tasync setLeafId(leafId: string | null): Promise<void> {\n\t\tif (leafId !== null && !this.byId.has(leafId)) {\n\t\t\tthrow new SessionError(\"not_found\", `Entry ${leafId} not found`);\n\t\t}\n\t\tconst entry: LeafEntry = {\n\t\t\ttype: \"leaf\",\n\t\t\tid: generateEntryId(this.byId),\n\t\t\tparentId: this.currentLeafId,\n\t\t\ttimestamp: new Date().toISOString(),\n\t\t\ttargetId: leafId,\n\t\t};\n\t\tgetFileSystemResultOrThrow(\n\t\t\tawait this.fs.appendFile(this.filePath, `${JSON.stringify(entry)}\\n`),\n\t\t\t`Failed to append session leaf ${entry.id}`,\n\t\t);\n\t\tthis.entries.push(entry);\n\t\tthis.byId.set(entry.id, entry);\n\t\tthis.currentLeafId = leafId;\n\t}\n\n\tasync createEntryId(): Promise<string> {\n\t\treturn generateEntryId(this.byId);\n\t}\n\n\tasync appendEntry(entry: SessionTreeEntry): Promise<void> {\n\t\tgetFileSystemResultOrThrow(\n\t\t\tawait this.fs.appendFile(this.filePath, `${JSON.stringify(entry)}\\n`),\n\t\t\t`Failed to append session entry ${entry.id}`,\n\t\t);\n\t\tthis.entries.push(entry);\n\t\tthis.byId.set(entry.id, entry);\n\t\tupdateLabelCache(this.labelsById, entry);\n\t\tthis.currentLeafId = leafIdAfterEntry(entry);\n\t}\n\n\tasync getEntry(id: string): Promise<SessionTreeEntry | undefined> {\n\t\treturn this.byId.get(id);\n\t}\n\n\tasync findEntries<TType extends SessionTreeEntry[\"type\"]>(\n\t\ttype: TType,\n\t): Promise<Array<Extract<SessionTreeEntry, { type: TType }>>> {\n\t\treturn this.entries.filter((entry): entry is Extract<SessionTreeEntry, { type: TType }> => entry.type === type);\n\t}\n\n\tasync getLabel(id: string): Promise<string | undefined> {\n\t\treturn this.labelsById.get(id);\n\t}\n\n\tasync getPathToRoot(leafId: string | null): Promise<SessionTreeEntry[]> {\n\t\tif (leafId === null) return [];\n\t\tconst path: SessionTreeEntry[] = [];\n\t\tlet current = this.byId.get(leafId);\n\t\tif (!current) throw new SessionError(\"not_found\", `Entry ${leafId} not found`);\n\t\twhile (current) {\n\t\t\tpath.unshift(current);\n\t\t\tif (!current.parentId) break;\n\t\t\tconst parent = this.byId.get(current.parentId);\n\t\t\tif (!parent) throw new SessionError(\"invalid_session\", `Entry ${current.parentId} not found`);\n\t\t\tcurrent = parent;\n\t\t}\n\t\treturn path;\n\t}\n\n\tasync getEntries(): Promise<SessionTreeEntry[]> {\n\t\treturn [...this.entries];\n\t}\n}\n"]}
1
+ {"version":3,"file":"jsonl-storage.js","sourceRoot":"","sources":["../../../src/harness/session/jsonl-storage.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,0BAA0B,EAAE,MAAM,iBAAiB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AAE,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;IAAA,CAChH;IAED,KAAK,CAAC,QAAQ,CAAC,EAAU,EAA+B;QACvD,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAAA,CAC/B;IAED,KAAK,CAAC,aAAa,CAAC,MAAqB,EAA+B;QACvE,IAAI,MAAM,KAAK,IAAI;YAAE,OAAO,EAAE,CAAC;QAC/B,MAAM,IAAI,GAAuB,EAAE,CAAC;QACpC,IAAI,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACpC,IAAI,CAAC,OAAO;YAAE,MAAM,IAAI,YAAY,CAAC,WAAW,EAAE,SAAS,MAAM,YAAY,CAAC,CAAC;QAC/E,OAAO,OAAO,EAAE,CAAC;YAChB,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;YACtB,IAAI,CAAC,OAAO,CAAC,QAAQ;gBAAE,MAAM;YAC7B,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;YAC/C,IAAI,CAAC,MAAM;gBAAE,MAAM,IAAI,YAAY,CAAC,iBAAiB,EAAE,SAAS,OAAO,CAAC,QAAQ,YAAY,CAAC,CAAC;YAC9F,OAAO,GAAG,MAAM,CAAC;QAClB,CAAC;QACD,OAAO,IAAI,CAAC;IAAA,CACZ;IAED,KAAK,CAAC,UAAU,GAAgC;QAC/C,OAAO,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC;IAAA,CACzB;CACD","sourcesContent":["import type { FileSystem, JsonlSessionMetadata, LeafEntry, SessionStorage, SessionTreeEntry } from \"../types.ts\";\nimport { SessionError, toError } from \"../types.ts\";\nimport { getFileSystemResultOrThrow } from \"./repo-utils.ts\";\nimport { uuidv7 } from \"./uuid.ts\";\n\ntype JsonlSessionStorageFileSystem = Pick<FileSystem, \"readTextFile\" | \"readTextLines\" | \"writeFile\" | \"appendFile\">;\n\ninterface SessionHeader {\n\ttype: \"session\";\n\tversion: 3;\n\tid: string;\n\ttimestamp: string;\n\tcwd: string;\n\tparentSession?: string;\n}\n\nfunction updateLabelCache(labelsById: Map<string, string>, entry: SessionTreeEntry): void {\n\tif (entry.type !== \"label\") return;\n\tconst label = entry.label?.trim();\n\tif (label) {\n\t\tlabelsById.set(entry.targetId, label);\n\t} else {\n\t\tlabelsById.delete(entry.targetId);\n\t}\n}\n\nfunction buildLabelsById(entries: SessionTreeEntry[]): Map<string, string> {\n\tconst labelsById = new Map<string, string>();\n\tfor (const entry of entries) {\n\t\tupdateLabelCache(labelsById, entry);\n\t}\n\treturn labelsById;\n}\n\nfunction generateEntryId(byId: { has(id: string): boolean }): string {\n\tfor (let i = 0; i < 100; i++) {\n\t\tconst id = uuidv7().slice(0, 8);\n\t\tif (!byId.has(id)) return id;\n\t}\n\treturn uuidv7();\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null;\n}\n\nfunction invalidSession(filePath: string, message: string, cause?: Error): SessionError {\n\treturn new SessionError(\"invalid_session\", `Invalid JSONL session file ${filePath}: ${message}`, cause);\n}\n\nfunction invalidEntry(filePath: string, lineNumber: number, message: string, cause?: Error): SessionError {\n\treturn new SessionError(\n\t\t\"invalid_entry\",\n\t\t`Invalid JSONL session file ${filePath}: line ${lineNumber} ${message}`,\n\t\tcause,\n\t);\n}\n\nfunction parseHeaderLine(line: string, filePath: string): SessionHeader {\n\tlet parsed: unknown;\n\ttry {\n\t\tparsed = JSON.parse(line);\n\t} catch (error) {\n\t\tthrow invalidSession(filePath, \"first line is not a valid session header\", toError(error));\n\t}\n\tif (!isRecord(parsed)) throw invalidSession(filePath, \"first line is not a valid session header\");\n\tif (parsed.type !== \"session\") throw invalidSession(filePath, \"first line is not a valid session header\");\n\tif (parsed.version !== 3) throw invalidSession(filePath, \"unsupported session version\");\n\tif (typeof parsed.id !== \"string\" || !parsed.id) throw invalidSession(filePath, \"session header is missing id\");\n\tif (typeof parsed.timestamp !== \"string\" || !parsed.timestamp) {\n\t\tthrow invalidSession(filePath, \"session header is missing timestamp\");\n\t}\n\tif (typeof parsed.cwd !== \"string\" || !parsed.cwd) throw invalidSession(filePath, \"session header is missing cwd\");\n\tif (parsed.parentSession !== undefined && typeof parsed.parentSession !== \"string\") {\n\t\tthrow invalidSession(filePath, \"session header parentSession must be a string\");\n\t}\n\treturn {\n\t\ttype: \"session\",\n\t\tversion: 3,\n\t\tid: parsed.id,\n\t\ttimestamp: parsed.timestamp,\n\t\tcwd: parsed.cwd,\n\t\tparentSession: parsed.parentSession,\n\t};\n}\n\nfunction parseEntryLine(line: string, filePath: string, lineNumber: number): SessionTreeEntry {\n\tlet parsed: unknown;\n\ttry {\n\t\tparsed = JSON.parse(line);\n\t} catch (error) {\n\t\tthrow invalidEntry(filePath, lineNumber, \"is not valid JSON\", toError(error));\n\t}\n\tif (!isRecord(parsed)) throw invalidEntry(filePath, lineNumber, \"is not a valid session entry\");\n\tif (typeof parsed.type !== \"string\") throw invalidEntry(filePath, lineNumber, \"is missing entry type\");\n\tif (typeof parsed.id !== \"string\" || !parsed.id) throw invalidEntry(filePath, lineNumber, \"is missing entry id\");\n\tif (parsed.parentId !== null && typeof parsed.parentId !== \"string\") {\n\t\tthrow invalidEntry(filePath, lineNumber, \"has invalid parentId\");\n\t}\n\tif (typeof parsed.timestamp !== \"string\" || !parsed.timestamp) {\n\t\tthrow invalidEntry(filePath, lineNumber, \"is missing timestamp\");\n\t}\n\tif (parsed.type === \"leaf\" && parsed.targetId !== null && typeof parsed.targetId !== \"string\") {\n\t\tthrow invalidEntry(filePath, lineNumber, \"has invalid targetId\");\n\t}\n\treturn parsed as unknown as SessionTreeEntry;\n}\n\nfunction leafIdAfterEntry(entry: SessionTreeEntry): string | null {\n\treturn entry.type === \"leaf\" ? entry.targetId : entry.id;\n}\n\nfunction headerToSessionMetadata(header: SessionHeader, path: string): JsonlSessionMetadata {\n\treturn {\n\t\tid: header.id,\n\t\tcreatedAt: header.timestamp,\n\t\tcwd: header.cwd,\n\t\tpath,\n\t\tparentSessionPath: header.parentSession,\n\t};\n}\n\nexport async function loadJsonlSessionMetadata(\n\tfs: JsonlSessionStorageFileSystem,\n\tfilePath: string,\n): Promise<JsonlSessionMetadata> {\n\tconst lines = getFileSystemResultOrThrow(\n\t\tawait fs.readTextLines(filePath, { maxLines: 1 }),\n\t\t`Failed to read session header ${filePath}`,\n\t);\n\tconst line = lines[0];\n\tif (line?.trim()) return headerToSessionMetadata(parseHeaderLine(line, filePath), filePath);\n\tthrow invalidSession(filePath, \"missing session header\");\n}\n\nasync function loadJsonlStorage(\n\tfs: JsonlSessionStorageFileSystem,\n\tfilePath: string,\n): Promise<{\n\theader: SessionHeader;\n\tentries: SessionTreeEntry[];\n\tleafId: string | null;\n}> {\n\tconst content = getFileSystemResultOrThrow(await fs.readTextFile(filePath), `Failed to read session ${filePath}`);\n\tconst lines = content.split(\"\\n\").filter((line) => line.trim());\n\tif (lines.length === 0) {\n\t\tthrow invalidSession(filePath, \"missing session header\");\n\t}\n\n\tconst header = parseHeaderLine(lines[0]!, filePath);\n\tconst entries: SessionTreeEntry[] = [];\n\tlet leafId: string | null = null;\n\tfor (let i = 1; i < lines.length; i++) {\n\t\tconst entry = parseEntryLine(lines[i]!, filePath, i + 1);\n\t\tentries.push(entry);\n\t\tleafId = leafIdAfterEntry(entry);\n\t}\n\treturn { header, entries, leafId };\n}\n\nexport class JsonlSessionStorage implements SessionStorage<JsonlSessionMetadata> {\n\tprivate readonly fs: JsonlSessionStorageFileSystem;\n\tprivate readonly filePath: string;\n\tprivate readonly metadata: JsonlSessionMetadata;\n\tprivate entries: SessionTreeEntry[];\n\tprivate byId: Map<string, SessionTreeEntry>;\n\tprivate labelsById: Map<string, string>;\n\tprivate currentLeafId: string | null;\n\n\tprivate constructor(\n\t\tfs: JsonlSessionStorageFileSystem,\n\t\tfilePath: string,\n\t\theader: SessionHeader,\n\t\tentries: SessionTreeEntry[],\n\t\tleafId: string | null,\n\t) {\n\t\tthis.fs = fs;\n\t\tthis.filePath = filePath;\n\t\tthis.metadata = headerToSessionMetadata(header, this.filePath);\n\t\tthis.entries = entries;\n\t\tthis.byId = new Map(entries.map((entry) => [entry.id, entry]));\n\t\tthis.labelsById = buildLabelsById(entries);\n\t\tthis.currentLeafId = leafId;\n\t}\n\n\tstatic async open(fs: JsonlSessionStorageFileSystem, filePath: string): Promise<JsonlSessionStorage> {\n\t\tconst loaded = await loadJsonlStorage(fs, filePath);\n\t\treturn new JsonlSessionStorage(fs, filePath, loaded.header, loaded.entries, loaded.leafId);\n\t}\n\n\tstatic async create(\n\t\tfs: JsonlSessionStorageFileSystem,\n\t\tfilePath: string,\n\t\toptions: {\n\t\t\tcwd: string;\n\t\t\tsessionId: string;\n\t\t\tparentSessionPath?: string;\n\t\t},\n\t): Promise<JsonlSessionStorage> {\n\t\tconst header: SessionHeader = {\n\t\t\ttype: \"session\",\n\t\t\tversion: 3,\n\t\t\tid: options.sessionId,\n\t\t\ttimestamp: new Date().toISOString(),\n\t\t\tcwd: options.cwd,\n\t\t\tparentSession: options.parentSessionPath,\n\t\t};\n\t\tgetFileSystemResultOrThrow(\n\t\t\tawait fs.writeFile(filePath, `${JSON.stringify(header)}\\n`),\n\t\t\t`Failed to create session ${filePath}`,\n\t\t);\n\t\treturn new JsonlSessionStorage(fs, filePath, header, [], null);\n\t}\n\n\tasync getMetadata(): Promise<JsonlSessionMetadata> {\n\t\treturn this.metadata;\n\t}\n\n\tasync getLeafId(): Promise<string | null> {\n\t\tif (this.currentLeafId !== null && !this.byId.has(this.currentLeafId)) {\n\t\t\tthrow new SessionError(\"invalid_session\", `Entry ${this.currentLeafId} not found`);\n\t\t}\n\t\treturn this.currentLeafId;\n\t}\n\n\tasync setLeafId(leafId: string | null): Promise<void> {\n\t\tif (leafId !== null && !this.byId.has(leafId)) {\n\t\t\tthrow new SessionError(\"not_found\", `Entry ${leafId} not found`);\n\t\t}\n\t\tconst entry: LeafEntry = {\n\t\t\ttype: \"leaf\",\n\t\t\tid: generateEntryId(this.byId),\n\t\t\tparentId: this.currentLeafId,\n\t\t\ttimestamp: new Date().toISOString(),\n\t\t\ttargetId: leafId,\n\t\t};\n\t\tgetFileSystemResultOrThrow(\n\t\t\tawait this.fs.appendFile(this.filePath, `${JSON.stringify(entry)}\\n`),\n\t\t\t`Failed to append session leaf ${entry.id}`,\n\t\t);\n\t\tthis.entries.push(entry);\n\t\tthis.byId.set(entry.id, entry);\n\t\tthis.currentLeafId = leafId;\n\t}\n\n\tasync createEntryId(): Promise<string> {\n\t\treturn generateEntryId(this.byId);\n\t}\n\n\tasync appendEntry(entry: SessionTreeEntry): Promise<void> {\n\t\tgetFileSystemResultOrThrow(\n\t\t\tawait this.fs.appendFile(this.filePath, `${JSON.stringify(entry)}\\n`),\n\t\t\t`Failed to append session entry ${entry.id}`,\n\t\t);\n\t\tthis.entries.push(entry);\n\t\tthis.byId.set(entry.id, entry);\n\t\tupdateLabelCache(this.labelsById, entry);\n\t\tthis.currentLeafId = leafIdAfterEntry(entry);\n\t}\n\n\tasync getEntry(id: string): Promise<SessionTreeEntry | undefined> {\n\t\treturn this.byId.get(id);\n\t}\n\n\tasync findEntries<TType extends SessionTreeEntry[\"type\"]>(\n\t\ttype: TType,\n\t): Promise<Array<Extract<SessionTreeEntry, { type: TType }>>> {\n\t\treturn this.entries.filter((entry): entry is Extract<SessionTreeEntry, { type: TType }> => entry.type === type);\n\t}\n\n\tasync getLabel(id: string): Promise<string | undefined> {\n\t\treturn this.labelsById.get(id);\n\t}\n\n\tasync getPathToRoot(leafId: string | null): Promise<SessionTreeEntry[]> {\n\t\tif (leafId === null) return [];\n\t\tconst path: SessionTreeEntry[] = [];\n\t\tlet current = this.byId.get(leafId);\n\t\tif (!current) throw new SessionError(\"not_found\", `Entry ${leafId} not found`);\n\t\twhile (current) {\n\t\t\tpath.unshift(current);\n\t\t\tif (!current.parentId) break;\n\t\t\tconst parent = this.byId.get(current.parentId);\n\t\t\tif (!parent) throw new SessionError(\"invalid_session\", `Entry ${current.parentId} not found`);\n\t\t\tcurrent = parent;\n\t\t}\n\t\treturn path;\n\t}\n\n\tasync getEntries(): Promise<SessionTreeEntry[]> {\n\t\treturn [...this.entries];\n\t}\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { type Session, type SessionMetadata, type SessionRepo } from "../types.js";
1
+ import { type Session, type SessionMetadata, type SessionRepo } from "../types.ts";
2
2
  export declare class InMemorySessionRepo implements SessionRepo<SessionMetadata, {
3
3
  id?: string;
4
4
  }, void> {
@@ -1 +1 @@
1
- {"version":3,"file":"memory-repo.d.ts","sourceRoot":"","sources":["../../../src/harness/session/memory-repo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAgB,KAAK,eAAe,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAIjG,qBAAa,mBAAoB,YAAW,WAAW,CAAC,eAAe,EAAE;IAAE,EAAE,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,IAAI,CAAC;IAC9F,OAAO,CAAC,QAAQ,CAA+C;IAEzD,MAAM,CAAC,OAAO,GAAE;QAAE,EAAE,CAAC,EAAE,MAAM,CAAA;KAAO,GAAG,OAAO,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,CAS7E;IAEK,IAAI,CAAC,QAAQ,EAAE,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,CAMvE;IAEK,IAAI,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC,CAEvC;IAEK,MAAM,CAAC,QAAQ,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAErD;IAEK,IAAI,CACT,cAAc,EAAE,eAAe,EAC/B,OAAO,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;QAAC,EAAE,CAAC,EAAE,MAAM,CAAA;KAAE,GACpE,OAAO,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,CAWnC;CACD","sourcesContent":["import { type Session, SessionError, type SessionMetadata, type SessionRepo } from \"../types.js\";\nimport { InMemorySessionStorage } from \"./memory-storage.js\";\nimport { createSessionId, createTimestamp, getEntriesToFork, toSession } from \"./repo-utils.js\";\n\nexport class InMemorySessionRepo implements SessionRepo<SessionMetadata, { id?: string }, void> {\n\tprivate sessions = new Map<string, Session<SessionMetadata>>();\n\n\tasync create(options: { id?: string } = {}): Promise<Session<SessionMetadata>> {\n\t\tconst metadata: SessionMetadata = {\n\t\t\tid: options.id ?? createSessionId(),\n\t\t\tcreatedAt: createTimestamp(),\n\t\t};\n\t\tconst storage = new InMemorySessionStorage({ metadata });\n\t\tconst session = toSession(storage);\n\t\tthis.sessions.set(metadata.id, session);\n\t\treturn session;\n\t}\n\n\tasync open(metadata: SessionMetadata): Promise<Session<SessionMetadata>> {\n\t\tconst session = this.sessions.get(metadata.id);\n\t\tif (!session) {\n\t\t\tthrow new SessionError(\"not_found\", `Session not found: ${metadata.id}`);\n\t\t}\n\t\treturn session;\n\t}\n\n\tasync list(): Promise<SessionMetadata[]> {\n\t\treturn Promise.all([...this.sessions.values()].map((session) => session.getMetadata()));\n\t}\n\n\tasync delete(metadata: SessionMetadata): Promise<void> {\n\t\tthis.sessions.delete(metadata.id);\n\t}\n\n\tasync fork(\n\t\tsourceMetadata: SessionMetadata,\n\t\toptions: { entryId?: string; position?: \"before\" | \"at\"; id?: string },\n\t): Promise<Session<SessionMetadata>> {\n\t\tconst source = await this.open(sourceMetadata);\n\t\tconst forkedEntries = await getEntriesToFork(source.getStorage(), options);\n\t\tconst metadata: SessionMetadata = {\n\t\t\tid: options.id ?? createSessionId(),\n\t\t\tcreatedAt: createTimestamp(),\n\t\t};\n\t\tconst storage = new InMemorySessionStorage({ metadata, entries: forkedEntries });\n\t\tconst session = toSession(storage);\n\t\tthis.sessions.set(metadata.id, session);\n\t\treturn session;\n\t}\n}\n"]}
1
+ {"version":3,"file":"memory-repo.d.ts","sourceRoot":"","sources":["../../../src/harness/session/memory-repo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAgB,KAAK,eAAe,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAIjG,qBAAa,mBAAoB,YAAW,WAAW,CAAC,eAAe,EAAE;IAAE,EAAE,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,IAAI,CAAC;IAC9F,OAAO,CAAC,QAAQ,CAA+C;IAEzD,MAAM,CAAC,OAAO,GAAE;QAAE,EAAE,CAAC,EAAE,MAAM,CAAA;KAAO,GAAG,OAAO,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,CAS7E;IAEK,IAAI,CAAC,QAAQ,EAAE,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,CAMvE;IAEK,IAAI,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC,CAEvC;IAEK,MAAM,CAAC,QAAQ,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAErD;IAEK,IAAI,CACT,cAAc,EAAE,eAAe,EAC/B,OAAO,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;QAAC,EAAE,CAAC,EAAE,MAAM,CAAA;KAAE,GACpE,OAAO,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,CAWnC;CACD","sourcesContent":["import { type Session, SessionError, type SessionMetadata, type SessionRepo } from \"../types.ts\";\nimport { InMemorySessionStorage } from \"./memory-storage.ts\";\nimport { createSessionId, createTimestamp, getEntriesToFork, toSession } from \"./repo-utils.ts\";\n\nexport class InMemorySessionRepo implements SessionRepo<SessionMetadata, { id?: string }, void> {\n\tprivate sessions = new Map<string, Session<SessionMetadata>>();\n\n\tasync create(options: { id?: string } = {}): Promise<Session<SessionMetadata>> {\n\t\tconst metadata: SessionMetadata = {\n\t\t\tid: options.id ?? createSessionId(),\n\t\t\tcreatedAt: createTimestamp(),\n\t\t};\n\t\tconst storage = new InMemorySessionStorage({ metadata });\n\t\tconst session = toSession(storage);\n\t\tthis.sessions.set(metadata.id, session);\n\t\treturn session;\n\t}\n\n\tasync open(metadata: SessionMetadata): Promise<Session<SessionMetadata>> {\n\t\tconst session = this.sessions.get(metadata.id);\n\t\tif (!session) {\n\t\t\tthrow new SessionError(\"not_found\", `Session not found: ${metadata.id}`);\n\t\t}\n\t\treturn session;\n\t}\n\n\tasync list(): Promise<SessionMetadata[]> {\n\t\treturn Promise.all([...this.sessions.values()].map((session) => session.getMetadata()));\n\t}\n\n\tasync delete(metadata: SessionMetadata): Promise<void> {\n\t\tthis.sessions.delete(metadata.id);\n\t}\n\n\tasync fork(\n\t\tsourceMetadata: SessionMetadata,\n\t\toptions: { entryId?: string; position?: \"before\" | \"at\"; id?: string },\n\t): Promise<Session<SessionMetadata>> {\n\t\tconst source = await this.open(sourceMetadata);\n\t\tconst forkedEntries = await getEntriesToFork(source.getStorage(), options);\n\t\tconst metadata: SessionMetadata = {\n\t\t\tid: options.id ?? createSessionId(),\n\t\t\tcreatedAt: createTimestamp(),\n\t\t};\n\t\tconst storage = new InMemorySessionStorage({ metadata, entries: forkedEntries });\n\t\tconst session = toSession(storage);\n\t\tthis.sessions.set(metadata.id, session);\n\t\treturn session;\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"memory-repo.js","sourceRoot":"","sources":["../../../src/harness/session/memory-repo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,YAAY,EAA0C,MAAM,aAAa,CAAC;AACjG,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEhG,MAAM,OAAO,mBAAmB;IACvB,QAAQ,GAAG,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c,CAAC,CAAC;QAC/C,MAAM,aAAa,GAAG,MAAM,gBAAgB,CAAC,MAAM,CAAC,UAAU,EAAE,EAAE,OAAO,CAAC,CAAC;QAC3E,MAAM,QAAQ,GAAoB;YACjC,EAAE,EAAE,OAAO,CAAC,EAAE,IAAI,eAAe,EAAE;YACnC,SAAS,EAAE,eAAe,EAAE;SAC5B,CAAC;QACF,MAAM,OAAO,GAAG,IAAI,sBAAsB,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,aAAa,EAAE,CAAC,CAAC;QACjF,MAAM,OAAO,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;QACnC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;QACxC,OAAO,OAAO,CAAC;IAAA,CACf;CACD","sourcesContent":["import { type Session, SessionError, type SessionMetadata, type SessionRepo } from \"../types.js\";\nimport { InMemorySessionStorage } from \"./memory-storage.js\";\nimport { createSessionId, createTimestamp, getEntriesToFork, toSession } from \"./repo-utils.js\";\n\nexport class InMemorySessionRepo implements SessionRepo<SessionMetadata, { id?: string }, void> {\n\tprivate sessions = new Map<string, Session<SessionMetadata>>();\n\n\tasync create(options: { id?: string } = {}): Promise<Session<SessionMetadata>> {\n\t\tconst metadata: SessionMetadata = {\n\t\t\tid: options.id ?? createSessionId(),\n\t\t\tcreatedAt: createTimestamp(),\n\t\t};\n\t\tconst storage = new InMemorySessionStorage({ metadata });\n\t\tconst session = toSession(storage);\n\t\tthis.sessions.set(metadata.id, session);\n\t\treturn session;\n\t}\n\n\tasync open(metadata: SessionMetadata): Promise<Session<SessionMetadata>> {\n\t\tconst session = this.sessions.get(metadata.id);\n\t\tif (!session) {\n\t\t\tthrow new SessionError(\"not_found\", `Session not found: ${metadata.id}`);\n\t\t}\n\t\treturn session;\n\t}\n\n\tasync list(): Promise<SessionMetadata[]> {\n\t\treturn Promise.all([...this.sessions.values()].map((session) => session.getMetadata()));\n\t}\n\n\tasync delete(metadata: SessionMetadata): Promise<void> {\n\t\tthis.sessions.delete(metadata.id);\n\t}\n\n\tasync fork(\n\t\tsourceMetadata: SessionMetadata,\n\t\toptions: { entryId?: string; position?: \"before\" | \"at\"; id?: string },\n\t): Promise<Session<SessionMetadata>> {\n\t\tconst source = await this.open(sourceMetadata);\n\t\tconst forkedEntries = await getEntriesToFork(source.getStorage(), options);\n\t\tconst metadata: SessionMetadata = {\n\t\t\tid: options.id ?? createSessionId(),\n\t\t\tcreatedAt: createTimestamp(),\n\t\t};\n\t\tconst storage = new InMemorySessionStorage({ metadata, entries: forkedEntries });\n\t\tconst session = toSession(storage);\n\t\tthis.sessions.set(metadata.id, session);\n\t\treturn session;\n\t}\n}\n"]}
1
+ {"version":3,"file":"memory-repo.js","sourceRoot":"","sources":["../../../src/harness/session/memory-repo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,YAAY,EAA0C,MAAM,aAAa,CAAC;AACjG,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEhG,MAAM,OAAO,mBAAmB;IACvB,QAAQ,GAAG,IAAI,GAAG,EAAoC,CAAC;IAE/D,KAAK,CAAC,MAAM,CAAC,OAAO,GAAoB,EAAE,EAAqC;QAC9E,MAAM,QAAQ,GAAoB;YACjC,EAAE,EAAE,OAAO,CAAC,EAAE,IAAI,eAAe,EAAE;YACnC,SAAS,EAAE,eAAe,EAAE;SAC5B,CAAC;QACF,MAAM,OAAO,GAAG,IAAI,sBAAsB,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC;QACzD,MAAM,OAAO,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;QACnC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;QACxC,OAAO,OAAO,CAAC;IAAA,CAC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AAO,CAAC,CAAC;QACxC,OAAO,OAAO,CAAC;IAAA,CACf;CACD","sourcesContent":["import { type Session, SessionError, type SessionMetadata, type SessionRepo } from \"../types.ts\";\nimport { InMemorySessionStorage } from \"./memory-storage.ts\";\nimport { createSessionId, createTimestamp, getEntriesToFork, toSession } from \"./repo-utils.ts\";\n\nexport class InMemorySessionRepo implements SessionRepo<SessionMetadata, { id?: string }, void> {\n\tprivate sessions = new Map<string, Session<SessionMetadata>>();\n\n\tasync create(options: { id?: string } = {}): Promise<Session<SessionMetadata>> {\n\t\tconst metadata: SessionMetadata = {\n\t\t\tid: options.id ?? createSessionId(),\n\t\t\tcreatedAt: createTimestamp(),\n\t\t};\n\t\tconst storage = new InMemorySessionStorage({ metadata });\n\t\tconst session = toSession(storage);\n\t\tthis.sessions.set(metadata.id, session);\n\t\treturn session;\n\t}\n\n\tasync open(metadata: SessionMetadata): Promise<Session<SessionMetadata>> {\n\t\tconst session = this.sessions.get(metadata.id);\n\t\tif (!session) {\n\t\t\tthrow new SessionError(\"not_found\", `Session not found: ${metadata.id}`);\n\t\t}\n\t\treturn session;\n\t}\n\n\tasync list(): Promise<SessionMetadata[]> {\n\t\treturn Promise.all([...this.sessions.values()].map((session) => session.getMetadata()));\n\t}\n\n\tasync delete(metadata: SessionMetadata): Promise<void> {\n\t\tthis.sessions.delete(metadata.id);\n\t}\n\n\tasync fork(\n\t\tsourceMetadata: SessionMetadata,\n\t\toptions: { entryId?: string; position?: \"before\" | \"at\"; id?: string },\n\t): Promise<Session<SessionMetadata>> {\n\t\tconst source = await this.open(sourceMetadata);\n\t\tconst forkedEntries = await getEntriesToFork(source.getStorage(), options);\n\t\tconst metadata: SessionMetadata = {\n\t\t\tid: options.id ?? createSessionId(),\n\t\t\tcreatedAt: createTimestamp(),\n\t\t};\n\t\tconst storage = new InMemorySessionStorage({ metadata, entries: forkedEntries });\n\t\tconst session = toSession(storage);\n\t\tthis.sessions.set(metadata.id, session);\n\t\treturn session;\n\t}\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { type SessionMetadata, type SessionStorage, type SessionTreeEntry } from "../types.js";
1
+ import { type SessionMetadata, type SessionStorage, type SessionTreeEntry } from "../types.ts";
2
2
  export declare class InMemorySessionStorage<TMetadata extends SessionMetadata = SessionMetadata> implements SessionStorage<TMetadata> {
3
3
  private readonly metadata;
4
4
  private entries;
@@ -1 +1 @@
1
- {"version":3,"file":"memory-storage.d.ts","sourceRoot":"","sources":["../../../src/harness/session/memory-storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,MAAM,aAAa,CAAC;AAiCrB,qBAAa,sBAAsB,CAAC,SAAS,SAAS,eAAe,GAAG,eAAe,CACtF,YAAW,cAAc,CAAC,SAAS,CAAC;IAEpC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAY;IACrC,OAAO,CAAC,OAAO,CAAqB;IACpC,OAAO,CAAC,IAAI,CAAgC;IAC5C,OAAO,CAAC,UAAU,CAAsB;IACxC,OAAO,CAAC,MAAM,CAAgB;IAE9B,YAAY,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,gBAAgB,EAAE,CAAC;QAAC,QAAQ,CAAC,EAAE,SAAS,CAAA;KAAE,EAU3E;IAEK,WAAW,IAAI,OAAO,CAAC,SAAS,CAAC,CAEtC;IAEK,SAAS,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAKxC;IAEK,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAcpD;IAEK,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC,CAErC;IAEK,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAKxD;IAEK,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC,CAEhE;IAEK,WAAW,CAAC,KAAK,SAAS,gBAAgB,CAAC,MAAM,CAAC,EACvD,IAAI,EAAE,KAAK,GACT,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,gBAAgB,EAAE;QAAE,IAAI,EAAE,KAAK,CAAA;KAAE,CAAC,CAAC,CAAC,CAE5D;IAEK,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAEtD;IAEK,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAatE;IAEK,UAAU,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAE9C;CACD","sourcesContent":["import {\n\ttype LeafEntry,\n\tSessionError,\n\ttype SessionMetadata,\n\ttype SessionStorage,\n\ttype SessionTreeEntry,\n} from \"../types.js\";\nimport { uuidv7 } from \"./uuid.js\";\n\nfunction updateLabelCache(labelsById: Map<string, string>, entry: SessionTreeEntry): void {\n\tif (entry.type !== \"label\") return;\n\tconst label = entry.label?.trim();\n\tif (label) {\n\t\tlabelsById.set(entry.targetId, label);\n\t} else {\n\t\tlabelsById.delete(entry.targetId);\n\t}\n}\n\nfunction buildLabelsById(entries: SessionTreeEntry[]): Map<string, string> {\n\tconst labelsById = new Map<string, string>();\n\tfor (const entry of entries) {\n\t\tupdateLabelCache(labelsById, entry);\n\t}\n\treturn labelsById;\n}\n\nfunction generateEntryId(byId: { has(id: string): boolean }): string {\n\tfor (let i = 0; i < 100; i++) {\n\t\tconst id = uuidv7().slice(0, 8);\n\t\tif (!byId.has(id)) return id;\n\t}\n\treturn uuidv7();\n}\n\nfunction leafIdAfterEntry(entry: SessionTreeEntry): string | null {\n\treturn entry.type === \"leaf\" ? entry.targetId : entry.id;\n}\n\nexport class InMemorySessionStorage<TMetadata extends SessionMetadata = SessionMetadata>\n\timplements SessionStorage<TMetadata>\n{\n\tprivate readonly metadata: TMetadata;\n\tprivate entries: SessionTreeEntry[];\n\tprivate byId: Map<string, SessionTreeEntry>;\n\tprivate labelsById: Map<string, string>;\n\tprivate leafId: string | null;\n\n\tconstructor(options?: { entries?: SessionTreeEntry[]; metadata?: TMetadata }) {\n\t\tthis.entries = options?.entries ? [...options.entries] : [];\n\t\tthis.byId = new Map(this.entries.map((entry) => [entry.id, entry]));\n\t\tthis.labelsById = buildLabelsById(this.entries);\n\t\tthis.leafId = null;\n\t\tfor (const entry of this.entries) this.leafId = leafIdAfterEntry(entry);\n\t\tif (this.leafId !== null && !this.byId.has(this.leafId)) {\n\t\t\tthrow new SessionError(\"invalid_session\", `Entry ${this.leafId} not found`);\n\t\t}\n\t\tthis.metadata = options?.metadata ?? ({ id: uuidv7(), createdAt: new Date().toISOString() } as TMetadata);\n\t}\n\n\tasync getMetadata(): Promise<TMetadata> {\n\t\treturn this.metadata;\n\t}\n\n\tasync getLeafId(): Promise<string | null> {\n\t\tif (this.leafId !== null && !this.byId.has(this.leafId)) {\n\t\t\tthrow new SessionError(\"invalid_session\", `Entry ${this.leafId} not found`);\n\t\t}\n\t\treturn this.leafId;\n\t}\n\n\tasync setLeafId(leafId: string | null): Promise<void> {\n\t\tif (leafId !== null && !this.byId.has(leafId)) {\n\t\t\tthrow new SessionError(\"not_found\", `Entry ${leafId} not found`);\n\t\t}\n\t\tconst entry: LeafEntry = {\n\t\t\ttype: \"leaf\",\n\t\t\tid: generateEntryId(this.byId),\n\t\t\tparentId: this.leafId,\n\t\t\ttimestamp: new Date().toISOString(),\n\t\t\ttargetId: leafId,\n\t\t};\n\t\tthis.entries.push(entry);\n\t\tthis.byId.set(entry.id, entry);\n\t\tthis.leafId = leafId;\n\t}\n\n\tasync createEntryId(): Promise<string> {\n\t\treturn generateEntryId(this.byId);\n\t}\n\n\tasync appendEntry(entry: SessionTreeEntry): Promise<void> {\n\t\tthis.entries.push(entry);\n\t\tthis.byId.set(entry.id, entry);\n\t\tupdateLabelCache(this.labelsById, entry);\n\t\tthis.leafId = leafIdAfterEntry(entry);\n\t}\n\n\tasync getEntry(id: string): Promise<SessionTreeEntry | undefined> {\n\t\treturn this.byId.get(id);\n\t}\n\n\tasync findEntries<TType extends SessionTreeEntry[\"type\"]>(\n\t\ttype: TType,\n\t): Promise<Array<Extract<SessionTreeEntry, { type: TType }>>> {\n\t\treturn this.entries.filter((entry): entry is Extract<SessionTreeEntry, { type: TType }> => entry.type === type);\n\t}\n\n\tasync getLabel(id: string): Promise<string | undefined> {\n\t\treturn this.labelsById.get(id);\n\t}\n\n\tasync getPathToRoot(leafId: string | null): Promise<SessionTreeEntry[]> {\n\t\tif (leafId === null) return [];\n\t\tconst path: SessionTreeEntry[] = [];\n\t\tlet current = this.byId.get(leafId);\n\t\tif (!current) throw new SessionError(\"not_found\", `Entry ${leafId} not found`);\n\t\twhile (current) {\n\t\t\tpath.unshift(current);\n\t\t\tif (!current.parentId) break;\n\t\t\tconst parent = this.byId.get(current.parentId);\n\t\t\tif (!parent) throw new SessionError(\"invalid_session\", `Entry ${current.parentId} not found`);\n\t\t\tcurrent = parent;\n\t\t}\n\t\treturn path;\n\t}\n\n\tasync getEntries(): Promise<SessionTreeEntry[]> {\n\t\treturn [...this.entries];\n\t}\n}\n"]}
1
+ {"version":3,"file":"memory-storage.d.ts","sourceRoot":"","sources":["../../../src/harness/session/memory-storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,MAAM,aAAa,CAAC;AAiCrB,qBAAa,sBAAsB,CAAC,SAAS,SAAS,eAAe,GAAG,eAAe,CACtF,YAAW,cAAc,CAAC,SAAS,CAAC;IAEpC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAY;IACrC,OAAO,CAAC,OAAO,CAAqB;IACpC,OAAO,CAAC,IAAI,CAAgC;IAC5C,OAAO,CAAC,UAAU,CAAsB;IACxC,OAAO,CAAC,MAAM,CAAgB;IAE9B,YAAY,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,gBAAgB,EAAE,CAAC;QAAC,QAAQ,CAAC,EAAE,SAAS,CAAA;KAAE,EAU3E;IAEK,WAAW,IAAI,OAAO,CAAC,SAAS,CAAC,CAEtC;IAEK,SAAS,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAKxC;IAEK,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAcpD;IAEK,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC,CAErC;IAEK,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAKxD;IAEK,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC,CAEhE;IAEK,WAAW,CAAC,KAAK,SAAS,gBAAgB,CAAC,MAAM,CAAC,EACvD,IAAI,EAAE,KAAK,GACT,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,gBAAgB,EAAE;QAAE,IAAI,EAAE,KAAK,CAAA;KAAE,CAAC,CAAC,CAAC,CAE5D;IAEK,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAEtD;IAEK,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAatE;IAEK,UAAU,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAE9C;CACD","sourcesContent":["import {\n\ttype LeafEntry,\n\tSessionError,\n\ttype SessionMetadata,\n\ttype SessionStorage,\n\ttype SessionTreeEntry,\n} from \"../types.ts\";\nimport { uuidv7 } from \"./uuid.ts\";\n\nfunction updateLabelCache(labelsById: Map<string, string>, entry: SessionTreeEntry): void {\n\tif (entry.type !== \"label\") return;\n\tconst label = entry.label?.trim();\n\tif (label) {\n\t\tlabelsById.set(entry.targetId, label);\n\t} else {\n\t\tlabelsById.delete(entry.targetId);\n\t}\n}\n\nfunction buildLabelsById(entries: SessionTreeEntry[]): Map<string, string> {\n\tconst labelsById = new Map<string, string>();\n\tfor (const entry of entries) {\n\t\tupdateLabelCache(labelsById, entry);\n\t}\n\treturn labelsById;\n}\n\nfunction generateEntryId(byId: { has(id: string): boolean }): string {\n\tfor (let i = 0; i < 100; i++) {\n\t\tconst id = uuidv7().slice(0, 8);\n\t\tif (!byId.has(id)) return id;\n\t}\n\treturn uuidv7();\n}\n\nfunction leafIdAfterEntry(entry: SessionTreeEntry): string | null {\n\treturn entry.type === \"leaf\" ? entry.targetId : entry.id;\n}\n\nexport class InMemorySessionStorage<TMetadata extends SessionMetadata = SessionMetadata>\n\timplements SessionStorage<TMetadata>\n{\n\tprivate readonly metadata: TMetadata;\n\tprivate entries: SessionTreeEntry[];\n\tprivate byId: Map<string, SessionTreeEntry>;\n\tprivate labelsById: Map<string, string>;\n\tprivate leafId: string | null;\n\n\tconstructor(options?: { entries?: SessionTreeEntry[]; metadata?: TMetadata }) {\n\t\tthis.entries = options?.entries ? [...options.entries] : [];\n\t\tthis.byId = new Map(this.entries.map((entry) => [entry.id, entry]));\n\t\tthis.labelsById = buildLabelsById(this.entries);\n\t\tthis.leafId = null;\n\t\tfor (const entry of this.entries) this.leafId = leafIdAfterEntry(entry);\n\t\tif (this.leafId !== null && !this.byId.has(this.leafId)) {\n\t\t\tthrow new SessionError(\"invalid_session\", `Entry ${this.leafId} not found`);\n\t\t}\n\t\tthis.metadata = options?.metadata ?? ({ id: uuidv7(), createdAt: new Date().toISOString() } as TMetadata);\n\t}\n\n\tasync getMetadata(): Promise<TMetadata> {\n\t\treturn this.metadata;\n\t}\n\n\tasync getLeafId(): Promise<string | null> {\n\t\tif (this.leafId !== null && !this.byId.has(this.leafId)) {\n\t\t\tthrow new SessionError(\"invalid_session\", `Entry ${this.leafId} not found`);\n\t\t}\n\t\treturn this.leafId;\n\t}\n\n\tasync setLeafId(leafId: string | null): Promise<void> {\n\t\tif (leafId !== null && !this.byId.has(leafId)) {\n\t\t\tthrow new SessionError(\"not_found\", `Entry ${leafId} not found`);\n\t\t}\n\t\tconst entry: LeafEntry = {\n\t\t\ttype: \"leaf\",\n\t\t\tid: generateEntryId(this.byId),\n\t\t\tparentId: this.leafId,\n\t\t\ttimestamp: new Date().toISOString(),\n\t\t\ttargetId: leafId,\n\t\t};\n\t\tthis.entries.push(entry);\n\t\tthis.byId.set(entry.id, entry);\n\t\tthis.leafId = leafId;\n\t}\n\n\tasync createEntryId(): Promise<string> {\n\t\treturn generateEntryId(this.byId);\n\t}\n\n\tasync appendEntry(entry: SessionTreeEntry): Promise<void> {\n\t\tthis.entries.push(entry);\n\t\tthis.byId.set(entry.id, entry);\n\t\tupdateLabelCache(this.labelsById, entry);\n\t\tthis.leafId = leafIdAfterEntry(entry);\n\t}\n\n\tasync getEntry(id: string): Promise<SessionTreeEntry | undefined> {\n\t\treturn this.byId.get(id);\n\t}\n\n\tasync findEntries<TType extends SessionTreeEntry[\"type\"]>(\n\t\ttype: TType,\n\t): Promise<Array<Extract<SessionTreeEntry, { type: TType }>>> {\n\t\treturn this.entries.filter((entry): entry is Extract<SessionTreeEntry, { type: TType }> => entry.type === type);\n\t}\n\n\tasync getLabel(id: string): Promise<string | undefined> {\n\t\treturn this.labelsById.get(id);\n\t}\n\n\tasync getPathToRoot(leafId: string | null): Promise<SessionTreeEntry[]> {\n\t\tif (leafId === null) return [];\n\t\tconst path: SessionTreeEntry[] = [];\n\t\tlet current = this.byId.get(leafId);\n\t\tif (!current) throw new SessionError(\"not_found\", `Entry ${leafId} not found`);\n\t\twhile (current) {\n\t\t\tpath.unshift(current);\n\t\t\tif (!current.parentId) break;\n\t\t\tconst parent = this.byId.get(current.parentId);\n\t\t\tif (!parent) throw new SessionError(\"invalid_session\", `Entry ${current.parentId} not found`);\n\t\t\tcurrent = parent;\n\t\t}\n\t\treturn path;\n\t}\n\n\tasync getEntries(): Promise<SessionTreeEntry[]> {\n\t\treturn [...this.entries];\n\t}\n}\n"]}
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AAC,CAAC;YAC9F,OAAO,GAAG,MAAM,CAAC;QAClB,CAAC;QACD,OAAO,IAAI,CAAC;IAAA,CACZ;IAED,KAAK,CAAC,UAAU,GAAgC;QAC/C,OAAO,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC;IAAA,CACzB;CACD","sourcesContent":["import {\n\ttype LeafEntry,\n\tSessionError,\n\ttype SessionMetadata,\n\ttype SessionStorage,\n\ttype SessionTreeEntry,\n} from \"../types.js\";\nimport { uuidv7 } from \"./uuid.js\";\n\nfunction updateLabelCache(labelsById: Map<string, string>, entry: SessionTreeEntry): void {\n\tif (entry.type !== \"label\") return;\n\tconst label = entry.label?.trim();\n\tif (label) {\n\t\tlabelsById.set(entry.targetId, label);\n\t} else {\n\t\tlabelsById.delete(entry.targetId);\n\t}\n}\n\nfunction buildLabelsById(entries: SessionTreeEntry[]): Map<string, string> {\n\tconst labelsById = new Map<string, string>();\n\tfor (const entry of entries) {\n\t\tupdateLabelCache(labelsById, entry);\n\t}\n\treturn labelsById;\n}\n\nfunction generateEntryId(byId: { has(id: string): boolean }): string {\n\tfor (let i = 0; i < 100; i++) {\n\t\tconst id = uuidv7().slice(0, 8);\n\t\tif (!byId.has(id)) return id;\n\t}\n\treturn uuidv7();\n}\n\nfunction leafIdAfterEntry(entry: SessionTreeEntry): string | null {\n\treturn entry.type === \"leaf\" ? entry.targetId : entry.id;\n}\n\nexport class InMemorySessionStorage<TMetadata extends SessionMetadata = SessionMetadata>\n\timplements SessionStorage<TMetadata>\n{\n\tprivate readonly metadata: TMetadata;\n\tprivate entries: SessionTreeEntry[];\n\tprivate byId: Map<string, SessionTreeEntry>;\n\tprivate labelsById: Map<string, string>;\n\tprivate leafId: string | null;\n\n\tconstructor(options?: { entries?: SessionTreeEntry[]; metadata?: TMetadata }) {\n\t\tthis.entries = options?.entries ? [...options.entries] : [];\n\t\tthis.byId = new Map(this.entries.map((entry) => [entry.id, entry]));\n\t\tthis.labelsById = buildLabelsById(this.entries);\n\t\tthis.leafId = null;\n\t\tfor (const entry of this.entries) this.leafId = leafIdAfterEntry(entry);\n\t\tif (this.leafId !== null && !this.byId.has(this.leafId)) {\n\t\t\tthrow new SessionError(\"invalid_session\", `Entry ${this.leafId} not found`);\n\t\t}\n\t\tthis.metadata = options?.metadata ?? ({ id: uuidv7(), createdAt: new Date().toISOString() } as TMetadata);\n\t}\n\n\tasync getMetadata(): Promise<TMetadata> {\n\t\treturn this.metadata;\n\t}\n\n\tasync getLeafId(): Promise<string | null> {\n\t\tif (this.leafId !== null && !this.byId.has(this.leafId)) {\n\t\t\tthrow new SessionError(\"invalid_session\", `Entry ${this.leafId} not found`);\n\t\t}\n\t\treturn this.leafId;\n\t}\n\n\tasync setLeafId(leafId: string | null): Promise<void> {\n\t\tif (leafId !== null && !this.byId.has(leafId)) {\n\t\t\tthrow new SessionError(\"not_found\", `Entry ${leafId} not found`);\n\t\t}\n\t\tconst entry: LeafEntry = {\n\t\t\ttype: \"leaf\",\n\t\t\tid: generateEntryId(this.byId),\n\t\t\tparentId: this.leafId,\n\t\t\ttimestamp: new Date().toISOString(),\n\t\t\ttargetId: leafId,\n\t\t};\n\t\tthis.entries.push(entry);\n\t\tthis.byId.set(entry.id, entry);\n\t\tthis.leafId = leafId;\n\t}\n\n\tasync createEntryId(): Promise<string> {\n\t\treturn generateEntryId(this.byId);\n\t}\n\n\tasync appendEntry(entry: SessionTreeEntry): Promise<void> {\n\t\tthis.entries.push(entry);\n\t\tthis.byId.set(entry.id, entry);\n\t\tupdateLabelCache(this.labelsById, entry);\n\t\tthis.leafId = leafIdAfterEntry(entry);\n\t}\n\n\tasync getEntry(id: string): Promise<SessionTreeEntry | undefined> {\n\t\treturn this.byId.get(id);\n\t}\n\n\tasync findEntries<TType extends SessionTreeEntry[\"type\"]>(\n\t\ttype: TType,\n\t): Promise<Array<Extract<SessionTreeEntry, { type: TType }>>> {\n\t\treturn this.entries.filter((entry): entry is Extract<SessionTreeEntry, { type: TType }> => entry.type === type);\n\t}\n\n\tasync getLabel(id: string): Promise<string | undefined> {\n\t\treturn this.labelsById.get(id);\n\t}\n\n\tasync getPathToRoot(leafId: string | null): Promise<SessionTreeEntry[]> {\n\t\tif (leafId === null) return [];\n\t\tconst path: SessionTreeEntry[] = [];\n\t\tlet current = this.byId.get(leafId);\n\t\tif (!current) throw new SessionError(\"not_found\", `Entry ${leafId} not found`);\n\t\twhile (current) {\n\t\t\tpath.unshift(current);\n\t\t\tif (!current.parentId) break;\n\t\t\tconst parent = this.byId.get(current.parentId);\n\t\t\tif (!parent) throw new SessionError(\"invalid_session\", `Entry ${current.parentId} not found`);\n\t\t\tcurrent = parent;\n\t\t}\n\t\treturn path;\n\t}\n\n\tasync getEntries(): Promise<SessionTreeEntry[]> {\n\t\treturn [...this.entries];\n\t}\n}\n"]}
1
+ {"version":3,"file":"memory-storage.js","sourceRoot":"","sources":["../../../src/harness/session/memory-storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,YAAY,GAIZ,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC,SAAS,gBAAgB,CAAC,UAA+B,EAAE,KAAuB,EAAQ;IACzF,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO;QAAE,OAAO;IACnC,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC;IAClC,IAAI,KAAK,EAAE,CAAC;QACX,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IACvC,CAAC;SAAM,CAAC;QACP,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IACnC,CAAC;AAAA,CACD;AAED,SAAS,eAAe,CAAC,OAA2B,EAAuB;IAC1E,MAAM,UAAU,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC7C,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC7B,gBAAgB,CAAC,UAAU,EAAE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AAO,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACpC,IAAI,CAAC,OAAO;YAAE,MAAM,IAAI,YAAY,CAAC,WAAW,EAAE,SAAS,MAAM,YAAY,CAAC,CAAC;QAC/E,OAAO,OAAO,EAAE,CAAC;YAChB,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;YACtB,IAAI,CAAC,OAAO,CAAC,QAAQ;gBAAE,MAAM;YAC7B,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;YAC/C,IAAI,CAAC,MAAM;gBAAE,MAAM,IAAI,YAAY,CAAC,iBAAiB,EAAE,SAAS,OAAO,CAAC,QAAQ,YAAY,CAAC,CAAC;YAC9F,OAAO,GAAG,MAAM,CAAC;QAClB,CAAC;QACD,OAAO,IAAI,CAAC;IAAA,CACZ;IAED,KAAK,CAAC,UAAU,GAAgC;QAC/C,OAAO,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC;IAAA,CACzB;CACD","sourcesContent":["import {\n\ttype LeafEntry,\n\tSessionError,\n\ttype SessionMetadata,\n\ttype SessionStorage,\n\ttype SessionTreeEntry,\n} from \"../types.ts\";\nimport { uuidv7 } from \"./uuid.ts\";\n\nfunction updateLabelCache(labelsById: Map<string, string>, entry: SessionTreeEntry): void {\n\tif (entry.type !== \"label\") return;\n\tconst label = entry.label?.trim();\n\tif (label) {\n\t\tlabelsById.set(entry.targetId, label);\n\t} else {\n\t\tlabelsById.delete(entry.targetId);\n\t}\n}\n\nfunction buildLabelsById(entries: SessionTreeEntry[]): Map<string, string> {\n\tconst labelsById = new Map<string, string>();\n\tfor (const entry of entries) {\n\t\tupdateLabelCache(labelsById, entry);\n\t}\n\treturn labelsById;\n}\n\nfunction generateEntryId(byId: { has(id: string): boolean }): string {\n\tfor (let i = 0; i < 100; i++) {\n\t\tconst id = uuidv7().slice(0, 8);\n\t\tif (!byId.has(id)) return id;\n\t}\n\treturn uuidv7();\n}\n\nfunction leafIdAfterEntry(entry: SessionTreeEntry): string | null {\n\treturn entry.type === \"leaf\" ? entry.targetId : entry.id;\n}\n\nexport class InMemorySessionStorage<TMetadata extends SessionMetadata = SessionMetadata>\n\timplements SessionStorage<TMetadata>\n{\n\tprivate readonly metadata: TMetadata;\n\tprivate entries: SessionTreeEntry[];\n\tprivate byId: Map<string, SessionTreeEntry>;\n\tprivate labelsById: Map<string, string>;\n\tprivate leafId: string | null;\n\n\tconstructor(options?: { entries?: SessionTreeEntry[]; metadata?: TMetadata }) {\n\t\tthis.entries = options?.entries ? [...options.entries] : [];\n\t\tthis.byId = new Map(this.entries.map((entry) => [entry.id, entry]));\n\t\tthis.labelsById = buildLabelsById(this.entries);\n\t\tthis.leafId = null;\n\t\tfor (const entry of this.entries) this.leafId = leafIdAfterEntry(entry);\n\t\tif (this.leafId !== null && !this.byId.has(this.leafId)) {\n\t\t\tthrow new SessionError(\"invalid_session\", `Entry ${this.leafId} not found`);\n\t\t}\n\t\tthis.metadata = options?.metadata ?? ({ id: uuidv7(), createdAt: new Date().toISOString() } as TMetadata);\n\t}\n\n\tasync getMetadata(): Promise<TMetadata> {\n\t\treturn this.metadata;\n\t}\n\n\tasync getLeafId(): Promise<string | null> {\n\t\tif (this.leafId !== null && !this.byId.has(this.leafId)) {\n\t\t\tthrow new SessionError(\"invalid_session\", `Entry ${this.leafId} not found`);\n\t\t}\n\t\treturn this.leafId;\n\t}\n\n\tasync setLeafId(leafId: string | null): Promise<void> {\n\t\tif (leafId !== null && !this.byId.has(leafId)) {\n\t\t\tthrow new SessionError(\"not_found\", `Entry ${leafId} not found`);\n\t\t}\n\t\tconst entry: LeafEntry = {\n\t\t\ttype: \"leaf\",\n\t\t\tid: generateEntryId(this.byId),\n\t\t\tparentId: this.leafId,\n\t\t\ttimestamp: new Date().toISOString(),\n\t\t\ttargetId: leafId,\n\t\t};\n\t\tthis.entries.push(entry);\n\t\tthis.byId.set(entry.id, entry);\n\t\tthis.leafId = leafId;\n\t}\n\n\tasync createEntryId(): Promise<string> {\n\t\treturn generateEntryId(this.byId);\n\t}\n\n\tasync appendEntry(entry: SessionTreeEntry): Promise<void> {\n\t\tthis.entries.push(entry);\n\t\tthis.byId.set(entry.id, entry);\n\t\tupdateLabelCache(this.labelsById, entry);\n\t\tthis.leafId = leafIdAfterEntry(entry);\n\t}\n\n\tasync getEntry(id: string): Promise<SessionTreeEntry | undefined> {\n\t\treturn this.byId.get(id);\n\t}\n\n\tasync findEntries<TType extends SessionTreeEntry[\"type\"]>(\n\t\ttype: TType,\n\t): Promise<Array<Extract<SessionTreeEntry, { type: TType }>>> {\n\t\treturn this.entries.filter((entry): entry is Extract<SessionTreeEntry, { type: TType }> => entry.type === type);\n\t}\n\n\tasync getLabel(id: string): Promise<string | undefined> {\n\t\treturn this.labelsById.get(id);\n\t}\n\n\tasync getPathToRoot(leafId: string | null): Promise<SessionTreeEntry[]> {\n\t\tif (leafId === null) return [];\n\t\tconst path: SessionTreeEntry[] = [];\n\t\tlet current = this.byId.get(leafId);\n\t\tif (!current) throw new SessionError(\"not_found\", `Entry ${leafId} not found`);\n\t\twhile (current) {\n\t\t\tpath.unshift(current);\n\t\t\tif (!current.parentId) break;\n\t\t\tconst parent = this.byId.get(current.parentId);\n\t\t\tif (!parent) throw new SessionError(\"invalid_session\", `Entry ${current.parentId} not found`);\n\t\t\tcurrent = parent;\n\t\t}\n\t\treturn path;\n\t}\n\n\tasync getEntries(): Promise<SessionTreeEntry[]> {\n\t\treturn [...this.entries];\n\t}\n}\n"]}
@@ -0,0 +1,20 @@
1
+ import type { JsonlSessionCreateOptions, JsonlSessionListOptions, JsonlSessionMetadata, JsonlSessionRepoApi, Session } from "../../types.js";
2
+ export declare class JsonlSessionRepo implements JsonlSessionRepoApi {
3
+ private sessionsRoot;
4
+ constructor(options: {
5
+ sessionsRoot: string;
6
+ });
7
+ private getSessionDir;
8
+ private createSessionFilePath;
9
+ create(options: JsonlSessionCreateOptions): Promise<Session<JsonlSessionMetadata>>;
10
+ open(metadata: JsonlSessionMetadata): Promise<Session<JsonlSessionMetadata>>;
11
+ list(options?: JsonlSessionListOptions): Promise<JsonlSessionMetadata[]>;
12
+ delete(metadata: JsonlSessionMetadata): Promise<void>;
13
+ fork(sourceMetadata: JsonlSessionMetadata, options: JsonlSessionCreateOptions & {
14
+ entryId?: string;
15
+ position?: "before" | "at";
16
+ id?: string;
17
+ }): Promise<Session<JsonlSessionMetadata>>;
18
+ private listSessionDirs;
19
+ }
20
+ //# sourceMappingURL=jsonl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonl.d.ts","sourceRoot":"","sources":["../../../../src/harness/session/repo/jsonl.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACX,yBAAyB,EACzB,uBAAuB,EACvB,oBAAoB,EACpB,mBAAmB,EACnB,OAAO,EACP,MAAM,gBAAgB,CAAC;AAiBxB,qBAAa,gBAAiB,YAAW,mBAAmB;IAC3D,OAAO,CAAC,YAAY,CAAS;IAE7B,YAAY,OAAO,EAAE;QAAE,YAAY,EAAE,MAAM,CAAA;KAAE,EAE5C;IAED,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,qBAAqB;IAIvB,MAAM,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC,CAWvF;IAEK,IAAI,CAAC,QAAQ,EAAE,oBAAoB,GAAG,OAAO,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC,CAMjF;IAEK,IAAI,CAAC,OAAO,GAAE,uBAA4B,GAAG,OAAO,CAAC,oBAAoB,EAAE,CAAC,CAgBjF;IAEK,MAAM,CAAC,QAAQ,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,CAE1D;IAEK,IAAI,CACT,cAAc,EAAE,oBAAoB,EACpC,OAAO,EAAE,yBAAyB,GAAG;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;QAAC,EAAE,CAAC,EAAE,MAAM,CAAA;KAAE,GAChG,OAAO,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC,CAcxC;YAEa,eAAe;CAK7B","sourcesContent":["import { constants } from \"node:fs\";\nimport { access, mkdir, readdir, rm } from \"node:fs/promises\";\nimport { join, resolve } from \"node:path\";\nimport type {\n\tJsonlSessionCreateOptions,\n\tJsonlSessionListOptions,\n\tJsonlSessionMetadata,\n\tJsonlSessionRepoApi,\n\tSession,\n} from \"../../types.js\";\nimport { JsonlSessionStorage, loadJsonlSessionMetadata } from \"../storage/jsonl.js\";\nimport { createSessionId, createTimestamp, getEntriesToFork, toSession } from \"./shared.js\";\n\nasync function exists(path: string): Promise<boolean> {\n\ttry {\n\t\tawait access(path, constants.F_OK);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nfunction encodeCwd(cwd: string): string {\n\treturn `--${cwd.replace(/^[/\\\\]/, \"\").replace(/[/\\\\:]/g, \"-\")}--`;\n}\n\nexport class JsonlSessionRepo implements JsonlSessionRepoApi {\n\tprivate sessionsRoot: string;\n\n\tconstructor(options: { sessionsRoot: string }) {\n\t\tthis.sessionsRoot = resolve(options.sessionsRoot);\n\t}\n\n\tprivate getSessionDir(cwd: string): string {\n\t\treturn join(this.sessionsRoot, encodeCwd(cwd));\n\t}\n\n\tprivate createSessionFilePath(cwd: string, sessionId: string, timestamp: string): string {\n\t\treturn join(this.getSessionDir(cwd), `${timestamp.replace(/[:.]/g, \"-\")}_${sessionId}.jsonl`);\n\t}\n\n\tasync create(options: JsonlSessionCreateOptions): Promise<Session<JsonlSessionMetadata>> {\n\t\tawait mkdir(this.sessionsRoot, { recursive: true });\n\t\tconst id = options.id ?? createSessionId();\n\t\tconst createdAt = createTimestamp();\n\t\tconst filePath = this.createSessionFilePath(options.cwd, id, createdAt);\n\t\tconst storage = await JsonlSessionStorage.create(filePath, {\n\t\t\tcwd: options.cwd,\n\t\t\tsessionId: id,\n\t\t\tparentSessionPath: options.parentSessionPath,\n\t\t});\n\t\treturn toSession(storage);\n\t}\n\n\tasync open(metadata: JsonlSessionMetadata): Promise<Session<JsonlSessionMetadata>> {\n\t\tif (!(await exists(metadata.path))) {\n\t\t\tthrow new Error(`Session not found: ${metadata.path}`);\n\t\t}\n\t\tconst storage = await JsonlSessionStorage.open(metadata.path);\n\t\treturn toSession(storage);\n\t}\n\n\tasync list(options: JsonlSessionListOptions = {}): Promise<JsonlSessionMetadata[]> {\n\t\tconst dirs = options.cwd ? [this.getSessionDir(options.cwd)] : await this.listSessionDirs();\n\t\tconst sessions: JsonlSessionMetadata[] = [];\n\t\tfor (const dir of dirs) {\n\t\t\tif (!(await exists(dir))) continue;\n\t\t\tconst files = (await readdir(dir)).filter((file) => file.endsWith(\".jsonl\")).map((file) => join(dir, file));\n\t\t\tfor (const filePath of files) {\n\t\t\t\ttry {\n\t\t\t\t\tsessions.push(await loadJsonlSessionMetadata(filePath));\n\t\t\t\t} catch {\n\t\t\t\t\t// Ignore invalid session files when listing a directory.\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tsessions.sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime());\n\t\treturn sessions;\n\t}\n\n\tasync delete(metadata: JsonlSessionMetadata): Promise<void> {\n\t\tawait rm(metadata.path, { force: true });\n\t}\n\n\tasync fork(\n\t\tsourceMetadata: JsonlSessionMetadata,\n\t\toptions: JsonlSessionCreateOptions & { entryId?: string; position?: \"before\" | \"at\"; id?: string },\n\t): Promise<Session<JsonlSessionMetadata>> {\n\t\tconst source = await this.open(sourceMetadata);\n\t\tconst forkedEntries = await getEntriesToFork(source.getStorage(), options);\n\t\tconst id = options.id ?? createSessionId();\n\t\tconst createdAt = createTimestamp();\n\t\tconst storage = await JsonlSessionStorage.create(this.createSessionFilePath(options.cwd, id, createdAt), {\n\t\t\tcwd: options.cwd,\n\t\t\tsessionId: id,\n\t\t\tparentSessionPath: options.parentSessionPath ?? sourceMetadata.path,\n\t\t});\n\t\tfor (const entry of forkedEntries) {\n\t\t\tawait storage.appendEntry(entry);\n\t\t}\n\t\treturn toSession(storage);\n\t}\n\n\tprivate async listSessionDirs(): Promise<string[]> {\n\t\tif (!(await exists(this.sessionsRoot))) return [];\n\t\tconst entries = await readdir(this.sessionsRoot, { withFileTypes: true });\n\t\treturn entries.filter((entry) => entry.isDirectory()).map((entry) => join(this.sessionsRoot, entry.name));\n\t}\n}\n"]}
@@ -0,0 +1,92 @@
1
+ import { constants } from "node:fs";
2
+ import { access, mkdir, readdir, rm } from "node:fs/promises";
3
+ import { join, resolve } from "node:path";
4
+ import { JsonlSessionStorage, loadJsonlSessionMetadata } from "../storage/jsonl.js";
5
+ import { createSessionId, createTimestamp, getEntriesToFork, toSession } from "./shared.js";
6
+ async function exists(path) {
7
+ try {
8
+ await access(path, constants.F_OK);
9
+ return true;
10
+ }
11
+ catch {
12
+ return false;
13
+ }
14
+ }
15
+ function encodeCwd(cwd) {
16
+ return `--${cwd.replace(/^[/\\]/, "").replace(/[/\\:]/g, "-")}--`;
17
+ }
18
+ export class JsonlSessionRepo {
19
+ sessionsRoot;
20
+ constructor(options) {
21
+ this.sessionsRoot = resolve(options.sessionsRoot);
22
+ }
23
+ getSessionDir(cwd) {
24
+ return join(this.sessionsRoot, encodeCwd(cwd));
25
+ }
26
+ createSessionFilePath(cwd, sessionId, timestamp) {
27
+ return join(this.getSessionDir(cwd), `${timestamp.replace(/[:.]/g, "-")}_${sessionId}.jsonl`);
28
+ }
29
+ async create(options) {
30
+ await mkdir(this.sessionsRoot, { recursive: true });
31
+ const id = options.id ?? createSessionId();
32
+ const createdAt = createTimestamp();
33
+ const filePath = this.createSessionFilePath(options.cwd, id, createdAt);
34
+ const storage = await JsonlSessionStorage.create(filePath, {
35
+ cwd: options.cwd,
36
+ sessionId: id,
37
+ parentSessionPath: options.parentSessionPath,
38
+ });
39
+ return toSession(storage);
40
+ }
41
+ async open(metadata) {
42
+ if (!(await exists(metadata.path))) {
43
+ throw new Error(`Session not found: ${metadata.path}`);
44
+ }
45
+ const storage = await JsonlSessionStorage.open(metadata.path);
46
+ return toSession(storage);
47
+ }
48
+ async list(options = {}) {
49
+ const dirs = options.cwd ? [this.getSessionDir(options.cwd)] : await this.listSessionDirs();
50
+ const sessions = [];
51
+ for (const dir of dirs) {
52
+ if (!(await exists(dir)))
53
+ continue;
54
+ const files = (await readdir(dir)).filter((file) => file.endsWith(".jsonl")).map((file) => join(dir, file));
55
+ for (const filePath of files) {
56
+ try {
57
+ sessions.push(await loadJsonlSessionMetadata(filePath));
58
+ }
59
+ catch {
60
+ // Ignore invalid session files when listing a directory.
61
+ }
62
+ }
63
+ }
64
+ sessions.sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime());
65
+ return sessions;
66
+ }
67
+ async delete(metadata) {
68
+ await rm(metadata.path, { force: true });
69
+ }
70
+ async fork(sourceMetadata, options) {
71
+ const source = await this.open(sourceMetadata);
72
+ const forkedEntries = await getEntriesToFork(source.getStorage(), options);
73
+ const id = options.id ?? createSessionId();
74
+ const createdAt = createTimestamp();
75
+ const storage = await JsonlSessionStorage.create(this.createSessionFilePath(options.cwd, id, createdAt), {
76
+ cwd: options.cwd,
77
+ sessionId: id,
78
+ parentSessionPath: options.parentSessionPath ?? sourceMetadata.path,
79
+ });
80
+ for (const entry of forkedEntries) {
81
+ await storage.appendEntry(entry);
82
+ }
83
+ return toSession(storage);
84
+ }
85
+ async listSessionDirs() {
86
+ if (!(await exists(this.sessionsRoot)))
87
+ return [];
88
+ const entries = await readdir(this.sessionsRoot, { withFileTypes: true });
89
+ return entries.filter((entry) => entry.isDirectory()).map((entry) => join(this.sessionsRoot, entry.name));
90
+ }
91
+ }
92
+ //# sourceMappingURL=jsonl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonl.js","sourceRoot":"","sources":["../../../../src/harness/session/repo/jsonl.ts"],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AE,OAAO,CAAC,CAAC;QAC3E,MAAM,EAAE,GAAG,OAAO,CAAC,EAAE,IAAI,eAAe,EAAE,CAAC;QAC3C,MAAM,SAAS,GAAG,eAAe,EAAE,CAAC;QACpC,MAAM,OAAO,GAAG,MAAM,mBAAmB,CAAC,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,EAAE,SAAS,CAAC,EAAE;YACxG,GAAG,EAAE,OAAO,CAAC,GAAG;YAChB,SAAS,EAAE,EAAE;YACb,iBAAiB,EAAE,OAAO,CAAC,iBAAiB,IAAI,cAAc,CAAC,IAAI;SACnE,CAAC,CAAC;QACH,KAAK,MAAM,KAAK,IAAI,aAAa,EAAE,CAAC;YACnC,MAAM,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QAClC,CAAC;QACD,OAAO,SAAS,CAAC,OAAO,CAAC,CAAC;IAAA,CAC1B;IAEO,KAAK,CAAC,eAAe,GAAsB;QAClD,IAAI,CAAC,CAAC,MAAM,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;YAAE,OAAO,EAAE,CAAC;QAClD,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;QAC1E,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;IAAA,CAC1G;CACD","sourcesContent":["import { constants } from \"node:fs\";\nimport { access, mkdir, readdir, rm } from \"node:fs/promises\";\nimport { join, resolve } from \"node:path\";\nimport type {\n\tJsonlSessionCreateOptions,\n\tJsonlSessionListOptions,\n\tJsonlSessionMetadata,\n\tJsonlSessionRepoApi,\n\tSession,\n} from \"../../types.js\";\nimport { JsonlSessionStorage, loadJsonlSessionMetadata } from \"../storage/jsonl.js\";\nimport { createSessionId, createTimestamp, getEntriesToFork, toSession } from \"./shared.js\";\n\nasync function exists(path: string): Promise<boolean> {\n\ttry {\n\t\tawait access(path, constants.F_OK);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nfunction encodeCwd(cwd: string): string {\n\treturn `--${cwd.replace(/^[/\\\\]/, \"\").replace(/[/\\\\:]/g, \"-\")}--`;\n}\n\nexport class JsonlSessionRepo implements JsonlSessionRepoApi {\n\tprivate sessionsRoot: string;\n\n\tconstructor(options: { sessionsRoot: string }) {\n\t\tthis.sessionsRoot = resolve(options.sessionsRoot);\n\t}\n\n\tprivate getSessionDir(cwd: string): string {\n\t\treturn join(this.sessionsRoot, encodeCwd(cwd));\n\t}\n\n\tprivate createSessionFilePath(cwd: string, sessionId: string, timestamp: string): string {\n\t\treturn join(this.getSessionDir(cwd), `${timestamp.replace(/[:.]/g, \"-\")}_${sessionId}.jsonl`);\n\t}\n\n\tasync create(options: JsonlSessionCreateOptions): Promise<Session<JsonlSessionMetadata>> {\n\t\tawait mkdir(this.sessionsRoot, { recursive: true });\n\t\tconst id = options.id ?? createSessionId();\n\t\tconst createdAt = createTimestamp();\n\t\tconst filePath = this.createSessionFilePath(options.cwd, id, createdAt);\n\t\tconst storage = await JsonlSessionStorage.create(filePath, {\n\t\t\tcwd: options.cwd,\n\t\t\tsessionId: id,\n\t\t\tparentSessionPath: options.parentSessionPath,\n\t\t});\n\t\treturn toSession(storage);\n\t}\n\n\tasync open(metadata: JsonlSessionMetadata): Promise<Session<JsonlSessionMetadata>> {\n\t\tif (!(await exists(metadata.path))) {\n\t\t\tthrow new Error(`Session not found: ${metadata.path}`);\n\t\t}\n\t\tconst storage = await JsonlSessionStorage.open(metadata.path);\n\t\treturn toSession(storage);\n\t}\n\n\tasync list(options: JsonlSessionListOptions = {}): Promise<JsonlSessionMetadata[]> {\n\t\tconst dirs = options.cwd ? [this.getSessionDir(options.cwd)] : await this.listSessionDirs();\n\t\tconst sessions: JsonlSessionMetadata[] = [];\n\t\tfor (const dir of dirs) {\n\t\t\tif (!(await exists(dir))) continue;\n\t\t\tconst files = (await readdir(dir)).filter((file) => file.endsWith(\".jsonl\")).map((file) => join(dir, file));\n\t\t\tfor (const filePath of files) {\n\t\t\t\ttry {\n\t\t\t\t\tsessions.push(await loadJsonlSessionMetadata(filePath));\n\t\t\t\t} catch {\n\t\t\t\t\t// Ignore invalid session files when listing a directory.\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tsessions.sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime());\n\t\treturn sessions;\n\t}\n\n\tasync delete(metadata: JsonlSessionMetadata): Promise<void> {\n\t\tawait rm(metadata.path, { force: true });\n\t}\n\n\tasync fork(\n\t\tsourceMetadata: JsonlSessionMetadata,\n\t\toptions: JsonlSessionCreateOptions & { entryId?: string; position?: \"before\" | \"at\"; id?: string },\n\t): Promise<Session<JsonlSessionMetadata>> {\n\t\tconst source = await this.open(sourceMetadata);\n\t\tconst forkedEntries = await getEntriesToFork(source.getStorage(), options);\n\t\tconst id = options.id ?? createSessionId();\n\t\tconst createdAt = createTimestamp();\n\t\tconst storage = await JsonlSessionStorage.create(this.createSessionFilePath(options.cwd, id, createdAt), {\n\t\t\tcwd: options.cwd,\n\t\t\tsessionId: id,\n\t\t\tparentSessionPath: options.parentSessionPath ?? sourceMetadata.path,\n\t\t});\n\t\tfor (const entry of forkedEntries) {\n\t\t\tawait storage.appendEntry(entry);\n\t\t}\n\t\treturn toSession(storage);\n\t}\n\n\tprivate async listSessionDirs(): Promise<string[]> {\n\t\tif (!(await exists(this.sessionsRoot))) return [];\n\t\tconst entries = await readdir(this.sessionsRoot, { withFileTypes: true });\n\t\treturn entries.filter((entry) => entry.isDirectory()).map((entry) => join(this.sessionsRoot, entry.name));\n\t}\n}\n"]}
@@ -0,0 +1,18 @@
1
+ import type { Session, SessionMetadata, SessionRepo } from "../../types.js";
2
+ export declare class InMemorySessionRepo implements SessionRepo<SessionMetadata, {
3
+ id?: string;
4
+ }, void> {
5
+ private sessions;
6
+ create(options?: {
7
+ id?: string;
8
+ }): Promise<Session<SessionMetadata>>;
9
+ open(metadata: SessionMetadata): Promise<Session<SessionMetadata>>;
10
+ list(): Promise<SessionMetadata[]>;
11
+ delete(metadata: SessionMetadata): Promise<void>;
12
+ fork(sourceMetadata: SessionMetadata, options: {
13
+ entryId?: string;
14
+ position?: "before" | "at";
15
+ id?: string;
16
+ }): Promise<Session<SessionMetadata>>;
17
+ }
18
+ //# sourceMappingURL=memory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../../../src/harness/session/repo/memory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAI5E,qBAAa,mBAAoB,YAAW,WAAW,CAAC,eAAe,EAAE;IAAE,EAAE,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,IAAI,CAAC;IAC9F,OAAO,CAAC,QAAQ,CAA+C;IAEzD,MAAM,CAAC,OAAO,GAAE;QAAE,EAAE,CAAC,EAAE,MAAM,CAAA;KAAO,GAAG,OAAO,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,CAS7E;IAEK,IAAI,CAAC,QAAQ,EAAE,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,CAMvE;IAEK,IAAI,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC,CAEvC;IAEK,MAAM,CAAC,QAAQ,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAErD;IAEK,IAAI,CACT,cAAc,EAAE,eAAe,EAC/B,OAAO,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;QAAC,EAAE,CAAC,EAAE,MAAM,CAAA;KAAE,GACpE,OAAO,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,CAYnC;CACD","sourcesContent":["import type { Session, SessionMetadata, SessionRepo } from \"../../types.js\";\nimport { InMemorySessionStorage } from \"../storage/memory.js\";\nimport { createSessionId, createTimestamp, getEntriesToFork, toSession } from \"./shared.js\";\n\nexport class InMemorySessionRepo implements SessionRepo<SessionMetadata, { id?: string }, void> {\n\tprivate sessions = new Map<string, Session<SessionMetadata>>();\n\n\tasync create(options: { id?: string } = {}): Promise<Session<SessionMetadata>> {\n\t\tconst metadata: SessionMetadata = {\n\t\t\tid: options.id ?? createSessionId(),\n\t\t\tcreatedAt: createTimestamp(),\n\t\t};\n\t\tconst storage = new InMemorySessionStorage({ metadata });\n\t\tconst session = toSession(storage);\n\t\tthis.sessions.set(metadata.id, session);\n\t\treturn session;\n\t}\n\n\tasync open(metadata: SessionMetadata): Promise<Session<SessionMetadata>> {\n\t\tconst session = this.sessions.get(metadata.id);\n\t\tif (!session) {\n\t\t\tthrow new Error(`Session not found: ${metadata.id}`);\n\t\t}\n\t\treturn session;\n\t}\n\n\tasync list(): Promise<SessionMetadata[]> {\n\t\treturn Promise.all([...this.sessions.values()].map((session) => session.getMetadata()));\n\t}\n\n\tasync delete(metadata: SessionMetadata): Promise<void> {\n\t\tthis.sessions.delete(metadata.id);\n\t}\n\n\tasync fork(\n\t\tsourceMetadata: SessionMetadata,\n\t\toptions: { entryId?: string; position?: \"before\" | \"at\"; id?: string },\n\t): Promise<Session<SessionMetadata>> {\n\t\tconst source = await this.open(sourceMetadata);\n\t\tconst forkedEntries = await getEntriesToFork(source.getStorage(), options);\n\t\tconst metadata: SessionMetadata = {\n\t\t\tid: options.id ?? createSessionId(),\n\t\t\tcreatedAt: createTimestamp(),\n\t\t};\n\t\tconst leafId = forkedEntries[forkedEntries.length - 1]?.id ?? null;\n\t\tconst storage = new InMemorySessionStorage({ metadata, entries: forkedEntries, leafId });\n\t\tconst session = toSession(storage);\n\t\tthis.sessions.set(metadata.id, session);\n\t\treturn session;\n\t}\n}\n"]}
@@ -0,0 +1,42 @@
1
+ import { InMemorySessionStorage } from "../storage/memory.js";
2
+ import { createSessionId, createTimestamp, getEntriesToFork, toSession } from "./shared.js";
3
+ export class InMemorySessionRepo {
4
+ sessions = new Map();
5
+ async create(options = {}) {
6
+ const metadata = {
7
+ id: options.id ?? createSessionId(),
8
+ createdAt: createTimestamp(),
9
+ };
10
+ const storage = new InMemorySessionStorage({ metadata });
11
+ const session = toSession(storage);
12
+ this.sessions.set(metadata.id, session);
13
+ return session;
14
+ }
15
+ async open(metadata) {
16
+ const session = this.sessions.get(metadata.id);
17
+ if (!session) {
18
+ throw new Error(`Session not found: ${metadata.id}`);
19
+ }
20
+ return session;
21
+ }
22
+ async list() {
23
+ return Promise.all([...this.sessions.values()].map((session) => session.getMetadata()));
24
+ }
25
+ async delete(metadata) {
26
+ this.sessions.delete(metadata.id);
27
+ }
28
+ async fork(sourceMetadata, options) {
29
+ const source = await this.open(sourceMetadata);
30
+ const forkedEntries = await getEntriesToFork(source.getStorage(), options);
31
+ const metadata = {
32
+ id: options.id ?? createSessionId(),
33
+ createdAt: createTimestamp(),
34
+ };
35
+ const leafId = forkedEntries[forkedEntries.length - 1]?.id ?? null;
36
+ const storage = new InMemorySessionStorage({ metadata, entries: forkedEntries, leafId });
37
+ const session = toSession(storage);
38
+ this.sessions.set(metadata.id, session);
39
+ return session;
40
+ }
41
+ }
42
+ //# sourceMappingURL=memory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory.js","sourceRoot":"","sources":["../../../../src/harness/session/repo/memory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE5F,MAAM,OAAO,mBAAmB;IACvB,QAAQ,GAAG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C;QAC/C,MAAM,aAAa,GAAG,MAAM,gBAAgB,CAAC,MAAM,CAAC,UAAU,EAAE,EAAE,OAAO,CAAC,CAAC;QAC3E,MAAM,QAAQ,GAAoB;YACjC,EAAE,EAAE,OAAO,CAAC,EAAE,IAAI,eAAe,EAAE;YACnC,SAAS,EAAE,eAAe,EAAE;SAC5B,CAAC;QACF,MAAM,MAAM,GAAG,aAAa,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,EAAE,IAAI,IAAI,CAAC;QACnE,MAAM,OAAO,GAAG,IAAI,sBAAsB,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,CAAC,CAAC;QACzF,MAAM,OAAO,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;QACnC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;QACxC,OAAO,OAAO,CAAC;IAAA,CACf;CACD","sourcesContent":["import type { Session, SessionMetadata, SessionRepo } from \"../../types.js\";\nimport { InMemorySessionStorage } from \"../storage/memory.js\";\nimport { createSessionId, createTimestamp, getEntriesToFork, toSession } from \"./shared.js\";\n\nexport class InMemorySessionRepo implements SessionRepo<SessionMetadata, { id?: string }, void> {\n\tprivate sessions = new Map<string, Session<SessionMetadata>>();\n\n\tasync create(options: { id?: string } = {}): Promise<Session<SessionMetadata>> {\n\t\tconst metadata: SessionMetadata = {\n\t\t\tid: options.id ?? createSessionId(),\n\t\t\tcreatedAt: createTimestamp(),\n\t\t};\n\t\tconst storage = new InMemorySessionStorage({ metadata });\n\t\tconst session = toSession(storage);\n\t\tthis.sessions.set(metadata.id, session);\n\t\treturn session;\n\t}\n\n\tasync open(metadata: SessionMetadata): Promise<Session<SessionMetadata>> {\n\t\tconst session = this.sessions.get(metadata.id);\n\t\tif (!session) {\n\t\t\tthrow new Error(`Session not found: ${metadata.id}`);\n\t\t}\n\t\treturn session;\n\t}\n\n\tasync list(): Promise<SessionMetadata[]> {\n\t\treturn Promise.all([...this.sessions.values()].map((session) => session.getMetadata()));\n\t}\n\n\tasync delete(metadata: SessionMetadata): Promise<void> {\n\t\tthis.sessions.delete(metadata.id);\n\t}\n\n\tasync fork(\n\t\tsourceMetadata: SessionMetadata,\n\t\toptions: { entryId?: string; position?: \"before\" | \"at\"; id?: string },\n\t): Promise<Session<SessionMetadata>> {\n\t\tconst source = await this.open(sourceMetadata);\n\t\tconst forkedEntries = await getEntriesToFork(source.getStorage(), options);\n\t\tconst metadata: SessionMetadata = {\n\t\t\tid: options.id ?? createSessionId(),\n\t\t\tcreatedAt: createTimestamp(),\n\t\t};\n\t\tconst leafId = forkedEntries[forkedEntries.length - 1]?.id ?? null;\n\t\tconst storage = new InMemorySessionStorage({ metadata, entries: forkedEntries, leafId });\n\t\tconst session = toSession(storage);\n\t\tthis.sessions.set(metadata.id, session);\n\t\treturn session;\n\t}\n}\n"]}
@@ -0,0 +1,10 @@
1
+ import type { SessionMetadata, SessionStorage, SessionTreeEntry } from "../../types.js";
2
+ import { Session } from "../session.js";
3
+ export declare function createSessionId(): string;
4
+ export declare function createTimestamp(): string;
5
+ export declare function toSession<TMetadata extends SessionMetadata>(storage: SessionStorage<TMetadata>): Session<TMetadata>;
6
+ export declare function getEntriesToFork(storage: SessionStorage, options: {
7
+ entryId?: string;
8
+ position?: "before" | "at";
9
+ }): Promise<SessionTreeEntry[]>;
10
+ //# sourceMappingURL=shared.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../../../src/harness/session/repo/shared.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACxF,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAGxC,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAED,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAED,wBAAgB,SAAS,CAAC,SAAS,SAAS,eAAe,EAAE,OAAO,EAAE,cAAc,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC,CAEnH;AAED,wBAAsB,gBAAgB,CACrC,OAAO,EAAE,cAAc,EACvB,OAAO,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAA;CAAE,GACvD,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAgB7B","sourcesContent":["import type { SessionMetadata, SessionStorage, SessionTreeEntry } from \"../../types.js\";\nimport { Session } from \"../session.js\";\nimport { uuidv7 } from \"../uuid.js\";\n\nexport function createSessionId(): string {\n\treturn uuidv7();\n}\n\nexport function createTimestamp(): string {\n\treturn new Date().toISOString();\n}\n\nexport function toSession<TMetadata extends SessionMetadata>(storage: SessionStorage<TMetadata>): Session<TMetadata> {\n\treturn new Session(storage);\n}\n\nexport async function getEntriesToFork(\n\tstorage: SessionStorage,\n\toptions: { entryId?: string; position?: \"before\" | \"at\" },\n): Promise<SessionTreeEntry[]> {\n\tif (!options.entryId) return storage.getEntries();\n\tconst target = await storage.getEntry(options.entryId);\n\tif (!target) {\n\t\tthrow new Error(`Entry ${options.entryId} not found`);\n\t}\n\tlet effectiveLeafId: string | null;\n\tif ((options.position ?? \"before\") === \"at\") {\n\t\teffectiveLeafId = target.id;\n\t} else {\n\t\tif (target.type !== \"message\" || target.message.role !== \"user\") {\n\t\t\tthrow new Error(`Entry ${options.entryId} is not a user message`);\n\t\t}\n\t\teffectiveLeafId = target.parentId;\n\t}\n\treturn storage.getPathToRoot(effectiveLeafId);\n}\n"]}
@@ -0,0 +1,31 @@
1
+ import { Session } from "../session.js";
2
+ import { uuidv7 } from "../uuid.js";
3
+ export function createSessionId() {
4
+ return uuidv7();
5
+ }
6
+ export function createTimestamp() {
7
+ return new Date().toISOString();
8
+ }
9
+ export function toSession(storage) {
10
+ return new Session(storage);
11
+ }
12
+ export async function getEntriesToFork(storage, options) {
13
+ if (!options.entryId)
14
+ return storage.getEntries();
15
+ const target = await storage.getEntry(options.entryId);
16
+ if (!target) {
17
+ throw new Error(`Entry ${options.entryId} not found`);
18
+ }
19
+ let effectiveLeafId;
20
+ if ((options.position ?? "before") === "at") {
21
+ effectiveLeafId = target.id;
22
+ }
23
+ else {
24
+ if (target.type !== "message" || target.message.role !== "user") {
25
+ throw new Error(`Entry ${options.entryId} is not a user message`);
26
+ }
27
+ effectiveLeafId = target.parentId;
28
+ }
29
+ return storage.getPathToRoot(effectiveLeafId);
30
+ }
31
+ //# sourceMappingURL=shared.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../../src/harness/session/repo/shared.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEpC,MAAM,UAAU,eAAe,GAAW;IACzC,OAAO,MAAM,EAAE,CAAC;AAAA,CAChB;AAED,MAAM,UAAU,eAAe,GAAW;IACzC,OAAO,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;AAAA,CAChC;AAED,MAAM,UAAU,SAAS,CAAoC,OAAkC,EAAsB;IACpH,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;AAAA,CAC5B;AAED,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACrC,OAAuB,EACvB,OAAyD,EAC3B;IAC9B,IAAI,CAAC,OAAO,CAAC,OAAO;QAAE,OAAO,OAAO,CAAC,UAAU,EAAE,CAAC;IAClD,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACvD,IAAI,CAAC,MAAM,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,SAAS,OAAO,CAAC,OAAO,YAAY,CAAC,CAAC;IACvD,CAAC;IACD,IAAI,eAA8B,CAAC;IACnC,IAAI,CAAC,OAAO,CAAC,QAAQ,IAAI,QAAQ,CAAC,KAAK,IAAI,EAAE,CAAC;QAC7C,eAAe,GAAG,MAAM,CAAC,EAAE,CAAC;IAC7B,CAAC;SAAM,CAAC;QACP,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;YACjE,MAAM,IAAI,KAAK,CAAC,SAAS,OAAO,CAAC,OAAO,wBAAwB,CAAC,CAAC;QACnE,CAAC;QACD,eAAe,GAAG,MAAM,CAAC,QAAQ,CAAC;IACnC,CAAC;IACD,OAAO,OAAO,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC;AAAA,CAC9C","sourcesContent":["import type { SessionMetadata, SessionStorage, SessionTreeEntry } from \"../../types.js\";\nimport { Session } from \"../session.js\";\nimport { uuidv7 } from \"../uuid.js\";\n\nexport function createSessionId(): string {\n\treturn uuidv7();\n}\n\nexport function createTimestamp(): string {\n\treturn new Date().toISOString();\n}\n\nexport function toSession<TMetadata extends SessionMetadata>(storage: SessionStorage<TMetadata>): Session<TMetadata> {\n\treturn new Session(storage);\n}\n\nexport async function getEntriesToFork(\n\tstorage: SessionStorage,\n\toptions: { entryId?: string; position?: \"before\" | \"at\" },\n): Promise<SessionTreeEntry[]> {\n\tif (!options.entryId) return storage.getEntries();\n\tconst target = await storage.getEntry(options.entryId);\n\tif (!target) {\n\t\tthrow new Error(`Entry ${options.entryId} not found`);\n\t}\n\tlet effectiveLeafId: string | null;\n\tif ((options.position ?? \"before\") === \"at\") {\n\t\teffectiveLeafId = target.id;\n\t} else {\n\t\tif (target.type !== \"message\" || target.message.role !== \"user\") {\n\t\t\tthrow new Error(`Entry ${options.entryId} is not a user message`);\n\t\t}\n\t\teffectiveLeafId = target.parentId;\n\t}\n\treturn storage.getPathToRoot(effectiveLeafId);\n}\n"]}
@@ -1,5 +1,5 @@
1
- import { type FileError, type Result, type SessionMetadata, type SessionStorage, type SessionTreeEntry } from "../types.js";
2
- import { Session } from "./session.js";
1
+ import { type FileError, type Result, type SessionMetadata, type SessionStorage, type SessionTreeEntry } from "../types.ts";
2
+ import { Session } from "./session.ts";
3
3
  export declare function createSessionId(): string;
4
4
  export declare function createTimestamp(): string;
5
5
  export declare function toSession<TMetadata extends SessionMetadata>(storage: SessionStorage<TMetadata>): Session<TMetadata>;