@astrosheep/keiyaku 4.6.4 → 4.6.7

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 (247) hide show
  1. package/README.md +7 -0
  2. package/build/{integrations/marketplace → plugins}/.agents/plugins/marketplace.json +1 -1
  3. package/build/plugins/.claude-plugin/marketplace.json +5 -0
  4. package/build/{integrations/marketplace/plugins/keiyaku → plugins/claude}/.claude-plugin/plugin.json +1 -1
  5. package/build/{integrations/marketplace/plugins/keiyaku → plugins/claude}/skills/keiyaku-akuma/SKILL.md +43 -8
  6. package/build/{integrations/marketplace/plugins/keiyaku → plugins/claude}/skills/keiyaku-bind/SKILL.md +7 -8
  7. package/build/{integrations/marketplace/plugins/keiyaku → plugins/claude}/skills/keiyaku-workflow/SKILL.md +3 -3
  8. package/build/{integrations/marketplace/plugins/keiyaku → plugins/codex}/.codex-plugin/plugin.json +1 -1
  9. package/build/plugins/codex/skills/keiyaku/SKILL.md +44 -0
  10. package/build/plugins/codex/skills/keiyaku-akuma/SKILL.md +130 -0
  11. package/build/plugins/codex/skills/keiyaku-akuma/references/automation.md +269 -0
  12. package/build/plugins/codex/skills/keiyaku-babysit/SKILL.md +65 -0
  13. package/build/plugins/codex/skills/keiyaku-bind/SKILL.md +216 -0
  14. package/build/plugins/codex/skills/keiyaku-bind/agents/openai.yaml +4 -0
  15. package/build/plugins/codex/skills/keiyaku-task/SKILL.md +104 -0
  16. package/build/plugins/codex/skills/keiyaku-workflow/SKILL.md +129 -0
  17. package/build/plugins/opencode/package.json +6 -0
  18. package/build/plugins/opencode/skills/keiyaku/SKILL.md +44 -0
  19. package/build/plugins/opencode/skills/keiyaku-akuma/SKILL.md +130 -0
  20. package/build/plugins/opencode/skills/keiyaku-akuma/references/automation.md +269 -0
  21. package/build/plugins/opencode/skills/keiyaku-babysit/SKILL.md +65 -0
  22. package/build/plugins/opencode/skills/keiyaku-bind/SKILL.md +216 -0
  23. package/build/plugins/opencode/skills/keiyaku-bind/agents/openai.yaml +4 -0
  24. package/build/plugins/opencode/skills/keiyaku-task/SKILL.md +104 -0
  25. package/build/plugins/opencode/skills/keiyaku-workflow/SKILL.md +129 -0
  26. package/build/skills/keiyaku/SKILL.md +44 -0
  27. package/build/skills/keiyaku-akuma/SKILL.md +130 -0
  28. package/build/skills/keiyaku-akuma/references/automation.md +269 -0
  29. package/build/skills/keiyaku-babysit/SKILL.md +65 -0
  30. package/build/skills/keiyaku-bind/SKILL.md +216 -0
  31. package/build/skills/keiyaku-bind/agents/openai.yaml +4 -0
  32. package/build/skills/keiyaku-task/SKILL.md +104 -0
  33. package/build/skills/keiyaku-workflow/SKILL.md +129 -0
  34. package/build/src/akuma/akuma-instance.js +7 -5
  35. package/build/src/akuma/akuma-observe.d.ts +22 -15
  36. package/build/src/akuma/akuma-observe.js +87 -16
  37. package/build/src/akuma/akuma-owner.d.ts +3 -2
  38. package/build/src/akuma/akuma-owner.js +28 -10
  39. package/build/src/akuma/akuma-selection-execution.d.ts +3 -1
  40. package/build/src/akuma/akuma-selection-execution.js +2 -1
  41. package/build/src/akuma/akuma-wait.d.ts +6 -4
  42. package/build/src/akuma/akuma-wait.js +78 -53
  43. package/build/src/akuma/akuma.d.ts +6 -4
  44. package/build/src/akuma/akuma.js +4 -0
  45. package/build/src/akuma/body.d.ts +1 -0
  46. package/build/src/akuma/body.js +12 -23
  47. package/build/src/akuma/call-initial-tell.d.ts +2 -2
  48. package/build/src/akuma/call-initial-tell.js +1 -1
  49. package/build/src/akuma/call-request.d.ts +2 -2
  50. package/build/src/akuma/heart/index.d.ts +7 -2
  51. package/build/src/akuma/heart/index.js +50 -5
  52. package/build/src/akuma/heart/tells.d.ts +33 -2
  53. package/build/src/akuma/heart/tells.js +24 -18
  54. package/build/src/akuma/heart/timeline.d.ts +23 -1
  55. package/build/src/akuma/heart/timeline.js +28 -21
  56. package/build/src/akuma/projection.d.ts +10 -10
  57. package/build/src/akuma/providers/pi/index.js +72 -39
  58. package/build/src/akuma/selection-observation.d.ts +20 -20
  59. package/build/src/akuma/selection-owner-port.d.ts +1 -1
  60. package/build/src/akuma/selection-owner-port.js +16 -5
  61. package/build/src/akuma/selection-request.d.ts +2 -0
  62. package/build/src/akuma/selection-request.js +2 -1
  63. package/build/src/akuma-body.js +5 -2
  64. package/build/src/alias/index.d.ts +0 -1
  65. package/build/src/alias/index.js +0 -4
  66. package/build/src/body/amend.d.ts +0 -4
  67. package/build/src/body/amend.js +0 -3
  68. package/build/src/body/region.d.ts +0 -1
  69. package/build/src/body/region.js +0 -3
  70. package/build/src/body/verification.d.ts +0 -1
  71. package/build/src/cli/commands/akuma-grammar.js +23 -66
  72. package/build/src/cli/commands/akuma.js +23 -42
  73. package/build/src/cli/commands/contract-grammar.d.ts +14 -1
  74. package/build/src/cli/commands/contract-grammar.js +54 -21
  75. package/build/src/cli/commands/contract-help.d.ts +9 -8
  76. package/build/src/cli/commands/contract-help.js +14 -7
  77. package/build/src/cli/commands/contract.js +57 -117
  78. package/build/src/cli/commands/install.d.ts +5 -5
  79. package/build/src/cli/commands/install.js +4 -7
  80. package/build/src/cli/commands/task-grammar.js +10 -66
  81. package/build/src/cli/commands/task.d.ts +0 -1
  82. package/build/src/cli/commands/task.js +34 -53
  83. package/build/src/cli/coordinates.d.ts +1 -2
  84. package/build/src/cli/coordinates.js +1 -4
  85. package/build/src/cli/parse.d.ts +2 -3
  86. package/build/src/cli/parse.js +24 -66
  87. package/build/src/cli/render/akuma.d.ts +3 -16
  88. package/build/src/cli/render/akuma.js +1 -13
  89. package/build/src/cli/render/audit.js +1 -1
  90. package/build/src/cli/render/contract.js +34 -32
  91. package/build/src/cli/render/kanshi-akuma.d.ts +8 -2
  92. package/build/src/cli/render/kanshi-akuma.js +14 -7
  93. package/build/src/cli/render/kanshi.d.ts +3 -1
  94. package/build/src/cli/render/kanshi.js +44 -32
  95. package/build/src/cli/render/receipt.js +6 -1
  96. package/build/src/cli/render/task.d.ts +1 -1
  97. package/build/src/cli/render/task.js +3 -27
  98. package/build/src/cli/render/terminal.d.ts +6 -2
  99. package/build/src/cli/render/terminal.js +8 -2
  100. package/build/src/cli/runtime.js +3 -16
  101. package/build/src/cli/scan.d.ts +26 -0
  102. package/build/src/cli/scan.js +82 -0
  103. package/build/src/cli/streams.d.ts +5 -0
  104. package/build/src/cli/streams.js +11 -0
  105. package/build/src/contract-worktree.js +38 -21
  106. package/build/src/core/facts/codec.d.ts +1 -2
  107. package/build/src/core/facts/codec.js +5 -11
  108. package/build/src/core/facts/types.d.ts +16 -2
  109. package/build/src/core/facts/types.js +15 -0
  110. package/build/src/core/verbs/abandon.js +3 -9
  111. package/build/src/core/verbs/amend.js +2 -9
  112. package/build/src/core/verbs/arc.js +6 -13
  113. package/build/src/core/verbs/attestation.js +2 -9
  114. package/build/src/core/verbs/bind.js +2 -9
  115. package/build/src/core/verbs/deliver.js +2 -9
  116. package/build/src/core/verbs/placement.d.ts +1 -1
  117. package/build/src/core/verbs/placement.js +2 -9
  118. package/build/src/core/verbs/reintegrate.d.ts +1 -1
  119. package/build/src/core/verbs/reintegrate.js +2 -9
  120. package/build/src/dispatch/index.d.ts +2 -2
  121. package/build/src/dispatch/index.js +33 -11
  122. package/build/src/git/hooks.d.ts +2 -4
  123. package/build/src/git/hooks.js +0 -12
  124. package/build/src/git/integration.d.ts +5 -3
  125. package/build/src/git/integration.js +36 -25
  126. package/build/src/git/nuke.js +4 -4
  127. package/build/src/git/observe.d.ts +4 -4
  128. package/build/src/git/observe.js +5 -5
  129. package/build/src/git/process.d.ts +1 -4
  130. package/build/src/git/process.js +1 -11
  131. package/build/src/git/read-observation.js +1 -1
  132. package/build/src/git/reconcile.d.ts +1 -1
  133. package/build/src/git/reconcile.js +15 -13
  134. package/build/src/git/repository.d.ts +2 -6
  135. package/build/src/git/repository.js +18 -31
  136. package/build/src/git/scratch.d.ts +6 -6
  137. package/build/src/git/scratch.js +110 -46
  138. package/build/src/git/target-placement.d.ts +5 -5
  139. package/build/src/git/target-placement.js +18 -33
  140. package/build/src/git/tender.d.ts +6 -2
  141. package/build/src/git/tender.js +19 -12
  142. package/build/src/git/terminal-reconcile.js +24 -13
  143. package/build/src/git/terminal-seal.d.ts +2 -5
  144. package/build/src/git/terminal-seal.js +5 -3
  145. package/build/src/git/workspace.d.ts +17 -13
  146. package/build/src/git/workspace.js +58 -41
  147. package/build/src/kanshi/index.d.ts +2 -2
  148. package/build/src/kanshi/index.js +1 -1
  149. package/build/src/kanshi/read.d.ts +8 -1
  150. package/build/src/kanshi/read.js +72 -7
  151. package/build/src/kanshi/report.d.ts +12 -0
  152. package/build/src/library/akuma-creation.d.ts +4 -4
  153. package/build/src/library/akuma-creation.js +21 -19
  154. package/build/src/library/bind.d.ts +1 -63
  155. package/build/src/library/bind.js +3 -9
  156. package/build/src/library/contract-creation.js +2 -30
  157. package/build/src/library/contract-execution.d.ts +0 -1
  158. package/build/src/library/contract-execution.js +9 -34
  159. package/build/src/library/contract-operations.d.ts +5 -1
  160. package/build/src/library/contract-operations.js +7 -3
  161. package/build/src/library/contract-types.d.ts +1 -1
  162. package/build/src/library/delivery.d.ts +91 -93
  163. package/build/src/library/delivery.js +2 -1
  164. package/build/src/library/input.d.ts +0 -2
  165. package/build/src/library/input.js +0 -4
  166. package/build/src/library/invocation.d.ts +0 -1
  167. package/build/src/library/invocation.js +3 -25
  168. package/build/src/library/outcome.d.ts +651 -602
  169. package/build/src/library/outcome.js +4 -4
  170. package/build/src/library/reconcile.d.ts +6 -0
  171. package/build/src/library/reconcile.js +31 -1
  172. package/build/src/library/repo.d.ts +0 -1
  173. package/build/src/library/selection.d.ts +1 -10
  174. package/build/src/library/selection.js +19 -17
  175. package/build/src/plugin/akuma-signals.d.ts +10 -11
  176. package/build/src/plugin/akuma-signals.js +36 -20
  177. package/build/src/plugin/public.d.ts +5 -0
  178. package/build/src/plugin/runtime.d.ts +1 -0
  179. package/build/src/plugin/runtime.js +34 -23
  180. package/build/src/protocol/abandon.d.ts +1 -1
  181. package/build/src/protocol/abandon.js +3 -10
  182. package/build/src/protocol/amend.js +2 -5
  183. package/build/src/protocol/arc.d.ts +1 -1
  184. package/build/src/protocol/arc.js +2 -9
  185. package/build/src/protocol/attempt.d.ts +3 -20
  186. package/build/src/protocol/attempt.js +6 -5
  187. package/build/src/protocol/audit.d.ts +1 -0
  188. package/build/src/protocol/audit.js +10 -11
  189. package/build/src/protocol/completion.d.ts +129 -55
  190. package/build/src/protocol/completion.js +62 -73
  191. package/build/src/protocol/deliver.d.ts +7 -5
  192. package/build/src/protocol/deliver.js +74 -44
  193. package/build/src/protocol/execution-observation.d.ts +2 -4
  194. package/build/src/protocol/execution-observation.js +3 -7
  195. package/build/src/protocol/intent.d.ts +1 -1
  196. package/build/src/protocol/intent.js +1 -0
  197. package/build/src/protocol/operations.d.ts +24 -12
  198. package/build/src/protocol/operations.js +36 -15
  199. package/build/src/protocol/placement.d.ts +2 -1
  200. package/build/src/protocol/placement.js +21 -5
  201. package/build/src/protocol/progress.d.ts +1 -1
  202. package/build/src/protocol/read/status.js +58 -41
  203. package/build/src/protocol/reintegrate.d.ts +1 -1
  204. package/build/src/protocol/reintegrate.js +10 -19
  205. package/build/src/protocol/review.d.ts +3 -28
  206. package/build/src/protocol/review.js +10 -37
  207. package/build/src/protocol/run.d.ts +19 -7
  208. package/build/src/protocol/run.js +19 -9
  209. package/build/src/runtime/proc/windows-launch.exe +0 -0
  210. package/build/src/settlement/holder.d.ts +2 -4
  211. package/build/src/settlement/holder.js +3 -6
  212. package/build/src/task/board.d.ts +6 -0
  213. package/build/src/task/board.js +30 -1
  214. package/build/src/task/catalog.js +1 -4
  215. package/build/src/task/compose.d.ts +0 -1
  216. package/build/src/task/compose.js +0 -1
  217. package/build/src/task/context.d.ts +0 -1
  218. package/build/src/task/context.js +0 -3
  219. package/build/src/task/created-observation.d.ts +5 -1
  220. package/build/src/task/created-observation.js +12 -5
  221. package/build/src/task/index.d.ts +1 -1
  222. package/build/src/task/index.js +7 -6
  223. package/build/src/task/input.d.ts +0 -6
  224. package/build/src/task/input.js +2 -14
  225. package/build/src/task/mutation.d.ts +3 -4
  226. package/build/src/task/mutation.js +11 -39
  227. package/build/src/task/operations.d.ts +2 -7
  228. package/build/src/task/operations.js +37 -49
  229. package/build/src/task/query.d.ts +0 -1
  230. package/build/src/task/query.js +1 -4
  231. package/build/src/task/store.d.ts +0 -2
  232. package/build/src/task/store.js +27 -11
  233. package/build/src/verification/declaration.js +3 -2
  234. package/build/src/verification/execution.d.ts +3 -2
  235. package/build/src/verification/execution.js +10 -6
  236. package/build/src/workspace-place.d.ts +0 -1
  237. package/build/src/workspace-place.js +0 -11
  238. package/package.json +13 -9
  239. package/build/integrations/marketplace/.claude-plugin/marketplace.json +0 -5
  240. package/build/integrations/marketplace/plugins/keiyaku/package.json +0 -17
  241. /package/build/{integrations/marketplace/plugins/keiyaku → plugins/claude}/skills/keiyaku/SKILL.md +0 -0
  242. /package/build/{integrations/marketplace/plugins/keiyaku → plugins/claude}/skills/keiyaku-akuma/references/automation.md +0 -0
  243. /package/build/{integrations/marketplace/plugins/keiyaku → plugins/claude}/skills/keiyaku-babysit/SKILL.md +0 -0
  244. /package/build/{integrations/marketplace/plugins/keiyaku → plugins/claude}/skills/keiyaku-bind/agents/openai.yaml +0 -0
  245. /package/build/{integrations/marketplace/plugins/keiyaku → plugins/claude}/skills/keiyaku-task/SKILL.md +0 -0
  246. /package/build/{integrations/marketplace/plugins/keiyaku/opencode.js → plugins/opencode/index.js} +0 -0
  247. /package/build/{integrations → plugins}/pi/keiyaku.ts +0 -0
