@sema-agent/core 7.72.0 → 7.73.0

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 (256) hide show
  1. package/CHANGELOG.md +319 -0
  2. package/dist/agents/inherited-tool-pool.d.ts +26 -1
  3. package/dist/agents/inherited-tool-pool.js +46 -2
  4. package/dist/agents/parked-resume-drive.d.ts +10 -0
  5. package/dist/agents/parked-resume-drive.js +9 -0
  6. package/dist/agents/retain-ledger.d.ts +3 -0
  7. package/dist/agents/send-message-tool.js +1 -0
  8. package/dist/agents/send-user-message-tool.d.ts +12 -0
  9. package/dist/agents/send-user-message-tool.js +67 -0
  10. package/dist/agents/subagent-steps.d.ts +9 -0
  11. package/dist/agents/subagent-steps.js +38 -0
  12. package/dist/agents/subagent.d.ts +2 -0
  13. package/dist/agents/subagent.js +43 -12
  14. package/dist/agents/verify.js +23 -8
  15. package/dist/agents/yield-adoption.js +3 -1
  16. package/dist/brain/anthropic.js +14 -9
  17. package/dist/brain/open-responses.js +4 -5
  18. package/dist/brain/openai.js +30 -23
  19. package/dist/brain/stream-engine.js +159 -151
  20. package/dist/core/actions-digest.d.ts +43 -0
  21. package/dist/core/actions-digest.js +22 -0
  22. package/dist/core/allow-entry.js +3 -3
  23. package/dist/core/auto-mode.d.ts +7 -9
  24. package/dist/core/auto-mode.js +114 -8
  25. package/dist/core/checkpoint-features.d.ts +3 -2
  26. package/dist/core/checkpoint-features.js +1 -1
  27. package/dist/core/checkpoint-rekey.d.ts +1 -1
  28. package/dist/core/checkpoint-rekey.js +6 -1
  29. package/dist/core/checkpoint-requirements.d.ts +23 -3
  30. package/dist/core/checkpoint-requirements.js +5 -1
  31. package/dist/core/checkpoint-row-verdict.js +7 -1
  32. package/dist/core/checkpoint-store.d.ts +24 -2
  33. package/dist/core/checkpoint-store.js +1 -0
  34. package/dist/core/child-clamp-seats.d.ts +15 -0
  35. package/dist/core/child-clamp-seats.js +15 -0
  36. package/dist/core/delegation-frames.d.ts +1 -0
  37. package/dist/core/delegation-frames.js +1 -1
  38. package/dist/core/engine-capabilities.d.ts +5 -1
  39. package/dist/core/engine-capabilities.js +1 -1
  40. package/dist/core/engine-notice.d.ts +30 -22
  41. package/dist/core/engine-version.js +1 -1
  42. package/dist/core/entries-not-applied.d.ts +19 -7
  43. package/dist/core/entries-not-applied.js +33 -1
  44. package/dist/core/governance-codes.d.ts +7 -1
  45. package/dist/core/governance-codes.js +13 -5
  46. package/dist/core/hooks.d.ts +3 -0
  47. package/dist/core/hooks.js +1 -0
  48. package/dist/core/host-instance.d.ts +23 -0
  49. package/dist/core/host-instance.js +69 -0
  50. package/dist/core/instruction-preview.d.ts +63 -0
  51. package/dist/core/instruction-preview.js +406 -0
  52. package/dist/core/leg-budget.d.ts +26 -0
  53. package/dist/core/leg-budget.js +9 -0
  54. package/dist/core/leg-identity.d.ts +51 -1
  55. package/dist/core/leg-identity.js +45 -2
  56. package/dist/core/manager-launch-check.d.ts +48 -0
  57. package/dist/core/manager-launch-check.js +64 -0
  58. package/dist/core/mcp-call-meta.d.ts +2 -2
  59. package/dist/core/mcp-injection-drop.d.ts +20 -10
  60. package/dist/core/mcp-injection-drop.js +9 -3
  61. package/dist/core/mcp-server-spec.d.ts +2 -1
  62. package/dist/core/member-outcome.d.ts +3 -2
  63. package/dist/core/member-outcome.js +1 -1
  64. package/dist/core/memory-engine/deletion-record.d.ts +46 -0
  65. package/dist/core/memory-engine/deletion-record.js +96 -0
  66. package/dist/core/memory-engine/engine.js +24 -16
  67. package/dist/core/memory-engine/file-backend.js +7 -5
  68. package/dist/core/memory-engine/projection-ledger.d.ts +1 -1
  69. package/dist/core/memory-engine/projection-ledger.js +1 -1
  70. package/dist/core/memory-engine/scope-contract.d.ts +18 -13
  71. package/dist/core/memory-engine/scope-contract.js +18 -18
  72. package/dist/core/memory-engine/sync-client.js +26 -6
  73. package/dist/core/memory-engine/sync.d.ts +20 -2
  74. package/dist/core/memory-engine/sync.js +18 -17
  75. package/dist/core/mode-policy.d.ts +21 -6
  76. package/dist/core/mode-policy.js +15 -6
  77. package/dist/core/own-property-receipt.js +11 -4
  78. package/dist/core/parent-spec-seat.d.ts +13 -11
  79. package/dist/core/parent-spec-seat.js +13 -9
  80. package/dist/core/peer-seat.js +3 -3
  81. package/dist/core/peer-task-store.d.ts +365 -0
  82. package/dist/core/peer-task-store.js +682 -0
  83. package/dist/core/permission-rule-consent.js +6 -11
  84. package/dist/core/permission-rule-model.d.ts +27 -0
  85. package/dist/core/permission-rule-model.js +33 -5
  86. package/dist/core/permission-rule-provider.d.ts +35 -33
  87. package/dist/core/permission-rule-provider.js +38 -295
  88. package/dist/core/permission-rule-store.d.ts +181 -8
  89. package/dist/core/permission-rule-store.js +420 -17
  90. package/dist/core/permission-rule-sync.js +15 -1
  91. package/dist/core/project-seat.d.ts +55 -0
  92. package/dist/core/project-seat.js +96 -0
  93. package/dist/core/protocol-http-auth.d.ts +3 -2
  94. package/dist/core/protocol-http-auth.js +26 -18
  95. package/dist/core/remote-env.d.ts +4 -4
  96. package/dist/core/retired-keys.js +1 -0
  97. package/dist/core/rule-offer-read.d.ts +1 -1
  98. package/dist/core/rule-offer-read.js +32 -4
  99. package/dist/core/run-ledger-seat.d.ts +66 -0
  100. package/dist/core/run-ledger-seat.js +70 -0
  101. package/dist/core/run-ledger.d.ts +332 -0
  102. package/dist/core/run-ledger.js +550 -0
  103. package/dist/core/runner/checkpoint-scope.d.ts +13 -3
  104. package/dist/core/runner/checkpoint-scope.js +12 -4
  105. package/dist/core/runner/construction-doors.js +6 -0
  106. package/dist/core/runner/contracts.d.ts +21 -5
  107. package/dist/core/runner/delegation-owner.d.ts +30 -0
  108. package/dist/core/runner/delegation-owner.js +20 -4
  109. package/dist/core/runner/finish-reason-seat.js +4 -2
  110. package/dist/core/runner/leg-frame.js +3 -0
  111. package/dist/core/runner/nested-memory-lane.d.ts +22 -5
  112. package/dist/core/runner/nested-memory-lane.js +91 -30
  113. package/dist/core/runner/person-path-rows.d.ts +21 -16
  114. package/dist/core/runner/person-path-rows.js +80 -15
  115. package/dist/core/runner/prepare-caps-and-workflow.js +98 -88
  116. package/dist/core/runner/prepare-config-doors.d.ts +1 -0
  117. package/dist/core/runner/prepare-config-doors.js +5 -3
  118. package/dist/core/runner/prepare-context-lane.js +1 -0
  119. package/dist/core/runner/prepare-delegation-surface.d.ts +3 -0
  120. package/dist/core/runner/prepare-delegation-surface.js +6 -0
  121. package/dist/core/runner/prepare-execution-env.d.ts +3 -3
  122. package/dist/core/runner/prepare-hands-readface.d.ts +5 -2
  123. package/dist/core/runner/prepare-hands-readface.js +12 -1
  124. package/dist/core/runner/prepare-inherited-gate.d.ts +6 -3
  125. package/dist/core/runner/prepare-inherited-gate.js +13 -5
  126. package/dist/core/runner/prepare-run-refs.d.ts +1 -1
  127. package/dist/core/runner/prepare-run-refs.js +3 -2
  128. package/dist/core/runner/prepare-suspend-saga.d.ts +6 -2
  129. package/dist/core/runner/prepare-suspend-saga.js +4 -2
  130. package/dist/core/runner/prepare-task.js +36 -27
  131. package/dist/core/runner/prepare-turn-wiring.d.ts +4 -3
  132. package/dist/core/runner/prepare-turn-wiring.js +2 -1
  133. package/dist/core/runner/prepare-wiring-manifest.d.ts +3 -1
  134. package/dist/core/runner/prepare-wiring-manifest.js +5 -2
  135. package/dist/core/runner/resume-apply.js +11 -5
  136. package/dist/core/runner/resume-review-outcome.d.ts +3 -0
  137. package/dist/core/runner/resume-review-outcome.js +24 -1
  138. package/dist/core/runner/run-harness-handlers.js +3 -0
  139. package/dist/core/runner/run-identity-wiring.js +3 -2
  140. package/dist/core/runner/run-leg.js +3 -0
  141. package/dist/core/runner/run-notification-lane.js +20 -1
  142. package/dist/core/runner/run-settle-and-teardown.js +21 -12
  143. package/dist/core/runner/run-stop-and-final-verify.js +6 -0
  144. package/dist/core/runner/run-telemetry-and-budget-seats.js +1 -1
  145. package/dist/core/runner/runtask.d.ts +6 -2
  146. package/dist/core/runner/runtask.js +21 -9
  147. package/dist/core/runner/shell-env-withheld.d.ts +3 -2
  148. package/dist/core/runner/shell-env-withheld.js +1 -2
  149. package/dist/core/runner/stop-tail-notice.d.ts +10 -2
  150. package/dist/core/runner/stop-tail-notice.js +9 -2
  151. package/dist/core/runner/stream-settle-backstop.d.ts +1 -0
  152. package/dist/core/runner/stream-settle-backstop.js +1 -0
  153. package/dist/core/runner/task-start-doors.js +6 -3
  154. package/dist/core/runner/terminal-account.d.ts +6 -1
  155. package/dist/core/runner/terminal-account.js +16 -1
  156. package/dist/core/runner/unreadable-person-rows.d.ts +2 -1
  157. package/dist/core/runner-deps.d.ts +13 -10
  158. package/dist/core/secret-env.d.ts +53 -37
  159. package/dist/core/secret-env.js +44 -47
  160. package/dist/core/session-checkout.d.ts +3 -0
  161. package/dist/core/session-checkout.js +1 -0
  162. package/dist/core/session-store.d.ts +12 -6
  163. package/dist/core/session-store.js +26 -6
  164. package/dist/core/session.d.ts +31 -8
  165. package/dist/core/store-contracts/checkpoint-store-contract.js +10 -0
  166. package/dist/core/store-contracts/peer-task-store-contract.d.ts +21 -0
  167. package/dist/core/store-contracts/peer-task-store-contract.js +516 -0
  168. package/dist/core/store-contracts/session-store-contract.d.ts +15 -2
  169. package/dist/core/store-contracts/session-store-contract.js +87 -3
  170. package/dist/core/store-contracts/workflow-journal-store-contract.d.ts +19 -1
  171. package/dist/core/store-contracts/workflow-journal-store-contract.js +89 -1
  172. package/dist/core/task-event.d.ts +10 -3
  173. package/dist/core/task-notification.d.ts +96 -10
  174. package/dist/core/task-notification.js +129 -5
  175. package/dist/core/task-registry-shared.d.ts +12 -1
  176. package/dist/core/task-registry-shared.js +3 -1
  177. package/dist/core/task-registry-workflow.d.ts +1 -1
  178. package/dist/core/task-registry-workflow.js +9 -1
  179. package/dist/core/task-registry.d.ts +39 -2
  180. package/dist/core/task-registry.js +76 -12
  181. package/dist/core/task-result.d.ts +13 -0
  182. package/dist/core/task-spec-members.d.ts +3 -1
  183. package/dist/core/task-spec-members.js +11 -3
  184. package/dist/core/task-spec.d.ts +48 -22
  185. package/dist/core/tool-catalog-entries.js +2 -0
  186. package/dist/core/tool-mount-facts.d.ts +1 -1
  187. package/dist/core/tool-mount-facts.js +1 -0
  188. package/dist/core/tool-mount-plan.d.ts +3 -1
  189. package/dist/core/tool-mount-plan.js +6 -0
  190. package/dist/core/tool-mount-static.d.ts +1 -1
  191. package/dist/core/tool-mount-static.js +4 -2
  192. package/dist/core/tool-result-store.d.ts +19 -2
  193. package/dist/core/tool-result-store.js +51 -2
  194. package/dist/core/tool-spec.d.ts +9 -2
  195. package/dist/core/user-attachment.d.ts +5 -1
  196. package/dist/core/user-attachment.js +14 -7
  197. package/dist/core/wiring-manifest.d.ts +26 -20
  198. package/dist/core/wiring-manifest.js +7 -3
  199. package/dist/core/workflow-journal-store.d.ts +53 -10
  200. package/dist/core/workflow-journal-store.js +27 -4
  201. package/dist/core/workflow-run-store-contract.js +16 -0
  202. package/dist/core/workflow-run-store.d.ts +9 -7
  203. package/dist/core/workflow-run-store.js +4 -1
  204. package/dist/engine/execution-env/node-execution-env.js +3 -1
  205. package/dist/engine/harness/types.d.ts +24 -1
  206. package/dist/engine/harness/types.js +10 -0
  207. package/dist/engine/llm/types.d.ts +5 -7
  208. package/dist/engine/lsp/node-lsp-manager.js +2 -1
  209. package/dist/engine/session/import-validate.js +6 -1
  210. package/dist/engine/session/session.d.ts +15 -2
  211. package/dist/engine/session/session.js +34 -4
  212. package/dist/index.d.ts +18 -7
  213. package/dist/index.js +13 -4
  214. package/dist/orchestration/run-workflow-tool.js +40 -32
  215. package/dist/orchestration/workflow-park-adoption.d.ts +51 -12
  216. package/dist/orchestration/workflow-park-adoption.js +47 -12
  217. package/dist/orchestration/workflow-stop.d.ts +128 -0
  218. package/dist/orchestration/workflow-stop.js +156 -0
  219. package/dist/orchestration/workflow.d.ts +30 -6
  220. package/dist/orchestration/workflow.js +117 -55
  221. package/dist/prompts/manager-recipe.d.ts +18 -0
  222. package/dist/prompts/manager-recipe.js +24 -0
  223. package/dist/stores/file/permission-rule-store.d.ts +3 -1
  224. package/dist/stores/file/permission-rule-store.js +0 -1
  225. package/dist/stores/file/workflow-journal-store.d.ts +16 -3
  226. package/dist/stores/file/workflow-journal-store.js +93 -5
  227. package/dist/stores/file/workflow-run-store.d.ts +1 -1
  228. package/dist/tools/fs/file-write-check.js +9 -3
  229. package/dist/tools/fs/index.d.ts +8 -7
  230. package/dist/tools/fs/index.js +4 -4
  231. package/dist/tools/fs/read-deny-home.d.ts +1 -1
  232. package/dist/tools/fs/read-deny-home.js +5 -5
  233. package/dist/tools/fs/read-deny.d.ts +33 -8
  234. package/dist/tools/fs/read-deny.js +114 -25
  235. package/dist/tools/fs/safety.d.ts +4 -1
  236. package/dist/tools/fs/safety.js +4 -2
  237. package/dist/tools/fs/shell-read-check.d.ts +9 -2
  238. package/dist/tools/fs/shell-read-check.js +96 -14
  239. package/dist/tools/fs/shell-read-establish.d.ts +9 -0
  240. package/dist/tools/fs/shell-read-establish.js +21 -11
  241. package/dist/tools/fs/shell-read-judge.d.ts +13 -1
  242. package/dist/tools/fs/shell-read-judge.js +26 -7
  243. package/dist/tools/fs/shell-read-plan.d.ts +5 -0
  244. package/dist/tools/fs/shell-read-write-targets.js +17 -9
  245. package/package.json +2 -2
  246. package/test/export-surface.snapshot.json +131 -1
  247. package/wire-changes/answers/core-stores-sql@7.73.0.json +28 -0
  248. package/wire-changes/answers/core@7.73.0.json +216 -0
  249. package/wire-changes/answers/mods-kernel@7.73.0.json +7 -0
  250. package/wire-changes/answers/primitives@7.73.0.json +12 -0
  251. package/wire-changes/answers/wiki-gate@7.73.0.json +7 -0
  252. package/wire-changes/core-stores-sql@7.73.0.json +326 -0
  253. package/wire-changes/core@7.73.0.json +6480 -0
  254. package/wire-changes/mods-kernel@7.73.0.json +147 -0
  255. package/wire-changes/primitives@7.73.0.json +227 -0
  256. package/wire-changes/wiki-gate@7.73.0.json +145 -0
