@astrosheep/keiyaku 4.1.0 → 4.1.2

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 (278) hide show
  1. package/README.md +1 -1
  2. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku/SKILL.md +3 -0
  3. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-akuma/SKILL.md +3 -0
  4. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-workflow/SKILL.md +3 -6
  5. package/build/src/akuma/akuma-errors.d.ts +6 -0
  6. package/build/src/akuma/akuma-errors.js +9 -0
  7. package/build/src/akuma/akuma-handle.d.ts +39 -0
  8. package/build/src/akuma/akuma-handle.js +263 -0
  9. package/build/src/akuma/akuma-observe.d.ts +19 -0
  10. package/build/src/akuma/akuma-observe.js +74 -0
  11. package/build/src/akuma/akuma-product-symbols.d.ts +1 -0
  12. package/build/src/akuma/akuma-product-symbols.js +1 -0
  13. package/build/src/akuma/akuma-product.d.ts +18 -0
  14. package/build/src/akuma/akuma-product.js +154 -0
  15. package/build/src/akuma/akuma.d.ts +37 -81
  16. package/build/src/akuma/akuma.js +39 -447
  17. package/build/src/akuma/allowed.d.ts +1 -0
  18. package/build/src/akuma/allowed.js +6 -0
  19. package/build/src/akuma/archetype.js +8 -5
  20. package/build/src/akuma/body-supervisor.d.ts +26 -0
  21. package/build/src/akuma/body-supervisor.js +89 -0
  22. package/build/src/akuma/body.d.ts +45 -4
  23. package/build/src/akuma/body.js +145 -35
  24. package/build/src/akuma/coordinate.js +17 -7
  25. package/build/src/akuma/heart/facts.js +1 -1
  26. package/build/src/akuma/heart/index.d.ts +1 -1
  27. package/build/src/akuma/heart/index.js +2 -4
  28. package/build/src/akuma/heart/request-authority.js +4 -4
  29. package/build/src/akuma/heart/request-rows.js +27 -16
  30. package/build/src/akuma/heart/rows.js +79 -41
  31. package/build/src/akuma/heart/soul.js +1 -1
  32. package/build/src/akuma/heart/storage.d.ts +1 -0
  33. package/build/src/akuma/heart/storage.js +76 -11
  34. package/build/src/akuma/heart/tells.js +35 -18
  35. package/build/src/akuma/heart/timeline.js +19 -11
  36. package/build/src/akuma/identity.d.ts +1 -0
  37. package/build/src/akuma/identity.js +1 -0
  38. package/build/src/akuma/index.d.ts +3 -3
  39. package/build/src/akuma/index.js +1 -1
  40. package/build/src/akuma/nuke.js +106 -14
  41. package/build/src/akuma/projection-read.d.ts +17 -0
  42. package/build/src/akuma/projection-read.js +135 -0
  43. package/build/src/akuma/projection.d.ts +1 -16
  44. package/build/src/akuma/projection.js +77 -154
  45. package/build/src/akuma/provider-recipe.js +11 -5
  46. package/build/src/akuma/provider.js +105 -62
  47. package/build/src/akuma/providers/acp/config.js +5 -6
  48. package/build/src/akuma/providers/acp/core.js +17 -10
  49. package/build/src/akuma/providers/acp/events.js +38 -29
  50. package/build/src/akuma/providers/acp/index.js +13 -9
  51. package/build/src/akuma/providers/claude/events.js +8 -12
  52. package/build/src/akuma/providers/claude/index.d.ts +1 -0
  53. package/build/src/akuma/providers/claude/index.js +55 -26
  54. package/build/src/akuma/providers/claude/input.js +6 -2
  55. package/build/src/akuma/providers/codex-app-server/events.js +61 -36
  56. package/build/src/akuma/providers/codex-app-server/index.js +25 -13
  57. package/build/src/akuma/providers/grok-build/index.js +22 -25
  58. package/build/src/akuma/providers/index.js +2 -18
  59. package/build/src/akuma/providers/opencode-sdk/events.js +32 -18
  60. package/build/src/akuma/providers/opencode-sdk/index.js +26 -17
  61. package/build/src/akuma/providers/opencode-sdk/session.js +21 -5
  62. package/build/src/akuma/providers/pi/events.js +26 -19
  63. package/build/src/akuma/providers/pi/index.js +58 -40
  64. package/build/src/akuma/publication.js +9 -9
  65. package/build/src/akuma/request-execution.d.ts +6 -0
  66. package/build/src/akuma/request-execution.js +86 -0
  67. package/build/src/akuma/request-serve.d.ts +12 -1
  68. package/build/src/akuma/request-serve.js +19 -122
  69. package/build/src/akuma/request-wire.d.ts +2 -2
  70. package/build/src/akuma/request-wire.js +75 -102
  71. package/build/src/akuma/requests.js +2 -2
  72. package/build/src/akuma/{body-turn.d.ts → turn-drive.d.ts} +2 -25
  73. package/build/src/akuma/{body-turn.js → turn-drive.js} +20 -103
  74. package/build/src/akuma-body.js +6 -5
  75. package/build/src/body/amend.d.ts +4 -1
  76. package/build/src/body/amend.js +14 -6
  77. package/build/src/body/decode.js +2 -4
  78. package/build/src/body/envelope.js +2 -4
  79. package/build/src/body/region.d.ts +1 -2
  80. package/build/src/body/region.js +2 -70
  81. package/build/src/body/render.js +17 -12
  82. package/build/src/body/shape.js +1 -7
  83. package/build/src/cli/accepted.d.ts +1 -1
  84. package/build/src/cli/accepted.js +8 -1
  85. package/build/src/cli/commands/akuma-invoke.js +18 -6
  86. package/build/src/cli/commands/akuma.d.ts +0 -6
  87. package/build/src/cli/commands/akuma.js +11 -24
  88. package/build/src/cli/commands/amend.d.ts +2 -2
  89. package/build/src/cli/commands/amend.js +2 -4
  90. package/build/src/cli/commands/bind.d.ts +4 -4
  91. package/build/src/cli/commands/bind.js +16 -6
  92. package/build/src/cli/commands/contract-invoke.d.ts +25 -0
  93. package/build/src/cli/commands/contract-invoke.js +193 -0
  94. package/build/src/cli/commands/contract.d.ts +109 -10
  95. package/build/src/cli/commands/contract.js +339 -16
  96. package/build/src/cli/commands/install.d.ts +1 -1
  97. package/build/src/cli/commands/install.js +23 -15
  98. package/build/src/cli/commands/task-invoke.js +187 -67
  99. package/build/src/cli/commands/task-query.js +48 -24
  100. package/build/src/cli/commands/task.js +150 -38
  101. package/build/src/cli/coordinates.js +2 -4
  102. package/build/src/cli/invoke.js +92 -208
  103. package/build/src/cli/main.js +4 -2
  104. package/build/src/cli/parse.d.ts +3 -90
  105. package/build/src/cli/parse.js +27 -233
  106. package/build/src/cli/render/akuma-activity.d.ts +38 -0
  107. package/build/src/cli/render/akuma-activity.js +362 -0
  108. package/build/src/cli/render/akuma-tool-command.js +6 -7
  109. package/build/src/cli/render/akuma-tool.js +10 -8
  110. package/build/src/cli/render/akuma.d.ts +1 -1
  111. package/build/src/cli/render/akuma.js +61 -353
  112. package/build/src/cli/render/audit.js +5 -15
  113. package/build/src/cli/render/board.d.ts +1 -0
  114. package/build/src/cli/render/board.js +17 -0
  115. package/build/src/cli/render/catalog.js +81 -8
  116. package/build/src/cli/render/contract-history.d.ts +2 -0
  117. package/build/src/cli/render/contract-history.js +83 -0
  118. package/build/src/cli/render/contract-observation.d.ts +10 -0
  119. package/build/src/cli/render/contract-observation.js +58 -0
  120. package/build/src/cli/render/contract.d.ts +1 -2
  121. package/build/src/cli/render/contract.js +41 -142
  122. package/build/src/cli/render/kanshi.js +239 -215
  123. package/build/src/cli/render/receipt.js +2 -9
  124. package/build/src/cli/render/refusal.js +10 -15
  125. package/build/src/cli/render/region.js +22 -6
  126. package/build/src/cli/render/settings.js +4 -4
  127. package/build/src/cli/render/task.js +34 -14
  128. package/build/src/cli/render/terminal.js +16 -5
  129. package/build/src/cli/result.d.ts +3 -3
  130. package/build/src/cli/runtime.d.ts +6 -1
  131. package/build/src/cli/runtime.js +84 -63
  132. package/build/src/cli/selectors.js +2 -4
  133. package/build/src/cli/usage.js +6 -5
  134. package/build/src/contract-worktree.d.ts +1 -23
  135. package/build/src/contract-worktree.js +79 -155
  136. package/build/src/coordination/durable-file.js +7 -3
  137. package/build/src/coordination/sqlite-transaction-lock.js +29 -12
  138. package/build/src/core/facts/codec.js +7 -3
  139. package/build/src/core/facts/types.d.ts +1 -1
  140. package/build/src/core/subject.js +16 -9
  141. package/build/src/core/verbs/abandon.d.ts +1 -1
  142. package/build/src/core/verbs/abandon.js +1 -1
  143. package/build/src/core/verbs/amend.d.ts +1 -1
  144. package/build/src/core/verbs/amend.js +7 -7
  145. package/build/src/core/verbs/attestation.js +4 -1
  146. package/build/src/core/verbs/bind.d.ts +1 -1
  147. package/build/src/core/verbs/bind.js +1 -1
  148. package/build/src/core/verbs/placement.d.ts +1 -1
  149. package/build/src/core/verbs/placement.js +10 -8
  150. package/build/src/dispatch/index.js +8 -6
  151. package/build/src/duration.js +5 -1
  152. package/build/src/git/admission.js +5 -3
  153. package/build/src/git/hooks.d.ts +8 -0
  154. package/build/src/git/hooks.js +63 -14
  155. package/build/src/git/identity.js +1 -4
  156. package/build/src/git/integration.d.ts +2 -3
  157. package/build/src/git/integration.js +32 -39
  158. package/build/src/git/nuke.d.ts +1 -1
  159. package/build/src/git/nuke.js +110 -57
  160. package/build/src/git/observe.d.ts +13 -1
  161. package/build/src/git/observe.js +51 -44
  162. package/build/src/git/process.js +4 -2
  163. package/build/src/git/read-observation.js +10 -8
  164. package/build/src/git/reconcile.d.ts +22 -2
  165. package/build/src/git/reconcile.js +38 -274
  166. package/build/src/git/repository.d.ts +2 -0
  167. package/build/src/git/repository.js +13 -22
  168. package/build/src/git/scratch.d.ts +8 -5
  169. package/build/src/git/scratch.js +29 -2
  170. package/build/src/git/target-placement.d.ts +9 -10
  171. package/build/src/git/target-placement.js +59 -62
  172. package/build/src/git/tender.js +13 -46
  173. package/build/src/git/terminal-reconcile.d.ts +21 -0
  174. package/build/src/git/terminal-reconcile.js +278 -0
  175. package/build/src/git/terminal-seal.js +15 -12
  176. package/build/src/git/tree.js +5 -2
  177. package/build/src/git/workspace.d.ts +24 -2
  178. package/build/src/git/workspace.js +120 -16
  179. package/build/src/identity/coordinates.js +3 -1
  180. package/build/src/identity/selector.js +6 -3
  181. package/build/src/kanshi/fleet.d.ts +6 -0
  182. package/build/src/kanshi/fleet.js +27 -0
  183. package/build/src/kanshi/index.d.ts +1 -1
  184. package/build/src/kanshi/read.js +60 -48
  185. package/build/src/kanshi/report.d.ts +11 -23
  186. package/build/src/kanshi/select.js +25 -24
  187. package/build/src/library/address.d.ts +2 -1
  188. package/build/src/library/address.js +7 -8
  189. package/build/src/library/akuma-creation.js +20 -12
  190. package/build/src/library/audit.d.ts +0 -1
  191. package/build/src/library/audit.js +1 -2
  192. package/build/src/library/bind.d.ts +53 -5
  193. package/build/src/library/bind.js +98 -22
  194. package/build/src/library/catalog.d.ts +1 -0
  195. package/build/src/library/catalog.js +6 -3
  196. package/build/src/library/configuration.js +3 -1
  197. package/build/src/library/continuation.d.ts +15 -4
  198. package/build/src/library/continuation.js +24 -16
  199. package/build/src/library/contract-bind.d.ts +26 -0
  200. package/build/src/library/contract-bind.js +106 -0
  201. package/build/src/library/contract-operations.d.ts +77 -0
  202. package/build/src/library/contract-operations.js +130 -0
  203. package/build/src/library/contract-types.d.ts +95 -0
  204. package/build/src/library/contract-types.js +1 -0
  205. package/build/src/library/contract.d.ts +19 -154
  206. package/build/src/library/contract.js +46 -261
  207. package/build/src/library/fleet.d.ts +1 -1
  208. package/build/src/library/fleet.js +19 -11
  209. package/build/src/library/input.d.ts +2 -0
  210. package/build/src/library/input.js +14 -0
  211. package/build/src/library/keiyaku.d.ts +8 -7
  212. package/build/src/library/keiyaku.js +3 -3
  213. package/build/src/library/nuke.js +14 -5
  214. package/build/src/library/reconcile.d.ts +9 -4
  215. package/build/src/library/reconcile.js +30 -24
  216. package/build/src/library/refusal.d.ts +13 -5
  217. package/build/src/library/refusal.js +7 -0
  218. package/build/src/library/region.d.ts +8 -7
  219. package/build/src/library/region.js +31 -11
  220. package/build/src/library/repo.js +2 -2
  221. package/build/src/markdown/lex.js +9 -2
  222. package/build/src/markdown/parse.js +11 -7
  223. package/build/src/markdown/query.js +4 -2
  224. package/build/src/protocol/amend.js +3 -1
  225. package/build/src/protocol/attempt.d.ts +7 -3
  226. package/build/src/protocol/attempt.js +9 -5
  227. package/build/src/protocol/audit.d.ts +1 -1
  228. package/build/src/protocol/audit.js +4 -14
  229. package/build/src/protocol/bind.d.ts +19 -6
  230. package/build/src/protocol/bind.js +28 -13
  231. package/build/src/protocol/completion.d.ts +0 -1
  232. package/build/src/protocol/completion.js +1 -3
  233. package/build/src/protocol/deliver.d.ts +1 -3
  234. package/build/src/protocol/deliver.js +15 -39
  235. package/build/src/protocol/intent.d.ts +1 -0
  236. package/build/src/protocol/intent.js +9 -7
  237. package/build/src/protocol/operations.d.ts +3 -7
  238. package/build/src/protocol/operations.js +5 -3
  239. package/build/src/protocol/placement.d.ts +0 -1
  240. package/build/src/protocol/placement.js +6 -6
  241. package/build/src/protocol/read/observation.d.ts +11 -0
  242. package/build/src/protocol/read/observation.js +37 -0
  243. package/build/src/protocol/read/status.d.ts +23 -12
  244. package/build/src/protocol/read/status.js +90 -72
  245. package/build/src/protocol/reconcile.d.ts +1 -0
  246. package/build/src/protocol/reconcile.js +2 -3
  247. package/build/src/protocol/reintegrate.js +1 -1
  248. package/build/src/protocol/review.d.ts +0 -1
  249. package/build/src/protocol/review.js +15 -22
  250. package/build/src/protocol/run.d.ts +1 -0
  251. package/build/src/protocol/run.js +4 -5
  252. package/build/src/runtime/proc/launch.d.ts +33 -0
  253. package/build/src/runtime/proc/launch.js +98 -0
  254. package/build/src/runtime/proc/line-rpc.js +9 -3
  255. package/build/src/runtime/proc/run.d.ts +12 -6
  256. package/build/src/runtime/proc/run.js +78 -21
  257. package/build/src/runtime/proc/stdio.js +7 -10
  258. package/build/src/settings.js +6 -2
  259. package/build/src/settlement/holder.js +13 -10
  260. package/build/src/settlement/settle.js +39 -6
  261. package/build/src/task/board.js +12 -6
  262. package/build/src/task/compose.js +85 -22
  263. package/build/src/task/context.js +21 -8
  264. package/build/src/task/document.js +46 -10
  265. package/build/src/task/identity.js +5 -2
  266. package/build/src/task/index.d.ts +0 -1
  267. package/build/src/task/index.js +119 -34
  268. package/build/src/task/input.js +29 -7
  269. package/build/src/task/mutation.js +61 -19
  270. package/build/src/task/operations.d.ts +6 -1
  271. package/build/src/task/operations.js +83 -29
  272. package/build/src/task/query.js +55 -26
  273. package/build/src/task/store.d.ts +3 -1
  274. package/build/src/task/store.js +81 -17
  275. package/build/src/verification/execution.js +14 -11
  276. package/build/src/workspace-place.js +19 -7
  277. package/build/src/world.js +16 -6
  278. package/package.json +8 -3
