@astrosheep/keiyaku 4.6.30 → 4.6.31

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 (398) hide show
  1. package/README.md +5 -5
  2. package/build/plugins/claude/.claude-plugin/plugin.json +1 -1
  3. package/build/plugins/claude/skills/keiyaku/SKILL.md +12 -12
  4. package/build/plugins/claude/skills/keiyaku-akuma/SKILL.md +16 -16
  5. package/build/plugins/claude/skills/keiyaku-akuma/references/automation.md +14 -14
  6. package/build/plugins/claude/skills/keiyaku-babysit/SKILL.md +10 -10
  7. package/build/plugins/claude/skills/keiyaku-bind/SKILL.md +15 -15
  8. package/build/plugins/claude/skills/keiyaku-debt/SKILL.md +16 -16
  9. package/build/plugins/claude/skills/keiyaku-workflow/SKILL.md +21 -21
  10. package/build/plugins/codex/.codex-plugin/plugin.json +1 -1
  11. package/build/plugins/codex/skills/keiyaku/SKILL.md +12 -12
  12. package/build/plugins/codex/skills/keiyaku-akuma/SKILL.md +16 -16
  13. package/build/plugins/codex/skills/keiyaku-akuma/references/automation.md +14 -14
  14. package/build/plugins/codex/skills/keiyaku-babysit/SKILL.md +10 -10
  15. package/build/plugins/codex/skills/keiyaku-bind/SKILL.md +15 -15
  16. package/build/plugins/codex/skills/keiyaku-debt/SKILL.md +16 -16
  17. package/build/plugins/codex/skills/keiyaku-workflow/SKILL.md +21 -21
  18. package/build/plugins/opencode/package.json +1 -1
  19. package/build/plugins/opencode/skills/keiyaku/SKILL.md +12 -12
  20. package/build/plugins/opencode/skills/keiyaku-akuma/SKILL.md +16 -16
  21. package/build/plugins/opencode/skills/keiyaku-akuma/references/automation.md +14 -14
  22. package/build/plugins/opencode/skills/keiyaku-babysit/SKILL.md +10 -10
  23. package/build/plugins/opencode/skills/keiyaku-bind/SKILL.md +15 -15
  24. package/build/plugins/opencode/skills/keiyaku-debt/SKILL.md +16 -16
  25. package/build/plugins/opencode/skills/keiyaku-workflow/SKILL.md +21 -21
  26. package/build/plugins/pi/README.md +5 -5
  27. package/build/plugins/pi/akuma-tools.ts +17 -23
  28. package/build/skills/keiyaku/SKILL.md +12 -12
  29. package/build/skills/keiyaku-akuma/SKILL.md +16 -16
  30. package/build/skills/keiyaku-akuma/references/automation.md +14 -14
  31. package/build/skills/keiyaku-babysit/SKILL.md +10 -10
  32. package/build/skills/keiyaku-bind/SKILL.md +15 -15
  33. package/build/skills/keiyaku-debt/SKILL.md +16 -16
  34. package/build/skills/keiyaku-workflow/SKILL.md +21 -21
  35. package/build/src/akuma/akuma-call.d.ts +1 -1
  36. package/build/src/akuma/akuma-call.js +9 -9
  37. package/build/src/akuma/akuma-errors.d.ts +5 -5
  38. package/build/src/akuma/akuma-instance.d.ts +355 -12
  39. package/build/src/akuma/akuma-instance.js +20 -20
  40. package/build/src/akuma/akuma-observe.d.ts +11 -12
  41. package/build/src/akuma/akuma-observe.js +34 -26
  42. package/build/src/akuma/akuma-owner.d.ts +32 -11
  43. package/build/src/akuma/akuma-owner.js +35 -16
  44. package/build/src/akuma/akuma-probe.d.ts +3 -3
  45. package/build/src/akuma/akuma-probe.js +2 -2
  46. package/build/src/akuma/akuma-selection-execution.d.ts +985 -1
  47. package/build/src/akuma/akuma-selection-execution.js +42 -18
  48. package/build/src/akuma/akuma-stream.d.ts +2 -2
  49. package/build/src/akuma/akuma-stream.js +1 -1
  50. package/build/src/akuma/akuma-wait.d.ts +5 -5
  51. package/build/src/akuma/akuma-wait.js +52 -14
  52. package/build/src/akuma/akuma.d.ts +245 -271
  53. package/build/src/akuma/akuma.js +98 -46
  54. package/build/src/akuma/archetype.d.ts +19 -6
  55. package/build/src/akuma/archetype.js +25 -9
  56. package/build/src/akuma/body-launch.d.ts +2 -2
  57. package/build/src/akuma/body.js +4 -4
  58. package/build/src/akuma/call-initial-tell.d.ts +60 -44
  59. package/build/src/akuma/call-initial-tell.js +41 -2
  60. package/build/src/akuma/caller.d.ts +26 -17
  61. package/build/src/akuma/caller.js +22 -9
  62. package/build/src/akuma/coordinate.d.ts +9 -0
  63. package/build/src/akuma/coordinate.js +13 -0
  64. package/build/src/akuma/detached-body.js +2 -2
  65. package/build/src/akuma/dispatch-association.d.ts +4 -4
  66. package/build/src/akuma/dispatch-association.js +12 -3
  67. package/build/src/akuma/execution-instructions.js +2 -2
  68. package/build/src/akuma/heart/facts.d.ts +29 -7
  69. package/build/src/akuma/heart/facts.js +13 -0
  70. package/build/src/akuma/heart/index.d.ts +0 -3
  71. package/build/src/akuma/heart/index.js +3 -6
  72. package/build/src/akuma/heart/rows.js +2 -2
  73. package/build/src/akuma/heart/soul.js +5 -5
  74. package/build/src/akuma/identity.d.ts +17 -16
  75. package/build/src/akuma/identity.js +20 -19
  76. package/build/src/akuma/index.d.ts +1 -2
  77. package/build/src/akuma/lineage-cache.d.ts +4 -4
  78. package/build/src/akuma/lineage-cache.js +10 -10
  79. package/build/src/akuma/projection-read.d.ts +2 -5
  80. package/build/src/akuma/projection-read.js +34 -47
  81. package/build/src/akuma/projection.d.ts +659 -569
  82. package/build/src/akuma/projection.js +203 -94
  83. package/build/src/akuma/providers/acp/index.js +1 -1
  84. package/build/src/akuma/providers/execution-environment.d.ts +1 -3
  85. package/build/src/akuma/providers/execution-environment.js +0 -4
  86. package/build/src/akuma/publication.d.ts +2 -2
  87. package/build/src/akuma/publication.js +3 -3
  88. package/build/src/akuma/retention.js +2 -2
  89. package/build/src/akuma/selection-observation.d.ts +507 -43
  90. package/build/src/akuma/selection-observation.js +153 -1
  91. package/build/src/akuma/status-projection.d.ts +288 -0
  92. package/build/src/akuma/status-projection.js +154 -0
  93. package/build/src/akuma/turn-drive.js +0 -3
  94. package/build/src/alias/index.d.ts +9 -4
  95. package/build/src/alias/index.js +11 -9
  96. package/build/src/bounded-list.d.ts +8 -0
  97. package/build/src/bounded-list.js +9 -0
  98. package/build/src/cli/commands/akuma-grammar.d.ts +2 -2
  99. package/build/src/cli/commands/akuma-grammar.js +21 -21
  100. package/build/src/cli/commands/akuma.d.ts +1 -2
  101. package/build/src/cli/commands/akuma.js +115 -251
  102. package/build/src/cli/commands/contract-grammar.d.ts +4 -3
  103. package/build/src/cli/commands/contract-grammar.js +39 -22
  104. package/build/src/cli/commands/contract-help.d.ts +3 -1
  105. package/build/src/cli/commands/contract-help.js +4 -3
  106. package/build/src/cli/commands/contract.d.ts +6 -3
  107. package/build/src/cli/commands/contract.js +203 -434
  108. package/build/src/cli/commands/debt.d.ts +2 -3
  109. package/build/src/cli/commands/debt.js +101 -317
  110. package/build/src/cli/commands/report.js +11 -28
  111. package/build/src/cli/commands/whoami.d.ts +3 -43
  112. package/build/src/cli/commands/whoami.js +8 -121
  113. package/build/src/cli/coordinates.d.ts +4 -35
  114. package/build/src/cli/coordinates.js +13 -129
  115. package/build/src/cli/parse.d.ts +0 -6
  116. package/build/src/cli/parse.js +5 -48
  117. package/build/src/cli/render/akuma-activity.d.ts +31 -16
  118. package/build/src/cli/render/akuma-activity.js +157 -149
  119. package/build/src/cli/render/akuma-tool.d.ts +3 -6
  120. package/build/src/cli/render/akuma-tool.js +20 -14
  121. package/build/src/cli/render/akuma.d.ts +25 -26
  122. package/build/src/cli/render/akuma.js +100 -129
  123. package/build/src/cli/render/catalog.d.ts +4 -7
  124. package/build/src/cli/render/catalog.js +52 -99
  125. package/build/src/cli/render/contract-history.d.ts +3 -1
  126. package/build/src/cli/render/contract-history.js +140 -215
  127. package/build/src/cli/render/contract-observation.d.ts +43 -30
  128. package/build/src/cli/render/contract-observation.js +64 -31
  129. package/build/src/cli/render/contract-wait.js +6 -6
  130. package/build/src/cli/render/contract.d.ts +41 -6
  131. package/build/src/cli/render/contract.js +274 -370
  132. package/build/src/cli/render/debt.d.ts +9 -19
  133. package/build/src/cli/render/debt.js +120 -185
  134. package/build/src/cli/render/delivery-preview.d.ts +4 -3
  135. package/build/src/cli/render/delivery-preview.js +68 -96
  136. package/build/src/cli/render/kanshi-akuma.d.ts +4 -4
  137. package/build/src/cli/render/kanshi-akuma.js +70 -59
  138. package/build/src/cli/render/kanshi.d.ts +4 -4
  139. package/build/src/cli/render/kanshi.js +205 -221
  140. package/build/src/cli/render/marks.d.ts +11 -2
  141. package/build/src/cli/render/marks.js +13 -3
  142. package/build/src/cli/render/nuke.d.ts +3 -3
  143. package/build/src/cli/render/nuke.js +13 -16
  144. package/build/src/cli/render/receipt.d.ts +37 -43
  145. package/build/src/cli/render/receipt.js +313 -236
  146. package/build/src/cli/render/reconcile.d.ts +6 -4
  147. package/build/src/cli/render/reconcile.js +53 -137
  148. package/build/src/cli/render/refusal.d.ts +3 -2
  149. package/build/src/cli/render/refusal.js +73 -54
  150. package/build/src/cli/render/region.d.ts +11 -2
  151. package/build/src/cli/render/region.js +17 -23
  152. package/build/src/cli/render/settings.d.ts +0 -1
  153. package/build/src/cli/render/settings.js +8 -17
  154. package/build/src/cli/render/terminal.d.ts +2 -0
  155. package/build/src/cli/render/verbs.d.ts +4 -0
  156. package/build/src/cli/render/verbs.js +312 -0
  157. package/build/src/cli/render/whoami.d.ts +1 -1
  158. package/build/src/cli/render/whoami.js +24 -31
  159. package/build/src/cli/runtime.d.ts +3 -11
  160. package/build/src/cli/runtime.js +96 -79
  161. package/build/src/cli/scan.d.ts +1 -1
  162. package/build/src/cli/streams.js +1 -0
  163. package/build/src/contract-guidance.js +2 -2
  164. package/build/src/contract-worktree.d.ts +2 -15
  165. package/build/src/contract-worktree.js +19 -35
  166. package/build/src/core/facts/observation.d.ts +4 -5
  167. package/build/src/core/facts/observation.js +7 -9
  168. package/build/src/core/verbs/amend.d.ts +0 -1
  169. package/build/src/core/verbs/amend.js +3 -3
  170. package/build/src/core/verbs/bind.d.ts +0 -1
  171. package/build/src/core/verbs/bind.js +5 -5
  172. package/build/src/core/verbs/deliver.d.ts +3 -2
  173. package/build/src/core/verbs/deliver.js +2 -2
  174. package/build/src/core/verbs/placement.d.ts +0 -5
  175. package/build/src/core/verbs/placement.js +4 -6
  176. package/build/src/core/verbs/reintegrate.d.ts +0 -1
  177. package/build/src/core/verbs/reintegrate.js +2 -2
  178. package/build/src/debt/board.d.ts +132 -116
  179. package/build/src/debt/board.js +138 -94
  180. package/build/src/debt/catalog.d.ts +4 -4
  181. package/build/src/debt/catalog.js +2 -18
  182. package/build/src/debt/context.d.ts +15 -3
  183. package/build/src/debt/context.js +12 -1
  184. package/build/src/debt/created-observation.d.ts +5 -17
  185. package/build/src/debt/created-observation.js +14 -6
  186. package/build/src/debt/document.d.ts +20 -15
  187. package/build/src/debt/document.js +18 -1
  188. package/build/src/debt/index.d.ts +346 -23
  189. package/build/src/debt/index.js +68 -22
  190. package/build/src/debt/input.d.ts +2 -1
  191. package/build/src/debt/input.js +14 -0
  192. package/build/src/debt/lifecycle-operations.d.ts +2 -2
  193. package/build/src/debt/lifecycle-operations.js +14 -22
  194. package/build/src/debt/operation-types.d.ts +188 -66
  195. package/build/src/debt/operation-types.js +113 -1
  196. package/build/src/debt/operations.d.ts +11 -10
  197. package/build/src/debt/operations.js +46 -71
  198. package/build/src/debt/query.d.ts +14 -10
  199. package/build/src/debt/query.js +3 -12
  200. package/build/src/debt/store.d.ts +4 -2
  201. package/build/src/debt/store.js +8 -8
  202. package/build/src/debt/view.d.ts +0 -3
  203. package/build/src/debt/view.js +0 -4
  204. package/build/src/dispatch/index.d.ts +22 -5
  205. package/build/src/dispatch/index.js +46 -37
  206. package/build/src/git/admission.d.ts +2 -2
  207. package/build/src/git/admission.js +2 -1
  208. package/build/src/git/hooks.d.ts +14 -35
  209. package/build/src/git/hooks.js +45 -25
  210. package/build/src/git/integration.d.ts +6 -24
  211. package/build/src/git/integration.js +10 -16
  212. package/build/src/git/private-state-seat.d.ts +2 -2
  213. package/build/src/git/private-state-seat.js +2 -1
  214. package/build/src/git/reconcile.d.ts +17 -79
  215. package/build/src/git/reconcile.js +37 -52
  216. package/build/src/git/scratch.d.ts +3 -3
  217. package/build/src/git/scratch.js +4 -1
  218. package/build/src/git/target-placement.d.ts +23 -31
  219. package/build/src/git/target-placement.js +42 -27
  220. package/build/src/git/target.d.ts +2 -2
  221. package/build/src/git/target.js +2 -1
  222. package/build/src/git/tender.d.ts +7 -39
  223. package/build/src/git/tender.js +21 -54
  224. package/build/src/git/terminal-reconcile.js +15 -18
  225. package/build/src/git/terminal-seal.d.ts +2 -4
  226. package/build/src/git/terminal-seal.js +7 -33
  227. package/build/src/git/workspace.d.ts +65 -41
  228. package/build/src/git/workspace.js +45 -14
  229. package/build/src/identity/selector.d.ts +2 -0
  230. package/build/src/identity/selector.js +13 -3
  231. package/build/src/index.d.ts +48 -54
  232. package/build/src/index.js +31 -43
  233. package/build/src/kanshi/counts.d.ts +42 -8
  234. package/build/src/kanshi/counts.js +13 -2
  235. package/build/src/kanshi/index.d.ts +5 -5
  236. package/build/src/kanshi/index.js +4 -3
  237. package/build/src/kanshi/read.d.ts +489 -6
  238. package/build/src/kanshi/read.js +334 -483
  239. package/build/src/kanshi/report.d.ts +2504 -103
  240. package/build/src/kanshi/report.js +165 -1
  241. package/build/src/kanshi/select.d.ts +0 -8
  242. package/build/src/kanshi/select.js +20 -59
  243. package/build/src/library/address.d.ts +8 -8
  244. package/build/src/library/address.js +7 -7
  245. package/build/src/library/akuma-creation.d.ts +690 -84
  246. package/build/src/library/akuma-creation.js +202 -142
  247. package/build/src/library/akuma-retention.d.ts +2 -2
  248. package/build/src/library/akuma-retention.js +2 -2
  249. package/build/src/library/akumas.d.ts +10 -6
  250. package/build/src/library/akumas.js +24 -7
  251. package/build/src/library/bind.d.ts +28 -54
  252. package/build/src/library/bind.js +6 -4
  253. package/build/src/library/continuation.d.ts +197 -479
  254. package/build/src/library/continuation.js +40 -23
  255. package/build/src/library/contract-address.d.ts +6 -5
  256. package/build/src/library/contract-address.js +5 -7
  257. package/build/src/library/contract-composition.d.ts +18 -12
  258. package/build/src/library/contract-composition.js +55 -47
  259. package/build/src/library/contract-creation.d.ts +3 -2
  260. package/build/src/library/contract-creation.js +38 -32
  261. package/build/src/library/contract-execution.js +77 -38
  262. package/build/src/library/contract-outcomes.d.ts +1877 -27
  263. package/build/src/library/contract-outcomes.js +93 -10
  264. package/build/src/library/contract-settings.d.ts +2 -2
  265. package/build/src/library/contract-settings.js +18 -14
  266. package/build/src/library/contract-types.d.ts +238 -61
  267. package/build/src/library/contract-types.js +131 -1
  268. package/build/src/library/contract-wait.d.ts +38 -17
  269. package/build/src/library/contract-wait.js +40 -10
  270. package/build/src/library/delivery.d.ts +588 -36
  271. package/build/src/library/delivery.js +35 -27
  272. package/build/src/library/input.d.ts +1 -1
  273. package/build/src/library/input.js +1 -2
  274. package/build/src/library/invocation.d.ts +11 -7
  275. package/build/src/library/invocation.js +42 -51
  276. package/build/src/library/kei.d.ts +48 -0
  277. package/build/src/library/kei.js +256 -0
  278. package/build/src/library/keiyaku-attribution.d.ts +11 -0
  279. package/build/src/{cli/delivery-identity.js → library/keiyaku-attribution.js} +12 -1
  280. package/build/src/library/keiyaku-classify.d.ts +11 -0
  281. package/build/src/library/keiyaku-classify.js +146 -0
  282. package/build/src/library/keiyaku-coordinates.d.ts +31 -0
  283. package/build/src/library/keiyaku-coordinates.js +103 -0
  284. package/build/src/library/keiyaku-debt.d.ts +142 -0
  285. package/build/src/library/keiyaku-debt.js +188 -0
  286. package/build/src/library/keiyaku-identity.d.ts +58 -0
  287. package/build/src/library/keiyaku-identity.js +176 -0
  288. package/build/src/library/keiyaku-policy.d.ts +27 -0
  289. package/build/src/library/keiyaku-policy.js +44 -0
  290. package/build/src/library/keiyaku-status.d.ts +1487 -0
  291. package/build/src/library/keiyaku-status.js +92 -0
  292. package/build/src/library/keiyaku-verbs.d.ts +6774 -0
  293. package/build/src/library/keiyaku-verbs.js +458 -0
  294. package/build/src/library/keiyaku.d.ts +871 -38
  295. package/build/src/library/keiyaku.js +677 -127
  296. package/build/src/library/nuke.d.ts +22 -0
  297. package/build/src/library/nuke.js +4 -1
  298. package/build/src/library/outcome.d.ts +706 -692
  299. package/build/src/library/outcome.js +582 -167
  300. package/build/src/library/reconcile.d.ts +464 -116
  301. package/build/src/library/reconcile.js +174 -102
  302. package/build/src/library/refusal.d.ts +113 -577
  303. package/build/src/library/refusal.js +64 -51
  304. package/build/src/library/region.d.ts +5 -24
  305. package/build/src/library/region.js +6 -21
  306. package/build/src/library/selection.d.ts +181 -32
  307. package/build/src/library/selection.js +99 -64
  308. package/build/src/mcp/adapter.d.ts +11 -0
  309. package/build/src/mcp/adapter.js +106 -0
  310. package/build/src/mcp/help.d.ts +1 -0
  311. package/build/src/mcp/help.js +26 -0
  312. package/build/src/mcp/index.d.ts +2 -0
  313. package/build/src/mcp/index.js +37 -0
  314. package/build/src/plugin/public.d.ts +1 -1
  315. package/build/src/plugin/runtime.js +17 -14
  316. package/build/src/protocol/arc.d.ts +4 -1
  317. package/build/src/protocol/arc.js +7 -1
  318. package/build/src/protocol/attempt.d.ts +2 -3
  319. package/build/src/protocol/attempt.js +1 -10
  320. package/build/src/protocol/bind.d.ts +6 -7
  321. package/build/src/protocol/bind.js +9 -5
  322. package/build/src/protocol/completion.d.ts +448 -12
  323. package/build/src/protocol/completion.js +164 -26
  324. package/build/src/protocol/deliver.d.ts +26 -24
  325. package/build/src/protocol/deliver.js +24 -52
  326. package/build/src/protocol/delivery-preview.d.ts +97 -247
  327. package/build/src/protocol/delivery-preview.js +132 -128
  328. package/build/src/protocol/execution-observation.d.ts +146 -123
  329. package/build/src/protocol/execution-observation.js +9 -6
  330. package/build/src/protocol/intent.d.ts +9 -48
  331. package/build/src/protocol/intent.js +32 -46
  332. package/build/src/protocol/operations.d.ts +207 -505
  333. package/build/src/protocol/operations.js +81 -134
  334. package/build/src/protocol/placement.d.ts +0 -1
  335. package/build/src/protocol/placement.js +5 -2
  336. package/build/src/protocol/progress.d.ts +7 -97
  337. package/build/src/protocol/progress.js +7 -55
  338. package/build/src/protocol/read/observation.d.ts +13 -6
  339. package/build/src/protocol/read/observation.js +10 -9
  340. package/build/src/protocol/read/status.d.ts +464 -93
  341. package/build/src/protocol/read/status.js +372 -85
  342. package/build/src/protocol/reconcile.d.ts +2 -0
  343. package/build/src/protocol/reconcile.js +12 -11
  344. package/build/src/protocol/reintegrate.d.ts +0 -1
  345. package/build/src/protocol/reintegrate.js +4 -4
  346. package/build/src/protocol/result-leaves.d.ts +528 -0
  347. package/build/src/protocol/result-leaves.js +195 -0
  348. package/build/src/protocol/result-reasons.d.ts +129 -0
  349. package/build/src/protocol/result-reasons.js +87 -0
  350. package/build/src/protocol/review.d.ts +14 -11
  351. package/build/src/protocol/review.js +30 -14
  352. package/build/src/protocol/run.d.ts +4 -4
  353. package/build/src/protocol/run.js +4 -1
  354. package/build/src/protocol/verify.d.ts +359 -30
  355. package/build/src/protocol/verify.js +118 -28
  356. package/build/src/region.d.ts +26 -0
  357. package/build/src/region.js +28 -0
  358. package/build/src/runtime/proc/diagnostic.d.ts +11 -0
  359. package/build/src/runtime/proc/diagnostic.js +20 -0
  360. package/build/src/runtime/proc/windows-launch.exe +0 -0
  361. package/build/src/settings.d.ts +126 -32
  362. package/build/src/settings.js +107 -34
  363. package/build/src/settlement/settle.d.ts +29 -12
  364. package/build/src/settlement/settle.js +22 -15
  365. package/build/src/verification/declaration.d.ts +1 -3
  366. package/build/src/verification/declaration.js +2 -5
  367. package/build/src/verification/execution.d.ts +7 -19
  368. package/build/src/verification/execution.js +37 -16
  369. package/build/src/verification/observation.d.ts +13 -13
  370. package/build/src/verification/observation.js +9 -7
  371. package/build/src/world.d.ts +8 -0
  372. package/build/src/world.js +7 -0
  373. package/package.json +6 -5
  374. package/plugins/paseo/plugin/server/keiyaku.ts +13 -46
  375. package/plugins/paseo/plugin/server/message.ts +8 -30
  376. package/plugins/paseo/plugin/server/mirror.ts +16 -20
  377. package/plugins/paseo/plugin/server/provider.ts +1 -1
  378. package/plugins/paseo/plugin/server/sdk.ts +14 -6
  379. package/plugins/pi/README.md +5 -5
  380. package/plugins/pi/akuma-tools.ts +17 -23
  381. package/skills/keiyaku/SKILL.md +12 -12
  382. package/skills/keiyaku-akuma/SKILL.md +16 -16
  383. package/skills/keiyaku-akuma/references/automation.md +14 -14
  384. package/skills/keiyaku-babysit/SKILL.md +10 -10
  385. package/skills/keiyaku-bind/SKILL.md +15 -15
  386. package/skills/keiyaku-debt/SKILL.md +16 -16
  387. package/skills/keiyaku-workflow/SKILL.md +21 -21
  388. package/build/src/cli/actor.d.ts +0 -10
  389. package/build/src/cli/actor.js +0 -24
  390. package/build/src/cli/akuma-caller.d.ts +0 -3
  391. package/build/src/cli/akuma-caller.js +0 -31
  392. package/build/src/cli/delivery-identity.d.ts +0 -3
  393. package/build/src/cli/render/effects.d.ts +0 -26
  394. package/build/src/cli/render/effects.js +0 -41
  395. package/build/src/cli/selectors.d.ts +0 -10
  396. package/build/src/cli/selectors.js +0 -42
  397. package/build/src/markdown/diff.d.ts +0 -1
  398. package/build/src/markdown/diff.js +0 -4