@@ -2,7 +2,7 @@ import type { AgentDefinition, McpServerSpec, ToolSpec } from "../core/types.js"
2
2
  import type { ToolSelector, ToolSelectorLayer } from "../core/tool-face.js";
3
3
  import { type MountedMcp } from "../core/mounted-mcp.js";
4
4
  import type { McpHostSeat } from "../core/mcp-host-seat.js";
5
- import type { InheritedGate, RunInternals } from "../core/runner/contracts.js";
5
+ import type { InheritedGate, RunInternals, RunnerSelfSeat } from "../core/runner/contracts.js";
6
6
  /**
7
7
  * What a delegated child inherits when its delegation tool has no explicit pool (`SubagentToolOptions.inheritedTools`):
8
8
  * the parent surface, narrowed at spawn by two laws, and the parent's MCP declarations. The mint of the parent bound
@@ -51,6 +51,13 @@ export declare function withoutWakerSeats(internals: RunInternals): RunInternals
51
51
  * chain): without any reading of the `sharedArtifactReads` setting. One rule: every wake is a run of its own and reads the seat
52
52
  * again — neither the spawner's old `allow` nor the waker's outlives a setting changed since. Every other member stays as it is. */
53
53
  export declare function wakeGate(gate: InheritedGate): InheritedGate;
