@astrosheep/keiyaku 4.6.31 → 4.6.33

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 (384) hide show
  1. package/README.md +42 -23
  2. package/build/plugins/claude/skills/keiyaku-akuma/SKILL.md +24 -15
  3. package/build/plugins/claude/skills/keiyaku-babysit/SKILL.md +12 -8
  4. package/build/plugins/claude/skills/keiyaku-bind/SKILL.md +4 -3
  5. package/build/plugins/claude/skills/keiyaku-debt/SKILL.md +17 -17
  6. package/build/plugins/claude/skills/keiyaku-workflow/SKILL.md +6 -4
  7. package/build/plugins/codex/skills/keiyaku-akuma/SKILL.md +24 -15
  8. package/build/plugins/codex/skills/keiyaku-babysit/SKILL.md +12 -8
  9. package/build/plugins/codex/skills/keiyaku-bind/SKILL.md +4 -3
  10. package/build/plugins/codex/skills/keiyaku-debt/SKILL.md +17 -17
  11. package/build/plugins/codex/skills/keiyaku-workflow/SKILL.md +6 -4
  12. package/build/plugins/opencode/skills/keiyaku-akuma/SKILL.md +24 -15
  13. package/build/plugins/opencode/skills/keiyaku-babysit/SKILL.md +12 -8
  14. package/build/plugins/opencode/skills/keiyaku-bind/SKILL.md +4 -3
  15. package/build/plugins/opencode/skills/keiyaku-debt/SKILL.md +17 -17
  16. package/build/plugins/opencode/skills/keiyaku-workflow/SKILL.md +6 -4
  17. package/build/plugins/pi/README.md +53 -97
  18. package/build/plugins/pi/keiyaku.ts +10 -6
  19. package/build/skills/keiyaku-akuma/SKILL.md +24 -15
  20. package/build/skills/keiyaku-babysit/SKILL.md +12 -8
  21. package/build/skills/keiyaku-bind/SKILL.md +4 -3
  22. package/build/skills/keiyaku-debt/SKILL.md +17 -17
  23. package/build/skills/keiyaku-workflow/SKILL.md +6 -4
  24. package/build/src/akuma/akuma-call.d.ts +3 -5
  25. package/build/src/akuma/akuma-call.js +7 -10
  26. package/build/src/akuma/akuma-errors.d.ts +7 -4
  27. package/build/src/akuma/akuma-errors.js +16 -12
  28. package/build/src/akuma/akuma-instance.d.ts +50 -303
  29. package/build/src/akuma/akuma-instance.js +48 -49
  30. package/build/src/akuma/akuma-observe.d.ts +5 -4
  31. package/build/src/akuma/akuma-observe.js +74 -21
  32. package/build/src/akuma/akuma-owner.d.ts +14 -6
  33. package/build/src/akuma/akuma-owner.js +33 -27
  34. package/build/src/akuma/akuma-selection-execution.d.ts +97 -19
  35. package/build/src/akuma/akuma-selection-execution.js +79 -133
  36. package/build/src/akuma/akuma-wait.d.ts +43 -4
  37. package/build/src/akuma/akuma-wait.js +58 -29
  38. package/build/src/akuma/akuma.d.ts +58 -384
  39. package/build/src/akuma/akuma.js +8 -58
  40. package/build/src/akuma/archetype.d.ts +16 -19
  41. package/build/src/akuma/archetype.js +48 -49
  42. package/build/src/akuma/body.js +44 -44
  43. package/build/src/akuma/call-initial-tell.d.ts +4 -2
  44. package/build/src/akuma/call-initial-tell.js +9 -2
  45. package/build/src/akuma/call-input.d.ts +8 -1
  46. package/build/src/akuma/call-input.js +27 -18
  47. package/build/src/akuma/caller.js +2 -1
  48. package/build/src/akuma/detached-body.js +1 -1
  49. package/build/src/akuma/heart/activity-schema.d.ts +16 -0
  50. package/build/src/akuma/heart/activity-schema.js +7 -0
  51. package/build/src/akuma/heart/facts.d.ts +5 -4
  52. package/build/src/akuma/heart/facts.js +5 -5
  53. package/build/src/akuma/heart/index.d.ts +1 -1
  54. package/build/src/akuma/heart/index.js +9 -1
  55. package/build/src/akuma/heart/soul.js +20 -4
  56. package/build/src/akuma/heart/timeline.js +4 -4
  57. package/build/src/akuma/identity.d.ts +1 -1
  58. package/build/src/akuma/identity.js +9 -4
  59. package/build/src/akuma/index.d.ts +6 -7
  60. package/build/src/akuma/index.js +2 -3
  61. package/build/src/akuma/projection-read.d.ts +4 -2
  62. package/build/src/akuma/projection-read.js +21 -14
  63. package/build/src/akuma/projection.d.ts +97 -2
  64. package/build/src/akuma/projection.js +47 -47
  65. package/build/src/akuma/provider-recipe.js +3 -2
  66. package/build/src/akuma/provider.d.ts +2 -2
  67. package/build/src/akuma/provider.js +27 -20
  68. package/build/src/akuma/providers/acp/config.js +11 -10
  69. package/build/src/akuma/providers/acp/core.js +2 -5
  70. package/build/src/akuma/providers/acp/index.js +2 -1
  71. package/build/src/akuma/providers/codex-app-server/index.js +7 -1
  72. package/build/src/akuma/providers/grok-build/index.js +2 -1
  73. package/build/src/akuma/providers/index.d.ts +0 -1
  74. package/build/src/akuma/providers/index.js +0 -8
  75. package/build/src/akuma/providers/opencode-sdk/events.d.ts +2 -1
  76. package/build/src/akuma/providers/opencode-sdk/events.js +31 -1
  77. package/build/src/akuma/providers/paseo/index.js +7 -4
  78. package/build/src/akuma/providers/pi/index.js +4 -3
  79. package/build/src/akuma/publication.d.ts +1 -2
  80. package/build/src/akuma/publication.js +19 -16
  81. package/build/src/akuma/schema.d.ts +3 -49
  82. package/build/src/akuma/schema.js +6 -147
  83. package/build/src/akuma/selection-observation.d.ts +304 -240
  84. package/build/src/akuma/selection-observation.js +135 -70
  85. package/build/src/akuma/status-projection.d.ts +61 -284
  86. package/build/src/akuma/status-projection.js +216 -138
  87. package/build/src/akuma/turn-drive.js +21 -15
  88. package/build/src/body/amend.js +7 -18
  89. package/build/src/body/arc.js +3 -2
  90. package/build/src/body/criteria.js +4 -3
  91. package/build/src/body/decode.js +13 -2
  92. package/build/src/body/envelope.d.ts +5 -1
  93. package/build/src/body/envelope.js +6 -3
  94. package/build/src/body/region.d.ts +1 -3
  95. package/build/src/body/region.js +3 -8
  96. package/build/src/body/render.js +4 -6
  97. package/build/src/body-host.d.ts +4 -11
  98. package/build/src/body-host.js +5 -4
  99. package/build/src/bounded-list.js +2 -1
  100. package/build/src/cli/commands/akuma-grammar.d.ts +107 -66
  101. package/build/src/cli/commands/akuma-grammar.js +66 -104
  102. package/build/src/cli/commands/akuma.d.ts +7 -3
  103. package/build/src/cli/commands/akuma.js +49 -160
  104. package/build/src/cli/commands/contract-grammar.d.ts +4 -135
  105. package/build/src/cli/commands/contract-grammar.js +126 -223
  106. package/build/src/cli/commands/contract-help.d.ts +26 -22
  107. package/build/src/cli/commands/contract-help.js +52 -38
  108. package/build/src/cli/commands/contract.d.ts +6 -18
  109. package/build/src/cli/commands/contract.js +68 -272
  110. package/build/src/cli/commands/debt-grammar.d.ts +2 -4
  111. package/build/src/cli/commands/debt-grammar.js +23 -193
  112. package/build/src/cli/commands/debt.js +10 -87
  113. package/build/src/cli/commands/report.d.ts +2 -4
  114. package/build/src/cli/coordinates.d.ts +1 -1
  115. package/build/src/cli/coordinates.js +1 -1
  116. package/build/src/cli/main.js +9 -3
  117. package/build/src/cli/parse.d.ts +80 -3
  118. package/build/src/cli/parse.js +76 -19
  119. package/build/src/cli/render/akuma-activity.d.ts +18 -35
  120. package/build/src/cli/render/akuma-activity.js +141 -290
  121. package/build/src/cli/render/akuma.d.ts +2 -8
  122. package/build/src/cli/render/akuma.js +50 -65
  123. package/build/src/cli/render/catalog.d.ts +2 -5
  124. package/build/src/cli/render/catalog.js +3 -37
  125. package/build/src/cli/render/contract-history.js +3 -2
  126. package/build/src/cli/render/contract-observation.d.ts +2 -8
  127. package/build/src/cli/render/contract-observation.js +25 -4
  128. package/build/src/cli/render/contract-wait.d.ts +2 -2
  129. package/build/src/cli/render/contract-wait.js +13 -17
  130. package/build/src/cli/render/contract.d.ts +7 -9
  131. package/build/src/cli/render/contract.js +46 -72
  132. package/build/src/cli/render/debt.d.ts +3 -11
  133. package/build/src/cli/render/debt.js +17 -89
  134. package/build/src/cli/render/delivery-preview.js +4 -4
  135. package/build/src/cli/render/execution-progress.js +1 -3
  136. package/build/src/cli/render/kanshi-akuma.d.ts +5 -3
  137. package/build/src/cli/render/kanshi-akuma.js +23 -20
  138. package/build/src/cli/render/kanshi.d.ts +1 -3
  139. package/build/src/cli/render/kanshi.js +27 -56
  140. package/build/src/cli/render/receipt.d.ts +21 -12
  141. package/build/src/cli/render/receipt.js +78 -68
  142. package/build/src/cli/render/reconcile.js +2 -5
  143. package/build/src/cli/render/refusal.d.ts +4 -3
  144. package/build/src/cli/render/refusal.js +17 -22
  145. package/build/src/cli/render/settings.d.ts +1 -1
  146. package/build/src/cli/render/terminal.d.ts +11 -12
  147. package/build/src/cli/render/terminal.js +53 -44
  148. package/build/src/cli/render/verbs.d.ts +4 -1
  149. package/build/src/cli/render/verbs.js +88 -128
  150. package/build/src/cli/runtime.js +65 -70
  151. package/build/src/cli/streams.d.ts +2 -9
  152. package/build/src/cli/streams.js +8 -1
  153. package/build/src/cli/usage.d.ts +2 -1
  154. package/build/src/cli/usage.js +3 -2
  155. package/build/src/contract-worktree.js +2 -10
  156. package/build/src/core/facts/codec.js +16 -25
  157. package/build/src/core/facts/eligibility.d.ts +4 -4
  158. package/build/src/core/facts/eligibility.js +11 -0
  159. package/build/src/core/facts/errors.d.ts +2 -1
  160. package/build/src/core/facts/errors.js +3 -3
  161. package/build/src/core/facts/fold.js +9 -5
  162. package/build/src/core/facts/gate.d.ts +5 -1
  163. package/build/src/core/facts/gate.js +14 -10
  164. package/build/src/core/facts/types.d.ts +7 -14
  165. package/build/src/core/facts/types.js +8 -6
  166. package/build/src/core/subject.d.ts +4 -1
  167. package/build/src/core/subject.js +10 -2
  168. package/build/src/core/verbs/abandon.d.ts +1 -2
  169. package/build/src/core/verbs/amend.d.ts +16 -6
  170. package/build/src/core/verbs/amend.js +19 -9
  171. package/build/src/core/verbs/arc.d.ts +1 -2
  172. package/build/src/core/verbs/attestation.d.ts +1 -2
  173. package/build/src/core/verbs/bind.d.ts +1 -2
  174. package/build/src/core/verbs/deliver.d.ts +1 -2
  175. package/build/src/core/verbs/placement.d.ts +1 -2
  176. package/build/src/core/verbs/reintegrate.d.ts +1 -2
  177. package/build/src/debt/board.d.ts +14 -94
  178. package/build/src/debt/board.js +25 -160
  179. package/build/src/debt/catalog.d.ts +0 -2
  180. package/build/src/debt/catalog.js +1 -22
  181. package/build/src/debt/document.d.ts +8 -11
  182. package/build/src/debt/document.js +19 -62
  183. package/build/src/debt/identity.d.ts +2 -14
  184. package/build/src/debt/identity.js +19 -49
  185. package/build/src/debt/index.d.ts +81 -220
  186. package/build/src/debt/index.js +61 -115
  187. package/build/src/debt/input.d.ts +21 -6
  188. package/build/src/debt/input.js +56 -180
  189. package/build/src/debt/lifecycle-operations.d.ts +1 -3
  190. package/build/src/debt/lifecycle-operations.js +1 -73
  191. package/build/src/debt/operation-types.d.ts +24 -128
  192. package/build/src/debt/operation-types.js +6 -62
  193. package/build/src/debt/operations.d.ts +8 -17
  194. package/build/src/debt/operations.js +58 -154
  195. package/build/src/debt/store.d.ts +0 -2
  196. package/build/src/debt/store.js +32 -87
  197. package/build/src/dispatch/index.d.ts +0 -17
  198. package/build/src/dispatch/index.js +1 -10
  199. package/build/src/errors.d.ts +28 -0
  200. package/build/src/errors.js +26 -0
  201. package/build/src/git/hooks.d.ts +1 -1
  202. package/build/src/git/identity.js +16 -45
  203. package/build/src/git/nuke.js +13 -23
  204. package/build/src/git/observe.d.ts +6 -0
  205. package/build/src/git/observe.js +40 -24
  206. package/build/src/git/process.js +11 -18
  207. package/build/src/git/read-observation.d.ts +5 -4
  208. package/build/src/git/reconcile.d.ts +3 -16
  209. package/build/src/git/reconcile.js +0 -18
  210. package/build/src/git/repository.d.ts +4 -1
  211. package/build/src/git/repository.js +16 -4
  212. package/build/src/git/scratch.js +2 -14
  213. package/build/src/git/target-placement.d.ts +4 -4
  214. package/build/src/git/target.d.ts +2 -2
  215. package/build/src/git/tender.d.ts +1 -2
  216. package/build/src/git/tender.js +5 -12
  217. package/build/src/git/terminal-reconcile.js +1 -13
  218. package/build/src/identity/coordinates.d.ts +1 -1
  219. package/build/src/identity/coordinates.js +3 -2
  220. package/build/src/identity/normalize.js +2 -1
  221. package/build/src/identity/selector.js +4 -3
  222. package/build/src/index.d.ts +36 -57
  223. package/build/src/index.js +11 -36
  224. package/build/src/kanshi/counts.d.ts +3 -8
  225. package/build/src/kanshi/counts.js +6 -14
  226. package/build/src/kanshi/index.d.ts +21 -7
  227. package/build/src/kanshi/index.js +29 -4
  228. package/build/src/kanshi/read.d.ts +101 -269
  229. package/build/src/kanshi/read.js +41 -200
  230. package/build/src/kanshi/report.d.ts +443 -1628
  231. package/build/src/kanshi/report.js +19 -31
  232. package/build/src/library/address.d.ts +20 -13
  233. package/build/src/library/address.js +48 -55
  234. package/build/src/library/akuma-creation.d.ts +249 -79
  235. package/build/src/library/akuma-creation.js +200 -247
  236. package/build/src/library/akumas.d.ts +24 -5
  237. package/build/src/library/akumas.js +96 -29
  238. package/build/src/library/bind.d.ts +7 -10
  239. package/build/src/library/bind.js +2 -8
  240. package/build/src/library/continuation.d.ts +151 -231
  241. package/build/src/library/continuation.js +22 -31
  242. package/build/src/library/contract-address.d.ts +6 -9
  243. package/build/src/library/contract-address.js +11 -16
  244. package/build/src/library/contract-composition.d.ts +2 -3
  245. package/build/src/library/contract-composition.js +12 -19
  246. package/build/src/library/contract-creation.js +35 -37
  247. package/build/src/library/contract-outcomes.d.ts +1349 -806
  248. package/build/src/library/contract-outcomes.js +12 -37
  249. package/build/src/library/contract-settings.d.ts +1 -2
  250. package/build/src/library/contract-settings.js +5 -7
  251. package/build/src/library/contract-types.d.ts +60 -67
  252. package/build/src/library/contract-types.js +17 -56
  253. package/build/src/library/contract-wait.d.ts +47 -3
  254. package/build/src/library/contract-wait.js +81 -70
  255. package/build/src/library/delivery.d.ts +391 -389
  256. package/build/src/library/delivery.js +5 -25
  257. package/build/src/library/input.d.ts +13 -5
  258. package/build/src/library/input.js +43 -38
  259. package/build/src/library/invocation.d.ts +13 -11
  260. package/build/src/library/invocation.js +69 -58
  261. package/build/src/library/kei.d.ts +16 -8
  262. package/build/src/library/kei.js +484 -25
  263. package/build/src/library/keiyaku-attribution.d.ts +0 -8
  264. package/build/src/library/keiyaku-attribution.js +0 -11
  265. package/build/src/library/keiyaku-classify.d.ts +2 -2
  266. package/build/src/library/keiyaku-classify.js +43 -62
  267. package/build/src/library/keiyaku-coordinates.d.ts +3 -8
  268. package/build/src/library/keiyaku-coordinates.js +6 -26
  269. package/build/src/library/keiyaku-debt.d.ts +21 -93
  270. package/build/src/library/keiyaku-debt.js +9 -159
  271. package/build/src/library/keiyaku-identity.d.ts +3 -3
  272. package/build/src/library/keiyaku-identity.js +16 -10
  273. package/build/src/library/keiyaku-verbs.d.ts +4102 -4889
  274. package/build/src/library/keiyaku-verbs.js +317 -291
  275. package/build/src/library/keiyaku-wait.d.ts +183 -0
  276. package/build/src/library/keiyaku-wait.js +213 -0
  277. package/build/src/library/keiyaku.d.ts +32 -860
  278. package/build/src/library/keiyaku.js +203 -314
  279. package/build/src/library/model-tools.d.ts +556 -0
  280. package/build/src/library/model-tools.js +347 -0
  281. package/build/src/library/nuke.d.ts +4 -2
  282. package/build/src/library/nuke.js +5 -1
  283. package/build/src/library/outcome.d.ts +424 -307
  284. package/build/src/library/outcome.js +166 -362
  285. package/build/src/library/reconcile.d.ts +331 -143
  286. package/build/src/library/reconcile.js +38 -72
  287. package/build/src/library/refusal.d.ts +45 -29
  288. package/build/src/library/refusal.js +5 -16
  289. package/build/src/library/repo.js +4 -3
  290. package/build/src/library/selection.d.ts +44 -21
  291. package/build/src/library/selection.js +63 -88
  292. package/build/src/mcp/adapter.js +37 -51
  293. package/build/src/mcp/description.d.ts +2 -0
  294. package/build/src/mcp/description.js +2 -0
  295. package/build/src/mcp/help.d.ts +1 -1
  296. package/build/src/mcp/help.js +16 -9
  297. package/build/src/pi/index.d.ts +3 -0
  298. package/build/src/pi/index.js +83 -0
  299. package/build/src/plugin/public.d.ts +4 -0
  300. package/build/src/plugin/runtime.d.ts +1 -1
  301. package/build/src/plugin/runtime.js +2 -2
  302. package/build/src/protocol/amend.d.ts +15 -4
  303. package/build/src/protocol/amend.js +114 -47
  304. package/build/src/protocol/bind.d.ts +5 -7
  305. package/build/src/protocol/bind.js +8 -19
  306. package/build/src/protocol/completion.d.ts +188 -195
  307. package/build/src/protocol/completion.js +63 -24
  308. package/build/src/protocol/deliver.d.ts +11 -6
  309. package/build/src/protocol/deliver.js +37 -50
  310. package/build/src/protocol/delivery-preview.d.ts +18 -11
  311. package/build/src/protocol/delivery-preview.js +2 -2
  312. package/build/src/protocol/execution-observation.d.ts +13 -13
  313. package/build/src/protocol/intent.d.ts +7 -9
  314. package/build/src/protocol/intent.js +22 -32
  315. package/build/src/protocol/operations.d.ts +102 -69
  316. package/build/src/protocol/operations.js +33 -56
  317. package/build/src/protocol/outcome.d.ts +3 -1
  318. package/build/src/protocol/placement.d.ts +1 -2
  319. package/build/src/protocol/placement.js +7 -1
  320. package/build/src/protocol/progress.d.ts +1 -0
  321. package/build/src/protocol/progress.js +0 -6
  322. package/build/src/protocol/read/status.d.ts +69 -112
  323. package/build/src/protocol/read/status.js +59 -88
  324. package/build/src/protocol/reintegrate.d.ts +1 -2
  325. package/build/src/protocol/reintegrate.js +2 -3
  326. package/build/src/protocol/result-leaves.d.ts +67 -40
  327. package/build/src/protocol/result-leaves.js +28 -58
  328. package/build/src/protocol/result-reasons.d.ts +6 -6
  329. package/build/src/protocol/review.js +0 -1
  330. package/build/src/protocol/run.js +1 -4
  331. package/build/src/protocol/verify.d.ts +202 -146
  332. package/build/src/protocol/verify.js +61 -47
  333. package/build/src/runtime/proc/windows-launch.exe +0 -0
  334. package/build/src/settings.d.ts +8 -9
  335. package/build/src/settings.js +16 -13
  336. package/build/src/settlement/holder.js +2 -2
  337. package/build/src/settlement/settle.d.ts +0 -6
  338. package/build/src/settlement/settle.js +19 -72
  339. package/build/src/verification/declaration.d.ts +3 -6
  340. package/build/src/verification/declaration.js +3 -5
  341. package/build/src/verification/observation.d.ts +2 -2
  342. package/build/src/world.d.ts +3 -2
  343. package/build/src/world.js +5 -6
  344. package/package.json +7 -3
  345. package/plugins/paseo/plugin/index.server.ts +1 -1
  346. package/plugins/paseo/plugin/server/attach.ts +74 -67
  347. package/plugins/paseo/plugin/server/keiyaku.ts +80 -14
  348. package/plugins/paseo/plugin/server/message.ts +2 -1
  349. package/plugins/paseo/plugin/server/mirror-identity.ts +6 -4
  350. package/plugins/paseo/plugin/server/sdk.ts +9 -11
  351. package/plugins/paseo/plugin/server/transport.ts +24 -1
  352. package/plugins/pi/README.md +53 -97
  353. package/plugins/pi/keiyaku.ts +10 -6
  354. package/skills/keiyaku-akuma/SKILL.md +24 -15
  355. package/skills/keiyaku-babysit/SKILL.md +12 -8
  356. package/skills/keiyaku-bind/SKILL.md +4 -3
  357. package/skills/keiyaku-debt/SKILL.md +17 -17
  358. package/skills/keiyaku-workflow/SKILL.md +6 -4
  359. package/build/plugins/pi/akuma-tools.ts +0 -290
  360. package/build/src/akuma/providers/codex-app-server/configuration.d.ts +0 -5
  361. package/build/src/akuma/providers/codex-app-server/configuration.js +0 -72
  362. package/build/src/body/keys.d.ts +0 -4
  363. package/build/src/body/keys.js +0 -11
  364. package/build/src/cli/commands/debt-query.d.ts +0 -5
  365. package/build/src/cli/commands/debt-query.js +0 -194
  366. package/build/src/cli/render/akuma-tool-command.d.ts +0 -6
  367. package/build/src/cli/render/akuma-tool-command.js +0 -143
  368. package/build/src/cli/render/akuma-tool.d.ts +0 -29
  369. package/build/src/cli/render/akuma-tool.js +0 -225
  370. package/build/src/debt/context.d.ts +0 -28
  371. package/build/src/debt/context.js +0 -102
  372. package/build/src/debt/created-observation.d.ts +0 -26
  373. package/build/src/debt/created-observation.js +0 -38
  374. package/build/src/debt/query.d.ts +0 -80
  375. package/build/src/debt/query.js +0 -283
  376. package/build/src/kanshi/roster.d.ts +0 -2
  377. package/build/src/kanshi/roster.js +0 -2
  378. package/build/src/library/contract-execution.d.ts +0 -28
  379. package/build/src/library/contract-execution.js +0 -506
  380. package/build/src/library/keiyaku-policy.d.ts +0 -27
  381. package/build/src/library/keiyaku-policy.js +0 -44
  382. package/build/src/library/keiyaku-status.d.ts +0 -1487
  383. package/build/src/library/keiyaku-status.js +0 -92
  384. package/plugins/pi/akuma-tools.ts +0 -290
