@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,68 @@
1
+ import { type BrandProfile, type SettingSource } from "@yanlinglabs/winter-agent-sdk";
2
+ export declare const DEFAULT_OUTPUT_STYLE_NAME = "default";
3
+ /** Per-style body ceiling. A style rides every request, so it needs a bound like every other injected file. */
4
+ export declare const OUTPUT_STYLE_MAX_BYTES: number;
5
+ export interface ResolvedOutputStyle {
6
+ /** Always the filename stem (or the built-in's name) -- never the frontmatter, so `list` and `resolve` cannot disagree. */
7
+ name: string;
8
+ description: string;
9
+ /** Injection-safe and capped for file styles; a trusted constant for built-ins. */
10
+ body: string;
11
+ /**
12
+ * `true` (the default) keeps the base prompt's coding-instructions section; `false` drops it. The
13
+ * style's body always lands in a dynamic section, in either case (fix round 4/I-F) -- this field
14
+ * never decides whether the body is added, only whether the ONE base section is cut.
15
+ */
16
+ keepCodingInstructions: boolean;
17
+ source: "project" | "user" | "builtin" | "plugin";
18
+ /** True when the file asked to DROP the coding-instructions section and the project-tier trust rule downgraded it to keeping it. */
19
+ replacementDowngraded: boolean;
20
+ }
21
+ /**
22
+ * The four built-ins. `default` is RESERVED: an empty body that is never injected, so selecting it
23
+ * is byte-identical to selecting nothing.
24
+ */
25
+ export declare const BUILTIN_OUTPUT_STYLES: readonly ResolvedOutputStyle[];
26
+ export declare const BUILTIN_OUTPUT_STYLE_NAMES: readonly string[];
27
+ /** A minimal projection of `plugins/bundle.ts`'s `PluginBundle` -- only the fields output-style resolution needs, so this file never depends on the plugin loader's own shape. */
28
+ export interface PluginOutputStyleSource {
29
+ name: string;
30
+ outputStylesPath?: string;
31
+ /**
32
+ * Fix round 5: a manifest `outputStyles` override -- see `PluginBundle.outputStylesPaths`'s own
33
+ * comment for why a real bundle never sets both this and `outputStylesPath` together (the override
34
+ * SHADOWS the default directory at load time). Each entry may be a directory (scanned the same way
35
+ * `outputStylesPath` is) or a single style file, matching claude's own `Tb`
36
+ * (`requireDirectory:false` for `output-styles`, dump-confirmed).
37
+ */
38
+ outputStylesPaths?: readonly string[];
39
+ }
40
+ export interface OutputStyleLookup {
41
+ cwd: string;
42
+ /** The resolved winter home (`~/<brand.homeDirName>` by default). */
43
+ home: string;
44
+ /** P7a (D19): the session's brand -- the project dot-dir the project tier is read from. Omitted = `WINTER_BRAND`. */
45
+ brand?: Pick<BrandProfile, "projectDirName">;
46
+ /** Omitted means all three tiers (the pinned default). */
47
+ settingSources?: readonly SettingSource[];
48
+ /** RULING P5-A's host-declared trust bit. Only `true` lets a PROJECT-tier style drop the coding-instructions section. */
49
+ trustedWorkspace?: boolean;
50
+ /**
51
+ * WS-21 §6.3 item 1 (fix round 2): the session's ENABLED plugins, projected to just the two
52
+ * fields a `<plugin>:<style>` lookup needs. Omitted (every pre-fix-round-2 caller) means no
53
+ * plugin ever resolves -- a qualified name simply falls through to `null`, matching what happened
54
+ * before this field existed.
55
+ */
56
+ pluginOutputStyles?: readonly PluginOutputStyleSource[];
57
+ }
58
+ /**
59
+ * Resolve a style by name: a `<plugin>:<style>` qualified name resolves against that plugin's own
60
+ * `output-styles/` directory (WS-21 §6.3 item 1) regardless of `settingSources` -- a plugin is
61
+ * DELIBERATELY NOT source-gated anywhere else in this codebase either (subagents/definitions.ts's
62
+ * own header states the identical reasoning: a plugin is loaded because the HOST or the USER
63
+ * decided to, a decision already made outside the repository, so gating it on workspace trust would
64
+ * make plugin behaviour depend on which directory the session happens to be in). Otherwise: project
65
+ * (source-gated) > user (source-gated) > built-in. Never throws; `null` means the name resolves to
66
+ * nothing, which the assembler treats as "no style".
67
+ */
68
+ export declare function resolveOutputStyle(name: string, lookup: OutputStyleLookup): ResolvedOutputStyle | null;
@@ -0,0 +1,29 @@
1
+ /**
2
+ * FIXED. States the restriction the permission engine enforces, so a denial is never a surprise.
3
+ */
4
+ export declare const PLAN_MODE_ENFORCEMENT: string;
5
+ /**
6
+ * REPLACEABLE. Winter's own answer to "what makes a good plan", used when the host supplies none.
7
+ */
8
+ export declare const DEFAULT_PLAN_BODY: string;
9
+ /** FIXED. The ExitPlanMode contract, plus where a written plan belongs. */
10
+ export declare const PLAN_MODE_PROTOCOL: string;
11
+ export interface PlanModeInput {
12
+ /** Where a plan file belongs when one is written. `RuntimeConfig.plansDirectory` / `Settings.plansDirectory`, default `<brand.projectDirName>/plans`. */
13
+ plansDirectory: string;
14
+ /** The host's replacement for the middle section (`planModeInstructions` on the wire). Whitespace-only counts as absent. */
15
+ hostPlanBody?: string;
16
+ /**
17
+ * P7a fix r1 (Minor-1): what a REFUSED `plansDirectory` falls back to.
18
+ *
19
+ * `renderablePlansDirectory` refuses a value that fails RULING P5-L's alphabet and substitutes
20
+ * this. It used to be `DEFAULT_PLANS_DIRECTORY` — Winter's own `<dot-dir>/plans` — under every
21
+ * brand, so the one path that reaches the model when a project's setting is malformed named a
22
+ * directory a reuser's product does not have. The caller (`context/assembler.ts`) already derives
23
+ * the NORMAL value from the session's profile; this is the same string.
24
+ */
25
+ plansDirectoryFallback?: string;
26
+ }
27
+ /** The value as it may be rendered into `system`: the caller's, if it is a plain path; otherwise the pinned default. */
28
+ export declare function renderablePlansDirectory(raw: string, fallback: string): string;
29
+ export declare function renderPlanModeBlock(input: PlanModeInput): string;
@@ -0,0 +1,138 @@
1
+ import type { ContentBlock, ProviderMessage, ProviderToolSpec } from "../engine.js";
2
+ import type { SystemPromptBlock } from "@yanlinglabs/winter-provider-runtime";
3
+ /** One userContext / systemContext entry, in the order it is rendered. */
4
+ export type ContextEntry = readonly [key: string, value: string];
5
+ /**
6
+ * claude's `mbt` text for a userContext map, or `undefined` when the map is empty (claude then
7
+ * prepends nothing). Exactly one trailing newline; the second one the wire shows comes from the
8
+ * merge with the prompt (`Noe`).
9
+ */
10
+ export declare function renderUserContext(entries: readonly ContextEntry[]): string | undefined;
11
+ /** claude's `pbt` systemContext part: `key: value` lines. `undefined` when there are none. */
12
+ export declare function renderSystemContext(entries: readonly ContextEntry[]): string | undefined;
13
+ /**
14
+ * claude's `VEe` for Winter's two halves. With a dynamic boundary (Winter's authored prompt, the
15
+ * preset, or a caller array that names one) the static half is one `global` block and the dynamic
16
+ * half -- systemContext appended last -- one `org` block. Without a boundary (a caller string, or a
17
+ * caller array with none) everything is one `org` block. Empty parts are dropped (`filter(Boolean)`).
18
+ */
19
+ export declare function buildSystemBlocks(input: {
20
+ staticParts: readonly string[];
21
+ dynamicParts: readonly string[];
22
+ systemContext?: string;
23
+ hasBoundary: boolean;
24
+ }): SystemPromptBlock[];
25
+ /** The `system` string equivalent of a block list (what a block-unaware provider receives). */
26
+ export declare function joinSystemBlocks(blocks: readonly SystemPromptBlock[]): string;
27
+ /**
28
+ * claude's `SJn` (reorderAttachmentsForAPI). WS-23: `stays` names attachments that keep their HISTORY
29
+ * position instead of bubbling up -- a system-role reminder must follow the user turn that triggered
30
+ * it, which is exactly where the engine appended it.
31
+ */
32
+ export declare function reorderAttachments(messages: readonly ProviderMessage[], stays?: (message: ProviderMessage) => boolean): ProviderMessage[];
33
+ /**
34
+ * claude's `NMe`: a reminder that must never be folded into a tool result (its poll-event
35
+ * deliveries). Ported literally; Winter produces neither prefix today, so this only keeps a
36
+ * claude-written transcript's shape intact on resume.
37
+ */
38
+ export declare function isSmooshExempt(text: string): boolean;
39
+ type ToolResultBlock = Extract<ContentBlock, {
40
+ type: "tool_result";
41
+ }>;
42
+ type TextBlock = Extract<ContentBlock, {
43
+ type: "text";
44
+ }>;
45
+ /**
46
+ * claude's `IMe`: fold trailing text blocks INTO a tool result. `null` when the result carries a
47
+ * `tool_reference` (claude refuses to fold into those).
48
+ */
49
+ export declare function foldTextIntoToolResult(result: ToolResultBlock, texts: TextBlock[]): ToolResultBlock | null;
50
+ /**
51
+ * The live request's message list: `history` with the index-0 context prepended, attachments
52
+ * reordered and consecutive user-role messages merged, exactly as the pinned binary builds it.
53
+ * Never mutates `history`. Assistant messages pass through untouched (their own merge is the
54
+ * adapters' business, as before).
55
+ */
56
+ export declare function buildRequestMessages(history: readonly ProviderMessage[], userContextText?: string, opts?: {
57
+ systemReminders?: boolean;
58
+ effort?: EffortMarkerPlan;
59
+ toolChanges?: ToolChangeRendering;
60
+ }): ProviderMessage[];
61
+ /**
62
+ * WS-23 (midconv): which `tool_changes` entries this request renders -- the active epoch's, by identity
63
+ * (the engine's own history objects). Absent: every bookkeeping entry is dropped (today's layout).
64
+ */
65
+ export interface ToolChangeRendering {
66
+ render: ReadonlySet<ProviderMessage>;
67
+ }
68
+ /** WS-23: the per-message effort plan `buildRequestMessages` lays out -- see `withEffortMarkers`. */
69
+ export interface EffortMarkerPlan {
70
+ /** The level in force before any marker: the frozen top-level value, or the model's default when none is sent. */
71
+ initial: string;
72
+ /** The level for the turn being generated now. */
73
+ live: string;
74
+ /** Levels the target row can take. */
75
+ accepts: (effort: string) => boolean;
76
+ /**
77
+ * WS-23 (reasoning-state): whether an assistant message is the TARGET model's own. A per-message effort
78
+ * level is a cache quirk of one model -- a vocabulary and a cached prefix of its own -- so only its own
79
+ * replies' levels become markers; another model's reply is read as un-annotated (no marker). Absent:
80
+ * every reply counts (the pre-WS-23 reading, and a session with no provider identity).
81
+ */
82
+ owns?: (message: ProviderMessage) => boolean;
83
+ }
84
+ /**
85
+ * `ordered` (the history AFTER the attachment reorder and BEFORE the user-turn merge) with an
86
+ * effort-only `system` marker before every human turn whose level differs from the one in force before
87
+ * it. Run before the merge on purpose (fix round 1, I2): after it, a prompt that follows an INTERRUPTED
88
+ * tool round is folded into the `tool` message ahead of it and is no longer recognisable as a turn
89
+ * start -- the change would silently not apply while the transcript recorded it. A marker is never
90
+ * merged, so it also keeps that prompt as its own user entry.
91
+ *
92
+ * PLACEMENT: before the turn's attachments when they bubbled up to the previous assistant reply (so
93
+ * the common case keeps its merged user entry), otherwise directly before the prompt. A turn with no
94
+ * annotated reply (a host-supplied or pre-WS-23 history) is left alone, and a level the row cannot take
95
+ * gets no marker -- both deterministic, so still byte-stable.
96
+ */
97
+ export declare function withEffortMarkers(ordered: readonly ProviderMessage[], plan: EffortMarkerPlan): ProviderMessage[];
98
+ /**
99
+ * WS-23: every tool name a ToolSearch result in `history` surfaced (`tool_result.loadedTools`, advertised
100
+ * names). A deferred tool in this set is referenced somewhere in the history, so it can stay declared
101
+ * `defer_loading: true`; a loaded tool outside it would be invisible to the model and is sent plainly.
102
+ */
103
+ export declare function referencedToolNames(history: readonly ProviderMessage[], modelKey?: string | null): Set<string>;
104
+ /**
105
+ * The top-level effort the session sent, read back off a history: the newest ANNOTATED assistant
106
+ * message's own `effort` (absent means the session sent none at the top level). `undefined` when no
107
+ * assistant message is annotated at all -- nothing to restore.
108
+ */
109
+ export declare function frozenEffortFromHistory(history: readonly ProviderMessage[], owns?: (message: ProviderMessage) => boolean): {
110
+ value: string | undefined;
111
+ } | undefined;
112
+ /**
113
+ * What a session last sent: the exact system blocks, the userContext entries behind its index-0
114
+ * message, and the tool specs. A byte-exact fork (a later lane) reuses these verbatim; nothing in
115
+ * this lane reads them.
116
+ */
117
+ export interface SessionRequestLayout {
118
+ system?: string;
119
+ systemBlocks: SystemPromptBlock[];
120
+ userContext: ContextEntry[];
121
+ tools: ProviderToolSpec[];
122
+ }
123
+ /** Records the layout of the request a session (or one of its agents) just sent. */
124
+ export declare function recordSessionRequestLayout(sessionId: string, agentId: string | undefined, layout: SessionRequestLayout): void;
125
+ /** The layout a session (or one of its agents) last sent, or `undefined` before its first request. */
126
+ export declare function getSessionRequestLayout(sessionId: string, agentId?: string): SessionRequestLayout | undefined;
127
+ /** Drops a session's (or agent's) recorded layout -- the engine's teardown calls this. */
128
+ export declare function clearSessionRequestLayout(sessionId: string, agentId?: string): void;
129
+ /** The engine registers its session-context memo's clear hook here (and withdraws it at teardown). */
130
+ export declare function registerSessionContextReload(sessionId: string, agentId: string | undefined, clear: () => void): void;
131
+ export declare function unregisterSessionContextReload(sessionId: string, agentId?: string): void;
132
+ /**
133
+ * EXPLICIT RELOAD: drop a live session's memoized userContext/systemContext so its next request
134
+ * re-reads the instructions files, the memory index and the git snapshot (claude does the same on a
135
+ * `reload_claude_md`-style request). `false` when no such session is running.
136
+ */
137
+ export declare function reloadSessionContext(sessionId: string, agentId?: string): boolean;
138
+ export {};
@@ -0,0 +1,63 @@
1
+ import type { BrandProfile } from "@yanlinglabs/winter-agent-sdk";
2
+ import type { AttachmentProducer, ProviderMessage } from "../engine.js";
3
+ import { type AttachmentPayload } from "./attachments.js";
4
+ export type RuleSettingSource = "user" | "project" | "local";
5
+ export interface LoadedRule {
6
+ /** Absolute path of the rule `.md` file. */
7
+ path: string;
8
+ tier: "user" | "project";
9
+ /** The rule's body, frontmatter stripped, trimmed. */
10
+ content: string;
11
+ /** Present (and non-empty) iff this is a CONDITIONAL rule. Raw glob strings, as authored. */
12
+ paths?: string[];
13
+ /**
14
+ * PROJECT tier only: the parent of the project dot-dir (brand.projectDirName) this rule file was
15
+ * discovered under, fixed at load time (F17's "relative to the parent of the project dot-dir").
16
+ * Absent for a user-tier rule, which resolves against whatever `originalCwd` `ruleMatches` is
17
+ * called with instead.
18
+ */
19
+ projectBase?: string;
20
+ }
21
+ export interface LoadRulesInput {
22
+ /** The winter home (`<PREFIX>HOME`, i.e. the shared runtime home under WS-21). */
23
+ home: string;
24
+ cwd: string;
25
+ /** The repository root, or `null` outside one. Project rules load only when this is set. */
26
+ projectRoot: string | null;
27
+ /** Omitted means every tier loads (loadRules has no separate "all tiers" default of its own --
28
+ * every caller threads the session's resolved settingSources explicitly). */
29
+ sources: readonly RuleSettingSource[];
30
+ brand: Pick<BrandProfile, "projectDirName">;
31
+ }
32
+ /**
33
+ * Load every rule visible to this session, split into UNCONDITIONAL (always present) and
34
+ * CONDITIONAL (announced on-touch, `conditionalRuleAttachmentProducer` below).
35
+ */
36
+ export declare function loadRules(input: LoadRulesInput): {
37
+ unconditional: LoadedRule[];
38
+ conditional: LoadedRule[];
39
+ };
40
+ /**
41
+ * Whether `filePath` matches one of `rule`'s `paths:` globs. `false` for an unconditional rule
42
+ * (nothing to match). `originalCwd` is the USER-tier base; a PROJECT-tier rule ignores it and uses
43
+ * its own fixed `projectBase` instead (see `LoadedRule.projectBase`'s header).
44
+ */
45
+ export declare function ruleMatches(rule: LoadedRule, filePath: string, originalCwd: string): boolean;
46
+ export interface ConditionalRuleAttachment extends AttachmentPayload {
47
+ type: "conditional_rule";
48
+ /** `LoadedRule.path` -- the dedupe key the "announced" fold reads back. */
49
+ path: string;
50
+ content: string;
51
+ }
52
+ /** Every conditional rule already announced in this history, keyed by `LoadedRule.path` -- the identical persisted-fold shape `dateChangeAnnounced`/`skillListingResumeSeed` already use. */
53
+ export declare function announcedRulePaths(messages: readonly ProviderMessage[]): Set<string>;
54
+ /**
55
+ * The conditional-rule attachment producer: scans the engine's own history for every Read/Edit/Write
56
+ * `file_path` an assistant turn has issued, and for each conditional rule not yet announced
57
+ * (`announcedRulePaths`), emits it the first time one of those paths matches. Once emitted, the
58
+ * PERSISTED attachment is what stops a second emission -- the fold reads it back exactly like every
59
+ * other attachment type does, so this producer itself carries no state across calls.
60
+ */
61
+ export declare function conditionalRuleAttachmentProducer(rules: readonly LoadedRule[], opts: {
62
+ originalCwd: string;
63
+ }): AttachmentProducer;
@@ -0,0 +1,136 @@
1
+ import type { RuntimeConfig } from "@yanlinglabs/winter-agent-sdk";
2
+ import type { ContextEntry } from "./request-layout.js";
3
+ export type SkillListing = Array<{
4
+ name: string;
5
+ description: string;
6
+ source: "project" | "user" | "plugin" | "builtin" | "self";
7
+ }>;
8
+ /**
9
+ * The configured output style's NAME -- `RuntimeConfig.outputStyle` / `Settings.outputStyle`, e.g.
10
+ * `"default"`.
11
+ *
12
+ * DIVERGENCE FROM THE BRIEF'S SPELLING, disclosed: the task-3 brief writes `outputStyle?: OutputStyle`
13
+ * without defining `OutputStyle`, and the obvious richer reading (a resolved `{name, body}` object)
14
+ * would put style RESOLUTION in the engine. It belongs to Lane C -- project-tier output styles
15
+ * discovery plus Winter's built-ins is that lane's own deliverable (task-6 brief), and the engine has
16
+ * no business reading those files. So the seam carries the name and Lane C resolves the body, and the
17
+ * brief's type name is kept so a lane brief citing it still lands somewhere.
18
+ */
19
+ export type OutputStyle = string;
20
+ /**
21
+ * Everything the assembler is allowed to depend on. Deliberately a PLAIN DATA snapshot: no
22
+ * filesystem handles, no live getters, nothing session-mutable. Two consequences the lanes rely on --
23
+ * an assembler is trivially testable from a literal, and the engine can compute this once per
24
+ * envelope and reuse it for every provider call in that turn without re-reading the world mid-turn.
25
+ *
26
+ * `env`/`platform`/`osVersion`/`shell`/`model` feed the `# Environment` section; `date` feeds the
27
+ * userContext `currentDate` entry (SDK 0.0.16). Whether the environment and auto-memory sections land
28
+ * in `system` or move into the index-0 userContext is `excludeDynamicSections`' job, which lives inside
29
+ * `config.systemPrompt`'s preset arm, not here.
30
+ */
31
+ export interface SystemPromptInput {
32
+ config: RuntimeConfig;
33
+ cwd: string;
34
+ env: Record<string, string | undefined>;
35
+ platform: string;
36
+ osVersion: string;
37
+ shell: string;
38
+ /** The session's LOCAL calendar date, `YYYY-MM-DD` (claude's `currentDate`). */
39
+ date: string;
40
+ /** SDK 0.0.16: the model id this session generates with, for the `# Environment` model line. */
41
+ model?: string;
42
+ /** SDK 0.0.16: the model's display name, when the host's catalog knows one. */
43
+ modelDisplayName?: string;
44
+ memoryDir?: string;
45
+ outputStyle?: OutputStyle;
46
+ planMode: boolean;
47
+ hostPlanBody?: string;
48
+ /**
49
+ * DISCLOSED WINTER FIELD, not in the brief's list: the child persona a subagent runs with
50
+ * (`AgentDefinition.prompt` composed over any inherited base -- subagents/child-engine.ts computes
51
+ * it). R5-3 retires P4-J's first-turn concatenation of that text into the message history and
52
+ * routes it "through `system`" instead; this is the field it travels on.
53
+ *
54
+ * An assembler that ignores it silently drops a child's persona, so Lane C MUST compose it. The
55
+ * engine's own no-assembler fallback uses it VERBATIM as the whole system prompt, which is
56
+ * consistent with R5-16: the engine still authors no text of its own, it only forwards the
57
+ * caller's.
58
+ */
59
+ agentPrompt?: string;
60
+ /**
61
+ * Spawn-surface parity (research §A1's `Explore`/`Plan` field table: "`omitClaudeMd: true`;
62
+ * context also drops gitStatus", mirrored on `RuntimeAgentDefinition.omitProjectContext`). When
63
+ * true, the index-0 userContext carries NO `claudeMd` entry at all (claude's `omitClaudeMd` drops the
64
+ * whole value -- the auto-memory index is one of its entries, so it goes too) and the systemContext
65
+ * `gitStatus` is not produced (`systemContextPlacement: "none"`). Everything else -- the date, the
66
+ * environment and auto-memory sections, the listings -- is unaffected.
67
+ */
68
+ omitProjectContext?: boolean;
69
+ }
70
+ /**
71
+ * What the assembler produces.
72
+ *
73
+ * `system` goes on `ProviderRequest.system` (with the systemContext appended by the engine).
74
+ *
75
+ * SDK 0.0.16 (P16-5): NOTHING IS ATTACHED TO THE TURN'S USER MESSAGE ANY MORE. The instructions
76
+ * files and the memory index are the index-0 userContext (`SystemPromptAssembler.userContext`,
77
+ * memoized per session by the engine); the listings are persisted attachments
78
+ * (context/attachments.ts). `userContextBlocks` is gone.
79
+ *
80
+ * `presetVersion` is the version stamp of whichever authored prompt produced `system`, for
81
+ * conformance/diagnostics -- absent exactly when WINTER AUTHORED NOTHING (the caller-supplied
82
+ * `string` and `string[]` arms), stamped for `undefined` (`winter_minimal@<n>`) and the preset arm.
83
+ */
84
+ export interface AssembledPrompt {
85
+ system: string;
86
+ /**
87
+ * SDK 0.0.16: `system` before it was joined -- the static (cacheable) half, the dynamic half, and
88
+ * whether the region has a dynamic boundary at all. The engine turns these into claude's cache
89
+ * blocks (`buildSystemBlocks`). Absent (a test double) = `system` is one uncached-scope block and the
90
+ * request carries no `systemBlocks`.
91
+ */
92
+ systemParts?: {
93
+ staticParts: string[];
94
+ dynamicParts: string[];
95
+ hasBoundary: boolean;
96
+ };
97
+ /**
98
+ * SDK 0.0.16: where the engine puts the systemContext `gitStatus` snapshot -- `system` (the last
99
+ * system part, the default layout), `userContext` (the FIRST index-0 entry, under
100
+ * `excludeDynamicSections`), or `none` (a caller-supplied prompt, an `omitProjectContext` agent,
101
+ * the kill switch, `includeGitInstructions: false`). Absent = `none`.
102
+ */
103
+ systemContextPlacement?: "system" | "userContext" | "none";
104
+ presetVersion?: string;
105
+ /**
106
+ * Phase 5 Task 8 (rider 22, RULING P5-G): TRUE when a PROJECT-tier output style asked to replace
107
+ * Winter's authored prompt (`keep-coding-instructions: false`) and the assembler downgraded it to
108
+ * an append because the host has not declared workspace trust. ABSENT (never `false`) otherwise.
109
+ */
110
+ replacementDowngraded?: boolean;
111
+ }
112
+ export interface SystemPromptAssembler {
113
+ assemble(input: SystemPromptInput): AssembledPrompt;
114
+ /**
115
+ * SDK 0.0.16 (P16-5): the session's userContext entries, in claude's key order -- `claudeMd`, then
116
+ * `currentDate` (then, under `excludeDynamicSections`, `Environment` and `auto memory`). The ENGINE
117
+ * memoizes the result per session and clears it on compaction, so this reads the filesystem once
118
+ * per session context rather than once per turn. Absent = no index-0 message.
119
+ */
120
+ userContext?(input: SystemPromptInput): ContextEntry[];
121
+ }
122
+ /**
123
+ * The spine's own test double. NOT a minimal prompt and never a stand-in for one (R5-16): it echoes
124
+ * its inputs in a mechanically checkable shape so an engine test can prove the assembled result
125
+ * reached the LIVE request, and so a lane can develop against a producer that exists.
126
+ *
127
+ * Every part is optional-in, deterministic, and free of authored prose.
128
+ */
129
+ export declare function fakeSystemPromptAssembler(opts?: {
130
+ system?: string;
131
+ /** SDK 0.0.16: the userContext entries the fake answers (absent = none, so no index-0 message). */
132
+ userContext?: ContextEntry[];
133
+ presetVersion?: string;
134
+ /** Records every input the engine handed over, in call order -- the "was it called per turn, with what?" assertion. */
135
+ calls?: SystemPromptInput[];
136
+ }): SystemPromptAssembler;
@@ -0,0 +1,118 @@
1
+ import type { ProviderMessage, ProviderToolSpec } from "../engine.js";
2
+ import type { ToolChangeSet } from "@yanlinglabs/winter-provider-runtime";
3
+ import type { AttachmentPayload } from "./attachments.js";
4
+ /**
5
+ * Which vendor form this epoch's changes take. Chosen per model from its catalog evidence:
6
+ * - `anthropic-inline`: by value and by reference (`inlineToolDefinitions`, Claude API only);
7
+ * - `anthropic-reference`: by reference only (`midConversationToolChanges`);
8
+ * - `openai`: `additional_tools` and/or `allowed_tools` (`additionalToolsItem` / `allowedToolsChoice`).
9
+ */
10
+ export type ToolChangeMechanism = "anthropic-reference" | "anthropic-inline" | "openai";
11
+ export declare const TOOL_EPOCH_ATTACHMENT = "tool_epoch";
12
+ export declare const TOOL_CHANGES_ATTACHMENT = "tool_changes";
13
+ /** The epoch's frozen `tools` array, verbatim, and the model and mechanism it was frozen for. */
14
+ export interface ToolEpochAttachment extends AttachmentPayload {
15
+ type: "tool_epoch";
16
+ mechanism: ToolChangeMechanism;
17
+ /** The catalog key of the model the epoch belongs to (`null` for a session with no identity). */
18
+ modelKey: string | null;
19
+ tools: ProviderToolSpec[];
20
+ }
21
+ /**
22
+ * One change point. `declare` is appended to `tools` from here on (Anthropic's deferred declarations:
23
+ * a tool must be declared before a reference can name it); `remove` and `add` are what the model reads
24
+ * at this position.
25
+ */
26
+ export interface ToolChangesAttachment extends AttachmentPayload {
27
+ type: "tool_changes";
28
+ mechanism: ToolChangeMechanism;
29
+ /**
30
+ * WS-23 (reasoning-state): the model whose epoch this change extends. Several models' epochs can now
31
+ * sit in one history (a switch no longer retires the earlier model's), so each change names its own.
32
+ * Absent on an entry a dev build wrote into the transcript: it belongs to the epoch before it.
33
+ */
34
+ modelKey?: string | null;
35
+ declare: ProviderToolSpec[];
36
+ remove: string[];
37
+ add: ToolChangeSet["add"];
38
+ }
39
+ export declare function isToolEpochMessage(message: ProviderMessage): boolean;
40
+ export declare function isToolChangesMessage(message: ProviderMessage): boolean;
41
+ /** Either bookkeeping attachment -- neither is ever sent as text. */
42
+ export declare function isToolBookkeeping(message: ProviderMessage): boolean;
43
+ /** The identity of one definition as the model reads it: name, description, schema -- never Winter's own flags. */
44
+ export declare function toolDefinitionKey(spec: {
45
+ name: string;
46
+ description: string;
47
+ inputSchema: Record<string, unknown>;
48
+ }): string;
49
+ /**
50
+ * The history's newest epoch for `mechanism` on `modelKey` -- that MODEL's own, wherever it sits.
51
+ *
52
+ * WS-23 (reasoning-state): a later epoch of ANOTHER model no longer retires this one. The tool list is a
53
+ * cache quirk of one model, so each model keeps its own epoch in the history and reads only its own:
54
+ * after Claude -> GPT -> Claude, Claude's epoch (and the cached prefix it heads) is still there to
55
+ * resume. Whether it SHOULD be resumed -- the cache may have expired while the other model ran -- is the
56
+ * engine's call (`planToolsForRequest`, the TTL rule); this only finds it.
57
+ */
58
+ export declare function activeToolEpoch(history: readonly ProviderMessage[], mechanism: ToolChangeMechanism, modelKey: string | undefined): {
59
+ index: number;
60
+ epoch: ToolEpochAttachment;
61
+ } | undefined;
62
+ /**
63
+ * The `tool_changes` entries that belong to the epoch at `epochIndex`, in order: after it, on its
64
+ * mechanism, and of its MODEL (WS-23 -- another model's changes in between are that model's). A change
65
+ * with no `modelKey` (a dev-build transcript entry) belongs to whichever epoch precedes it.
66
+ */
67
+ export declare function epochChangeMessages(history: readonly ProviderMessage[], epochIndex: number, mechanism: ToolChangeMechanism): ProviderMessage[];
68
+ /** What the model can see at the tail of an epoch: the declared `tools` array, and the tools it may call. */
69
+ export interface ToolState {
70
+ /** The request's `tools` array: the frozen list, then every `declare` in order. Never sorted again. */
71
+ declared: ProviderToolSpec[];
72
+ /** Name -> the definition the model currently has for it. */
73
+ available: Map<string, ProviderToolSpec>;
74
+ }
75
+ /**
76
+ * Folds an epoch and its change entries into the state at the tail. `referenced` are the deferred names
77
+ * a ToolSearch result surfaced (`tool_result.loadedTools`): on Anthropic those are callable through the
78
+ * `tool_reference` blocks the adapter writes into the result, so they count as available.
79
+ */
80
+ export declare function foldToolState(epoch: ToolEpochAttachment, changes: readonly ProviderMessage[], referenced?: ReadonlySet<string>): ToolState;
81
+ /** The frozen `tools` array for a NEW epoch. OpenAI's client tool search never declares a deferred tool (it rides the search output). */
82
+ export declare function epochToolsFor(live: readonly ProviderToolSpec[], mechanism: ToolChangeMechanism): ProviderToolSpec[];
83
+ /** What the mechanism can express, from the row's evidence. */
84
+ export interface ToolChangeCaps {
85
+ /** OpenAI: an `additional_tools` item may add or redefine a tool. */
86
+ additionalTools?: boolean;
87
+ /** OpenAI: `tool_choice: allowed_tools` may restrict the callable set. */
88
+ allowedTools?: boolean;
89
+ }
90
+ export type ToolDiff = {
91
+ kind: "same";
92
+ allowedTools?: string[];
93
+ } | {
94
+ kind: "change";
95
+ change: Pick<ToolChangesAttachment, "declare" | "remove" | "add">;
96
+ allowedTools?: string[];
97
+ }
98
+ /** The mechanism cannot express this change: start a new epoch (today's full rebuild of `tools`, once). */
99
+ | {
100
+ kind: "new-epoch";
101
+ reason: string;
102
+ };
103
+ /**
104
+ * The live tool list against the folded state: what to append, or that the epoch cannot express it.
105
+ *
106
+ * `live` is the engine's own per-request list (sorted by name; on a deferred-loading row, deferred tools
107
+ * carry `deferLoading`, which means "declared, not shown"). Deterministic: removals and additions are in
108
+ * name order, declarations in `live` order.
109
+ */
110
+ export declare function diffToolState(live: readonly ProviderToolSpec[], state: ToolState, mechanism: ToolChangeMechanism, caps?: ToolChangeCaps): ToolDiff;
111
+ /** The wire form of one `tool_changes` entry: an empty-content `system` message, or `undefined` when it says nothing. */
112
+ export declare function toolChangesWireMessage(message: ProviderMessage): ProviderMessage | undefined;
113
+ /**
114
+ * The deferred tools a `tool_changes` entry of the current epoch surfaced by reference (see
115
+ * `referencedToolNames`). WS-23: with `modelKey`, the current epoch is THAT model's newest (and only its
116
+ * own changes count); without, the history's last epoch of any model -- the pre-WS-23 reading.
117
+ */
118
+ export declare function toolChangeReferences(history: readonly ProviderMessage[], modelKey?: string | null): string[];
@@ -0,0 +1,39 @@
1
+ import { type BrandProfile, type SystemPromptPreset } from "@yanlinglabs/winter-agent-sdk";
2
+ /**
3
+ * The categories WS-11 §6.2 requires, in the order the document lists them. Each is a `## `
4
+ * heading in the preset, which is what makes coverage checkable by a test rather than by a reader.
5
+ */
6
+ export declare const WINTER_CODE_PRESET_CATEGORIES: readonly string[];
7
+ /**
8
+ * Bump on any edit to `presets/winter-code.md`. WS-11 §6.2 requires the preset to be versioned so a
9
+ * conformance run can say WHICH authored preset it compared, and so a behaviour change is
10
+ * attributable to a prompt revision rather than to a model.
11
+ */
12
+ export declare const WINTER_CODE_PRESET_VERSION: string;
13
+ /** The authored preset text. Trailing whitespace trimmed once, here, so no caller has to. */
14
+ export declare const WINTER_CODE_PRESET: string;
15
+ /**
16
+ * Both accepted spellings of the preset for a given brand. `claude_code` is the Claude-mirroring
17
+ * compatibility alias (WS-01 §5, never rebranded); `brand.presetName` is the native one (WS-01 §6).
18
+ */
19
+ export declare function winterCodePresetNames(brand?: Pick<BrandProfile, "presetName">): readonly string[];
20
+ /** The default profile's pair, for every caller that has not threaded a brand. */
21
+ export declare const WINTER_CODE_PRESET_NAMES: readonly string[];
22
+ export declare function isWinterCodePreset(preset: string, brand?: Pick<BrandProfile, "presetName">): boolean;
23
+ /**
24
+ * The preset arm's system text: the preset, then `append`.
25
+ *
26
+ * `append` ADDS; it never replaces any part of the preset (WS-11 §6.2). A whitespace-only append is
27
+ * treated as absent so a host that always sets the field from an optional config value does not get
28
+ * a trailing blank section.
29
+ */
30
+ export declare function resolvePresetSystemPrompt(preset: SystemPromptPreset): string;
31
+ /**
32
+ * Removes ONLY the coding-instructions section from an authored prompt string, collapsing the
33
+ * resulting blank-line run back down to one blank line. A SAFE NO-OP when the start heading is
34
+ * absent (e.g. `MINIMAL_PROMPT`, which has no such section at all -- fix round 4 disclosed this as
35
+ * an intentional behaviour change, see `assembler.test.ts`) or when the end heading cannot be found
36
+ * after it (a malformed/future preset shape): returns `prompt` unchanged rather than guessing at or
37
+ * truncating past a boundary that turned out not to be there.
38
+ */
39
+ export declare function dropCodingInstructionsSection(prompt: string): string;