@astrosheep/keiyaku 4.6.7 → 4.6.9

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 (336) hide show
  1. package/README.md +46 -16
  2. package/build/plugins/claude/.claude-plugin/plugin.json +1 -1
  3. package/build/plugins/claude/skills/keiyaku/SKILL.md +5 -6
  4. package/build/plugins/claude/skills/keiyaku-akuma/SKILL.md +1 -1
  5. package/build/plugins/claude/skills/keiyaku-akuma/references/automation.md +8 -8
  6. package/build/plugins/claude/skills/keiyaku-babysit/SKILL.md +1 -1
  7. package/build/plugins/claude/skills/keiyaku-bind/SKILL.md +9 -9
  8. package/build/plugins/claude/skills/keiyaku-debt/SKILL.md +91 -0
  9. package/build/plugins/claude/skills/keiyaku-workflow/SKILL.md +2 -2
  10. package/build/plugins/codex/.codex-plugin/plugin.json +1 -1
  11. package/build/plugins/codex/skills/keiyaku/SKILL.md +5 -6
  12. package/build/plugins/codex/skills/keiyaku-akuma/SKILL.md +1 -1
  13. package/build/plugins/codex/skills/keiyaku-akuma/references/automation.md +8 -8
  14. package/build/plugins/codex/skills/keiyaku-babysit/SKILL.md +1 -1
  15. package/build/plugins/codex/skills/keiyaku-bind/SKILL.md +9 -9
  16. package/build/plugins/codex/skills/keiyaku-debt/SKILL.md +91 -0
  17. package/build/plugins/codex/skills/keiyaku-workflow/SKILL.md +2 -2
  18. package/build/plugins/opencode/index.js +1 -1
  19. package/build/plugins/opencode/skills/keiyaku/SKILL.md +5 -6
  20. package/build/plugins/opencode/skills/keiyaku-akuma/SKILL.md +1 -1
  21. package/build/plugins/opencode/skills/keiyaku-akuma/references/automation.md +8 -8
  22. package/build/plugins/opencode/skills/keiyaku-babysit/SKILL.md +1 -1
  23. package/build/plugins/opencode/skills/keiyaku-bind/SKILL.md +9 -9
  24. package/build/plugins/opencode/skills/keiyaku-debt/SKILL.md +91 -0
  25. package/build/plugins/opencode/skills/keiyaku-workflow/SKILL.md +2 -2
  26. package/build/plugins/pi/keiyaku.ts +0 -5
  27. package/build/skills/keiyaku/SKILL.md +5 -6
  28. package/build/skills/keiyaku-akuma/SKILL.md +1 -1
  29. package/build/skills/keiyaku-akuma/references/automation.md +8 -8
  30. package/build/skills/keiyaku-babysit/SKILL.md +1 -1
  31. package/build/skills/keiyaku-bind/SKILL.md +9 -9
  32. package/build/skills/keiyaku-debt/SKILL.md +91 -0
  33. package/build/skills/keiyaku-workflow/SKILL.md +2 -2
  34. package/build/src/akuma/akuma-call.d.ts +2 -0
  35. package/build/src/akuma/akuma-call.js +8 -2
  36. package/build/src/akuma/akuma-instance.d.ts +14 -1
  37. package/build/src/akuma/akuma-instance.js +37 -7
  38. package/build/src/akuma/akuma-observe.d.ts +33 -8
  39. package/build/src/akuma/akuma-observe.js +89 -63
  40. package/build/src/akuma/akuma-owner.d.ts +14 -2
  41. package/build/src/akuma/akuma-owner.js +49 -35
  42. package/build/src/akuma/akuma-selection-execution.js +9 -1
  43. package/build/src/akuma/akuma-stream.d.ts +22 -0
  44. package/build/src/akuma/akuma-stream.js +116 -0
  45. package/build/src/akuma/akuma-wait.d.ts +1 -40
  46. package/build/src/akuma/akuma-wait.js +23 -84
  47. package/build/src/akuma/akuma.d.ts +52 -16
  48. package/build/src/akuma/akuma.js +10 -10
  49. package/build/src/akuma/allowed.d.ts +7 -12
  50. package/build/src/akuma/allowed.js +13 -4
  51. package/build/src/akuma/archetype.d.ts +7 -15
  52. package/build/src/akuma/archetype.js +36 -35
  53. package/build/src/akuma/body-supervisor.d.ts +5 -5
  54. package/build/src/akuma/body-supervisor.js +22 -20
  55. package/build/src/akuma/body.d.ts +5 -3
  56. package/build/src/akuma/body.js +57 -8
  57. package/build/src/akuma/call-request.d.ts +30 -32
  58. package/build/src/akuma/call-request.js +10 -3
  59. package/build/src/akuma/caller.d.ts +39 -0
  60. package/build/src/akuma/caller.js +36 -0
  61. package/build/src/akuma/dispatch-association.d.ts +0 -1
  62. package/build/src/akuma/dispatch-association.js +0 -3
  63. package/build/src/akuma/heart/activity-schema.d.ts +12 -0
  64. package/build/src/akuma/heart/activity-schema.js +6 -0
  65. package/build/src/akuma/heart/facts.d.ts +16 -12
  66. package/build/src/akuma/heart/facts.js +8 -0
  67. package/build/src/akuma/heart/index.d.ts +61 -9
  68. package/build/src/akuma/heart/index.js +89 -24
  69. package/build/src/akuma/heart/rows.d.ts +3 -3
  70. package/build/src/akuma/heart/rows.js +5 -3
  71. package/build/src/akuma/heart/soul.d.ts +10 -1
  72. package/build/src/akuma/heart/soul.js +34 -24
  73. package/build/src/akuma/heart/storage.d.ts +20 -0
  74. package/build/src/akuma/heart/storage.js +62 -3
  75. package/build/src/akuma/heart/timeline.d.ts +7 -0
  76. package/build/src/akuma/heart/timeline.js +10 -0
  77. package/build/src/akuma/identity.d.ts +0 -1
  78. package/build/src/akuma/identity.js +2 -5
  79. package/build/src/akuma/index.d.ts +6 -2
  80. package/build/src/akuma/index.js +1 -0
  81. package/build/src/akuma/nuke.js +6 -28
  82. package/build/src/akuma/projection.d.ts +25 -11
  83. package/build/src/akuma/projection.js +24 -7
  84. package/build/src/akuma/provider-recipe.d.ts +18 -6
  85. package/build/src/akuma/provider-recipe.js +24 -1
  86. package/build/src/akuma/provider.d.ts +31 -10
  87. package/build/src/akuma/provider.js +105 -14
  88. package/build/src/akuma/providers/acp/events.js +29 -19
  89. package/build/src/akuma/providers/acp/index.js +2 -3
  90. package/build/src/akuma/providers/claude/events.js +110 -69
  91. package/build/src/akuma/providers/claude/index.d.ts +2 -2
  92. package/build/src/akuma/providers/claude/index.js +4 -8
  93. package/build/src/akuma/providers/codex-app-server/events.js +17 -2
  94. package/build/src/akuma/providers/codex-app-server/index.js +17 -11
  95. package/build/src/akuma/providers/decode.d.ts +33 -0
  96. package/build/src/akuma/providers/decode.js +65 -0
  97. package/build/src/akuma/providers/execution-environment.d.ts +2 -1
  98. package/build/src/akuma/providers/execution-environment.js +3 -0
  99. package/build/src/akuma/providers/grok-build/index.js +16 -48
  100. package/build/src/akuma/providers/index.js +2 -0
  101. package/build/src/akuma/providers/lifecycle.d.ts +9 -0
  102. package/build/src/akuma/providers/lifecycle.js +10 -0
  103. package/build/src/akuma/providers/opencode-sdk/event-stream.d.ts +3 -3
  104. package/build/src/akuma/providers/opencode-sdk/event-stream.js +2 -25
  105. package/build/src/akuma/providers/opencode-sdk/events.d.ts +7 -43
  106. package/build/src/akuma/providers/opencode-sdk/events.js +146 -296
  107. package/build/src/akuma/providers/opencode-sdk/index.js +270 -431
  108. package/build/src/akuma/providers/opencode-sdk/native-http.d.ts +9 -0
  109. package/build/src/akuma/providers/opencode-sdk/native-http.js +69 -0
  110. package/build/src/akuma/providers/opencode-sdk/session.d.ts +42 -36
  111. package/build/src/akuma/providers/opencode-sdk/session.js +75 -84
  112. package/build/src/akuma/providers/paseo/events.d.ts +33 -0
  113. package/build/src/akuma/providers/paseo/events.js +204 -0
  114. package/build/src/akuma/providers/paseo/index.d.ts +9 -0
  115. package/build/src/akuma/providers/paseo/index.js +357 -0
  116. package/build/src/akuma/providers/pi/events.d.ts +2 -0
  117. package/build/src/akuma/providers/pi/events.js +36 -38
  118. package/build/src/akuma/providers/pi/index.js +21 -35
  119. package/build/src/akuma/publication.d.ts +2 -0
  120. package/build/src/akuma/publication.js +5 -0
  121. package/build/src/akuma/request-lifecycle.d.ts +4 -2
  122. package/build/src/akuma/request-lifecycle.js +27 -12
  123. package/build/src/akuma/request-rendezvous.js +38 -55
  124. package/build/src/akuma/request-serve.d.ts +1 -1
  125. package/build/src/akuma/request-serve.js +77 -113
  126. package/build/src/akuma/requests.d.ts +3 -1
  127. package/build/src/akuma/requests.js +32 -0
  128. package/build/src/akuma/selection-observation.d.ts +129 -53
  129. package/build/src/akuma/selection-observation.js +3 -9
  130. package/build/src/akuma/turn-drive.d.ts +3 -0
  131. package/build/src/akuma/turn-drive.js +28 -10
  132. package/build/src/akuma-body.js +12 -22
  133. package/build/src/cli/akuma-caller.d.ts +3 -0
  134. package/build/src/cli/akuma-caller.js +31 -0
  135. package/build/src/cli/commands/akuma-grammar.js +10 -16
  136. package/build/src/cli/commands/akuma.js +25 -55
  137. package/build/src/cli/commands/contract-grammar.d.ts +9 -7
  138. package/build/src/cli/commands/contract-grammar.js +40 -47
  139. package/build/src/cli/commands/contract-help.d.ts +17 -7
  140. package/build/src/cli/commands/contract-help.js +50 -11
  141. package/build/src/cli/commands/contract.js +34 -63
  142. package/build/src/cli/commands/debt-grammar.d.ts +19 -0
  143. package/build/src/cli/commands/debt-grammar.js +323 -0
  144. package/build/src/cli/commands/debt-query.d.ts +5 -0
  145. package/build/src/cli/commands/{task-query.js → debt-query.js} +9 -9
  146. package/build/src/cli/commands/{task.d.ts → debt.d.ts} +2 -2
  147. package/build/src/cli/commands/{task.js → debt.js} +87 -164
  148. package/build/src/cli/coordinates.d.ts +1 -1
  149. package/build/src/cli/coordinates.js +1 -1
  150. package/build/src/cli/parse.d.ts +5 -5
  151. package/build/src/cli/parse.js +17 -16
  152. package/build/src/cli/render/akuma-activity.d.ts +11 -83
  153. package/build/src/cli/render/akuma-activity.js +20 -382
  154. package/build/src/cli/render/catalog.d.ts +4 -7
  155. package/build/src/cli/render/catalog.js +5 -5
  156. package/build/src/cli/render/contract-history.js +3 -6
  157. package/build/src/cli/render/contract.js +17 -52
  158. package/build/src/cli/render/debt.d.ts +28 -0
  159. package/build/src/cli/render/{task.js → debt.js} +55 -133
  160. package/build/src/cli/render/kanshi.js +28 -28
  161. package/build/src/cli/render/marks.d.ts +5 -5
  162. package/build/src/cli/render/marks.js +4 -10
  163. package/build/src/cli/render/nuke.js +1 -1
  164. package/build/src/cli/render/receipt.js +3 -10
  165. package/build/src/cli/runtime.d.ts +1 -1
  166. package/build/src/cli/runtime.js +14 -20
  167. package/build/src/cli/scan.d.ts +1 -1
  168. package/build/src/cli/selectors.d.ts +3 -6
  169. package/build/src/cli/selectors.js +22 -53
  170. package/build/src/cli/usage.d.ts +1 -1
  171. package/build/src/cli/usage.js +4 -4
  172. package/build/src/contract-worktree.js +3 -3
  173. package/build/src/debt/board.d.ts +160 -0
  174. package/build/src/{task → debt}/board.js +89 -89
  175. package/build/src/debt/catalog.d.ts +11 -0
  176. package/build/src/debt/catalog.js +59 -0
  177. package/build/src/{task → debt}/context.d.ts +1 -1
  178. package/build/src/{task → debt}/context.js +1 -1
  179. package/build/src/{task → debt}/created-observation.d.ts +6 -10
  180. package/build/src/{task → debt}/created-observation.js +7 -7
  181. package/build/src/debt/document.d.ts +37 -0
  182. package/build/src/{task → debt}/document.js +37 -37
  183. package/build/src/debt/identity.d.ts +21 -0
  184. package/build/src/{task → debt}/identity.js +35 -35
  185. package/build/src/debt/index.d.ts +111 -0
  186. package/build/src/debt/index.js +203 -0
  187. package/build/src/{task → debt}/input.d.ts +8 -8
  188. package/build/src/{task → debt}/input.js +21 -21
  189. package/build/src/debt/lifecycle-operations.d.ts +6 -0
  190. package/build/src/{task → debt}/lifecycle-operations.js +27 -31
  191. package/build/src/debt/mutation-result.d.ts +981 -0
  192. package/build/src/debt/mutation-result.js +109 -0
  193. package/build/src/debt/mutation.d.ts +424 -0
  194. package/build/src/debt/mutation.js +223 -0
  195. package/build/src/debt/operation-types.d.ts +71 -0
  196. package/build/src/debt/operations.d.ts +28 -0
  197. package/build/src/{task → debt}/operations.js +59 -60
  198. package/build/src/debt/query.d.ts +76 -0
  199. package/build/src/{task → debt}/query.js +55 -55
  200. package/build/src/{task → debt}/store.d.ts +13 -13
  201. package/build/src/{task → debt}/store.js +58 -49
  202. package/build/src/debt/view.d.ts +4 -0
  203. package/build/src/debt/view.js +7 -0
  204. package/build/src/dispatch/index.d.ts +3 -3
  205. package/build/src/dispatch/index.js +1 -2
  206. package/build/src/git/observe.d.ts +6 -2
  207. package/build/src/git/observe.js +6 -2
  208. package/build/src/identity/coordinates.d.ts +1 -1
  209. package/build/src/index.d.ts +17 -17
  210. package/build/src/index.js +11 -11
  211. package/build/src/kanshi/index.d.ts +2 -2
  212. package/build/src/kanshi/read.js +54 -39
  213. package/build/src/kanshi/report.d.ts +7 -7
  214. package/build/src/kanshi/select.js +4 -4
  215. package/build/src/library/address.js +2 -4
  216. package/build/src/library/akuma-creation.d.ts +5 -1
  217. package/build/src/library/akuma-creation.js +27 -47
  218. package/build/src/library/akumas.d.ts +7 -7
  219. package/build/src/library/akumas.js +13 -9
  220. package/build/src/library/bind.d.ts +17 -17
  221. package/build/src/library/bind.js +16 -12
  222. package/build/src/library/contract-address.d.ts +9 -0
  223. package/build/src/library/contract-address.js +71 -0
  224. package/build/src/library/contract-composition.d.ts +4 -7
  225. package/build/src/library/contract-composition.js +6 -18
  226. package/build/src/library/contract-creation.d.ts +3 -5
  227. package/build/src/library/contract-creation.js +24 -22
  228. package/build/src/library/contract-execution.js +21 -26
  229. package/build/src/library/contract-outcomes.d.ts +2 -14
  230. package/build/src/library/contract-outcomes.js +2 -13
  231. package/build/src/library/contract-types.d.ts +38 -4
  232. package/build/src/library/delivery.d.ts +0 -2
  233. package/build/src/library/delivery.js +2 -5
  234. package/build/src/library/input.d.ts +2 -2
  235. package/build/src/library/input.js +5 -5
  236. package/build/src/library/invocation.js +2 -2
  237. package/build/src/library/keiyaku.d.ts +0 -5
  238. package/build/src/library/keiyaku.js +6 -12
  239. package/build/src/library/nuke.js +3 -3
  240. package/build/src/library/outcome.d.ts +626 -625
  241. package/build/src/library/outcome.js +13 -3
  242. package/build/src/library/reconcile.js +8 -16
  243. package/build/src/library/refusal.d.ts +2 -2
  244. package/build/src/library/repo.d.ts +3 -2
  245. package/build/src/library/repo.js +10 -5
  246. package/build/src/library/selection.d.ts +5 -8
  247. package/build/src/library/selection.js +22 -73
  248. package/build/src/plugin/akuma-signals.d.ts +2 -0
  249. package/build/src/plugin/akuma-signals.js +4 -0
  250. package/build/src/plugin/public.d.ts +32 -2
  251. package/build/src/plugin/runtime.js +5 -3
  252. package/build/src/protocol/amend.js +3 -2
  253. package/build/src/protocol/attempt.js +3 -8
  254. package/build/src/protocol/bind.d.ts +2 -2
  255. package/build/src/protocol/bind.js +1 -1
  256. package/build/src/protocol/deliver.js +3 -3
  257. package/build/src/protocol/operations.d.ts +1 -3
  258. package/build/src/protocol/operations.js +0 -8
  259. package/build/src/protocol/outcome.d.ts +1 -2
  260. package/build/src/protocol/outcome.js +1 -13
  261. package/build/src/protocol/placement.js +3 -10
  262. package/build/src/protocol/read/status.js +31 -70
  263. package/build/src/protocol/reintegrate.js +3 -10
  264. package/build/src/protocol/review.js +3 -3
  265. package/build/src/protocol/run.d.ts +5 -1
  266. package/build/src/protocol/run.js +3 -3
  267. package/build/src/runtime/proc/windows-launch.exe +0 -0
  268. package/build/src/settlement/fence.d.ts +3 -3
  269. package/build/src/settlement/fence.js +4 -4
  270. package/build/src/settlement/holder.d.ts +16 -16
  271. package/build/src/settlement/holder.js +69 -63
  272. package/build/src/settlement/settle.d.ts +5 -5
  273. package/build/src/settlement/settle.js +53 -53
  274. package/package.json +19 -9
  275. package/plugins/paseo/plugin/index.server.ts +17 -0
  276. package/plugins/paseo/plugin/paseo-plugin.json +4 -0
  277. package/plugins/paseo/plugin/server/attach.ts +52 -0
  278. package/plugins/paseo/plugin/server/keiyaku.ts +44 -0
  279. package/plugins/paseo/plugin/server/message.ts +60 -0
  280. package/plugins/paseo/plugin/server/mirror.ts +193 -0
  281. package/plugins/paseo/plugin/server/model.ts +14 -0
  282. package/plugins/paseo/plugin/server/provider.ts +276 -0
  283. package/plugins/paseo/plugin/server/sdk-worker.ts +237 -0
  284. package/plugins/paseo/plugin/server/sdk.ts +289 -0
  285. package/plugins/paseo/plugin/server/stop.ts +26 -0
  286. package/plugins/paseo/plugin/server/transport.ts +35 -0
  287. package/plugins/paseo/plugin/shared/attach-rpc.ts +10 -0
  288. package/plugins/paseo/plugin/shared/refresh-rpc.ts +6 -0
  289. package/plugins/paseo/plugin/tsconfig.json +6 -0
  290. package/plugins/pi/keiyaku.ts +57 -0
  291. package/skills/keiyaku/SKILL.md +43 -0
  292. package/skills/keiyaku-akuma/SKILL.md +130 -0
  293. package/skills/keiyaku-akuma/references/automation.md +269 -0
  294. package/skills/keiyaku-babysit/SKILL.md +65 -0
  295. package/skills/keiyaku-bind/SKILL.md +216 -0
  296. package/skills/keiyaku-bind/agents/openai.yaml +4 -0
  297. package/skills/keiyaku-debt/SKILL.md +91 -0
  298. package/skills/keiyaku-workflow/SKILL.md +129 -0
  299. package/build/plugins/claude/skills/keiyaku-task/SKILL.md +0 -104
  300. package/build/plugins/codex/skills/keiyaku-task/SKILL.md +0 -104
  301. package/build/plugins/opencode/skills/keiyaku-task/SKILL.md +0 -104
  302. package/build/skills/keiyaku-task/SKILL.md +0 -104
  303. package/build/src/cli/commands/amend.d.ts +0 -12
  304. package/build/src/cli/commands/amend.js +0 -10
  305. package/build/src/cli/commands/bind.d.ts +0 -11
  306. package/build/src/cli/commands/bind.js +0 -23
  307. package/build/src/cli/commands/task-grammar.d.ts +0 -19
  308. package/build/src/cli/commands/task-grammar.js +0 -384
  309. package/build/src/cli/commands/task-query.d.ts +0 -5
  310. package/build/src/cli/render/task.d.ts +0 -41
  311. package/build/src/dispatch/association.d.ts +0 -1
  312. package/build/src/dispatch/association.js +0 -1
  313. package/build/src/task/board.d.ts +0 -168
  314. package/build/src/task/catalog.d.ts +0 -11
  315. package/build/src/task/catalog.js +0 -59
  316. package/build/src/task/compose-language.d.ts +0 -57
  317. package/build/src/task/compose-language.js +0 -364
  318. package/build/src/task/compose-parser.d.ts +0 -32
  319. package/build/src/task/compose-parser.js +0 -180
  320. package/build/src/task/compose.d.ts +0 -16
  321. package/build/src/task/compose.js +0 -189
  322. package/build/src/task/document.d.ts +0 -39
  323. package/build/src/task/identity.d.ts +0 -21
  324. package/build/src/task/index.d.ts +0 -138
  325. package/build/src/task/index.js +0 -269
  326. package/build/src/task/lifecycle-operations.d.ts +0 -6
  327. package/build/src/task/mutation-result.d.ts +0 -1726
  328. package/build/src/task/mutation-result.js +0 -198
  329. package/build/src/task/mutation.d.ts +0 -590
  330. package/build/src/task/mutation.js +0 -262
  331. package/build/src/task/operation-types.d.ts +0 -71
  332. package/build/src/task/operations.d.ts +0 -28
  333. package/build/src/task/query.d.ts +0 -76
  334. package/build/src/task/view.d.ts +0 -4
  335. package/build/src/task/view.js +0 -7
  336. /package/build/src/{task → debt}/operation-types.js +0 -0