54
+ /** Merge an agent definition's MCP servers with the lane's servers, returning both the mounted list and any shadowed entries. */
55
+ export declare function mergeDefinitionServers<S extends {
56
+ readonly name: string;
57
+ }>(handed: readonly S[] | undefined, own: readonly S[] | undefined): {
58
+ servers: S[];
59
+ dropped: S[];
60
+ };
54
61
  /**
55
62
  * The MCP servers a leg spawned as an agent definition is declared ({@link AgentDefinition.mcp}): the servers its lane hands it (the
56
63
  * spawning run's it inherits, a workflow child's governed spec's) first, then each of the definition's own whose tool namespace none of
@@ -61,6 +68,24 @@ export declare function wakeGate(gate: InheritedGate): InheritedGate;
61
68
  export declare function withDefinitionServers<S extends {
62
69
  readonly name: string;
63
70
  }>(handed: readonly S[] | undefined, own: readonly S[] | undefined): S[];
71
+ /**
72
+ * Announce shadowed agent-definition MCP entries through `mcpInjectionDroppedNotice`, once per (runner, root session address, agent,
73
+ * server) while that tuple is among the last `MAX_SHADOWED_ANNOUNCEMENTS_PER_RUNNER` announced (one pushed out is said again). The announcement is said on behalf of the spawning tree's leg `leg` and goes where that leg's children's notices go
74
+ * (`noticeAddressOf` over the root anchor `root` the children are handed): to the tree's root, under the runner's admission for that
75
+ * route — an announcement for a root occupant the root no longer holds is discarded and said, never delivered to its later occupant.
76
+ */
77
+ export declare function announceShadowedDefinitionServers(args: {
78
+ readonly runner: Pick<RunnerSelfSeat, "emitNotice">;
79
+ readonly leg: string | undefined;
80
+ readonly root: {
81
+ readonly rootSessionId?: string;
82
+ readonly rootSessionIncarnation?: string;
83
+ };
84
+ readonly agent: string | undefined;
85
+ readonly dropped: ReadonlyArray<{
86
+ readonly name: string;
87
+ }>;
88
+ }): void;
64
89
  /**
65
90
  * A definition's own allowed-tools list as its leg's selector reads it: the list it wrote, extended by every tool of each MCP server it
66
91
  * declares (`mcp__<server>__*`) — the servers an agent brings are its own whatever its list names, and its denied list still wins over them.
@@ -1,5 +1,8 @@
1
1
  import { hostSeatsAlong } from "../core/mounted-mcp.js";
2
2
  import { transportKindOf } from "../core/mcp-server-spec.js";
3
+ import { deliverEngineNotice } from "../core/engine-notice.js";
4
+ import { mcpInjectionDroppedNotice } from "../core/mcp-injection-drop.js";
5
+ import { noticeAddressOf } from "../core/leg-identity.js";
3
6
  import { MCP_NAMESPACE, mintNamespacePrefix } from "@sema-agent/primitives";
4
7
  import { TASK_CREATE_TOOL_NAME, TASK_GET_TOOL_NAME, TASK_LIST_TOOL_NAME, TASK_UPDATE_TOOL_NAME } from "../core/tool-catalog-entries.js";
5
8
  export const TEAM_TASK_LIST_TOOL_NAMES = Object.freeze([TASK_CREATE_TOOL_NAME, TASK_GET_TOOL_NAME, TASK_LIST_TOOL_NAME, TASK_UPDATE_TOOL_NAME]);
@@ -33,9 +36,50 @@ export function wakeGate(gate) {
33
36
  const { sharedArtifactReads: _reading, ...kept } = gate;
34
37
  return kept;
35
38
  }
36
- export function withDefinitionServers(handed, own) {
39
+ export function mergeDefinitionServers(handed, own) {
37
40
  const held = new Set((handed ?? []).map((s) => mintNamespacePrefix(MCP_NAMESPACE, s.name)));
38
- return [...(handed ?? []), ...(own ?? []).filter((s) => !held.has(mintNamespacePrefix(MCP_NAMESPACE, s.name)))];
41
+ const kept = [];
42
+ const dropped = [];
43
+ for (const s of own ?? []) {
44
+ if (held.has(mintNamespacePrefix(MCP_NAMESPACE, s.name)))
45
+ dropped.push(s);
46
+ else
47
+ kept.push(s);
48
+ }
49
+ return { servers: [...(handed ?? []), ...kept], dropped };
50
+ }
51
+ export function withDefinitionServers(handed, own) {
52
+ return mergeDefinitionServers(handed, own).servers;
53
+ }
54
+ const announcedShadowedServers = new WeakMap();
55
+ const MAX_SHADOWED_ANNOUNCEMENTS_PER_RUNNER = 4_096;
56
+ export function announceShadowedDefinitionServers(args) {
57
+ const { runner, leg, root, agent, dropped } = args;
58
+ if (dropped.length === 0 || typeof leg !== "string" || leg.length === 0 || typeof agent !== "string" || agent.length === 0)
59
+ return;
60
+ const route = noticeAddressOf({ sourceSessionId: leg, isDelegatedChild: true }, root);
61
+ const sessionId = route.address.sessionId;
62
+ let seen = announcedShadowedServers.get(runner);
63
+ if (seen === undefined) {
64
+ seen = new Set();
65
+ announcedShadowedServers.set(runner, seen);
66
+ }
67
+ for (const s of dropped) {
68
+ const key = JSON.stringify([sessionId, root.rootSessionIncarnation ?? null, agent, s.name]);
69
+ if (seen.has(key))
70
+ continue;
71
+ if (seen.size >= MAX_SHADOWED_ANNOUNCEMENTS_PER_RUNNER) {
72
+ const oldest = seen.values().next().value;
73
+ if (oldest !== undefined)
74
+ seen.delete(oldest);
75
+ }
76
+ seen.add(key);
77
+ const notice = mcpInjectionDroppedNotice({ sessionId, server: s.name, reason: "name_already_mounted", agent });
78
+ if (runner.emitNotice !== undefined)
79
+ runner.emitNotice(notice, route);
80
+ else
81
+ deliverEngineNotice(undefined, notice);
82
+ }
39
83
  }
40
84
  export function definitionAllowTools(def) {
41
85
  const written = def.allowTools ?? undefined;
@@ -24,6 +24,16 @@ export declare function parkedResumeDoor(pr: {
24
24
  }): ParkedResumeGateReading | {
25
25
  readonly refusal: unknown;
26
26
  };
27
+ /**
28
+ * The root task's facts a drive must hand, or the refusal naming the first it lacks: the root's seat (`parentSpecSeat`, minted with
29
+ * `parentSpecSeatOf` from the root's stored spec — the revived leg's instruction family, language, directories and mods are read from
30
+ * it; the row records only the principal and the sandbox), then the root's current mode (`parkedResume.inheritedGate.permissionMode`
31
+ * — the row froze the mode at the park, and the root may have tightened it since). Asked of every drive, an allow and a deny alike;
32
+ * the drive refuses before the consume and rolls the claim back, as for any other fact it lacks.
33
+ */
34
+ export declare function parkedResumeUnhanded(seat: unknown, gate: {
35
+ readonly permissionMode?: PermissionMode;
36
+ } | undefined): Error | undefined;
27
37
  /** The account of the resume's own rejection `e` when the chain raised it for a deny the resume validated on THIS card
28
38
  * (`takeDeniedChainRefusalToken`, the ladder's mark on that one throw, naming the card's token — every code and reason the chain's
29
39
  * rungs refuse with), else `undefined`: its code and reason, as the stopped agent's receipt names them (the refusal's own sentence
@@ -40,6 +40,15 @@ export function parkedResumeDoor(pr) {
40
40
  return { refusal: e };
41
41
  }
42
42
  }
43
+ export function parkedResumeUnhanded(seat, gate) {
44
+ if (seat === undefined) {
45
+ return Object.assign(new Error("the parked agent was not resumed: the drive hands no `parentSpecSeat` — mint it with `parentSpecSeatOf` from the root task's stored spec, so the agent reads its instruction files, language and directories; the approval stays pending"), { code: "config.parent_spec_seat_missing" });
46
+ }
47
+ if (gate?.permissionMode === undefined) {
48
+ return Object.assign(new Error("the parked agent was not resumed: the drive hands no `parkedResume.inheritedGate.permissionMode` — hand the root task's current mode (the row's is the mode at the park); the approval stays pending"), { code: "config.invalid_argument", detail: { field: "inheritedGate" } });
49
+ }
50
+ return undefined;
51
+ }
43
52
  export function unresumableChainRefusal(e, token) {
44
53
  if (takeDeniedChainRefusalToken(e) !== token)
45
54
  return undefined;
@@ -146,6 +146,9 @@ export interface SubagentRetainEntry {
146
146
  * runner, so this adds no new retention class.
147
147
  */
