@yanlinglabs/winter-agent-runtime 0.0.27

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 (311) hide show
  1. package/LICENSE +21 -0
  2. package/NOTICE +41 -0
  3. package/README.md +64 -0
  4. package/dist/checkpoint/file-history.d.ts +81 -0
  5. package/dist/checkpoint/rewind.d.ts +55 -0
  6. package/dist/checkpoint/seam.d.ts +47 -0
  7. package/dist/checkpoint/sink.d.ts +66 -0
  8. package/dist/commands/builtins-listing.d.ts +40 -0
  9. package/dist/commands/resolver.d.ts +103 -0
  10. package/dist/commands/seam.d.ts +53 -0
  11. package/dist/compaction/controller.d.ts +23 -0
  12. package/dist/compaction/retention.d.ts +35 -0
  13. package/dist/compaction/seam.d.ts +115 -0
  14. package/dist/compaction/summarizer.d.ts +79 -0
  15. package/dist/context/agent-listing.d.ts +39 -0
  16. package/dist/context/assembler.d.ts +46 -0
  17. package/dist/context/attachments.d.ts +104 -0
  18. package/dist/context/dynamic-sections.d.ts +31 -0
  19. package/dist/context/git-fixture.d.ts +18 -0
  20. package/dist/context/git-status.d.ts +16 -0
  21. package/dist/context/imports.d.ts +22 -0
  22. package/dist/context/injection.d.ts +53 -0
  23. package/dist/context/memory-key.d.ts +46 -0
  24. package/dist/context/memory.d.ts +28 -0
  25. package/dist/context/minimal-prompt.d.ts +5 -0
  26. package/dist/context/output-styles.d.ts +68 -0
  27. package/dist/context/plan-mode.d.ts +29 -0
  28. package/dist/context/request-layout.d.ts +138 -0
  29. package/dist/context/rules.d.ts +63 -0
  30. package/dist/context/seam.d.ts +136 -0
  31. package/dist/context/tool-epoch.d.ts +118 -0
  32. package/dist/context/winter-code-preset.d.ts +39 -0
  33. package/dist/context/winter-md.d.ts +81 -0
  34. package/dist/embedded-host.d.ts +48 -0
  35. package/dist/embedded-host.js +155 -0
  36. package/dist/embedded-protocol.d.ts +44 -0
  37. package/dist/embedded-worker.d.ts +1 -0
  38. package/dist/embedded-worker.js +74 -0
  39. package/dist/embedded.d.ts +34 -0
  40. package/dist/embedded.js +9 -0
  41. package/dist/engine.d.ts +1298 -0
  42. package/dist/hooks/additional-context.d.ts +21 -0
  43. package/dist/hooks/bounds.d.ts +6 -0
  44. package/dist/hooks/bridge-invoker.d.ts +3 -0
  45. package/dist/hooks/command-invoker.d.ts +52 -0
  46. package/dist/hooks/from-config.d.ts +31 -0
  47. package/dist/hooks/hook-stage.d.ts +25 -0
  48. package/dist/hooks/input-validator.d.ts +6 -0
  49. package/dist/hooks/reducer.d.ts +74 -0
  50. package/dist/hooks/registry.d.ts +33 -0
  51. package/dist/hooks/runner.d.ts +105 -0
  52. package/dist/index-584yahed.js +6037 -0
  53. package/dist/index-97t2rmtf.js +42 -0
  54. package/dist/index-9qgkpv56.js +27183 -0
  55. package/dist/index-bef62z3r.js +437 -0
  56. package/dist/index-rkhh0457.js +187 -0
  57. package/dist/index.d.ts +37 -0
  58. package/dist/index.js +353 -0
  59. package/dist/main.d.ts +1 -0
  60. package/dist/mcp/client.d.ts +105 -0
  61. package/dist/mcp/control-seam.d.ts +25 -0
  62. package/dist/mcp/control.d.ts +5 -0
  63. package/dist/mcp/elicitation.d.ts +35 -0
  64. package/dist/mcp/env.d.ts +12 -0
  65. package/dist/mcp/lifecycle.d.ts +142 -0
  66. package/dist/mcp/output-cap.d.ts +15 -0
  67. package/dist/mcp/state.d.ts +24 -0
  68. package/dist/mcp/test-fixtures.d.ts +88 -0
  69. package/dist/mcp/transports/__fixtures__/stdio-server.d.ts +1 -0
  70. package/dist/mcp/transports/http.d.ts +5 -0
  71. package/dist/mcp/transports/sdk.d.ts +5 -0
  72. package/dist/mcp/transports/sse.d.ts +3 -0
  73. package/dist/mcp/transports/stdio.d.ts +35 -0
  74. package/dist/mcp/winter-server.d.ts +2 -0
  75. package/dist/messaging/reference-adapter.d.ts +88 -0
  76. package/dist/messaging/router.d.ts +8 -0
  77. package/dist/paths/project-dir-name.d.ts +2 -0
  78. package/dist/paths/temp.d.ts +25 -0
  79. package/dist/permissions/approvals.d.ts +107 -0
  80. package/dist/permissions/auto/caches.d.ts +53 -0
  81. package/dist/permissions/auto/config.d.ts +37 -0
  82. package/dist/permissions/auto/engine.d.ts +74 -0
  83. package/dist/permissions/auto/envelope.d.ts +45 -0
  84. package/dist/permissions/auto/inheritance.d.ts +27 -0
  85. package/dist/permissions/edit-recognition.d.ts +30 -0
  86. package/dist/permissions/evaluator.d.ts +284 -0
  87. package/dist/permissions/file-rules.d.ts +384 -0
  88. package/dist/permissions/grammar.d.ts +113 -0
  89. package/dist/permissions/paths.d.ts +32 -0
  90. package/dist/permissions/policy-state.d.ts +64 -0
  91. package/dist/permissions/prompt-stage.d.ts +3 -0
  92. package/dist/permissions/protected.d.ts +54 -0
  93. package/dist/permissions/ruleset.d.ts +134 -0
  94. package/dist/permissions/shell-structure.d.ts +41 -0
  95. package/dist/plugins/bundle.d.ts +100 -0
  96. package/dist/plugins/installed.d.ts +30 -0
  97. package/dist/plugins/loader.d.ts +56 -0
  98. package/dist/plugins/manifest.d.ts +115 -0
  99. package/dist/production-wiring.d.ts +340 -0
  100. package/dist/protocol/channel.d.ts +22 -0
  101. package/dist/provider/advisor-route.d.ts +47 -0
  102. package/dist/provider/bridge.d.ts +124 -0
  103. package/dist/provider/classifier/model-classifier.d.ts +82 -0
  104. package/dist/provider/classifier/prompt.d.ts +62 -0
  105. package/dist/provider/classifier/verdict-schema.d.ts +83 -0
  106. package/dist/provider/credential-api.d.ts +160 -0
  107. package/dist/provider/family-listing.d.ts +27 -0
  108. package/dist/provider/first-party.d.ts +4 -0
  109. package/dist/provider/keychain-store.d.ts +59 -0
  110. package/dist/provider/lean-prompt.d.ts +7 -0
  111. package/dist/provider/mock.d.ts +55 -0
  112. package/dist/provider/scenario-fake.d.ts +96 -0
  113. package/dist/provider/selection.d.ts +115 -0
  114. package/dist/provider/session-provider.d.ts +426 -0
  115. package/dist/provider/slots.d.ts +120 -0
  116. package/dist/provider/stream-frames.d.ts +25 -0
  117. package/dist/provider/tool-secret.d.ts +57 -0
  118. package/dist/rpc/bridge.d.ts +14 -0
  119. package/dist/rpc/mcp-control.d.ts +26 -0
  120. package/dist/runtime.d.ts +14 -0
  121. package/dist/sandbox/profile.d.ts +249 -0
  122. package/dist/sandbox/spawn.d.ts +139 -0
  123. package/dist/settings/env-filter.d.ts +52 -0
  124. package/dist/settings/loaders/hooks.d.ts +44 -0
  125. package/dist/settings/loaders/mcp-config.d.ts +83 -0
  126. package/dist/settings/loaders/plugin-mcp.d.ts +3 -0
  127. package/dist/settings/loaders/strict-plugin-only.d.ts +13 -0
  128. package/dist/settings/resolve.d.ts +2 -0
  129. package/dist/settings/sources.d.ts +2 -0
  130. package/dist/settings/trust.d.ts +36 -0
  131. package/dist/skills/attachment.d.ts +25 -0
  132. package/dist/skills/frontmatter.d.ts +64 -0
  133. package/dist/skills/index.d.ts +16 -0
  134. package/dist/skills/listing.d.ts +89 -0
  135. package/dist/skills/loader.d.ts +104 -0
  136. package/dist/skills/option.d.ts +68 -0
  137. package/dist/skills/permission-rules.d.ts +21 -0
  138. package/dist/skills/runtime.d.ts +21 -0
  139. package/dist/skills/store.d.ts +163 -0
  140. package/dist/store/continuation-attach.d.ts +44 -0
  141. package/dist/store/dialect.d.ts +526 -0
  142. package/dist/store/provider-state.d.ts +188 -0
  143. package/dist/store/resume.d.ts +92 -0
  144. package/dist/structured/ajv-seam.d.ts +7 -0
  145. package/dist/structured/descriptor.d.ts +9 -0
  146. package/dist/structured/seam.d.ts +51 -0
  147. package/dist/structured/validator.d.ts +22 -0
  148. package/dist/subagents/activity.d.ts +13 -0
  149. package/dist/subagents/availability.d.ts +30 -0
  150. package/dist/subagents/builtin-agents.d.ts +37 -0
  151. package/dist/subagents/child-engine.d.ts +198 -0
  152. package/dist/subagents/child-handle.d.ts +344 -0
  153. package/dist/subagents/definitions.d.ts +189 -0
  154. package/dist/subagents/fork.d.ts +55 -0
  155. package/dist/subagents/git-root.d.ts +1 -0
  156. package/dist/subagents/limits.d.ts +28 -0
  157. package/dist/subagents/notification-queue.d.ts +233 -0
  158. package/dist/subagents/plugin-agents.d.ts +5 -0
  159. package/dist/subagents/policy.d.ts +46 -0
  160. package/dist/subagents/register-default-factory.d.ts +66 -0
  161. package/dist/subagents/resolution.d.ts +56 -0
  162. package/dist/subagents/restore.d.ts +9 -0
  163. package/dist/subagents/roster.d.ts +17 -0
  164. package/dist/subagents/test-fakes.d.ts +12 -0
  165. package/dist/subagents/tool-pools.d.ts +69 -0
  166. package/dist/subagents/watchdog.d.ts +13 -0
  167. package/dist/subagents/workspace.d.ts +27 -0
  168. package/dist/testing.d.ts +5 -0
  169. package/dist/testing.js +194 -0
  170. package/dist/tools/background-tasks.d.ts +10 -0
  171. package/dist/tools/descriptors/_shared.d.ts +34 -0
  172. package/dist/tools/descriptors/advisor.d.ts +1 -0
  173. package/dist/tools/descriptors/agent.d.ts +47 -0
  174. package/dist/tools/descriptors/artifact.d.ts +1 -0
  175. package/dist/tools/descriptors/ask-user-question.d.ts +1 -0
  176. package/dist/tools/descriptors/bash.d.ts +20 -0
  177. package/dist/tools/descriptors/claude-design.d.ts +1 -0
  178. package/dist/tools/descriptors/cron-create.d.ts +1 -0
  179. package/dist/tools/descriptors/cron-delete.d.ts +1 -0
  180. package/dist/tools/descriptors/cron-list.d.ts +1 -0
  181. package/dist/tools/descriptors/edit.d.ts +1 -0
  182. package/dist/tools/descriptors/end-conversation.d.ts +1 -0
  183. package/dist/tools/descriptors/enter-plan-mode.d.ts +1 -0
  184. package/dist/tools/descriptors/enter-worktree.d.ts +1 -0
  185. package/dist/tools/descriptors/exit-plan-mode.d.ts +1 -0
  186. package/dist/tools/descriptors/exit-worktree.d.ts +1 -0
  187. package/dist/tools/descriptors/glob.d.ts +1 -0
  188. package/dist/tools/descriptors/grep.d.ts +1 -0
  189. package/dist/tools/descriptors/index.d.ts +59 -0
  190. package/dist/tools/descriptors/list-agents.d.ts +1 -0
  191. package/dist/tools/descriptors/list-mcp-resources-tool.d.ts +1 -0
  192. package/dist/tools/descriptors/lsp.d.ts +1 -0
  193. package/dist/tools/descriptors/monitor.d.ts +1 -0
  194. package/dist/tools/descriptors/notebook-edit.d.ts +1 -0
  195. package/dist/tools/descriptors/powershell.d.ts +1 -0
  196. package/dist/tools/descriptors/projects.d.ts +1 -0
  197. package/dist/tools/descriptors/propose-goal.d.ts +1 -0
  198. package/dist/tools/descriptors/propose-skills.d.ts +1 -0
  199. package/dist/tools/descriptors/push-notification.d.ts +1 -0
  200. package/dist/tools/descriptors/read-mcp-resource-dir-tool.d.ts +1 -0
  201. package/dist/tools/descriptors/read-mcp-resource-tool.d.ts +1 -0
  202. package/dist/tools/descriptors/read-notifications.d.ts +1 -0
  203. package/dist/tools/descriptors/read.d.ts +1 -0
  204. package/dist/tools/descriptors/refresh-mcp-tools.d.ts +1 -0
  205. package/dist/tools/descriptors/remote-trigger.d.ts +1 -0
  206. package/dist/tools/descriptors/repl.d.ts +1 -0
  207. package/dist/tools/descriptors/report-findings.d.ts +1 -0
  208. package/dist/tools/descriptors/schedule-wakeup.d.ts +1 -0
  209. package/dist/tools/descriptors/send-feedback.d.ts +1 -0
  210. package/dist/tools/descriptors/send-message.d.ts +1 -0
  211. package/dist/tools/descriptors/send-user-file.d.ts +1 -0
  212. package/dist/tools/descriptors/share-onboarding-guide.d.ts +1 -0
  213. package/dist/tools/descriptors/show-onboarding-role-picker.d.ts +1 -0
  214. package/dist/tools/descriptors/skill.d.ts +1 -0
  215. package/dist/tools/descriptors/structured-output.d.ts +1 -0
  216. package/dist/tools/descriptors/task-create.d.ts +1 -0
  217. package/dist/tools/descriptors/task-get.d.ts +1 -0
  218. package/dist/tools/descriptors/task-list.d.ts +1 -0
  219. package/dist/tools/descriptors/task-output.d.ts +1 -0
  220. package/dist/tools/descriptors/task-stop.d.ts +1 -0
  221. package/dist/tools/descriptors/task-update.d.ts +1 -0
  222. package/dist/tools/descriptors/todo-write.d.ts +1 -0
  223. package/dist/tools/descriptors/tool-search.d.ts +1 -0
  224. package/dist/tools/descriptors/wait-for-mcp-servers.d.ts +1 -0
  225. package/dist/tools/descriptors/web-fetch.d.ts +8 -0
  226. package/dist/tools/descriptors/web-search.d.ts +15 -0
  227. package/dist/tools/descriptors/winter-list-agents.d.ts +1 -0
  228. package/dist/tools/descriptors/winter-send-message.d.ts +1 -0
  229. package/dist/tools/descriptors/workflow.d.ts +1 -0
  230. package/dist/tools/descriptors/write.d.ts +1 -0
  231. package/dist/tools/impl/_caller.d.ts +14 -0
  232. package/dist/tools/impl/_domains.d.ts +25 -0
  233. package/dist/tools/impl/_exa-client.d.ts +122 -0
  234. package/dist/tools/impl/_exa-session-client.d.ts +23 -0
  235. package/dist/tools/impl/_inner-model.d.ts +135 -0
  236. package/dist/tools/impl/_search-budget.d.ts +36 -0
  237. package/dist/tools/impl/_web-fetch-cache.d.ts +37 -0
  238. package/dist/tools/impl/_web-fetch-html.d.ts +26 -0
  239. package/dist/tools/impl/_web-fetch-net.d.ts +99 -0
  240. package/dist/tools/impl/_web-search-assembler.d.ts +57 -0
  241. package/dist/tools/impl/advisor.d.ts +37 -0
  242. package/dist/tools/impl/agent.d.ts +10 -0
  243. package/dist/tools/impl/ask-user-question.d.ts +5 -0
  244. package/dist/tools/impl/background-task-runtime.d.ts +272 -0
  245. package/dist/tools/impl/bash.d.ts +78 -0
  246. package/dist/tools/impl/cron.d.ts +11 -0
  247. package/dist/tools/impl/edit.d.ts +1 -0
  248. package/dist/tools/impl/enter-plan-mode.d.ts +4 -0
  249. package/dist/tools/impl/enter-worktree.d.ts +25 -0
  250. package/dist/tools/impl/exit-plan-mode.d.ts +4 -0
  251. package/dist/tools/impl/exit-worktree.d.ts +4 -0
  252. package/dist/tools/impl/glob.d.ts +1 -0
  253. package/dist/tools/impl/grep.d.ts +19 -0
  254. package/dist/tools/impl/index.d.ts +37 -0
  255. package/dist/tools/impl/list-agents.d.ts +7 -0
  256. package/dist/tools/impl/list-mcp-resources-tool.d.ts +9 -0
  257. package/dist/tools/impl/monitor.d.ts +66 -0
  258. package/dist/tools/impl/notebook-edit.d.ts +1 -0
  259. package/dist/tools/impl/push-notification.d.ts +4 -0
  260. package/dist/tools/impl/read-ladder.d.ts +25 -0
  261. package/dist/tools/impl/read-mcp-resource-dir-tool.d.ts +9 -0
  262. package/dist/tools/impl/read-mcp-resource-tool.d.ts +9 -0
  263. package/dist/tools/impl/read-notifications.d.ts +5 -0
  264. package/dist/tools/impl/read.d.ts +44 -0
  265. package/dist/tools/impl/refresh-mcp-tools.d.ts +8 -0
  266. package/dist/tools/impl/report-findings.d.ts +1 -0
  267. package/dist/tools/impl/schedule-wakeup.d.ts +2 -0
  268. package/dist/tools/impl/send-message.d.ts +7 -0
  269. package/dist/tools/impl/skill.d.ts +5 -0
  270. package/dist/tools/impl/task-graph.d.ts +1 -0
  271. package/dist/tools/impl/task-output.d.ts +16 -0
  272. package/dist/tools/impl/task-stop.d.ts +11 -0
  273. package/dist/tools/impl/todo-write.d.ts +8 -0
  274. package/dist/tools/impl/tool-search.d.ts +4 -0
  275. package/dist/tools/impl/wait-for-mcp-servers.d.ts +29 -0
  276. package/dist/tools/impl/web-fetch.d.ts +36 -0
  277. package/dist/tools/impl/web-search.d.ts +30 -0
  278. package/dist/tools/impl/workflow.d.ts +5 -0
  279. package/dist/tools/impl/write.d.ts +8 -0
  280. package/dist/tools/paths-seam.d.ts +6 -0
  281. package/dist/tools/read-state.d.ts +12 -0
  282. package/dist/tools/registry.d.ts +423 -0
  283. package/dist/tools/task-graph-store.d.ts +61 -0
  284. package/dist/toolsearch/aliases.d.ts +26 -0
  285. package/dist/toolsearch/exposure.d.ts +30 -0
  286. package/dist/toolsearch/ranking.d.ts +6 -0
  287. package/dist/toolsearch/search.d.ts +45 -0
  288. package/dist/version.d.ts +1 -0
  289. package/dist/version.js +5 -0
  290. package/dist/web/fetchable-url.d.ts +28 -0
  291. package/dist/web/preapproved-hosts.d.ts +52 -0
  292. package/dist/web/private-address.d.ts +55 -0
  293. package/dist/web/session-runtime.d.ts +86 -0
  294. package/dist/workflows/bridge.d.ts +87 -0
  295. package/dist/workflows/budget.d.ts +24 -0
  296. package/dist/workflows/host-registry.d.ts +142 -0
  297. package/dist/workflows/journal.d.ts +29 -0
  298. package/dist/workflows/meta.d.ts +45 -0
  299. package/dist/workflows/registry.d.ts +24 -0
  300. package/dist/workflows/runtime.d.ts +254 -0
  301. package/dist/workflows/sandbox.d.ts +49 -0
  302. package/dist/workflows/script-api.d.ts +58 -0
  303. package/dist/workflows/seam.d.ts +92 -0
  304. package/dist/workflows/semaphore.d.ts +16 -0
  305. package/dist/workflows/store.d.ts +177 -0
  306. package/dist/workflows/subprocess-entry.d.ts +38 -0
  307. package/dist/workflows/subprocess-entry.js +14 -0
  308. package/dist/workflows/transcript.d.ts +56 -0
  309. package/dist/workflows/types.d.ts +84 -0
  310. package/dist/workflows/worker-harness.d.ts +45 -0
  311. package/package.json +76 -0