@@ -2,210 +2,35 @@ import { documentDiff } from "../markdown/diff.js";
2
2
  import { applyAmendDocument } from "../body/amend.js";
3
3
  import { decodeArcDocument } from "../body/arc.js";
4
4
  import { decodeContractDocument } from "../body/decode.js";
5
- import { renderContractGuidance, resolveHereContractWorkspace, } from "../contract-worktree.js";
5
+ import { renderContractGuidance } from "../contract-worktree.js";
6
6
  import { actorOption, contractTerms, documentDerivation, normalizedGates, normalizedList, optionalBoolean, optionalNonblank, optionalSignal, requireInput, requireMarkdown, } from "./input.js";
7
- import { observeRegion } from "./region.js";
7
+ import { observeChangedRegion } from "./region.js";
8
8
  import { worktreeHooksOption } from "./configuration.js";
9
9
  import { contractId, } from "../core/facts/types.js";
10
- import { AuthorityCorruptionError } from "../core/facts/errors.js";
11
10
  export { AuthorityCorruptionError } from "../core/facts/errors.js";
12
11
  import { contractObservationOperation, contractsOperation, deliveryDiffOperation, deliveryOperation, stateOperation, } from "../protocol/operations.js";
13
12
  import { abandonOperation } from "../protocol/abandon.js";