@@ -0,0 +1,91 @@
1
+ ---
2
+ name: keiyaku-debt
3
+ description: >-
4
+ Must read when recording confirmed unresolved work or dependencies in Debts.
5
+ ---
6
+
7
+ # Keiyaku Debt
8
+
9
+ A Debt records confirmed unresolved work and its relationships. Debt is an
10
+ independent product; it is not a Contract, Arc, Akuma, permission, acceptance
11
+ boundary, or fulfillment lifecycle.
12
+
13
+ ## 1. When To Use A Debt
14
+
15
+ Use a Debt when confirmed unresolved work or a dependency must outlive the
16
+ current conversation. Keep plans and execution progress in reasoning or session
17
+ notes instead.
18
+
19
+ - Use a `kei` for one independently acceptable outcome.
20
+ - Use an Arc for a chapter inside one `kei`.
21
+ - Use a Debt for confirmed unresolved work and its prerequisites.
22
+ - Do not create a Debt just to mirror a `kei`.
23
+
24
+ A Debt may exist without a Contract. Associating a Debt with a `kei` does not
25
+ transfer the Contract's holder, acceptance, or lifecycle to the Debt.
26
+
27
+ ## 2. Relationships And Parallel Work
28
+
29
+ Independent work may proceed in parallel when its dependencies allow it.
30
+ Debt records no execution-progress state.
31
+
32
+ Use the relationships for their actual meanings:
33
+
34
+ - `needs` means this Debt must wait for another Debt to become terminal.
35
+ - `parent` groups decomposition; it does not create a dependency.
36
+ - `supersedes` points to work replaced by this Debt.
37
+ - `relates` records a connection without affecting readiness.
38
+
39
+ Only `needs` orders work. Do not add it because Debts touch the same Region or
40
+ because one Debt is related to another. A terminal Debt releases its dependents.
41
+
42
+ ## 3. Debt Commands
43
+
44
+ Create and inspect Debts:
45
+
46
+ ```bash
47
+ keiyaku debt add "<title>"
48
+ keiyaku debt add "<title>" --priority 1 --needs <debt-id>
49
+ keiyaku debt show <debt-id>
50
+ keiyaku debt ls
51
+ keiyaku debt ready
52
+ keiyaku debt blocked
53
+ keiyaku debt tree <debt-id>
54
+ keiyaku debt doctor
55
+ ```
56
+
57
+ Use complete Debt IDs for targeted commands. `ls`, `ready`, and `blocked` use
58
+ the current namespace; use `--world` to inspect the complete Debt world.
59
+
60
+ Close work:
61
+
62
+ ```bash
63
+ keiyaku debt done <debt-id>...
64
+ keiyaku debt drop <debt-id>... --note "<reason>"
65
+ ```
66
+
67
+ Use `done` when the Debt is complete. Use `drop` when it is no longer owed.
68
+ Both terminal states release dependent Debts. Unresolved `needs` appear in
69
+ `blocked`; open work with all prerequisites terminal appears in `ready`.
70
+
71
+ Update a Debt without changing its lifecycle:
72
+
73
+ ```bash
74
+ keiyaku debt update <debt-id> --title "<title>"
75
+ keiyaku debt update <debt-id> --body "<body>"
76
+ keiyaku debt update <debt-id> --needs <debt-id>
77
+ ```
78
+
79
+ ## 4. After Creating A Debt
80
+
81
+ Read the returned Debt identity. Then:
82
+
83
+ 1. Add or remove relationships when the confirmed prerequisites change.
84
+ 2. Mark completed work `done`, or work no longer owed `drop` with a reason.
85
+ 3. Use `ready`, `blocked`, `tree`, or `doctor` to inspect the current ledger.
86
+
87
+ Debt records unresolved work. It does not perform the work, claim acceptance,
88
+ assign a holder, or decide what a Contract may accept.
89
+
90
+ Read `keiyaku-bind` for Contract authoring and `keiyaku-workflow` for Contract
91
+ lifecycle.
@@ -33,7 +33,7 @@ to create parallel work.
33
33
 
