@astrosheep/keiyaku 4.0.0 → 4.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (308) hide show
  1. package/README.md +133 -8
  2. package/build/integrations/marketplace/plugins/keiyaku/.claude-plugin/plugin.json +2 -2
  3. package/build/integrations/marketplace/plugins/keiyaku/.codex-plugin/plugin.json +4 -4
  4. package/build/integrations/marketplace/plugins/keiyaku/opencode.js +2 -2
  5. package/build/integrations/marketplace/plugins/keiyaku/package.json +2 -2
  6. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku/SKILL.md +13 -5
  7. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-akuma/SKILL.md +91 -32
  8. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-bind/SKILL.md +134 -0
  9. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-bind/agents/openai.yaml +4 -0
  10. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-task/SKILL.md +41 -6
  11. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-workflow/SKILL.md +262 -46
  12. package/build/src/akuma/abort.d.ts +2 -0
  13. package/build/src/akuma/abort.js +50 -0
  14. package/build/src/akuma/akuma.d.ts +50 -33
  15. package/build/src/akuma/akuma.js +175 -127
  16. package/build/src/akuma/archetype.d.ts +14 -5
  17. package/build/src/akuma/archetype.js +85 -39
  18. package/build/src/akuma/body.d.ts +3 -5
  19. package/build/src/akuma/body.js +490 -183
  20. package/build/src/akuma/coordinate.d.ts +9 -0
  21. package/build/src/akuma/coordinate.js +22 -0
  22. package/build/src/akuma/heart/facts.d.ts +88 -45
  23. package/build/src/akuma/heart/facts.js +19 -8
  24. package/build/src/akuma/heart/index.d.ts +64 -55
  25. package/build/src/akuma/heart/index.js +172 -252
  26. package/build/src/akuma/heart/rows.d.ts +38 -83
  27. package/build/src/akuma/heart/rows.js +117 -155
  28. package/build/src/akuma/heart/schema.d.ts +1 -1
  29. package/build/src/akuma/heart/schema.js +61 -22
  30. package/build/src/akuma/heart/soul.d.ts +8 -0
  31. package/build/src/akuma/heart/soul.js +136 -0
  32. package/build/src/akuma/heart/storage.d.ts +47 -0
  33. package/build/src/akuma/heart/storage.js +224 -0
  34. package/build/src/akuma/heart/tells.d.ts +12 -0
  35. package/build/src/akuma/heart/tells.js +79 -0
  36. package/build/src/akuma/heart/timeline.d.ts +15 -0
  37. package/build/src/akuma/heart/timeline.js +86 -0
  38. package/build/src/akuma/identity.d.ts +2 -2
  39. package/build/src/akuma/identity.js +9 -9
  40. package/build/src/akuma/index.d.ts +10 -3
  41. package/build/src/akuma/index.js +7 -1
  42. package/build/src/akuma/projection.d.ts +176 -0
  43. package/build/src/akuma/projection.js +256 -0
  44. package/build/src/akuma/provider-recipe.d.ts +24 -0
  45. package/build/src/akuma/provider-recipe.js +100 -0
  46. package/build/src/akuma/provider.d.ts +67 -13
  47. package/build/src/akuma/provider.js +172 -105
  48. package/build/src/akuma/providers/acp/core.d.ts +19 -0
  49. package/build/src/akuma/providers/acp/core.js +159 -0
  50. package/build/src/akuma/providers/acp/events.d.ts +20 -0
  51. package/build/src/akuma/providers/acp/events.js +73 -0
  52. package/build/src/akuma/providers/acp/index.d.ts +12 -0
  53. package/build/src/akuma/providers/acp/index.js +94 -0
  54. package/build/src/akuma/providers/{claude.d.ts → claude/events.d.ts} +9 -41
  55. package/build/src/akuma/providers/claude/events.js +238 -0
  56. package/build/src/akuma/providers/claude/index.d.ts +47 -0
  57. package/build/src/akuma/providers/claude/index.js +279 -0
  58. package/build/src/akuma/providers/claude/input.d.ts +13 -0
  59. package/build/src/akuma/providers/claude/input.js +109 -0
  60. package/build/src/akuma/providers/codex-app-server/events.d.ts +1 -1
  61. package/build/src/akuma/providers/codex-app-server/events.js +15 -12
  62. package/build/src/akuma/providers/codex-app-server/index.d.ts +15 -13
  63. package/build/src/akuma/providers/codex-app-server/index.js +77 -33
  64. package/build/src/akuma/providers/grok-build/index.d.ts +4 -0
  65. package/build/src/akuma/providers/grok-build/index.js +70 -0
  66. package/build/src/akuma/providers/index.d.ts +5 -3
  67. package/build/src/akuma/providers/index.js +35 -56
  68. package/build/src/akuma/providers/opencode-sdk/events.d.ts +54 -0
  69. package/build/src/akuma/providers/opencode-sdk/events.js +235 -0
  70. package/build/src/akuma/providers/opencode-sdk/index.d.ts +33 -0
  71. package/build/src/akuma/providers/opencode-sdk/index.js +308 -0
  72. package/build/src/akuma/providers/opencode-sdk/session.d.ts +26 -0
  73. package/build/src/akuma/providers/opencode-sdk/session.js +63 -0
  74. package/build/src/akuma/providers/pi/events.d.ts +33 -0
  75. package/build/src/akuma/providers/pi/events.js +166 -0
  76. package/build/src/akuma/providers/pi/index.d.ts +11 -0
  77. package/build/src/akuma/providers/pi/index.js +191 -0
  78. package/build/src/akuma/publication.d.ts +3 -3
  79. package/build/src/akuma/publication.js +28 -40
  80. package/build/src/akuma/requests.d.ts +9 -6
  81. package/build/src/akuma/requests.js +95 -65
  82. package/build/src/alias/index.d.ts +4 -3
  83. package/build/src/alias/index.js +12 -13
  84. package/build/src/body/decode.js +7 -1
  85. package/build/src/body/region.d.ts +2 -0
  86. package/build/src/body/region.js +77 -7
  87. package/build/src/body/render.js +2 -1
  88. package/build/src/body/shape.js +7 -1
  89. package/build/src/body/verification.js +19 -4
  90. package/build/src/cli/accepted.d.ts +18 -12
  91. package/build/src/cli/accepted.js +73 -34
  92. package/build/src/cli/actor.js +3 -3
  93. package/build/src/cli/commands/akuma-invoke.d.ts +44 -19
  94. package/build/src/cli/commands/akuma-invoke.js +101 -52
  95. package/build/src/cli/commands/akuma.d.ts +27 -9
  96. package/build/src/cli/commands/akuma.js +151 -80
  97. package/build/src/cli/commands/contract.d.ts +155 -0
  98. package/build/src/cli/commands/contract.js +20 -0
  99. package/build/src/cli/commands/install.js +2 -0
  100. package/build/src/cli/commands/task-invoke.d.ts +19 -4
  101. package/build/src/cli/commands/task-invoke.js +65 -17
  102. package/build/src/cli/commands/task-query.d.ts +5 -0
  103. package/build/src/cli/commands/task-query.js +247 -0
  104. package/build/src/cli/commands/task.d.ts +3 -1
  105. package/build/src/cli/commands/task.js +52 -14
  106. package/build/src/cli/coordinates.d.ts +18 -0
  107. package/build/src/cli/coordinates.js +120 -0
  108. package/build/src/cli/draft.d.ts +8 -0
  109. package/build/src/cli/draft.js +96 -0
  110. package/build/src/cli/invoke.d.ts +9 -3
  111. package/build/src/cli/invoke.js +287 -108
  112. package/build/src/cli/main.js +54 -7
  113. package/build/src/cli/parse.d.ts +21 -117
  114. package/build/src/cli/parse.js +79 -84
  115. package/build/src/cli/render/akuma-tool-command.d.ts +6 -0
  116. package/build/src/cli/render/akuma-tool-command.js +144 -0
  117. package/build/src/cli/render/akuma-tool.d.ts +4 -2
  118. package/build/src/cli/render/akuma-tool.js +35 -5
  119. package/build/src/cli/render/akuma.d.ts +3 -1
  120. package/build/src/cli/render/akuma.js +247 -212
  121. package/build/src/cli/render/audit.d.ts +3 -0
  122. package/build/src/cli/render/audit.js +104 -0
  123. package/build/src/cli/render/catalog.d.ts +2 -0
  124. package/build/src/cli/render/catalog.js +16 -0
  125. package/build/src/cli/render/contract.d.ts +3 -3
  126. package/build/src/cli/render/contract.js +200 -54
  127. package/build/src/cli/render/kanshi.js +272 -129
  128. package/build/src/cli/render/receipt.d.ts +19 -0
  129. package/build/src/cli/render/receipt.js +106 -0
  130. package/build/src/cli/render/refusal.d.ts +16 -2
  131. package/build/src/cli/render/refusal.js +88 -3
  132. package/build/src/cli/render/region.d.ts +2 -0
  133. package/build/src/cli/render/region.js +17 -0
  134. package/build/src/cli/render/task.d.ts +2 -1
  135. package/build/src/cli/render/task.js +223 -60
  136. package/build/src/cli/render/terminal.d.ts +20 -0
  137. package/build/src/cli/render/terminal.js +121 -0
  138. package/build/src/cli/render/text.js +11 -3
  139. package/build/src/cli/result.d.ts +126 -19
  140. package/build/src/cli/usage.d.ts +1 -0
  141. package/build/src/cli/usage.js +3 -0
  142. package/build/src/contract-worktree.d.ts +44 -0
  143. package/build/src/contract-worktree.js +251 -0
  144. package/build/src/coordination/durable-file.d.ts +5 -1
  145. package/build/src/coordination/durable-file.js +57 -10
  146. package/build/src/coordination/sqlite-transaction-lock.d.ts +4 -0
  147. package/build/src/coordination/sqlite-transaction-lock.js +22 -5
  148. package/build/src/core/facts/codec.js +23 -4
  149. package/build/src/core/facts/eligibility.d.ts +1 -10
  150. package/build/src/core/facts/eligibility.js +0 -49
  151. package/build/src/core/facts/fold.js +1 -6
  152. package/build/src/core/facts/gate.d.ts +1 -0
  153. package/build/src/core/facts/gate.js +1 -0
  154. package/build/src/core/facts/observation.d.ts +3 -0
  155. package/build/src/core/facts/observation.js +12 -0
  156. package/build/src/core/facts/types.d.ts +10 -3
  157. package/build/src/core/subject.js +2 -2
  158. package/build/src/core/verbs/amend.d.ts +1 -1
  159. package/build/src/core/verbs/amend.js +3 -18
  160. package/build/src/core/verbs/bind.js +2 -16
  161. package/build/src/core/verbs/deliver.d.ts +1 -1
  162. package/build/src/core/verbs/deliver.js +14 -4
  163. package/build/src/core/verbs/placement.d.ts +1 -1
  164. package/build/src/core/verbs/placement.js +7 -9
  165. package/build/src/dispatch/index.d.ts +5 -3
  166. package/build/src/dispatch/index.js +30 -21
  167. package/build/src/duration.d.ts +10 -0
  168. package/build/src/duration.js +22 -0
  169. package/build/src/git/admission.d.ts +2 -2
  170. package/build/src/git/admission.js +33 -23
  171. package/build/src/git/hooks.d.ts +15 -0
  172. package/build/src/git/hooks.js +70 -18
  173. package/build/src/git/identity.d.ts +5 -1
  174. package/build/src/git/identity.js +23 -4
  175. package/build/src/git/integration.d.ts +48 -0
  176. package/build/src/git/integration.js +250 -0
  177. package/build/src/git/observe.d.ts +29 -15
  178. package/build/src/git/observe.js +185 -76
  179. package/build/src/git/read-observation.d.ts +41 -0
  180. package/build/src/git/read-observation.js +361 -0
  181. package/build/src/git/reconcile.d.ts +17 -5
  182. package/build/src/git/reconcile.js +305 -109
  183. package/build/src/git/repository.d.ts +41 -18
  184. package/build/src/git/repository.js +220 -114
  185. package/build/src/git/scratch.d.ts +17 -0
  186. package/build/src/git/scratch.js +73 -0
  187. package/build/src/git/target-placement.d.ts +92 -0
  188. package/build/src/git/target-placement.js +375 -0
  189. package/build/src/git/tender.d.ts +49 -0
  190. package/build/src/git/tender.js +63 -0
  191. package/build/src/git/terminal-seal.d.ts +24 -0
  192. package/build/src/git/terminal-seal.js +89 -0
  193. package/build/src/git/tree.d.ts +2 -2
  194. package/build/src/git/tree.js +4 -0
  195. package/build/src/git/workspace.d.ts +53 -0
  196. package/build/src/git/workspace.js +139 -0
  197. package/build/src/identity/selector.d.ts +6 -0
  198. package/build/src/identity/selector.js +19 -0
  199. package/build/src/index.d.ts +4 -2
  200. package/build/src/index.js +2 -1
  201. package/build/src/kanshi/index.d.ts +2 -2
  202. package/build/src/kanshi/index.js +1 -1
  203. package/build/src/kanshi/read.d.ts +7 -3
  204. package/build/src/kanshi/read.js +245 -45
  205. package/build/src/kanshi/report.d.ts +81 -6
  206. package/build/src/kanshi/select.d.ts +5 -0
  207. package/build/src/kanshi/select.js +33 -1
  208. package/build/src/library/address.d.ts +57 -0
  209. package/build/src/library/address.js +165 -0
  210. package/build/src/library/akuma-creation.d.ts +16 -7
  211. package/build/src/library/akuma-creation.js +96 -22
  212. package/build/src/library/audit.d.ts +18 -0
  213. package/build/src/library/audit.js +44 -0
  214. package/build/src/library/bind.d.ts +21 -0
  215. package/build/src/library/bind.js +56 -0
  216. package/build/src/library/catalog.d.ts +58 -0
  217. package/build/src/library/catalog.js +69 -0
  218. package/build/src/library/configuration.d.ts +6 -15
  219. package/build/src/library/configuration.js +14 -17
  220. package/build/src/library/contract.d.ts +23 -49
  221. package/build/src/library/contract.js +171 -185
  222. package/build/src/library/delivery.d.ts +24 -0
  223. package/build/src/library/delivery.js +21 -0
  224. package/build/src/library/fleet.d.ts +65 -0
  225. package/build/src/library/fleet.js +153 -0
  226. package/build/src/library/input.d.ts +3 -0
  227. package/build/src/library/input.js +19 -0
  228. package/build/src/library/keiyaku.d.ts +18 -3
  229. package/build/src/library/keiyaku.js +12 -1
  230. package/build/src/library/mutation.d.ts +39 -0
  231. package/build/src/library/mutation.js +37 -0
  232. package/build/src/library/reconcile.d.ts +29 -0
  233. package/build/src/library/reconcile.js +179 -0
  234. package/build/src/library/refusal.d.ts +21 -0
  235. package/build/src/library/refusal.js +29 -0
  236. package/build/src/library/region.d.ts +14 -1
  237. package/build/src/library/region.js +18 -4
  238. package/build/src/library/repo.d.ts +4 -13
  239. package/build/src/library/repo.js +14 -24
  240. package/build/src/protocol/attempt.d.ts +16 -3
  241. package/build/src/protocol/attempt.js +41 -10
  242. package/build/src/protocol/bind.d.ts +9 -2
  243. package/build/src/protocol/bind.js +48 -40
  244. package/build/src/protocol/intent.d.ts +57 -20
  245. package/build/src/protocol/intent.js +55 -79
  246. package/build/src/protocol/operations.d.ts +152 -43
  247. package/build/src/protocol/operations.js +482 -166
  248. package/build/src/protocol/outcome.d.ts +14 -3
  249. package/build/src/protocol/outcome.js +11 -3
  250. package/build/src/protocol/placement.d.ts +41 -0
  251. package/build/src/protocol/placement.js +147 -0
  252. package/build/src/protocol/read/documents.d.ts +2 -2
  253. package/build/src/protocol/read/documents.js +4 -4
  254. package/build/src/protocol/read/status.d.ts +18 -5
  255. package/build/src/protocol/read/status.js +73 -13
  256. package/build/src/protocol/run.d.ts +49 -7
  257. package/build/src/protocol/run.js +53 -25
  258. package/build/src/runtime/proc/line-rpc.d.ts +4 -8
  259. package/build/src/runtime/proc/line-rpc.js +22 -28
  260. package/build/src/runtime/proc/run.d.ts +23 -21
  261. package/build/src/runtime/proc/run.js +123 -89
  262. package/build/src/runtime/proc/stdio.d.ts +18 -0
  263. package/build/src/runtime/proc/stdio.js +58 -0
  264. package/build/src/settings.d.ts +7 -1
  265. package/build/src/settings.js +32 -17
  266. package/build/src/settlement/fence.d.ts +5 -0
  267. package/build/src/settlement/fence.js +14 -0
  268. package/build/src/settlement/holder.d.ts +35 -4
  269. package/build/src/settlement/holder.js +127 -28
  270. package/build/src/settlement/settle.d.ts +9 -1
  271. package/build/src/settlement/settle.js +74 -37
  272. package/build/src/task/board.d.ts +23 -5
  273. package/build/src/task/board.js +17 -10
  274. package/build/src/task/compose.d.ts +2 -2
  275. package/build/src/task/compose.js +18 -10
  276. package/build/src/task/context.d.ts +3 -3
  277. package/build/src/task/context.js +15 -20
  278. package/build/src/task/document.d.ts +2 -1
  279. package/build/src/task/document.js +15 -5
  280. package/build/src/task/index.d.ts +27 -15
  281. package/build/src/task/index.js +57 -35
  282. package/build/src/task/operations.d.ts +38 -13
  283. package/build/src/task/operations.js +80 -46
  284. package/build/src/task/query.d.ts +67 -0
  285. package/build/src/task/query.js +279 -0
  286. package/build/src/task/store.d.ts +5 -7
  287. package/build/src/task/store.js +43 -28
  288. package/build/src/verification/declaration.d.ts +1 -0
  289. package/build/src/verification/execution.d.ts +51 -0
  290. package/build/src/verification/execution.js +108 -0
  291. package/build/src/workspace-place.d.ts +41 -0
  292. package/build/src/workspace-place.js +386 -0
  293. package/build/src/world.d.ts +24 -0
  294. package/build/src/world.js +136 -0
  295. package/package.json +8 -4
  296. package/build/src/akuma/activity.d.ts +0 -66
  297. package/build/src/akuma/activity.js +0 -139
  298. package/build/src/akuma/providers/claude.js +0 -305
  299. package/build/src/context-root.d.ts +0 -4
  300. package/build/src/context-root.js +0 -15
  301. package/build/src/git/delivery.d.ts +0 -20
  302. package/build/src/git/delivery.js +0 -109
  303. package/build/src/git/verification.d.ts +0 -14
  304. package/build/src/git/verification.js +0 -56
  305. package/build/src/protocol/read/audit.d.ts +0 -25
  306. package/build/src/protocol/read/audit.js +0 -39
  307. package/build/src/verification/producer.d.ts +0 -23
  308. package/build/src/verification/producer.js +0 -54