14
13
  import { amendOperation } from "../protocol/amend.js";
15
14
  import { arcOperation } from "../protocol/arc.js";
16
- import { deliverOperation, } from "../protocol/deliver.js";
17
- import { reviewOperation } from "../protocol/review.js";
18
15
  import { readDispatchesAt } from "../dispatch/index.js";
19
16
  import { mintSnapshotId } from "../git/identity.js";
20
17
  import { observeContractsForAdmissionInObservationAt } from "../git/observe.js";
21
18
  import { withGitDecodeChannel, withGitReadObservation } from "../git/read-observation.js";
22
- import { claimTaskHolderWithFence, releaseTaskHolder, releaseTaskHolderWithFence, taskHolderObservationSelection, } from "../settlement/holder.js";
23
- import { parseTaskId } from "../task/identity.js";
19
+ import { releaseTaskHolder, releaseTaskHolderWithFence, taskHolderObservationSelection } from "../settlement/holder.js";
24
20
  import { reconcileInput, scopeForRepo } from "./repo.js";
25
- import { injectedBodyRequests, requestBodyDeliver, requestBodyReview, } from "../akuma/requests.js";
21
+ import { injectedBodyRequests, requestBodyDeliver, requestBodyReview } from "../akuma/requests.js";
26
22
  import { auditContract } from "./audit.js";
27
23
  import { Delivery, deliveryHandle } from "./delivery.js";
28
- import { continueDeliveredDependents } from "./continuation.js";
29
- import { completionInput, completeHolderMutation, completeMutation, } from "./mutation.js";
24
+ import { completionInput, completeHolderMutation, completeMutation } from "./mutation.js";
30
25
  import { completeReconcile } from "./reconcile.js";
31
- import { admitBindWithAppointment } from "./bind.js";
26
+ import { bindFromCli as bindFromCliImplementation, bindKeiyaku as bindKeiyakuImplementation } from "./contract-bind.js";
27
+ import { executeLocalDelivery, executeLocalReview, forwardedReceipt, requireForwarded, } from "./contract-operations.js";
32
28
  import { KeiyakuRefused, KeiyakuRetry, requireAccepted, } from "./refusal.js";
