@astrosheep/keiyaku 4.5.6 → 4.5.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (245) hide show
  1. package/README.md +10 -0
  2. package/build/integrations/marketplace/plugins/keiyaku/.claude-plugin/plugin.json +1 -1
  3. package/build/integrations/marketplace/plugins/keiyaku/.codex-plugin/plugin.json +1 -1
  4. package/build/integrations/marketplace/plugins/keiyaku/opencode.js +3 -2
  5. package/build/integrations/marketplace/plugins/keiyaku/package.json +1 -1
  6. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku/SKILL.md +10 -8
  7. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-akuma/SKILL.md +22 -1
  8. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-babysit/SKILL.md +53 -0
  9. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-bind/SKILL.md +28 -49
  10. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-task/SKILL.md +21 -15
  11. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-workflow/SKILL.md +148 -89
  12. package/build/src/akuma/abort.d.ts +2 -1
  13. package/build/src/akuma/abort.js +6 -23
  14. package/build/src/akuma/akuma-handle.js +4 -2
  15. package/build/src/akuma/akuma-observe.d.ts +2 -0
  16. package/build/src/akuma/akuma-observe.js +1 -0
  17. package/build/src/akuma/akuma-product.js +9 -7
  18. package/build/src/akuma/akuma.d.ts +372 -9
  19. package/build/src/akuma/akuma.js +31 -1
  20. package/build/src/akuma/allowed.d.ts +1 -1
  21. package/build/src/akuma/allowed.js +1 -0
  22. package/build/src/akuma/body.d.ts +7 -5
  23. package/build/src/akuma/body.js +25 -36
  24. package/build/src/akuma/call-request.d.ts +80 -0
  25. package/build/src/akuma/call-request.js +211 -0
  26. package/build/src/akuma/heart/facts.d.ts +6 -78
  27. package/build/src/akuma/heart/index.d.ts +3 -3
  28. package/build/src/akuma/heart/index.js +2 -2
  29. package/build/src/akuma/heart/request-authority.d.ts +6 -4
  30. package/build/src/akuma/heart/request-authority.js +31 -35
  31. package/build/src/akuma/heart/request-rows.js +12 -23
  32. package/build/src/akuma/heart/schema.d.ts +1 -1
  33. package/build/src/akuma/heart/schema.js +5 -13
  34. package/build/src/akuma/heart/storage.d.ts +0 -1
  35. package/build/src/akuma/heart/storage.js +0 -54
  36. package/build/src/akuma/index.d.ts +1 -1
  37. package/build/src/akuma/index.js +1 -1
  38. package/build/src/akuma/projection-read.d.ts +1 -0
  39. package/build/src/akuma/projection-read.js +8 -1
  40. package/build/src/akuma/projection.d.ts +856 -137
  41. package/build/src/akuma/projection.js +190 -0
  42. package/build/src/akuma/provider.d.ts +30 -3
  43. package/build/src/akuma/provider.js +104 -0
  44. package/build/src/akuma/providers/acp/core.d.ts +2 -2
  45. package/build/src/akuma/providers/acp/core.js +13 -6
  46. package/build/src/akuma/providers/acp/index.js +5 -4
  47. package/build/src/akuma/providers/claude/index.d.ts +3 -3
  48. package/build/src/akuma/providers/claude/index.js +16 -5
  49. package/build/src/akuma/providers/codex-app-server/events.js +1 -1
  50. package/build/src/akuma/providers/codex-app-server/index.js +18 -6
  51. package/build/src/akuma/providers/grok-build/index.js +5 -4
  52. package/build/src/akuma/providers/opencode-sdk/index.js +66 -25
  53. package/build/src/akuma/providers/opencode-sdk/session.d.ts +3 -2
  54. package/build/src/akuma/providers/opencode-sdk/session.js +28 -11
  55. package/build/src/akuma/providers/pi/index.js +42 -14
  56. package/build/src/akuma/publication.js +75 -13
  57. package/build/src/akuma/request-lifecycle.d.ts +3 -9
  58. package/build/src/akuma/request-lifecycle.js +12 -25
  59. package/build/src/akuma/request-rendezvous.d.ts +26 -0
  60. package/build/src/akuma/request-rendezvous.js +100 -0
  61. package/build/src/akuma/request-serve.d.ts +5 -65
  62. package/build/src/akuma/request-serve.js +92 -204
  63. package/build/src/akuma/request-wire.d.ts +109 -115
  64. package/build/src/akuma/request-wire.js +63 -318
  65. package/build/src/akuma/requests.d.ts +19 -47
  66. package/build/src/akuma/requests.js +51 -107
  67. package/build/src/akuma/turn-drive.d.ts +5 -3
  68. package/build/src/akuma/turn-drive.js +32 -10
  69. package/build/src/akuma-body.d.ts +7 -2
  70. package/build/src/akuma-body.js +68 -46
  71. package/build/src/cli/accepted.d.ts +1 -1
  72. package/build/src/cli/accepted.js +2 -2
  73. package/build/src/cli/commands/akuma-invoke.d.ts +2 -0
  74. package/build/src/cli/commands/akuma-invoke.js +17 -9
  75. package/build/src/cli/commands/akuma.js +7 -7
  76. package/build/src/cli/commands/contract-invoke.d.ts +3 -2
  77. package/build/src/cli/commands/contract-invoke.js +26 -19
  78. package/build/src/cli/commands/contract.d.ts +13 -13
  79. package/build/src/cli/commands/contract.js +32 -17
  80. package/build/src/cli/commands/install.d.ts +1 -1
  81. package/build/src/cli/commands/install.js +1 -1
  82. package/build/src/cli/commands/task-invoke.d.ts +7 -2
  83. package/build/src/cli/commands/task-invoke.js +67 -158
  84. package/build/src/cli/commands/task.d.ts +1 -1
  85. package/build/src/cli/commands/task.js +60 -22
  86. package/build/src/cli/coordinates.d.ts +2 -0
  87. package/build/src/cli/coordinates.js +18 -2
  88. package/build/src/cli/invoke.js +39 -25
  89. package/build/src/cli/main.js +2 -1
  90. package/build/src/cli/parse.d.ts +2 -2
  91. package/build/src/cli/parse.js +37 -22
  92. package/build/src/cli/render/akuma-activity.d.ts +4 -1
  93. package/build/src/cli/render/akuma-activity.js +45 -30
  94. package/build/src/cli/render/akuma-tool.d.ts +5 -1
  95. package/build/src/cli/render/akuma.js +5 -9
  96. package/build/src/cli/render/audit.js +1 -1
  97. package/build/src/cli/render/catalog.js +80 -21
  98. package/build/src/cli/render/contract-observation.d.ts +2 -0
  99. package/build/src/cli/render/contract-observation.js +11 -0
  100. package/build/src/cli/render/contract.js +25 -65
  101. package/build/src/cli/render/kanshi-akuma.d.ts +8 -0
  102. package/build/src/cli/render/kanshi-akuma.js +111 -0
  103. package/build/src/cli/render/kanshi.js +108 -213
  104. package/build/src/cli/render/receipt.d.ts +1 -2
  105. package/build/src/cli/render/receipt.js +76 -26
  106. package/build/src/cli/render/refusal.js +2 -10
  107. package/build/src/cli/render/region.js +5 -2
  108. package/build/src/cli/render/settings.d.ts +1 -1
  109. package/build/src/cli/render/settings.js +27 -8
  110. package/build/src/cli/render/task.js +28 -10
  111. package/build/src/cli/render/terminal.d.ts +28 -0
  112. package/build/src/cli/render/terminal.js +65 -0
  113. package/build/src/cli/result.d.ts +3 -3
  114. package/build/src/cli/runtime.js +3 -1
  115. package/build/src/cli/selectors.d.ts +2 -1
  116. package/build/src/cli/selectors.js +4 -3
  117. package/build/src/cli/square-edge.js +120 -36
  118. package/build/src/cli/usage.js +2 -1
  119. package/build/src/contract-guidance.d.ts +5 -0
  120. package/build/src/contract-guidance.js +121 -0
  121. package/build/src/contract-worktree.d.ts +0 -1
  122. package/build/src/contract-worktree.js +32 -83
  123. package/build/src/coordination/sqlite-transaction-lock.d.ts +1 -0
  124. package/build/src/coordination/sqlite-transaction-lock.js +5 -0
  125. package/build/src/core/facts/codec.d.ts +2 -0
  126. package/build/src/core/facts/codec.js +4 -0
  127. package/build/src/core/verbs/placement.d.ts +6 -1
  128. package/build/src/core/verbs/placement.js +5 -3
  129. package/build/src/dispatch/index.d.ts +0 -2
  130. package/build/src/dispatch/index.js +54 -55
  131. package/build/src/git/admission.js +2 -2
  132. package/build/src/git/hooks.d.ts +9 -15
  133. package/build/src/git/hooks.js +23 -317
  134. package/build/src/git/nuke.d.ts +2 -1
  135. package/build/src/git/nuke.js +36 -18
  136. package/build/src/git/private-state-seat.d.ts +12 -0
  137. package/build/src/git/private-state-seat.js +39 -0
  138. package/build/src/git/process.d.ts +6 -0
  139. package/build/src/git/process.js +19 -7
  140. package/build/src/git/read-observation.js +29 -20
  141. package/build/src/git/reconcile.d.ts +11 -0
  142. package/build/src/git/reconcile.js +64 -11
  143. package/build/src/git/repository.d.ts +8 -2
  144. package/build/src/git/repository.js +42 -21
  145. package/build/src/git/target-placement.d.ts +1 -0
  146. package/build/src/git/target-placement.js +5 -6
  147. package/build/src/git/tender.d.ts +1 -0
  148. package/build/src/git/terminal-reconcile.d.ts +1 -1
  149. package/build/src/git/terminal-reconcile.js +22 -20
  150. package/build/src/git/workspace.d.ts +14 -0
  151. package/build/src/git/workspace.js +44 -0
  152. package/build/src/kanshi/index.d.ts +1 -1
  153. package/build/src/kanshi/read.js +16 -16
  154. package/build/src/kanshi/report.d.ts +2 -2
  155. package/build/src/library/address.d.ts +9 -3
  156. package/build/src/library/address.js +3 -2
  157. package/build/src/library/akuma-creation.d.ts +4 -3
  158. package/build/src/library/akuma-creation.js +19 -13
  159. package/build/src/library/audit.d.ts +1 -1
  160. package/build/src/library/audit.js +5 -3
  161. package/build/src/library/catalog.d.ts +3 -1
  162. package/build/src/library/catalog.js +20 -6
  163. package/build/src/library/composition.d.ts +371 -0
  164. package/build/src/library/composition.js +28 -0
  165. package/build/src/library/configuration.js +8 -2
  166. package/build/src/library/continuation.js +66 -30
  167. package/build/src/library/contract-bind.js +10 -2
  168. package/build/src/library/contract-forwarding-reconciliation-result.d.ts +96 -0
  169. package/build/src/library/contract-forwarding-reconciliation-result.js +83 -0
  170. package/build/src/library/contract-forwarding-result.d.ts +6723 -0
  171. package/build/src/library/contract-forwarding-result.js +521 -0
  172. package/build/src/library/contract-forwarding.d.ts +72 -0
  173. package/build/src/library/contract-forwarding.js +125 -0
  174. package/build/src/library/contract-handle.d.ts +36 -0
  175. package/build/src/library/contract-handle.js +313 -0
  176. package/build/src/library/contract-operations.d.ts +1044 -67
  177. package/build/src/library/contract-operations.js +190 -118
  178. package/build/src/library/contract.d.ts +11 -32
  179. package/build/src/library/contract.js +16 -289
  180. package/build/src/library/fleet-result.d.ts +1454 -0
  181. package/build/src/library/fleet-result.js +96 -0
  182. package/build/src/library/fleet.d.ts +112 -54
  183. package/build/src/library/fleet.js +211 -71
  184. package/build/src/library/input.d.ts +2 -0
  185. package/build/src/library/input.js +4 -0
  186. package/build/src/library/keiyaku.d.ts +371 -20
  187. package/build/src/library/keiyaku.js +8 -21
  188. package/build/src/library/mutation.d.ts +3 -3
  189. package/build/src/library/mutation.js +5 -9
  190. package/build/src/library/nuke.d.ts +1 -1
  191. package/build/src/library/nuke.js +4 -3
  192. package/build/src/library/reconcile.d.ts +4 -0
  193. package/build/src/library/reconcile.js +2 -0
  194. package/build/src/library/refusal.d.ts +0 -9
  195. package/build/src/library/refusal.js +0 -7
  196. package/build/src/protocol/amend.js +56 -50
  197. package/build/src/protocol/attempt.d.ts +2 -0
  198. package/build/src/protocol/attempt.js +17 -5
  199. package/build/src/protocol/completion.js +7 -0
  200. package/build/src/protocol/deliver.js +6 -2
  201. package/build/src/protocol/operations.d.ts +4 -1
  202. package/build/src/protocol/operations.js +5 -2
  203. package/build/src/protocol/placement.d.ts +1 -0
  204. package/build/src/protocol/placement.js +52 -38
  205. package/build/src/protocol/read/observation.d.ts +1 -4
  206. package/build/src/protocol/read/observation.js +2 -15
  207. package/build/src/protocol/reintegrate.js +62 -58
  208. package/build/src/protocol/review.js +5 -0
  209. package/build/src/protocol/run.js +17 -13
  210. package/build/src/runtime/proc/run.d.ts +8 -0
  211. package/build/src/runtime/proc/run.js +27 -0
  212. package/build/src/runtime/proc/termination.js +26 -22
  213. package/build/src/runtime/proc/windows-launch.exe +0 -0
  214. package/build/src/settlement/holder.d.ts +2 -1
  215. package/build/src/settlement/holder.js +15 -4
  216. package/build/src/settlement/settle.js +99 -33
  217. package/build/src/task/board.d.ts +68 -27
  218. package/build/src/task/board.js +31 -1
  219. package/build/src/task/catalog.d.ts +4 -0
  220. package/build/src/task/catalog.js +23 -0
  221. package/build/src/task/compose-language.d.ts +4 -0
  222. package/build/src/task/compose-language.js +40 -7
  223. package/build/src/task/compose-parser.d.ts +2 -1
  224. package/build/src/task/compose-parser.js +5 -3
  225. package/build/src/task/compose.d.ts +1 -0
  226. package/build/src/task/compose.js +4 -1
  227. package/build/src/task/context.d.ts +7 -1
  228. package/build/src/task/context.js +25 -6
  229. package/build/src/task/index.d.ts +18 -5
  230. package/build/src/task/index.js +97 -16
  231. package/build/src/task/mutation-result.d.ts +923 -0
  232. package/build/src/task/mutation-result.js +140 -0
  233. package/build/src/task/mutation.d.ts +552 -28
  234. package/build/src/task/mutation.js +304 -97
  235. package/build/src/task/operations.d.ts +1 -4
  236. package/build/src/task/operations.js +0 -6
  237. package/build/src/task/public.d.ts +2 -0
  238. package/build/src/task/public.js +1 -0
  239. package/build/src/workspace-place.d.ts +7 -2
  240. package/build/src/workspace-place.js +34 -24
  241. package/build/src/world.d.ts +1 -0
  242. package/build/src/world.js +11 -0
  243. package/package.json +8 -6
  244. package/build/src/akuma/request-execution.d.ts +0 -8
  245. package/build/src/akuma/request-execution.js +0 -98
