@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
@@ -1,7 +1,6 @@
1
1
  import { AkumaNotBornError, AkumaObservationError } from "../akuma/akuma-errors.js";
2
- import { AkumaArchetypeError } from "../akuma/archetype.js";
3
- import { AKUMA_REQUESTS_ENV } from "../akuma/provider.js";
4
- import { bodyRequestExecution, localExecutionContext } from "../akuma/requests.js";
2
+ import { executionForEnvironment } from "../akuma/requests.js";
3
+ import { AkumaArchetypeError } from "../index.js";
5
4
  import { AkumaAddressError, AkumaWorldScopeError } from "../library/address.js";
6
5
  import { encodeFailureWire, KeiyakuError } from "../library/outcome.js";
7
6
  import { isParsedAkumaCommand, runAkumaCommand } from "./commands/akuma.js";
@@ -28,11 +27,6 @@ function memoized(reader) {
28
27
  let value;
29
28
  return () => (value ??= reader());
30
29
  }
31
- function executionForEnvironment(environment) {
32
- return environment[AKUMA_REQUESTS_ENV] === undefined
33
- ? localExecutionContext()
34
- : bodyRequestExecution({ directory: environment[AKUMA_REQUESTS_ENV] });
35
- }
36
30
  function homeFromEnvironment(environment) {
37
31
  const mapped = environment.KEIYAKU_HOME?.trim();
38
32
  return mapped === undefined || mapped.length === 0 ? undefined : mapped;
@@ -175,16 +169,16 @@ export async function runCliCommand(invocation, input = {}) {
175
169
  const home = homeFromEnvironment(environment);
176
170
  const cancellation = cliCancellation(input.signal);
177
171
  let progress;
178
- const runtime = {
179
- environment,
180
- execution: executionForEnvironment(environment),
181
- ...(home === undefined ? {} : { home }),
182
- readStdin: memoized(input.readStdin ?? processStdin),
183
- signal: cancellation.signal,
184
- progress: () => (progress ??= writeExecutionProgress()),
185
- ...(input.actor === undefined ? {} : { actor: input.actor }),
186
- };
187
172
  try {
173
+ const runtime = {
174
+ environment,
175
+ execution: await executionForEnvironment(environment, cancellation.signal),
176
+ ...(home === undefined ? {} : { home }),
177
+ readStdin: memoized(input.readStdin ?? processStdin),
178
+ signal: cancellation.signal,
179
+ progress: () => (progress ??= writeExecutionProgress()),
180
+ ...(input.actor === undefined ? {} : { actor: input.actor }),
181
+ };
188
182
  if (command.command === "install")
189
183
  return await runInstall(command, environment);
190
184
  await admitBindInput(command, invocation, runtime, input.cwd ?? process.cwd());
@@ -1,14 +1,11 @@
1
1
  import { type ExecutionContext } from "../akuma/requests.js";
2
- import type { ContractBoard, ContractId, Keiyaku, Repo } from "../index.js";
3
- import type { KanshiReport } from "../kanshi/index.js";
2
+ import { Keiyaku, type ContractId, type Repo } from "../index.js";
4
3
  type SelectedContract = Readonly<{
5
4
  id: ContractId;
6
5
  contract: Keiyaku;
7
6
  }>;
8
7
  export declare function contractFromInput(repo: Repo, value: string, execution?: ExecutionContext): SelectedContract;
9
- export declare function resolveContextualContract(board: ContractBoard, selector: string | undefined, scope: string): ContractId;
10
- /** Resolve one explicit, short, or worktree-contextual selector to its Contract id. */
11
- export declare function resolveContractId(repo: Repo, selector: string | undefined, scope: string): Promise<ContractId>;
8
+ /** Adapt public Contract resolution evidence to the existing CLI usage diagnostics. */
9
+ export declare function resolveContractId(repo: Repo, selector: string | undefined, cwd: string): Promise<ContractId>;
12
10
  export declare function canonicalContractSelector(selector: string): ContractId;
13
- export declare function resolveKanshiContract(report: KanshiReport, selector: string): string;
14
11
  export {};
@@ -1,76 +1,45 @@
1
- import { resolve } from "node:path";
2
1
  import { localExecutionContext } from "../akuma/requests.js";
3
2
  import { identitySegments } from "../identity/coordinates.js";
3
+ import { Keiyaku } from "../index.js";
4
4
  import { composeContractLibrary } from "../library/contract-composition.js";
5
5
  import { createKeiyakuHandle } from "../library/keiyaku.js";
6
6
  import { CliUsageError } from "./parse.js";
7
- function selectorError(message) {
8
- throw new CliUsageError(message);
9
- }
10
- function activeManagedCandidates(rows) {
11
- return rows.flatMap((contract) => {
12
- if (contract.disposition !== "active" || contract.workspace !== "worktree" || contract.worktreePath === null)
13
- return [];
14
- return [{ id: contract.id, worktreePath: contract.worktreePath }];
15
- });
16
- }
17
7
  export function contractFromInput(repo, value, execution = localExecutionContext()) {
18
8
  try {
19
9
  const id = value;
20
10
  return { id, contract: composeContractLibrary(execution, createKeiyakuHandle).select({ repo, id }) };
21
11
  }
22
12
  catch (error) {
23
- selectorError(error instanceof Error ? error.message : String(error));
13
+ throw new CliUsageError(error instanceof Error ? error.message : String(error));
24
14
  }
25
15
  }
26
- function resolveShortContract(rows, selector) {
27
- if (selector.startsWith("@kei/"))
28
- selectorError(`redundant short contract selector: ${selector}`);
29
- const short = selector.slice(1);
30
- const candidates = activeManagedCandidates(rows).filter((candidate) => candidate.id.slice("kei/".length) === short);
31
- if (candidates.length === 0)
32
- selectorError(`unknown contract selector: ${selector}`);
33
- if (candidates.length !== 1)
34
- selectorError(`ambiguous contract selector: ${selector}`);
35
- return candidates[0].id;
36
- }
37
- function resolveOmittedContract(board, scope) {
38
- const candidates = activeManagedCandidates(board.rows).filter((candidate) => resolve(scope) === resolve(candidate.worktreePath));
39
- if (candidates.length === 0) {
40
- selectorError("an explicit full or @ contract selector is required outside a managed worktree");
16
+ /** Adapt public Contract resolution evidence to the existing CLI usage diagnostics. */
17
+ export async function resolveContractId(repo, selector, cwd) {
18
+ const result = await Keiyaku.with().resolve({ repo, ...(selector === undefined ? {} : { selector }), cwd });
19
+ if (result.kind === "resolved")
20
+ return result.id;
21
+ const refusal = result.refusal;
22
+ switch (refusal.kind) {
23
+ case "invalid-selector":
24
+ throw new CliUsageError(refusal.diagnostic);
25
+ case "redundant-short-selector":
26
+ throw new CliUsageError(`redundant short contract selector: ${refusal.selector}`);
27
+ case "unknown-short-selector":
28
+ throw new CliUsageError(`unknown contract selector: ${refusal.selector}`);
29
+ case "ambiguous-selector":
30
+ throw new CliUsageError("selector" in refusal
31
+ ? `ambiguous contract selector: ${refusal.selector}`
32
+ : "ambiguous managed worktree contract selector");
33
+ case "no-contextual-match":
34
+ throw new CliUsageError("an explicit full or @ contract selector is required outside a managed worktree");
41
35
  }
42
- if (candidates.length !== 1)
43
- selectorError("ambiguous managed worktree contract selector");
44
- return candidates[0].id;
45
- }
46
- export function resolveContextualContract(board, selector, scope) {
47
- if (selector === undefined)
48
- return resolveOmittedContract(board, scope);
49
- if (selector.startsWith("@"))
50
- return resolveShortContract(board.rows, selector);
51
- return selectorError(`contract selector must be kei/<contract-segment> or @<contract-segment>: ${selector}`);
52
- }
53
- /** Resolve one explicit, short, or worktree-contextual selector to its Contract id. */
54
- export async function resolveContractId(repo, selector, scope) {
55
- if (selector !== undefined && !selector.startsWith("@"))
56
- return contractFromInput(repo, selector).id;
57
- const { listKeiyaku } = await import("../library/contract-composition.js");
58
- return resolveContextualContract(await listKeiyaku({ repo }), selector, scope);
59
36
  }
60
37
  export function canonicalContractSelector(selector) {
61
38
  try {
62
39
  identitySegments({ family: "kei", value: selector });
63
40
  }
64
41
  catch {
65
- return selectorError(`contract selector must use kei/: ${selector}`);
42
+ throw new CliUsageError(`contract selector must use kei/: ${selector}`);
66
43
  }
67
44
  return selector;
68
45
  }
69
- export function resolveKanshiContract(report, selector) {
70
- if (report.contracts.kind !== "present") {
71
- return selectorError(`cannot select a contract while the Contract world is ${report.contracts.kind}`);
72
- }
73
- if (selector.startsWith("@"))
74
- return resolveShortContract(report.contracts.value.rows, selector);
75
- return canonicalContractSelector(selector);
76
- }
@@ -3,7 +3,7 @@ import { type AkuId } from "../akuma/identity.js";
3
3
  import { type PrivateStateSeatCloseLag } from "../git/private-state-seat.js";
4
4
  import type { GitRepository } from "../git/process.js";
5
5
  import { type GitReadObservation } from "../git/read-observation.js";
6
- import { type DispatchAssociation } from "./association.js";
6
+ import { type DispatchAssociation } from "../akuma/dispatch-association.js";
7
7
  export type Dispatch = Readonly<{
8
8
  akuId: AkuId;
9
9
  contractId: ContractId;
@@ -16,7 +16,7 @@ export type DispatchFailure = Readonly<{
16
16
  kind: "publication-failed";
17
17
  diagnostic: string;
18
18
  }>;
19
- export type DispatchPublication = Readonly<{
19
+ type DispatchPublication = Readonly<{
20
20
  kind: "dispatched";
21
21
  dispatch: Dispatch;
22
22
  seatClose?: readonly PrivateStateSeatCloseLag[];
@@ -32,6 +32,6 @@ export declare function publishDispatch(input: Readonly<{
32
32
  akuId: AkuId;
33
33
  contractId: ContractId;
34
34
  }>): Promise<DispatchPublication>;
35
- export { dispatchAssociationSchema, NO_DISPATCH_ASSOCIATION, parseDispatchAssociation, type DispatchAssociation, } from "./association.js";
36
35
  /** Read selected associations in one targeted observation, isolating per-identity decoding failures. */
37
36
  export declare function observeDispatchAssociations(repository: GitRepository | undefined, akuIds: readonly AkuId[]): Promise<ReadonlyMap<AkuId, DispatchAssociation>>;
37
+ export {};
@@ -5,7 +5,7 @@ import { parseAkuId } from "../akuma/identity.js";
5
5
  import { appendPrivateStateSeatClose, confirmPrivateStatePublication, mergePrivateStateSeatClose, withPrivateStatePublicationSeat, } from "../git/private-state-seat.js";
6
6
  import { GIT_FORMAT_BYTES, GIT_FORMAT_PATH, GIT_REF, readBlob, readGitPaths, updateGitTree, updateRefsAtomically, writeBlob, writeStateCommit, } from "../git/repository.js";
7
7
  import { withGitDecodeChannel, withGitReadObservation, withGitTargetedReadObservation, } from "../git/read-observation.js";
8
- import { NO_DISPATCH_ASSOCIATION } from "./association.js";
8
+ import { NO_DISPATCH_ASSOCIATION } from "../akuma/dispatch-association.js";
9
9
  const DISPATCH_ROOT = "dispatch";
10
10
  const DISPATCH_PREFIX = `${DISPATCH_ROOT}/`;
11
11
  const DISPATCH_SUFFIX = ".json";
@@ -186,7 +186,6 @@ export async function publishDispatch(input) {
186
186
  };
187
187
  }));
188
188
  }
189
- export { dispatchAssociationSchema, NO_DISPATCH_ASSOCIATION, parseDispatchAssociation, } from "./association.js";
190
189
  /** Read selected associations in one targeted observation, isolating per-identity decoding failures. */
191
190
  export async function observeDispatchAssociations(repository, akuIds) {
192
191
  const requested = [...new Set(akuIds.map((akuId) => parseAkuId(akuId).id))];
@@ -49,8 +49,12 @@ export type BindTargetSelection = Readonly<{
49
49
  export declare function normalizeTargetBranch(repository: GitRepository, input: string): Promise<string | null>;
50
50
  /** Read one worktree's attached branch, or null for detached HEAD. */
51
51
  export declare function currentBranch(repository: GitRepository, path?: string): Promise<string | null>;
52
- /** Observe bind's tender start and optional reward target without creating persistent state. */
53
- export declare function observeBindCoordinates(repository: GitRepository, selection?: BindTargetSelection): Promise<BindCoordinatesObservation | UnbornHeadObservation | null>;
52
+ /**
53
+ * Observe bind's tender start and optional reward target without creating persistent state.
54
+ * `current-branch` reads the observed worktree coordinate's own attached branch; the caller names
55
+ * which coordinate it wants observed.
56
+ */
57
+ export declare function observeBindCoordinates(repository: GitRepository, selection: BindTargetSelection): Promise<BindCoordinatesObservation | UnbornHeadObservation | null>;
54
58
  export declare function observeActiveContractWorld(observation: GitReadObservation): Promise<ActiveContractWorldObservation>;
55
59
  export declare function observeContractWorld(observation: GitReadObservation, requested?: readonly ContractId[]): Promise<ContractWorldObservation>;
56
60
  export declare function observeContractsForAdmissionAt(repository: GitRepository, channel: GitDecodeChannel, ids: readonly ContractId[], selection?: GitTreeSelection): Promise<GitDecisionObservation>;
@@ -77,8 +77,12 @@ async function observeHeadCoordinates(repository) {
77
77
  throw error;
78
78
  }
79
79
  }
80
- /** Observe bind's tender start and optional reward target without creating persistent state. */
81
- export async function observeBindCoordinates(repository, selection = { kind: "targetless" }) {
80
+ /**
81
+ * Observe bind's tender start and optional reward target without creating persistent state.
82
+ * `current-branch` reads the observed worktree coordinate's own attached branch; the caller names
83
+ * which coordinate it wants observed.
84
+ */
85
+ export async function observeBindCoordinates(repository, selection) {
82
86
  if (selection.kind === "explicit") {
83
87
  const requestedTarget = selection.target;
84
88
  if (isKeiyakuOwnedRef(requestedTarget)) {
@@ -45,17 +45,17 @@ export { actorId } from "./core/facts/types.js";
45
45
  * configuration helpers stay off this entry; only CLI and Body import them.
46
46
  */
47
47
  export { z } from "zod";
48
- export { ALLOWED_ACTIONS, Akuma, AkumaBusyError, AkumaDecodeError, AkumaNotBornError, AkumaProviderError, Schema, } from "./akuma/index.js";
49
- export type { ActivityHistory, ActivityRow, AkuId, AkumaAskObservation, AkumaAskOptions, AkumaAskResult, AkumaBirthInput, AkumaHistoryOptions, AkumaIdleOptions, AkumaIdleResult, AkumaSignalOptions, AkumaStatus, AkumaTellOptions, AkumaTellResult, AllowedAction, AllowedActions, InterruptReceipt, JsonSchema, JsonSchemaDocument, KillEvidence, SchemaLike, StandardSchemaV1, } from "./akuma/index.js";
48
+ export { ALLOWED_ACTIONS, Akuma, AkumaArchetypeError, AkumaBusyError, AkumaDecodeError, AkumaNotBornError, AkumaProviderError, Schema, listArchetypeDefinitions, } from "./akuma/index.js";
49
+ export type { AkumaCaller, AkumaOrigin, ActivityHistory, ActivityRow, AkuId, AkumaAskObservation, AkumaAskOptions, AkumaAskResult, AkumaBirthInput, AkumaHistoryOptions, AkumaHostOptions, AkumaIdleOptions, AkumaIdleResult, AkumaSignalOptions, AkumaStatus, AkumaTellOptions, AkumaTellResult, AllowedAction, AllowedActions, ArchetypeCatalog, ArchetypeCatalogInput, ArchetypeCatalogRow, InterruptReceipt, JsonSchema, JsonSchemaDocument, KillEvidence, SchemaLike, StandardSchemaV1, } from "./akuma/index.js";
50
50
  export type { ActorId, ChangeId, ContractHead, ContractId, ContractState, JournalEntry as Fact, FactKind, SnapshotId, } from "./core/facts/types.js";
51
- export { kanshi, observeKanshi, selectKanshi, selectRegion } from "./kanshi/index.js";
52
- export type { AkumaKanshiRow, AkumaKanshiWorld, ContractEndpointObservation, ContractHolderObservation, ContractKanshiBoard, ContractKanshiRow, KanshiInput, KanshiRegionSelection, KanshiReport, KanshiSelection, RegionDeclaration, RegionRead, Section, TaskKanshiRow, TaskKanshiWorld, } from "./kanshi/index.js";
51
+ export { kanshi, kanshiCategory, observeKanshi, selectKanshi, selectRegion } from "./kanshi/index.js";
52
+ export type { AkumaKanshiRow, AkumaKanshiWorld, ContractEndpointObservation, ContractHolderObservation, ContractKanshiBoard, ContractKanshiRow, KanshiCategoryInput, KanshiCategoryReport, KanshiInput, KanshiRegionSelection, KanshiReport, KanshiSelection, RegionDeclaration, RegionRead, Section, TaskKanshiRow, TaskKanshiWorld, } from "./kanshi/index.js";
53
53
  export { AkumaAddressError, AkumaWorldScopeError, Akumas } from "./library/akumas.js";
54
54
  export type { AkumaAddressInput, AkumaAskInput, AkumaHistoryInput, AkumaHistoryResult, AkumaKillInput, AkumaKillResult, AkumaList, AkumaListInput, AkumaObservation, AkumaObservationStage, AkumaTellInput, AkumaWaitInput, AkumaWaitResult, AkumaWorldScopeRefusal, CallInput, CallResult, CallWaitHead, CreatedTaskObservation, DispatchAssociation, DispatchStage, ForkInput, ForkResult, TellResult, TellWake, WaitObservedAkuma, WaitObserver, WaitSelectedAkuma, } from "./library/akumas.js";
55
55
  export type { ContinuationReport } from "./library/continuation.js";
56
56
  export type { KeiyakuLibrary, ReconcileInput } from "./library/contract-composition.js";
57
57
  export type { AbandonOutcome, AmendOutcome, ArcOutcome, AuditOutcome, BindOutcome, BindResult, DeliverOutcome, ReviewOutcome, } from "./library/contract-outcomes.js";
58
- export type { AbandonInput, AmendInput, ArcInput, BindInput, ContractHistory, ContractHistoryEvent, ContractList, ContractListInput, ContractObservationInput, DeliverInput, KeiyakuSelectInput, LocalContractComposition, ReviewInput, } from "./library/contract-types.js";
58
+ export type { AbandonInput, AmendInput, ArcInput, BindInput, ContractHistory, ContractHistoryEvent, ContractList, ContractListInput, ContractObservationInput, ContractResolveInput, ContractResolution, ContractSelectorRefusal, DeliverInput, KeiyakuSelectInput, LocalContractComposition, ReviewInput, } from "./library/contract-types.js";
59
59
  export { nukeKeiyaku as nuke } from "./library/nuke.js";
60
60
  export type { NukeInput, NukeResult } from "./library/nuke.js";
61
61
  export type { InvocationEffect, KeiyakuErrorCategory, PartialOutcomeEnvelope, PendingSurface, ReconciliationLag, Review, } from "./library/outcome.js";
@@ -63,7 +63,7 @@ export type { ReconcileCompletion, RepoContractReconcileReport, RepoReconcileRep
63
63
  export type { KeiyakuRefusal, KeiyakuRetryReason, NukeConfirmationRefusal, NukeConfirmationRequiredRefusal, OperationRetries, } from "./library/refusal.js";
64
64
  export type { RegionOverlap } from "./library/region.js";
65
65
  export type { RepoAtInput } from "./library/repo.js";
66
- export type { KeiyakuPlugin, PluginBodyEnd, PluginContext, PluginHooks, PluginInstance, PluginManifest, PluginOutcome, PluginSignal, PluginSignalMap, } from "./plugin/public.js";
66
+ export type { KeiyakuPlugin, PluginAkumaCaller, PluginAkumaOrigin, PluginBodyEnd, PluginContext, PluginHooks, PluginInstance, PluginManifest, PluginOutcome, PluginSignal, PluginSignalMap, } from "./plugin/public.js";
67
67
  export type { AuditReport } from "./protocol/audit.js";
68
68
  export type { IntegrationConflictMaterialized, VerificationReuse } from "./protocol/deliver.js";
69
69
  export type { ExecutionObservation, ExecutionObserver } from "./protocol/execution-observation.js";
@@ -45,8 +45,8 @@ export { actorId } from "./core/facts/types.js";
45
45
  * configuration helpers stay off this entry; only CLI and Body import them.
46
46
  */
47
47
  export { z } from "zod";
48
- export { ALLOWED_ACTIONS, Akuma, AkumaBusyError, AkumaDecodeError, AkumaNotBornError, AkumaProviderError, Schema, } from "./akuma/index.js";
49
- export { kanshi, observeKanshi, selectKanshi, selectRegion } from "./kanshi/index.js";
48
+ export { ALLOWED_ACTIONS, Akuma, AkumaArchetypeError, AkumaBusyError, AkumaDecodeError, AkumaNotBornError, AkumaProviderError, Schema, listArchetypeDefinitions, } from "./akuma/index.js";
49
+ export { kanshi, kanshiCategory, observeKanshi, selectKanshi, selectRegion } from "./kanshi/index.js";
50
50
  export { AkumaAddressError, AkumaWorldScopeError, Akumas } from "./library/akumas.js";
51
51
  export { nukeKeiyaku as nuke } from "./library/nuke.js";
52
52
  export { SettingsError, settings } from "./settings.js";
@@ -1,5 +1,5 @@
1
1
  export { kanshi, kanshiCategory, observeKanshi } from "./read.js";
2
2
  export { selectKanshi, selectRegion } from "./select.js";
3
- export type { KanshiInput } from "./read.js";
3
+ export type { KanshiCategoryInput, KanshiInput } from "./read.js";
4
4
  export type { AkumaKanshiRow, AkumaKanshiWorld, ContractEndpointObservation, ContractHolderObservation, ContractKanshiBoard, ContractKanshiRow, KanshiCategoryReport, KanshiReport, Section, TaskKanshiRow, TaskKanshiWorld, KanshiRegionSelection, RegionDeclaration, RegionOverlap, RegionRead, } from "./report.js";
5
5
  export type { KanshiSelection } from "./select.js";
@@ -89,6 +89,12 @@ function regionSelection(value) {
89
89
  }
90
90
  throw new TypeError(`kanshi region selection kind is invalid: ${selection.kind}`);
91
91
  }
92
+ function worldCoordinate(world, repo) {
93
+ if (world !== null && (typeof world !== "string" || world.trim().length === 0))
94
+ throw new TypeError("kanshi world must be a WorldRoot or null");
95
+ if (repo !== undefined && !(repo instanceof Repo))
96
+ throw new TypeError("kanshi repo must be a Repo");
97
+ }
92
98
  function coordinate(input) {
93
99
  if (typeof input !== "object" || input === null || Array.isArray(input))
94
100
  throw new TypeError("kanshi input must be an object");
@@ -97,11 +103,7 @@ function coordinate(input) {
97
103
  throw new TypeError(`kanshi input has unknown field: ${key}`);
98
104
  }
99
105
  }
100
- if (input.world !== null && (typeof input.world !== "string" || input.world.trim().length === 0)) {
101
- throw new TypeError("kanshi world must be a WorldRoot or null");
102
- }
103
- if (input.repo !== undefined && !(input.repo instanceof Repo))
104
- throw new TypeError("kanshi repo must be a Repo");
106
+ worldCoordinate(input.world, input.repo);
105
107
  return {
106
108
  ...input,
107
109
  ...(input.region === undefined ? {} : { region: regionSelection(input.region) }),
@@ -498,9 +500,22 @@ async function observeContractCategory(world, repo, limit, observedAt) {
498
500
  return report({ kind: "failed", failure: { message: diagnostic(error) } });
499
501
  }
500
502
  }
503
+ const DEFAULT_CATEGORY_LIMIT = 10;
504
+ /** Caller-invalid category requests are refused here, before any owner observation runs. */
505
+ function validateCategoryInput(input) {
506
+ const value = record(input, "category input");
507
+ exactKeys(value, ["world", "repo", "category", "limit"], "category input");
508
+ worldCoordinate(value.world, value.repo);
509
+ if (value.category !== "akuma" && value.category !== "contract")
510
+ throw new TypeError(`kanshi category is invalid: ${String(value.category)}`);
511
+ const { limit } = value;
512
+ if (limit !== undefined && (typeof limit !== "number" || !Number.isSafeInteger(limit) || limit < 1))
513
+ throw new TypeError("kanshi category limit must be a positive safe integer");
514
+ }
501
515
  export async function kanshiCategory(input) {
502
516
  const observedAt = new Date().toISOString();
503
- const { world, repo, category, limit = 10 } = input;
517
+ validateCategoryInput(input);
518
+ const { world, repo, category, limit = DEFAULT_CATEGORY_LIMIT } = input;
504
519
  if (category === "contract") {
505
520
  if (repo === undefined)
506
521
  throw new TypeError("kanshi contract category requires a Repo");
@@ -7,6 +7,7 @@ import { contractId } from "../core/facts/types.js";
7
7
  import { readDispatches } from "../dispatch/index.js";
8
8
  import { matchesAkumaGlob, parseReadableAkumaAlias, parseAkumaGlob, } from "../identity/selector.js";
9
9
  import { World } from "../world.js";
10
+ import { matchContractCandidates } from "./contract-address.js";
10
11
  import { requireInput } from "./input.js";
11
12
  import { scopeForRepo } from "./repo.js";
12
13
  export class AkumaAddressError extends Error {
@@ -69,10 +70,7 @@ export function resolveNamedAddress(input) {
69
70
  if (selector.startsWith("aku/"))
70
71
  return { kind: "akuma", id: parseAddressId(selector).id };
71
72
  const alias = parseAddressAlias(selector);
72
- const contractMatches = (input.report.contracts.kind === "present" ? input.report.contracts.value.rows : []).filter((row) => row.disposition === "active" &&
73
- row.workspace === "worktree" &&
74
- row.worktreePath !== null &&
75
- `@${row.id.slice("kei/".length)}` === alias);
73
+ const contractMatches = matchContractCandidates(input.report.contracts.kind === "present" ? input.report.contracts.value.rows : [], { selector: alias });
76
74
  const aliasId = input.aliases.kind === "present"
77
75
  ? (input.aliases.value.find((binding) => binding.alias === alias)?.akuId ?? null)
78
76
  : null;
@@ -1,3 +1,4 @@
1
+ import { type AkumaCaller } from "../akuma/caller.js";
1
2
  import { type ForkReceipt } from "../akuma/akuma-owner.js";
2
3
  import { type AskObserver } from "../akuma/akuma-selection-execution.js";
3
4
  import type { AkumaStatus } from "../akuma/akuma.js";
@@ -63,6 +64,7 @@ export type CallInput = Readonly<{
63
64
  allowed?: readonly AllowedAction[];
64
65
  schema?: Schema<unknown>;
65
66
  initiator?: string;
67
+ caller?: AkumaCaller;
66
68
  signal?: AbortSignal;
67
69
  observe?: CallWaitObserver;
68
70
  }>;
@@ -98,6 +100,8 @@ export type ForkInput = Readonly<{
98
100
  akuma: string;
99
101
  at: string;
100
102
  repo?: Repo;
103
+ caller?: AkumaCaller;
104
+ initiator?: string;
101
105
  }>;
102
106
  export type ForkResult = Readonly<{
103
107
  kind: "forked";
@@ -112,7 +116,7 @@ export type ForkResult = Readonly<{
112
116
  }>);
113
117
  export declare function callAkumas(input: CallInput & Readonly<{
114
118
  path: WorldRoot;
115
- }>, execution?: ExecutionContext): Promise<CallResult>;
119
+ }>, execution?: ExecutionContext, reportDiagnostic?: (message: string) => void): Promise<CallResult>;
116
120
  export declare function forkAkumas(input: ForkInput & Readonly<{
117
121
  path: WorldRoot;
118
122
  }>): Promise<ForkResult>;
@@ -1,11 +1,11 @@
1
1
  /** @architectureCompositionRoot */
2
2
  import { randomUUID } from "node:crypto";
3
3
  import { appendFile } from "node:fs/promises";
4
+ import { decodeAkumaCaller } from "../akuma/caller.js";
4
5
  import { admitAkumaCall } from "../akuma/akuma-call.js";
5
6
  import { AkumaOwner } from "../akuma/akuma-owner.js";
6
7
  import { decodeAskObservation, observeAdmittedAskAkuma } from "../akuma/akuma-selection-execution.js";
7
8
  import { canonicalBirthCwd } from "../akuma/call-input.js";
8
- import { readSoul } from "../akuma/heart/index.js";
9
9
  import { pathsForAkuId } from "../akuma/identity.js";
10
10
  import { localExecutionContext } from "../akuma/requests.js";
11
11
  import { schemaJsonText } from "../akuma/schema.js";
@@ -13,7 +13,7 @@ import { moveAlias } from "../alias/index.js";
13
13
  import { AuthorityCorruptionError } from "../core/facts/errors.js";
14
14
  import { publishDispatch, readDispatch } from "../dispatch/index.js";
15
15
  import { parseAkumaAlias } from "../identity/selector.js";
16
- import { emitCalledPluginSignal } from "../plugin/akuma-signals.js";
16
+ import { outcomePluginObserver } from "../plugin/akuma-signals.js";
17
17
  import { World } from "../world.js";
18
18
  import { addressAkuma } from "./address.js";
19
19
  import { requireInput } from "./input.js";
@@ -100,52 +100,24 @@ function callSeat(contract) {
100
100
  throw new TypeError("contract must be a Keiyaku");
101
101
  return seat;
102
102
  }
103
- async function requestedParent(path, id) {
104
- const soul = await readSoul(pathsForAkuId(path, id));
105
- return soul?.origin.kind === "request" ? soul.origin.parent : undefined;
106
- }
107
103
  function pluginDiagnostic(error) {
108
104
  const message = error instanceof Error ? error.message : String(error);
109
105
  return message.length <= 500 ? message : `${message.slice(0, 500)}...`;
110
106
  }
111
- async function recordPluginDiagnostic(paths, error) {
107
+ async function recordPluginDiagnostic(paths, error, occurrence) {
112
108
  try {
113
- await appendFile(paths.log, `plugin call admission failed: ${pluginDiagnostic(error)}\n`);
109
+ await appendFile(paths.log, `plugin ${occurrence} failed: ${pluginDiagnostic(error)}\n`);
114
110
  }
115
111
  catch {
116
112
  // Plugin diagnostic loss must not change an already admitted call.
117
113
  }
118
114
  }
119
- /**
120
- * The submitting process's optional called-plugin observation. It runs once,
121
- * after the prepared executor returned its local value or the forwarded caller
122
- * received its exact live output, and it never gates birth, initial Tell, or a
123
- * later integration stage. A failed delivery stays a diagnostic.
124
- */
125
- async function emitCalledSignal(input) {
126
- try {
127
- const paths = pathsForAkuId(input.path, input.admitted.id);
128
- const callerAkumaId = input.admitted.requested ? await requestedParent(input.path, input.admitted.id) : undefined;
129
- const reportDiagnostic = (message) => {
130
- void recordPluginDiagnostic(paths, message);
131
- };
132
- try {
133
- await emitCalledPluginSignal({
134
- world: input.path,
135
- ...(input.settings === undefined ? {} : { settings: input.settings }),
136
- reportDiagnostic,
137
- akumaId: input.admitted.id,
138
- ...(callerAkumaId === undefined ? {} : { callerAkumaId }),
139
- ...(input.contractId === undefined ? {} : { contractId: input.contractId }),
140
- });
141
- }
142
- catch (error) {
143
- await recordPluginDiagnostic(paths, error);
144
- }
145
- }
146
- catch {
147
- // Plugin delivery must not change an already admitted call.
148
- }
115
+ function callDiagnosticSink(paths, occurrence, reportDiagnostic) {
116
+ return (message) => {
117
+ void recordPluginDiagnostic(paths, message, occurrence);
118
+ // Return the host's possible Promise for the plugin diagnostic isolation boundary.
119
+ return reportDiagnostic?.(message);
120
+ };
149
121
  }
150
122
  async function dispatchStage(input) {
151
123
  try {
@@ -210,6 +182,7 @@ const CALL_INPUT_KEYS = [
210
182
  "allowed",
211
183
  "schema",
212
184
  "initiator",
185
+ "caller",
213
186
  "signal",
214
187
  "observe",
215
188
  ];
@@ -220,6 +193,7 @@ async function parseCallInput(input) {
220
193
  const archetype = nonblank(values.archetype, "archetype");
221
194
  const body = callBody(values.body);
222
195
  const initiator = values.initiator === undefined ? undefined : text(values.initiator, "initiator");
196
+ const caller = decodeAkumaCaller(values.caller);
223
197
  const cwd = values.cwd === undefined ? undefined : nonblank(values.cwd, "cwd");
224
198
  const mode = callMode(values.mode);
225
199
  validateCallBodyOptions(body, values, mode);
@@ -253,6 +227,8 @@ async function parseCallInput(input) {
253
227
  ...(alias === undefined ? {} : { alias }),
254
228
  ...(values.allowed === undefined ? {} : { allowed: values.allowed }),
255
229
  seat,
230
+ ...(caller === undefined ? {} : { caller }),
231
+ ...(initiator === undefined ? {} : { initiator }),
256
232
  ...(initialTell === undefined ? {} : { initialTell }),
257
233
  ...(observe === undefined ? {} : { observe }),
258
234
  };
@@ -267,6 +243,8 @@ function callConfiguration(input, execution) {
267
243
  function callAdmissionInput(input, execution) {
268
244
  return {
269
245
  archetype: input.archetype,
246
+ ...(input.caller === undefined ? {} : { caller: input.caller }),
247
+ ...(input.initiator === undefined ? {} : { initiator: input.initiator }),
270
248
  ...(input.initialTell === undefined
271
249
  ? {}
272
250
  : {
@@ -303,7 +281,7 @@ function failedCall(result, tellId, error, tell) {
303
281
  },
304
282
  };
305
283
  }
306
- async function observeCall(input) {
284
+ async function observeCall(input, reportDiagnostic) {
307
285
  const onObserve = {
308
286
  admitted: async (receipt, id) => {
309
287
  await input.observe?.admitted?.(receipt, id, {
@@ -320,6 +298,11 @@ async function observeCall(input) {
320
298
  tellId: input.initialTell.tellId,
321
299
  timeoutMs: input.timeoutMs,
322
300
  receipt: input.receipt,
301
+ outcomeObserved: outcomePluginObserver({
302
+ world: input.path,
303
+ ...(input.settings === undefined ? {} : { settings: input.settings }),
304
+ reportDiagnostic: callDiagnosticSink(pathsForAkuId(input.path, input.akuma), "outcome observation", reportDiagnostic),
305
+ }),
323
306
  ...(input.signal === undefined ? {} : { signal: input.signal }),
324
307
  onObserve,
325
308
  });
@@ -351,7 +334,7 @@ function knownChildFailure(reason, akuma) {
351
334
  function asError(failure) {
352
335
  return failure instanceof Error ? failure : new Error(failure === undefined ? "call failed" : String(failure));
353
336
  }
354
- export async function callAkumas(input, execution = localExecutionContext()) {
337
+ export async function callAkumas(input, execution = localExecutionContext(), reportDiagnostic) {
355
338
  const parsed = await parseCallInput(input);
356
339
  const selectedExecution = await resolveCallExecution(parsed.cwd === undefined ? {} : { cwd: parsed.cwd });
357
340
  const seat = parsed.seat;
@@ -359,14 +342,6 @@ export async function callAkumas(input, execution = localExecutionContext()) {
359
342
  ...callAdmissionInput(parsed, selectedExecution),
360
343
  ...(seat === undefined ? {} : { contractId: seat.id }),
361
344
  }, selectedExecution === undefined ? {} : { cwdCanonical: true });
362
- // One caller-wiring sequence, after the prepared executor returned its local value
363
- // or the forwarded caller received its exact live output, before outcome observation.
364
- await emitCalledSignal({
365
- path: parsed.path,
366
- ...(parsed.settings === undefined ? {} : { settings: parsed.settings }),
367
- admitted,
368
- ...(seat === undefined ? {} : { contractId: seat.id }),
369
- });
370
345
  const dispatch = seat === undefined
371
346
  ? { kind: "none" }
372
347
  : await dispatchStage({ repository: seat.scope, akuId: admitted.id, contractId: seat.id });
@@ -400,18 +375,25 @@ export async function callAkumas(input, execution = localExecutionContext()) {
400
375
  initialTell: parsed.initialTell,
401
376
  receipt,
402
377
  timeoutMs: parsed.timeoutMs,
378
+ ...(parsed.settings === undefined ? {} : { settings: parsed.settings }),
403
379
  ...(parsed.signal === undefined ? {} : { signal: parsed.signal }),
404
380
  ...(parsed.observe === undefined ? {} : { observe: parsed.observe }),
405
- });
381
+ }, reportDiagnostic);
406
382
  }
407
383
  export async function forkAkumas(input) {
408
384
  const values = requireInput(input, "Akumas.fork input");
409
- onlyKeys(values, ["path", "akuma", "at", "repo"], "Akumas.fork input");
385
+ onlyKeys(values, ["path", "akuma", "at", "repo", "caller", "initiator"], "Akumas.fork input");
386
+ const caller = decodeAkumaCaller(values.caller);
387
+ const initiator = values.initiator === undefined ? undefined : text(values.initiator, "initiator");
410
388
  const at = nonblank(values.at, "at");
411
389
  const addressed = await addressAkuma({ path: values.path, akuma: nonblank(values.akuma, "akuma") });
412
390
  const { path, id: akuma } = addressed;
413
391
  const repository = values.repo === undefined ? undefined : scopeForRepo(values.repo);
414
- const receipt = await new AkumaOwner(akuma, path).fork({ at });
392
+ const receipt = await new AkumaOwner(akuma, path).fork({
393
+ at,
394
+ ...(caller === undefined ? {} : { caller }),
395
+ ...(initiator === undefined ? {} : { initiator }),
396
+ });
415
397
  if (receipt.kind !== "forked")
416
398
  return { ...receipt, parent: akuma };
417
399
  const dispatch = repository === undefined
@@ -1,8 +1,9 @@
1
1
  /** @architectureCompositionRoot */
2
+ import { type AkumaHostOptions } from "../akuma/akuma-instance.js";
2
3
  import type { AkumaList, AkumaListInput } from "../akuma/akuma.js";
3
4
  import type { TellResult, TellWake } from "../akuma/body.js";
4
5
  import { type ExecutionContext } from "../akuma/requests.js";
5
- import type { DispatchAssociation } from "../dispatch/association.js";
6
+ import type { DispatchAssociation } from "../akuma/dispatch-association.js";
6
7
  import type { CreatedTaskObservation } from "../task/created-observation.js";
7
8
  import { type WorldRoot } from "../world.js";
8
9
  import type { AkumaAddressInput, AkumaWorldScopeRefusal } from "./address.js";
@@ -18,7 +19,7 @@ export type { WaitObservedAkuma, WaitObserver, WaitSelectedAkuma } from "../akum
18
19
  export type Akumas = AkumasHandle;
19
20
  declare class AkumasHandle {
20
21
  #private;
21
- constructor(world: WorldRoot, execution: ExecutionContext);
22
+ constructor(world: WorldRoot, execution: ExecutionContext, host?: AkumaHostOptions);
22
23
  list(input?: AkumaListInput): Promise<AkumaList>;
23
24
  call(input: CallInput): Promise<CallResult>;
24
25
  fork(input: ForkInput): Promise<ForkResult>;
@@ -34,7 +35,7 @@ declare class AkumasHandle {
34
35
  * The one Akumas composition. Public `of` fixes local execution; CLI and Body pass their captured
35
36
  * internal channel through `akumasWithExecution` instead of a second constructor.
36
37
  */
37
- export declare function akumasWithExecution(world: WorldRoot, execution: ExecutionContext): Akumas;
38
+ export declare function akumasWithExecution(world: WorldRoot, execution: ExecutionContext, host?: AkumaHostOptions): Akumas;
38
39
  export declare const Akumas: Readonly<{
39
- of(world: WorldRoot): Akumas;
40
+ of(world: WorldRoot, host?: AkumaHostOptions): Akumas;
40
41
  }>;