@@ -1,10 +1,21 @@
1
1
  import { harnessOwner } from "@astrosheep/square";
2
+ import { actorId as mintActorId } from "../core/facts/types.js";
3
+ /** Resolve optional caller testimony from explicit invocation input. */
4
+ export function resolveActor(input = {}) {
5
+ if (input.actor !== undefined) {
6
+ if (input.actor.trim().length === 0)
7
+ throw new TypeError("actor must be a nonblank string");
8
+ return mintActorId(input.actor);
9
+ }
10
+ const actorId = input.env?.KEIYAKU_ACTOR_ID;
11
+ return actorId !== undefined && actorId.trim().length > 0 ? mintActorId(actorId) : undefined;
12
+ }
2
13
  /** Select attribution at the submitting edge; no host or artifact lookup. */
3
14
  export function deliveryOwner(environment) {
4
15
  const explicit = environment.KEIYAKU_INITIATOR?.trim();
5
16
  if (explicit)
6
17
  return explicit;
7
- if (environment.CLAUDE_CODE_CHILD_SESSION === "1")
18
+ if (environment.CLAUDE_CODE_CHILD_SESSION === "1" && !environment.CLAUDE_CODE_SESSION_ID?.trim())
8
19
  return undefined;
9
20
  const coordinates = [
10
21
  ["CLAUDE_CODE_SESSION_ID", "claude-code"],
@@ -0,0 +1,11 @@
1
+ import type { VerbInput, VerbName, VerbOutput } from "./keiyaku-verbs.js";
2
+ export type VerbDisposition = "accepted" | "refused" | "retryable" | "failed" | "usage";
3
+ export type VerbCompletion<O> = Readonly<{
4
+ kind: "returned";
5
+ value: O;
6
+ }> | Readonly<{
7
+ kind: "threw";
8
+ error: unknown;
9
+ }>;
10
+ /** Classify the native completion without changing or reconstructing its evidence. */
11
+ export declare function classifyVerb<K extends VerbName>(name: K, input: VerbInput<K>, completion: VerbCompletion<VerbOutput<K>>): VerbDisposition;
@@ -0,0 +1,146 @@
1
+ import { AkumaNotBornError } from "../akuma/akuma-errors.js";
2
+ import { AkumaArchetypeError } from "../akuma/archetype.js";
3
+ import { AkumaAddressError, AkumaWorldScopeError } from "./address.js";
4
+ import { KeiyakuArcDocumentError, KeiyakuUsageError } from "./keiyaku-coordinates.js";
5
+ import { KeiyakuError, contractOutcomeDisposition, invocationIssueIsFailure, resetIssueIsRequired, spawnFailureReceipt, } from "./outcome.js";
6
+ function classifyDebt(result) {
7
+ if ("items" in result) {
8
+ if (result.items.some((item) => item.kind === "retry"))
9
+ return "retryable";
10
+ return result.items.some((item) => item.kind === "refused" || item.kind === "missing") ? "refused" : "accepted";
11
+ }
12
+ if (result.kind === "retry")
13
+ return "retryable";
14
+ if (result.kind === "refused" ||
15
+ result.kind === "absent" ||
16
+ result.kind === "missing" ||
17
+ result.kind === "invalid-namespace-context")
18
+ return "refused";
19
+ return "issues" in result && (result.issues?.length ?? 0) > 0 ? "failed" : "accepted";
20
+ }
21
+ function classifyThrown(name, error) {
22
+ if (spawnFailureReceipt(error) !== undefined || (error instanceof KeiyakuError && error.outcome !== undefined))
23
+ return "failed";
24
+ if (error instanceof KeiyakuUsageError)
25
+ return "usage";
26
+ if (error instanceof AkumaAddressError ||
27
+ error instanceof AkumaNotBornError ||
28
+ error instanceof AkumaWorldScopeError ||
29
+ error instanceof KeiyakuArcDocumentError ||
30
+ (name === "spawn" && error instanceof AkumaArchetypeError))
31
+ return "refused";
32
+ return "failed";
33
+ }
34
+ function classifySpawn(result) {
35
+ return result.failure !== undefined ||
36
+ result.dispatchFailure !== undefined ||
37
+ (result.alias !== undefined && result.alias.kind !== "moved") ||
38
+ result.wake?.kind === "failed" ||
39
+ result.input?.kind === "failed" ||
40
+ result.input?.kind === "invalid-output"
41
+ ? "failed"
42
+ : "accepted";
43
+ }
44
+ function classifyFork(result) {
45
+ if (result.kind === "forked")
46
+ return result.dispatchFailure === undefined ? "accepted" : "failed";
47
+ return result.kind === "fork-failed" || result.kind === "provider-forked-local-birth-failed" ? "failed" : "refused";
48
+ }
49
+ function classifyStatus(value) {
50
+ return "kind" in value && value.kind === "contract-missing" ? "refused" : "accepted";
51
+ }
52
+ function classifyRegion(value) {
53
+ return value.kind === "contract-missing" || value.kind === "contract-terminal" ? "refused" : "accepted";
54
+ }
55
+ function classifyReconcile(result) {
56
+ switch (result.kind) {
57
+ case "missing":
58
+ return "refused";
59
+ case "world-observation-failed":
60
+ return "failed";
61
+ case "contract":
62
+ return result.issues?.some(invocationIssueIsFailure) === true ? "failed" : "accepted";
63
+ case "world":
64
+ return result.contracts?.some((item) => item.issues?.some(invocationIssueIsFailure) === true) === true
65
+ ? "failed"
66
+ : "accepted";
67
+ }
68
+ }
69
+ function classifyWait(result) {
70
+ if (result.kind === "contract")
71
+ return result.reason === "missing" ? "refused" : "accepted";
72
+ return result.results.some((item) => item.kind !== "observed") ? "failed" : "accepted";
73
+ }
74
+ function classifyHistory(value) {
75
+ return value.kind === "contract-missing" || value.kind === "akuma-unknown-history" ? "refused" : "accepted";
76
+ }
77
+ function classifyNuke(result) {
78
+ if (result.kind === "refused")
79
+ return "refused";
80
+ return result.issues?.some(resetIssueIsRequired) === true ? "retryable" : "accepted";
81
+ }
82
+ /** Classify the native completion without changing or reconstructing its evidence. */
83
+ export function classifyVerb(name, input, completion) {
84
+ if (completion.kind === "threw")
85
+ return classifyThrown(name, completion.error);
86
+ const value = completion.value;
87
+ switch (name) {
88
+ case "ls":
89
+ return input.of === "debt" ? classifyDebt(value) : "accepted";
90
+ case "debt.add":
91
+ case "debt.addDocument":
92
+ case "debt.update":
93
+ case "debt.show":
94
+ case "debt.done":
95
+ case "debt.drop":
96
+ case "debt.ready":
97
+ case "debt.blocked":
98
+ case "debt.query":
99
+ case "debt.tree":
100
+ case "debt.doctor":
101
+ case "debt.context":
102
+ return classifyDebt(value);
103
+ case "bind":
104
+ case "amend":
105
+ case "arc":
106
+ case "deliver":
107
+ case "deliver.preview":
108
+ case "verify":
109
+ case "review":
110
+ case "abandon": {
111
+ return contractOutcomeDisposition(value);
112
+ }
113
+ case "spawn":
114
+ return classifySpawn(value);
115
+ case "fork":
116
+ return classifyFork(value);
117
+ case "tell":
118
+ return value.wake?.kind === "failed" ? "failed" : "accepted";
119
+ case "ask": {
120
+ const reason = value.kind;
121
+ return reason === "failed" || reason === "invalid-output" ? "failed" : "accepted";
122
+ }
123
+ case "kill":
124
+ return value.results.some(({ outcome }) => outcome === "unavailable" || outcome === "hung" || outcome === "untidy")
125
+ ? "failed"
126
+ : "accepted";
127
+ case "wait":
128
+ return classifyWait(value);
129
+ case "history":
130
+ return classifyHistory(value);
131
+ case "show":
132
+ return value.kind === "missing" ? "refused" : "accepted";
133
+ case "status":
134
+ return classifyStatus(value);
135
+ case "region":
136
+ return classifyRegion(value);
137
+ case "reconcile":
138
+ return classifyReconcile(value);
139
+ case "nuke":
140
+ return classifyNuke(value);
141
+ case "report":
142
+ return value.kind === "refused" ? "refused" : "accepted";
143
+ default:
144
+ return "accepted";
145
+ }
146
+ }
@@ -0,0 +1,31 @@
1
+ import { type WorldRoot } from "../world.js";
2
+ import { Repo } from "./repo.js";
3
+ import type { ContractId } from "../core/facts/types.js";
4
+ /** Invalid arc material retains the resolved subject for the process-edge refusal. */
5
+ export declare class KeiyakuArcDocumentError extends Error {
6
+ readonly contract: ContractId;
7
+ constructor(contract: ContractId, cause: Error);
8
+ }
9
+ export declare class KeiyakuUsageError extends TypeError {
10
+ constructor(message: string);
11
+ }
12
+ export type InvocationCoordinates = Readonly<{
13
+ cwd: string;
14
+ repo?: Repo;
15
+ world: WorldRoot | null;
16
+ candidateWorld: WorldRoot | null;
17
+ debtContext: Readonly<{
18
+ directory: string;
19
+ boundary: string;
20
+ writeRoot: string;
21
+ managed: boolean;
22
+ }>;
23
+ establishWorld: () => Promise<WorldRoot>;
24
+ }>;
25
+ export declare function invocationCoordinates(input: Readonly<{
26
+ cwd: string;
27
+ repo?: string;
28
+ environment: Readonly<Record<string, string | undefined>>;
29
+ use: "none" | "optional" | "required";
30
+ contractWait?: boolean;
31
+ }>): Promise<InvocationCoordinates>;
@@ -0,0 +1,103 @@
1
+ import { lstat, realpath } from "node:fs/promises";
2
+ import { resolve } from "node:path";
3
+ import { World, WorldError } from "../world.js";
4
+ import { NoGitWorldError, Repo } from "./repo.js";
5
+ /** Invalid arc material retains the resolved subject for the process-edge refusal. */
6
+ export class KeiyakuArcDocumentError extends Error {
7
+ contract;
8
+ constructor(contract, cause) {
9
+ super(cause.message, { cause });
10
+ this.contract = contract;
11
+ }
12
+ }
13
+ export class KeiyakuUsageError extends TypeError {
14
+ constructor(message) {
15
+ super(message);
16
+ this.name = "KeiyakuUsageError";
17
+ }
18
+ }
19
+ async function discoverRepo(path, gitPath) {
20
+ try {
21
+ return { kind: "present", repo: await Repo.at({ path, ...(gitPath === undefined ? {} : { gitPath }) }) };
22
+ }
23
+ catch (error) {
24
+ if (error instanceof NoGitWorldError)
25
+ return { kind: "absent", error };
26
+ throw error;
27
+ }
28
+ }
29
+ async function managedContractWorktree(root) {
30
+ try {
31
+ const stat = await lstat(resolve(root, ".keiyaku", "KEIYAKU.md"));
32
+ return stat.isFile() && !stat.isSymbolicLink();
33
+ }
34
+ catch (error) {
35
+ if (error.code === "ENOENT")
36
+ return false;
37
+ throw error;
38
+ }
39
+ }
40
+ // eslint-disable-next-line complexity -- coordinate discovery preserves independent Repo and World policies.
41
+ export async function invocationCoordinates(input) {
42
+ const gitPath = input.environment.KEIYAKU_GIT_PATH;
43
+ if (gitPath !== undefined && gitPath.trim() === "")
44
+ throw new KeiyakuUsageError("KEIYAKU_GIT_PATH requires a nonblank value");
45
+ let cwd;
46
+ try {
47
+ cwd = await realpath(input.cwd);
48
+ }
49
+ catch {
50
+ throw new KeiyakuUsageError(`invocation cwd is not an existing directory: ${input.cwd}`);
51
+ }
52
+ const invocation = input.contractWait === true ? undefined : await discoverRepo(cwd, gitPath);
53
+ const selected = input.repo === undefined && invocation !== undefined
54
+ ? invocation
55
+ : await discoverRepo(input.repo === undefined ? cwd : resolve(cwd, input.repo), gitPath);
56
+ if (input.use === "required" && selected.kind === "absent")
57
+ throw selected.error;
58
+ const repo = input.use !== "none" && selected.kind === "present" ? selected.repo : undefined;
59
+ if (input.contractWait === true) {
60
+ return {
61
+ cwd,
62
+ ...(repo === undefined ? {} : { repo }),
63
+ world: null,
64
+ candidateWorld: null,
65
+ debtContext: { directory: cwd, boundary: cwd, writeRoot: cwd, managed: false },
66
+ establishWorld: async () => {
67
+ throw new Error("Contract wait has no World");
68
+ },
69
+ };
70
+ }
71
+ const worldRepo = invocation?.kind === "present" ? invocation.repo : undefined;
72
+ try {
73
+ const world = await World.resolve({ cwd, ...(worldRepo === undefined ? {} : { repositoryRoot: worldRepo.root }) });
74
+ const boundary = worldRepo === undefined ? (world.root ?? world.candidate ?? cwd) : worldRepo.cwd;
75
+ return {
76
+ cwd,
77
+ ...(repo === undefined ? {} : { repo }),
78
+ world: world.root,
79
+ candidateWorld: world.candidate,
80
+ debtContext: {
81
+ directory: cwd,
82
+ boundary,
83
+ writeRoot: worldRepo === undefined ? boundary : cwd,
84
+ managed: await managedContractWorktree(boundary),
85
+ },
86
+ establishWorld: async () => {
87
+ try {
88
+ return await world.establish();
89
+ }
90
+ catch (error) {
91
+ if (error instanceof WorldError)
92
+ throw new KeiyakuUsageError(error.message);
93
+ throw error;
94
+ }
95
+ },
96
+ };
97
+ }
98
+ catch (error) {
99
+ if (error instanceof WorldError)
100
+ throw new KeiyakuUsageError(error.message);
101
+ throw error;
102
+ }
103
+ }
@@ -0,0 +1,142 @@
1
+ import { type AddDebtInput, type AddDebtDocumentInput, type UpdateDebtInput, type DebtQueryExpression, type DebtQuerySort, type DebtAbsent, type DebtCatalogue, type DebtShowResult } from "../debt/index.js";
2
+ import type { KeiyakuAt } from "./keiyaku.js";
3
+ export type DebtSelection = "active" | "closed" | "all";
4
+ export type DebtReadScope = Readonly<{
5
+ scope?: "namespace" | "world";
6
+ namespace?: readonly string[];
7
+ limit?: number;
8
+ }>;
9
+ export type DebtLsInvocation = DebtReadScope & Readonly<{
10
+ of: "debt";
11
+ selection?: DebtSelection;
12
+ }>;
13
+ export type DebtReadyInvocation = DebtReadScope & Readonly<{
14
+ parent?: string;
15
+ }>;
16
+ export type DebtQueryInvocation = DebtReadScope & Readonly<{
17
+ selection?: DebtSelection;
18
+ where?: DebtQueryExpression;
19
+ sort?: DebtQuerySort;
20
+ }>;
21
+ export type DebtUpdateInvocation = UpdateDebtInput & Readonly<{
22
+ id: string;
23
+ }>;
24
+ export type DebtCloseInvocation = Readonly<{
25
+ ids: readonly string[];
26
+ note?: string;
27
+ signal?: AbortSignal;
28
+ }>;
29
+ export type DebtShowInvocation = Readonly<{
30
+ id: string;
31
+ ids?: never;
32
+ }> | Readonly<{
33
+ ids: readonly string[];
34
+ id?: never;
35
+ }>;
36
+ export type DebtContextInvocation = Readonly<{
37
+ namespace?: readonly string[];
38
+ }>;
39
+ declare const absent: DebtAbsent;
40
+ export declare function debtAdd(at: KeiyakuAt, input: AddDebtInput | AddDebtDocumentInput, document: boolean): Promise<Readonly<{
41
+ kind: "refused";
42
+ reason: "invalid-graph";
43
+ diagnostic: string;
44
+ }> | Readonly<{
45
+ kind: "refused";
46
+ reason: "invalid-namespace-context";
47
+ path?: string;
48
+ }> | Readonly<{
49
+ kind: "retry";
50
+ reason: "busy" | "concurrent-modification";
51
+ }> | Readonly<{
52
+ kind: "accepted";
53
+ id: `debt/${string}`;
54
+ warning?: string;
55
+ }>>;
56
+ export declare function debtUpdate(at: KeiyakuAt, input: DebtUpdateInvocation): Promise<Readonly<{
57
+ kind: "refused";
58
+ reason: "debt-missing";
59
+ }> | Readonly<{
60
+ kind: "refused";
61
+ reason: "invalid-graph";
62
+ diagnostic: string;
63
+ }> | Readonly<{
64
+ kind: "refused";
65
+ reason: "relation-owned-by-other";
66
+ related: `debt/${string}`;
67
+ }> | Readonly<{
68
+ kind: "retry";
69
+ reason: "busy" | "concurrent-modification";
70
+ }> | Readonly<{
71
+ kind: "accepted";
72
+ changes?: readonly ("note" | "body" | "parent" | "title" | "priority" | "needs" | "supersedes" | "relates")[];
73
+ warning?: string;
74
+ }>>;
75
+ export declare function debtShow(at: KeiyakuAt, input: DebtShowInvocation): Promise<DebtShowResult | DebtAbsent>;
76
+ export declare function debtClose(at: KeiyakuAt, input: DebtCloseInvocation, verb: "done" | "drop"): Promise<Readonly<{
77
+ items: readonly (Readonly<{
78
+ kind: "refused";
79
+ reason: "debt-missing";
80
+ }> | Readonly<{
81
+ kind: "refused";
82
+ reason: "invalid-lifecycle-transition";
83
+ state: "drop" | "done";
84
+ }> | Readonly<{
85
+ kind: "retry";
86
+ reason: "busy" | "concurrent-modification";
87
+ }> | Readonly<{
88
+ kind: "accepted";
89
+ warning?: string;
90
+ }>)[];
91
+ }>>;
92
+ export declare function debtList(at: KeiyakuAt, input: DebtLsInvocation): Promise<DebtCatalogue>;
93
+ export declare function debtReady(at: KeiyakuAt, input: DebtReadyInvocation, blocked: false): Promise<import("../debt/index.js").DebtReadyList | typeof absent>;
94
+ export declare function debtReady(at: KeiyakuAt, input: DebtReadyInvocation, blocked: true): Promise<import("../debt/index.js").BlockedDebtList | typeof absent>;
95
+ export declare function debtQuery(at: KeiyakuAt, input: DebtQueryInvocation): Promise<import("../debt/index.js").DebtQueryResult>;
96
+ export declare function debtTree(at: KeiyakuAt, input: Readonly<{
97
+ id: string;
98
+ }>): Promise<Readonly<{
99
+ kind: "absent";
100
+ }> | Readonly<{
101
+ title: string;
102
+ state: "open" | "drop" | "done";
103
+ priority: 0 | 1 | 2 | 3;
104
+ kind: "present";
105
+ children?: readonly import("../debt/board.js").DebtTreeNode[];
106
+ }> | Readonly<{
107
+ kind: "missing";
108
+ }>>;
109
+ export declare function debtDoctor(at: KeiyakuAt): Promise<Readonly<{
110
+ kind: "absent";
111
+ }> | Readonly<{
112
+ kind: "present";
113
+ issues?: readonly (Readonly<{
114
+ kind: "missing-target";
115
+ debtId: `debt/${string}`;
116
+ relation: "parent" | "needs" | "supersedes" | "relates";
117
+ target: `debt/${string}`;
118
+ }> | Readonly<{
119
+ kind: "self-relation";
120
+ debtId: `debt/${string}`;
121
+ relation: "parent" | "needs" | "supersedes" | "relates";
122
+ }> | Readonly<{
123
+ kind: "cycle";
124
+ relation: "parent" | "needs" | "supersedes";
125
+ debts: readonly `debt/${string}`[];
126
+ }>)[];
127
+ }>>;
128
+ export declare function debtContext(at: KeiyakuAt, input: DebtContextInvocation): Promise<{
129
+ readonly kind: "present";
130
+ readonly source: "default-root";
131
+ readonly path?: never;
132
+ } | {
133
+ readonly kind: "refused";
134
+ readonly path: string;
135
+ readonly source?: never;
136
+ } | {
137
+ readonly namespace?: string;
138
+ readonly kind: "present";
139
+ readonly source: "contract-installed" | "local-override";
140
+ readonly path?: never;
141
+ }>;
142
+ export {};
@@ -0,0 +1,188 @@
1
+ import { Debts, debtRowViewLimit, } from "../debt/index.js";
2
+ import { addDebt, addDebtDocument } from "../debt/operations.js";
3
+ import { addInput, addDocumentInput, closed, record, namespace, debtId, debtIds, text, signal, updateInput, sort, } from "../debt/input.js";
4
+ import { parseDebtCreationDocument } from "../debt/document.js";
5
+ import { debtQuerySelection, normalizeDebtQuery } from "../debt/query.js";
6
+ import { installNamespaceContext, resolveDebtNamespaceContext, validateNamespaceContext } from "../debt/context.js";
7
+ import { invocationCoordinates, KeiyakuUsageError } from "./keiyaku-coordinates.js";
8
+ import { resolveActor } from "./keiyaku-attribution.js";
9
+ const coordinates = (at) => invocationCoordinates({ ...at, use: "none" });
10
+ const absent = { kind: "absent" };
11
+ const missing = () => ({ kind: "refused", reason: "debt-missing" });
12
+ function selection(value) {
13
+ if (value === undefined)
14
+ return "active";
15
+ if (value !== "active" && value !== "closed" && value !== "all")
16
+ throw new TypeError("selection must be active, closed, or all");
17
+ return value;
18
+ }
19
+ function readInput(input, label, extra) {
20
+ const v = record(input, `${label} input`);
21
+ closed(v, ["scope", "namespace", "limit", ...extra], `${label} input`);
22
+ if (v.scope !== undefined && v.scope !== "namespace" && v.scope !== "world")
23
+ throw new TypeError("scope must be namespace or world");
24
+ const ns = namespace(v.namespace);
25
+ if (v.scope === "world" && ns !== undefined)
26
+ throw new TypeError("namespace and world scope are mutually exclusive");
27
+ debtRowViewLimit(v.limit);
28
+ return v;
29
+ }
30
+ async function selectedScope(at, input) {
31
+ if (input.scope === "world")
32
+ return { scope: "world" };
33
+ if (input.namespace !== undefined)
34
+ return { namespace: input.namespace };
35
+ const context = await resolveDebtNamespaceContext(at.debtContext);
36
+ return "kind" in context
37
+ ? { kind: "refused", reason: context.kind, path: context.path }
38
+ : { namespace: context.namespace };
39
+ }
40
+ export async function debtAdd(at, input, document) {
41
+ const parsed = document ? addDocumentInput(input) : addInput(input);
42
+ if (document)
43
+ parseDebtCreationDocument(parsed.markdown);
44
+ const actor = resolveActor({ env: at.environment, ...(parsed.actor === undefined ? {} : { actor: parsed.actor }) });
45
+ const coord = await coordinates(at);
46
+ const world = coord.world ?? (await coord.establishWorld());
47
+ const scope = parsed.namespace === undefined ? await selectedScope(coord, {}) : { namespace: parsed.namespace };
48
+ if ("kind" in scope)
49
+ return scope;
50
+ const composed = { ...parsed, ...scope, ...(actor === undefined ? {} : { actor }) };
51
+ return document ? addDebtDocument(world, composed) : addDebt(world, composed);
52
+ }
53
+ export async function debtUpdate(at, input) {
54
+ const { id: raw, ...rest } = record(input, "update input");
55
+ const id = debtId(raw), coord = await coordinates(at);
56
+ if (coord.world !== null)
57
+ return Debts.of(coord.world)
58
+ .debt({ id })
59
+ .update(rest);
60
+ updateInput(rest).signal?.throwIfAborted();
61
+ return missing();
62
+ }
63
+ export async function debtShow(at, input) {
64
+ const v = record(input, "show input");
65
+ closed(v, ["id", "ids"], "show input");
66
+ if ((v.id === undefined) === (v.ids === undefined))
67
+ throw new TypeError("show requires id or ids");
68
+ const plural = v.ids !== undefined;
69
+ if (plural && (!Array.isArray(v.ids) || v.ids.length === 0))
70
+ throw new TypeError("ids requires at least one DebtId");
71
+ const ids = plural ? v.ids.map(debtId) : [debtId(v.id)];
72
+ const coord = await coordinates(at);
73
+ if (coord.world === null)
74
+ return absent;
75
+ const items = [];
76
+ for (const id of ids) {
77
+ const result = await Debts.of(coord.world).debt({ id }).read();
78
+ items.push(result.kind === "present" ? { ...result, kind: "found" } : result);
79
+ }
80
+ return { kind: "present", items };
81
+ }
82
+ export async function debtClose(at, input, verb) {
83
+ const v = record(input, "close input");
84
+ closed(v, ["ids", "note", "signal"], "close input");
85
+ const coord = await coordinates(at);
86
+ if (coord.world !== null)
87
+ return Debts.of(coord.world).batch({ ...input, verb });
88
+ const ids = debtIds(v.ids, "ids");
89
+ if (ids === undefined || ids.length === 0)
90
+ throw new TypeError("ids requires at least one DebtId");
91
+ text(v.note, "note");
92
+ signal(v.signal)?.throwIfAborted();
93
+ return { items: ids.map(() => missing()) };
94
+ }
95
+ export async function debtList(at, input) {
96
+ const v = readInput(input, "list", ["of", "selection"]);
97
+ if (v.of !== "debt")
98
+ throw new TypeError("of must be debt");
99
+ const selected = selection(v.selection), coord = await coordinates(at);
100
+ if (coord.world === null)
101
+ return absent;
102
+ const scope = await selectedScope(coord, input);
103
+ if ("kind" in scope)
104
+ return { kind: scope.reason, path: scope.path };
105
+ return Debts.of(coord.world).list({
106
+ ...scope,
107
+ selection: selected,
108
+ ...(input.limit === undefined ? {} : { limit: input.limit }),
109
+ });
110
+ }
111
+ export async function debtReady(at, input, blocked) {
112
+ const v = readInput(input, blocked ? "blocked" : "ready", ["parent"]);
113
+ if (v.parent !== undefined)
114
+ debtId(v.parent);
115
+ const coord = await coordinates(at);
116
+ if (coord.world === null)
117
+ return absent;
118
+ const scope = await selectedScope(coord, input);
119
+ if ("kind" in scope)
120
+ return scope;
121
+ const args = {
122
+ ...scope,
123
+ ...(input.parent === undefined ? {} : { parent: input.parent }),
124
+ ...(input.limit === undefined ? {} : { limit: input.limit }),
125
+ };
126
+ return blocked ? Debts.of(coord.world).blocked(args) : Debts.of(coord.world).ready(args);
127
+ }
128
+ export async function debtQuery(at, input) {
129
+ const v = readInput(input, "query", ["selection", "where", "sort"]);
130
+ const selected = selection(v.selection);
131
+ if (v.where !== undefined)
132
+ normalizeDebtQuery(v.where);
133
+ sort(v.sort);
134
+ const coord = await coordinates(at);
135
+ if (coord.world === null)
136
+ return absent;
137
+ const scope = await selectedScope(coord, input);
138
+ if ("kind" in scope)
139
+ return scope;
140
+ return Debts.of(coord.world).query({
141
+ ...scope,
142
+ where: debtQuerySelection(selected, input.where),
143
+ ...(input.sort === undefined ? {} : { sort: input.sort }),
144
+ ...(input.limit === undefined ? {} : { limit: input.limit }),
145
+ });
146
+ }
147
+ export async function debtTree(at, input) {
148
+ const v = record(input, "tree input");
149
+ closed(v, ["id"], "tree input");
150
+ const id = debtId(v.id), coord = await coordinates(at);
151
+ return coord.world === null ? absent : Debts.of(coord.world).debt({ id }).tree();
152
+ }
153
+ export async function debtDoctor(at) {
154
+ const coord = await coordinates(at);
155
+ return coord.world === null ? absent : Debts.of(coord.world).doctor();
156
+ }
157
+ export async function debtContext(at, input) {
158
+ const v = record(input, "context input");
159
+ closed(v, ["namespace"], "context input");
160
+ if (v.namespace !== undefined) {
161
+ try {
162
+ validateNamespaceContext(v.namespace);
163
+ }
164
+ catch (error) {
165
+ if (error instanceof TypeError)
166
+ throw new KeiyakuUsageError(error.message);
167
+ throw error;
168
+ }
169
+ }
170
+ const coord = await coordinates(at);
171
+ if (v.namespace !== undefined) {
172
+ if (coord.world === null)
173
+ await coord.establishWorld();
174
+ await installNamespaceContext(coord.debtContext.writeRoot, v.namespace);
175
+ }
176
+ else if (coord.world === null)
177
+ return { kind: "present", source: "default-root" };
178
+ const resolved = await resolveDebtNamespaceContext(coord.debtContext);
179
+ if ("kind" in resolved)
180
+ return { kind: "refused", path: resolved.path };
181
+ if (resolved.source === "default-root")
182
+ return { kind: "present", source: resolved.source };
183
+ return {
184
+ kind: "present",
185
+ source: resolved.source,
186
+ ...(resolved.namespace.length === 0 ? {} : { namespace: resolved.namespace.join("/") }),
187
+ };
188
+ }