@code-yeongyu/senpi-agent-core 2026.9.12-3 → 2026.9.12

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 (344) hide show
  1. package/README.md +0 -4
  2. package/dist/harness/agent-harness.d.ts +384 -639
  3. package/dist/harness/agent-harness.d.ts.map +1 -1
  4. package/dist/harness/agent-harness.js +250 -5
  5. package/dist/harness/agent-harness.js.map +1 -1
  6. package/dist/harness/compaction/branch-summarization.d.ts +6 -12
  7. package/dist/harness/compaction/branch-summarization.d.ts.map +1 -1
  8. package/dist/harness/compaction/branch-summarization.js +27 -33
  9. package/dist/harness/compaction/branch-summarization.js.map +1 -1
  10. package/dist/harness/compaction/compaction.d.ts +8 -30
  11. package/dist/harness/compaction/compaction.d.ts.map +1 -1
  12. package/dist/harness/compaction/compaction.js +64 -53
  13. package/dist/harness/compaction/compaction.js.map +1 -1
  14. package/dist/harness/env/nodejs.d.ts +28 -25
  15. package/dist/harness/env/nodejs.d.ts.map +1 -1
  16. package/dist/harness/env/nodejs.js +125 -368
  17. package/dist/harness/env/nodejs.js.map +1 -1
  18. package/dist/harness/events.d.ts +38 -20
  19. package/dist/harness/events.d.ts.map +1 -1
  20. package/dist/harness/events.js +55 -233
  21. package/dist/harness/events.js.map +1 -1
  22. package/dist/harness/messages.d.ts +2 -2
  23. package/dist/harness/messages.d.ts.map +1 -1
  24. package/dist/harness/messages.js.map +1 -1
  25. package/dist/harness/prompt-templates.d.ts +2 -3
  26. package/dist/harness/prompt-templates.d.ts.map +1 -1
  27. package/dist/harness/prompt-templates.js +17 -17
  28. package/dist/harness/prompt-templates.js.map +1 -1
  29. package/dist/harness/reducer.d.ts +100 -0
  30. package/dist/harness/reducer.d.ts.map +1 -0
  31. package/dist/harness/reducer.js +420 -0
  32. package/dist/harness/reducer.js.map +1 -0
  33. package/dist/harness/result.d.ts +0 -93
  34. package/dist/harness/result.d.ts.map +1 -1
  35. package/dist/harness/result.js +0 -39
  36. package/dist/harness/result.js.map +1 -1
  37. package/dist/harness/session/context.d.ts +19 -6
  38. package/dist/harness/session/context.d.ts.map +1 -1
  39. package/dist/harness/session/context.js +53 -31
  40. package/dist/harness/session/context.js.map +1 -1
  41. package/dist/harness/session/index.d.ts +5 -9
  42. package/dist/harness/session/index.d.ts.map +1 -1
  43. package/dist/harness/session/index.js +4 -7
  44. package/dist/harness/session/index.js.map +1 -1
  45. package/dist/harness/session/jsonl/codec.d.ts +8 -19
  46. package/dist/harness/session/jsonl/codec.d.ts.map +1 -1
  47. package/dist/harness/session/jsonl/codec.js +219 -34
  48. package/dist/harness/session/jsonl/codec.js.map +1 -1
  49. package/dist/harness/session/jsonl/errors.d.ts +9 -0
  50. package/dist/harness/session/jsonl/errors.d.ts.map +1 -0
  51. package/dist/harness/session/jsonl/errors.js +18 -0
  52. package/dist/harness/session/jsonl/errors.js.map +1 -0
  53. package/dist/harness/session/jsonl/repo.d.ts +24 -27
  54. package/dist/harness/session/jsonl/repo.d.ts.map +1 -1
  55. package/dist/harness/session/jsonl/repo.js +151 -276
  56. package/dist/harness/session/jsonl/repo.js.map +1 -1
  57. package/dist/harness/session/jsonl/storage.d.ts +41 -39
  58. package/dist/harness/session/jsonl/storage.d.ts.map +1 -1
  59. package/dist/harness/session/jsonl/storage.js +196 -175
  60. package/dist/harness/session/jsonl/storage.js.map +1 -1
  61. package/dist/harness/session/jsonl/types.d.ts +22 -23
  62. package/dist/harness/session/jsonl/types.d.ts.map +1 -1
  63. package/dist/harness/session/jsonl/types.js +1 -2
  64. package/dist/harness/session/jsonl/types.js.map +1 -1
  65. package/dist/harness/session/jsonl.d.ts +3 -0
  66. package/dist/harness/session/jsonl.d.ts.map +1 -0
  67. package/dist/harness/session/jsonl.js +2 -0
  68. package/dist/harness/session/jsonl.js.map +1 -0
  69. package/dist/harness/session/memory.d.ts +40 -44
  70. package/dist/harness/session/memory.d.ts.map +1 -1
  71. package/dist/harness/session/memory.js +115 -333
  72. package/dist/harness/session/memory.js.map +1 -1
  73. package/dist/harness/session/session.d.ts +51 -78
  74. package/dist/harness/session/session.d.ts.map +1 -1
  75. package/dist/harness/session/session.js +207 -327
  76. package/dist/harness/session/session.js.map +1 -1
  77. package/dist/harness/session/state.d.ts +65 -0
  78. package/dist/harness/session/state.d.ts.map +1 -0
  79. package/dist/harness/session/state.js +320 -0
  80. package/dist/harness/session/state.js.map +1 -0
  81. package/dist/harness/session/testing/conformance.d.ts +4 -0
  82. package/dist/harness/session/testing/conformance.d.ts.map +1 -0
  83. package/dist/harness/session/testing/conformance.js +762 -0
  84. package/dist/harness/session/testing/conformance.js.map +1 -0
  85. package/dist/harness/session/testing/index.d.ts +2 -9
  86. package/dist/harness/session/testing/index.d.ts.map +1 -1
  87. package/dist/harness/session/testing/index.js +1 -8
  88. package/dist/harness/session/testing/index.js.map +1 -1
  89. package/dist/harness/session/testing/types.d.ts +7 -5
  90. package/dist/harness/session/testing/types.d.ts.map +1 -1
  91. package/dist/harness/session/testing/types.js.map +1 -1
  92. package/dist/harness/session/types.d.ts +265 -425
  93. package/dist/harness/session/types.d.ts.map +1 -1
  94. package/dist/harness/session/types.js +7 -7
  95. package/dist/harness/session/types.js.map +1 -1
  96. package/dist/harness/skills.d.ts +2 -3
  97. package/dist/harness/skills.d.ts.map +1 -1
  98. package/dist/harness/skills.js +26 -29
  99. package/dist/harness/skills.js.map +1 -1
  100. package/dist/harness/telemetry.d.ts +43 -64
  101. package/dist/harness/telemetry.d.ts.map +1 -1
  102. package/dist/harness/telemetry.js +26 -45
  103. package/dist/harness/telemetry.js.map +1 -1
  104. package/dist/harness/tools/bash.d.ts +4 -4
  105. package/dist/harness/tools/bash.d.ts.map +1 -1
  106. package/dist/harness/tools/bash.js +93 -66
  107. package/dist/harness/tools/bash.js.map +1 -1
  108. package/dist/harness/tools/edit.d.ts.map +1 -1
  109. package/dist/harness/tools/edit.js +13 -17
  110. package/dist/harness/tools/edit.js.map +1 -1
  111. package/dist/harness/tools/file-mutation-queue.d.ts +1 -2
  112. package/dist/harness/tools/file-mutation-queue.d.ts.map +1 -1
  113. package/dist/harness/tools/file-mutation-queue.js +5 -5
  114. package/dist/harness/tools/file-mutation-queue.js.map +1 -1
  115. package/dist/harness/tools/path-utils.d.ts +2 -3
  116. package/dist/harness/tools/path-utils.d.ts.map +1 -1
  117. package/dist/harness/tools/path-utils.js +5 -5
  118. package/dist/harness/tools/path-utils.js.map +1 -1
  119. package/dist/harness/tools/read.d.ts +1 -2
  120. package/dist/harness/tools/read.d.ts.map +1 -1
  121. package/dist/harness/tools/read.js +6 -4
  122. package/dist/harness/tools/read.js.map +1 -1
  123. package/dist/harness/tools/write.d.ts.map +1 -1
  124. package/dist/harness/tools/write.js +8 -12
  125. package/dist/harness/tools/write.js.map +1 -1
  126. package/dist/harness/types.d.ts +45 -128
  127. package/dist/harness/types.d.ts.map +1 -1
  128. package/dist/harness/types.js.map +1 -1
  129. package/dist/harness/utils/shell-output.d.ts +5 -19
  130. package/dist/harness/utils/shell-output.d.ts.map +1 -1
  131. package/dist/harness/utils/shell-output.js +192 -65
  132. package/dist/harness/utils/shell-output.js.map +1 -1
  133. package/dist/harness/utils/truncate.d.ts +0 -1
  134. package/dist/harness/utils/truncate.d.ts.map +1 -1
  135. package/dist/harness/utils/truncate.js +1 -1
  136. package/dist/harness/utils/truncate.js.map +1 -1
  137. package/dist/index.d.ts +1 -4
  138. package/dist/index.d.ts.map +1 -1
  139. package/dist/index.js +6 -3
  140. package/dist/index.js.map +1 -1
  141. package/dist/search/index.d.ts +16 -24
  142. package/dist/search/index.d.ts.map +1 -1
  143. package/dist/search/index.js +1 -1
  144. package/dist/search/index.js.map +1 -1
  145. package/dist/search/scanning.d.ts +29 -0
  146. package/dist/search/scanning.d.ts.map +1 -0
  147. package/dist/search/scanning.js +103 -0
  148. package/dist/search/scanning.js.map +1 -0
  149. package/dist/types.d.ts +0 -2
  150. package/dist/types.d.ts.map +1 -1
  151. package/dist/types.js.map +1 -1
  152. package/package.json +6 -27
  153. package/dist/harness/config.d.ts +0 -9
  154. package/dist/harness/config.d.ts.map +0 -1
  155. package/dist/harness/config.js +0 -35
  156. package/dist/harness/config.js.map +0 -1
  157. package/dist/harness/context.d.ts +0 -9
  158. package/dist/harness/context.d.ts.map +0 -1
  159. package/dist/harness/context.js +0 -13
  160. package/dist/harness/context.js.map +0 -1
  161. package/dist/harness/execution/assistant.d.ts +0 -42
  162. package/dist/harness/execution/assistant.d.ts.map +0 -1
  163. package/dist/harness/execution/assistant.js +0 -82
  164. package/dist/harness/execution/assistant.js.map +0 -1
  165. package/dist/harness/execution/effect-gate.d.ts +0 -22
  166. package/dist/harness/execution/effect-gate.d.ts.map +0 -1
  167. package/dist/harness/execution/effect-gate.js +0 -48
  168. package/dist/harness/execution/effect-gate.js.map +0 -1
  169. package/dist/harness/execution/tools.d.ts +0 -67
  170. package/dist/harness/execution/tools.d.ts.map +0 -1
  171. package/dist/harness/execution/tools.js +0 -121
  172. package/dist/harness/execution/tools.js.map +0 -1
  173. package/dist/harness/hooks.d.ts +0 -38
  174. package/dist/harness/hooks.d.ts.map +0 -1
  175. package/dist/harness/hooks.js +0 -404
  176. package/dist/harness/hooks.js.map +0 -1
  177. package/dist/harness/runtime/drive/boundary.d.ts +0 -28
  178. package/dist/harness/runtime/drive/boundary.d.ts.map +0 -1
  179. package/dist/harness/runtime/drive/boundary.js +0 -173
  180. package/dist/harness/runtime/drive/boundary.js.map +0 -1
  181. package/dist/harness/runtime/drive/checkpoint.d.ts +0 -8
  182. package/dist/harness/runtime/drive/checkpoint.d.ts.map +0 -1
  183. package/dist/harness/runtime/drive/checkpoint.js +0 -133
  184. package/dist/harness/runtime/drive/checkpoint.js.map +0 -1
  185. package/dist/harness/runtime/drive/deferred.d.ts +0 -15
  186. package/dist/harness/runtime/drive/deferred.d.ts.map +0 -1
  187. package/dist/harness/runtime/drive/deferred.js +0 -179
  188. package/dist/harness/runtime/drive/deferred.js.map +0 -1
  189. package/dist/harness/runtime/drive/generation.d.ts +0 -8
  190. package/dist/harness/runtime/drive/generation.d.ts.map +0 -1
  191. package/dist/harness/runtime/drive/generation.js +0 -205
  192. package/dist/harness/runtime/drive/generation.js.map +0 -1
  193. package/dist/harness/runtime/drive/reconcile.d.ts +0 -5
  194. package/dist/harness/runtime/drive/reconcile.d.ts.map +0 -1
  195. package/dist/harness/runtime/drive/reconcile.js +0 -140
  196. package/dist/harness/runtime/drive/reconcile.js.map +0 -1
  197. package/dist/harness/runtime/drive/recovery.d.ts +0 -8
  198. package/dist/harness/runtime/drive/recovery.d.ts.map +0 -1
  199. package/dist/harness/runtime/drive/recovery.js +0 -85
  200. package/dist/harness/runtime/drive/recovery.js.map +0 -1
  201. package/dist/harness/runtime/drive/response.d.ts +0 -23
  202. package/dist/harness/runtime/drive/response.d.ts.map +0 -1
  203. package/dist/harness/runtime/drive/response.js +0 -394
  204. package/dist/harness/runtime/drive/response.js.map +0 -1
  205. package/dist/harness/runtime/drive/retry.d.ts +0 -4
  206. package/dist/harness/runtime/drive/retry.d.ts.map +0 -1
  207. package/dist/harness/runtime/drive/retry.js +0 -34
  208. package/dist/harness/runtime/drive/retry.js.map +0 -1
  209. package/dist/harness/runtime/drive/structural.d.ts +0 -32
  210. package/dist/harness/runtime/drive/structural.d.ts.map +0 -1
  211. package/dist/harness/runtime/drive/structural.js +0 -929
  212. package/dist/harness/runtime/drive/structural.js.map +0 -1
  213. package/dist/harness/runtime/drive/terminal.d.ts +0 -7
  214. package/dist/harness/runtime/drive/terminal.d.ts.map +0 -1
  215. package/dist/harness/runtime/drive/terminal.js +0 -49
  216. package/dist/harness/runtime/drive/terminal.js.map +0 -1
  217. package/dist/harness/runtime/drive/tool-placement.d.ts +0 -14
  218. package/dist/harness/runtime/drive/tool-placement.d.ts.map +0 -1
  219. package/dist/harness/runtime/drive/tool-placement.js +0 -244
  220. package/dist/harness/runtime/drive/tool-placement.js.map +0 -1
  221. package/dist/harness/runtime/drive/tools.d.ts +0 -6
  222. package/dist/harness/runtime/drive/tools.d.ts.map +0 -1
  223. package/dist/harness/runtime/drive/tools.js +0 -449
  224. package/dist/harness/runtime/drive/tools.js.map +0 -1
  225. package/dist/harness/runtime/drive.d.ts +0 -6
  226. package/dist/harness/runtime/drive.d.ts.map +0 -1
  227. package/dist/harness/runtime/drive.js +0 -93
  228. package/dist/harness/runtime/drive.js.map +0 -1
  229. package/dist/harness/runtime/harness.d.ts +0 -59
  230. package/dist/harness/runtime/harness.d.ts.map +0 -1
  231. package/dist/harness/runtime/harness.js +0 -302
  232. package/dist/harness/runtime/harness.js.map +0 -1
  233. package/dist/harness/runtime/index.d.ts +0 -2
  234. package/dist/harness/runtime/index.d.ts.map +0 -1
  235. package/dist/harness/runtime/index.js +0 -2
  236. package/dist/harness/runtime/index.js.map +0 -1
  237. package/dist/harness/runtime/lane.d.ts +0 -118
  238. package/dist/harness/runtime/lane.d.ts.map +0 -1
  239. package/dist/harness/runtime/lane.js +0 -1559
  240. package/dist/harness/runtime/lane.js.map +0 -1
  241. package/dist/harness/runtime/progress.d.ts +0 -15
  242. package/dist/harness/runtime/progress.d.ts.map +0 -1
  243. package/dist/harness/runtime/progress.js +0 -66
  244. package/dist/harness/runtime/progress.js.map +0 -1
  245. package/dist/harness/runtime/reducer.d.ts +0 -5
  246. package/dist/harness/runtime/reducer.d.ts.map +0 -1
  247. package/dist/harness/runtime/reducer.js +0 -240
  248. package/dist/harness/runtime/reducer.js.map +0 -1
  249. package/dist/harness/runtime/restore.d.ts +0 -24
  250. package/dist/harness/runtime/restore.d.ts.map +0 -1
  251. package/dist/harness/runtime/restore.js +0 -117
  252. package/dist/harness/runtime/restore.js.map +0 -1
  253. package/dist/harness/runtime/transcript.d.ts +0 -21
  254. package/dist/harness/runtime/transcript.d.ts.map +0 -1
  255. package/dist/harness/runtime/transcript.js +0 -72
  256. package/dist/harness/runtime/transcript.js.map +0 -1
  257. package/dist/harness/runtime/types.d.ts +0 -105
  258. package/dist/harness/runtime/types.d.ts.map +0 -1
  259. package/dist/harness/runtime/types.js +0 -50
  260. package/dist/harness/runtime/types.js.map +0 -1
  261. package/dist/harness/session/commit.d.ts +0 -53
  262. package/dist/harness/session/commit.d.ts.map +0 -1
  263. package/dist/harness/session/commit.js +0 -57
  264. package/dist/harness/session/commit.js.map +0 -1
  265. package/dist/harness/session/fork-policy.d.ts +0 -21
  266. package/dist/harness/session/fork-policy.d.ts.map +0 -1
  267. package/dist/harness/session/fork-policy.js +0 -55
  268. package/dist/harness/session/fork-policy.js.map +0 -1
  269. package/dist/harness/session/fork.d.ts +0 -16
  270. package/dist/harness/session/fork.d.ts.map +0 -1
  271. package/dist/harness/session/fork.js +0 -79
  272. package/dist/harness/session/fork.js.map +0 -1
  273. package/dist/harness/session/in-memory-storage-state.d.ts +0 -39
  274. package/dist/harness/session/in-memory-storage-state.d.ts.map +0 -1
  275. package/dist/harness/session/in-memory-storage-state.js +0 -269
  276. package/dist/harness/session/in-memory-storage-state.js.map +0 -1
  277. package/dist/harness/session/jsonl/fork.d.ts +0 -38
  278. package/dist/harness/session/jsonl/fork.d.ts.map +0 -1
  279. package/dist/harness/session/jsonl/fork.js +0 -266
  280. package/dist/harness/session/jsonl/fork.js.map +0 -1
  281. package/dist/harness/session/jsonl/index.d.ts +0 -4
  282. package/dist/harness/session/jsonl/index.d.ts.map +0 -1
  283. package/dist/harness/session/jsonl/index.js +0 -4
  284. package/dist/harness/session/jsonl/index.js.map +0 -1
  285. package/dist/harness/session/jsonl/io.d.ts +0 -14
  286. package/dist/harness/session/jsonl/io.d.ts.map +0 -1
  287. package/dist/harness/session/jsonl/io.js +0 -86
  288. package/dist/harness/session/jsonl/io.js.map +0 -1
  289. package/dist/harness/session/jsonl/legacy-v3.d.ts +0 -44
  290. package/dist/harness/session/jsonl/legacy-v3.d.ts.map +0 -1
  291. package/dist/harness/session/jsonl/legacy-v3.js +0 -454
  292. package/dist/harness/session/jsonl/legacy-v3.js.map +0 -1
  293. package/dist/harness/session/mutation-line.d.ts +0 -8
  294. package/dist/harness/session/mutation-line.d.ts.map +0 -1
  295. package/dist/harness/session/mutation-line.js +0 -22
  296. package/dist/harness/session/mutation-line.js.map +0 -1
  297. package/dist/harness/session/testing/benchmark/datasets.d.ts +0 -12
  298. package/dist/harness/session/testing/benchmark/datasets.d.ts.map +0 -1
  299. package/dist/harness/session/testing/benchmark/datasets.js +0 -24
  300. package/dist/harness/session/testing/benchmark/datasets.js.map +0 -1
  301. package/dist/harness/session/testing/benchmark/session-repo.d.ts +0 -42
  302. package/dist/harness/session/testing/benchmark/session-repo.d.ts.map +0 -1
  303. package/dist/harness/session/testing/benchmark/session-repo.js +0 -127
  304. package/dist/harness/session/testing/benchmark/session-repo.js.map +0 -1
  305. package/dist/harness/session/testing/benchmark/storage.d.ts +0 -25
  306. package/dist/harness/session/testing/benchmark/storage.d.ts.map +0 -1
  307. package/dist/harness/session/testing/benchmark/storage.js +0 -114
  308. package/dist/harness/session/testing/benchmark/storage.js.map +0 -1
  309. package/dist/harness/session/testing/conformance/session-repo.d.ts +0 -23
  310. package/dist/harness/session/testing/conformance/session-repo.d.ts.map +0 -1
  311. package/dist/harness/session/testing/conformance/session-repo.js +0 -809
  312. package/dist/harness/session/testing/conformance/session-repo.js.map +0 -1
  313. package/dist/harness/session/testing/conformance/storage.d.ts +0 -4
  314. package/dist/harness/session/testing/conformance/storage.d.ts.map +0 -1
  315. package/dist/harness/session/testing/conformance/storage.js +0 -600
  316. package/dist/harness/session/testing/conformance/storage.js.map +0 -1
  317. package/dist/harness/session/testing/gating-storage.d.ts +0 -26
  318. package/dist/harness/session/testing/gating-storage.d.ts.map +0 -1
  319. package/dist/harness/session/testing/gating-storage.js +0 -103
  320. package/dist/harness/session/testing/gating-storage.js.map +0 -1
  321. package/dist/harness/session/testing/instrumented-storage.d.ts +0 -11
  322. package/dist/harness/session/testing/instrumented-storage.d.ts.map +0 -1
  323. package/dist/harness/session/testing/instrumented-storage.js +0 -19
  324. package/dist/harness/session/testing/instrumented-storage.js.map +0 -1
  325. package/dist/harness/session/testing/storage-decorator.d.ts +0 -20
  326. package/dist/harness/session/testing/storage-decorator.d.ts.map +0 -1
  327. package/dist/harness/session/testing/storage-decorator.js +0 -40
  328. package/dist/harness/session/testing/storage-decorator.js.map +0 -1
  329. package/dist/harness/session/values.d.ts +0 -95
  330. package/dist/harness/session/values.d.ts.map +0 -1
  331. package/dist/harness/session/values.js +0 -81
  332. package/dist/harness/session/values.js.map +0 -1
  333. package/dist/harness/utils/adaptive-publisher.d.ts +0 -24
  334. package/dist/harness/utils/adaptive-publisher.d.ts.map +0 -1
  335. package/dist/harness/utils/adaptive-publisher.js +0 -79
  336. package/dist/harness/utils/adaptive-publisher.js.map +0 -1
  337. package/dist/harness/utils/output-capture.d.ts +0 -31
  338. package/dist/harness/utils/output-capture.d.ts.map +0 -1
  339. package/dist/harness/utils/output-capture.js +0 -217
  340. package/dist/harness/utils/output-capture.js.map +0 -1
  341. package/dist/harness/utils/usage.d.ts +0 -4
  342. package/dist/harness/utils/usage.d.ts.map +0 -1
  343. package/dist/harness/utils/usage.js +0 -33
  344. package/dist/harness/utils/usage.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reducer.js","sourceRoot":"","sources":["../../src/harness/reducer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAkCtC,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IAG7C,YAAY,MAAiC,EAAE,OAAe;QAC7D,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;QAClC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACtB,CAAC;CACD;AAuFD,SAAS,OAAO,CAAC,MAAiC,EAAE,OAAe;IAClE,MAAM,IAAI,mBAAmB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAChD,CAAC;AAED,SAAS,QAAQ,CAAC,MAAkB;IACnC,OAAO,OAAO,IAAI,MAAM,IAAI,OAAO,MAA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ClD,OAAO,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC;aACtC,CAAC;QACH,CAAC;IACF,CAAC;IAED,OAAO;QACN,SAAS,EAAE;YACV,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,SAAS,EAAE;gBACV,EAAE,EAAE,OAAO,CAAC,EAAE;gBACd,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,IAAI;gBACzB,MAAM,EAAE,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;gBAC7B,QAAQ;gBACR,IAAI;gBACJ,SAAS,EAAE,eAAe,CAAC,OAAO,CAAC,EAAE,EAAE,gBAAgB,EAAE,UAAU,EAAE,WAAW,EAAE,gBAAgB,CAAC;gBACnG,sBAAsB;gBACtB,YAAY;gBACZ,eAAe;gBACf,aAAa;gBACb,QAAQ;gBACR,oBAAoB;gBACpB,SAAS;gBACT,OAAO;aACP;YACD,cAAc;SACd;QACD,sBAAsB;QACtB,eAAe;KACf,CAAC;AACH,CAAC","sourcesContent":["import type { AssistantMessage, DeferredHandle, StopReason } from \"@earendil-works/pi-ai\";\nimport { Guard } from \"typebox/guard\";\nimport type { AgentMessage, AgentToolCall, ThinkingLevel } from \"../types.ts\";\nimport type {\n\tEntry,\n\tLaneRecord,\n\tOperationStartedRecord,\n\tProvisionedEntry,\n\tQueueEnqueuedRecord,\n\tStepAttemptRecord,\n\tToolStartedRecord,\n\tWriteDeferredRecord,\n} from \"./session/types.ts\";\n\n/**\n * Machine-readable category for a contradiction in a lane's durable recovery\n * slice. These indicate states the single-writer record protocol cannot\n * produce, not ordinary operation failures or incomplete-but-recoverable\n * intent/result prefixes. Restore must reject such states rather than repair or\n * continue it; the accompanying error message supplies human-readable detail.\n */\nexport type RecordLogCorruptionReason =\n\t| \"multiple_open_operations\"\n\t| \"unknown_operation\"\n\t| \"record_after_finish\"\n\t| \"non_consecutive_attempt\"\n\t| \"invalid_compaction_reason\"\n\t| \"queue_after_abort\"\n\t| \"invalid_queue_cancellation\"\n\t| \"inconsistent_step\"\n\t| \"tool_call_mismatch\"\n\t| \"duplicate_tool_invocation\"\n\t| \"provisioned_entry_mismatch\"\n\t| \"invalid_deferred_handle\";\n\nexport class RecordLogCorruption extends Error {\n\treadonly reason: RecordLogCorruptionReason;\n\n\tconstructor(reason: RecordLogCorruptionReason, message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"RecordLogCorruption\";\n\t\tthis.reason = reason;\n\t}\n}\n\nexport interface RecordLogSlice {\n\tlane: string;\n\topenOperations: readonly OperationStartedRecord[];\n\trecords: readonly LaneRecord[];\n\t/** Operation-owned entries plus entries fetched directly by provisioned or referenced ids. */\n\tentries: readonly Entry[];\n}\n\nexport interface EffectiveLaneConfiguration {\n\tmodel: { provider: string; modelId: string };\n\tthinkingLevel: ThinkingLevel;\n\tactiveToolNames: string[];\n}\n\nexport interface TerminalFailureState {\n\tentryId: string;\n\tsource: \"step\" | \"deferred_fetch\";\n\tmessage: AssistantMessage;\n}\n\nexport interface ToolBatchState {\n\tassistantEntryId: string;\n\tcalls: {\n\t\ttoolIndex: number;\n\t\ttoolCall: AgentToolCall;\n\t\tstarted?: ToolStartedRecord;\n\t\tresultExists: boolean;\n\t\tterminate?: boolean;\n\t}[];\n\ttruncated: boolean;\n\tunresolved: boolean;\n}\n\nexport interface LaneState {\n\tlane: string;\n\tleafId: string | null;\n\toperation: null | {\n\t\tid: string;\n\t\tkind: \"run\" | \"compaction\" | \"navigation\";\n\t\tintent: OperationStartedRecord[\"intent\"];\n\t\taborting: boolean;\n\t\tstep: null | {\n\t\t\tkind: \"assistant\" | \"compaction\" | \"branch_summary\";\n\t\t\tattempts: number;\n\t\t\tresultEntryId: string;\n\t\t\tcompactionReason?: \"manual\" | \"threshold\" | \"overflow\";\n\t\t};\n\t\ttoolBatch: ToolBatchState | null;\n\t\tmissingInitialMessages: ProvisionedEntry[];\n\t\tpendingSteer: ProvisionedEntry[];\n\t\tpendingFollowUp: ProvisionedEntry[];\n\t\tpendingWrites: ProvisionedEntry[];\n\t\tdeferred: DeferredHandle | null;\n\t\toverflowRecoveryUsed: boolean;\n\t\tnewestOwn: null | {\n\t\t\tentryId: string;\n\t\t\ttype: Entry[\"type\"];\n\t\t\trole?: AgentMessage[\"role\"];\n\t\t\tstopReason?: StopReason;\n\t\t};\n\t\ttargets: { result?: boolean; summary?: boolean };\n\t};\n\tpendingNextRun: ProvisionedEntry[];\n}\n\nexport interface LaneReductionInput extends RecordLogSlice {\n\tleafId: string | null;\n\t/** Entries appended by the open operation, oldest first. Empty when idle. */\n\townEntries: readonly Entry[];\n\t/** Bounded effective-state lookups at the operation anchor or idle leaf, oldest first. */\n\tconfigurationEntries: readonly Entry[];\n\t/** Harness option fallbacks used when no persisted value exists. */\n\tdefaults: EffectiveLaneConfiguration;\n}\n\nexport interface LaneReductionResult {\n\tlaneState: LaneState;\n\teffectiveConfiguration: EffectiveLaneConfiguration;\n\tterminalFailure: TerminalFailureState | null;\n}\n\ninterface AttemptSeries {\n\trecord: StepAttemptRecord;\n}\n\nfunction corrupt(reason: RecordLogCorruptionReason, message: string): never {\n\tthrow new RecordLogCorruption(reason, message);\n}\n\nfunction hasRunId(record: LaneRecord): record is Exclude<LaneRecord, OperationStartedRecord> & { runId: string } {\n\treturn \"runId\" in record && typeof record.runId === \"string\";\n}\n\nfunction matchesProvisionedEntry(entry: Entry, target: ProvisionedEntry): boolean {\n\tconst { parentId: _parentId, seq: _seq, timestamp: _timestamp, ...payload } = entry;\n\treturn Guard.IsDeepEqual(payload, target);\n}\n\nfunction validateExactProvisionedEntry(entriesById: ReadonlyMap<string, Entry>, target: ProvisionedEntry): void {\n\tconst entry = entriesById.get(target.id);\n\tif (entry && !matchesProvisionedEntry(entry, target)) {\n\t\tcorrupt(\n\t\t\t\"provisioned_entry_mismatch\",\n\t\t\t`Provisioned entry ${target.id} exists with content different from its intent`,\n\t\t);\n\t}\n}\n\nfunction validateResultEntry(\n\tentriesById: ReadonlyMap<string, Entry>,\n\tresultEntryId: string,\n\tmatches: (entry: Entry) => boolean,\n\tdescription: string,\n): void {\n\tconst entry = entriesById.get(resultEntryId);\n\tif (entry && !matches(entry)) {\n\t\tcorrupt(\n\t\t\t\"provisioned_entry_mismatch\",\n\t\t\t`Provisioned ${description} entry ${resultEntryId} exists with different content`,\n\t\t);\n\t}\n}\n\nfunction validateAttemptReason(record: StepAttemptRecord): void {\n\tconst reason = (record as { compactionReason?: unknown }).compactionReason;\n\tif (record.step === \"compaction\") {\n\t\tif (reason !== \"manual\" && reason !== \"threshold\" && reason !== \"overflow\") {\n\t\t\tcorrupt(\"invalid_compaction_reason\", `Compaction attempt ${record.id} has no valid compaction reason`);\n\t\t}\n\t} else if (reason !== undefined) {\n\t\tcorrupt(\"invalid_compaction_reason\", `${record.step} attempt ${record.id} has a compaction reason`);\n\t}\n}\n\nfunction validateAttemptSequence(\n\trecord: StepAttemptRecord,\n\tprevious: AttemptSeries | undefined,\n\tentriesById: ReadonlyMap<string, Entry>,\n): void {\n\tconst previousRecord = previous?.record;\n\tconst previousResult = previousRecord ? entriesById.get(previousRecord.resultEntryId) : undefined;\n\tconst continuesSeries =\n\t\tpreviousRecord !== undefined &&\n\t\tpreviousRecord.step === record.step &&\n\t\t(previousResult === undefined || previousResult.seq >= record.seq);\n\tconst expectedAttempt = continuesSeries ? previousRecord.attempt + 1 : 1;\n\tif (record.attempt !== expectedAttempt) {\n\t\tcorrupt(\n\t\t\t\"non_consecutive_attempt\",\n\t\t\t`${record.step} attempt ${record.id} is ${record.attempt}; expected ${expectedAttempt}`,\n\t\t);\n\t}\n\tif (!continuesSeries || record.step === \"assistant\" || previousRecord === undefined) return;\n\tif (record.resultEntryId !== previousRecord.resultEntryId) {\n\t\tcorrupt(\"inconsistent_step\", `${record.step} attempts disagree on their result entry id`);\n\t}\n\tif (record.compactionReason !== previousRecord.compactionReason) {\n\t\tcorrupt(\"inconsistent_step\", `${record.step} attempts disagree on their compaction reason`);\n\t}\n}\n\nfunction validateAttemptResult(entriesById: ReadonlyMap<string, Entry>, record: StepAttemptRecord): void {\n\tswitch (record.step) {\n\t\tcase \"assistant\":\n\t\t\tvalidateResultEntry(\n\t\t\t\tentriesById,\n\t\t\t\trecord.resultEntryId,\n\t\t\t\t(entry) => entry.type === \"message\" && entry.message.role === \"assistant\",\n\t\t\t\t\"assistant result\",\n\t\t\t);\n\t\t\tbreak;\n\t\tcase \"compaction\":\n\t\t\tvalidateResultEntry(\n\t\t\t\tentriesById,\n\t\t\t\trecord.resultEntryId,\n\t\t\t\t(entry) => entry.type === \"compaction\",\n\t\t\t\t\"compaction result\",\n\t\t\t);\n\t\t\tbreak;\n\t\tcase \"branch_summary\":\n\t\t\tvalidateResultEntry(\n\t\t\t\tentriesById,\n\t\t\t\trecord.resultEntryId,\n\t\t\t\t(entry) => entry.type === \"branch_summary\",\n\t\t\t\t\"branch-summary result\",\n\t\t\t);\n\t\t\tbreak;\n\t}\n}\n\nfunction validateToolStart(\n\trecord: Extract<LaneRecord, { type: \"tool_started\" }>,\n\tentriesById: ReadonlyMap<string, Entry>,\n\tinvocations: Set<string>,\n): void {\n\tconst invocation = `${record.assistantEntryId}\\u0000${record.toolIndex}`;\n\tif (invocations.has(invocation)) {\n\t\tcorrupt(\n\t\t\t\"duplicate_tool_invocation\",\n\t\t\t`Tool invocation ${record.assistantEntryId}:${record.toolIndex} is duplicated`,\n\t\t);\n\t}\n\tinvocations.add(invocation);\n\n\tconst assistantEntry = entriesById.get(record.assistantEntryId);\n\tif (assistantEntry?.type !== \"message\" || assistantEntry.message.role !== \"assistant\") {\n\t\tcorrupt(\"tool_call_mismatch\", `Tool start ${record.id} does not reference an assistant entry`);\n\t}\n\tconst toolCalls = assistantEntry.message.content.filter((content) => content.type === \"toolCall\");\n\tconst toolCall = toolCalls[record.toolIndex];\n\tif (!toolCall || toolCall.id !== record.toolCallId || toolCall.name !== record.toolName) {\n\t\tcorrupt(\"tool_call_mismatch\", `Tool start ${record.id} does not match its assistant tool-call ordinal`);\n\t}\n\n\tvalidateResultEntry(\n\t\tentriesById,\n\t\trecord.resultEntryId,\n\t\t(entry) =>\n\t\t\tentry.type === \"message\" &&\n\t\t\tentry.message.role === \"toolResult\" &&\n\t\t\tentry.message.toolCallId === record.toolCallId &&\n\t\t\tentry.message.toolName === record.toolName,\n\t\t\"tool result\",\n\t);\n}\n\nfunction validateDeferredHandles(entries: Iterable<Entry>): void {\n\tfor (const entry of entries) {\n\t\tif (\n\t\t\tentry.type === \"message\" &&\n\t\t\tentry.message.role === \"assistant\" &&\n\t\t\tentry.message.stopReason === \"deferred\" &&\n\t\t\t!entry.message.deferred\n\t\t) {\n\t\t\tcorrupt(\"invalid_deferred_handle\", `Deferred assistant entry ${entry.id} does not carry a handle`);\n\t\t}\n\t}\n}\n\nfunction validateOperationResult(entriesById: ReadonlyMap<string, Entry>, record: OperationStartedRecord): void {\n\tswitch (record.intent.kind) {\n\t\tcase \"run\":\n\t\t\tfor (const target of record.intent.initialMessages) validateExactProvisionedEntry(entriesById, target);\n\t\t\tbreak;\n\t\tcase \"compaction\":\n\t\t\tvalidateResultEntry(\n\t\t\t\tentriesById,\n\t\t\t\trecord.intent.resultEntryId,\n\t\t\t\t(entry) => entry.type === \"compaction\",\n\t\t\t\t\"manual compaction\",\n\t\t\t);\n\t\t\tbreak;\n\t\tcase \"navigation\":\n\t\t\tif (record.intent.summaryEntryId) {\n\t\t\t\tvalidateResultEntry(\n\t\t\t\t\tentriesById,\n\t\t\t\t\trecord.intent.summaryEntryId,\n\t\t\t\t\t(entry) => entry.type === \"branch_summary\",\n\t\t\t\t\t\"navigation summary\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tbreak;\n\t}\n}\n\n/** Validates a bounded lane recovery slice without reading or mutating session state. */\nexport function validateRecordLog(input: RecordLogSlice): void {\n\tif (input.openOperations.length > 1) {\n\t\tcorrupt(\"multiple_open_operations\", `Lane ${input.lane} has at least two open operations`);\n\t}\n\n\tconst entriesById = new Map(input.entries.map((entry) => [entry.id, entry]));\n\tvalidateDeferredHandles(entriesById.values());\n\tconst starts = new Map<string, OperationStartedRecord>();\n\tconst finishedAt = new Map<string, number>();\n\tconst abortedAt = new Map<string, number>();\n\tconst queueEnqueues = new Map<string, Extract<LaneRecord, { type: \"queue_enqueued\" }>>();\n\tconst latestAttempt = new Map<string, AttemptSeries>();\n\tconst toolInvocations = new Set<string>();\n\tconst records = [...input.records].sort((left, right) => left.seq - right.seq);\n\n\tfor (const record of records) {\n\t\tif (record.type === \"operation_started\") {\n\t\t\tstarts.set(record.id, record);\n\t\t\tvalidateOperationResult(entriesById, record);\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (hasRunId(record)) {\n\t\t\tif (!starts.has(record.runId)) {\n\t\t\t\tcorrupt(\"unknown_operation\", `Record ${record.id} references unknown operation ${record.runId}`);\n\t\t\t}\n\t\t\tconst finishSeq = finishedAt.get(record.runId);\n\t\t\tif (finishSeq !== undefined && record.seq > finishSeq) {\n\t\t\t\tcorrupt(\"record_after_finish\", `Record ${record.id} follows the finish of operation ${record.runId}`);\n\t\t\t}\n\t\t}\n\n\t\tswitch (record.type) {\n\t\t\tcase \"operation_finished\":\n\t\t\t\tfinishedAt.set(record.runId, record.seq);\n\t\t\t\tbreak;\n\t\t\tcase \"abort_requested\":\n\t\t\t\tabortedAt.set(record.runId, record.seq);\n\t\t\t\tbreak;\n\t\t\tcase \"step_attempt\":\n\t\t\t\tvalidateAttemptReason(record);\n\t\t\t\tvalidateAttemptSequence(record, latestAttempt.get(record.runId), entriesById);\n\t\t\t\tvalidateAttemptResult(entriesById, record);\n\t\t\t\tlatestAttempt.set(record.runId, { record });\n\t\t\t\tbreak;\n\t\t\tcase \"tool_started\":\n\t\t\t\tvalidateToolStart(record, entriesById, toolInvocations);\n\t\t\t\tbreak;\n\t\t\tcase \"queue_enqueued\":\n\t\t\t\tif (\n\t\t\t\t\trecord.queue !== \"nextRun\" &&\n\t\t\t\t\tabortedAt.get(record.runId) !== undefined &&\n\t\t\t\t\trecord.seq > abortedAt.get(record.runId)!\n\t\t\t\t) {\n\t\t\t\t\tcorrupt(\"queue_after_abort\", `${record.queue} item ${record.target.id} was enqueued after abort`);\n\t\t\t\t}\n\t\t\t\tqueueEnqueues.set(record.target.id, record);\n\t\t\t\tvalidateExactProvisionedEntry(entriesById, record.target);\n\t\t\t\tbreak;\n\t\t\tcase \"queue_cancelled\": {\n\t\t\t\tconst enqueue = queueEnqueues.get(record.entryId);\n\t\t\t\tif (\n\t\t\t\t\t!enqueue ||\n\t\t\t\t\tenqueue.seq >= record.seq ||\n\t\t\t\t\tenqueue.runId !== record.runId ||\n\t\t\t\t\tentriesById.has(record.entryId)\n\t\t\t\t) {\n\t\t\t\t\tcorrupt(\"invalid_queue_cancellation\", `Queue cancellation ${record.id} has no pending matching enqueue`);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"write_deferred\":\n\t\t\t\tvalidateExactProvisionedEntry(entriesById, record.target);\n\t\t\t\tbreak;\n\t\t\tcase \"usage\":\n\t\t\t\tbreak;\n\t\t}\n\t}\n}\n\nfunction clone<T>(value: T): T {\n\treturn structuredClone(value);\n}\n\nfunction bySequence<T extends { seq: number }>(values: readonly T[]): T[] {\n\treturn [...values].sort((left, right) => left.seq - right.seq);\n}\n\nfunction deriveEffectiveConfiguration(input: LaneReductionInput): EffectiveLaneConfiguration {\n\tlet configuration = clone(input.defaults);\n\tconst entriesById = new Map<string, Entry>();\n\tfor (const entry of [...input.configurationEntries, ...input.ownEntries]) entriesById.set(entry.id, entry);\n\n\tfor (const entry of bySequence([...entriesById.values()])) {\n\t\tswitch (entry.type) {\n\t\t\tcase \"model_change\":\n\t\t\t\tconfiguration = { ...configuration, model: { provider: entry.provider, modelId: entry.modelId } };\n\t\t\t\tbreak;\n\t\t\tcase \"thinking_level_change\":\n\t\t\t\tconfiguration = { ...configuration, thinkingLevel: entry.thinkingLevel as ThinkingLevel };\n\t\t\t\tbreak;\n\t\t\tcase \"configuration_update\":\n\t\t\t\tconfiguration = {\n\t\t\t\t\t...configuration,\n\t\t\t\t\tthinkingLevel: entry.reasoning.effort as ThinkingLevel,\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\tcase \"active_tools_change\":\n\t\t\t\tconfiguration = { ...configuration, activeToolNames: [...entry.activeToolNames] };\n\t\t\t\tbreak;\n\t\t\tcase \"message\":\n\t\t\t\tif (entry.message.role === \"assistant\") {\n\t\t\t\t\tconfiguration = {\n\t\t\t\t\t\t...configuration,\n\t\t\t\t\t\tmodel: { provider: entry.message.provider, modelId: entry.message.model },\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t}\n\t}\n\treturn configuration;\n}\n\nfunction deriveNewestOwn(\n\tentry: Entry | undefined,\n): NonNullable<NonNullable<LaneState[\"operation\"]>[\"newestOwn\"]> | null {\n\tif (!entry) return null;\n\tif (entry.type !== \"message\") return { entryId: entry.id, type: entry.type };\n\tif (entry.message.role !== \"assistant\") {\n\t\treturn { entryId: entry.id, type: entry.type, role: entry.message.role };\n\t}\n\treturn {\n\t\tentryId: entry.id,\n\t\ttype: entry.type,\n\t\trole: entry.message.role,\n\t\tstopReason: entry.message.stopReason,\n\t};\n}\n\nfunction deriveToolBatch(\n\toperationId: string,\n\trecords: readonly LaneRecord[],\n\townEntries: readonly Entry[],\n\tentriesById: ReadonlyMap<string, Entry>,\n\tdeferredWriteIds: ReadonlySet<string>,\n): ToolBatchState | null {\n\tconst assistantEntry = [...ownEntries]\n\t\t.reverse()\n\t\t.find(\n\t\t\t(entry) =>\n\t\t\t\tentry.type === \"message\" &&\n\t\t\t\tentry.message.role === \"assistant\" &&\n\t\t\t\tentry.message.content.some((content) => content.type === \"toolCall\"),\n\t\t);\n\tif (assistantEntry?.type !== \"message\" || assistantEntry.message.role !== \"assistant\") return null;\n\n\tconst toolCalls = assistantEntry.message.content.filter(\n\t\t(content): content is AgentToolCall => content.type === \"toolCall\",\n\t);\n\tconst starts = new Map<number, ToolStartedRecord>();\n\tfor (const record of records) {\n\t\tif (\n\t\t\trecord.type === \"tool_started\" &&\n\t\t\trecord.runId === operationId &&\n\t\t\trecord.assistantEntryId === assistantEntry.id\n\t\t) {\n\t\t\tstarts.set(record.toolIndex, record);\n\t\t}\n\t}\n\n\tconst calls = toolCalls.map((toolCall, toolIndex) => {\n\t\tconst started = starts.get(toolIndex);\n\t\tconst startedResult = started ? entriesById.get(started.resultEntryId) : undefined;\n\t\tconst blockedResult = ownEntries.find(\n\t\t\t(entry) =>\n\t\t\t\tentry.seq > assistantEntry.seq &&\n\t\t\t\t!deferredWriteIds.has(entry.id) &&\n\t\t\t\tentry.type === \"message\" &&\n\t\t\t\tentry.message.role === \"toolResult\" &&\n\t\t\t\tentry.message.toolCallId === toolCall.id,\n\t\t);\n\t\tconst result = startedResult ?? blockedResult;\n\t\treturn {\n\t\t\ttoolIndex,\n\t\t\ttoolCall: clone(toolCall),\n\t\t\t...(started ? { started: clone(started) } : {}),\n\t\t\tresultExists: result !== undefined,\n\t\t\t...(result?.type === \"message\" && result.terminate === true ? { terminate: true } : {}),\n\t\t};\n\t});\n\n\treturn {\n\t\tassistantEntryId: assistantEntry.id,\n\t\tcalls,\n\t\ttruncated: assistantEntry.message.stopReason === \"length\",\n\t\tunresolved: calls.some((call) => !call.resultExists),\n\t};\n}\n\n/** Purely reconstructs one lane's orchestration state from its bounded recovery inputs. */\nexport function reduceLaneState(input: LaneReductionInput): LaneReductionResult {\n\tvalidateRecordLog(input);\n\n\tconst records = bySequence(input.records);\n\tconst ownEntries = bySequence(input.ownEntries);\n\tconst entriesById = new Map<string, Entry>();\n\tfor (const entry of [...input.entries, ...ownEntries]) entriesById.set(entry.id, entry);\n\tconst cancelledQueueIds = new Set(\n\t\trecords.filter((record) => record.type === \"queue_cancelled\").map((record) => record.entryId),\n\t);\n\tconst pendingQueueRecords = records.filter(\n\t\t(record): record is QueueEnqueuedRecord =>\n\t\t\trecord.type === \"queue_enqueued\" &&\n\t\t\t!entriesById.has(record.target.id) &&\n\t\t\t!cancelledQueueIds.has(record.target.id),\n\t);\n\tconst started = input.openOperations[0];\n\tconst capturedInitialMessageIds = new Set(\n\t\tstarted?.intent.kind === \"run\" ? started.intent.initialMessages.map((target) => target.id) : [],\n\t);\n\tconst pendingNextRun = pendingQueueRecords\n\t\t.filter((record) => record.queue === \"nextRun\" && !capturedInitialMessageIds.has(record.target.id))\n\t\t.map((record) => clone(record.target));\n\tconst effectiveConfiguration = deriveEffectiveConfiguration(input);\n\n\tif (!started) {\n\t\treturn {\n\t\t\tlaneState: { lane: input.lane, leafId: input.leafId, operation: null, pendingNextRun },\n\t\t\teffectiveConfiguration,\n\t\t\tterminalFailure: null,\n\t\t};\n\t}\n\n\tconst operationRecords = records.filter((record) =>\n\t\trecord.type === \"operation_started\" ? record.id === started.id : \"runId\" in record && record.runId === started.id,\n\t);\n\tconst aborting = operationRecords.some((record) => record.type === \"abort_requested\");\n\tconst pendingSteer = aborting\n\t\t? []\n\t\t: pendingQueueRecords\n\t\t\t\t.filter((record) => record.queue === \"steer\" && record.runId === started.id)\n\t\t\t\t.map((record) => clone(record.target));\n\tconst pendingFollowUp = aborting\n\t\t? []\n\t\t: pendingQueueRecords\n\t\t\t\t.filter((record) => record.queue === \"followUp\" && record.runId === started.id)\n\t\t\t\t.map((record) => clone(record.target));\n\tconst pendingWrites = operationRecords\n\t\t.filter(\n\t\t\t(record): record is WriteDeferredRecord =>\n\t\t\t\trecord.type === \"write_deferred\" && !entriesById.has(record.target.id),\n\t\t)\n\t\t.map((record) => clone(record.target));\n\tconst missingInitialMessages =\n\t\tstarted.intent.kind === \"run\"\n\t\t\t? started.intent.initialMessages.filter((target) => !entriesById.has(target.id)).map(clone)\n\t\t\t: [];\n\n\tconst newestAttempt = operationRecords.filter((record) => record.type === \"step_attempt\").at(-1);\n\tconst step =\n\t\tnewestAttempt && !entriesById.has(newestAttempt.resultEntryId)\n\t\t\t? {\n\t\t\t\t\tkind: newestAttempt.step,\n\t\t\t\t\tattempts: newestAttempt.attempt,\n\t\t\t\t\tresultEntryId: newestAttempt.resultEntryId,\n\t\t\t\t\t...(newestAttempt.step === \"compaction\" ? { compactionReason: newestAttempt.compactionReason } : {}),\n\t\t\t\t}\n\t\t\t: null;\n\n\tconst consumedInputIds = new Set<string>();\n\tif (started.intent.kind === \"run\") {\n\t\tfor (const target of started.intent.initialMessages) consumedInputIds.add(target.id);\n\t}\n\tfor (const record of operationRecords) {\n\t\tif (record.type === \"queue_enqueued\" && record.queue !== \"nextRun\") consumedInputIds.add(record.target.id);\n\t}\n\tlet newestConsumedInputSequence = Number.NEGATIVE_INFINITY;\n\tfor (const id of consumedInputIds) {\n\t\tconst entry = entriesById.get(id);\n\t\tif (entry?.type === \"message\") newestConsumedInputSequence = Math.max(newestConsumedInputSequence, entry.seq);\n\t}\n\tconst overflowRecoveryUsed = operationRecords.some(\n\t\t(record) =>\n\t\t\trecord.type === \"step_attempt\" &&\n\t\t\trecord.step === \"compaction\" &&\n\t\t\trecord.compactionReason === \"overflow\" &&\n\t\t\trecord.seq > newestConsumedInputSequence,\n\t);\n\n\tconst newestOwnEntry = ownEntries.at(-1);\n\tconst newestOwn = deriveNewestOwn(newestOwnEntry);\n\tconst deferred =\n\t\tnewestOwnEntry?.type === \"message\" &&\n\t\tnewestOwnEntry.message.role === \"assistant\" &&\n\t\tnewestOwnEntry.message.stopReason === \"deferred\" &&\n\t\tnewestOwnEntry.message.deferred\n\t\t\t? clone(newestOwnEntry.message.deferred)\n\t\t\t: null;\n\tconst targets: { result?: boolean; summary?: boolean } = {};\n\tif (started.intent.kind === \"compaction\") {\n\t\ttargets.result = entriesById.has(started.intent.resultEntryId);\n\t} else if (started.intent.kind === \"navigation\" && started.intent.summaryEntryId) {\n\t\ttargets.summary = entriesById.has(started.intent.summaryEntryId);\n\t}\n\n\tconst deferredWriteIds = new Set(\n\t\toperationRecords.filter((record) => record.type === \"write_deferred\").map((record) => record.target.id),\n\t);\n\tlet terminalFailure: TerminalFailureState | null = null;\n\tif (\n\t\tnewestOwnEntry?.type === \"message\" &&\n\t\tnewestOwnEntry.message.role === \"assistant\" &&\n\t\tnewestOwnEntry.message.stopReason === \"error\" &&\n\t\t!deferredWriteIds.has(newestOwnEntry.id)\n\t) {\n\t\tconst producedByStep = operationRecords.some(\n\t\t\t(record) => record.type === \"step_attempt\" && record.resultEntryId === newestOwnEntry.id,\n\t\t);\n\t\tconst previousOwnEntry = ownEntries.at(-2);\n\t\tconst producedByDeferredFetch =\n\t\t\toperationRecords.some(\n\t\t\t\t(record) =>\n\t\t\t\t\trecord.type === \"usage\" && record.cause === \"deferred_fetch\" && record.entryId === newestOwnEntry.id,\n\t\t\t) ||\n\t\t\t(previousOwnEntry?.type === \"message\" &&\n\t\t\t\tpreviousOwnEntry.message.role === \"assistant\" &&\n\t\t\t\tpreviousOwnEntry.message.stopReason === \"deferred\");\n\t\tif (producedByStep || producedByDeferredFetch) {\n\t\t\tterminalFailure = {\n\t\t\t\tentryId: newestOwnEntry.id,\n\t\t\t\tsource: producedByStep ? \"step\" : \"deferred_fetch\",\n\t\t\t\tmessage: clone(newestOwnEntry.message),\n\t\t\t};\n\t\t}\n\t}\n\n\treturn {\n\t\tlaneState: {\n\t\t\tlane: input.lane,\n\t\t\tleafId: input.leafId,\n\t\t\toperation: {\n\t\t\t\tid: started.id,\n\t\t\t\tkind: started.intent.kind,\n\t\t\t\tintent: clone(started.intent),\n\t\t\t\taborting,\n\t\t\t\tstep,\n\t\t\t\ttoolBatch: deriveToolBatch(started.id, operationRecords, ownEntries, entriesById, deferredWriteIds),\n\t\t\t\tmissingInitialMessages,\n\t\t\t\tpendingSteer,\n\t\t\t\tpendingFollowUp,\n\t\t\t\tpendingWrites,\n\t\t\t\tdeferred,\n\t\t\t\toverflowRecoveryUsed,\n\t\t\t\tnewestOwn,\n\t\t\t\ttargets,\n\t\t\t},\n\t\t\tpendingNextRun,\n\t\t},\n\t\teffectiveConfiguration,\n\t\tterminalFailure,\n\t};\n}\n"]}