@@ -1,28 +1,31 @@
1
1
  /** @architectureCompositionRoot */
2
2
  import { z } from "zod";
3
3
  export { classifyVerb } from "./keiyaku-classify.js";
4
- import { akumaCallerSchema } from "../akuma/caller.js";
4
+ import { durationSchema } from "../akuma/call-input.js";
5
+ import { parseDuration } from "../duration.js";
6
+ import { addDebtInputSchema, updateDebtInputSchema } from "../debt/input.js";
7
+ import { amendInputSchema } from "./input.js";
5
8
  import { askProgressSchema } from "../akuma/akuma-selection-execution.js";
6
9
  import { akumaReportResultSchema } from "../akuma/akuma-instance.js";
7
- import { akumaListSchema } from "../akuma/akuma.js";
8
- import { archetypeCatalogSchema } from "../akuma/archetype.js";
9
- import { akumaAskResultSchema, akumaKillResultSchema, akumaTellResultSchema, akumaWaitResultSchema, } from "../akuma/selection-observation.js";
10
- import { regionResultSchema } from "../kanshi/report.js";
10
+ import { akumaIdSchema } from "../akuma/identity.js";
11
+ import { contractIdSchema } from "../git/identity.js";
12
+ import { akumaNameCatalogSchema } from "../akuma/archetype.js";
13
+ import { akumaCatalogueSchema, akumaObservationSchema, akumaAskResultSchema, akumaAskNormalResultSchema, akumaKillResultSchema, akumaTellResultSchema, } from "../akuma/selection-observation.js";
14
+ import { regionResultSchema, kanshiReportSchema, contractStatusSchema, contractNormalStatusSchema, } from "../kanshi/report.js";
11
15
  import { settingsSchema } from "../settings.js";