@@ -0,0 +1,198 @@
1
+ import type { RuntimeConfig, SessionStore, RuntimeHooksConfig, SandboxSettingsConfig, PermissionMode, BrandProfile } from "@yanlinglabs/winter-agent-sdk";
2
+ import { type EngineOptions, type EngineSettingsRuleSeed, type Provider } from "../engine.js";
3
+ import type { ChildEngineFactory } from "./child-handle.js";
4
+ import { type ModelCatalog } from "./resolution.js";
5
+ import type { SystemPromptAssembler } from "../context/seam.js";
6
+ import { type SkillSessionRuntime } from "../skills/runtime.js";
7
+ import type { SkillListing } from "../context/seam.js";
8
+ import type { StructuredOutputSeam } from "../structured/seam.js";
9
+ import type { SourcedHookEntry } from "../hooks/registry.js";
10
+ import type { CompactionController } from "../compaction/seam.js";
11
+ /** The identity an R6-17 child's own provider reports. `authRefKind` is the CHILD's material's kind (Ruling E-1), never the parent's. */
12
+ export interface ChildProviderIdentity {
13
+ providerId: string;
14
+ modelKey: string;
15
+ family: string;
16
+ continuationDomain?: string;
17
+ adapterId?: string;
18
+ adapterVersion?: string;
19
+ catalogVersion?: string;
20
+ authRefKind?: string;
21
+ }
22
+ /**
23
+ * What `resolveChildProvider` answers. THREE shapes, plus `undefined` -- and the distinction between
24
+ * the third shape and `undefined` is load-bearing (P6.6 fix wave, whole-branch Important-1):
25
+ *
26
+ * - `{ provider, identity }` -- a full resolution onto the child's OWN adapter.
27
+ * - `{ refused, provider, identity }` (Ruling E-1, R-E3) -- the cross-provider child with no
28
+ * credential of its own: the resolver names the child, the provider and the reason, the spawn path
29
+ * says so on stderr AND on a `continuity_warning` frame, and the child runs on the
30
+ * DEFERRED-REFUSAL provider it carries -- its first generation lands on R6-F with NO request. Never
31
+ * the parent's provider: a foreign model id on the parent's wire is exactly what a refusal exists
32
+ * to prevent.
33
+ * - `{ sameAsParent: true, identity }` -- THE MODEL RESOLVED, onto exactly the key the parent is
34
+ * running RIGHT NOW, so no second adapter is needed: the caller uses the parent's own provider.
35
+ * The `identity` is what it resolved TO, which is what makes this shape distinguishable from an
36
+ * unresolvable one on resume. No `provider` rides along deliberately: the parent's adapter is the
37
+ * answer, and the resolver has no business handing back a second reference to it.
38
+ * - `undefined` -- STRICTLY "unresolvable, or there is no catalog to resolve against" (a scripted
39
+ * test double, a model id the registry rejects). NEVER "same as the parent" -- that overload is
40
+ * exactly the bug the third shape exists to kill: `resume()` cannot distinguish "the parent moved
41
+ * onto this child's own model key" (harmless, the child is servable) from "this child's model no
42
+ * longer resolves at all" (a genuine refusal) when both arrive as `undefined`, and the false
43
+ * refusal it produced named a provider as no longer serving a model it serves perfectly well.
44
+ */
45
+ export type ChildProviderResolution = {
46
+ provider: Provider;
47
+ identity: ChildProviderIdentity;
48
+ } | {
49
+ refused: {
50
+ providerId: string;
51
+ modelKey: string;
52
+ reason: string;
53
+ };
54
+ provider: Provider;
55
+ identity: ChildProviderIdentity;
56
+ } | {
57
+ sameAsParent: true;
58
+ identity: ChildProviderIdentity;
59
+ };
60
+ export interface ChildEngineFactoryDeps {
61
+ provider: Provider;
62
+ /**
63
+ * Ruling E-1: the operator's channel for a refused cross-provider child. `main.ts` writes it to
64
+ * the process's stderr, `testing.ts` to the in-memory leg's own stderr queue -- the same two sinks
65
+ * every wiring warning already uses. Absent means the stderr half is silent (the frame still goes).
66
+ */
67
+ warn?: (line: string) => void;
68
+ /**
69
+ * Phase 6 Task 10 (R6-17): THE CHILD'S OWN PROVIDER.
70
+ *
71
+ * `AgentDefinition.model` is a real per-child model selection, and until this seam existed a child
72
+ * that named one ran off `deps.provider` -- the PARENT's already-resolved adapter, pinned to the
73
+ * parent's model id and, for a qualified `<providerId>/<model>` key, to the parent's PROVIDER. The
74
+ * child's model then travelled only as `ProviderRequest.model`, so a cross-provider child sent one
75
+ * vendor's model id to another vendor's endpoint.
76
+ *
77
+ * Returns `{ sameAsParent: true, identity }` when the model resolves to the same key the parent is
78
+ * running, and `undefined` when it cannot be resolved at all (no catalog, or a key the registry
79
+ * rejects); the parent's provider is used unchanged in BOTH cases at spawn -- which is every pre-P6
80
+ * child and every session whose provider is the reserved test double. They are two different facts
81
+ * and must not share one answer: see `ChildProviderResolution` for what `resume()` does with each.
82
+ *
83
+ * The IDENTITY comes back with it deliberately: a child running its own provider that reported its
84
+ * PARENT's identity would write provider-state records naming a model it never called, and the
85
+ * resume side reads those records to decide what may be replayed natively.
86
+ */
87
+ resolveChildProvider?: (model: string) => ChildProviderResolution | undefined | Promise<ChildProviderResolution | undefined>;
88
+ store?: SessionStore;
89
+ winterHome?: string;
90
+ /**
91
+ * WS-21 §3.7: the shared runtime home's durable-paths root (`config.storeHome`), preferred over
92
+ * `winterHome` wherever this factory resolves an ABSOLUTE durable path for a child -- the
93
+ * transcript record's own display path, and the provider-state sidecar's attachment gate below
94
+ * (both point at the SAME `<store>/projects/...` tree `store` itself writes into once its own
95
+ * construction site prefers `storeHome` too; this factory's own display/gate is what §6.3 item 11
96
+ * covers). Absent falls back to `winterHome`, byte-identical to pre-WS-21 behaviour.
97
+ */
98
+ storeHome?: string;
99
+ env?: Record<string, string | undefined>;
100
+ modelCatalog?: ModelCatalog;
101
+ interactiveDefault?: boolean;
102
+ disableBypassPermissionsMode?: boolean;
103
+ forwardSubagentText?: boolean;
104
+ parentPermissionRules?: {
105
+ allow?: string[];
106
+ ask?: string[];
107
+ deny?: string[];
108
+ };
109
+ parentHooks?: RuntimeHooksConfig;
110
+ parentIncludeHookEvents?: boolean;
111
+ parentSandbox?: SandboxSettingsConfig;
112
+ /**
113
+ * P7a (D19): the PARENT session's resolved brand profile, mirrored down like every other
114
+ * `parent*` field here.
115
+ *
116
+ * A child is a session of the SAME product as its parent -- its worktree lives under the parent's
117
+ * project dot-dir, its spawn limits read the parent's env prefix, and its own `RuntimeConfig`
118
+ * must carry the profile onward so ITS children (and its assembler, and its tool executors) stay
119
+ * branded. Omitted = `WINTER_BRAND`, which is byte-identical to the behaviour before this field.
120
+ */
121
+ parentBrand?: BrandProfile;
122
+ /**
123
+ * The host's `Options.autoMemory` and `Options.web`, mirrored down like `parentBrand` and for the
124
+ * same reason: a child's config is HAND-BUILT, so a host option that is not threaded reads as its
125
+ * DEFAULT inside the child. For `autoMemory` that meant a child rendering the memory section at the
126
+ * computed path under a host that had turned memory off or moved it (the child shares the
127
+ * production assembler). For `web` it is the fail-closed half: a child normally inherits the web
128
+ * configuration from the root's registration, and one that cannot see it must land on the HOST's
129
+ * block-list and policy, not on "search on, no block-list, ask".
130
+ */
131
+ parentAutoMemory?: RuntimeConfig["autoMemory"];
132
+ parentWeb?: RuntimeConfig["web"];
133
+ /**
134
+ * The session's pricing, stated-model and tool-secret seams, so a CHILD's engine has what its
135
+ * parent's has. `priceUsage` is what makes a child's generations priced at all; the cost then
136
+ * climbs through `ChildEngineRunContext.recordDescendantCost`. The two resolvers are also
137
+ * inherited through the web session registry -- threading them here is the fail-closed half, for a
138
+ * child that cannot see the root's registration.
139
+ */
140
+ priceUsage?: EngineOptions["priceUsage"];
141
+ /** The row facts for a child's UNPRICED generations -- see `EngineOptions.usageRowFacts`. Remapped to the child's own key exactly like `priceUsage`. */
142
+ usageRowFacts?: EngineOptions["usageRowFacts"];
143
+ resolveAuxiliaryModel?: EngineOptions["resolveAuxiliaryModel"];
144
+ resolveToolSecret?: EngineOptions["resolveToolSecret"];
145
+ getParentPolicy?: () => {
146
+ mode: PermissionMode;
147
+ version: number;
148
+ hash: string;
149
+ };
150
+ systemPromptAssembler?: SystemPromptAssembler;
151
+ skillRuntime?: {
152
+ index: SkillSessionRuntime["index"];
153
+ skillOverrides?: SkillSessionRuntime["skillOverrides"];
154
+ };
155
+ skillListing?: SkillListing;
156
+ /** SDK 0.0.16: the catalog's model display names, for the child's own `# Environment` line. */
157
+ describeModel?: EngineOptions["describeModel"];
158
+ /**
159
+ * Phase 5 residual round (NEW-4): THE SETTINGS SEED, tags intact.
160
+ *
161
+ * C1 gave the parent its settings-file rules and I1 gave it the resolved-root floors; neither
162
+ * reached a child, so the MANAGED tier -- the strongest one, and the only one a forced-bypass
163
+ * child still honours -- stopped at the session boundary. A model reached it by delegating.
164
+ *
165
+ * NOT the `getParentRules` mirror, deliberately: a mirrored entry arrives re-tagged `sdk`, and
166
+ * stage 2 under forced bypass honours `managed` denies alone, so the mirror is inert in precisely
167
+ * the hostile case. Passing the seed keeps every source tag, which is also what keeps the child's
168
+ * P5-A/P5-D per-tier gates identical to its parent's.
169
+ */
170
+ settingsRules?: EngineSettingsRuleSeed;
171
+ structuredOutput?: StructuredOutputSeam;
172
+ extraHookEntries?: readonly SourcedHookEntry[];
173
+ compactionController?: CompactionController;
174
+ /**
175
+ * Phase 5 residual round, NEW-2: ONE CONTROLLER PER SPAWN, not one per session.
176
+ *
177
+ * `compactionController` above is a single instance built once for the whole factory, so every
178
+ * SIBLING child shared one `lastSummary` memo. The comment at its construction site claimed
179
+ * "per-parent", and the reason it gives -- a child folding its own history into the parent's memo
180
+ * -- applies between siblings just as exactly.
181
+ *
182
+ * Bounded rather than dramatic: `compaction/controller.ts`'s carry-forward is gated on the input's
183
+ * head message being content-equal to `lastSummary`, so a sibling's summary can only be carried
184
+ * into a child whose own head is byte-identical to it. That is rare, and it is also not a property
185
+ * anyone reasoned about -- it is the accident that kept a shared memo from being visible.
186
+ *
187
+ * Per SPAWN and not per GENERATION: a child that compacts and then resumes must keep its own memo
188
+ * across generations, which is exactly what the memo is for.
189
+ */
190
+ compactionControllerFactory?: () => CompactionController;
191
+ }
192
+ export declare function createChildEngineFactory(deps: ChildEngineFactoryDeps): ChildEngineFactory;
193
+ /**
194
+ * What a child reports when the SPENDING CEILING ended it (whole-branch review MINOR 9). One constant,
195
+ * because the engine's own `error_max_budget_usd` result carries no text to forward and the parent must
196
+ * not be told a retry is worth trying: the ceiling is the session's, so a retry hits it again.
197
+ */
198
+ export declare const CHILD_BUDGET_STOP_TEXT = "The agent stopped because the session reached its spending limit (maxBudgetUsd), so no further model calls could be made. Retrying will not help -- continue with what it produced, or ask the user to raise the session's budget.";
@@ -0,0 +1,344 @@
1
+ import type { ActiveSlotSet, ControlResponseFrame, McpServerConfigForProcessTransport, OutputFormat, PermissionMode, RuntimeAgentDefinition, WinterFrame } from "@yanlinglabs/winter-agent-sdk";
2
+ import type { RecordedModelEffort } from "./resolution.js";
3
+ import type { McpServerStateSource } from "../mcp/state.js";
4
+ import type { McpControlSeam } from "../mcp/control-seam.js";
5
+ import type { ChildPolicyResult } from "../permissions/auto/inheritance.js";
6
+ import type { ProviderMessage } from "../engine.js";
7
+ import type { SessionRequestLayout } from "../context/request-layout.js";
8
+ import type { GlobalAgentMessage, DeliveryOutcome } from "@yanlinglabs/winter-agent-sdk/messaging";
9
+ export type ChildStatus = "running" | "completed" | "stopped" | "failed";
10
+ export interface ChildSessionRecord {
11
+ id: string;
12
+ parentSessionId: string;
13
+ parentToolUseId: string;
14
+ transcript: string;
15
+ status: ChildStatus;
16
+ runtime: "winter-agent";
17
+ /** R-6c-20: the record's model block IS `RecordedModelEffort` (`effectiveProvider`/`slot` included) — one declaration, no local intersection. */
18
+ model: RecordedModelEffort;
19
+ permission: {
20
+ effectiveMode: PermissionMode;
21
+ parentPolicyHash: string;
22
+ parentPolicyVersion: number;
23
+ };
24
+ name?: string;
25
+ /**
26
+ * Task-frames parity (2026-09-17 contract §4): 1 for a top-level spawn, N+1 when spawned inside a
27
+ * depth-N agent -- `limits.ts`'s own `checkAndRegisterSpawn` already computes exactly this value
28
+ * (its own header: "depth 1 for its direct children, depth 2 for their own, etc.") and this is
29
+ * simply where child-engine.ts records it, once, at spawn. Absent only for a hand-built
30
+ * `ChildSessionRecord` (every pre-existing `impl/*.test.ts` fixture) that never went through the
31
+ * real spawn path at all.
32
+ */
33
+ spawnDepth?: number;
34
+ }
35
+ export interface ChildResult {
36
+ status: "completed" | "stopped" | "failed";
37
+ content: string;
38
+ resolvedModel?: string;
39
+ totalToolUseCount?: number;
40
+ totalDurationMs?: number;
41
+ /**
42
+ * RULING P5-I (Phase 5 fix wave): the child's VALIDATED structured result, when it produced one.
43
+ *
44
+ * `SpawnChildRequest.outputFormat` threads a schema into the child's own generation config, and the
45
+ * child's engine validates against it and puts the value on `result.structured_output` -- and
46
+ * nothing carried it back across this seam. Lane W's `agent({schema})` therefore re-parsed the
47
+ * child's final TEXT and re-validated it through the same validator, which a child forced onto
48
+ * `StructuredOutput` generally does not produce at all, so the call mostly resolved `null`.
49
+ *
50
+ * ABSENT when the child produced none, and a consumer must fall back to the text re-parse only
51
+ * then -- never treat unvalidated data as validated (the ruling's own wording).
52
+ */
53
+ structuredOutput?: unknown;
54
+ /**
55
+ * Task-frames parity (2026-09-17 contract §4): the SAME counting `task_progress` uses, taken at
56
+ * settle() -- `total_tokens` is the LAST recorded turn's (input + cache_write + cache_read) plus
57
+ * the SUM of every turn's output_tokens; `tool_uses` is every `tool_use` block seen across the
58
+ * child's own assistant messages; `duration_ms` is settle time minus spawn time. Needed here (not
59
+ * only on the last `task_progress` frame) because the pin's FINAL `task_notification.usage` must
60
+ * include the child's LAST turn too -- a trailing text-only turn (no tool_use block) never fires
61
+ * `onProgress` at all, so tools/impl/agent.ts has nowhere else to read a complete total from.
62
+ *
63
+ * Always present once a generation actually started (even a zero-turn child reports zeroed
64
+ * counters) -- never fabricated for a child that never ran at all, which cannot reach settle().
65
+ */
66
+ usage?: {
67
+ totalTokens: number;
68
+ toolUses: number;
69
+ durationMs: number;
70
+ };
71
+ }
72
+ /**
73
+ * Task-frames parity (2026-09-17 contract §4): what `SpawnChildRequest.onProgress` (below) is called
74
+ * with -- one call per child ASSISTANT message that carries at least one `tool_use` block, foreground
75
+ * and background alike, synchronous with the frame reaching the parent's own stream.
76
+ */
77
+ export interface ChildTaskProgress {
78
+ /** `tool_uses` accumulated so far this generation -- the running total, not a per-message delta. */
79
+ toolUses: number;
80
+ /** `total_tokens` per the contract's own formula (see `ChildResult.usage`'s own comment). */
81
+ totalTokens: number;
82
+ durationMs: number;
83
+ /** The name of the LAST `tool_use` block in the qualifying message. */
84
+ lastToolName: string;
85
+ /**
86
+ * Contract §8: the activity text of the child's MOST RECENT RECORDED tool call (every `tool_use`
87
+ * except the structured-output tool is recorded; the value is sticky across messages, like the
88
+ * pin's tracker `lastActivity`). `undefined` when that call's tool has no activity text (or nothing
89
+ * has been recorded yet) -- the caller then falls back to the task description.
90
+ */
91
+ activity?: string;
92
+ }
93
+ export interface ChildHandle {
94
+ readonly record: ChildSessionRecord;
95
+ status(): ChildStatus;
96
+ steer(msg: GlobalAgentMessage): Promise<DeliveryOutcome>;
97
+ resume(msg: GlobalAgentMessage): Promise<DeliveryOutcome>;
98
+ result(): Promise<ChildResult>;
99
+ stop(): Promise<void>;
100
+ /**
101
+ * Review r1 finding 4: the CURRENT generation's live usage counters (the same numbers
102
+ * `ChildResult.usage` settles with). Optional -- a hand-built test handle has none. The agent
103
+ * task's registry row reads it, so a TaskStop that finalizes the row before the child's own result
104
+ * arrives still reports usage.
105
+ */
106
+ usage?(): ChildResult["usage"];
107
+ }
108
+ export type ResolvedAgentDefinition = RuntimeAgentDefinition;
109
+ export interface SpawnChildRequest {
110
+ parentToolUseId: string;
111
+ definition?: ResolvedAgentDefinition;
112
+ fork?: true;
113
+ prompt: string;
114
+ model?: string;
115
+ runInBackground: boolean;
116
+ isolation?: "worktree";
117
+ name?: string;
118
+ /**
119
+ * SDK 0.0.16 Lane P (R3b §5): the RESOLVED `subagent_type`, set ONLY when the definition
120
+ * `tools/impl/agent.ts` resolved came from `_source === "builtin"` -- i.e. Winter's own shipped
121
+ * definition, never a same-named user/project/plugin/programmatic override that merely shadows
122
+ * one. `SourcedAgentDefinition._source` (subagents/definitions.ts) does not survive onto
123
+ * `ResolvedAgentDefinition`/`RuntimeAgentDefinition` (a wire shape with no such field), so this is
124
+ * the one channel by which engine.ts's own `resolveChildModel` -- which sees only this request,
125
+ * never the definitions map -- can tell "this child IS the built-in Explore" from "this child is
126
+ * merely named 'Explore'" for the Explore model cap (R3b §5). Absent for every fork, every
127
+ * non-built-in definition, and every hand-built request in a test fixture that predates this
128
+ * field -- byte-identical to before it existed.
129
+ */
130
+ builtinAgentType?: string;
131
+ /**
132
+ * WS-23: the `subagent_type` this child was spawned as (whatever its source), for the
133
+ * `agent_type` field of its SubagentStart/SubagentStop hook input -- and the subject those events'
134
+ * matchers are tested against. Absent from a hand-built request; child-engine.ts then falls back
135
+ * to `builtinAgentType`, `"fork"` for a fork, else `"general-purpose"`.
136
+ */
137
+ agentType?: string;
138
+ outputFormat?: OutputFormat;
139
+ /**
140
+ * Task-frames parity (2026-09-17 contract §4): fired synchronously after each child ASSISTANT
141
+ * message whose content holds at least one `tool_use` block -- foreground and background alike.
142
+ * `tools/impl/agent.ts` is the one caller with a `ctx.emitFrame` to turn this into a real
143
+ * `task_progress` frame (a `task_id` only exists once agent.ts has spawned and, for a background
144
+ * task, called `createBackgroundTask` -- this request is built and handed to `spawnChild` BEFORE
145
+ * either of those, so the callback closes over a variable assigned once they are known, rather
146
+ * than the id being a field of the request itself).
147
+ *
148
+ * child-engine.ts is the one caller: its own pump already counts `tool_use` blocks per assistant
149
+ * message (`ChildResult.totalToolUseCount`'s own producer) and already wraps the child's
150
+ * `ContextAccountant` (for `ChildResult.usage`'s own identical counting) -- this is that SAME
151
+ * bookkeeping, surfaced per qualifying message instead of only once at settle().
152
+ */
153
+ onProgress?: (progress: ChildTaskProgress) => void;
154
+ /**
155
+ * Review r1 finding 9: fired ONCE, synchronously, with the real handle, after the child's record
156
+ * exists and BEFORE its first generation starts -- so a caller (tools/impl/agent.ts) can register
157
+ * the task and emit `task_started` before any child frame or `task_progress` for that task can
158
+ * exist. A throw from it is swallowed here (the caller records its own failure and decides what to
159
+ * do with the child once `spawn` returns). A spawner that never calls it (a hand-built test
160
+ * double) is fine: the caller falls back to registering after `spawn` resolves.
161
+ */
162
+ onSpawned?: (handle: ChildHandle) => void;
163
+ }
164
+ export interface ChildInheritance {
165
+ policy: ChildPolicyResult;
166
+ tools: string[];
167
+ model: string;
168
+ effort: string;
169
+ thinking: unknown;
170
+ systemPrompt: string;
171
+ /**
172
+ * Phase 5 Task 8 (rider 12, WS-11 §6.5 "dispatch-children inherit the parent's style"): the
173
+ * parent's resolved output-style NAME.
174
+ *
175
+ * Lane C's report named this exactly: the assembler already applies whatever arrives on
176
+ * `input.outputStyle`/`config.outputStyle`, so the MECHANISM was ready and only the CHANNEL was
177
+ * missing -- `ChildInheritance` carried policy/tools/model/effort/thinking/systemPrompt/messages/
178
+ * sessionRoot and nothing about style, and `buildChildInheritance` set none of it on the child's
179
+ * `RuntimeConfig`. A child therefore silently ran under the default style however the parent was
180
+ * configured.
181
+ *
182
+ * Absent when the parent configured none, which is the same thing as "the default" -- never a
183
+ * fabricated `"default"` string, so a child of a parent with no style is byte-identical to a
184
+ * pre-P5 child.
185
+ */
186
+ outputStyle?: string;
187
+ messages?: ProviderMessage[];
188
+ sessionRoot: string;
189
+ /**
190
+ * Phase 6 Task 3 (R6-17): the PARENT's RESOLVED provider identity.
191
+ *
192
+ * `model` above is the child's own bare string (a definition's override, or the parent's). This is
193
+ * what that string resolves AGAINST: `AgentDefinition.model` goes through the same selection path
194
+ * as the session's, against the PARENT's provider unless the id is itself qualified. Without this
195
+ * field a child with a bare model id had no provider to resolve against at all and would either
196
+ * pick the host's default or fail -- neither of which is "the parent's provider".
197
+ *
198
+ * It is also what makes a child's own provider-state records identify themselves: a child writes
199
+ * its own sidecar beside its own transcript, and `provider`/`model`/`family` on those records come
200
+ * from here.
201
+ *
202
+ * Absent when the parent has not resolved one (every pre-P6 session and every test double), which
203
+ * reads as "no provider identity to inherit" -- never a fabricated one.
204
+ */
205
+ provider?: {
206
+ providerId: string;
207
+ modelKey: string;
208
+ family: string;
209
+ continuationDomain?: string;
210
+ };
211
+ /**
212
+ * R6-17 / P4 carry: the parent's EFFECTIVE reasoning configuration, from real session concepts.
213
+ *
214
+ * `effort` above is a `string` and its base value was the literal `"inherit"` -- an honest
215
+ * placeholder written when `RuntimeConfig` carried no session-level effort concept at all. It does
216
+ * now (`config.effort`/`config.thinking`, T2's option mirrors), so these two fields carry the real
217
+ * resolved values a definition's own override is layered on top of. Kept SEPARATE from `effort`/
218
+ * `thinking` above rather than replacing them: those are the REQUESTED values (a definition's, or
219
+ * the placeholder), and WS-10 §3.4's recorded-resolution fields want both halves.
220
+ */
221
+ effectiveEffort?: "low" | "medium" | "high" | "xhigh" | "max" | number;
222
+ effectiveThinking?: {
223
+ type: "disabled";
224
+ } | {
225
+ type: "enabled";
226
+ budgetTokens?: number;
227
+ display?: "summarized" | "omitted";
228
+ } | {
229
+ type: "adaptive";
230
+ display?: "summarized" | "omitted";
231
+ };
232
+ /**
233
+ * WS-13c §3 (recorded on the child, extending WS-10 §3.4): the SLOT the parent's `AgentInput.model`
234
+ * named, and where that slot came from.
235
+ *
236
+ * `model` above is the bare string as sent; this says what it MEANT — `{ family: "gpt", name:
237
+ * "astra", source: "family-default" }`. Without it a child's record cannot distinguish a slot the
238
+ * session advertised from a unique foreign name the model copied out of older context (§3
239
+ * acceptance (b)), which is exactly the case §8's cross-family resume has to reason about.
240
+ *
241
+ * `source` is the FULL four-member `ActiveSlotSet["source"]` union, not a narrowed copy: this is
242
+ * assigned straight from `SlotProviderResolution`, and a three-member twin here would make
243
+ * `claude-pinned` unrepresentable on the very record that documents a cross-family spawn.
244
+ *
245
+ * Absent when the parent resolved no slot (every pre-P6.6 session, every test double, and every
246
+ * child whose model came from `AgentDefinition.model` host-side rather than from the tool).
247
+ */
248
+ slot?: {
249
+ family: string;
250
+ name: string;
251
+ source: ActiveSlotSet["source"];
252
+ };
253
+ /**
254
+ * SDK 0.0.16 (P16-7, R3a §2): a FORK's exact inherited request layout -- the parent's LAST rendered
255
+ * system prompt/blocks, its exact advertised tool specs (names/order/schemas), and its userContext
256
+ * entries, all captured verbatim from `context/request-layout.ts`'s own per-session memo
257
+ * (`getSessionRequestLayout`) at the moment this fork was spawned. `subagents/child-engine.ts`
258
+ * hands this straight to the child's own `runEngine()` as `EngineOptions.exactRequestLayout`, which
259
+ * bypasses that engine's OWN system-prompt assembly, tool-spec rendering and userContext build
260
+ * entirely -- the byte-exactness WS-10 §3.5 ("inherits... system prompt... tool pool... verbatim")
261
+ * needs cannot survive a second independent render, however faithful.
262
+ *
263
+ * Fork-only, mirroring `messages` above -- never set for a definition-backed or bare child, which
264
+ * render their own system prompt/tools normally (WS-10 §2's own per-child restriction concept has
265
+ * no equivalent for "send the parent's exact bytes").
266
+ */
267
+ requestLayout?: SessionRequestLayout;
268
+ }
269
+ export interface ChildEngineDeps {
270
+ spawn(req: SpawnChildRequest, inherit: ChildInheritance): Promise<ChildHandle>;
271
+ }
272
+ export interface ChildEngineRunContext {
273
+ parentSessionId: string;
274
+ parentAgentId?: string;
275
+ forwardChildFrame(frame: WinterFrame, correlation: {
276
+ parentToolUseId: string;
277
+ agentId: string;
278
+ }): void;
279
+ registerChildResponseHandler?(handle: (frame: ControlResponseFrame) => boolean): () => void;
280
+ /**
281
+ * RULING P5-J (Phase 5 fix wave): fold a DESCENDANT's provider usage into the OWNING session's
282
+ * cumulative spend.
283
+ *
284
+ * A per-run accessor rather than a construction-time mirror, for the reason every other live
285
+ * accessor on this interface exists: a registered factory is built once and the accountant belongs
286
+ * to a RUN. Without it a workflow's `budget` bounded only the parent's own turns while every agent
287
+ * it spawned spent freely -- which is what made `budget.spent()` report an honest but useless 0.
288
+ *
289
+ * Adds to the cumulative counter ONLY, never to `contextTokens()`: a child's tokens are spend the
290
+ * session is responsible for, and they are not part of the parent's own next request.
291
+ */
292
+ recordDescendantUsage?(usage: {
293
+ inputTokens: number;
294
+ outputTokens: number;
295
+ }): void;
296
+ /**
297
+ * The COST roll-up, beside the token one above: one PRICED generation of a descendant, folded into
298
+ * the owning run's cost ledger. Separate because a price is per MODEL and the token roll-up carries
299
+ * no model key. Without it a subagent's spend was invisible to `total_cost_usd` and `maxBudgetUsd`.
300
+ */
301
+ recordDescendantCost?(entry: import("../engine.js").PricedGenerationEntry): void;
302
+ /**
303
+ * Has the OWNING run (or any run above it) crossed its `maxBudgetUsd`? The child engine ORs this
304
+ * into its own budget check, so a descendant's main loop -- and any inner-model pass inside it,
305
+ * through `WebSessionRuntime.budgetExceeded` -- stops at its next request. `maxBudgetUsd` itself is
306
+ * deliberately NOT threaded into a child's config: a child's ledger is only its own subtree.
307
+ * Optional and additive: absent reads as "no".
308
+ */
309
+ budgetExceeded?(): boolean;
310
+ getParentPolicy?(): {
311
+ mode: PermissionMode;
312
+ version: number;
313
+ hash: string;
314
+ };
315
+ getParentRules?(): ParentRuleMirror;
316
+ getParentMcpState?(): ParentMcpState;
317
+ getParentAgents?(): Record<string, unknown> | undefined;
318
+ }
319
+ export interface ParentMcpState {
320
+ stateSource?: McpServerStateSource;
321
+ controlSeam?: McpControlSeam;
322
+ declaredServers?: Record<string, McpServerConfigForProcessTransport>;
323
+ /**
324
+ * Fix round 21: every MCP server the parent run can see -- its own board, its declared servers and,
325
+ * recursively, what IT inherited -- read at call time. A child's advertised partition keeps a live
326
+ * server's tools for these servers plus its own (engine.ts's `computeAdvertisedPartition`), so every
327
+ * descendant is offered the session's servers as claude's are (the Agent tool's pool is
328
+ * `JP($n, Y2(yr.mcp.tools.concat(pn)))`, dump byte 18016381).
329
+ */
330
+ visibleServerNames?: () => readonly string[];
331
+ }
332
+ export interface ParentRuleMirror {
333
+ allow: string[];
334
+ ask: string[];
335
+ deny: string[];
336
+ }
337
+ export type ChildEngineFactory = (runCtx: ChildEngineRunContext) => ChildEngineDeps;
338
+ export declare function registerChildEngineFactory(factory: ChildEngineFactory): void;
339
+ export declare function getChildEngineFactory(): ChildEngineFactory | undefined;
340
+ export declare function resetChildEngineFactoryForTest(): void;
341
+ export declare function transformChildFrame(frame: WinterFrame, correlation: {
342
+ parentToolUseId: string;
343
+ agentId: string;
344
+ }, forwardSubagentText: boolean): WinterFrame | null;