@@ -0,0 +1,24 @@
1
+ import type { SnapshotId } from "../core/facts/types.js";
2
+ import type { DeliverValue } from "../protocol/operations.js";
3
+ declare class DeliveryHandle {
4
+ private readonly readDiff;
5
+ readonly verification?: DeliverValue["verification"];
6
+ readonly verificationReuse?: DeliverValue["verificationReuse"];
7
+ readonly placement?: DeliverValue["placement"];
8
+ readonly cleanup?: DeliverValue["cleanup"];
9
+ readonly leak?: DeliverValue["leak"];
10
+ readonly tenderSnapshot: SnapshotId;
11
+ readonly integration: DeliverValue["integration"];
12
+ readonly method: DeliverValue["method"];
13
+ readonly policy: DeliverValue["policy"];
14
+ constructor(identity: Pick<DeliverValue, "tenderSnapshot" | "integration" | "method" | "policy">, readDiff: () => Promise<string | null>, outcomes?: Partial<Pick<DeliverValue, "verification" | "verificationReuse" | "placement" | "cleanup" | "leak">>);
15
+ diff(): Promise<string | null>;
16
+ }
17
+ export type Delivery = DeliveryHandle;
18
+ type HandleType<T extends object> = Readonly<{
19
+ prototype: T;
20
+ [Symbol.hasInstance](value: unknown): boolean;
21
+ }>;
22
+ export declare const Delivery: HandleType<DeliveryHandle>;
23
+ export declare function deliveryHandle(delivery: DeliverValue, readDiff: () => Promise<string | null>): Delivery;
24
+ export {};
@@ -0,0 +1,21 @@
1
+ class DeliveryHandle {
2
+ readDiff;
3
+ constructor(identity, readDiff, outcomes = {}) {
4
+ this.readDiff = readDiff;
5
+ this.tenderSnapshot = identity.tenderSnapshot;
6
+ this.integration = identity.integration;
7
+ this.method = identity.method;
8
+ this.policy = identity.policy;
9
+ Object.assign(this, outcomes);
10
+ }
11
+ diff() {
12
+ return this.readDiff();
13
+ }
14
+ }
15
+ export const Delivery = Object.freeze({
16
+ prototype: DeliveryHandle.prototype,
17
+ [Symbol.hasInstance]: (value) => value instanceof DeliveryHandle,
18
+ });
19
+ export function deliveryHandle(delivery, readDiff) {
20
+ return new DeliveryHandle(delivery, readDiff, delivery);
21
+ }
@@ -0,0 +1,65 @@
1
+ import { type ActivityHistory, type AkumaStatus, type InterruptReceipt, type KillEvidence, type TellResult } from "../akuma/index.js";
2
+ import type { ContractId } from "../core/facts/types.js";
3
+ import { type AkumaAddressInput, type AkumaSetAddressInput } from "./address.js";
4
+ export type AkumaWaitInput = AkumaSetAddressInput & Readonly<{
5
+ completion?: "any" | "all";
6
+ timeoutMs?: number;
7
+ }>;
8
+ export type AkumaWaitResult = Readonly<{
9
+ completion: "any" | "all";
10
+ statuses: readonly AkumaStatusView[];
11
+ }>;
12
+ export type AkumaStatusView = Readonly<{
13
+ status: AkumaStatus;
14
+ contractId?: ContractId;
15
+ }>;
16
+ export type AkumaKillResult = Readonly<{
17
+ results: readonly Readonly<{
18
+ id: AkumaStatus["id"];
19
+ evidence: KillEvidence;
20
+ observation: AkumaStatusView;
21
+ }>[];
22
+ }>;
23
+ export type AkumaTellInput = AkumaAddressInput & Readonly<{
24
+ body: string;
25
+ }>;
26
+ export type AkumaTellResult = Readonly<{
27
+ akuma: AkumaStatus["id"];
28
+ tell: TellResult;
29
+ observation: AkumaStatusView;
30
+ }>;
31
+ export type AkumaInterruptInput = AkumaAddressInput & Readonly<{
32
+ body: string;
33
+ }>;
34
+ export type AkumaInterruptResult = Readonly<{
35
+ id: AkumaStatus["id"];
36
+ receipt: InterruptReceipt;
37
+ observation: AkumaStatusView;
38
+ }>;
39
+ export type AkumaHistoryInput = AkumaAddressInput & Readonly<{
40
+ before?: number;
41
+ since?: number;
42
+ limit?: number;
43
+ last?: boolean;
44
+ }>;
45
+ export type AkumaHistoryResult = Readonly<{
46
+ kind: "history";
47
+ id: AkumaStatus["id"];
48
+ history: ActivityHistory;
49
+ contractId?: ContractId;
50
+ }> | Readonly<{
51
+ kind: "last";
52
+ id: AkumaStatus["id"];
53
+ answer: string;
54
+ contractId?: ContractId;
55
+ }> | Readonly<{
56
+ kind: "no-answer";
57
+ id: AkumaStatus["id"];
58
+ contractId?: ContractId;
59
+ }>;
60
+ export declare function statusAkuma(input: AkumaAddressInput): Promise<AkumaStatusView>;
61
+ export declare function waitAkuma(input: AkumaWaitInput): Promise<AkumaWaitResult>;
62
+ export declare function killAkuma(input: AkumaSetAddressInput): Promise<AkumaKillResult>;
63
+ export declare function tellAkuma(input: AkumaTellInput): Promise<AkumaTellResult>;
64
+ export declare function interruptAkuma(input: AkumaInterruptInput): Promise<AkumaInterruptResult>;
65
+ export declare function historyAkuma(input: AkumaHistoryInput): Promise<AkumaHistoryResult>;
@@ -0,0 +1,153 @@
1
+ import { Akuma, } from "../akuma/index.js";
2
+ import { readActionFeedbackStatus, readBudgetedStatus } from "../akuma/akuma.js";
3
+ import { readDispatch } from "../dispatch/index.js";
4
+ import { addressAkuma, addressAkumaSet } from "./address.js";
5
+ import { requireInput } from "./input.js";
6
+ import { scopeForRepo } from "./repo.js";
7
+ function source(path, settings) {
8
+ return Akuma.of(path, settings);
9
+ }
10
+ async function contractFor(repo, id) {
11
+ const dispatch = repo === undefined ? null : await readDispatch(scopeForRepo(repo), id);
12
+ return dispatch?.contractId;
13
+ }
14
+ async function statusView(status, repo) {
15
+ const contractId = await contractFor(repo, status.id);
16
+ return contractId === undefined ? { status } : { status, contractId };
17
+ }
18
+ function timeout(value) {
19
+ if (value === undefined)
20
+ return undefined;
21
+ if (typeof value !== "number" || !Number.isFinite(value) || value < 0) {
22
+ throw new TypeError("timeoutMs must be a nonnegative finite number");
23
+ }
24
+ return value;
25
+ }
26
+ function delay(milliseconds) {
27
+ return new Promise((resolve) => setTimeout(resolve, milliseconds));
28
+ }
29
+ const SHARED_ORDINARY_BUDGET = 30;
30
+ async function observeWaitStatuses(path, ids, settings) {
31
+ if (ids.length <= 1) {
32
+ return await Promise.all(ids.map(async (id) => await source(path, settings).of({ id }).status()));
33
+ }
34
+ let remaining = SHARED_ORDINARY_BUDGET;
35
+ const statuses = [];
36
+ for (const id of ids) {
37
+ const observed = await readBudgetedStatus(path, id, { ordinaryBudget: remaining });
38
+ statuses.push(observed.status);
39
+ remaining -= observed.ordinarySelected;
40
+ }
41
+ return statuses;
42
+ }
43
+ function directAddress(values) {
44
+ return {
45
+ path: values.path,
46
+ akuma: values.akuma,
47
+ ...(values.settings === undefined ? {} : { settings: values.settings }),
48
+ ...(values.repo === undefined ? {} : { repo: values.repo }),
49
+ };
50
+ }
51
+ function setAddress(values) {
52
+ return {
53
+ path: values.path,
54
+ akuma: values.akuma,
55
+ ...(values.settings === undefined ? {} : { settings: values.settings }),
56
+ ...(values.repo === undefined ? {} : { repo: values.repo }),
57
+ };
58
+ }
59
+ export async function statusAkuma(input) {
60
+ const addressed = await addressAkuma(input);
61
+ return await statusView(await source(addressed.path, addressed.settings).of({ id: addressed.id }).status(), input.repo);
62
+ }
63
+ export async function waitAkuma(input) {
64
+ const values = requireInput(input, "Keiyaku.wait input");
65
+ for (const key of Object.keys(values)) {
66
+ if (!["path", "akuma", "settings", "repo", "completion", "timeoutMs"].includes(key)) {
67
+ throw new TypeError(`Keiyaku.wait input has unknown field: ${key}`);
68
+ }
69
+ }
70
+ const addressed = await addressAkumaSet(setAddress(values));
71
+ const completion = values.completion;
72
+ if (addressed.ids.length > 1 && completion !== "any" && completion !== "all") {
73
+ throw new TypeError("completion must be any or all when waiting for multiple Akuma");
74
+ }
75
+ if (completion !== undefined && completion !== "any" && completion !== "all")
76
+ throw new TypeError("completion must be any or all");
77
+ const selected = completion ?? "all";
78
+ const timeoutMs = timeout(values.timeoutMs);
79
+ const deadline = timeoutMs === undefined ? undefined : performance.now() + timeoutMs;
80
+ for (;;) {
81
+ const statuses = await observeWaitStatuses(addressed.path, addressed.ids, addressed.settings);
82
+ const settled = statuses.map((status) => status.life !== "running");
83
+ if ((selected === "any" ? settled.some(Boolean) : settled.every(Boolean))
84
+ || (deadline !== undefined && performance.now() >= deadline)) {
85
+ return { completion: selected, statuses: await Promise.all(statuses.map(async (status) => await statusView(status, values.repo))) };
86
+ }
87
+ await delay(deadline === undefined ? 25 : Math.min(25, Math.max(0, deadline - performance.now())));
88
+ }
89
+ }
90
+ export async function killAkuma(input) {
91
+ const addressed = await addressAkumaSet(input);
92
+ const handles = addressed.ids.map((id) => source(addressed.path, addressed.settings).of({ id }));
93
+ const evidence = await Promise.all(handles.map(async (handle) => await handle.kill()));
94
+ const observations = await Promise.all(addressed.ids.map(async (id) => await statusView(await readActionFeedbackStatus(addressed.path, id), input.repo)));
95
+ return {
96
+ results: addressed.ids.map((id, index) => ({
97
+ id,
98
+ evidence: evidence[index],
99
+ observation: observations[index],
100
+ })),
101
+ };
102
+ }
103
+ export async function tellAkuma(input) {
104
+ const values = requireInput(input, "Keiyaku.tell input");
105
+ for (const key of Object.keys(values)) {
106
+ if (!["path", "akuma", "settings", "body", "repo"].includes(key))
107
+ throw new TypeError(`Keiyaku.tell input has unknown field: ${key}`);
108
+ }
109
+ if (typeof values.body !== "string")
110
+ throw new TypeError("body must be a string");
111
+ const addressed = await addressAkuma(directAddress(values));
112
+ const handle = source(addressed.path, addressed.settings).of({ id: addressed.id });
113
+ const tell = await handle.tell(values.body);
114
+ return { akuma: addressed.id, tell, observation: await statusView(await readActionFeedbackStatus(addressed.path, addressed.id), values.repo) };
115
+ }
116
+ export async function interruptAkuma(input) {
117
+ const values = requireInput(input, "Keiyaku.interrupt input");
118
+ for (const key of Object.keys(values)) {
119
+ if (!["path", "akuma", "settings", "body", "repo"].includes(key))
120
+ throw new TypeError(`Keiyaku.interrupt input has unknown field: ${key}`);
121
+ }
122
+ if (typeof values.body !== "string")
123
+ throw new TypeError("body must be a string");
124
+ const addressed = await addressAkuma(directAddress(values));
125
+ const receipt = await source(addressed.path, addressed.settings).of({ id: addressed.id }).interrupt(values.body);
126
+ return { id: addressed.id, receipt, observation: await statusView(await readActionFeedbackStatus(addressed.path, addressed.id), values.repo) };
127
+ }
128
+ export async function historyAkuma(input) {
129
+ const values = requireInput(input, "Keiyaku.history input");
130
+ for (const key of Object.keys(values)) {
131
+ if (!["path", "akuma", "settings", "before", "since", "limit", "last", "repo"].includes(key)) {
132
+ throw new TypeError(`Keiyaku.history input has unknown field: ${key}`);
133
+ }
134
+ }
135
+ if (values.last !== undefined && typeof values.last !== "boolean")
136
+ throw new TypeError("last must be a boolean");
137
+ const addressed = await addressAkuma(directAddress(values));
138
+ const handle = source(addressed.path, addressed.settings).of({ id: addressed.id });
139
+ if (values.last === true) {
140
+ const answer = await handle.lastAnswer();
141
+ const contractId = await contractFor(values.repo, addressed.id);
142
+ return answer.kind === "answer"
143
+ ? { kind: "last", id: addressed.id, answer: answer.answer, ...(contractId === undefined ? {} : { contractId }) }
144
+ : { kind: "no-answer", id: addressed.id, ...(contractId === undefined ? {} : { contractId }) };
145
+ }
146
+ const history = await handle.history({
147
+ ...(values.before === undefined ? {} : { before: values.before }),
148
+ ...(values.since === undefined ? {} : { since: values.since }),
149
+ ...(values.limit === undefined ? {} : { limit: values.limit }),
150
+ });
151
+ const contractId = await contractFor(values.repo, addressed.id);
152
+ return { kind: "history", id: addressed.id, history, ...(contractId === undefined ? {} : { contractId }) };
153
+ }
@@ -6,7 +6,10 @@ export declare function actorOption(actor: unknown): Readonly<{
6
6
  }>;