12
16
  import { contractCatalogueSchema } from "../protocol/read/status.js";
13
17
  import { executionObservationSchema } from "../protocol/execution-observation.js";
14
- import { spawnProgressSchema, spawnResultSchema, forkResultSchema, } from "./akuma-creation.js";
15
- import { bindOutcomeSchema, amendOutcomeSchema, arcOutcomeSchema, deliverOutcomeSchema, deliveryPreviewOutcomeSchema, verifyOutcomeSchema, reviewOutcomeSchema, abandonOutcomeSchema, } from "./contract-outcomes.js";
18
+ import { spawnResultSchema, spawnNormalResultSchema, forkResultSchema, forkNormalResultSchema, } from "./akuma-creation.js";
19
+ import { bindOutcomeSchema, bindNormalOutcomeSchema, amendOutcomeSchema, arcOutcomeSchema, deliverOutcomeSchema, deliveryPreviewOutcomeSchema, verifyOutcomeSchema, verifyNormalOutcomeSchema, reviewOutcomeSchema, abandonOutcomeSchema, } from "./contract-outcomes.js";
16
20
  import { contractHistorySchema } from "./contract-types.js";
17
- import { guidanceSchema } from "./kei.js";
18
- import { contractWaitResultSchema } from "./contract-wait.js";
21
+ import { guidanceSchema, guidanceNormalSchema } from "./kei.js";
22
+ import { invocationWaitResultSchema, invocationWaitNormalResultSchema } from "./keiyaku-wait.js";
23
+ import { parseAkumaGlob, parseReadableAkumaAlias } from "../identity/selector.js";
19
24
  import { reconcileResultSchema } from "./reconcile.js";
