@astrosheep/keiyaku 4.6.31 → 4.6.32

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