@astrosheep/keiyaku 4.6.26 → 4.6.28

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 (301) hide show
  1. package/README.md +113 -35
  2. package/build/plugins/claude/.claude-plugin/plugin.json +1 -1
  3. package/build/plugins/claude/skills/keiyaku/SKILL.md +14 -26
  4. package/build/plugins/claude/skills/keiyaku-akuma/SKILL.md +64 -44
  5. package/build/plugins/claude/skills/keiyaku-akuma/references/automation.md +13 -25
  6. package/build/plugins/claude/skills/keiyaku-babysit/SKILL.md +1 -1
  7. package/build/plugins/claude/skills/keiyaku-bind/SKILL.md +42 -29
  8. package/build/plugins/claude/skills/keiyaku-debt/SKILL.md +13 -8
  9. package/build/plugins/claude/skills/keiyaku-workflow/SKILL.md +57 -61
  10. package/build/plugins/codex/.codex-plugin/plugin.json +1 -1
  11. package/build/plugins/codex/skills/keiyaku/SKILL.md +14 -26
  12. package/build/plugins/codex/skills/keiyaku-akuma/SKILL.md +64 -44
  13. package/build/plugins/codex/skills/keiyaku-akuma/references/automation.md +13 -25
  14. package/build/plugins/codex/skills/keiyaku-babysit/SKILL.md +1 -1
  15. package/build/plugins/codex/skills/keiyaku-bind/SKILL.md +42 -29
  16. package/build/plugins/codex/skills/keiyaku-debt/SKILL.md +13 -8
  17. package/build/plugins/codex/skills/keiyaku-workflow/SKILL.md +57 -61
  18. package/build/plugins/opencode/package.json +1 -1
  19. package/build/plugins/opencode/skills/keiyaku/SKILL.md +14 -26
  20. package/build/plugins/opencode/skills/keiyaku-akuma/SKILL.md +64 -44
  21. package/build/plugins/opencode/skills/keiyaku-akuma/references/automation.md +13 -25
  22. package/build/plugins/opencode/skills/keiyaku-babysit/SKILL.md +1 -1
  23. package/build/plugins/opencode/skills/keiyaku-bind/SKILL.md +42 -29
  24. package/build/plugins/opencode/skills/keiyaku-debt/SKILL.md +13 -8
  25. package/build/plugins/opencode/skills/keiyaku-workflow/SKILL.md +57 -61
  26. package/build/plugins/pi/README.md +7 -12
  27. package/build/plugins/pi/akuma-tools.ts +3 -18
  28. package/build/skills/keiyaku/SKILL.md +14 -26
  29. package/build/skills/keiyaku-akuma/SKILL.md +64 -44
  30. package/build/skills/keiyaku-akuma/references/automation.md +13 -25
  31. package/build/skills/keiyaku-babysit/SKILL.md +1 -1
  32. package/build/skills/keiyaku-bind/SKILL.md +42 -29
  33. package/build/skills/keiyaku-debt/SKILL.md +13 -8
  34. package/build/skills/keiyaku-workflow/SKILL.md +57 -61
  35. package/build/src/akuma/akuma-call.d.ts +15 -18
  36. package/build/src/akuma/akuma-call.js +55 -112
  37. package/build/src/akuma/akuma-errors.d.ts +0 -5
  38. package/build/src/akuma/akuma-errors.js +0 -9
  39. package/build/src/akuma/akuma-instance.d.ts +0 -2
  40. package/build/src/akuma/akuma-instance.js +18 -14
  41. package/build/src/akuma/akuma-observe.js +0 -1
  42. package/build/src/akuma/akuma-owner.js +0 -1
  43. package/build/src/akuma/akuma.d.ts +10 -26
  44. package/build/src/akuma/akuma.js +0 -2
  45. package/build/src/akuma/archetype.d.ts +0 -2
  46. package/build/src/akuma/archetype.js +3 -9
  47. package/build/src/akuma/body-launch.d.ts +12 -4
  48. package/build/src/akuma/body.d.ts +2 -5
  49. package/build/src/akuma/body.js +5 -49
  50. package/build/src/akuma/call-initial-tell.d.ts +39 -147
  51. package/build/src/akuma/call-initial-tell.js +0 -48
  52. package/build/src/akuma/caller.d.ts +0 -4
  53. package/build/src/akuma/custody.js +1 -57
  54. package/build/src/akuma/heart/facts.d.ts +0 -39
  55. package/build/src/akuma/heart/facts.js +0 -1
  56. package/build/src/akuma/heart/index.d.ts +1 -2
  57. package/build/src/akuma/heart/index.js +0 -1
  58. package/build/src/akuma/heart/schema.js +0 -26
  59. package/build/src/akuma/heart/soul.d.ts +2 -2
  60. package/build/src/akuma/heart/soul.js +2 -4
  61. package/build/src/akuma/identity.d.ts +0 -1
  62. package/build/src/akuma/identity.js +0 -2
  63. package/build/src/akuma/in-process-body.d.ts +1 -1
  64. package/build/src/akuma/index.d.ts +0 -2
  65. package/build/src/akuma/index.js +0 -1
  66. package/build/src/akuma/projection.d.ts +23 -23
  67. package/build/src/akuma/provider.d.ts +0 -5
  68. package/build/src/akuma/provider.js +0 -1
  69. package/build/src/akuma/providers/acp/core.js +1 -1
  70. package/build/src/akuma/providers/claude/index.js +1 -2
  71. package/build/src/akuma/providers/codex-app-server/events.d.ts +1 -1
  72. package/build/src/akuma/providers/codex-app-server/events.js +1 -3
  73. package/build/src/akuma/providers/codex-app-server/index.js +1 -1
  74. package/build/src/akuma/providers/execution-environment.d.ts +1 -3
  75. package/build/src/akuma/providers/execution-environment.js +1 -7
  76. package/build/src/akuma/providers/opencode-sdk/index.js +0 -1
  77. package/build/src/akuma/providers/opencode-sdk/session.d.ts +0 -1
  78. package/build/src/akuma/providers/opencode-sdk/session.js +4 -4
  79. package/build/src/akuma/providers/paseo/index.js +2 -9
  80. package/build/src/akuma/providers/pi/index.js +8 -14
  81. package/build/src/akuma/publication.d.ts +24 -59
  82. package/build/src/akuma/publication.js +29 -64
  83. package/build/src/akuma/selection-observation.d.ts +47 -2036
  84. package/build/src/akuma/selection-observation.js +1 -59
  85. package/build/src/akuma/turn-drive.d.ts +0 -8
  86. package/build/src/akuma/turn-drive.js +19 -103
  87. package/build/src/akuma-body.js +3 -6
  88. package/build/src/body-host.d.ts +8 -2
  89. package/build/src/body-host.js +30 -4
  90. package/build/src/cli/commands/akuma-grammar.d.ts +0 -2
  91. package/build/src/cli/commands/akuma-grammar.js +14 -37
  92. package/build/src/cli/commands/akuma.js +31 -49
  93. package/build/src/cli/commands/contract-grammar.d.ts +7 -1
  94. package/build/src/cli/commands/contract-grammar.js +15 -0
  95. package/build/src/cli/commands/contract-help.d.ts +13 -1
  96. package/build/src/cli/commands/contract-help.js +88 -81
  97. package/build/src/cli/commands/contract.js +27 -26
  98. package/build/src/cli/commands/debt-grammar.js +15 -15
  99. package/build/src/cli/commands/debt.js +3 -3
  100. package/build/src/cli/commands/install.d.ts +1 -1
  101. package/build/src/cli/commands/install.js +1 -2
  102. package/build/src/cli/commands/whoami.d.ts +0 -2
  103. package/build/src/cli/commands/whoami.js +0 -5
  104. package/build/src/cli/coordinates.js +15 -0
  105. package/build/src/cli/delivery-identity.d.ts +3 -0
  106. package/build/src/cli/delivery-identity.js +23 -0
  107. package/build/src/cli/parse.js +2 -1
  108. package/build/src/cli/render/akuma-activity.d.ts +0 -1
  109. package/build/src/cli/render/akuma-activity.js +1 -4
  110. package/build/src/cli/render/catalog.js +7 -1
  111. package/build/src/cli/render/contract-history.js +16 -38
  112. package/build/src/cli/render/contract-observation.d.ts +23 -10
  113. package/build/src/cli/render/contract-observation.js +9 -6
  114. package/build/src/cli/render/contract-wait.d.ts +2 -0
  115. package/build/src/cli/render/contract-wait.js +18 -0
  116. package/build/src/cli/render/contract.d.ts +2 -2
  117. package/build/src/cli/render/contract.js +57 -39
  118. package/build/src/cli/render/delivery-preview.js +13 -26
  119. package/build/src/cli/render/execution-progress.js +9 -9
  120. package/build/src/cli/render/kanshi.js +4 -11
  121. package/build/src/cli/render/receipt.d.ts +18 -0
  122. package/build/src/cli/render/receipt.js +34 -10
  123. package/build/src/cli/render/reconcile.js +3 -0
  124. package/build/src/cli/render/refusal.js +28 -6
  125. package/build/src/cli/render/whoami.js +1 -4
  126. package/build/src/cli/runtime.d.ts +0 -2
  127. package/build/src/cli/runtime.js +3 -7
  128. package/build/src/cli/selectors.d.ts +1 -2
  129. package/build/src/cli/selectors.js +2 -5
  130. package/build/src/contract-guidance.js +4 -2
  131. package/build/src/contract-worktree.d.ts +3 -3
  132. package/build/src/core/facts/codec.js +38 -5
  133. package/build/src/core/facts/fold.js +1 -0
  134. package/build/src/core/facts/gate.d.ts +10 -4
  135. package/build/src/core/facts/gate.js +56 -39
  136. package/build/src/core/facts/observation.d.ts +7 -1
  137. package/build/src/core/facts/observation.js +15 -0
  138. package/build/src/core/facts/offer.d.ts +2 -2
  139. package/build/src/core/facts/types.d.ts +17 -1
  140. package/build/src/core/facts/types.js +6 -0
  141. package/build/src/core/verbs/amend.js +8 -0
  142. package/build/src/core/verbs/bind.d.ts +3 -1
  143. package/build/src/core/verbs/bind.js +9 -1
  144. package/build/src/core/verbs/deliver.d.ts +2 -1
  145. package/build/src/core/verbs/deliver.js +4 -1
  146. package/build/src/core/verbs/placement.d.ts +2 -1
  147. package/build/src/core/verbs/placement.js +7 -4
  148. package/build/src/core/verbs/reintegrate.d.ts +2 -1
  149. package/build/src/core/verbs/reintegrate.js +4 -1
  150. package/build/src/debt/board.d.ts +10 -10
  151. package/build/src/debt/created-observation.d.ts +3 -3
  152. package/build/src/debt/document.d.ts +1 -1
  153. package/build/src/debt/index.d.ts +2 -24
  154. package/build/src/debt/index.js +11 -71
  155. package/build/src/debt/operation-types.d.ts +44 -3
  156. package/build/src/git/admission.js +18 -6
  157. package/build/src/git/integration.d.ts +4 -4
  158. package/build/src/git/integration.js +7 -1
  159. package/build/src/git/observe.d.ts +6 -4
  160. package/build/src/git/observe.js +18 -17
  161. package/build/src/git/reconcile.d.ts +20 -8
  162. package/build/src/git/reconcile.js +94 -45
  163. package/build/src/git/repository.d.ts +3 -1
  164. package/build/src/git/repository.js +26 -4
  165. package/build/src/git/scratch.d.ts +1 -1
  166. package/build/src/git/scratch.js +19 -18
  167. package/build/src/git/target-placement.d.ts +33 -7
  168. package/build/src/git/target-placement.js +67 -18
  169. package/build/src/git/target.d.ts +32 -0
  170. package/build/src/git/target.js +84 -0
  171. package/build/src/git/terminal-reconcile.d.ts +1 -1
  172. package/build/src/git/terminal-reconcile.js +34 -6
  173. package/build/src/index.d.ts +9 -7
  174. package/build/src/index.js +1 -1
  175. package/build/src/library/address.d.ts +1 -20
  176. package/build/src/library/address.js +3 -24
  177. package/build/src/library/akuma-creation.d.ts +2 -5
  178. package/build/src/library/akuma-creation.js +60 -44
  179. package/build/src/library/akumas.d.ts +3 -9
  180. package/build/src/library/akumas.js +12 -25
  181. package/build/src/library/bind.d.ts +21 -9
  182. package/build/src/library/bind.js +5 -1
  183. package/build/src/library/continuation.d.ts +130 -155
  184. package/build/src/library/continuation.js +1 -4
  185. package/build/src/library/contract-composition.d.ts +4 -9
  186. package/build/src/library/contract-composition.js +8 -12
  187. package/build/src/library/contract-creation.d.ts +1 -3
  188. package/build/src/library/contract-creation.js +2 -3
  189. package/build/src/library/contract-execution.d.ts +3 -5
  190. package/build/src/library/contract-execution.js +55 -96
  191. package/build/src/library/contract-outcomes.d.ts +2 -1
  192. package/build/src/library/contract-types.d.ts +5 -0
  193. package/build/src/library/contract-wait.d.ts +35 -0
  194. package/build/src/library/contract-wait.js +141 -0
  195. package/build/src/library/delivery.d.ts +13 -525
  196. package/build/src/library/delivery.js +1 -12
  197. package/build/src/library/input.js +2 -1
  198. package/build/src/library/invocation.d.ts +5 -1
  199. package/build/src/library/invocation.js +9 -2
  200. package/build/src/library/keiyaku.d.ts +7 -6
  201. package/build/src/library/keiyaku.js +12 -7
  202. package/build/src/library/outcome.d.ts +461 -12586
  203. package/build/src/library/outcome.js +15 -234
  204. package/build/src/library/reconcile.d.ts +12 -0
  205. package/build/src/library/reconcile.js +1 -0
  206. package/build/src/library/refusal.d.ts +251 -34
  207. package/build/src/library/refusal.js +10 -5
  208. package/build/src/library/selection.d.ts +9 -35
  209. package/build/src/library/selection.js +59 -129
  210. package/build/src/plugin/akuma-signals.d.ts +2 -2
  211. package/build/src/plugin/akuma-signals.js +2 -2
  212. package/build/src/plugin/public.d.ts +0 -7
  213. package/build/src/plugin/runtime.d.ts +2 -2
  214. package/build/src/plugin/runtime.js +4 -3
  215. package/build/src/protocol/attempt.js +7 -3
  216. package/build/src/protocol/bind.d.ts +18 -4
  217. package/build/src/protocol/bind.js +102 -35
  218. package/build/src/protocol/completion.d.ts +18 -331
  219. package/build/src/protocol/completion.js +17 -130
  220. package/build/src/protocol/deliver.d.ts +3 -3
  221. package/build/src/protocol/deliver.js +64 -74
  222. package/build/src/protocol/delivery-preview.d.ts +85 -28
  223. package/build/src/protocol/delivery-preview.js +34 -22
  224. package/build/src/protocol/execution-observation.d.ts +12 -9
  225. package/build/src/protocol/execution-observation.js +0 -1
  226. package/build/src/protocol/intent.d.ts +20 -50
  227. package/build/src/protocol/intent.js +37 -44
  228. package/build/src/protocol/operations.d.ts +299 -19
  229. package/build/src/protocol/operations.js +68 -27
  230. package/build/src/protocol/outcome.d.ts +1 -1
  231. package/build/src/protocol/placement.d.ts +2 -2
  232. package/build/src/protocol/placement.js +4 -3
  233. package/build/src/protocol/progress.d.ts +35 -2
  234. package/build/src/protocol/progress.js +12 -1
  235. package/build/src/protocol/read/observation.js +15 -4
  236. package/build/src/protocol/read/status.d.ts +9 -14
  237. package/build/src/protocol/read/status.js +15 -22
  238. package/build/src/protocol/reintegrate.d.ts +4 -3
  239. package/build/src/protocol/reintegrate.js +21 -5
  240. package/build/src/protocol/review.d.ts +9 -15
  241. package/build/src/protocol/review.js +2 -6
  242. package/build/src/protocol/run.d.ts +1 -1
  243. package/build/src/protocol/verify.d.ts +51 -0
  244. package/build/src/protocol/verify.js +128 -0
  245. package/build/src/runtime/proc/windows-launch.exe +0 -0
  246. package/build/src/verification/declaration.d.ts +5 -1
  247. package/build/src/verification/declaration.js +19 -2
  248. package/build/src/verification/execution.d.ts +5 -2
  249. package/build/src/verification/execution.js +48 -53
  250. package/build/src/verification/observation.d.ts +10 -6
  251. package/build/src/verification/observation.js +5 -2
  252. package/package.json +3 -3
  253. package/plugins/paseo/plugin/index.server.ts +3 -0
  254. package/plugins/paseo/plugin/server/attach.ts +42 -0
  255. package/plugins/paseo/plugin/server/mirror-identity.ts +51 -0
  256. package/plugins/paseo/plugin/server/model.ts +26 -0
  257. package/plugins/paseo/plugin/server/provider.ts +4 -6
  258. package/plugins/paseo/plugin/server/reopen.ts +4 -39
  259. package/plugins/pi/README.md +7 -12
  260. package/plugins/pi/akuma-tools.ts +3 -18
  261. package/skills/keiyaku/SKILL.md +14 -26
  262. package/skills/keiyaku-akuma/SKILL.md +64 -44
  263. package/skills/keiyaku-akuma/references/automation.md +13 -25
  264. package/skills/keiyaku-babysit/SKILL.md +1 -1
  265. package/skills/keiyaku-bind/SKILL.md +42 -29
  266. package/skills/keiyaku-debt/SKILL.md +13 -8
  267. package/skills/keiyaku-workflow/SKILL.md +57 -61
  268. package/build/src/akuma/allowed.d.ts +0 -23
  269. package/build/src/akuma/allowed.js +0 -63
  270. package/build/src/akuma/call-request.d.ts +0 -308
  271. package/build/src/akuma/call-request.js +0 -175
  272. package/build/src/akuma/heart/request-authority.d.ts +0 -16
  273. package/build/src/akuma/heart/request-authority.js +0 -140
  274. package/build/src/akuma/heart/request-rows.d.ts +0 -18
  275. package/build/src/akuma/heart/request-rows.js +0 -107
  276. package/build/src/akuma/request-lifecycle.d.ts +0 -42
  277. package/build/src/akuma/request-lifecycle.js +0 -197
  278. package/build/src/akuma/request-observation.d.ts +0 -45
  279. package/build/src/akuma/request-observation.js +0 -162
  280. package/build/src/akuma/request-rendezvous.d.ts +0 -32
  281. package/build/src/akuma/request-rendezvous.js +0 -189
  282. package/build/src/akuma/request-serve.d.ts +0 -16
  283. package/build/src/akuma/request-serve.js +0 -188
  284. package/build/src/akuma/request-wire.d.ts +0 -143
  285. package/build/src/akuma/request-wire.js +0 -146
  286. package/build/src/akuma/requests.d.ts +0 -20
  287. package/build/src/akuma/requests.js +0 -72
  288. package/build/src/akuma/selection-owner-port.d.ts +0 -14
  289. package/build/src/akuma/selection-owner-port.js +0 -54
  290. package/build/src/akuma/selection-request.d.ts +0 -305
  291. package/build/src/akuma/selection-request.js +0 -307
  292. package/build/src/body-requests.d.ts +0 -13
  293. package/build/src/body-requests.js +0 -131
  294. package/build/src/cli/square-identity.d.ts +0 -10
  295. package/build/src/cli/square-identity.js +0 -130
  296. package/build/src/debt/mutation-result.d.ts +0 -981
  297. package/build/src/debt/mutation-result.js +0 -109
  298. package/build/src/debt/mutation.d.ts +0 -424
  299. package/build/src/debt/mutation.js +0 -223
  300. package/build/src/library/contract-operations.d.ts +0 -382
  301. package/build/src/library/contract-operations.js +0 -300