@@ -1,10 +1,11 @@
1
1
  import { type TellResult, type TellWakeRuntime } from "./body.js";
2
- import { HeldAkumaLeash, type AkumaLife, type KillEvidence, type ResumeCoordinate, type Soul } from "./heart/index.js";
2
+ import { HeldAkumaLeash, type AkumaLife, type KillEvidence, type ResumeCoordinate } from "./heart/index.js";
3
3
  import { type AkuId, type AkumaPaths } from "./identity.js";
4
- import type { ActivitySnapshot } from "./projection.js";
5
4
  import type { Settings } from "../settings.js";
6
5
  import type { WorldRoot } from "../world.js";
7
6
  import type { AllowedAction } from "./allowed.js";
7
+ import type { ExecutionContext } from "./requests.js";
8
+ import { z } from "zod";
8
9
  export declare const POLL_MS = 100;
9
10
  export declare function canonicalBirthCwd(input: string): Promise<string>;
10
11
  export declare function callReadonly(value: unknown): Readonly<{
@@ -19,13 +20,373 @@ export type AkumaListRow = Readonly<{
19
20
  lastActivityAt: string | null;
20
21
  pending: readonly string[];
21
22
  }>;
22
- export type AkumaStatus = Readonly<{
23
- id: AkuId;
24
- life: AkumaLife;
25
- readonly?: Soul["readonly"];
26
- timeline: ActivitySnapshot;
27
- strandedReason?: "resume-unsupported";
28
- }>;
23
+ export declare const akumaIdSchema: z.ZodPipe<z.ZodString, z.ZodTransform<AkuId, string>>;
24
+ export declare const akumaStatusSchema: z.ZodObject<{
25
+ id: z.ZodPipe<z.ZodString, z.ZodTransform<AkuId, string>>;
26
+ life: z.ZodEnum<{
27
+ killed: "killed";
28
+ hung: "hung";
29
+ untidy: "untidy";
30
+ running: "running";
31
+ asleep: "asleep";
32
+ stranded: "stranded";
33
+ }>;
34
+ readonly: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
35
+ enforcement: z.ZodLiteral<"native">;
36
+ }, z.core.$strict>, z.ZodObject<{
37
+ enforcement: z.ZodLiteral<"none">;
38
+ diagnostic: z.ZodString;
39
+ }, z.core.$strict>]>>;
40
+ timeline: z.ZodUnion<readonly [z.ZodObject<{
41
+ reportedChanges: z.ZodReadonly<z.ZodArray<z.ZodObject<{
42
+ sequence: z.ZodNumber;
43
+ at: z.ZodString;
44
+ op: z.ZodEnum<{
45
+ add: "add";
46
+ update: "update";
47
+ delete: "delete";
48
+ unspecified: "unspecified";
49
+ }>;
50
+ path: z.ZodString;
51
+ diffstat: z.ZodOptional<z.ZodObject<{
52
+ added: z.ZodNumber;
53
+ removed: z.ZodNumber;
54
+ }, z.core.$strict>>;
55
+ }, z.core.$strict>>>;
56
+ reportedChangesOmitted: z.ZodNumber;
57
+ kind: z.ZodLiteral<"unborn">;
58
+ entries: z.ZodReadonly<z.ZodTuple<[], null>>;
59
+ omitted: z.ZodLiteral<0>;
60
+ }, z.core.$strict>, z.ZodObject<{
61
+ reportedChanges: z.ZodReadonly<z.ZodArray<z.ZodObject<{
62
+ sequence: z.ZodNumber;
63
+ at: z.ZodString;
64
+ op: z.ZodEnum<{
65
+ add: "add";
66
+ update: "update";
67
+ delete: "delete";
68
+ unspecified: "unspecified";
69
+ }>;
70
+ path: z.ZodString;
71
+ diffstat: z.ZodOptional<z.ZodObject<{
72
+ added: z.ZodNumber;
73
+ removed: z.ZodNumber;
74
+ }, z.core.$strict>>;
75
+ }, z.core.$strict>>>;
76
+ reportedChangesOmitted: z.ZodNumber;
77
+ kind: z.ZodLiteral<"open">;
78
+ turn: z.ZodObject<{
79
+ kind: z.ZodLiteral<"turn">;
80
+ sequence: z.ZodNumber;
81
+ turnSequence: z.ZodNumber;
82
+ bodySequence: z.ZodNumber;
83
+ at: z.ZodString;
84
+ }, z.core.$strict>;
85
+ entries: z.ZodReadonly<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
86
+ kind: z.ZodLiteral<"gap">;
87
+ count: z.ZodNumber;
88
+ }, z.core.$strict>, z.ZodObject<{
89
+ kind: z.ZodLiteral<"row">;
90
+ row: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodObject<{
91
+ kind: z.ZodLiteral<"call">;
92
+ sequence: z.ZodNumber;
93
+ turnSequence: z.ZodNumber;
94
+ at: z.ZodString;
95
+ text: z.ZodString;
96
+ }, z.core.$strict>, z.ZodObject<{
97
+ kind: z.ZodLiteral<"note" | "thought" | "said">;
98
+ sequence: z.ZodNumber;
99
+ turnSequence: z.ZodNumber;
100
+ at: z.ZodString;
101
+ text: z.ZodString;
102
+ truncated: z.ZodOptional<z.ZodLiteral<true>>;
103
+ }, z.core.$strict>, z.ZodObject<{
104
+ kind: z.ZodLiteral<"note" | "thought" | "said">;
105
+ sequence: z.ZodNumber;
106
+ turnSequence: z.ZodNumber;
107
+ at: z.ZodString;
108
+ text: z.ZodString;
109
+ truncated: z.ZodOptional<z.ZodLiteral<true>>;
110
+ }, z.core.$strict>, z.ZodObject<{
111
+ kind: z.ZodLiteral<"note" | "thought" | "said">;
112
+ sequence: z.ZodNumber;
113
+ turnSequence: z.ZodNumber;
114
+ at: z.ZodString;
115
+ text: z.ZodString;
116
+ truncated: z.ZodOptional<z.ZodLiteral<true>>;
117
+ }, z.core.$strict>, z.ZodObject<{
118
+ kind: z.ZodLiteral<"tell">;
119
+ sequence: z.ZodNumber;
120
+ at: z.ZodString;
121
+ tellId: z.ZodString;
122
+ text: z.ZodString;
123
+ state: z.ZodEnum<{
124
+ pending: "pending";
125
+ told: "told";
126
+ }>;
127
+ deliveries: z.ZodReadonly<z.ZodArray<z.ZodObject<{
128
+ deliveredAt: z.ZodString;
129
+ route: z.ZodEnum<{
130
+ live: "live";
131
+ launch: "launch";
132
+ }>;
133
+ turnSequence: z.ZodNumber;
134
+ receipt: z.ZodOptional<z.ZodEnum<{
135
+ required: "required";
136
+ unavailable: "unavailable";
137
+ }>>;
138
+ }, z.core.$strict>>>;
139
+ }, z.core.$strict>]>, z.ZodObject<{
140
+ kind: z.ZodLiteral<"tool">;
141
+ sequence: z.ZodNumber;
142
+ turnSequence: z.ZodNumber;
143
+ at: z.ZodString;
144
+ name: z.ZodString;
145
+ call: z.ZodUnion<readonly [z.ZodObject<{
146
+ kind: z.ZodLiteral<"run">;
147
+ command: z.ZodString;
148
+ }, z.core.$strict>, z.ZodObject<{
149
+ kind: z.ZodLiteral<"read">;
150
+ path: z.ZodString;
151
+ offset: z.ZodOptional<z.ZodNumber>;
152
+ limit: z.ZodOptional<z.ZodNumber>;
153
+ }, z.core.$strict>, z.ZodObject<{
154
+ kind: z.ZodLiteral<"search">;
155
+ query: z.ZodString;
156
+ scope: z.ZodOptional<z.ZodEnum<{
157
+ content: "content";
158
+ files: "files";
159
+ web: "web";
160
+ }>>;
161
+ path: z.ZodOptional<z.ZodString>;
162
+ glob: z.ZodOptional<z.ZodString>;
163
+ }, z.core.$strict>, z.ZodObject<{
164
+ kind: z.ZodLiteral<"fileChange">;
165
+ changes: z.ZodReadonly<z.ZodArray<z.ZodObject<{
166
+ op: z.ZodEnum<{
167
+ add: "add";
168
+ update: "update";
169
+ delete: "delete";
170
+ unspecified: "unspecified";
171
+ }>;
172
+ path: z.ZodString;
173
+ diffstat: z.ZodOptional<z.ZodObject<{
174
+ added: z.ZodNumber;
175
+ removed: z.ZodNumber;
176
+ }, z.core.$strict>>;
177
+ }, z.core.$strict>>>;
178
+ }, z.core.$strict>, z.ZodObject<{
179
+ kind: z.ZodLiteral<"other">;
180
+ display: z.ZodString;
181
+ }, z.core.$strict>]>;
182
+ state: z.ZodLiteral<"active">;
183
+ truncated: z.ZodOptional<z.ZodLiteral<true>>;
184
+ }, z.core.$strict>, z.ZodObject<{
185
+ kind: z.ZodLiteral<"tool">;
186
+ sequence: z.ZodNumber;
187
+ turnSequence: z.ZodNumber;
188
+ at: z.ZodString;
189
+ completedAt: z.ZodOptional<z.ZodString>;
190
+ durationMs: z.ZodOptional<z.ZodNumber>;
191
+ name: z.ZodString;
192
+ call: z.ZodUnion<readonly [z.ZodObject<{
193
+ kind: z.ZodLiteral<"run">;
194
+ command: z.ZodString;
195
+ }, z.core.$strict>, z.ZodObject<{
196
+ kind: z.ZodLiteral<"read">;
197
+ path: z.ZodString;
198
+ offset: z.ZodOptional<z.ZodNumber>;
199
+ limit: z.ZodOptional<z.ZodNumber>;
200
+ }, z.core.$strict>, z.ZodObject<{
201
+ kind: z.ZodLiteral<"search">;
202
+ query: z.ZodString;
203
+ scope: z.ZodOptional<z.ZodEnum<{
204
+ content: "content";
205
+ files: "files";
206
+ web: "web";
207
+ }>>;
208
+ path: z.ZodOptional<z.ZodString>;
209
+ glob: z.ZodOptional<z.ZodString>;
210
+ }, z.core.$strict>, z.ZodObject<{
211
+ kind: z.ZodLiteral<"fileChange">;
212
+ changes: z.ZodReadonly<z.ZodArray<z.ZodObject<{
213
+ op: z.ZodEnum<{
214
+ add: "add";
215
+ update: "update";
216
+ delete: "delete";
217
+ unspecified: "unspecified";
218
+ }>;
219
+ path: z.ZodString;
220
+ diffstat: z.ZodOptional<z.ZodObject<{
221
+ added: z.ZodNumber;
222
+ removed: z.ZodNumber;
223
+ }, z.core.$strict>>;
224
+ }, z.core.$strict>>>;
225
+ }, z.core.$strict>, z.ZodObject<{
226
+ kind: z.ZodLiteral<"other">;
227
+ display: z.ZodString;
228
+ }, z.core.$strict>]>;
229
+ state: z.ZodObject<{
230
+ status: z.ZodEnum<{
231
+ error: "error";
232
+ ok: "ok";
233
+ }>;
234
+ message: z.ZodOptional<z.ZodString>;
235
+ exitCode: z.ZodOptional<z.ZodNumber>;
236
+ }, z.core.$strict>;
237
+ truncated: z.ZodOptional<z.ZodLiteral<true>>;
238
+ }, z.core.$strict>]>;
239
+ }, z.core.$strict>]>>>;
240
+ omitted: z.ZodNumber;
241
+ }, z.core.$strict>, z.ZodObject<{
242
+ reportedChanges: z.ZodReadonly<z.ZodArray<z.ZodObject<{
243
+ sequence: z.ZodNumber;
244
+ at: z.ZodString;
245
+ op: z.ZodEnum<{
246
+ add: "add";
247
+ update: "update";
248
+ delete: "delete";
249
+ unspecified: "unspecified";
250
+ }>;
251
+ path: z.ZodString;
252
+ diffstat: z.ZodOptional<z.ZodObject<{
253
+ added: z.ZodNumber;
254
+ removed: z.ZodNumber;
255
+ }, z.core.$strict>>;
256
+ }, z.core.$strict>>>;
257
+ reportedChangesOmitted: z.ZodNumber;
258
+ kind: z.ZodLiteral<"idle">;
259
+ outcome: z.ZodOptional<z.ZodObject<{
260
+ kind: z.ZodLiteral<"outcome">;
261
+ sequence: z.ZodNumber;
262
+ turnSequence: z.ZodNumber;
263
+ at: z.ZodString;
264
+ outcome: z.ZodUnion<readonly [z.ZodObject<{
265
+ kind: z.ZodLiteral<"answered">;
266
+ historyId: z.ZodString;
267
+ answer: z.ZodString;
268
+ }, z.core.$strict>, z.ZodObject<{
269
+ kind: z.ZodLiteral<"failed">;
270
+ historyId: z.ZodString;
271
+ diagnostic: z.ZodString;
272
+ }, z.core.$strict>]>;
273
+ }, z.core.$strict>>;
274
+ entries: z.ZodReadonly<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
275
+ kind: z.ZodLiteral<"gap">;
276
+ count: z.ZodNumber;
277
+ }, z.core.$strict>, z.ZodObject<{
278
+ kind: z.ZodLiteral<"row">;
279
+ row: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodObject<{
280
+ kind: z.ZodLiteral<"call">;
281
+ sequence: z.ZodNumber;
282
+ turnSequence: z.ZodNumber;
283
+ at: z.ZodString;
284
+ text: z.ZodString;
285
+ }, z.core.$strict>, z.ZodObject<{
286
+ kind: z.ZodLiteral<"note" | "thought" | "said">;
287
+ sequence: z.ZodNumber;
288
+ turnSequence: z.ZodNumber;
289
+ at: z.ZodString;
290
+ text: z.ZodString;
291
+ truncated: z.ZodOptional<z.ZodLiteral<true>>;
292
+ }, z.core.$strict>, z.ZodObject<{
293
+ kind: z.ZodLiteral<"note" | "thought" | "said">;
294
+ sequence: z.ZodNumber;
295
+ turnSequence: z.ZodNumber;
296
+ at: z.ZodString;
297
+ text: z.ZodString;
298
+ truncated: z.ZodOptional<z.ZodLiteral<true>>;
299
+ }, z.core.$strict>, z.ZodObject<{
300
+ kind: z.ZodLiteral<"note" | "thought" | "said">;
301
+ sequence: z.ZodNumber;
302
+ turnSequence: z.ZodNumber;
303
+ at: z.ZodString;
304
+ text: z.ZodString;
305
+ truncated: z.ZodOptional<z.ZodLiteral<true>>;
306
+ }, z.core.$strict>, z.ZodObject<{
307
+ kind: z.ZodLiteral<"tell">;
308
+ sequence: z.ZodNumber;
309
+ at: z.ZodString;
310
+ tellId: z.ZodString;
311
+ text: z.ZodString;
312
+ state: z.ZodEnum<{
313
+ pending: "pending";
314
+ told: "told";
315
+ }>;
316
+ deliveries: z.ZodReadonly<z.ZodArray<z.ZodObject<{
317
+ deliveredAt: z.ZodString;
318
+ route: z.ZodEnum<{
319
+ live: "live";
320
+ launch: "launch";
321
+ }>;
322
+ turnSequence: z.ZodNumber;
323
+ receipt: z.ZodOptional<z.ZodEnum<{
324
+ required: "required";
325
+ unavailable: "unavailable";
326
+ }>>;
327
+ }, z.core.$strict>>>;
328
+ }, z.core.$strict>]>, z.ZodObject<{
329
+ kind: z.ZodLiteral<"tool">;
330
+ sequence: z.ZodNumber;
331
+ turnSequence: z.ZodNumber;
332
+ at: z.ZodString;
333
+ completedAt: z.ZodOptional<z.ZodString>;
334
+ durationMs: z.ZodOptional<z.ZodNumber>;
335
+ name: z.ZodString;
336
+ call: z.ZodUnion<readonly [z.ZodObject<{
337
+ kind: z.ZodLiteral<"run">;
338
+ command: z.ZodString;
339
+ }, z.core.$strict>, z.ZodObject<{
340
+ kind: z.ZodLiteral<"read">;
341
+ path: z.ZodString;
342
+ offset: z.ZodOptional<z.ZodNumber>;
343
+ limit: z.ZodOptional<z.ZodNumber>;
344
+ }, z.core.$strict>, z.ZodObject<{
345
+ kind: z.ZodLiteral<"search">;
346
+ query: z.ZodString;
347
+ scope: z.ZodOptional<z.ZodEnum<{
348
+ content: "content";
349
+ files: "files";
350
+ web: "web";
351
+ }>>;
352
+ path: z.ZodOptional<z.ZodString>;
353
+ glob: z.ZodOptional<z.ZodString>;
354
+ }, z.core.$strict>, z.ZodObject<{
355
+ kind: z.ZodLiteral<"fileChange">;
356
+ changes: z.ZodReadonly<z.ZodArray<z.ZodObject<{
357
+ op: z.ZodEnum<{
358
+ add: "add";
359
+ update: "update";
360
+ delete: "delete";
361
+ unspecified: "unspecified";
362
+ }>;
363
+ path: z.ZodString;
364
+ diffstat: z.ZodOptional<z.ZodObject<{
365
+ added: z.ZodNumber;
366
+ removed: z.ZodNumber;
367
+ }, z.core.$strict>>;
368
+ }, z.core.$strict>>>;
369
+ }, z.core.$strict>, z.ZodObject<{
370
+ kind: z.ZodLiteral<"other">;
371
+ display: z.ZodString;
372
+ }, z.core.$strict>]>;
373
+ state: z.ZodObject<{
374
+ status: z.ZodEnum<{
375
+ error: "error";
376
+ ok: "ok";
377
+ }>;
378
+ message: z.ZodOptional<z.ZodString>;
379
+ exitCode: z.ZodOptional<z.ZodNumber>;
380
+ }, z.core.$strict>;
381
+ truncated: z.ZodOptional<z.ZodLiteral<true>>;
382
+ }, z.core.$strict>]>;
383
+ }, z.core.$strict>]>>>;
384
+ omitted: z.ZodNumber;
385
+ }, z.core.$strict>]>;
386
+ strandedReason: z.ZodOptional<z.ZodLiteral<"resume-unsupported">>;
387
+ }, z.core.$strict>;
388
+ export type AkumaStatus = z.infer<typeof akumaStatusSchema>;
389
+ export declare function parseAkumaStatus(value: unknown): AkumaStatus;
29
390
  /** The default completion judgment over one complete status snapshot. */