20
- import { akumaHistoryResultSchema } from "./selection.js";
21
- import { statusResultSchema } from "./keiyaku-status.js";
25
+ import { akumaHistoryResultSchema, historySelectionSchemas } from "./selection.js";
22
26
  import { whoamiFactsSchema } from "./keiyaku-identity.js";
23
27
  import { resetOutcomeSchema } from "./outcome.js";
24
- import { debtAbsentSchema, debtBatchResultSchema, debtTreeResultSchema, debtCatalogueSchema, debtShowResultSchema, debtDoctorReportSchema, debtReadyListSchema, blockedDebtListSchema, debtMutationResultSchema, debtQueryResultSchema, debtContextResultSchema, debtUpdateResultSchema, } from "../debt/index.js";
25
- import { debtPrioritySchema, debtStateSchema } from "../debt/document.js";
28
+ import { debtAbsentSchema, debtShowResultSchema, debtShowNormalResultSchema, debtDoctorReportSchema, debtMutationResultSchema, debtMutationNormalResultSchema, debtCatalogueSchema, debtListSchema, debtUpdateResultSchema, } from "../debt/index.js";
26
29
  import { debtIdSchema } from "../debt/identity.js";
27
30
  const text = z.string();
28
31
  const nonblank = text.regex(/\S/u, "Must not be blank");
@@ -30,261 +33,367 @@ const optText = text.exactOptional();
30
33
  const optBool = z.boolean().exactOptional();
31
34
  const strings = z.array(text).readonly();
32
35
  const positive = z.number().int().positive();
33
- const timeout = z.number().finite().nonnegative().exactOptional();
34
- const contract = { contract: optText };
35
- const actor = { actor: optText };
36
+ const timeout = durationSchema.exactOptional();
37
+ const waitDuration = text.refine((value) => parseDuration(value).kind === "parsed", {
38
+ message: "wait requires an integer duration with unit ms, s, m, or h within the safe millisecond range",
39
+ });
40
+ const contract = {
41
+ contract: optText.describe("Target Contract selector (kei/...); omit to resolve from cwd when inside an appointed Contract worktree."),
42
+ };
36
43
  const commonBind = {
37
- target: text.nullable().exactOptional(),
38
- workspace: z.literal("worktree").exactOptional(),
39
- ...actor,
44
+ target: text
45
+ .nullable()
46
+ .exactOptional()
47
+ .describe("Integration target: branch name, active kei/... to stack on, or null for a targetless Contract. Omit to target the current branch."),
40
48
  };
41
- const jsonValue = z.lazy(() => z.union([
42
- z.null(),
43
- z.boolean(),
44
- z.number().finite(),
45
- z.string(),
46
- z.array(jsonValue).readonly(),
47
- z.record(z.string(), jsonValue).readonly(),
48
- ]));
49
- const jsonDocument = z.record(z.string(), jsonValue).readonly();
49
+ const jsonDocument = z.record(z.string(), z.unknown()).readonly();
50
50
  const contractSelector = text.startsWith("kei/");
51
51
  const akumaSelector = text.regex(/^(?!kei\/)/u);