148
148
  runner?: RunnerSelfSeat;
149
+ /** The run that dispatched the child keeps a member ledger (`ToolExecuteContext.runLedgerBook` at the spawn): every cycle's
150
+ * terminal frame carries the child's actions digest, a woken cycle's as the spawn cycle's. */
151
+ actionsDigest?: true;
149
152
  agentName?: string;
150
153
  /** fix-C5: PER-ENTRY retain TTL override (ms). A SESSION-scoped ledger is shared by two purposes with
151
154
  * different windows (failure-evidence retain = FAILED_SESSION_RETAIN_TTL_MS vs a session-scoped bg
@@ -1135,6 +1135,7 @@ export function createSendMessageTool(opts) {
1135
1135
  ...(opts.taskArtifacts !== undefined ? { currentTaskArtifacts: opts.taskArtifacts } : {}),
1136
1136
  ...(ctx.onQuestion !== undefined && row.sessionScoped !== true ? { currentOnQuestion: ctx.onQuestion } : {}),
1137
1137
  currentClamps: clampValuesOf(ctx, ctx.parentSpecSeat),
1138
+ ...(ctx.parentSpecSeat?.project !== undefined ? { currentProject: ctx.parentSpecSeat.project } : {}),
1138
1139
  ...(ctx.autoModeReview !== undefined ? { currentAutoModeReview: ctx.autoModeReview } : {}),
1139
1140
  ...(ctx.spendSeat !== undefined ? { currentSpendSeat: ctx.spendSeat } : {}),
1140
1141
  continuationTier,
@@ -0,0 +1,12 @@
1
+ import type { AgentTool } from "../internal/harness-types.js";
2
+ import type { RunLedger, RunLedgerBook } from "../core/run-ledger.js";
3
+ export declare const SEND_USER_MESSAGE_TOOL_NAME = "SendUserMessage";
4
+ export interface SendUserMessageSeats {
5
+ /** The run's ledger book. */
6
+ readonly book: RunLedgerBook;
7
+ /** Record the ledger snapshot a delivery carries in the run's session log (best effort: a failed write does not refuse the
8
+ * delivery — the snapshot still rides the call's result). */
9
+ readonly record: (ledger: RunLedger) => Promise<void>;
10
+ }
11
+ /** Build the report tool over the run's book. */
12
+ export declare function createSendUserMessageTool(seats: SendUserMessageSeats): AgentTool;
@@ -0,0 +1,67 @@
1
+ import { Type } from "typebox";
2
+ import { defineTool } from "../core/tools.js";
3
+ import { mountRuleFace, toolFace } from "../core/tool-catalog-entries.js";
4
+ import { egressValue } from "../core/untrusted-egress.js";
5
+ export const SEND_USER_MESSAGE_TOOL_NAME = "SendUserMessage";
6
+ const DELIVERED = "Message delivered to user.";
7
+ const CLAIM = Type.Object({
8
+ about: Type.String({ description: "The task id of the member this conclusion is about, as the ledger lists it." }),
9
+ text: Type.String({ description: "The conclusion, in one or two sentences." }),
10
+ basis: Type.Union([Type.Literal("verified"), Type.Literal("relayed"), Type.Literal("inferred")], {
11
+ description: '"verified": you checked it yourself after that member reported (cite the check) — "relayed": it is what the member said, unchecked — "inferred": your own judgment.',
12
+ }),
13
+ verdict: Type.Optional(Type.Union([Type.Literal("confirms"), Type.Literal("refutes"), Type.Literal("partial")], { description: 'For "verified": whether your check confirms, refutes or partly confirms what the member reported.' })),
14
+ evidence: Type.Optional(Type.Array(Type.String(), { maxItems: 8, description: 'For "verified": the id of each check — a tool call you made after the member reported, or another member\'s task id (a verification worker).' })),
15
+ }, { additionalProperties: false });
16
+ const PARAMETERS = Type.Object({
17
+ message: Type.String({ description: "What the person reads. Markdown is fine." }),
18
+ status: Type.Union([Type.Literal("normal"), Type.Literal("proactive")], {
19
+ description: "'normal' when replying to what they just asked; 'proactive' when you are initiating — a phase finished, a blocker surfaced, a result was overturned, you need a decision. Set it honestly; downstream routing uses it.",
20
+ }),
21
+ report: Type.Optional(Type.Object({
22
+ kind: Type.Optional(Type.Union([Type.Literal("start"), Type.Literal("interim"), Type.Literal("final")])),
23
+ claims: Type.Optional(Type.Array(CLAIM, { maxItems: 32 })),
24
+ decisions: Type.Optional(Type.Array(Type.Object({ question: Type.String(), options: Type.Array(Type.String(), { maxItems: 8 }), recommend: Type.Optional(Type.String()) }, { additionalProperties: false }), { maxItems: 8 })),
25
+ next: Type.Optional(Type.String()),
26
+ }, { additionalProperties: false })),
27
+ }, { additionalProperties: false });
28
+ export function createSendUserMessageTool(seats) {
29
+ return defineTool({
30
+ name: SEND_USER_MESSAGE_TOOL_NAME,
31
+ ...toolFace("send-user-message"),
32
+ ruleFace: mountRuleFace("send-user-message"),
33
+ description: "Send a message the person you work for will read. Use it to report — when you start, when a result is overturned, when you are blocked or need a decision, and at the end.\n\n" +
34
+ "`status` labels intent: 'normal' when replying to what they just asked; 'proactive' when you are initiating. Set it honestly; downstream routing uses it.\n\n" +
35
+ "`report.claims` is optional: one entry per conclusion about a member you dispatched (`about` = its task id), each saying what it rests on. " +
36
+ 'A "verified" claim must cite evidence made AFTER that member reported — a tool call of your own, or another member that checked it — and state a verdict; ' +
37
+ "a report whose checks do not hold is not delivered and the reason comes back, so check again or mark the claim \"relayed\". " +
38
+ "Beside every message the engine delivers its own ledger of the members — how each ended, what each did, which ones nobody checked — whatever the message says.",
39
+ parameters: PARAMETERS,
40
+ execute: async (args, ctx) => {
41
+ const a = egressValue("same-principal", args);
42
+ const verdict = seats.book.acceptReport({
43
+ status: a.status,
44
+ message: a.message,
45
+ ...(a.report !== undefined ? { report: { ...(a.report.kind !== undefined ? { kind: a.report.kind } : {}), ...(a.report.claims !== undefined ? { claims: a.report.claims } : {}) } } : {}),
46
+ ...(ctx?.toolCallId !== undefined ? { toolCallId: ctx.toolCallId } : {}),
47
+ });
48
+ if (!verdict.ok) {
49
+ return { content: `Report not sent: ${verdict.why.slice(0, 1200)}`, details: { type: "send-user-message", status: a.status, delivered: false }, isError: true };
50
+ }
51
+ const ledger = seats.book.snapshot({ kind: "report", ...(ctx?.toolCallId !== undefined ? { toolCallId: ctx.toolCallId } : {}) });
52
+ await seats.record(ledger).catch(() => undefined);
53
+ return {
54
+ content: `${DELIVERED}\nLedger: ${ledger.headline}`,
55
+ details: {
56
+ type: "send-user-message",
57
+ status: a.status,
58
+ delivered: true,
59
+ message: a.message,
60
+ ...(a.report?.kind !== undefined ? { kind: a.report.kind } : {}),
61
+ ...(a.report !== undefined ? { report: a.report } : {}),
62
+ ledger,
63
+ },
64
+ };
65
+ },
66
+ });
67
+ }
@@ -18,6 +18,7 @@
18
18
  * Everything is BOUNDED (step ring ≤ {@link STEP_CAP}, fields truncated): a pathological child cannot balloon the parent's view.
