@astrosheep/keiyaku 4.5.7 → 4.5.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (234) hide show
  1. package/README.md +10 -0
  2. package/build/integrations/marketplace/plugins/keiyaku/.claude-plugin/plugin.json +1 -1
  3. package/build/integrations/marketplace/plugins/keiyaku/.codex-plugin/plugin.json +1 -1
  4. package/build/integrations/marketplace/plugins/keiyaku/opencode.js +3 -2
  5. package/build/integrations/marketplace/plugins/keiyaku/package.json +1 -1
  6. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku/SKILL.md +10 -9
  7. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-akuma/SKILL.md +22 -1
  8. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-babysit/SKILL.md +35 -96
  9. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-bind/SKILL.md +28 -49
  10. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-task/SKILL.md +21 -15
  11. package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-workflow/SKILL.md +148 -89
  12. package/build/src/akuma/abort.d.ts +2 -1
  13. package/build/src/akuma/abort.js +6 -23
  14. package/build/src/akuma/akuma-handle.js +4 -2
  15. package/build/src/akuma/akuma-observe.d.ts +2 -0
  16. package/build/src/akuma/akuma-observe.js +1 -0
  17. package/build/src/akuma/akuma-product.js +9 -7
  18. package/build/src/akuma/akuma.d.ts +372 -9
  19. package/build/src/akuma/akuma.js +31 -1
  20. package/build/src/akuma/allowed.d.ts +1 -1
  21. package/build/src/akuma/allowed.js +1 -0
  22. package/build/src/akuma/body.d.ts +6 -4
  23. package/build/src/akuma/body.js +5 -3
  24. package/build/src/akuma/call-request.d.ts +80 -0
  25. package/build/src/akuma/call-request.js +211 -0
  26. package/build/src/akuma/heart/facts.d.ts +6 -78
  27. package/build/src/akuma/heart/index.d.ts +1 -1
  28. package/build/src/akuma/heart/request-authority.d.ts +5 -4
  29. package/build/src/akuma/heart/request-authority.js +20 -34
  30. package/build/src/akuma/heart/request-rows.js +12 -23
  31. package/build/src/akuma/heart/schema.d.ts +1 -1
  32. package/build/src/akuma/heart/schema.js +5 -13
  33. package/build/src/akuma/index.d.ts +1 -1
  34. package/build/src/akuma/index.js +1 -1
  35. package/build/src/akuma/projection-read.d.ts +1 -0
  36. package/build/src/akuma/projection-read.js +8 -1
  37. package/build/src/akuma/projection.d.ts +856 -137
  38. package/build/src/akuma/projection.js +190 -0
  39. package/build/src/akuma/provider.d.ts +30 -3
  40. package/build/src/akuma/provider.js +104 -0
  41. package/build/src/akuma/providers/acp/core.d.ts +2 -2
  42. package/build/src/akuma/providers/acp/core.js +13 -6
  43. package/build/src/akuma/providers/acp/index.js +5 -4
  44. package/build/src/akuma/providers/claude/index.d.ts +3 -3
  45. package/build/src/akuma/providers/claude/index.js +16 -5
  46. package/build/src/akuma/providers/codex-app-server/events.js +1 -1
  47. package/build/src/akuma/providers/codex-app-server/index.js +18 -6
  48. package/build/src/akuma/providers/grok-build/index.js +5 -4
  49. package/build/src/akuma/providers/opencode-sdk/index.js +66 -25
  50. package/build/src/akuma/providers/opencode-sdk/session.d.ts +3 -2
  51. package/build/src/akuma/providers/opencode-sdk/session.js +28 -11
  52. package/build/src/akuma/providers/pi/index.js +42 -14
  53. package/build/src/akuma/request-lifecycle.d.ts +3 -9
  54. package/build/src/akuma/request-lifecycle.js +4 -4
  55. package/build/src/akuma/request-rendezvous.d.ts +26 -0
  56. package/build/src/akuma/request-rendezvous.js +100 -0
  57. package/build/src/akuma/request-serve.d.ts +5 -65
  58. package/build/src/akuma/request-serve.js +81 -208
  59. package/build/src/akuma/request-wire.d.ts +109 -115
  60. package/build/src/akuma/request-wire.js +63 -318
  61. package/build/src/akuma/requests.d.ts +19 -47
  62. package/build/src/akuma/requests.js +51 -107
  63. package/build/src/akuma/turn-drive.d.ts +5 -3
  64. package/build/src/akuma/turn-drive.js +32 -10
  65. package/build/src/akuma-body.d.ts +7 -2
  66. package/build/src/akuma-body.js +68 -46
  67. package/build/src/cli/accepted.d.ts +1 -1
  68. package/build/src/cli/accepted.js +2 -2
  69. package/build/src/cli/commands/akuma-invoke.d.ts +2 -0
  70. package/build/src/cli/commands/akuma-invoke.js +17 -9
  71. package/build/src/cli/commands/akuma.js +7 -7
  72. package/build/src/cli/commands/contract-invoke.d.ts +3 -2
  73. package/build/src/cli/commands/contract-invoke.js +26 -19
  74. package/build/src/cli/commands/contract.d.ts +13 -13
  75. package/build/src/cli/commands/contract.js +32 -17
  76. package/build/src/cli/commands/install.d.ts +1 -1
  77. package/build/src/cli/commands/install.js +1 -1
  78. package/build/src/cli/commands/task-invoke.d.ts +3 -0
  79. package/build/src/cli/commands/task-invoke.js +23 -140
  80. package/build/src/cli/commands/task.js +54 -20
  81. package/build/src/cli/invoke.js +39 -25
  82. package/build/src/cli/main.js +2 -1
  83. package/build/src/cli/parse.d.ts +2 -2
  84. package/build/src/cli/parse.js +37 -22
  85. package/build/src/cli/render/akuma-activity.d.ts +4 -1
  86. package/build/src/cli/render/akuma-activity.js +45 -30
  87. package/build/src/cli/render/akuma-tool.d.ts +5 -1
  88. package/build/src/cli/render/akuma.js +5 -9
  89. package/build/src/cli/render/audit.js +1 -1
  90. package/build/src/cli/render/catalog.js +80 -21
  91. package/build/src/cli/render/contract-observation.d.ts +2 -0
  92. package/build/src/cli/render/contract-observation.js +11 -0
  93. package/build/src/cli/render/contract.js +25 -65
  94. package/build/src/cli/render/kanshi-akuma.d.ts +8 -0
  95. package/build/src/cli/render/kanshi-akuma.js +111 -0
  96. package/build/src/cli/render/kanshi.js +108 -213
  97. package/build/src/cli/render/receipt.d.ts +1 -2
  98. package/build/src/cli/render/receipt.js +76 -26
  99. package/build/src/cli/render/refusal.js +2 -10
  100. package/build/src/cli/render/region.js +5 -2
  101. package/build/src/cli/render/settings.d.ts +1 -1
  102. package/build/src/cli/render/settings.js +27 -8
  103. package/build/src/cli/render/task.js +22 -5
  104. package/build/src/cli/render/terminal.d.ts +28 -0
  105. package/build/src/cli/render/terminal.js +65 -0
  106. package/build/src/cli/result.d.ts +3 -3
  107. package/build/src/cli/runtime.js +3 -1
  108. package/build/src/cli/selectors.d.ts +2 -1
  109. package/build/src/cli/selectors.js +4 -3
  110. package/build/src/cli/square-edge.js +120 -36
  111. package/build/src/cli/usage.js +2 -1
  112. package/build/src/contract-guidance.d.ts +5 -0
  113. package/build/src/contract-guidance.js +121 -0
  114. package/build/src/contract-worktree.d.ts +0 -1
  115. package/build/src/contract-worktree.js +32 -83
  116. package/build/src/coordination/sqlite-transaction-lock.d.ts +1 -0
  117. package/build/src/coordination/sqlite-transaction-lock.js +5 -0
  118. package/build/src/core/facts/codec.d.ts +2 -0
  119. package/build/src/core/facts/codec.js +4 -0
  120. package/build/src/core/verbs/placement.d.ts +6 -1
  121. package/build/src/core/verbs/placement.js +5 -3
  122. package/build/src/dispatch/index.d.ts +0 -2
  123. package/build/src/dispatch/index.js +54 -55
  124. package/build/src/git/admission.js +2 -2
  125. package/build/src/git/hooks.d.ts +9 -15
  126. package/build/src/git/hooks.js +23 -317
  127. package/build/src/git/nuke.d.ts +2 -1
  128. package/build/src/git/nuke.js +36 -18
  129. package/build/src/git/private-state-seat.d.ts +12 -0
  130. package/build/src/git/private-state-seat.js +39 -0
  131. package/build/src/git/process.d.ts +6 -0
  132. package/build/src/git/process.js +19 -7
  133. package/build/src/git/read-observation.js +29 -20
  134. package/build/src/git/reconcile.d.ts +11 -0
  135. package/build/src/git/reconcile.js +64 -11
  136. package/build/src/git/repository.d.ts +6 -2
  137. package/build/src/git/repository.js +8 -0
  138. package/build/src/git/target-placement.d.ts +1 -0
  139. package/build/src/git/target-placement.js +5 -0
  140. package/build/src/git/tender.d.ts +1 -0
  141. package/build/src/git/terminal-reconcile.d.ts +1 -1
  142. package/build/src/git/terminal-reconcile.js +22 -20
  143. package/build/src/git/workspace.d.ts +14 -0
  144. package/build/src/git/workspace.js +44 -0
  145. package/build/src/kanshi/index.d.ts +1 -1
  146. package/build/src/kanshi/read.js +16 -16
  147. package/build/src/kanshi/report.d.ts +2 -2
  148. package/build/src/library/address.d.ts +9 -3
  149. package/build/src/library/address.js +3 -2
  150. package/build/src/library/akuma-creation.d.ts +4 -3
  151. package/build/src/library/akuma-creation.js +19 -13
  152. package/build/src/library/audit.d.ts +1 -1
  153. package/build/src/library/audit.js +5 -3
  154. package/build/src/library/catalog.d.ts +3 -1
  155. package/build/src/library/catalog.js +20 -6
  156. package/build/src/library/composition.d.ts +371 -0
  157. package/build/src/library/composition.js +28 -0
  158. package/build/src/library/configuration.js +8 -2
  159. package/build/src/library/continuation.js +66 -30
  160. package/build/src/library/contract-bind.js +10 -2
  161. package/build/src/library/contract-forwarding-reconciliation-result.d.ts +96 -0
  162. package/build/src/library/contract-forwarding-reconciliation-result.js +83 -0
  163. package/build/src/library/contract-forwarding-result.d.ts +6723 -0
  164. package/build/src/library/contract-forwarding-result.js +521 -0
  165. package/build/src/library/contract-forwarding.d.ts +72 -0
  166. package/build/src/library/contract-forwarding.js +125 -0
  167. package/build/src/library/contract-handle.d.ts +36 -0
  168. package/build/src/library/contract-handle.js +313 -0
  169. package/build/src/library/contract-operations.d.ts +1044 -67
  170. package/build/src/library/contract-operations.js +190 -118
  171. package/build/src/library/contract.d.ts +11 -32
  172. package/build/src/library/contract.js +16 -289
  173. package/build/src/library/fleet-result.d.ts +1454 -0
  174. package/build/src/library/fleet-result.js +96 -0
  175. package/build/src/library/fleet.d.ts +112 -54
  176. package/build/src/library/fleet.js +211 -71
  177. package/build/src/library/input.d.ts +2 -0
  178. package/build/src/library/input.js +4 -0
  179. package/build/src/library/keiyaku.d.ts +371 -20
  180. package/build/src/library/keiyaku.js +8 -21
  181. package/build/src/library/mutation.d.ts +3 -3
  182. package/build/src/library/mutation.js +5 -9
  183. package/build/src/library/nuke.d.ts +1 -1
  184. package/build/src/library/nuke.js +4 -3
  185. package/build/src/library/reconcile.d.ts +4 -0
  186. package/build/src/library/reconcile.js +2 -0
  187. package/build/src/library/refusal.d.ts +0 -9
  188. package/build/src/library/refusal.js +0 -7
  189. package/build/src/protocol/amend.js +56 -50
  190. package/build/src/protocol/attempt.d.ts +2 -0
  191. package/build/src/protocol/attempt.js +8 -1
  192. package/build/src/protocol/completion.js +7 -0
  193. package/build/src/protocol/deliver.js +6 -2
  194. package/build/src/protocol/operations.d.ts +4 -1
  195. package/build/src/protocol/operations.js +5 -2
  196. package/build/src/protocol/placement.d.ts +1 -0
  197. package/build/src/protocol/placement.js +52 -38
  198. package/build/src/protocol/read/observation.d.ts +1 -4
  199. package/build/src/protocol/read/observation.js +2 -15
  200. package/build/src/protocol/reintegrate.js +62 -58
  201. package/build/src/protocol/review.js +5 -0
  202. package/build/src/protocol/run.js +17 -13
  203. package/build/src/runtime/proc/run.d.ts +8 -0
  204. package/build/src/runtime/proc/run.js +27 -0
  205. package/build/src/runtime/proc/termination.js +26 -22
  206. package/build/src/runtime/proc/windows-launch.exe +0 -0
  207. package/build/src/settlement/holder.d.ts +2 -1
  208. package/build/src/settlement/holder.js +15 -4
  209. package/build/src/settlement/settle.js +99 -33
  210. package/build/src/task/board.d.ts +68 -27
  211. package/build/src/task/board.js +31 -1
  212. package/build/src/task/catalog.d.ts +4 -0
  213. package/build/src/task/catalog.js +23 -0
  214. package/build/src/task/compose-language.js +33 -7
  215. package/build/src/task/compose-parser.d.ts +1 -1
  216. package/build/src/task/compose-parser.js +1 -1
  217. package/build/src/task/compose.js +2 -0
  218. package/build/src/task/index.d.ts +12 -4
  219. package/build/src/task/index.js +97 -16
  220. package/build/src/task/mutation-result.d.ts +923 -0
  221. package/build/src/task/mutation-result.js +140 -0
  222. package/build/src/task/mutation.d.ts +552 -28
  223. package/build/src/task/mutation.js +304 -97
  224. package/build/src/task/operations.d.ts +1 -4
  225. package/build/src/task/operations.js +0 -6
  226. package/build/src/task/public.d.ts +2 -0
  227. package/build/src/task/public.js +1 -0
  228. package/build/src/workspace-place.d.ts +7 -2
  229. package/build/src/workspace-place.js +34 -24
  230. package/build/src/world.d.ts +1 -0
  231. package/build/src/world.js +11 -0
  232. package/package.json +8 -6
  233. package/build/src/akuma/request-execution.d.ts +0 -8
  234. package/build/src/akuma/request-execution.js +0 -98