@@ -2,21 +2,20 @@ import { akumaCallerFromEnvironment } from "../akuma-caller.js";
2
2
  import { CliUsageError, isBlankInput } from "../usage.js";
3
3
  import { readFile } from "node:fs/promises";
4
4
  import { resolve } from "node:path";
5
- import { squareSeat } from "../square-identity.js";
6
- import { emitPluginSignal } from "../../plugin/akuma-signals.js";
5
+ import { deliveryOwner } from "../delivery-identity.js";
7
6
  import { canonicalBirthCwd } from "../../akuma/call-input.js";
8
7
  import { Schema } from "../../akuma/index.js";
9
- import { executionChannel } from "../../akuma/requests.js";
10
8
  import { settings } from "../../settings.js";
11
- import { AkumaWorldScopeError } from "../../index.js";
12
- import { akumasWithExecution } from "../../library/akumas.js";
9
+ import { Akumas, AkumaWorldScopeError, } from "../../index.js";
10
+ import { Keiyaku } from "../../index.js";
13
11
  import { World } from "../../world.js";
14
12
  import { contractFromInput } from "../selectors.js";
15
13
  import { ActivityDriver } from "../activity.js";
16
14
  import { displayContext, emit, resultContext, writeJson, writeStderr, writeStdout, } from "../streams.js";