30
391
  export declare function defaultWaitComplete(status: AkumaStatus): boolean;
31
392
  export type { ReadonlyRestraint } from "./provider-recipe.js";
@@ -39,6 +400,7 @@ export type UnbornAkumaListRow = Readonly<{
39
400
  }>;
40
401
  }>;
41
402
  export type AkumaList = Readonly<{
403
+ observedAt: string;
42
404
  rows: readonly (AkumaListRow | UnbornAkumaListRow)[];
43
405
  searched: readonly string[];
44
406
  }>;
@@ -108,6 +470,7 @@ export { bornStatus, fleetListRow, readAkumaBirthCwd, readBudgetedStatus, type B
108
470
  export type AkumaConfiguration = Readonly<{
109
471
  home?: string;
110
472
  settings?: Settings;
473
+ execution?: ExecutionContext;
111
474
  }>;
112
475
  export { AkumaHandle, akumaCallExecution, type LastAnswer } from "./akuma-handle.js";
113
476
  export { Akuma, callAkumaWithContext } from "./akuma-product.js";
@@ -3,7 +3,9 @@ import { realpath, stat } from "node:fs/promises";
3
3
  import { resolve } from "node:path";
4
4
  import { CONTROL_RESPONSE_MS, handoffPendingTells, wakeRecordedTell, } from "./body.js";
5
5
  import { HeldAkumaLeash, readHeart, readKill, recordTell, requestStop, } from "./heart/index.js";
6
- import { pathsForAkuId } from "./identity.js";
6
+ import { parseAkuId, pathsForAkuId } from "./identity.js";
7
+ import { activitySnapshotSchema } from "./projection.js";
8
+ import { z } from "zod";
7
9
  export const POLL_MS = 100;
8
10
  export async function canonicalBirthCwd(input) {
9
11
  const selected = resolve(input);
@@ -24,6 +26,34 @@ export function callReadonly(value) {
24
26
  throw new TypeError("Akuma call readonly must be true");
25
27
  return { readonly: true };
26
28
  }
29
+ export const akumaIdSchema = z.string().transform((value, context) => {
30
+ try {
31
+ const id = parseAkuId(value).id;
32
+ if (id !== value)
33
+ throw new Error("not canonical");
34
+ return id;
35
+ }
36
+ catch {
37
+ context.addIssue({ code: "custom", message: "expected canonical AkuId" });
38
+ return z.NEVER;
39
+ }
40
+ });
41
+ const readonlySchema = z.union([
42
+ z.object({ enforcement: z.literal("native") }).strict(),
43
+ z.object({ enforcement: z.literal("none"), diagnostic: z.string().refine((value) => value.trim() !== "") }).strict(),
44
+ ]);
45
+ export const akumaStatusSchema = z
46
+ .object({
47
+ id: akumaIdSchema,
48
+ life: z.enum(["running", "asleep", "stranded", "hung", "untidy", "killed"]),
49
+ readonly: readonlySchema.optional(),
50
+ timeline: activitySnapshotSchema,
51
+ strandedReason: z.literal("resume-unsupported").optional(),
52
+ })
53
+ .strict();
54
+ export function parseAkumaStatus(value) {
55
+ return akumaStatusSchema.parse(value);
56
+ }
27
57
  /** The default completion judgment over one complete status snapshot. */
28
58
  export function defaultWaitComplete(status) {
29
59
  return (status.life !== "running" &&
@@ -1,4 +1,4 @@
1
- export declare const ALLOWED_ACTIONS: readonly ["akuma.call", "akuma.kill", "akuma.tell", "contract.deliver", "contract.review", "task.add", "task.addDocument", "task.compose", "task.done", "task.drop", "task.hold", "task.resume", "task.start", "task.stop", "task.update"];
1
+ export declare const ALLOWED_ACTIONS: readonly ["akuma.call", "akuma.kill", "akuma.tell", "contract.audit", "contract.deliver", "contract.review", "task.add", "task.addDocument", "task.compose", "task.done", "task.drop", "task.hold", "task.resume", "task.start", "task.stop", "task.update"];
2
2
  export type AllowedAction = (typeof ALLOWED_ACTIONS)[number];
3
3
  export type AllowedActions = readonly AllowedAction[];
4
4
  export declare function isAllowedAction(value: unknown): value is AllowedAction;
@@ -3,6 +3,7 @@ export const ALLOWED_ACTIONS = Object.freeze([
3
3
  "akuma.call",
4
4
  "akuma.kill",
5
5
  "akuma.tell",
6
+ "contract.audit",
6
7
  "contract.deliver",
7
8
  "contract.review",
8
9
  ...TASK_MUTATION_ACTIONS,
@@ -1,7 +1,8 @@
1
+ import type { AkumaCallRequestChildLaunch } from "./call-request.js";
1
2
  import { type SessionFact, type Soul } from "./heart/index.js";
2
3
  import { type AkumaPaths } from "./identity.js";
3
4
  import type { ProviderAdapter } from "./provider.js";
4
- import { type UpstreamExecutionPort, type RequestChildLaunch } from "./request-serve.js";
5
+ import type { ErasedRequestCommand } from "./request-wire.js";
5
6
  import { type OwnedProcess, type RunLogReference } from "../runtime/proc/run.js";
6
7
  export declare const LEASH_HELD_EXIT = 75;
7
8
  export { CONTROL_RESPONSE_MS } from "./body-supervisor.js";
@@ -40,14 +41,15 @@ export type TellResult = Readonly<{
40
41
  wake: TellWake;
41
42
  }>;
42
43
  export type TellWakeRuntime = Readonly<{
43
- observeHeart(paths: AkumaPaths, signal: AbortSignal): Promise<AsyncGenerator<void>>;
44
44
  spawn(paths: AkumaPaths): Promise<OwnedProcess>;
45
+ schedule?(milliseconds: number, signal: AbortSignal): Promise<void>;
45
46
  }>;
46
47
  type BodyRuntime = Readonly<{
47
48
  now(): string;
48
- spawnChild?(launch: RequestChildLaunch): Promise<OwnedProcess>;
49
+ spawnChild?(launch: AkumaCallRequestChildLaunch): Promise<OwnedProcess>;
49
50
  spawnBody?(launch: BodyLaunch): Promise<OwnedProcess>;
50
- upstream?: UpstreamExecutionPort;
51
+ upstream?: unknown;
52
+ commands: Readonly<Record<string, ErasedRequestCommand>>;
51
53
  }>;
52
54
  export declare function bodyProcessInput(launch: BodyLaunch, bodyModuleUrl?: string): Promise<{
53
55
  argv: string[];
@@ -60,5 +62,5 @@ export declare function bodyProcessInput(launch: BodyLaunch, bodyModuleUrl?: str
60
62
  export declare function handoffPendingTells(paths: AkumaPaths, spawn?: (launch: BodyLaunch) => Promise<OwnedProcess>): Promise<void>;
61
63
  export declare function driveAkumaBody(launch: BodyLaunch, adapter?: ProviderAdapter, runtime?: BodyRuntime): Promise<"held" | void>;
62
64
  export declare function spawnAkumaBody(launch: BodyLaunch): Promise<OwnedProcess>;
63
- export declare function runAkumaBody(launch: BodyLaunch, upstream: UpstreamExecutionPort): Promise<"held" | void>;
65
+ export declare function runAkumaBody(launch: BodyLaunch, upstream: unknown, commands: Readonly<Record<string, ErasedRequestCommand>>): Promise<"held" | void>;
64
66
  export declare function wakeRecordedTell(paths: AkumaPaths, tellId: string, runtime?: TellWakeRuntime): Promise<TellResult>;
@@ -3,13 +3,14 @@ import { fileURLToPath } from "node:url";
3
3
  import { abortableDelay } from "./abort.js";
4
4
  import { BodySupervisor } from "./body-supervisor.js";
5
5
  import { driveTurn, turnRecipe } from "./turn-drive.js";
6
- import { HeldAkumaLeash, breakBody, endTurn, finishBodyIfIdle, heartExists, isHeartAbsent, readHeart, readNonterminalRequests, watchHeart, } from "./heart/index.js";
6
+ import { HeldAkumaLeash, breakBody, endTurn, finishBodyIfIdle, heartExists, isHeartAbsent, readHeart, readNonterminalRequests, } from "./heart/index.js";
7
7
  import { worldRootForAkumaPaths } from "./identity.js";
8
8
  import { keiyakuSquarePath } from "../world.js";
9
9
  import { resolveProviderExecution } from "./providers/index.js";
10
- import { clearBodyRequestTransport, settleBodyRequests, } from "./request-serve.js";
10
+ import { clearBodyRequestTransport, settleBodyRequests } from "./request-serve.js";
11
11
  import { spawnDetachedProcess, } from "../runtime/proc/run.js";
12
12
  const LEASH_RETRY_MS = 100;
13
+ const WAKE_REREAD_MS = 100;
13
14
  export const LEASH_HELD_EXIT = 75;
14
15
  export { CONTROL_RESPONSE_MS } from "./body-supervisor.js";
15
16
  function missing(error) {
@@ -120,6 +121,7 @@ function defaultRuntime() {
120
121
  return {
121
122
  now: () => new Date().toISOString(),
122
123
  spawnChild: spawnAkumaBody,
124
+ commands: {},
123
125
  spawnBody: spawnAkumaBody,
124
126
  };
125
127
  }
@@ -200,6 +202,7 @@ async function runBodyTurns(input) {
200
202
  ...(initial === undefined ? {} : { call: initial }),
201
203
  launchTells,
202
204
  ...(runtime.upstream === undefined ? {} : { upstream: runtime.upstream }),
205
+ commands: runtime.commands,
203
206
  now: runtime.now,
204
207
  });
205
208
  if (result.kind === "hung")
@@ -292,12 +295,12 @@ export async function driveAkumaBody(launch, adapter, runtime = defaultRuntime()
292
295
  export async function spawnAkumaBody(launch) {
293
296
  return await spawnDetachedProcess(await bodyProcessInput(launch));
294
297
  }
295
- export async function runAkumaBody(launch, upstream) {
296
- return await driveAkumaBody(launch, undefined, { ...defaultRuntime(), upstream });
298
+ export async function runAkumaBody(launch, upstream, commands) {
299
+ return await driveAkumaBody(launch, undefined, { ...defaultRuntime(), upstream, commands });
297
300
  }
298
301
  const DIRECT_TELL_WAKE = {
299
- observeHeart: watchHeart,
300
302
  spawn: async (paths) => await spawnAkumaBody({ paths, refuseIfHeld: true }),
303
+ schedule: abortableDelay,
301
304
  };
302
305
  function diagnostic(error) {
303
306
  return error instanceof Error ? error.message : String(error);
@@ -321,61 +324,47 @@ function failedChild(exit) {
321
324
  child: { code: exit.code, signal: exit.signal, log: exit.log },
322
325
  };
323
326
  }
324
- async function awaitWake(paths, tellId, after, child, changed) {
325
- let nextChange = changed.next();
327
+ async function awaitWake(paths, tellId, after, child, schedule) {
326
328
  for (;;) {
327
329
  const settled = await settledWake(paths, tellId, after);
328
330
  if (settled !== null) {
329
331
  child.release();
330
332
  return settled;
331
333
  }
332
- const winner = await Promise.race([
333
- nextChange.then(({ done }) => ({ kind: done ? "closed" : "changed" }), (error) => ({ kind: "observer-failed", error })),
334
- child.exited.then((exit) => ({ kind: "exited", exit })),
335
- ]);
336
- if (winner.kind === "changed") {
337
- nextChange = changed.next();
338
- continue;
334
+ const timerController = new AbortController();
335
+ const timer = schedule(WAKE_REREAD_MS, timerController.signal).then(() => ({ kind: "timer" }));
336
+ let winner;
337
+ try {
338
+ winner = await Promise.race([child.exited.then((exit) => ({ kind: "exited", exit })), timer]);
339
339
  }
340
+ catch (error) {
341
+ timerController.abort();
342
+ await timer.catch(() => undefined);
343
+ throw error;
344
+ }
345
+ if (winner.kind === "timer")
346
+ continue;
347
+ timerController.abort();
348
+ await timer.catch(() => undefined);
340
349
  const final = await settledWake(paths, tellId, after);
341
350
  if (final !== null) {
342
351
  child.release();
343
352
  return final;
344
353
  }
345
- if (winner.kind === "exited") {
346
- return winner.exit.code === LEASH_HELD_EXIT ? { kind: "held" } : failedChild(winner.exit);
347
- }
348
- try {
349
- await child.terminate();
350
- }
351
- catch (error) {
352
- /* Termination rejection leaves physical custody unresolved; release it deliberately. */
353
- child.release();
354
- return { kind: "failed", diagnostic: diagnostic(error) };
355
- }
356
- return winner.kind === "observer-failed"
357
- ? { kind: "failed", diagnostic: diagnostic(winner.error) }
358
- : { kind: "failed", diagnostic: "Heart observer closed" };
354
+ return winner.exit.code === LEASH_HELD_EXIT ? { kind: "held" } : failedChild(winner.exit);
359
355
  }
360
356
  }
361
357
  async function wakePendingTells(paths, tellId, runtime) {
362
- const watching = new AbortController();
363
- let changed;
364
358
  try {
365
- changed = await runtime.observeHeart(paths, watching.signal);
366
359
  const beforeHeart = await readHeart(paths);
367
360
  if (tellId === undefined && beforeHeart.pending.length === 0)
368
361
  return null;
369
362
  const before = beforeHeart.latestBody?.sequence ?? 0;
370
- return await awaitWake(paths, tellId, before, await runtime.spawn(paths), changed);
363
+ return await awaitWake(paths, tellId, before, await runtime.spawn(paths), runtime.schedule ?? abortableDelay);
371
364
  }
372
365
  catch (error) {
373
366
  return { kind: "failed", diagnostic: diagnostic(error) };
374
367
  }
375
- finally {
376
- watching.abort();
377
- await changed?.return(undefined);
378
- }
379
368
  }
380
369
  export async function wakeRecordedTell(paths, tellId, runtime = DIRECT_TELL_WAKE) {
381
370
  return {