@astrosheep/keiyaku 4.5.7 → 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 (234) 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 -9
  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 +35 -96
  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 +6 -4
  23. package/build/src/akuma/body.js +5 -3
  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 +1 -1
  28. package/build/src/akuma/heart/request-authority.d.ts +5 -4
  29. package/build/src/akuma/heart/request-authority.js +20 -34
  30. package/build/src/akuma/heart/request-rows.js +12 -23
  31. package/build/src/akuma/heart/schema.d.ts +1 -1
  32. package/build/src/akuma/heart/schema.js +5 -13
  33. package/build/src/akuma/index.d.ts +1 -1
  34. package/build/src/akuma/index.js +1 -1
  35. package/build/src/akuma/projection-read.d.ts +1 -0
  36. package/build/src/akuma/projection-read.js +8 -1
  37. package/build/src/akuma/projection.d.ts +856 -137
  38. package/build/src/akuma/projection.js +190 -0
  39. package/build/src/akuma/provider.d.ts +30 -3
  40. package/build/src/akuma/provider.js +104 -0
  41. package/build/src/akuma/providers/acp/core.d.ts +2 -2
  42. package/build/src/akuma/providers/acp/core.js +13 -6
  43. package/build/src/akuma/providers/acp/index.js +5 -4
  44. package/build/src/akuma/providers/claude/index.d.ts +3 -3
  45. package/build/src/akuma/providers/claude/index.js +16 -5
  46. package/build/src/akuma/providers/codex-app-server/events.js +1 -1
  47. package/build/src/akuma/providers/codex-app-server/index.js +18 -6
  48. package/build/src/akuma/providers/grok-build/index.js +5 -4
  49. package/build/src/akuma/providers/opencode-sdk/index.js +66 -25
  50. package/build/src/akuma/providers/opencode-sdk/session.d.ts +3 -2
  51. package/build/src/akuma/providers/opencode-sdk/session.js +28 -11
  52. package/build/src/akuma/providers/pi/index.js +42 -14
  53. package/build/src/akuma/request-lifecycle.d.ts +3 -9
  54. package/build/src/akuma/request-lifecycle.js +4 -4
  55. package/build/src/akuma/request-rendezvous.d.ts +26 -0
  56. package/build/src/akuma/request-rendezvous.js +100 -0
  57. package/build/src/akuma/request-serve.d.ts +5 -65
  58. package/build/src/akuma/request-serve.js +81 -208
  59. package/build/src/akuma/request-wire.d.ts +109 -115
  60. package/build/src/akuma/request-wire.js +63 -318
  61. package/build/src/akuma/requests.d.ts +19 -47
  62. package/build/src/akuma/requests.js +51 -107
  63. package/build/src/akuma/turn-drive.d.ts +5 -3
  64. package/build/src/akuma/turn-drive.js +32 -10
  65. package/build/src/akuma-body.d.ts +7 -2
  66. package/build/src/akuma-body.js +68 -46
  67. package/build/src/cli/accepted.d.ts +1 -1
  68. package/build/src/cli/accepted.js +2 -2
  69. package/build/src/cli/commands/akuma-invoke.d.ts +2 -0
  70. package/build/src/cli/commands/akuma-invoke.js +17 -9
  71. package/build/src/cli/commands/akuma.js +7 -7
  72. package/build/src/cli/commands/contract-invoke.d.ts +3 -2
  73. package/build/src/cli/commands/contract-invoke.js +26 -19
  74. package/build/src/cli/commands/contract.d.ts +13 -13
  75. package/build/src/cli/commands/contract.js +32 -17
  76. package/build/src/cli/commands/install.d.ts +1 -1
  77. package/build/src/cli/commands/install.js +1 -1
  78. package/build/src/cli/commands/task-invoke.d.ts +3 -0
  79. package/build/src/cli/commands/task-invoke.js +23 -140
  80. package/build/src/cli/commands/task.js +54 -20
  81. package/build/src/cli/invoke.js +39 -25
  82. package/build/src/cli/main.js +2 -1
  83. package/build/src/cli/parse.d.ts +2 -2
  84. package/build/src/cli/parse.js +37 -22
  85. package/build/src/cli/render/akuma-activity.d.ts +4 -1
  86. package/build/src/cli/render/akuma-activity.js +45 -30
  87. package/build/src/cli/render/akuma-tool.d.ts +5 -1
  88. package/build/src/cli/render/akuma.js +5 -9
  89. package/build/src/cli/render/audit.js +1 -1
  90. package/build/src/cli/render/catalog.js +80 -21
  91. package/build/src/cli/render/contract-observation.d.ts +2 -0
  92. package/build/src/cli/render/contract-observation.js +11 -0
  93. package/build/src/cli/render/contract.js +25 -65
  94. package/build/src/cli/render/kanshi-akuma.d.ts +8 -0
  95. package/build/src/cli/render/kanshi-akuma.js +111 -0
  96. package/build/src/cli/render/kanshi.js +108 -213
  97. package/build/src/cli/render/receipt.d.ts +1 -2
  98. package/build/src/cli/render/receipt.js +76 -26
  99. package/build/src/cli/render/refusal.js +2 -10
  100. package/build/src/cli/render/region.js +5 -2
  101. package/build/src/cli/render/settings.d.ts +1 -1
  102. package/build/src/cli/render/settings.js +27 -8
  103. package/build/src/cli/render/task.js +22 -5
  104. package/build/src/cli/render/terminal.d.ts +28 -0
  105. package/build/src/cli/render/terminal.js +65 -0
  106. package/build/src/cli/result.d.ts +3 -3
  107. package/build/src/cli/runtime.js +3 -1
  108. package/build/src/cli/selectors.d.ts +2 -1
  109. package/build/src/cli/selectors.js +4 -3
  110. package/build/src/cli/square-edge.js +120 -36
  111. package/build/src/cli/usage.js +2 -1
  112. package/build/src/contract-guidance.d.ts +5 -0
  113. package/build/src/contract-guidance.js +121 -0
  114. package/build/src/contract-worktree.d.ts +0 -1
  115. package/build/src/contract-worktree.js +32 -83
  116. package/build/src/coordination/sqlite-transaction-lock.d.ts +1 -0
  117. package/build/src/coordination/sqlite-transaction-lock.js +5 -0
  118. package/build/src/core/facts/codec.d.ts +2 -0
  119. package/build/src/core/facts/codec.js +4 -0
  120. package/build/src/core/verbs/placement.d.ts +6 -1
  121. package/build/src/core/verbs/placement.js +5 -3
  122. package/build/src/dispatch/index.d.ts +0 -2
  123. package/build/src/dispatch/index.js +54 -55
  124. package/build/src/git/admission.js +2 -2
  125. package/build/src/git/hooks.d.ts +9 -15
  126. package/build/src/git/hooks.js +23 -317
  127. package/build/src/git/nuke.d.ts +2 -1
  128. package/build/src/git/nuke.js +36 -18
  129. package/build/src/git/private-state-seat.d.ts +12 -0
  130. package/build/src/git/private-state-seat.js +39 -0
  131. package/build/src/git/process.d.ts +6 -0
  132. package/build/src/git/process.js +19 -7
  133. package/build/src/git/read-observation.js +29 -20
  134. package/build/src/git/reconcile.d.ts +11 -0
  135. package/build/src/git/reconcile.js +64 -11
  136. package/build/src/git/repository.d.ts +6 -2
  137. package/build/src/git/repository.js +8 -0
  138. package/build/src/git/target-placement.d.ts +1 -0
  139. package/build/src/git/target-placement.js +5 -0
  140. package/build/src/git/tender.d.ts +1 -0
  141. package/build/src/git/terminal-reconcile.d.ts +1 -1
  142. package/build/src/git/terminal-reconcile.js +22 -20
  143. package/build/src/git/workspace.d.ts +14 -0
  144. package/build/src/git/workspace.js +44 -0
  145. package/build/src/kanshi/index.d.ts +1 -1
  146. package/build/src/kanshi/read.js +16 -16
  147. package/build/src/kanshi/report.d.ts +2 -2
  148. package/build/src/library/address.d.ts +9 -3
  149. package/build/src/library/address.js +3 -2
  150. package/build/src/library/akuma-creation.d.ts +4 -3
  151. package/build/src/library/akuma-creation.js +19 -13
  152. package/build/src/library/audit.d.ts +1 -1
  153. package/build/src/library/audit.js +5 -3
  154. package/build/src/library/catalog.d.ts +3 -1
  155. package/build/src/library/catalog.js +20 -6
  156. package/build/src/library/composition.d.ts +371 -0
  157. package/build/src/library/composition.js +28 -0
  158. package/build/src/library/configuration.js +8 -2
  159. package/build/src/library/continuation.js +66 -30
  160. package/build/src/library/contract-bind.js +10 -2
  161. package/build/src/library/contract-forwarding-reconciliation-result.d.ts +96 -0
  162. package/build/src/library/contract-forwarding-reconciliation-result.js +83 -0
  163. package/build/src/library/contract-forwarding-result.d.ts +6723 -0
  164. package/build/src/library/contract-forwarding-result.js +521 -0
  165. package/build/src/library/contract-forwarding.d.ts +72 -0
  166. package/build/src/library/contract-forwarding.js +125 -0
  167. package/build/src/library/contract-handle.d.ts +36 -0
  168. package/build/src/library/contract-handle.js +313 -0
  169. package/build/src/library/contract-operations.d.ts +1044 -67
  170. package/build/src/library/contract-operations.js +190 -118
  171. package/build/src/library/contract.d.ts +11 -32
  172. package/build/src/library/contract.js +16 -289
  173. package/build/src/library/fleet-result.d.ts +1454 -0
  174. package/build/src/library/fleet-result.js +96 -0
  175. package/build/src/library/fleet.d.ts +112 -54
  176. package/build/src/library/fleet.js +211 -71
  177. package/build/src/library/input.d.ts +2 -0
  178. package/build/src/library/input.js +4 -0
  179. package/build/src/library/keiyaku.d.ts +371 -20
  180. package/build/src/library/keiyaku.js +8 -21
  181. package/build/src/library/mutation.d.ts +3 -3
  182. package/build/src/library/mutation.js +5 -9
  183. package/build/src/library/nuke.d.ts +1 -1
  184. package/build/src/library/nuke.js +4 -3
  185. package/build/src/library/reconcile.d.ts +4 -0
  186. package/build/src/library/reconcile.js +2 -0
  187. package/build/src/library/refusal.d.ts +0 -9
  188. package/build/src/library/refusal.js +0 -7
  189. package/build/src/protocol/amend.js +56 -50
  190. package/build/src/protocol/attempt.d.ts +2 -0
  191. package/build/src/protocol/attempt.js +8 -1
  192. package/build/src/protocol/completion.js +7 -0
  193. package/build/src/protocol/deliver.js +6 -2
  194. package/build/src/protocol/operations.d.ts +4 -1
  195. package/build/src/protocol/operations.js +5 -2
  196. package/build/src/protocol/placement.d.ts +1 -0
  197. package/build/src/protocol/placement.js +52 -38
  198. package/build/src/protocol/read/observation.d.ts +1 -4
  199. package/build/src/protocol/read/observation.js +2 -15
  200. package/build/src/protocol/reintegrate.js +62 -58
  201. package/build/src/protocol/review.js +5 -0
  202. package/build/src/protocol/run.js +17 -13
  203. package/build/src/runtime/proc/run.d.ts +8 -0
  204. package/build/src/runtime/proc/run.js +27 -0
  205. package/build/src/runtime/proc/termination.js +26 -22
  206. package/build/src/runtime/proc/windows-launch.exe +0 -0
  207. package/build/src/settlement/holder.d.ts +2 -1
  208. package/build/src/settlement/holder.js +15 -4
  209. package/build/src/settlement/settle.js +99 -33
  210. package/build/src/task/board.d.ts +68 -27
  211. package/build/src/task/board.js +31 -1
  212. package/build/src/task/catalog.d.ts +4 -0
  213. package/build/src/task/catalog.js +23 -0
  214. package/build/src/task/compose-language.js +33 -7
  215. package/build/src/task/compose-parser.d.ts +1 -1
  216. package/build/src/task/compose-parser.js +1 -1
  217. package/build/src/task/compose.js +2 -0
  218. package/build/src/task/index.d.ts +12 -4
  219. package/build/src/task/index.js +97 -16
  220. package/build/src/task/mutation-result.d.ts +923 -0
  221. package/build/src/task/mutation-result.js +140 -0
  222. package/build/src/task/mutation.d.ts +552 -28
  223. package/build/src/task/mutation.js +304 -97
  224. package/build/src/task/operations.d.ts +1 -4
  225. package/build/src/task/operations.js +0 -6
  226. package/build/src/task/public.d.ts +2 -0
  227. package/build/src/task/public.js +1 -0
  228. package/build/src/workspace-place.d.ts +7 -2
  229. package/build/src/workspace-place.js +34 -24
  230. package/build/src/world.d.ts +1 -0
  231. package/build/src/world.js +11 -0
  232. package/package.json +8 -6
  233. package/build/src/akuma/request-execution.d.ts +0 -8
  234. package/build/src/akuma/request-execution.js +0 -98