17
15
  import { callObservationStream } from "../render/akuma-activity.js";
16
+ import { contractWaitText } from "../render/contract-wait.js";
18
17
  import { askRawAnswer, callRawAnswer, historyRawAnswer, historyText, tellText, waitText, } from "../render/akuma-activity.js";
19
- import { askOutcome, askProgressStream, callOutcome, callObservationHead, forkOutcome, historyOutcome, killOutcome, renderCallText, renderFailedCallObservation, renderForkText, renderKillText, tellOutcome, waitedTellProgress, } from "../render/akuma.js";
18
+ import { askOutcome, askProgressStream, callOutcome, callObservationHead, forkOutcome, historyOutcome, killOutcome, renderCallText, renderFailedCallObservation, renderForkText, renderKillText, tellOutcome, } from "../render/akuma.js";
20
19
  export { isParsedAkumaCommand, renderAkumaHelp } from "./akuma-grammar.js";
21
20
  // ---------------------------------------------------------------------------
22
21
  // Leaf dispatch: acquisition, one public SDK invocation, direct rendering
@@ -28,7 +27,7 @@ async function settingsAt(root, home) {
28
27
  });
29
28
  }
30
29
  function akumas(input) {
31
- return akumasWithExecution(input.path, input.execution, { reportDiagnostic: writeStderr });
30
+ return Akumas.of(input.path, { reportDiagnostic: writeStderr });
32
31
  }
