@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.
- package/LICENSE +21 -0
- package/NOTICE +41 -0
- package/README.md +64 -0
- package/dist/checkpoint/file-history.d.ts +81 -0
- package/dist/checkpoint/rewind.d.ts +55 -0
- package/dist/checkpoint/seam.d.ts +47 -0
- package/dist/checkpoint/sink.d.ts +66 -0
- package/dist/commands/builtins-listing.d.ts +40 -0
- package/dist/commands/resolver.d.ts +103 -0
- package/dist/commands/seam.d.ts +53 -0
- package/dist/compaction/controller.d.ts +23 -0
- package/dist/compaction/retention.d.ts +35 -0
- package/dist/compaction/seam.d.ts +115 -0
- package/dist/compaction/summarizer.d.ts +79 -0
- package/dist/context/agent-listing.d.ts +39 -0
- package/dist/context/assembler.d.ts +46 -0
- package/dist/context/attachments.d.ts +104 -0
- package/dist/context/dynamic-sections.d.ts +31 -0
- package/dist/context/git-fixture.d.ts +18 -0
- package/dist/context/git-status.d.ts +16 -0
- package/dist/context/imports.d.ts +22 -0
- package/dist/context/injection.d.ts +53 -0
- package/dist/context/memory-key.d.ts +46 -0
- package/dist/context/memory.d.ts +28 -0
- package/dist/context/minimal-prompt.d.ts +5 -0
- package/dist/context/output-styles.d.ts +68 -0
- package/dist/context/plan-mode.d.ts +29 -0
- package/dist/context/request-layout.d.ts +138 -0
- package/dist/context/rules.d.ts +63 -0
- package/dist/context/seam.d.ts +136 -0
- package/dist/context/tool-epoch.d.ts +118 -0
- package/dist/context/winter-code-preset.d.ts +39 -0
- package/dist/context/winter-md.d.ts +81 -0
- package/dist/embedded-host.d.ts +48 -0
- package/dist/embedded-host.js +155 -0
- package/dist/embedded-protocol.d.ts +44 -0
- package/dist/embedded-worker.d.ts +1 -0
- package/dist/embedded-worker.js +74 -0
- package/dist/embedded.d.ts +34 -0
- package/dist/embedded.js +9 -0
- package/dist/engine.d.ts +1298 -0
- package/dist/hooks/additional-context.d.ts +21 -0
- package/dist/hooks/bounds.d.ts +6 -0
- package/dist/hooks/bridge-invoker.d.ts +3 -0
- package/dist/hooks/command-invoker.d.ts +52 -0
- package/dist/hooks/from-config.d.ts +31 -0
- package/dist/hooks/hook-stage.d.ts +25 -0
- package/dist/hooks/input-validator.d.ts +6 -0
- package/dist/hooks/reducer.d.ts +74 -0
- package/dist/hooks/registry.d.ts +33 -0
- package/dist/hooks/runner.d.ts +105 -0
- package/dist/index-584yahed.js +6037 -0
- package/dist/index-97t2rmtf.js +42 -0
- package/dist/index-9qgkpv56.js +27183 -0
- package/dist/index-bef62z3r.js +437 -0
- package/dist/index-rkhh0457.js +187 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.js +353 -0
- package/dist/main.d.ts +1 -0
- package/dist/mcp/client.d.ts +105 -0
- package/dist/mcp/control-seam.d.ts +25 -0
- package/dist/mcp/control.d.ts +5 -0
- package/dist/mcp/elicitation.d.ts +35 -0
- package/dist/mcp/env.d.ts +12 -0
- package/dist/mcp/lifecycle.d.ts +142 -0
- package/dist/mcp/output-cap.d.ts +15 -0
- package/dist/mcp/state.d.ts +24 -0
- package/dist/mcp/test-fixtures.d.ts +88 -0
- package/dist/mcp/transports/__fixtures__/stdio-server.d.ts +1 -0
- package/dist/mcp/transports/http.d.ts +5 -0
- package/dist/mcp/transports/sdk.d.ts +5 -0
- package/dist/mcp/transports/sse.d.ts +3 -0
- package/dist/mcp/transports/stdio.d.ts +35 -0
- package/dist/mcp/winter-server.d.ts +2 -0
- package/dist/messaging/reference-adapter.d.ts +88 -0
- package/dist/messaging/router.d.ts +8 -0
- package/dist/paths/project-dir-name.d.ts +2 -0
- package/dist/paths/temp.d.ts +25 -0
- package/dist/permissions/approvals.d.ts +107 -0
- package/dist/permissions/auto/caches.d.ts +53 -0
- package/dist/permissions/auto/config.d.ts +37 -0
- package/dist/permissions/auto/engine.d.ts +74 -0
- package/dist/permissions/auto/envelope.d.ts +45 -0
- package/dist/permissions/auto/inheritance.d.ts +27 -0
- package/dist/permissions/edit-recognition.d.ts +30 -0
- package/dist/permissions/evaluator.d.ts +284 -0
- package/dist/permissions/file-rules.d.ts +384 -0
- package/dist/permissions/grammar.d.ts +113 -0
- package/dist/permissions/paths.d.ts +32 -0
- package/dist/permissions/policy-state.d.ts +64 -0
- package/dist/permissions/prompt-stage.d.ts +3 -0
- package/dist/permissions/protected.d.ts +54 -0
- package/dist/permissions/ruleset.d.ts +134 -0
- package/dist/permissions/shell-structure.d.ts +41 -0
- package/dist/plugins/bundle.d.ts +100 -0
- package/dist/plugins/installed.d.ts +30 -0
- package/dist/plugins/loader.d.ts +56 -0
- package/dist/plugins/manifest.d.ts +115 -0
- package/dist/production-wiring.d.ts +340 -0
- package/dist/protocol/channel.d.ts +22 -0
- package/dist/provider/advisor-route.d.ts +47 -0
- package/dist/provider/bridge.d.ts +124 -0
- package/dist/provider/classifier/model-classifier.d.ts +82 -0
- package/dist/provider/classifier/prompt.d.ts +62 -0
- package/dist/provider/classifier/verdict-schema.d.ts +83 -0
- package/dist/provider/credential-api.d.ts +160 -0
- package/dist/provider/family-listing.d.ts +27 -0
- package/dist/provider/first-party.d.ts +4 -0
- package/dist/provider/keychain-store.d.ts +59 -0
- package/dist/provider/lean-prompt.d.ts +7 -0
- package/dist/provider/mock.d.ts +55 -0
- package/dist/provider/scenario-fake.d.ts +96 -0
- package/dist/provider/selection.d.ts +115 -0
- package/dist/provider/session-provider.d.ts +426 -0
- package/dist/provider/slots.d.ts +120 -0
- package/dist/provider/stream-frames.d.ts +25 -0
- package/dist/provider/tool-secret.d.ts +57 -0
- package/dist/rpc/bridge.d.ts +14 -0
- package/dist/rpc/mcp-control.d.ts +26 -0
- package/dist/runtime.d.ts +14 -0
- package/dist/sandbox/profile.d.ts +249 -0
- package/dist/sandbox/spawn.d.ts +139 -0
- package/dist/settings/env-filter.d.ts +52 -0
- package/dist/settings/loaders/hooks.d.ts +44 -0
- package/dist/settings/loaders/mcp-config.d.ts +83 -0
- package/dist/settings/loaders/plugin-mcp.d.ts +3 -0
- package/dist/settings/loaders/strict-plugin-only.d.ts +13 -0
- package/dist/settings/resolve.d.ts +2 -0
- package/dist/settings/sources.d.ts +2 -0
- package/dist/settings/trust.d.ts +36 -0
- package/dist/skills/attachment.d.ts +25 -0
- package/dist/skills/frontmatter.d.ts +64 -0
- package/dist/skills/index.d.ts +16 -0
- package/dist/skills/listing.d.ts +89 -0
- package/dist/skills/loader.d.ts +104 -0
- package/dist/skills/option.d.ts +68 -0
- package/dist/skills/permission-rules.d.ts +21 -0
- package/dist/skills/runtime.d.ts +21 -0
- package/dist/skills/store.d.ts +163 -0
- package/dist/store/continuation-attach.d.ts +44 -0
- package/dist/store/dialect.d.ts +526 -0
- package/dist/store/provider-state.d.ts +188 -0
- package/dist/store/resume.d.ts +92 -0
- package/dist/structured/ajv-seam.d.ts +7 -0
- package/dist/structured/descriptor.d.ts +9 -0
- package/dist/structured/seam.d.ts +51 -0
- package/dist/structured/validator.d.ts +22 -0
- package/dist/subagents/activity.d.ts +13 -0
- package/dist/subagents/availability.d.ts +30 -0
- package/dist/subagents/builtin-agents.d.ts +37 -0
- package/dist/subagents/child-engine.d.ts +198 -0
- package/dist/subagents/child-handle.d.ts +344 -0
- package/dist/subagents/definitions.d.ts +189 -0
- package/dist/subagents/fork.d.ts +55 -0
- package/dist/subagents/git-root.d.ts +1 -0
- package/dist/subagents/limits.d.ts +28 -0
- package/dist/subagents/notification-queue.d.ts +233 -0
- package/dist/subagents/plugin-agents.d.ts +5 -0
- package/dist/subagents/policy.d.ts +46 -0
- package/dist/subagents/register-default-factory.d.ts +66 -0
- package/dist/subagents/resolution.d.ts +56 -0
- package/dist/subagents/restore.d.ts +9 -0
- package/dist/subagents/roster.d.ts +17 -0
- package/dist/subagents/test-fakes.d.ts +12 -0
- package/dist/subagents/tool-pools.d.ts +69 -0
- package/dist/subagents/watchdog.d.ts +13 -0
- package/dist/subagents/workspace.d.ts +27 -0
- package/dist/testing.d.ts +5 -0
- package/dist/testing.js +194 -0
- package/dist/tools/background-tasks.d.ts +10 -0
- package/dist/tools/descriptors/_shared.d.ts +34 -0
- package/dist/tools/descriptors/advisor.d.ts +1 -0
- package/dist/tools/descriptors/agent.d.ts +47 -0
- package/dist/tools/descriptors/artifact.d.ts +1 -0
- package/dist/tools/descriptors/ask-user-question.d.ts +1 -0
- package/dist/tools/descriptors/bash.d.ts +20 -0
- package/dist/tools/descriptors/claude-design.d.ts +1 -0
- package/dist/tools/descriptors/cron-create.d.ts +1 -0
- package/dist/tools/descriptors/cron-delete.d.ts +1 -0
- package/dist/tools/descriptors/cron-list.d.ts +1 -0
- package/dist/tools/descriptors/edit.d.ts +1 -0
- package/dist/tools/descriptors/end-conversation.d.ts +1 -0
- package/dist/tools/descriptors/enter-plan-mode.d.ts +1 -0
- package/dist/tools/descriptors/enter-worktree.d.ts +1 -0
- package/dist/tools/descriptors/exit-plan-mode.d.ts +1 -0
- package/dist/tools/descriptors/exit-worktree.d.ts +1 -0
- package/dist/tools/descriptors/glob.d.ts +1 -0
- package/dist/tools/descriptors/grep.d.ts +1 -0
- package/dist/tools/descriptors/index.d.ts +59 -0
- package/dist/tools/descriptors/list-agents.d.ts +1 -0
- package/dist/tools/descriptors/list-mcp-resources-tool.d.ts +1 -0
- package/dist/tools/descriptors/lsp.d.ts +1 -0
- package/dist/tools/descriptors/monitor.d.ts +1 -0
- package/dist/tools/descriptors/notebook-edit.d.ts +1 -0
- package/dist/tools/descriptors/powershell.d.ts +1 -0
- package/dist/tools/descriptors/projects.d.ts +1 -0
- package/dist/tools/descriptors/propose-goal.d.ts +1 -0
- package/dist/tools/descriptors/propose-skills.d.ts +1 -0
- package/dist/tools/descriptors/push-notification.d.ts +1 -0
- package/dist/tools/descriptors/read-mcp-resource-dir-tool.d.ts +1 -0
- package/dist/tools/descriptors/read-mcp-resource-tool.d.ts +1 -0
- package/dist/tools/descriptors/read-notifications.d.ts +1 -0
- package/dist/tools/descriptors/read.d.ts +1 -0
- package/dist/tools/descriptors/refresh-mcp-tools.d.ts +1 -0
- package/dist/tools/descriptors/remote-trigger.d.ts +1 -0
- package/dist/tools/descriptors/repl.d.ts +1 -0
- package/dist/tools/descriptors/report-findings.d.ts +1 -0
- package/dist/tools/descriptors/schedule-wakeup.d.ts +1 -0
- package/dist/tools/descriptors/send-feedback.d.ts +1 -0
- package/dist/tools/descriptors/send-message.d.ts +1 -0
- package/dist/tools/descriptors/send-user-file.d.ts +1 -0
- package/dist/tools/descriptors/share-onboarding-guide.d.ts +1 -0
- package/dist/tools/descriptors/show-onboarding-role-picker.d.ts +1 -0
- package/dist/tools/descriptors/skill.d.ts +1 -0
- package/dist/tools/descriptors/structured-output.d.ts +1 -0
- package/dist/tools/descriptors/task-create.d.ts +1 -0
- package/dist/tools/descriptors/task-get.d.ts +1 -0
- package/dist/tools/descriptors/task-list.d.ts +1 -0
- package/dist/tools/descriptors/task-output.d.ts +1 -0
- package/dist/tools/descriptors/task-stop.d.ts +1 -0
- package/dist/tools/descriptors/task-update.d.ts +1 -0
- package/dist/tools/descriptors/todo-write.d.ts +1 -0
- package/dist/tools/descriptors/tool-search.d.ts +1 -0
- package/dist/tools/descriptors/wait-for-mcp-servers.d.ts +1 -0
- package/dist/tools/descriptors/web-fetch.d.ts +8 -0
- package/dist/tools/descriptors/web-search.d.ts +15 -0
- package/dist/tools/descriptors/winter-list-agents.d.ts +1 -0
- package/dist/tools/descriptors/winter-send-message.d.ts +1 -0
- package/dist/tools/descriptors/workflow.d.ts +1 -0
- package/dist/tools/descriptors/write.d.ts +1 -0
- package/dist/tools/impl/_caller.d.ts +14 -0
- package/dist/tools/impl/_domains.d.ts +25 -0
- package/dist/tools/impl/_exa-client.d.ts +122 -0
- package/dist/tools/impl/_exa-session-client.d.ts +23 -0
- package/dist/tools/impl/_inner-model.d.ts +135 -0
- package/dist/tools/impl/_search-budget.d.ts +36 -0
- package/dist/tools/impl/_web-fetch-cache.d.ts +37 -0
- package/dist/tools/impl/_web-fetch-html.d.ts +26 -0
- package/dist/tools/impl/_web-fetch-net.d.ts +99 -0
- package/dist/tools/impl/_web-search-assembler.d.ts +57 -0
- package/dist/tools/impl/advisor.d.ts +37 -0
- package/dist/tools/impl/agent.d.ts +10 -0
- package/dist/tools/impl/ask-user-question.d.ts +5 -0
- package/dist/tools/impl/background-task-runtime.d.ts +272 -0
- package/dist/tools/impl/bash.d.ts +78 -0
- package/dist/tools/impl/cron.d.ts +11 -0
- package/dist/tools/impl/edit.d.ts +1 -0
- package/dist/tools/impl/enter-plan-mode.d.ts +4 -0
- package/dist/tools/impl/enter-worktree.d.ts +25 -0
- package/dist/tools/impl/exit-plan-mode.d.ts +4 -0
- package/dist/tools/impl/exit-worktree.d.ts +4 -0
- package/dist/tools/impl/glob.d.ts +1 -0
- package/dist/tools/impl/grep.d.ts +19 -0
- package/dist/tools/impl/index.d.ts +37 -0
- package/dist/tools/impl/list-agents.d.ts +7 -0
- package/dist/tools/impl/list-mcp-resources-tool.d.ts +9 -0
- package/dist/tools/impl/monitor.d.ts +66 -0
- package/dist/tools/impl/notebook-edit.d.ts +1 -0
- package/dist/tools/impl/push-notification.d.ts +4 -0
- package/dist/tools/impl/read-ladder.d.ts +25 -0
- package/dist/tools/impl/read-mcp-resource-dir-tool.d.ts +9 -0
- package/dist/tools/impl/read-mcp-resource-tool.d.ts +9 -0
- package/dist/tools/impl/read-notifications.d.ts +5 -0
- package/dist/tools/impl/read.d.ts +44 -0
- package/dist/tools/impl/refresh-mcp-tools.d.ts +8 -0
- package/dist/tools/impl/report-findings.d.ts +1 -0
- package/dist/tools/impl/schedule-wakeup.d.ts +2 -0
- package/dist/tools/impl/send-message.d.ts +7 -0
- package/dist/tools/impl/skill.d.ts +5 -0
- package/dist/tools/impl/task-graph.d.ts +1 -0
- package/dist/tools/impl/task-output.d.ts +16 -0
- package/dist/tools/impl/task-stop.d.ts +11 -0
- package/dist/tools/impl/todo-write.d.ts +8 -0
- package/dist/tools/impl/tool-search.d.ts +4 -0
- package/dist/tools/impl/wait-for-mcp-servers.d.ts +29 -0
- package/dist/tools/impl/web-fetch.d.ts +36 -0
- package/dist/tools/impl/web-search.d.ts +30 -0
- package/dist/tools/impl/workflow.d.ts +5 -0
- package/dist/tools/impl/write.d.ts +8 -0
- package/dist/tools/paths-seam.d.ts +6 -0
- package/dist/tools/read-state.d.ts +12 -0
- package/dist/tools/registry.d.ts +423 -0
- package/dist/tools/task-graph-store.d.ts +61 -0
- package/dist/toolsearch/aliases.d.ts +26 -0
- package/dist/toolsearch/exposure.d.ts +30 -0
- package/dist/toolsearch/ranking.d.ts +6 -0
- package/dist/toolsearch/search.d.ts +45 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +5 -0
- package/dist/web/fetchable-url.d.ts +28 -0
- package/dist/web/preapproved-hosts.d.ts +52 -0
- package/dist/web/private-address.d.ts +55 -0
- package/dist/web/session-runtime.d.ts +86 -0
- package/dist/workflows/bridge.d.ts +87 -0
- package/dist/workflows/budget.d.ts +24 -0
- package/dist/workflows/host-registry.d.ts +142 -0
- package/dist/workflows/journal.d.ts +29 -0
- package/dist/workflows/meta.d.ts +45 -0
- package/dist/workflows/registry.d.ts +24 -0
- package/dist/workflows/runtime.d.ts +254 -0
- package/dist/workflows/sandbox.d.ts +49 -0
- package/dist/workflows/script-api.d.ts +58 -0
- package/dist/workflows/seam.d.ts +92 -0
- package/dist/workflows/semaphore.d.ts +16 -0
- package/dist/workflows/store.d.ts +177 -0
- package/dist/workflows/subprocess-entry.d.ts +38 -0
- package/dist/workflows/subprocess-entry.js +14 -0
- package/dist/workflows/transcript.d.ts +56 -0
- package/dist/workflows/types.d.ts +84 -0
- package/dist/workflows/worker-harness.d.ts +45 -0
- package/package.json +76 -0
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import type { McpServerConfigForProcessTransport } from "@yanlinglabs/winter-agent-sdk";
|
|
2
|
+
import type { McpServerStateSource } from "./state.js";
|
|
3
|
+
import type { McpControlSeam } from "./control-seam.js";
|
|
4
|
+
import type { McpEnvConfig } from "./env.js";
|
|
5
|
+
import { type McpToolInfo, type ConnectedMcpClient } from "./client.js";
|
|
6
|
+
import type { ElicitationAsker } from "./elicitation.js";
|
|
7
|
+
import type { InProcessMcpServer } from "./transports/sdk.js";
|
|
8
|
+
export type McpConfigSourceOrigin = "explicit" | "settings" | "project" | "plugin" | "dynamic";
|
|
9
|
+
export interface McpServerSource {
|
|
10
|
+
origin: McpConfigSourceOrigin;
|
|
11
|
+
servers: Readonly<Record<string, unknown>>;
|
|
12
|
+
}
|
|
13
|
+
export interface ResolvedMcpServerEntry {
|
|
14
|
+
name: string;
|
|
15
|
+
origin: McpConfigSourceOrigin;
|
|
16
|
+
config: McpServerConfigForProcessTransport;
|
|
17
|
+
/**
|
|
18
|
+
* RULING P5-K (fix wave): present means "this declaration is VALID but must not connect until the
|
|
19
|
+
* host says so", and the string is the human-readable why. `createMcpLifecycle` gives such an entry
|
|
20
|
+
* a slot in the `disabled` state carrying this reason, `start()` makes no connection attempt for
|
|
21
|
+
* it, and `enableSlot(name)` connects it -- a toggle being, by construction, a host decision.
|
|
22
|
+
*
|
|
23
|
+
* DISTINCT FROM `rejected`, deliberately. A rejected declaration is WRONG (malformed, reserved
|
|
24
|
+
* name, unknown type) and never becomes a slot at all -- it is invisible, which is the right answer
|
|
25
|
+
* for something that could never work. An untrusted project server is not wrong; it is not yet
|
|
26
|
+
* permitted, and a host that cannot see it cannot permit it.
|
|
27
|
+
*/
|
|
28
|
+
disabledReason?: string;
|
|
29
|
+
}
|
|
30
|
+
export interface ShadowedMcpServerEntry {
|
|
31
|
+
name: string;
|
|
32
|
+
origin: McpConfigSourceOrigin;
|
|
33
|
+
shadowedBy: McpConfigSourceOrigin;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Why a declaration was refused, as a CODE a caller can branch on (the `reason` is prose for a
|
|
37
|
+
* human). WS-23 added the code; every rejection carries one.
|
|
38
|
+
*
|
|
39
|
+
* - `invalid_config` -- malformed, an unrecognized `type`, the claudeai-proxy variant, or a bad
|
|
40
|
+
* `versionNegotiation` value (`validateServerConfig`).
|
|
41
|
+
* - `reserved_name` -- the standing server's name (RULING P4-B).
|
|
42
|
+
* - `sdk_type_from_file_config` -- a `type: "sdk"` entry from a settings/project/plugin FILE. Only
|
|
43
|
+
* the host's own `Options.mcpServers` (origin `explicit`) may declare one; see the check itself.
|
|
44
|
+
*/
|
|
45
|
+
export type McpServerRejectionCode = "invalid_config" | "reserved_name" | "sdk_type_from_file_config";
|
|
46
|
+
export interface RejectedMcpServerEntry {
|
|
47
|
+
name: string;
|
|
48
|
+
origin: McpConfigSourceOrigin;
|
|
49
|
+
code: McpServerRejectionCode;
|
|
50
|
+
reason: string;
|
|
51
|
+
}
|
|
52
|
+
export interface ResolveMcpServerSourcesResult {
|
|
53
|
+
resolved: ResolvedMcpServerEntry[];
|
|
54
|
+
shadowed: ShadowedMcpServerEntry[];
|
|
55
|
+
rejected: RejectedMcpServerEntry[];
|
|
56
|
+
}
|
|
57
|
+
declare function validateServerConfig(raw: unknown): {
|
|
58
|
+
ok: true;
|
|
59
|
+
config: McpServerConfigForProcessTransport;
|
|
60
|
+
} | {
|
|
61
|
+
ok: false;
|
|
62
|
+
reason: string;
|
|
63
|
+
};
|
|
64
|
+
export { validateServerConfig };
|
|
65
|
+
/**
|
|
66
|
+
* P7a fix wave (item 5, whole-branch review I-2): the RESERVED name is the SESSION BRAND's.
|
|
67
|
+
*
|
|
68
|
+
* `WINTER_SERVER_NAME` is `WINTER_BRAND.mcpServerName` computed at module load, so under a rebrand
|
|
69
|
+
* this door and `registry.ts`'s read two different names. The registry reserves the SESSION's
|
|
70
|
+
* `brand.mcpServerName` (per session, via `rebrandStandingServerTools`); this door reserved
|
|
71
|
+
* `"winter"` forever. Consequences, both real:
|
|
72
|
+
*
|
|
73
|
+
* - a settings/project/explicit server named `acme` passed here, got validated, CONNECTED (a stdio
|
|
74
|
+
* child spawned, `slot.client` assigned) and only then hit `registerMcpServerTools`' own
|
|
75
|
+
* reserved-name throw -- which is verbatim the defect control.ts records the P4 fix wave closing,
|
|
76
|
+
* re-opened for the brand's own name;
|
|
77
|
+
* - and a reuser could not name any live server `winter`, a stale reservation for a standing
|
|
78
|
+
* server that under their brand is called `acme`.
|
|
79
|
+
*
|
|
80
|
+
* The parameter defaults to `WINTER_SERVER_NAME`, so every existing caller and fixture keeps today's
|
|
81
|
+
* behaviour byte for byte.
|
|
82
|
+
*/
|
|
83
|
+
export declare function resolveMcpServerSources(sources: readonly McpServerSource[], opts: {
|
|
84
|
+
strictMcpConfig?: boolean;
|
|
85
|
+
trustedWorkspace: boolean;
|
|
86
|
+
reservedServerName?: string;
|
|
87
|
+
}): ResolveMcpServerSourcesResult;
|
|
88
|
+
export interface McpDiscoveryCache {
|
|
89
|
+
get(key: string): McpToolInfo[] | undefined;
|
|
90
|
+
set(key: string, tools: McpToolInfo[]): void;
|
|
91
|
+
}
|
|
92
|
+
export declare function createInMemoryDiscoveryCache(): McpDiscoveryCache;
|
|
93
|
+
export declare const FIRST_TURN_MCP_WAIT_DEFAULT_MS = 2000;
|
|
94
|
+
export declare function firstTurnMcpWaitDeadlineMs(opts: {
|
|
95
|
+
strictMcpConfig?: boolean;
|
|
96
|
+
explicitServers?: Readonly<Record<string, unknown>>;
|
|
97
|
+
envConfig: Pick<McpEnvConfig, "timeoutMs">;
|
|
98
|
+
}): number;
|
|
99
|
+
export interface McpLifecycleDeps {
|
|
100
|
+
servers: readonly ResolvedMcpServerEntry[];
|
|
101
|
+
envConfig: McpEnvConfig;
|
|
102
|
+
elicitationAsk: ElicitationAsker;
|
|
103
|
+
inProcessServers?: Readonly<Record<string, InProcessMcpServer>>;
|
|
104
|
+
discoveryCache?: McpDiscoveryCache;
|
|
105
|
+
/**
|
|
106
|
+
* P7a fix wave (item 5, I-2): the name the STANDING server occupies for this session --
|
|
107
|
+
* `brand.mcpServerName`, not the module-load default. Forwarded to the control seam, whose
|
|
108
|
+
* `addAndConnect` guard is the second door onto the same rule. Defaults to `WINTER_SERVER_NAME`.
|
|
109
|
+
*/
|
|
110
|
+
reservedServerName?: string;
|
|
111
|
+
/** WS-23: the session cwd every stdio server of this lifecycle is spawned in (see `ConnectMcpServerOptions.cwd`). */
|
|
112
|
+
cwd?: string;
|
|
113
|
+
}
|
|
114
|
+
export type RefreshServerToolsResult = {
|
|
115
|
+
ok: true;
|
|
116
|
+
toolNames: string[];
|
|
117
|
+
} | {
|
|
118
|
+
ok: false;
|
|
119
|
+
reason: string;
|
|
120
|
+
};
|
|
121
|
+
export interface McpLifecycle {
|
|
122
|
+
readonly stateSource: McpServerStateSource;
|
|
123
|
+
readonly controlSeam: McpControlSeam;
|
|
124
|
+
start(): Promise<void>;
|
|
125
|
+
dispose(): Promise<void>;
|
|
126
|
+
listConnectedServerNames(): string[];
|
|
127
|
+
getConnectedClient(server: string): ConnectedMcpClient | undefined;
|
|
128
|
+
refreshServerTools(server: string): Promise<RefreshServerToolsResult>;
|
|
129
|
+
}
|
|
130
|
+
export declare function registerSessionMcpLifecycle(sessionId: string, lifecycle: McpLifecycle): () => void;
|
|
131
|
+
export declare function getSessionMcpLifecycle(sessionId: string): McpLifecycle | undefined;
|
|
132
|
+
export declare function createMcpLifecycle(deps: McpLifecycleDeps): McpLifecycle;
|
|
133
|
+
export interface McpLifecycleInternals {
|
|
134
|
+
hasSlot(name: string): boolean;
|
|
135
|
+
getSlotOrigin(name: string): McpConfigSourceOrigin | undefined;
|
|
136
|
+
listSlotNames(): string[];
|
|
137
|
+
reconnectExisting(name: string): Promise<void>;
|
|
138
|
+
disableSlot(name: string): void;
|
|
139
|
+
enableSlot(name: string): Promise<void>;
|
|
140
|
+
addAndConnect(name: string, origin: McpConfigSourceOrigin, config: McpServerConfigForProcessTransport): Promise<void>;
|
|
141
|
+
removeSlot(name: string): Promise<void>;
|
|
142
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const MCP_PERSISTED_OUTPUT_DIRNAME = "mcp-output";
|
|
2
|
+
export declare function estimateTokens(text: string): number;
|
|
3
|
+
export interface McpOutputCapResult {
|
|
4
|
+
text: string;
|
|
5
|
+
truncated: boolean;
|
|
6
|
+
originalTokens: number;
|
|
7
|
+
cappedTokens: number;
|
|
8
|
+
persistedPath?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface McpPersistTarget {
|
|
11
|
+
sessionDir(): string;
|
|
12
|
+
serverName: string;
|
|
13
|
+
toolName: string;
|
|
14
|
+
}
|
|
15
|
+
export declare function capMcpOutput(text: string, maxOutputTokens: number, target: McpPersistTarget): McpOutputCapResult;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export type McpServerStateKind = "pending" | "connected" | "cached" | "failed" | "needsAuth" | "disabled" | "unconfigured";
|
|
2
|
+
export interface McpServerState {
|
|
3
|
+
name: string;
|
|
4
|
+
state: McpServerStateKind;
|
|
5
|
+
errorCode?: string;
|
|
6
|
+
error?: string;
|
|
7
|
+
toolNames: string[];
|
|
8
|
+
/**
|
|
9
|
+
* WS-23: the protocol revision the server's LIVE connection negotiated (`2025-11-25`, or
|
|
10
|
+
* `2026-07-28` when `versionNegotiation` selected the modern era). Present only while a live
|
|
11
|
+
* connection exists -- absent for `pending`/`cached`/`failed`/`needsAuth`, and for an in-process
|
|
12
|
+
* `sdk` server reported through RULING P4-C's state-only feed (there is no protocol connection to
|
|
13
|
+
* have a version). Additive: every consumer that predates it reads name/state/toolNames only.
|
|
14
|
+
*/
|
|
15
|
+
protocolVersion?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface McpServerStateSource {
|
|
18
|
+
snapshot(): McpServerState[];
|
|
19
|
+
subscribe(cb: (states: McpServerState[]) => void): () => void;
|
|
20
|
+
waitForPending(servers: string[] | undefined, deadlineMs: number): Promise<McpServerState[]>;
|
|
21
|
+
}
|
|
22
|
+
export declare function createFakeMcpServerStateSource(initial: readonly McpServerState[]): McpServerStateSource & {
|
|
23
|
+
transition(name: string, next: McpServerStateKind, extra?: Partial<McpServerState>): void;
|
|
24
|
+
};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { type Transport } from "@modelcontextprotocol/client";
|
|
2
|
+
import { Server, type InputRequiredResult, type ServerContext } from "@modelcontextprotocol/server";
|
|
3
|
+
export interface FixtureContentBlock {
|
|
4
|
+
type: string;
|
|
5
|
+
text?: string;
|
|
6
|
+
[key: string]: unknown;
|
|
7
|
+
}
|
|
8
|
+
export interface FixtureToolResult {
|
|
9
|
+
content: FixtureContentBlock[];
|
|
10
|
+
isError?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface FixtureTool {
|
|
13
|
+
name: string;
|
|
14
|
+
description?: string;
|
|
15
|
+
inputSchema?: Record<string, unknown>;
|
|
16
|
+
annotations?: Record<string, unknown>;
|
|
17
|
+
_meta?: Record<string, unknown>;
|
|
18
|
+
/**
|
|
19
|
+
* `ctx` is the v2 request context: a 2026-07-28 multi-round-trip handler reads the client's
|
|
20
|
+
* answers off `ctx.mcpReq.inputResponses` and returns `inputRequired(...)` to ask for more (on a
|
|
21
|
+
* 2025-era connection the SDK's legacy shim turns that same return into a real server->client
|
|
22
|
+
* `elicitation/create`, so one handler serves both eras).
|
|
23
|
+
*/
|
|
24
|
+
handler: (args: Record<string, unknown>, server: Server, ctx: ServerContext) => Promise<FixtureToolResult | InputRequiredResult> | FixtureToolResult | InputRequiredResult;
|
|
25
|
+
}
|
|
26
|
+
export interface FixtureResourceBody {
|
|
27
|
+
text?: string;
|
|
28
|
+
blobBase64?: string;
|
|
29
|
+
mimeType?: string;
|
|
30
|
+
}
|
|
31
|
+
export interface FixtureResource {
|
|
32
|
+
uri: string;
|
|
33
|
+
name?: string;
|
|
34
|
+
mimeType?: string;
|
|
35
|
+
description?: string;
|
|
36
|
+
read: () => FixtureResourceBody;
|
|
37
|
+
}
|
|
38
|
+
export interface FixtureServerSpec {
|
|
39
|
+
name?: string;
|
|
40
|
+
/** Read at REQUEST time, not captured at construction: a test may replace it and then announce the change. */
|
|
41
|
+
tools?: FixtureTool[];
|
|
42
|
+
resources?: FixtureResource[];
|
|
43
|
+
/** WS-23: advertise `tools.listChanged`, so a client wires its list-changed handler. */
|
|
44
|
+
toolsListChanged?: boolean;
|
|
45
|
+
}
|
|
46
|
+
export declare function defaultFixtureSpec(): FixtureServerSpec;
|
|
47
|
+
export declare function createFixtureMcpServer(spec: FixtureServerSpec): Server;
|
|
48
|
+
export declare function withInMemoryFixture<T>(spec: FixtureServerSpec, fn: (clientTransport: Transport, server: Server) => Promise<T>): Promise<T>;
|
|
49
|
+
export declare function withModernInMemoryFixture<T>(spec: FixtureServerSpec, fn: (clientTransport: Transport, servers: Server[]) => Promise<T>): Promise<T>;
|
|
50
|
+
export declare function withHttpFixture<T>(spec: FixtureServerSpec, fn: (url: URL) => Promise<T>): Promise<T>;
|
|
51
|
+
export declare function withModernHttpFixture<T>(spec: FixtureServerSpec, fn: (url: URL, notify: {
|
|
52
|
+
toolsChanged(): void;
|
|
53
|
+
}) => Promise<T>): Promise<T>;
|
|
54
|
+
export declare function withSseFixture<T>(spec: FixtureServerSpec, fn: (url: URL) => Promise<T>): Promise<T>;
|
|
55
|
+
export declare function stdioFixtureCommand(): {
|
|
56
|
+
command: string;
|
|
57
|
+
args: string[];
|
|
58
|
+
};
|
|
59
|
+
export declare function pingFixtureCommand(opts?: {
|
|
60
|
+
label?: string;
|
|
61
|
+
delayMs?: number;
|
|
62
|
+
}): {
|
|
63
|
+
command: string;
|
|
64
|
+
args: string[];
|
|
65
|
+
};
|
|
66
|
+
export declare function grandchildSpawningCommand(): {
|
|
67
|
+
command: string;
|
|
68
|
+
args: string[];
|
|
69
|
+
};
|
|
70
|
+
import type { McpLifecycle, RefreshServerToolsResult } from "./lifecycle.js";
|
|
71
|
+
import type { ConnectedMcpClient, McpResourceContent, McpResourceInfo, McpToolCallResult, McpToolInfo } from "./client.js";
|
|
72
|
+
export interface FakeConnectedMcpClientOverrides {
|
|
73
|
+
listTools?: () => Promise<McpToolInfo[]>;
|
|
74
|
+
listResources?: () => Promise<McpResourceInfo[]>;
|
|
75
|
+
readResource?: (uri: string, opts?: {
|
|
76
|
+
timeoutMs?: number;
|
|
77
|
+
}) => Promise<McpResourceContent[]>;
|
|
78
|
+
callTool?: (name: string, args: Record<string, unknown>, opts?: {
|
|
79
|
+
timeoutMs?: number;
|
|
80
|
+
}) => Promise<McpToolCallResult>;
|
|
81
|
+
close?: () => Promise<void>;
|
|
82
|
+
}
|
|
83
|
+
export declare function createFakeConnectedMcpClient(serverName: string, overrides?: FakeConnectedMcpClientOverrides): ConnectedMcpClient;
|
|
84
|
+
export interface FakeMcpLifecycleOverrides {
|
|
85
|
+
connectedServers?: Readonly<Record<string, ConnectedMcpClient>>;
|
|
86
|
+
refreshServerTools?: (server: string) => Promise<RefreshServerToolsResult>;
|
|
87
|
+
}
|
|
88
|
+
export declare function createFakeMcpLifecycle(overrides?: FakeMcpLifecycleOverrides): McpLifecycle;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type JSONRPCMessage, type Transport } from "@modelcontextprotocol/client";
|
|
2
|
+
import type { McpStdioServerConfig } from "@yanlinglabs/winter-agent-sdk";
|
|
3
|
+
export declare const STDIO_BASE_ENV_NAMES: readonly ["HOME", "LOGNAME", "PATH", "SHELL", "TERM", "USER"];
|
|
4
|
+
export declare function buildStdioEnv(cfgEnv: Record<string, string> | undefined): Record<string, string>;
|
|
5
|
+
export interface WinterStdioTransportOptions {
|
|
6
|
+
command: string;
|
|
7
|
+
args?: string[];
|
|
8
|
+
env?: Record<string, string>;
|
|
9
|
+
/**
|
|
10
|
+
* WS-23: the SESSION's cwd, REQUIRED. A spawned `winter` child used to be started in the session
|
|
11
|
+
* cwd, so an unstated spawn cwd inherited it; an embedded session runs in a Worker, which cannot
|
|
12
|
+
* have a cwd of its own (`process.cwd()` there is the host daemon's -- `/` under launchd), so a
|
|
13
|
+
* server with relative `args` (`node ./mcp/server.js`) would start in the wrong tree. Required
|
|
14
|
+
* rather than defaulted so no caller can silently fall back to the process cwd.
|
|
15
|
+
*/
|
|
16
|
+
cwd: string;
|
|
17
|
+
}
|
|
18
|
+
export declare class WinterStdioTransport implements Transport {
|
|
19
|
+
private readonly opts;
|
|
20
|
+
private child;
|
|
21
|
+
private readonly readBuffer;
|
|
22
|
+
private stderrTailBuffer;
|
|
23
|
+
onclose?: () => void;
|
|
24
|
+
onerror?: (error: Error) => void;
|
|
25
|
+
onmessage?: (message: JSONRPCMessage) => void;
|
|
26
|
+
constructor(opts: WinterStdioTransportOptions);
|
|
27
|
+
get pid(): number | null;
|
|
28
|
+
start(): Promise<void>;
|
|
29
|
+
get stderrTail(): string;
|
|
30
|
+
private withStderrTail;
|
|
31
|
+
private processReadBuffer;
|
|
32
|
+
send(message: JSONRPCMessage): Promise<void>;
|
|
33
|
+
close(): Promise<void>;
|
|
34
|
+
}
|
|
35
|
+
export declare function buildStdioTransport(cfg: McpStdioServerConfig, cwd: string): WinterStdioTransport;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { PermissionMode } from "@yanlinglabs/winter-agent-sdk";
|
|
2
|
+
import { type ChildLike, type RuntimeAddress, type DeliveryOutcome, type GlobalAgentMessage, type RuntimeMessagingAdapter, type CrossSessionInbound, type NotificationQueue, type MessagingRouterSeamWithRoster, type MessagingRuntimeDeps, type SubscriberDirectory } from "@yanlinglabs/winter-agent-sdk/messaging";
|
|
3
|
+
export interface PeerSessionHandle {
|
|
4
|
+
readonly address: RuntimeAddress;
|
|
5
|
+
readonly name?: string;
|
|
6
|
+
readonly cwd?: string;
|
|
7
|
+
status(): "starting" | "running" | "idle" | "exited" | "unavailable" | "archived";
|
|
8
|
+
mode(): PermissionMode;
|
|
9
|
+
bypassAvailable(): boolean;
|
|
10
|
+
crossSessionInbound?(): CrossSessionInbound | undefined;
|
|
11
|
+
hasReliableIdleSignal(): boolean;
|
|
12
|
+
deliver(msg: GlobalAgentMessage): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
export interface PeerDirectory {
|
|
15
|
+
list(): PeerSessionHandle[];
|
|
16
|
+
find(address: RuntimeAddress): PeerSessionHandle | undefined;
|
|
17
|
+
register(handle: PeerSessionHandle): () => void;
|
|
18
|
+
}
|
|
19
|
+
export declare function createInMemoryPeerDirectory(): PeerDirectory;
|
|
20
|
+
export interface ReferenceAdapterDeps {
|
|
21
|
+
getChildren(): readonly ChildLike[];
|
|
22
|
+
peers: PeerDirectory;
|
|
23
|
+
notifications: NotificationQueue;
|
|
24
|
+
subscribers: SubscriberDirectory;
|
|
25
|
+
now(): number;
|
|
26
|
+
}
|
|
27
|
+
export interface ReferenceMessagingAdapter extends RuntimeMessagingAdapter {
|
|
28
|
+
firePeerIdleTransition(address: RuntimeAddress): void;
|
|
29
|
+
sweepExpiredIdleSubscriptions(): void;
|
|
30
|
+
reevaluateHeldFor(address: RuntimeAddress): Promise<Array<{
|
|
31
|
+
messageId: string;
|
|
32
|
+
outcome: DeliveryOutcome;
|
|
33
|
+
}>>;
|
|
34
|
+
sweepExpiredHeld(): Array<{
|
|
35
|
+
messageId: string;
|
|
36
|
+
outcome: DeliveryOutcome;
|
|
37
|
+
}>;
|
|
38
|
+
}
|
|
39
|
+
export declare function createReferenceMessagingAdapter(deps: ReferenceAdapterDeps): ReferenceMessagingAdapter;
|
|
40
|
+
export interface DefaultMessagingRuntime extends MessagingRuntimeDeps {
|
|
41
|
+
adapter: ReferenceMessagingAdapter;
|
|
42
|
+
peers: PeerDirectory;
|
|
43
|
+
seam: MessagingRouterSeamWithRoster;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* R-7b-4: THIS RUNTIME's answer to "was that throw a policy refusal, or a crash window?"
|
|
47
|
+
*
|
|
48
|
+
* `MessagingRuntimeDeps.classifyDeliveryError` is the one behavioural seam the move introduced. The
|
|
49
|
+
* router core cannot recognise a refusal class belonging to a runtime it does not import, so the
|
|
50
|
+
* owner supplies the predicate -- and this is Winter's: RULING P4-D's incomparable
|
|
51
|
+
* recorded-vs-current-parent mode pair, thrown by `ChildHandle.resume()` and deliberately NOT
|
|
52
|
+
* swallowed by the adapter above, is a clean, side-effect-free policy refusal. Everything else is
|
|
53
|
+
* indistinguishable from "the effect may already have happened", which is WS-10 §12's
|
|
54
|
+
* `delivery_uncertain`.
|
|
55
|
+
*
|
|
56
|
+
* Exported so `router-wiring.test.ts` can pin both directions on the REAL class.
|
|
57
|
+
*/
|
|
58
|
+
export declare function classifyDeliveryError(err: unknown): "refused" | "uncertain";
|
|
59
|
+
/**
|
|
60
|
+
* Fix r1 (I3): a message into a session's input stream whose sender cannot be ATTRIBUTED.
|
|
61
|
+
*
|
|
62
|
+
* A clean, side-effect-free refusal -- nothing has been written -- so it classifies as `refused`
|
|
63
|
+
* rather than as WS-10 §12's crash window. Thrown from a session peer's own `deliver`, which is the
|
|
64
|
+
* only point that knows both the envelope and the stream it would be written to.
|
|
65
|
+
*/
|
|
66
|
+
export declare class UnattributableSenderError extends Error {
|
|
67
|
+
constructor(reason: string);
|
|
68
|
+
}
|
|
69
|
+
export declare function createDefaultMessagingRuntime(opts?: {
|
|
70
|
+
now?: () => number;
|
|
71
|
+
getChildren?: () => readonly ChildLike[];
|
|
72
|
+
}): DefaultMessagingRuntime;
|
|
73
|
+
/**
|
|
74
|
+
* The registered runtime, IF it is one this file built.
|
|
75
|
+
*
|
|
76
|
+
* `getMessagingRuntime()` answers `MessagingRuntimeDeps`, which is all the router core needs and
|
|
77
|
+
* deliberately carries neither a peer directory nor an idle-transition trigger -- both are
|
|
78
|
+
* owner-specific (WS-10 §15). The engine's messaging facet needs both to serve
|
|
79
|
+
* `messaging.subscribe_idle` and `messaging.idle_notice`, so it asks THIS question instead of
|
|
80
|
+
* casting: a host that registered its OWN runtime has its own session-status event source and its
|
|
81
|
+
* own directory, and must not have this one's absence papered over with a cast that would throw at
|
|
82
|
+
* the first call.
|
|
83
|
+
*
|
|
84
|
+
* Duck-typed on the two members the engine actually uses, so a host that supplies a compatible
|
|
85
|
+
* runtime is served too -- the check is about capability, not about identity.
|
|
86
|
+
*/
|
|
87
|
+
export declare function getDefaultMessagingRuntime(): DefaultMessagingRuntime | undefined;
|
|
88
|
+
export declare function ensureDefaultMessagingRuntimeRegistered(): MessagingRouterSeamWithRoster;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { PermissionMode } from "@yanlinglabs/winter-agent-sdk";
|
|
2
|
+
import type { MessagingRuntimeDeps } from "@yanlinglabs/winter-agent-sdk/messaging";
|
|
3
|
+
export { MAX_TRACKED_MESSAGE_IDS, rememberBounded, createMessagingRouterSeam, createSubscriberDirectory, callerAddress, sendMessage, listAgents, readNotifications, createMessagingRouter, } from "@yanlinglabs/winter-agent-sdk/messaging";
|
|
4
|
+
export type { MessagingRouterSeamWithRoster, SubscriberDirectory, MessagingRuntimeDeps, CallerContext, SessionCallerContext, SendMessageInput, NotifyOutcome, SendMessageResult, ListAgentsInput, MessagingRouter, RuntimeAddress, ListedRuntimeObject, DeliveryOutcome, } from "@yanlinglabs/winter-agent-sdk/messaging";
|
|
5
|
+
export type { PermissionMode };
|
|
6
|
+
export declare function registerMessagingRuntime(runtime: MessagingRuntimeDeps): void;
|
|
7
|
+
export declare function getMessagingRuntime(): MessagingRuntimeDeps | undefined;
|
|
8
|
+
export declare function resetMessagingRuntimeForTest(): void;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Stats } from "node:fs";
|
|
2
|
+
import { type BrandProfile } from "@yanlinglabs/winter-agent-sdk";
|
|
3
|
+
export type TempBrand = Pick<BrandProfile, "envPrefix" | "tempRootName">;
|
|
4
|
+
export declare class WinterPathsError extends Error {
|
|
5
|
+
constructor(message: string);
|
|
6
|
+
}
|
|
7
|
+
export declare function assertOwnedDir(stat: Pick<Stats, "uid"> & {
|
|
8
|
+
isDirectory(): boolean;
|
|
9
|
+
isSymbolicLink(): boolean;
|
|
10
|
+
}, pathForError: string): void;
|
|
11
|
+
export declare function resolveTempBase(env?: Record<string, string | undefined>, brand?: Pick<BrandProfile, "envPrefix">): string;
|
|
12
|
+
export interface SessionTempDirOptions {
|
|
13
|
+
tempProjectKey: string;
|
|
14
|
+
backendUuid: string;
|
|
15
|
+
env?: Record<string, string | undefined>;
|
|
16
|
+
/** P7a (D19): the session's resolved brand. Omitted = `WINTER_BRAND`, i.e. today's names. */
|
|
17
|
+
brand?: TempBrand;
|
|
18
|
+
}
|
|
19
|
+
export interface SessionTempDirPaths {
|
|
20
|
+
root: string;
|
|
21
|
+
scratchpad: string;
|
|
22
|
+
tasks: string;
|
|
23
|
+
}
|
|
24
|
+
export declare function sessionTempDir(opts: SessionTempDirOptions): SessionTempDirPaths;
|
|
25
|
+
export declare function ensureTasksDir(paths: Pick<SessionTempDirPaths, "tasks">): string;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import type { PermissionMode, PermissionUpdate, RuleSource, PermissionDecisionClassification } from "@yanlinglabs/winter-agent-sdk";
|
|
2
|
+
export interface DurableApprovalDisplayMetadata {
|
|
3
|
+
decisionReason: string;
|
|
4
|
+
blockedPath?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface ApprovalResolution {
|
|
7
|
+
mechanism: "hook" | "canUseTool" | "system";
|
|
8
|
+
at: string;
|
|
9
|
+
message?: string;
|
|
10
|
+
transformedInput?: Record<string, unknown>;
|
|
11
|
+
updatedPermissions?: PermissionUpdate[];
|
|
12
|
+
decisionClassification?: PermissionDecisionClassification;
|
|
13
|
+
reason?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface DurableApprovalRecord {
|
|
16
|
+
runtimeKind: string;
|
|
17
|
+
sessionId: string;
|
|
18
|
+
backendSessionId: string;
|
|
19
|
+
requestId: string;
|
|
20
|
+
toolUseID: string;
|
|
21
|
+
agentID?: string;
|
|
22
|
+
toolName: string;
|
|
23
|
+
originalInput: Record<string, unknown>;
|
|
24
|
+
displayMetadata: DurableApprovalDisplayMetadata;
|
|
25
|
+
permissionSuggestions?: PermissionUpdate[];
|
|
26
|
+
matchedAskRule?: {
|
|
27
|
+
source: RuleSource;
|
|
28
|
+
toolName: string;
|
|
29
|
+
ruleContent?: string;
|
|
30
|
+
};
|
|
31
|
+
policyMode: PermissionMode;
|
|
32
|
+
policyVersion: number;
|
|
33
|
+
policyHash?: string;
|
|
34
|
+
issuedAt: string;
|
|
35
|
+
expiresAt?: string;
|
|
36
|
+
state: "pending" | "allowed" | "denied" | "cancelled" | "expired";
|
|
37
|
+
issuedCwd: string;
|
|
38
|
+
issuedHome: string;
|
|
39
|
+
issuedResolvedTargets?: string[];
|
|
40
|
+
resolution?: ApprovalResolution;
|
|
41
|
+
consumedAt?: string;
|
|
42
|
+
consumedResult?: string;
|
|
43
|
+
consumedIsError?: boolean;
|
|
44
|
+
consumingAt?: string;
|
|
45
|
+
}
|
|
46
|
+
export declare const WINTER_RUNTIME_KIND = "winter-agent";
|
|
47
|
+
export interface ApprovalResponseInput {
|
|
48
|
+
outcome: "allowed" | "denied";
|
|
49
|
+
mechanism: "hook" | "canUseTool" | "system";
|
|
50
|
+
message?: string;
|
|
51
|
+
transformedInput?: Record<string, unknown>;
|
|
52
|
+
updatedPermissions?: PermissionUpdate[];
|
|
53
|
+
decisionClassification?: PermissionDecisionClassification;
|
|
54
|
+
}
|
|
55
|
+
export interface RespondResult {
|
|
56
|
+
applied: boolean;
|
|
57
|
+
record: DurableApprovalRecord;
|
|
58
|
+
}
|
|
59
|
+
export declare class DurableApprovalStoreError extends Error {
|
|
60
|
+
constructor(message: string);
|
|
61
|
+
}
|
|
62
|
+
export interface RevalidationContext {
|
|
63
|
+
runtimeKind: string;
|
|
64
|
+
sessionId: string;
|
|
65
|
+
backendSessionId: string;
|
|
66
|
+
toolUseID: string;
|
|
67
|
+
policyMode: PermissionMode;
|
|
68
|
+
policyVersion: number;
|
|
69
|
+
policyHash: string;
|
|
70
|
+
cwd: string;
|
|
71
|
+
home: string;
|
|
72
|
+
}
|
|
73
|
+
export type RevalidationAxis = "session" | "toolCall" | "policy" | "paths" | "runtime";
|
|
74
|
+
export type RevalidationVerdict = {
|
|
75
|
+
ok: true;
|
|
76
|
+
} | {
|
|
77
|
+
ok: false;
|
|
78
|
+
axis: RevalidationAxis;
|
|
79
|
+
reason: string;
|
|
80
|
+
};
|
|
81
|
+
export declare function revalidateApproval(approval: DurableApprovalRecord, ctx: RevalidationContext): RevalidationVerdict;
|
|
82
|
+
export interface SessionKeyLike {
|
|
83
|
+
sessionId: string;
|
|
84
|
+
}
|
|
85
|
+
export interface ConsumedResultInput {
|
|
86
|
+
output: string;
|
|
87
|
+
isError?: boolean;
|
|
88
|
+
}
|
|
89
|
+
export interface DurableApprovalStore {
|
|
90
|
+
record(approval: DurableApprovalRecord): void;
|
|
91
|
+
respond(requestId: string, response: ApprovalResponseInput): RespondResult;
|
|
92
|
+
pendingFor(sessionKey: SessionKeyLike): DurableApprovalRecord[];
|
|
93
|
+
listFor(sessionKey: SessionKeyLike): DurableApprovalRecord[];
|
|
94
|
+
get(requestId: string): DurableApprovalRecord | undefined;
|
|
95
|
+
revalidate(approval: DurableApprovalRecord, ctx: RevalidationContext): RevalidationVerdict;
|
|
96
|
+
cancelPendingFor(sessionKey: SessionKeyLike, reason: string): void;
|
|
97
|
+
expire(requestId: string, reason: string): void;
|
|
98
|
+
markConsumed(requestId: string, result: ConsumedResultInput): void;
|
|
99
|
+
markConsuming(requestId: string): void;
|
|
100
|
+
}
|
|
101
|
+
export declare function createInMemoryApprovalStore(): DurableApprovalStore;
|
|
102
|
+
export interface ApprovalStoreLocation {
|
|
103
|
+
winterHome: string;
|
|
104
|
+
projectKey: string;
|
|
105
|
+
sessionId: string;
|
|
106
|
+
}
|
|
107
|
+
export declare function createFileDurableApprovalStore(location: ApprovalStoreLocation): DurableApprovalStore;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { PolicyState } from "../policy-state.js";
|
|
2
|
+
import type { PermissionCall, AutoEngineVerdict } from "../evaluator.js";
|
|
3
|
+
export declare function stableHash(value: unknown): string;
|
|
4
|
+
export declare function computePolicyHash(policy: Pick<PolicyState, "mode" | "rules" | "autoConfig">): string;
|
|
5
|
+
export interface EnvHashInputs {
|
|
6
|
+
cwd: string;
|
|
7
|
+
home: string;
|
|
8
|
+
trustedWorkspace: boolean;
|
|
9
|
+
sessionBypassEnabled?: boolean;
|
|
10
|
+
additionalDirectories?: string[];
|
|
11
|
+
}
|
|
12
|
+
export declare function computeEnvHash(inputs: EnvHashInputs): string;
|
|
13
|
+
export declare function computeActionFingerprint(call: PermissionCall): string;
|
|
14
|
+
export interface AutoVerdictCacheKey {
|
|
15
|
+
host?: string;
|
|
16
|
+
port?: number;
|
|
17
|
+
policyHash: string;
|
|
18
|
+
envHash: string;
|
|
19
|
+
sessionId: string;
|
|
20
|
+
generation: number;
|
|
21
|
+
actionFingerprint: string;
|
|
22
|
+
}
|
|
23
|
+
export interface AutoVerdictCacheEntry {
|
|
24
|
+
verdict: AutoEngineVerdict;
|
|
25
|
+
cachedAt: string;
|
|
26
|
+
}
|
|
27
|
+
export interface AutoVerdictCache {
|
|
28
|
+
get(key: AutoVerdictCacheKey): AutoVerdictCacheEntry | undefined;
|
|
29
|
+
set(key: AutoVerdictCacheKey, entry: AutoVerdictCacheEntry): void;
|
|
30
|
+
}
|
|
31
|
+
export declare function createInMemoryVerdictCache(): AutoVerdictCache;
|
|
32
|
+
export declare const AUTO_FALLBACK_CONSECUTIVE_THRESHOLD = 3;
|
|
33
|
+
export declare const AUTO_FALLBACK_TOTAL_THRESHOLD = 20;
|
|
34
|
+
export interface AutoCounterState {
|
|
35
|
+
consecutive: number;
|
|
36
|
+
total: number;
|
|
37
|
+
}
|
|
38
|
+
export declare function isFallbackActive(state: AutoCounterState): boolean;
|
|
39
|
+
export interface AutoCounterStore {
|
|
40
|
+
get(sessionId: string): AutoCounterState;
|
|
41
|
+
recordDeny(sessionId: string): AutoCounterState;
|
|
42
|
+
recordAllow(sessionId: string): AutoCounterState;
|
|
43
|
+
}
|
|
44
|
+
export declare function createInMemoryAutoCounterStore(): AutoCounterStore;
|
|
45
|
+
export declare class AutoCounterStoreError extends Error {
|
|
46
|
+
constructor(message: string);
|
|
47
|
+
}
|
|
48
|
+
export interface AutoCounterStoreLocation {
|
|
49
|
+
winterHome: string;
|
|
50
|
+
projectKey: string;
|
|
51
|
+
sessionId: string;
|
|
52
|
+
}
|
|
53
|
+
export declare function createFileAutoCounterStore(location: AutoCounterStoreLocation): AutoCounterStore;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { RuleSource } from "@yanlinglabs/winter-agent-sdk";
|
|
2
|
+
import type { ParsedRule } from "../grammar.js";
|
|
3
|
+
export interface AutoModeConfig {
|
|
4
|
+
environment?: string[];
|
|
5
|
+
allow?: string[];
|
|
6
|
+
soft_deny?: string[];
|
|
7
|
+
hard_deny?: string[];
|
|
8
|
+
classifyAllShell?: boolean;
|
|
9
|
+
useAutoModeDuringPlan?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare const AUTO_MODE_DEFAULT_ENVIRONMENT: readonly string[];
|
|
12
|
+
export declare const AUTO_MODE_DEFAULT_ALLOW: readonly string[];
|
|
13
|
+
export declare const AUTO_MODE_DEFAULT_SOFT_DENY: readonly string[];
|
|
14
|
+
export declare const AUTO_MODE_DEFAULT_HARD_DENY: readonly string[];
|
|
15
|
+
export declare const AUTO_MODE_DEFAULT_USE_AUTO_MODE_DURING_PLAN = true;
|
|
16
|
+
export declare const AUTO_MODE_DEFAULTS_TOKEN = "$defaults";
|
|
17
|
+
export type AutoModeListField = "environment" | "allow" | "soft_deny" | "hard_deny";
|
|
18
|
+
export interface NormalizedAutoModeConfig {
|
|
19
|
+
environment: string[];
|
|
20
|
+
allow: string[];
|
|
21
|
+
soft_deny: string[];
|
|
22
|
+
hard_deny: string[];
|
|
23
|
+
classifyAllShell: boolean;
|
|
24
|
+
useAutoModeDuringPlan: boolean;
|
|
25
|
+
securityRelevantReplacements: AutoModeListField[];
|
|
26
|
+
}
|
|
27
|
+
export declare function normalizeAutoModeConfig(input: AutoModeConfig | undefined): NormalizedAutoModeConfig;
|
|
28
|
+
export type AutoModeConfigSource = "user" | "managed" | "sdk";
|
|
29
|
+
export declare class AutoModeConfigSourceError extends Error {
|
|
30
|
+
constructor(source: RuleSource);
|
|
31
|
+
}
|
|
32
|
+
export declare function assertAutoModeConfigSource(source: RuleSource): asserts source is AutoModeConfigSource;
|
|
33
|
+
export type AutoTierVerdict = "hard_denied" | "soft_denied" | "cleared" | "unclassified";
|
|
34
|
+
export declare function resolveAutoTier(category: string | undefined, config: NormalizedAutoModeConfig): AutoTierVerdict;
|
|
35
|
+
export declare const AUTO_SUSPENDED_INTERPRETER_COMMANDS: ReadonlySet<string>;
|
|
36
|
+
export declare const AUTO_SUSPENDED_PACKAGE_MANAGER_COMMANDS: ReadonlySet<string>;
|
|
37
|
+
export declare function isAutoSuspendedAllowRule(rule: ParsedRule, config: Pick<NormalizedAutoModeConfig, "classifyAllShell">): boolean;
|