@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
@@ -1,512 +1,352 @@
1
- import type { JsonValue } from "@earendil-works/chord";
2
- import type { AssistantMessage, StopReason, Usage } from "@earendil-works/pi-ai";
3
- import type { AgentMessage, QueueMode, ThinkingLevel } from "../../types.ts";
4
- import type { BranchPreparation } from "../compaction/branch-summarization.ts";
5
- import type { CompactionPreparation, CompactionSettings } from "../compaction/compaction.ts";
6
- import type { Context } from "../context.ts";
7
- import type { AgentHarnessStreamOptions } from "../types.ts";
8
- import type { ListElement, ListReadOptions, ListWrite, StoredValue, Value, ValueList, ValueWrite } from "./values.ts";
9
- export type { JsonValue } from "@earendil-works/chord";
10
- export type SettledAssistantMessage = AssistantMessage & {
11
- stopReason: Exclude<StopReason, "pending">;
1
+ import type { StopReason, Usage } from "@earendil-works/pi-ai";
2
+ import "../messages.ts";
3
+ import type { AgentMessage } from "../../types.ts";
4
+ import type { Session } from "./session.ts";
5
+ export type JsonValue = null | boolean | number | string | JsonValue[] | {
6
+ [key: string]: JsonValue;
12
7
  };
13
- export type EntryType = "message" | "compaction" | "branch_summary" | "custom";
8
+ export type SessionStopReason = Exclude<StopReason, "pending"> | "deferred";
9
+ export interface IdGenerator {
10
+ next(): string;
11
+ }
14
12
  export interface EntryBase {
13
+ type: string;
15
14
  id: string;
16
- parentId: string | null;
17
15
  seq: number;
16
+ parentId: string | null;
18
17
  timestamp: number;
19
- type: EntryType;
20
- customType?: string;
21
18
  }
22
19
  export interface MessageEntry extends EntryBase {
23
20
  type: "message";
24
21
  message: AgentMessage;
25
22
  terminate?: true;
26
23
  }
24
+ export interface ModelChangeEntry extends EntryBase {
25
+ type: "model_change";
26
+ provider: string;
27
+ modelId: string;
28
+ }
29
+ export interface ThinkingLevelEntry extends EntryBase {
30
+ type: "thinking_level_change";
31
+ thinkingLevel: string;
32
+ }
33
+ export interface ConfigurationUpdateEntry extends EntryBase {
34
+ type: "configuration_update";
35
+ reasoning: {
36
+ effort: string;
37
+ };
38
+ }
39
+ export interface ActiveToolsEntry extends EntryBase {
40
+ type: "active_tools_change";
41
+ activeToolNames: string[];
42
+ }
27
43
  export interface CompactionEntry extends EntryBase {
28
44
  type: "compaction";
29
45
  summary: string;
30
46
  retainedTail: AgentMessage[];
31
47
  tokensBefore: number;
32
- details?: JsonValue;
48
+ details?: unknown;
33
49
  usage?: Usage;
34
- fromHook: boolean;
35
50
  }
36
51
  export interface BranchSummaryEntry extends EntryBase {
37
52
  type: "branch_summary";
38
- fromId: string | null;
53
+ fromId: string;
39
54
  summary: string;
40
- details?: JsonValue;
55
+ details?: unknown;
41
56
  usage?: Usage;
42
- fromHook: boolean;
43
57
  }
44
58
  export interface CustomEntry extends EntryBase {
45
59
  type: "custom";
46
60
  customType: string;
47
- data?: JsonValue;
48
- }
49
- /** Convert an application-defined custom entry into model context. */
50
- export type EntryProjector = (entry: CustomEntry, context: Context) => AgentMessage[] | undefined | Promise<AgentMessage[] | undefined>;
51
- export type Entry = MessageEntry | CompactionEntry | BranchSummaryEntry | CustomEntry;
52
- /** Entry supplied to a transaction before storage assigns sequence and timestamp. */
53
- export type NewEntry<TEntry extends Entry = Entry> = TEntry extends Entry ? Omit<TEntry, "seq" | "timestamp"> : never;
54
- export interface LaneConfiguration {
55
- model: {
56
- provider: string;
57
- modelId: string;
58
- };
59
- thinkingLevel: ThinkingLevel;
60
- activeToolNames: string[];
61
+ data?: unknown;
61
62
  }
62
- export interface OperationMeta {
63
- operationId: string;
63
+ export type Entry = MessageEntry | ModelChangeEntry | ThinkingLevelEntry | ConfigurationUpdateEntry | ActiveToolsEntry | CompactionEntry | BranchSummaryEntry | CustomEntry;
64
+ export type ProvisionedEntry<TEntry extends Entry = Entry> = TEntry extends Entry ? Omit<TEntry, "parentId" | "seq" | "timestamp"> : never;
65
+ export interface RecordBase {
66
+ id: string;
67
+ seq: number;
64
68
  lane: string;
65
- sourceTipId: string | null;
66
- startedAt: number;
69
+ timestamp: number;
70
+ }
71
+ export interface OperationStartedRecord extends RecordBase {
72
+ type: "operation_started";
73
+ sourceLeafId: string | null;
67
74
  intent: {
68
75
  kind: "run";
69
- promptEntryIds: string[];
76
+ /** Normalized caller input before before_run; kept for suspended operations and before_resume. */
77
+ originalPrompt: AgentMessage[];
78
+ /** Captured nextRun items, then the prompt, then before_run injections. */
79
+ initialMessages: ProvisionedEntry[];
80
+ systemPromptOverride?: string;
81
+ resumeData?: {
82
+ [extensionId: string]: JsonValue;
83
+ };
70
84
  } | {
71
85
  kind: "compaction";
72
86
  customInstructions?: string;
87
+ resultEntryId: string;
73
88
  } | {
74
89
  kind: "navigation";
75
90
  targetId: string | null;
76
91
  summarize: boolean;
77
- label?: string;
78
92
  customInstructions?: string;
93
+ label?: string;
94
+ summaryEntryId?: string;
79
95
  };
80
96
  }
81
- export type Control = {
82
- status: "running";
83
- } | {
84
- status: "cancel_requested";
85
- requestedAt: number;
86
- };
87
- export interface OperationError {
88
- code: string;
89
- message: string;
90
- details?: JsonValue;
91
- }
92
- export type TerminalStatus = "completed" | "declined" | "aborted" | "failed";
93
- /** Immutable lane-lived observation record written by one terminal transaction. */
94
- export interface OperationResultRecord {
95
- operationId: string;
96
- kind: OperationMeta["intent"]["kind"];
97
- status: TerminalStatus;
98
- error?: OperationError;
99
- fromTipId: string | null;
100
- tipId: string | null;
101
- startedAt: number;
102
- endedAt: number;
103
- }
104
- export type Continuation = {
105
- kind: "need_assistant";
106
- overflowRecoveryUsed: boolean;
107
- } | {
108
- kind: "may_finish";
109
- includeFinalAssistant: boolean;
110
- };
111
- /** Checkpoint payload; the flat leaf literal replaces the old nested phase tag. */
112
- export interface CheckpointData {
113
- continuation: Continuation;
114
- triggerEntryId: string;
115
- }
116
- export type InboxItemKind = "steer" | "followUp" | "nextRun" | "write";
117
- export interface InboxItem {
118
- entryId: string;
119
- kind: InboxItemKind;
120
- }
121
- export interface NormalizedRetryPolicy {
122
- maxAttempts: number;
123
- baseDelayMs: number;
124
- maxAgentDelayMs: number;
125
- }
126
- export interface GenerationContext {
127
- stepId: string;
128
- triggerEntryId: string;
129
- configuration: LaneConfiguration;
130
- streamOptions: AgentHarnessStreamOptions;
131
- retryPolicy: NormalizedRetryPolicy;
132
- overflowRecoveryUsed: boolean;
97
+ export interface AbortRequestedRecord extends RecordBase {
98
+ type: "abort_requested";
99
+ runId: string;
100
+ }
101
+ export interface OperationFinishedRecord extends RecordBase {
102
+ type: "operation_finished";
103
+ runId: string;
104
+ outcome: "completed" | "aborted" | "failed" | "declined";
105
+ error?: {
106
+ code: string;
107
+ message: string;
108
+ };
133
109
  }
134
- interface ToolCallSource {
135
- /** Zero-based index in the assistant message's complete content array, not a filtered tool-call ordinal. */
136
- sourceIndex: number;
110
+ export type CompactionReason = "manual" | "threshold" | "overflow";
111
+ export type StepAttemptRecord = RecordBase & ({
112
+ type: "step_attempt";
113
+ runId: string;
114
+ step: "assistant" | "branch_summary";
115
+ attempt: number;
137
116
  resultEntryId: string;
138
- }
139
- export type ToolCall = ToolCallSource & ({
140
- status: "planned";
141
- } | {
142
- status: "effect_pending";
143
- replay: "never" | "safe";
144
- } | {
145
- status: "outcome_ready";
146
- terminate: boolean;
117
+ compactionReason?: never;
147
118
  } | {
148
- status: "completed";
149
- terminate: boolean;
119
+ type: "step_attempt";
120
+ runId: string;
121
+ step: "compaction";
122
+ attempt: number;
123
+ resultEntryId: string;
124
+ /** Persists why compaction summary generation started so recovery resumes the same work. */
125
+ compactionReason: CompactionReason;
150
126
  });
151
- export interface ToolBatch {
127
+ export interface ToolStartedRecord extends RecordBase {
128
+ type: "tool_started";
129
+ runId: string;
152
130
  assistantEntryId: string;
153
- configuration: LaneConfiguration;
154
- turnId: string;
155
- calls: ToolCall[];
156
- }
157
- export interface SummaryContext {
131
+ toolIndex: number;
132
+ toolCallId: string;
133
+ toolName: string;
134
+ effectiveArgs: {
135
+ [key: string]: unknown;
136
+ };
158
137
  resultEntryId: string;
159
- configuration: LaneConfiguration;
160
- streamOptions: AgentHarnessStreamOptions;
161
- retryPolicy: NormalizedRetryPolicy;
162
- }
163
- export interface Cancellable {
164
- control: Control;
165
- }
166
- export interface RunSettings {
167
- compaction: CompactionSettings;
168
- steeringMode: QueueMode;
169
- followUpMode: QueueMode;
170
- toolExecution: "sequential" | "parallel";
171
- }
172
- /** Uniform scope carried by every operation leaf. */
173
- export interface OperationScope extends Cancellable {
174
- settings: RunSettings;
175
- latestAssistantEntryId: string | null;
176
- }
177
- /** Shared backoff data for every retry-wait leaf. */
178
- export interface RetryWait {
179
- nextAttempt: number;
180
- notBefore: number;
181
- errorMessage: string;
182
- }
183
- export interface AssistantGenerationScope {
184
- generationContext: GenerationContext;
138
+ replay: "never" | "safe";
185
139
  }
186
- export type ResultBoundary = {
187
- kind: "resume_checkpoint";
188
- resumeAfter: CheckpointData;
140
+ export type QueueEnqueuedRecord = RecordBase & ({
141
+ type: "queue_enqueued";
142
+ queue: "steer" | "followUp";
143
+ runId: string;
144
+ target: ProvisionedEntry;
189
145
  } | {
190
- kind: "finish";
191
- } | {
192
- kind: "commit_navigation";
193
- targetId: string;
194
- label?: string;
195
- };
196
- export interface SummaryTask {
197
- taskId: string;
198
- reason?: "manual" | "threshold" | "overflow";
199
- customInstructions?: string;
200
- boundary: ResultBoundary;
201
- }
202
- export interface SummaryGenerationScope {
203
- task: SummaryTask;
204
- summaryContext: SummaryContext;
205
- }
206
- export interface SummaryGenerationReady extends SummaryGenerationScope {
207
- nextAttempt: number;
208
- }
209
- export interface SummaryGenerationEffectPending extends SummaryGenerationScope {
210
- attempt: number;
211
- request?: {
212
- index: number;
213
- usageId: string;
214
- };
215
- usageIds: string[];
216
- }
217
- export interface SummaryGenerationRetryWait extends SummaryGenerationScope, RetryWait {
218
- }
219
- export interface DeferredScope extends OperationScope {
220
- stepId: string;
221
- sourceEntryId: string;
222
- poll: number;
223
- configuration: LaneConfiguration;
224
- streamOptions: AgentHarnessStreamOptions;
225
- }
226
- export interface StartingOperation extends OperationScope {
227
- at: "starting";
228
- }
229
- export interface CheckpointOperation extends OperationScope, CheckpointData {
230
- at: "checkpoint";
146
+ type: "queue_enqueued";
147
+ queue: "nextRun";
148
+ runId?: never;
149
+ target: ProvisionedEntry;
150
+ });
151
+ export interface QueueCancelledRecord extends RecordBase {
152
+ type: "queue_cancelled";
153
+ runId?: string;
154
+ entryId: string;
231
155
  }
232
- export interface AssistantReadyOperation extends OperationScope, AssistantGenerationScope {
233
- at: "assistant.ready";
234
- nextAttempt: number;
156
+ export interface WriteDeferredRecord extends RecordBase {
157
+ type: "write_deferred";
158
+ runId: string;
159
+ target: ProvisionedEntry;
235
160
  }
236
- export interface AssistantEffectPendingOperation extends OperationScope, AssistantGenerationScope {
237
- at: "assistant.effect_pending";
161
+ export type UsageRecord = RecordBase & {
162
+ type: "usage";
163
+ usage: Usage;
164
+ } & ({
165
+ cause: "assistant" | "compaction" | "branch_summary" | "deferred_fetch";
166
+ runId: string;
167
+ entryId: string;
238
168
  attempt: number;
239
- responseEntryId: string;
240
- usageId: string;
241
- intendedOutputLimit: number;
242
- contextWindow: number;
243
- }
244
- export interface AssistantRetryWaitOperation extends OperationScope, AssistantGenerationScope, RetryWait {
245
- at: "assistant.retry_wait";
246
- }
247
- export interface ToolsOperation extends OperationScope {
248
- at: "tools";
249
- batch: ToolBatch;
250
- }
251
- export interface DeferredSuspendedOperation extends DeferredScope {
252
- at: "deferred.suspended";
253
- }
254
- export interface DeferredEffectPendingOperation extends DeferredScope {
255
- at: "deferred.effect_pending";
256
- responseEntryId: string;
257
- usageId: string;
258
- }
259
- export interface SummaryDecidingOperation extends OperationScope {
260
- at: "summary.deciding";
261
- task: SummaryTask;
262
- }
263
- export interface SummaryReadyOperation extends OperationScope, SummaryGenerationReady {
264
- at: "summary.ready";
265
- }
266
- export interface SummaryEffectPendingOperation extends OperationScope, SummaryGenerationEffectPending {
267
- at: "summary.effect_pending";
268
- }
269
- export interface SummaryRetryWaitOperation extends OperationScope, SummaryGenerationRetryWait {
270
- at: "summary.retry_wait";
271
- }
272
- export interface NavigationReadyToCommitOperation extends OperationScope {
273
- at: "navigation.ready_to_commit";
274
- /** Unsummarized navigation may target the branch root (null). */
275
- targetId: string | null;
276
- label?: string;
277
- }
278
- /** Flat durable operation state: exactly 13 family-neutral dispatcher leaves. */
279
- export type OperationState = StartingOperation | CheckpointOperation | AssistantReadyOperation | AssistantEffectPendingOperation | AssistantRetryWaitOperation | ToolsOperation | DeferredSuspendedOperation | DeferredEffectPendingOperation | SummaryDecidingOperation | SummaryReadyOperation | SummaryEffectPendingOperation | SummaryRetryWaitOperation | NavigationReadyToCommitOperation;
280
- export type OperationAt = OperationState["at"];
281
- /** Copy only the uniform operation scope when constructing a successor leaf. */
282
- export declare function operationScopeOf(state: OperationState): OperationScope;
283
- export type Operation = {
284
- meta: OperationMeta;
285
- state: OperationState;
286
- };
287
- export interface LaneState {
288
- currentOperationId: string | null;
289
- lastOperationId: string | null;
290
- inbox: InboxItem[];
291
- }
292
- export type PendingEntry = {
293
- type: "message";
294
- payload: AgentMessage;
169
+ stopReason: SessionStopReason;
295
170
  } | {
296
- type: "custom";
297
- customType: string;
298
- payload?: JsonValue;
299
- };
300
- export interface DurableFileOperations {
301
- read: string[];
302
- written: string[];
303
- edited: string[];
304
- }
305
- export type DurableStructuralPreparation = {
306
- kind: "compaction";
307
- messagesToSummarize: CompactionPreparation["messagesToSummarize"];
308
- turnPrefixMessages: CompactionPreparation["turnPrefixMessages"];
309
- retainedTail: CompactionPreparation["retainedTail"];
310
- isSplitTurn: boolean;
311
- tokensBefore: number;
312
- previousSummary?: string;
313
- fileOps: DurableFileOperations;
314
- settings: CompactionSettings;
171
+ cause: "tool";
172
+ runId: string;
173
+ entryId: string;
174
+ toolCallId: string;
315
175
  } | {
316
- kind: "branch_summary";
317
- messages: BranchPreparation["messages"];
318
- fileOps: DurableFileOperations;
319
- totalTokens: number;
320
- };
321
- export interface UsageRow {
322
- id: string;
323
- seq: number;
324
- usage: Usage;
176
+ cause: "hook";
177
+ runId: string;
178
+ entryId: string;
179
+ } | {
180
+ cause: "adjustment";
181
+ runId?: string;
325
182
  entryId?: string;
326
- adjustment: boolean;
327
183
  details?: JsonValue;
328
- }
329
- export interface EntryWrite {
330
- kind: "entry";
331
- entry: NewEntry;
332
- }
333
- export interface UsageWrite {
334
- kind: "usage";
335
- row: Omit<UsageRow, "seq">;
336
- }
337
- export type Write = EntryWrite | UsageWrite | ValueWrite | ListWrite;
338
- export interface CommitResult {
339
- firstSeq: number;
340
- seqs: number[];
341
- timestamp: number;
342
- /** Session totals immediately after this commit was applied. */
343
- stats: SessionStats;
344
- }
345
- export interface EntryStructure {
346
- id: string;
347
- parentId: string | null;
348
- seq: number;
349
- timestamp: number;
350
- type: EntryType;
351
- customType?: string;
352
- }
184
+ });
185
+ export type LaneRecord = OperationStartedRecord | AbortRequestedRecord | OperationFinishedRecord | StepAttemptRecord | ToolStartedRecord | QueueEnqueuedRecord | QueueCancelledRecord | WriteDeferredRecord | UsageRecord;
186
+ export type NewRecord<TRecord extends LaneRecord = LaneRecord> = TRecord extends LaneRecord ? Omit<TRecord, "seq" | "timestamp"> : never;
187
+ export type EntryOrder = "newestFirst" | "oldestFirst";
353
188
  export interface EntryCursor {
354
- seq: number;
189
+ afterSeq: number;
355
190
  }
356
- export interface BranchScan {
357
- start?: string;
358
- stopAtType?: EntryType;
359
- stopAtId?: string;
360
- type?: EntryType;
191
+ export interface EntryQuery {
192
+ type?: Entry["type"];
361
193
  customType?: string;
362
- order?: "newestFirst" | "oldestFirst";
194
+ order?: EntryOrder;
363
195
  limit?: number;
364
196
  cursor?: EntryCursor;
365
197
  }
366
- export type StorageBranchScan = BranchScan & {
367
- start: string;
368
- };
369
- export interface EntryScan {
370
- type?: EntryType;
371
- customType?: string;
372
- fromSeq?: number;
373
- toSeq?: number;
374
- order?: "asc" | "desc";
375
- limit?: number;
198
+ /** Bounds of a branch scan. Default: the whole path, leaf to root. */
199
+ export interface BranchBounds {
200
+ start?: string;
201
+ stopAtType?: Entry["type"];
202
+ stopAtId?: string;
376
203
  }
377
- export interface UsageScan {
378
- fromSeq?: number;
379
- toSeq?: number;
380
- order?: "asc" | "desc";
204
+ export interface RecordQuery {
205
+ /** Exact lane match. Omit to query every lane. */
206
+ lane?: string;
207
+ /** Exact record discriminant match. Omit to query every record type. */
208
+ type?: LaneRecord["type"];
209
+ /**
210
+ * Operation identity. Matches OperationStartedRecord.id and the runId
211
+ * property of operation-owned records. Records without an operation
212
+ * identity do not match.
213
+ */
214
+ runId?: string;
215
+ /** Exact operation intent kind. Valid only with type "operation_started". */
216
+ operationKind?: OperationStartedRecord["intent"]["kind"];
217
+ /** Exclusive chronological lower bound: seq > afterSeq, regardless of order. */
218
+ afterSeq?: number;
219
+ /** Sequence order. Default: "newestFirst". */
220
+ order?: EntryOrder;
221
+ /** Positive maximum number of matching records. */
381
222
  limit?: number;
382
223
  }
383
- export interface SessionStats {
384
- messageCount: number;
385
- usage: Usage;
386
- }
387
- export interface Storage {
388
- commit(writes: Write[], context: Context): Promise<CommitResult>;
389
- getEntries(ids: string[], context: Context): Promise<Map<string, Entry>>;
390
- getValue<T>(address: Value<T>, context: Context): Promise<StoredValue<T> | undefined>;
391
- scanValues<T>(prefix: Value<T>, context: Context): Promise<StoredValue<T>[]>;
392
- readList<T>(address: ValueList<T>, options: ListReadOptions | undefined, context: Context): Promise<ListElement<T>[]>;
393
- scanBranch(query: StorageBranchScan, context: Context): Promise<Entry[]>;
394
- scanBranchStructure(query: StorageBranchScan, context: Context): Promise<EntryStructure[]>;
395
- scanEntries(query: EntryScan, context: Context): Promise<Entry[]>;
396
- scanUsage(query: UsageScan, context: Context): Promise<UsageRow[]>;
397
- getStats(context: Context): Promise<SessionStats>;
398
- close(context: Context): Promise<void>;
399
- }
400
224
  export interface SessionMetadata {
401
225
  id: string;
402
226
  createdAt: number;
403
- storageVersion: number;
404
- cwd?: string;
405
227
  parentSessionId?: string;
406
- legacyParentSessionPath?: string;
407
- }
408
- export interface IdGenerator {
409
- next(timestampMs?: number): string;
410
- }
411
- export interface EntryQuery {
412
- type?: EntryType;
413
- customType?: string;
414
- order?: "asc" | "desc";
415
- limit?: number;
416
- cursor?: EntryCursor;
417
228
  }
418
- export interface SessionReader {
419
- getEntries(ids: string[], context: Context): Promise<Map<string, Entry>>;
420
- getStats(context: Context): Promise<SessionStats>;
421
- getValue<T>(address: Value<T>, context: Context): Promise<StoredValue<T> | undefined>;
422
- scanValues<T>(prefix: Value<T>, context: Context): Promise<StoredValue<T>[]>;
423
- readList<T>(address: ValueList<T>, options: ListReadOptions | undefined, context: Context): Promise<ListElement<T>[]>;
424
- /** Scan a branch from an explicit entry while this reader capability remains valid. */
425
- scanBranch(query: StorageBranchScan, context: Context): Promise<Entry[]>;
229
+ export interface SessionStats {
230
+ messageCount: number;
231
+ cachedTokens: number;
232
+ uncachedTokens: number;
233
+ totalTokens: number;
234
+ costTotal: number;
426
235
  }
427
- /** Exclusive keyless mutation barrier for one Session. */
428
- export interface SessionMutation extends SessionReader {
429
- /** Exactly zero or one commit attempt. A second attempt rejects. */
430
- commit(writes: Write[], context: Context): Promise<CommitResult>;
431
- /** Wait for any commit attempt, invalidate the capability, and release the barrier. */
432
- end(context: Context): Promise<void>;
236
+ export interface LanePointer {
237
+ lane: string;
238
+ leafId: string | null;
433
239
  }
434
- /** Callback-scoped mutation capability without authority to release its Session barrier. */
435
- export type SessionMutator = Omit<SessionMutation, "end">;
436
- export type SessionMutationCallback<T> = (mutator: SessionMutator, context: Context) => T | Promise<T>;
437
- export interface Branch {
438
- readonly name: string;
439
- getTipId(context: Context): Promise<string | null>;
440
- findEntries(query: BranchScan | undefined, context: Context): Promise<Entry[]>;
441
- findEntry(query: BranchScan | undefined, context: Context): Promise<Entry | undefined>;
442
- appendMessage(message: AgentMessage, context: Context): Promise<string>;
443
- appendCustomEntry(customType: string, data: JsonValue | undefined, context: Context): Promise<string>;
240
+ export type LogItem = {
241
+ kind: "entry";
242
+ seq: number;
243
+ entry: Entry;
244
+ } | {
245
+ kind: "record";
246
+ seq: number;
247
+ record: LaneRecord;
248
+ } | {
249
+ kind: "lane";
250
+ seq: number;
251
+ lane: string;
252
+ leafId: string | null;
253
+ } | {
254
+ kind: "fact";
255
+ seq: number;
256
+ fact: "name";
257
+ name: string | undefined;
258
+ } | {
259
+ kind: "fact";
260
+ seq: number;
261
+ fact: "label";
262
+ targetId: string;
263
+ label: string | undefined;
264
+ };
265
+ export interface LogOptions {
266
+ afterSeq?: number;
267
+ limit?: number;
444
268
  }
445
- export interface Session<TMetadata extends SessionMetadata = SessionMetadata> extends SessionReader {
446
- readonly metadata: TMetadata;
447
- readonly idGenerator: IdGenerator;
448
- getEntry(id: string, context: Context): Promise<Entry | undefined>;
449
- getStats(context: Context): Promise<SessionStats>;
450
- getName(context: Context): Promise<string | undefined>;
451
- getLabel(targetId: string, context: Context): Promise<string | undefined>;
452
- findEntries(query: EntryQuery | undefined, context: Context): Promise<Entry[]>;
453
- findEntry(query: EntryQuery | undefined, context: Context): Promise<Entry | undefined>;
454
- branch(name: string, context: Context): Promise<Branch | undefined>;
455
- createBranch(name: string, at: string | null, context: Context): Promise<Branch>;
456
- beginMutation(context: Context): Promise<SessionMutation>;
269
+ export interface SessionStorage<TMetadata extends SessionMetadata = SessionMetadata> {
270
+ getMetadata(): Promise<TMetadata>;
271
+ getLanes(): Promise<{
272
+ lane: string;
273
+ leafId: string | null;
274
+ }[]>;
275
+ createLane(lane: string, at: string | null): Promise<void>;
276
+ moveLane(lane: string, to: string | null): Promise<void>;
277
+ appendEntry<TEntry extends Entry>(entry: ProvisionedEntry<TEntry>, lane: string): Promise<TEntry>;
278
+ appendRecord<TRecord extends LaneRecord>(record: NewRecord<TRecord>): Promise<TRecord>;
279
+ getEntry(id: string): Promise<Entry | undefined>;
280
+ findEntries(query?: EntryQuery): Promise<Entry[]>;
281
+ /** start is mandatory here (as opposed to SessionTree's findEntriesOnBranch); defaulting to a lane's leaf is view sugar. */
282
+ findEntriesOnBranch(query: EntryQuery & BranchBounds & {
283
+ start: string;
284
+ }): Promise<Entry[]>;
285
+ findRecords<K extends LaneRecord["type"]>(query: RecordQuery & {
286
+ type: K;
287
+ }): Promise<Extract<LaneRecord, {
288
+ type: K;
289
+ }>[]>;
290
+ findRecords(query?: RecordQuery): Promise<LaneRecord[]>;
457
291
  /**
458
- * Trusted exclusive callback over the Session mutation line. Calling a public Session writer from
459
- * this callback queues it behind the callback; awaiting that nested writer therefore deadlocks.
460
- * Use the supplied mutator for the callback's sole commit.
292
+ * Returns unfinished operation starts newest first. Recovery uses `limit: 2`:
293
+ * zero results mean the lane is idle, one means it is suspended, and two
294
+ * mean at least two operations are open, which is corruption. Further
295
+ * results provide no additional recovery state.
461
296
  */
462
- mutate<T>(mutation: SessionMutationCallback<T>, context: Context): Promise<T>;
463
- setValue<T>(address: Value<T>, next: NoInfer<T>, context: Context): Promise<void>;
464
- deleteValue<T>(address: Value<T>, context: Context): Promise<void>;
465
- appendList<T>(address: ValueList<T>, element: NoInfer<T>, context: Context): Promise<void>;
466
- deleteList<T>(address: ValueList<T>, context: Context): Promise<void>;
467
- setName(name: string | undefined, context: Context): Promise<void>;
468
- setLabel(targetId: string, label: string | undefined, context: Context): Promise<void>;
469
- close(context: Context): Promise<void>;
297
+ findOpenOperations(lane: string, options?: {
298
+ limit?: number;
299
+ }): Promise<OperationStartedRecord[]>;
300
+ getLog(options?: {
301
+ afterSeq?: number;
302
+ limit?: number;
303
+ }): Promise<LogItem[]>;
304
+ getName(): Promise<string | undefined>;
305
+ setName(name: string | undefined): Promise<void>;
306
+ getLabel(id: string): Promise<string | undefined>;
307
+ setLabel(id: string, label: string | undefined): Promise<void>;
308
+ getStats(): Promise<SessionStats>;
309
+ }
310
+ export interface SessionTree {
311
+ getLeafId(): Promise<string | null>;
312
+ getEntry(id: string): Promise<Entry | undefined>;
313
+ getStats(): Promise<SessionStats>;
314
+ getName(): Promise<string | undefined>;
315
+ setName(name: string | undefined): Promise<void>;
316
+ getLabel(targetId: string): Promise<string | undefined>;
317
+ setLabel(targetId: string, label: string | undefined): Promise<void>;
318
+ /** Session-wide, all branches, sequence order. */
319
+ findEntries(query?: EntryQuery): Promise<Entry[]>;
320
+ findEntry(query?: EntryQuery): Promise<Entry | undefined>;
321
+ /** Branch-scoped: the path from start toward root. */
322
+ findEntriesOnBranch(query?: EntryQuery & BranchBounds): Promise<Entry[]>;
323
+ findEntryOnBranch(query?: EntryQuery & BranchBounds): Promise<Entry | undefined>;
324
+ appendMessage(message: AgentMessage): Promise<string>;
325
+ appendCustomEntry(customType: string, data?: unknown): Promise<string>;
470
326
  }
471
327
  export interface SessionCreateOptions {
472
328
  id?: string;
473
329
  parentSessionId?: string;
474
330
  }
475
331
  export type ForkOptions = {
476
- /**
477
- * Copy one path from a complete configured source AgentLane under the same
478
- * Branch name, with copied configuration and fresh idle lane state.
479
- */
480
- scope: "branch";
481
- /** Source Branch to copy. */
482
- branch: string;
483
- /** Entry on the source Branch's current tip ancestry. Defaults to the current tip. */
332
+ scope?: "branch";
484
333
  entryId?: string;
485
- /**
486
- * Whether the fork includes the selected entry or stops at its parent.
487
- * Defaults to including the selected entry.
488
- */
489
334
  position?: "before" | "at";
490
- /** Optional destination session id. */
491
- id?: string;
492
335
  } | {
493
- /**
494
- * Copy the whole conversation tree and every Branch tip. Each configured
495
- * AgentLane copies configuration plus fresh idle state; data-only Branches
496
- * remain data-only. Operation/pending/result/usage state is excluded.
497
- */
498
336
  scope: "tree";
499
- /** Optional destination session id. */
500
- id?: string;
501
337
  };
502
- export interface SessionRepo<TMetadata extends SessionMetadata = SessionMetadata, TCreateOptions extends {
503
- id?: string;
504
- parentSessionId?: string;
505
- } = SessionCreateOptions, TListOptions = void> {
506
- create(options: TCreateOptions, context: Context): Promise<Session<TMetadata>>;
507
- open(metadata: TMetadata, context: Context): Promise<Session<TMetadata>>;
508
- list(options: TListOptions | undefined, context: Context): Promise<TMetadata[]>;
509
- delete(metadata: TMetadata, context: Context): Promise<void>;
510
- fork(source: TMetadata, options: ForkOptions, context: Context): Promise<Session<TMetadata>>;
338
+ export interface SessionRepo<TMetadata extends SessionMetadata = SessionMetadata, TCreateOptions extends SessionCreateOptions = SessionCreateOptions, TListOptions = void> {
339
+ create(options: TCreateOptions): Promise<Session<TMetadata>>;
340
+ /** Opens the session for writing and acquires any backend writer claim. */
341
+ open(metadata: TMetadata): Promise<Session<TMetadata>>;
342
+ /** Lists session metadata without opening sessions or acquiring writer claims. */
343
+ list(options?: TListOptions): Promise<TMetadata[]>;
344
+ delete(metadata: TMetadata): Promise<void>;
345
+ fork(source: TMetadata, options: ForkOptions & TCreateOptions): Promise<Session<TMetadata>>;
346
+ }
347
+ export type SessionErrorCode = "not_found" | "already_exists" | "invalid_entry" | "invalid_payload" | "invalid_lane" | "invalid_query" | "invalid_fork_target" | "storage";
348
+ export declare class SessionError extends Error {
349
+ readonly code: SessionErrorCode;
350
+ constructor(code: SessionErrorCode, message: string, cause?: Error);
511
351
  }
512
352
  //# sourceMappingURL=types.d.ts.map