@draht/agent-core 2026.10.20 → 2026.10.23

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 (468) hide show
  1. package/dist/agent-loop.d.ts +6 -1
  2. package/dist/agent-loop.d.ts.map +1 -1
  3. package/dist/agent-loop.js +16 -2
  4. package/dist/agent-loop.js.map +1 -1
  5. package/dist/agent.d.ts +8 -1
  6. package/dist/agent.d.ts.map +1 -1
  7. package/dist/agent.js +4 -0
  8. package/dist/agent.js.map +1 -1
  9. package/dist/index.d.ts +0 -22
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +0 -20
  12. package/dist/index.js.map +1 -1
  13. package/dist/proxy.d.ts +2 -5
  14. package/dist/proxy.d.ts.map +1 -1
  15. package/dist/proxy.js +2 -14
  16. package/dist/proxy.js.map +1 -1
  17. package/dist/types.d.ts +4 -0
  18. package/dist/types.d.ts.map +1 -1
  19. package/dist/types.js.map +1 -1
  20. package/package.json +4 -47
  21. package/dist/harness/agent-harness.d.ts +0 -716
  22. package/dist/harness/agent-harness.d.ts.map +0 -1
  23. package/dist/harness/agent-harness.js +0 -6
  24. package/dist/harness/agent-harness.js.map +0 -1
  25. package/dist/harness/compaction/branch-summarization.d.ts +0 -68
  26. package/dist/harness/compaction/branch-summarization.d.ts.map +0 -1
  27. package/dist/harness/compaction/branch-summarization.js +0 -176
  28. package/dist/harness/compaction/branch-summarization.js.map +0 -1
  29. package/dist/harness/compaction/compaction.d.ts +0 -126
  30. package/dist/harness/compaction/compaction.d.ts.map +0 -1
  31. package/dist/harness/compaction/compaction.js +0 -561
  32. package/dist/harness/compaction/compaction.js.map +0 -1
  33. package/dist/harness/compaction/utils.d.ts +0 -28
  34. package/dist/harness/compaction/utils.d.ts.map +0 -1
  35. package/dist/harness/compaction/utils.js +0 -123
  36. package/dist/harness/compaction/utils.js.map +0 -1
  37. package/dist/harness/config.d.ts +0 -9
  38. package/dist/harness/config.d.ts.map +0 -1
  39. package/dist/harness/config.js +0 -35
  40. package/dist/harness/config.js.map +0 -1
  41. package/dist/harness/context.d.ts +0 -9
  42. package/dist/harness/context.d.ts.map +0 -1
  43. package/dist/harness/context.js +0 -13
  44. package/dist/harness/context.js.map +0 -1
  45. package/dist/harness/env/nodejs.d.ts +0 -43
  46. package/dist/harness/env/nodejs.d.ts.map +0 -1
  47. package/dist/harness/env/nodejs.js +0 -865
  48. package/dist/harness/env/nodejs.js.map +0 -1
  49. package/dist/harness/events.d.ts +0 -24
  50. package/dist/harness/events.d.ts.map +0 -1
  51. package/dist/harness/events.js +0 -233
  52. package/dist/harness/events.js.map +0 -1
  53. package/dist/harness/execution/assistant.d.ts +0 -42
  54. package/dist/harness/execution/assistant.d.ts.map +0 -1
  55. package/dist/harness/execution/assistant.js +0 -82
  56. package/dist/harness/execution/assistant.js.map +0 -1
  57. package/dist/harness/execution/effect-gate.d.ts +0 -22
  58. package/dist/harness/execution/effect-gate.d.ts.map +0 -1
  59. package/dist/harness/execution/effect-gate.js +0 -49
  60. package/dist/harness/execution/effect-gate.js.map +0 -1
  61. package/dist/harness/execution/tools.d.ts +0 -67
  62. package/dist/harness/execution/tools.d.ts.map +0 -1
  63. package/dist/harness/execution/tools.js +0 -119
  64. package/dist/harness/execution/tools.js.map +0 -1
  65. package/dist/harness/execution-env.d.ts +0 -4
  66. package/dist/harness/execution-env.d.ts.map +0 -1
  67. package/dist/harness/execution-env.js +0 -3
  68. package/dist/harness/execution-env.js.map +0 -1
  69. package/dist/harness/hooks.d.ts +0 -38
  70. package/dist/harness/hooks.d.ts.map +0 -1
  71. package/dist/harness/hooks.js +0 -406
  72. package/dist/harness/hooks.js.map +0 -1
  73. package/dist/harness/messages.d.ts +0 -51
  74. package/dist/harness/messages.d.ts.map +0 -1
  75. package/dist/harness/messages.js +0 -103
  76. package/dist/harness/messages.js.map +0 -1
  77. package/dist/harness/pico3/bash.d.ts +0 -10
  78. package/dist/harness/pico3/bash.d.ts.map +0 -1
  79. package/dist/harness/pico3/bash.js +0 -25
  80. package/dist/harness/pico3/bash.js.map +0 -1
  81. package/dist/harness/pico3/bounded.d.ts +0 -21
  82. package/dist/harness/pico3/bounded.d.ts.map +0 -1
  83. package/dist/harness/pico3/bounded.js +0 -98
  84. package/dist/harness/pico3/bounded.js.map +0 -1
  85. package/dist/harness/pico3/chord.d.ts +0 -41
  86. package/dist/harness/pico3/chord.d.ts.map +0 -1
  87. package/dist/harness/pico3/chord.js +0 -147
  88. package/dist/harness/pico3/chord.js.map +0 -1
  89. package/dist/harness/pico3/context.d.ts +0 -16
  90. package/dist/harness/pico3/context.d.ts.map +0 -1
  91. package/dist/harness/pico3/context.js +0 -88
  92. package/dist/harness/pico3/context.js.map +0 -1
  93. package/dist/harness/pico3/harness.d.ts +0 -198
  94. package/dist/harness/pico3/harness.d.ts.map +0 -1
  95. package/dist/harness/pico3/harness.js +0 -654
  96. package/dist/harness/pico3/harness.js.map +0 -1
  97. package/dist/harness/pico3/hooks.d.ts +0 -10
  98. package/dist/harness/pico3/hooks.d.ts.map +0 -1
  99. package/dist/harness/pico3/hooks.js +0 -33
  100. package/dist/harness/pico3/hooks.js.map +0 -1
  101. package/dist/harness/pico3/index.d.ts +0 -19
  102. package/dist/harness/pico3/index.d.ts.map +0 -1
  103. package/dist/harness/pico3/index.js +0 -15
  104. package/dist/harness/pico3/index.js.map +0 -1
  105. package/dist/harness/pico3/jsonl.d.ts +0 -58
  106. package/dist/harness/pico3/jsonl.d.ts.map +0 -1
  107. package/dist/harness/pico3/jsonl.js +0 -325
  108. package/dist/harness/pico3/jsonl.js.map +0 -1
  109. package/dist/harness/pico3/kinds/collapse.d.ts +0 -49
  110. package/dist/harness/pico3/kinds/collapse.d.ts.map +0 -1
  111. package/dist/harness/pico3/kinds/collapse.js +0 -191
  112. package/dist/harness/pico3/kinds/collapse.js.map +0 -1
  113. package/dist/harness/pico3/kinds/entries.d.ts +0 -78
  114. package/dist/harness/pico3/kinds/entries.d.ts.map +0 -1
  115. package/dist/harness/pico3/kinds/entries.js +0 -13
  116. package/dist/harness/pico3/kinds/entries.js.map +0 -1
  117. package/dist/harness/pico3/kinds/frames.d.ts +0 -9
  118. package/dist/harness/pico3/kinds/frames.d.ts.map +0 -1
  119. package/dist/harness/pico3/kinds/frames.js +0 -75
  120. package/dist/harness/pico3/kinds/frames.js.map +0 -1
  121. package/dist/harness/pico3/kinds/generation.d.ts +0 -94
  122. package/dist/harness/pico3/kinds/generation.d.ts.map +0 -1
  123. package/dist/harness/pico3/kinds/generation.js +0 -504
  124. package/dist/harness/pico3/kinds/generation.js.map +0 -1
  125. package/dist/harness/pico3/kinds/job.d.ts +0 -44
  126. package/dist/harness/pico3/kinds/job.d.ts.map +0 -1
  127. package/dist/harness/pico3/kinds/job.js +0 -143
  128. package/dist/harness/pico3/kinds/job.js.map +0 -1
  129. package/dist/harness/pico3/kinds/plugin.d.ts +0 -15
  130. package/dist/harness/pico3/kinds/plugin.d.ts.map +0 -1
  131. package/dist/harness/pico3/kinds/plugin.js +0 -35
  132. package/dist/harness/pico3/kinds/plugin.js.map +0 -1
  133. package/dist/harness/pico3/kinds/post-tools.d.ts +0 -22
  134. package/dist/harness/pico3/kinds/post-tools.d.ts.map +0 -1
  135. package/dist/harness/pico3/kinds/post-tools.js +0 -145
  136. package/dist/harness/pico3/kinds/post-tools.js.map +0 -1
  137. package/dist/harness/pico3/kinds/task-api.d.ts +0 -3
  138. package/dist/harness/pico3/kinds/task-api.d.ts.map +0 -1
  139. package/dist/harness/pico3/kinds/task-api.js +0 -45
  140. package/dist/harness/pico3/kinds/task-api.js.map +0 -1
  141. package/dist/harness/pico3/kinds/tool.d.ts +0 -43
  142. package/dist/harness/pico3/kinds/tool.d.ts.map +0 -1
  143. package/dist/harness/pico3/kinds/tool.js +0 -373
  144. package/dist/harness/pico3/kinds/tool.js.map +0 -1
  145. package/dist/harness/pico3/legacy-tracker.d.ts +0 -11
  146. package/dist/harness/pico3/legacy-tracker.d.ts.map +0 -1
  147. package/dist/harness/pico3/legacy-tracker.js +0 -41
  148. package/dist/harness/pico3/legacy-tracker.js.map +0 -1
  149. package/dist/harness/pico3/membrane.d.ts +0 -23
  150. package/dist/harness/pico3/membrane.d.ts.map +0 -1
  151. package/dist/harness/pico3/membrane.js +0 -141
  152. package/dist/harness/pico3/membrane.js.map +0 -1
  153. package/dist/harness/pico3/memory.d.ts +0 -53
  154. package/dist/harness/pico3/memory.d.ts.map +0 -1
  155. package/dist/harness/pico3/memory.js +0 -264
  156. package/dist/harness/pico3/memory.js.map +0 -1
  157. package/dist/harness/pico3/scheduler.d.ts +0 -49
  158. package/dist/harness/pico3/scheduler.d.ts.map +0 -1
  159. package/dist/harness/pico3/scheduler.js +0 -438
  160. package/dist/harness/pico3/scheduler.js.map +0 -1
  161. package/dist/harness/pico3/session.d.ts +0 -264
  162. package/dist/harness/pico3/session.d.ts.map +0 -1
  163. package/dist/harness/pico3/session.js +0 -1348
  164. package/dist/harness/pico3/session.js.map +0 -1
  165. package/dist/harness/pico3/system.d.ts +0 -126
  166. package/dist/harness/pico3/system.d.ts.map +0 -1
  167. package/dist/harness/pico3/system.js +0 -244
  168. package/dist/harness/pico3/system.js.map +0 -1
  169. package/dist/harness/pico3/types.d.ts +0 -973
  170. package/dist/harness/pico3/types.d.ts.map +0 -1
  171. package/dist/harness/pico3/types.js +0 -106
  172. package/dist/harness/pico3/types.js.map +0 -1
  173. package/dist/harness/pico3/view.d.ts +0 -34
  174. package/dist/harness/pico3/view.d.ts.map +0 -1
  175. package/dist/harness/pico3/view.js +0 -411
  176. package/dist/harness/pico3/view.js.map +0 -1
  177. package/dist/harness/prompt-templates.d.ts +0 -49
  178. package/dist/harness/prompt-templates.d.ts.map +0 -1
  179. package/dist/harness/prompt-templates.js +0 -225
  180. package/dist/harness/prompt-templates.js.map +0 -1
  181. package/dist/harness/result.d.ts +0 -133
  182. package/dist/harness/result.d.ts.map +0 -1
  183. package/dist/harness/result.js +0 -81
  184. package/dist/harness/result.js.map +0 -1
  185. package/dist/harness/runtime/drive/boundary.d.ts +0 -28
  186. package/dist/harness/runtime/drive/boundary.d.ts.map +0 -1
  187. package/dist/harness/runtime/drive/boundary.js +0 -173
  188. package/dist/harness/runtime/drive/boundary.js.map +0 -1
  189. package/dist/harness/runtime/drive/checkpoint.d.ts +0 -8
  190. package/dist/harness/runtime/drive/checkpoint.d.ts.map +0 -1
  191. package/dist/harness/runtime/drive/checkpoint.js +0 -133
  192. package/dist/harness/runtime/drive/checkpoint.js.map +0 -1
  193. package/dist/harness/runtime/drive/deferred.d.ts +0 -15
  194. package/dist/harness/runtime/drive/deferred.d.ts.map +0 -1
  195. package/dist/harness/runtime/drive/deferred.js +0 -179
  196. package/dist/harness/runtime/drive/deferred.js.map +0 -1
  197. package/dist/harness/runtime/drive/generation.d.ts +0 -8
  198. package/dist/harness/runtime/drive/generation.d.ts.map +0 -1
  199. package/dist/harness/runtime/drive/generation.js +0 -205
  200. package/dist/harness/runtime/drive/generation.js.map +0 -1
  201. package/dist/harness/runtime/drive/reconcile.d.ts +0 -5
  202. package/dist/harness/runtime/drive/reconcile.d.ts.map +0 -1
  203. package/dist/harness/runtime/drive/reconcile.js +0 -140
  204. package/dist/harness/runtime/drive/reconcile.js.map +0 -1
  205. package/dist/harness/runtime/drive/recovery.d.ts +0 -8
  206. package/dist/harness/runtime/drive/recovery.d.ts.map +0 -1
  207. package/dist/harness/runtime/drive/recovery.js +0 -85
  208. package/dist/harness/runtime/drive/recovery.js.map +0 -1
  209. package/dist/harness/runtime/drive/response.d.ts +0 -23
  210. package/dist/harness/runtime/drive/response.d.ts.map +0 -1
  211. package/dist/harness/runtime/drive/response.js +0 -394
  212. package/dist/harness/runtime/drive/response.js.map +0 -1
  213. package/dist/harness/runtime/drive/retry.d.ts +0 -4
  214. package/dist/harness/runtime/drive/retry.d.ts.map +0 -1
  215. package/dist/harness/runtime/drive/retry.js +0 -34
  216. package/dist/harness/runtime/drive/retry.js.map +0 -1
  217. package/dist/harness/runtime/drive/structural.d.ts +0 -32
  218. package/dist/harness/runtime/drive/structural.d.ts.map +0 -1
  219. package/dist/harness/runtime/drive/structural.js +0 -929
  220. package/dist/harness/runtime/drive/structural.js.map +0 -1
  221. package/dist/harness/runtime/drive/terminal.d.ts +0 -7
  222. package/dist/harness/runtime/drive/terminal.d.ts.map +0 -1
  223. package/dist/harness/runtime/drive/terminal.js +0 -49
  224. package/dist/harness/runtime/drive/terminal.js.map +0 -1
  225. package/dist/harness/runtime/drive/tool-placement.d.ts +0 -14
  226. package/dist/harness/runtime/drive/tool-placement.d.ts.map +0 -1
  227. package/dist/harness/runtime/drive/tool-placement.js +0 -219
  228. package/dist/harness/runtime/drive/tool-placement.js.map +0 -1
  229. package/dist/harness/runtime/drive/tools.d.ts +0 -6
  230. package/dist/harness/runtime/drive/tools.d.ts.map +0 -1
  231. package/dist/harness/runtime/drive/tools.js +0 -449
  232. package/dist/harness/runtime/drive/tools.js.map +0 -1
  233. package/dist/harness/runtime/drive.d.ts +0 -6
  234. package/dist/harness/runtime/drive.d.ts.map +0 -1
  235. package/dist/harness/runtime/drive.js +0 -93
  236. package/dist/harness/runtime/drive.js.map +0 -1
  237. package/dist/harness/runtime/harness.d.ts +0 -59
  238. package/dist/harness/runtime/harness.d.ts.map +0 -1
  239. package/dist/harness/runtime/harness.js +0 -311
  240. package/dist/harness/runtime/harness.js.map +0 -1
  241. package/dist/harness/runtime/index.d.ts +0 -2
  242. package/dist/harness/runtime/index.d.ts.map +0 -1
  243. package/dist/harness/runtime/index.js +0 -2
  244. package/dist/harness/runtime/index.js.map +0 -1
  245. package/dist/harness/runtime/lane.d.ts +0 -118
  246. package/dist/harness/runtime/lane.d.ts.map +0 -1
  247. package/dist/harness/runtime/lane.js +0 -1575
  248. package/dist/harness/runtime/lane.js.map +0 -1
  249. package/dist/harness/runtime/progress.d.ts +0 -15
  250. package/dist/harness/runtime/progress.d.ts.map +0 -1
  251. package/dist/harness/runtime/progress.js +0 -66
  252. package/dist/harness/runtime/progress.js.map +0 -1
  253. package/dist/harness/runtime/reducer.d.ts +0 -5
  254. package/dist/harness/runtime/reducer.d.ts.map +0 -1
  255. package/dist/harness/runtime/reducer.js +0 -240
  256. package/dist/harness/runtime/reducer.js.map +0 -1
  257. package/dist/harness/runtime/restore.d.ts +0 -24
  258. package/dist/harness/runtime/restore.d.ts.map +0 -1
  259. package/dist/harness/runtime/restore.js +0 -117
  260. package/dist/harness/runtime/restore.js.map +0 -1
  261. package/dist/harness/runtime/transcript.d.ts +0 -21
  262. package/dist/harness/runtime/transcript.d.ts.map +0 -1
  263. package/dist/harness/runtime/transcript.js +0 -72
  264. package/dist/harness/runtime/transcript.js.map +0 -1
  265. package/dist/harness/runtime/types.d.ts +0 -105
  266. package/dist/harness/runtime/types.d.ts.map +0 -1
  267. package/dist/harness/runtime/types.js +0 -61
  268. package/dist/harness/runtime/types.js.map +0 -1
  269. package/dist/harness/session/commit.d.ts +0 -53
  270. package/dist/harness/session/commit.d.ts.map +0 -1
  271. package/dist/harness/session/commit.js +0 -57
  272. package/dist/harness/session/commit.js.map +0 -1
  273. package/dist/harness/session/context.d.ts +0 -10
  274. package/dist/harness/session/context.d.ts.map +0 -1
  275. package/dist/harness/session/context.js +0 -49
  276. package/dist/harness/session/context.js.map +0 -1
  277. package/dist/harness/session/fork-policy.d.ts +0 -21
  278. package/dist/harness/session/fork-policy.d.ts.map +0 -1
  279. package/dist/harness/session/fork-policy.js +0 -55
  280. package/dist/harness/session/fork-policy.js.map +0 -1
  281. package/dist/harness/session/fork.d.ts +0 -16
  282. package/dist/harness/session/fork.d.ts.map +0 -1
  283. package/dist/harness/session/fork.js +0 -79
  284. package/dist/harness/session/fork.js.map +0 -1
  285. package/dist/harness/session/in-memory-storage-state.d.ts +0 -39
  286. package/dist/harness/session/in-memory-storage-state.d.ts.map +0 -1
  287. package/dist/harness/session/in-memory-storage-state.js +0 -276
  288. package/dist/harness/session/in-memory-storage-state.js.map +0 -1
  289. package/dist/harness/session/index.d.ts +0 -11
  290. package/dist/harness/session/index.d.ts.map +0 -1
  291. package/dist/harness/session/index.js +0 -9
  292. package/dist/harness/session/index.js.map +0 -1
  293. package/dist/harness/session/jsonl/codec.d.ts +0 -21
  294. package/dist/harness/session/jsonl/codec.d.ts.map +0 -1
  295. package/dist/harness/session/jsonl/codec.js +0 -45
  296. package/dist/harness/session/jsonl/codec.js.map +0 -1
  297. package/dist/harness/session/jsonl/fork.d.ts +0 -38
  298. package/dist/harness/session/jsonl/fork.d.ts.map +0 -1
  299. package/dist/harness/session/jsonl/fork.js +0 -264
  300. package/dist/harness/session/jsonl/fork.js.map +0 -1
  301. package/dist/harness/session/jsonl/index.d.ts +0 -4
  302. package/dist/harness/session/jsonl/index.d.ts.map +0 -1
  303. package/dist/harness/session/jsonl/index.js +0 -4
  304. package/dist/harness/session/jsonl/index.js.map +0 -1
  305. package/dist/harness/session/jsonl/io.d.ts +0 -14
  306. package/dist/harness/session/jsonl/io.d.ts.map +0 -1
  307. package/dist/harness/session/jsonl/io.js +0 -86
  308. package/dist/harness/session/jsonl/io.js.map +0 -1
  309. package/dist/harness/session/jsonl/legacy-v3.d.ts +0 -44
  310. package/dist/harness/session/jsonl/legacy-v3.d.ts.map +0 -1
  311. package/dist/harness/session/jsonl/legacy-v3.js +0 -462
  312. package/dist/harness/session/jsonl/legacy-v3.js.map +0 -1
  313. package/dist/harness/session/jsonl/repo.d.ts +0 -35
  314. package/dist/harness/session/jsonl/repo.d.ts.map +0 -1
  315. package/dist/harness/session/jsonl/repo.js +0 -301
  316. package/dist/harness/session/jsonl/repo.js.map +0 -1
  317. package/dist/harness/session/jsonl/storage.d.ts +0 -41
  318. package/dist/harness/session/jsonl/storage.d.ts.map +0 -1
  319. package/dist/harness/session/jsonl/storage.js +0 -200
  320. package/dist/harness/session/jsonl/storage.js.map +0 -1
  321. package/dist/harness/session/jsonl/types.d.ts +0 -39
  322. package/dist/harness/session/jsonl/types.d.ts.map +0 -1
  323. package/dist/harness/session/jsonl/types.js +0 -3
  324. package/dist/harness/session/jsonl/types.js.map +0 -1
  325. package/dist/harness/session/memory.d.ts +0 -48
  326. package/dist/harness/session/memory.d.ts.map +0 -1
  327. package/dist/harness/session/memory.js +0 -369
  328. package/dist/harness/session/memory.js.map +0 -1
  329. package/dist/harness/session/mutation-line.d.ts +0 -8
  330. package/dist/harness/session/mutation-line.d.ts.map +0 -1
  331. package/dist/harness/session/mutation-line.js +0 -21
  332. package/dist/harness/session/mutation-line.js.map +0 -1
  333. package/dist/harness/session/session.d.ts +0 -82
  334. package/dist/harness/session/session.d.ts.map +0 -1
  335. package/dist/harness/session/session.js +0 -361
  336. package/dist/harness/session/session.js.map +0 -1
  337. package/dist/harness/session/testing/benchmark/datasets.d.ts +0 -12
  338. package/dist/harness/session/testing/benchmark/datasets.d.ts.map +0 -1
  339. package/dist/harness/session/testing/benchmark/datasets.js +0 -24
  340. package/dist/harness/session/testing/benchmark/datasets.js.map +0 -1
  341. package/dist/harness/session/testing/benchmark/session-repo.d.ts +0 -42
  342. package/dist/harness/session/testing/benchmark/session-repo.d.ts.map +0 -1
  343. package/dist/harness/session/testing/benchmark/session-repo.js +0 -127
  344. package/dist/harness/session/testing/benchmark/session-repo.js.map +0 -1
  345. package/dist/harness/session/testing/benchmark/storage.d.ts +0 -25
  346. package/dist/harness/session/testing/benchmark/storage.d.ts.map +0 -1
  347. package/dist/harness/session/testing/benchmark/storage.js +0 -114
  348. package/dist/harness/session/testing/benchmark/storage.js.map +0 -1
  349. package/dist/harness/session/testing/conformance/session-repo.d.ts +0 -23
  350. package/dist/harness/session/testing/conformance/session-repo.d.ts.map +0 -1
  351. package/dist/harness/session/testing/conformance/session-repo.js +0 -809
  352. package/dist/harness/session/testing/conformance/session-repo.js.map +0 -1
  353. package/dist/harness/session/testing/conformance/storage.d.ts +0 -4
  354. package/dist/harness/session/testing/conformance/storage.d.ts.map +0 -1
  355. package/dist/harness/session/testing/conformance/storage.js +0 -600
  356. package/dist/harness/session/testing/conformance/storage.js.map +0 -1
  357. package/dist/harness/session/testing/gating-storage.d.ts +0 -26
  358. package/dist/harness/session/testing/gating-storage.d.ts.map +0 -1
  359. package/dist/harness/session/testing/gating-storage.js +0 -100
  360. package/dist/harness/session/testing/gating-storage.js.map +0 -1
  361. package/dist/harness/session/testing/index.d.ts +0 -10
  362. package/dist/harness/session/testing/index.d.ts.map +0 -1
  363. package/dist/harness/session/testing/index.js +0 -9
  364. package/dist/harness/session/testing/index.js.map +0 -1
  365. package/dist/harness/session/testing/instrumented-storage.d.ts +0 -11
  366. package/dist/harness/session/testing/instrumented-storage.d.ts.map +0 -1
  367. package/dist/harness/session/testing/instrumented-storage.js +0 -16
  368. package/dist/harness/session/testing/instrumented-storage.js.map +0 -1
  369. package/dist/harness/session/testing/storage-decorator.d.ts +0 -20
  370. package/dist/harness/session/testing/storage-decorator.d.ts.map +0 -1
  371. package/dist/harness/session/testing/storage-decorator.js +0 -41
  372. package/dist/harness/session/testing/storage-decorator.js.map +0 -1
  373. package/dist/harness/session/testing/types.d.ts +0 -12
  374. package/dist/harness/session/testing/types.d.ts.map +0 -1
  375. package/dist/harness/session/testing/types.js +0 -2
  376. package/dist/harness/session/testing/types.js.map +0 -1
  377. package/dist/harness/session/types.d.ts +0 -512
  378. package/dist/harness/session/types.d.ts.map +0 -1
  379. package/dist/harness/session/types.js +0 -9
  380. package/dist/harness/session/types.js.map +0 -1
  381. package/dist/harness/session/values.d.ts +0 -95
  382. package/dist/harness/session/values.d.ts.map +0 -1
  383. package/dist/harness/session/values.js +0 -81
  384. package/dist/harness/session/values.js.map +0 -1
  385. package/dist/harness/skills.d.ts +0 -46
  386. package/dist/harness/skills.d.ts.map +0 -1
  387. package/dist/harness/skills.js +0 -326
  388. package/dist/harness/skills.js.map +0 -1
  389. package/dist/harness/system-prompt.d.ts +0 -3
  390. package/dist/harness/system-prompt.d.ts.map +0 -1
  391. package/dist/harness/system-prompt.js +0 -30
  392. package/dist/harness/system-prompt.js.map +0 -1
  393. package/dist/harness/telemetry.d.ts +0 -1242
  394. package/dist/harness/telemetry.d.ts.map +0 -1
  395. package/dist/harness/telemetry.js +0 -527
  396. package/dist/harness/telemetry.js.map +0 -1
  397. package/dist/harness/tools/bash.d.ts +0 -27
  398. package/dist/harness/tools/bash.d.ts.map +0 -1
  399. package/dist/harness/tools/bash.js +0 -105
  400. package/dist/harness/tools/bash.js.map +0 -1
  401. package/dist/harness/tools/edit-diff.d.ts +0 -89
  402. package/dist/harness/tools/edit-diff.d.ts.map +0 -1
  403. package/dist/harness/tools/edit-diff.js +0 -386
  404. package/dist/harness/tools/edit-diff.js.map +0 -1
  405. package/dist/harness/tools/edit.d.ts +0 -19
  406. package/dist/harness/tools/edit.d.ts.map +0 -1
  407. package/dist/harness/tools/edit.js +0 -108
  408. package/dist/harness/tools/edit.js.map +0 -1
  409. package/dist/harness/tools/file-mutation-queue.d.ts +0 -5
  410. package/dist/harness/tools/file-mutation-queue.d.ts.map +0 -1
  411. package/dist/harness/tools/file-mutation-queue.js +0 -46
  412. package/dist/harness/tools/file-mutation-queue.js.map +0 -1
  413. package/dist/harness/tools/image.d.ts +0 -3
  414. package/dist/harness/tools/image.d.ts.map +0 -1
  415. package/dist/harness/tools/image.js +0 -106
  416. package/dist/harness/tools/image.js.map +0 -1
  417. package/dist/harness/tools/index.d.ts +0 -6
  418. package/dist/harness/tools/index.d.ts.map +0 -1
  419. package/dist/harness/tools/index.js +0 -5
  420. package/dist/harness/tools/index.js.map +0 -1
  421. package/dist/harness/tools/path-utils.d.ts +0 -5
  422. package/dist/harness/tools/path-utils.d.ts.map +0 -1
  423. package/dist/harness/tools/path-utils.js +0 -26
  424. package/dist/harness/tools/path-utils.js.map +0 -1
  425. package/dist/harness/tools/read.d.ts +0 -35
  426. package/dist/harness/tools/read.d.ts.map +0 -1
  427. package/dist/harness/tools/read.js +0 -108
  428. package/dist/harness/tools/read.js.map +0 -1
  429. package/dist/harness/tools/tool-context.d.ts +0 -6
  430. package/dist/harness/tools/tool-context.d.ts.map +0 -1
  431. package/dist/harness/tools/tool-context.js +0 -2
  432. package/dist/harness/tools/tool-context.js.map +0 -1
  433. package/dist/harness/tools/write.d.ts +0 -11
  434. package/dist/harness/tools/write.d.ts.map +0 -1
  435. package/dist/harness/tools/write.js +0 -31
  436. package/dist/harness/tools/write.js.map +0 -1
  437. package/dist/harness/types.d.ts +0 -305
  438. package/dist/harness/types.d.ts.map +0 -1
  439. package/dist/harness/types.js +0 -75
  440. package/dist/harness/types.js.map +0 -1
  441. package/dist/harness/utils/adaptive-publisher.d.ts +0 -24
  442. package/dist/harness/utils/adaptive-publisher.d.ts.map +0 -1
  443. package/dist/harness/utils/adaptive-publisher.js +0 -79
  444. package/dist/harness/utils/adaptive-publisher.js.map +0 -1
  445. package/dist/harness/utils/output-capture.d.ts +0 -31
  446. package/dist/harness/utils/output-capture.d.ts.map +0 -1
  447. package/dist/harness/utils/output-capture.js +0 -217
  448. package/dist/harness/utils/output-capture.js.map +0 -1
  449. package/dist/harness/utils/shell-output.d.ts +0 -29
  450. package/dist/harness/utils/shell-output.d.ts.map +0 -1
  451. package/dist/harness/utils/shell-output.js +0 -71
  452. package/dist/harness/utils/shell-output.js.map +0 -1
  453. package/dist/harness/utils/truncate.d.ts +0 -71
  454. package/dist/harness/utils/truncate.d.ts.map +0 -1
  455. package/dist/harness/utils/truncate.js +0 -296
  456. package/dist/harness/utils/truncate.js.map +0 -1
  457. package/dist/harness/utils/usage.d.ts +0 -4
  458. package/dist/harness/utils/usage.d.ts.map +0 -1
  459. package/dist/harness/utils/usage.js +0 -33
  460. package/dist/harness/utils/usage.js.map +0 -1
  461. package/dist/node.d.ts +0 -3
  462. package/dist/node.d.ts.map +0 -1
  463. package/dist/node.js +0 -3
  464. package/dist/node.js.map +0 -1
  465. package/dist/search/index.d.ts +0 -29
  466. package/dist/search/index.d.ts.map +0 -1
  467. package/dist/search/index.js +0 -2
  468. package/dist/search/index.js.map +0 -1
