@astrosheep/keiyaku 4.5.6 → 4.5.8

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 (245) hide show
  1. package/README.md +10 -0
  2. package/build/integrations/marketplace/plugins/keiyaku/.claude-plugin/plugin.json +1 -1
  3. package/build/integrations/marketplace/plugins/keiyaku/.codex-plugin/plugin.json +1 -1
  4. package/build/integrations/marketplace/plugins/keiyaku/opencode.js +3 -2
  5. package/build/integrations/marketplace/plugins/keiyaku/package.json +1 -1
  6. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku/SKILL.md +10 -8
  7. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-akuma/SKILL.md +22 -1
  8. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-babysit/SKILL.md +53 -0
  9. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-bind/SKILL.md +28 -49
  10. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-task/SKILL.md +21 -15
  11. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-workflow/SKILL.md +148 -89
  12. package/build/src/akuma/abort.d.ts +2 -1
  13. package/build/src/akuma/abort.js +6 -23
  14. package/build/src/akuma/akuma-handle.js +4 -2
  15. package/build/src/akuma/akuma-observe.d.ts +2 -0
  16. package/build/src/akuma/akuma-observe.js +1 -0
  17. package/build/src/akuma/akuma-product.js +9 -7
  18. package/build/src/akuma/akuma.d.ts +372 -9
  19. package/build/src/akuma/akuma.js +31 -1
  20. package/build/src/akuma/allowed.d.ts +1 -1
  21. package/build/src/akuma/allowed.js +1 -0
  22. package/build/src/akuma/body.d.ts +7 -5
  23. package/build/src/akuma/body.js +25 -36
  24. package/build/src/akuma/call-request.d.ts +80 -0
  25. package/build/src/akuma/call-request.js +211 -0
  26. package/build/src/akuma/heart/facts.d.ts +6 -78
  27. package/build/src/akuma/heart/index.d.ts +3 -3
  28. package/build/src/akuma/heart/index.js +2 -2
  29. package/build/src/akuma/heart/request-authority.d.ts +6 -4
  30. package/build/src/akuma/heart/request-authority.js +31 -35
  31. package/build/src/akuma/heart/request-rows.js +12 -23
  32. package/build/src/akuma/heart/schema.d.ts +1 -1
  33. package/build/src/akuma/heart/schema.js +5 -13
  34. package/build/src/akuma/heart/storage.d.ts +0 -1
  35. package/build/src/akuma/heart/storage.js +0 -54
  36. package/build/src/akuma/index.d.ts +1 -1
  37. package/build/src/akuma/index.js +1 -1
  38. package/build/src/akuma/projection-read.d.ts +1 -0
  39. package/build/src/akuma/projection-read.js +8 -1
  40. package/build/src/akuma/projection.d.ts +856 -137
  41. package/build/src/akuma/projection.js +190 -0
  42. package/build/src/akuma/provider.d.ts +30 -3
  43. package/build/src/akuma/provider.js +104 -0
  44. package/build/src/akuma/providers/acp/core.d.ts +2 -2
  45. package/build/src/akuma/providers/acp/core.js +13 -6
  46. package/build/src/akuma/providers/acp/index.js +5 -4
  47. package/build/src/akuma/providers/claude/index.d.ts +3 -3
  48. package/build/src/akuma/providers/claude/index.js +16 -5
  49. package/build/src/akuma/providers/codex-app-server/events.js +1 -1
  50. package/build/src/akuma/providers/codex-app-server/index.js +18 -6
  51. package/build/src/akuma/providers/grok-build/index.js +5 -4
  52. package/build/src/akuma/providers/opencode-sdk/index.js +66 -25
  53. package/build/src/akuma/providers/opencode-sdk/session.d.ts +3 -2
  54. package/build/src/akuma/providers/opencode-sdk/session.js +28 -11
  55. package/build/src/akuma/providers/pi/index.js +42 -14
  56. package/build/src/akuma/publication.js +75 -13
  57. package/build/src/akuma/request-lifecycle.d.ts +3 -9
  58. package/build/src/akuma/request-lifecycle.js +12 -25
  59. package/build/src/akuma/request-rendezvous.d.ts +26 -0
  60. package/build/src/akuma/request-rendezvous.js +100 -0
  61. package/build/src/akuma/request-serve.d.ts +5 -65
  62. package/build/src/akuma/request-serve.js +92 -204
  63. package/build/src/akuma/request-wire.d.ts +109 -115
  64. package/build/src/akuma/request-wire.js +63 -318
  65. package/build/src/akuma/requests.d.ts +19 -47
  66. package/build/src/akuma/requests.js +51 -107
  67. package/build/src/akuma/turn-drive.d.ts +5 -3
  68. package/build/src/akuma/turn-drive.js +32 -10
  69. package/build/src/akuma-body.d.ts +7 -2
  70. package/build/src/akuma-body.js +68 -46
  71. package/build/src/cli/accepted.d.ts +1 -1
  72. package/build/src/cli/accepted.js +2 -2
  73. package/build/src/cli/commands/akuma-invoke.d.ts +2 -0
  74. package/build/src/cli/commands/akuma-invoke.js +17 -9
  75. package/build/src/cli/commands/akuma.js +7 -7
  76. package/build/src/cli/commands/contract-invoke.d.ts +3 -2
  77. package/build/src/cli/commands/contract-invoke.js +26 -19
  78. package/build/src/cli/commands/contract.d.ts +13 -13
  79. package/build/src/cli/commands/contract.js +32 -17
  80. package/build/src/cli/commands/install.d.ts +1 -1
  81. package/build/src/cli/commands/install.js +1 -1
  82. package/build/src/cli/commands/task-invoke.d.ts +7 -2
  83. package/build/src/cli/commands/task-invoke.js +67 -158
  84. package/build/src/cli/commands/task.d.ts +1 -1
  85. package/build/src/cli/commands/task.js +60 -22
  86. package/build/src/cli/coordinates.d.ts +2 -0
  87. package/build/src/cli/coordinates.js +18 -2
  88. package/build/src/cli/invoke.js +39 -25
  89. package/build/src/cli/main.js +2 -1
  90. package/build/src/cli/parse.d.ts +2 -2
  91. package/build/src/cli/parse.js +37 -22
  92. package/build/src/cli/render/akuma-activity.d.ts +4 -1
  93. package/build/src/cli/render/akuma-activity.js +45 -30
  94. package/build/src/cli/render/akuma-tool.d.ts +5 -1
  95. package/build/src/cli/render/akuma.js +5 -9
  96. package/build/src/cli/render/audit.js +1 -1
  97. package/build/src/cli/render/catalog.js +80 -21
  98. package/build/src/cli/render/contract-observation.d.ts +2 -0
  99. package/build/src/cli/render/contract-observation.js +11 -0
  100. package/build/src/cli/render/contract.js +25 -65
  101. package/build/src/cli/render/kanshi-akuma.d.ts +8 -0
  102. package/build/src/cli/render/kanshi-akuma.js +111 -0
  103. package/build/src/cli/render/kanshi.js +108 -213
  104. package/build/src/cli/render/receipt.d.ts +1 -2
  105. package/build/src/cli/render/receipt.js +76 -26
  106. package/build/src/cli/render/refusal.js +2 -10
  107. package/build/src/cli/render/region.js +5 -2
  108. package/build/src/cli/render/settings.d.ts +1 -1
  109. package/build/src/cli/render/settings.js +27 -8
  110. package/build/src/cli/render/task.js +28 -10
  111. package/build/src/cli/render/terminal.d.ts +28 -0
  112. package/build/src/cli/render/terminal.js +65 -0
  113. package/build/src/cli/result.d.ts +3 -3
  114. package/build/src/cli/runtime.js +3 -1
  115. package/build/src/cli/selectors.d.ts +2 -1
  116. package/build/src/cli/selectors.js +4 -3
  117. package/build/src/cli/square-edge.js +120 -36
  118. package/build/src/cli/usage.js +2 -1
  119. package/build/src/contract-guidance.d.ts +5 -0
  120. package/build/src/contract-guidance.js +121 -0
  121. package/build/src/contract-worktree.d.ts +0 -1
  122. package/build/src/contract-worktree.js +32 -83
  123. package/build/src/coordination/sqlite-transaction-lock.d.ts +1 -0
  124. package/build/src/coordination/sqlite-transaction-lock.js +5 -0
  125. package/build/src/core/facts/codec.d.ts +2 -0
  126. package/build/src/core/facts/codec.js +4 -0
  127. package/build/src/core/verbs/placement.d.ts +6 -1
  128. package/build/src/core/verbs/placement.js +5 -3
  129. package/build/src/dispatch/index.d.ts +0 -2
  130. package/build/src/dispatch/index.js +54 -55
  131. package/build/src/git/admission.js +2 -2
  132. package/build/src/git/hooks.d.ts +9 -15
  133. package/build/src/git/hooks.js +23 -317
  134. package/build/src/git/nuke.d.ts +2 -1
  135. package/build/src/git/nuke.js +36 -18
  136. package/build/src/git/private-state-seat.d.ts +12 -0
  137. package/build/src/git/private-state-seat.js +39 -0
  138. package/build/src/git/process.d.ts +6 -0
  139. package/build/src/git/process.js +19 -7
  140. package/build/src/git/read-observation.js +29 -20
  141. package/build/src/git/reconcile.d.ts +11 -0
  142. package/build/src/git/reconcile.js +64 -11
  143. package/build/src/git/repository.d.ts +8 -2
  144. package/build/src/git/repository.js +42 -21
  145. package/build/src/git/target-placement.d.ts +1 -0
  146. package/build/src/git/target-placement.js +5 -6
  147. package/build/src/git/tender.d.ts +1 -0
  148. package/build/src/git/terminal-reconcile.d.ts +1 -1
  149. package/build/src/git/terminal-reconcile.js +22 -20
  150. package/build/src/git/workspace.d.ts +14 -0
  151. package/build/src/git/workspace.js +44 -0
  152. package/build/src/kanshi/index.d.ts +1 -1
  153. package/build/src/kanshi/read.js +16 -16
  154. package/build/src/kanshi/report.d.ts +2 -2
  155. package/build/src/library/address.d.ts +9 -3
  156. package/build/src/library/address.js +3 -2
  157. package/build/src/library/akuma-creation.d.ts +4 -3
  158. package/build/src/library/akuma-creation.js +19 -13
  159. package/build/src/library/audit.d.ts +1 -1
  160. package/build/src/library/audit.js +5 -3
  161. package/build/src/library/catalog.d.ts +3 -1
  162. package/build/src/library/catalog.js +20 -6
  163. package/build/src/library/composition.d.ts +371 -0
  164. package/build/src/library/composition.js +28 -0
  165. package/build/src/library/configuration.js +8 -2
  166. package/build/src/library/continuation.js +66 -30
  167. package/build/src/library/contract-bind.js +10 -2
  168. package/build/src/library/contract-forwarding-reconciliation-result.d.ts +96 -0
  169. package/build/src/library/contract-forwarding-reconciliation-result.js +83 -0
  170. package/build/src/library/contract-forwarding-result.d.ts +6723 -0
  171. package/build/src/library/contract-forwarding-result.js +521 -0
  172. package/build/src/library/contract-forwarding.d.ts +72 -0
  173. package/build/src/library/contract-forwarding.js +125 -0
  174. package/build/src/library/contract-handle.d.ts +36 -0
  175. package/build/src/library/contract-handle.js +313 -0
  176. package/build/src/library/contract-operations.d.ts +1044 -67
  177. package/build/src/library/contract-operations.js +190 -118
  178. package/build/src/library/contract.d.ts +11 -32
  179. package/build/src/library/contract.js +16 -289
  180. package/build/src/library/fleet-result.d.ts +1454 -0
  181. package/build/src/library/fleet-result.js +96 -0
  182. package/build/src/library/fleet.d.ts +112 -54
  183. package/build/src/library/fleet.js +211 -71
  184. package/build/src/library/input.d.ts +2 -0
  185. package/build/src/library/input.js +4 -0
  186. package/build/src/library/keiyaku.d.ts +371 -20
  187. package/build/src/library/keiyaku.js +8 -21
  188. package/build/src/library/mutation.d.ts +3 -3
  189. package/build/src/library/mutation.js +5 -9
  190. package/build/src/library/nuke.d.ts +1 -1
  191. package/build/src/library/nuke.js +4 -3
  192. package/build/src/library/reconcile.d.ts +4 -0
  193. package/build/src/library/reconcile.js +2 -0
  194. package/build/src/library/refusal.d.ts +0 -9
  195. package/build/src/library/refusal.js +0 -7
  196. package/build/src/protocol/amend.js +56 -50
  197. package/build/src/protocol/attempt.d.ts +2 -0
  198. package/build/src/protocol/attempt.js +17 -5
  199. package/build/src/protocol/completion.js +7 -0
  200. package/build/src/protocol/deliver.js +6 -2
  201. package/build/src/protocol/operations.d.ts +4 -1
  202. package/build/src/protocol/operations.js +5 -2
  203. package/build/src/protocol/placement.d.ts +1 -0
  204. package/build/src/protocol/placement.js +52 -38
  205. package/build/src/protocol/read/observation.d.ts +1 -4
  206. package/build/src/protocol/read/observation.js +2 -15
  207. package/build/src/protocol/reintegrate.js +62 -58
  208. package/build/src/protocol/review.js +5 -0
  209. package/build/src/protocol/run.js +17 -13
  210. package/build/src/runtime/proc/run.d.ts +8 -0
  211. package/build/src/runtime/proc/run.js +27 -0
  212. package/build/src/runtime/proc/termination.js +26 -22
  213. package/build/src/runtime/proc/windows-launch.exe +0 -0
  214. package/build/src/settlement/holder.d.ts +2 -1
  215. package/build/src/settlement/holder.js +15 -4
  216. package/build/src/settlement/settle.js +99 -33
  217. package/build/src/task/board.d.ts +68 -27
  218. package/build/src/task/board.js +31 -1
  219. package/build/src/task/catalog.d.ts +4 -0
  220. package/build/src/task/catalog.js +23 -0
  221. package/build/src/task/compose-language.d.ts +4 -0
  222. package/build/src/task/compose-language.js +40 -7
  223. package/build/src/task/compose-parser.d.ts +2 -1
  224. package/build/src/task/compose-parser.js +5 -3
  225. package/build/src/task/compose.d.ts +1 -0
  226. package/build/src/task/compose.js +4 -1
  227. package/build/src/task/context.d.ts +7 -1
  228. package/build/src/task/context.js +25 -6
  229. package/build/src/task/index.d.ts +18 -5
  230. package/build/src/task/index.js +97 -16
  231. package/build/src/task/mutation-result.d.ts +923 -0
  232. package/build/src/task/mutation-result.js +140 -0
  233. package/build/src/task/mutation.d.ts +552 -28
  234. package/build/src/task/mutation.js +304 -97
  235. package/build/src/task/operations.d.ts +1 -4
  236. package/build/src/task/operations.js +0 -6
  237. package/build/src/task/public.d.ts +2 -0
  238. package/build/src/task/public.js +1 -0
  239. package/build/src/workspace-place.d.ts +7 -2
  240. package/build/src/workspace-place.js +34 -24
  241. package/build/src/world.d.ts +1 -0
  242. package/build/src/world.js +11 -0
  243. package/package.json +8 -6
  244. package/build/src/akuma/request-execution.d.ts +0 -8
  245. package/build/src/akuma/request-execution.js +0 -98