@@ -5,6 +5,7 @@ import { parseAkuId } from "../akuma/identity.js";
5
5
  import { contractId } from "../core/facts/types.js";
6
6
  import { readDispatches } from "../dispatch/index.js";
7
7
  import { matchesAkumaGlob, parseAkumaAlias, parseAkumaGlob, } from "../identity/selector.js";
8
+ import { World } from "../world.js";
8
9
  import { requireInput } from "./input.js";
9
10
  import { scopeForRepo } from "./repo.js";
10
11
  export class AkumaWorldScopeError extends TypeError {
@@ -72,7 +73,7 @@ export async function addressAkuma(input) {
72
73
  }
73
74
  if (values.repo !== undefined)
74
75
  scopeForRepo(values.repo);
75
- const path = nonblank(values.path, "path");
76
+ const path = await World.prove(nonblank(values.path, "path"));
76
77
  return { path, id: await directId(path, nonblank(values.akuma, "akuma")) };
77
78
  }
78
79
  function idsFromFleet(fleet) {
@@ -143,7 +144,7 @@ export async function addressAkumaSet(input) {
143
144
  }
144
145
  if (!Array.isArray(values.akuma) || values.akuma.length === 0)
145
146
  throw new TypeError("akuma must be a nonempty selector array");
146
- const path = nonblank(values.path, "path");
147
+ const path = await World.prove(nonblank(values.path, "path"));
147
148
  const selectors = values.akuma.map(parseSetSelector);
148
149
  if (hasSelectorKind(selectors, "contract") && values.repo === undefined) {
149
150
  throw new TypeError("Contract Akuma selector requires repo");
@@ -5,8 +5,9 @@ import type { AkuId } from "../akuma/identity.js";
5
5
  import { type Dispatch, type DispatchFailure } from "../dispatch/index.js";
6
6
  import { type AkumaAlias } from "../identity/selector.js";
7
7
  import type { Settings } from "../settings.js";
8
- import type { WorldRoot } from "../world.js";
8
+ import { type WorldRoot } from "../world.js";
9
9
  import type { AllowedAction } from "../akuma/allowed.js";
10
+ import { type ExecutionContext } from "../akuma/requests.js";
10
11
  import { type Keiyaku } from "./contract.js";
11
12
  import { type Repo } from "./repo.js";
12
13
  export type { AkumaStatus } from "../akuma/akuma.js";
@@ -98,7 +99,7 @@ export type ForkResult = Readonly<{
98
99
  }>> & Readonly<{
99
100
  parent: AkuId;
100
101
  }>);
101
- export declare function beginCall(input: CallInput): Promise<BornCall>;
102
+ export declare function beginCall(input: CallInput, context: ExecutionContext): Promise<BornCall>;
102
103
  export declare function finishCall(born: BornCall, participantName?: string): Promise<CallResult>;
103
- export declare function callKeiyaku(input: CallInput): Promise<CallResult>;
104
+ export declare function callKeiyaku(input: CallInput, execution?: ExecutionContext): Promise<CallResult>;
104
105
  export declare function forkKeiyaku(input: ForkInput): Promise<ForkResult>;
@@ -6,9 +6,12 @@ import { AuthorityCorruptionError } from "../core/facts/errors.js";
6
6
  import { publishDispatch, readDispatch } from "../dispatch/index.js";
7
7
  import { parseAkumaAlias } from "../identity/selector.js";
8
8
  import { readManagedWorktreeAppointment } from "../workspace-place.js";
9
+ import { World } from "../world.js";
10
+ import { localExecutionContext } from "../akuma/requests.js";
9
11
  import { requireInput } from "./input.js";
10
12
  import { addressAkuma } from "./address.js";
11
- import { KeiyakuRefused, seatForKeiyaku } from "./contract.js";
13
+ import { KeiyakuRefused } from "./contract.js";
14
+ import { seatForKeiyaku } from "./contract-handle.js";
12
15
  import { scopeForRepo } from "./repo.js";
13
16
  function nonblank(value, label) {
14
17
  if (typeof value !== "string" || value.trim().length === 0) {
@@ -36,10 +39,11 @@ function homeOption(value) {
36
39
  return undefined;
37
40
  return nonblank(value, "home");
38
41
  }
39
- function akumaWorld(path, home, settings) {
42
+ function akumaWorld(path, home, settings, execution) {
40
43
  return Akuma.of(path, {
41
44
  ...(home === undefined ? {} : { home }),
42
45
  ...(settings === undefined ? {} : { settings }),
46
+ ...(execution === undefined ? {} : { execution }),
43
47
  });
44
48
  }
45
49
  function onlyKeys(values, allowed, label) {
@@ -151,6 +155,8 @@ async function resolveCallExecution(input) {
151
155
  }
152
156
  if (input.contract !== undefined) {
153
157
  const seat = seatForKeiyaku(input.contract);
158
+ if (seat === null)
159
+ throw new TypeError("contract must be a Keiyaku");
154
160
  const state = await currentManagedContract(input.contract, seat.id);
155
161
  const appointment = await readManagedWorktreeAppointment(seat.scope, state.id);
156
162
  if (appointment.kind === "unappointed") {
@@ -166,7 +172,7 @@ async function resolveCallExecution(input) {
166
172
  }
167
173
  return undefined;
168
174
  }
169
- export async function beginCall(input) {
175
+ export async function beginCall(input, context) {
170
176
  const values = requireInput(input, "Keiyaku.call input");
171
177
  onlyKeys(values, [
172
178
  "path",
@@ -182,7 +188,7 @@ export async function beginCall(input) {
182
188
  "alias",
183
189
  "allowed",
184
190
  ], "Keiyaku.call input");
185
- const path = nonblank(values.path, "path");
191
+ const path = await World.prove(nonblank(values.path, "path"));
186
192
  const archetype = nonblank(values.archetype, "archetype");
187
193
  const body = text(values.body, "body");
188
194
  const readonlyRequested = callReadonly(values.readonly);
@@ -192,13 +198,16 @@ export async function beginCall(input) {
192
198
  const home = homeOption(values.home);
193
199
  const settings = settingsOption(values.settings);
194
200
  const alias = values.alias === undefined ? undefined : parseAkumaAlias(nonblank(values.alias, "alias"));
195
- const seat = values.contract === undefined ? undefined : seatForKeiyaku(values.contract);
201
+ const selectedSeat = values.contract === undefined ? undefined : seatForKeiyaku(values.contract);
202
+ if (values.contract !== undefined && selectedSeat === null)
203
+ throw new TypeError("contract must be a Keiyaku");
204
+ const seat = selectedSeat ?? undefined;
196
205
  const execution = await resolveCallExecution({
197
206
  path,
198
207
  ...(cwd === undefined ? {} : { cwd }),
199
208
  ...(seat === undefined ? {} : { contract: values.contract }),
200
209
  });
201
- const world = akumaWorld(path, home, settings);
210
+ const world = akumaWorld(path, home, settings, context);
202
211
  const call = {
203
212
  archetype,
204
213
  body,
@@ -255,18 +264,15 @@ export async function finishCall(born, participantName) {
255
264
  observation,
256
265
  };
257
266
  }
258
- export async function callKeiyaku(input) {
259
- return await finishCall(await beginCall(input));
267
+ export async function callKeiyaku(input, execution = localExecutionContext()) {
268
+ return await finishCall(await beginCall(input, execution));
260
269
  }
261
270
  export async function forkKeiyaku(input) {
262
271
  const values = requireInput(input, "Keiyaku.fork input");
263
272
  onlyKeys(values, ["path", "akuma", "at", "repo"], "Keiyaku.fork input");
264
- const path = nonblank(values.path, "path");
265
273
  const at = nonblank(values.at, "at");
266
- const akuma = (await addressAkuma({
267
- path,
268
- akuma: nonblank(values.akuma, "akuma"),
269
- })).id;
274
+ const addressed = await addressAkuma({ path: values.path, akuma: nonblank(values.akuma, "akuma") });
275
+ const { path, id: akuma } = addressed;
270
276
  const repository = values.repo === undefined ? undefined : scopeForRepo(values.repo);
271
277
  const receipt = await Akuma.of(path).of({ id: akuma }).fork({ at });
272
278
  if (receipt.kind !== "forked")
@@ -1,6 +1,6 @@
1
1
  import type { ContractId } from "../core/facts/types.js";
2
2
  import { type AuditReport } from "../protocol/audit.js";
3
- import type { RepositoryScope } from "../protocol/operations.js";
3
+ import { type RepositoryScope } from "../protocol/operations.js";
4
4
  import { type WorktreeHooks } from "./configuration.js";
5
5
  import { type MutationResult } from "./mutation.js";
6
6
  export type AuditInput = Readonly<{
@@ -1,6 +1,7 @@
1
1
  import { decodeContractDocument } from "../body/decode.js";
2
2
  import { withGitDecodeChannel } from "../git/read-observation.js";
3
3
  import { auditOperation } from "../protocol/audit.js";
4
+ import { withScopeAbortSignal } from "../protocol/operations.js";
4
5
  import { worktreeHooksOption } from "./configuration.js";
5
6
  import { actorOption, documentDerivation, optionalBoolean, optionalSignal, requireInput } from "./input.js";
6
7
  import { completeMutation } from "./mutation.js";
@@ -20,9 +21,10 @@ function normalizeAuditInput(input) {
20
21
  /** Normalize public audit input and project the protocol audit operation. */
21
22
  export async function auditContract(input) {
22
23
  const normalized = normalizeAuditInput(input.input);
23
- return withGitDecodeChannel(input.scope, async (channel) => {
24
+ const scope = withScopeAbortSignal(input.scope, normalized.signal);
25
+ return withGitDecodeChannel(scope, async (channel) => {
24
26
  const accepted = requireAccepted(await auditOperation({
25
- scope: input.scope,
27
+ scope,
26
28
  channel,
27
29
  contractId: input.contractId,
28
30
  deriveDocument: (state) => documentDerivation(decodeContractDocument(state.terms.document.bytes), state.terms.gates, state.id),
@@ -33,7 +35,7 @@ export async function auditContract(input) {
33
35
  ...(normalized.actor === undefined ? {} : { actor: normalized.actor }),
34
36
  }));
35
37
  return completeMutation({
36
- scope: input.scope,
38
+ scope,
37
39
  channel,
38
40
  contractId: input.contractId,
39
41
  accepted,
@@ -3,9 +3,10 @@ import { type ArchetypeCatalogRow } from "../akuma/archetype.js";
3
3
  import type { TaskRow } from "../task/index.js";
4
4
  import { type ContractBoard } from "./contract.js";
5
5
  import { Repo } from "./repo.js";
6
- import type { WorldRoot } from "../world.js";
6
+ import { type WorldRoot } from "../world.js";
7
7
  export type CatalogQuery = Readonly<{
8
8
  kind: "tasks";
9
+ namespace?: readonly string[];
9
10
  }> | Readonly<{
10
11
  kind: "contracts";
11
12
  }> | Readonly<{
@@ -52,6 +53,7 @@ export type Catalog = Readonly<{
52
53
  kind: "akuma";
53
54
  root: WorldRoot;
54
55
  archetype: string | null;
56
+ observedAt: string;
55
57
  rows: AkumaList["rows"];
56
58
  searched: readonly string[];
57
59
  }>;
@@ -1,9 +1,10 @@
1
1
  import { Akuma } from "../akuma/akuma.js";
2
2
  import { listArchetypeDefinitions } from "../akuma/archetype.js";
3
- import { observeTaskCatalogRows } from "../task/operations.js";
3
+ import { observeTaskCatalogRows } from "../task/catalog.js";
4
4
  import { listKeiyaku } from "./contract.js";
5
5
  import { requireInput } from "./input.js";
6
6
  import { Repo } from "./repo.js";
7
+ import { World } from "../world.js";
7
8
  function optionalHome(value) {
8
9
  if (value === undefined)
9
10
  return undefined;
@@ -12,10 +13,18 @@ function optionalHome(value) {
12
13
  }
13
14
  return value;
14
15
  }
15
- function worldRoot(value) {
16
+ async function worldRoot(value) {
16
17
  if (typeof value !== "string" || value.trim().length === 0)
17
18
  throw new TypeError("path must be a WorldRoot");
18
- return value;
19
+ return await World.prove(value);
20
+ }
21
+ function taskQueryValue(query) {
22
+ if (query.namespace !== undefined && !Array.isArray(query.namespace))
23
+ throw new TypeError("Keiyaku.ls Task namespace must be an array");
24
+ return {
25
+ kind: "tasks",
26
+ ...(query.namespace === undefined ? {} : { namespace: query.namespace }),
27
+ };
19
28
  }
20
29
  function queryValue(value) {
21
30
  if (typeof value !== "object" || value === null || Array.isArray(value)) {
@@ -26,10 +35,14 @@ function queryValue(value) {
26
35
  throw new TypeError("Keiyaku.ls query kind is invalid");
27
36
  }
28
37
  for (const key of Object.keys(query)) {
29
- if (key !== "kind" && !(query.kind === "akuma" && key === "archetype")) {
38
+ if (key !== "kind" &&
39
+ !(query.kind === "akuma" && key === "archetype") &&
40
+ !(query.kind === "tasks" && key === "namespace")) {
30
41
  throw new TypeError(`Keiyaku.ls query has unknown field: ${key}`);
31
42
  }
32
43
  }
44
+ if (query.kind === "tasks")
45
+ return taskQueryValue(query);
33
46
  if (query.kind !== "akuma")
34
47
  return { kind: query.kind };
35
48
  if (query.archetype !== undefined && typeof query.archetype !== "string") {
@@ -62,15 +75,16 @@ export async function listCatalog(input) {
62
75
  rows: await listArchetypeDefinitions(home === undefined ? {} : { home }),
63
76
  };
64
77
  }
65
- const path = worldRoot(values.path);
78
+ const path = await worldRoot(values.path);
66
79
  if (query.kind === "tasks") {
67
- return { kind: "tasks", root: path, rows: await observeTaskCatalogRows(path) };
80
+ return { kind: "tasks", root: path, rows: await observeTaskCatalogRows(path, query.namespace) };
68
81
  }
69
82
  const listed = await Akuma.of(path).list(query.archetype === undefined ? undefined : { archetype: query.archetype });
70
83
  return {
71
84
  kind: "akuma",
72
85
  root: path,
73
86
  archetype: query.archetype ?? null,
87
+ observedAt: listed.observedAt,
74
88
  rows: listed.rows,
75
89
  searched: listed.searched,
76
90
  };
@@ -0,0 +1,371 @@
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";
6
+ import { type ExecutionContext } from "../akuma/requests.js";
7
+ /** Internal composition root for one immutable execution channel. */
8
+ export declare function composeLibrary(context?: ExecutionContext): Readonly<{
9
+ prototype: KeiyakuHandle;
10
+ [Symbol.hasInstance]: (value: unknown) => boolean;
11
+ bind: (input: Parameters<typeof bindKeiyaku>[0]) => Promise<import("./contract-types.js").BindResult>;
12
+ call: (input: Parameters<typeof callKeiyaku>[0]) => Promise<Readonly<{
13
+ kind: "called";
14
+ akuma: import("./keiyaku.js").AkuId;
15
+ readonly?: import("../akuma/provider-recipe.js").ReadonlyRestraint;
16
+ execution: Readonly<{
17
+ cwd: string;
18
+ source: "input" | "contract-worktree" | "caller" | "process" | "world";
19
+ }>;
20
+ dispatch: import("./akuma-creation.js").DispatchStage;
21
+ alias: import("./akuma-creation.js").AliasStage;
22
+ observation: import("./akuma-creation.js").CallObservation;
23
+ }>>;
24
+ fork: typeof forkKeiyaku;
25
+ history: typeof historyAkuma;
26
+ interrupt: typeof interruptAkuma;
27
+ kill: (input: Parameters<typeof killAkuma>[0]) => Promise<{
28
+ results: {
29
+ id: import("./keiyaku.js").AkuId;
30
+ evidence: "unavailable" | "killed" | "already-killed" | "already-stopped" | "hung" | "untidy";
31
+ }[];
32
+ }>;
33
+ ls: typeof listCatalog;
34
+ nuke: typeof nukeKeiyaku;
35
+ list: typeof listKeiyaku;
36
+ observe: typeof observeKeiyaku;
37
+ of: (input: Parameters<typeof keiyakuOf>[0]) => KeiyakuHandle;
38
+ status: typeof statusAkuma;
39
+ tell: (input: Parameters<typeof tellAkuma>[0]) => Promise<{
40
+ akuma: import("./keiyaku.js").AkuId;
41
+ tell: {
42
+ admission: {
43
+ fact: "recorded";
44
+ tellId: string;
45
+ };
46
+ wake: {
47
+ kind: "failed";
48
+ diagnostic: string;
49
+ } | {
50
+ child: {
51
+ code: number | null;
52
+ signal: string | null;
53
+ log: {
54
+ path: string;
55
+ from: number;
56
+ to: number;
57
+ };
58
+ };
59
+ kind: "failed";
60
+ diagnostic: string;
61
+ } | {
62
+ kind: "told";
63
+ } | {
64
+ kind: "held";
65
+ } | {
66
+ kind: "pursuing";
67
+ bodySequence: number;
68
+ };
69
+ };
70
+ }>;
71
+ wait: (input: Parameters<typeof waitAkuma>[0]) => Promise<{
72
+ completion: "any" | "all";
73
+ observations: {
74
+ status: {
75
+ id: import("./keiyaku.js").AkuId;
76
+ life: "killed" | "hung" | "untidy" | "running" | "asleep" | "stranded";
77
+ timeline: {
78
+ reportedChanges: readonly {
79
+ sequence: number;
80
+ at: string;
81
+ op: "add" | "update" | "delete" | "unspecified";
82
+ path: string;
83
+ diffstat?: {
84
+ added: number;
85
+ removed: number;
86
+ } | undefined;
87
+ }[];
88
+ reportedChangesOmitted: number;
89
+ kind: "unborn";
90
+ entries: readonly never[];
91
+ omitted: 0;
92
+ } | {
93
+ reportedChanges: readonly {
94
+ sequence: number;
95
+ at: string;
96
+ op: "add" | "update" | "delete" | "unspecified";
97
+ path: string;
98
+ diffstat?: {
99
+ added: number;
100
+ removed: number;
101
+ } | undefined;
102
+ }[];
103
+ reportedChangesOmitted: number;
104
+ kind: "open";
105
+ turn: {
106
+ kind: "turn";
107
+ sequence: number;
108
+ turnSequence: number;
109
+ bodySequence: number;
110
+ at: string;
111
+ };
112
+ entries: readonly ({
113
+ kind: "gap";
114
+ count: number;
115
+ } | {
116
+ kind: "row";
117
+ row: {
118
+ kind: "call";
119
+ sequence: number;
120
+ turnSequence: number;
121
+ at: string;
122
+ text: string;
123
+ } | {
124
+ kind: "note" | "thought" | "said";
125
+ sequence: number;
126
+ turnSequence: number;
127
+ at: string;
128
+ text: string;
129
+ truncated?: true | undefined;
130
+ } | {
131
+ kind: "tell";
132
+ sequence: number;
133
+ at: string;
134
+ tellId: string;
135
+ text: string;
136
+ state: "pending" | "told";
137
+ deliveries: readonly {
138
+ deliveredAt: string;
139
+ route: "live" | "launch";
140
+ turnSequence: number;
141
+ receipt?: "required" | "unavailable" | undefined;
142
+ }[];
143
+ } | {
144
+ kind: "tool";
145
+ sequence: number;
146
+ turnSequence: number;
147
+ at: string;
148
+ name: string;
149
+ call: {
150
+ kind: "run";
151
+ command: string;
152
+ } | {
153
+ kind: "read";
154
+ path: string;
155
+ offset?: number | undefined;
156
+ limit?: number | undefined;
157
+ } | {
158
+ kind: "search";
159
+ query: string;
160
+ scope?: "content" | "files" | "web" | undefined;
161
+ path?: string | undefined;
162
+ glob?: string | undefined;
163
+ } | {
164
+ kind: "fileChange";
165
+ changes: readonly {
166
+ op: "add" | "update" | "delete" | "unspecified";
167
+ path: string;
168
+ diffstat?: {
169
+ added: number;
170
+ removed: number;
171
+ } | undefined;
172
+ }[];
173
+ } | {
174
+ kind: "other";
175
+ display: string;
176
+ };
177
+ state: "active";
178
+ truncated?: true | undefined;
179
+ } | {
180
+ kind: "tool";
181
+ sequence: number;
182
+ turnSequence: number;
183
+ at: string;
184
+ name: string;
185
+ call: {
186
+ kind: "run";
187
+ command: string;
188
+ } | {
189
+ kind: "read";
190
+ path: string;
191
+ offset?: number | undefined;
192
+ limit?: number | undefined;
193
+ } | {
194
+ kind: "search";
195
+ query: string;
196
+ scope?: "content" | "files" | "web" | undefined;
197
+ path?: string | undefined;
198
+ glob?: string | undefined;
199
+ } | {
200
+ kind: "fileChange";
201
+ changes: readonly {
202
+ op: "add" | "update" | "delete" | "unspecified";
203
+ path: string;
204
+ diffstat?: {
205
+ added: number;
206
+ removed: number;
207
+ } | undefined;
208
+ }[];
209
+ } | {
210
+ kind: "other";
211
+ display: string;
212
+ };
213
+ state: {
214
+ status: "error" | "ok";
215
+ message?: string | undefined;
216
+ exitCode?: number | undefined;
217
+ };
218
+ completedAt?: string | undefined;
219
+ durationMs?: number | undefined;
220
+ truncated?: true | undefined;
221
+ };
222
+ })[];
223
+ omitted: number;
224
+ } | {
225
+ reportedChanges: readonly {
226
+ sequence: number;
227
+ at: string;
228
+ op: "add" | "update" | "delete" | "unspecified";
229
+ path: string;
230
+ diffstat?: {
231
+ added: number;
232
+ removed: number;
233
+ } | undefined;
234
+ }[];
235
+ reportedChangesOmitted: number;
236
+ kind: "idle";
237
+ entries: readonly ({
238
+ kind: "gap";
239
+ count: number;
240
+ } | {
241
+ kind: "row";
242
+ row: {
243
+ kind: "call";
244
+ sequence: number;
245
+ turnSequence: number;
246
+ at: string;
247
+ text: string;
248
+ } | {
249
+ kind: "note" | "thought" | "said";
250
+ sequence: number;
251
+ turnSequence: number;
252
+ at: string;
253
+ text: string;
254
+ truncated?: true | undefined;
255
+ } | {
256
+ kind: "tell";
257
+ sequence: number;
258
+ at: string;
259
+ tellId: string;
260
+ text: string;
261
+ state: "pending" | "told";
262
+ deliveries: readonly {
263
+ deliveredAt: string;
264
+ route: "live" | "launch";
265
+ turnSequence: number;
266
+ receipt?: "required" | "unavailable" | undefined;
267
+ }[];
268
+ } | {
269
+ kind: "tool";
270
+ sequence: number;
271
+ turnSequence: number;
272
+ at: string;
273
+ name: string;
274
+ call: {
275
+ kind: "run";
276
+ command: string;
277
+ } | {
278
+ kind: "read";
279
+ path: string;
280
+ offset?: number | undefined;
281
+ limit?: number | undefined;
282
+ } | {
283
+ kind: "search";
284
+ query: string;
285
+ scope?: "content" | "files" | "web" | undefined;
286
+ path?: string | undefined;
287
+ glob?: string | undefined;
288
+ } | {
289
+ kind: "fileChange";
290
+ changes: readonly {
291
+ op: "add" | "update" | "delete" | "unspecified";
292
+ path: string;
293
+ diffstat?: {
294
+ added: number;
295
+ removed: number;
296
+ } | undefined;
297
+ }[];
298
+ } | {
299
+ kind: "other";
300
+ display: string;
301
+ };
302
+ state: {
303
+ status: "error" | "ok";
304
+ message?: string | undefined;
305
+ exitCode?: number | undefined;
306
+ };
307
+ completedAt?: string | undefined;
308
+ durationMs?: number | undefined;
309
+ truncated?: true | undefined;
310
+ };
311
+ })[];
312
+ omitted: number;
313
+ outcome?: {
314
+ kind: "outcome";
315
+ sequence: number;
316
+ turnSequence: number;
317
+ at: string;
318
+ outcome: {
319
+ kind: "answered";
320
+ historyId: string;
321
+ answer: string;
322
+ } | {
323
+ kind: "failed";
324
+ historyId: string;
325
+ diagnostic: string;
326
+ };
327
+ } | undefined;
328
+ };
329
+ readonly?: {
330
+ enforcement: "native";
331
+ } | {
332
+ enforcement: "none";
333
+ diagnostic: string;
334
+ } | undefined;
335
+ strandedReason?: "resume-unsupported" | undefined;
336
+ };
337
+ contract: {
338
+ kind: "none";
339
+ } | {
340
+ kind: "associated";
341
+ contractId: import("./contract.js").ContractId;
342
+ } | {
343
+ kind: "failed";
344
+ diagnostic: string;
345
+ };
346
+ createdTasks: {
347
+ kind: "present";
348
+ rows: readonly {
349
+ id: `task/${string}`;
350
+ title: string;
351
+ state: "open" | "in_progress" | "on_hold" | "done" | "drop";
352
+ priority: 0 | 1 | 2 | 3;
353
+ disposition: "in_progress" | "on_hold" | "done" | "drop" | "ready" | "blocked";
354
+ updatedAt: string;
355
+ bodyPresent: boolean;
356
+ children?: {
357
+ live: number;
358
+ total: number;
359
+ } | undefined;
360
+ }[];
361
+ } | {
362
+ kind: "failed";
363
+ diagnostic: string;
364
+ };
365
+ }[];
366
+ unobserved: {
367
+ id: import("./keiyaku.js").AkuId;
368
+ diagnostic: string;
369
+ }[];
370
+ }>;
371
+ }>;
@@ -0,0 +1,28 @@
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";
6
+ import { executionChannel, localExecutionContext } from "../akuma/requests.js";
7
+ /** Internal composition root for one immutable execution channel. */
8
+ export function composeLibrary(context = localExecutionContext()) {
9
+ const captured = Object.freeze({ channel: executionChannel(context) });
10
+ return Object.freeze({
11
+ prototype: KeiyakuHandle.prototype,
12
+ [Symbol.hasInstance]: (value) => value instanceof KeiyakuHandle,
13
+ bind: (input) => bindKeiyaku(input, captured),
14
+ call: (input) => callKeiyaku(input, captured),
15
+ fork: forkKeiyaku,
16
+ history: historyAkuma,
17
+ interrupt: interruptAkuma,
18
+ kill: (input) => killAkuma(input, captured),
19
+ ls: listCatalog,
20
+ nuke: nukeKeiyaku,
21
+ list: listKeiyaku,
22
+ observe: observeKeiyaku,
23
+ of: (input) => keiyakuOf(input, captured),
24
+ status: statusAkuma,
25
+ tell: (input) => tellAkuma(input, captured),
26
+ wait: (input) => waitAkuma(input, captured),
27
+ });
28
+ }