@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 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ /** The name `engine.ts`'s `toolSpecFor` branches on for the lean/full choice, mirroring `WEB_SEARCH_CANONICAL_NAME` -- so no tool name is a literal there. */
2
+ export declare const WEB_FETCH_CANONICAL_NAME = "WebFetch";
3
+ export declare const WEB_FETCH_DESCRIPTION_LEAN: string;
4
+ export declare const WEB_FETCH_DESCRIPTION_FULL: string;
5
+ /** claude's own `leanPrompt(model)` gate, applied to WebFetch's description exactly as `sessionLeanModel` applies it to the Agent tool's `whenToUseLean`. */
6
+ export declare function webFetchDescriptionFor(leanModel: boolean): string;
7
+ /** The schema to ADVERTISE: claude's own bytes for a first-party Anthropic session, the portable rendering for every other provider (see the block comment above). */
8
+ export declare function webFetchInputSchemaFor(firstPartyAnthropic: boolean): Record<string, unknown>;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Mirrors `provider/slots.ts`'s own `AGENT_TOOL_CANONICAL_NAME` precedent: `engine.ts`'s `toolSpecFor`
3
+ * recognises this descriptor by canonical name WITHOUT spelling `"WebSearch"` as a literal at its own
4
+ * call site. This file's `stub(descriptor)` call below is the only other place the name originates.
5
+ */
6
+ export declare const WEB_SEARCH_CANONICAL_NAME = "WebSearch";
7
+ /** `new Date().toLocaleString("en-US",{month:"long",year:"numeric"})`, e.g. "September 2026" -- claude's own `${t}`. */
8
+ export declare function currentMonthYear(now?: () => Date): string;
9
+ /**
10
+ * Renders WebSearch's description AT THE CALL SITE -- so the month is always today's, whether the
11
+ * caller is `toolSpecFor` at advertise time or a test. `now` is injectable for tests.
12
+ */
13
+ export declare function webSearchDescription(lean: boolean, now?: () => Date): string;
14
+ /** The schema to ADVERTISE: claude's own bytes for a first-party Anthropic session, the portable rendering for every other provider. */
15
+ export declare function webSearchInputSchemaFor(firstPartyAnthropic: boolean): Record<string, unknown>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,14 @@
1
+ import type { WinterToolCaller } from "@yanlinglabs/winter-agent-sdk/tools";
2
+ import type { ToolExecutionContext } from "../registry.js";
3
+ /**
4
+ * The caller identity a messaging tool runs AS — from the execution context, never from the
5
+ * arguments. Taking it from the arguments would make the sender's identity something a model could
6
+ * write, and every fence in the messaging core is keyed on it.
7
+ *
8
+ * `ctx.toolUseId` is real (registry.ts threads `EngineToolCall.id` onto every context it builds), so
9
+ * WS-10 §12's retry-stable messageId derivation is live in production. It is passed through as
10
+ * possibly-undefined rather than defaulted here: the SDK's port allocates the fallback, once, for
11
+ * both hosts, and its posture is the one this runtime used to carry — a fresh id per call and NO
12
+ * dedupe, because two distinct model calls must never be mistaken for one retry of each other.
13
+ */
14
+ export declare function callerContextFrom(ctx: ToolExecutionContext): WinterToolCaller;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * One list entry, or one host/URL under test, as the canonical hostname the URL parser gives it --
3
+ * or `undefined` for something that names no host.
4
+ *
5
+ * Tolerant of what people actually write in a block-list: a leading `*.` or `.`, a scheme, userinfo,
6
+ * a port, a path, surrounding whitespace, a unicode name, a bare IPv6 address.
7
+ * `https://Ads.Example.com/track` and `*.ads.example.com` both become `ads.example.com`.
8
+ */
9
+ export declare function normalizeDomain(entry: string): string | undefined;
10
+ /** `host` is `domain`, or a subdomain of it when `domain` is a multi-label NAME. Both are normalised first. */
11
+ export declare function hostMatchesDomain(host: string, domain: string): boolean;
12
+ /** The first entry of `domains` that covers `hostOrUrl`, or `undefined`. */
13
+ export declare function matchingDomain(hostOrUrl: string, domains: readonly string[]): string | undefined;
14
+ export declare function isDomainBlocked(hostOrUrl: string, blockedDomains: readonly string[]): boolean;
15
+ /** Normalised, de-duplicated union, in first-seen order. Entries that name no host are dropped. */
16
+ export declare function mergeDomainLists(...lists: ReadonlyArray<readonly string[] | undefined>): string[];
17
+ /**
18
+ * The subset of an (already merged) list that may be handed to a search BACKEND's own exclude filter:
19
+ * MULTI-LABEL NAMES ONLY. An IP literal and a single-label entry (`com`, `localhost`) match EXACTLY
20
+ * here, by this module's own rule -- but a backend's rule for them is unknown, and one that reads
21
+ * `com` as a suffix turns a typo'd entry into "no .com result, ever", silently. They are withheld from
22
+ * the backend and lose nothing: the caller still drops any hit they cover, locally, with
23
+ * `isDomainBlocked`, under the rule this module documents.
24
+ */
25
+ export declare function backendExcludableDomains(domains: readonly string[]): string[];
@@ -0,0 +1,122 @@
1
+ import { connectMcpServer } from "../../mcp/client.js";
2
+ import type { ToolSecretResult } from "../../provider/tool-secret.js";
3
+ import type { WebSessionRuntime } from "../../web/session-runtime.js";
4
+ export declare const EXA_MCP_ENDPOINT = "https://mcp.exa.ai/mcp";
5
+ export declare const EXA_SEARCH_TOOL = "web_search_exa";
6
+ export declare const EXA_ADVANCED_SEARCH_TOOL = "web_search_advanced_exa";
7
+ /** The only two tools this client asks the server to expose (the endpoint's `tools=` selector). */
8
+ export declare const EXA_ENABLED_TOOLS: readonly string[];
9
+ export declare const EXA_API_KEY_HEADER = "x-api-key";
10
+ /** How long the anonymous tier is skipped after it answers rate-limited, before it is re-probed. See the header. */
11
+ export declare const EXA_ANONYMOUS_COOLDOWN_MS: number;
12
+ /** The anonymous tier allows 2 calls per second; call STARTS are spaced at least this far apart, process-wide. */
13
+ export declare const EXA_ANONYMOUS_MIN_INTERVAL_MS = 500;
14
+ export declare const EXA_CONNECT_TIMEOUT_MS = 10000;
15
+ export declare const EXA_CALL_TIMEOUT_MS = 25000;
16
+ export declare const EXA_DEFAULT_NUM_RESULTS = 8;
17
+ /** The ceiling on `numResults`, and on the hits handed on. Each hit is capped; without this the COUNT was not. */
18
+ export declare const EXA_MAX_NUM_RESULTS = 20;
19
+ export declare const EXA_TITLE_MAX_CHARACTERS = 300;
20
+ /** A hit with a longer URL is DROPPED, never truncated -- a cut URL is a different, wrong URL. */
21
+ export declare const EXA_URL_MAX_CHARACTERS = 2000;
22
+ /** Per-result highlight budget asked of the server, and enforced again on what comes back. */
23
+ export declare const EXA_HIGHLIGHTS_MAX_CHARACTERS = 1200;
24
+ /** The advanced tool returns the whole page as `text` unless told otherwise; highlights are what is used. */
25
+ export declare const EXA_TEXT_MAX_CHARACTERS = 300;
26
+ /** The cap on one search's raw text, applied before parsing results are handed on. */
27
+ export declare const EXA_MAX_RESULT_CHARS = 40000;
28
+ export interface ExaSearchHit {
29
+ title: string;
30
+ url: string;
31
+ /** The result's highlight text, capped at `EXA_HIGHLIGHTS_MAX_CHARACTERS`. Empty when the backend sent none. */
32
+ highlight: string;
33
+ publishedDate?: string;
34
+ }
35
+ export interface ExaSearchParams {
36
+ query: string;
37
+ /** `web_search_exa` REQUIRES one; defaults to the query itself. */
38
+ objective?: string;
39
+ numResults?: number;
40
+ /** The call's own allow-list. Mutually exclusive with `excludeDomains` at the tool's surface. */
41
+ includeDomains?: readonly string[];
42
+ /** The call's own block-list. The host's `blockedDomains` floor is ADDED to it on every search. */
43
+ excludeDomains?: readonly string[];
44
+ }
45
+ export type ExaTier = "anonymous" | "key";
46
+ /**
47
+ * `quota-exhausted` the anonymous tier is exhausted/rate-limited and NO key is configured.
48
+ * `key-unreadable` ...and a key IS configured but could not be read (the message says why).
49
+ * `key-rate-limited` the KEY tier answered rate-limited or out of credit.
50
+ * `key-rejected` the key tier answered 401/403.
51
+ * `blocked-domains` every allowed domain is on the host's block-list: nothing may be searched.
52
+ * `timeout` / `aborted` / `unreachable` / `backend-error` as named.
53
+ */
54
+ export type ExaSearchFailureCode = "quota-exhausted" | "key-unreadable" | "key-rate-limited" | "key-rejected" | "blocked-domains" | "timeout" | "aborted" | "unreachable" | "backend-error";
55
+ export type ExaSearchResult = {
56
+ ok: true;
57
+ hits: ExaSearchHit[];
58
+ tier: ExaTier;
59
+ tool: string; /** The payload's text, capped. */
60
+ rawText: string;
61
+ truncated: boolean;
62
+ } | {
63
+ ok: false;
64
+ code: ExaSearchFailureCode;
65
+ message: string;
66
+ };
67
+ /**
68
+ * The anonymous tier's breaker and pacer. PROCESS-WIDE by default (`sharedExaBackendState`): the
69
+ * allowance is per network address, so every session in this process shares one. A test passes its own.
70
+ */
71
+ export interface ExaBackendState {
72
+ /** When the anonymous tier last answered rate-limited; `undefined` while it is believed usable. */
73
+ anonymousRateLimitedAt?: number;
74
+ /** WHY it was last refused -- so a keyless caller is told the truth (an auth refusal is not an exhausted quota). Absent reads as `rate-limited`. */
75
+ anonymousRefusal?: "rate-limited" | "auth";
76
+ /** The earliest time the next anonymous call may START (pacing). */
77
+ nextAnonymousCallAt: number;
78
+ /** How many callers are asleep in the pacer RIGHT NOW -- what tells a deep queue from a clock step. Absent reads as 0. */
79
+ anonymousWaiting?: number;
80
+ }
81
+ export declare function createExaBackendState(): ExaBackendState;
82
+ export declare const sharedExaBackendState: ExaBackendState;
83
+ /** True while the anonymous tier is being skipped. After the cooldown it reads `false`, and the next call is the re-probe. */
84
+ export declare function anonymousBreakerOpen(state: ExaBackendState, now: number): boolean;
85
+ export interface ExaSearchClientOptions {
86
+ /**
87
+ * Resolves the fallback key, LAZILY: it is not called at all while the anonymous tier answers, so
88
+ * a session that never exhausts the free tier never touches the keychain. Called at most once per
89
+ * client. Absent means "no key is configured".
90
+ */
91
+ resolveKey?: () => Promise<ToolSecretResult>;
92
+ /** The host's `blockedDomains` floor: excluded from EVERY search, and any hit on it is dropped. */
93
+ blockedDomains?: readonly string[];
94
+ /** Overrides `EXA_MCP_ENDPOINT` -- a test points this at a loopback fixture. */
95
+ endpoint?: string;
96
+ state?: ExaBackendState;
97
+ now?: () => number;
98
+ /** Resolves after `ms`, or early (without throwing) when `signal` aborts. */
99
+ sleep?: (ms: number, signal?: AbortSignal) => Promise<void>;
100
+ connect?: typeof connectMcpServer;
101
+ callTimeoutMs?: number;
102
+ connectTimeoutMs?: number;
103
+ maxResultChars?: number;
104
+ }
105
+ export interface ExaSearchClient {
106
+ search(params: ExaSearchParams, opts?: {
107
+ signal?: AbortSignal;
108
+ }): Promise<ExaSearchResult>;
109
+ /** Closes both tiers' connections. Idempotent; never throws. */
110
+ close(): Promise<void>;
111
+ }
112
+ /** The lazy key resolver for a session: `web.search.authRef` through the session's tool-secret resolver. */
113
+ export declare function exaKeyResolverFor(runtime: Pick<WebSessionRuntime, "web" | "resolveToolSecret">): (() => Promise<ToolSecretResult>) | undefined;
114
+ /**
115
+ * Search hits out of one payload's text. Tolerant by design: JSON with a `results` array (the
116
+ * advanced tool), else `Title:`/`URL:` records (the basic tool), else NO hits -- never a throw. A
117
+ * result with no URL is dropped (there is nothing to link to); one with no title uses its URL.
118
+ */
119
+ export declare function parseExaHits(text: string): ExaSearchHit[];
120
+ /** The endpoint with its `tools=` selector. Built by hand so the comma list is sent exactly as documented, and so NOTHING else -- least of all a key -- can ride the query string. */
121
+ export declare function exaEndpointUrl(endpoint?: string): string;
122
+ export declare function createExaSearchClient(options?: ExaSearchClientOptions): ExaSearchClient;
@@ -0,0 +1,23 @@
1
+ import type { ExaSearchClient } from "./_exa-client.js";
2
+ /**
3
+ * The session's own client -- built by `factory()` on the first call for this `sessionId` and reused
4
+ * by every later one, REGARDLESS of whatever options a later call's `factory` closure would have
5
+ * built (a session's search wiring -- credential ref, blocked-domain floor, test endpoint -- is fixed
6
+ * for the life of one engine run, the same assumption `web/session-runtime.ts`'s own registry makes).
7
+ *
8
+ * `undefined` means this session's client was CLOSED and nothing may build another one for it (the
9
+ * tombstone, see the module header) -- the caller answers with an ordinary error result.
10
+ */
11
+ export declare function exaSearchClientForSession(sessionId: string, factory: () => ExaSearchClient): ExaSearchClient | undefined;
12
+ /**
13
+ * Closes and forgets `sessionId`'s client, if it ever built one, and TOMBSTONES the id either way --
14
+ * "no client had been built yet" is exactly the state in which a late child would build one.
15
+ * Idempotent; never throws.
16
+ */
17
+ export declare function closeExaSearchClientForSession(sessionId: string): Promise<void>;
18
+ /** Lifts the tombstone: a ROOT run starting (or RESUMING) this session id may search again. Idempotent. */
19
+ export declare function reopenExaSearchClientsForSession(sessionId: string): void;
20
+ /** Test/diagnostic only: is this session id tombstoned? */
21
+ export declare function exaSearchClientIsClosedForTest(sessionId: string): boolean;
22
+ /** Test hygiene only: forgets every cached client WITHOUT closing it -- a test's own fixture teardown closes its client itself -- and lifts every tombstone. */
23
+ export declare function resetExaSessionClientsForTest(): void;
@@ -0,0 +1,135 @@
1
+ import type { CredentialRef } from "@yanlinglabs/winter-agent-sdk";
2
+ import type { ProviderUsage } from "../../engine.js";
3
+ import type { ToolExecutionContext } from "../registry.js";
4
+ import { type WebSessionRuntime } from "../../web/session-runtime.js";
5
+ /**
6
+ * Which model runs the inner pass.
7
+ *
8
+ * `session` (the default) is the SESSION'S OWN live model: always resolvable, no second credential.
9
+ * `tag` is a STATED model -- a provider-qualified key or a slot name -- resolved under the
10
+ * cross-provider credential rule with `authRef` as the route's own credential. A stated tag that
11
+ * cannot resolve is a typed failure, NEVER a fallback onto the session's model.
12
+ */
13
+ export type InnerModelSelector = {
14
+ kind: "session";
15
+ } | {
16
+ kind: "tag";
17
+ tag: string;
18
+ authRef?: CredentialRef;
19
+ };
20
+ /** The ONE function tool the inner model may call. */
21
+ export interface InnerToolSpec {
22
+ name: string;
23
+ description: string;
24
+ inputSchema: Record<string, unknown>;
25
+ }
26
+ export interface InnerToolCallInfo {
27
+ /** 1-based index of this handler call within the loop. */
28
+ index: number;
29
+ /** The inner model's own id for the call. */
30
+ toolUseId: string;
31
+ /** The turn's abort signal. A handler doing I/O must honour it. */
32
+ signal?: AbortSignal;
33
+ }
34
+ /** Runs one inner tool call. Must RETURN an error (`isError: true`) rather than throw; a throw is caught and reported to the inner model as an error result. */
35
+ export type InnerToolHandler = (input: unknown, info: InnerToolCallInfo) => Promise<{
36
+ output: string;
37
+ isError?: boolean;
38
+ }>;
39
+ export interface InnerModelRequest {
40
+ /** Defaults to `{ kind: "session" }`. */
41
+ model?: InnerModelSelector;
42
+ /** The inner pass's own system prompt. Omitted entirely when absent -- never an empty string. */
43
+ system?: string;
44
+ /** The single user message. */
45
+ prompt: string;
46
+ /**
47
+ * PRESENT -> the BOUNDED TOOL LOOP, every round `toolChoice: auto`. ABSENT -> one generation with no
48
+ * tools.
49
+ *
50
+ * WS-23: ROUND 1 IS NO LONGER FORCED. It used to be sent with `toolChoice: {type: "tool", name}` so
51
+ * the model could not answer from memory; Opus 5.5 and Fable 5.1 reject a forced choice (a documented
52
+ * 400, downgraded to `auto` by the Anthropic adapter), so on those models the "guarantee" silently
53
+ * became a suggestion. A caller that needs the tool to run at least once runs it itself before the
54
+ * pass and hands the model the result (WebSearch's seed search does exactly that).
55
+ */
56
+ tool?: InnerToolSpec;
57
+ /** Required with `tool`. */
58
+ handler?: InnerToolHandler;
59
+ /**
60
+ * The most HANDLER calls the loop will make (every call in a parallel tool-use turn counts).
61
+ * Calls beyond it are answered with a limit notice and never reach the handler, and the model gets
62
+ * exactly ONE further generation to write its answer. Required with `tool`; values below 1 read as 1.
63
+ */
64
+ maxToolCalls?: number;
65
+ }
66
+ /**
67
+ * The inner pass's transcript, IN STREAM ORDER -- what a caller assembles its output from. A
68
+ * `tool_call` step carries the call AND its result, because every consumer needs them together and
69
+ * in the position the call was made.
70
+ */
71
+ export type InnerModelStep = {
72
+ kind: "text";
73
+ text: string;
74
+ } | {
75
+ kind: "tool_call";
76
+ toolUseId: string;
77
+ input: unknown;
78
+ output: string;
79
+ isError: boolean;
80
+ executed: boolean;
81
+ };
82
+ /**
83
+ * `not-wired` no session runtime is registered for this call (a host wiring gap).
84
+ * `invalid-request` `tool` without `handler`/`maxToolCalls` -- a CALLER bug, reported not thrown.
85
+ * `model-unresolvable` a STATED model tag was refused; `detail` is the resolver's own code.
86
+ * `no-credential` the model resolved but no credential exists for its provider.
87
+ * `provider-error` the provider failed (HTTP error, refusal to serve, malformed stream).
88
+ * `aborted` the turn was interrupted before or during the pass.
89
+ */
90
+ export type InnerModelFailureCode = "not-wired" | "invalid-request" | "model-unresolvable" | "no-credential" | "provider-error" | "aborted";
91
+ export interface InnerModelFailure {
92
+ ok: false;
93
+ code: InnerModelFailureCode;
94
+ /** Safe to show the model: never a credential, never provider opaque state. */
95
+ message: string;
96
+ /** The underlying typed code where there is one (`unknown-model`, `slot-unservable`, `rate_limit`, ...). */
97
+ detail?: string;
98
+ /** Whatever the pass produced before it failed -- a partial loop's searches are still real. */
99
+ steps: InnerModelStep[];
100
+ toolCalls: number;
101
+ }
102
+ export interface InnerModelSuccess {
103
+ ok: true;
104
+ /** Every text step joined by a blank line. For the single-shot shape this is simply the answer. */
105
+ text: string;
106
+ steps: InnerModelStep[];
107
+ /** Handler calls actually made. */
108
+ toolCalls: number;
109
+ /** `answer`: the model ended with text. `tool-call-limit`: it was still calling the tool after its closing generation. */
110
+ stoppedBy: "answer" | "tool-call-limit";
111
+ /** The key usage was accounted under. */
112
+ modelKey: string | undefined;
113
+ /** The sum over every generation in the pass (already accounted; reported for the caller's own use). */
114
+ usage: ProviderUsage;
115
+ }
116
+ export type InnerModelResult = InnerModelSuccess | InnerModelFailure;
117
+ /** What the loop needs from the session, narrowed so a test hands in three functions and no engine. */
118
+ export type InnerModelRuntime = Pick<WebSessionRuntime, "sessionModel" | "resolveAuxiliaryModel" | "accountUsage" | "budgetExceeded">;
119
+ /** The notice an over-limit call is answered with. Exported so a caller can recognise (and not re-report) it. */
120
+ export declare const INNER_TOOL_LIMIT_NOTICE = "The tool-call limit for this request has been reached. Do not call the tool again; answer now from the results you already have.";
121
+ /**
122
+ * The `detail` a SESSION-BUDGET stop carries. A budget crossing is reported under the existing
123
+ * `aborted` code (the pass was stopped BY the session, not by a failure -- and the code union the two
124
+ * tools switch on does not grow), so this string is the ONLY thing that tells it from a genuine
125
+ * interrupt. Exported so a consumer matches the constant, never its own spelling of it.
126
+ */
127
+ export declare const INNER_MODEL_BUDGET_EXCEEDED_DETAIL = "budget-exceeded";
128
+ /**
129
+ * Runs a tool's inner model pass. See the module header for the contract; in one line: resolves the
130
+ * model, threads the abort signal, accounts every generation's usage, and never throws for an
131
+ * expected failure.
132
+ *
133
+ * `runtime` is for tests; an executor passes only `ctx` and the session's own registration is used.
134
+ */
135
+ export declare function runInnerModel(ctx: Pick<ToolExecutionContext, "sessionId" | "agentId" | "signal">, request: InnerModelRequest, runtime?: InnerModelRuntime): Promise<InnerModelResult>;
@@ -0,0 +1,36 @@
1
+ import { type BrandProfile } from "@yanlinglabs/winter-agent-sdk";
2
+ type EnvBrand = Pick<BrandProfile, "envPrefix">;
3
+ export declare const DEFAULT_MAX_WEB_SEARCHES_PER_SESSION = 200;
4
+ /**
5
+ * claude's own env name is `CLAUDE_CODE_MAX_WEB_SEARCHES_PER_SESSION` (research file, verbatim); this
6
+ * is Winter's copy of the MECHANISM (a session-cap override), branded through `envName` like every
7
+ * other product env name in this codebase -- never a literal `WINTER_...` string (brand-gate rule 9/10).
8
+ */
9
+ export declare function maxWebSearchesPerSessionEnvName(brand?: EnvBrand): string;
10
+ export declare function resolveMaxWebSearchesPerSession(env?: Record<string, string | undefined>, brand?: EnvBrand): number;
11
+ export interface WebSearchBudgetReservation {
12
+ ok: boolean;
13
+ /** Calls already spent BEFORE this reservation (never incremented by a refusal). */
14
+ used: number;
15
+ cap: number;
16
+ }
17
+ /**
18
+ * Reserves ONE WebSearch call against `sessionId`'s budget -- called BEFORE the search runs, so a
19
+ * call that is never reserved (an input-validation failure, a wiring gap) never counts against it,
20
+ * matching claude's own `validateInput`-before-`call` ordering.
21
+ *
22
+ * `ok: false` leaves the counter UNCHANGED: the 201st call and the 202nd both read "200 of 200", not
23
+ * "201 of 200" -- the refusal is a repeatable fact about the session, not an escalating one.
24
+ */
25
+ export declare function reserveWebSearchCall(sessionId: string, cap: number): WebSearchBudgetReservation;
26
+ export declare function webSearchCallsUsed(sessionId: string): number;
27
+ /**
28
+ * claude's own refusal text (research file, verbatim), with the env var name substituted for
29
+ * Winter's branded one. A RESULT, never an error: `durationSeconds:0, searchCount:0` in claude's own
30
+ * structured output, which this runtime does not carry -- the string alone is what reaches the model.
31
+ */
32
+ export declare function webSearchBudgetRefusalText(used: number, cap: number, brand?: EnvBrand): string;
33
+ /** Forgets `sessionId`'s spend (whole-branch review MINOR 4). Called from the ROOT run's teardown; idempotent. */
34
+ export declare function forgetWebSearchBudgetForSession(sessionId: string): void;
35
+ export declare function resetWebSearchBudgetForTest(): void;
36
+ export {};
@@ -0,0 +1,37 @@
1
+ export interface WebFetchCacheEntry {
2
+ /** The converted content's own UTF-8 byte length -- the cache's weight unit. */
3
+ bytes: number;
4
+ /** Always a 2xx status: redirects and errors are never cached (the caller enforces this by never calling `set` for them). */
5
+ code: number;
6
+ codeText: string;
7
+ /** The CONVERTED content (markdown, or raw text/passthrough) -- never the inner model's answer, which is why a cache hit still re-runs the digest pass. */
8
+ content: string;
9
+ contentType: string;
10
+ /** The URL actually fetched (after the https upgrade and any auto-followed same-host redirect) -- may differ from the cache key. */
11
+ finalUrl: string;
12
+ }
13
+ export declare const WEB_FETCH_CACHE_TTL_MS: number;
14
+ export declare const WEB_FETCH_CACHE_MAX_BYTES: number;
15
+ export type ClockFn = () => number;
16
+ export declare class WebFetchCache {
17
+ private readonly sessions;
18
+ private readonly now;
19
+ private readonly ttlMs;
20
+ private readonly maxBytes;
21
+ constructor(opts?: {
22
+ now?: ClockFn;
23
+ ttlMs?: number;
24
+ maxBytes?: number;
25
+ });
26
+ get(sessionId: string, url: string): WebFetchCacheEntry | undefined;
27
+ set(sessionId: string, url: string, entry: WebFetchCacheEntry): void;
28
+ /**
29
+ * Drops everything cached for `sessionId` (whole-branch review MINOR 4). Called from the ROOT run's
30
+ * teardown; idempotent, and unknown session ids are a no-op.
31
+ */
32
+ forgetSession(sessionId: string): void;
33
+ /** Test/diagnostic only: how many sessions currently hold at least one live entry. */
34
+ sessionCountForTest(): number;
35
+ }
36
+ /** The module-load default: one process-wide cache instance, sessions partitioned by key as documented above. */
37
+ export declare const webFetchCache: WebFetchCache;
@@ -0,0 +1,26 @@
1
+ export declare const WEB_FETCH_HTML_TRUNCATION_NOTICE = "\n\n[Content truncated due to length...]";
2
+ /**
3
+ * Security review minor: `&#0;` and `&#xD800;` (a lone UTF-16 surrogate, `0xD800..0xDFFF`) previously
4
+ * round-tripped to U+0000 and an actual lone surrogate respectively -- both are exactly what the HTML
5
+ * spec's own numeric-character-reference algorithm maps to U+FFFD instead, and a lone surrogate in
6
+ * particular is a well-known way to make a downstream JSON/UTF-8 encode step (here: the digest
7
+ * REQUEST to the inner model) fail outright on otherwise ordinary-looking input.
8
+ */
9
+ export declare function decodeHtmlEntities(input: string): string;
10
+ export declare class HtmlBudgetExceededError extends Error {
11
+ }
12
+ /**
13
+ * Converts `html` to markdown using the rules above, driven by Bun's `HTMLRewriter` as a SAX walk
14
+ * (see the module header). Never throws for malformed markup on its own -- `HTMLRewriter` tolerates
15
+ * it the way a real HTML5 parser does -- but a genuine internal failure (including
16
+ * `HtmlBudgetExceededError`, security review finding N2) is caught and reported so the caller can
17
+ * fall back to the raw HTML, matching claude's own "turndown throwing -> raw HTML" rule.
18
+ */
19
+ export declare function htmlToMarkdown(html: string): Promise<string>;
20
+ /**
21
+ * The full conversion claude's own WebFetch applies: cap the RAW HTML at 1,048,576 chars first (so a
22
+ * pathological document costs conversion no more than that), convert what remains, and append the
23
+ * verbatim truncation notice when it was capped. A conversion failure falls back to the (possibly
24
+ * capped) raw HTML, per claude's own "turndown throwing -> raw HTML."
25
+ */
26
+ export declare function convertFetchedHtml(html: string): Promise<string>;