@@ -1,299 +1,26 @@
1
- import { documentDiff } from "../markdown/diff.js";
2
- import { applyAmendDocument } from "../body/amend.js";
3
- import { decodeArcDocument } from "../body/arc.js";
4
- import { decodeContractDocument } from "../body/decode.js";
5
- import { renderContractGuidance } from "../contract-worktree.js";
6
- import { actorOption, contractTerms, documentDerivation, normalizedGates, normalizedList, optionalBoolean, optionalNonblank, optionalSignal, requireInput, requireMarkdown, } from "./input.js";
7
- import { observeChangedRegion } from "./region.js";
8
- import { worktreeHooksOption } from "./configuration.js";
1
+ // Contract's static facade deliberately depends only on construction and observation.
2
+ import { requireInput } from "./input.js";
9
3
  import { contractId, } from "../core/facts/types.js";
10
4
  export { AuthorityCorruptionError } from "../core/facts/errors.js";
11
- import { contractObservationOperation, contractsOperation, deliveryDiffOperation, deliveryOperation, stateOperation, } from "../protocol/operations.js";
12
- import { abandonOperation } from "../protocol/abandon.js";
13
- import { amendOperation } from "../protocol/amend.js";
14
- import { arcOperation } from "../protocol/arc.js";
15
- import { readDispatchesAt } from "../dispatch/index.js";
16
- import { mintSnapshotId } from "../git/identity.js";
17
- import { observeContractsForAdmissionInObservationAt } from "../git/observe.js";
18
- import { withGitDecodeChannel, withGitReadObservation } from "../git/read-observation.js";
19
- import { releaseTaskHolder, releaseTaskHolderWithFence, taskHolderObservationSelection } from "../settlement/holder.js";
20
- import { reconcileInput, scopeForRepo } from "./repo.js";
21
- import { injectedBodyRequests, requestBodyDeliver, requestBodyReview } from "../akuma/requests.js";
22
- import { auditContract } from "./audit.js";
23
- import { Delivery, deliveryHandle } from "./delivery.js";
24
- import { completionInput, completeHolderMutation, completeMutation } from "./mutation.js";
25
- import { completeReconcile } from "./reconcile.js";
5
+ import { contractObservationOperation, contractsOperation, } from "../protocol/operations.js";
6
+ import { withGitDecodeChannel } from "../git/read-observation.js";
7
+ import { scopeForRepo } from "./repo.js";
8
+ import { localExecutionContext } from "../akuma/requests.js";
9
+ import { Delivery } from "./delivery.js";
26
10
  import { bindFromCli as bindFromCliImplementation, bindKeiyaku as bindKeiyakuImplementation } from "./contract-bind.js";