@@ -1,141 +0,0 @@
1
- /**
2
- * A transaction-scoped revocable membrane over a Chord-tracked document.
3
- *
4
- * Every object reached through a document proxy is wrapped lazily; all wrappers of one
5
- * transaction share one liveness flag; identity is preserved by a WeakMap. Mutations forward
6
- * to the underlying Chord proxy so its tracker records ops. At transaction finish — success,
7
- * callback failure, validation failure, storage failure — `revoke()` flips the flag and every
8
- * retained wrapper, root or nested, throws on any operation.
9
- *
10
- * Assigning one wrapper into another (`a.list = b.list`) is rejected: Chord stores the value it
11
- * is given, and a stored proxy is the classic footgun. Assign plain values; splice in place.
12
- */
13
- export class Membrane {
14
- alive = true;
15
- wrappers = new WeakMap();
16
- isWrapper = new WeakSet();
17
- what;
18
- constructor(what) {
19
- this.what = what;
20
- }
21
- revoke() {
22
- this.alive = false;
23
- }
24
- wrap(target) {
25
- const hit = this.wrappers.get(target);
26
- if (hit !== undefined)
27
- return hit;
28
- const m = this;
29
- const dead = () => new TypeError(`document proxy (${m.what}) used outside its transaction`);
30
- const out = (v) => (typeof v === "object" && v !== null ? m.wrap(v) : v);
31
- const inp = (value) => {
32
- if (typeof value !== "object" || value === null)
33
- return value;
34
- m.assertPlainInput(value, new WeakSet());
35
- return JSON.parse(JSON.stringify(value));
36
- };
37
- const proxy = new Proxy(target, {
38
- get(t, key, receiver) {
39
- if (!m.alive)
40
- throw dead();
41
- const v = Reflect.get(t, key, receiver === proxy ? t : receiver);
42
- if (typeof v === "function") {
43
- // Methods run against the tracked target. Callback arguments (array elements and
44
- // the array itself) must cross back through the membrane before user code sees them.
45
- return (...args) => {
46
- if (!m.alive)
47
- throw dead();
48
- const safeArgs = args.map((arg) => {
49
- if (typeof arg !== "function")
50
- return inp(arg);
51
- return function (...callbackArgs) {
52
- if (!m.alive)
53
- throw dead();
54
- return Reflect.apply(arg, this, callbackArgs.map(out));
55
- };
56
- });
57
- return out(Reflect.apply(v, t, safeArgs));
58
- };
59
- }
60
- return out(v);
61
- },
62
- set(t, key, value) {
63
- if (!m.alive)
64
- throw dead();
65
- if (key === "__proto__")
66
- throw new TypeError(`document proxy (${m.what}) cannot change prototypes`);
67
- return Reflect.set(t, key, inp(value));
68
- },
69
- deleteProperty(t, key) {
70
- if (!m.alive)
71
- throw dead();
72
- return Reflect.deleteProperty(t, key);
73
- },
74
- has(t, key) {
75
- if (!m.alive)
76
- throw dead();
77
- return Reflect.has(t, key);
78
- },
79
- ownKeys(t) {
80
- if (!m.alive)
81
- throw dead();
82
- return Reflect.ownKeys(t);
83
- },
84
- getOwnPropertyDescriptor(t, key) {
85
- if (!m.alive)
86
- throw dead();
87
- const d = Reflect.getOwnPropertyDescriptor(t, key);
88
- if (d === undefined)
89
- return undefined;
90
- // Descriptors must not leak a raw nested object.
91
- if ("value" in d)
92
- d.value = out(d.value);
93
- return d;
94
- },
95
- defineProperty(t, key, descriptor) {
96
- if (!m.alive)
97
- throw dead();
98
- if ("get" in descriptor || "set" in descriptor)
99
- throw new TypeError(`document proxy (${m.what}) cannot define accessors`);
100
- const safe = "value" in descriptor ? { ...descriptor, value: inp(descriptor.value) } : descriptor;
101
- return Reflect.defineProperty(t, key, safe);
102
- },
103
- getPrototypeOf(t) {
104
- if (!m.alive)
105
- throw dead();
106
- return Reflect.getPrototypeOf(t);
107
- },
108
- setPrototypeOf() {
109
- if (!m.alive)
110
- throw dead();
111
- throw new TypeError(`document proxy (${m.what}) cannot change prototypes`);
112
- },
113
- isExtensible(t) {
114
- if (!m.alive)
115
- throw dead();
116
- return Reflect.isExtensible(t);
117
- },
118
- preventExtensions() {
119
- if (!m.alive)
120
- throw dead();
121
- throw new TypeError(`document proxy (${m.what}) cannot change extensibility`);
122
- },
123
- });
124
- this.wrappers.set(target, proxy);
125
- this.isWrapper.add(proxy);
126
- return proxy;
127
- }
128
- assertPlainInput(value, seen) {
129
- if (this.isWrapper.has(value))
130
- throw new TypeError(`assigning a document proxy into a document (${this.what}); assign a plain value`);
131
- if (seen.has(value))
132
- throw new TypeError(`assigning a cyclic value into a document (${this.what})`);
133
- seen.add(value);
134
- for (const nested of Object.values(value)) {
135
- if (typeof nested === "object" && nested !== null)
136
- this.assertPlainInput(nested, seen);
137
- }
138
- seen.delete(value);
139
- }
140
- }
141
- //# sourceMappingURL=membrane.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"membrane.js","sourceRoot":"","sources":["../../../src/harness/pico3/membrane.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,QAAQ;IACZ,KAAK,GAAG,IAAI,CAAC;IACJ,QAAQ,GAAG,IAAI,OAAO,EAAkB,CAAC;IACzC,SAAS,GAAG,IAAI,OAAO,EAAU,CAAC;IAClC,IAAI,CAAS;IAE9B,YAAY,IAAY;QACvB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IAClB,CAAC;IAED,MAAM;QACL,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACpB,CAAC;IAED,IAAI,CAAmB,MAAS;QAC/B,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACtC,IAAI,GAAG,KAAK,SAAS;YAAE,OAAO,GAAQ,CAAC;QACvC,MAAM,CAAC,GAAG,IAAI,CAAC;QACf,MAAM,IAAI,GAAG,GAAG,EAAE,CAAC,IAAI,SAAS,CAAC,mBAAmB,CAAC,CAAC,IAAI,gCAAgC,CAAC,CAAC;QAC5F,MAAM,GAAG,GAAG,CAAC,CAAU,EAAW,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3F,MAAM,GAAG,GAAG,CAAC,KAAc,EAAW,EAAE;YACvC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;gBAAE,OAAO,KAAK,CAAC;YAC9D,CAAC,CAAC,gBAAgB,CAAC,KAAK,EAAE,IAAI,OAAO,EAAE,CAAC,CAAC;YACzC,OAAO,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CAAC,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QACjC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAC1B,OAAO,KAAU,CAAC;IACnB,CAAC;IAEO,gBAAgB,CAAC,KAAa,EAAE,IAAqB;QAC5D,IAAI,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC;YAC5B,MAAM,IAAI,SAAS,CAAC,+CAA+C,IAAI,CAAC,IAAI,yBAAyB,CAAC,CAAC;QACxG,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC;YAAE,MAAM,IAAI,SAAS,CAAC,6CAA6C,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC;QACpG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAChB,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;YAC3C,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI;gBAAE,IAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QACxF,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACpB,CAAC;CACD","sourcesContent":["/**\n * A transaction-scoped revocable membrane over a Chord-tracked document.\n *\n * Every object reached through a document proxy is wrapped lazily; all wrappers of one\n * transaction share one liveness flag; identity is preserved by a WeakMap. Mutations forward\n * to the underlying Chord proxy so its tracker records ops. At transaction finish — success,\n * callback failure, validation failure, storage failure — `revoke()` flips the flag and every\n * retained wrapper, root or nested, throws on any operation.\n *\n * Assigning one wrapper into another (`a.list = b.list`) is rejected: Chord stores the value it\n * is given, and a stored proxy is the classic footgun. Assign plain values; splice in place.\n */\nexport class Membrane {\n\tprivate alive = true;\n\tprivate readonly wrappers = new WeakMap<object, object>();\n\tprivate readonly isWrapper = new WeakSet<object>();\n\tprivate readonly what: string;\n\n\tconstructor(what: string) {\n\t\tthis.what = what;\n\t}\n\n\trevoke() {\n\t\tthis.alive = false;\n\t}\n\n\twrap<T extends object>(target: T): T {\n\t\tconst hit = this.wrappers.get(target);\n\t\tif (hit !== undefined) return hit as T;\n\t\tconst m = this;\n\t\tconst dead = () => new TypeError(`document proxy (${m.what}) used outside its transaction`);\n\t\tconst out = (v: unknown): unknown => (typeof v === \"object\" && v !== null ? m.wrap(v) : v);\n\t\tconst inp = (value: unknown): unknown => {\n\t\t\tif (typeof value !== \"object\" || value === null) return value;\n\t\t\tm.assertPlainInput(value, new WeakSet());\n\t\t\treturn JSON.parse(JSON.stringify(value)) as unknown;\n\t\t};\n\t\tconst proxy = new Proxy(target, {\n\t\t\tget(t, key, receiver) {\n\t\t\t\tif (!m.alive) throw dead();\n\t\t\t\tconst v = Reflect.get(t, key, receiver === proxy ? t : receiver);\n\t\t\t\tif (typeof v === \"function\") {\n\t\t\t\t\t// Methods run against the tracked target. Callback arguments (array elements and\n\t\t\t\t\t// the array itself) must cross back through the membrane before user code sees them.\n\t\t\t\t\treturn (...args: unknown[]) => {\n\t\t\t\t\t\tif (!m.alive) throw dead();\n\t\t\t\t\t\tconst safeArgs = args.map((arg) => {\n\t\t\t\t\t\t\tif (typeof arg !== \"function\") return inp(arg);\n\t\t\t\t\t\t\treturn function (this: unknown, ...callbackArgs: unknown[]) {\n\t\t\t\t\t\t\t\tif (!m.alive) throw dead();\n\t\t\t\t\t\t\t\treturn Reflect.apply(arg, this, callbackArgs.map(out));\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t});\n\t\t\t\t\t\treturn out(Reflect.apply(v, t, safeArgs));\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\treturn out(v);\n\t\t\t},\n\t\t\tset(t, key, value) {\n\t\t\t\tif (!m.alive) throw dead();\n\t\t\t\tif (key === \"__proto__\") throw new TypeError(`document proxy (${m.what}) cannot change prototypes`);\n\t\t\t\treturn Reflect.set(t, key, inp(value) as never);\n\t\t\t},\n\t\t\tdeleteProperty(t, key) {\n\t\t\t\tif (!m.alive) throw dead();\n\t\t\t\treturn Reflect.deleteProperty(t, key);\n\t\t\t},\n\t\t\thas(t, key) {\n\t\t\t\tif (!m.alive) throw dead();\n\t\t\t\treturn Reflect.has(t, key);\n\t\t\t},\n\t\t\townKeys(t) {\n\t\t\t\tif (!m.alive) throw dead();\n\t\t\t\treturn Reflect.ownKeys(t);\n\t\t\t},\n\t\t\tgetOwnPropertyDescriptor(t, key) {\n\t\t\t\tif (!m.alive) throw dead();\n\t\t\t\tconst d = Reflect.getOwnPropertyDescriptor(t, key);\n\t\t\t\tif (d === undefined) return undefined;\n\t\t\t\t// Descriptors must not leak a raw nested object.\n\t\t\t\tif (\"value\" in d) (d as { value: unknown }).value = out(d.value);\n\t\t\t\treturn d;\n\t\t\t},\n\t\t\tdefineProperty(t, key, descriptor) {\n\t\t\t\tif (!m.alive) throw dead();\n\t\t\t\tif (\"get\" in descriptor || \"set\" in descriptor)\n\t\t\t\t\tthrow new TypeError(`document proxy (${m.what}) cannot define accessors`);\n\t\t\t\tconst safe = \"value\" in descriptor ? { ...descriptor, value: inp(descriptor.value) } : descriptor;\n\t\t\t\treturn Reflect.defineProperty(t, key, safe);\n\t\t\t},\n\t\t\tgetPrototypeOf(t) {\n\t\t\t\tif (!m.alive) throw dead();\n\t\t\t\treturn Reflect.getPrototypeOf(t);\n\t\t\t},\n\t\t\tsetPrototypeOf() {\n\t\t\t\tif (!m.alive) throw dead();\n\t\t\t\tthrow new TypeError(`document proxy (${m.what}) cannot change prototypes`);\n\t\t\t},\n\t\t\tisExtensible(t) {\n\t\t\t\tif (!m.alive) throw dead();\n\t\t\t\treturn Reflect.isExtensible(t);\n\t\t\t},\n\t\t\tpreventExtensions() {\n\t\t\t\tif (!m.alive) throw dead();\n\t\t\t\tthrow new TypeError(`document proxy (${m.what}) cannot change extensibility`);\n\t\t\t},\n\t\t});\n\t\tthis.wrappers.set(target, proxy);\n\t\tthis.isWrapper.add(proxy);\n\t\treturn proxy as T;\n\t}\n\n\tprivate assertPlainInput(value: object, seen: WeakSet<object>): void {\n\t\tif (this.isWrapper.has(value))\n\t\t\tthrow new TypeError(`assigning a document proxy into a document (${this.what}); assign a plain value`);\n\t\tif (seen.has(value)) throw new TypeError(`assigning a cyclic value into a document (${this.what})`);\n\t\tseen.add(value);\n\t\tfor (const nested of Object.values(value)) {\n\t\t\tif (typeof nested === \"object\" && nested !== null) this.assertPlainInput(nested, seen);\n\t\t}\n\t\tseen.delete(value);\n\t}\n}\n"]}
@@ -1,53 +0,0 @@
1
- import type { Context } from "@draht/chord";
2
- import { type Op } from "@draht/chord/delta";
3
- import type { Conversation, DocRef, Entry, EntryScan, Id, Input, JsonObject, Seq, Storage, Task, TaskScan, Write } from "./types.ts";
4
- /**
5
- * In-memory Storage. The reference backend, and the read path of JsonlStorage.
6
- *
7
- * A batch is validated and staged in full before any table changes: one failed
8
- * batch changes no table, no document, no ID high-water, no sequence. Committed
9
- * IDs are never reused; IDs minted but never committed may be reused after reopen.
10
- */
11
- export declare class MemoryStorage implements Storage {
12
- protected readonly conversationsById: Map<number, Conversation>;
13
- protected readonly entriesById: Map<number, Entry>;
14
- protected readonly entriesByConversation: Map<number, Entry[]>;
15
- protected readonly tasksById: Map<number, Task<import("@draht/chord").JsonValue, import("./types.ts").Checkpoint>>;
16
- protected readonly inputsById: Map<number, Input>;
17
- protected readonly inputsByRequest: Map<string, Input>;
18
- /** Rewindable docs keep their full op history with the seq of each batch, for `docAsOf`. */
19
- protected readonly rewindableLog: Map<number, {
20
- seq: Seq;
21
- ops: Op[];
22
- }[]>;
23
- protected readonly stickyLog: Map<number, Op[][]>;
24
- protected sessionDoc: JsonObject | undefined;
25
- protected readonly entrySeq: Map<number, number>;
26
- protected nextIdValue: number;
27
- protected seq: Seq;
28
- private closed;
29
- mintId(): Id;
30
- protected setNextId(n: Id): void;
31
- commit(writes: readonly Write[], _ctx: Context): Promise<Seq>;
32
- /** Validate the whole batch against the current tables; return a function that applies it. */
33
- protected stage(writes: readonly Write[], seq: Seq): () => void;
34
- conversation(id: Id, _ctx?: Context): Promise<Conversation | undefined>;
35
- conversations(_ctx?: Context): Promise<Conversation[]>;
36
- entries(ids: readonly Id[], _ctx?: Context): Promise<Map<number, Entry>>;
37
- /** Newest-first, fork-aware: after this conversation's own entries, the parent's up to the fork point, and so on. */
38
- scanEntries(scan: EntryScan, _ctx?: Context): Promise<Entry[]>;
39
- task(id: Id, _ctx?: Context): Promise<Task<import("@draht/chord").JsonValue, import("./types.ts").Checkpoint> | undefined>;
40
- scanTasks(scan: TaskScan, _ctx?: Context): Promise<Task<import("@draht/chord").JsonValue, import("./types.ts").Checkpoint>[]>;
41
- input(id: Id, _ctx?: Context): Promise<Input | undefined>;
42
- inputByRequest(conversationId: Id, requestId: string, _ctx?: Context): Promise<Input | undefined>;
43
- doc(ref: DocRef, _ctx?: Context): Promise<JsonObject | undefined>;
44
- /**
45
- * Commit-granular history: the rewindable state after the atomic commit that contains
46
- * entry `at`, walking the fork chain for entries owned by ancestors.
47
- */
48
- docAsOf(conversationId: Id, at: Id, _ctx?: Context): Promise<JsonObject | undefined>;
49
- protected fold(log: Op[][]): JsonObject;
50
- truncate(ref: DocRef, _ctx?: Context): Promise<void>;
51
- close(_ctx?: Context): Promise<void>;
52
- }
53
- //# sourceMappingURL=memory.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../../src/harness/pico3/memory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAA0B,KAAK,EAAE,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,KAAK,EACX,YAAY,EACZ,MAAM,EACN,KAAK,EACL,SAAS,EACT,EAAE,EACF,KAAK,EACL,UAAU,EACV,GAAG,EACH,OAAO,EACP,IAAI,EACJ,QAAQ,EACR,KAAK,EACL,MAAM,YAAY,CAAC;AAEpB;;;;;;GAMG;AACH,qB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IAAI,CAAC,EAAE,OAAO,oBAkBhD;IACK,IAAI,CAAC,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,OAAO,gGAEhC;IACK,SAAS,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,CAAC,EAAE,OAAO,sFAS7C;IACK,KAAK,CAAC,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,OAAO,8BAEjC;IACK,cAAc,CAAC,cAAc,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,8BAEzE;IAEK,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAStE;IACD;;;OAGG;IACG,OAAO,CAAC,cAAc,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAazF;IACD,SAAS,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE,GAAG,UAAU,CAUtC;IACK,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,iBAWzC;IACK,KAAK,CAAC,IAAI,CAAC,EAAE,OAAO,iBAEzB;CACD"}
@@ -1,264 +0,0 @@
1
- import { applyImmutable, isBase } from "@draht/chord/delta";
2
- /**
3
- * In-memory Storage. The reference backend, and the read path of JsonlStorage.
4
- *
5
- * A batch is validated and staged in full before any table changes: one failed
6
- * batch changes no table, no document, no ID high-water, no sequence. Committed
7
- * IDs are never reused; IDs minted but never committed may be reused after reopen.
8
- */
9
- export class MemoryStorage {
10
- conversationsById = new Map();
11
- entriesById = new Map();
12
- entriesByConversation = new Map(); // ascending
13
- tasksById = new Map();
14
- inputsById = new Map();
15
- inputsByRequest = new Map();
16
- /** Rewindable docs keep their full op history with the seq of each batch, for `docAsOf`. */
17
- rewindableLog = new Map();
18
- stickyLog = new Map();
19
- sessionDoc;
20
- entrySeq = new Map(); // entry id → seq of its batch
21
- nextIdValue = 1;
22
- seq = 0;
23
- closed = false;
24
- mintId() {
25
- return this.nextIdValue++;
26
- }
27
- setNextId(n) {
28
- this.nextIdValue = Math.max(this.nextIdValue, n);
29
- }
30
- async commit(writes, _ctx) {
31
- if (this.closed)
32
- throw new Error("storage closed");
33
- const seq = this.seq + 1;
34
- const staged = this.stage(writes, seq); // throws before any mutation
35
- staged();
36
- this.seq = seq;
37
- return seq;
38
- }
39
- /** Validate the whole batch against the current tables; return a function that applies it. */
40
- stage(writes, seq) {
41
- const ops = [];
42
- const created = new Set();
43
- let maxId = 0;
44
- const claim = (id, what) => {
45
- if (!Number.isSafeInteger(id) || id <= 0)
46
- throw new Error(`${what}: invalid id ${id}`);
47
- if (created.has(id))
48
- throw new Error(`${what}: id ${id} created twice in one batch`);
49
- created.add(id);
50
- maxId = Math.max(maxId, id);
51
- };
52
- for (const w of writes) {
53
- switch (w.type) {
54
- case "conversation": {
55
- if (this.conversationsById.has(w.conversation.id))
56
- throw new Error(`conversation ${w.conversation.id} exists`);
57
- claim(w.conversation.id, "conversation");
58
- const c = clone(w.conversation);
59
- ops.push(() => {
60
- this.conversationsById.set(c.id, c);
61
- this.entriesByConversation.set(c.id, []);
62
- });
63
- break;
64
- }
65
- case "entry": {
66
- if (this.entriesById.has(w.entry.id))
67
- throw new Error(`entry ${w.entry.id} exists`);
68
- claim(w.entry.id, "entry");
69
- const e = clone(w.entry);
70
- ops.push(() => {
71
- this.entriesById.set(e.id, e);
72
- (this.entriesByConversation.get(e.conversationId) ??
73
- this.entriesByConversation.set(e.conversationId, []).get(e.conversationId)).push(e);
74
- this.entrySeq.set(e.id, seq);
75
- });
76
- break;
77
- }
78
- case "task": {
79
- if (this.tasksById.has(w.task.id))
80
- throw new Error(`task ${w.task.id} exists`);
81
- claim(w.task.id, "task");
82
- const t = clone(w.task);
83
- ops.push(() => this.tasksById.set(t.id, t));
84
- break;
85
- }
86
- case "task.patch": {
87
- const prev = this.tasksById.get(w.patch.id) ??
88
- [...writes]
89
- .filter((x) => x.type === "task")
90
- .find((x) => x.task.id === w.patch.id)?.task;
91
- if (prev === undefined)
92
- throw new Error(`patch for unknown task ${w.patch.id}`);
93
- const p = clone(w.patch);
94
- ops.push(() => {
95
- const cur = this.tasksById.get(p.id);
96
- const { id: _i, ...fields } = p;
97
- const next = { ...cur, ...fields };
98
- if (p.checkpoint === null)
99
- delete next.checkpoint;
100
- this.tasksById.set(p.id, next);
101
- });
102
- break;
103
- }
104
- case "input": {
105
- const i = clone(w.input);
106
- if (!this.inputsById.has(i.id))
107
- claim(i.id, "input");
108
- ops.push(() => {
109
- this.inputsById.set(i.id, i);
110
- if (i.requestId !== undefined)
111
- this.inputsByRequest.set(`${i.conversationId}:${i.requestId}`, i);
112
- });
113
- break;
114
- }
115
- case "doc": {
116
- const ref = clone(w.ref);
117
- const o = clone(w.ops);
118
- if (ref.doc === "session")
119
- ops.push(() => {
120
- this.sessionDoc = applyImmutable((this.sessionDoc ?? { plugins: {} }), o);
121
- });
122
- else if (ref.doc === "rewindable")
123
- ops.push(() => (this.rewindableLog.get(ref.conversationId) ??
124
- this.rewindableLog.set(ref.conversationId, []).get(ref.conversationId)).push({ seq, ops: o }));
125
- else
126
- ops.push(() => (this.stickyLog.get(ref.conversationId) ??
127
- this.stickyLog.set(ref.conversationId, []).get(ref.conversationId)).push(o));
128
- break;
129
- }
130
- }
131
- }
132
- return () => {
133
- for (const op of ops)
134
- op();
135
- this.setNextId(maxId + 1);
136
- };
137
- }
138
- async conversation(id, _ctx) {
139
- return optionalClone(this.conversationsById.get(id));
140
- }
141
- async conversations(_ctx) {
142
- return [...this.conversationsById.values()].map(clone);
143
- }
144
- async entries(ids, _ctx) {
145
- const out = new Map();
146
- for (const id of ids) {
147
- const e = this.entriesById.get(id);
148
- if (e)
149
- out.set(id, clone(e));
150
- }
151
- return out;
152
- }
153
- /** Newest-first, fork-aware: after this conversation's own entries, the parent's up to the fork point, and so on. */
154
- async scanEntries(scan, _ctx) {
155
- const out = [];
156
- let conversationId = scan.conversationId;
157
- let cap = scan.before;
158
- while (conversationId !== undefined && out.length < scan.limit) {
159
- const own = this.entriesByConversation.get(conversationId) ?? [];
160
- for (let i = own.length - 1; i >= 0 && out.length < scan.limit; i--) {
161
- const e = own[i];
162
- if (cap !== undefined && e.id >= cap)
163
- continue;
164
- if (scan.kind !== undefined && e.kind !== scan.kind)
165
- continue;
166
- if (scan.withHead && e.head === undefined)
167
- continue;
168
- out.push(clone(e));
169
- }
170
- const c = this.conversationsById.get(conversationId);
171
- conversationId = c?.parent?.conversationId;
172
- cap = c?.parent === undefined ? undefined : Math.min(cap ?? Infinity, c.parent.at + 1);
173
- }
174
- return out;
175
- }
176
- async task(id, _ctx) {
177
- return optionalClone(this.tasksById.get(id));
178
- }
179
- async scanTasks(scan, _ctx) {
180
- const out = [];
181
- for (const t of this.tasksById.values()) {
182
- if (scan.conversationId !== undefined && t.conversationId !== scan.conversationId)
183
- continue;
184
- if (scan.status !== undefined && !scan.status.includes(t.status))
185
- continue;
186
- if (scan.kind !== undefined && t.kind !== scan.kind)
187
- continue;
188
- out.push(clone(t));
189
- }
190
- return out;
191
- }
192
- async input(id, _ctx) {
193
- return optionalClone(this.inputsById.get(id));
194
- }
195
- async inputByRequest(conversationId, requestId, _ctx) {
196
- return optionalClone(this.inputsByRequest.get(`${conversationId}:${requestId}`));
197
- }
198
- async doc(ref, _ctx) {
199
- if (ref.doc === "session")
200
- return this.sessionDoc === undefined ? { plugins: {} } : structuredClone(this.sessionDoc);
201
- const log = ref.doc === "rewindable"
202
- ? this.rewindableLog.get(ref.conversationId)?.map((r) => r.ops)
203
- : this.stickyLog.get(ref.conversationId);
204
- if (log === undefined)
205
- return undefined;
206
- return clone(this.fold(log));
207
- }
208
- /**
209
- * Commit-granular history: the rewindable state after the atomic commit that contains
210
- * entry `at`, walking the fork chain for entries owned by ancestors.
211
- */
212
- async docAsOf(conversationId, at, _ctx) {
213
- const owner = this.entriesById.get(at)?.conversationId;
214
- if (owner === undefined)
215
- return undefined;
216
- const chain = [];
217
- let c = this.conversationsById.get(conversationId);
218
- while (c !== undefined && c.id !== owner) {
219
- chain.push(c.id);
220
- c = c.parent ? this.conversationsById.get(c.parent.conversationId) : undefined;
221
- }
222
- if (c === undefined)
223
- return undefined;
224
- const seqAt = this.entrySeq.get(at) ?? 0;
225
- const log = (this.rewindableLog.get(owner) ?? []).filter((r) => r.seq <= seqAt).map((r) => r.ops);
226
- return log.length === 0 ? undefined : clone(this.fold(log));
227
- }
228
- fold(log) {
229
- let start = 0;
230
- for (let i = log.length - 1; i >= 0; i--)
231
- if (isBase(log[i])) {
232
- start = i;
233
- break;
234
- }
235
- let state = {};
236
- for (let i = start; i < log.length; i++)
237
- state = applyImmutable(state, log[i]);
238
- return state;
239
- }
240
- async truncate(ref, _ctx) {
241
- if (ref.doc !== "sticky")
242
- return;
243
- const log = this.stickyLog.get(ref.conversationId);
244
- if (log === undefined)
245
- return;
246
- let start = 0;
247
- for (let i = log.length - 1; i >= 0; i--)
248
- if (isBase(log[i])) {
249
- start = i;
250
- break;
251
- }
252
- log.splice(0, start);
253
- }
254
- async close(_ctx) {
255
- this.closed = true;
256
- }
257
- }
258
- function clone(value) {
259
- return JSON.parse(JSON.stringify(value));
260
- }
261
- function optionalClone(value) {
262
- return value === undefined ? undefined : clone(value);
263
- }
264
- //# sourceMappingURL=memory.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"memory.js","sourceRoot":"","sources":["../../../src/harness/pico3/memory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,EAAW,MAAM,oBAAoB,CAAC;AAgBrE;;;;;;GAMG;AACH,MAAM,OAAO,aAAa;IACN,iBAAiB,GAAG,IAAI,GAAG,EAAoB,CAAC;IAChD,WAAW,GAAG,IAAI,GAAG,EAAa,CAAC;IACnC,qBAAqB,GAAG,IAAI,GAAG,EAAe,C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AG,KAAK,SAAS;YAAE,OAAO;QAC9B,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,KAAK,IAAI,CAAC,GAAG,GAAG,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE;YACvC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAE,CAAC,EAAE,CAAC;gBACrB,KAAK,GAAG,CAAC,CAAC;gBACV,MAAM;YACP,CAAC;QACF,GAAG,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IACtB,CAAC;IACD,KAAK,CAAC,KAAK,CAAC,IAAc;QACzB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;IACpB,CAAC;CACD;AAED,SAAS,KAAK,CAAI,KAAQ;IACzB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAM,CAAC;AAC/C,CAAC;AAED,SAAS,aAAa,CAAI,KAAoB;IAC7C,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AACvD,CAAC","sourcesContent":["import type { Context } from \"@draht/chord\";\nimport { applyImmutable, isBase, type Op } from \"@draht/chord/delta\";\nimport type {\n\tConversation,\n\tDocRef,\n\tEntry,\n\tEntryScan,\n\tId,\n\tInput,\n\tJsonObject,\n\tSeq,\n\tStorage,\n\tTask,\n\tTaskScan,\n\tWrite,\n} from \"./types.ts\";\n\n/**\n * In-memory Storage. The reference backend, and the read path of JsonlStorage.\n *\n * A batch is validated and staged in full before any table changes: one failed\n * batch changes no table, no document, no ID high-water, no sequence. Committed\n * IDs are never reused; IDs minted but never committed may be reused after reopen.\n */\nexport class MemoryStorage implements Storage {\n\tprotected readonly conversationsById = new Map<Id, Conversation>();\n\tprotected readonly entriesById = new Map<Id, Entry>();\n\tprotected readonly entriesByConversation = new Map<Id, Entry[]>(); // ascending\n\tprotected readonly tasksById = new Map<Id, Task>();\n\tprotected readonly inputsById = new Map<Id, Input>();\n\tprotected readonly inputsByRequest = new Map<string, Input>();\n\t/** Rewindable docs keep their full op history with the seq of each batch, for `docAsOf`. */\n\tprotected readonly rewindableLog = new Map<Id, { seq: Seq; ops: Op[] }[]>();\n\tprotected readonly stickyLog = new Map<Id, Op[][]>();\n\tprotected sessionDoc: JsonObject | undefined;\n\tprotected readonly entrySeq = new Map<Id, Seq>(); // entry id → seq of its batch\n\tprotected nextIdValue = 1;\n\tprotected seq: Seq = 0;\n\tprivate closed = false;\n\n\tmintId(): Id {\n\t\treturn this.nextIdValue++;\n\t}\n\tprotected setNextId(n: Id) {\n\t\tthis.nextIdValue = Math.max(this.nextIdValue, n);\n\t}\n\n\tasync commit(writes: readonly Write[], _ctx: Context): Promise<Seq> {\n\t\tif (this.closed) throw new Error(\"storage closed\");\n\t\tconst seq = this.seq + 1;\n\t\tconst staged = this.stage(writes, seq); // throws before any mutation\n\t\tstaged();\n\t\tthis.seq = seq;\n\t\treturn seq;\n\t}\n\n\t/** Validate the whole batch against the current tables; return a function that applies it. */\n\tprotected stage(writes: readonly Write[], seq: Seq): () => void {\n\t\tconst ops: (() => void)[] = [];\n\t\tconst created = new Set<Id>();\n\t\tlet maxId = 0;\n\t\tconst claim = (id: Id, what: string) => {\n\t\t\tif (!Number.isSafeInteger(id) || id <= 0) throw new Error(`${what}: invalid id ${id}`);\n\t\t\tif (created.has(id)) throw new Error(`${what}: id ${id} created twice in one batch`);\n\t\t\tcreated.add(id);\n\t\t\tmaxId = Math.max(maxId, id);\n\t\t};\n\t\tfor (const w of writes) {\n\t\t\tswitch (w.type) {\n\t\t\t\tcase \"conversation\": {\n\t\t\t\t\tif (this.conversationsById.has(w.conversation.id))\n\t\t\t\t\t\tthrow new Error(`conversation ${w.conversation.id} exists`);\n\t\t\t\t\tclaim(w.conversation.id, \"conversation\");\n\t\t\t\t\tconst c = clone(w.conversation);\n\t\t\t\t\tops.push(() => {\n\t\t\t\t\t\tthis.conversationsById.set(c.id, c);\n\t\t\t\t\t\tthis.entriesByConversation.set(c.id, []);\n\t\t\t\t\t});\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"entry\": {\n\t\t\t\t\tif (this.entriesById.has(w.entry.id)) throw new Error(`entry ${w.entry.id} exists`);\n\t\t\t\t\tclaim(w.entry.id, \"entry\");\n\t\t\t\t\tconst e = clone(w.entry);\n\t\t\t\t\tops.push(() => {\n\t\t\t\t\t\tthis.entriesById.set(e.id, e);\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\tthis.entriesByConversation.get(e.conversationId) ??\n\t\t\t\t\t\t\tthis.entriesByConversation.set(e.conversationId, []).get(e.conversationId)!\n\t\t\t\t\t\t).push(e);\n\t\t\t\t\t\tthis.entrySeq.set(e.id, seq);\n\t\t\t\t\t});\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"task\": {\n\t\t\t\t\tif (this.tasksById.has(w.task.id)) throw new Error(`task ${w.task.id} exists`);\n\t\t\t\t\tclaim(w.task.id, \"task\");\n\t\t\t\t\tconst t = clone(w.task);\n\t\t\t\t\tops.push(() => this.tasksById.set(t.id, t));\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"task.patch\": {\n\t\t\t\t\tconst prev =\n\t\t\t\t\t\tthis.tasksById.get(w.patch.id) ??\n\t\t\t\t\t\t[...writes]\n\t\t\t\t\t\t\t.filter((x): x is Extract<Write, { type: \"task\" }> => x.type === \"task\")\n\t\t\t\t\t\t\t.find((x) => x.task.id === w.patch.id)?.task;\n\t\t\t\t\tif (prev === undefined) throw new Error(`patch for unknown task ${w.patch.id}`);\n\t\t\t\t\tconst p = clone(w.patch);\n\t\t\t\t\tops.push(() => {\n\t\t\t\t\t\tconst cur = this.tasksById.get(p.id)!;\n\t\t\t\t\t\tconst { id: _i, ...fields } = p;\n\t\t\t\t\t\tconst next = { ...cur, ...fields } as Task;\n\t\t\t\t\t\tif (p.checkpoint === null) delete (next as { checkpoint?: unknown }).checkpoint;\n\t\t\t\t\t\tthis.tasksById.set(p.id, next);\n\t\t\t\t\t});\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"input\": {\n\t\t\t\t\tconst i = clone(w.input);\n\t\t\t\t\tif (!this.inputsById.has(i.id)) claim(i.id, \"input\");\n\t\t\t\t\tops.push(() => {\n\t\t\t\t\t\tthis.inputsById.set(i.id, i);\n\t\t\t\t\t\tif (i.requestId !== undefined) this.inputsByRequest.set(`${i.conversationId}:${i.requestId}`, i);\n\t\t\t\t\t});\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase \"doc\": {\n\t\t\t\t\tconst ref = clone(w.ref);\n\t\t\t\t\tconst o = clone(w.ops);\n\t\t\t\t\tif (ref.doc === \"session\")\n\t\t\t\t\t\tops.push(() => {\n\t\t\t\t\t\t\tthis.sessionDoc = applyImmutable(\n\t\t\t\t\t\t\t\t(this.sessionDoc ?? { plugins: {} }) as JsonObject,\n\t\t\t\t\t\t\t\to,\n\t\t\t\t\t\t\t) as JsonObject;\n\t\t\t\t\t\t});\n\t\t\t\t\telse if (ref.doc === \"rewindable\")\n\t\t\t\t\t\tops.push(() =>\n\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\tthis.rewindableLog.get(ref.conversationId) ??\n\t\t\t\t\t\t\t\tthis.rewindableLog.set(ref.conversationId, []).get(ref.conversationId)!\n\t\t\t\t\t\t\t).push({ seq, ops: o }),\n\t\t\t\t\t\t);\n\t\t\t\t\telse\n\t\t\t\t\t\tops.push(() =>\n\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\tthis.stickyLog.get(ref.conversationId) ??\n\t\t\t\t\t\t\t\tthis.stickyLog.set(ref.conversationId, []).get(ref.conversationId)!\n\t\t\t\t\t\t\t).push(o),\n\t\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn () => {\n\t\t\tfor (const op of ops) op();\n\t\t\tthis.setNextId(maxId + 1);\n\t\t};\n\t}\n\n\tasync conversation(id: Id, _ctx?: Context) {\n\t\treturn optionalClone(this.conversationsById.get(id));\n\t}\n\tasync conversations(_ctx?: Context) {\n\t\treturn [...this.conversationsById.values()].map(clone);\n\t}\n\tasync entries(ids: readonly Id[], _ctx?: Context) {\n\t\tconst out = new Map<Id, Entry>();\n\t\tfor (const id of ids) {\n\t\t\tconst e = this.entriesById.get(id);\n\t\t\tif (e) out.set(id, clone(e));\n\t\t}\n\t\treturn out;\n\t}\n\t/** Newest-first, fork-aware: after this conversation's own entries, the parent's up to the fork point, and so on. */\n\tasync scanEntries(scan: EntryScan, _ctx?: Context) {\n\t\tconst out: Entry[] = [];\n\t\tlet conversationId: Id | undefined = scan.conversationId;\n\t\tlet cap: Id | undefined = scan.before;\n\t\twhile (conversationId !== undefined && out.length < scan.limit) {\n\t\t\tconst own = this.entriesByConversation.get(conversationId) ?? [];\n\t\t\tfor (let i = own.length - 1; i >= 0 && out.length < scan.limit; i--) {\n\t\t\t\tconst e = own[i]!;\n\t\t\t\tif (cap !== undefined && e.id >= cap) continue;\n\t\t\t\tif (scan.kind !== undefined && e.kind !== scan.kind) continue;\n\t\t\t\tif (scan.withHead && e.head === undefined) continue;\n\t\t\t\tout.push(clone(e));\n\t\t\t}\n\t\t\tconst c = this.conversationsById.get(conversationId);\n\t\t\tconversationId = c?.parent?.conversationId;\n\t\t\tcap = c?.parent === undefined ? undefined : Math.min(cap ?? Infinity, c.parent.at + 1);\n\t\t}\n\t\treturn out;\n\t}\n\tasync task(id: Id, _ctx?: Context) {\n\t\treturn optionalClone(this.tasksById.get(id));\n\t}\n\tasync scanTasks(scan: TaskScan, _ctx?: Context) {\n\t\tconst out: Task[] = [];\n\t\tfor (const t of this.tasksById.values()) {\n\t\t\tif (scan.conversationId !== undefined && t.conversationId !== scan.conversationId) continue;\n\t\t\tif (scan.status !== undefined && !scan.status.includes(t.status)) continue;\n\t\t\tif (scan.kind !== undefined && t.kind !== scan.kind) continue;\n\t\t\tout.push(clone(t));\n\t\t}\n\t\treturn out;\n\t}\n\tasync input(id: Id, _ctx?: Context) {\n\t\treturn optionalClone(this.inputsById.get(id));\n\t}\n\tasync inputByRequest(conversationId: Id, requestId: string, _ctx?: Context) {\n\t\treturn optionalClone(this.inputsByRequest.get(`${conversationId}:${requestId}`));\n\t}\n\n\tasync doc(ref: DocRef, _ctx?: Context): Promise<JsonObject | undefined> {\n\t\tif (ref.doc === \"session\")\n\t\t\treturn this.sessionDoc === undefined ? { plugins: {} } : structuredClone(this.sessionDoc);\n\t\tconst log =\n\t\t\tref.doc === \"rewindable\"\n\t\t\t\t? this.rewindableLog.get(ref.conversationId)?.map((r) => r.ops)\n\t\t\t\t: this.stickyLog.get(ref.conversationId);\n\t\tif (log === undefined) return undefined;\n\t\treturn clone(this.fold(log));\n\t}\n\t/**\n\t * Commit-granular history: the rewindable state after the atomic commit that contains\n\t * entry `at`, walking the fork chain for entries owned by ancestors.\n\t */\n\tasync docAsOf(conversationId: Id, at: Id, _ctx?: Context): Promise<JsonObject | undefined> {\n\t\tconst owner = this.entriesById.get(at)?.conversationId;\n\t\tif (owner === undefined) return undefined;\n\t\tconst chain: Id[] = [];\n\t\tlet c: Conversation | undefined = this.conversationsById.get(conversationId);\n\t\twhile (c !== undefined && c.id !== owner) {\n\t\t\tchain.push(c.id);\n\t\t\tc = c.parent ? this.conversationsById.get(c.parent.conversationId) : undefined;\n\t\t}\n\t\tif (c === undefined) return undefined;\n\t\tconst seqAt = this.entrySeq.get(at) ?? 0;\n\t\tconst log = (this.rewindableLog.get(owner) ?? []).filter((r) => r.seq <= seqAt).map((r) => r.ops);\n\t\treturn log.length === 0 ? undefined : clone(this.fold(log));\n\t}\n\tprotected fold(log: Op[][]): JsonObject {\n\t\tlet start = 0;\n\t\tfor (let i = log.length - 1; i >= 0; i--)\n\t\t\tif (isBase(log[i]!)) {\n\t\t\t\tstart = i;\n\t\t\t\tbreak;\n\t\t\t}\n\t\tlet state: JsonObject = {};\n\t\tfor (let i = start; i < log.length; i++) state = applyImmutable(state, log[i]!) as JsonObject;\n\t\treturn state;\n\t}\n\tasync truncate(ref: DocRef, _ctx?: Context) {\n\t\tif (ref.doc !== \"sticky\") return;\n\t\tconst log = this.stickyLog.get(ref.conversationId);\n\t\tif (log === undefined) return;\n\t\tlet start = 0;\n\t\tfor (let i = log.length - 1; i >= 0; i--)\n\t\t\tif (isBase(log[i]!)) {\n\t\t\t\tstart = i;\n\t\t\t\tbreak;\n\t\t\t}\n\t\tlog.splice(0, start);\n\t}\n\tasync close(_ctx?: Context) {\n\t\tthis.closed = true;\n\t}\n}\n\nfunction clone<T>(value: T): T {\n\treturn JSON.parse(JSON.stringify(value)) as T;\n}\n\nfunction optionalClone<T>(value: T | undefined): T | undefined {\n\treturn value === undefined ? undefined : clone(value);\n}\n"]}
@@ -1,49 +0,0 @@
1
- import type { Context } from "@draht/chord";
2
- import type { Session } from "./session.ts";
3
- import { type AnyKind, type Id, type Input, type Invoker, type Runtime, type Task } from "./types.ts";
4
- export interface SchedulerDeps {
5
- session: Session;
6
- kinds: ReadonlyMap<string, AnyKind>;
7
- runtime(task: Task, invoker: Extract<Invoker, {
8
- type: "task";
9
- }>, ctx: Context): Runtime;
10
- onReport(error: unknown): void;
11
- ctx: Context;
12
- }
13
- export declare class Scheduler {
14
- private readonly deps;
15
- private enabled;
16
- private holds;
17
- private dirty;
18
- private draining;
19
- private readonly invocations;
20
- private readonly taskWaiters;
21
- private readonly inputWaiters;
22
- private readonly idleWaiters;
23
- constructor(deps: SchedulerDeps);
24
- resume(): void;
25
- stop(): void;
26
- hold(): () => void;
27
- kick(): void;
28
- private drain;
29
- /** On the line: reserve every eligible task. */
30
- private reserveEligible;
31
- private dispatch;
32
- private lease;
33
- /** The phase loop. Each handler gets a capability lease revoked when that handler's promise returns. */
34
- private runPhases;
35
- /** Mark, revoke, signal, join. The scheduler then reserves the fresh abort on its next drain. */
36
- abortTask(id: Id, ctx: Context): Promise<"marked" | "terminal">;
37
- waitForTask(id: Id, ctx: Context): Promise<Task>;
38
- waitForInput(id: Id, ctx: Context): Promise<Input>;
39
- /** Read state and install the waiter in one line operation; the wait itself happens off-line. */
40
- private waiter;
41
- waitForIdle(conversationId: Id | undefined, ctx: Context): Promise<void>;
42
- private isIdle;
43
- private checkIdle;
44
- /** Signal every invocation and wait for them; nothing is written. */
45
- joinAll(): Promise<void>;
46
- quiescent(): boolean;
47
- get liveInvocations(): number;
48
- }
49
- //# sourceMappingURL=scheduler.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"scheduler.d.ts","sourceRoot":"","sources":["../../../src/harness/pico3/scheduler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,KAAK,EAAE,OAAO,EAAU,MAAM,cAAc,CAAC;AACpD,OAAO,EACN,KAAK,OAAO,EAGZ,KAAK,EAAE,EACP,KAAK,KAAK,EAEV,KAAK,OAAO,EAGZ,KAAK,OAAO,EAEZ,KAAK,IAAI,EAET,MAAM,YAAY,CAAC;AASpB,MAAM,WAAW,aAAa;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACpC,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,EAAE,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC;IACxF,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;IAC/B,GAAG,EAAE,OAAO,CAAC;CACb;AAmDD,qBAAa,SAAS;IACrB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAgB;IACrC,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,KAAK,CAAK;IAClB,OAAO,CAAC,KAAK,CAAS;IACt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