@astrosheep/keiyaku 4.5.7 → 4.5.9

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