33
- export { KeiyakuRefused, } from "./refusal.js";
29
+ export { KeiyakuRefused } from "./refusal.js";
34
30
  export { KeiyakuRetry };
31
+ export { executeForwardedDeliver, executeForwardedReview } from "./contract-operations.js";
35
32
  export { gatesFrom, requireBranchesToBeUpToDateFrom, SettingsError } from "./configuration.js";
36
33
  export { Delivery };
37
- function taskOption(value) {
38
- if (value === undefined)
39
- return undefined;
40
- if (typeof value !== "string")
41
- throw new TypeError("task must be a TaskId");
42
- try {
43
- parseTaskId(value);
44
- }
45
- catch (error) {
46
- throw new TypeError(error instanceof Error ? error.message : "task must be a TaskId");
47
- }
48
- return value;
49
- }
50
- async function resolveHereWorkspace(scope, id) {
51
- const appointment = await resolveHereContractWorkspace(scope, id);
52
- if (appointment.kind === "failed") {
53
- if (appointment.cause === "duplicate")
54
- throw new AuthorityCorruptionError(appointment.diagnostic);
55
- throw new Error(appointment.diagnostic);
56
- }
57
- return appointment.kind === "appointed" ? appointment.path : undefined;
58
- }
59
- function derivedDocument(state) {
60
- return documentDerivation(decodeContractDocument(state.terms.document.bytes), state.terms.gates, state.id);
61
- }
62
- async function executeLocalDelivery(input) {
63
- return withGitDecodeChannel(input.scope, async (channel) => {
64
- const outcome = await deliverOperation({
65
- scope: input.scope,
66
- channel,
67
- contractId: input.contractId,
68
- deriveDocument: derivedDocument,
69
- ...(input.actor === undefined ? {} : { actor: input.actor }),
70
- ...(input.message === undefined ? {} : { message: input.message }),
71
- requireBranchesToBeUpToDate: input.requireBranchesToBeUpToDate,
72
- includeDirty: input.includeDirty,
73
- materializeConflict: input.materializeConflict,
74
- ...(input.signal === undefined ? {} : { signal: input.signal }),
75
- resolveHereWorkspace: async (id) => await resolveHereWorkspace(input.scope, id),
76
- });
77
- if (outcome.kind === "integration-conflict-materialized")
78
- return outcome;
79
- const accepted = requireAccepted(outcome);
80
- const continued = accepted.value.completion === undefined
81
- ? accepted
82
- : await continueDeliveredDependents({
83
- scope: input.scope,
84
- channel,
85
- contractId: input.contractId,
86
- accepted,
87
- deriveDocument: derivedDocument,
88
- resolveHereWorkspace: async (id) => await resolveHereWorkspace(input.scope, id),
89
- ...(input.actor === undefined ? {} : { actor: input.actor }),
90
- ...(input.signal === undefined ? {} : { signal: input.signal }),
91
- });
92
- return completeMutation({
93
- ...completionInput(input.scope, channel, input.contractId, (delivery) => delivery, input.hooks),
94
- accepted: continued,
95
- });
96
- });
97
- }
98
- async function executeLocalReview(input) {
99
- return withGitDecodeChannel(input.scope, async (channel) => {
100
- const accepted = requireAccepted(await reviewOperation({
101
- scope: input.scope,
102
- channel,
103
- contractId: input.contractId,
104
- deriveDocument: derivedDocument,
105
- verdict: input.verdict,
106
- ...(input.summary === undefined ? {} : { summary: input.summary }),
107
- ...(input.actor === undefined ? {} : { actor: input.actor }),
108
- resolveHereWorkspace: async (id) => await resolveHereWorkspace(input.scope, id),
109
- }));
110
- const continued = accepted.value.completion === undefined
111
- ? accepted
112
- : await continueDeliveredDependents({
113
- scope: input.scope,
114
- channel,
115
- contractId: input.contractId,
116
- accepted,
117
- deriveDocument: derivedDocument,
118
- resolveHereWorkspace: async (id) => await resolveHereWorkspace(input.scope, id),
119
- ...(input.actor === undefined ? {} : { actor: input.actor }),
120
- });
121
- return completeMutation({
122
- ...completionInput(input.scope, channel, input.contractId, (review) => review, input.hooks),
123
- accepted: continued,
124
- });
125
- });
126
- }
127
- function forwardedReceipt(outcome, action) {
128
- if (outcome.kind === "failed") {
129
- throw new Error(outcome.failure.kind === "failed"
130
- ? outcome.failure.diagnostic
131
- : `Unexpected Akuma target failure for ${action}: ${outcome.failure.id}`);
132
- }
133
- return outcome.result;
134
- }
135
- function requireForwardedDelivery(receipt) {
136
- if (receipt.kind === "refused")
137
- throw new KeiyakuRefused(receipt.refusal);
138
- if (receipt.kind === "retry")
139
- throw new KeiyakuRetry(receipt.reason);
140
- return receipt.kind === "accepted" ? receipt.result : receipt;
141
- }
142
- function requireForwardedReview(receipt) {
143
- if (receipt.kind === "refused")
144
- throw new KeiyakuRefused(receipt.refusal);
145
- if (receipt.kind === "retry")
146
- throw new KeiyakuRetry(receipt.reason);
147
- return receipt.result;
148
- }
149
- export async function executeForwardedDeliver(input) {
150
- const id = contractId(input.contractId);
151
- const actor = actorOption(input.requester).actor;
152
- const message = optionalNonblank(input.message, "deliver message");
153
- try {
154
- const result = await executeLocalDelivery({
155
- scope: scopeForRepo(input.repo),
156
- contractId: id,
157
- ...(actor === undefined ? {} : { actor }),
158
- ...(message === undefined ? {} : { message }),
159
- requireBranchesToBeUpToDate: input.requireBranchesToBeUpToDate,
160
- includeDirty: input.includeDirty,
161
- materializeConflict: input.materializeConflict,
162
- ...(input.signal === undefined ? {} : { signal: input.signal }),
163
- hooks: input.hooks,
164
- });
165
- if (!("facts" in result))
166
- return { result };
167
- const delivery = result.facts.find((fact) => fact.kind === "deliver");
168
- if (delivery === undefined)
169
- throw new Error("accepted delivery is missing its journal fact");
170
- return { result: { kind: "accepted", result }, deliveryFactId: delivery.entry };
171
- }
172
- catch (error) {
173
- if (error instanceof KeiyakuRefused)
174
- return { result: { kind: "refused", refusal: error.refusal } };
175
- if (error instanceof KeiyakuRetry)
176
- return { result: { kind: "retry", reason: error.reason } };
177
- throw error;
178
- }
179
- }
180
- export async function executeForwardedReview(input) {
181
- const id = contractId(input.contractId);
182
- const actor = actorOption(input.requester).actor;
183
- if (input.verdict !== "satisfied" && input.verdict !== "unsatisfied") {
184
- throw new TypeError("verdict must be satisfied or unsatisfied");
185
- }
186
- const summary = optionalNonblank(input.summary, "review summary");
187
- try {
188
- const result = await executeLocalReview({
189
- scope: scopeForRepo(input.repo),
190
- contractId: id,
191
- ...(actor === undefined ? {} : { actor }),
192
- verdict: input.verdict,
193
- ...(summary === undefined ? {} : { summary }),
194
- hooks: input.hooks,
195
- });
196
- const review = result.facts.find((fact) => fact.kind === "attestation");
197
- if (review === undefined)
198
- throw new Error("accepted review is missing its journal fact");
199
- return { result: { kind: "accepted", result }, reviewFactId: review.entry };
200
- }
201
- catch (error) {
202
- if (error instanceof KeiyakuRefused)
203
- return { result: { kind: "refused", refusal: error.refusal } };
204
- if (error instanceof KeiyakuRetry)
205
- return { result: { kind: "retry", reason: error.reason } };
206
- throw error;
207
- }
208
- }
209
34
  export class KeiyakuHandle {
210
35
  id;
211
36
  scope;
@@ -235,7 +60,7 @@ export class KeiyakuHandle {
235
60
  const commit = observation.snapshot.commit;
236
61
  if (commit === null)
237
62
  throw new Error("contract history requires a keiyaku-state snapshot");
238
- const recordedAt = (event) => (event.source === "journal" ? event.fact.at : event.dispatch.dispatchedAt);
63
+ const recordedAt = (event) => event.source === "journal" ? event.fact.at : event.dispatch.dispatchedAt;
239
64
  const events = [
240
65
  ...record.entries.map((fact) => ({ source: "journal", fact })),
241
66
  ...dispatches
@@ -267,9 +92,7 @@ export class KeiyakuHandle {
267
92
  channel,
268
93
  contractId: this.id,
269
94
  }));
270
- return delivery === null
271
- ? null
272
- : this.deliveryHandle(delivery);
95
+ return delivery === null ? null : this.deliveryHandle(delivery);
273
96
  }