19
19
  */
20
20
  import type { TaskEvent } from "../core/types.js";
21
+ import { type SubagentActions } from "../core/actions-digest.js";
21
22
  /** One completed tool step in the child's tail — enough for the parent to say "you stopped at X". */
22
23
  export interface SubagentStep {
23
24
  /** Tool name (or its distinct {@link ToolSpec.label} when set). */
@@ -49,6 +50,11 @@ export declare class SubagentStepRecorder {
49
50
  private readonly steps;
50
51
  private readonly pending;
51
52
  private readonly edits;
53
+ /** The whole-stream counters the actions digest reads (never the ring): calls by tool, and the shell commands. */
54
+ private readonly toolCounts;
55
+ private toolCallTotal;
56
+ private readonly commands;
57
+ private commandsPast;
52
58
  private action;
53
59
  private actionTool;
54
60
  private actionTarget;
@@ -76,6 +82,9 @@ export declare class SubagentStepRecorder {
76
82
  recentSteps(): SubagentStep[] | undefined;
77
83
  /** Files the child mutated with edit counts; undefined if none. */
78
84
  editedFiles(): SubagentEditedFile[] | undefined;
85
+ /** The child's whole-stream actions digest ({@link SubagentActions}) — present even when the child called no tool (a
86
+ * zero digest is the fact a self-report of work is read against). */
87
+ actions(): SubagentActions;
79
88
  /** The child's most recent tool intent as one human line ("Bash npm test", "Edit src/x.ts"); undefined if none. */
80
89
  currentAction(): string | undefined;
81
90
  /** {@link currentAction} pre-formatted into a fleet-view Progress-section
@@ -3,6 +3,16 @@ import { renderContentBlock } from "../internal/llm.js";
3
3
  import { cutAt, redactThenCut } from "../core/untrusted-egress.js";
4
4
  import { isProtectedWrite } from "../core/tool-registry.js";
5
5
  import { writeTargetPath } from "../tools/fs/safety.js";
6
+ import { ACTIONS_COMMANDS_CAP, ACTIONS_TOOLS_CAP } from "../core/actions-digest.js";
7
+ const SHELL_TOOL_NAME = "Bash";
8
+ function shellExitCode(structured, output) {
9
+ const s = structured;
10
+ if (s !== null && typeof s === "object" && typeof s.exitCode === "number" && Number.isInteger(s.exitCode))
11
+ return s.exitCode;
12
+ const text = typeof output === "string" ? output : Array.isArray(output) ? output.map(renderContentBlock).join("\n") : "";
13
+ const m = /^exit code: (-?\d+)/.exec(text);
14
+ return m !== null ? Number(m[1]) : undefined;
15
+ }
6
16
  export const STEP_CAP = 10;
7
17
  const FIELD_MAX = 80;
8
18
  const EDITED_FILES_CAP = 32;
@@ -55,6 +65,10 @@ export class SubagentStepRecorder {
55
65
  steps = [];
56
66
  pending = new Map();
57
67
  edits = new Map();
68
+ toolCounts = new Map();
69
+ toolCallTotal = 0;
70
+ commands = [];
71
+ commandsPast = 0;
58
72
  action;
59
73
  actionTool;
60
74
  actionTarget;
@@ -71,6 +85,10 @@ export class SubagentStepRecorder {
71
85
  this.steps.length = 0;
72
86
  this.pending.clear();
73
87
  this.edits.clear();
88
+ this.toolCounts.clear();
89
+ this.toolCallTotal = 0;
90
+ this.commands.length = 0;
91
+ this.commandsPast = 0;
74
92
  this.action = undefined;
75
93
  this.actionTool = undefined;
76
94
  this.actionTarget = undefined;
@@ -111,6 +129,16 @@ export class SubagentStepRecorder {
111
129
  this.steps.push({ tool, target, outcome });
112
130
  if (this.steps.length > STEP_CAP)
113
131
  this.steps.shift();
132
+ this.toolCallTotal += 1;
133
+ this.toolCounts.set(e.toolName, (this.toolCounts.get(e.toolName) ?? 0) + 1);
134
+ if (e.toolName === SHELL_TOOL_NAME) {
135
+ if (this.commands.length < ACTIONS_COMMANDS_CAP) {
136
+ const exitCode = shellExitCode(e.structured, e.output);
137
+ this.commands.push({ command: target, ...(exitCode !== undefined ? { exitCode } : {}) });
138
+ }
139
+ else
140
+ this.commandsPast += 1;
141
+ }
114
142
  const editPath = start?.edit;
115
143
  if (editPath !== undefined && !e.isError) {
116
144
  if (this.edits.has(editPath))
@@ -129,6 +157,16 @@ export class SubagentStepRecorder {
129
157
  editedFiles() {
130
158
  return this.edits.size > 0 ? [...this.edits].map(([path, edits]) => ({ path, edits })) : undefined;
131
159
  }
160
+ actions() {
161
+ const byTool = [...this.toolCounts].map(([tool, calls]) => ({ tool, calls })).sort((a, b) => b.calls - a.calls).slice(0, ACTIONS_TOOLS_CAP);
162
+ return {
163
+ toolCalls: this.toolCallTotal,
164
+ byTool,
165
+ commands: this.commands.map((c) => ({ ...c })),
166
+ ...(this.commandsPast > 0 ? { commandsUnlisted: this.commandsPast } : {}),
167
+ filesEdited: this.editedFiles() ?? [],
168
+ };
169
+ }
132
170
  currentAction() {
133
171
  return this.action;
134
172
  }
@@ -433,6 +433,8 @@ export declare function createSubagentResume(deps: {
433
433
  * has no live face and its `AskUserQuestion` mount falls back to the automatic criterion's other legs
434
434
  * — never a call into a closed surface. */
435
435
  currentOnQuestion?: import("../core/ask-question.js").OnQuestion;
436
+ /** The RESUMING caller's own project seat (`ParentSpecSeat.project`): a woken cycle runs under its WAKER's, as a tier-3 revival does; the spawn snapshot's is not kept (absent ⇒ none). */
437
+ currentProject?: import("../core/project-seat.js").ProjectSeat;
436
438
  /** The RESUMING caller's own tighten-only CLAMPS (its trusted `ToolExecuteContext` seats), folded ON TOP
437
439
  * of the frozen snapshot so a wake can only ever narrow the child. Without this the snapshot alone
438
440
  * decides: a child spawned by a write-capable, interactive, long-lived run could be woken BY a
@@ -16,7 +16,7 @@ import { sanitizedTtlMs } from "../core/runner/park-commit.js";
16
16
  import { ADVISOR_FORK_SENTENCE, ADVISOR_TOOL_NAME } from "../core/advisor-verdict.js";
17
17
  import { applyClampSeats, assertClampRecord, childClampSeats, clampSeatsOf, clampSourceOf, clampValuesOf, engineHeadlessLegSeats, foldClampSources, postureUnderClamps, readClampFloor } from "../core/child-clamp-seats.js";
18
18
  import { assertNoRetiredKeys } from "../core/retired-keys.js";
19
- import { parkedResumeDoor, spawnDepthUnknownNotice, unresumableChainRefusal } from "./parked-resume-drive.js";
19
+ import { parkedResumeDoor, parkedResumeUnhanded, spawnDepthUnknownNotice, unresumableChainRefusal } from "./parked-resume-drive.js";
20
20
  import { stripSpawnTurnQuestionFace } from "../core/ask-question.js";
21
21
  import { withDelegationProvenance } from "../core/tool-policy.js";
22
22
  import { errorResult } from "../core/tools.js";
@@ -104,7 +104,7 @@ import { childOwnerKeys, parkCompletionNotify, runningBackgroundUnder } from "./
104
104
  import { placesSubagentTranscripts, subagentTranscriptPlacement } from "./subagent-transcript-placement.js";
105
105
  import { OUTPUT_TOOL_NAME, mountRuleFace, toolFace } from "../core/tool-catalog-entries.js";
106
106
  import { canonicalNameValue } from "../core/permission-rule-model.js";
107
- import { definitionAllowTools, definitionSelectorLayer, inheritedChildPool, inheritedHostSeats, inheritedMcpDeclarations, selectorLayerOf, wakeGate, withDefinitionServers, withoutWakerSeats } from "./inherited-tool-pool.js";
107
+ import { announceShadowedDefinitionServers, definitionAllowTools, definitionSelectorLayer, inheritedChildPool, inheritedHostSeats, inheritedMcpDeclarations, mergeDefinitionServers, selectorLayerOf, wakeGate, withoutWakerSeats } from "./inherited-tool-pool.js";
108
108
  import { codedRefusal, readMember, thrownMarksOf, thrownText } from "../core/thrown-value.js";
109
109
  import { GIT_READ_ONLY } from "../core/git-read-only.js";
110
110
  const BG_AGENT_RESULT_MAX = 4_000;
@@ -384,6 +384,22 @@ const ccElapsedTag = (ms) => {
384
384
  };
385
385
  const ccCompletionText = (desc, settled, rawStatus, elapsedMs) => `Agent "${desc}" ${settled === "killed" ? "stopped" : settled === "completed" ? "finished" : rawStatus}${ccElapsedTag(elapsedMs)}`;
386
386
  const SYNC_ESCAPE_SENTENCE = "Pass `run_in_background: false` for a synchronous run when you need the result before continuing (a named agent always runs in the background).";
387
+ function reportInCallMember(ctx, member) {
388
+ const taskId = member.taskId ?? ctx.toolCallId;
389
+ if (taskId !== undefined) {
390
+ ctx.runLedgerBook?.memberSettled({
391
+ taskId,
392
+ kind: "subagent",
393
+ label: typeof member.description === "string" ? member.description : "",
394
+ ...(member.name !== undefined ? { name: member.name } : {}),
395
+ outcome: member.outcome,
396
+ ...(member.selfReport !== undefined ? { selfReport: member.selfReport } : {}),
397
+ actions: member.actions,
398
+ ...(ctx.toolCallId !== undefined ? { toolCallId: ctx.toolCallId } : {}),
399
+ });
400
+ }
401
+ return member.outcome;
402
+ }
387
403
  export const AGENT_RAN_SYNC_NO_CHANNEL_NOTE = "note: this agent ran synchronously — no completion would come back from a background agent on this mount, so the background lane is not used here.";
388
404
  function continuationSentence(toolName, durableRevival, forkOffered) {
389
405
  return (`Where the SendMessage tool is mounted, use it with the agent's ID or name to message a RUNNING agent, or — when session retention${durableRevival ? " or durable named-agent revival" : ""} is enabled — ` +
@@ -630,7 +646,7 @@ export function createSubagentResume(deps) {
630
646
  const resumeResidual = () => {
631
647
  const recentSteps = resumeStepRecorder.recentSteps();
632
648
  const editedFiles = resumeStepRecorder.editedFiles();
633
- return { ...(recentSteps !== undefined && recentSteps.length > 0 ? { recentSteps } : {}), ...(editedFiles !== undefined && editedFiles.length > 0 ? { editedFiles } : {}) };
649
+ return { ...(recentSteps !== undefined && recentSteps.length > 0 ? { recentSteps } : {}), ...(editedFiles !== undefined && editedFiles.length > 0 ? { editedFiles } : {}), ...(entry.actionsDigest === true ? { actions: resumeStepRecorder.actions() } : {}) };
634
650
  };
635
651
  const childRunner = entry.runner ?? deps.runner;
636
652
  let stream;
@@ -733,10 +749,11 @@ export function createSubagentResume(deps) {
733
749
  });
734
750
  });
735
751
  releaseCycleSlot = deps.entryGate?.occupy(reviveCycle !== undefined ? "registered" : "local") ?? noopRelease;
736
- const { spendParent: _spawnerAccount, ...snapshotSeats } = entry.internalsSnapshot;
737
- void _spawnerAccount;
752
+ const { spendParent: _spawnerAccount, parentProject: _spawnersProject, ...snapshotSeats } = entry.internalsSnapshot;
753
+ void _spawnerAccount, void _spawnersProject;
738
754
  stream = childRunner.runTaskStream(resumeSpec, undefined, {
739
755
  ...snapshotSeats,
756
+ ...(deps.currentProject !== undefined ? { parentProject: deps.currentProject } : {}),
740
757
  ...(deps.currentSpendSeat !== undefined ? { spendParent: { seat: deps.currentSpendSeat, link: "session" } } : {}),
741
758
  ...(deps.registry !== undefined && deps.taskId !== undefined ? { onSubtreeActivity: rowActivitySeat(deps.registry, deps.taskId) } : {}),
742
759
  ...inheritedHostSeats(deps.currentMcpHostSeats, resumeSpec.mcp ?? []),
@@ -2058,7 +2075,9 @@ function buildSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
2058
2075
  const childCeiling = ctx.toolSelector?.layers ?? [];
2059
2076
  const mountedMcpNow = ctx.mountedMcp?.();
2060
2077
  const inheritedMcp = opts.tools === undefined && extraToolsNote === undefined && mountedMcpNow !== undefined ? inheritedMcpDeclarations(mountedMcpNow, compileToolSelector([...childCeiling, childOwnLayer])) : [];
2061
- const childMcp = withDefinitionServers(inheritedMcp, def?.mcp);
2078
+ const mergedMcp = mergeDefinitionServers(inheritedMcp, def?.mcp);
2079
+ announceShadowedDefinitionServers({ runner: opts.runner, leg: ctx.sessionId, root: { rootSessionId: ctx.rootSessionId ?? ctx.sessionId, rootSessionIncarnation: ctx.rootSessionIncarnation }, agent: def?.name, dropped: mergedMcp.dropped });
2080
+ const childMcp = mergedMcp.servers;
2062
2081
  const childTools = [...childPool];
2063
2082
  const childRoleBase = roleBaseOf([def !== undefined ? { systemPrompt: def.systemPrompt } : undefined, { promptRole: opts.promptRole, systemPrompt: opts.systemPrompt }]);
2064
2083
  const childSystemPrompt = childRoleBase?.systemPrompt;
@@ -2307,7 +2326,7 @@ function buildSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
2307
2326
  const residualFields = () => {
2308
2327
  const recentSteps = stepRecorder.recentSteps();
2309
2328
  const editedFiles = stepRecorder.editedFiles();
2310
- return { ...(recentSteps ? { recentSteps } : {}), ...(editedFiles ? { editedFiles } : {}) };
2329
+ return { ...(recentSteps ? { recentSteps } : {}), ...(editedFiles ? { editedFiles } : {}), ...(ctx.runLedgerBook !== undefined ? { actions: stepRecorder.actions() } : {}) };
2311
2330
  };
2312
2331
  const entryCapPoolAnchor = backgroundRegistry ?? opts;
2313
2332
  const entryCaps = ctx.delegationEntryCaps ?? { maxConcurrent: DELEGATION_MAX_CONCURRENT_DEFAULT, maxCumulativePerSession: DELEGATION_MAX_PER_SESSION_DEFAULT };
@@ -2358,7 +2377,7 @@ function buildSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
2358
2377
  isDelegatedChild: true,
2359
2378
  objectiveAuthor: reviveClaim !== undefined ? "peer" : "parent_model",
2360
2379
  ...(childPosture !== undefined ? { parentInteractionPosture: childPosture } : {}),
2361
- ...(parentSpecSeat?.projectId !== undefined ? { parentProjectId: parentSpecSeat.projectId } : {}),
2380
+ ...(parentSpecSeat?.project !== undefined ? { parentProject: parentSpecSeat.project } : {}),
2362
2381
  ...(reviveClaim === undefined
2363
2382
  ? {
2364
2383
  ...(liveCaptureFloor?.optedOut === true ? { memoryCaptureFloor: true } : {}),
@@ -2478,6 +2497,7 @@ function buildSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
2478
2497
  })());
2479
2498
  let entry = ledger.register(ctx.toolCallId, {
2480
2499
  childSessionId,
2500
+ ...(ctx.runLedgerBook !== undefined ? { actionsDigest: true } : {}),
2481
2501
  rowVerified,
2482
2502
  declarations: holdKeeperDeclarations(opts.runner)(plainSpec),
2483
2503
  runner: opts.runner,
@@ -2547,6 +2567,7 @@ function buildSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
2547
2567
  const { signal: _spawnSignal, ...plainSpec } = failedRetainStrip.spec;
2548
2568
  const entry = ledger.register(ctx.toolCallId, {
2549
2569
  childSessionId,
2570
+ ...(ctx.runLedgerBook !== undefined ? { actionsDigest: true } : {}),
2550
2571
  rowVerified: () => true,
2551
2572
  declarations: holdKeeperDeclarations(opts.runner)(plainSpec),
2552
2573
  runner: opts.runner,
@@ -3121,7 +3142,9 @@ function buildSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
3121
3142
  catch {
3122
3143
  }
3123
3144
  const wt = await finishWorktree();
3124
- return { isError: true, content: `Fork failed: the forked run threw (${childThrownText(e)}).${wt ? `\n${wt}` : ""}`, details: thrownMarksOf(childRejection(e)) ?? {} };
3145
+ const rejection = childRejection(e);
3146
+ reportInCallMember(ctx, { taskId: forkedId, description: a.description, outcome: memberOutcomeOf("subagent", "live", { from: "ended", status: "failed", ...((code) => (code !== undefined ? { code } : {}))(childRowCode(childFailureOf(rejection))) }), actions: stepRecorder.actions() });
3147
+ return { isError: true, content: `Fork failed: the forked run threw (${childThrownText(e)}).${wt ? `\n${wt}` : ""}`, details: thrownMarksOf(rejection) ?? {} };
3125
3148
  }
3126
3149
  finally {
3127
3150
  syncForkAdmission.release();
@@ -3140,6 +3163,7 @@ function buildSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
3140
3163
  const forkFace = childTerminalFace(forkChild.terminal);
3141
3164
  const forkErr = classifySubagentError(forkChild.terminal);
3142
3165
  const forkOutcome = memberOutcomeOf("subagent", "live", { from: "result", result: forkChild, parked: false });
3166
+ reportInCallMember(ctx, { taskId: forkChild.taskId, description: a.description, outcome: forkOutcome, selfReport: forkChild.result, actions: stepRecorder.actions() });
3143
3167
  const forkLines = [
3144
3168
  ...(forkHandbackLead !== undefined ? [forkHandbackLead, ""] : []),
3145
3169
  `[Sub-agent report · ${FORK_SUBAGENT_TYPE}${a.description ? ` · ${String(a.description)}` : ""}] (forked session …${forkedId.slice(-8)})`,
@@ -3611,6 +3635,9 @@ function buildSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
3611
3635
  if ("refusal" in door)
3612
3636
  return rollbackAndThrow(door.refusal);
3613
3637
  const gateSeat = door.seat;
3638
+ const unhanded = parkedResumeUnhanded(parentSpecSeat, gateSeat);
3639
+ if (unhanded !== undefined)
3640
+ return rollbackAndThrow(unhanded);
3614
3641
  if (floorRefusal !== undefined)
3615
3642
  return rollbackAndThrow(Object.assign(new Error(`the agent was not resumed: ${inlineUntrusted(floorRefusal, 400)}, so the restrictions it ran under cannot be held on a new cycle`), { code: "revive.policy_floor_unreadable" }));
3616
3643
  try {
@@ -4070,6 +4097,8 @@ function buildSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
4070
4097
  };
4071
4098
  }
4072
4099
  let child;
4100
+ const ledgerMember = (taskId, outcome, selfReport) => reportInCallMember(ctx, { taskId, description: a.description, name: agentName, outcome, selfReport, actions: stepRecorder.actions() });
4101
+ const ledgerThrown = (e, retained) => { const rejection = childRejection(e); ledgerMember(retained?.childSessionId ?? ctx.toolCallId, memberOutcomeOf("subagent", "live", { from: "ended", status: "failed", ...((code) => (code !== undefined ? { code } : {}))(childRowCode(childFailureOf(rejection))) })); return rejection; };
4073
4102
  const syncEntryGate = await openEntryGate();
4074
4103
  if (ctx.signal?.aborted) {
4075
4104
  await cancelObserver();
@@ -4107,6 +4136,7 @@ function buildSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
4107
4136
  entryGate: syncEntryGate,
4108
4137
  ...(opts.onObserverError !== undefined ? { onNotifyError: (f) => opts.onObserverError?.(f.error, { site: f.site }) } : {}),
4109
4138
  ...(ctx.onQuestion !== undefined ? { currentOnQuestion: ctx.onQuestion } : {}),
4139
+ ...(ctx.parentSpecSeat?.project !== undefined ? { currentProject: ctx.parentSpecSeat.project } : {}),
4110
4140
  ...(ctx.autoModeReview !== undefined ? { currentAutoModeReview: ctx.autoModeReview } : {}),
4111
4141
  ...(ctx.spendSeat !== undefined ? { currentSpendSeat: ctx.spendSeat } : {}),
4112
4142
  currentMcpHostSeats: ctx.mountedMcp?.().hostSeats,
@@ -4124,7 +4154,7 @@ function buildSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
4124
4154
  }
4125
4155
  catch (e) {
4126
4156
  await settleObserver("failed");
4127
- throw childRejection(e);
4157
+ throw ledgerThrown(e, retainEntry);
4128
4158
  }
4129
4159
  finally {
4130
4160
  settleResolve();
@@ -4141,7 +4171,7 @@ function buildSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
4141
4171
  child = await opts.runner.runTask(buildChildSpec(ctx.signal), childInternals);
4142
4172
  }
4143
4173
  catch (e) {
4144
- throw childRejection(e);
4174
+ throw ledgerThrown(e, undefined);
4145
4175
  }
4146
4176
  }
4147
4177
  }
@@ -4169,7 +4199,7 @@ function buildSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
4169
4199
  if (isDurablePause(child.terminal)) {
4170
4200
  if (retainEntry)
4171
4201
  ctx.subagentRetain?.abandon(ctx.toolCallId, "durable_pause");
4172
- return durablePauseDelegationReport(def ? ` · ${def.name}` : "", child.terminal, memberOutcomeOf("subagent", "live", { from: "result", result: child }));
4202
+ return durablePauseDelegationReport(def ? ` · ${def.name}` : "", child.terminal, ledgerMember(child.taskId, memberOutcomeOf("subagent", "live", { from: "result", result: child }), child.result));
4173
4203
  }
4174
4204
  let failureRetained = false;
4175
4205
  if (!retainEntry && namesVerifiedSession(child)) {
@@ -4189,6 +4219,7 @@ function buildSubagentToolNode(opts, depth, excluded, extraToolsBudget) {
4189
4219
  return isolationUnavailable(WORKTREE_UNAVAILABLE.notHonored);
4190
4220
  const errClass = classifySubagentError(child.terminal);
4191
4221
  const childOutcome = memberOutcomeOf("subagent", "live", { from: "result", result: child, parked: false });
4222
+ ledgerMember(child.taskId, childOutcome, child.result);
4192
4223
  const lines = [
4193
4224
  ...((lead) => (lead !== undefined ? [lead, ""] : []))(handbackLeadOf(handback)),
4194
4225
  `[Sub-agent report${def ? ` · ${def.name}` : ""}${a.description ? ` · ${String(a.description)}` : ""}]`,
@@ -15,6 +15,7 @@ import { chargeFirstLeg, compositionAccount, compositionExhausted, laterLegTurns
15
15
  import { recipeContinuationLeg } from "../core/input-author.js";
16
16
  import { readIndependence, verifierIsImplementerNotice } from "./verifier-independence.js";
17
17
  import { withOpeningObjective } from "../core/task-spec-members.js";
18
+ import { screenProjectSeat } from "../core/project-seat.js";
18
19
  import { withLegIdentity } from "./leg-label.js";
19
20
  export const VERIFICATION_PROMPT = `You are a verification specialist. Your job is NOT to confirm the implementation works — it is to try to BREAK it.
20
21
 
@@ -115,9 +116,21 @@ function verifierObjective(originalObjective, impl, evidence) {
115
116
  return parts.join("\n\n");
116
117
  }
117
118
  export async function verifyCompleted(runner, result, specBase, objective, config, internals) {
118
- return verifyCompletedPlaced(runner, result, specBase, objective, config, internals, compositionPlacement(internals, identityMembersOf(specBase)), compositionAccount(specBase, internals?.spendParent));
119
+ return verifyCompletedPlaced(runner, result, specBase, objective, config, internals, compositionPlacement(internals, identityMembersOf(specBase)), compositionAccount(specBase, internals?.spendParent), gateProject(specBase).project);
119
120
  }
120
- async function verifyCompletedPlaced(runner, result, specBase, objective, config, internals, placement, composition) {
121
+ function gateProject(spec) {
122
+ let screened;
123
+ try {
124
+ screened = screenProjectSeat(Reflect.get(spec, "project"));
125
+ }
126
+ catch {
127
+ return { spec };
128
+ }
129
+ if (!screened.ok || screened.seat === undefined)
130
+ return { spec };
131
+ return { spec: Object.create(spec, { project: { value: screened.seat, enumerable: true } }), project: screened.seat };
132
+ }
133
+ async function verifyCompletedPlaced(runner, result, specBase, objective, config, internals, placement, composition, project) {
121
134
  refuseUnhonorableInternals(internals, "door");
122
135
  if (result.terminal.kind !== "completed") {
123
136
  return { ...result, verification: { verdict: "unverified", unverifiedReason: "impl_incomplete", rounds: 0, findings: [] } };
@@ -208,7 +221,7 @@ async function verifyCompletedPlaced(runner, result, specBase, objective, config
208
221
  ...(specBase.clientContext !== undefined ? { clientContext: { ...specBase.clientContext } } : {}),
209
222
  ...(specBase.promptLean !== undefined ? { promptLean: specBase.promptLean } : {}),
210
223
  ...(specBase.promptLocale !== undefined ? { promptLocale: specBase.promptLocale } : {}),
211
- ...(specBase.projectId !== undefined ? { projectId: specBase.projectId } : {}),
224
+ ...(project !== undefined ? { project } : {}),
212
225
  signal: specBase.signal,
213
226
  }, projectContextSeat);
214
227
  const v = await runner.runTask(verifierSpec, withLegIdentity(verifierLegInternals(round), { kind: "verifier", round }, internals));
@@ -308,7 +321,7 @@ async function verifyCompletedPlaced(runner, result, specBase, objective, config
308
321
  const { blockReadsOutsideRoots: _readBlockOffTheResult, ...withoutReadBlock } = turns.spec ?? specBase;
309
322
  const { sandbox: _sandboxOffTheResult, ...continuedConfig } = withoutReadBlock;
310
323
  const fixLegSpec = {
311
- ...placement.laterIdentity(withOpeningObjective({ ...continuedConfig, ...continuedSandbox() }, fixObjective(outcome.findings), current.sessionId)),
324
+ ...placement.laterIdentity(withOpeningObjective({ ...continuedConfig, ...continuedSandbox(), ...(project !== undefined ? { project } : {}) }, fixObjective(outcome.findings), current.sessionId)),
312
325
  ...childClampSeats({
313
326
  ...clampSourceOf(specBase),
314
327
  readFace: foldedRootsFace ? "roots" : specBase.readFace,
@@ -335,23 +348,25 @@ export async function runWithVerification(runner, implSpec, config = {}, interna
335
348
  refuseUnhonorableInternals(internals, "door");
336
349
  const placement = compositionPlacement(internals, identityMembersOf(implSpec));
337
350
  const composition = compositionAccount(implSpec, internals?.spendParent);
338
- const result = await runner.runTask(implSpec, withLegIdentity(onComposition(placement.firstLeg, composition), IMPL_LEG, internals));
351
+ const gate = gateProject(implSpec);
352
+ const result = await runner.runTask(gate.spec, withLegIdentity(onComposition(placement.firstLeg, composition), IMPL_LEG, internals));
339
353
  if (isDurablePause(result.terminal)) {
340
354
  return { ...mapNestedSuspend(result, GATE_RESUME_ENTRY), verification: { verdict: "unverified", unverifiedReason: pauseFamily(result.terminal), rounds: 0, findings: [] } };
341
355
  }
342
356
  refuseUnhonorableInternals(internals, "before_leg");
343
- return verifyCompletedPlaced(runner, result, implSpec, implSpec.objective, config, internals, placement, composition);
357
+ return verifyCompletedPlaced(runner, result, implSpec, implSpec.objective, config, internals, placement, composition, gate.project);
344
358
  }
345
359
  export async function resumeWithVerification(runner, token, outcome, taskConfig, objective, config = {}, internals) {
346
360
  refuseUnhonorableInternals(internals, "door");
347
361
  const placement = compositionPlacement(internals, identityMembersOf(taskConfig));
348
362
  const composition = compositionAccount(taskConfig, internals?.spendParent);
349
- const result = await runner.resume(token, outcome, taskConfig, withLegIdentity(onComposition(placement.firstLeg, composition), IMPL_LEG, internals, "resumeStream"));
363
+ const gate = gateProject(taskConfig);
364
+ const result = await runner.resume(token, outcome, gate.spec, withLegIdentity(onComposition(placement.firstLeg, composition), IMPL_LEG, internals, "resumeStream"));
350
365
  if (isDurablePause(result.terminal)) {
351
366
  return { ...mapNestedSuspend(result, GATE_RESUME_ENTRY), verification: { verdict: "unverified", unverifiedReason: pauseFamily(result.terminal), rounds: 0, findings: [] } };
352
367
  }
353
368
  refuseUnhonorableInternals(internals, "before_leg");
354
- return verifyCompletedPlaced(runner, result, taskConfig, objective, config, internals, placement, composition);
369
+ return verifyCompletedPlaced(runner, result, taskConfig, objective, config, internals, placement, composition, gate.project);
355
370
  }
356
371
  export async function runDeveloperTask(runner, spec, config = {}, internals) {
357
372
  const implSpec = namesRoleBase(spec) ? spec : { ...spec, promptRole: "code" };