@@ -23,6 +23,10 @@ export function requireInput(value, label) {
23
23
  throw new TypeError(`${label} must be an object`);
24
24
  return value;
25
25
  }
26
+ /** Shared public-input failure path for operation owners. */
27
+ export function invalidInput(message) {
28
+ throw new TypeError(message);
29
+ }
26
30
  export function taskOption(value) {
27
31
  if (value === undefined)
28
32
  return undefined;
@@ -1,13 +1,13 @@
1
- import { KeiyakuHandle, bindKeiyaku, keiyakuOf, listKeiyaku, observeKeiyaku, type Keiyaku as KeiyakuType } from "./contract.js";
2
- import { callKeiyaku, forkKeiyaku } from "./akuma-creation.js";
3
- import { historyAkuma, interruptAkuma, killAkuma, statusAkuma, tellAkuma, waitAkuma } from "./fleet.js";
4
- import { listCatalog } from "./catalog.js";
5
- import { nukeKeiyaku } from "./nuke.js";
1
+ import type { Keiyaku as KeiyakuType } from "./contract.js";
2
+ import { composeLibrary } from "./composition.js";
3
+ import { type LibraryExecution } from "../akuma/requests.js";
6
4
  export { AuthorityCorruptionError } from "../core/facts/errors.js";
7
5
  export { Delivery, KeiyakuRefused, KeiyakuRetry } from "./contract.js";
8
6
  export { NoGitWorldError, Repo } from "./repo.js";
9
7
  export { gatesFrom, requireBranchesToBeUpToDateFrom, SettingsError, worktreeHooksFrom } from "./configuration.js";
10
8
  export { AkumaWorldScopeError } from "./address.js";
9
+ export { bodyRequestExecution } from "../akuma/requests.js";
10
+ export type { LibraryExecution } from "../akuma/requests.js";
11
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
12
  export type { ContractId, ContractState, ChangeId, SnapshotId } from "../core/facts/types.js";
13
13
  export type { Gate, GatesFromInput, HookCommand, RequireBranchesToBeUpToDateFromInput, WorktreeHooks, } from "./configuration.js";
@@ -28,21 +28,372 @@ export type { NukeConfirmationRefusal, NukeConfirmationRequiredRefusal } from ".
28
28
  export type { AkumaAddressInput, AkumaSetAddressInput, AkumaWorldScopeRefusal, DirectAkumaSelector, SetAkumaSelector, } from "./address.js";
29
29
  export type { AkumaHistoryInput, AkumaHistoryResult, AkumaInterruptInput, AkumaInterruptResult, AkumaKillResult, AkumaObservation, AkumaObservationStage, AkumaTellInput, AkumaUnobserved, CreatedTaskObservation, DispatchAssociation, AkumaTellResult, AkumaWaitInput, AkumaWaitResult, } from "./fleet.js";
30
30
  export type Keiyaku = KeiyakuType;
31
+ export type KeiyakuLibrary = ReturnType<typeof composeLibrary>;
32
+ declare function routedLibrary(input: Readonly<{
33
+ execution: LibraryExecution;
34
+ }>): KeiyakuLibrary;
31
35
  export declare const Keiyaku: Readonly<{
32
- prototype: KeiyakuHandle;
36
+ withExecution: typeof routedLibrary;
37
+ prototype: import("./contract-handle.js").KeiyakuHandle;
33
38
  [Symbol.hasInstance]: (value: unknown) => boolean;
34
- bind: typeof bindKeiyaku;
35
- call: typeof callKeiyaku;
36
- fork: typeof forkKeiyaku;
37
- history: typeof historyAkuma;
38
- interrupt: typeof interruptAkuma;
39
- kill: typeof killAkuma;
40
- ls: typeof listCatalog;
41
- nuke: typeof nukeKeiyaku;
42
- list: typeof listKeiyaku;
43
- observe: typeof observeKeiyaku;
44
- of: typeof keiyakuOf;
45
- status: typeof statusAkuma;
46
- tell: typeof tellAkuma;
47
- wait: typeof waitAkuma;
39
+ bind: (input: Parameters<typeof import("./contract.js").bindKeiyaku>[0]) => Promise<import("./contract-types.js").BindResult>;
40
+ call: (input: Parameters<typeof import("./akuma-creation.js").callKeiyaku>[0]) => Promise<Readonly<{
41
+ kind: "called";
42
+ akuma: import("../akuma/identity.js").AkuId;
43
+ readonly?: import("../akuma/provider-recipe.js").ReadonlyRestraint;
44
+ execution: Readonly<{
45
+ cwd: string;
46
+ source: "input" | "contract-worktree" | "caller" | "process" | "world";
47
+ }>;
48
+ dispatch: import("./akuma-creation.js").DispatchStage;
49
+ alias: import("./akuma-creation.js").AliasStage;
50
+ observation: import("./akuma-creation.js").CallObservation;
51
+ }>>;
52
+ fork: typeof import("./akuma-creation.js").forkKeiyaku;
53
+ history: typeof import("./fleet.js").historyAkuma;
54
+ interrupt: typeof import("./fleet.js").interruptAkuma;
55
+ kill: (input: Parameters<typeof import("./fleet.js").killAkuma>[0]) => Promise<{
56
+ results: {
57
+ id: import("../akuma/identity.js").AkuId;
58
+ evidence: "unavailable" | "killed" | "already-killed" | "already-stopped" | "hung" | "untidy";
59
+ }[];
60
+ }>;
61
+ ls: typeof import("./catalog.js").listCatalog;
62
+ nuke: typeof import("./nuke.js").nukeKeiyaku;
63
+ list: typeof import("./contract.js").listKeiyaku;
64
+ observe: typeof import("./contract.js").observeKeiyaku;
65
+ of: (input: Parameters<typeof import("./contract.js").keiyakuOf>[0]) => import("./contract-handle.js").KeiyakuHandle;
66
+ status: typeof import("./fleet.js").statusAkuma;
67
+ tell: (input: Parameters<typeof import("./fleet.js").tellAkuma>[0]) => Promise<{
68
+ akuma: import("../akuma/identity.js").AkuId;
69
+ tell: {
70
+ admission: {
71
+ fact: "recorded";
72
+ tellId: string;
73
+ };
74
+ wake: {
75
+ kind: "failed";
76
+ diagnostic: string;
77
+ } | {
78
+ child: {
79
+ code: number | null;
80
+ signal: string | null;
81
+ log: {
82
+ path: string;
83
+ from: number;
84
+ to: number;
85
+ };
86
+ };
87
+ kind: "failed";
88
+ diagnostic: string;
89
+ } | {
90
+ kind: "told";
91
+ } | {
92
+ kind: "held";
93
+ } | {
94
+ kind: "pursuing";
95
+ bodySequence: number;
96
+ };
97
+ };
98
+ }>;
99
+ wait: (input: Parameters<typeof import("./fleet.js").waitAkuma>[0]) => Promise<{
100
+ completion: "any" | "all";
101
+ observations: {
102
+ status: {
103
+ id: import("../akuma/identity.js").AkuId;
104
+ life: "killed" | "hung" | "untidy" | "running" | "asleep" | "stranded";
105
+ timeline: {
106
+ reportedChanges: readonly {
107
+ sequence: number;
108
+ at: string;
109
+ op: "add" | "update" | "delete" | "unspecified";
110
+ path: string;
111
+ diffstat?: {
112
+ added: number;
113
+ removed: number;
114
+ } | undefined;
115
+ }[];
116
+ reportedChangesOmitted: number;
117
+ kind: "unborn";
118
+ entries: readonly never[];
119
+ omitted: 0;
120
+ } | {
121
+ reportedChanges: readonly {
122
+ sequence: number;
123
+ at: string;
124
+ op: "add" | "update" | "delete" | "unspecified";
125
+ path: string;
126
+ diffstat?: {
127
+ added: number;
128
+ removed: number;
129
+ } | undefined;
130
+ }[];
131
+ reportedChangesOmitted: number;
132
+ kind: "open";
133
+ turn: {
134
+ kind: "turn";
135
+ sequence: number;
136
+ turnSequence: number;
137
+ bodySequence: number;
138
+ at: string;
139
+ };
140
+ entries: readonly ({
141
+ kind: "gap";
142
+ count: number;
143
+ } | {
144
+ kind: "row";
145
+ row: {
146
+ kind: "call";
147
+ sequence: number;
148
+ turnSequence: number;
149
+ at: string;
150
+ text: string;
151
+ } | {
152
+ kind: "note" | "thought" | "said";
153
+ sequence: number;
154
+ turnSequence: number;
155
+ at: string;
156
+ text: string;
157
+ truncated?: true | undefined;
158
+ } | {
159
+ kind: "tell";
160
+ sequence: number;
161
+ at: string;
162
+ tellId: string;
163
+ text: string;
164
+ state: "pending" | "told";
165
+ deliveries: readonly {
166
+ deliveredAt: string;
167
+ route: "live" | "launch";
168
+ turnSequence: number;
169
+ receipt?: "required" | "unavailable" | undefined;
170
+ }[];
171
+ } | {
172
+ kind: "tool";
173
+ sequence: number;
174
+ turnSequence: number;
175
+ at: string;
176
+ name: string;
177
+ call: {
178
+ kind: "run";
179
+ command: string;
180
+ } | {
181
+ kind: "read";
182
+ path: string;
183
+ offset?: number | undefined;
184
+ limit?: number | undefined;
185
+ } | {
186
+ kind: "search";
187
+ query: string;
188
+ scope?: "content" | "files" | "web" | undefined;
189
+ path?: string | undefined;
190
+ glob?: string | undefined;
191
+ } | {
192
+ kind: "fileChange";
193
+ changes: readonly {
194
+ op: "add" | "update" | "delete" | "unspecified";
195
+ path: string;
196
+ diffstat?: {
197
+ added: number;
198
+ removed: number;
199
+ } | undefined;
200
+ }[];
201
+ } | {
202
+ kind: "other";
203
+ display: string;
204
+ };
205
+ state: "active";
206
+ truncated?: true | undefined;
207
+ } | {
208
+ kind: "tool";
209
+ sequence: number;
210
+ turnSequence: number;
211
+ at: string;
212
+ name: string;
213
+ call: {
214
+ kind: "run";
215
+ command: string;
216
+ } | {
217
+ kind: "read";
218
+ path: string;
219
+ offset?: number | undefined;
220
+ limit?: number | undefined;
221
+ } | {
222
+ kind: "search";
223
+ query: string;
224
+ scope?: "content" | "files" | "web" | undefined;
225
+ path?: string | undefined;
226
+ glob?: string | undefined;
227
+ } | {
228
+ kind: "fileChange";
229
+ changes: readonly {
230
+ op: "add" | "update" | "delete" | "unspecified";
231
+ path: string;
232
+ diffstat?: {
233
+ added: number;
234
+ removed: number;
235
+ } | undefined;
236
+ }[];
237
+ } | {
238
+ kind: "other";
239
+ display: string;
240
+ };
241
+ state: {
242
+ status: "error" | "ok";
243
+ message?: string | undefined;
244
+ exitCode?: number | undefined;
245
+ };
246
+ completedAt?: string | undefined;
247
+ durationMs?: number | undefined;
248
+ truncated?: true | undefined;
249
+ };
250
+ })[];
251
+ omitted: number;
252
+ } | {
253
+ reportedChanges: readonly {
254
+ sequence: number;
255
+ at: string;
256
+ op: "add" | "update" | "delete" | "unspecified";
257
+ path: string;
258
+ diffstat?: {
259
+ added: number;
260
+ removed: number;
261
+ } | undefined;
262
+ }[];
263
+ reportedChangesOmitted: number;
264
+ kind: "idle";
265
+ entries: readonly ({
266
+ kind: "gap";
267
+ count: number;
268
+ } | {
269
+ kind: "row";
270
+ row: {
271
+ kind: "call";
272
+ sequence: number;
273
+ turnSequence: number;
274
+ at: string;
275
+ text: string;
276
+ } | {
277
+ kind: "note" | "thought" | "said";
278
+ sequence: number;
279
+ turnSequence: number;
280
+ at: string;
281
+ text: string;
282
+ truncated?: true | undefined;
283
+ } | {
284
+ kind: "tell";
285
+ sequence: number;
286
+ at: string;
287
+ tellId: string;
288
+ text: string;
289
+ state: "pending" | "told";
290
+ deliveries: readonly {
291
+ deliveredAt: string;
292
+ route: "live" | "launch";
293
+ turnSequence: number;
294
+ receipt?: "required" | "unavailable" | undefined;
295
+ }[];
296
+ } | {
297
+ kind: "tool";
298
+ sequence: number;
299
+ turnSequence: number;
300
+ at: string;
301
+ name: string;
302
+ call: {
303
+ kind: "run";
304
+ command: string;
305
+ } | {
306
+ kind: "read";
307
+ path: string;
308
+ offset?: number | undefined;
309
+ limit?: number | undefined;
310
+ } | {
311
+ kind: "search";
312
+ query: string;
313
+ scope?: "content" | "files" | "web" | undefined;
314
+ path?: string | undefined;
315
+ glob?: string | undefined;
316
+ } | {
317
+ kind: "fileChange";
318
+ changes: readonly {
319
+ op: "add" | "update" | "delete" | "unspecified";
320
+ path: string;
321
+ diffstat?: {
322
+ added: number;
323
+ removed: number;
324
+ } | undefined;
325
+ }[];
326
+ } | {
327
+ kind: "other";
328
+ display: string;
329
+ };
330
+ state: {
331
+ status: "error" | "ok";
332
+ message?: string | undefined;
333
+ exitCode?: number | undefined;
334
+ };
335
+ completedAt?: string | undefined;
336
+ durationMs?: number | undefined;
337
+ truncated?: true | undefined;
338
+ };
339
+ })[];
340
+ omitted: number;
341
+ outcome?: {
342
+ kind: "outcome";
343
+ sequence: number;
344
+ turnSequence: number;
345
+ at: string;
346
+ outcome: {
347
+ kind: "answered";
348
+ historyId: string;
349
+ answer: string;
350
+ } | {
351
+ kind: "failed";
352
+ historyId: string;
353
+ diagnostic: string;
354
+ };
355
+ } | undefined;
356
+ };
357
+ readonly?: {
358
+ enforcement: "native";
359
+ } | {
360
+ enforcement: "none";
361
+ diagnostic: string;
362
+ } | undefined;
363
+ strandedReason?: "resume-unsupported" | undefined;
364
+ };
365
+ contract: {
366
+ kind: "none";
367
+ } | {
368
+ kind: "associated";
369
+ contractId: import("./contract.js").ContractId;
370
+ } | {
371
+ kind: "failed";
372
+ diagnostic: string;
373
+ };
374
+ createdTasks: {
375
+ kind: "present";
376
+ rows: readonly {
377
+ id: `task/${string}`;
378
+ title: string;
379
+ state: "open" | "in_progress" | "on_hold" | "done" | "drop";
380
+ priority: 0 | 1 | 2 | 3;
381
+ disposition: "in_progress" | "on_hold" | "done" | "drop" | "ready" | "blocked";
382
+ updatedAt: string;
383
+ bodyPresent: boolean;
384
+ children?: {
385
+ live: number;
386
+ total: number;
387
+ } | undefined;
388
+ }[];
389
+ } | {
390
+ kind: "failed";
391
+ diagnostic: string;
392
+ };
393
+ }[];
394
+ unobserved: {
395
+ id: import("../akuma/identity.js").AkuId;
396
+ diagnostic: string;
397
+ }[];
398
+ }>;
48
399
  }>;
@@ -1,28 +1,15 @@
1
- import { KeiyakuHandle, bindKeiyaku, keiyakuOf, listKeiyaku, observeKeiyaku, } from "./contract.js";
2
- import { callKeiyaku, forkKeiyaku } from "./akuma-creation.js";
3
- import { historyAkuma, interruptAkuma, killAkuma, statusAkuma, tellAkuma, waitAkuma } from "./fleet.js";
4
- import { listCatalog } from "./catalog.js";
5
- import { nukeKeiyaku } from "./nuke.js";
1
+ import { composeLibrary } from "./composition.js";
2
+ import { libraryExecutionInput } from "../akuma/requests.js";
6
3
  export { AuthorityCorruptionError } from "../core/facts/errors.js";
7
4
  export { Delivery, KeiyakuRefused, KeiyakuRetry } from "./contract.js";
8
5
  export { NoGitWorldError, Repo } from "./repo.js";
9
6
  export { gatesFrom, requireBranchesToBeUpToDateFrom, SettingsError, worktreeHooksFrom } from "./configuration.js";
10
7
  export { AkumaWorldScopeError } from "./address.js";
8
+ export { bodyRequestExecution } from "../akuma/requests.js";
9
+ function routedLibrary(input) {
10
+ return composeLibrary(libraryExecutionInput(input));
11
+ }
11
12
  export const Keiyaku = Object.freeze({
12
- prototype: KeiyakuHandle.prototype,
13
- [Symbol.hasInstance]: (value) => value instanceof KeiyakuHandle,
14
- bind: bindKeiyaku,
15
- call: callKeiyaku,
16
- fork: forkKeiyaku,
17
- history: historyAkuma,
18
- interrupt: interruptAkuma,
19
- kill: killAkuma,
20
- ls: listCatalog,
21
- nuke: nukeKeiyaku,
22
- list: listKeiyaku,
23
- observe: observeKeiyaku,
24
- of: keiyakuOf,
25
- status: statusAkuma,
26
- tell: tellAkuma,
27
- wait: waitAkuma,
13
+ ...composeLibrary(),
14
+ withExecution: routedLibrary,
28
15
  });
@@ -1,4 +1,4 @@
1
- import type { ContractHead, ContractId, JournalEntry } from "../core/facts/types.js";
1
+ import type { ContractHead, ContractId, JournalEntry, SnapshotId } from "../core/facts/types.js";
2
2
  import type { GitDecodeChannel } from "../git/read-observation.js";
3
3
  import type { ReconcileReport } from "../protocol/reconcile.js";
4
4
  import type { RepositoryScope } from "../protocol/operations.js";
@@ -19,9 +19,9 @@ export type MutationResult<Value> = Readonly<{
19
19
  facts: readonly JournalEntry[];
20
20
  head: ContractHead;
21
21
  value: Value;
22
- effects: ReconcileCompletion["effects"];
23
22
  lags: ReconcileCompletion["lag"];
24
- settlement: SettlementReport;
23
+ settlementLags: SettlementReport["lags"];
24
+ recoverySnapshot?: SnapshotId;
25
25
  } & AcceptedObligations>;
26
26
  type Completion<Value, PublicValue> = Readonly<{
27
27
  scope: RepositoryScope;
@@ -14,16 +14,15 @@ export async function completeMutation(input) {
14
14
  ...(accepted.cleanup === undefined ? {} : { cleanup: accepted.cleanup }),
15
15
  ...(accepted.leak === undefined ? {} : { leak: accepted.leak }),
16
16
  };
17
+ const effects = [...(accepted.physical?.effects ?? []), ...reports.flatMap((report) => report.effects)];
18
+ const recoverySnapshot = effects.findLast((effect) => effect.kind === "recovery-snapshot")?.snapshot;
17
19
  return {
18
20
  facts: accepted.facts,
19
21
  head: accepted.head,
20
22
  value: value(accepted.value),
21
- effects: [...(accepted.physical?.effects ?? []), ...reports.flatMap((report) => report.effects)],
22
23
  lags: [...(accepted.physical?.lag ?? []), ...reports.flatMap((report) => report.lag)],
23
- settlement: {
24
- actions: reports.flatMap((report) => report.settlement.actions),
25
- lags: reports.flatMap((report) => report.settlement.lags),
26
- },
24
+ settlementLags: reports.flatMap((report) => report.settlement.lags),
25
+ ...(recoverySnapshot === undefined ? {} : { recoverySnapshot }),
27
26
  ...obligations,
28
27
  };
29
28
  }
@@ -39,9 +38,6 @@ export async function completeHolderMutation(input) {
39
38
  });