7
7
  export declare function requireMarkdown(value: unknown, label?: string): string;
8
8
  export declare function requireInput(value: unknown, label: string): Record<string, unknown>;
9
+ export declare function rejectUnknownFields(values: Record<string, unknown>, allowed: readonly string[], label: string): void;
9
10
  export declare function optionalNonblank(value: unknown, label: string): string | undefined;
11
+ export declare function optionalBoolean(value: unknown, label: string): boolean | undefined;
12
+ export declare function optionalSignal(value: unknown): AbortSignal | undefined;
10
13
  export declare function normalizedList<T>(values: unknown, label: string, brand: (value: string) => T): readonly T[];
11
14
  export declare function normalizedGates(values: unknown): readonly Gate[];
12
15
  export declare function contractTerms(document: DecodedContractDocument, gates: readonly Gate[], after: readonly ContractId[]): ContractTerms;
@@ -22,6 +22,11 @@ export function requireInput(value, label) {
22
22
  throw new TypeError(`${label} must be an object`);
23
23
  return value;
24
24
  }
25
+ export function rejectUnknownFields(values, allowed, label) {
26
+ for (const key of Object.keys(values))
27
+ if (!allowed.includes(key))
28
+ throw new TypeError(`${label} has unknown field: ${key}`);
29
+ }
25
30
  export function optionalNonblank(value, label) {
26
31
  if (value === undefined)
27
32
  return undefined;
@@ -30,6 +35,20 @@ export function optionalNonblank(value, label) {
30
35
  }
31
36
  return value;
32
37
  }
