@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,74 @@
1
+ import type { AutoEngine } from "../evaluator.js";
2
+ export { BLOCKED_BY_CLASSIFIER_MESSAGE } from "../evaluator.js";
3
+ import { type ActionEnvelope } from "./envelope.js";
4
+ import { type NormalizedAutoModeConfig } from "./config.js";
5
+ import { type AutoVerdictCache, type AutoCounterStore } from "./caches.js";
6
+ import type { AttributedContext } from "../../hooks/reducer.js";
7
+ export interface ClassifierRawResult {
8
+ verdict: "allow" | "deny" | "no_verdict";
9
+ category?: string;
10
+ severity?: string;
11
+ reasonCode?: string;
12
+ auditReason?: string;
13
+ }
14
+ export interface ClassifierContext {
15
+ autoConfig: NormalizedAutoModeConfig;
16
+ classifierContext: AttributedContext[];
17
+ recentUserMessages?: string[];
18
+ winterMdContent?: string;
19
+ repository?: {
20
+ remotes: string[];
21
+ };
22
+ gitStatusSummary?: string;
23
+ }
24
+ export interface ClassifierInterface {
25
+ classify(envelope: ActionEnvelope, context: ClassifierContext): Promise<ClassifierRawResult>;
26
+ }
27
+ export declare const alwaysNoVerdictClassifier: ClassifierInterface;
28
+ export interface ScriptedClassifier extends ClassifierInterface {
29
+ readonly calls: ReadonlyArray<{
30
+ envelope: ActionEnvelope;
31
+ context: ClassifierContext;
32
+ }>;
33
+ }
34
+ export declare function createScriptedClassifier(script: ClassifierRawResult | ClassifierRawResult[] | ((envelope: ActionEnvelope, context: ClassifierContext) => ClassifierRawResult | Promise<ClassifierRawResult>)): ScriptedClassifier;
35
+ export type AutoAuditEventType = "permission_evaluated" | "classifier_started" | "classifier_result" | "classifier_cache_hit" | "permission_denied" | "fallback_state";
36
+ export interface AutoAuditRecord {
37
+ type: AutoAuditEventType;
38
+ sessionId: string;
39
+ at: string;
40
+ toolName: string;
41
+ toolUseId?: string;
42
+ agentId?: string;
43
+ verdict?: "allow" | "deny" | "no_verdict";
44
+ category?: string;
45
+ severity?: string;
46
+ reasonCode?: string;
47
+ auditReason?: string;
48
+ fallbackActive?: boolean;
49
+ consecutive?: number;
50
+ total?: number;
51
+ policyVersion: number;
52
+ policyHash: string;
53
+ latencyMs: number;
54
+ model?: string;
55
+ }
56
+ export interface AutoAuditRecorder {
57
+ record(entry: AutoAuditRecord): void | Promise<void>;
58
+ }
59
+ export declare const NO_OP_AUTO_AUDIT_RECORDER: AutoAuditRecorder;
60
+ export declare function redactAuditReason(reason: string | undefined, ctx: {
61
+ cwd: string;
62
+ home: string;
63
+ }): string | undefined;
64
+ export interface AutoEngineOptions {
65
+ sessionId: string;
66
+ runtimeKind?: string;
67
+ classifier?: ClassifierInterface;
68
+ counters?: AutoCounterStore;
69
+ cache?: AutoVerdictCache;
70
+ audit?: AutoAuditRecorder;
71
+ getClassifierContext?: () => AttributedContext[];
72
+ getGeneration?: () => number;
73
+ }
74
+ export declare function createAutoEngine(options: AutoEngineOptions): AutoEngine;
@@ -0,0 +1,45 @@
1
+ import type { PermissionCall, EvaluationContext } from "../evaluator.js";
2
+ import type { AttributedContext } from "../../hooks/reducer.js";
3
+ export interface ResolvedEnvelopePath {
4
+ path: string;
5
+ resolvedTarget: string;
6
+ isSymlink: boolean;
7
+ }
8
+ export interface ActionProvenance {
9
+ suspicious?: boolean;
10
+ source?: string;
11
+ }
12
+ export interface ActionBoundaries {
13
+ protectedWrite: boolean;
14
+ criticalRemoval: boolean;
15
+ criticalReason?: string;
16
+ }
17
+ export interface ActionEnvelope {
18
+ toolUseId?: string;
19
+ agentId?: string;
20
+ sessionId?: string;
21
+ runtimeKind?: string;
22
+ turnId?: string;
23
+ toolName: string;
24
+ canonicalToolName: string;
25
+ input: Record<string, unknown>;
26
+ cwd: string;
27
+ roots: string[];
28
+ resolvedPaths: ResolvedEnvelopePath[];
29
+ shellSubcommands?: string[];
30
+ shellRedirectTargets?: string[];
31
+ provenance?: ActionProvenance;
32
+ boundaries: ActionBoundaries;
33
+ sessionCreatedResources: string[];
34
+ networkDestinations?: string[];
35
+ repository?: {
36
+ remotes: string[];
37
+ };
38
+ classifierContext: AttributedContext[];
39
+ }
40
+ export interface BuildActionEnvelopeExtras {
41
+ sessionId?: string;
42
+ runtimeKind?: string;
43
+ classifierContext?: AttributedContext[];
44
+ }
45
+ export declare function buildActionEnvelope(call: PermissionCall, ctx: EvaluationContext, extras?: BuildActionEnvelopeExtras): ActionEnvelope;
@@ -0,0 +1,27 @@
1
+ import type { PermissionMode } from "@yanlinglabs/winter-agent-sdk";
2
+ import type { PolicyState } from "../policy-state.js";
3
+ export declare const AUTO_MODE_STRICTNESS_ORDER: readonly PermissionMode[];
4
+ export declare class ChildResumeModeIncomparableError extends Error {
5
+ readonly modeA: PermissionMode;
6
+ readonly modeB: PermissionMode;
7
+ constructor(modeA: PermissionMode, modeB: PermissionMode);
8
+ }
9
+ export declare function stricterOf(a: PermissionMode, b: PermissionMode): PermissionMode;
10
+ export interface ChildAgentDefinition {
11
+ permissionMode?: PermissionMode;
12
+ }
13
+ export interface ComputeChildPolicyOptions {
14
+ disableBypassPermissionsMode?: boolean;
15
+ }
16
+ export interface ChildPolicyResult {
17
+ effectiveMode: PermissionMode;
18
+ parentPolicyVersion: number;
19
+ parentPolicyHash: string;
20
+ }
21
+ export declare function computeChildPolicy(parent: PolicyState, def: ChildAgentDefinition, opts?: ComputeChildPolicyOptions): ChildPolicyResult;
22
+ export interface RecordedChildPolicy {
23
+ effectiveMode: PermissionMode;
24
+ parentPolicyVersion: number;
25
+ parentPolicyHash: string;
26
+ }
27
+ export declare function resolveChildResumeMode(recorded: RecordedChildPolicy, currentParentMode: PermissionMode): PermissionMode;
@@ -0,0 +1,30 @@
1
+ import { type BrandProfile } from "@yanlinglabs/winter-agent-sdk";
2
+ export type RecognizedEditKind = "edit" | "bashFsOp" | "other";
3
+ export interface RecognizedEditOperation {
4
+ kind: RecognizedEditKind;
5
+ paths: string[];
6
+ }
7
+ export declare const RECOGNIZED_BASH_FS_OPS: ReadonlySet<string>;
8
+ export declare function tokenizeWords(s: string): string[];
9
+ export declare function isFlagToken(token: string): boolean;
10
+ export declare function nonFlagOperands(tokens: string[]): string[];
11
+ export declare function fileRulePathField(toolName: string): "file_path" | "notebook_path" | "path";
12
+ export declare function shellCommandOf(call: {
13
+ toolName: string;
14
+ input: Record<string, unknown>;
15
+ }): string | undefined;
16
+ export declare function recognizeEditOperation(call: {
17
+ toolName: string;
18
+ input: Record<string, unknown>;
19
+ }, opts?: {
20
+ sessionRoot?: string;
21
+ brand?: Pick<BrandProfile, "projectDirName">;
22
+ home?: string;
23
+ }): RecognizedEditOperation | null;
24
+ /**
25
+ * Why a shell command's WRITES cannot be auto-approved, or `undefined`: a process substitution, a
26
+ * command that cannot be parsed, a write target that is a variable/command expansion, a `~user` form
27
+ * or a glob, and `cp`/`mv` with ANY flag (`--target-directory=PATH` hides the destination). The
28
+ * working-directory and `cd` checks that follow claude's are evaluator.ts's (they need the session).
29
+ */
30
+ export declare function shellWriteConstraint(command: string): string | undefined;
@@ -0,0 +1,284 @@
1
+ import type { PermissionBehavior, PermissionUpdate, RuleSource, PermissionDecisionClassification } from "@yanlinglabs/winter-agent-sdk";
2
+ import type { SourcedRuleEntry, SourcedRuleSet } from "./ruleset.js";
3
+ import type { PolicyState, AutoModeConfig } from "./policy-state.js";
4
+ import { type ProtectedBrand } from "./protected.js";
5
+ export type { AutoModeConfig };
6
+ export type { PermissionDecisionClassification };
7
+ export interface PermissionCall {
8
+ toolName: string;
9
+ input: Record<string, unknown>;
10
+ toolUseId?: string;
11
+ agentId?: string;
12
+ }
13
+ export declare const ASK_USER_QUESTION_TOOL_NAME = "AskUserQuestion";
14
+ export interface HookDecision {
15
+ decision: "allow" | "deny" | "ask" | "defer" | "no_opinion";
16
+ transformedInput?: Record<string, unknown>;
17
+ message?: string;
18
+ interrupt?: boolean;
19
+ hookId?: string;
20
+ }
21
+ export interface PermissionRequestHookDecision {
22
+ decision: "allow" | "deny";
23
+ transformedInput?: Record<string, unknown>;
24
+ updatedPermissions?: PermissionUpdate[];
25
+ message?: string;
26
+ interrupt?: boolean;
27
+ hookId?: string;
28
+ }
29
+ export interface HookStage {
30
+ preToolUse(call: PermissionCall, ctx: EvaluationContext): Promise<HookDecision>;
31
+ permissionRequest(call: PermissionCall, ctx: EvaluationContext, meta: PromptStageMeta): Promise<PermissionRequestHookDecision | null>;
32
+ }
33
+ export interface PromptStageMeta {
34
+ decisionReason: string;
35
+ toolUseID?: string;
36
+ agentID?: string;
37
+ matchedAskRule?: {
38
+ source: RuleSource;
39
+ toolName: string;
40
+ ruleContent?: string;
41
+ };
42
+ blockedPath?: string;
43
+ }
44
+ export interface PromptDecision {
45
+ decision: "allow" | "deny";
46
+ transformedInput?: Record<string, unknown>;
47
+ message?: string;
48
+ interrupt?: boolean;
49
+ updatedPermissions?: PermissionUpdate[];
50
+ decisionClassification?: PermissionDecisionClassification;
51
+ }
52
+ export interface PromptStage {
53
+ prompt(call: PermissionCall, ctx: EvaluationContext, meta: PromptStageMeta): Promise<PromptDecision | null>;
54
+ }
55
+ export interface AutoEngineVerdict {
56
+ verdict: "allow" | "deny" | "no_verdict";
57
+ category?: string;
58
+ reasonCode?: string;
59
+ fallbackToPrompt?: boolean;
60
+ }
61
+ export interface AutoEngine {
62
+ classify(call: PermissionCall, ctx: EvaluationContext): Promise<AutoEngineVerdict>;
63
+ noteFallbackResolution?(outcome: "allow" | "deny"): void;
64
+ noteHeadlessFallbackDenial?(call: PermissionCall, ctx: EvaluationContext): void | Promise<void>;
65
+ }
66
+ export interface CriticalRemovalResult {
67
+ critical: boolean;
68
+ reason?: string;
69
+ }
70
+ export interface SpecialChecks {
71
+ isProtectedWrite(call: PermissionCall, ctx: EvaluationContext): boolean;
72
+ isCriticalRemoval(call: PermissionCall, ctx: EvaluationContext): CriticalRemovalResult;
73
+ }
74
+ export interface EvaluationContext {
75
+ policy: PolicyState;
76
+ cwd: string;
77
+ /**
78
+ * Does this Bash call's `dangerouslyDisableSandbox` actually take it OUT of a sandbox it would
79
+ * otherwise run in? (dist-session fixes, lane C C3 -- claude's `!shouldUseSandbox(input) &&
80
+ * shouldUseSandbox({...input, dangerouslyDisableSandbox: false})`.) False when the session's sandbox
81
+ * is off, when the policy forbids unsandboxed commands (the flag is then ignored), or when the
82
+ * command is an allowed `excludedCommands` entry. Only such a call is an ESCAPE, handled by
83
+ * `resolveSandboxEscape`. Injected because the evaluator cannot see the session's sandbox settings;
84
+ * ABSENT reads as "the flag escapes" -- the conservative answer.
85
+ */
86
+ bashSandboxEscape?: (call: PermissionCall) => boolean;
87
+ /**
88
+ * The CURRENT TURN's abort signal (lane C, C2). The prompt stage hands it to the permission RPC, so
89
+ * an interrupt while a prompt is open cancels that request at its source -- the bridge writes
90
+ * `control_cancel_request` and the host's `canUseTool` sees its signal abort (claude parity). Absent
91
+ * outside a turn (and in every hand-built test context): the request then waits as it always has.
92
+ */
93
+ signal?: AbortSignal;
94
+ sessionRoot: string;
95
+ home: string;
96
+ trustedWorkspace: boolean;
97
+ allowManagedPermissionRulesOnly?: boolean;
98
+ additionalDirectories?: string[];
99
+ sessionBypassEnabled?: boolean;
100
+ /**
101
+ * Phase 5 Task 8 (rider 18): every name a skill answers to -- `SkillIndex.identities(name)`.
102
+ *
103
+ * Injected rather than imported for the same reason `requiresInteraction` below is: the evaluator
104
+ * is stateless and holds no session, while the skill index is per-session state
105
+ * (`skills/runtime.ts`'s registry, keyed `agentId ?? sessionId`). engine.ts supplies it; a direct
106
+ * caller may omit it, and a `Skill(...)` rule then matches on the literal name alone -- correct,
107
+ * just blind to the `<projectDir>:<name>` alias a project skill also answers to.
108
+ */
109
+ skillIdentities?: (skillName: string) => readonly string[];
110
+ /**
111
+ * Phase 5 fix wave, I1: the RESOLVED winter root, DISTINCT from `home` (the OS home) above.
112
+ *
113
+ * Two consumers, both of which were silently wrong under a `<PREFIX>HOME` whose basename is not
114
+ * the brand's own dot-dir: the P5-B workflow-script carve-out (which must name the directory
115
+ * `workflows/store.ts` actually persists to) and `isProtectedWrite`'s own carve-out check.
116
+ * Absent = the pre-fix behaviour, `<home>/<homeDirName>/...` only.
117
+ */
118
+ winterHome?: string;
119
+ /**
120
+ * WS-21 §3.7: the shared runtime home's durable-paths root (`config.storeHome`), preferred over
121
+ * `winterHome` by the SAME two consumers `winterHome`'s own header names -- `projects/` (what the
122
+ * P5-B workflow-script carve-out and `isProtectedWrite`'s own wholesale-protect check both
123
+ * address) lives under the store home once the router links `buildRunHome`, not under the per-run
124
+ * folder `winterHome` names. Absent falls back to `winterHome`, byte-identical to pre-WS-21.
125
+ */
126
+ storeHome?: string;
127
+ /**
128
+ * The session's outputs directory (`RuntimeConfig.outputsDir`, exported to the shell as `$OUTDIR`).
129
+ * Two effects, both mirroring what the Bash tool already does with it (a sandbox-writable root):
130
+ * a shell write there is inside the session's writable directories (claude's sandbox-write-allowlist
131
+ * step), and, when it sits inside the winter home, the protected floor's winter-home part does not
132
+ * cover it (protected.ts's outputs carve-out). It is NOT a working directory: acceptEdits and the
133
+ * mode allows are unchanged. Absent = no outputs directory.
134
+ */
135
+ outputsDir?: string;
136
+ /**
137
+ * P7a (D19): the session's brand -- the protected-path floor's own dot-dir and instructions file.
138
+ *
139
+ * Optional, `WINTER_BRAND` when absent, so every hand-built evaluation context in this package's
140
+ * tests keeps exactly today's verdicts.
141
+ */
142
+ brand?: ProtectedBrand;
143
+ /**
144
+ * Phase 5 fix wave, B-H1(a): "will this exact call run under the OS sandbox, with
145
+ * `autoAllowBashIfSandboxed` on?" -- WS-12 §1's composition MUST, which had no consumer at all.
146
+ *
147
+ * INJECTED rather than computed here, for the same reason `requiresInteraction` and
148
+ * `skillIdentities` are: the answer depends on the session's resolved `SandboxSettings`, on
149
+ * `sandbox-exec` being available on this host, and on the call's own `dangerouslyDisableSandbox`
150
+ * (an escape -- see `bashSandboxEscape`), none of which this module can see. Absent = the pre-fix behaviour, i.e. the setting
151
+ * stays inert for any caller that does not supply it.
152
+ */
153
+ bashRunsSandboxed?: (call: PermissionCall) => boolean;
154
+ hookStage: HookStage;
155
+ promptStage: PromptStage;
156
+ autoEngine: AutoEngine;
157
+ specialChecks: SpecialChecks;
158
+ requiresInteraction?: (toolName: string) => boolean;
159
+ /**
160
+ * The session's `web.fetch.privateAddressPolicy`, exactly as configured -- `"allow" | "ask" | "deny"`.
161
+ *
162
+ * INJECTED for the same reason `requiresInteraction` is: the value lives on the session's web
163
+ * runtime, and this module holds no session. Taken RAW (a plain `string`) and normalised here by
164
+ * `normalizePrivateAddressPolicy`, which fails closed: only the exact string `"allow"` is allow,
165
+ * `"deny"` is deny, and ANYTHING ELSE -- an unrecognised value, and an absent one -- is `"ask"`,
166
+ * the option's own documented default. So a hand-built context that omits this field gets the
167
+ * default posture rather than silently none.
168
+ */
169
+ webFetchPrivateAddressPolicy?: string;
170
+ }
171
+ export interface PermissionDecisionRecord {
172
+ decision: "allow" | "deny" | "ask" | "defer";
173
+ mechanism: "hook" | "rule" | "mode" | "canUseTool" | "autoEngine" | "crash";
174
+ source?: RuleSource;
175
+ hookId?: string;
176
+ ruleRef?: string;
177
+ transformedInput?: Record<string, unknown>;
178
+ message?: string;
179
+ interrupt?: boolean;
180
+ updatedPermissions?: PermissionUpdate[];
181
+ decisionClassification?: PermissionDecisionClassification;
182
+ policyVersion: number;
183
+ deniedBareSchemaRemoval?: boolean;
184
+ /**
185
+ * WHY an `allow` was allowed, where the reason is not already carried by `mechanism`/`ruleRef`.
186
+ * Set today by two paths: the preapproved-host auto-allow (`PREAPPROVED_HOST_REASON`) and the
187
+ * lexically-unfetchable WebFetch short-circuit (`UNFETCHABLE_URL_REASON`).
188
+ */
189
+ decisionReason?: string;
190
+ /**
191
+ * Set on an `allow` that was EXPLICITLY approved for this exact call, as opposed to one the
192
+ * session's mode or a broad rule let through:
193
+ * - `"prompt"` -- something ANSWERED a request for this call: a `canUseTool` answer, or a
194
+ * PermissionRequest hook's. The asker saw this call's own input.
195
+ * - `"rule"` -- a standing allow rule NAMES this call's target exactly. For WebFetch that is
196
+ * `WebFetch(domain:<host>)` with no `*` in it, equal to the call's hostname, from a tier this
197
+ * workspace's trust admits. It is stamped whichever stage produced the allow -- the consent is
198
+ * the rule's existence, not the route the call happened to take (under `bypassPermissions` the
199
+ * mode stage allows first and the rule is never consulted, yet the user's consent is the same).
200
+ *
201
+ * ABSENT for everything else: a mode allow, a bare / `Tool(*)` / glob rule, a PreToolUse hook's
202
+ * pre-approval, the classifier. None of those is a statement about THIS target.
203
+ *
204
+ * STAMPED ONLY FOR THE TOOLS THAT CONSUME IT -- today `WebFetch`, whose executor must know whether
205
+ * a private-address target was consented to (it cannot prompt mid-call). Every other tool's record
206
+ * is byte-identical to what it was before this field existed.
207
+ */
208
+ explicitApproval?: "prompt" | "rule";
209
+ }
210
+ export declare const NO_OPINION_HOOK_STAGE: HookStage;
211
+ export declare const NO_OPINION_PROMPT_STAGE: PromptStage;
212
+ export declare const NO_OPINION_AUTO_ENGINE: AutoEngine;
213
+ export declare const NO_SPECIAL_CHECKS: SpecialChecks;
214
+ export declare function boundedRoots(ctx: EvaluationContext): string[];
215
+ export declare function extractCandidateWritePaths(call: PermissionCall, ctx: EvaluationContext): string[];
216
+ /**
217
+ * Port of claude's `mL` (dump byte 14442494, pinned 2.1.250) -- the safety check `$K` (same byte
218
+ * region) runs on every candidate write path BEFORE any other approval logic, unconditionally
219
+ * forcing an ask (`classifierApprovable:!1` in claude's own source -- never classifier/auto-
220
+ * approvable, unlike `$K`'s OTHER checks) when it fires. Ported here as a pure predicate; the
221
+ * evaluator wires it in as a new stage-3 mandatory-ask reason, below.
222
+ *
223
+ * Two of claude's own branches are Windows/WSL-only BY CLAUDE'S OWN GATE and are DELIBERATELY
224
+ * omitted, disclosed rather than silently dropped (this codebase targets macOS only, CLAUDE.md's own
225
+ * latest-OS-floors rule):
226
+ * - the `U()==="windows"||U()==="wsl"`-gated colon-position check (a second `:` after index 2,
227
+ * Windows alternate-data-stream syntax) is genuinely inert off Windows/WSL in claude's OWN
228
+ * source -- there is nothing to port.
229
+ * - the trailing `Dg(e,!0)&&!Ha(e)&&!Fe(e,t)` clause is STRUCTURALLY DEAD on macOS in claude's own
230
+ * source too: `Dg`'s (dump byte 14418249) own first line is `if(U()!=="windows")return!1`, which
231
+ * short-circuits the whole `&&` chain to `false` on every non-Windows host claude itself runs
232
+ * on. Porting an intentional no-op would just be dead code; omitted, disclosed rather than
233
+ * silently dropped.
234
+ *
235
+ * `FU` (dump byte 11268201: `function FU(t){return lt.test(t)||t.includes("??")&&lt.test(pt(t))}`,
236
+ * `pt` win32-normalizes only on Windows, else identity) IS ported below, in its macOS-reduced form
237
+ * (`pt` is the identity function here, so `FU` reduces to the single regex test) -- claude calls it
238
+ * unconditionally, not gated to Windows, so this is a straight port, not a judgment call. `lt`'s own
239
+ * literal bytes (re-verified with a fresh byte-slice extraction after an advisor review caught a
240
+ * narrower first draft: the dump's raw bytes are `[` `\` `\` `/` `]`, i.e. a JS source character
241
+ * class holding an ESCAPED backslash plus a forward slash) is `/^[\\/]\?\?[\\/]/` -- EITHER separator
242
+ * at both ends (`\??\`, `\??/`, `/??\`, `/??/`), not `/` alone.
243
+ */
244
+ export declare function isSuspiciousPath(path: string): boolean;
245
+ export declare const REAL_SPECIAL_CHECKS: SpecialChecks;
246
+ export declare function findMatchingRuleEntry(rules: SourcedRuleSet, call: PermissionCall, behavior: PermissionBehavior, ctx: EvaluationContext, opts?: {
247
+ skip?: (entry: SourcedRuleEntry) => boolean;
248
+ }): SourcedRuleEntry | undefined;
249
+ export declare function findAgentDenyRule(rules: SourcedRuleSet, type: string, opts?: {
250
+ allowManagedPermissionRulesOnly?: boolean;
251
+ }): SourcedRuleEntry | undefined;
252
+ /**
253
+ * R3b §4's own denial prose, verbatim shape (ground truth: d2-report.md scenario 3):
254
+ * "Agent type '<t>' has been denied by permission rule '<ruleRef>' from <source>." `<source>` is
255
+ * Winter's OWN rule-source label for wherever the matched entry actually came from (`entry.source`
256
+ * -- "sdk" for `Options.disallowedTools`, "user"/"project"/"local"/"managed"/"session" for the
257
+ * others) -- never a hardcoded "cliArg" (that is claude's OWN label for the differential harness's
258
+ * `--disallowedTools` CLI flag, a mechanism this repo's own tests do not reproduce; the task brief
259
+ * is explicit that the source label must match Winter's own).
260
+ */
261
+ export declare function agentTypeDeniedMessage(type: string, entry: SourcedRuleEntry): string;
262
+ /** The `skip` predicate the stage-2 deny lookup passes, or `undefined` when this call earns no carve-out at all. */
263
+ export declare function workflowScriptCarveOutSkip(call: PermissionCall, ctx: EvaluationContext): ((entry: SourcedRuleEntry) => boolean) | undefined;
264
+ /** The auto-memory `skip` predicate, or `undefined` when this call earns no carve-out at all. */
265
+ export declare function memoryCarveOutSkip(call: PermissionCall, ctx: EvaluationContext): ((entry: SourcedRuleEntry) => boolean) | undefined;
266
+ /**
267
+ * The ONE skip both stage-2 deny lookups pass: the union of the two `projects/**` carve-outs.
268
+ *
269
+ * A union rather than a third predicate, so each carve-out keeps its own independently-testable
270
+ * entry point (`brand-rebrand.test.ts` pins `workflowScriptCarveOutSkip` by name) and neither can
271
+ * widen the other. Both arms return the identical `isProjectsBaselineDeny` predicate, so which arm
272
+ * produced it is not observable downstream -- only WHETHER this call earns one at all.
273
+ */
274
+ export declare function projectsCarveOutSkip(call: PermissionCall, ctx: EvaluationContext): ((entry: SourcedRuleEntry) => boolean) | undefined;
275
+ /** The reason recorded on a preapproved-host allow -- the reference runtime's own wording. */
276
+ export declare const PREAPPROVED_HOST_REASON = "Preapproved host";
277
+ /** `decisionReason` for the whole-branch review's M2 short-circuit: see `certainlyUnfetchableWebFetchTarget` and the branch that uses it. */
278
+ export declare const UNFETCHABLE_URL_REASON = "WebFetch refuses this URL before any network access";
279
+ export declare const PLAN_WRITE_WITHHELD_MESSAGE = "Denied: plan mode withholds file/shell writes until the plan is approved or session bypass is enabled (WS-07 \u00A76.5)";
280
+ export declare const BLOCKED_BY_CLASSIFIER_MESSAGE = "Blocked by classifier";
281
+ export declare const SANDBOX_ESCAPE_REASON = "Run outside of the sandbox";
282
+ export declare function evaluate(call: PermissionCall, ctx: EvaluationContext): Promise<PermissionDecisionRecord>;
283
+ export type ReadAccessProbe = "silent" | "prompt" | "deny";
284
+ export declare function probeReadAccess(filePath: string, ctx: EvaluationContext): ReadAccessProbe;