@@ -31,103 +31,10 @@ export interface TaggedErrorFactory<Tag extends string> {
31
31
  is(value: unknown): value is TaggedErrorValue<Tag>;
32
32
  }
33
33
  export declare function TaggedError<Tag extends string>(tag: Tag): TaggedErrorFactory<Tag>;
34
- declare const LaneBusy_base: TaggedErrorFactory<"LaneBusy">;
35
- export declare class LaneBusy extends LaneBusy_base<{
36
- lane: string;
37
- operationId: string;
38
- operationKind: "run" | "compaction" | "navigation";
39
- message: string;
40
- }> {
41
- }
42
- declare const OperationMismatch_base: TaggedErrorFactory<"OperationMismatch">;
43
- export declare class OperationMismatch extends OperationMismatch_base<{
44
- lane: string;
45
- expectedOperationId: string;
46
- currentOperationId?: string;
47
- lastOperationId?: string;
48
- message: string;
49
- }> {
50
- }
51
- declare const NoActiveRun_base: TaggedErrorFactory<"NoActiveRun">;
52
- export declare class NoActiveRun extends NoActiveRun_base<{
53
- lane: string;
54
- message: string;
55
- }> {
56
- }
57
- declare const NoActiveOperation_base: TaggedErrorFactory<"NoActiveOperation">;
58
- export declare class NoActiveOperation extends NoActiveOperation_base<{
59
- lane: string;
60
- message: string;
61
- }> {
62
- }
63
- declare const NothingToResume_base: TaggedErrorFactory<"NothingToResume">;
64
- export declare class NothingToResume extends NothingToResume_base<{
65
- lane: string;
66
- message: string;
67
- }> {
68
- }
69
- declare const NothingToCompact_base: TaggedErrorFactory<"NothingToCompact">;
70
- export declare class NothingToCompact extends NothingToCompact_base<{
71
- lane: string;
72
- message: string;
73
- }> {
74
- }
75
- declare const InvalidMessage_base: TaggedErrorFactory<"InvalidMessage">;
76
- export declare class InvalidMessage extends InvalidMessage_base<{
77
- lane: string;
78
- reason: string;
79
- message: string;
80
- }> {
81
- }
82
- declare const InvalidNavigation_base: TaggedErrorFactory<"InvalidNavigation">;
83
- export declare class InvalidNavigation extends InvalidNavigation_base<{
84
- lane: string;
85
- reason: string;
86
- message: string;
87
- }> {
88
- }
89
- declare const UnknownSkill_base: TaggedErrorFactory<"UnknownSkill">;
90
- export declare class UnknownSkill extends UnknownSkill_base<{
91
- name: string;
92
- message: string;
93
- }> {
94
- }
95
- declare const UnknownTemplate_base: TaggedErrorFactory<"UnknownTemplate">;
96
- export declare class UnknownTemplate extends UnknownTemplate_base<{
97
- name: string;
98
- message: string;
99
- }> {
100
- }
101
- declare const UnknownTarget_base: TaggedErrorFactory<"UnknownTarget">;
102
- export declare class UnknownTarget extends UnknownTarget_base<{
103
- targetId: string;
104
- message: string;
105
- }> {
106
- }
107
- declare const InvalidLane_base: TaggedErrorFactory<"InvalidLane">;
108
- export declare class InvalidLane extends InvalidLane_base<{
109
- lane: string;
110
- reason: string;
111
- message: string;
112
- }> {
113
- }
114
- declare const Closed_base: TaggedErrorFactory<"Closed">;
115
- export declare class Closed extends Closed_base<{
116
- message: string;
117
- }> {
118
- }
119
- export declare class HarnessFault extends Error {
120
- readonly cause: unknown;
121
- constructor(message: string, cause: unknown);
122
- }
123
- export declare class HarnessClosed extends Error {
124
- constructor();
125
- }
126
34
  export type ErrorMatchers<TError extends TaggedErrorValue<string>, TValue> = {
127
35
  [Tag in TError["_tag"]]: (error: Extract<TError, {
128
36
  _tag: Tag;
129
37
  }>) => TValue;
130
38
  };
