@astrosheep/keiyaku 4.6.6 → 4.6.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 (217) hide show
  1. package/README.md +11 -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/codex}/.codex-plugin/plugin.json +1 -1
  6. package/build/plugins/codex/skills/keiyaku/SKILL.md +44 -0
  7. package/build/plugins/codex/skills/keiyaku-akuma/SKILL.md +130 -0
  8. package/build/plugins/codex/skills/keiyaku-akuma/references/automation.md +269 -0
  9. package/build/plugins/codex/skills/keiyaku-babysit/SKILL.md +65 -0
  10. package/build/plugins/codex/skills/keiyaku-bind/SKILL.md +216 -0
  11. package/build/plugins/codex/skills/keiyaku-bind/agents/openai.yaml +4 -0
  12. package/build/plugins/codex/skills/keiyaku-task/SKILL.md +104 -0
  13. package/build/plugins/codex/skills/keiyaku-workflow/SKILL.md +129 -0
  14. package/build/plugins/opencode/package.json +6 -0
  15. package/build/plugins/opencode/skills/keiyaku/SKILL.md +44 -0
  16. package/build/plugins/opencode/skills/keiyaku-akuma/SKILL.md +130 -0
  17. package/build/plugins/opencode/skills/keiyaku-akuma/references/automation.md +269 -0
  18. package/build/plugins/opencode/skills/keiyaku-babysit/SKILL.md +65 -0
  19. package/build/plugins/opencode/skills/keiyaku-bind/SKILL.md +216 -0
  20. package/build/plugins/opencode/skills/keiyaku-bind/agents/openai.yaml +4 -0
  21. package/build/plugins/opencode/skills/keiyaku-task/SKILL.md +104 -0
  22. package/build/plugins/opencode/skills/keiyaku-workflow/SKILL.md +129 -0
  23. package/build/{integrations → plugins}/pi/keiyaku.ts +0 -5
  24. package/build/skills/keiyaku/SKILL.md +44 -0
  25. package/build/skills/keiyaku-akuma/SKILL.md +130 -0
  26. package/build/skills/keiyaku-akuma/references/automation.md +269 -0
  27. package/build/skills/keiyaku-babysit/SKILL.md +65 -0
  28. package/build/skills/keiyaku-bind/SKILL.md +216 -0
  29. package/build/skills/keiyaku-bind/agents/openai.yaml +4 -0
  30. package/build/skills/keiyaku-task/SKILL.md +104 -0
  31. package/build/skills/keiyaku-workflow/SKILL.md +129 -0
  32. package/build/src/akuma/akuma-call.d.ts +2 -0
  33. package/build/src/akuma/akuma-call.js +8 -2
  34. package/build/src/akuma/akuma-instance.d.ts +12 -1
  35. package/build/src/akuma/akuma-instance.js +31 -9
  36. package/build/src/akuma/akuma-observe.d.ts +4 -0
  37. package/build/src/akuma/akuma-observe.js +14 -0
  38. package/build/src/akuma/akuma-owner.d.ts +6 -2
  39. package/build/src/akuma/akuma-owner.js +32 -10
  40. package/build/src/akuma/akuma-selection-execution.d.ts +3 -1
  41. package/build/src/akuma/akuma-selection-execution.js +2 -1
  42. package/build/src/akuma/akuma-wait.d.ts +2 -1
  43. package/build/src/akuma/akuma-wait.js +4 -1
  44. package/build/src/akuma/akuma.d.ts +35 -5
  45. package/build/src/akuma/akuma.js +8 -10
  46. package/build/src/akuma/archetype.d.ts +7 -15
  47. package/build/src/akuma/archetype.js +36 -35
  48. package/build/src/akuma/body.d.ts +6 -3
  49. package/build/src/akuma/body.js +41 -30
  50. package/build/src/akuma/call-request.d.ts +18 -10
  51. package/build/src/akuma/call-request.js +10 -3
  52. package/build/src/akuma/caller.d.ts +39 -0
  53. package/build/src/akuma/caller.js +36 -0
  54. package/build/src/akuma/dispatch-association.d.ts +0 -1
  55. package/build/src/akuma/dispatch-association.js +0 -3
  56. package/build/src/akuma/heart/facts.d.ts +16 -12
  57. package/build/src/akuma/heart/facts.js +8 -0
  58. package/build/src/akuma/heart/index.d.ts +2 -7
  59. package/build/src/akuma/heart/index.js +3 -17
  60. package/build/src/akuma/heart/rows.d.ts +3 -3
  61. package/build/src/akuma/heart/soul.d.ts +1 -1
  62. package/build/src/akuma/heart/soul.js +5 -24
  63. package/build/src/akuma/heart/storage.d.ts +5 -0
  64. package/build/src/akuma/heart/storage.js +7 -3
  65. package/build/src/akuma/identity.d.ts +0 -1
  66. package/build/src/akuma/identity.js +2 -5
  67. package/build/src/akuma/index.d.ts +5 -2
  68. package/build/src/akuma/index.js +1 -0
  69. package/build/src/akuma/nuke.js +6 -28
  70. package/build/src/akuma/projection.d.ts +0 -11
  71. package/build/src/akuma/provider-recipe.d.ts +7 -6
  72. package/build/src/akuma/provider-recipe.js +1 -1
  73. package/build/src/akuma/provider.d.ts +6 -10
  74. package/build/src/akuma/provider.js +6 -7
  75. package/build/src/akuma/providers/acp/events.js +5 -18
  76. package/build/src/akuma/providers/acp/index.js +2 -3
  77. package/build/src/akuma/providers/claude/events.js +35 -60
  78. package/build/src/akuma/providers/claude/index.d.ts +2 -2
  79. package/build/src/akuma/providers/claude/index.js +2 -3
  80. package/build/src/akuma/providers/codex-app-server/index.js +2 -2
  81. package/build/src/akuma/providers/decode.d.ts +25 -0
  82. package/build/src/akuma/providers/decode.js +44 -0
  83. package/build/src/akuma/providers/execution-environment.d.ts +2 -1
  84. package/build/src/akuma/providers/execution-environment.js +3 -0
  85. package/build/src/akuma/providers/grok-build/index.js +6 -22
  86. package/build/src/akuma/providers/index.js +2 -0
  87. package/build/src/akuma/providers/lifecycle.d.ts +9 -0
  88. package/build/src/akuma/providers/lifecycle.js +10 -0
  89. package/build/src/akuma/providers/opencode-sdk/events.js +1 -14
  90. package/build/src/akuma/providers/opencode-sdk/index.js +10 -17
  91. package/build/src/akuma/providers/opencode-sdk/session.js +1 -3
  92. package/build/src/akuma/providers/paseo/events.d.ts +25 -0
  93. package/build/src/akuma/providers/paseo/events.js +157 -0
  94. package/build/src/akuma/providers/paseo/index.d.ts +9 -0
  95. package/build/src/akuma/providers/paseo/index.js +353 -0
  96. package/build/src/akuma/providers/pi/events.js +5 -15
  97. package/build/src/akuma/publication.d.ts +2 -0
  98. package/build/src/akuma/publication.js +5 -0
  99. package/build/src/akuma/request-lifecycle.d.ts +3 -0
  100. package/build/src/akuma/request-lifecycle.js +25 -4
  101. package/build/src/akuma/requests.d.ts +3 -1
  102. package/build/src/akuma/requests.js +32 -0
  103. package/build/src/akuma/selection-observation.d.ts +72 -2
  104. package/build/src/akuma/selection-observation.js +0 -6
  105. package/build/src/akuma/selection-owner-port.d.ts +1 -1
  106. package/build/src/akuma/selection-owner-port.js +16 -5
  107. package/build/src/akuma/selection-request.d.ts +2 -0
  108. package/build/src/akuma/selection-request.js +2 -1
  109. package/build/src/akuma/turn-drive.js +2 -5
  110. package/build/src/akuma-body.js +4 -2
  111. package/build/src/cli/akuma-caller.d.ts +3 -0
  112. package/build/src/cli/akuma-caller.js +21 -0
  113. package/build/src/cli/commands/akuma-grammar.js +7 -12
  114. package/build/src/cli/commands/akuma.js +18 -16
  115. package/build/src/cli/commands/contract-grammar.d.ts +2 -1
  116. package/build/src/cli/commands/contract-grammar.js +13 -15
  117. package/build/src/cli/commands/contract-help.d.ts +2 -1
  118. package/build/src/cli/commands/contract-help.js +31 -1
  119. package/build/src/cli/commands/contract.js +24 -53
  120. package/build/src/cli/commands/install.js +3 -3
  121. package/build/src/cli/commands/task.js +18 -35
  122. package/build/src/cli/parse.d.ts +2 -2
  123. package/build/src/cli/render/catalog.d.ts +2 -5
  124. package/build/src/cli/render/contract-history.js +3 -6
  125. package/build/src/cli/render/contract.js +15 -50
  126. package/build/src/cli/render/receipt.js +3 -10
  127. package/build/src/cli/render/task.d.ts +4 -6
  128. package/build/src/cli/render/task.js +9 -26
  129. package/build/src/cli/runtime.d.ts +1 -1
  130. package/build/src/cli/runtime.js +11 -17
  131. package/build/src/cli/selectors.d.ts +3 -6
  132. package/build/src/cli/selectors.js +22 -53
  133. package/build/src/dispatch/index.d.ts +3 -3
  134. package/build/src/dispatch/index.js +1 -2
  135. package/build/src/git/observe.d.ts +6 -2
  136. package/build/src/git/observe.js +6 -2
  137. package/build/src/index.d.ts +6 -6
  138. package/build/src/index.js +2 -2
  139. package/build/src/kanshi/index.d.ts +1 -1
  140. package/build/src/kanshi/read.js +21 -6
  141. package/build/src/library/address.js +2 -4
  142. package/build/src/library/akuma-creation.d.ts +5 -1
  143. package/build/src/library/akuma-creation.js +33 -51
  144. package/build/src/library/akumas.d.ts +5 -4
  145. package/build/src/library/akumas.js +13 -9
  146. package/build/src/library/bind.d.ts +14 -14
  147. package/build/src/library/bind.js +11 -7
  148. package/build/src/library/contract-address.d.ts +9 -0
  149. package/build/src/library/contract-address.js +71 -0
  150. package/build/src/library/contract-composition.d.ts +4 -7
  151. package/build/src/library/contract-composition.js +6 -18
  152. package/build/src/library/contract-creation.d.ts +3 -5
  153. package/build/src/library/contract-creation.js +19 -17
  154. package/build/src/library/contract-execution.js +18 -23
  155. package/build/src/library/contract-outcomes.d.ts +2 -14
  156. package/build/src/library/contract-outcomes.js +2 -13
  157. package/build/src/library/contract-types.d.ts +36 -2
  158. package/build/src/library/delivery.d.ts +0 -2
  159. package/build/src/library/delivery.js +2 -5
  160. package/build/src/library/keiyaku.d.ts +0 -5
  161. package/build/src/library/keiyaku.js +6 -12
  162. package/build/src/library/outcome.d.ts +500 -499
  163. package/build/src/library/outcome.js +10 -0
  164. package/build/src/library/reconcile.js +8 -16
  165. package/build/src/library/refusal.d.ts +2 -2
  166. package/build/src/library/repo.d.ts +3 -2
  167. package/build/src/library/repo.js +10 -5
  168. package/build/src/library/selection.d.ts +4 -4
  169. package/build/src/library/selection.js +12 -9
  170. package/build/src/plugin/akuma-signals.d.ts +12 -11
  171. package/build/src/plugin/akuma-signals.js +40 -20
  172. package/build/src/plugin/public.d.ts +32 -2
  173. package/build/src/plugin/runtime.d.ts +1 -0
  174. package/build/src/plugin/runtime.js +35 -24
  175. package/build/src/protocol/amend.js +3 -2
  176. package/build/src/protocol/attempt.js +3 -8
  177. package/build/src/protocol/bind.d.ts +2 -2
  178. package/build/src/protocol/bind.js +1 -1
  179. package/build/src/protocol/deliver.js +3 -3
  180. package/build/src/protocol/operations.d.ts +1 -3
  181. package/build/src/protocol/operations.js +0 -8
  182. package/build/src/protocol/outcome.d.ts +1 -2
  183. package/build/src/protocol/outcome.js +1 -13
  184. package/build/src/protocol/placement.js +3 -10
  185. package/build/src/protocol/read/status.js +31 -70
  186. package/build/src/protocol/reintegrate.js +3 -10
  187. package/build/src/protocol/review.js +3 -3
  188. package/build/src/protocol/run.d.ts +5 -1
  189. package/build/src/protocol/run.js +3 -3
  190. package/build/src/runtime/proc/windows-launch.exe +0 -0
  191. package/package.json +12 -8
  192. package/plugins/pi/keiyaku.ts +57 -0
  193. package/skills/keiyaku/SKILL.md +44 -0
  194. package/skills/keiyaku-akuma/SKILL.md +130 -0
  195. package/skills/keiyaku-akuma/references/automation.md +269 -0
  196. package/skills/keiyaku-babysit/SKILL.md +65 -0
  197. package/skills/keiyaku-bind/SKILL.md +216 -0
  198. package/skills/keiyaku-bind/agents/openai.yaml +4 -0
  199. package/skills/keiyaku-task/SKILL.md +104 -0
  200. package/skills/keiyaku-workflow/SKILL.md +129 -0
  201. package/build/integrations/marketplace/.claude-plugin/marketplace.json +0 -5
  202. package/build/integrations/marketplace/plugins/keiyaku/package.json +0 -17
  203. package/build/src/cli/commands/amend.d.ts +0 -12
  204. package/build/src/cli/commands/amend.js +0 -10
  205. package/build/src/cli/commands/bind.d.ts +0 -11
  206. package/build/src/cli/commands/bind.js +0 -23
  207. package/build/src/dispatch/association.d.ts +0 -1
  208. package/build/src/dispatch/association.js +0 -1
  209. /package/build/{integrations/marketplace/plugins/keiyaku → plugins/claude}/skills/keiyaku/SKILL.md +0 -0
  210. /package/build/{integrations/marketplace/plugins/keiyaku → plugins/claude}/skills/keiyaku-akuma/SKILL.md +0 -0
  211. /package/build/{integrations/marketplace/plugins/keiyaku → plugins/claude}/skills/keiyaku-akuma/references/automation.md +0 -0
  212. /package/build/{integrations/marketplace/plugins/keiyaku → plugins/claude}/skills/keiyaku-babysit/SKILL.md +0 -0
  213. /package/build/{integrations/marketplace/plugins/keiyaku → plugins/claude}/skills/keiyaku-bind/SKILL.md +0 -0
  214. /package/build/{integrations/marketplace/plugins/keiyaku → plugins/claude}/skills/keiyaku-bind/agents/openai.yaml +0 -0
  215. /package/build/{integrations/marketplace/plugins/keiyaku → plugins/claude}/skills/keiyaku-task/SKILL.md +0 -0
  216. /package/build/{integrations/marketplace/plugins/keiyaku → plugins/claude}/skills/keiyaku-workflow/SKILL.md +0 -0
  217. /package/build/{integrations/marketplace/plugins/keiyaku/opencode.js → plugins/opencode/index.js} +0 -0
