@yanlinglabs/winter-runtime-sdk 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +249 -0
  3. package/dist/directory/directory.d.ts +55 -0
  4. package/dist/directory/entries.d.ts +82 -0
  5. package/dist/directory/recovery.d.ts +49 -0
  6. package/dist/door.d.ts +247 -0
  7. package/dist/errors.d.ts +104 -0
  8. package/dist/index.d.ts +25 -0
  9. package/dist/index.js +6679 -0
  10. package/dist/messaging/attribution.d.ts +47 -0
  11. package/dist/messaging/dispatch.d.ts +78 -0
  12. package/dist/messaging/handlers.d.ts +56 -0
  13. package/dist/messaging/inbound.d.ts +110 -0
  14. package/dist/messaging/index.d.ts +39 -0
  15. package/dist/messaging/official-adapter.d.ts +36 -0
  16. package/dist/messaging/router.d.ts +101 -0
  17. package/dist/messaging/sessions.d.ts +49 -0
  18. package/dist/messaging/winter-adapter.d.ts +47 -0
  19. package/dist/native-args.d.ts +76 -0
  20. package/dist/official/adapter.d.ts +88 -0
  21. package/dist/official/aliases.d.ts +48 -0
  22. package/dist/official/auth.d.ts +117 -0
  23. package/dist/official/branding.d.ts +31 -0
  24. package/dist/official/callbacks.d.ts +143 -0
  25. package/dist/official/containment.d.ts +130 -0
  26. package/dist/official/env-allowlist.d.ts +237 -0
  27. package/dist/official/env-registry-rule.d.ts +12 -0
  28. package/dist/official/env-registry.d.ts +3 -0
  29. package/dist/official/errors.d.ts +250 -0
  30. package/dist/official/index.d.ts +31 -0
  31. package/dist/official/mcp-descriptors.d.ts +130 -0
  32. package/dist/official/options-template.d.ts +110 -0
  33. package/dist/official/spawn-proxy.d.ts +144 -0
  34. package/dist/official/spool.d.ts +80 -0
  35. package/dist/official/supervision.d.ts +49 -0
  36. package/dist/official/sweep.d.ts +65 -0
  37. package/dist/sdk.d.ts +214 -0
  38. package/dist/seams/context.d.ts +26 -0
  39. package/dist/seams/directory-store.d.ts +274 -0
  40. package/dist/seams/directory.d.ts +46 -0
  41. package/dist/seams/global-messaging.d.ts +30 -0
  42. package/dist/seams/handoff.d.ts +77 -0
  43. package/dist/seams/index.d.ts +11 -0
  44. package/dist/seams/keychain.d.ts +11 -0
  45. package/dist/seams/materialized-resume.d.ts +46 -0
  46. package/dist/seams/messaging-contract.d.ts +29 -0
  47. package/dist/seams/official-adapter.d.ts +125 -0
  48. package/dist/seams/official-sdk-shapes.d.ts +126 -0
  49. package/dist/seams/stubs.d.ts +34 -0
  50. package/dist/selection/child-runtime.d.ts +81 -0
  51. package/dist/selection/runtime-selection.d.ts +217 -0
  52. package/dist/selection/select-runtime.d.ts +213 -0
  53. package/dist/store/handoff-barrier.d.ts +238 -0
  54. package/dist/store/index.d.ts +11 -0
  55. package/dist/store/materialized-resume.d.ts +100 -0
  56. package/dist/store/pinned-probes.d.ts +17 -0
  57. package/dist/store/reconcile.d.ts +157 -0
  58. package/dist/store/temp-continuity.d.ts +92 -0
  59. package/dist/store/wiring.d.ts +250 -0
  60. package/dist/vendor-paths.d.ts +21 -0
  61. package/dist/version-matrix.d.ts +84 -0
  62. package/docs/conformance-rows.md +195 -0
  63. package/package.json +65 -0