27
- import { executeLocalDelivery, executeLocalReview, forwardedReceipt, requireForwarded, } from "./contract-operations.js";
28
- import { KeiyakuRefused, KeiyakuRetry, requireAccepted, } from "./refusal.js";
11
+ export { KeiyakuHandle } from "./contract-handle.js";
12
+ import { KeiyakuHandle } from "./contract-handle.js";
13
+ import { KeiyakuRetry } from "./refusal.js";
29
14
  export { KeiyakuRefused } from "./refusal.js";
30
15
  export { KeiyakuRetry };
31
- export { executeForwardedDeliver, executeForwardedReview } from "./contract-operations.js";
32
16
  export { gatesFrom, requireBranchesToBeUpToDateFrom, SettingsError } from "./configuration.js";
33
17
  export { Delivery };
34
- export class KeiyakuHandle {
35
- id;
36
- scope;
37
- constructor(id, scope) {
38
- this.id = id;
39
- this.scope = scope;
40
- KEIYAKU_SEATS.set(this, { id, scope });
41
- }
42
- async state() {
43
- return withGitDecodeChannel(this.scope, (channel) => stateOperation({
44
- scope: this.scope,
45
- channel,
46
- contractId: this.id,
47
- }));
48
- }
49
- async history() {
50
- return withGitDecodeChannel(this.scope, (channel) => withGitReadObservation(this.scope, channel, async (observation) => {
51
- const [journals, dispatches] = await Promise.all([
52
- observeContractsForAdmissionInObservationAt(observation, [this.id]),
53
- readDispatchesAt(observation),
54
- ]);
55
- const record = journals.journals.get(this.id);
56
- if (record === undefined)
57
- throw new Error(`missing requested contract observation: ${this.id}`);
58
- if (record.state === null)
59
- throw new KeiyakuRefused({ kind: "contract-missing", contractId: this.id });
60
- const commit = observation.snapshot.commit;
61
- if (commit === null)
62
- throw new Error("contract history requires a keiyaku-state snapshot");
63
- const recordedAt = (event) => event.source === "journal" ? event.fact.at : event.dispatch.dispatchedAt;
64
- const events = [
65
- ...record.entries.map((fact) => ({ source: "journal", fact })),
66
- ...dispatches
67
- .filter((dispatch) => dispatch.contractId === this.id)
68
- .map((dispatch) => ({ source: "dispatch", dispatch })),
69
- ].sort((left, right) => {
70
- const leftAt = recordedAt(left);
71
- const rightAt = recordedAt(right);
72
- if (leftAt !== rightAt)
73
- return leftAt < rightAt ? -1 : 1;
74
- if (left.source !== right.source)
75
- return left.source === "journal" ? -1 : 1;
76
- return 0;
77
- });
78
- return { id: this.id, state: mintSnapshotId(commit), events };
79
- }));
80
- }
81
- async guidance() {
82
- return withGitDecodeChannel(this.scope, async (channel) => {
83
- const observed = await contractObservationOperation({ scope: this.scope, channel, contractId: this.id });
84
- if (observed.kind === "missing")
85
- throw new KeiyakuRefused({ kind: "contract-missing", contractId: this.id });
86
- return renderContractGuidance(await stateOperation({ scope: this.scope, channel, contractId: this.id }));
87
- });
88
- }
89
- async delivery() {
90
- const delivery = await withGitDecodeChannel(this.scope, (channel) => deliveryOperation({
91
- scope: this.scope,
92
- channel,
93
- contractId: this.id,
94
- }));
95
- return delivery === null ? null : this.deliveryHandle(delivery);
96
- }
97
- async amend(input) {
98
- const values = requireInput(input, "amend input");
99
- const hooks = worktreeHooksOption(values.hooks);
100
- const markdown = values.markdown === undefined ? undefined : requireMarkdown(values.markdown);
101
- const actor = actorOption(values.actor);
102
- const gates = values.gates === undefined ? undefined : normalizedGates(values.gates);
103
- const prerequisites = values.after === undefined ? undefined : normalizedList(values.after, "after", contractId);
104
- if (markdown === undefined && gates === undefined && prerequisites === undefined) {
105
- throw new TypeError("amend requires markdown, after, or gates");
106
- }
107
- const amendment = await withGitDecodeChannel(this.scope, async (channel) => {
108
- let changedSections;
109
- const accepted = requireAccepted(await amendOperation({
110
- scope: this.scope,
111
- channel,
112
- contractId: this.id,
113
- ...actor,
114
- deriveAmendment: (source) => {
115
- const amendment = markdown === undefined
116
- ? undefined
117
- : applyAmendDocument(markdown, decodeContractDocument(source.document.bytes));
118
- changedSections = amendment?.changedSections;
119
- const document = amendment === undefined
120
- ? decodeContractDocument(source.document.bytes)
121
- : decodeContractDocument(amendment.document);
122
- const terms = markdown === undefined
123
- ? {
124
- document: source.document,
125
- segments: source.segments,
126
- gates: gates ?? source.gates,
127
- after: prerequisites ?? source.after,
128
- }
129
- : contractTerms(document, gates ?? source.gates, prerequisites ?? source.after);
130
- return {
131
- terms,
132
- verification: documentDerivation(document, terms.gates, this.id).verification,
133
- };
134
- },
135
- }));
136
- const completed = await completeMutation({
137
- ...completionInput(this.scope, channel, this.id, () => undefined, hooks),
138
- accepted,
139
- });
140
- return {
141
- completed,
142
- document: decodeContractDocument(accepted.value.terms.document.bytes),
143
- changedSections,
144
- documentDiff: documentDiff("before", "after", accepted.value.source.document.bytes, accepted.value.terms.document.bytes),
145
- };
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
- };
153
- }
154
- async deliver(input) {
155
- const values = input === undefined ? undefined : requireInput(input, "deliver input");
156
- const hooks = worktreeHooksOption(values?.hooks);
157
- const message = optionalNonblank(values?.message, "deliver message");
158
- const requireBranchesToBeUpToDate = optionalBoolean(values?.requireBranchesToBeUpToDate, "requireBranchesToBeUpToDate") ?? false;
159
- const includeDirty = optionalBoolean(values?.includeDirty, "includeDirty") ?? false;
160
- const materializeConflict = optionalBoolean(values?.materializeConflict, "materializeConflict") ?? false;
161
- const actor = actorOption(values?.actor);
162
- const signal = optionalSignal(values?.signal);
163
- const requests = injectedBodyRequests();
164
- const result = requests === null
165
- ? await executeLocalDelivery({
166
- scope: this.scope,
167
- contractId: this.id,
168
- ...actor,
169
- ...(message === undefined ? {} : { message }),
170
- requireBranchesToBeUpToDate,
171
- includeDirty,
172
- materializeConflict,
173
- ...(signal === undefined ? {} : { signal }),
174
- hooks,
175
- })
176
- : requireForwarded(forwardedReceipt(await requestBodyDeliver({
177
- directory: requests,
178
- repoRoot: this.scope.primaryWorktree,
179
- contractId: this.id,
180
- ...(message === undefined ? {} : { message }),
181
- includeDirty,
182
- materializeConflict,
183
- ...(signal === undefined ? {} : { signal }),
184
- }), "deliver"));
185
- return "facts" in result ? { ...result, value: this.deliveryHandle(result.value) } : result;
186
- }
187
- async review(input) {
188
- const values = requireInput(input, "review input");
189
- const hooks = worktreeHooksOption(values.hooks);
190
- const verdict = values.verdict;
191
- if (verdict !== "satisfied" && verdict !== "unsatisfied") {
192
- throw new TypeError("verdict must be satisfied or unsatisfied");
193
- }
194
- const summary = optionalNonblank(values.summary, "review summary");
195
- const actor = actorOption(values.actor);
196
- const requests = injectedBodyRequests();
197
- if (requests !== null) {
198
- return requireForwarded(forwardedReceipt(await requestBodyReview({
199
- directory: requests,
200
- repoRoot: this.scope.primaryWorktree,
201
- contractId: this.id,
202
- verdict,
203
- ...(summary === undefined ? {} : { summary }),
204
- }), "review"));
205
- }
206
- return await executeLocalReview({
207
- scope: this.scope,
208
- contractId: this.id,
209
- ...actor,
210
- verdict,
211
- ...(summary === undefined ? {} : { summary }),
212
- hooks,
213
- });
214
- }
215
- async abandon(input) {
216
- const values = input === undefined ? undefined : requireInput(input, "abandon input");
217
- const hooks = worktreeHooksOption(values?.hooks);
218
- const note = optionalNonblank(values?.note, "abandon note");
219
- return withGitDecodeChannel(this.scope, async (channel) => {
220
- const admission = await releaseTaskHolderWithFence(this.scope, channel, this.id, () => abandonOperation({
221
- scope: this.scope,
222
- channel,
223
- contractId: this.id,
224
- ...actorOption(values?.actor),
225
- ...(note === undefined ? {} : { note }),
226
- observationSelection: taskHolderObservationSelection(),
227
- decorateOffer: async ({ observation, contractId: owner }) => {
228
- const companion = await releaseTaskHolder(channel, observation, owner);
229
- return companion === null ? [] : [companion];
230
- },
231
- }));
232
- return completeHolderMutation({
233
- completion: completionInput(this.scope, channel, this.id, () => undefined, hooks),
234
- admission,
235
- requireAccepted,
236
- });
237
- });
238
- }
239
- async arc(input) {
240
- const values = requireInput(input, "arc input");
241
- const hooks = worktreeHooksOption(values.hooks);
242
- const chapter = decodeArcDocument(requireMarkdown(values.markdown));
243
- return withGitDecodeChannel(this.scope, async (channel) => {
244
- const accepted = requireAccepted(await arcOperation({
245
- scope: this.scope,
246
- channel,
247
- contractId: this.id,
248
- ...actorOption(values.actor),
249
- chapter,
250
- }));
251
- return completeMutation({
252
- ...completionInput(this.scope, channel, this.id, () => undefined, hooks),
253
- accepted,
254
- });
255
- });
256
- }
257
- async audit(input) {
258
- return auditContract({
259
- scope: this.scope,
260
- contractId: this.id,
261
- ...(input === undefined ? {} : { input }),
262
- });
263
- }
264
- async reconcile(input) {
265
- const options = reconcileInput(input);
266
- return withGitDecodeChannel(this.scope, (channel) => completeReconcile({
267
- scope: this.scope,
268
- channel,
269
- contractId: this.id,
270
- ...options,
271
- }));
272
- }
273
- deliveryHandle(delivery) {
274
- return deliveryHandle(delivery, () => deliveryDiffOperation({
275
- scope: this.scope,
276
- integrationPredecessor: delivery.integration.predecessor,
277
- integrationSnapshot: delivery.integration.snapshot,
278
- }));
279
- }
280
- }
281
- const KEIYAKU_SEATS = new WeakMap();
282
- /** Internal package composition capability; not exported from the package root. */
283
- export function seatForKeiyaku(value) {
284
- if (!(value instanceof KeiyakuHandle))
285
- throw new TypeError("contract must be a Keiyaku");
286
- const seat = KEIYAKU_SEATS.get(value);
287
- if (seat === undefined)
288
- throw new TypeError("contract must be a Keiyaku");
289
- return seat;
290
- }
291
- export function keiyakuOf(input) {
18
+ export function keiyakuOf(input, execution = localExecutionContext()) {
292
19
  const values = requireInput(input, "Keiyaku.of input");
293
20
  const scope = scopeForRepo(values.repo);
294
21
  if (typeof values.id !== "string")
295
22
  throw new TypeError("contract ID must be a string");
296
- return new KeiyakuHandle(contractId(values.id), scope);
23
+ return new KeiyakuHandle(contractId(values.id), scope, execution);
297
24
  }
298
25
  export async function listKeiyaku(input) {
299
26
  const values = requireInput(input, "Keiyaku.list input");
@@ -320,10 +47,10 @@ export async function observeKeiyaku(input) {
320
47
  }
321
48
  return withGitDecodeChannel(scope, (channel) => contractObservationOperation({ scope, channel, contractId: id }));
322
49
  }
323
- export async function bindKeiyaku(input) {
324
- return bindKeiyakuImplementation(input, (id, scope) => new KeiyakuHandle(id, scope));
50
+ export async function bindKeiyaku(input, execution = localExecutionContext()) {
51
+ return bindKeiyakuImplementation(input, (id, scope) => new KeiyakuHandle(id, scope, execution));
325
52
  }
326
53
  /** 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));
54
+ export async function bindFromCli(input, execution = localExecutionContext()) {
55
+ return bindFromCliImplementation(input, (id, scope) => new KeiyakuHandle(id, scope, execution));
329
56
  }