34
34
  - Separate `kei`s have independently acceptable outcomes.
35
35
  - An Arc is a chapter of one `kei`; it is not separately accepted.
36
- - A Task stores decomposition or dependencies that outlive this conversation.
36
+ - A Debt records confirmed unresolved work and its dependencies.
37
37
 
38
38
  Use `after` only when one `kei` requires another to be accepted first. Ordinary
39
39
  overlap is not a dependency.
@@ -101,7 +101,7 @@ authority.
101
101
  | Role | Grant at birth | Return |
102
102
  | --- | --- | --- |
103
103
  | Holder | The actions the delegated loop will perform; include `contract.review` when this holder will review. Commission with the `kei`, current Arc when one exists, appointed worktree, and holder duties. | Acceptance or abandonment, with receipts. |
104
- | Deliverer | The ordinary baseline: every Task mutation, Contract audit and delivery, and Akuma management. `keiyaku -C <repo> call worker --alias @deliverer --contract <kei/...> --workdir <appointed-path> -` | The delivery receipt. |
104
+ | Deliverer | The ordinary baseline: every Debt mutation, Contract audit and delivery, and Akuma management. `keiyaku -C <repo> call worker --alias @deliverer --contract <kei/...> --workdir <appointed-path> -` | The delivery receipt. |
105
105
  | Reviewer | `--allowed contract.review`: `keiyaku -C <repo> call review-akuma --alias @reviewer --contract <kei/...> --workdir <appointed-path> --allowed contract.review -` | The verdict receipt. Without the grant, `not-allowed` refuses and no verdict is recorded. |