274
97
  async amend(input) {
275
98
  const values = requireInput(input, "amend input");
@@ -277,22 +100,25 @@ export class KeiyakuHandle {
277
100
  const markdown = values.markdown === undefined ? undefined : requireMarkdown(values.markdown);
278
101
  const actor = actorOption(values.actor);
279
102
  const gates = values.gates === undefined ? undefined : normalizedGates(values.gates);
280
- const prerequisites = values.after === undefined
281
- ? undefined
282
- : normalizedList(values.after, "after", contractId);
103
+ const prerequisites = values.after === undefined ? undefined : normalizedList(values.after, "after", contractId);
283
104
  if (markdown === undefined && gates === undefined && prerequisites === undefined) {
284
105
  throw new TypeError("amend requires markdown, after, or gates");
285
106
  }
286
- return withGitDecodeChannel(this.scope, async (channel) => {
107
+ const amendment = await withGitDecodeChannel(this.scope, async (channel) => {
108
+ let changedSections;
287
109
  const accepted = requireAccepted(await amendOperation({
288
110
  scope: this.scope,
289
111
  channel,
290
112
  contractId: this.id,
291
113
  ...actor,
292
114
  deriveAmendment: (source) => {
293
- const document = markdown === undefined
115
+ const amendment = markdown === undefined
116
+ ? undefined
117
+ : applyAmendDocument(markdown, decodeContractDocument(source.document.bytes));
118
+ changedSections = amendment?.changedSections;
119
+ const document = amendment === undefined
294
120
  ? decodeContractDocument(source.document.bytes)
295
- : decodeContractDocument(applyAmendDocument(markdown, decodeContractDocument(source.document.bytes)));
121
+ : decodeContractDocument(amendment.document);
296
122
  const terms = markdown === undefined
297
123
  ? {
298
124
  document: source.document,
@@ -307,16 +133,23 @@ export class KeiyakuHandle {
307
133
  };
308
134
  },
309
135
  }));
310
- const document = decodeContractDocument(accepted.value.terms.document.bytes);
136
+ const completed = await completeMutation({
137
+ ...completionInput(this.scope, channel, this.id, () => undefined, hooks),
138
+ accepted,
139
+ });
311
140
  return {
312
- ...await completeMutation({
313
- ...completionInput(this.scope, channel, this.id, () => undefined, hooks),
314
- accepted,
315
- }),
141
+ completed,
142
+ document: decodeContractDocument(accepted.value.terms.document.bytes),
143
+ changedSections,
316
144
  documentDiff: documentDiff("before", "after", accepted.value.source.document.bytes, accepted.value.terms.document.bytes),
317
- ...await observeRegion(this.scope, channel, this.id, document.region),
318
145
  };
319
146
  });
147
+ const regionObservation = await observeChangedRegion(this.scope, this.id, amendment.changedSections, amendment.document.region);
148
+ return {
149
+ ...amendment.completed,
150
+ documentDiff: amendment.documentDiff,
151
+ ...regionObservation,
152
+ };
320
153
  }
321
154
  async deliver(input) {
322
155
  const values = input === undefined ? undefined : requireInput(input, "deliver input");
@@ -340,7 +173,7 @@ export class KeiyakuHandle {
340
173
  ...(signal === undefined ? {} : { signal }),
341
174
  hooks,
342
175
  })
343
- : requireForwardedDelivery(forwardedReceipt(await requestBodyDeliver({
176
+ : requireForwarded(forwardedReceipt(await requestBodyDeliver({
344
177
  directory: requests,
345
178
  repoRoot: this.scope.primaryWorktree,
346
179
  contractId: this.id,
@@ -362,7 +195,7 @@ export class KeiyakuHandle {
362
195
  const actor = actorOption(values.actor);
363
196
  const requests = injectedBodyRequests();
364
197
  if (requests !== null) {
365
- return requireForwardedReview(forwardedReceipt(await requestBodyReview({
198
+ return requireForwarded(forwardedReceipt(await requestBodyReview({
366
199
  directory: requests,
367
200
  repoRoot: this.scope.primaryWorktree,
368
201
  contractId: this.id,
@@ -431,7 +264,10 @@ export class KeiyakuHandle {
431
264
  async reconcile(input) {
432
265
  const options = reconcileInput(input);
433
266
  return withGitDecodeChannel(this.scope, (channel) => completeReconcile({
434
- scope: this.scope, channel, contractId: this.id, ...options,
267
+ scope: this.scope,
268
+ channel,
269
+ contractId: this.id,
270
+ ...options,
435
271
  }));
436
272
  }
437
273
  deliveryHandle(delivery) {
@@ -465,11 +301,7 @@ export async function listKeiyaku(input) {
465
301
  if (key !== "repo")
466
302
  throw new TypeError(`Keiyaku.list input has unknown field: ${key}`);
467
303
  const scope = scopeForRepo(values.repo);
468
- return withGitDecodeChannel(scope, (channel) => contractsOperation({
469
- scope,
470
- channel,
471
- hereWorkspace: async (id) => await resolveHereContractWorkspace(scope, id),
472
- }));
304
+ return withGitDecodeChannel(scope, (channel) => contractsOperation({ scope, channel }));
473
305
  }
474
306
  export async function observeKeiyaku(input) {
475
307
  const values = requireInput(input, "Keiyaku.observe input");
@@ -486,59 +318,12 @@ export async function observeKeiyaku(input) {
486
318
  catch (error) {
487
319
  throw new TypeError(error instanceof Error ? error.message : "contract ID is invalid");
488
320
  }
489
- return withGitDecodeChannel(scope, (channel) => contractObservationOperation({
490
- scope,
491
- channel,
492
- contractId: id,
493
- hereWorkspace: async (contract) => await resolveHereContractWorkspace(scope, contract),
494
- }));
321
+ return withGitDecodeChannel(scope, (channel) => contractObservationOperation({ scope, channel, contractId: id }));
495
322
  }
496
323
  export async function bindKeiyaku(input) {
497
- const values = requireInput(input, "Keiyaku.bind input");
498
- const hooks = worktreeHooksOption(values.hooks);
499
- const scope = scopeForRepo(values.repo);
500
- const markdown = requireMarkdown(values.markdown);
501
- const task = taskOption(values.task);
502
- const document = decodeContractDocument(markdown);
503
- const workspace = values.workspace === undefined ? "worktree" : values.workspace;
504
- if (workspace !== "worktree" && workspace !== "here")
505
- throw new TypeError("workspace must be worktree or here");
506
- const target = values.target;
507
- if (target !== undefined && typeof target !== "string")
508
- throw new TypeError("target must be a string");
509
- const actor = actorOption(values.actor);
510
- const terms = contractTerms(document, normalizedGates(values.gates), normalizedList(values.after, "after", contractId));
511
- return withGitDecodeChannel(scope, async (channel) => {
512
- const admitCandidate = () => admitBindWithAppointment({
513
- scope,
514
- channel,
515
- title: document.title,
516
- terms,
517
- verification: documentDerivation(document, terms.gates).verification,
518
- workspace,
519
- ...(target === undefined ? {} : { target }),
520
- ...(task === undefined ? {} : { task }),
521
- ...actor,
522
- });
523
- const admission = task === undefined ? null : await claimTaskHolderWithFence(scope, task, admitCandidate);
524
- const accepted = requireAccepted(admission === null ? await admitCandidate() : admission.result);
525
- const id = accepted.value.contractId;
526
- const toHandle = ({ contractId: contract }) => new KeiyakuHandle(contract, scope);
527
- const result = admission === null
528
- ? await completeMutation({ ...completionInput(scope, channel, id, toHandle, hooks), accepted })
529
- : await completeHolderMutation({
530
- completion: completionInput(scope, channel, id, toHandle, hooks),
531
- admission,
532
- requireAccepted,
533
- });
534
- return {
535
- facts: result.facts,
536
- head: result.head,
537
- keiyaku: result.value,
538
- effects: result.effects,
539
- lags: result.lags,
540
- settlement: result.settlement,
541
- ...await observeRegion(scope, channel, id, document.region),
542
- };
543
- });
324
+ return bindKeiyakuImplementation(input, (id, scope) => new KeiyakuHandle(id, scope));
325
+ }
326
+ /** Internal CLI composition; not exported from the package root. */
327
+ export async function bindFromCli(input) {
328
+ return bindFromCliImplementation(input, (id, scope) => new KeiyakuHandle(id, scope));
544
329
  }
@@ -59,6 +59,7 @@ export type AkumaTellResult = Readonly<{
59
59
  tell: TellResult;
60
60
  observation: AkumaObservationStage;
61
61
  }>;
62
+ export type { TellResult, TellWake } from "../akuma/index.js";
62
63
  export type AkumaInterruptInput = AkumaAddressInput & Readonly<{
63
64
  body: string;
64
65
  }>;
@@ -120,4 +121,3 @@ export declare function killAkuma(input: AkumaSetAddressInput): Promise<AkumaKil
120
121
  export declare function tellAkuma(input: AkumaTellInput): Promise<AkumaTellResult>;
121
122
  export declare function interruptAkuma(input: AkumaInterruptInput): Promise<AkumaInterruptResult>;
122
123
  export declare function historyAkuma(input: AkumaHistoryInput): Promise<AkumaHistoryResult>;
123
- export {};
@@ -1,4 +1,4 @@
1
- import { Akuma, AkumaNotBornError, } from "../akuma/index.js";
1
+ import { Akuma, AkumaNotBornError, defaultWaitComplete, } from "../akuma/index.js";
2
2
  import { readBudgetedStatus, tellAkumaWithId } from "../akuma/akuma.js";
3
3
  import { injectedBodyRequests, requestBodyKill, requestBodyTell, requestBodyWait, } from "../akuma/requests.js";
4
4
  import { readDispatch } from "../dispatch/index.js";
@@ -43,7 +43,8 @@ async function observeAkuma(status, path, repo) {
43
43
  }
44
44
  async function observeAkumaStage(path, id, repo) {
45
45
  try {
46
- return { kind: "observed", ...await observeAkuma(await source(path).of({ id }).status(), path, repo) };
46
+ const observed = await readBudgetedStatus(path, id, { aperture: "receipt" });
47
+ return { kind: "observed", ...(await observeAkuma(observed.status, path, repo)) };
47
48
  }
48
49
  catch (error) {
49
50
  if (error instanceof AkumaNotBornError)
@@ -87,6 +88,7 @@ function delay(milliseconds, signal) {
87
88
  });
88
89
  }
89
90
  const SHARED_ORDINARY_BUDGET = 30;
91
+ const POLL_MS = 100;
90
92
  async function observeWaitRound(path, ids, signal) {
91
93
  signal?.throwIfAborted();
92
94
  if (ids.length <= 1) {
@@ -101,7 +103,7 @@ async function observeWaitRound(path, ids, signal) {
101
103
  for (const id of ids) {
102
104
  signal?.throwIfAborted();
103
105
  try {
104
- const observed = await readBudgetedStatus(path, id, { ordinaryBudget: remaining });
106
+ const observed = await readBudgetedStatus(path, id, { aperture: "monitoring", ordinaryBudget: remaining });
105
107
  statuses.push(observed.status);
106
108
  remaining -= observed.ordinarySelected;
107
109
  }
@@ -117,18 +119,16 @@ export async function executeWaitAkuma(input) {
117
119
  const deadline = input.timeoutMs === undefined ? undefined : performance.now() + input.timeoutMs;
118
120
  for (;;) {
119
121
  const round = await observeWaitRound(input.path, input.ids, input.signal);
120
- const settled = round.statuses.map((status) => status.life !== "running");
121
- const completed = round.statuses.length > 0
122
- && (input.completion === "any" ? settled.some(Boolean) : settled.every(Boolean));
123
- if (completed
124
- || (deadline !== undefined && performance.now() >= deadline)) {
122
+ const settled = round.statuses.map(defaultWaitComplete);
123
+ const completed = round.statuses.length > 0 && (input.completion === "any" ? settled.some(Boolean) : settled.every(Boolean));
124
+ if (completed || (deadline !== undefined && performance.now() >= deadline)) {
125
125
  return {
126
126
  completion: input.completion,
127
127
  observations: await observeAkumaSet(round.statuses, input.path, input.repo),
128
128
  unobserved: round.unobserved,
129
129
  };
130
130
  }
131
- await delay(deadline === undefined ? 25 : Math.min(25, Math.max(0, deadline - performance.now())), input.signal);
131
+ await delay(deadline === undefined ? POLL_MS : Math.min(POLL_MS, Math.max(0, deadline - performance.now())), input.signal);
132
132
  }
133
133
  }
134
134
  export async function executeTellAkuma(input) {
@@ -136,7 +136,13 @@ export async function executeTellAkuma(input) {
136
136
  const handle = source(input.path).of({ id: input.id });
137
137
  const tell = input.tellId === undefined
138
138
  ? await handle.tell(input.body)
139
- : await tellAkumaWithId(input.path, input.id, input.body, input.tellId, input.recordedAt);
139
+ : await tellAkumaWithId({
140
+ worldPath: input.path,
141
+ id: input.id,
142
+ body: input.body,
143
+ tellId: input.tellId,
144
+ ...(input.recordedAt === undefined ? {} : { recordedAt: input.recordedAt }),
145
+ });
140
146
  input.signal?.throwIfAborted();
141
147
  return {
142
148
  akuma: input.id,
@@ -186,7 +192,9 @@ async function attachWaitContracts(repo, result) {
186
192
  };
187
193
  }
188
194
  async function attachTellContract(repo, result) {
189
- return repo === undefined ? result : { ...result, observation: await attachObservationStage(repo, result.observation) };
195
+ return repo === undefined
196
+ ? result
197
+ : { ...result, observation: await attachObservationStage(repo, result.observation) };
190
198
  }
191
199
  async function attachKillContracts(repo, result) {
192
200
  return repo === undefined
@@ -1,11 +1,13 @@
1
1
  import type { DecodedContractDocument } from "../body/types.js";
2
2
  import { type ActorId, type ContractId, type ContractTerms, type Gate } from "../core/facts/types.js";
3
+ import { type TaskId } from "../task/identity.js";
3
4
  import type { DocumentDerivation } from "../protocol/operations.js";
4
5
  export declare function actorOption(actor: unknown): Readonly<{
5
6
  actor?: ActorId;
6
7
  }>;
7
8
  export declare function requireMarkdown(value: unknown, label?: string): string;
8
9
  export declare function requireInput(value: unknown, label: string): Record<string, unknown>;
10
+ export declare function taskOption(value: unknown): TaskId | undefined;
9
11
  export declare function optionalNonblank(value: unknown, label: string): string | undefined;
10
12
  export declare function optionalBoolean(value: unknown, label: string): boolean | undefined;
11
13
  export declare function optionalSignal(value: unknown): AbortSignal | undefined;
@@ -1,5 +1,6 @@
1
1
  import { verificationDefinition } from "../body/decode.js";
2
2
  import { actorId, gate, gateWord, } from "../core/facts/types.js";
3
+ import { parseTaskId } from "../task/identity.js";
3
4
  import { prepareVerificationDeclaration } from "../verification/declaration.js";
4
5
  export function actorOption(actor) {
5
6
  if (actor === undefined)
@@ -22,6 +23,19 @@ export function requireInput(value, label) {
22
23
  throw new TypeError(`${label} must be an object`);
23
24
  return value;
24
25
  }
26
+ export function taskOption(value) {
27
+ if (value === undefined)
28
+ return undefined;
29
+ if (typeof value !== "string")
30
+ throw new TypeError("task must be a TaskId");
31
+ try {
32
+ parseTaskId(value);
33
+ }
34
+ catch (error) {
35
+ throw new TypeError(error instanceof Error ? error.message : "task must be a TaskId");
36
+ }
37
+ return value;
38
+ }
25
39
  export function optionalNonblank(value, label) {
26
40
  if (value === undefined)
27
41
  return undefined;
@@ -4,25 +4,26 @@ import { historyAkuma, interruptAkuma, killAkuma, statusAkuma, tellAkuma, waitAk
4
4
  import { listCatalog } from "./catalog.js";
5
5
  import { nukeKeiyaku } from "./nuke.js";
6
6
  export { AuthorityCorruptionError } from "../core/facts/errors.js";
7
- export { Delivery, KeiyakuRefused, KeiyakuRetry, } from "./contract.js";
7
+ export { Delivery, KeiyakuRefused, KeiyakuRetry } from "./contract.js";
8
8
  export { NoGitWorldError, Repo } from "./repo.js";
9
- export { gatesFrom, requireBranchesToBeUpToDateFrom, SettingsError, worktreeHooksFrom, } from "./configuration.js";
9
+ export { gatesFrom, requireBranchesToBeUpToDateFrom, SettingsError, worktreeHooksFrom } from "./configuration.js";
10
10
  export { AkumaWorldScopeError } from "./address.js";
11
- export type { AbandonInput, ActorId, AmendInput, AmendResult, ArcInput, AttestationVerdict, AuditInput, AuditReport, DeliveryPreparationRefusal, BindInput, BindResult, ContractBoard, ContractDisposition, ContractGateCurrent, ContractGateReport, ContractHistory, ContractHistoryEvent, ContractListInput, ContractObservation, ContractObservationInput, ContractPhase, ContractRow, ContinuationReport, DeliverInput, Fact, IntegrationConflictMaterialized, FactKind, KeiyakuOfInput, KeiyakuRefusal, KeiyakuRetryReason, Lag, MutationResult, PlacementStop, ReconcileReport, Review, ReviewInput, TaskId, TopologyEffect, VerificationReuse, VerificationStop, } from "./contract.js";
12
- export type { ContractId, ContractState, ChangeId, SnapshotId, } from "../core/facts/types.js";
11
+ export type { AbandonInput, ActorId, AmendInput, AmendResult, ArcInput, AttestationVerdict, AuditInput, AuditReport, DeliveryPreparationRefusal, BindInput, BindResult, AfterEndpointObservation, ContractAfterEdge, ContractBoard, ContractDependent, ContractDisposition, ContractGateCurrent, ContractGateReport, ContractHistory, ContractHistoryEvent, ContractListInput, ContractObservation, ContractObservationInput, ContractPhase, ContractRow, ContractWorkspaceObservation, ContinuationReport, DeliverInput, Fact, IntegrationConflictMaterialized, FactKind, KeiyakuOfInput, KeiyakuRefusal, KeiyakuRetryReason, Lag, MutationResult, PlacementStop, ReconcileReport, Review, ReviewInput, TaskId, TopologyEffect, VerificationReuse, VerificationStop, } from "./contract.js";
12
+ export type { ContractId, ContractState, ChangeId, SnapshotId } from "../core/facts/types.js";
13
13
  export type { Gate, GatesFromInput, HookCommand, RequireBranchesToBeUpToDateFromInput, WorktreeHooks, } from "./configuration.js";
14
14
  export type { RegionOverlap } from "./region.js";
15
- export type { ReconcileInput, RepoAtInput, RepoReconcileReport, } from "./repo.js";
16
- export type { SettlementAction, SettlementLag, SettlementReport, } from "../settlement/settle.js";
15
+ export type { ReconcileInput, RepoAtInput, RepoReconcileReport } from "./repo.js";
16
+ export type { SettlementAction, SettlementLag, SettlementReport } from "../settlement/settle.js";
17
17
  export type { AliasStage, AkumaStatus, CallObservation, CallInput, CallResult, DispatchStage, ForkInput, ForkResult, IntegrationFailure, } from "./akuma-creation.js";
18
18
  export type { AliasBinding } from "../alias/index.js";
19
19
  export type { Dispatch, DispatchFailure } from "../dispatch/index.js";
20
20
  export type { AkumaAlias } from "../identity/selector.js";
21
21
  export type { AkumaGlob } from "../identity/selector.js";
22
22
  export type { AkuId } from "../akuma/identity.js";
23
+ export type { TellResult, TellWake } from "./fleet.js";
23
24
  export type { AllowedAction, AllowedActions } from "../akuma/allowed.js";
24
25
  export type { Catalog, CatalogInput, CatalogQuery } from "./catalog.js";
25
- export type { NukeInput, NukeResult, } from "./nuke.js";
26
+ export type { NukeInput, NukeResult } from "./nuke.js";
26
27
  export type { NukeConfirmationRefusal, NukeConfirmationRequiredRefusal } from "./refusal.js";
27
28
  export type { AkumaAddressInput, AkumaSetAddressInput, AkumaWorldScopeRefusal, DirectAkumaSelector, SetAkumaSelector, } from "./address.js";
28
29
  export type { AkumaHistoryInput, AkumaHistoryResult, AkumaInterruptInput, AkumaInterruptResult, AkumaKillResult, AkumaObservation, AkumaObservationStage, AkumaTellInput, AkumaUnobserved, CreatedTaskObservation, DispatchAssociation, AkumaTellResult, AkumaWaitInput, AkumaWaitResult, } from "./fleet.js";
@@ -1,12 +1,12 @@
1
1
  import { KeiyakuHandle, bindKeiyaku, keiyakuOf, listKeiyaku, observeKeiyaku, } from "./contract.js";
2
2
  import { callKeiyaku, forkKeiyaku } from "./akuma-creation.js";
3
- import { historyAkuma, interruptAkuma, killAkuma, statusAkuma, tellAkuma, waitAkuma, } from "./fleet.js";
3
+ import { historyAkuma, interruptAkuma, killAkuma, statusAkuma, tellAkuma, waitAkuma } from "./fleet.js";
4
4
  import { listCatalog } from "./catalog.js";
5
5
  import { nukeKeiyaku } from "./nuke.js";
6
6
  export { AuthorityCorruptionError } from "../core/facts/errors.js";
7
- export { Delivery, KeiyakuRefused, KeiyakuRetry, } from "./contract.js";
7
+ export { Delivery, KeiyakuRefused, KeiyakuRetry } from "./contract.js";
8
8
  export { NoGitWorldError, Repo } from "./repo.js";
9
- export { gatesFrom, requireBranchesToBeUpToDateFrom, SettingsError, worktreeHooksFrom, } from "./configuration.js";
9
+ export { gatesFrom, requireBranchesToBeUpToDateFrom, SettingsError, worktreeHooksFrom } from "./configuration.js";
10
10
  export { AkumaWorldScopeError } from "./address.js";
11
11
  export const Keiyaku = Object.freeze({
12
12
  prototype: KeiyakuHandle.prototype,
@@ -1,3 +1,5 @@
1
+ import { rmdir } from "node:fs/promises";
2
+ import { resolve } from "node:path";
1
3
  import { stopAkuma } from "../akuma/nuke.js";
2
4
  import { nukeGit } from "../git/nuke.js";
3
5
  import { nukeTask } from "../task/operations.js";
@@ -6,6 +8,16 @@ import { requireInput, requireMarkdown } from "./input.js";
6
8
  function diagnostic(error) {
7
9
  return error instanceof Error ? error.message : String(error);
8
10
  }
11
+ async function removeEmptyWorldMarker(world) {
12
+ try {
13
+ await rmdir(resolve(world, ".keiyaku"));
14
+ }
15
+ catch (error) {
16
+ const code = error.code;
17
+ if (code !== "ENOENT" && code !== "ENOTEMPTY")
18
+ throw error;
19
+ }
20
+ }
9
21
  function nukeInput(input) {
10
22
  const value = requireInput(input, "nuke input");
11
23
  const world = requireMarkdown(value.world, "world");
@@ -39,13 +51,10 @@ export async function nukeKeiyaku(input) {
39
51
  }
40
52
  }
41
53
  };
42
- await Promise.all([
43
- attempt(deleteAkuma()),
44
- attempt(nukeGit(value.world)),
45
- attempt(nukeTask(value.world)),
46
- ]);
54
+ await Promise.all([attempt(deleteAkuma()), attempt(nukeGit(value.world)), attempt(nukeTask(value.world))]);
47
55
  if (failed)
48
56
  throw firstDiagnostic;
57
+ await removeEmptyWorldMarker(value.world);
49
58
  return { kind: "success", world: value.world };
50
59
  }
51
60
  catch (error) {
@@ -11,11 +11,16 @@ export type ReconcileCompletion = Readonly<{
11
11
  settlement: SettlementReport;
12
12
  }>;
13
13
  export type RepoContractReconcileReport = ReconcileCompletion;
14
+ type RepoReconcileContracts = readonly Readonly<{
15
+ contractId: ContractId;
16
+ report: RepoContractReconcileReport;
17
+ }>[];
14
18
  export type RepoReconcileReport = Readonly<{
15
- contracts: readonly Readonly<{
16
- contractId: ContractId;
17
- report: RepoContractReconcileReport;
18
- }>[];
19
+ kind: "completed";
20
+ contracts: RepoReconcileContracts;
21
+ }> | Readonly<{
22
+ kind: "world-observation-failed";
23
+ diagnostic: string;
19
24
  }>;
20
25
  type ReconcileOptions = Readonly<{
21
26
  scope: RepositoryScope;