33
32
  async function schemaFromFile(path) {
34
33
  try {
@@ -50,34 +49,9 @@ async function promptBody(action, command, input) {
50
49
  throw new CliUsageError(`${action} requires a nonblank prompt`);
51
50
  return bytes;
52
51
  }
53
- /**
54
- * A generic integration initiator outranks any Square guess; otherwise the Square
55
- * edge selects. Identity selection is optional, so it never refuses the operation.
56
- */
57
- async function submittingInitiator(input) {
58
- const declared = input.environment.KEIYAKU_INITIATOR?.trim();
59
- if (declared !== undefined && declared !== "")
60
- return declared;
61
- try {
62
- return await squareSeat({ path: input.path, environment: input.environment }, { ...(input.signal === undefined ? {} : { signal: input.signal }) });
63
- }
64
- catch {
65
- return undefined;
66
- }
67
- }
68
- async function inputInitiator(input) {
69
- const initiator = await submittingInitiator(input);
70
- if (initiator === undefined)
71
- return {};
72
- // Identity preparation needs established plugin custody, not just a candidate.
73
- if (!(await World.established(input.path)))
74
- return { initiator };
75
- await emitPluginSignal({
76
- world: input.path,
77
- ...(input.settings === undefined ? {} : { settings: input.settings }),
78
- reportDiagnostic: (message) => writeStderr(message),
79
- }, { kind: "akuma.initiating", initiator });
80
- return { initiator };
52
+ function inputInitiator(input) {
53
+ const initiator = deliveryOwner(input.environment);
54
+ return initiator === undefined ? {} : { initiator };
81
55
  }
82
56
  function emitAnswer(body, exact) {
83
57
  if (exact)
@@ -89,10 +63,7 @@ function emitAnswer(body, exact) {
89
63
  async function runCall(command, input) {
90
64
  const body = command.prompt === undefined ? undefined : await promptBody("call", { prompt: command.prompt }, input);
91
65
  const schema = command.schema === undefined ? undefined : await schemaFromFile(command.schema);
92
- const declaredCaller = executionChannel(input.execution).kind === "body-request"
93
- ? undefined
94
- : await akumaCallerFromEnvironment(input.environment);
95
- // Establish the selected World before preparing the submitting Square route.
66
+ const declaredCaller = await akumaCallerFromEnvironment(input.environment);
96
67
  await World.at(input.path);
97
68
  const caller = akumas(input);
98
69
  const request = {
@@ -105,7 +76,6 @@ async function runCall(command, input) {
105
76
  ...(input.executionCwd === undefined ? {} : { cwd: input.executionCwd }),
106
77
  ...(input.contract === undefined ? {} : { contract: input.contract }),
107
78
  ...(command.alias === undefined ? {} : { alias: command.alias }),
108
- ...(command.allowed === undefined ? {} : { allowed: command.allowed }),
109
79
  ...(input.writableDirectories === undefined ? {} : { writableDirectories: input.writableDirectories }),
110
80
  ...(command.bare === undefined ? {} : { bare: command.bare }),
111
81
  ...(schema === undefined ? {} : { schema }),
@@ -192,10 +162,7 @@ async function runAsk(command, input) {
192
162
  const body = await promptBody("ask", command, input);
193
163
  const schema = command.schema === undefined ? undefined : await schemaFromFile(command.schema);
194
164
  const alias = inputAlias(command.akuma);
195
- const channel = executionChannel(input.execution);
196
- const progress = command.output === "text" && channel.kind === "local"
197
- ? askProgressStream(undefined, alias, resultContext())
198
- : undefined;
165
+ const progress = command.output === "text" ? askProgressStream(undefined, alias, resultContext()) : undefined;
199
166
  const driver = new ActivityDriver(process.stderr);
200
167
  try {
201
168
  const result = await akumas(input).ask({
@@ -222,8 +189,6 @@ async function runAsk(command, input) {
222
189
  });
223
190
  if (progress !== undefined)
224
191
  driver.conclude(progress.conclude(result).join("\n"));
225
- else if (command.output === "text" && channel.kind === "body-request")
226
- writeStderr(waitedTellProgress(result, alias, resultContext()));
227
192
  if (command.output === "json")
228
193
  writeJson(result);
229
194
  else
@@ -309,13 +274,12 @@ async function akumaInput(command, coordinates, workdir, runtime) {
309
274
  throw new TypeError("--add-dir requires a nonblank directory");
310
275
  return canonicalBirthCwd(resolve(coordinates.cwd, path));
311
276
  }));
312
- const execution = runtime.execution;
313
277
  const home = command.command === "call" ? runtime.home : undefined;
314
278
  const configuration = command.command === "call" ? await settingsAt(path, home) : undefined;
315
279
  if (command.command === "call" && command.contract !== undefined && coordinates.repo === undefined)
316
280
  throw new Error("call with Contract requires a resolved Repo");
317
281
  const contract = command.command === "call" && command.contract !== undefined
318
- ? contractFromInput(coordinates.repo, command.contract, execution).contract
282
+ ? contractFromInput(coordinates.repo, command.contract).contract
319
283
  : undefined;
320
284
  return {
321
285
  path,
@@ -327,12 +291,30 @@ async function akumaInput(command, coordinates, workdir, runtime) {
327
291
  ...(coordinates.repo === undefined ? {} : { repo: coordinates.repo }),
328
292
  environment: runtime.environment,
329
293
  readStdin: runtime.readStdin,
330
- execution,
331
294
  ...(runtime.signal === undefined ? {} : { signal: runtime.signal }),
332
295
  };
333
296
  }
334
297
  export async function runAkumaCommand(command, coordinates, workdir, runtime) {
335
298
  try {
299
+ if (command.command === "wait") {
300
+ const contracts = command.akuma.filter((selector) => selector.startsWith("kei/"));
301
+ if (contracts.length > 0) {
302
+ if (coordinates.repo === undefined)
303
+ throw new CliUsageError("Contract wait requires a repository");
304
+ const result = await Keiyaku.with().wait({
305
+ repo: coordinates.repo,
306
+ contracts,
307
+ ...(command.completion === undefined ? {} : { completion: command.completion }),
308
+ ...(command.timeoutMs === undefined ? {} : { timeoutMs: command.timeoutMs }),
309
+ ...(runtime.signal === undefined ? {} : { signal: runtime.signal }),
310
+ });
311
+ if (command.output === "json")
312
+ writeJson(result);
313
+ else
314
+ writeStdout(contractWaitText(result));
315
+ return result.kind === "missing" ? "refused" : "accepted";
316
+ }
317
+ }
336
318
  const input = await akumaInput(command, coordinates, workdir, runtime);
337
319
  switch (command.command) {
338
320
  case "call":
@@ -59,6 +59,12 @@ export type ParsedDeliver = Output & Readonly<{
59
59
  materializeConflict: boolean;
60
60
  overwrite: boolean;
61
61
  }>;
62
+ export type ParsedVerify = Output & Readonly<{
63
+ command: "verify";
64
+ contract?: string;
65
+ index?: number;
66
+ includeDirty: boolean;
67
+ }>;
62
68
  export type ParsedReview = Output & Actor & Readonly<{
63
69
  command: "review";
64
70
  contract?: string;
@@ -129,7 +135,7 @@ export type ParsedContractParts = Readonly<{
129
135
  output: "text" | "json";
130
136
  actor?: string;
131
137
  }>;
132
- export type ParsedContractCommand = ParsedBind | ParsedAmend | ParsedDeliver | ParsedReview | ParsedArc | ParsedAbandon | ParsedShow | ParsedStatus | ParsedLs | ParsedReconcile | ParsedNuke | ParsedSettings | ParsedRegion;
138
+ export type ParsedContractCommand = ParsedBind | ParsedAmend | ParsedDeliver | ParsedVerify | ParsedReview | ParsedArc | ParsedAbandon | ParsedShow | ParsedStatus | ParsedLs | ParsedReconcile | ParsedNuke | ParsedSettings | ParsedRegion;
133
139
  export type StatusCategory = "akuma" | "contract";
134
140
  export declare function parseContractCommand(parts: ParsedContractParts): ParsedContractCommand;
135
141
  export {};
@@ -129,6 +129,19 @@ function parseDeliver(parts) {
129
129
  output: parts.output,
130
130
  };
131
131
  }
132
+ function parseVerify(parts) {
133
+ const contract = parts.positionals[0];
134
+ const index = optionalFlag(parts.flags, "index");
135
+ if (index !== undefined && (!/^[1-9][0-9]*$/u.test(index) || !Number.isSafeInteger(Number(index))))
136
+ refuse("verify", "--index requires a positive safe integer");
137
+ return {
138
+ command: "verify",
139
+ ...(contract === undefined ? {} : { contract }),
140
+ ...(index === undefined ? {} : { index: Number(index) }),
141
+ includeDirty: parts.flags["include-dirty"] === true,
142
+ output: parts.output,
143
+ };
144
+ }
132
145
  function parseReview(parts) {
133
146
  if (Number(parts.flags.satisfied === true) + Number(parts.flags.unsatisfied === true) !== 1) {
134
147
  refuse("review", "review requires exactly one verdict flag");
@@ -318,6 +331,8 @@ export function parseContractCommand(parts) {
318
331
  return parseAmend(parts);
319
332
  case "deliver":
320
333
  return parseDeliver(parts);
334
+ case "verify":
335
+ return parseVerify(parts);
321
336
  case "review":
322
337
  return parseReview(parts);
323
338
  case "arc": {
@@ -21,7 +21,7 @@ export declare const CONTRACT_COMMAND_SPECS: {
21
21
  readonly "fork-of": "value";
22
22
  readonly json: "boolean";
23
23
  };
24
- readonly usage: "bind [--debt <debt/...>] [--target <ref> | --no-target] [--after <kei/...>]... [--gates <name,...>] [--actor <actor>] [--repo <path>] -\nbind --fork-of <kei/...> [--target <ref> | --no-target] [--actor <actor>] [--repo <path>]";
24
+ readonly usage: "bind [--debt <debt/...>] [--target <branch|kei/...> | --no-target] [--after <kei/...>]... [--gates <name,...>] [--actor <actor>] [--repo <path>] -\nbind --fork-of <kei/...> [--target <branch|kei/...> | --no-target] [--actor <actor>] [--repo <path>]";
25
25
  readonly purpose: "Create a Contract from stdin Markdown or copy an existing Contract as a starting point.";
26
26
  readonly details: string;
27
27
  };
@@ -55,6 +55,18 @@ export declare const CONTRACT_COMMAND_SPECS: {
55
55
  readonly purpose: "Submit work for a Contract and integrate it when its requirements are met.";
56
56
  readonly details: string;
57
57
  };
58
+ readonly verify: {
59
+ readonly positional: "optional";
60
+ readonly stdin: "none";
61
+ readonly flags: {
62
+ readonly index: "value";
63
+ readonly "include-dirty": "boolean";
64
+ readonly json: "boolean";
65
+ };
66
+ readonly usage: "verify [<contract>|@<contract>] [--index <n>] [--include-dirty] [--repo <path>]";
67
+ readonly purpose: "Execute independent Verification checks and record their evidence.";
68
+ readonly details: string;
69
+ };
58
70
  readonly review: {
59
71
  readonly positional: "optional";
60
72
  readonly stdin: "optional";
@@ -13,17 +13,19 @@ export const CONTRACT_COMMAND_SPECS = {
13
13
  "fork-of": "value",
14
14
  json: "boolean",
15
15
  },
16
- usage: "bind [--debt <debt/...>] [--target <ref> | --no-target] [--after <kei/...>]... [--gates <name,...>] [--actor <actor>] [--repo <path>] -\nbind --fork-of <kei/...> [--target <ref> | --no-target] [--actor <actor>] [--repo <path>]",
16
+ usage: "bind [--debt <debt/...>] [--target <branch|kei/...> | --no-target] [--after <kei/...>]... [--gates <name,...>] [--actor <actor>] [--repo <path>] -\nbind --fork-of <kei/...> [--target <branch|kei/...> | --no-target] [--actor <actor>] [--repo <path>]",
17
17
  purpose: "Create a Contract from stdin Markdown or copy an existing Contract as a starting point.",
18
18
  details: [
19
- "--target names one existing local branch literally; it is never created and never",
20
- "guessed. Omitting it binds to the current branch of the invocation worktree",
21
- "coordinate, or binds without a target on a detached committed HEAD. --no-target",
22
- "binds without a target on purpose, and is refused together with --target.",
23
- "A fork copies its source target when neither flag is given.",
19
+ "--target names an existing local branch or a complete active kei/... identity.",
20
+ "A Contract target lands into its appointed detached worktree, not its branch;",
21
+ "only its committed HEAD is used as the child's start. To name a branch beginning",
22
+ "kei/, use refs/heads/kei/.... Omitting --target selects the invocation worktree's",
23
+ "current branch, or no target on detached committed HEAD. --no-target explicitly",
24
+ "selects no target and cannot be combined with --target. A fork inherits its",
25
+ "source's exact target when neither flag is given, including its worktree identity.",
24
26
  "",
25
27
  "Gates are acceptance obligations checked at placement: reviewed awaits a",
26
- "satisfied review, verified awaits a passing Verification run.",
28
+ "satisfied review, verified awaits satisfied evidence for every Verification declaration.",
27
29
  "",
28
30
  "--gates <name,...> selects reviewed, verified, or named gate groups from Settings",
29
31
  "(keiyaku settings). A group expands into its gates; unknown names are rejected",
@@ -41,20 +43,18 @@ export const CONTRACT_COMMAND_SPECS = {
41
43
  " # <title>",
42
44
  " ## Context motivation, authority, baseline, and boundaries",
43
45
  " ## Objective one observable end state",
44
- " ## Design the approach, important decisions, and ordering",
45
- " leave implementation details to the person doing the work",
46
+ " ## Design settled design: decisions the implementation must follow",
46
47
  " ## Region narrowest justified intended writes for this approach, one pattern per line",
47
48
  " ## Criteria one or more ### <criterion> entries",
48
49
  " ## Verification optional fenced executor declarations",
49
50
  "",
50
- "Region accepts the narrowest justified intended writes for this approach, not every potentially",
51
- "involved file. Do not use broad directory fallbacks or redundant parent/child patterns. Patterns",
52
- "are fenced lines, list items, or bare lines; the three forms union. Put one repository-relative",
53
- "path pattern on each nonblank line. A trailing '/' is directory shorthand for 'path/**'.",
54
- "A pattern containing whitespace binds with a warning. A fence carries no",
55
- "info string or exactly 'txt'.",
51
+ "Region lists the narrowest writes this approach needs, not every file involved;",
52
+ "avoid broad directories and redundant parent/child patterns. Put one repository-relative",
53
+ "pattern per nonblank line: bare lines, list items, or fences (no info string, or",
54
+ "txt) are combined. A trailing '/' means 'path/**'. Whitespace in a pattern",
55
+ "binds with a warning.",
56
56
  "",
57
- "Verification runs only with the verified gate; without it the section is inert text.",
57
+ "Only verify runs Verification; without the verified gate the section is inert text.",
58
58
  "Verification uses one or more closed bash, zsh, or pwsh fences. Its fence",
59
59
  "may add timeout=<integer><ms|s|m|h>; the section contains no other prose.",
60
60
  "Unknown ## sections are retained as extensions; reserved section names are refused.",
@@ -67,17 +67,13 @@ export const CONTRACT_COMMAND_SPECS = {
67
67
  usage: "amend [<contract>|@<contract>] [--after <kei/...> [--after <kei/...>]... | --clear-after] [--gates <name,...>] [--actor <actor>] [--repo <path>] [-]",
68
68
  purpose: "Change a Contract's document, prerequisites, or acceptance gates.",
69
69
  details: [
70
- "Gates are acceptance obligations checked at placement: reviewed awaits a",
71
- "satisfied review, verified awaits a passing Verification run.",
72
- "",
73
- "--gates <name,...> replaces gates using reviewed, verified, or named gate groups",
74
- "from Settings (keiyaku settings). A group expands into its gates; unknown names",
75
- "are rejected with the known names listed. Custom gates must be declared in a",
76
- "configured group. Duplicates are removed in first-seen order.",
77
- "Names match ^[a-z][a-z0-9-]{0,63}$.",
78
- 'Omitting --gates leaves gates unchanged; --gates "" clears them.',
70
+ "Gates are checked at integration: reviewed needs a satisfied review;",
71
+ "verified needs satisfied evidence for every declaration. --gates <name,...> replaces them with",
72
+ "reviewed, verified, or configured groups (see keiyaku settings).",
73
+ 'Omitting --gates keeps them; --gates "" clears them.',
79
74
  "",
80
- " ## Context|Objective|Design|Region|Criteria|Verification|<extension> (replace, or add new extension)",
75
+ "stdin is an amendment; each heading is one edit:",
76
+ " ## Context|Objective|Design|Region|Criteria|Verification|<extension> (replace, or add a new extension)",
81
77
  " ## Replace: Context|Objective|Design|Region|Criteria|Verification|<extension>",
82
78
  " ## Append: Context|Objective|Design|Criteria|<extension>",
83
79
  " ## Add: Criteria|<new-extension-title>",
@@ -100,22 +96,61 @@ export const CONTRACT_COMMAND_SPECS = {
100
96
  usage: "deliver [<contract>|@<contract>] [--message <text>] [--include-dirty] [--materialize-conflict] [--overwrite] [--repo <path>]\ndeliver [<contract>|@<contract>] --dry-run [--include-dirty] [--show-diff] [--repo <path>]",
101
97
  purpose: "Submit work for a Contract and integrate it when its requirements are met.",
102
98
  details: [
103
- "The Contract, not the current Arc, sets what delivery must satisfy. An Arc records progress; it does not narrow acceptance.",
104
- "With the verified gate, delivery runs Verification or reuses current satisfied evidence.",
105
- "Verification, integration, and cleanup progress appears on stderr; stdout contains one final result.",
106
- "By default, delivery uses HEAD. --include-dirty includes all non-ignored worktree changes, staged or not; it leaves your branch and index unchanged, so staging or committing is unnecessary.",
107
- "Repeating delivery with unchanged work resumes unfinished verification or integration. Changed work replaces the candidate.",
108
- "Delivery requests integration. If prerequisites and gates pass, it integrates now and accepts the Contract; otherwise the candidate remains waiting.",
109
- "Only changed candidate work invalidates earlier review. If Verification did not finish, repeating delivery resumes that candidate; --overwrite replaces it.",
110
- "Delivery never counts as an independent review verdict.",
111
- "--dry-run observes the candidate, preparation conflicts, standing Verification evidence and target followability without submitting work. It never runs Verification or hooks, places, reconciles, settles, or continues dependents. Real delivery observes again; a prepared candidate is not a promise of acceptance.",
112
- "--show-diff includes the proposed diff and requires --dry-run. --message, --materialize-conflict and --overwrite are refused with --dry-run.",
113
- "Preview may create ref-free Git objects and a transient private index; refs, the real index, worktree bytes and worktree registrations are preserved.",
114
- "Content identity names the change's content hash, never a commit; it survives rebase and Git cannot look it up.",
99
+ "Delivery is judged against the whole Contract, not the current Arc. It uses",
100
+ "HEAD and consumes standing gate evidence. If prerequisites and every gate",
101
+ "requirement pass, it integrates and accepts now; otherwise the candidate waits.",
102
+ "Delivery never runs Verification or counts as a review.",
103
+ "",
104
+ "Repeating delivery with unchanged work resumes unfinished integration.",
105
+ "Changed work replaces the candidate and invalidates earlier review.",
106
+ "Identical content keeps review across rebase or target movement.",
107
+ "",
108
+ "Progress goes to stderr; stdout carries one final result. Ctrl-C requests a",
109
+ "stop and waits for the final receipt; it does not roll back admitted work.",
110
+ "Content identity is a content hash, not a commit: it survives rebase, and Git",
111
+ "cannot look it up.",
112
+ "",
113
+ " --include-dirty Include all non-ignored changes, staged or not;",
114
+ " capturing them leaves your branch and index unchanged.",
115
+ " --message Set the delivery commit's subject.",
116
+ " --dry-run Preview candidate, conflicts, standing evidence and",
117
+ " target followability. No Verification, hooks or",
118
+ " integration; refs, index and worktrees stay untouched.",
119
+ " Real delivery checks again; preview promises no acceptance.",
120
+ " --show-diff Include the proposed diff; requires --dry-run.",
121
+ " --materialize-conflict Write the observed conflict as an uncommitted merge.",
122
+ " With --include-dirty, preserve current changes first.",
123
+ " --overwrite Bypass reuse of a pending candidate.",
115
124
  "",
116
- " --materialize-conflict Write the observed integration conflict into the worktree as an uncommitted merge.",
117
- " With --include-dirty, current non-ignored changes are preserved first.",
118
- " --overwrite Replace a candidate whose Verification has not finished.",
125
+ "--message, --materialize-conflict and --overwrite are refused with --dry-run.",
126
+ ].join("\n"),
127
+ },
128
+ verify: {
129
+ positional: "optional",
130
+ stdin: "none",
131
+ flags: { index: "value", "include-dirty": "boolean", json: "boolean" },
132
+ usage: "verify [<contract>|@<contract>] [--index <n>] [--include-dirty] [--repo <path>]",
133
+ purpose: "Execute independent Verification checks and record their evidence.",
134
+ details: [
135
+ "Requires an active Contract with the verified gate and Verification declarations.",
136
+ "Omitted selection uses the exact appointed worktree's Contract context.",
137
+ "--index selects one declaration by its current one-based position; it must be",
138
+ "a positive safe integer written with digits only, with no leading zero.",
139
+ "Omitting --index runs all declarations. An out-of-range index refuses before execution.",
140
+ "",
141
+ "Each selected declaration always executes in its own clean scratch, including",
142
+ "when satisfied evidence already exists. Setup and cleanup run independently;",
143
+ "checks cannot share scratch files. Normal failure or timeout records an",
144
+ "unsatisfied verdict and allows remaining checks to run. Operational stops",
145
+ "and cancellation retain earlier admitted evidence without inventing a verdict.",
146
+ "",
147
+ "--include-dirty captures all non-ignored worktree changes without changing",
148
+ "the real index or branch. Checks cover the exact prospective integration.",
149
+ "Verify admits no delivery. After execution it requests ordinary completion;",
150
+ "only an already-delivered candidate with all requirements met can integrate.",
151
+ "The receipt names each check's execution, verdict, admission or reuse, and stop.",
152
+ "Progress goes to stderr; stdout carries one final result. Ctrl-C requests",
153
+ "a stop and waits for the final receipt, preserving admitted evidence.",
119
154
  ].join("\n"),
120
155
  },
121
156
  review: {
@@ -128,6 +163,7 @@ export const CONTRACT_COMMAND_SPECS = {
128
163
  "A review checks the whole Contract, not just one Arc. After delivery it checks the candidate; before delivery it checks the current Contract and worktree, but cannot integrate.",
129
164
  "--satisfied means every acceptance criterion is met. It records the verdict and requests integration; if the candidate, prerequisites, and gates are ready, this invocation integrates and accepts the Contract. Otherwise the Contract stays active.",
130
165
  "--unsatisfied records what is missing and does not request integration.",
166
+ "Review consumes standing gate evidence and never executes Verification.",
131
167
  "--summary gives the conclusion and evidence for --satisfied, or the specific blocker for --unsatisfied.",
132
168
  "Progress appears on stderr; stdout contains one final result.",
133
169
  ].join("\n"),
@@ -230,55 +266,26 @@ export function renderContractHelp(command) {
230
266
  const spec = CONTRACT_COMMAND_SPECS[command];
231
267
  if (command === "settings") {
232
268
  return [
233
- "Show effective Settings — the merged read-only view of:",
269
+ "Show effective Settings (read-only), merged from:",
234
270
  " user ~/.keiyaku/settings.json",
235
271
  " project <WorldRoot>/.keiyaku/settings.json",
236
- "A project record wholly shadows the same-name user record.",
272
+ "A project record wholly shadows the same-name user record. Edit the files",
273
+ "directly; there is no write command.",
237
274
  "",
238
- "Shape: namespace -> entry -> JSON value. There is no write",
239
- "command; edit the files directly.",
275
+ usageLine(spec.usage),
240
276
  "",
241
277
  "Recognized settings:",
242
- " gates named gate groups selected by bind and amend",
243
- " worktree commands run when worktrees are created or destroyed",
244
- " git.requireBranchesToBeUpToDate whether delivery and its preview require up-to-date target branches",
245
- " providers the available Akuma and how each is run",
246
- "",
247
- "Each entry is validated by the feature that reads it. A rejected",
248
- "value's diagnostic states the expected shape.",
278
+ " gates named gate groups for bind/amend --gates",
279
+ " worktree commands run when Contract worktrees are created or destroyed",
280
+ " git.requireBranchesToBeUpToDate whether delivery and preview require an up-to-date target",
281
+ " providers Akuma providers and how each is run",
249
282
  "",
250
283
  "Akuma definitions are Markdown files, one per name:",
251
284
  " user ~/.keiyaku/akumas/<name>.md",
252
285
  " project <WorldRoot>/.keiyaku/akumas/<name>.md",
253
- "A project file wholly shadows the same-name user file. YAML",
254
- "frontmatter selects the provider and may declare base, model,",
255
- "effort, network, allowed, systemPromptMode, and description; the body is",
256
- "an optional system prompt.",
257
- "",
258
- "Local Paseo provider in settings.json:",
259
- ' { "providers": { "paseo": {',
260
- ' "kind": "paseo",',
261
- ' "config": { "url": "ws://127.0.0.1:6767/ws", "provider": "claude" }',
262
- " } } }",
263
- "The native provider id is bare (claude, codex, pi), not provider/model.",
264
- "Example .keiyaku/akumas/paseo-worker.md frontmatter:",
265
- " ---",
266
- " provider: paseo",
267
- " model: <native-model-id>",
268
- " effort: high",
269
- " ---",
270
- "Model and effort must be offered by the selected native provider;",
271
- "effort names its native thinking option id.",
272
- 'PASEO_PASSWORD=<password> keiyaku call paseo-worker "<prompt>"',
273
- "Paseo must already be running locally. Resume keeps its live native",
274
- "runtime; after Paseo native reload/restart create a fresh Akuma.",
275
- "Observed busy agents refuse; native steer still has a check/send race.",
276
- "Explicit control cancels native current execution session-wide and may",
277
- "affect concurrent human work. Normal completion only retires the client",
278
- "and its sockets; it never cancels later work or closes the native runtime.",
279
- "Socket closure does not prove native cancellation succeeded.",
280
- "",
281
- usageLine(spec.usage),
286
+ "Project wins. Frontmatter: provider, base, model, effort, network,",
287
+ "systemPromptMode, description. The body is an optional system prompt.",
288
+ "Provider setup: see README Configuration.",
282
289
  ].join("\n");
283
290
  }
284
291
  const help = `${spec.purpose}\n\n${usageLine(spec.usage)}`;
@@ -1,10 +1,8 @@
1
- import { executionChannel } from "../../akuma/requests.js";
2
1
  import { Akumas, Keiyaku, KeiyakuError, kanshiCategory, listArchetypeDefinitions, nuke } from "../../index.js";
3
2
  import { kanshi, selectRegion } from "../../kanshi/index.js";
4
3
  import { observeNamedAddress, resolveNamedAddress } from "../../library/address.js";
5
- import { composeContractLibrary, observeKeiyaku } from "../../library/contract-composition.js";
4
+ import { observeKeiyaku } from "../../library/contract-composition.js";
6
5
  import { validateArcMarkdown, validateContractMarkdown } from "../../library/input.js";
7
- import { createKeiyakuHandle } from "../../library/keiyaku.js";
8
6
  import { SettingsError, settings } from "../../settings.js";
9
7
  import { akumaCallerFromEnvironment } from "../akuma-caller.js";
10
8
  import { Debts } from "../../debt/index.js";
@@ -35,17 +33,6 @@ async function settingsAt(root, home) {
35
33
  ...(home === undefined ? {} : { home }),
36
34
  });
37
35
  }
38
- /**
39
- * The process edge loads one Settings value and hands it to the private composition.
40
- * A forwarded preview/deliver/review is served by its parent, which loads its own.
41
- */
42
- async function contractSettings(command, execution, world, home) {
43
- const forwarded = executionChannel(execution).kind === "body-request" &&
44
- (command.command === "deliver" || command.command === "review");
45
- if (forwarded)
46
- return undefined;
47
- return await settingsAt(world ?? undefined, home);
48
- }
49
36
  function draftWarning(error) {
50
37
  return { warning: `bind draft could not be preserved: ${error instanceof Error ? error.message : String(error)}` };
51
38
  }
@@ -201,6 +188,22 @@ async function runDeliver(command, runtime, seat) {
201
188
  }
202
189
  return await finishContractAnswer(answer, command.output, deliverRefusalProjection);
203
190
  }
191
+ async function runVerify(command, runtime, seat) {
192
+ const driver = command.output === "text" ? await runtime.progress() : undefined;
193
+ let answer;
194
+ try {
195
+ answer = await seat.contract.verify({
196
+ ...(command.index === undefined ? {} : { index: command.index }),
197
+ includeDirty: command.includeDirty,
198
+ ...(runtime.signal === undefined ? {} : { signal: runtime.signal }),
199
+ }, { ...(driver === undefined ? {} : { observe: driver.observe }) });
200
+ }
201
+ finally {
202
+ if (driver !== undefined)
203
+ await driver.finish().catch(() => undefined);
204
+ }
205
+ return await finishContractAnswer(answer, command.output, deliverRefusalProjection);
206
+ }
204
207
  async function runReview(command, runtime, seat) {
205
208
  const summary = command.summaryFromStdin === true ? await runtime.readStdin() : command.summary;
206
209
  if (command.summaryFromStdin === true && isBlankInput(summary ?? ""))
@@ -247,11 +250,11 @@ async function runAbandon(command, seat) {
247
250
  return await finishContractAnswer(answer, command.output);
248
251
  }
249
252
  async function runContractMutation(command, input) {
250
- const { execution, configuration, runtime } = input;
251
- const actor = executionChannel(execution).kind === "local" && ["deliver", "review"].includes(command.command)
253
+ const { configuration, runtime } = input;
254
+ const actor = ["deliver", "verify", "review"].includes(command.command)
252
255
  ? actorFromEdge(undefined, runtime.environment)
253
256
  : undefined;
254
- const library = composeContractLibrary(execution, createKeiyakuHandle, {
257
+ const library = Keiyaku.with({
255
258
  ...(configuration === undefined ? {} : { settings: configuration }),
256
259
  ...(actor === undefined ? {} : { actor }),
257
260
  });
@@ -263,6 +266,8 @@ async function runContractMutation(command, input) {
263
266
  return await runAmend(command, input, seat);
264
267
  case "deliver":
265
268
  return await runDeliver(command, input.runtime, seat);
269
+ case "verify":
270
+ return await runVerify(command, input.runtime, seat);
266
271
  case "review":
267
272
  return await runReview(command, input.runtime, seat);
268
273
  case "arc":
@@ -501,12 +506,10 @@ export async function runContractHistoryCommand(command, coordinates) {
501
506
  }
502
507
  return emit(command.output, history, () => renderContractHistory(history, { full: command.full }), "accepted");
503
508
  }
504
- async function runReconcile(command, coordinates, execution, home) {
509
+ async function runReconcile(command, coordinates, home) {
505
510
  const repo = requiredRepo(coordinates);
506
- const configuration = await contractSettings(command, execution, coordinates.world, home);
507
- const library = composeContractLibrary(execution, createKeiyakuHandle, {
508
- ...(configuration === undefined ? {} : { settings: configuration }),
509
- });
511
+ const configuration = await settingsAt(coordinates.world ?? undefined, home);
512
+ const library = Keiyaku.with({ settings: configuration });
510
513
  let report;
511
514
  if (command.contract === undefined) {
512
515
  report = await library.reconcile({ repo, retryHooks: command.retryHooks });
@@ -530,7 +533,6 @@ async function runReconcile(command, coordinates, execution, home) {
530
533
  return reconcileHasFailure(report) ? "failed" : "accepted";
531
534
  }
532
535
  export async function runContractCommand(command, coordinates, runtime) {
533
- const execution = runtime.execution;
534
536
  const home = runtime.home;
535
537
  switch (command.command) {
536
538
  case "settings":
@@ -546,13 +548,12 @@ export async function runContractCommand(command, coordinates, runtime) {
546
548
  case "region":
547
549
  return await runRegion(command, coordinates);
548
550
  case "reconcile":
549
- return await runReconcile(command, coordinates, execution, home);
551
+ return await runReconcile(command, coordinates, home);
550
552
  default: {
551
- const configuration = await contractSettings(command, execution, coordinates.world, home);
553
+ const configuration = await settingsAt(coordinates.world ?? undefined, home);
552
554
  return await runContractMutation(command, {
553
555
  coordinates,
554
556
  runtime,
555
- execution,
556
557
  ...(configuration === undefined ? {} : { configuration }),
557
558
  });
558
559
  }