40
39
  return {
41
40
  ...completed,
42
- settlement: {
43
- actions: completed.settlement.actions,
44
- lags: [...completed.settlement.lags, ...deferred.lags],
45
- },
41
+ settlementLags: [...completed.settlementLags, ...deferred.lags],
46
42
  };
47
43
  }
@@ -1,4 +1,4 @@
1
- import type { WorldRoot } from "../world.js";
1
+ import { type WorldRoot } from "../world.js";
2
2
  export type NukeInput = Readonly<{
3
3
  world: WorldRoot;
4
4
  confirm?: string;
@@ -3,6 +3,7 @@ import { resolve } from "node:path";
3
3
  import { stopAkuma } from "../akuma/nuke.js";
4
4
  import { nukeGit } from "../git/nuke.js";
5
5
  import { nukeTask } from "../task/operations.js";
6
+ import { World } from "../world.js";
6
7
  import { KeiyakuRefused } from "./refusal.js";
7
8
  import { requireInput, requireMarkdown } from "./input.js";
8
9
  function diagnostic(error) {
@@ -18,14 +19,14 @@ async function removeEmptyWorldMarker(world) {
18
19
  throw error;
19
20
  }
20
21
  }
21
- function nukeInput(input) {
22
+ async function nukeInput(input) {
22
23
  const value = requireInput(input, "nuke input");
23
- const world = requireMarkdown(value.world, "world");
24
+ const world = await World.prove(requireMarkdown(value.world, "world"));
24
25
  const confirm = value.confirm === undefined ? undefined : requireMarkdown(value.confirm, "confirm");
25
26
  return { world, ...(confirm === undefined ? {} : { confirm }) };
26
27
  }
27
28
  export async function nukeKeiyaku(input) {
28
- const value = nukeInput(input);
29
+ const value = await nukeInput(input);
29
30
  if (value.confirm === undefined) {
30
31
  throw new KeiyakuRefused({ kind: "nuke-confirmation-required", world: value.world });
31
32
  }
@@ -9,6 +9,10 @@ export type ReconcileCompletion = Readonly<{
9
9
  effects: readonly (ReconcileReport["effects"][number] | ContractFileEffect)[];
10
10
  lag: readonly (ReconcileReport["lag"][number] | ContractFileLag)[];
11
11
  settlement: SettlementReport;
12
+ hookRuns?: readonly {
13
+ phase: "create" | "destroy";
14
+ name: string;
15
+ }[];
12
16
  }>;
13
17
  export type RepoContractReconcileReport = ReconcileCompletion;
14
18
  type RepoReconcileContracts = readonly Readonly<{
@@ -97,6 +97,7 @@ export async function completeReconcile(input) {
97
97
  const release = releaseEligible(retained.state, cleanup?.report, appointment.place !== undefined)
98
98
  ? await releaseAppointments(input.scope, [input.contractId])
99
99
  : undefined;
100
+ const hookRuns = [...(retained.report.hookRuns ?? []), ...(cleanup?.report.hookRuns ?? [])];
100
101
  return {
101
102
  effects: [...retained.report.effects, ...projection.effects, ...(cleanup?.report.effects ?? [])],
102
103
  lag: [
@@ -106,6 +107,7 @@ export async function completeReconcile(input) {
106
107
  ...(release === undefined ? [] : [release]),
107
108
  ],
108
109
  settlement,
110
+ ...(hookRuns.length === 0 ? {} : { hookRuns }),
109
111
  };
110
112
  }
111
113
  function attachReleaseLag(contracts, released, lag) {
@@ -27,12 +27,3 @@ export declare class KeiyakuRetry extends Error {
27
27
  get code(): KeiyakuRetryReason["kind"];
28
28
  }
29
29
  export declare function requireAccepted<Value, Refusal extends KeiyakuRefusal>(result: IntentOutcome<Value, Refusal>): AcceptedIntent<Value>;
30
- export declare function forwardedMutationFailure(error: unknown): Readonly<{
31
- result: Readonly<{
32
- kind: "refused";
33
- refusal: KeiyakuRefusal;
34
- } | {
35
- kind: "retry";
36
- reason: KeiyakuRetryReason;
37
- }>;
38
- }>;
@@ -27,10 +27,3 @@ export function requireAccepted(result) {
27
27
  throw new KeiyakuRetry(result.reason);
28
28
  return result;
29
29
  }
30
- export function forwardedMutationFailure(error) {
31
- if (error instanceof KeiyakuRefused)
32
- return { result: { kind: "refused", refusal: error.refusal } };
33
- if (error instanceof KeiyakuRetry)
34
- return { result: { kind: "retry", reason: error.reason } };
35
- throw error;
36
- }