@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,423 @@
1
+ import type { PermissionMode, BackgroundTaskMessage, BrandProfile, SettingSource } from "@yanlinglabs/winter-agent-sdk";
2
+ import type { ReadAccessProbe } from "../permissions/evaluator.js";
3
+ import type { SessionReadState } from "./read-state.js";
4
+ import type { SandboxSettings } from "../sandbox/profile.js";
5
+ import type { SpawnChildRequest, ChildHandle } from "../subagents/child-handle.js";
6
+ export interface JSONSchema {
7
+ type?: string | readonly string[];
8
+ properties?: Record<string, JSONSchema>;
9
+ items?: JSONSchema | readonly JSONSchema[];
10
+ required?: readonly string[];
11
+ enum?: readonly unknown[];
12
+ const?: unknown;
13
+ description?: string;
14
+ additionalProperties?: boolean | JSONSchema;
15
+ oneOf?: readonly JSONSchema[];
16
+ anyOf?: readonly JSONSchema[];
17
+ allOf?: readonly JSONSchema[];
18
+ minimum?: number;
19
+ maximum?: number;
20
+ minItems?: number;
21
+ maxItems?: number;
22
+ minLength?: number;
23
+ maxLength?: number;
24
+ pattern?: string;
25
+ [key: string]: unknown;
26
+ }
27
+ export interface ToolAnnotations {
28
+ readOnlyHint?: boolean;
29
+ destructiveHint?: boolean;
30
+ openWorldHint?: boolean;
31
+ title?: string;
32
+ idempotentHint?: boolean;
33
+ }
34
+ export type PermissionClass = "read" | "edit" | "execute" | "network" | "interaction" | "messaging" | "task" | "mode" | "mcp" | "hosted";
35
+ export interface AvailabilityPredicate {
36
+ modes?: readonly PermissionMode[];
37
+ platforms?: readonly NodeJS.Platform[];
38
+ requiresFeatures?: readonly string[];
39
+ requiresToolSearchDisabled?: true;
40
+ requiresToolSearchEnabled?: true;
41
+ hiddenWhenFamilyTaskNative?: true;
42
+ insideSubagent?: false;
43
+ }
44
+ export type ToolDisposition = "implement-now" | "implement-later" | "correctly-absent" | "winter-backed-equivalent" | "winter-backed-later";
45
+ export interface ToolDescriptor {
46
+ canonicalName: string;
47
+ advertisedName: string;
48
+ source: "builtin" | "mcp" | "sdk" | "plugin" | "host";
49
+ inputSchema: JSONSchema;
50
+ outputSchema?: JSONSchema;
51
+ description: string;
52
+ searchHint?: string;
53
+ annotations?: ToolAnnotations;
54
+ exposure: "eager" | "deferred" | "hidden";
55
+ permissionClass: PermissionClass;
56
+ availability: AvailabilityPredicate;
57
+ capabilityRequirements: string[];
58
+ disposition: ToolDisposition;
59
+ versionIntroduced?: string;
60
+ deferred?: boolean | readonly PermissionMode[];
61
+ alwaysLoad?: boolean;
62
+ _meta?: Record<string, unknown>;
63
+ interaction?: "required";
64
+ }
65
+ export interface ToolResultPayload {
66
+ output: string;
67
+ isError?: boolean;
68
+ }
69
+ /** See `ToolExecutionContext.permission`. */
70
+ export interface ToolCallPermission {
71
+ explicitApproval: "prompt" | "rule";
72
+ }
73
+ /** What the engine may hand the adapter per call; both optional, both absent for a hand-made call. */
74
+ export interface ToolCallExecuteOptions {
75
+ signal?: AbortSignal;
76
+ /** The permission decision's `explicitApproval`, when it carried one. */
77
+ explicitApproval?: "prompt" | "rule";
78
+ }
79
+ export interface ToolExecutionContext {
80
+ cwd: string;
81
+ home: string;
82
+ /**
83
+ * Phase 5 fix wave, I1: the RESOLVED winter root for this session (`<PREFIX>HOME` when set),
84
+ * DISTINCT from `home` above, which is the OS home directory.
85
+ *
86
+ * The two are not interchangeable and confusing them is a shipped-bug class in this codebase --
87
+ * see `SkillIndexOptions.winterHome`'s own header. A tool that needs to name Winter's own storage
88
+ * (the agents user tier, a seatbelt deny, the checkpoint store) reads THIS; a tool that needs the
89
+ * user's home for a `~`-anchored path reads `home`. Absent for a hand-built context, in which case
90
+ * every consumer falls back to `<home>/<brand.homeDirName>/...` -- the pre-fix behaviour.
91
+ */
92
+ winterHome?: string;
93
+ /**
94
+ * WS-21 §3.7/§6.3 item 11 (fix round 1, item 4): the shared runtime home's durable-paths root
95
+ * (`config.storeHome`), preferred over `winterHome` for the SAME two consumers `winterHome`'s own
96
+ * header names when a real seatbelt profile needs to fence durable content -- `bash.ts`'s own
97
+ * `buildRunCommandOptions` is the one production reader (`sandbox/spawn.ts`'s
98
+ * `buildSeatbeltProfile`, in turn). Absent falls back to `winterHome`, byte-identical to
99
+ * pre-WS-21 behaviour.
100
+ */
101
+ storeHome?: string;
102
+ /**
103
+ * WS-21 §6.3 item 1 (durable-write audit sibling, fix round 2): the session's ENABLED plugins
104
+ * that ship a `workflows/` directory, for the Workflow tool's `<plugin>:<name>` resolution
105
+ * (`workflows/store.ts`'s `resolveWorkflowByName`). Fixed per incarnation, like every other
106
+ * plugin-derived value this codebase threads. Absent means no qualified workflow name ever
107
+ * resolves, matching every pre-fix-round-2 caller.
108
+ *
109
+ * Fix round 4 (minors, M-3's last bullet): also carries `workflowsPaths` -- see
110
+ * `engine.ts`'s own `EngineOptions.pluginWorkflows` for why this widened rather than a new field.
111
+ */
112
+ pluginWorkflows?: readonly {
113
+ name: string;
114
+ workflowsPath?: string;
115
+ workflowsPaths?: readonly string[];
116
+ }[];
117
+ /**
118
+ * SV-5 fix round 3 (I-4): the session's resolved `settingSources` (`RuntimeConfig.settingSources`),
119
+ * for the Workflow tool's project/user tier resolution (`workflows/store.ts`'s
120
+ * `resolveWorkflowByName`) -- the same fact `production-wiring.ts` already resolves once per
121
+ * incarnation for skills/agents/rules/MCP. Absent means every tier is allowed, matching claude's
122
+ * own `settingSources` default and every pre-fix-round-3 caller.
123
+ */
124
+ settingSources?: readonly SettingSource[];
125
+ /**
126
+ * P7a (D19): the session's RESOLVED brand profile, threaded from `RuntimeConfig.brand`.
127
+ *
128
+ * Every tool that names a Winter-owned surface from inside its own executor -- the project
129
+ * dot-dir a workflow/worktree/cron file lives under, an env variable, the instructions file --
130
+ * reads it from HERE rather than spelling one. OPTIONAL for the same reason as
131
+ * `insideSubagent`/`trustedWorkspace` (~25 hand-built test contexts with no shared builder);
132
+ * ABSENT READS AS `WINTER_BRAND`, which is byte-identical to the behaviour before this field.
133
+ */
134
+ brand?: BrandProfile;
135
+ sessionId: string;
136
+ readState: SessionReadState;
137
+ emitFrame: (frame: BackgroundTaskMessage) => void;
138
+ emitToolReference?: (names: string[]) => void;
139
+ permissions: {
140
+ probeReadAccess(filePath: string): ReadAccessProbe;
141
+ };
142
+ tempDir: string;
143
+ sandboxSettings: SandboxSettings;
144
+ /**
145
+ * Phase 6 Task 3 (R6-6, P4 carry): the engine's per-turn abort signal.
146
+ *
147
+ * ABORTED when the turn is interrupted. Bash and Monitor honour it -- their process-group kill
148
+ * already existed, and this is the channel that reaches it: before this field the interrupt was a
149
+ * raced Promise the engine stopped waiting on while the child kept running to completion.
150
+ * An executor that ignores the field behaves exactly as before.
151
+ *
152
+ * OPTIONAL, matching `insideSubagent`/`emitToolReference` and for the identical reason: ~25
153
+ * `impl/*.test.ts` files build a `ToolExecutionContext` by hand with no shared builder, and a
154
+ * required field would force a throwaway stub into every one of them.
155
+ */
156
+ signal?: AbortSignal;
157
+ outDir?: string;
158
+ insideSubagent?: boolean;
159
+ isolationPinnedCwd?: boolean;
160
+ trustedWorkspace?: boolean;
161
+ agentId?: string;
162
+ toolUseId?: string;
163
+ agents?: Readonly<Record<string, unknown>>;
164
+ /**
165
+ * Spawn-surface parity: the SESSION's environment (the engine's `env` option, else the process
166
+ * env) -- the per-session kill switches the Agent tool reads (`loadAgentDefinitions`' built-in
167
+ * gates, the background kill switch, the fork gate's env fallback) come from here, exactly like
168
+ * `limits.ts`'s own per-session env reads. Absent = `process.env`.
169
+ */
170
+ env?: Readonly<Record<string, string | undefined>>;
171
+ /** Spawn-surface parity (R-S5): this session's resolved fork gate (RuntimeConfig.forkSubagent, else the env fallback). Absent = resolve from `env`. */
172
+ forkSubagentEnabled?: boolean;
173
+ /** I4 (fix wave): this session's resolved background-by-default opt-out (RuntimeConfig.backgroundByDefault, else the env fallback). Absent = resolve from `env` (`subagents/policy.ts`'s `resolveBackgroundByDefaultEnabled`). */
174
+ backgroundByDefault?: boolean;
175
+ /** Spawn-surface parity (R-S5): this engine is itself a forked worker (RuntimeConfig.insideFork) -- a fork may not fork again. */
176
+ insideFork?: boolean;
177
+ /**
178
+ * Review r2 finding 2 (whole-branch): the session's ONE rejection reporter for a filesystem
179
+ * `agents/*.md` file `loadAgentDefinitions` could not parse (`tools/impl/agent.ts`'s own call
180
+ * passes it straight through as `onReject`). Typed structurally (the same discipline `agents?`
181
+ * above documents) rather than importing `subagents/definitions.ts`'s own `AgentDefinitionRejection`
182
+ * here. Absent = silent-skip, the pre-existing behavior for every hand-built test context.
183
+ */
184
+ onAgentDefinitionRejected?: (rejection: {
185
+ source: "user" | "project" | "plugin";
186
+ filePath: string;
187
+ reason: string;
188
+ }) => void;
189
+ /**
190
+ * Spawn-surface parity (research §A8): the names this session currently ADVERTISES to its model
191
+ * (canonical). The Agent tool's background launch result reads it to decide whether the model can
192
+ * read the task's output file at all (`Read`/`Bash` present). A getter: the set can move mid-run.
193
+ */
194
+ advertisedToolNames?: () => readonly string[];
195
+ /**
196
+ * SDK 0.0.16 Lane P (R3b §4): this session's live Agent-type availability -- `Agent(type)` deny
197
+ * rules, `allowedAgentTypes`, and "every tool it may use is denied" -- built fresh per call
198
+ * (never cached) so a live rule/settings change is reflected without a restart, mirroring
199
+ * `probeReadAccess`'s own "cheap, side-effect-free, re-derived per call" precedent.
200
+ * `tools/impl/agent.ts` is the one consumer: it resolves a requested `subagent_type` against the
201
+ * FULL definitions map (a denied/not-allowed type still names itself in the refusal, never a bare
202
+ * "not found"), then asks this closure whether the resolved name is available right now and why
203
+ * not. Structurally typed (no `SourcedRuleEntry`/evaluator.ts import here, matching this
204
+ * interface's own `onAgentDefinitionRejected` precedent immediately above) -- engine.ts builds
205
+ * both the name list and the per-type message from its own `permissions/evaluator.ts` +
206
+ * `subagents/availability.ts` imports, and hands this seam only the already-formatted result.
207
+ */
208
+ agentAvailability?: () => {
209
+ /** Names available right now -- deny rules, allowedAgentTypes and all-tools-denied already applied. Used for "Available agents: ..." refusal text and the omitted-type default's own availability check. */
210
+ availableNames: readonly string[];
211
+ /**
212
+ * Exact refusal prose for a type that EXISTS in the full definitions map but is refused for a
213
+ * reason OTHER than `allowedAgentTypes` (a per-type deny rule, or "every tool it may use is
214
+ * denied") -- `undefined` when neither applies (including when the type does not exist at all,
215
+ * or is merely excluded by `allowedAgentTypes` -- claude reuses the plain not-found shape for
216
+ * that case, built by the caller from `availableNames` above).
217
+ */
218
+ unavailableMessage: (agentType: string) => string | undefined;
219
+ };
220
+ /**
221
+ * HOW THIS CALL WAS PERMITTED -- present only when it was EXPLICITLY approved.
222
+ *
223
+ * An executor cannot prompt mid-call, so a tool whose safety depends on "did a person (or a rule
224
+ * naming this exact target) consent to THIS call?" has to be told. `explicitApproval` is the
225
+ * permission decision's own marker (`PermissionDecisionRecord.explicitApproval`), carried verbatim:
226
+ * - `"prompt"` -- a permission request for this call was answered allow;
227
+ * - `"rule"` -- a standing allow rule names this call's target exactly.
228
+ * ABSENT means the call was allowed by the session's mode, a broad rule, a pre-approving hook or
229
+ * the classifier -- or that this context was hand-built. An executor must read absence as "not
230
+ * explicitly approved", never the other way round.
231
+ *
232
+ * One consumer today: `WebFetch`, for a private-address target under the `"ask"` policy.
233
+ */
234
+ permission?: ToolCallPermission;
235
+ session: {
236
+ setCwd(p: string): void;
237
+ addBoundedRoot(p: string): void;
238
+ removeBoundedRoot(p: string): void;
239
+ getSessionRoot(): string;
240
+ setSessionRoot(p: string): void;
241
+ setPermissionMode(mode: PermissionMode): void;
242
+ getBoundedRoots(): string[];
243
+ getPermissionMode(): PermissionMode;
244
+ spawnChild?(req: SpawnChildRequest): Promise<ChildHandle>;
245
+ };
246
+ }
247
+ export interface ToolExecutor {
248
+ execute(input: unknown, ctx: ToolExecutionContext): Promise<ToolResultPayload>;
249
+ }
250
+ export interface RegisteredTool {
251
+ descriptor: ToolDescriptor;
252
+ executor?: ToolExecutor;
253
+ extractPaths?: (input: unknown) => {
254
+ reads: string[];
255
+ writes: string[];
256
+ };
257
+ }
258
+ export declare function registerTool(t: RegisteredTool): void;
259
+ export declare function replaceExecutor(canonicalName: string, executor: ToolExecutor, extractPaths?: RegisteredTool["extractPaths"]): void;
260
+ export declare function getRegisteredTool(canonicalName: string): RegisteredTool | undefined;
261
+ export declare function listRegisteredTools(): readonly RegisteredTool[];
262
+ /**
263
+ * The ONLY names a host-generated registration may claim (fix round 1, M1).
264
+ *
265
+ * WS-06 §3.6 declares `StructuredOutput`'s `input_schema` as "GENERATED per-call from the caller's
266
+ * requested output schema -- never one static interface", and its own P3 descriptor
267
+ * (descriptors/structured-output.ts) calls its schema a placeholder the host substitutes. That
268
+ * declaration is what makes the name generatable; nothing else in the catalogue carries it.
269
+ *
270
+ * Defined HERE rather than in structured/seam.ts so the registry depends on nothing to enforce its
271
+ * own guard; that module re-exports it for Lane K.
272
+ */
273
+ export declare const HOST_GENERATABLE_TOOL_NAMES: ReadonlySet<string>;
274
+ export declare function registerHostGeneratedTool(t: RegisteredTool): () => void;
275
+ export declare function unregisterToolForTest(canonicalName: string): void;
276
+ export interface McpToolDefinition {
277
+ name: string;
278
+ description?: string;
279
+ inputSchema: JSONSchema;
280
+ outputSchema?: JSONSchema;
281
+ annotations?: ToolAnnotations;
282
+ _meta?: Record<string, unknown>;
283
+ }
284
+ export declare function onRegistryChange(cb: () => void): () => void;
285
+ export declare function rebrandStandingServerTools(renames: ReadonlyArray<{
286
+ from: string;
287
+ to: string;
288
+ }>, serverName: string): () => void;
289
+ export declare function registerMcpServerTools(server: string, incomingTools: readonly McpToolDefinition[], opts: {
290
+ alwaysLoad?: boolean;
291
+ deferredDefault: boolean | readonly PermissionMode[];
292
+ }): void;
293
+ /**
294
+ * Fix round 20: the live MCP server that registered `canonicalName` through `registerMcpServerTools`,
295
+ * or `undefined` for any other registration (a static descriptor, a standing-server twin). The
296
+ * registry is process-wide; a run's advertised partition uses this to keep only the MCP tools of
297
+ * servers that run can see (engine.ts's `computeAdvertisedPartition`).
298
+ */
299
+ export declare function mcpServerOwningTool(canonicalName: string): string | undefined;
300
+ export declare function unregisterMcpServerTools(server: string): void;
301
+ export interface LoadedToolSet {
302
+ isLoaded(name: string): boolean;
303
+ load(names: string[]): {
304
+ loaded: string[];
305
+ unknown: string[];
306
+ };
307
+ reset(evidenced: string[]): void;
308
+ snapshot(): string[];
309
+ }
310
+ export declare function createLoadedToolSet(): LoadedToolSet;
311
+ export declare function onCompaction(loaded: LoadedToolSet, evidencedToolNames: readonly string[]): void;
312
+ export interface DeferralActivation {
313
+ enableToolSearch: "unset" | "true" | "false" | "auto" | {
314
+ auto: number;
315
+ };
316
+ providerSupportsToolSearch: boolean;
317
+ deferrableContextShare: number;
318
+ }
319
+ export declare function isDeferralActive(activation: DeferralActivation): boolean;
320
+ export declare function resolveDeferral(descriptor: ToolDescriptor, mode: PermissionMode, activation: DeferralActivation): "eager" | "deferred" | "hidden";
321
+ export interface AdvertisedPartition {
322
+ eager: ToolDescriptor[];
323
+ deferred: ToolDescriptor[];
324
+ hidden: ToolDescriptor[];
325
+ }
326
+ export declare function partitionAdvertisedTools(cfg: AdvertisedSetInputs, activation: DeferralActivation): AdvertisedPartition;
327
+ export declare function isLoadFirstBlocked(toolName: string, mode: PermissionMode, activation: DeferralActivation, loaded: LoadedToolSet): boolean;
328
+ export interface AdvertisedSetInputs {
329
+ mode: PermissionMode;
330
+ platform?: NodeJS.Platform;
331
+ features?: Readonly<Record<string, boolean>>;
332
+ capabilities?: readonly string[];
333
+ familyMetadata?: {
334
+ taskNative?: boolean;
335
+ };
336
+ toolSearchEnabled?: boolean;
337
+ insideSubagent?: boolean;
338
+ tools?: readonly string[];
339
+ allowedTools?: readonly string[];
340
+ disallowedTools?: readonly string[];
341
+ }
342
+ export declare function isToolAvailable(descriptor: ToolDescriptor, cfg: AdvertisedSetInputs): boolean;
343
+ export interface RuntimeDerivedCapability {
344
+ token: string;
345
+ probeTool: string;
346
+ requiresSessionFact?: keyof SessionCapabilityFacts;
347
+ }
348
+ export interface SessionCapabilityFacts {
349
+ hasMcpServers: boolean;
350
+ }
351
+ export declare const RUNTIME_DERIVED_CAPABILITIES: readonly RuntimeDerivedCapability[];
352
+ export declare function deriveRuntimeCapabilities(facts: SessionCapabilityFacts): string[];
353
+ export declare function resolveSessionCapabilities(hostSupplied: readonly string[] | undefined, facts: SessionCapabilityFacts): string[];
354
+ export declare function isBareDenied(canonicalName: string, disallowedTools: readonly string[] | undefined): boolean;
355
+ export declare function buildAdvertisedSet(cfg: AdvertisedSetInputs): ToolDescriptor[];
356
+ export interface EngineToolCall {
357
+ id: string;
358
+ name: string;
359
+ input: unknown;
360
+ }
361
+ export interface EngineToolResult {
362
+ output: string;
363
+ /**
364
+ * Spawn-surface parity (R-S4, research gap 6): the executor's own `isError`, carried to the engine
365
+ * so the model-facing `tool_result` block says `is_error: true` -- claude's shape for every tool
366
+ * error. Dropped here before, so every executor error reached the wire (and the daemon) as a
367
+ * success.
368
+ */
369
+ isError?: boolean;
370
+ }
371
+ export interface EngineFacingToolExecutor {
372
+ /** Phase 6 Task 3 (R6-6): `opts.signal` is the engine's per-turn abort. It reaches a real executor as `ToolExecutionContext.signal`. */
373
+ execute(call: EngineToolCall, opts?: ToolCallExecuteOptions): Promise<EngineToolResult>;
374
+ }
375
+ export interface RegistryToolExecutorDeps {
376
+ sessionId: string;
377
+ home: string;
378
+ /** Phase 5 fix wave, I1: the resolved winter root -- see `ToolExecutionContext.winterHome`. */
379
+ winterHome?: string;
380
+ /** WS-21 fix round 1, item 4: the shared store home -- see `ToolExecutionContext.storeHome`. */
381
+ storeHome?: string;
382
+ /** WS-21 §6.3 item 1, fix round 2: plugin workflow directories -- see `ToolExecutionContext.pluginWorkflows`. */
383
+ pluginWorkflows?: readonly {
384
+ name: string;
385
+ workflowsPath?: string;
386
+ workflowsPaths?: readonly string[];
387
+ }[];
388
+ /** SV-5 fix round 3 (I-4): the session's resolved settingSources -- see `ToolExecutionContext.settingSources`. */
389
+ settingSources?: readonly SettingSource[];
390
+ /** P7a (D19): the session's resolved brand -- see `ToolExecutionContext.brand`. */
391
+ brand?: BrandProfile;
392
+ getCwd: () => string;
393
+ probeReadAccess: (filePath: string) => ReadAccessProbe;
394
+ emitFrame: (frame: BackgroundTaskMessage) => void;
395
+ emitToolReference?: (names: string[]) => void;
396
+ session: ToolExecutionContext["session"];
397
+ readState: SessionReadState;
398
+ getTempDir: () => string;
399
+ sandboxSettings: SandboxSettings;
400
+ outDir?: string;
401
+ insideSubagent?: boolean;
402
+ isolationPinnedCwd?: boolean;
403
+ trustedWorkspace?: boolean;
404
+ agentId?: string;
405
+ agents?: Readonly<Record<string, unknown>>;
406
+ env?: Readonly<Record<string, string | undefined>>;
407
+ forkSubagentEnabled?: boolean;
408
+ backgroundByDefault?: boolean;
409
+ insideFork?: boolean;
410
+ advertisedToolNames?: () => readonly string[];
411
+ onAgentDefinitionRejected?: (rejection: {
412
+ source: "user" | "project" | "plugin";
413
+ filePath: string;
414
+ reason: string;
415
+ }) => void;
416
+ agentAvailability?: () => {
417
+ availableNames: readonly string[];
418
+ unavailableMessage: (agentType: string) => string | undefined;
419
+ };
420
+ getAvailabilityInputs?: () => AdvertisedSetInputs;
421
+ }
422
+ export declare function buildRegistryToolExecutor(deps: RegistryToolExecutorDeps): EngineFacingToolExecutor;
423
+ export declare function buildRegistryToolExecutorWithFallback(deps: RegistryToolExecutorDeps, fallback: EngineFacingToolExecutor): EngineFacingToolExecutor;
@@ -0,0 +1,61 @@
1
+ export type TaskStatus = "pending" | "in_progress" | "completed" | "deleted";
2
+ export interface TaskGraphRow {
3
+ id: string;
4
+ subject: string;
5
+ description: string;
6
+ activeForm?: string;
7
+ status: TaskStatus;
8
+ blocks: string[];
9
+ blockedBy: string[];
10
+ owner?: string;
11
+ metadata?: Record<string, unknown>;
12
+ }
13
+ export interface TaskCreateInput {
14
+ subject: string;
15
+ description: string;
16
+ activeForm?: string;
17
+ metadata?: Record<string, unknown>;
18
+ }
19
+ export interface TaskUpdateInput {
20
+ taskId: string;
21
+ subject?: string;
22
+ description?: string;
23
+ activeForm?: string;
24
+ status?: TaskStatus;
25
+ addBlocks?: string[];
26
+ addBlockedBy?: string[];
27
+ owner?: string;
28
+ metadata?: Record<string, unknown>;
29
+ }
30
+ export interface TaskListRow {
31
+ id: string;
32
+ subject: string;
33
+ status: TaskStatus;
34
+ owner?: string;
35
+ blockedBy: string[];
36
+ }
37
+ export type TaskUpdateError = {
38
+ kind: "not_found";
39
+ taskId: string;
40
+ } | {
41
+ kind: "self_reference";
42
+ taskId: string;
43
+ field: "addBlocks" | "addBlockedBy";
44
+ } | {
45
+ kind: "unknown_reference";
46
+ taskId: string;
47
+ field: "addBlocks" | "addBlockedBy";
48
+ missing: string;
49
+ };
50
+ export type TaskUpdateResult = {
51
+ ok: true;
52
+ row: TaskGraphRow;
53
+ } | {
54
+ ok: false;
55
+ error: TaskUpdateError;
56
+ };
57
+ export declare function resetTaskGraphStoreForTest(sessionId?: string): void;
58
+ export declare function createTask(sessionId: string, input: TaskCreateInput): TaskGraphRow;
59
+ export declare function getTask(sessionId: string, taskId: string): TaskGraphRow | undefined;
60
+ export declare function listTasks(sessionId: string): TaskListRow[];
61
+ export declare function updateTask(sessionId: string, input: TaskUpdateInput): TaskUpdateResult;
@@ -0,0 +1,26 @@
1
+ import { type AdvertisedPartition } from "../tools/registry.js";
2
+ import { type BrandProfile } from "@yanlinglabs/winter-agent-sdk";
3
+ /** The one brand field this module needs: the standing server's name. */
4
+ export type AliasBrand = Pick<BrandProfile, "mcpServerName">;
5
+ export declare const WINTER_CANONICAL_ALIAS_SUFFIXES: Readonly<Record<string, string>>;
6
+ /** The branch's own canonical pair for a given brand. */
7
+ export declare function canonicalAliases(brand?: AliasBrand): Record<string, string>;
8
+ /** The default profile's pair, for every caller that has not threaded a brand. */
9
+ export declare const WINTER_CANONICAL_ALIASES: Readonly<Record<string, string>>;
10
+ export declare function effectiveAliasTable(hostAliases: Record<string, string> | undefined, brand?: AliasBrand): Record<string, string>;
11
+ export declare function resolveToolAlias(name: string, toolAliases: Record<string, string> | undefined): string;
12
+ export declare function suppressAliasedDuplicates(partition: AdvertisedPartition, toolAliases: Record<string, string> | undefined, disallowedTools?: readonly string[], brand?: AliasBrand): AdvertisedPartition;
13
+ export interface AliasExclusion {
14
+ reason: string;
15
+ cause: "native-excluded" | "target-denied";
16
+ }
17
+ export declare function aliasExclusionReasons(partition: AdvertisedPartition, hostAliases: Record<string, string> | undefined, disallowedTools: readonly string[] | undefined, brand?: AliasBrand): Map<string, AliasExclusion>;
18
+ export declare function hideAliasExcludedTwins(partition: AdvertisedPartition, hostAliases: Record<string, string> | undefined, disallowedTools: readonly string[] | undefined, brand?: AliasBrand): AdvertisedPartition;
19
+ export declare function aliasPermissionIdentities(name: string, hostAliases: Record<string, string> | undefined, brand?: AliasBrand): string[];
20
+ export interface AliasIdentityProbes {
21
+ deniedByRule(name: string): boolean;
22
+ askedByRule(name: string): boolean;
23
+ hookScoped(name: string): boolean;
24
+ allowedByRule(name: string): boolean;
25
+ }
26
+ export declare function resolvePermissionIdentity(name: string, hostAliases: Record<string, string> | undefined, probes: AliasIdentityProbes, brand?: AliasBrand): string;
@@ -0,0 +1,30 @@
1
+ import { type DeferralActivation, type ToolDescriptor } from "../tools/registry.js";
2
+ import type { PermissionMode } from "@yanlinglabs/winter-agent-sdk";
3
+ export interface ExposureQuery {
4
+ mode: PermissionMode;
5
+ activation: DeferralActivation;
6
+ platform?: NodeJS.Platform;
7
+ capabilities?: readonly string[];
8
+ disallowedTools?: readonly string[];
9
+ insideSubagent?: boolean;
10
+ familyMetadata?: {
11
+ taskNative?: boolean;
12
+ };
13
+ toolAliases?: Record<string, string>;
14
+ /**
15
+ * Fix round 21: the run's own scope over the process-wide registry -- engine.ts passes the SAME
16
+ * predicate its advertised partition applies (`computeAdvertisedPartition`: a live server's MCP tool
17
+ * only for a server the run can see), so ToolSearch never finds or selects another run's tools
18
+ * (e.g. a subagent's own object-form server's, while that subagent runs). claude's ToolSearch
19
+ * searches only the calling agent's own tools (`x = refreshTools?.() ?? tools`, dump byte
20
+ * 15619044). Absent = no scope (every pre-round-21 caller).
21
+ */
22
+ toolFilter?: (descriptor: ToolDescriptor) => boolean;
23
+ }
24
+ export interface DeferredCandidates {
25
+ eager: readonly ToolDescriptor[];
26
+ deferred: readonly ToolDescriptor[];
27
+ hidden: readonly ToolDescriptor[];
28
+ totalDeferredTools: number;
29
+ }
30
+ export declare function computeExposurePartition(query: ExposureQuery): DeferredCandidates;
@@ -0,0 +1,6 @@
1
+ export interface RankableCandidate {
2
+ name: string;
3
+ description: string;
4
+ searchHint?: string;
5
+ }
6
+ export declare function rankCandidates(query: string, candidates: readonly RankableCandidate[], maxResults: number): string[];
@@ -0,0 +1,45 @@
1
+ import type { PermissionMode } from "@yanlinglabs/winter-agent-sdk";
2
+ import type { DeferralActivation, ToolDescriptor } from "../tools/registry.js";
3
+ import type { McpServerStateSource } from "../mcp/state.js";
4
+ export interface FailedMcpServerEntry {
5
+ name: string;
6
+ errorCode?: string;
7
+ error?: string;
8
+ }
9
+ export interface ToolSearchResult {
10
+ matches: string[];
11
+ query: string;
12
+ total_deferred_tools: number;
13
+ pending_mcp_servers?: string[];
14
+ failed_mcp_servers?: FailedMcpServerEntry[];
15
+ }
16
+ export type ToolSearchOutcome = {
17
+ ok: true;
18
+ result: ToolSearchResult;
19
+ } | {
20
+ ok: false;
21
+ message: string;
22
+ };
23
+ export interface ToolSearchDeps {
24
+ getMode(): PermissionMode;
25
+ activation: DeferralActivation;
26
+ platform?: NodeJS.Platform;
27
+ capabilities?: readonly string[];
28
+ disallowedTools?: readonly string[];
29
+ insideSubagent?: boolean;
30
+ familyMetadata?: {
31
+ taskNative?: boolean;
32
+ };
33
+ stateSource?: McpServerStateSource;
34
+ toolAliases?: Record<string, string>;
35
+ toolFilter?: (descriptor: ToolDescriptor) => boolean;
36
+ emitToolReference?(names: string[]): void;
37
+ pendingWaitMs?: number;
38
+ }
39
+ declare function parseSelect(query: string): string[] | undefined;
40
+ export declare function executeToolSearch(input: unknown, deps: ToolSearchDeps): Promise<ToolSearchOutcome>;
41
+ export type ToolSearchSessionRuntime = Omit<ToolSearchDeps, "emitToolReference">;
42
+ export declare function registerToolSearchSessionRuntime(sessionId: string, runtime: ToolSearchSessionRuntime): () => void;
43
+ export declare function unregisterToolSearchSessionRuntime(sessionId: string): void;
44
+ export declare function getToolSearchSessionRuntime(sessionId: string): ToolSearchSessionRuntime | undefined;
45
+ export { parseSelect as parseToolSearchSelect };
@@ -0,0 +1 @@
1
+ export declare const RUNTIME_VERSION = "0.0.27";
@@ -0,0 +1,5 @@
1
+ // src/version.ts
2
+ var RUNTIME_VERSION = "0.0.27";
3
+ export {
4
+ RUNTIME_VERSION
5
+ };
@@ -0,0 +1,28 @@
1
+ /** claude's fetch-time rejects, as a reason a caller may name in a comment or a test. The TEXT the model sees is always `FETCH_TIME_INVALID_URL`. */
2
+ export type UnfetchableUrlReason = "too-long" | "embedded-credentials" | "single-label-hostname";
3
+ /** The three FETCH-TIME rejects' text: a bare `Invalid URL`, never the fuller parse-failure sentence (extraction-notes fidelity #2, corrected). */
4
+ export declare const FETCH_TIME_INVALID_URL = "Invalid URL";
5
+ /** The `http:` -> `https:` upgrade, unconditional and claude's own. Returns `url` itself for any other scheme. */
6
+ export declare function upgradeToHttps(url: URL): URL;
7
+ /**
8
+ * claude's own fetch-time rejects for ONE already-parsed URL: overlong, embedded credentials, a
9
+ * hostname with fewer than two dot-separated labels. `undefined` means none of them applies.
10
+ *
11
+ * Run PER HOP by the executor (claude runs it once on the raw input; running it again on every
12
+ * upgraded hop is strictly stricter and is kept deliberately -- a disclosed, safe deviation).
13
+ */
14
+ export declare function fetchTimeUrlRefusal(url: URL): UnfetchableUrlReason | undefined;
15
+ /**
16
+ * Is this target one the executor is CERTAIN to refuse before it touches the network -- i.e. after
17
+ * the https upgrade, does a fetch-time reject apply?
18
+ *
19
+ * The question the permission layer asks. It takes an already-parsed URL, so an UNPARSEABLE input is
20
+ * outside this predicate entirely: such a call names no host, so no rule could be suggested or saved
21
+ * for it, and its own refusal (`validateInput`'s parse-failure sentence) is a different text.
22
+ */
23
+ export declare function isCertainlyUnfetchableUrl(url: URL): UnfetchableUrlReason | undefined;
24
+ /**
25
+ * The one sentence every text about a private/loopback target ends with, so the ask, the rule hint
26
+ * and the executor's own refusal all say the SAME true thing about what an approval can achieve.
27
+ */
28
+ export declare const FETCHABLE_TARGET_SHAPE = "WebFetch upgrades http to https unconditionally, so only an https service at an IPv4 literal (127.0.0.1) or at a name with two or more dot-separated labels (printer.local) is reachable at all -- a plain-http port on localhost or an IPv6 literal cannot be fetched whatever the policy says.";