38
+ export function optionalBoolean(value, label) {
39
+ if (value === undefined)
40
+ return undefined;
41
+ if (typeof value !== "boolean")
42
+ throw new TypeError(`${label} must be a boolean`);
43
+ return value;
44
+ }
45
+ export function optionalSignal(value) {
46
+ if (value === undefined)
47
+ return undefined;
48
+ if (!(value instanceof AbortSignal))
49
+ throw new TypeError("signal must be an AbortSignal");
50
+ return value;
51
+ }
33
52
  export function normalizedList(values, label, brand) {
34
53
  if (values === undefined)
35
54
  return [];
@@ -1,12 +1,16 @@
1
1
  import { KeiyakuHandle, bindKeiyaku, keiyakuOf, listKeiyaku, observeKeiyaku, type Keiyaku as KeiyakuType } from "./contract.js";
2
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";
3
5
  export { AuthorityCorruptionError } from "../core/facts/errors.js";
4
6
  export { Delivery, KeiyakuRefused, KeiyakuRetry, } from "./contract.js";
5
7
  export { NoGitWorldError, Repo } from "./repo.js";
6
- export { gatesFrom, SettingsError, worktreeHooksFrom, } from "./configuration.js";
7
- export type { AbandonInput, ActorId, AmendInput, AmendResult, ArcInput, AttestationVerdict, AuditInput, AuditReport, BindInput, BindResult, ContractBoard, ContractDisposition, ContractGateCurrent, ContractGateReport, ContractListInput, ContractObservation, ContractObservationInput, ContractPhase, ContractRow, DeliverInput, Fact, FactKind, KeiyakuOfInput, KeiyakuRefusal, KeiyakuRetryReason, Lag, MutationResult, PlacementStop, ReconcileReport, Review, ReviewInput, TimelineEntry, TaskId, TopologyEffect, VerificationStop, } from "./contract.js";
8
+ export { gatesFrom, requireBranchesToBeUpToDateFrom, SettingsError, } from "./configuration.js";
9
+ export { worktreeHooksFrom } from "../git/hooks.js";
10
+ export { AkumaWorldScopeError } from "./address.js";
11
+ export type { AbandonInput, ActorId, AmendInput, AmendResult, ArcInput, AttestationVerdict, AuditInput, AuditReport, DeliveryPreparationRefusal, BindInput, BindResult, ContractBoard, ContractDisposition, ContractGateCurrent, ContractGateReport, ContractListInput, ContractObservation, ContractObservationInput, ContractPhase, ContractRow, DeliverInput, Fact, FactKind, KeiyakuOfInput, KeiyakuRefusal, KeiyakuRetryReason, Lag, MutationResult, PlacementStop, ReconcileReport, Review, ReviewInput, TaskId, TopologyEffect, VerificationReuse, VerificationStop, } from "./contract.js";
8
12
  export type { ContractId, ContractState, ChangeId, SnapshotId, } from "../core/facts/types.js";
9
- export type { Gate, GatesFromInput, HookCommand, WorktreeHooks, WorktreeHooksFromInput, } from "./configuration.js";
13
+ export type { Gate, GatesFromInput, HookCommand, RequireBranchesToBeUpToDateFromInput, WorktreeHooks, } from "./configuration.js";
10
14
  export type { RegionOverlap } from "./region.js";
11
15
  export type { ReconcileInput, RepoAtInput, RepoReconcileReport, } from "./repo.js";
12
16
  export type { SettlementAction, SettlementLag, SettlementReport, } from "../settlement/settle.js";
@@ -14,7 +18,11 @@ export type { AliasStage, AkumaStatus, CallObservation, CallInput, CallResult, D
14
18
  export type { AliasBinding } from "../alias/index.js";
15
19
  export type { Dispatch, DispatchFailure } from "../dispatch/index.js";
16
20
  export type { AkumaAlias } from "../identity/selector.js";
21
+ export type { AkumaGlob } from "../identity/selector.js";
17
22
  export type { AkuId } from "../akuma/identity.js";
23
+ export type { Catalog, CatalogInput, CatalogQuery } from "./catalog.js";
24
+ export type { AkumaAddressInput, AkumaSetAddressInput, AkumaWorldScopeRefusal, DirectAkumaSelector, SetAkumaSelector, } from "./address.js";
25
+ export type { AkumaHistoryInput, AkumaHistoryResult, AkumaInterruptInput, AkumaInterruptResult, AkumaKillResult, AkumaStatusView, AkumaTellInput, AkumaTellResult, AkumaWaitInput, AkumaWaitResult, } from "./fleet.js";
18
26
  export type Keiyaku = KeiyakuType;
19
27
  export declare const Keiyaku: Readonly<{
20
28
  prototype: KeiyakuHandle;
@@ -22,7 +30,14 @@ export declare const Keiyaku: Readonly<{
22
30
  bind: typeof bindKeiyaku;
23
31
  call: typeof callKeiyaku;
24
32
  fork: typeof forkKeiyaku;
33
+ history: typeof historyAkuma;
34
+ interrupt: typeof interruptAkuma;
35
+ kill: typeof killAkuma;
36
+ ls: typeof listCatalog;
25
37
  list: typeof listKeiyaku;
26
38
  observe: typeof observeKeiyaku;
27
39
  of: typeof keiyakuOf;
40
+ status: typeof statusAkuma;
41
+ tell: typeof tellAkuma;
42
+ wait: typeof waitAkuma;
28
43
  }>;
@@ -1,16 +1,27 @@
1
1
  import { KeiyakuHandle, bindKeiyaku, keiyakuOf, listKeiyaku, observeKeiyaku, } from "./contract.js";
2
2
  import { callKeiyaku, forkKeiyaku } from "./akuma-creation.js";
3
+ import { historyAkuma, interruptAkuma, killAkuma, statusAkuma, tellAkuma, waitAkuma, } from "./fleet.js";
4
+ import { listCatalog } from "./catalog.js";
3
5
  export { AuthorityCorruptionError } from "../core/facts/errors.js";
4
6
  export { Delivery, KeiyakuRefused, KeiyakuRetry, } from "./contract.js";
5
7
  export { NoGitWorldError, Repo } from "./repo.js";
6
- export { gatesFrom, SettingsError, worktreeHooksFrom, } from "./configuration.js";
8
+ export { gatesFrom, requireBranchesToBeUpToDateFrom, SettingsError, } from "./configuration.js";
9
+ export { worktreeHooksFrom } from "../git/hooks.js";
10
+ export { AkumaWorldScopeError } from "./address.js";
7
11
  export const Keiyaku = Object.freeze({
8
12
  prototype: KeiyakuHandle.prototype,
9
13
  [Symbol.hasInstance]: (value) => value instanceof KeiyakuHandle,
10
14
  bind: bindKeiyaku,
11
15
  call: callKeiyaku,
12
16
  fork: forkKeiyaku,
17
+ history: historyAkuma,
18
+ interrupt: interruptAkuma,
19
+ kill: killAkuma,
20
+ ls: listCatalog,
13
21
  list: listKeiyaku,
14
22
  observe: observeKeiyaku,
15
23
  of: keiyakuOf,
24
+ status: statusAkuma,
25
+ tell: tellAkuma,
26
+ wait: waitAkuma,
16
27
  });
@@ -0,0 +1,39 @@
1
+ import type { ContractHead, ContractId, JournalEntry } from "../core/facts/types.js";
2
+ import type { GitDecodeChannel } from "../git/read-observation.js";
3
+ import type { ReconcileReport, RepositoryScope } from "../protocol/operations.js";
4
+ import type { IntentOutcome } from "../protocol/operations.js";
5
+ import type { AcceptedObligations } from "../protocol/outcome.js";
6
+ import { type SettlementReport } from "../settlement/settle.js";
7
+ import type { TaskHolderAdmission } from "../settlement/holder.js";
8
+ import type { WorktreeHooks } from "./configuration.js";
9
+ import { type ReconcileCompletion } from "./reconcile.js";
10
+ export type AcceptedIntent<Value> = Readonly<{
11
+ kind: "accepted";
12
+ facts: readonly JournalEntry[];
13
+ head: ContractHead;
14
+ value: Value;
15
+ physical?: ReconcileReport;
16
+ } & AcceptedObligations>;
17
+ export type MutationResult<Value> = Readonly<{
18
+ facts: readonly JournalEntry[];
19
+ head: ContractHead;
20
+ value: Value;
21
+ effects: ReconcileCompletion["effects"];
22
+ lags: ReconcileCompletion["lag"];
23
+ settlement: SettlementReport;
24
+ } & AcceptedObligations>;
25
+ type Completion<Value, PublicValue> = Readonly<{
26
+ scope: RepositoryScope;
27
+ channel: GitDecodeChannel;
28
+ contractId: ContractId;
29
+ accepted: AcceptedIntent<Value>;
30
+ value: (result: Value) => PublicValue;
31
+ hooks: WorktreeHooks;
32
+ }>;
33
+ export declare function completeMutation<Value, PublicValue>(input: Completion<Value, PublicValue>): Promise<MutationResult<PublicValue>>;
34
+ export declare function completeHolderMutation<Value, PublicValue, Refusal>(input: Readonly<{
35
+ completion: Omit<Completion<Value, PublicValue>, "accepted">;
36
+ admission: TaskHolderAdmission<IntentOutcome<Value, Refusal>>;
37
+ requireAccepted: (result: IntentOutcome<Value, Refusal>) => AcceptedIntent<Value>;
38
+ }>): Promise<MutationResult<PublicValue>>;
39
+ export {};
@@ -0,0 +1,37 @@
1
+ import { deferredTaskHolderSettlement } from "../settlement/settle.js";
2
+ import { completeReconcile } from "./reconcile.js";
3
+ export async function completeMutation(input) {
4
+ const { scope, channel, contractId, accepted, value, hooks } = input;
5
+ const report = await completeReconcile({ scope, channel, contractId, hooks, retryHooks: false });
6
+ const obligations = {
7
+ ...(accepted.cleanup === undefined ? {} : { cleanup: accepted.cleanup }),
8
+ ...(accepted.leak === undefined ? {} : { leak: accepted.leak }),
9
+ };
10
+ return {
11
+ facts: accepted.facts,
12
+ head: accepted.head,
13
+ value: value(accepted.value),
14
+ effects: [...(accepted.physical?.effects ?? []), ...report.effects],
15
+ lags: [...(accepted.physical?.lag ?? []), ...report.lag],
16
+ settlement: report.settlement,
17
+ ...obligations,
18
+ };
19
+ }
20
+ export async function completeHolderMutation(input) {
21
+ const accepted = input.requireAccepted(input.admission.result);
22
+ const completed = await completeMutation({ ...input.completion, accepted });
23
+ if (input.admission.kind === "completed")
24
+ return completed;
25
+ const deferred = deferredTaskHolderSettlement({
26
+ contractId: input.completion.contractId,
27
+ taskId: input.admission.taskId,
28
+ diagnostic: input.admission.diagnostic,
29
+ });
30
+ return {
31
+ ...completed,
32
+ settlement: {
33
+ actions: completed.settlement.actions,
34
+ lags: [...completed.settlement.lags, ...deferred.lags],
35
+ },
36
+ };
37
+ }
@@ -0,0 +1,29 @@
1
+ import type { ContractId } from "../core/facts/types.js";
2
+ import type { GitDecodeChannel } from "../git/read-observation.js";
3
+ import { type ReconcileReport, type RepositoryScope } from "../protocol/operations.js";
4
+ import { type SettlementReport } from "../settlement/settle.js";
5
+ import type { WorktreeHooks } from "./configuration.js";
6
+ import { type ContractFileEffect, type ContractFileLag } from "../contract-worktree.js";
7
+ export type ReconcileCompletion = Readonly<{
8
+ effects: readonly (ReconcileReport["effects"][number] | ContractFileEffect)[];
9
+ lag: readonly (ReconcileReport["lag"][number] | ContractFileLag)[];
10
+ settlement: SettlementReport;
11
+ }>;
12
+ export type RepoContractReconcileReport = ReconcileCompletion;
13
+ export type RepoReconcileReport = Readonly<{
14
+ contracts: readonly Readonly<{
15
+ contractId: ContractId;
16
+ report: RepoContractReconcileReport;
17
+ }>[];
18
+ }>;
19
+ type ReconcileOptions = Readonly<{
20
+ scope: RepositoryScope;
21
+ channel: GitDecodeChannel;
22
+ hooks: WorktreeHooks;
23
+ retryHooks: boolean;
24
+ }>;
25
+ export declare function completeReconcile(input: ReconcileOptions & Readonly<{
26
+ contractId: ContractId;
27
+ }>): Promise<ReconcileCompletion>;
28
+ export declare function completeRepoReconcile(input: ReconcileOptions): Promise<RepoReconcileReport>;
29
+ export {};