@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,340 @@
|
|
|
1
|
+
import type { InitPluginInfo, RuntimeConfig, Settings } from "@yanlinglabs/winter-agent-sdk";
|
|
2
|
+
import { type SourcedRuleEntry } from "./permissions/ruleset.js";
|
|
3
|
+
import type { RuleSource } from "@yanlinglabs/winter-agent-sdk";
|
|
4
|
+
import type { DetailedResolvedSettings } from "./settings/resolve.js";
|
|
5
|
+
import type { DefaultChildEngineFactoryOptions } from "./subagents/register-default-factory.js";
|
|
6
|
+
import { FilesystemCommandResolver } from "./commands/resolver.js";
|
|
7
|
+
import type { SourcedHookEntry } from "./hooks/registry.js";
|
|
8
|
+
import type { McpServerSource } from "./mcp/lifecycle.js";
|
|
9
|
+
import type { SkillListing, SystemPromptAssembler } from "./context/seam.js";
|
|
10
|
+
import type { CompactionController } from "./compaction/seam.js";
|
|
11
|
+
import type { StructuredOutputSeam } from "./structured/seam.js";
|
|
12
|
+
import type { FileCheckpointSink } from "./checkpoint/seam.js";
|
|
13
|
+
import { type SessionProviderOptions, type SessionProviderWiring } from "./provider/session-provider.js";
|
|
14
|
+
import type { ProviderStateRecordInput } from "./store/provider-state.js";
|
|
15
|
+
import type { ClassifierInterface } from "./permissions/auto/engine.js";
|
|
16
|
+
import { type SlotProviderResolution } from "./provider/slots.js";
|
|
17
|
+
import type { ActiveSlotSet, ModelFamilyListing } from "@yanlinglabs/winter-agent-sdk";
|
|
18
|
+
import { type WinterCatalog } from "@yanlinglabs/winter-provider-catalog";
|
|
19
|
+
import type { AttachmentProducer, EngineOptions, ModelDescription, PricedUsage, ProviderUsage, ResolveModelSwitch, UsageRowFacts } from "./engine.js";
|
|
20
|
+
/**
|
|
21
|
+
* RIDER 24: the assembler's `deps.settings` MUST be the post-`OVERLAY_NEVER_KEYS` EFFECTIVE getter.
|
|
22
|
+
*
|
|
23
|
+
* `resolveSettings`' `effective` already applies the filter (`withoutOverlayNeverKeys`, applied to
|
|
24
|
+
* the project tier only). A caller reaching for `perSource[i].values` or a raw file would let a
|
|
25
|
+
* repo-committed project `settings.json` set `autoMemoryDirectory` -- pointing this session's memory
|
|
26
|
+
* at a directory the repository chose, which is precisely the self-grant P5-A closes elsewhere.
|
|
27
|
+
*
|
|
28
|
+
* Asserted rather than merely documented: nothing about the two shapes differs structurally, so a
|
|
29
|
+
* future edit swapping one for the other would type-check and pass every test. This throws at
|
|
30
|
+
* session construction, which is loud and early, rather than degrading a live session.
|
|
31
|
+
*
|
|
32
|
+
* WHOLE-BRANCH MINOR m7 -- WHY THIS COMPARES AGAINST `perSource`, NOT AGAINST `resolved.effective`.
|
|
33
|
+
* It used to do the latter, and the production call site passes `resolved.effective`: `f(x, y)`
|
|
34
|
+
* comparing `x` to `y.effective` where `x === y.effective` is an identity check, so the guard could
|
|
35
|
+
* not fire in production no matter what went wrong. Its two fixtures tested the function; nothing
|
|
36
|
+
* tested the wiring.
|
|
37
|
+
*
|
|
38
|
+
* Against the PROJECT TIER'S RAW VALUES the same call becomes a real question: "does the view I am
|
|
39
|
+
* about to hand the assembler still carry the value the repository asked for?" `resolved.effective`
|
|
40
|
+
* answers no (the filter ran) and answers YES the moment `withoutOverlayNeverKeys` regresses or a
|
|
41
|
+
* caller substitutes a per-source view -- which is the property rider 24 wanted asserted all along.
|
|
42
|
+
*
|
|
43
|
+
* The one legitimate way a view may carry the project's value is if another tier independently set
|
|
44
|
+
* the SAME value, so that is the single exemption. Comparing values rather than presence is still
|
|
45
|
+
* load-bearing for the opposite case: when project and a higher tier both set the key with
|
|
46
|
+
* DIFFERENT values, a raw project view has the same presence as `effective` and would sail through
|
|
47
|
+
* any `key in settings` test.
|
|
48
|
+
*/
|
|
49
|
+
export declare function assertEffectiveSettings(settings: Settings | undefined, resolved: DetailedResolvedSettings): void;
|
|
50
|
+
/**
|
|
51
|
+
* Phase 5 fix wave, C1: everything the engine needs from a settings file's `permissions` block.
|
|
52
|
+
*
|
|
53
|
+
* A SEED, not a policy: the engine folds `entries`/`directories` into its own initial rule set after
|
|
54
|
+
* the managed baseline and before the `sdk` entries, and the per-entry trust filter downstream is
|
|
55
|
+
* what makes a project-tier `allow` inert without host-declared trust.
|
|
56
|
+
*/
|
|
57
|
+
export interface SettingsRuleSeed {
|
|
58
|
+
/** Tagged with the tier that asserted them, which is what the P5-A gate reads. */
|
|
59
|
+
entries: SourcedRuleEntry[];
|
|
60
|
+
/** `permissions.additionalDirectories`, tagged the same way (`effectiveDirectories` gates project-tier grants). */
|
|
61
|
+
directories: Array<{
|
|
62
|
+
path: string;
|
|
63
|
+
source: RuleSource;
|
|
64
|
+
}>;
|
|
65
|
+
/**
|
|
66
|
+
* The surviving `permissions.defaultMode`, AFTER the pinned `filterEscalatingDefaultMode` -- so a
|
|
67
|
+
* repo-committed `bypassPermissions` never reaches the engine. A DEFAULT: an explicit
|
|
68
|
+
* `config.permissionMode` still wins, because a file cannot override what the host asked for.
|
|
69
|
+
*/
|
|
70
|
+
defaultMode?: string;
|
|
71
|
+
/** WS-07 §6.4's veto, from ANY tier. `engine.ts` read `config.permissions` only. */
|
|
72
|
+
disableBypassPermissionsMode?: boolean;
|
|
73
|
+
/** Non-fatal problems, surfaced through `ProductionWiring.warnings`. */
|
|
74
|
+
warnings: string[];
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* One `SourcedRuleEntry` per (tier, behavior, rule string), in the pinned precedence order.
|
|
78
|
+
*
|
|
79
|
+
* ORDER IS `perSource`'s OWN (highest-precedence first), and it matters: `resolveRules` and
|
|
80
|
+
* `findMatchingRuleEntry` both return the FIRST match within a behavior, so a managed deny must be
|
|
81
|
+
* reached before a user one. `perSource` is already ordered that way.
|
|
82
|
+
*
|
|
83
|
+
* A MALFORMED RULE IS REPORTED, NEVER THROWN. `sourceRule` validates at add time and raises
|
|
84
|
+
* `PermissionRuleValidationError`; that is the right behaviour for an `Options` field the host
|
|
85
|
+
* controls (fail loud at startup) and the wrong one for a FILE a repository may have written --
|
|
86
|
+
* a single bad string in a checked-in project `settings.json` must not make the session unstartable.
|
|
87
|
+
* The bad entry is dropped and named in `warnings`; every other rule in the same file still binds.
|
|
88
|
+
*/
|
|
89
|
+
export declare function buildSettingsRuleSeed(resolved: DetailedResolvedSettings, opts?: {
|
|
90
|
+
allowDangerouslySkipPermissions?: boolean;
|
|
91
|
+
disableBypassPermissionsMode?: boolean;
|
|
92
|
+
cwd?: string;
|
|
93
|
+
home?: string;
|
|
94
|
+
}): SettingsRuleSeed;
|
|
95
|
+
export interface ProductionWiringOptions {
|
|
96
|
+
/** The session's EFFECTIVE config (post-`resolveEngineSession`), never the raw pre-resolution one. */
|
|
97
|
+
config: RuntimeConfig;
|
|
98
|
+
/** The environment governing `WINTER_HOME` and every env-derived read below. Explicit at both entrypoints. */
|
|
99
|
+
env: Record<string, string | undefined>;
|
|
100
|
+
/**
|
|
101
|
+
* The resolved `~/.winter` root -- `config.winterHome ?? resolveWinterHome(env)`. Passed rather
|
|
102
|
+
* than re-derived so this module and `resolveEngineSession` can never disagree about where a
|
|
103
|
+
* session lives (Lane S's judgment call 10: the two conventions in this codebase are not
|
|
104
|
+
* interchangeable, and picking the wrong one silently empties the user tier).
|
|
105
|
+
*/
|
|
106
|
+
winterHome?: string;
|
|
107
|
+
/**
|
|
108
|
+
* The session's durable transcript sink (`resolveEngineSession`'s own `store`), so the two P5
|
|
109
|
+
* dialect entries have somewhere to land: Lane S's `invoked_skills` attachment and Lane K's
|
|
110
|
+
* `file-history-*` records. Omitted for a non-persistent session, in which case both are simply
|
|
111
|
+
* never written -- exactly as a session with no store has no durable anything.
|
|
112
|
+
*/
|
|
113
|
+
persistence?: {
|
|
114
|
+
/** Review r1, M-1: the renderer's sticky decoration decisions, kept as layer-2 sidecar records. */
|
|
115
|
+
recordProviderState?(record: ProviderStateRecordInput): void | Promise<void>;
|
|
116
|
+
recordInvokedSkills?(attachment: {
|
|
117
|
+
type: string;
|
|
118
|
+
skills: unknown[];
|
|
119
|
+
}): void | Promise<void>;
|
|
120
|
+
recordFileHistory?(record: {
|
|
121
|
+
kind: "snapshot" | "delta";
|
|
122
|
+
userMessageUuid: string;
|
|
123
|
+
path: string;
|
|
124
|
+
pathHash: string;
|
|
125
|
+
tool: string;
|
|
126
|
+
at: string;
|
|
127
|
+
version: number;
|
|
128
|
+
absent?: boolean;
|
|
129
|
+
parentRealPath?: string;
|
|
130
|
+
anchorPath?: string;
|
|
131
|
+
anchorRealPath?: string;
|
|
132
|
+
}): void | Promise<void>;
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* Phase 6 Task 10: what the session's PROVIDER is built from.
|
|
136
|
+
*
|
|
137
|
+
* Every field is an injection point a TEST uses and production leaves alone: the catalog (a fixture
|
|
138
|
+
* owns its own rows), the credential store (an in-memory one, never the Keychain), the reserved
|
|
139
|
+
* `winter-test/<name>` namespace's scripted double, and the resumed continuation chain. Production
|
|
140
|
+
* passes only `testProviders` (the harness alias R6-13 keeps) and the OS home.
|
|
141
|
+
*
|
|
142
|
+
* OMITTING THE WHOLE OBJECT still runs selection: there is no "skip the provider" mode, because a
|
|
143
|
+
* mode that skipped it is exactly how a leg ends up with a different provider policy from the other
|
|
144
|
+
* two.
|
|
145
|
+
*/
|
|
146
|
+
provider?: Omit<SessionProviderOptions, "config" | "env">;
|
|
147
|
+
}
|
|
148
|
+
export interface ProductionWiring {
|
|
149
|
+
/** Spread into `runEngine({...})`. Every field is one of `EngineOptions`' own P5 seams or init inputs. */
|
|
150
|
+
engineOptions: {
|
|
151
|
+
winterHome: string;
|
|
152
|
+
settingsRules: SettingsRuleSeed;
|
|
153
|
+
providerIdentity?: {
|
|
154
|
+
providerId: string;
|
|
155
|
+
modelKey: string;
|
|
156
|
+
family: string;
|
|
157
|
+
continuationDomain?: string;
|
|
158
|
+
adapterId?: string;
|
|
159
|
+
adapterVersion?: string;
|
|
160
|
+
catalogVersion?: string;
|
|
161
|
+
authRefKind?: string;
|
|
162
|
+
};
|
|
163
|
+
apiKeySource: string;
|
|
164
|
+
providerSupportsToolSearch?: boolean;
|
|
165
|
+
classifier?: ClassifierInterface;
|
|
166
|
+
/** P6 fix wave (Ruling E-2): the switch seam, from the session's own wiring. */
|
|
167
|
+
resolveModelSwitch?: ResolveModelSwitch;
|
|
168
|
+
/** P6 fix wave (Ruling E-3): `fallbackModel`'s candidates as catalog keys, present only when configured. */
|
|
169
|
+
fallbackModels?: string[];
|
|
170
|
+
/** P6 fix wave (Ruling E-4): R6-H's price of one generation, from the session's own wiring. */
|
|
171
|
+
priceUsage?: (modelKey: string, usage: ProviderUsage) => PricedUsage | undefined;
|
|
172
|
+
/** Dist-session fixes (C1): the catalog facts for an UNPRICED generation's `modelUsage` row. */
|
|
173
|
+
usageRowFacts?: (modelKey: string) => UsageRowFacts | undefined;
|
|
174
|
+
/** P6 fix wave (Ruling E-5): the classifier model's key, for the session pin -- present exactly when `classifier` is. */
|
|
175
|
+
classifierIdentity?: {
|
|
176
|
+
modelKey: string;
|
|
177
|
+
};
|
|
178
|
+
/** R6-I: the `list_models` control handler's source. */
|
|
179
|
+
supportedModels: () => unknown[];
|
|
180
|
+
/** The Winter-only `account_info` control handler's source. */
|
|
181
|
+
accountInfo: () => unknown;
|
|
182
|
+
/** WS-13c §3: the active slot set for a given model key -- the Agent tool's `model` enum and description lines. */
|
|
183
|
+
activeSlotSet?: (currentModelKey: string | undefined) => ActiveSlotSet;
|
|
184
|
+
/** WS-13c §4: slot name -> provider + catalog key, for a child spawn and for `set_model`. */
|
|
185
|
+
resolveSlot?: (requested: string, currentModelKey: string | undefined) => SlotProviderResolution;
|
|
186
|
+
/** WS-13c §5: bumps when the resolved settings view changes, so a `modelSlots` edit re-renders with no restart. */
|
|
187
|
+
settingsVersion?: () => number;
|
|
188
|
+
/**
|
|
189
|
+
* WS-13c §7: the `list_model_families` control handler's source.
|
|
190
|
+
*
|
|
191
|
+
* The parameter is Lane A's; the spine's `EngineOptions.listModelFamilies` is `() => …`, which
|
|
192
|
+
* this is assignable to. See the producer for the one-line spine fix that makes the engine
|
|
193
|
+
* actually pass the live key.
|
|
194
|
+
*/
|
|
195
|
+
listModelFamilies?: (currentModelKey?: string) => ModelFamilyListing;
|
|
196
|
+
systemPromptAssembler: SystemPromptAssembler;
|
|
197
|
+
commandResolver: FilesystemCommandResolver;
|
|
198
|
+
compactionController: CompactionController;
|
|
199
|
+
structuredOutput: StructuredOutputSeam;
|
|
200
|
+
fileCheckpointSink?: FileCheckpointSink;
|
|
201
|
+
extraHookEntries: readonly SourcedHookEntry[];
|
|
202
|
+
/**
|
|
203
|
+
* WS-21 §6.3 item 2 (fix round 1, Critical 1): the conditional-rule on-touch attachment
|
|
204
|
+
* producer (`context/rules.ts`'s `conditionalRuleAttachmentProducer`), when this session has
|
|
205
|
+
* any conditional rules to announce. `EngineOptions.attachmentProducers` has no other producer
|
|
206
|
+
* in production today, so this is always either absent or a one-element array -- declared as
|
|
207
|
+
* the full array type anyway, matching `EngineOptions`'s own shape, so a second producer some
|
|
208
|
+
* later lane adds is a one-line change here, not a second field.
|
|
209
|
+
*/
|
|
210
|
+
attachmentProducers?: readonly AttachmentProducer[];
|
|
211
|
+
/**
|
|
212
|
+
* WS-21 §6.3 item 1 (fix round 2): the enabled plugins that ship a `workflows/` directory,
|
|
213
|
+
* threaded to `EngineOptions.pluginWorkflows` -> `RegistryToolExecutorDeps.pluginWorkflows`
|
|
214
|
+
* (registry.ts) so the Workflow tool's `<plugin>:<name>` resolution can find them.
|
|
215
|
+
*/
|
|
216
|
+
pluginWorkflows?: readonly {
|
|
217
|
+
name: string;
|
|
218
|
+
workflowsPath?: string;
|
|
219
|
+
workflowsPaths?: readonly string[];
|
|
220
|
+
}[];
|
|
221
|
+
extraMcpServerSources: readonly McpServerSource[];
|
|
222
|
+
initSlashCommands: readonly string[];
|
|
223
|
+
initSkills: readonly string[];
|
|
224
|
+
initPlugins: readonly InitPluginInfo[];
|
|
225
|
+
initOutputStyle: string;
|
|
226
|
+
skillListing: SkillListing;
|
|
227
|
+
/** SDK 0.0.16: the catalog's model display names for the `# Environment` model line. */
|
|
228
|
+
describeModel: NonNullable<EngineOptions["describeModel"]>;
|
|
229
|
+
/**
|
|
230
|
+
* The web tools' two wiring-level seams, DECLARED here rather than riding the spread undeclared:
|
|
231
|
+
* a spread of a property the destination type has not declared is not an excess-property error,
|
|
232
|
+
* so an undeclared one type-checks whether or not anything downstream reads it.
|
|
233
|
+
* `resolveAuxiliaryModel` is withheld on the arms with no catalog identity, like `resolveReviewer`;
|
|
234
|
+
* `resolveToolSecret` is present on every arm (it needs a credential store, not a model).
|
|
235
|
+
*/
|
|
236
|
+
resolveAuxiliaryModel?: NonNullable<EngineOptions["resolveAuxiliaryModel"]>;
|
|
237
|
+
resolveToolSecret: NonNullable<EngineOptions["resolveToolSecret"]>;
|
|
238
|
+
};
|
|
239
|
+
/**
|
|
240
|
+
* Mirrors handed to `registerDefaultChildEngineFactory`, so a CHILD engine gets the same context
|
|
241
|
+
* surface its parent does -- see that function's own fields for the two gaps this closes.
|
|
242
|
+
*/
|
|
243
|
+
/**
|
|
244
|
+
* Mirrors handed to `registerDefaultChildEngineFactory`, so a CHILD engine gets the same context
|
|
245
|
+
* surface its parent does.
|
|
246
|
+
*
|
|
247
|
+
* TYPED AS A `Pick` OF THE FACTORY'S OWN OPTIONS (rn-1, residual round 2), which is a tripwire and
|
|
248
|
+
* not tidiness. This was an independent object literal spread into the factory, and a spread of a
|
|
249
|
+
* property the destination has not declared is NOT an excess-property error -- so `skillListing`
|
|
250
|
+
* was declared here, type-checked, arrived on `opts`, and was dropped one line before `deps`,
|
|
251
|
+
* inert in production for a whole round while a review recorded it as landed. Against a `Pick`,
|
|
252
|
+
* a field the factory has not declared is a compile error AT THE PRODUCER, where the mistake is
|
|
253
|
+
* made, instead of a silent drop at the consumer, where nobody is looking.
|
|
254
|
+
*
|
|
255
|
+
* Adding a mirror is therefore now a two-file edit by construction: declare it on
|
|
256
|
+
* `DefaultChildEngineFactoryOptions` first, then produce it here.
|
|
257
|
+
*/
|
|
258
|
+
childFactoryOptions: Required<Pick<DefaultChildEngineFactoryOptions, "systemPromptAssembler" | "skillRuntime" | "skillListing" | "settingsRules" | "structuredOutput" | "extraHookEntries" | "compactionControllerFactory" | "resolveChildProvider" | "describeModel" | "priceUsage" | "usageRowFacts" | "resolveToolSecret">> & Pick<DefaultChildEngineFactoryOptions, "resolveAuxiliaryModel">;
|
|
259
|
+
/**
|
|
260
|
+
* Phase 6 Task 10: the session's provider, and everything resolved with it.
|
|
261
|
+
*
|
|
262
|
+
* `provider` is spread into `runEngine` by both entrypoints; the rest is what the control handlers
|
|
263
|
+
* (`supportedModels`/`accountInfo`) and the report read. See `session-provider.ts`.
|
|
264
|
+
*/
|
|
265
|
+
providerWiring: SessionProviderWiring;
|
|
266
|
+
/**
|
|
267
|
+
* WS-21 §3.4.4 step 4 / §6.3 item 6: every settings tier's `env` block, claude's per-tier filters
|
|
268
|
+
* applied (`settings/env-filter.ts`), merged HIGHEST-PRECEDENCE-WINS. APPLIED by this function
|
|
269
|
+
* (fix round 1, item 5): `Object.assign(env, settingsEnv)` after every settings read, which reaches a
|
|
270
|
+
* tool spawn's process env the way claude's own `Object.assign(process.env, filtered)` does -- in
|
|
271
|
+
* production `env` IS `process.env`, and each test passes its own isolated object. Also exposed here
|
|
272
|
+
* so a caller (and this file's tests) can see exactly which variables were applied.
|
|
273
|
+
*/
|
|
274
|
+
settingsEnv: Record<string, string>;
|
|
275
|
+
/**
|
|
276
|
+
* WS-21 §6.3 item 5 (fix round 1): the SAME live getter `systemPromptAssembler`/`providerEnabled`/
|
|
277
|
+
* `advisorModelSetting` read internally (`settingsGetter`, defined once at the top of this
|
|
278
|
+
* function), surfaced so a caller -- and this file's own tests -- can observe the settings view
|
|
279
|
+
* this wiring actually resolved, host-managed filtering (`applyHostManagedSettingsFilter`)
|
|
280
|
+
* included, without a second, divergent resolution. `Settings.apiKeyHelper` has no production
|
|
281
|
+
* reader anywhere in `packages/runtime/src` today (grepped as part of this fix round), so this is
|
|
282
|
+
* also the only way to prove that filter's wiring end to end until a consumer exists.
|
|
283
|
+
*/
|
|
284
|
+
settings: () => Settings | undefined;
|
|
285
|
+
/**
|
|
286
|
+
* The config the ENGINE should run, which differs from the input config in the provider-derived
|
|
287
|
+
* defaults only (`contextWindowTokens` from the descriptor when the host stated none).
|
|
288
|
+
*
|
|
289
|
+
* RETURNED rather than mutated: `ProductionWiringOptions.config` is what every other consumer in
|
|
290
|
+
* this function reads, and a builder that silently rewrote its own input would make the ordering
|
|
291
|
+
* between the two invisible at the call site -- the same argument `withAutoSkillPermissions`'
|
|
292
|
+
* header already makes.
|
|
293
|
+
*/
|
|
294
|
+
config: RuntimeConfig;
|
|
295
|
+
/**
|
|
296
|
+
* Non-fatal problems worth telling a host about: a malformed project `mcp.json`, a plugin that
|
|
297
|
+
* would not load, a `skills` option naming something unknown. NEVER thrown -- Lane S's
|
|
298
|
+
* `validateSkillsOption` returns a result precisely so the decision is the caller's, and a broken
|
|
299
|
+
* plugin must not take a session down (`loadPlugins` returns rejections for the same reason).
|
|
300
|
+
*/
|
|
301
|
+
warnings: readonly string[];
|
|
302
|
+
/** Withdraws every session-keyed registration. Called on teardown; `main.ts` may skip it (the process exits). */
|
|
303
|
+
dispose(): void;
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* The display name the `# Environment` model line uses for `model`, read from the catalog UNDER THE
|
|
307
|
+
* SESSION'S OWN PROVIDER (dist-session fixes E4).
|
|
308
|
+
*
|
|
309
|
+
* A host commonly spawns with the provider-local id plus `Options.provider` (the Winter daemon does),
|
|
310
|
+
* and one bare id is served by many providers -- `deepseek-v4-flash` by eleven, each with its own row
|
|
311
|
+
* (deepseek's and deepseek-anthropic's own rows are now `deepseek-flash`, keeping `deepseek-v4-flash`
|
|
312
|
+
* only as an alias). A first-match search over the whole catalog named the model by whichever
|
|
313
|
+
* provider sorted first.
|
|
314
|
+
*
|
|
315
|
+
* - with `providerId`: that provider's rows only, in TWO PASSES like the adapters' descriptor index --
|
|
316
|
+
* key or upstream id first, alias only after -- so an alias can never shadow a real id, and
|
|
317
|
+
* novita's provider-local `deepseek/deepseek-v4-pro` names novita's row, not deepseek's KEY;
|
|
318
|
+
* - without one (a session with no provider identity at all): the string is read as a catalog KEY
|
|
319
|
+
* when it is one (a key names its provider), and a bare id or alias only when exactly ONE row in
|
|
320
|
+
* the whole catalog answers to it. Ambiguous -> nothing, and the line keeps the bare id.
|
|
321
|
+
*/
|
|
322
|
+
export declare function describeCatalogModel(catalog: WinterCatalog, model: string, providerId?: string): ModelDescription | undefined;
|
|
323
|
+
/**
|
|
324
|
+
* Build every P5 seam for one session.
|
|
325
|
+
*
|
|
326
|
+
* STARTUP ORDER IS LOAD-BEARING and follows Lane S's recipe exactly -- each step's input is the
|
|
327
|
+
* previous step's output: settings -> plugins -> skill index -> skills-option validation -> command
|
|
328
|
+
* resolver. Reordering it silently produces an index with no plugin skills, or a resolver whose
|
|
329
|
+
* `/name` set disagrees with the model's own listing.
|
|
330
|
+
*/
|
|
331
|
+
export declare function buildProductionWiring(opts: ProductionWiringOptions): Promise<ProductionWiring>;
|
|
332
|
+
/**
|
|
333
|
+
* The automatic `Skill(...)` allow entries for a session, folded into `allowedTools` by BOTH
|
|
334
|
+
* entrypoints before `runEngine` seeds its rule set.
|
|
335
|
+
*
|
|
336
|
+
* Separate from `buildProductionWiring` because it must be applied to the CONFIG, and the config is
|
|
337
|
+
* what that function takes as input -- returning a mutated config from a builder whose job is to
|
|
338
|
+
* produce seams would make the ordering between the two invisible at the call site.
|
|
339
|
+
*/
|
|
340
|
+
export declare function withAutoSkillPermissions(config: RuntimeConfig): RuntimeConfig;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { WinterFrame } from "@yanlinglabs/winter-agent-sdk";
|
|
2
|
+
export interface FrameSink {
|
|
3
|
+
write(f: WinterFrame): void;
|
|
4
|
+
end(): void;
|
|
5
|
+
}
|
|
6
|
+
export type FrameSource = AsyncIterable<WinterFrame>;
|
|
7
|
+
export interface Duplex {
|
|
8
|
+
input: FrameSource;
|
|
9
|
+
output: FrameSink;
|
|
10
|
+
}
|
|
11
|
+
export declare class Queue<T> implements AsyncIterable<T> {
|
|
12
|
+
private buf;
|
|
13
|
+
private resolvers;
|
|
14
|
+
private ended;
|
|
15
|
+
write(v: T): void;
|
|
16
|
+
end(): void;
|
|
17
|
+
[Symbol.asyncIterator](): AsyncGenerator<Awaited<T>, void, unknown>;
|
|
18
|
+
}
|
|
19
|
+
export declare function createInMemoryChannel(): {
|
|
20
|
+
host: Duplex;
|
|
21
|
+
runtime: Duplex;
|
|
22
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { WinterCatalog } from "@yanlinglabs/winter-provider-catalog";
|
|
2
|
+
import type { SlotProviderResolution } from "./slots.js";
|
|
3
|
+
export interface AdvisorRouteInput {
|
|
4
|
+
catalog: WinterCatalog;
|
|
5
|
+
/** The session's LIVE effective model key (the engine's, not the wiring's start snapshot). Undefined for a session with no resolvable model. */
|
|
6
|
+
sessionModelKey: string | undefined;
|
|
7
|
+
/** `Options.advisor.model` / `RuntimeConfig.advisor.model`. */
|
|
8
|
+
optionModel?: string;
|
|
9
|
+
/** `settings.advisor.model`, read through the LIVE settings getter (hot, D30). */
|
|
10
|
+
settingModel?: string;
|
|
11
|
+
/** WS-13c §4, one argument: the slot layer already knows the session's model key. */
|
|
12
|
+
resolveSlot: (requested: string) => SlotProviderResolution;
|
|
13
|
+
}
|
|
14
|
+
export type AdvisorRoute = {
|
|
15
|
+
ok: true;
|
|
16
|
+
modelKey: string;
|
|
17
|
+
providerId: string;
|
|
18
|
+
source: "option" | "setting" | "family-default" | "own-model";
|
|
19
|
+
} | {
|
|
20
|
+
ok: false;
|
|
21
|
+
reason: string;
|
|
22
|
+
};
|
|
23
|
+
/** The precedence step that named a candidate, and what it named. `undefined` = nothing states one. */
|
|
24
|
+
interface AdvisorCandidate {
|
|
25
|
+
requested: string;
|
|
26
|
+
source: "option" | "setting" | "family-default" | "own-model";
|
|
27
|
+
/** How the refusal describes where this value came from, so the user knows WHICH knob to fix. */
|
|
28
|
+
origin: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The ONE candidate this session's advisor uses, per D30's precedence.
|
|
32
|
+
*
|
|
33
|
+
* Exported for the tests that pin the precedence independently of whether a candidate happens to
|
|
34
|
+
* RESOLVE — the two questions are separate, and conflating them is how a "default" test can pass
|
|
35
|
+
* while precedence is broken.
|
|
36
|
+
*/
|
|
37
|
+
export declare function selectAdvisorCandidate(input: Pick<AdvisorRouteInput, "catalog" | "sessionModelKey" | "optionModel" | "settingModel">): AdvisorCandidate | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* WS-06 §4 / D30: the reviewer this session's advisor consults, or a typed reason it has none.
|
|
40
|
+
*
|
|
41
|
+
* NEVER A SUBSTITUTION. Three shapes of "no": nothing states a candidate at all; the stated
|
|
42
|
+
* candidate does not resolve (the slot layer's own `slot-unservable`/`ambiguous-slot-name`/
|
|
43
|
+
* `unknown-slot` message rides through verbatim, because it already names every row that WOULD have
|
|
44
|
+
* served it and why each did not); or the resolved row is a Claude row Winter cannot authenticate.
|
|
45
|
+
*/
|
|
46
|
+
export declare function resolveAdvisorRoute(input: AdvisorRouteInput): AdvisorRoute;
|
|
47
|
+
export {};
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import type { ProviderAdapter, ProviderContext, ProviderEvent, ResolvedModel } from "@yanlinglabs/winter-provider-runtime";
|
|
2
|
+
import { ProviderTurnError, type MessageOrigin, type Provider, type ProviderMessage, type ProviderRequest, type ProviderStreamSink, type ProviderTurn } from "../engine.js";
|
|
3
|
+
import type { ContinuationChain } from "../store/provider-state.js";
|
|
4
|
+
export { ProviderTurnError, isProviderTurnError } from "../engine.js";
|
|
5
|
+
/**
|
|
6
|
+
* R6-3 / Lane C: renders the engine's history into what THIS target may actually be sent.
|
|
7
|
+
*
|
|
8
|
+
* Lane C implements the real one (per-message cross-family decoration, `classifySwitch`'s loss
|
|
9
|
+
* matrix at the engine's switch point). T3 ships the IDENTITY renderer below, which is deliberately the most conservative
|
|
10
|
+
* thing that is still correct.
|
|
11
|
+
*/
|
|
12
|
+
export interface HistoryRenderer {
|
|
13
|
+
render(messages: ProviderMessage[], chain: ContinuationChain, target: {
|
|
14
|
+
family: string;
|
|
15
|
+
continuationDomain?: string;
|
|
16
|
+
readableState: "none" | "summary" | "full-exposed";
|
|
17
|
+
providerId?: string;
|
|
18
|
+
modelKey?: string;
|
|
19
|
+
readsImages?: boolean;
|
|
20
|
+
}): ProviderMessage[];
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The T3 renderer: NO decoration, and native state replayed ONLY inside the same continuation domain.
|
|
24
|
+
*
|
|
25
|
+
* Both halves are refusals rather than features, and that is the point. Decoration is Lane C's --
|
|
26
|
+
* inventing a cross-family note here would put Winter-authored text into a model's context that no
|
|
27
|
+
* ruling has approved. Replaying native state ACROSS a domain boundary is worse than not replaying
|
|
28
|
+
* it: opaque items are meaningful only to the provider that minted them, so a cross-domain replay is
|
|
29
|
+
* at best rejected and at worst silently misinterpreted. When the domains disagree the annotation is
|
|
30
|
+
* dropped and the message rides as plain content -- which is exactly R6-7's "degrade to
|
|
31
|
+
* summary-level", applied at the point of use.
|
|
32
|
+
*
|
|
33
|
+
* A message WITH an `origin` is passed through untouched apart from the nativeState domain check
|
|
34
|
+
* above: absence of a domain match is not this renderer's job to carry across (that is Lane C's).
|
|
35
|
+
*
|
|
36
|
+
* A message with NO `origin` at all (every pre-P6 history, and every message the host supplied) --
|
|
37
|
+
* micro-round Minor 2, mirroring `provider-runtime`'s own renderer fix: FAIL CLOSED, LAYERED ON TOP
|
|
38
|
+
* of the nativeState domain check above rather than replacing it (a live, same-turn message can
|
|
39
|
+
* carry a stamped `nativeState.continuationDomain` with no `.origin` of its own -- `stampNativeState`
|
|
40
|
+
* stamps the former directly, per this file's own header; the two are independent facts, and the
|
|
41
|
+
* domain check must still run for a message that only has the first). Unknown provenance is this
|
|
42
|
+
* renderer's worst-informed case too, and "decoration is Lane C's" was never a reason to also skip
|
|
43
|
+
* STRIPPING what `stripOpaque` already knows how to strip -- the in-dialect `thinking`/
|
|
44
|
+
* `redacted_thinking` blocks that ride in the CONTENT (the exact gap this function's own header used
|
|
45
|
+
* to name and accept: "which the identity renderer could not do anything about"). Delegates to
|
|
46
|
+
* `stripOpaque` itself (exported for exactly this) rather than reimplementing the two-carrier rule a
|
|
47
|
+
* second time and risking the two copies drifting apart on what counts as opaque. Object identity is
|
|
48
|
+
* preserved when there is truly nothing to strip.
|
|
49
|
+
*/
|
|
50
|
+
export declare function createIdentityHistoryRenderer(): HistoryRenderer;
|
|
51
|
+
/** What `adapterAsProvider` needs beyond the adapter and its context. */
|
|
52
|
+
export interface AdapterProviderOptions {
|
|
53
|
+
renderer?: HistoryRenderer;
|
|
54
|
+
/** Overrides the adapter on `resolved`. The one caller is a test that wants a scripted adapter against a real `ResolvedModel`. */
|
|
55
|
+
adapter?: ProviderAdapter;
|
|
56
|
+
/**
|
|
57
|
+
* Phase 6 Task 10 (Lane C wiring item 2): THE RESUMED CONTINUATION CHAIN.
|
|
58
|
+
*
|
|
59
|
+
* A GETTER, because the chain is re-attached asynchronously at the start of a run
|
|
60
|
+
* (`attachContinuationChain`) — long after this provider is constructed — so a captured value would
|
|
61
|
+
* always be the empty map this option replaces.
|
|
62
|
+
*
|
|
63
|
+
* What it buys: `createHistoryRenderer` reads a message's `origin` off the message itself when the
|
|
64
|
+
* engine already annotated it, and otherwise off `chain.get(message.uuid)`. The second path is the
|
|
65
|
+
* one that matters for a RESUMED history whose `summary` records (R6-8's foreign reasoning, which
|
|
66
|
+
* may never enter the transcript) live only in the sidecar: without the chain those messages render
|
|
67
|
+
* with no decoration at all, which looks exactly like a session that had nothing to say.
|
|
68
|
+
*
|
|
69
|
+
* Absent -> an empty chain, which is what T3 shipped and what a non-persistent session genuinely has.
|
|
70
|
+
*/
|
|
71
|
+
chain?: () => ContinuationChain;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* A `Provider` that is known to produce only the two PRODUCTION turn kinds.
|
|
75
|
+
*
|
|
76
|
+
* Narrower than `Provider` on purpose: no adapter stream can express `rpc_probe`, so a caller reading
|
|
77
|
+
* `turn.nativeState`/`turn.thinking` off one of these needs no cast -- and a cast is exactly what
|
|
78
|
+
* would also silence a real mistake.
|
|
79
|
+
*/
|
|
80
|
+
export interface AdapterProvider extends Provider {
|
|
81
|
+
generate(input: ProviderRequest): Promise<FoldedProviderTurn>;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Wraps a resolved adapter as the engine's `Provider`.
|
|
85
|
+
*
|
|
86
|
+
* The whole conversion in one place: render the history, build a `TurnRequest`, consume
|
|
87
|
+
* `streamTurn`, fold, STAMP the resolved identity onto any native state, and normalize any failure
|
|
88
|
+
* into a `ProviderTurnError`.
|
|
89
|
+
*/
|
|
90
|
+
export declare function adapterAsProvider(resolved: ResolvedModel, ctx: ProviderContext, opts?: AdapterProviderOptions): AdapterProvider;
|
|
91
|
+
/**
|
|
92
|
+
* What a fold can produce: the two PRODUCTION turn kinds and nothing else.
|
|
93
|
+
*
|
|
94
|
+
* `rpc_probe` is a P1-only test affordance the engine performs on a provider's behalf; no adapter
|
|
95
|
+
* stream can express it, so narrowing the return type here is not a convenience -- it is what lets a
|
|
96
|
+
* caller read `turn.thinking`/`turn.nativeState` without a cast that would also silence a real
|
|
97
|
+
* mistake.
|
|
98
|
+
*/
|
|
99
|
+
export type FoldedProviderTurn = Exclude<ProviderTurn, {
|
|
100
|
+
kind: "rpc_probe";
|
|
101
|
+
}>;
|
|
102
|
+
/**
|
|
103
|
+
* The fold itself, exported so a lane can test its own adapter's stream against the REAL consumer
|
|
104
|
+
* rather than a re-implementation of it.
|
|
105
|
+
*/
|
|
106
|
+
export declare function foldProviderStream(stream: AsyncIterable<ProviderEvent>, sink?: ProviderStreamSink): Promise<FoldedProviderTurn>;
|
|
107
|
+
/**
|
|
108
|
+
* Anything thrown -> a `ProviderTurnError`.
|
|
109
|
+
*
|
|
110
|
+
* The ORIGINAL is never re-thrown, and never attached as `cause`. An arbitrary throw from an adapter
|
|
111
|
+
* can carry a request object, a response body, or a header map -- any of which may hold credential
|
|
112
|
+
* material or opaque provider state, and all of which would then ride the error into a frame and a
|
|
113
|
+
* log. Only a BOUNDED message survives (Global Constraints: credential material is redacted
|
|
114
|
+
* everywhere, including thrown error messages).
|
|
115
|
+
*/
|
|
116
|
+
export declare function toProviderTurnError(err: unknown, committed?: boolean): ProviderTurnError;
|
|
117
|
+
/**
|
|
118
|
+
* Stamps the RESOLVED identity's family and continuation domain onto a folded turn's native state.
|
|
119
|
+
*
|
|
120
|
+
* The fold has no access to either -- it consumes an adapter's event stream, not its resolution -- so
|
|
121
|
+
* this is the one place the two meet. A turn with no native state is returned untouched: stamping
|
|
122
|
+
* never fabricates state that an adapter did not produce.
|
|
123
|
+
*/
|
|
124
|
+
export declare function stampNativeState(turn: FoldedProviderTurn, origin: MessageOrigin): FoldedProviderTurn;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { AutoClassifierConfig, CredentialRef } from "@yanlinglabs/winter-agent-sdk";
|
|
2
|
+
import type { WinterModelDescriptor } from "@yanlinglabs/winter-provider-catalog";
|
|
3
|
+
import type { ClassifierInterface } from "../../permissions/auto/engine.js";
|
|
4
|
+
import type { Provider, ProviderRequest } from "../../engine.js";
|
|
5
|
+
import { type ClassifierPromptResult } from "./prompt.js";
|
|
6
|
+
import { type ClassifierNoVerdictReason } from "./verdict-schema.js";
|
|
7
|
+
/**
|
|
8
|
+
* A DISCLOSED Winter default (no pinned counterpart — §10 documents no timeout).
|
|
9
|
+
*
|
|
10
|
+
* 15 s is chosen against what the failure costs rather than against a model's latency: every
|
|
11
|
+
* expiry is a fail-closed denial the user then has to resolve by hand, so a value too low turns a
|
|
12
|
+
* slow provider into a broken session, while a value too high makes a hung classifier feel like a
|
|
13
|
+
* hung agent. A host that knows its route can pass its own.
|
|
14
|
+
*/
|
|
15
|
+
export declare const DEFAULT_CLASSIFIER_TIMEOUT_MS = 15000;
|
|
16
|
+
export interface ModelClassifierOptions {
|
|
17
|
+
/** The engine `Provider` seam. A scripted double in a fixture, `adapterAsProvider(...)` in production — this file cannot tell them apart, which is the point. */
|
|
18
|
+
provider: Provider;
|
|
19
|
+
/** The classifier's OWN model, pinned per session and independent of the worker model (§10.6-4). */
|
|
20
|
+
model: string;
|
|
21
|
+
timeoutMs?: number;
|
|
22
|
+
/** P2 carry: the app-owned accumulated-context bound. See `prompt.ts`'s `DEFAULT_MAX_CONTEXT_CHARS`. */
|
|
23
|
+
maxContextChars?: number;
|
|
24
|
+
/** P7a fix wave (item 5, M-1): the running brand's instructions file, so the classifier prompt labels the operator's own file correctly. */
|
|
25
|
+
instructionsFile?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Test seam: observes what was actually sent and what came back, WITHOUT the classifier logging
|
|
28
|
+
* anything itself. Nothing in this file writes to a log — a permission review's request contains
|
|
29
|
+
* the envelope, and the envelope contains file paths and command lines.
|
|
30
|
+
*/
|
|
31
|
+
onRequest?: (info: {
|
|
32
|
+
request: ProviderRequest;
|
|
33
|
+
prompt: ClassifierPromptResult;
|
|
34
|
+
}) => void;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* `createModelClassifier` — one forced tool call, one verdict, every failure collapsed.
|
|
38
|
+
*/
|
|
39
|
+
export declare function createModelClassifier(opts: ModelClassifierOptions): ClassifierInterface;
|
|
40
|
+
export type ClassifierRoute =
|
|
41
|
+
/** `config.autoClassifier` named a model. It resolves through the SAME selection path as the session model (§10.6-4: "chosen via WS-13"). */
|
|
42
|
+
{
|
|
43
|
+
kind: "configured";
|
|
44
|
+
model: string;
|
|
45
|
+
authRef?: CredentialRef;
|
|
46
|
+
}
|
|
47
|
+
/** No route configured, and the worker model itself clears the bar in R6-14. */
|
|
48
|
+
| {
|
|
49
|
+
kind: "worker-eligible";
|
|
50
|
+
}
|
|
51
|
+
/** Neither. §10.6-4: "otherwise fall back to Manual, never silently weaken." */
|
|
52
|
+
| {
|
|
53
|
+
kind: "manual-fallback";
|
|
54
|
+
reason: string;
|
|
55
|
+
};
|
|
56
|
+
/** The narrow shape this needs from a session config. Structural so `RuntimeConfig` satisfies it and a fixture need not build one. */
|
|
57
|
+
export interface ClassifierRouteConfig {
|
|
58
|
+
model?: string;
|
|
59
|
+
autoClassifier?: AutoClassifierConfig;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* R6-14's route rule, and it is a ONE-WAY door: a session either gets a classifier it has real
|
|
63
|
+
* evidence for, or it gets Manual.
|
|
64
|
+
*
|
|
65
|
+
* The worker-eligible bar is `structuredOutput.confidence === "verified"` AND `classifierEligible`.
|
|
66
|
+
* Both halves are required and neither is a formality:
|
|
67
|
+
*
|
|
68
|
+
* - `structuredOutput` verified means someone OBSERVED this model honour a forced tool schema. On
|
|
69
|
+
* today's seed catalog every `structuredOutput` row is `inferred`, so nothing is worker-eligible
|
|
70
|
+
* — which is the correct state, not a gap: an inferred capability is a guess, and a guess about
|
|
71
|
+
* schema adherence is a guess about whether the security reviewer can be parsed at all.
|
|
72
|
+
* - `classifierEligible` is set only after the safety corpus passes LIVE against that model
|
|
73
|
+
* (R6-14's own wording, and the descriptor field's own comment). It is the evidence that the
|
|
74
|
+
* model answers the security questions correctly, which schema adherence says nothing about.
|
|
75
|
+
*
|
|
76
|
+
* TIGHTENED, deliberately, past the ruling's literal wording: `structuredOutput.value === true` is
|
|
77
|
+
* required as well as its confidence. A `verified` claim that the model does NOT support structured
|
|
78
|
+
* output is verified evidence AGAINST eligibility, and reading the confidence without the value
|
|
79
|
+
* would turn it into evidence for. Strictness only; disclosed in the task report.
|
|
80
|
+
*/
|
|
81
|
+
export declare function selectClassifierRoute(config: ClassifierRouteConfig, descriptorOf: (modelKey: string) => WinterModelDescriptor | undefined): ClassifierRoute;
|
|
82
|
+
export type { ClassifierNoVerdictReason };
|