@@ -0,0 +1,237 @@
1
+ import type { BrandProfile } from "@yanlinglabs/winter-agent-sdk";
2
+ import type { EnvInput, RemoteConfigPolicy } from "../seams/official-adapter.js";
3
+ import type { RuntimeSelection } from "../selection/runtime-selection.js";
4
+ import { AUTH_FAMILY_VARIABLES, allowedAuthVariables, type ClaudeOauthGate } from "./auth.js";
5
+ /**
6
+ * §3's "smallest set proven required".
7
+ *
8
+ * `LC_*` is a FAMILY rather than a name (the locale variables are `LC_ALL`, `LC_CTYPE`, … and a host
9
+ * legitimately has several), so it is matched by prefix; everything else is exact.
10
+ */
11
+ export declare const MINIMAL_OS_VARIABLES: readonly string[];
12
+ export declare const MINIMAL_OS_VARIABLE_PREFIXES: readonly string[];
13
+ /** The vendor-named variables this branch sets itself (§1/§3). Claude-mirroring literals (WS-01 §5). */
14
+ export declare const OFFICIAL_RUNTIME_VARIABLES: {
15
+ readonly configDir: "CLAUDE_CONFIG_DIR";
16
+ readonly projectDirName: "CLAUDE_CODE_PROJECT_DIR_NAME";
17
+ readonly tmpdir: "CLAUDE_CODE_TMPDIR";
18
+ };
19
+ /**
20
+ * Proxy and telemetry variables §3 excludes "unless explicitly configured".
21
+ *
22
+ * They are refused by NAME rather than merely omitted because the failure they cause is invisible:
23
+ * a proxy variable that reached this child routes the runtime's traffic somewhere the host did not
24
+ * choose and no assertion in a session would ever notice.
25
+ */
26
+ export declare const PROXY_AND_TELEMETRY_VARIABLES: readonly string[];
27
+ export declare const PROXY_AND_TELEMETRY_PREFIXES: readonly string[];
28
+ /**
29
+ * R-7b-11: THE FOUR TRAFFIC OPT-OUTS THIS BRANCH SETS ON EVERY CHILD, BY DEFAULT.
30
+ *
31
+ * These are not a privacy setting; they are what makes "the pinned artifact" mean one thing. Measured
32
+ * on 0.3.250 — same binary, same options, same loopback endpoint — the runtime advertises 25 tools
33
+ * with these unset and 21 with them set; `DesignSync`, `Monitor`, `PushNotification` and
34
+ * `advisor_20260301:advisor` are present only when its feature-flag CDN answers. A tool surface that
35
+ * changes with a remote flag under one version defeats WS-02 §6.1's "a new official version is a
36
+ * reviewed compatibility event": the surface moves with nothing reviewed and nothing versioned.
37
+ *
38
+ * WS-14 §3's own words permit this — proxy and telemetry variables reach the child "unless explicitly
39
+ * configured", and the router configuring them explicitly is that clause, not an exception to it. Two
40
+ * of the four names (`DISABLE_TELEMETRY`, `DISABLE_ERROR_REPORTING`) are in
41
+ * `PROXY_AND_TELEMETRY_VARIABLES`, i.e. names this module refuses to let a child INHERIT — which is a
42
+ * different question from whether this branch SETS them, and the validator below now separates the
43
+ * two rather than conflating them.
44
+ *
45
+ * THEY ARE BRANCH-OWNED, like the config dir: a host may not pass them through `configuredExtras`
46
+ * (the record would then disagree with the environment), it opts back in with
47
+ * `OfficialEnvPolicy.remoteConfig: "allow"`, and that choice is recorded on the session's directory
48
+ * row. A test-only escape hatch is not needed any more — the hermetic beds get this for free.
49
+ */
50
+ export declare const TRAFFIC_OPT_OUT_VARIABLES: Readonly<Record<string, string>>;
51
+ /** The four names above, for the validator and the drift-gate snapshot. */
52
+ export declare const TRAFFIC_OPT_OUT_VARIABLE_NAMES: readonly string[];
53
+ /** Drops the entries of a path-list value that reach into the vendor's user-level home. */
54
+ export declare function sanitizePathListValue(value: string): string;
55
+ /**
56
+ * What `buildChildEnv` needs beyond the spine's `EnvInput`.
57
+ *
58
+ * TWO FIELDS THE SEAM DOES NOT NAME, and both are per-SESSION rather than per-adapter, so neither
59
+ * could be answered from the adapter's own configuration:
60
+ *
61
+ * `projectKey` §3's `CLAUDE_CODE_PROJECT_DIR_NAME` — "Winter's stable transcript key,
62
+ * decoupling the spool's project dir from the legacy encoded-cwd default".
63
+ * MEASURED: with it set, both the spool and the canonical store wrote to
64
+ * `projects/<key>/`; without it, the spool used the encoded absolute cwd.
65
+ * `sharedTempRoot` §3's `CLAUDE_CODE_TMPDIR` — the shared per-user temp root the host derives from
66
+ * `brand.tempRootName`. Passed IN rather than derived here so a test can hand it
67
+ * a `mkdtemp` and so this module spells no product path.
68
+ *
69
+ * Declared as an EXTENSION of the pinned seam input rather than as a change to it: a lane may not
70
+ * edit `src/seams/**`, and structural typing means a host that has these values simply passes the
71
+ * wider object. The Lane A report carries the two-field diff as the NEEDS_CONTEXT if the spine wants
72
+ * them named on `EnvInput` itself.
73
+ */
74
+ export interface OfficialEnvInput extends EnvInput {
75
+ projectKey?: string;
76
+ sharedTempRoot?: string;
77
+ }
78
+ /** Host policy for the env builder — §3's "deliberate, documented addition" escape hatch, fenced. */
79
+ export interface OfficialEnvPolicy {
80
+ /**
81
+ * Extra variables this deployment deliberately configures (a gateway's proxy, an operator's
82
+ * telemetry). Named here, they pass the validator; unnamed, they are refused.
83
+ */
84
+ configuredExtras?: Readonly<Record<string, string>>;
85
+ /** Additional env prefixes the HOST owns (its daemon's own product prefix). The brand's is always refused. */
86
+ hostEnvPrefixes?: readonly string[];
87
+ /**
88
+ * Auth-SHAPED variables this deployment has reviewed and needs anyway (review r2, NEW-2).
89
+ *
90
+ * The extras door is closed to credential-bearing shapes by default, because the pinned runtime
91
+ * reads far more of them than any table lists and one of them re-points the whole session. A host
92
+ * with a real need — a cloud tuning variable its family table does not carry — names it here, which
93
+ * is §12's own "reviewed compatibility event" rather than a silent addition.
94
+ */
95
+ reviewedCredentialShapedExtras?: readonly string[];
96
+ /**
97
+ * Execution/indirection variables this deployment has reviewed and needs anyway (item 22, NEW-A).
98
+ *
99
+ * The sibling of `reviewedCredentialShapedExtras`, for the other blind spot: names that change how
100
+ * the child EXECUTES code or authenticates (`BASH_ENV`, `NODE_OPTIONS`, `GIT_ASKPASS`, `LD_*`, …).
101
+ * They are refused by name even when the pinned registry declares them, because "the artifact reads
102
+ * it" is exactly why it is dangerous. One name at a time; never a prefix, never a wildcard.
103
+ */
104
+ reviewedExecutionExtras?: readonly string[];
105
+ /**
106
+ * R-7b-11: `"deny"` (the default) sets `TRAFFIC_OPT_OUT_VARIABLES` on the child; `"allow"` omits
107
+ * them, letting the runtime fetch its own remote feature configuration.
108
+ *
109
+ * ABSENT MEANS DENY, EVERYWHERE — including for a host that never heard of this field, which is the
110
+ * point: the shipped default must be the one that makes the pin mean one artifact.
111
+ */
112
+ remoteConfig?: RemoteConfigPolicy;
113
+ /** D14's ship gate, threaded to the auth validator. Default: closed. */
114
+ claudeOauth?: ClaudeOauthGate;
115
+ }
116
+ /**
117
+ * NAMES THAT CHANGE HOW THE CHILD EXECUTES CODE OR AUTHENTICATES — refused by NAME, always (item 22,
118
+ * fix-wave re-review NEW-A).
119
+ *
120
+ * WHY A LITERAL SET AND NOT A RULE. The extras door already has two rules and BOTH are blind here.
121
+ * The credential rule is a SHAPE rule (`_KEY`, `TOKEN`, `OAUTH`, …) and none of these names looks
122
+ * like a credential; the positive-allowlist rule admits any name the pinned artifact's own registry
123
+ * declares, and all five of the headline names below ARE declared there — the artifact reads them, so
124
+ * the registry is right to list them, and that is precisely why "the registry declares it" cannot be
125
+ * the whole test. Measured on the head before this set existed: `BASH_ENV`,
126
+ * `CLAUDE_CODE_SHELL_PREFIX`, `NODE_OPTIONS`, `GIT_ASKPASS` and `CLAUDE_CODE_GIT_BASH_PATH` were all
127
+ * ADMITTED through `configuredExtras`, while the README told hosts they were refused.
128
+ *
129
+ * WHAT THESE NAMES DO, which is the reason they are one class:
130
+ *
131
+ * * `BASH_ENV` / `ENV` / `CLAUDE_CODE_SHELL_PREFIX` — a file the shell SOURCES on every
132
+ * non-interactive start, or a prefix wrapped around every command. Arbitrary code before any
133
+ * command the containment floor ever sees.
134
+ * * `NODE_OPTIONS` / `LD_PRELOAD` / `LD_*` / `DYLD_*` — loader and runtime hooks. `--require` runs
135
+ * a module inside the child before its own entry point.
136
+ * * `GIT_ASKPASS` / `SSH_ASKPASS` / `SUDO_ASKPASS` / `GIT_SSH*` / `GIT_CREDENTIAL_HELPER` — programs
137
+ * the child EXECUTES to obtain credentials. Not credential-shaped; credential-producing.
138
+ *
139
+ * THE SET IS THE ARTIFACT'S OWN, NOT OURS (round 3, NEW-H). The first version named five measured
140
+ * headline variables and the README described the CLASS — which was wider than the set: nineteen more
141
+ * registry names of exactly that class rode the door, and two were then measured doing what the class
142
+ * describes. `CLAUDE_CODE_SHELL` made the runtime run a planted program as the Bash tool's shell (114
143
+ * invocations in one session, the marker visible in the tool result the model was shown), and
144
+ * `CLAUDE_ENV_FILE` was sourced into every Bash call — `BASH_ENV` by another door, which made the
145
+ * `BASH_ENV` refusal decorative. So the list below is the PINNED ARTIFACT'S OWN scrub list (the
146
+ * environment it strips before running its policy helper — the vendor's definition of this class, and
147
+ * therefore the pin's rather than our taste) plus the runtime-specific doors that are not on it. The
148
+ * drift gate in `test/official/env-allowlist.test.ts` fails when a pin bump adds a registry name of
149
+ * this shape that nothing classifies.
150
+ *
151
+ * The exposure was bounded (the `base` door drops these silently, so only a host naming one itself
152
+ * could pass it), which is why this is a scheduled hardening rather than an incident — but "the
153
+ * README claims a refusal the code does not make" is the one state that must not ship.
154
+ *
155
+ * IT IS STILL A DOOR, NOT A WALL. A deployment that has REVIEWED a specific name and needs it says so
156
+ * in `reviewedExecutionExtras`, one name at a time — the same shape as the credential hatch, and a
157
+ * reviewed compatibility event rather than a silent addition.
158
+ */
159
+ export declare const EXECUTION_INDIRECTION_ENV_NAMES: readonly string[];
160
+ /**
161
+ * The PREFIXES, which no closed list can enumerate — the artifact's own scrub prefixes plus `DYLD_`.
162
+ *
163
+ * `GIT_` IS A WHOLE PREFIX, and that is the vendor's call rather than ours: the artifact scrubs it
164
+ * entirely before running its policy helper, because `GIT_CONFIG_GLOBAL`/`_SYSTEM`/`_COUNT` name files
165
+ * git reads for a `credential.helper`, `GIT_SSH_COMMAND`/`GIT_EXTERNAL_DIFF`/`GIT_PAGER` name programs
166
+ * git RUNS, and `GIT_ASKPASS` supplies credentials. A host that needs one names it in
167
+ * `reviewedExecutionExtras`.
168
+ */
169
+ export declare const EXECUTION_INDIRECTION_ENV_PREFIXES: readonly string[];
170
+ /** True for a name that changes how the child executes code or authenticates. Case-insensitive. */
171
+ export declare function isExecutionIndirectionVariable(name: string): boolean;
172
+ /** Picks the minimal OS set out of a caller-supplied source. The host passes `process.env`; we never do. */
173
+ export declare function minimalOsEnvironmentFrom(source: Readonly<Record<string, string | undefined>>): Record<string, string>;
174
+ /**
175
+ * Builds the child environment: §3's table, in one pass, from an allowlist.
176
+ *
177
+ * ORDER IS ALPHABETICAL IN THE RESULT because this object is a golden-capture input and a stable
178
+ * fixture must not depend on which branch of the builder ran first.
179
+ */
180
+ export declare function buildOfficialChildEnv(input: OfficialEnvInput, policy?: OfficialEnvPolicy): Record<string, string>;
181
+ /**
182
+ * §3's MUST-NOT list, as a refusal.
183
+ *
184
+ * Every clause is a leak with a name:
185
+ * * a product-prefixed variable hands the child the DAEMON's configuration, which is how a spawned
186
+ * runtime ends up reading the host's own home directory;
187
+ * * `CLAUDE_CODE_OAUTH_TOKEN` is the credential D14 gates and §12 routes through the spool instead;
188
+ * * an undeclared proxy or telemetry variable silently redirects or duplicates traffic;
189
+ * * a VALUE pointing into the vendor's user-level home is the isolation failure this whole branch
190
+ * exists to prevent — and it is a value check, because the variable that carries it can be
191
+ * anything at all (WS-17 row 4's "zero visibility into the vendor home").
192
+ */
193
+ export declare function assertNoForbiddenChildVariables(env: Readonly<Record<string, string>>, args: {
194
+ brand: Pick<BrandProfile, "envPrefix" | "processLabel">;
195
+ selection?: Pick<RuntimeSelection, "authFamily" | "providerId">;
196
+ policy?: OfficialEnvPolicy;
197
+ branchLabel?: string;
198
+ }): void;
199
+ /**
200
+ * WS-17's drift-gate input: the allowlist as NAMES, grouped, with the pinned runtime version they
201
+ * were captured against. Never a value — see this module's header.
202
+ */
203
+ export interface EnvAllowlistSnapshot {
204
+ pinnedRuntime: string;
205
+ runtimeVariables: readonly string[];
206
+ minimalOsVariables: readonly string[];
207
+ minimalOsVariablePrefixes: readonly string[];
208
+ authFamilies: Readonly<Record<string, readonly string[]>>;
209
+ neverInjected: readonly string[];
210
+ refusedProxyTelemetry: readonly string[];
211
+ refusedProxyTelemetryPrefixes: readonly string[];
212
+ /** R-7b-11: the names this branch SETS by default. A change here is a reviewed compatibility event too. */
213
+ trafficOptOuts: readonly string[];
214
+ /** R-7b-13: the shape the pin accepts for the transcript project key — a rejected one is substituted. */
215
+ projectDirNamePattern: string;
216
+ }
217
+ /** The pinned artifact every name above was captured from (WS-02 §6.1: an upgrade is reviewed). */
218
+ export declare const PINNED_OFFICIAL_RUNTIME = "0.3.250";
219
+ /**
220
+ * R-7b-13: the shape the PINNED ARTIFACT accepts for `CLAUDE_CODE_PROJECT_DIR_NAME`.
221
+ *
222
+ * A PINNED LITERAL, read off 0.3.250 itself, because the consequence of getting it wrong is silent:
223
+ * the runtime validates the variable against this pattern and, when it does not match, FALLS BACK TO
224
+ * ITS OWN cwd-derived key. Measured — a 70-character key left the transcript under the vendor's own
225
+ * realpath-derived name while the directory row, the child environment and the auto-memory directory
226
+ * all named the host's key. That is "the record and the transcript disagree", which is the class WS-14
227
+ * §1 exists to prevent, and no assertion downstream would ever notice it.
228
+ *
229
+ * So a key this pattern rejects is REFUSED here rather than passed through and quietly ignored. The
230
+ * drift gate re-checks the literal on every pin bump.
231
+ */
232
+ export declare const PINNED_PROJECT_DIR_NAME_PATTERN = "^[A-Za-z0-9_-]{1,64}$";
233
+ export declare function officialEnvAllowlistSnapshot(): EnvAllowlistSnapshot;
234
+ /** Every name the snapshot mentions, flattened — what a scan of the pinned artifact is run against. */
235
+ export declare function officialEnvAllowlistNames(): readonly string[];
236
+ /** Re-exported so a caller building a plan has one import site for the family tables. */
237
+ export { AUTH_FAMILY_VARIABLES, allowedAuthVariables };
@@ -0,0 +1,12 @@
1
+ /** Segments that make a variable name credential-bearing, whatever else it says. */
2
+ export declare const CREDENTIAL_NAME_KEYWORDS: readonly string[];
3
+ /**
4
+ * Every env-shaped accessor the pinned artifact declares (`NAME:()=>fn` in its own export map).
5
+ *
6
+ * Filtered to env-SHAPED names — an upper- or lower-snake identifier with at least one underscore —
7
+ * because the same construct carries minified function names, and a registry padded with those would
8
+ * make the drift gate noisy rather than informative.
9
+ */
10
+ export declare function extractEnvRegistry(artifact: string): string[];
11
+ /** The independent rule: is this NAME credential-bearing? Case-insensitive, by segment. */
12
+ export declare function isCredentialByName(name: string): boolean;
@@ -0,0 +1,3 @@
1
+ export declare const PINNED_ENV_REGISTRY_SIZE = 886;
2
+ /** The non-credential subset of the pinned artifact's own env registry (672 names). */
3
+ export declare const NON_CREDENTIAL_ENV_REGISTRY: readonly string[];
@@ -0,0 +1,250 @@
1
+ import { RuntimeSdkError } from "../errors.js";
2
+ /** The WS-03 §11 classes an official-branch failure maps onto, by exported name. */
3
+ export type WinterErrorClassName = "WinterSDKError" | "CLIConnectionError" | "ProcessError" | "ResultError" | "ProtocolDecodeError" | "AbortError" | "SessionNotFoundError";
4
+ /**
5
+ * WS-14 §9's crash classes — the failures that describe the CHILD PROCESS rather than the turn.
6
+ *
7
+ * `killed` is the fifth member §9 names and the one that is not itself an error condition: a
8
+ * supervised teardown kills the child on purpose, and the class exists so the projector can tell
9
+ * "we ended it" from "it died".
10
+ */
11
+ export type OfficialCrashClass = "executable-not-found" | "connection-failure" | "malformed-protocol" | "nonzero-exit" | "killed" | "stdout-unterminated";
12
+ /** Every code in this taxonomy, in WS-14 §13's own order. Exported so a test can assert completeness. */
13
+ export declare const OFFICIAL_ERROR_CODES: readonly ["official_configuration_invalid", "official_executable_not_found", "official_connection_failure", "official_malformed_protocol", "official_nonzero_exit", "official_killed", "official_agent_result_failure", "official_api_failure", "official_tool_failure", "official_permission_denied", "official_mcp_failure", "official_session_store_failure", "official_session_not_found", "official_invalid_resume", "official_interrupted", "official_stdout_unterminated", "official_containment_breach"];
14
+ export type OfficialErrorCode = (typeof OFFICIAL_ERROR_CODES)[number];
15
+ /**
16
+ * The base class of the official branch's taxonomy.
17
+ *
18
+ * Extends the router's own `RuntimeSdkError` so a host can catch this package's whole family with one
19
+ * `instanceof`, exactly as `src/errors.ts` promises.
20
+ */
21
+ export declare abstract class OfficialBranchError extends RuntimeSdkError {
22
+ abstract readonly code: OfficialErrorCode;
23
+ abstract readonly winterClass: WinterErrorClassName;
24
+ /** Present only on the process-lifecycle classes (§9). */
25
+ readonly crashClass?: OfficialCrashClass;
26
+ /** WS-14 §14: the internal diagnostics label of this branch, so a log line names the branch. */
27
+ readonly branch: string;
28
+ constructor(message: string, branchLabel: string, options?: {
29
+ cause?: unknown;
30
+ });
31
+ }
32
+ /** §13.1 — an `Options` combination this branch refuses to build (§5.1's withheld options live here). */
33
+ export declare class OfficialConfigurationError extends OfficialBranchError {
34
+ readonly code = "official_configuration_invalid";
35
+ readonly winterClass = "WinterSDKError";
36
+ /** WHICH option was wrong, so a host can point at a field rather than parse prose. */
37
+ readonly option: string;
38
+ constructor(args: {
39
+ option: string;
40
+ reason: string;
41
+ branchLabel: string;
42
+ });
43
+ }
44
+ /** §13.2 / §9 — the vendored runtime is not where the host said it was. */
45
+ export declare class OfficialExecutableNotFoundError extends OfficialBranchError {
46
+ readonly code = "official_executable_not_found";
47
+ readonly winterClass = "CLIConnectionError";
48
+ readonly crashClass: "executable-not-found";
49
+ readonly path: string;
50
+ constructor(args: {
51
+ path: string;
52
+ branchLabel: string;
53
+ cause?: unknown;
54
+ });
55
+ }
56
+ /** §13.3 / §9 — the child started but the stdio channel never came up. */
57
+ export declare class OfficialConnectionError extends OfficialBranchError {
58
+ readonly code = "official_connection_failure";
59
+ readonly winterClass = "CLIConnectionError";
60
+ readonly crashClass: "connection-failure";
61
+ constructor(args: {
62
+ reason: string;
63
+ branchLabel: string;
64
+ cause?: unknown;
65
+ });
66
+ }
67
+ /** §13.4 / §9 — a frame arrived that is not the pinned protocol. */
68
+ export declare class OfficialProtocolError extends OfficialBranchError {
69
+ readonly code = "official_malformed_protocol";
70
+ readonly winterClass = "ProtocolDecodeError";
71
+ readonly crashClass: "malformed-protocol";
72
+ constructor(args: {
73
+ reason: string;
74
+ branchLabel: string;
75
+ });
76
+ }
77
+ /**
78
+ * §13.5 / §9 — the child exited nonzero.
79
+ *
80
+ * `stderrTail` is here because §6 rule 6 requires stderr to be DRAINED CONTINUOUSLY: the drain has to
81
+ * put what it saw somewhere, and the exit error is the only place a consumer will look. Bounded by
82
+ * the proxy (a runaway child must not turn an error message into a memory leak).
83
+ */
84
+ export declare class OfficialNonzeroExitError extends OfficialBranchError {
85
+ readonly code = "official_nonzero_exit";
86
+ readonly winterClass = "ProcessError";
87
+ readonly crashClass: "nonzero-exit";
88
+ readonly exitCode: number | null;
89
+ readonly signal: string | null;
90
+ readonly stderrTail: string;
91
+ constructor(args: {
92
+ exitCode: number | null;
93
+ signal: string | null;
94
+ stderrTail: string;
95
+ branchLabel: string;
96
+ });
97
+ }
98
+ /** §9's fifth crash class — a supervised kill. Distinct from a nonzero exit: this one WE caused. */
99
+ export declare class OfficialKilledError extends OfficialBranchError {
100
+ readonly code = "official_killed";
101
+ readonly winterClass = "ProcessError";
102
+ readonly crashClass: "killed";
103
+ readonly signal: string;
104
+ constructor(args: {
105
+ signal: string;
106
+ reason: string;
107
+ branchLabel: string;
108
+ });
109
+ }
110
+ /** §8's post-hoc breach — see `OFFICIAL_ERROR_CODES`. Never a crash class: the process is healthy. */
111
+ export declare class OfficialContainmentBreachError extends OfficialBranchError {
112
+ readonly code = "official_containment_breach";
113
+ readonly winterClass = "WinterSDKError";
114
+ readonly tool: string;
115
+ readonly created: readonly string[];
116
+ readonly removed: readonly string[];
117
+ readonly retained: readonly string[];
118
+ constructor(args: {
119
+ toolName: string;
120
+ created: readonly string[];
121
+ removed: readonly string[];
122
+ retained: readonly string[];
123
+ branchLabel: string;
124
+ });
125
+ }
126
+ /** M4's sixth crash class: the child exited and its stdout never closed. See `OFFICIAL_ERROR_CODES`. */
127
+ export declare class OfficialStdoutUnterminatedError extends OfficialBranchError {
128
+ readonly code = "official_stdout_unterminated";
129
+ readonly winterClass = "ProcessError";
130
+ readonly crashClass: "stdout-unterminated";
131
+ readonly graceMs: number;
132
+ constructor(args: {
133
+ graceMs: number;
134
+ branchLabel: string;
135
+ });
136
+ }
137
+ /**
138
+ * §13.6 — the TURN failed, and the process is fine.
139
+ *
140
+ * The class §9 exists to keep separate from the five above it. `subtype` is the result message's own
141
+ * subtype, which is what a consumer branches on ("consumers branch on error class AND result
142
+ * subtype").
143
+ */
144
+ export declare class OfficialAgentResultError extends OfficialBranchError {
145
+ readonly code = "official_agent_result_failure";
146
+ readonly winterClass = "ResultError";
147
+ readonly subtype: string;
148
+ constructor(args: {
149
+ subtype: string;
150
+ detail?: string;
151
+ branchLabel: string;
152
+ });
153
+ }
154
+ /** §13.7 — the provider request failed. Never the same class as a crashed child. */
155
+ export declare class OfficialApiError extends OfficialBranchError {
156
+ readonly code = "official_api_failure";
157
+ readonly winterClass = "ResultError";
158
+ readonly status?: number;
159
+ constructor(args: {
160
+ reason: string;
161
+ status?: number;
162
+ branchLabel: string;
163
+ });
164
+ }
165
+ /** §13.8 — one tool call failed; the turn continues. */
166
+ export declare class OfficialToolError extends OfficialBranchError {
167
+ readonly code = "official_tool_failure";
168
+ readonly winterClass = "WinterSDKError";
169
+ readonly tool: string;
170
+ constructor(args: {
171
+ tool: string;
172
+ reason: string;
173
+ branchLabel: string;
174
+ });
175
+ }
176
+ /** §13.9 — a permission decision denied the call. A normal outcome, and still its own class. */
177
+ export declare class OfficialPermissionDeniedError extends OfficialBranchError {
178
+ readonly code = "official_permission_denied";
179
+ readonly winterClass = "WinterSDKError";
180
+ readonly tool: string;
181
+ constructor(args: {
182
+ tool: string;
183
+ reason: string;
184
+ branchLabel: string;
185
+ });
186
+ }
187
+ /** §13.10 — an MCP server failed to start, connect, or answer. */
188
+ export declare class OfficialMcpError extends OfficialBranchError {
189
+ readonly code = "official_mcp_failure";
190
+ readonly winterClass = "WinterSDKError";
191
+ readonly server: string;
192
+ constructor(args: {
193
+ server: string;
194
+ reason: string;
195
+ branchLabel: string;
196
+ });
197
+ }
198
+ /**
199
+ * §13.11 / §5 — `mirror_error`: the canonical store did not receive everything.
200
+ *
201
+ * NON-FATAL TO THE TURN, and the class says so in a field rather than in prose: "MUST NOT
202
+ * retroactively fail the model turn". What it DOES do is set `transcriptHealth: repair-required` and
203
+ * block handoff until reconciliation — `recordedLocalWriteRoot` is the root that reconciliation runs
204
+ * against (§1), which is why it travels with the error.
205
+ */
206
+ export declare class OfficialSessionStoreError extends OfficialBranchError {
207
+ readonly code = "official_session_store_failure";
208
+ readonly winterClass = "WinterSDKError";
209
+ readonly fatalToTurn = false;
210
+ readonly transcriptHealth: "repair-required";
211
+ readonly recordedLocalWriteRoot?: string;
212
+ constructor(args: {
213
+ reason: string;
214
+ recordedLocalWriteRoot?: string;
215
+ branchLabel: string;
216
+ });
217
+ }
218
+ /** §13.12 — the backend session id is not resolvable (WS-05 §7's rules decide "not found"). */
219
+ export declare class OfficialSessionNotFoundError extends OfficialBranchError {
220
+ readonly code = "official_session_not_found";
221
+ readonly winterClass = "SessionNotFoundError";
222
+ readonly reason: "not_found" | "ambiguous";
223
+ constructor(args: {
224
+ sessionId: string;
225
+ reason: "not_found" | "ambiguous";
226
+ branchLabel: string;
227
+ });
228
+ }
229
+ /** §13.13 — a resume or fork request this branch refuses to make (§5.1's fork rules). */
230
+ export declare class OfficialInvalidResumeError extends OfficialBranchError {
231
+ readonly code = "official_invalid_resume";
232
+ readonly winterClass = "WinterSDKError";
233
+ constructor(args: {
234
+ reason: string;
235
+ branchLabel: string;
236
+ });
237
+ }
238
+ /** §13.14 / §9 — an interrupt or a cancellation. `AbortError` is its Winter counterpart. */
239
+ export declare class OfficialInterruptedError extends OfficialBranchError {
240
+ readonly code = "official_interrupted";
241
+ readonly winterClass = "AbortError";
242
+ /** WS-14 §9's four gestures — which one produced this. */
243
+ readonly gesture: "interrupt-turn" | "stop-task" | "end-session" | "kill-process";
244
+ constructor(args: {
245
+ gesture: OfficialInterruptedError["gesture"];
246
+ branchLabel: string;
247
+ });
248
+ }
249
+ /** Narrows anything to this branch's taxonomy — the one `instanceof` a projector needs. */
250
+ export declare function isOfficialBranchError(value: unknown): value is OfficialBranchError;
@@ -0,0 +1,31 @@
1
+ export { createOfficialAdapter, officialHandoffEligibility } from "./adapter.js";
2
+ export type { HandoffEligibility, OfficialAdapterHandle, OfficialAdapterPolicy, OfficialSessionHandle, OfficialSessionHealth } from "./adapter.js";
3
+ export { ALIASED_BUILTINS, CANONICAL_DUPLICATE_EXPOSURE, aliasDenyNames, aliasTargetFor, officialToolAliases } from "./aliases.js";
4
+ export type { AliasedBuiltin } from "./aliases.js";
5
+ export { NON_CREDENTIAL_ENV_REGISTRY, PINNED_ENV_REGISTRY_SIZE } from "./env-registry.js";
6
+ export { CREDENTIAL_NAME_KEYWORDS, extractEnvRegistry, isCredentialByName } from "./env-registry-rule.js";
7
+ export { ALL_AUTH_VARIABLES, AUTH_FAMILY_VARIABLES, AUTH_SHAPED_RE, NEVER_INJECTED_AUTH_VARIABLES, allowedAuthVariables, authVariableSetKey, fetchAuthCredentials, isAuthShapedVariable, validateAuthEnvironment } from "./auth.js";
8
+ export type { AuthCredentialPlan, AuthFamily, AuthVariableSetKey, ClaudeOauthGate } from "./auth.js";
9
+ export { OFFICIAL_DISCLOSURES, officialBranchLabel } from "./branding.js";
10
+ export type { OfficialDisclosure } from "./branding.js";
11
+ export { APPROVAL_BRIDGE_MARK, CONTAINMENT_FLOOR_MARK, carriesMark, createApprovalBridge, createContainmentHooks, createFirstResponseWins, isOurApprovalBridge, isOurContainmentHook, revalidateResumedDecision } from "./callbacks.js";
12
+ export type { ApprovalBroker, ApprovalRequest, ApprovalBridgeOptions, ContainmentHooksOptions, DecisionContext, DecisionSource, OfficialApprovalBridge, OfficialHookOutput, OfficialPermissionMode, PreToolUseHookInput, ResumedDecision, } from "./callbacks.js";
13
+ export { FORBIDDEN_TARGETS, VENDOR_HOME_SEGMENT_RE, containmentDecisionFor, containmentDispositions, containmentPaths, officialDisallowedTools, resolveSavedApprovalDisposition, targetsForbiddenPath } from "./containment.js";
14
+ export type { ContainmentDecision, ContainmentDisposition, ContainmentPaths, ContainmentPolicy, SavedApprovalDisposition } from "./containment.js";
15
+ export { MINIMAL_OS_VARIABLES, sanitizePathListValue, MINIMAL_OS_VARIABLE_PREFIXES, OFFICIAL_RUNTIME_VARIABLES, PINNED_OFFICIAL_RUNTIME, PROXY_AND_TELEMETRY_PREFIXES, PROXY_AND_TELEMETRY_VARIABLES, TRAFFIC_OPT_OUT_VARIABLES, TRAFFIC_OPT_OUT_VARIABLE_NAMES, assertNoForbiddenChildVariables, buildOfficialChildEnv, minimalOsEnvironmentFrom, officialEnvAllowlistNames, officialEnvAllowlistSnapshot, } from "./env-allowlist.js";
16
+ export { EXECUTION_INDIRECTION_ENV_NAMES, EXECUTION_INDIRECTION_ENV_PREFIXES, isExecutionIndirectionVariable } from "./env-allowlist.js";
17
+ export type { EnvAllowlistSnapshot, OfficialEnvInput, OfficialEnvPolicy } from "./env-allowlist.js";
18
+ export { OFFICIAL_ERROR_CODES, OfficialStdoutUnterminatedError, OfficialAgentResultError, OfficialApiError, OfficialBranchError, OfficialConfigurationError, OfficialConnectionError, OfficialExecutableNotFoundError, OfficialInterruptedError, OfficialInvalidResumeError, OfficialKilledError, OfficialMcpError, OfficialNonzeroExitError, OfficialPermissionDeniedError, OfficialProtocolError, OfficialSessionNotFoundError, OfficialSessionStoreError, OfficialToolError, isOfficialBranchError, } from "./errors.js";
19
+ export type { OfficialCrashClass, OfficialErrorCode, WinterErrorClassName } from "./errors.js";
20
+ export { OFFICIAL_MATERIALIZATION_DROPS, assertNoAdvisor, canonicalToolNames, materializeOfficialMcpServer, messagingToolDescriptors, officialMcpServers, winterMcpServerDescriptor } from "./mcp-descriptors.js";
21
+ export type { InputShapeFactory, JsonSchemaObject, MessagingHandlers, OfficialMcpModule, WinterMcpHandler, WinterMcpServerDescriptor, WinterMcpToolDescriptor, WinterMcpToolResult } from "./mcp-descriptors.js";
22
+ export { AUTO_MEMORY_LOAD_CAP, DEFAULT_EXCLUDE_DYNAMIC_SECTIONS, PINNED_SYSTEM_PROMPT_PRESET, assertOptionsInvariants, brandedFlagSettings, buildOfficialOptions, captureOptions, mergeHooks } from "./options-template.js";
23
+ export type { OptionsTemplatePolicy } from "./options-template.js";
24
+ export { SPOOL_SEGMENTS, classifyLocalWriteRoot, officialSpoolRoot, validateObservedConfigDir, vendorTempRootReport } from "./spool.js";
25
+ export type { LocalWriteRootKind, ObservedLocalWriteRoot, VendorTempRootReport } from "./spool.js";
26
+ export { createSupervisedSpawnProxy, directoryRecordSink, prepareDefaultSpawn } from "./spawn-proxy.js";
27
+ export type { ProcessIdentity, SpawnChild, SpawnObservation, SpawnRecordSink, SpawnedChildProcess, SupervisedSpawnProxy, SupervisedSpawnProxyOptions, TranscriptReconcile } from "./spawn-proxy.js";
28
+ export { POST_TOOL_EVENTS, SWEPT_TARGETS, SWEPT_TOOLS, createContainmentSweep, forbiddenArtifactsUnder } from "./sweep.js";
29
+ export type { ContainmentBreach, ContainmentSweep, ContainmentSweepOptions } from "./sweep.js";
30
+ export { CANCELLATION_MAPPINGS, DEFAULT_SESSION_QUOTAS, cancellationMappingFor, crashClassOf, interruptionFor, isProcessCrash, revalidateProcessIdentity } from "./supervision.js";
31
+ export type { CancellationGesture, CancellationMapping } from "./supervision.js";