131
39
  export declare function matchError<TError extends TaggedErrorValue<string>, TValue>(error: TError, matchers: ErrorMatchers<TError, TValue>): TValue;
132
- export {};
133
40
  //# sourceMappingURL=result.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"result.d.ts","sourceRoot":"","sources":["../../src/harness/result.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,MAAM,CAAC,MAAM,EAAE,MAAM,IAAI;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEhG,eAAO,MAAM,MAAM;IAClB,EAAE,CAAC,MAAM,SAAS,MAAM,GAAG,MAAM,CAAC,MAAM,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AAS,gBAAgB,CAAC,MAAM,CAAC,EAAE,MAAM,IAAI;KAC3E,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,GAAG,CAAA;KAAE,CAAC,KAAK,MAAM;CAC1E,CAAC;AAEF,wBAAgB,UAAU,CAAC,MAAM,SAAS,gBAAgB,CAAC,MAAM,CAAC,EAAE,MAAM,EACzE,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,aAAa,CAAC,MAAM,EAAE,MAAM,CAAC,GACrC,MAAM,CAGR"}
@@ -34,45 +34,6 @@ export function TaggedError(tag) {
34
34
  }
35
35
  return TaggedErrorClass;
36
36
  }
37
- export class LaneBusy extends TaggedError("LaneBusy") {
38
- }
39
- export class OperationMismatch extends TaggedError("OperationMismatch") {
40
- }
41
- export class NoActiveRun extends TaggedError("NoActiveRun") {
42
- }
43
- export class NoActiveOperation extends TaggedError("NoActiveOperation") {
44
- }
45
- export class NothingToResume extends TaggedError("NothingToResume") {
46
- }
47
- export class NothingToCompact extends TaggedError("NothingToCompact") {
48
- }
49
- export class InvalidMessage extends TaggedError("InvalidMessage") {
50
- }
51
- export class InvalidNavigation extends TaggedError("InvalidNavigation") {
52
- }
53
- export class UnknownSkill extends TaggedError("UnknownSkill") {
54
- }
55
- export class UnknownTemplate extends TaggedError("UnknownTemplate") {
56
- }
57
- export class UnknownTarget extends TaggedError("UnknownTarget") {
58
- }
59
- export class InvalidLane extends TaggedError("InvalidLane") {
60
- }
61
- export class Closed extends TaggedError("Closed") {
62
- }
63
- export class HarnessFault extends Error {
64
- constructor(message, cause) {
65
- super(message);
66
- this.name = "HarnessFault";
67
- this.cause = cause;
68
- }
69
- }
70
- export class HarnessClosed extends Error {
71
- constructor() {
72
- super("AgentHarness was closed while the operation was active");
73
- this.name = "HarnessClosed";
74
- }
75
- }
76
37
  export function matchError(error, matchers) {
77
38
  const matcher = matchers[error._tag];
78
39
  return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B,KAAa,EACb,QAAuC;IAEvC,MAAM,OAAO,GAAI,QAAiE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC/F,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC","sourcesContent":["export type Result<TValue, TError> = { ok: true; value: TValue } | { ok: false; error: TError };\n\nexport const Result = {\n\tok<TValue>(value: TValue): Result<TValue, never> {\n\t\treturn { ok: true, value };\n\t},\n\terr<TError>(error: TError): Result<never, TError> {\n\t\treturn { ok: false, error };\n\t},\n\tisOk<TValue, TError>(result: Result<TValue, TError>): result is { ok: true; value: TValue } {\n\t\treturn result.ok;\n\t},\n\tisErr<TValue, TError>(result: Result<TValue, TError>): result is { ok: false; error: TError } {\n\t\treturn !result.ok;\n\t},\n};\n\nexport interface TaggedErrorValue<Tag extends string> extends Error {\n\treadonly _tag: Tag;\n\ttoJSON(): { _tag: Tag; message: string } & Record<string, unknown>;\n}\n\nexport interface TaggedErrorFactory<Tag extends string> {\n\tnew <Props extends { message: string }>(props: Props): TaggedErrorValue<Tag> & Readonly<Props>;\n\tis(value: unknown): value is TaggedErrorValue<Tag>;\n}\n\nexport function TaggedError<Tag extends string>(tag: Tag): TaggedErrorFactory<Tag> {\n\tclass TaggedErrorClass extends Error {\n\t\treadonly _tag = tag;\n\n\t\tconstructor(props: { message: string } & Record<string, unknown>) {\n\t\t\tsuper(props.message);\n\t\t\tthis.name = tag;\n\t\t\tObject.assign(this, props);\n\t\t}\n\n\t\ttoJSON(): { _tag: Tag; message: string } & Record<string, unknown> {\n\t\t\tconst payload: Record<string, unknown> = {};\n\t\t\tfor (const key of Object.keys(this)) {\n\t\t\t\tif (key !== \"_tag\") payload[key] = (this as unknown as Record<string, unknown>)[key];\n\t\t\t}\n\t\t\treturn { _tag: tag, message: this.message, ...payload };\n\t\t}\n\n\t\tstatic is(value: unknown): value is TaggedErrorValue<Tag> {\n\t\t\treturn value instanceof TaggedErrorClass;\n\t\t}\n\t}\n\treturn TaggedErrorClass as unknown as TaggedErrorFactory<Tag>;\n}\n\nexport class LaneBusy extends TaggedError(\"LaneBusy\")<{\n\tlane: string;\n\toperationId: string;\n\toperationKind: \"run\" | \"compaction\" | \"navigation\";\n\tmessage: string;\n}> {}\nexport class OperationMismatch extends TaggedError(\"OperationMismatch\")<{\n\tlane: string;\n\texpectedOperationId: string;\n\tcurrentOperationId?: string;\n\tlastOperationId?: string;\n\tmessage: string;\n}> {}\nexport class NoActiveRun extends TaggedError(\"NoActiveRun\")<{ lane: string; message: string }> {}\nexport class NoActiveOperation extends TaggedError(\"NoActiveOperation\")<{ lane: string; message: string }> {}\nexport class NothingToResume extends TaggedError(\"NothingToResume\")<{ lane: string; message: string }> {}\nexport class NothingToCompact extends TaggedError(\"NothingToCompact\")<{ lane: string; message: string }> {}\nexport class InvalidMessage extends TaggedError(\"InvalidMessage\")<{\n\tlane: string;\n\treason: string;\n\tmessage: string;\n}> {}\nexport class InvalidNavigation extends TaggedError(\"InvalidNavigation\")<{\n\tlane: string;\n\treason: string;\n\tmessage: string;\n}> {}\nexport class UnknownSkill extends TaggedError(\"UnknownSkill\")<{ name: string; message: string }> {}\nexport class UnknownTemplate extends TaggedError(\"UnknownTemplate\")<{ name: string; message: string }> {}\nexport class UnknownTarget extends TaggedError(\"UnknownTarget\")<{ targetId: string; message: string }> {}\nexport class InvalidLane extends TaggedError(\"InvalidLane\")<{\n\tlane: string;\n\treason: string;\n\tmessage: string;\n}> {}\nexport class Closed extends TaggedError(\"Closed\")<{ message: string }> {}\n\nexport class HarnessFault extends Error {\n\treadonly cause: unknown;\n\n\tconstructor(message: string, cause: unknown) {\n\t\tsuper(message);\n\t\tthis.name = \"HarnessFault\";\n\t\tthis.cause = cause;\n\t}\n}\n\nexport class HarnessClosed extends Error {\n\tconstructor() {\n\t\tsuper(\"AgentHarness was closed while the operation was active\");\n\t\tthis.name = \"HarnessClosed\";\n\t}\n}\n\nexport type ErrorMatchers<TError extends TaggedErrorValue<string>, TValue> = {\n\t[Tag in TError[\"_tag\"]]: (error: Extract<TError, { _tag: Tag }>) => TValue;\n};\n\nexport function matchError<TError extends TaggedErrorValue<string>, TValue>(\n\terror: TError,\n\tmatchers: ErrorMatchers<TError, TValue>,\n): TValue {\n\tconst matcher = (matchers as unknown as Record<string, (value: TError) => TValue>)[error._tag];\n\treturn matcher(error);\n}\n"]}
1
+ {"version":3,"file":"result.js","sourceRoot":"","sources":["../../src/harness/result.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,MAAM,GAAG;IACrB,EAAE,CAAS,KAAa;QACvB,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;IAC5B,CAAC;IACD,GAAG,CAAS,KAAa;QACxB,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;IAC7B,CAAC;IACD,IAAI,CAAiB,MAA8B;QAClD,OAAO,MAAM,CAAC,EAAE,CAAC;IAClB,CAAC;IACD,KAAK,CAAiB,MAA8B;QACnD,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;IACnB,CAAC;CACD,CAAC;AAYF,MAAM,UAAU,WAAW,CAAqB,GAAQ;IACvD,MAAM,gBAAiB,SAAQ,KAAK;QAGnC,YAAY,KAAoD;YAC/D,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YAHb,SAAI,GAAG,GAAG,CAAC;YAInB,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;YAChB,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAC5B,CAAC;QAED,MAAM;YACL,MAAM,OAAO,GAA4B,EAAE,CAAC;YAC5C,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;gBACrC,IAAI,GAAG,KAAK,MAAM;oBAAE,OAAO,CAAC,GAAG,CAAC,GAAI,IAA2C,CAAC,GAAG,CAAC,CAAC;YACtF,CAAC;YACD,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,GAAG,OAAO,EAAE,CAAC;QACzD,CAAC;QAED,MAAM,CAAC,EAAE,CAAC,KAAc;YACvB,OAAO,KAAK,YAAY,gBAAgB,CAAC;QAC1C,CAAC;KACD;IACD,OAAO,gBAAsD,CAAC;AAC/D,CAAC;AAMD,MAAM,UAAU,UAAU,CACzB,KAAa,EACb,QAAuC;IAEvC,MAAM,OAAO,GAAI,QAAiE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC/F,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC","sourcesContent":["export type Result<TValue, TError> = { ok: true; value: TValue } | { ok: false; error: TError };\n\nexport const Result = {\n\tok<TValue>(value: TValue): Result<TValue, never> {\n\t\treturn { ok: true, value };\n\t},\n\terr<TError>(error: TError): Result<never, TError> {\n\t\treturn { ok: false, error };\n\t},\n\tisOk<TValue, TError>(result: Result<TValue, TError>): result is { ok: true; value: TValue } {\n\t\treturn result.ok;\n\t},\n\tisErr<TValue, TError>(result: Result<TValue, TError>): result is { ok: false; error: TError } {\n\t\treturn !result.ok;\n\t},\n};\n\nexport interface TaggedErrorValue<Tag extends string> extends Error {\n\treadonly _tag: Tag;\n\ttoJSON(): { _tag: Tag; message: string } & Record<string, unknown>;\n}\n\nexport interface TaggedErrorFactory<Tag extends string> {\n\tnew <Props extends { message: string }>(props: Props): TaggedErrorValue<Tag> & Readonly<Props>;\n\tis(value: unknown): value is TaggedErrorValue<Tag>;\n}\n\nexport function TaggedError<Tag extends string>(tag: Tag): TaggedErrorFactory<Tag> {\n\tclass TaggedErrorClass extends Error {\n\t\treadonly _tag = tag;\n\n\t\tconstructor(props: { message: string } & Record<string, unknown>) {\n\t\t\tsuper(props.message);\n\t\t\tthis.name = tag;\n\t\t\tObject.assign(this, props);\n\t\t}\n\n\t\ttoJSON(): { _tag: Tag; message: string } & Record<string, unknown> {\n\t\t\tconst payload: Record<string, unknown> = {};\n\t\t\tfor (const key of Object.keys(this)) {\n\t\t\t\tif (key !== \"_tag\") payload[key] = (this as unknown as Record<string, unknown>)[key];\n\t\t\t}\n\t\t\treturn { _tag: tag, message: this.message, ...payload };\n\t\t}\n\n\t\tstatic is(value: unknown): value is TaggedErrorValue<Tag> {\n\t\t\treturn value instanceof TaggedErrorClass;\n\t\t}\n\t}\n\treturn TaggedErrorClass as unknown as TaggedErrorFactory<Tag>;\n}\n\nexport type ErrorMatchers<TError extends TaggedErrorValue<string>, TValue> = {\n\t[Tag in TError[\"_tag\"]]: (error: Extract<TError, { _tag: Tag }>) => TValue;\n};\n\nexport function matchError<TError extends TaggedErrorValue<string>, TValue>(\n\terror: TError,\n\tmatchers: ErrorMatchers<TError, TValue>,\n): TValue {\n\tconst matcher = (matchers as unknown as Record<string, (value: TError) => TValue>)[error._tag];\n\treturn matcher(error);\n}\n"]}
@@ -1,10 +1,23 @@
1
1
  import type { AgentMessage } from "../../types.ts";
2
- import type { Context } from "../context.ts";
3
- import type { Entry, EntryProjector } from "./types.ts";
2
+ import type { ConfigurationUpdateEntry, CustomEntry, Entry } from "./types.ts";
3
+ export interface SessionContext {
4
+ messages: AgentMessage[];
5
+ thinkingLevel: string;
6
+ configurationUpdate: ConfigurationUpdateEntry["reasoning"] | null;
7
+ model: {
8
+ provider: string;
9
+ modelId: string;
10
+ } | null;
11
+ activeToolNames: string[] | null;
12
+ }
13
+ export type ContextEntryTransform = (entries: readonly Entry[]) => readonly Entry[];
14
+ export type CustomEntryContextMessageProjector = (entry: CustomEntry, index: number, entries: readonly Entry[]) => readonly AgentMessage[] | undefined;
4
15
  export interface SessionContextBuildOptions {
5
- entryProjectors?: Readonly<Record<string, EntryProjector>>;
16
+ entryTransforms?: readonly ContextEntryTransform[];
17
+ entryProjectors?: Readonly<Record<string, CustomEntryContextMessageProjector>>;
6
18
  }
7
- export declare function buildContextEntries(pathEntries: readonly Entry[]): Entry[];
8
- export declare function sessionEntryToContextMessages(entry: Entry): AgentMessage[];
9
- export declare function buildSessionContext(pathEntries: readonly Entry[], options: SessionContextBuildOptions | undefined, context: Context): Promise<AgentMessage[]>;
19
+ export declare function defaultContextEntryTransform(pathEntries: readonly Entry[]): Entry[];
20
+ export declare function buildContextEntries(pathEntries: readonly Entry[], options?: SessionContextBuildOptions): Entry[];
21
+ export declare function sessionEntryToContextMessages(entry: Entry, index: number, entries: readonly Entry[], options?: SessionContextBuildOptions): AgentMessage[];
22
+ export declare function buildSessionContext(pathEntries: readonly Entry[], options?: SessionContextBuildOptions): SessionContext;
10
23
  //# sourceMappingURL=context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/harness/session/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAE7C,OAAO,KAAK,EAAmB,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEzE,MAAM,WAAW,0BAA0B;IAC1C,eAAe,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC;CAC3D;AAED,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,SAAS,KAAK,EAAE,GAAG,KAAK,EAAE,CAY1E;AASD,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,KAAK,GAAG,YAAY,EAAE,CAc1E;AAED,wBAAsB,mBAAmB,CACxC,WAAW,EAAE,SAAS,KAAK,EAAE,EAC7B,OAAO,EAAE,0BAA0B,GAAG,SAAS,EAC/C,OAAO,EAAE,OAAO,GACd,OAAO,CAAC,YAAY,EAAE,CAAC,CAazB"}
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/harness/session/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD,OAAO,KAAK,EAAmB,wBAA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AA+B,GACtC,cAAc,CAOhB"}
@@ -1,10 +1,34 @@
1
1
  import { createBranchSummaryMessage, createCompactionSummaryMessage } from "../messages.js";
2
- export function buildContextEntries(pathEntries) {
2
+ function deriveSessionContextState(pathEntries) {
3
+ let thinkingLevel = "off";
4
+ let configurationUpdate = null;
5
+ let model = null;
6
+ let activeToolNames = null;
7
+ for (const entry of pathEntries) {
8
+ if (entry.type === "thinking_level_change") {
9
+ thinkingLevel = entry.thinkingLevel;
10
+ }
11
+ else if (entry.type === "configuration_update") {
12
+ configurationUpdate = { ...entry.reasoning };
13
+ }
14
+ else if (entry.type === "model_change") {
15
+ model = { provider: entry.provider, modelId: entry.modelId };
16
+ }
17
+ else if (entry.type === "message" && entry.message.role === "assistant") {
18
+ model = { provider: entry.message.provider, modelId: entry.message.model };
19
+ }
20
+ else if (entry.type === "active_tools_change") {
21
+ activeToolNames = [...entry.activeToolNames];
22
+ }
23
+ }
24
+ return { thinkingLevel, configurationUpdate, model, activeToolNames };
25
+ }
26
+ export function defaultContextEntryTransform(pathEntries) {
3
27
  let compaction;
4
28
  let compactionIndex = -1;
5
29
  for (let index = pathEntries.length - 1; index >= 0; index--) {
6
30
  const entry = pathEntries[index];
7
- if (entry?.type === "compaction") {
31
+ if (entry.type === "compaction") {
8
32
  compaction = entry;
9
33
  compactionIndex = index;
10
34
  break;
@@ -12,38 +36,36 @@ export function buildContextEntries(pathEntries) {
12
36
  }
13
37
  return compaction === undefined ? [...pathEntries] : [compaction, ...pathEntries.slice(compactionIndex + 1)];
14
38
  }
15
- function isContextMessage(message) {
16
- return (message.role !== "assistant" ||
17
- (message.stopReason !== "error" && message.stopReason !== "aborted" && message.stopReason !== "deferred"));
39
+ export function buildContextEntries(pathEntries, options = {}) {
40
+ let entries = defaultContextEntryTransform(pathEntries);
41
+ for (const transform of options.entryTransforms ?? [])
42
+ entries = [...transform(entries)];
43
+ return entries;
18
44
  }
19
- export function sessionEntryToContextMessages(entry) {
20
- switch (entry.type) {
21
- case "message":
22
- return isContextMessage(entry.message) ? [entry.message] : [];
23
- case "compaction":
24
- return [
25
- createCompactionSummaryMessage(entry.summary, entry.tokensBefore, entry.timestamp),
26
- ...entry.retainedTail.filter(isContextMessage),
27
- ];
28
- case "branch_summary":
29
- return entry.summary ? [createBranchSummaryMessage(entry.summary, entry.fromId, entry.timestamp)] : [];
30
- case "custom":
45
+ export function sessionEntryToContextMessages(entry, index, entries, options = {}) {
46
+ if (entry.type === "message") {
47
+ if (entry.message.role === "assistant" && entry.message.stopReason === "deferred")
31
48
  return [];
49
+ return [entry.message];
32
50
  }
33
- }
34
- export async function buildSessionContext(pathEntries, options, context) {
35
- options ??= {};
36
- const entries = buildContextEntries(pathEntries);
37
- const messages = [];
38
- for (const entry of entries) {
39
- if (entry.type !== "custom") {
40
- messages.push(...sessionEntryToContextMessages(entry));
41
- continue;
42
- }
43
- const projector = options.entryProjectors?.[entry.customType];
44
- if (projector !== undefined)
45
- messages.push(...((await projector(entry, context)) ?? []));
51
+ if (entry.type === "compaction") {
52
+ return [
53
+ createCompactionSummaryMessage(entry.summary, entry.tokensBefore, entry.timestamp),
54
+ ...entry.retainedTail,
55
+ ];
46
56
  }
47
- return messages;
57
+ if (entry.type === "branch_summary" && entry.summary) {
58
+ return [createBranchSummaryMessage(entry.summary, entry.fromId, entry.timestamp)];
59
+ }
60
+ if (entry.type === "custom") {
61
+ return [...(options.entryProjectors?.[entry.customType]?.(entry, index, entries) ?? [])];
62
+ }
63
+ return [];
64
+ }
65
+ export function buildSessionContext(pathEntries, options = {}) {
66
+ const state = deriveSessionContextState(pathEntries);
67
+ const contextEntries = buildContextEntries(pathEntries, options);
68
+ const messages = contextEntries.flatMap((entry, index) => sessionEntryToContextMessages(entry, index, contextEntries, options));
69
+ return { ...state, messages };
48
70
  }
49
71
  //# sourceMappingURL=context.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/harness/session/context.ts"],"names":[],"mappings":"AAEA,OAAO,EA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AS,CAAC;gBAClF,GAAG,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,gBAAgB,CAAC;aAC9C,CAAC;QACH,KAAK,gBAAgB;YACpB,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,0BAA0B,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACxG,KAAK,QAAQ;YACZ,OAAO,EAAE,CAAC;IACZ,CAAC;AACF,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACxC,WAA6B,EAC7B,OAA+C,EAC/C,OAAgB;IAEhB,OAAO,KAAK,EAAE,CAAC;IACf,MAAM,OAAO,GAAG,mBAAmB,CAAC,WAAW,CAAC,CAAC;IACjD,MAAM,QAAQ,GAAmB,EAAE,CAAC;IACpC,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC7B,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC7B,QAAQ,CAAC,IAAI,CAAC,GAAG,6BAA6B,CAAC,KAAK,CAAC,CAAC,CAAC;YACvD,SAAS;QACV,CAAC;QACD,MAAM,SAAS,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QAC9D,IAAI,SAAS,KAAK,SAAS;YAAE,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IAC1F,CAAC;IACD,OAAO,QAAQ,CAAC;AACjB,CAAC","sourcesContent":["import type { AgentMessage } from \"../../types.ts\";\nimport type { Context } from \"../context.ts\";\nimport { createBranchSummaryMessage, createCompactionSummaryMessage } from \"../messages.ts\";\nimport type { CompactionEntry, Entry, EntryProjector } from \"./types.ts\";\n\nexport interface SessionContextBuildOptions {\n\tentryProjectors?: Readonly<Record<string, EntryProjector>>;\n}\n\nexport function buildContextEntries(pathEntries: readonly Entry[]): Entry[] {\n\tlet compaction: CompactionEntry | undefined;\n\tlet compactionIndex = -1;\n\tfor (let index = pathEntries.length - 1; index >= 0; index--) {\n\t\tconst entry = pathEntries[index];\n\t\tif (entry?.type === \"compaction\") {\n\t\t\tcompaction = entry;\n\t\t\tcompactionIndex = index;\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn compaction === undefined ? [...pathEntries] : [compaction, ...pathEntries.slice(compactionIndex + 1)];\n}\n\nfunction isContextMessage(message: AgentMessage): boolean {\n\treturn (\n\t\tmessage.role !== \"assistant\" ||\n\t\t(message.stopReason !== \"error\" && message.stopReason !== \"aborted\" && message.stopReason !== \"deferred\")\n\t);\n}\n\nexport function sessionEntryToContextMessages(entry: Entry): AgentMessage[] {\n\tswitch (entry.type) {\n\t\tcase \"message\":\n\t\t\treturn isContextMessage(entry.message) ? [entry.message] : [];\n\t\tcase \"compaction\":\n\t\t\treturn [\n\t\t\t\tcreateCompactionSummaryMessage(entry.summary, entry.tokensBefore, entry.timestamp),\n\t\t\t\t...entry.retainedTail.filter(isContextMessage),\n\t\t\t];\n\t\tcase \"branch_summary\":\n\t\t\treturn entry.summary ? [createBranchSummaryMessage(entry.summary, entry.fromId, entry.timestamp)] : [];\n\t\tcase \"custom\":\n\t\t\treturn [];\n\t}\n}\n\nexport async function buildSessionContext(\n\tpathEntries: readonly Entry[],\n\toptions: SessionContextBuildOptions | undefined,\n\tcontext: Context,\n): Promise<AgentMessage[]> {\n\toptions ??= {};\n\tconst entries = buildContextEntries(pathEntries);\n\tconst messages: AgentMessage[] = [];\n\tfor (const entry of entries) {\n\t\tif (entry.type !== \"custom\") {\n\t\t\tmessages.push(...sessionEntryToContextMessages(entry));\n\t\t\tcontinue;\n\t\t}\n\t\tconst projector = options.entryProjectors?.[entry.customType];\n\t\tif (projector !== undefined) messages.push(...((await projector(entry, context)) ?? []));\n\t}\n\treturn messages;\n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CAAC,OAAO,CAAC,CAAC;IACxB,CAAC;IACD,IAAI,KAAK,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;QACjC,OAAO;YACN,8BAA8B,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,YAAY,EAAE,KAAK,CAAC,SAAS,CAAC;YAClF,GAAG,KAAK,CAAC,YAAY;SACrB,CAAC;IACH,CAAC;IACD,IAAI,KAAK,CAAC,IAAI,KAAK,gBAAgB,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;QACtD,OAAO,CAAC,0BAA0B,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC;IACnF,CAAC;IACD,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7B,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,eAAe,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IAC1F,CAAC;IACD,OAAO,EAAE,CAAC;AACX,CAAC;AAED,MAAM,UAAU,mBAAmB,CAClC,WAA6B,EAC7B,OAAO,GAA+B,EAAE;IAExC,MAAM,KAAK,GAAG,yBAAyB,CAAC,WAAW,CAAC,CAAC;IACrD,MAAM,cAAc,GAAG,mBAAmB,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IACjE,MAAM,QAAQ,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CACxD,6BAA6B,CAAC,KAAK,EAAE,KAAK,EAAE,cAAc,EAAE,OAAO,CAAC,CACpE,CAAC;IACF,OAAO,EAAE,GAAG,KAAK,EAAE,QAAQ,EAAE,CAAC;AAC/B,CAAC","sourcesContent":["import type { AgentMessage } from \"../../types.ts\";\nimport { createBranchSummaryMessage, createCompactionSummaryMessage } from \"../messages.ts\";\nimport type { CompactionEntry, ConfigurationUpdateEntry, CustomEntry, Entry } from \"./types.ts\";\n\nexport interface SessionContext {\n\tmessages: AgentMessage[];\n\tthinkingLevel: string;\n\tconfigurationUpdate: ConfigurationUpdateEntry[\"reasoning\"] | null;\n\tmodel: { provider: string; modelId: string } | null;\n\tactiveToolNames: string[] | null;\n}\n\nexport type ContextEntryTransform = (entries: readonly Entry[]) => readonly Entry[];\n\nexport type CustomEntryContextMessageProjector = (\n\tentry: CustomEntry,\n\tindex: number,\n\tentries: readonly Entry[],\n) => readonly AgentMessage[] | undefined;\n\nexport interface SessionContextBuildOptions {\n\tentryTransforms?: readonly ContextEntryTransform[];\n\tentryProjectors?: Readonly<Record<string, CustomEntryContextMessageProjector>>;\n}\n\nfunction deriveSessionContextState(pathEntries: readonly Entry[]): Omit<SessionContext, \"messages\"> {\n\tlet thinkingLevel = \"off\";\n\tlet configurationUpdate: ConfigurationUpdateEntry[\"reasoning\"] | null = null;\n\tlet model: { provider: string; modelId: string } | null = null;\n\tlet activeToolNames: string[] | null = null;\n\n\tfor (const entry of pathEntries) {\n\t\tif (entry.type === \"thinking_level_change\") {\n\t\t\tthinkingLevel = entry.thinkingLevel;\n\t\t} else if (entry.type === \"configuration_update\") {\n\t\t\tconfigurationUpdate = { ...entry.reasoning };\n\t\t} else if (entry.type === \"model_change\") {\n\t\t\tmodel = { provider: entry.provider, modelId: entry.modelId };\n\t\t} else if (entry.type === \"message\" && entry.message.role === \"assistant\") {\n\t\t\tmodel = { provider: entry.message.provider, modelId: entry.message.model };\n\t\t} else if (entry.type === \"active_tools_change\") {\n\t\t\tactiveToolNames = [...entry.activeToolNames];\n\t\t}\n\t}\n\n\treturn { thinkingLevel, configurationUpdate, model, activeToolNames };\n}\n\nexport function defaultContextEntryTransform(pathEntries: readonly Entry[]): Entry[] {\n\tlet compaction: CompactionEntry | undefined;\n\tlet compactionIndex = -1;\n\tfor (let index = pathEntries.length - 1; index >= 0; index--) {\n\t\tconst entry = pathEntries[index]!;\n\t\tif (entry.type === \"compaction\") {\n\t\t\tcompaction = entry;\n\t\t\tcompactionIndex = index;\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn compaction === undefined ? [...pathEntries] : [compaction, ...pathEntries.slice(compactionIndex + 1)];\n}\n\nexport function buildContextEntries(pathEntries: readonly Entry[], options: SessionContextBuildOptions = {}): Entry[] {\n\tlet entries = defaultContextEntryTransform(pathEntries);\n\tfor (const transform of options.entryTransforms ?? []) entries = [...transform(entries)];\n\treturn entries;\n}\n\nexport function sessionEntryToContextMessages(\n\tentry: Entry,\n\tindex: number,\n\tentries: readonly Entry[],\n\toptions: SessionContextBuildOptions = {},\n): AgentMessage[] {\n\tif (entry.type === \"message\") {\n\t\tif (entry.message.role === \"assistant\" && entry.message.stopReason === \"deferred\") return [];\n\t\treturn [entry.message];\n\t}\n\tif (entry.type === \"compaction\") {\n\t\treturn [\n\t\t\tcreateCompactionSummaryMessage(entry.summary, entry.tokensBefore, entry.timestamp),\n\t\t\t...entry.retainedTail,\n\t\t];\n\t}\n\tif (entry.type === \"branch_summary\" && entry.summary) {\n\t\treturn [createBranchSummaryMessage(entry.summary, entry.fromId, entry.timestamp)];\n\t}\n\tif (entry.type === \"custom\") {\n\t\treturn [...(options.entryProjectors?.[entry.customType]?.(entry, index, entries) ?? [])];\n\t}\n\treturn [];\n}\n\nexport function buildSessionContext(\n\tpathEntries: readonly Entry[],\n\toptions: SessionContextBuildOptions = {},\n): SessionContext {\n\tconst state = deriveSessionContextState(pathEntries);\n\tconst contextEntries = buildContextEntries(pathEntries, options);\n\tconst messages = contextEntries.flatMap((entry, index) =>\n\t\tsessionEntryToContextMessages(entry, index, contextEntries, options),\n\t);\n\treturn { ...state, messages };\n}\n"]}
@@ -1,11 +1,7 @@
1
- export type { CommittedEntryWrite, CommittedListAppendWrite, CommittedListDeleteWrite, CommittedUsageWrite, CommittedValueDeleteWrite, CommittedValueSetWrite, CommittedWrite, CommitValidationState, PreparedCommit, } from "./commit.ts";
2
- export { commitWrite, insertEntry, insertUsage, prepareStorageCommit, validateCommittedWrites } from "./commit.ts";
3
- export { createForkSnapshot, type ForkSourceSnapshot } from "./fork.ts";
4
- export { type ForkCurrentStatePlan, projectForkCurrentStateWrite } from "./fork-policy.ts";
5
- export { JSONL_STORAGE_VERSION, type JsonlSessionCreateOptions, type JsonlSessionListOptions, type JsonlSessionMetadata, JsonlSessionRepo, type JsonlSessionRepoOptions, } from "./jsonl/index.ts";
6
- export type { MemorySessionRepoOptions } from "./memory.ts";
7
- export { MemorySessionRepo } from "./memory.ts";
8
- export { SessionBranchExistsError, SessionInvalidBranchError, SessionInvariantError, SessionPendingAssistantMessageError, SessionUnknownTargetError, StorageBackedSession, type StorageBackedSessionOptions, } from "./session.ts";
1
+ export * from "./context.ts";
2
+ export type { JsonlSessionCreateOptions, JsonlSessionListOptions, JsonlSessionMetadata, JsonlSessionRepoFileSystem, JsonlSessionRepoOptions, JsonlV4Header, } from "./jsonl.ts";
3
+ export { JsonlSessionRepo } from "./jsonl.ts";
4
+ export * from "./memory.ts";
5
+ export * from "./session.ts";
9
6
  export * from "./types.ts";
10
- export * from "./values.ts";
11
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/harness/session/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACX,mBAAmB,EACnB,wBAAwB,EACxB,wBAAwB,EACxB,mBAAmB,EACnB,yBAAyB,EACzB,sBAAsB,EACtB,cAAc,EACd,qBAAqB,EACrB,cAAc,GACd,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACnH,OAAO,EAAE,kBAAkB,EAAE,KAAK,kBAAkB,EAAE,MAAM,WAAW,CAAC;AACxE,OAAO,EAAE,KAAK,oBAAoB,EAAE,4BAA4B,EAAE,MAAM,kBAAkB,CAAC;AAC3F,OAAO,EACN,qBAAqB,EACrB,KAAK,yBAAyB,EAC9B,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EACzB,gBAAgB,EAChB,KAAK,uBAAuB,GAC5B,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EACN,wBAAwB,EACxB,yBAAyB,EACzB,qBAAqB,EACrB,mCAAmC,EACnC,yBAAyB,EACzB,oBAAoB,EACpB,KAAK,2BAA2B,GAChC,MAAM,cAAc,CAAC;AACtB,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/harness/session/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,YAAY,EACX,yBAAyB,EACzB,uBAAuB,EACvB,oBAAoB,EACpB,0BAA0B,EAC1B,uBAAuB,EACvB,aAAa,GACb,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC"}
@@ -1,9 +1,6 @@
1
- export { commitWrite, insertEntry, insertUsage, prepareStorageCommit, validateCommittedWrites } from "./commit.js";
2
- export { createForkSnapshot } from "./fork.js";
3
- export { projectForkCurrentStateWrite } from "./fork-policy.js";
4
- export { JSONL_STORAGE_VERSION, JsonlSessionRepo, } from "./jsonl/index.js";
5
- export { MemorySessionRepo } from "./memory.js";
6
- export { SessionBranchExistsError, SessionInvalidBranchError, SessionInvariantError, SessionPendingAssistantMessageError, SessionUnknownTargetError, StorageBackedSession, } from "./session.js";
1
+ export * from "./context.js";
2
+ export { JsonlSessionRepo } from "./jsonl.js";
3
+ export * from "./memory.js";
4
+ export * from "./session.js";
7
5
  export * from "./types.js";
8
- export * from "./values.js";
9
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/harness/session/index.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACnH,OAAO,EAAE,kBAAkB,EAA2B,MAAM,WAAW,CAAC;AACxE,OAAO,EAA6B,4BAA4B,EAAE,MAAM,kBAAkB,CAAC;AAC3F,OAAO,EACN,qBAAqB,EAIrB,gBAAgB,GAEhB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EACN,wBAAwB,EACxB,yBAAyB,EACzB,qBAAqB,EACrB,mCAAmC,EACnC,yBAAyB,EACzB,oBAAoB,GAEpB,MAAM,cAAc,CAAC;AACtB,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC","sourcesContent":["export type {\n\tCommittedEntryWrite,\n\tCommittedListAppendWrite,\n\tCommittedListDeleteWrite,\n\tCommittedUsageWrite,\n\tCommittedValueDeleteWrite,\n\tCommittedValueSetWrite,\n\tCommittedWrite,\n\tCommitValidationState,\n\tPreparedCommit,\n} from \"./commit.ts\";\nexport { commitWrite, insertEntry, insertUsage, prepareStorageCommit, validateCommittedWrites } from \"./commit.ts\";\nexport { createForkSnapshot, type ForkSourceSnapshot } from \"./fork.ts\";\nexport { type ForkCurrentStatePlan, projectForkCurrentStateWrite } from \"./fork-policy.ts\";\nexport {\n\tJSONL_STORAGE_VERSION,\n\ttype JsonlSessionCreateOptions,\n\ttype JsonlSessionListOptions,\n\ttype JsonlSessionMetadata,\n\tJsonlSessionRepo,\n\ttype JsonlSessionRepoOptions,\n} from \"./jsonl/index.ts\";\nexport type { MemorySessionRepoOptions } from \"./memory.ts\";\nexport { MemorySessionRepo } from \"./memory.ts\";\nexport {\n\tSessionBranchExistsError,\n\tSessionInvalidBranchError,\n\tSessionInvariantError,\n\tSessionPendingAssistantMessageError,\n\tSessionUnknownTargetError,\n\tStorageBackedSession,\n\ttype StorageBackedSessionOptions,\n} from \"./session.ts\";\nexport * from \"./types.ts\";\nexport * from \"./values.ts\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/harness/session/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAS7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC","sourcesContent":["export * from \"./context.ts\";\nexport type {\n\tJsonlSessionCreateOptions,\n\tJsonlSessionListOptions,\n\tJsonlSessionMetadata,\n\tJsonlSessionRepoFileSystem,\n\tJsonlSessionRepoOptions,\n\tJsonlV4Header,\n} from \"./jsonl.ts\";\nexport { JsonlSessionRepo } from \"./jsonl.ts\";\nexport * from \"./memory.ts\";\nexport * from \"./session.ts\";\nexport * from \"./types.ts\";\n"]}
@@ -1,21 +1,10 @@
1
1
  import { type Result } from "../../types.ts";
2
- import { type JsonlStorageHeader } from "./types.ts";
3
- export interface LegacyV3SessionHeader {
4
- type: "session";
5
- version: 3;
6
- id: string;
7
- timestamp: string;
8
- cwd: string;
9
- parentSession?: string;
10
- }
11
- export declare function isLegacyV3SessionHeader(value: unknown): value is LegacyV3SessionHeader;
12
- export declare function isJsonlStorageHeader(value: unknown): value is JsonlStorageHeader;
13
- export type JsonlParsedSessionHeader = {
14
- format: "v4";
15
- header: JsonlStorageHeader;
16
- } | {
17
- format: "v3-legacy";
18
- header: LegacyV3SessionHeader;
19
- };
20
- export declare function parseJsonlSessionHeader(line: string): Result<JsonlParsedSessionHeader, Error>;
2
+ import type { SessionMutation } from "../state.ts";
3
+ import { JsonlDecodeError } from "./errors.ts";
4
+ import type { JsonlSessionMetadata, JsonlV4Header } from "./types.ts";
5
+ export declare function parseHeader(line: string): Result<JsonlV4Header, JsonlDecodeError>;
6
+ export declare function encodeHeader(header: JsonlV4Header): string;
7
+ export declare function metadataFromHeader(header: JsonlV4Header, path: string, modifiedAt: number): JsonlSessionMetadata;
8
+ export declare function parseMutation(line: string): Result<SessionMutation, JsonlDecodeError>;
9
+ export declare function encodeMutation(mutation: SessionMutation): string;
21
10
  //# sourceMappingURL=codec.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"codec.d.ts","sourceRoot":"","sources":["../../../../src/harness/session/jsonl/codec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAwB,KAAK,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAE3E,MAAM,WAAW,qBAAqB;IACrC,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,EAAE,CAAC,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,aAAa,CAAC,EAAE,MAAM,CAAC;CACvB;AAUD,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,qBAAqB,CAWtF;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,kBAAkB,CAahF;AAED,MAAM,MAAM,wBAAwB,GACjC;IAAE,MAAM,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,kBAAkB,CAAA;CAAE,GAC5C;IAAE,MAAM,EAAE,WAAW,CAAC;IAAC,MAAM,EAAE,qBAAqB,CAAA;CAAE,CAAC;AAE1D,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAU7F"}
1
+ {"version":3,"file":"codec.d.ts","sourceRoot":"","sources":["../../../../src/harness/session/jsonl/codec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,MAAM,EAAE,MAA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