@@ -115,6 +115,37 @@ async function runPiPrompt(native, input, events, state, settle) {
115
115
  : { kind: "failed", diagnostic: diagnostic(error) });
116
116
  }
117
117
  }
118
+ async function retirePiSession(native) {
119
+ let failure;
120
+ let unsubscribe;
121
+ try {
122
+ const runner = native.extensionRunner;
123
+ unsubscribe = runner?.onError((error) => {
124
+ if (error.event === "session_shutdown")
125
+ failure ??= new Error(error.error);
126
+ });
127
+ await runner?.emit({ type: "session_shutdown", reason: "quit" });
128
+ }
129
+ catch (error) {
130
+ failure ??= error;
131
+ }
132
+ finally {
133
+ try {
134
+ unsubscribe?.();
135
+ }
136
+ catch (error) {
137
+ failure ??= error;
138
+ }
139
+ try {
140
+ native.dispose();
141
+ }
142
+ catch (error) {
143
+ failure ??= error;
144
+ }
145
+ }
146
+ if (failure !== undefined)
147
+ throw failure;
148
+ }
118
149
  async function drivePi(sdk, execution, input, signal, custody) {
119
150
  const created = await createPiSession(sdk, execution, input);
120
151
  const native = created.session;
@@ -144,33 +175,7 @@ async function drivePi(sdk, execution, input, signal, custody) {
144
175
  const agent = native.agent;
145
176
  let unsubscribeAgent;
146
177
  let unsubscribe;
147
- try {
148
- unsubscribeAgent = agent.subscribe((event) => {
149
- if (event.type === "message_end") {
150
- const waiter = pendingTells.get(event.message);
151
- if (waiter !== undefined) {
152
- pendingTells.delete(event.message);
153
- waiter.resolve({ kind: "accepted", fence: `${native.sessionId}:${waiter.id}` });
154
- }
155
- }
156
- });
157
- unsubscribe = native.subscribe((event) => {
158
- if (event.type === "agent_end" && !event.willRetry) {
159
- state.terminalFailure = piTerminalFailure(event.messages);
160
- }
161
- for (const translated of translatePiEvent(event, eventState))
162
- events.emit(translated);
163
- });
164
- }
165
- catch (error) {
166
- try {
167
- unsubscribeAgent?.();
168
- }
169
- finally {
170
- native.dispose();
171
- }
172
- throw error;
173
- }
178
+ let binding;
174
179
  const settle = (result) => {
175
180
  if (state.settled)
176
181
  return closed;
@@ -178,7 +183,7 @@ async function drivePi(sdk, execution, input, signal, custody) {
178
183
  endPendingTells();
179
184
  let failure;
180
185
  try {
181
- unsubscribe();
186
+ unsubscribe?.();
182
187
  }
183
188
  catch (error) {
184
189
  failure = error;
@@ -191,16 +196,19 @@ async function drivePi(sdk, execution, input, signal, custody) {
191
196
  }
192
197
  events.end();
193
198
  settleCompletion(result);
194
- try {
195
- native.dispose();
196
- }
197
- catch (error) {
198
- failure ??= error;
199
- }
200
- if (failure === undefined)
201
- settleRetired();
202
- else
203
- failRetired(failure);
199
+ void (async () => {
200
+ // Binding can create extension resources after cancellation. Shutdown must
201
+ // run after that work, while its contexts are still valid.
202
+ await binding?.catch(() => undefined);
203
+ try {
204
+ await retirePiSession(native);
205
+ }
206
+ catch (error) {
207
+ failure ??= error;
208
+ }
209
+ if (failure !== undefined)
210
+ throw failure;
211
+ })().then(settleRetired, failRetired);
204
212
  return closed;
205
213
  };
206
214
  const forceDispose = async () => {
@@ -209,6 +217,28 @@ async function drivePi(sdk, execution, input, signal, custody) {
209
217
  await settle({ kind: "failed", diagnostic: "Pi session force-disposed" });
210
218
  };
211
219
  custody?.own({ closed, abort: forceDispose, forceDispose });
220
+ try {
221
+ unsubscribeAgent = agent.subscribe((event) => {
222
+ if (event.type === "message_end") {
223
+ const waiter = pendingTells.get(event.message);
224
+ if (waiter !== undefined) {
225
+ pendingTells.delete(event.message);
226
+ waiter.resolve({ kind: "accepted", fence: `${native.sessionId}:${waiter.id}` });
227
+ }
228
+ }
229
+ });
230
+ unsubscribe = native.subscribe((event) => {
231
+ if (event.type === "agent_end" && !event.willRetry) {
232
+ state.terminalFailure = piTerminalFailure(event.messages);
233
+ }
234
+ for (const translated of translatePiEvent(event, eventState))
235
+ events.emit(translated);
236
+ });
237
+ }
238
+ catch (error) {
239
+ await settle({ kind: "failed", diagnostic: diagnostic(error) });
240
+ throw error;
241
+ }
212
242
  if (signal.aborted) {
213
243
  await settle({ kind: "failed", diagnostic: "Pi session aborted" });
214
244
  signal.throwIfAborted();
@@ -217,9 +247,12 @@ async function drivePi(sdk, execution, input, signal, custody) {
217
247
  await settle({ kind: "failed", diagnostic: "Pi session admitted without sessionFile" });
218
248
  throw new Error("Pi session admitted without sessionFile");
219
249
  }
250
+ binding = Promise.resolve().then(() => native.bindExtensions({}));
251
+ await abortable(binding, signal);
252
+ signal.throwIfAborted();
220
253
  events.emit({ type: "session", coordinate: { sessionFile: native.sessionFile, sessionId: native.sessionId } });
221
254
  void runPiPrompt(native, input, eventState, state, (result) => {
222
- void settle(result);
255
+ void settle(result).catch(() => undefined);
223
256
  });
224
257
  return {
225
258
  admission: { fence: native.sessionId },
@@ -125,8 +125,8 @@ declare const akumaObservationSchema: z.ZodObject<{
125
125
  }>;
126
126
  turnSequence: z.ZodNumber;
127
127
  receipt: z.ZodOptional<z.ZodEnum<{
128
- required: "required";
129
128
  unavailable: "unavailable";
129
+ required: "required";
130
130
  }>>;
131
131
  }, z.core.$strict>, z.ZodTransform<Readonly<{
132
132
  turnSequence: number;
@@ -137,7 +137,7 @@ declare const akumaObservationSchema: z.ZodObject<{
137
137
  deliveredAt: string;
138
138
  route: "live" | "launch";
139
139
  turnSequence: number;
140
- receipt?: "required" | "unavailable" | undefined;
140
+ receipt?: "unavailable" | "required" | undefined;
141
141
  }>>>>;
142
142
  }, z.core.$strict>]>, z.ZodObject<{
143
143
  kind: z.ZodLiteral<"tool">;
@@ -332,8 +332,8 @@ declare const akumaObservationSchema: z.ZodObject<{
332
332
  }>;
333
333
  turnSequence: z.ZodNumber;
334
334
  receipt: z.ZodOptional<z.ZodEnum<{
335
- required: "required";
336
335
  unavailable: "unavailable";
336
+ required: "required";
337
337
  }>>;
338
338
  }, z.core.$strict>, z.ZodTransform<Readonly<{
339
339
  turnSequence: number;
@@ -344,7 +344,7 @@ declare const akumaObservationSchema: z.ZodObject<{
344
344
  deliveredAt: string;
345
345
  route: "live" | "launch";
346
346
  turnSequence: number;
347
- receipt?: "required" | "unavailable" | undefined;
347
+ receipt?: "unavailable" | "required" | undefined;
348
348
  }>>>>;
349
349
  }, z.core.$strict>]>, z.ZodObject<{
350
350
  kind: z.ZodLiteral<"tool">;
@@ -589,8 +589,8 @@ declare const akumaWaitResultSchema: z.ZodObject<{
589
589
  }>;
590
590
  turnSequence: z.ZodNumber;
591
591
  receipt: z.ZodOptional<z.ZodEnum<{
592
- required: "required";
593
592
  unavailable: "unavailable";
593
+ required: "required";
594
594
  }>>;
595
595
  }, z.core.$strict>, z.ZodTransform<Readonly<{
596
596
  turnSequence: number;
@@ -601,7 +601,7 @@ declare const akumaWaitResultSchema: z.ZodObject<{
601
601
  deliveredAt: string;
602
602
  route: "live" | "launch";
603
603
  turnSequence: number;
604
- receipt?: "required" | "unavailable" | undefined;
604
+ receipt?: "unavailable" | "required" | undefined;
605
605
  }>>>>;
606
606
  }, z.core.$strict>]>, z.ZodObject<{
607
607
  kind: z.ZodLiteral<"tool">;
@@ -796,8 +796,8 @@ declare const akumaWaitResultSchema: z.ZodObject<{
796
796
  }>;
797
797
  turnSequence: z.ZodNumber;
798
798
  receipt: z.ZodOptional<z.ZodEnum<{
799
- required: "required";
800
799
  unavailable: "unavailable";
800
+ required: "required";
801
801
  }>>;
802
802
  }, z.core.$strict>, z.ZodTransform<Readonly<{
803
803
  turnSequence: number;
@@ -808,7 +808,7 @@ declare const akumaWaitResultSchema: z.ZodObject<{
808
808
  deliveredAt: string;
809
809
  route: "live" | "launch";
810
810
  turnSequence: number;
811
- receipt?: "required" | "unavailable" | undefined;
811
+ receipt?: "unavailable" | "required" | undefined;
812
812
  }>>>>;
813
813
  }, z.core.$strict>]>, z.ZodObject<{
814
814
  kind: z.ZodLiteral<"tool">;
@@ -958,8 +958,8 @@ declare const akumaTellResultSchema: z.ZodObject<{
958
958
  }>;
959
959
  turnSequence: z.ZodNumber;
960
960
  receipt: z.ZodOptional<z.ZodEnum<{
961
- required: "required";
962
961
  unavailable: "unavailable";
962
+ required: "required";
963
963
  }>>;
964
964
  }, z.core.$strict>, z.ZodTransform<Readonly<{
965
965
  turnSequence: number;
@@ -970,7 +970,7 @@ declare const akumaTellResultSchema: z.ZodObject<{
970
970
  deliveredAt: string;
971
971
  route: "live" | "launch";
972
972
  turnSequence: number;
973
- receipt?: "required" | "unavailable" | undefined;
973
+ receipt?: "unavailable" | "required" | undefined;
974
974
  }>>>>;
975
975
  }, z.core.$strict>;
976
976
  wake: z.ZodUnion<readonly [z.ZodObject<{
@@ -1062,8 +1062,8 @@ declare const akumaAskResultSchema: z.ZodObject<{
1062
1062
  }>;
1063
1063
  turnSequence: z.ZodNumber;
1064
1064
  receipt: z.ZodOptional<z.ZodEnum<{
1065
- required: "required";
1066
1065
  unavailable: "unavailable";
1066
+ required: "required";
1067
1067
  }>>;
1068
1068
  }, z.core.$strict>, z.ZodTransform<Readonly<{
1069
1069
  turnSequence: number;
@@ -1074,7 +1074,7 @@ declare const akumaAskResultSchema: z.ZodObject<{
1074
1074
  deliveredAt: string;
1075
1075
  route: "live" | "launch";
1076
1076
  turnSequence: number;
1077
- receipt?: "required" | "unavailable" | undefined;
1077
+ receipt?: "unavailable" | "required" | undefined;
1078
1078
  }>>>>;
1079
1079
  }, z.core.$strict>;
1080
1080
  wake: z.ZodUnion<readonly [z.ZodObject<{
@@ -1301,8 +1301,8 @@ export declare const selectionResultSchemas: {
1301
1301
  }>;
1302
1302
  turnSequence: z.ZodNumber;
1303
1303
  receipt: z.ZodOptional<z.ZodEnum<{
1304
- required: "required";
1305
1304
  unavailable: "unavailable";
1305
+ required: "required";
1306
1306
  }>>;
1307
1307
  }, z.core.$strict>, z.ZodTransform<Readonly<{
1308
1308
  turnSequence: number;
@@ -1313,7 +1313,7 @@ export declare const selectionResultSchemas: {
1313
1313
  deliveredAt: string;
1314
1314
  route: "live" | "launch";
1315
1315
  turnSequence: number;
1316
- receipt?: "required" | "unavailable" | undefined;
1316
+ receipt?: "unavailable" | "required" | undefined;
1317
1317
  }>>>>;
1318
1318
  }, z.core.$strict>]>, z.ZodObject<{
1319
1319
  kind: z.ZodLiteral<"tool">;
@@ -1508,8 +1508,8 @@ export declare const selectionResultSchemas: {
1508
1508
  }>;
1509
1509
  turnSequence: z.ZodNumber;
1510
1510
  receipt: z.ZodOptional<z.ZodEnum<{
1511
- required: "required";
1512
1511
  unavailable: "unavailable";
1512
+ required: "required";
1513
1513
  }>>;
1514
1514
  }, z.core.$strict>, z.ZodTransform<Readonly<{
1515
1515
  turnSequence: number;
@@ -1520,7 +1520,7 @@ export declare const selectionResultSchemas: {
1520
1520
  deliveredAt: string;
1521
1521
  route: "live" | "launch";
1522
1522
  turnSequence: number;
1523
- receipt?: "required" | "unavailable" | undefined;
1523
+ receipt?: "unavailable" | "required" | undefined;
1524
1524
  }>>>>;
1525
1525
  }, z.core.$strict>]>, z.ZodObject<{
1526
1526
  kind: z.ZodLiteral<"tool">;
@@ -1657,8 +1657,8 @@ export declare const selectionResultSchemas: {
1657
1657
  }>;
1658
1658
  turnSequence: z.ZodNumber;
1659
1659
  receipt: z.ZodOptional<z.ZodEnum<{
1660
- required: "required";
1661
1660
  unavailable: "unavailable";
1661
+ required: "required";
1662
1662
  }>>;
1663
1663
  }, z.core.$strict>, z.ZodTransform<Readonly<{
1664
1664
  turnSequence: number;
@@ -1669,7 +1669,7 @@ export declare const selectionResultSchemas: {
1669
1669
  deliveredAt: string;
1670
1670
  route: "live" | "launch";
1671
1671
  turnSequence: number;
1672
- receipt?: "required" | "unavailable" | undefined;
1672
+ receipt?: "unavailable" | "required" | undefined;
1673
1673
  }>>>>;
1674
1674
  }, z.core.$strict>;
1675
1675
  wake: z.ZodUnion<readonly [z.ZodObject<{
@@ -1746,8 +1746,8 @@ export declare const selectionResultSchemas: {
1746
1746
  }>;
1747
1747
  turnSequence: z.ZodNumber;
1748
1748
  receipt: z.ZodOptional<z.ZodEnum<{
1749
- required: "required";
1750
1749
  unavailable: "unavailable";
1750
+ required: "required";
1751
1751
  }>>;
1752
1752
  }, z.core.$strict>, z.ZodTransform<Readonly<{
1753
1753
  turnSequence: number;
@@ -1758,7 +1758,7 @@ export declare const selectionResultSchemas: {
1758
1758
  deliveredAt: string;
1759
1759
  route: "live" | "launch";
1760
1760
  turnSequence: number;
1761
- receipt?: "required" | "unavailable" | undefined;
1761
+ receipt?: "unavailable" | "required" | undefined;
1762
1762
  }>>>>;
1763
1763
  }, z.core.$strict>;
1764
1764
  wake: z.ZodUnion<readonly [z.ZodObject<{
@@ -9,4 +9,4 @@ import type { SelectionRequestPort } from "./selection-request.js";
9
9
  * unaddressable member never starts; the executor's own access to the target is
10
10
  * then the product act, never a second addressing probe.
11
11
  */
12
- export declare function selectionRequestPort(world: WorldRoot): SelectionRequestPort;
12
+ export declare function selectionRequestPort(world: WorldRoot, reportDiagnostic: (message: string) => void): SelectionRequestPort;
@@ -1,3 +1,4 @@
1
+ import { outcomePluginObserver } from "../plugin/akuma-signals.js";
1
2
  import { requireBornAkuma } from "./akuma-probe.js";
2
3
  import { executeAskAkuma, executeKillAkuma, executeTellAkuma } from "./akuma-selection-execution.js";
3
4
  import { executeWaitAkuma } from "./akuma-wait.js";
@@ -11,26 +12,36 @@ import { akumaObservationOf } from "./selection-observation.js";
11
12
  * unaddressable member never starts; the executor's own access to the target is
12
13
  * then the product act, never a second addressing probe.
13
14
  */
14
- export function selectionRequestPort(world) {
15
+ export function selectionRequestPort(world, reportDiagnostic) {
15
16
  const prove = async (targets) => {
16
17
  for (const id of targets)
17
18
  await requireBornAkuma(world, id);
18
19
  };
19
20
  return {
20
- wait: async ({ targets, ...request }) => {
21
+ wait: async ({ targets, observer, ...request }) => {
21
22
  await prove(targets);
22
23
  // The lower wait owner returns association-free native evidence; the
23
24
  // actual request crossing composes its canonical transport shape.
24
- const native = await executeWaitAkuma({ path: world, ids: targets, ...request });
25
+ const native = await executeWaitAkuma({
26
+ path: world,
27
+ ids: targets,
28
+ ...request,
29
+ outcomeObserved: outcomePluginObserver({ world, reportDiagnostic }, observer),
30
+ });
25
31
  return { ...native, observations: native.observations.map(akumaObservationOf) };
26
32
  },
27
33
  tell: async ({ target, ...request }) => {
28
34
  await prove([target]);
29
35
  return await executeTellAkuma({ path: world, id: target, ...request });
30
36
  },
31
- ask: async ({ target, ...request }) => {
37
+ ask: async ({ target, observer, ...request }) => {
32
38
  await prove([target]);
33
- return await executeAskAkuma({ path: world, id: target, ...request });
39
+ return await executeAskAkuma({
40
+ path: world,
41
+ id: target,
42
+ ...request,
43
+ outcomeObserved: outcomePluginObserver({ world, reportDiagnostic }, observer),
44
+ });
34
45
  },
35
46
  kill: async ({ targets, ...request }) => {
36
47
  await prove(targets);
@@ -106,6 +106,7 @@ export type SelectionRequestPort = Readonly<{
106
106
  targets: readonly AkumaStatus["id"][];
107
107
  completion: "any" | "all";
108
108
  timeoutMs?: number;
109
+ observer: string;
109
110
  signal: AbortSignal;
110
111
  }>): Promise<AkumaWaitResult>;
111
112
  tell(input: Readonly<{
@@ -126,6 +127,7 @@ export type SelectionRequestPort = Readonly<{
126
127
  schemaJson?: string;
127
128
  initiator?: string;
128
129
  interrupt?: boolean;
130
+ observer: string;
129
131
  signal: AbortSignal;
130
132
  }>): Promise<AkumaAskResult>;
131
133
  kill(input: Readonly<{
@@ -167,7 +167,7 @@ export function selectionRequestCommand(action, port) {
167
167
  if (request.action === "akuma.wait") {
168
168
  return {
169
169
  kind: "served",
170
- result: await port.wait({ ...request, signal: facts.signal }),
170
+ result: await port.wait({ ...request, observer: facts.requester, signal: facts.signal }),
171
171
  service: { action: request.action },
172
172
  };
173
173
  }
@@ -196,6 +196,7 @@ export function selectionRequestCommand(action, port) {
196
196
  body: request.body,
197
197
  tellId: facts.id,
198
198
  recordedAt: facts.admittedAt,
199
+ observer: facts.requester,
199
200
  ...(request.timeoutMs === undefined ? {} : { timeoutMs: request.timeoutMs }),
200
201
  ...(request.schemaJson === undefined ? {} : { schemaJson: request.schemaJson }),
201
202
  ...(request.initiator === undefined ? {} : { initiator: request.initiator }),
@@ -1,6 +1,6 @@
1
1
  import { resolve } from "node:path";
2
2
  import { fileURLToPath } from "node:url";
3
- import { bodyLaunchSchema, LEASH_HELD_EXIT, runAkumaBody } from "./akuma/body.js";
3
+ import { bodyLaunchSchema, LEASH_HELD_EXIT, runAkumaBody, recordPluginDiagnostic, } from "./akuma/body.js";
4
4
  import { worldRootForAkumaPaths } from "./akuma/identity.js";
5
5
  import { composeRequestCommands } from "./akuma/request-wire.js";
6
6
  import { localExecutionContext } from "./akuma/requests.js";
@@ -62,6 +62,7 @@ function contractUpstream(processConfiguration) {
62
62
  return await contractChannel(repo, input.contractId, input.requester, configuration).review({
63
63
  verdict: input.verdict,
64
64
  ...(input.summary === undefined ? {} : { summary: input.summary }),
65
+ ...(input.actor === undefined ? {} : { actor: input.actor }),
65
66
  signal: input.signal,
66
67
  }, input.observe === undefined ? undefined : { observe: input.observe });
67
68
  },
@@ -107,7 +108,9 @@ export async function externalRequestCommandsFor(launch, processConfiguration) {
107
108
  const world = await World.prove(worldRootForAkumaPaths(launch.paths));
108
109
  return {
109
110
  world,
110
- commands: composeRequestCommands(selectionRequestCommands(selectionRequestPort(world)), contractRequestCommands(contractUpstream(processConfiguration)), taskMutationRequestCommands(taskMutationRequestPort())),
111
+ commands: composeRequestCommands(selectionRequestCommands(selectionRequestPort(world, (message) => {
112
+ void recordPluginDiagnostic(launch.paths, "outcome observation", message);
113
+ })), contractRequestCommands(contractUpstream(processConfiguration)), taskMutationRequestCommands(taskMutationRequestPort())),
111
114
  };
112
115
  }
113
116
  function bodyProcessConfiguration() {
@@ -11,7 +11,6 @@ export type AliasMove = Readonly<{
11
11
  }>;
12
12
  export declare function nukeAliases(world: WorldRoot): Promise<void>;
13
13
  export declare function readAliases(world: WorldRoot): Promise<readonly AliasBinding[]>;
14
- export declare function resolveAlias(world: WorldRoot, value: AkumaAlias): Promise<AkuId | null>;
15
14
  export declare function moveAlias(input: Readonly<{
16
15
  world: WorldRoot;
17
16
  alias: AkumaAlias;
@@ -113,10 +113,6 @@ export async function nukeAliases(world) {
113
113
  export async function readAliases(world) {
114
114
  return await read(paths(world).authority);
115
115
  }
116
- export async function resolveAlias(world, value) {
117
- const alias = parseReadableAkumaAlias(value);
118
- return (await readAliases(world)).find((binding) => binding.alias === alias)?.akuId ?? null;
119
- }
120
116
  export async function moveAlias(input) {
121
117
  const alias = parseAkumaAlias(input.alias);
122
118
  const akuId = parseAkuId(input.akuId).id;
@@ -1,8 +1,4 @@
1
1
  import type { DecodedContractDocument } from "./types.js";
2
- export declare function applyAmendDocument(source: string, current: DecodedContractDocument): Readonly<{
3
- document: string;
4
- changedSections: ReadonlySet<string>;
5
- }>;
6
2
  /** Caller syntax is decoded before any repository observation; current-dependent application stays pure. */
7
3
  export declare function prepareAmendDocument(source: string): (current: DecodedContractDocument) => Readonly<{
8
4
  document: string;
@@ -239,9 +239,6 @@ function apply(document, operations, current) {
239
239
  }
240
240
  return { body: completeBody(body), changed };
241
241
  }
242
- export function applyAmendDocument(source, current) {
243
- return prepareAmendDocument(source)(current);
244
- }
245
242
  /** Caller syntax is decoded before any repository observation; current-dependent application stays pure. */
246
243
  export function prepareAmendDocument(source) {
247
244
  const document = parseToAST(source);
@@ -17,4 +17,3 @@ export declare function decodeRegionOrRefusal(document: DocumentNode, section: S
17
17
  export type RegionRelation = "same" | "mine-within-theirs" | "theirs-within-mine" | "intersect";
18
18
  export type RegionOverlapPair = readonly [mine: string, theirs: string, relation: RegionRelation];
19
19
  export declare function regionsOverlapWithRelation(mine: readonly string[], theirs: readonly string[]): readonly RegionOverlapPair[];
20
- export declare function regionsOverlap(mine: readonly string[], theirs: readonly string[]): readonly [string, string][];
@@ -254,6 +254,3 @@ export function regionsOverlapWithRelation(mine, theirs) {
254
254
  }
255
255
  return overlaps;
256
256
  }
257
- export function regionsOverlap(mine, theirs) {
258
- return regionsOverlapWithRelation(mine, theirs).map(([minePattern, theirsPattern]) => [minePattern, theirsPattern]);
259
- }
@@ -1,6 +1,5 @@
1
1
  import type { DocumentNode, SectionNode } from "../markdown/types.js";
2
2
  import type { VerificationDeclaration } from "../verification/declaration.js";
3
- export type { VerificationDeclaration, VerificationExecutor } from "../verification/declaration.js";
4
3
  export declare class VerificationDocumentError extends Error {
5
4
  constructor(message: string);
6
5
  }
@@ -1,4 +1,5 @@
1
- import { CliUsageError, commandGuide, isBlankInput, usageLine } from "../usage.js";
1
+ import { CliUsageError, commandGuide, usageLine } from "../usage.js";
2
+ import { scanArgs } from "../scan.js";
2
3
  import { parseDuration as decodeDuration } from "../../duration.js";
3
4
  import { parseAkumaAlias, parseAkumaGlob } from "../../identity/selector.js";
4
5
  import { ALLOWED_ACTIONS, DEFAULT_ALLOWED_ACTIONS, decodeAllowedActions, } from "../../akuma/allowed.js";
@@ -12,7 +13,7 @@ const AKUMA_COMMAND_SPECS = {
12
13
  contract: "value",
13
14
  alias: "value",
14
15
  wait: "value",
15
- allowed: "repeatable",
16
+ allowed: "repeat",
16
17
  json: "boolean",
17
18
  schema: "value",
18
19
  },
@@ -134,6 +135,23 @@ export function renderAkumaHelp(action) {
134
135
  export function akumaUsageGuide(action) {
135
136
  return commandGuide(action, AKUMA_COMMAND_SPECS[action].usage);
136
137
  }
138
+ const TELL_ONLY_REFUSALS = {
139
+ "--wait": "tell --wait is not supported; use ask --wait",
140
+ "--schema": "tell --schema is not supported; use ask --schema",
141
+ };
142
+ /** The prompt is the only stdin reader; the ask-only options are refused tokens, as is `-d`. */
143
+ function scanSpec(action, spec) {
144
+ return {
145
+ subject: action,
146
+ flags: spec.flags,
147
+ ...(spec.stdin ? { stdin: "prompt" } : {}),
148
+ stdinRefusal: `stdin marker '-' is not valid for ${action}`,
149
+ refused: {
150
+ "-d": `option -d is not valid for ${action}`,
151
+ ...(action === "tell" ? TELL_ONLY_REFUSALS : {}),
152
+ },
153
+ };
154
+ }
137
155
  function stringFlag(value, diagnostic, fail) {
138
156
  if (typeof value !== "string")
139
157
  fail(diagnostic);
@@ -149,67 +167,6 @@ function parseDuration(raw, option, fail) {
149
167
  fail(`${option} duration exceeds the safe millisecond range`);
150
168
  return duration.milliseconds;
151
169
  }
152
- function scanNamedOption(input, flags, fail) {
153
- const token = input.argv[input.index];
154
- const name = token.slice(2);
155
- const kind = input.spec.flags[name];
156
- if (kind === undefined)
157
- fail(`option ${token} is not valid for ${input.action}`);
158
- if (kind !== "repeatable" && flags[name] !== undefined)
159
- fail(`duplicate option: ${token}`);
160
- if (kind === "boolean") {
161
- flags[name] = true;
162
- return input.index;
163
- }
164
- const value = input.argv[input.index + 1];
165
- if (value === undefined || value === "-" || value === "-d" || value.startsWith("--")) {
166
- fail(`${token} requires a value`);
167
- }
168
- if (isBlankInput(value))
169
- fail(`${token} requires a nonblank value`);
170
- flags[name] = kind === "repeatable" ? [...(Array.isArray(flags[name]) ? flags[name] : []), value] : value;
171
- return input.index + 1;
172
- }
173
- function scanAkuma(action, argv, fail) {
174
- const spec = AKUMA_COMMAND_SPECS[action];
175
- const flags = {};
176
- const positionals = [];
177
- let stdin = false;
178
- let positionalOnly = false;
179
- for (let index = 1; index < argv.length; index += 1) {
180
- const token = argv[index];
181
- if (!positionalOnly && token === "--") {
182
- positionalOnly = true;
183
- continue;
184
- }
185
- if (positionalOnly) {
186
- if (isBlankInput(token))
187
- fail(`${action} requires a nonblank value`);
188
- positionals.push(token);
189
- }
190
- else if (token === "-") {
191
- if (!spec.stdin)
192
- fail(`stdin marker '-' is not valid for ${action}`);
193
- if (stdin)
194
- fail("stdin marker '-' may appear only once");
195
- stdin = true;
196
- }
197
- else if (token === "-d") {
198
- fail(`option ${token} is not valid for ${action}`);
199
- }
200
- else if (!token.startsWith("--")) {
201
- if (isBlankInput(token))
202
- fail(`${action} requires a nonblank value`);
203
- positionals.push(token);
204
- }
205
- else {
206
- if (action === "tell" && (token === "--wait" || token === "--schema"))
207
- fail(`tell ${token} is not supported; use ask ${token}`);
208
- index = scanNamedOption({ action, spec, argv, index }, flags, fail);
209
- }
210
- }
211
- return { flags, positionals, stdin };
212
- }
213
170
  function positiveIndex(raw, option, fail) {
214
171
  if (typeof raw !== "string" || !/^[1-9][0-9]*$/u.test(raw))
215
172
  fail(`${option} requires a positive integer`);
@@ -397,10 +354,10 @@ export function parseAkumaCommand(argv) {
397
354
  const fail = (message) => {
398
355
  throw new CliUsageError(message, akumaUsageGuide(action));
399
356
  };
400
- const { flags, positionals, stdin } = scanAkuma(action, argv, fail);
357
+ const { flags, positionals, stdin } = scanArgs(argv, scanSpec(action, spec), fail);
401
358
  const output = flags.json === true ? "json" : "text";
402
359
  if (action === "call" || action === "tell" || action === "ask") {
403
- const parsed = parsePrompted(action, positionals, stdin, fail);
360
+ const parsed = parsePrompted(action, positionals, stdin !== undefined, fail);
404
361
  return action === "call"
405
362
  ? parseCall(flags, parsed.subject, parsed.prompt, output, fail)
406
363
  : action === "tell"
@@ -417,7 +374,7 @@ export function parseAkumaCommand(argv) {
417
374
  ? `${action} accepts one Akuma selector`
418
375
  : `${action} accepts exactly ${spec.arity} Akuma selectors`);
419
376
  }
420
- if (stdin)
377
+ if (stdin !== undefined)
421
378
  fail(`${action} reads no stdin`);
422
379
  return parseAddressed(action, positionals, flags, output, fail);
423
380
  }