@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
@@ -22,7 +22,7 @@ import { regionOverlapSchema } from "./region.js";
22
22
  // One invocation-wide tagged Effect carrier
23
23
  // ---------------------------------------------------------------------------
24
24
  const reconciliationEffectSchema = z.union([reconcileEffectSchema, contractFileEffectSchema]);
25
- const resetOwnerSchema = z.enum(["akuma", "git", "task", "world"]);
25
+ const resetOwnerSchema = z.enum(["akuma", "git", "debt", "world"]);
26
26
  const resetEffectFields = { world: z.string().min(1), owner: resetOwnerSchema, diagnostic: z.string().min(1) };
27
27
  const resetEffectSchema = z.union([
28
28
  z.object({ kind: z.literal("reset-owner-stopped"), ...resetEffectFields }).strict(),
@@ -158,7 +158,7 @@ export function project(operation, snapshot, projection) {
158
158
  if (operation !== "nuke")
159
159
  throw new Error("reset projection requires nuke");
160
160
  const effects = snapshot.effects.filter((effect) => effect.kind === "reset-owner-stopped" || effect.kind === "reset-residue");
161
- const value = { removed: snapshot.reset?.removed ?? { refs: 0, worktrees: 0, tasks: 0 } };
161
+ const value = { removed: snapshot.reset?.removed ?? { refs: 0, worktrees: 0, debts: 0 } };
162
162
  const base = { operation, world: projection.world, effects, pending: projectPending(operation, value, effects) };
163
163
  if (projection.kind === "failed")
164
164
  return {
@@ -257,6 +257,16 @@ export function errorCategory(error) {
257
257
  return "aborted";
258
258
  return "internal";
259
259
  }
260
+ export async function readContractValue(operation) {
261
+ try {
262
+ return await operation();
263
+ }
264
+ catch (error) {
265
+ if (error instanceof KeiyakuError)
266
+ throw error;
267
+ throw new KeiyakuError(errorCategory(error), errorDiagnostic(error), { cause: error });
268
+ }
269
+ }
260
270
  function errorDiagnostic(error) {
261
271
  return error instanceof Error ? error.message : String(error);
262
272
  }
@@ -394,7 +404,7 @@ const resetCountsSchema = z
394
404
  .object({
395
405
  refs: z.number().int().nonnegative(),
396
406
  worktrees: z.number().int().nonnegative(),
397
- tasks: z.number().int().nonnegative(),
407
+ debts: z.number().int().nonnegative(),
398
408
  })
399
409
  .strict();
400
410
  const resetValueSchema = z.object({ removed: resetCountsSchema }).strict();
@@ -54,11 +54,8 @@ function registerLag(scope, error) {
54
54
  function emptySettlement() {
55
55
  return { actions: [], lags: [] };
56
56
  }
57
- function isManagedWorktree(state) {
58
- return state.coordinates.workspace === "worktree";
59
- }
60
57
  function isManagedTerminal(state) {
61
- return state !== null && isManagedWorktree(state) && state.terminal !== null;
58
+ return state !== null && state.terminal !== null;
62
59
  }
63
60
  /**
64
61
  * Terminal cleanup retires the appointed worktree. Name its short name only when this
@@ -76,7 +73,7 @@ function terminalWorktreeOutcome(scope, cleanup, place) {
76
73
  return undefined;
77
74
  }
78
75
  function appointableManagedContracts(states) {
79
- return states.filter((state) => isManagedWorktree(state) && state.terminal === null).map((state) => state.id);
76
+ return states.filter((state) => state.terminal === null).map((state) => state.id);
80
77
  }
81
78
  async function appointPlaces(scope, states) {
82
79
  return await appointManagedWorktrees(scope, appointableManagedContracts(states));
@@ -114,8 +111,6 @@ async function observeState(scope, channel, contractId) {
114
111
  }
115
112
  }
116
113
  async function appointForContract(scope, state) {
117
- if (!isManagedWorktree(state))
118
- return {};
119
114
  try {
120
115
  const register = await appointPlaces(scope, [state]);
121
116
  const place = register.byContract.get(state.id)?.place;
@@ -265,16 +260,13 @@ export async function completeRepoReconcile(input) {
265
260
  if (!isOperationalFailure(error))
266
261
  throw error;
267
262
  const lag = registerLag(input.scope, error);
268
- const contracts = [];
269
- for (const state of states) {
270
- contracts.push({
263
+ return {
264
+ kind: "completed",
265
+ contracts: states.map((state) => ({
271
266
  contractId: state.id,
272
- report: isManagedWorktree(state)
273
- ? { effects: [], lag: [lag], settlement: emptySettlement() }
274
- : await completeReconcile({ ...input, contractId: state.id }),
275
- });
276
- }
277
- return { kind: "completed", contracts };
267
+ report: { effects: [], lag: [lag], settlement: emptySettlement() },
268
+ })),
269
+ };
278
270
  }
279
271
  const places = new Map(appointed.appointments.map((appointment) => [appointment.contract, appointment.place]));
280
272
  const retained = await reconcileAllOperation({
@@ -177,8 +177,8 @@ export declare const keiyakuRefusalSchema: z.ZodUnion<readonly [z.ZodUnion<reado
177
177
  }, z.core.$strict>>>;
178
178
  }, z.core.$strict>]>, z.ZodObject<{
179
179
  kind: z.ZodEnum<{
180
- "unborn-head": "unborn-head";
181
180
  "target-missing": "target-missing";
181
+ "unborn-head": "unborn-head";
182
182
  "invalid-target": "invalid-target";
183
183
  }>;
184
184
  }, z.core.$strict>, z.ZodObject<{
@@ -302,8 +302,8 @@ export declare const operationRefusalSchemas: {
302
302
  contractId: z.ZodPipe<z.ZodString, z.ZodTransform<import("../index.js").ContractId, string>>;
303
303
  }, z.core.$strict>, z.ZodObject<{
304
304
  kind: z.ZodEnum<{
305
- "unborn-head": "unborn-head";
306
305
  "target-missing": "target-missing";
306
+ "unborn-head": "unborn-head";
307
307
  "invalid-target": "invalid-target";
308
308
  }>;
309
309
  }, z.core.$strict>, z.ZodUnion<readonly [z.ZodObject<{
@@ -1,8 +1,9 @@
1
1
  import { type RepositoryScope } from "../protocol/operations.js";
2
2
  import { NoGitWorldError } from "../git/repository.js";
3
3
  export { NoGitWorldError };
4
+ /** One explicit worktree coordinate. The caller resolves relative and ambient spellings, never this edge. */
4
5
  export type RepoAtInput = Readonly<{
5
- path?: string;
6
+ path: string;
6
7
  gitPath?: string;
7
8
  }>;
8
9
  /** One Git world shared by its worktrees; it is coordinate proof and branch observation only. */
@@ -10,7 +11,7 @@ export declare class Repo {
10
11
  readonly root: string;
11
12
  readonly cwd: string;
12
13
  private constructor();
13
- static at(input?: RepoAtInput): Promise<Repo>;
14
+ static at(input: RepoAtInput): Promise<Repo>;
14
15
  currentBranch(): Promise<string | null>;
15
16
  }
16
17
  export declare function scopeForRepo(value: unknown): RepositoryScope;
@@ -1,13 +1,19 @@
1
1
  import { realpath } from "node:fs/promises";
2
- import { resolve } from "node:path";
2
+ import { isAbsolute } from "node:path";
3
3
  import { currentBranchOperation, scopeOperation } from "../protocol/operations.js";
4
4
  import { NoGitWorldError } from "../git/repository.js";
5
5
  import { optionalNonblank, requireInput } from "./input.js";
6
6
  export { NoGitWorldError };
7
7
  const REPO_SCOPES = new WeakMap();
8
- async function resolvePinnedScope(path, gitPath) {
8
+ async function resolvePinnedScope(values) {
9
+ const path = values.path;
10
+ if (typeof path !== "string" || path.trim().length === 0)
11
+ throw new TypeError("repository path must be a nonblank string");
12
+ if (!isAbsolute(path))
13
+ throw new TypeError(`repository path must be absolute: ${path}`);
14
+ const gitPath = optionalNonblank(values.gitPath, "Git executable path");
9
15
  return await scopeOperation({
10
- coordinate: await realpath(resolve(path === undefined ? process.cwd() : path)),
16
+ coordinate: await realpath(path),
11
17
  ...(gitPath === undefined ? {} : { gitPath }),
12
18
  });
13
19
  }
@@ -21,8 +27,7 @@ export class Repo {
21
27
  REPO_SCOPES.set(this, scope);
22
28
  }
23
29
  static async at(input) {
24
- const values = input === undefined ? undefined : requireInput(input, "Repo.at input");
25
- return new Repo(await resolvePinnedScope(optionalNonblank(values?.path, "repository path"), optionalNonblank(values?.gitPath, "Git executable path")));
30
+ return new Repo(await resolvePinnedScope(requireInput(input, "Repo.at input", ["path", "gitPath"])));
26
31
  }
27
32
  async currentBranch() {
28
33
  return await currentBranchOperation({ scope: scopeForRepo(this) });
@@ -1,11 +1,10 @@
1
1
  import { type AskObserver } from "../akuma/akuma-selection-execution.js";
2
- import { type WaitObserver } from "../akuma/akuma-wait.js";
3
2
  import { type AkumaStatus } from "../akuma/akuma.js";
4
3
  import { type ActivityHistory, type OutcomeRow } from "../akuma/projection.js";
5
4
  import { type ExecutionContext } from "../akuma/requests.js";
6
5
  import { type Schema } from "../akuma/schema.js";
7
6
  import type { AkumaAskResult, AkumaKillResult, AkumaObservation, AkumaTellResult, AkumaWaitResult } from "../akuma/selection-observation.js";
8
- import { type DispatchAssociation } from "../dispatch/index.js";
7
+ import type { DispatchAssociation } from "../akuma/dispatch-association.js";
9
8
  import type { WorldRoot } from "../world.js";
10
9
  import { addressAkuma, addressAkumaSet, type AkumaAddressInput, type AkumaSetAddressInput } from "./address.js";
11
10
  import { type Repo } from "./repo.js";
@@ -28,18 +27,16 @@ type SelectionWaitMode = Readonly<{
28
27
  export type SelectionSeam = Readonly<{
29
28
  addressOne(input: UncheckedSelectionAddress): Promise<AddressedAkuma>;
30
29
  addressSet(input: UncheckedSelectionAddress): Promise<AddressedAkumaSet>;
31
- wait(addressed: AddressedAkumaSet, mode: SelectionWaitMode, observer?: WaitObserver): Promise<AkumaWaitResult>;
30
+ wait(addressed: AddressedAkumaSet, mode: SelectionWaitMode): Promise<AkumaWaitResult>;
32
31
  kill(addressed: AddressedAkumaSet, signal?: AbortSignal): Promise<AkumaKillResult>;
33
32
  tell(addressed: AddressedAkuma, input: AkumaTellInput, signal?: AbortSignal): Promise<AkumaTellResult>;
34
33
  ask<T>(addressed: AddressedAkuma, input: AkumaAskInput<T>, signal?: AbortSignal): Promise<AkumaAskResult<T>>;
35
34
  }>;
36
- export declare function selectionSeam(execution: ExecutionContext): SelectionSeam;
35
+ export declare function selectionSeam(execution: ExecutionContext, reportDiagnostic?: (message: string) => void): SelectionSeam;
37
36
  export type AkumaWaitInput = AkumaSetAddressInput & Readonly<{
38
37
  completion?: "any" | "all";
39
38
  timeoutMs?: number;
40
39
  signal?: AbortSignal;
41
- /** The existing optional live-observation seam, validated here like Ask's. */
42
- observe?: WaitObserver;
43
40
  }>;
44
41
  export type AkumaTellInput = AkumaAddressInput & Readonly<{
45
42
  body: string;
@@ -94,7 +91,7 @@ export type AkumaHistoryResult = Readonly<{
94
91
  }>;
95
92
  export declare function statusAkuma(input: AkumaAddressInput & Readonly<{
96
93
  path: WorldRoot;
97
- }>): Promise<AkumaObservation>;
94
+ }>, reportDiagnostic?: (message: string) => void): Promise<AkumaObservation>;
98
95
  export declare function waitAkumaOn(seam: SelectionSeam, input: AkumaWaitInput & Readonly<{
99
96
  path: WorldRoot;
100
97
  }>): Promise<AkumaWaitResult>;
@@ -109,4 +106,4 @@ export declare function askAkumaOn<T = string>(seam: SelectionSeam, input: Akuma
109
106
  }>): Promise<AkumaAskResult<T>>;
110
107
  export declare function historyAkuma(input: AkumaHistoryInput & Readonly<{
111
108
  path: WorldRoot;
112
- }>): Promise<AkumaHistoryResult>;
109
+ }>, reportDiagnostic?: (message: string) => void): Promise<AkumaHistoryResult>;
@@ -3,23 +3,22 @@ import { withoutReportedChanges } from "../akuma/projection.js";
3
3
  import { AkumaNotBornError, AkumaObservationError } from "../akuma/akuma-errors.js";
4
4
  import { AkumaOwner } from "../akuma/akuma-owner.js";
5
5
  import { decodeAskObservation, executeAskAkuma, executeKillAkuma, executeTellAkuma, } from "../akuma/akuma-selection-execution.js";
6
- import { executeWaitAkuma, } from "../akuma/akuma-wait.js";
6
+ import { executeWaitAkuma } from "../akuma/akuma-wait.js";
7
7
  import { parsePublicHistoryId } from "../akuma/identity.js";
8
8
  import { executionChannel } from "../akuma/requests.js";
9
9
  import { schemaJsonText } from "../akuma/schema.js";
10
10
  import { requestForwardedSelectionAsk, requestForwardedSelectionKill, requestForwardedSelectionTell, requestForwardedSelectionWait, } from "../akuma/selection-request.js";
11
- import { readAliases } from "../alias/index.js";
12
11
  import { observeDispatchAssociations } from "../dispatch/index.js";
13
12
  import { observeContractAt } from "../git/observe.js";
14
13
  import { withGitDecodeChannel } from "../git/read-observation.js";
15
- import { observeCreatedTaskObservations } from "../task/created-observation.js";
16
- import { outcomePluginObserver } from "../plugin/akuma-signals.js";
14
+ import { observeCreatedDebtObservations } from "../debt/created-observation.js";
15
+ import { outcomePluginObserver, stderrPluginDiagnostic } from "../plugin/akuma-signals.js";
17
16
  import { addressAkuma, addressAkumaSet, resolveAkuma, resolveAkumaSet, } from "./address.js";
18
17
  import { requireInput } from "./input.js";
19
18
  import { scopeForRepo } from "./repo.js";
20
- export function selectionSeam(execution) {
19
+ export function selectionSeam(execution, reportDiagnostic = stderrPluginDiagnostic) {
21
20
  const channel = executionChannel(execution);
22
- return channel.kind === "body-request" ? forwardedSelection(channel.directory) : localSelection();
21
+ return channel.kind === "body-request" ? forwardedSelection(channel.directory) : localSelection(reportDiagnostic);
23
22
  }
24
23
  function forwardedSelection(directory) {
25
24
  return {
@@ -56,11 +55,11 @@ function forwardedSelection(directory) {
56
55
  },
57
56
  };
58
57
  }
59
- function localSelection() {
58
+ function localSelection(reportDiagnostic) {
60
59
  return {
61
60
  addressOne: addressAkuma,
62
61
  addressSet: addressAkumaSet,
63
- wait: async (addressed, mode, observer) => await localWait(addressed, { ...mode, ...(observer === undefined ? {} : { observer }) }),
62
+ wait: async (addressed, mode) => await localWait(addressed, mode, reportDiagnostic),
64
63
  kill: async (addressed, abort) => await executeKillAkuma({
65
64
  path: addressed.path,
66
65
  ids: addressed.orderedIds,
@@ -78,7 +77,7 @@ function localSelection() {
78
77
  const result = await executeAskAkuma({
79
78
  path: addressed.path,
80
79
  id: addressed.id,
81
- outcomeObserved: outcomePluginObserver({ world: addressed.path, reportDiagnostic: console.error }),
80
+ outcomeObserved: outcomePluginObserver({ world: addressed.path, reportDiagnostic }),
82
81
  body: input.body,
83
82
  ...(input.timeoutMs === undefined ? {} : { timeoutMs: input.timeoutMs }),
84
83
  ...(input.schema === undefined ? {} : { schemaJson: schemaJsonText(input.schema) }),
@@ -136,43 +135,19 @@ function placementDischarged(repo) {
136
135
  async function composeObservation(status, contract, discharged) {
137
136
  return (await discharged(contract)) ? { ...status, timeline: withoutReportedChanges(status.timeline) } : status;
138
137
  }
139
- async function createdTasksFor(path, statuses) {
140
- return await observeCreatedTaskObservations(path, statuses.map((status) => status.id));
141
- }
142
- /**
143
- * One wait's identity-fact resolver: the alias bound to an Akuma in its world and
144
- * its Dispatch association. The alias index is read once, on the first observed
145
- * Akuma, and each Akuma's alias is the first binding the canonical order offers.
146
- * Alias bindings and selected Dispatch associations are read once for this live
147
- * stage. Final result composition owns a separate, fresh Dispatch observation.
148
- */
149
- function waitIdentityFacts(path, repo, selected) {
150
- let aliases;
151
- let contracts;
152
- return async (id) => {
153
- if (aliases === undefined) {
154
- const bound = new Map();
155
- for (const binding of await readAliases(path)) {
156
- if (!bound.has(binding.akuId))
157
- bound.set(binding.akuId, binding.alias);
158
- }
159
- aliases = bound;
160
- }
161
- contracts ??= await dispatchAssociations(repo, selected);
162
- const alias = aliases.get(id);
163
- return { ...(alias === undefined ? {} : { alias }), contract: contracts.get(id) };
164
- };
138
+ async function createdDebtsFor(path, statuses) {
139
+ return await observeCreatedDebtObservations(path, statuses.map((status) => status.id));
165
140
  }
166
141
  async function observeAkuma(status, path, repo) {
167
142
  return (await composeAkumaAssociations([status], path, repo))[0];
168
143
  }
169
144
  /**
170
145
  * The one upper composition of association-free native status evidence into its
171
- * public observation shape. It reads Alias-independent Dispatch and Task
146
+ * public observation shape. It reads Alias-independent Dispatch and Debt
172
147
  * associations after the lower values, never before or inside them.
173
148
  */
174
149
  async function composeAkumaAssociations(statuses, path, repo) {
175
- const created = await createdTasksFor(path, statuses);
150
+ const created = await createdDebtsFor(path, statuses);
176
151
  const discharged = placementDischarged(repo);
177
152
  const contracts = await dispatchAssociations(repo, statuses.map((status) => status.id));
178
153
  return await Promise.all(statuses.map(async (status, index) => {
@@ -180,7 +155,7 @@ async function composeAkumaAssociations(statuses, path, repo) {
180
155
  return {
181
156
  status: await composeObservation(status, contract, discharged),
182
157
  contract,
183
- createdTasks: created[index],
158
+ createdDebts: created[index],
184
159
  };
185
160
  }));
186
161
  }
@@ -214,7 +189,7 @@ async function composeWaitResult(path, repo, result) {
214
189
  }
215
190
  /**
216
191
  * Re-attach upper associations after a wait result crosses a forwarded
217
- * boundary; the serving side must observe its own Dispatch and Task state.
192
+ * boundary; the serving side must observe its own Dispatch and Debt state.
218
193
  */
219
194
  async function attachWaitAssociations(path, repo, result) {
220
195
  return await composeWaitResult(path, repo, {
@@ -238,10 +213,10 @@ function setAddress(values) {
238
213
  ...(values.repo === undefined ? {} : { repo: values.repo }),
239
214
  };
240
215
  }
241
- export async function statusAkuma(input) {
216
+ export async function statusAkuma(input, reportDiagnostic = stderrPluginDiagnostic) {
242
217
  const addressed = await addressAkuma(input);
243
218
  try {
244
- return await observeAkuma(await new AkumaOwner(addressed.id, addressed.path, outcomePluginObserver({ world: addressed.path, reportDiagnostic: console.error })).status(), addressed.path, input.repo);
219
+ return await observeAkuma(await new AkumaOwner(addressed.id, addressed.path, outcomePluginObserver({ world: addressed.path, reportDiagnostic })).status(), addressed.path, input.repo);
245
220
  }
246
221
  catch (error) {
247
222
  throw observationError(addressed.id, error);
@@ -264,19 +239,15 @@ async function forwardedWait(addressed, input) {
264
239
  ...(input.signal === undefined ? {} : { signal: input.signal }),
265
240
  }));
266
241
  }
267
- async function localWait(addressed, input) {
242
+ async function localWait(addressed, input, reportDiagnostic) {
268
243
  try {
269
244
  return await composeWaitResult(addressed.path, input.repo, await executeWaitAkuma({
270
245
  path: addressed.path,
271
246
  ids: addressed.orderedIds,
272
247
  completion: input.completion,
273
- outcomeObserved: outcomePluginObserver({ world: addressed.path, reportDiagnostic: console.error }),
248
+ outcomeObserved: outcomePluginObserver({ world: addressed.path, reportDiagnostic }),
274
249
  ...(input.timeoutMs === undefined ? {} : { timeoutMs: input.timeoutMs }),
275
250
  ...(input.signal === undefined ? {} : { signal: input.signal }),
276
- identity: waitIdentityFacts(addressed.path, input.repo, addressed.orderedIds),
277
- selectionOrder: addressed.orderedIds,
278
- ...(input.observer?.selected === undefined ? {} : { onSelected: input.observer.selected }),
279
- ...(input.observer?.observe === undefined ? {} : { observe: input.observer.observe }),
280
251
  }));
281
252
  }
282
253
  catch (error) {
@@ -285,35 +256,13 @@ async function localWait(addressed, input) {
285
256
  throw observationError(addressed.orderedIds[0], error);
286
257
  }
287
258
  }
288
- function waitObserver(value) {
289
- if (value === undefined)
290
- return undefined;
291
- if (typeof value !== "object" || value === null || Array.isArray(value))
292
- throw new TypeError("observe must be a WaitObserver");
293
- const record = value;
294
- for (const key of Object.keys(record)) {
295
- if (key !== "selected" && key !== "observe")
296
- throw new TypeError(`observe has unknown field: ${key}`);
297
- if (record[key] !== undefined && typeof record[key] !== "function")
298
- throw new TypeError(`observe.${key} must be a function`);
299
- }
300
- return {
301
- ...(record.selected === undefined
302
- ? {}
303
- : { selected: record.selected }),
304
- ...(record.observe === undefined
305
- ? {}
306
- : { observe: record.observe }),
307
- };
308
- }
309
259
  export async function waitAkumaOn(seam, input) {
310
260
  const values = requireInput(input, "Akumas.wait input");
311
261
  for (const key of Object.keys(values)) {
312
- if (!["path", "akuma", "repo", "completion", "timeoutMs", "signal", "observe"].includes(key)) {
262
+ if (!["path", "akuma", "repo", "completion", "timeoutMs", "signal"].includes(key)) {
313
263
  throw new TypeError(`Akumas.wait input has unknown field: ${key}`);
314
264
  }
315
265
  }
316
- const observer = waitObserver(values.observe);
317
266
  const selected = completionMode(values.completion);
318
267
  const timeoutMs = timeout(values.timeoutMs);
319
268
  const callerSignal = signal(values.signal);
@@ -324,7 +273,7 @@ export async function waitAkumaOn(seam, input) {
324
273
  ...(timeoutMs === undefined ? {} : { timeoutMs }),
325
274
  ...(callerSignal === undefined ? {} : { signal: callerSignal }),
326
275
  ...(repo === undefined ? {} : { repo }),
327
- }, observer);
276
+ });
328
277
  }
329
278
  export async function killAkumaOn(seam, input) {
330
279
  const values = requireInput(input, "Akumas.kill input");
@@ -388,12 +337,12 @@ function validateHistoryInput(values) {
388
337
  (values.last === true || values.before !== undefined || values.since !== undefined || values.limit !== undefined))
389
338
  throw new TypeError("id cannot be combined with last, before, since, or limit");
390
339
  }
391
- export async function historyAkuma(input) {
340
+ export async function historyAkuma(input, reportDiagnostic = stderrPluginDiagnostic) {
392
341
  const values = requireInput(input, "Akumas.history input");
393
342
  validateHistoryInput(values);
394
343
  const addressed = await addressAkuma(directAddress(values));
395
344
  try {
396
- const handle = new AkumaOwner(addressed.id, addressed.path, outcomePluginObserver({ world: addressed.path, reportDiagnostic: console.error }));
345
+ const handle = new AkumaOwner(addressed.id, addressed.path, outcomePluginObserver({ world: addressed.path, reportDiagnostic }));
397
346
  const contract = (await dispatchAssociations(values.repo, [addressed.id])).get(addressed.id);
398
347
  if (values.last === true) {
399
348
  const answer = await handle.lastAnswer();
@@ -1,6 +1,8 @@
1
1
  import type { Settings } from "../settings.js";
2
2
  import type { WorldRoot } from "../world.js";
3
3
  import type { PluginSignal } from "./public.js";
4
+ /** The local library observation default; CLI and Body supply their own sinks. */
5
+ export declare function stderrPluginDiagnostic(message: string): void;
4
6
  type PluginSignalEmission = Readonly<{
5
7
  world: WorldRoot;
6
8
  settings?: Settings;
@@ -1,4 +1,8 @@
1
1
  import { pluginRuntime, reportPluginDiagnostic } from "./runtime.js";
2
+ /** The local library observation default; CLI and Body supply their own sinks. */
3
+ export function stderrPluginDiagnostic(message) {
4
+ console.error(message);
5
+ }
2
6
  /**
3
7
  * The one producer entry for plugin signals. It owns runtime acquisition, the
4
8
  * World Settings fallback, bounded delivery, and failure isolation: a delivery
@@ -15,13 +15,38 @@ export type PluginOutcome = Readonly<{
15
15
  reason: string;
16
16
  }>;
17
17
  export type PluginBodyEnd = "exited" | "broke-off" | "put-down" | "hung";
18
+ export type PluginAkumaOrigin = Readonly<{
19
+ kind: "direct";
20
+ }> | Readonly<{
21
+ kind: "request";
22
+ parent: string;
23
+ requestId: string;
24
+ }> | Readonly<{
25
+ kind: "fork";
26
+ parent: string;
27
+ at: string;
28
+ }>;
29
+ export type PluginAkumaCaller = Readonly<{
30
+ kind: "akuma";
31
+ world: string;
32
+ akuId: string;
33
+ }> | Readonly<{
34
+ kind: "external";
35
+ integration: string;
36
+ id: string;
37
+ }> | Readonly<{
38
+ kind: "unknown";
39
+ }>;
18
40
  export type PluginSignalMap = Readonly<{
19
41
  "akuma.initiating": Readonly<{
20
42
  initiator: string;
21
43
  }>;
22
- "akuma.called": Readonly<{
44
+ "akuma.born": Readonly<{
23
45
  akumaId: string;
24
- callerAkumaId?: string;
46
+ bodySequence: number;
47
+ origin: PluginAkumaOrigin;
48
+ caller: PluginAkumaCaller;
49
+ initiator?: string;
25
50
  contractId?: string;
26
51
  }>;
27
52
  "akuma.outcome-observed": Readonly<{
@@ -29,6 +54,11 @@ export type PluginSignalMap = Readonly<{
29
54
  historyId: string;
30
55
  observer?: string;
31
56
  }>;
57
+ "akuma.turn-started": Readonly<{
58
+ akumaId: string;
59
+ turnSequence: number;
60
+ initiator?: string;
61
+ }>;
32
62
  "akuma.turn-outcome": Readonly<{
33
63
  akumaId: string;
34
64
  bodySequence: number;
@@ -7,6 +7,7 @@ const DIAGNOSTIC_LIMIT = 500;
7
7
  const PLUGIN_ATTEMPT_TIMEOUT_MS = 5_000;
8
8
  const PLUGIN_NAMESPACE = "plugins";
9
9
  const SQUARE_PLUGIN_PACKAGE = "@astrosheep/keiyaku-plugin-square";
10
+ const BUNDLED_PLUGIN_PACKAGES = new Set([SQUARE_PLUGIN_PACKAGE, "@astrosheep/keiyaku-plugin-paseo"]);
10
11
  const BUILTIN_PLUGINS = Object.freeze([
11
12
  Object.freeze({ id: "square", package: SQUARE_PLUGIN_PACKAGE, config: undefined }),
12
13
  ]);
@@ -22,7 +23,7 @@ export function reportPluginDiagnostic(report, subject, stage, error) {
22
23
  if (report === undefined)
23
24
  return;
24
25
  try {
25
- report(`plugin ${subject} ${stage}: ${message(error)}`.slice(0, DIAGNOSTIC_LIMIT));
26
+ void Promise.resolve(report(`plugin ${subject} ${stage}: ${message(error)}`.slice(0, DIAGNOSTIC_LIMIT))).catch(() => { });
26
27
  }
27
28
  catch {
28
29
  // Diagnostics are optional side effects too.
@@ -204,8 +205,9 @@ async function writablePaths(world, declarations) {
204
205
  */
205
206
  const SIGNAL_KINDS = Object.freeze({
206
207
  "akuma.initiating": true,
207
- "akuma.called": true,
208
+ "akuma.born": true,
208
209
  "akuma.outcome-observed": true,
210
+ "akuma.turn-started": true,
209
211
  "akuma.turn-outcome": true,
210
212
  "akuma.body-ended": true,
211
213
  });
@@ -245,7 +247,7 @@ function sourceUrl(world, packageName) {
245
247
  return null;
246
248
  }
247
249
  async function importFromWorld(world, packageName) {
248
- if (packageName === SQUARE_PLUGIN_PACKAGE)
250
+ if (BUNDLED_PLUGIN_PACKAGES.has(packageName))
249
251
  return (await import(packageName));
250
252
  const direct = sourceUrl(world, packageName);
251
253
  if (direct !== null)
@@ -3,7 +3,8 @@ import { withPrivateStatePublicationSeat } from "../git/private-state-seat.js";
3
3
  import { contractState } from "../core/facts/observation.js";
4
4
  import { decideAmend } from "../core/verbs/amend.js";
5
5
  import { admitDecidedOffer, mintAttempts } from "./attempt.js";
6
- import { admitted, intentOutcomeWithSeatClose } from "./outcome.js";
6
+ import { admitted } from "./outcome.js";
7
+ import { protocolSeatClose } from "./run.js";
7
8
  import { timestamp } from "./operations.js";
8
9
  async function extendPrerequisiteClosureAt(channel, observation, seeds) {
9
10
  let current = observation;
@@ -34,7 +35,7 @@ export async function amendOperation(input) {
34
35
  const amendment = source === undefined || input.deriveAmendment === undefined
35
36
  ? undefined
36
37
  : { source, ...input.deriveAmendment(source) };
37
- return intentOutcomeWithSeatClose(await withPrivateStatePublicationSeat(input.scope, async (seat) => {
38
+ return protocolSeatClose(await withPrivateStatePublicationSeat(input.scope, async (seat) => {
38
39
  const attempts = mintAttempts({ entryCount: 1 });
39
40
  for (let index = 0; index < attempts.length; index += 1) {
40
41
  let observation = await observeContractsForAdmissionAt(input.scope, input.channel, [input.contractId]);
@@ -65,12 +65,6 @@ function validateOffer(offer, attempt) {
65
65
  if (actualEntries.size === 0)
66
66
  throw new Error("offer requires at least one current-attempt ULID");
67
67
  }
68
- function snapshotFor(append, journals, head) {
69
- const record = journals.get(append.contractId);
70
- if (record === undefined)
71
- throw new Error("accepted offer contract is missing from its observation");
72
- return foldJournal(append.contractId, [...record.entries, ...append.entries], head);
73
- }
74
68
  function journalFor(append, journals) {
75
69
  const record = journals.get(append.contractId);
76
70
  if (record === undefined)
@@ -118,11 +112,12 @@ export async function admitDecidedOffer(input) {
118
112
  if (admission.kind === "accepted") {
119
113
  confirmPrivateStatePublication(seat);
120
114
  input.progress?.recordPublication(primaryContract, admission.heads[primary.contractId], offerEntries(offer));
115
+ const journal = journalFor(primary, decisionObservation.journals);
121
116
  const accepted = {
122
117
  kind: "accepted",
123
118
  facts: offerEntries(offer),
124
- state: snapshotFor(primary, decisionObservation.journals, admission.heads[primary.contractId]),
125
- journal: journalFor(primary, decisionObservation.journals),
119
+ state: foldJournal(primary.contractId, journal, admission.heads[primary.contractId]),
120
+ journal,
126
121
  };
127
122
  input.progress?.recordAdmission(accepted);
128
123
  return accepted;
@@ -11,8 +11,8 @@ export type { BindRefusal } from "../core/verbs/bind.js";
11
11
  export type { BindTargetSelection };
12
12
  export declare const targetInputRefusalSchema: z.ZodObject<{
13
13
  kind: z.ZodEnum<{
14
- "unborn-head": "unborn-head";
15
14
  "target-missing": "target-missing";
15
+ "unborn-head": "unborn-head";
16
16
  "invalid-target": "invalid-target";
17
17
  }>;
18
18
  }, z.core.$strict>;
@@ -27,7 +27,7 @@ type BindOperationInput = Readonly<{
27
27
  channel: GitDecodeChannel;
28
28
  terms: BindData["terms"];
29
29
  verification: VerificationDeclarationPreparation;
30
- targetSelection?: BindTargetSelection;
30
+ targetSelection: BindTargetSelection;
31
31
  workspace: "worktree";
32
32
  actor?: ActorId;
33
33
  decorateOffer?: CompanionDecorator;
@@ -67,7 +67,7 @@ async function assembleBindInput(input, selection, seed, prepared) {
67
67
  };
68
68
  }
69
69
  export async function bindOperation(input) {
70
- let selection = input.targetSelection ?? { kind: "targetless" };
70
+ let selection = input.targetSelection;
71
71
  if (selection.kind === "explicit") {
72
72
  const normalized = await normalizeTargetBranch(input.scope, selection.target);
73
73
  if (normalized === null)
@@ -6,13 +6,13 @@ import { materializeIntegrationSnapshot, materializeJudgedConflict, planIntegrat
6
6
  import { captureTender, dirtyTenderRefusal, materializeTenderSnapshot, prepareDeliveryCommitMetadata, } from "../git/tender.js";
7
7
  import { checkoutDetachedSnapshot, recordConflictHandoff, retireConflictHandoff, workspaceMergeStatePresent, worktreePath, conflictRecovery, } from "../git/workspace.js";
8
8
  import { observeContractsForAdmissionAt } from "../git/observe.js";
9
- import { externalPreparation, privateStateSeatAttempt, runBoundedAttempts, sameWorktreeWitness, STALE_PRIVATE_STATE_PREPARATION, } from "./run.js";
9
+ import { externalPreparation, privateStateSeatAttempt, protocolSeatClose, runBoundedAttempts, sameWorktreeWitness, STALE_PRIVATE_STATE_PREPARATION, } from "./run.js";
10
10
  import { contractState } from "../core/facts/observation.js";
11
11
  import { decideDeliver } from "../core/verbs/deliver.js";
12
12
  import { currentVerifiedAttestation } from "./intent.js";
13
13
  import { admitDecidedOffer, mintAttempts } from "./attempt.js";
14
14
  import { appointmentFor, readPlaceRegister } from "../workspace-place.js";
15
- import { attemptDecisionWithSeatClose, recordedIntegrationSnapshots, timestamp } from "./operations.js";
15
+ import { recordedIntegrationSnapshots, timestamp } from "./operations.js";
16
16
  export const deliverLeadingSchema = z
17
17
  .object({
18
18
  kind: z.enum(["admitted-now", "already-admitted"]),
@@ -418,7 +418,7 @@ async function deliverAttempt(input, attempt) {
418
418
  if (assembled.kind === "stale")
419
419
  return STALE_PRIVATE_STATE_PREPARATION;
420
420
  return await decideAndAdmitDelivery(input, attempt, seat, observation, assembled);
421
- }, attemptDecisionWithSeatClose);
421
+ }, protocolSeatClose);
422
422
  }
423
423
  function isIntegrationConflict(refusal) {
424
424
  return refusal.kind === "integration-failed" && refusal.reason === "conflict";