106
106
 
107
107
  An Archetype's explicit allowed set replaces the ordinary baseline; check
@@ -1,3 +1,4 @@
1
+ import { type AkumaCaller } from "./caller.js";
1
2
  import type { Settings } from "../settings.js";
2
3
  import type { WorldRoot } from "../world.js";
3
4
  import { type AllowedAction } from "./allowed.js";
@@ -17,6 +18,7 @@ export type AkumaCallInput = Readonly<{
17
18
  allowed?: readonly AllowedAction[];
18
19
  schema?: Schema<unknown>;
19
20
  initiator?: string;
21
+ caller?: AkumaCaller;
20
22
  signal?: AbortSignal;
21
23
  }>;
22
24
  type AkumaCallContext = Readonly<{
@@ -1,3 +1,4 @@
1
+ import { decodeAkumaCaller } from "./caller.js";
1
2
  import { randomUUID } from "node:crypto";
2
3
  import { settings as readSettings } from "../settings.js";
3
4
  import { readAkumaBirthCwd } from "./akuma-observe.js";
@@ -7,7 +8,7 @@ import { AkumaArchetypeError, loadPreparedArchetype } from "./archetype.js";
7
8
  import { spawnAkumaBody } from "./body.js";
8
9
  import { canonicalBirthCwd } from "./call-input.js";
9
10
  import { requestForwardedAkumaCall } from "./call-request.js";
10
- import { archetypeName } from "./identity.js";
11
+ import { validateAkumaName } from "../identity/normalize.js";
11
12
  import { PreparedCallAdmissionError, executePreparedCall } from "./publication.js";
12
13
  import { executionChannel } from "./requests.js";
13
14
  async function admitBodyRequest(input) {
@@ -24,6 +25,8 @@ async function admitBodyRequest(input) {
24
25
  ...(input.call.initialTell === undefined ? {} : { initialTell: input.call.initialTell }),
25
26
  ...(cwd === undefined ? {} : { cwd }),
26
27
  recipe: input.recipe,
28
+ ...(input.call.initiator === undefined ? {} : { birthInitiator: input.call.initiator }),
29
+ ...(input.call.contractId === undefined ? {} : { contractId: input.call.contractId }),
27
30
  ...(input.call.signal === undefined ? {} : { signal: input.call.signal }),
28
31
  });
29
32
  const bornCwd = await readAkumaBirthCwd(input.path, response.id);
@@ -50,6 +53,7 @@ async function admitDirect(input) {
50
53
  result = await executePreparedCall({
51
54
  archetype: input.archetype.name,
52
55
  cwd,
56
+ ...(input.call.caller === undefined ? {} : { caller: input.call.caller }),
53
57
  ...(input.call.initialTell === undefined ? {} : { initialTell: input.call.initialTell }),
54
58
  ...(input.call.signal === undefined ? {} : { signal: input.call.signal }),
55
59
  custody: {
@@ -59,6 +63,7 @@ async function admitDirect(input) {
59
63
  spawn: async (launch) => await spawnAkumaBody({
60
64
  paths: launch.paths,
61
65
  seed: launch.seed,
66
+ ...(input.call.initiator === undefined ? {} : { birthInitiator: input.call.initiator }),
62
67
  ...(input.call.contractId === undefined ? {} : { completion: { contractId: input.call.contractId } }),
63
68
  }),
64
69
  admitInitialTell: async ({ id, initialTell, signal }) => await new AkumaOwner(id, input.path).admitInitialTell(initialTell, {
@@ -93,7 +98,8 @@ async function admitDirect(input) {
93
98
  * then invoke the P3 prepared-call executor under local or request custody.
94
99
  */
95
100
  export async function admitAkumaCall(path, configuration, input, context) {
96
- const name = archetypeName(input.archetype);
101
+ decodeAkumaCaller(input.caller);
102
+ const name = validateAkumaName(input.archetype);
97
103
  const home = configuration.home === undefined ? {} : { home: configuration.home };
98
104
  const settings = configuration.settings ?? (await readSettings({ root: path, ...home }));
99
105
  const archetype = await loadPreparedArchetype({ name, project: path, ...home, settings });
@@ -1,5 +1,7 @@
1
+ import type { AkumaCaller } from "./caller.js";
1
2
  import type { Settings } from "../settings.js";
2
3
  import type { WorldRoot } from "../world.js";
4
+ import type { AkumaStreamSnapshot } from "./akuma-stream.js";
3
5
  import { type InterruptReceipt } from "./akuma-owner.js";
4
6
  import { type AkumaStatus } from "./akuma.js";
5
7
  import type { AllowedAction } from "./allowed.js";
@@ -24,12 +26,21 @@ export type AkumaHistoryOptions = Readonly<{
24
26
  export type AkumaSignalOptions = Readonly<{
25
27
  signal?: AbortSignal;
26
28
  }>;
29
+ /** Observes only plugin diagnostics produced in this host, never remote Body logs. */
30
+ export type AkumaHostOptions = Readonly<{
31
+ reportDiagnostic?: (message: string) => void;
32
+ }>;
33
+ /** Capture the observer capability, not the caller's mutable options object. */
34
+ export declare function captureAkumaHostDiagnostic(host: AkumaHostOptions | undefined): AkumaHostOptions["reportDiagnostic"];
27
35
  export type AkumaBirthInput = Readonly<{
28
36
  root: WorldRoot;
29
37
  cwd?: string;
30
38
  home?: string;
31
39
  settings?: Settings;
32
40
  allowed?: readonly AllowedAction[];
41
+ caller?: AkumaCaller;
42
+ initiator?: string;
43
+ host?: AkumaHostOptions;
33
44
  }>;
34
45
  export type AkumaTellOptions = AkumaSignalOptions & Readonly<{
35
46
  interrupt?: boolean;
@@ -43,10 +54,11 @@ export type { AkumaAskResult, AkumaTellResult, InterruptReceipt, KillEvidence };
43
54
  export declare class Akuma {
44
55
  readonly id: AkuId;
45
56
  private readonly root;
57
+ private readonly reportDiagnostic;
46
58
  private constructor();
47
59
  private owner;
48
60
  static birth(archetype: string, input: AkumaBirthInput): Promise<Akuma>;
49
- static select(root: WorldRoot, selector: string): Akuma;
61
+ static select(root: WorldRoot, selector: string, host?: AkumaHostOptions): Akuma;
50
62
  tell(text: string, options?: AkumaTellOptions): Promise<AkumaTellResult>;
51
63
  ask(text: string, options?: AkumaAskOptions<string>): Promise<AkumaAskResult<string>>;
52
64
  ask<T>(text: string, options: AkumaAskOptions<T> & Readonly<{
@@ -55,5 +67,6 @@ export declare class Akuma {
55
67
  status(): Promise<AkumaStatus>;
56
68
  idle(options?: AkumaIdleOptions): Promise<AkumaIdleResult>;
57
69
  history(options?: AkumaHistoryOptions): Promise<ActivityHistory>;
70
+ stream(options?: AkumaSignalOptions): AsyncIterable<AkumaStreamSnapshot>;
58
71
  kill(options?: AkumaSignalOptions): Promise<KillEvidence>;
59
72
  }
@@ -1,4 +1,4 @@
1
- import { outcomePluginObserver } from "../plugin/akuma-signals.js";
1
+ import { outcomePluginObserver, stderrPluginDiagnostic } from "../plugin/akuma-signals.js";
2
2
  import { abortable } from "./abort.js";
3
3
  import { admitAkumaCall } from "./akuma-call.js";
4
4
  import { defaultWaitComplete } from "./akuma-observe.js";
@@ -6,6 +6,20 @@ import { AkumaOwner } from "./akuma-owner.js";
6
6
  import { decodeAskObservation, executeAskAkuma, executeTellAkuma } from "./akuma-selection-execution.js";
7
7
  import { parseAkuId } from "./identity.js";
8
8
  import { schemaFromStandard, schemaJsonText } from "./schema.js";
9
+ /** Capture the observer capability, not the caller's mutable options object. */
10
+ export function captureAkumaHostDiagnostic(host) {
11
+ if (host === undefined)
12
+ return undefined;
13
+ if (typeof host !== "object" || host === null || Array.isArray(host))
14
+ throw new TypeError("Akuma host options must be an object");
15
+ const unknown = Object.keys(host).find((key) => key !== "reportDiagnostic");
16
+ if (unknown !== undefined)
17
+ throw new TypeError(`Akuma host options has unknown field: ${unknown}`);
18
+ const reportDiagnostic = host.reportDiagnostic;
19
+ if (reportDiagnostic !== undefined && typeof reportDiagnostic !== "function")
20
+ throw new TypeError("Akuma host reportDiagnostic must be a function");
21
+ return reportDiagnostic;
22
+ }
9
23
  function signalOption(value) {
10
24
  if (value === undefined)
11
25
  return undefined;
@@ -16,13 +30,15 @@ function signalOption(value) {
16
30
  export class Akuma {
17
31
  id;
18
32
  root;
19
- constructor(id, root) {
33
+ reportDiagnostic;
34
+ constructor(id, root, reportDiagnostic) {
20
35
  this.id = id;
21
36
  this.root = root;
37
+ this.reportDiagnostic = reportDiagnostic;
22
38
  Object.freeze(this);
23
39
  }
24
40
  owner(observing = false) {
25
- return new AkumaOwner(this.id, this.root, observing ? outcomePluginObserver({ world: this.root, reportDiagnostic: console.error }) : undefined);
41
+ return new AkumaOwner(this.id, this.root, observing ? outcomePluginObserver({ world: this.root, reportDiagnostic: this.reportDiagnostic }) : undefined);
26
42
  }
27
43
  static async birth(archetype, input) {
28
44
  if (typeof input !== "object" || input === null || Array.isArray(input)) {
@@ -30,6 +46,7 @@ export class Akuma {
30
46
  }
31
47
  if (typeof input.root !== "string")
32
48
  throw new TypeError("Akuma birth root must be a WorldRoot");
49
+ const reportDiagnostic = captureAkumaHostDiagnostic(input.host) ?? stderrPluginDiagnostic;
33
50
  const admitted = await admitAkumaCall(input.root, {
34
51
  ...(input.home === undefined ? {} : { home: input.home }),
35
52
  ...(input.settings === undefined ? {} : { settings: input.settings }),
@@ -37,15 +54,18 @@ export class Akuma {
37
54
  archetype,
38
55
  ...(input.cwd === undefined ? {} : { cwd: input.cwd }),
39
56
  ...(input.allowed === undefined ? {} : { allowed: input.allowed }),
57
+ ...(input.caller === undefined ? {} : { caller: input.caller }),
58
+ ...(input.initiator === undefined ? {} : { initiator: input.initiator }),
40
59
  }, {});
41
60
  if (admitted.failure !== undefined)
42
61
  throw admitted.failure;
43
- return new Akuma(admitted.id, input.root);
62
+ return new Akuma(admitted.id, input.root, reportDiagnostic);
44
63
  }
45
- static select(root, selector) {
64
+ static select(root, selector, host) {
46
65
  if (typeof root !== "string")
47
66
  throw new TypeError("Akuma.select root must be a WorldRoot");
48
- return new Akuma(parseAkuId(selector).id, root);
67
+ const reportDiagnostic = captureAkumaHostDiagnostic(host) ?? stderrPluginDiagnostic;
68
+ return new Akuma(parseAkuId(selector).id, root, reportDiagnostic);
49
69
  }
50
70
  async tell(text, options = {}) {
51
71
  if (typeof text !== "string")
@@ -85,7 +105,7 @@ export class Akuma {
85
105
  const result = await executeAskAkuma({
86
106
  path: this.root,
87
107
  id: this.id,
88
- outcomeObserved: outcomePluginObserver({ world: this.root, reportDiagnostic: console.error }),
108
+ outcomeObserved: outcomePluginObserver({ world: this.root, reportDiagnostic: this.reportDiagnostic }),
89
109
  body: text,
90
110
  ...(options.timeoutMs === undefined ? {} : { timeoutMs: options.timeoutMs }),
91
111
  ...(schema === undefined ? {} : { schemaJson: schemaJsonText(schema) }),
@@ -131,6 +151,16 @@ export class Akuma {
131
151
  ...(options.limit === undefined ? {} : { limit: options.limit }),
132
152
  }));
133
153
  }
154
+ stream(options = {}) {
155
+ if (typeof options !== "object" || options === null || Array.isArray(options)) {
156
+ throw new TypeError("Akuma stream options must be an object");
157
+ }
158
+ const unknown = Object.keys(options).find((key) => key !== "signal");
159
+ if (unknown !== undefined)
160
+ throw new TypeError(`Akuma stream options has unknown field: ${unknown}`);
161
+ const signal = signalOption(options.signal);
162
+ return this.owner(true).stream(signal === undefined ? {} : { signal });
163
+ }
134
164
  async kill(options = {}) {
135
165
  if (typeof options !== "object" || options === null || Array.isArray(options)) {
136
166
  throw new TypeError("Akuma kill options must be an object");
@@ -1,5 +1,5 @@
1
1
  import { type AkuId, type AkumaPaths } from "./identity.js";
2
- import { selectHistory, selectSnapshot, type ActivityHistory, type ActivityRow, type ActivitySnapshot, type TurnLedger } from "./projection.js";
2
+ import { selectHistory, type ActivityHistory, type ActivityRow, type ActivitySnapshot } from "./projection.js";
3
3
  import type { WorldRoot } from "../world.js";
4
4
  import type { AkumaAlias } from "../identity/selector.js";
5
5
  import type { AkumaListRow, AkumaStatus, UnbornAkumaListRow } from "./akuma.js";
@@ -25,23 +25,47 @@ type StatusObservationInput = Readonly<{
25
25
  ordinaryBudget?: number;
26
26
  admittedTellId?: string;
27
27
  }>;
28
- type StatusProjection = Readonly<{
29
- ledger: TurnLedger;
30
- selected: ReturnType<typeof selectSnapshot>;
31
- }>;
32
28
  /** Private to a live wait: retain only this member's current frontier and last selection. */
33
29
  export declare function createLiveStatusReader(paths: AkumaPaths, expected: AkuId): {
34
30
  clear: () => void;
31
+ execution(signal?: AbortSignal): Promise<import("./heart/facts.js").AkumaLife>;
32
+ tellOutcome: (id: string, signal?: AbortSignal) => Promise<{
33
+ tell: Readonly<{
34
+ kind: "tell";
35
+ sequence: number;
36
+ id: string;
37
+ body: string;
38
+ initiator?: string;
39
+ schemaJson?: string;
40
+ recordedAt: string;
41
+ state: "pending" | "told";
42
+ deliveries: readonly import("./heart/facts.js").TellDelivery[];
43
+ binding?: import("./heart/facts.js").TellBinding;
44
+ }> | null;
45
+ end: Readonly<{
46
+ kind: "turn-end";
47
+ sequence: number;
48
+ turnSequence: number;
49
+ outcome: import("./heart/facts.js").TurnOutcome;
50
+ completedAt: string;
51
+ }> | undefined;
52
+ }>;
53
+ complete(signal?: AbortSignal): Promise<boolean>;
35
54
  read(input: StatusObservationInput, signal?: AbortSignal): Promise<LiveStatusObservation>;
36
55
  };
37
- /** Internal live companion for an observation loop; it is not a public result. */
38
- export declare function bornLiveStatus(paths: AkumaPaths, expected: AkuId, input: StatusObservationInput, signal?: AbortSignal, readProjection?: () => Promise<StatusProjection>): Promise<LiveStatusObservation>;
56
+ /** One-shot observations use the same reader and always release it. */
57
+ export declare function bornLiveStatus(paths: AkumaPaths, expected: AkuId, input: StatusObservationInput, signal?: AbortSignal): Promise<LiveStatusObservation>;
39
58
  export declare function bornStatus(paths: AkumaPaths, expected: AkuId, input: StatusObservationInput): Promise<BudgetedStatusObservation>;
40
59
  export declare function readLiveStatus(worldPath: WorldRoot, id: AkuId, input: StatusObservationInput, signal?: AbortSignal): Promise<LiveStatusObservation>;
60
+ export type ExecutionProgress = "settled" | "advancing" | "stopped";
61
+ /** Pending input is not execution. An owned launch can bridge the admission gap. */
62
+ export declare function executionProgress(life: AkumaStatus["life"], pending: boolean, wake?: "launching" | "settled" | "failed"): ExecutionProgress;
41
63
  export declare function defaultWaitComplete(status: AkumaStatus): boolean;
42
64
  /** Probe completion only; returned statuses still come from a full observation. */
43
- export declare function readWaitComplete(worldPath: WorldRoot, ids: readonly AkuId[], completion: "any" | "all", signal?: AbortSignal): Promise<boolean>;
65
+ export declare function readWaitComplete(worldPath: WorldRoot, ids: readonly AkuId[], completion: "any" | "all", signal?: AbortSignal, probe?: (id: AkuId) => Promise<boolean>): Promise<boolean>;
44
66
  export type WaitReason = "completed" | "deadline";
67
+ /** The one observation cadence public waiting and timeline streaming share. */
68
+ export declare const OBSERVATION_POLL_MS = 100;
45
69
  /**
46
70
  * The one deadline-aware observation loop for public Akuma waiting. It always
47
71
  * reads once before judging a passed deadline, so a zero-duration wait remains
@@ -49,6 +73,7 @@ export type WaitReason = "completed" | "deadline";
49
73
  */
50
74
  export declare function waitForObservation<T>(input: Readonly<{
51
75
  timeoutMs?: number;
76
+ pollMs?: number;
52
77
  signal?: AbortSignal;
53
78
  probe?(): Promise<boolean>;
54
79
  observe(): Promise<T>;
@@ -1,4 +1,5 @@
1
- import { readStatusFacts, createStatusFactReader, readLifeSnapshot, HeldAkumaLeash, isHeartAbsent, life, lifeAt, probeLeash, readHeart, readSeal, readSoul, } from "./heart/index.js";
1
+ import { projectAkumaBirth } from "./caller.js";
2
+ import { createStatusFactReader, readLifeSnapshot, HeldAkumaLeash, isHeartAbsent, life, lifeAt, probeLeash, readHeart, readSeal, readSoul, } from "./heart/index.js";
2
3
  import { pathsForAkuId } from "./identity.js";
3
4
  import { ordinarySnapshotBudget, projectTurns, selectHistory, selectSnapshot, } from "./projection.js";
4
5
  import { resolveProviderExecution } from "./providers/index.js";
@@ -88,59 +89,75 @@ export function createLiveStatusReader(paths, expected) {
88
89
  };
89
90
  return {
90
91
  clear,
91
- async read(input, signal) {
92
+ async execution(signal) {
93
+ return (await bornObservation(paths, expected, () => reader.life(signal))).currentLife;
94
+ },
95
+ tellOutcome: reader.tellOutcome,
96
+ async complete(signal) {
92
97
  try {
93
- return await bornLiveStatus(paths, expected, input, signal, async () => {
94
- const facts = await reader.read(input, signal);
95
- const ledger = memo?.facts === facts ? memo.ledger : projectTurns(facts);
96
- const options = snapshotSelection(input);
97
- const selected = memo?.ledger === ledger &&
98
- memo.options.aperture === options.aperture &&
99
- memo.options.admittedTellId === options.admittedTellId &&
100
- memo.options.budget.tail === options.budget.tail &&
101
- memo.options.budget.voice === options.budget.voice
102
- ? memo.selected
103
- : selectSnapshot(ledger, options);
104
- memo = { facts, ledger, options, selected };
105
- return { ledger, selected };
106
- });
98
+ const observed = await bornObservation(paths, expected, () => reader.life(signal));
99
+ return complete(observed.currentLife, observed.snapshot.hasPendingTell);
107
100
  }
108
101
  catch (error) {
109
102
  clear();
110
103
  throw error;
111
104
  }
112
105
  },
113
- };
114
- }
115
- /** Internal live companion for an observation loop; it is not a public result. */
116
- export async function bornLiveStatus(paths, expected, input, signal, readProjection) {
117
- if (input.ordinaryBudget !== undefined && (!Number.isSafeInteger(input.ordinaryBudget) || input.ordinaryBudget < 0))
118
- throw new TypeError("ordinary budget must be a nonnegative safe integer");
119
- const { snapshot, soul, currentLife } = await bornObservation(paths, expected, () => readLifeSnapshot(paths, signal));
120
- const resumeUnsupported = currentLife === "stranded" &&
121
- snapshot.latestSession?.provider === soul.provider.name &&
122
- (await resolveProviderExecution(soul.provider)).adapter.resume === undefined;
123
- const { ledger, selected } = readProjection === undefined ? await readStatusProjection(paths, input, signal) : await readProjection();
124
- return {
125
- status: {
126
- id: soul.id,
127
- life: currentLife,
128
- cwd: soul.cwd,
129
- allowed: soul.allowed,
130
- ...(resumeUnsupported ? { strandedReason: "resume-unsupported" } : {}),
131
- timeline: selected.snapshot,
106
+ async read(input, signal) {
107
+ try {
108
+ if (input.ordinaryBudget !== undefined &&
109
+ (!Number.isSafeInteger(input.ordinaryBudget) || input.ordinaryBudget < 0))
110
+ throw new TypeError("ordinary budget must be a nonnegative safe integer");
111
+ const { snapshot, soul, currentLife } = await bornObservation(paths, expected, () => reader.life(signal));
112
+ const resumeUnsupported = currentLife === "stranded" &&
113
+ snapshot.latestSession?.provider === soul.provider.name &&
114
+ (await resolveProviderExecution(soul.provider)).adapter.resume === undefined;
115
+ const facts = await reader.read(input, signal);
116
+ const ledger = memo?.facts === facts ? memo.ledger : projectTurns(facts);
117
+ const options = snapshotSelection(input);
118
+ const selected = memo?.ledger === ledger &&
119
+ memo.options.aperture === options.aperture &&
120
+ memo.options.admittedTellId === options.admittedTellId &&
121
+ memo.options.budget.tail === options.budget.tail &&
122
+ memo.options.budget.voice === options.budget.voice
123
+ ? memo.selected
124
+ : selectSnapshot(ledger, options);
125
+ memo = { facts, ledger, options, selected };
126
+ return {
127
+ status: {
128
+ id: soul.id,
129
+ birth: projectAkumaBirth(soul),
130
+ life: currentLife,
131
+ cwd: soul.cwd,
132
+ // The execution adapter and its one current model are what this Akuma
133
+ // actually runs; a birth request the Soul still only seeded is not a
134
+ // claim that a native runtime ever used it.
135
+ provider: soul.provider.name,
136
+ ...(soul.options.model === undefined ? {} : { model: soul.options.model }),
137
+ allowed: soul.allowed,
138
+ ...(resumeUnsupported ? { strandedReason: "resume-unsupported" } : {}),
139
+ timeline: selected.snapshot,
140
+ },
141
+ ordinarySelected: selected.ordinaryCount,
142
+ rows: ledger.rows,
143
+ };
144
+ }
145
+ catch (error) {
146
+ clear();
147
+ throw error;
148
+ }
132
149
  },
133
- ordinarySelected: selected.ordinaryCount,
134
- rows: ledger.rows,
135
150
  };
136
151
  }
137
- async function readStatusProjection(paths, input, signal) {
138
- const facts = await readStatusFacts(paths, input, signal);
139
- const ledger = projectTurns(facts);
140
- return {
141
- ledger,
142
- selected: selectSnapshot(ledger, snapshotSelection(input)),
143
- };
152
+ /** One-shot observations use the same reader and always release it. */
153
+ export async function bornLiveStatus(paths, expected, input, signal) {
154
+ const reader = createLiveStatusReader(paths, expected);
155
+ try {
156
+ return await reader.read(input, signal);
157
+ }
158
+ finally {
159
+ reader.clear();
160
+ }
144
161
  }
145
162
  export async function bornStatus(paths, expected, input) {
146
163
  const { rows: _rows, ...status } = await bornLiveStatus(paths, expected, input);
@@ -149,21 +166,33 @@ export async function bornStatus(paths, expected, input) {
149
166
  export async function readLiveStatus(worldPath, id, input, signal) {
150
167
  return await bornLiveStatus(pathsForAkuId(worldPath, id), id, input, signal);
151
168
  }
169
+ /** Pending input is not execution. An owned launch can bridge the admission gap. */
170
+ export function executionProgress(life, pending, wake = "settled") {
171
+ if (wake === "launching" || life === "running")
172
+ return "advancing";
173
+ if (wake === "failed")
174
+ return "stopped";
175
+ if (life === "asleep")
176
+ return pending ? "advancing" : "settled";
177
+ return "stopped";
178
+ }
152
179
  function complete(life, pending) {
153
- return life !== "running" && !pending;
180
+ return executionProgress(life, pending) !== "advancing";
154
181
  }
155
182
  export function defaultWaitComplete(status) {
156
183
  return complete(status.life, status.timeline.entries.some((entry) => entry.kind === "row" && entry.row.kind === "tell" && entry.row.state === "pending"));
157
184
  }
158
185
  /** Probe completion only; returned statuses still come from a full observation. */
159
- export async function readWaitComplete(worldPath, ids, completion, signal) {
186
+ export async function readWaitComplete(worldPath, ids, completion, signal, probe) {
160
187
  let completed = 0;
161
188
  for (const id of ids) {
162
189
  signal?.throwIfAborted();
163
190
  try {
164
191
  const paths = pathsForAkuId(worldPath, id);
165
- const observed = await bornObservation(paths, id, () => readLifeSnapshot(paths, signal));
166
- if (complete(observed.currentLife, observed.snapshot.hasPendingTell)) {
192
+ const ready = probe === undefined
193
+ ? await bornObservation(paths, id, () => readLifeSnapshot(paths, signal)).then((observed) => complete(observed.currentLife, observed.snapshot.hasPendingTell))
194
+ : await probe(id);
195
+ if (ready) {
167
196
  if (completion === "any")
168
197
  return true;
169
198
  completed += 1;
@@ -176,7 +205,8 @@ export async function readWaitComplete(worldPath, ids, completion, signal) {
176
205
  }
177
206
  return ids.length > 0 && completed === ids.length;
178
207
  }
179
- const OBSERVATION_POLL_MS = 100;
208
+ /** The one observation cadence public waiting and timeline streaming share. */
209
+ export const OBSERVATION_POLL_MS = 100;
180
210
  /**
181
211
  * The one deadline-aware observation loop for public Akuma waiting. It always
182
212
  * reads once before judging a passed deadline, so a zero-duration wait remains
@@ -188,22 +218,18 @@ export async function waitForObservation(input) {
188
218
  input.signal?.throwIfAborted();
189
219
  const ready = input.probe === undefined || (await input.probe());
190
220
  input.signal?.throwIfAborted();
191
- if (!ready && (deadline === undefined || performance.now() < deadline)) {
192
- await abortableDelay(deadline === undefined
193
- ? OBSERVATION_POLL_MS
194
- : Math.min(OBSERVATION_POLL_MS, Math.max(0, deadline - performance.now())), input.signal);
195
- continue;
221
+ if (ready || (deadline !== undefined && performance.now() >= deadline)) {
222
+ const value = await input.observe();
223
+ input.signal?.throwIfAborted();
224
+ await input.onObserve?.(value);
225
+ if (input.complete(value))
226
+ return { reason: "completed", value };
227
+ if (deadline !== undefined && performance.now() >= deadline)
228
+ return { reason: "deadline", value };
196
229
  }
197
- const value = await input.observe();
198
- input.signal?.throwIfAborted();
199
- await input.onObserve?.(value);
200
- if (input.complete(value))
201
- return { reason: "completed", value };
202
- if (deadline !== undefined && performance.now() >= deadline)
203
- return { reason: "deadline", value };
204
230
  await abortableDelay(deadline === undefined
205
- ? OBSERVATION_POLL_MS
206
- : Math.min(OBSERVATION_POLL_MS, Math.max(0, deadline - performance.now())), input.signal);
231
+ ? (input.pollMs ?? OBSERVATION_POLL_MS)
232
+ : Math.min(input.pollMs ?? OBSERVATION_POLL_MS, Math.max(0, deadline - performance.now())), input.signal);
207
233
  }
208
234
  }
209
235
  export async function readAkumaBirthCwd(worldPath, id) {
@@ -1,5 +1,7 @@
1
+ import { type AkumaCaller } from "./caller.js";
1
2
  import type { WorldRoot } from "../world.js";
2
3
  import { type OutcomeObserver, type LiveStatusObservation, type WaitReason } from "./akuma-observe.js";
4
+ import { type AkumaStreamSnapshot } from "./akuma-stream.js";
3
5
  import type { AkumaStatus } from "./akuma.js";
4
6
  import { type TellResult, type TellWakeRuntime } from "./body.js";
5
7
  import { type CallInitialTell, type CallInitialTellAdmission } from "./call-initial-tell.js";
@@ -63,7 +65,7 @@ export declare function killAkumaWithRecovery(paths: AkumaPaths, recover?: (path
63
65
  * The one lower native Akuma owner: standalone identity, plural selection and
64
66
  * the request service all consume these same single-target algorithms. It reads
65
67
  * only Heart, leash, provider and filesystem state; optional Alias, Dispatch,
66
- * Task and Contract associations are composed above this boundary.
68
+ * Debt and Contract associations are composed above this boundary.
67
69
  */
68
70
  export declare class AkumaOwner {
69
71
  readonly id: AkuId;
@@ -80,6 +82,14 @@ export declare class AkumaOwner {
80
82
  since?: number;
81
83
  limit?: number;
82
84
  }>): Promise<ActivityHistory | ExactHistory>;
85
+ /**
86
+ * Continuously observe that same retained timeline. Each emission is the whole
87
+ * latest bounded window through the existing history projection, and the
88
+ * operation observes until its caller stops pulling or aborts.
89
+ */
90
+ stream(options?: Readonly<{
91
+ signal?: AbortSignal;
92
+ }>): AsyncIterable<AkumaStreamSnapshot>;
83
93
  waitReceipt(predicate?: (status: AkumaStatus) => boolean, options?: Readonly<{
84
94
  timeoutMs?: number;
85
95
  signal?: AbortSignal;
@@ -121,12 +131,12 @@ export declare class AkumaOwner {
121
131
  timeoutMs?: number;
122
132
  signal?: AbortSignal;
123
133
  observe?: (observation: LiveStatusObservation) => void | Promise<void>;
134
+ wake?: () => "launching" | "settled" | "failed";
124
135
  }>): Promise<Readonly<{
125
136
  reason: WaitReason;
126
137
  outcome: TurnOutcome | null;
127
138
  completedAt: string | null;
128
139
  }>>;
129
- private boundTellOutcome;
130
140
  interrupt(body: string, options?: Readonly<{
131
141
  tellId?: string;
132
142
  schemaJson?: string;
@@ -147,6 +157,8 @@ export declare class AkumaOwner {
147
157
  }>): Promise<InterruptAdmission>;
148
158
  fork(input: Readonly<{
149
159
  at: string;
160
+ caller?: AkumaCaller;
161
+ initiator?: string;
150
162
  }>): Promise<ForkReceipt>;
151
163
  kill(options?: Readonly<{
152
164
  signal?: AbortSignal;