@@ -3,6 +3,30 @@ import { type AkumaStatus } from "./akuma.js";
3
3
  declare const akumaObservationSchema: z.ZodObject<{
4
4
  status: z.ZodObject<{
5
5
  id: z.ZodPipe<z.ZodString, z.ZodTransform<import("./identity.js").AkuId, string>>;
6
+ birth: z.ZodObject<{
7
+ origin: z.ZodDiscriminatedUnion<[z.ZodObject<{
8
+ kind: z.ZodLiteral<"direct">;
9
+ }, z.core.$strip>, z.ZodObject<{
10
+ kind: z.ZodLiteral<"request">;
11
+ parent: z.ZodPipe<z.ZodString, z.ZodTransform<import("./identity.js").AkuId, string>>;
12
+ requestId: z.ZodString;
13
+ }, z.core.$strip>, z.ZodObject<{
14
+ kind: z.ZodLiteral<"fork">;
15
+ parent: z.ZodPipe<z.ZodString, z.ZodTransform<import("./identity.js").AkuId, string>>;
16
+ at: z.ZodString;
17
+ }, z.core.$strip>], "kind">;
18
+ caller: z.ZodUnion<readonly [z.ZodDiscriminatedUnion<[z.ZodObject<{
19
+ kind: z.ZodLiteral<"akuma">;
20
+ world: z.ZodCustom<import("../world.js").WorldRoot, import("../world.js").WorldRoot>;
21
+ akuId: z.ZodPipe<z.ZodString, z.ZodTransform<import("./identity.js").AkuId, string>>;
22
+ }, z.core.$strict>, z.ZodObject<{
23
+ kind: z.ZodLiteral<"external">;
24
+ integration: z.ZodString;
25
+ id: z.ZodString;
26
+ }, z.core.$strict>], "kind">, z.ZodObject<{
27
+ kind: z.ZodLiteral<"unknown">;
28
+ }, z.core.$strict>]>;
29
+ }, z.core.$strict>;
6
30
  life: z.ZodEnum<{
7
31
  killed: "killed";
8
32
  hung: "hung";
@@ -467,6 +491,30 @@ declare const akumaWaitResultSchema: z.ZodObject<{
467
491
  observations: z.ZodReadonly<z.ZodArray<z.ZodObject<{
468
492
  status: z.ZodObject<{
469
493
  id: z.ZodPipe<z.ZodString, z.ZodTransform<import("./identity.js").AkuId, string>>;
494
+ birth: z.ZodObject<{
495
+ origin: z.ZodDiscriminatedUnion<[z.ZodObject<{
496
+ kind: z.ZodLiteral<"direct">;
497
+ }, z.core.$strip>, z.ZodObject<{
498
+ kind: z.ZodLiteral<"request">;
499
+ parent: z.ZodPipe<z.ZodString, z.ZodTransform<import("./identity.js").AkuId, string>>;
500
+ requestId: z.ZodString;
501
+ }, z.core.$strip>, z.ZodObject<{
502
+ kind: z.ZodLiteral<"fork">;
503
+ parent: z.ZodPipe<z.ZodString, z.ZodTransform<import("./identity.js").AkuId, string>>;
504
+ at: z.ZodString;
505
+ }, z.core.$strip>], "kind">;
506
+ caller: z.ZodUnion<readonly [z.ZodDiscriminatedUnion<[z.ZodObject<{
507
+ kind: z.ZodLiteral<"akuma">;
508
+ world: z.ZodCustom<import("../world.js").WorldRoot, import("../world.js").WorldRoot>;
509
+ akuId: z.ZodPipe<z.ZodString, z.ZodTransform<import("./identity.js").AkuId, string>>;
510
+ }, z.core.$strict>, z.ZodObject<{
511
+ kind: z.ZodLiteral<"external">;
512
+ integration: z.ZodString;
513
+ id: z.ZodString;
514
+ }, z.core.$strict>], "kind">, z.ZodObject<{
515
+ kind: z.ZodLiteral<"unknown">;
516
+ }, z.core.$strict>]>;
517
+ }, z.core.$strict>;
470
518
  life: z.ZodEnum<{
471
519
  killed: "killed";
472
520
  hung: "hung";
@@ -1164,8 +1212,6 @@ export type AkumaAskResult<T = unknown> = Omit<z.infer<typeof akumaAskResultSche
1164
1212
  }>;
1165
1213
  /** Compose one native status into the canonical observation its crossing transports. */
1166
1214
  export declare function akumaObservationOf(status: AkumaStatus): AkumaObservation;
1167
- export declare function isTellResult(value: unknown): value is AkumaTellResult;
1168
- export declare function isAskResult(value: unknown): value is AkumaAskResult;
1169
1215
  export declare const selectionResultSchemas: {
1170
1216
  wait: z.ZodObject<{
1171
1217
  mode: z.ZodEnum<{
@@ -1179,6 +1225,30 @@ export declare const selectionResultSchemas: {
1179
1225
  observations: z.ZodReadonly<z.ZodArray<z.ZodObject<{
1180
1226
  status: z.ZodObject<{
1181
1227
  id: z.ZodPipe<z.ZodString, z.ZodTransform<import("./identity.js").AkuId, string>>;
1228
+ birth: z.ZodObject<{
1229
+ origin: z.ZodDiscriminatedUnion<[z.ZodObject<{
1230
+ kind: z.ZodLiteral<"direct">;
1231
+ }, z.core.$strip>, z.ZodObject<{
1232
+ kind: z.ZodLiteral<"request">;
1233
+ parent: z.ZodPipe<z.ZodString, z.ZodTransform<import("./identity.js").AkuId, string>>;
1234
+ requestId: z.ZodString;
1235
+ }, z.core.$strip>, z.ZodObject<{
1236
+ kind: z.ZodLiteral<"fork">;
1237
+ parent: z.ZodPipe<z.ZodString, z.ZodTransform<import("./identity.js").AkuId, string>>;
1238
+ at: z.ZodString;
1239
+ }, z.core.$strip>], "kind">;
1240
+ caller: z.ZodUnion<readonly [z.ZodDiscriminatedUnion<[z.ZodObject<{
1241
+ kind: z.ZodLiteral<"akuma">;
1242
+ world: z.ZodCustom<import("../world.js").WorldRoot, import("../world.js").WorldRoot>;
1243
+ akuId: z.ZodPipe<z.ZodString, z.ZodTransform<import("./identity.js").AkuId, string>>;
1244
+ }, z.core.$strict>, z.ZodObject<{
1245
+ kind: z.ZodLiteral<"external">;
1246
+ integration: z.ZodString;
1247
+ id: z.ZodString;
1248
+ }, z.core.$strict>], "kind">, z.ZodObject<{
1249
+ kind: z.ZodLiteral<"unknown">;
1250
+ }, z.core.$strict>]>;
1251
+ }, z.core.$strict>;
1182
1252
  life: z.ZodEnum<{
1183
1253
  killed: "killed";
1184
1254
  hung: "hung";
@@ -50,12 +50,6 @@ const akumaAskResultSchema = z
50
50
  export function akumaObservationOf(status) {
51
51
  return { status, contract: NO_DISPATCH_ASSOCIATION, createdTasks: EMPTY_CREATED_TASK_OBSERVATION };
52
52
  }
53
- export function isTellResult(value) {
54
- return akumaTellResultSchema.safeParse(value).success;
55
- }
56
- export function isAskResult(value) {
57
- return akumaAskResultSchema.safeParse(value).success;
58
- }
59
53
  export const selectionResultSchemas = {
60
54
  wait: akumaWaitResultSchema,
61
55
  tell: akumaTellResultSchema,
@@ -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 }),
@@ -115,7 +115,7 @@ async function startTurnDrive(input) {
115
115
  cwd,
116
116
  options,
117
117
  signal: driveController.signal,
118
- requests: { dir: requests.directory },
118
+ requests: { dir: requests.directory, entry: requests.entry },
119
119
  ...(schemaJson === undefined ? {} : { schemaJson }),
120
120
  };
121
121
  const attempt = session === undefined
@@ -232,9 +232,6 @@ function pumpReceipts(writers) {
232
232
  function observeFailure(settlement) {
233
233
  return settlement.then(() => new Promise(() => { }), (error) => Promise.reject(error));
234
234
  }
235
- function observeReceiptFailure(receiptPump) {
236
- return observeFailure(receiptPump);
237
- }
238
235
  function observeCompletionFailure(drive) {
239
236
  return drive.completion.then(() => new Promise(() => { }), (error) => ({ kind: "completion-failed", error }));
240
237
  }
@@ -354,7 +351,7 @@ async function consumeTurnDrive(input, active) {
354
351
  let writesOpen = true;
355
352
  const mayWrite = () => writesOpen && !input.supervisor.signal.aborted;
356
353
  const writers = { input, turnSequence, drive, writeWitness, mayWrite };
357
- const receiptFailure = observeReceiptFailure(pumpReceipts(writers));
354
+ const receiptFailure = observeFailure(pumpReceipts(writers));
358
355
  const completionFailure = observeCompletionFailure(drive);
359
356
  const iterator = drive.events[Symbol.asyncIterator]();
360
357
  let liveTells = true;
@@ -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";
@@ -108,7 +108,9 @@ export async function externalRequestCommandsFor(launch, processConfiguration) {
108
108
  const world = await World.prove(worldRootForAkumaPaths(launch.paths));
109
109
  return {
110
110
  world,
111
- 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())),
112
114
  };
113
115
  }
114
116
  function bodyProcessConfiguration() {
@@ -0,0 +1,3 @@
1
+ import { type AkumaCaller } from "../akuma/caller.js";
2
+ /** Environment attribution belongs to the process edge, never SDK admission. */
3
+ export declare function akumaCallerFromEnvironment(environment: NodeJS.ProcessEnv): Promise<AkumaCaller | undefined>;
@@ -0,0 +1,21 @@
1
+ import { decodeAkumaCaller } from "../akuma/caller.js";
2
+ import { World } from "../world.js";
3
+ /** Environment attribution belongs to the process edge, never SDK admission. */
4
+ export async function akumaCallerFromEnvironment(environment) {
5
+ const id = environment.KEIYAKU_ACTOR_ID;
6
+ const world = environment.KEIYAKU_ACTOR_WORLD;
7
+ if ((id === undefined) !== (world === undefined)) {
8
+ throw new TypeError("Akuma caller requires both KEIYAKU_ACTOR_ID and KEIYAKU_ACTOR_WORLD");
9
+ }
10
+ if (id !== undefined && world !== undefined) {
11
+ const resolved = await World.resolve({ cwd: world, repositoryRoot: world });
12
+ return decodeAkumaCaller({ kind: "akuma", akuId: id, world: resolved.candidate });
13
+ }
14
+ const external = environment.KEIYAKU_EXTERNAL_CALLER;
15
+ if (external === undefined)
16
+ return undefined;
17
+ const colon = external.indexOf(":");
18
+ if (colon < 0)
19
+ throw new TypeError("KEIYAKU_EXTERNAL_CALLER must be <integration>:<id>");
20
+ return decodeAkumaCaller({ kind: "external", integration: external.slice(0, colon), id: external.slice(colon + 1) });
21
+ }
@@ -175,11 +175,6 @@ function positiveIndex(raw, option, fail) {
175
175
  fail(`${option} exceeds the safe integer range`);
176
176
  return value;
177
177
  }
178
- function validateDirect(value, _fail) {
179
- // Address validation belongs to the operation boundary so callers receive
180
- // the compact Akuma refusal instead of a generic usage page.
181
- return value;
182
- }
183
178
  function validateSet(value, fail) {
184
179
  if (value.startsWith("kei/"))
185
180
  return value;
@@ -192,7 +187,7 @@ function validateSet(value, fail) {
192
187
  }
193
188
  return value;
194
189
  }
195
- return validateDirect(value, fail);
190
+ return value;
196
191
  }
197
192
  function parseWait(rawSelectors, flags, output, fail) {
198
193
  if (flags.any === true && flags.all === true)
@@ -236,7 +231,7 @@ function parseAkumaHistory(selector, flags, output, fail) {
236
231
  fail("history --id requires turn/<positive safe integer>");
237
232
  return {
238
233
  command: "history",
239
- akuma: validateDirect(selector, fail),
234
+ akuma: selector,
240
235
  ...(id === undefined ? {} : { id }),
241
236
  last: flags.last === true,
242
237
  ...(flags.before === undefined ? {} : { before: positiveIndex(flags.before, "--before", fail) }),
@@ -256,7 +251,7 @@ function parseAddressed(action, rawSelectors, flags, output, fail) {
256
251
  fail("history accepts one complete aku/..., @alias, or kei/... selector");
257
252
  return parseHistory(selector, flags, output, fail);
258
253
  }
259
- const akuma = validateDirect(rawSelectors[0], fail);
254
+ const akuma = rawSelectors[0];
260
255
  const at = stringFlag(flags.at, "fork requires --at <historyId>", fail);
261
256
  return { command: action, akuma, at, output };
262
257
  }
@@ -279,10 +274,10 @@ function parsePrompted(action, positionals, stdin, fail) {
279
274
  : { prompt: { kind: "argument", value: argument } }),
280
275
  };
281
276
  }
282
- function parseTell(flags, subject, prompt, output, fail) {
277
+ function parseTell(flags, subject, prompt, output) {
283
278
  return {
284
279
  command: "tell",
285
- akuma: validateDirect(subject, fail),
280
+ akuma: subject,
286
281
  interrupt: flags.interrupt === true,
287
282
  prompt,
288
283
  output,
@@ -292,7 +287,7 @@ function parseAsk(flags, subject, prompt, output, fail) {
292
287
  const schema = flags.schema === undefined ? undefined : stringFlag(flags.schema, "ask --schema requires a file", fail);
293
288
  return {
294
289
  command: "ask",
295
- akuma: validateDirect(subject, fail),
290
+ akuma: subject,
296
291
  interrupt: flags.interrupt === true,
297
292
  ...(schema === undefined ? {} : { schema }),
298
293
  ...(flags.wait === undefined ? {} : { timeoutMs: parseDuration(flags.wait, "--wait", fail) }),
@@ -361,7 +356,7 @@ export function parseAkumaCommand(argv) {
361
356
  return action === "call"
362
357
  ? parseCall(flags, parsed.subject, parsed.prompt, output, fail)
363
358
  : action === "tell"
364
- ? parseTell(flags, parsed.subject, parsed.prompt, output, fail)
359
+ ? parseTell(flags, parsed.subject, parsed.prompt, output)
365
360
  : parseAsk(flags, parsed.subject, parsed.prompt, output, fail);
366
361
  }
367
362
  if (spec.arity === "one-or-more" ? positionals.length === 0 : positionals.length !== spec.arity) {
@@ -1,8 +1,9 @@
1
+ import { akumaCallerFromEnvironment } from "../akuma-caller.js";
1
2
  import { CliUsageError, isBlankInput } from "../usage.js";
2
3
  import { readFile } from "node:fs/promises";
3
4
  import { resolve } from "node:path";
4
5
  import { squareAssignedParticipantName } from "@astrosheep/square";
5
- import { emitInitiatingPluginSignal } from "../../plugin/akuma-signals.js";
6
+ import { emitPluginSignal } from "../../plugin/akuma-signals.js";
6
7
  import { canonicalBirthCwd } from "../../akuma/call-input.js";
7
8
  import { Schema } from "../../akuma/index.js";
8
9
  import { executionChannel } from "../../akuma/requests.js";
@@ -27,7 +28,7 @@ async function settingsAt(root, home) {
27
28
  });
28
29
  }
29
30
  function akumas(input) {
30
- return akumasWithExecution(input.path, input.execution);
31
+ return akumasWithExecution(input.path, input.execution, { reportDiagnostic: writeStderr });
31
32
  }
32
33
  async function schemaFromFile(path) {
33
34
  try {
@@ -68,22 +69,14 @@ async function inputInitiator(input) {
68
69
  catch { }
69
70
  if (initiator === undefined)
70
71
  return {};
71
- // Plugins coordinate within an established World; a `call` may run where the
72
- // marker does not exist yet, and activating there would only fail noisily.
73
- // The initiator still travels with the request either way.
72
+ // Identity preparation needs established plugin custody, not just a candidate.
74
73
  if (!(await World.established(input.path)))
75
74
  return { initiator };
76
- try {
77
- await emitInitiatingPluginSignal({
78
- world: input.path,
79
- ...(input.settings === undefined ? {} : { settings: input.settings }),
80
- initiator,
81
- reportDiagnostic: (message) => writeStderr(message),
82
- });
83
- }
84
- catch (error) {
85
- writeStderr(`! plugin initiation: ${error instanceof Error ? error.message : String(error)}`);
86
- }
75
+ await emitPluginSignal({
76
+ world: input.path,
77
+ ...(input.settings === undefined ? {} : { settings: input.settings }),
78
+ reportDiagnostic: (message) => writeStderr(message),
79
+ }, { kind: "akuma.initiating", initiator });
87
80
  return { initiator };
88
81
  }
89
82
  function emitAnswer(body, exact) {
@@ -96,9 +89,15 @@ function emitAnswer(body, exact) {
96
89
  async function runCall(command, input) {
97
90
  const body = command.prompt === undefined ? undefined : await promptBody("call", { prompt: command.prompt }, input);
98
91
  const schema = command.schema === undefined ? undefined : await schemaFromFile(command.schema);
92
+ const declaredCaller = executionChannel(input.execution).kind === "body-request"
93
+ ? undefined
94
+ : await akumaCallerFromEnvironment(input.environment);
95
+ // Establish the selected World before preparing the submitting Square route.
96
+ await World.at(input.path);
99
97
  const caller = akumas(input);
100
98
  const request = {
101
99
  ...(await inputInitiator(input)),
100
+ ...(declaredCaller === undefined ? {} : { caller: declaredCaller }),
102
101
  archetype: command.archetype,
103
102
  ...(body === undefined ? {} : { body }),
104
103
  ...(input.home === undefined ? {} : { home: input.home }),
@@ -293,7 +292,10 @@ async function runHistory(command, input) {
293
292
  return historyExitCode(result, command.id);
294
293
  }
295
294
  async function runFork(command, input) {
295
+ const caller = await akumaCallerFromEnvironment(input.environment);
296
296
  const receipt = await akumas(input).fork({
297
+ ...(await inputInitiator(input)),
298
+ ...(caller === undefined ? {} : { caller }),
297
299
  akuma: command.akuma,
298
300
  at: command.at,
299
301
  ...(input.repo === undefined ? {} : { repo: input.repo }),
@@ -24,7 +24,8 @@ export type ParsedBind = Output & Actor & Readonly<{
24
24
  command: "bind";
25
25
  forkOf?: string;
26
26
  task?: string;
27
- target?: string;
27
+ /** A literal target branch, or `null` for a deliberately targetless bind. */
28
+ target?: string | null;
28
29
  after?: readonly string[];
29
30
  gates?: readonly string[];
30
31
  }>;
@@ -1,4 +1,4 @@
1
- import { archetypeName } from "../../akuma/identity.js";
1
+ import { validateAkumaName } from "../../identity/normalize.js";
2
2
  import { parseTaskNamespaceSelector } from "../../task/catalog.js";
3
3
  import { CliUsageError, commandGuide } from "../usage.js";
4
4
  import { CONTRACT_COMMAND_SPECS } from "./contract-help.js";
@@ -9,11 +9,11 @@ function parseAkumaCatalogPath(value) {
9
9
  return { kind: "akuma" };
10
10
  const scopedGlob = /^aku\/([^/]+)\/\*$/u.exec(value);
11
11
  if (scopedGlob !== null)
12
- return { kind: "akuma", archetype: archetypeName(scopedGlob[1]) };
12
+ return { kind: "akuma", archetype: validateAkumaName(scopedGlob[1]) };
13
13
  const match = /^aku\/([^/]+)\/?$/u.exec(value);
14
14
  if (match === null)
15
15
  return null;
16
- return { kind: "akuma", archetype: archetypeName(match[1]) };
16
+ return { kind: "akuma", archetype: validateAkumaName(match[1]) };
17
17
  }
18
18
  function optionalFlag(flags, name) {
19
19
  const value = flags[name];
@@ -41,6 +41,13 @@ function parseGateNames(parts, command) {
41
41
  }
42
42
  return names;
43
43
  }
44
+ function parseBindTarget(parts) {
45
+ const target = optionalFlag(parts.flags, "target");
46
+ const noTarget = parts.flags["no-target"] === true;
47
+ if (target !== undefined && noTarget)
48
+ refuse("bind", "--target and --no-target are mutually exclusive");
49
+ return noTarget ? null : target;
50
+ }
44
51
  function parseBind(parts) {
45
52
  const forkOf = optionalFlag(parts.flags, "fork-of");
46
53
  if (forkOf !== undefined) {
@@ -50,7 +57,7 @@ function parseBind(parts) {
50
57
  if (parts.flags[option] !== undefined)
51
58
  refuse("bind", `--${option} is not valid with --fork-of`);
52
59
  }
53
- const target = optionalFlag(parts.flags, "target");
60
+ const target = parseBindTarget(parts);
54
61
  return {
55
62
  command: "bind",
56
63
  forkOf,
@@ -62,7 +69,7 @@ function parseBind(parts) {
62
69
  if (!parts.stdin)
63
70
  refuse("bind", "bind requires stdin");
64
71
  const task = optionalFlag(parts.flags, "task");
65
- const target = optionalFlag(parts.flags, "target");
72
+ const target = parseBindTarget(parts);
66
73
  const after = parts.flags.after === undefined ? [] : Array.isArray(parts.flags.after) ? parts.flags.after : [parts.flags.after];
67
74
  const gates = parseGateNames(parts, "bind");
68
75
  return {
@@ -196,15 +203,6 @@ function parseRegion(parts) {
196
203
  output: parts.output,
197
204
  };
198
205
  }
199
- function akumaCatalogQuery(query, parts) {
200
- const limit = optionalFlag(parts.flags, "limit");
201
- if (limit !== undefined && (!/^[1-9][0-9]*$/u.test(limit) || !Number.isSafeInteger(Number(limit))))
202
- refuse("ls", "--limit requires a positive safe integer");
203
- return {
204
- ...query,
205
- ...(limit === undefined ? {} : { limit: Number(limit) }),
206
- };
207
- }
208
206
  function listLimit(parts, command = "ls") {
209
207
  const limit = optionalFlag(parts.flags, "limit");
210
208
  if (limit !== undefined && (!/^[1-9][0-9]*$/u.test(limit) || !Number.isSafeInteger(Number(limit))))
@@ -249,7 +247,7 @@ function parseLs(parts) {
249
247
  const query = parseAkumaCatalogPath(path);
250
248
  if (query === null)
251
249
  refuse("ls", "ls requires a supported identity directory selector");
252
- return { command: "ls", query: akumaCatalogQuery(query, parts), output: parts.output };
250
+ return { command: "ls", query: { ...query, ...(limit === undefined ? {} : { limit }) }, output: parts.output };
253
251
  }
254
252
  catch (error) {
255
253
  if (error instanceof CliUsageError)
@@ -15,12 +15,13 @@ export declare const CONTRACT_COMMAND_SPECS: {
15
15
  readonly actor: "value";
16
16
  readonly task: "value";
17
17
  readonly target: "value";
18
+ readonly "no-target": "boolean";
18
19
  readonly after: "repeat";
19
20
  readonly gates: "raw-value";
20
21
  readonly "fork-of": "value";
21
22
  readonly json: "boolean";
22
23
  };
23
- readonly usage: "bind [--task <task/...>] [--target <ref>] [--after <kei/...> ...] [--gates <name,...>] [--actor <actor>] - | bind --fork-of <kei/...> [--target <ref>] [--actor <actor>]";
24
+ readonly usage: "bind [--task <task/...>] [--target <ref> | --no-target] [--after <kei/...> ...] [--gates <name,...>] [--actor <actor>] - | bind --fork-of <kei/...> [--target <ref> | --no-target] [--actor <actor>]";
24
25
  readonly purpose: "Create a Contract from stdin Markdown or copy an existing Contract as a starting point.";
25
26
  readonly details: string;
26
27
  };
@@ -7,14 +7,21 @@ export const CONTRACT_COMMAND_SPECS = {
7
7
  actor: "value",
8
8
  task: "value",
9
9
  target: "value",
10
+ "no-target": "boolean",
10
11
  after: "repeat",
11
12
  gates: "raw-value",
12
13
  "fork-of": "value",
13
14
  json: "boolean",
14
15
  },
15
- usage: "bind [--task <task/...>] [--target <ref>] [--after <kei/...> ...] [--gates <name,...>] [--actor <actor>] - | bind --fork-of <kei/...> [--target <ref>] [--actor <actor>]",
16
+ usage: "bind [--task <task/...>] [--target <ref> | --no-target] [--after <kei/...> ...] [--gates <name,...>] [--actor <actor>] - | bind --fork-of <kei/...> [--target <ref> | --no-target] [--actor <actor>]",
16
17
  purpose: "Create a Contract from stdin Markdown or copy an existing Contract as a starting point.",
17
18
  details: [
19
+ "--target names one existing local branch literally; it is never created and never",
20
+ "guessed. Omitting it binds to the current branch of the invocation worktree",
21
+ "coordinate, or binds without a target on a detached committed HEAD. --no-target",
22
+ "binds without a target on purpose, and is refused together with --target.",
23
+ "A fork copies its source target when neither flag is given.",
24
+ "",
18
25
  "Gates are acceptance obligations checked at placement: reviewed awaits a",
19
26
  "satisfied review, verified awaits a passing Verification run.",
20
27
  "",
@@ -245,6 +252,29 @@ export function renderContractHelp(command) {
245
252
  "effort, network, allowed, systemPromptMode, and description; the body is",
246
253
  "an optional system prompt.",
247
254
  "",
255
+ "Local Paseo provider in settings.json:",
256
+ ' { "providers": { "paseo": {',
257
+ ' "kind": "paseo",',
258
+ ' "config": { "url": "ws://127.0.0.1:6767/ws", "provider": "claude" }',
259
+ " } } }",
260
+ "The native provider id is bare (claude, codex, pi), not provider/model.",
261
+ "Example .keiyaku/akuma/paseo-worker.md frontmatter:",
262
+ " ---",
263
+ " provider: paseo",
264
+ " model: <native-model-id>",
265
+ " effort: high",
266
+ " ---",
267
+ "Model and effort must be offered by the selected native provider;",
268
+ "effort names its native thinking option id.",
269
+ 'PASEO_PASSWORD=<password> keiyaku call paseo-worker "<prompt>"',
270
+ "Paseo must already be running locally. Resume keeps its live native",
271
+ "runtime; after Paseo native reload/restart create a fresh Akuma.",
272
+ "Observed busy agents refuse; native steer still has a check/send race.",
273
+ "Explicit control cancels native current execution session-wide and may",
274
+ "affect concurrent human work. Normal completion only retires the client",
275
+ "and its sockets; it never cancels later work or closes the native runtime.",
276
+ "Socket closure does not prove native cancellation succeeded.",
277
+ "",
248
278
  usageLine(spec.usage),
249
279
  ].join("\n");
250
280
  }