52
- const debtReadScope = {
53
- scope: z.enum(["namespace", "world"]).exactOptional(),
54
- namespace: strings.exactOptional(),
55
- limit: positive.exactOptional(),
52
+ const debtSelection = z
53
+ .enum(["active", "closed", "all"])
54
+ .exactOptional()
55
+ .describe('Debt lifecycle filter (valid only with "debt"/"debt/"): "active" (open, default), "closed" (done or drop), or "all".');
56
+ const catalogueSelector = 'Catalogue path selector: "kei"/"kei/", "debt"/"debt/", "aku"/"aku/" (akumaName values), or "aku/*" / "aku/*/*" / "aku/<name>" / "aku/<name>/*" (instances).';
57
+ const lsInputSchema = z
58
+ .strictObject({
59
+ selector: text
60
+ .regex(/^(?:kei|debt|aku)\/?$|^aku\/(?:\*(?:\/\*)?|[^/*]+(?:\/\*|\/)?)$/u)
61
+ .describe(catalogueSelector),
62
+ limit: positive.exactOptional().describe("Maximum rows to return (positive integer)."),
63
+ selection: debtSelection,
64
+ mine: optBool.describe("When true on an Akuma-instance selector, restrict to direct and transitive descendants of this server environment's caller identity."),
65
+ })
66
+ .superRefine(({ selector, selection, mine }, context) => {
67
+ if (selection !== undefined && selector !== "debt" && selector !== "debt/")
68
+ context.addIssue({ code: "custom", message: "selection is valid only with a Debt catalogue" });
69
+ if (mine !== undefined && (!selector.startsWith("aku/") || selector === "aku/"))
70
+ context.addIssue({ code: "custom", message: "mine is valid only with an Akuma-instance catalogue" });
71
+ })
72
+ .readonly();
73
+ const spawnFields = {
74
+ akumaName: nonblank.describe('akumaName to spawn. Use ls {"selector":"aku/"} to list valid names, including when the selected name is not found. Always births a new instance; use tell or ask to continue an existing Akuma.'),
75
+ contract: optText.describe("Contract ID (kei/...) to record as Dispatch association for status/kanshi; does not set workdir or inject Contract text."),
76
+ workdir: optText.describe("Execution directory for the Akuma (relative paths resolve from cwd; defaults to cwd)."),
77
+ alias: optText.describe("World-local alias (with or without leading @) assigned to this Akuma, reassigning any previous holder."),
78
+ bare: optBool.describe("Omit Keiyaku runtime instructions for this Akuma's lifetime (required for generic ACP providers)."),
56
79
  };
57
- const debtSelection = z.enum(["active", "closed", "all"]).exactOptional();
58
- const debtRelations = {
59
- needs: strings.exactOptional(),
60
- parent: text.nullable().exactOptional(),
61
- supersedes: strings.exactOptional(),
62
- relates: strings.exactOptional(),
80
+ const tellFields = {
81
+ akuma: text.describe("Target Akuma selector (aku/<name>/<hex> or @alias)."),
82
+ prompt: nonblank.describe("Nonblank text instruction to admit."),
83
+ interrupt: optBool.describe("Request the currently running turn to yield before waking a successor turn for this prompt."),
63
84
  };
64
- const debtPredicate = z.union([
65
- z.strictObject({ field: z.literal("state"), operator: z.enum(["=", "!="]), value: debtStateSchema }).readonly(),
66
- z
67
- .strictObject({
68
- field: z.literal("priority"),
69
- operator: z.enum(["=", "!=", "<", "<=", ">", ">="]),
70
- value: debtPrioritySchema,
71
- })
72
- .readonly(),
73
- z.strictObject({ field: z.enum(["title", "id"]), operator: z.enum(["=", "!=", "~"]), value: text }).readonly(),
74
- z
75
- .strictObject({ field: z.literal("parent"), operator: z.enum(["=", "!="]), value: debtIdSchema.nullable() })
76
- .readonly(),
77
- z
78
- .strictObject({ field: z.enum(["under", "needs", "blocks"]), operator: z.enum(["=", "!="]), value: debtIdSchema })
79
- .readonly(),
80
- z.strictObject({ field: z.enum(["ready", "blocked"]), operator: z.enum(["=", "!="]), value: z.boolean() }).readonly(),
81
- z
82
- .strictObject({
83
- field: z.enum(["created", "updated"]),
84
- operator: z.enum(["=", "!=", "<", "<=", ">", ">="]),
85
- value: text,
86
- })
87
- .readonly(),
88
- ]);
89
- const debtQueryExpression = z.lazy(() => z.union([
90
- z.strictObject({ kind: z.enum(["and", "or"]), terms: z.array(debtQueryExpression).readonly() }).readonly(),
91
- z.strictObject({ kind: z.literal("not"), term: debtQueryExpression }).readonly(),
92
- z.strictObject({ kind: z.literal("predicate"), predicate: debtPredicate }).readonly(),
93
- ]));
94
85
  export const verbs = Object.freeze({
95
86
  bind: {
96
- description: "Bind Contract terms or fork existing terms.",
87
+ description: "Bind a Contract: one tracked delivery with fixed terms. Complete Markdown terms in (or forkOf to copy another's); a kei/... id and its own worktree out. target is where the work lands once accepted; gates is what must pass first. Runs no checks.",
97
88
  input: z.union([
98
89
  z
99
90
  .strictObject({
100
- markdown: text,
101
- debt: optText,
91
+ markdown: text.describe("Complete Contract Markdown document (# Title, ## Context, ## Objective, ## Design, ## Region, ## Criteria, optional ## Verification). Mutually exclusive with forkOf."),
92
+ debt: debtIdSchema
93
+ .exactOptional()
94
+ .describe("Open Debt ID (debt/<slug>-<hex>) to associate as this Contract's held Debt."),
95
+ ...commonBind,
96
+ after: strings
97
+ .exactOptional()
98
+ .describe("Logical prerequisite Contract IDs (kei/...) that must be accepted before placement completes."),
99
+ gates: strings
100
+ .exactOptional()
101
+ .describe('Acceptance gate names overriding default gates (for example ["reviewed", "verified"], or [] for ungated placement).'),
102
+ })
103
+ .readonly(),
104
+ z
105
+ .strictObject({
106
+ forkOf: text.describe("Existing Contract selector (kei/...) whose terms are copied into a new Contract. Mutually exclusive with markdown, debt, after, and gates."),
102
107
  ...commonBind,
103
- after: strings.exactOptional(),
104
- gates: strings.exactOptional(),
105
108
  })
106
109
  .readonly(),
107
- z.strictObject({ forkOf: text, ...commonBind }).readonly(),
108
110
  ]),
109
111
  output: bindOutcomeSchema,
112
+ normal: bindNormalOutcomeSchema,
110
113
  effect: "write",
111
114
  },
112
115
  amend: {
113
- description: "Amend Contract terms.",
114
- input: z
115
- .strictObject({
116
- ...contract,
117
- markdown: optText,
118
- after: strings.exactOptional(),
119
- gates: strings.exactOptional(),
120
- ...actor,
116
+ description: "Rewrite an active Contract's terms, target, prerequisites (after), or gates; naming none reports the Contract unchanged and writes nothing. markdown is H2 edits such as ## Replace: Objective, not a new Contract. Returns only what changed.",
117
+ input: amendInputSchema
118
+ .extend({
119
+ markdown: amendInputSchema.shape.markdown.describe("Replacement Contract Markdown document or section-level amendment."),
120
+ after: amendInputSchema.shape.after.describe("Replacement prerequisite Contract IDs (kei/...); pass [] to clear prerequisites."),
121
+ gates: amendInputSchema.shape.gates.describe("Replacement acceptance gate names; pass [] to clear all gates."),
122
+ target: amendInputSchema.shape.target.describe("Explicit existing branch or active Contract destination; omission retains the current target."),
121
123
  })
124
+ .extend(contract)
122
125
  .readonly(),
123
126
  output: amendOutcomeSchema,
124
127
  effect: "write",
125
128
  },
126
129
  arc: {
127
- description: "Add a Contract arc.",
128
- input: z.strictObject({ ...contract, markdown: text, ...actor }).readonly(),
129
- output: arcOutcomeSchema,
130
- effect: "write",
131
- },
132
- deliver: {
133
- description: "Deliver a Contract candidate.",
130
+ description: "Open the next chapter of an active Contract: a # Title and optional notes telling its Akumas what is being done now. The terms stay as bound.",
134
131
  input: z
135
132
  .strictObject({
136
133
  ...contract,
137
- message: optText,
138
- includeDirty: optBool,
139
- materializeConflict: optBool,
140
- overwrite: optBool,
134
+ markdown: text.describe("Arc Markdown body naming and scoping the current chapter."),
141
135
  })
142
136
  .readonly(),
143
- output: deliverOutcomeSchema,
144
- progress: executionObservationSchema,
137
+ output: arcOutcomeSchema,
145
138
  effect: "write",
146
139
  },
147
- "deliver.preview": {
148
- description: "Observe a prospective delivery.",
149
- input: z.strictObject({ ...contract, includeDirty: optBool, showDiff: optBool }).readonly(),
150
- output: deliveryPreviewOutcomeSchema,
140
+ deliver: {
141
+ description: "Hand in the work from a Contract's worktree. It lands on the target once prerequisites are accepted and every gate passes (reviewed: a satisfied review; verified: passing verify results); until then it waits, delivered. Uncommitted changes need includeDirty. dryRun: true only looks. Runs no checks and records no review.",
142
+ input: z.union([
143
+ z
144
+ .strictObject({
145
+ ...contract,
146
+ dryRun: z
147
+ .literal(true)
148
+ .describe("When true, read-only preview of candidate integration, standing gate evidence, and target followability without recording delivery or mutating refs."),
149
+ includeDirty: optBool.describe("Capture uncommitted worktree and untracked changes via a private index without altering the worktree's real Git index."),
150
+ showDiff: optBool.describe("Include the candidate patch diff in dryRun preview output (valid only with dryRun: true)."),
151
+ })
152
+ .readonly(),
153
+ z
154
+ .strictObject({
155
+ ...contract,
156
+ dryRun: z
157
+ .literal(false)
158
+ .exactOptional()
159
+ .describe("When true, read-only preview of candidate integration, standing gate evidence, and target followability without recording delivery or mutating refs."),
160
+ message: optText.describe("Optional commit/integration message for the delivered candidate (submission only)."),
161
+ includeDirty: optBool.describe("Capture uncommitted worktree and untracked changes via a private index without altering the worktree's real Git index."),
162
+ materializeConflict: optBool.describe("When target integration conflicts, materialize conflict markers into the appointed worktree for resolution instead of refusing cleanly (submission only)."),
163
+ overwrite: optBool.describe("Allow replacing an earlier delivered candidate when required by conflict or rewrite state (submission only)."),
164
+ })
165
+ .readonly(),
166
+ ]),
167
+ output: z.union([deliverOutcomeSchema, deliveryPreviewOutcomeSchema]),
151
168
  progress: executionObservationSchema,
152
- effect: "read",
169
+ effect: "write",
153
170
  },
154
171
  verify: {
155
- description: "Run declared verification.",
156
- input: z.strictObject({ ...contract, index: positive.exactOptional(), includeDirty: optBool }).readonly(),
172
+ description: "Run the Contract's ## Verification checks now. A failed check is a verdict, not a tool error. Results are bound to the exact integration tree they ran on: any change to the work or the target makes them stale. They count only under the verified gate, and may land an already-delivered Contract.",
173
+ input: z
174
+ .strictObject({
175
+ ...contract,
176
+ index: positive
177
+ .exactOptional()
178
+ .describe("1-based position of a single ## Verification fence to execute; omit to run all declared fences."),
179
+ includeDirty: optBool.describe("Verify a prospective snapshot that includes uncommitted worktree changes without staging them."),
180
+ })
181
+ .readonly(),
157
182
  output: verifyOutcomeSchema,
183
+ normal: verifyNormalOutcomeSchema,
158
184
  progress: executionObservationSchema,
159
185
  effect: "write",
160
186
  },
161
187
  review: {
162
- description: "Record Contract review.",
188
+ description: "Record your verdict on a Contract's diff: satisfied or unsatisfied, with reasons. Valid before or after deliver. Bound to the diff content: a pure rebase keeps it, a changed diff makes it stale. Satisfied may land an already-delivered Contract.",
163
189
  input: z
164
- .strictObject({ ...contract, verdict: z.enum(["satisfied", "unsatisfied"]), summary: nonblank, ...actor })
190
+ .strictObject({
191
+ ...contract,
192
+ verdict: z
193
+ .enum(["satisfied", "unsatisfied"])
194
+ .describe('Review judgment for the candidate: "satisfied" or "unsatisfied".'),
195
+ summary: nonblank.describe("Nonblank review rationale and findings recorded as testimony."),
196
+ })
165
197
  .readonly(),
166
198
  output: reviewOutcomeSchema,
167
199
  progress: executionObservationSchema,
168
200
  effect: "write",
169
201
  },
170
202
  abandon: {
171
- description: "Abandon a Contract.",
172
- input: z.strictObject({ ...contract, note: optText, ...actor }).readonly(),
203
+ description: "Break an active Contract. Its work never lands; its worktree is reclaimed. No undo.",
204
+ input: z
205
+ .strictObject({
206
+ ...contract,
207
+ note: optText.describe("Optional reason recorded on the abandonment entry."),
208
+ })
209
+ .readonly(),
173
210
  output: abandonOutcomeSchema,
174
211
  effect: "destroy",
175
212
  },
176
213
  show: {
177
- description: "Read Contract guidance.",
178
- input: z.strictObject(contract).readonly(),
179
- output: guidanceSchema,
214
+ description: "Read a Contract in full: terms, current chapter, and working instructions. Or read one Debt in full with its prerequisites. Omit id to read the Contract whose worktree you stand in.",
215
+ input: z
216
+ .strictObject({
217
+ id: text
218
+ .superRefine((id, context) => {
219
+ if (debtIdSchema.safeParse(id).success ||
220
+ contractIdSchema.safeParse(id.startsWith("@") ? `kei/${id.slice(1)}` : id).success)
221
+ return;
222
+ context.addIssue({
223
+ code: "custom",
224
+ message: id.startsWith("@kei/")
225
+ ? `redundant short contract selector: ${id}`
226
+ : "show requires one Contract selector or one Debt ID",
227
+ });
228
+ })
229
+ .exactOptional()
230
+ .describe("One kei/... or @name for Contract guidance, or one debt/... ID. Omit for contextual Contract guidance from cwd."),
231
+ })
232
+ .readonly(),
233
+ output: z.union([guidanceSchema, debtShowResultSchema, debtAbsentSchema]),
234
+ normal: z.union([guidanceNormalSchema, debtShowNormalResultSchema]),
180
235
  effect: "read",
181
236
  },
182
237
  reconcile: {
183
- description: "Reconcile Contract effects.",
184
- input: z.strictObject({ ...contract, retryHooks: optBool }).readonly(),
238
+ description: "Finish what an interrupted or lagging call left half done: Git, worktree, and hook steps, for one Contract or all. Safe to repeat; never undoes a recorded result.",
239
+ input: z
240
+ .strictObject({
241
+ contract: optText.describe("Contract selector (kei/...) to reconcile; omit to reconcile all Contracts in the repo."),
242
+ retryHooks: optBool.describe("Re-run failed worktree lifecycle hooks during reconciliation."),
243
+ })
244
+ .readonly(),
185
245
  output: reconcileResultSchema,
186
246
  effect: "write",
187
247
  },
188
248
  spawn: {
189
- description: "Spawn an Akuma.",
249
+ description: "Birth a new Akuma from akumaName (ls aku/), with an optional first order. Returns birth and admission, not an answer; observe separately with wait. contract only marks whose work it is; give it a workdir and the terms yourself. A failed result with an akumaId still left an Akuma alive.",
190
250
  input: z
191
251
  .strictObject({
192
- akumaName: text,
193
- prompt: optText,
194
- ...contract,
195
- workdir: optText,
196
- alias: optText,
197
- mode: z.enum(["wait", "detach"]).exactOptional(),
198
- timeoutMs: timeout,
199
- writableDirectories: strings.exactOptional(),
200
- bare: optBool,
201
- schema: jsonDocument.exactOptional(),
252
+ ...spawnFields,
253
+ prompt: nonblank.exactOptional().describe("Opening instruction text; omit to birth idle."),
202
254
  })
203
255
  .readonly(),
204
256
  output: spawnResultSchema,
205
- progress: spawnProgressSchema,
257
+ normal: spawnNormalResultSchema,
206
258
  effect: "write",
207
259
  },
208
260
  fork: {
209
- description: "Fork an Akuma at a history point.",
210
- input: z.strictObject({ akuma: text, at: text, bare: optBool }).readonly(),
261
+ description: "Birth a copy of an Akuma as it stood at an answered turn (turn/<n> from history), to try another path. The copy wakes idle; give it orders with tell. Needs provider support.",
262
+ input: z
263
+ .strictObject({
264
+ akuma: text.describe("Source Akuma selector (aku/<name>/<hex> or @alias)."),
265
+ at: text.describe("Exact retained answered turn coordinate (turn/<n>) to branch from."),
266
+ bare: optBool.describe("Omit Keiyaku runtime instructions on the forked child (a bare parent stays bare regardless)."),
267
+ })
268
+ .readonly(),
211
269
  output: forkResultSchema,
270
+ normal: forkNormalResultSchema,
212
271
  effect: "write",
213
272
  },
214
273
  tell: {
215
- description: "Send an Akuma a prompt.",
216
- input: z.strictObject({ akuma: text, prompt: text, interrupt: optBool }).readonly(),
274
+ description: "Give an Akuma new orders: steers its current work or wakes it. Returns admission, not an answer. Observe work separately with wait, or use ask for a structured answer.",
275
+ input: z
276
+ .strictObject({
277
+ ...tellFields,
278
+ })
279
+ .readonly(),
217
280
  output: akumaTellResultSchema,
218
281
  effect: "write",
219
282
  },
220
283
  ask: {
221
- description: "Ask an Akuma and observe its answer.",
284
+ description: "Demand a structured answer from an Akuma: a prompt and a JSON Schema in, parsed JSON out. The answer is not checked against the schema; non-JSON is a failure. Not every provider honors schemas.",
222
285
  input: z
223
286
  .strictObject({
224
- akuma: text,
225
- prompt: text,
226
- timeoutMs: timeout,
227
- schema: jsonDocument.exactOptional(),
228
- interrupt: optBool,
287
+ akuma: text.describe("Target Akuma selector (aku/<name>/<hex> or @alias)."),
288
+ prompt: nonblank.describe("Nonblank question or instruction to admit."),
289
+ timeoutMs: timeout.describe("Optional observation deadline in integer milliseconds (stops observation on deadline without retracting the prompt or killing the Akuma)."),
290
+ schema: jsonDocument.describe("JSON Schema object sent to the provider to constrain the turn's JSON output."),
291
+ interrupt: optBool.describe("Request the currently running turn to yield before running this Ask."),
229
292
  })
230
293
  .readonly(),
231
294
  output: akumaAskResultSchema,
295
+ normal: akumaAskNormalResultSchema,
232
296
  progress: askProgressSchema,
233
297
  effect: "write",
234
298
  },
235
299
  kill: {
236
- description: "Kill selected Akumas.",
237
- input: z.strictObject({ akuma: z.array(text).min(1).readonly() }).readonly(),
300
+ description: "Kill an Akuma's current execution. Nothing is erased: history and queued orders remain, and tell or ask wakes it.",
301
+ input: z
302
+ .strictObject({
303
+ akuma: nonblank.describe('One Akuma selector: aku/<name>/<hex>, @alias, kei/... (all Akumas dispatched to that Contract), or glob "aku/<name-pattern>/<hex-pattern>". Contract/glob selection may expand to several members.'),
304
+ })
305
+ .readonly(),
238
306
  output: akumaKillResultSchema,
239
307
  effect: "destroy",
240
308
  },
241
309
  wait: {
242
- description: "Wait for selected Contracts or Akumas.",
243
- input: z.union([
244
- z
245
- .strictObject({
246
- selectors: z.array(contractSelector).min(1).readonly(),
247
- completion: z.enum(["any", "all"]).exactOptional(),
248
- timeoutMs: timeout,
249
- })
250
- .readonly(),
251
- z
252
- .strictObject({
253
- selectors: z.array(akumaSelector).min(1).readonly(),
254
- completion: z.enum(["any", "all"]).exactOptional(),
255
- timeoutMs: timeout,
256
- })
257
- .readonly(),
258
- ]),
259
- output: z.union([contractWaitResultSchema, akumaWaitResultSchema]),
310
+ description: "Wait for Contracts to change or close and Akumas to finish their current work, together or separately. Any/all applies to the whole selection. Already satisfied members count immediately. A timeout ends observation, never the work.",
311
+ input: z
312
+ .strictObject({
313
+ selectors: z
314
+ .array(z.union([
315
+ contractIdSchema,
316
+ text.refine((value) => {
317
+ try {
318
+ if (value.startsWith("@"))
319
+ parseReadableAkumaAlias(value);
320
+ else if (value.includes("*"))
321
+ parseAkumaGlob(value);
322
+ else
323
+ return akumaIdSchema.safeParse(value).success;
324
+ return true;
325
+ }
326
+ catch {
327
+ return false;
328
+ }
329
+ }, "Expected an Akuma ID, alias or glob"),
330
+ ]))
331
+ .min(1)
332
+ .readonly()
333
+ .describe('Contract IDs (kei/...) and Akuma selectors (aku/<name>/<hex>, @alias, or "aku/<name-pattern>/<hex-pattern>"), in caller order. A Contract selects its journal, not dispatched Akumas.'),
334
+ completion: z
335
+ .enum(["any", "all"])
336
+ .exactOptional()
337
+ .describe('Wake when "any" member satisfies (default), or wait for "all" members.'),
338
+ timeout: waitDuration
339
+ .exactOptional()
340
+ .describe("One observation deadline as a duration (e.g. 5m); never cancels work."),
341
+ })
342
+ .readonly(),
343
+ output: invocationWaitResultSchema,
344
+ normal: invocationWaitNormalResultSchema,
260
345
  effect: "read",
261
346
  },
262
347
  history: {
263
- description: "Read Contract or Akuma history.",
348
+ description: "Look back: a Contract's journal, or an Akuma's recent activity. For an Akuma, last returns its latest answer and id opens one item such as turn/<n> or report/<n>.",
264
349
  input: z.union([
265
- z.strictObject({ selector: contractSelector, full: optBool }).readonly(),
266
350
  z
267
351
  .strictObject({
268
- selector: akumaSelector,
269
- id: optText,
270
- before: positive.exactOptional(),
271
- since: positive.exactOptional(),
272
- limit: positive.exactOptional(),
273
- last: optBool,
352
+ selector: contractSelector.describe("Single subject: kei/... for Contract history, or aku/<name>/<hex> / @alias for Akuma history."),
353
+ full: optBool.describe("Include full event details on Contract history (valid only for kei/... selectors)."),
274
354
  })
275
355
  .readonly(),
356
+ ...historySelectionSchemas.map((branch) => branch.extend({
357
+ last: branch.shape.last.describe("When true, return only the Akuma's latest retained answer bytes (mutually exclusive with id, before, since, and limit)."),
358
+ ...("id" in branch.shape
359
+ ? {
360
+ id: branch.shape.id.describe("Exact Akuma item coordinate: turn/<n> (turn outcome), report/<n> (full progress report), or positive decimal activity sequence. Mutually exclusive with before, since, limit, and last."),
361
+ }
362
+ : {}),
363
+ ...("before" in branch.shape
364
+ ? {
365
+ before: branch.shape.before.describe("Page older Akuma timeline events strictly before this positive decimal sequence."),
366
+ }
367
+ : {}),
368
+ ...("since" in branch.shape
369
+ ? {
370
+ since: branch.shape.since.describe("Page newer Akuma timeline events strictly after this nonnegative decimal sequence (mutually exclusive with before)."),
371
+ }
372
+ : {}),
373
+ ...("limit" in branch.shape
374
+ ? { limit: branch.shape.limit.describe("Maximum Akuma timeline rows to return (1..5000, default 12).") }
375
+ : {}),
376
+ })
377
+ .extend({
378
+ selector: akumaSelector.describe("Single subject: kei/... for Contract history, or aku/<name>/<hex> / @alias for Akuma history."),
379
+ })
380
+ .readonly()),
276
381
  ]),
277
382
  output: z.union([contractHistorySchema, akumaHistoryResultSchema]),
278
383
  effect: "read",
279
384
  },
280
385
  report: {
281
- description: "Record a report for the current execution.",
282
- input: z.strictObject({ text: nonblank }).readonly(),
386
+ description: "From inside a running Akuma, leave a progress note for whoever holds it and keep working. Only works when this server runs inside that Akuma.",
387
+ input: z
388
+ .strictObject({
389
+ text: nonblank.describe("Nonblank progress report Markdown/text recorded on the current turn timeline."),
390
+ })
391
+ .readonly(),
283
392
  output: akumaReportResultSchema,
284
393
  effect: "write",
285
394
  },
286
395
  whoami: {
287
- description: "Observe the invocation's identity and context.",
396
+ description: "Who this server acts as: caller or Akuma identity, its Contract link and turn initiator, and which Contract worktree cwd stands in. Read from the environment; not authentication.",
288
397
  input: z.strictObject({}).readonly(),
289
398
  output: whoamiFactsSchema,
290
399
  effect: "read",
@@ -301,158 +410,75 @@ export const verbs = Object.freeze({
301
410
  output: resetOutcomeSchema,
302
411
  effect: "destroy",
303
412
  },
413
+ kanshi: {
414
+ description: "Watch everything at once: active Contracts, Debts, and Akumas. Use status, show, or history to look closer.",
415
+ input: z.strictObject({}).readonly(),
416
+ output: kanshiReportSchema,
417
+ effect: "read",
418
+ },
304
419
  status: {
305
- description: "Observe the World or selected subjects.",
306
- input: z.union([
307
- z.strictObject({}).readonly(),
308
- z.strictObject({ selector: text }).readonly(),
309
- z.strictObject({ selectors: z.array(text).min(2).readonly() }).readonly(),
310
- z.strictObject({ category: z.enum(["akuma", "contract"]), limit: positive.exactOptional() }).readonly(),
311
- ]),
312
- output: statusResultSchema,
420
+ description: "Where one Contract stands (stage, gates, prerequisites, worktree) or what one Akuma is doing (state, current work, changed files). Exact kei/... or aku/<name>/<id> only; no aliases.",
421
+ input: z
422
+ .strictObject({
423
+ id: z
424
+ .union([contractIdSchema, akumaIdSchema])
425
+ .describe("Exact Contract ID (kei/...) or Akuma ID (aku/<name>/<hex>); @aliases and category paths are refused."),
426
+ })
427
+ .readonly(),
428
+ output: z.union([contractStatusSchema, akumaObservationSchema]),
429
+ normal: z.union([contractNormalStatusSchema, akumaObservationSchema]),
313
430
  effect: "read",
314
431
  },
315
- region: {
316
- description: "Observe Region declarations or overlaps.",
317
- input: z.union([
318
- z.strictObject({}).readonly(),
319
- z.strictObject({ contract: text }).readonly(),
320
- z.strictObject({ paths: z.array(text).min(1).readonly() }).readonly(),
321
- ]),
322
- output: regionResultSchema,
432
+ ls: {
433
+ description: "List ids of one kind: active Contracts (kei/), open Debts (debt/), akumaName values you can birth (aku/), or existing Akumas (aku/*).",
434
+ input: lsInputSchema,
435
+ output: z.union([contractCatalogueSchema, akumaCatalogueSchema, akumaNameCatalogSchema, debtCatalogueSchema]),
436
+ normal: z.union([contractCatalogueSchema, akumaCatalogueSchema, akumaNameCatalogSchema, debtListSchema]),
323
437
  effect: "read",
324
438
  },
325
- "debt.add": {
326
- description: "Create a Debt.",
439
+ region: {
440
+ description: "Before parallel work: which files active Contracts claim to change and where those claims overlap. Advisory only; no locks, no conflict prediction.",
327
441
  input: z
328
442
  .strictObject({
329
- title: text,
330
- namespace: strings.exactOptional(),
331
- body: optText,
332
- note: optText,
333
- state: debtStateSchema.exactOptional(),
334
- priority: debtPrioritySchema.exactOptional(),
335
- ...debtRelations,
336
- ...actor,
443
+ contract: optText.describe("Contract selector (kei/...) whose declared Region and overlaps to inspect; mutually exclusive with paths."),
444
+ paths: z
445
+ .array(text)
446
+ .min(1)
447
+ .readonly()
448
+ .refine((paths) => paths.length > 0)
449
+ .exactOptional()
450
+ .describe("Nonempty repository-relative path or glob patterns to check against active Contract Regions; mutually exclusive with contract."),
337
451
  })
452
+ .refine((input) => !(input.contract !== undefined && input.paths !== undefined), "contract and paths are mutually exclusive")
338
453
  .readonly(),
454
+ output: regionResultSchema,
455
+ effect: "read",
456
+ },
457
+ "debt.add": {
458
+ description: "Record open work still owed, with optional body, priority and prerequisite needs. Returns its debt/... id.",
459
+ input: addDebtInputSchema.readonly(),
339
460
  output: debtMutationResultSchema,
461
+ normal: debtMutationNormalResultSchema,
340
462
  effect: "write",
341
463
  },
342
464
  "debt.addDocument": {
343
465
  description: "Create a Debt from Markdown.",
344
- input: z.strictObject({ markdown: text, namespace: strings.exactOptional(), ...actor }).readonly(),
466
+ input: z.strictObject({ markdown: text }).readonly(),
345
467
  output: debtMutationResultSchema,
346
468
  effect: "write",
347
469
  },
348
470
  "debt.update": {
349
- description: "Update a Debt.",
350
- input: z
351
- .strictObject({
352
- id: text,
353
- title: optText,
354
- body: optText,
355
- appendBody: optText,
356
- note: optText,
357
- priority: debtPrioritySchema.exactOptional(),
358
- ...debtRelations,
359
- addNeeds: strings.exactOptional(),
360
- dropNeeds: strings.exactOptional(),
361
- addSupersedes: strings.exactOptional(),
362
- dropSupersedes: strings.exactOptional(),
363
- addRelates: strings.exactOptional(),
364
- dropRelates: strings.exactOptional(),
365
- })
471
+ description: "Replace a Debt's text, priority or prerequisites, or set its disposition to open, done or drop. Any state may be reopened or changed; omitted fields are preserved and empty body, note or needs clears them.",
472
+ input: updateDebtInputSchema
473
+ .safeExtend({ id: debtIdSchema.describe("Target Debt ID (debt/<slug>-<hex>).") })
366
474
  .readonly(),
367
475
  output: debtUpdateResultSchema,
368
476
  effect: "write",
369
477
  },
370
- "debt.show": {
371
- description: "Read one or more Debts.",
372
- input: z.union([
373
- z.strictObject({ id: text }).readonly(),
374
- z.strictObject({ ids: z.array(text).min(1).readonly() }).readonly(),
375
- ]),
376
- output: z.union([debtShowResultSchema, debtAbsentSchema]),
377
- effect: "read",
378
- },
379
- "debt.done": {
380
- description: "Complete Debts in caller order.",
381
- input: z.strictObject({ ids: z.array(text).min(1).readonly(), note: optText }).readonly(),
382
- output: debtBatchResultSchema,
383
- effect: "write",
384
- },
385
- "debt.drop": {
386
- description: "Drop Debts in caller order.",
387
- input: z.strictObject({ ids: z.array(text).min(1).readonly(), note: optText }).readonly(),
388
- output: debtBatchResultSchema,
389
- effect: "write",
390
- },
391
- "debt.ready": {
392
- description: "List ready Debts.",
393
- input: z.strictObject({ ...debtReadScope, parent: optText }).readonly(),
394
- output: debtReadyListSchema,
395
- effect: "read",
396
- },
397
- "debt.blocked": {
398
- description: "List blocked Debts.",
399
- input: z.strictObject({ ...debtReadScope, parent: optText }).readonly(),
400
- output: blockedDebtListSchema,
401
- effect: "read",
402
- },
403
- "debt.query": {
404
- description: "Query Debts using the owner expression.",
405
- input: z
406
- .strictObject({
407
- ...debtReadScope,
408
- selection: debtSelection,
409
- where: debtQueryExpression.exactOptional(),
410
- sort: z.enum(["priority", "created", "updated", "id"]).exactOptional(),
411
- })
412
- .readonly(),
413
- output: debtQueryResultSchema,
414
- effect: "read",
415
- },
416
- "debt.tree": {
417
- description: "Observe a Debt decomposition tree.",
418
- input: z.strictObject({ id: text }).readonly(),
419
- output: z.union([debtTreeResultSchema, debtAbsentSchema]),
420
- effect: "read",
421
- },
422
478
  "debt.doctor": {
423
- description: "Diagnose Debt authority and relations.",
479
+ description: "Diagnose Debt authority and prerequisites.",
424
480
  input: z.strictObject({}).readonly(),
425
481
  output: z.union([debtDoctorReportSchema, debtAbsentSchema]),
426
482
  effect: "read",
427
483
  },
428
- "debt.context": {
429
- description: "Observe or set the Debt namespace context.",
430
- input: z.strictObject({ namespace: strings.exactOptional() }).readonly(),
431
- output: debtContextResultSchema,
432
- effect: "write",
433
- },
434
- ls: {
435
- description: "List Contracts, Akumas, archetypes, or Debts.",
436
- input: z.union([
437
- z.strictObject({ of: z.literal("kei"), limit: positive.exactOptional() }).readonly(),
438
- z
439
- .strictObject({
440
- of: z.literal("aku"),
441
- limit: positive.exactOptional(),
442
- akumaName: optText,
443
- caller: z
444
- .union([
445
- z.strictObject({ kind: z.literal("mine") }).readonly(),
446
- z.strictObject({ kind: z.literal("external"), caller: akumaCallerSchema }).readonly(),
447
- z.strictObject({ kind: z.literal("akuma"), akumaId: text }).readonly(),
448
- ])
449
- .exactOptional(),
450
- })
451
- .readonly(),
452
- z.strictObject({ of: z.literal("akuma-name"), limit: positive.exactOptional() }).readonly(),
453
- z.strictObject({ of: z.literal("debt"), ...debtReadScope, selection: debtSelection }).readonly(),
454
- ]),
455
- output: z.union([contractCatalogueSchema, akumaListSchema, archetypeCatalogSchema, debtCatalogueSchema]),
456
- effect: "read",
457
- },
458
484
  });