@yanlinglabs/winter-agent-sdk 0.0.23 → 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/dist/index.d.ts CHANGED
@@ -20,14 +20,14 @@ export { WinterSDKError, CLIConnectionError, ProcessError, ResultError, Protocol
20
20
  export { resolveRuntimeExecutable, defaultSpawn } from "./transport.js";
21
21
  export type { SpawnedRuntimeProcess, SpawnRuntimeOptions, SpawnClaudeCodeProcess } from "./transport.js";
22
22
  export type { RuntimeConfig, RuntimeHooksConfig, RuntimeHookMatcherGroup, SandboxSettingsConfig } from "./protocol/config.js";
23
- export type { McpServerConfigForProcessTransport, AgentMcpServerSpec, RuntimeAgentDefinition } from "./protocol/config.js";
23
+ export type { McpServerConfigForProcessTransport, McpVersionNegotiation, AgentMcpServerSpec, RuntimeAgentDefinition } from "./protocol/config.js";
24
24
  export { encodeFrame, decodeFrame, splitFrames, ProtocolError } from "./protocol/codec.js";
25
25
  export { PROTOCOL_VERSION } from "./protocol/frames.js";
26
26
  export { SDK_VERSION } from "./version.js";
27
27
  export { MESSAGING_CONTROL_SUBTYPES, MESSAGING_CONTROL_SUBTYPE_LIST, MESSAGING_HOST_REQUEST_SUBTYPES, MESSAGING_RUNTIME_REQUEST_SUBTYPES, resolveFacetTarget } from "./protocol/messaging.js";
28
28
  export { isRuntimeAddress, isGlobalAgentMessage, isDeliveryOutcome, isListedRuntimeObjectArray, isPermissionClassLabel, isMessagingDeliverRequest, isMessagingChildRequest, isMessagingSubscribeIdleRequest, isMessagingReadNotificationsRequest, isMessagingNotificationsPage, isMessagingIdleNoticePayload, isNotificationRecord, } from "./protocol/messaging.js";
29
29
  export type { MessagingControlSubtype, MessagingDeliverRequest, MessagingChildRequest, MessagingSubscribeIdleRequest, MessagingSenderClassResponse, MessagingReadNotificationsRequest, MessagingNotificationsPage, MessagingIdleNoticePayload, } from "./protocol/messaging.js";
30
- export type { ProtocolVersion, WinterFrame, SdkMessage as ProtocolSdkMessage, InitFrame, UserFrame, DataFrame, ControlRequestFrame, ControlResponseFrame, ControlCancelRequestFrame, WireResultUsage, UnknownFrame, SDKHookStartedMessage, SDKHookProgressMessage, SDKHookResponseMessage, SDKPermissionDeniedMessage, SDKPermissionDenial, SDKTaskStartedMessage, SDKTaskNotificationMessage, SDKTaskUpdatedMessage, SDKTaskProgressMessage, SDKBackgroundTasksChangedMessage, SDKLocalCommandOutputMessage, BackgroundTaskMessage, SDKCompactBoundaryMessage, SDKSessionStateChangedMessage, WireContentBlock, WireStreamEvent, WireStreamEventDelta, SDKPartialAssistantMessage, SDKAssistantMessageError, SDKAPIRetryMessage, SDKRateLimitEvent, SDKRateLimitInfo, SDKAuthStatusMessage, SDKThinkingTokensMessage, SDKModelRefusalFallbackMessage, SDKModelRefusalNoFallbackMessage, SDKReasoningSummaryMessage, SDKModelSwitchMessage, SDKContinuityWarningMessage, } from "./protocol/frames.js";
30
+ export type { ProtocolVersion, WinterFrame, SdkMessage as ProtocolSdkMessage, InitFrame, UserFrame, DataFrame, ControlRequestFrame, ControlResponseFrame, ControlCancelRequestFrame, WireResultUsage, UnknownFrame, SDKHookStartedMessage, SDKHookProgressMessage, SDKHookResponseMessage, SDKPermissionDeniedMessage, SDKPermissionDenial, SDKTaskStartedMessage, SDKTaskNotificationMessage, SDKTaskUpdatedMessage, SDKTaskProgressMessage, SDKBackgroundTasksChangedMessage, SDKLocalCommandOutputMessage, BackgroundTaskMessage, SDKCompactBoundaryMessage, SDKSessionStateChangedMessage, SDKInformationalMessage, WireContentBlock, WireStreamEvent, WireStreamEventDelta, SDKPartialAssistantMessage, SDKAssistantMessageError, SDKAPIRetryMessage, SDKRateLimitEvent, SDKRateLimitInfo, SDKAuthStatusMessage, SDKThinkingTokensMessage, SDKModelRefusalFallbackMessage, SDKModelRefusalNoFallbackMessage, SDKReasoningSummaryMessage, SDKModelSwitchMessage, SDKContinuityWarningMessage, } from "./protocol/frames.js";
31
31
  export { resolveWinterHome, resolveKeychainServiceForProfile, isUnset } from "./paths/home.js";
32
32
  export { transcriptProjectKey, TRANSCRIPT_PROJECT_KEY_MAX_LENGTH, isVendorCompliantProjectKey } from "./paths/project-key.js";
33
33
  export { compatibilityKeys } from "./paths/keys.js";
@@ -50,7 +50,7 @@ export type { PermissionMode, PermissionBehavior, PermissionRuleValue } from "./
50
50
  export type { PermissionUpdate, PermissionUpdateDestination, RuleSource } from "./permissions/types.js";
51
51
  export type { CanUseTool, PermissionResult, PermissionDecisionClassification, PermissionRequestPayload } from "./permissions/types.js";
52
52
  export { HOOK_EVENTS } from "./permissions/types.js";
53
- export type { HookEvent, HookEventName, HookSource, HookPermissionDecision, BaseHookInput, PreToolUseHookInput, PostToolUseHookInput, PostToolUseFailureHookInput, UserPromptSubmitHookInput, StopHookInput, SessionStartHookInput, SessionEndHookInput, NotificationHookInput, PermissionRequestHookInput, PermissionDeniedHookInput, GenericHookInput, HookInput, AsyncHookJSONOutput, SyncHookJSONOutput, HookJSONOutput, PreToolUseHookSpecificOutput, PostToolUseHookSpecificOutput, PostToolUseFailureHookSpecificOutput, UserPromptSubmitHookSpecificOutput, StopHookSpecificOutput, SessionStartHookSpecificOutput, NotificationHookSpecificOutput, PermissionRequestHookSpecificOutput, PermissionDeniedHookSpecificOutput, GenericHookSpecificOutput, HookSpecificOutput, HookCallback, HookCallbackMatcher, HookInvocationPayload, } from "./permissions/types.js";
53
+ export type { HookEvent, HookEventName, HookSource, HookPermissionDecision, BaseHookInput, PreToolUseHookInput, PostToolUseHookInput, PostToolUseFailureHookInput, UserPromptSubmitHookInput, StopHookInput, SessionStartHookInput, SessionEndHookInput, NotificationHookInput, PermissionRequestHookInput, PermissionDeniedHookInput, SubagentStartHookInput, SubagentStopHookInput, GenericHookInput, HookInput, AsyncHookJSONOutput, SyncHookJSONOutput, HookJSONOutput, PreToolUseHookSpecificOutput, PostToolUseHookSpecificOutput, PostToolUseFailureHookSpecificOutput, UserPromptSubmitHookSpecificOutput, StopHookSpecificOutput, SubagentStartHookSpecificOutput, SubagentStopHookSpecificOutput, SessionStartHookSpecificOutput, NotificationHookSpecificOutput, PermissionRequestHookSpecificOutput, PermissionDeniedHookSpecificOutput, GenericHookSpecificOutput, HookSpecificOutput, HookCallback, HookCallbackMatcher, HookInvocationPayload, } from "./permissions/types.js";
54
54
  export { CATALOG_TAG_RENAMES } from "@yanlinglabs/winter-provider-catalog";
55
55
  export { PluginManagerError, listMarketplaces, addMarketplace, removeMarketplace, updateMarketplace, installPlugin, uninstallPlugin, setPluginEnabled, updatePlugin, listPlugins } from "./plugins/manage.js";
56
56
  export type { PluginScope, PluginManagerOptions, MarketplaceInfo, InstalledPlugin, PluginListing } from "./plugins/manage.js";
package/dist/index.js CHANGED
@@ -139,7 +139,7 @@ class ProcessError extends WinterSDKError {
139
139
  class ResultError extends ProcessError {
140
140
  result;
141
141
  constructor(result) {
142
- super(result.terminal_reason === "api_error" ? `provider request failed: ${result.result ?? "unknown provider error"}` : `result error: ${result.subtype}`);
142
+ super(result.terminal_reason === "api_error" ? `provider request failed: ${result.result ?? "unknown provider error"}` : result.is_error === true && typeof result.terminal_reason === "string" && result.terminal_reason.length > 0 ? `${result.terminal_reason}: ${result.result ?? result.subtype}` : `result error: ${result.subtype}`);
143
143
  this.result = result;
144
144
  this.name = "ResultError";
145
145
  }
@@ -488,7 +488,8 @@ function buildRuntimeHooksConfig(hooks) {
488
488
  hookCount: group.hooks.length,
489
489
  ...group.timeout !== undefined ? { timeoutSec: group.timeout } : {},
490
490
  source: "sdk",
491
- ...hookNames.some((n) => n !== null) ? { hookNames } : {}
491
+ ...hookNames.some((n) => n !== null) ? { hookNames } : {},
492
+ ...group.failClosed === true ? { failClosed: true } : {}
492
493
  };
493
494
  });
494
495
  }
@@ -619,6 +620,7 @@ function query(args) {
619
620
  ...options.enableFileCheckpointing !== undefined ? { enableFileCheckpointing: options.enableFileCheckpointing } : {},
620
621
  ...options.contextWindowTokens !== undefined ? { contextWindowTokens: options.contextWindowTokens } : {},
621
622
  ...options.compactionThreshold !== undefined ? { compactionThreshold: options.compactionThreshold } : {},
623
+ ...options.promptCacheTtl !== undefined ? { promptCacheTtl: options.promptCacheTtl } : {},
622
624
  ...options.trustedWorkspace !== undefined ? { trustedWorkspace: options.trustedWorkspace } : {},
623
625
  ...options.plansDirectory !== undefined ? { plansDirectory: options.plansDirectory } : {},
624
626
  ...options.outputStyle !== undefined ? { outputStyle: options.outputStyle } : {},
@@ -630,6 +632,7 @@ function query(args) {
630
632
  ...options.includePartialMessages !== undefined ? { includePartialMessages: options.includePartialMessages } : {},
631
633
  ...options.maxBudgetUsd !== undefined ? { maxBudgetUsd: options.maxBudgetUsd } : {},
632
634
  ...options.providerStallTimeoutMs !== undefined ? { providerStallTimeoutMs: options.providerStallTimeoutMs } : {},
635
+ ...options.maxOutputTokens !== undefined ? { maxOutputTokens: options.maxOutputTokens } : {},
633
636
  ...brand.keychainService !== WINTER_BRAND2.keychainService || options.keychainService !== undefined ? { keychainService: brand.keychainService } : {},
634
637
  ...options.autoClassifier !== undefined ? { autoClassifier: options.autoClassifier } : {},
635
638
  ...options.advisor !== undefined ? { advisor: options.advisor } : {},
@@ -902,6 +905,14 @@ function query(args) {
902
905
  gen.setModel = async (model) => {
903
906
  await sendControlRequest("set_model", model !== undefined ? { model } : {});
904
907
  };
908
+ gen.setEffort = async (effort) => {
909
+ await sendControlRequest("set_effort", effort !== undefined ? { effort } : {});
910
+ };
911
+ gen.compact = async (opts) => {
912
+ const payload = await sendControlRequest("compact", opts?.customInstructions !== undefined ? { custom_instructions: opts.customInstructions } : {});
913
+ const retained = typeof payload === "object" && payload !== null ? payload.retained_count : undefined;
914
+ return { retainedCount: typeof retained === "number" ? retained : 0 };
915
+ };
905
916
  gen.supportedModels = async () => {
906
917
  const payload = await sendControlRequest("list_models", undefined);
907
918
  return Array.isArray(payload) ? payload : [];
@@ -1021,7 +1032,7 @@ function query(args) {
1021
1032
  return gen;
1022
1033
  }
1023
1034
  // src/version.ts
1024
- var SDK_VERSION = "0.0.23";
1035
+ var SDK_VERSION = "0.0.27";
1025
1036
  // src/paths/project-key.ts
1026
1037
  var TRANSCRIPT_PROJECT_KEY_MAX_LENGTH = 64;
1027
1038
  var VENDOR_PROJECT_KEY_PATTERN = /^[A-Za-z0-9_-]{1,64}$/;
package/dist/options.d.ts CHANGED
@@ -191,6 +191,15 @@ export interface Options {
191
191
  sessionStore?: SessionStore;
192
192
  contextWindowTokens?: number;
193
193
  compactionThreshold?: number;
194
+ /**
195
+ * WS-23 -- DISCLOSED WINTER option: how long the provider keeps this session's cached SYSTEM prompt.
196
+ * `"5m"` (the default, the vendor's own) or `"1h"` (written at twice the input price, worth it where
197
+ * idle gaps of 5-60 minutes are common: https://platform.claude.com/docs/en/build-with-claude/prompt-caching#1-hour-cache-duration).
198
+ * Applies to models whose catalog row documents prompt caching; the conversation's own rolling
199
+ * breakpoint stays at 5 minutes, which is the order the vendor requires (longer TTLs first). The
200
+ * host's choice; resolved runtime-side, so absent is byte-identical to before.
201
+ */
202
+ promptCacheTtl?: "5m" | "1h";
194
203
  trustedWorkspace?: boolean;
195
204
  plansDirectory?: string;
196
205
  outputStyle?: string;
@@ -269,6 +278,14 @@ export interface Options {
269
278
  maxBudgetUsd?: number;
270
279
  /** DISCLOSED WINTER option (R6-6): a stream silent for this long aborts as a typed `ProviderStallError`. Absent means DEFAULT_PROVIDER_STALL_TIMEOUT_MS. */
271
280
  providerStallTimeoutMs?: number;
281
+ /**
282
+ * DISCLOSED WINTER option (WS-23): the output-token ceiling (`max_tokens` on the Anthropic dialect)
283
+ * every main-loop generation asks for. Absent means the adapter's own default -- on a Claude row,
284
+ * 64000 capped at the row's declared maximum. A value above the row's maximum is refused typed,
285
+ * before the request. Forwarded as `TurnRequest.maxOutputTokens`, which an adapter treats as an
286
+ * explicit request (it wins over every default).
287
+ */
288
+ maxOutputTokens?: number;
272
289
  /** DISCLOSED WINTER option (R6-10): the macOS Keychain service every `{ kind: "keychain" }` ref resolves under. Absent means DEFAULT_KEYCHAIN_SERVICE. */
273
290
  keychainService?: string;
274
291
  /** DISCLOSED WINTER option (R6-14): the permission classifier's own model/credential, resolved through the SAME selection path as the session model. With none configured the worker serves only a `classifierEligible` model, else Manual fallback — never a silent weakening. */
@@ -167,10 +167,23 @@ export interface PermissionDeniedHookInput extends BaseHookInput {
167
167
  tool_use_id: string;
168
168
  reason: string;
169
169
  }
170
+ export interface SubagentStartHookInput extends BaseHookInput {
171
+ hook_event_name: "SubagentStart";
172
+ agent_id: string;
173
+ agent_type: string;
174
+ }
175
+ export interface SubagentStopHookInput extends BaseHookInput {
176
+ hook_event_name: "SubagentStop";
177
+ stop_hook_active: boolean;
178
+ agent_id: string;
179
+ agent_transcript_path: string;
180
+ agent_type: string;
181
+ last_assistant_message?: string;
182
+ }
170
183
  export interface GenericHookInput extends BaseHookInput {
171
184
  hook_event_name: string;
172
185
  }
173
- export type HookInput = PreToolUseHookInput | PostToolUseHookInput | PostToolUseFailureHookInput | UserPromptSubmitHookInput | StopHookInput | SessionStartHookInput | SessionEndHookInput | NotificationHookInput | PermissionRequestHookInput | PermissionDeniedHookInput | GenericHookInput;
186
+ export type HookInput = PreToolUseHookInput | PostToolUseHookInput | PostToolUseFailureHookInput | UserPromptSubmitHookInput | StopHookInput | SessionStartHookInput | SessionEndHookInput | NotificationHookInput | PermissionRequestHookInput | PermissionDeniedHookInput | SubagentStartHookInput | SubagentStopHookInput | GenericHookInput;
174
187
  export interface AsyncHookJSONOutput {
175
188
  async: true;
176
189
  asyncTimeout?: number;
@@ -203,6 +216,14 @@ export interface StopHookSpecificOutput {
203
216
  hookEventName: "Stop";
204
217
  additionalContext?: string;
205
218
  }
219
+ export interface SubagentStartHookSpecificOutput {
220
+ hookEventName: "SubagentStart";
221
+ additionalContext?: string;
222
+ }
223
+ export interface SubagentStopHookSpecificOutput {
224
+ hookEventName: "SubagentStop";
225
+ additionalContext?: string;
226
+ }
206
227
  export interface SessionStartHookSpecificOutput {
207
228
  hookEventName: "SessionStart";
208
229
  additionalContext?: string;
@@ -236,7 +257,7 @@ export interface GenericHookSpecificOutput {
236
257
  additionalContext?: string;
237
258
  [key: string]: unknown;
238
259
  }
239
- export type HookSpecificOutput = PreToolUseHookSpecificOutput | PostToolUseHookSpecificOutput | PostToolUseFailureHookSpecificOutput | UserPromptSubmitHookSpecificOutput | StopHookSpecificOutput | SessionStartHookSpecificOutput | NotificationHookSpecificOutput | PermissionRequestHookSpecificOutput | PermissionDeniedHookSpecificOutput | GenericHookSpecificOutput;
260
+ export type HookSpecificOutput = PreToolUseHookSpecificOutput | PostToolUseHookSpecificOutput | PostToolUseFailureHookSpecificOutput | UserPromptSubmitHookSpecificOutput | StopHookSpecificOutput | SubagentStartHookSpecificOutput | SubagentStopHookSpecificOutput | SessionStartHookSpecificOutput | NotificationHookSpecificOutput | PermissionRequestHookSpecificOutput | PermissionDeniedHookSpecificOutput | GenericHookSpecificOutput;
240
261
  export interface SyncHookJSONOutput {
241
262
  continue?: boolean;
242
263
  suppressOutput?: boolean;
@@ -255,6 +276,15 @@ export interface HookCallbackMatcher {
255
276
  matcher?: string;
256
277
  hooks: HookCallback[];
257
278
  timeout?: number;
279
+ /**
280
+ * WS-23: FAIL CLOSED. Default off, so a hook that errors stays a non-blocking error exactly as
281
+ * before. When true, and the event is `PreToolUse` or `PermissionRequest`, a callback that throws,
282
+ * times out or returns a malformed output DENIES the call, with a reason naming the hook -- the
283
+ * posture a SECURITY hook needs (a floor that crashes must not wave the call through). Every hook
284
+ * in this matcher shares it, like `timeout`. Ignored on every other event: none of them decides a
285
+ * call, so there is nothing for "closed" to mean there.
286
+ */
287
+ failClosed?: boolean;
258
288
  }
259
289
  export interface HookInvocationPayload {
260
290
  event: string;
@@ -78,6 +78,7 @@ export interface RuntimeHookMatcherGroup {
78
78
  timeoutSec?: number;
79
79
  source: HookSource;
80
80
  hookNames?: Array<string | null>;
81
+ failClosed?: boolean;
81
82
  }
82
83
  export type RuntimeHooksConfig = Partial<Record<string, RuntimeHookMatcherGroup[]>>;
83
84
  export interface SandboxSettingsConfig {
@@ -103,6 +104,22 @@ export interface McpServerToolPolicy {
103
104
  permission_policy?: "always_allow" | "always_ask" | "always_deny";
104
105
  org_max_permission?: "allow" | "ask" | "blocked";
105
106
  }
107
+ /**
108
+ * WS-23, WINTER-OWNED (no counterpart on the pinned official shape): how the runtime's MCP client
109
+ * negotiates the protocol revision with ONE server (MCP TS SDK v2, protocol revision 2026-07-28).
110
+ *
111
+ * - `"legacy"` -- the plain 2025 `initialize` handshake, byte-identical to the v1 client.
112
+ * - `"auto"` -- probe `server/discover` first; a server that offers 2026-07-28 gets the modern era,
113
+ * anything else falls back to `initialize`.
114
+ * - `{ pin: "<revision>" }` -- the modern era at exactly that revision, or the connect fails (typed).
115
+ *
116
+ * Absent means the per-transport default the runtime owns (`mcp/client.ts`'s
117
+ * `resolveVersionNegotiation`): `"auto"` for `http`, `"legacy"` for `stdio` and `sse`. The negotiated
118
+ * revision is reported per server on the `mcp_status` control response.
119
+ */
120
+ export type McpVersionNegotiation = "legacy" | "auto" | {
121
+ pin: string;
122
+ };
106
123
  export interface McpStdioServerConfig {
107
124
  type?: "stdio";
108
125
  command: string;
@@ -110,6 +127,7 @@ export interface McpStdioServerConfig {
110
127
  env?: Record<string, string>;
111
128
  timeout?: number;
112
129
  alwaysLoad?: boolean;
130
+ versionNegotiation?: McpVersionNegotiation;
113
131
  }
114
132
  export interface McpHttpServerConfig {
115
133
  type: "http";
@@ -118,6 +136,7 @@ export interface McpHttpServerConfig {
118
136
  tools?: McpServerToolPolicy[];
119
137
  timeout?: number;
120
138
  alwaysLoad?: boolean;
139
+ versionNegotiation?: McpVersionNegotiation;
121
140
  }
122
141
  export interface McpSSEServerConfig {
123
142
  type: "sse";
@@ -126,6 +145,7 @@ export interface McpSSEServerConfig {
126
145
  tools?: McpServerToolPolicy[];
127
146
  timeout?: number;
128
147
  alwaysLoad?: boolean;
148
+ versionNegotiation?: McpVersionNegotiation;
129
149
  }
130
150
  export interface WireMcpToolDefinition {
131
151
  name: string;
@@ -299,6 +319,8 @@ export interface RuntimeConfig {
299
319
  enableFileCheckpointing?: boolean;
300
320
  contextWindowTokens?: number;
301
321
  compactionThreshold?: number;
322
+ /** WS-23: the system prompt's cache lifetime (`Options.promptCacheTtl`); absent means the runtime's default, 5 minutes. */
323
+ promptCacheTtl?: "5m" | "1h";
302
324
  trustedWorkspace?: boolean;
303
325
  plansDirectory?: string;
304
326
  outputStyle?: string;
@@ -332,6 +354,8 @@ export interface RuntimeConfig {
332
354
  includePartialMessages?: boolean;
333
355
  maxBudgetUsd?: number;
334
356
  providerStallTimeoutMs?: number;
357
+ /** WS-23: `Options.maxOutputTokens`, carried to every main-loop `TurnRequest`. See its own doc. */
358
+ maxOutputTokens?: number;
335
359
  keychainService?: string;
336
360
  autoClassifier?: AutoClassifierConfig;
337
361
  advisor?: AdvisorConfig;
@@ -4,6 +4,7 @@ export declare const PROTOCOL_VERSION: "1.0";
4
4
  export interface WireMcpServerStatus {
5
5
  name: string;
6
6
  status: string;
7
+ protocolVersion?: string;
7
8
  }
8
9
  export interface InitFrame {
9
10
  type: "init";
@@ -82,6 +83,19 @@ export interface WireResultUsage {
82
83
  inference_geo: string;
83
84
  iterations: unknown[];
84
85
  speed: "standard" | "fast";
86
+ /**
87
+ * WS-23 -- WINTER-ONLY, additive, present only when there is something to say: each generation of
88
+ * this turn whose provider reported where its prompt prefix diverged from the previous request
89
+ * (Anthropic's `diagnostics.cache_miss_reason`: `type`, in Anthropic's own vocabulary only, and the
90
+ * estimated `missed_input_tokens` it cost), and/or that it dropped replayed thinking blocks
91
+ * (`thinking_blocks_dropped`, from `input_transformations` -- its own field, never a `type`). claude
92
+ * has no such field.
93
+ */
94
+ cache_misses?: Array<{
95
+ type?: string;
96
+ missed_input_tokens?: number;
97
+ thinking_blocks_dropped?: number;
98
+ }>;
85
99
  }
86
100
  export interface ControlCancelRequestFrame {
87
101
  type: "control_cancel_request";
@@ -582,8 +596,13 @@ export interface SDKContinuityWarningMessage {
582
596
  * ANOTHER provider for which no credential is configured (Ruling E-1 / R-E3) -- the child then
583
597
  * runs on a deferred-refusal provider whose first generation is R6-F's result with no request,
584
598
  * never the parent's provider with a foreign model id on the parent's wire.
599
+ *
600
+ * WS-23 (reasoning-state) adds three, each shown to the user by the host: `model_switch_lossy` at a
601
+ * switch whose loss class is `warned-lossy`; `switch_compaction` when the conversation is summarized
602
+ * before a switch to a model that cannot hold it; `reasoning_state_unsaved` when a turn's reasoning
603
+ * records could not be written after one retry (the thinking is then kept inline in the transcript).
585
604
  */
586
- warning: "provider_state_missing" | "provider_state_deleted" | "cross_domain_replay_dropped" | "sidecar_unreadable" | "child_provider_refused";
605
+ warning: "provider_state_missing" | "provider_state_deleted" | "cross_domain_replay_dropped" | "sidecar_unreadable" | "child_provider_refused" | "model_switch_lossy" | "switch_compaction" | "reasoning_state_unsaved";
587
606
  detail: string;
588
607
  anchor_uuid?: string;
589
608
  uuid: string;
@@ -607,6 +626,23 @@ export interface SDKSessionStateChangedMessage {
607
626
  session_id: string;
608
627
  [k: string]: unknown;
609
628
  }
629
+ /**
630
+ * WS-23: claude 2.1.282's `SDKInformationalMessage` -- "generic text banner emitted by the loop --
631
+ * non-error status lines, hook feedback (e.g. a UserPromptSubmit hook's block reason)". Winter had no
632
+ * text-notice frame at all; this is the one a hook's `systemMessage`, a blocked prompt's reason and a
633
+ * hook's `continue: false` ride to the host. `prevent_continuation` is set when the notice is the
634
+ * reason the turn is ending.
635
+ */
636
+ export interface SDKInformationalMessage {
637
+ type: "system";
638
+ subtype: "informational";
639
+ content: string;
640
+ level: "info" | "notice" | "suggestion" | "warning";
641
+ tool_use_id?: string;
642
+ prevent_continuation?: boolean;
643
+ uuid: string;
644
+ session_id: string;
645
+ }
610
646
  export type SdkMessage = {
611
647
  type: "system";
612
648
  subtype: "init";
@@ -631,7 +667,7 @@ export type SdkMessage = {
631
667
  */
632
668
  agents?: string[];
633
669
  [k: string]: unknown;
634
- } | SDKHookStartedMessage | SDKHookProgressMessage | SDKHookResponseMessage | SDKPermissionDeniedMessage | SDKStatusMessage | SDKCompactBoundaryMessage | SDKSessionStateChangedMessage | BackgroundTaskMessage | SDKPartialAssistantMessage | SDKAPIRetryMessage | SDKRateLimitEvent | SDKAuthStatusMessage | SDKThinkingTokensMessage | SDKModelRefusalFallbackMessage | SDKModelRefusalNoFallbackMessage | SDKReasoningSummaryMessage | SDKModelSwitchMessage | SDKContinuityWarningMessage | {
670
+ } | SDKHookStartedMessage | SDKHookProgressMessage | SDKHookResponseMessage | SDKPermissionDeniedMessage | SDKStatusMessage | SDKCompactBoundaryMessage | SDKSessionStateChangedMessage | SDKInformationalMessage | BackgroundTaskMessage | SDKPartialAssistantMessage | SDKAPIRetryMessage | SDKRateLimitEvent | SDKAuthStatusMessage | SDKThinkingTokensMessage | SDKModelRefusalFallbackMessage | SDKModelRefusalNoFallbackMessage | SDKReasoningSummaryMessage | SDKModelSwitchMessage | SDKContinuityWarningMessage | {
635
671
  type: "assistant";
636
672
  message: {
637
673
  content: Array<{
@@ -661,7 +697,7 @@ export type SdkMessage = {
661
697
  is_error?: boolean;
662
698
  result?: string;
663
699
  structured_output?: unknown;
664
- terminal_reason?: "structured_output_retry_exhausted" | "api_error" | string;
700
+ terminal_reason?: "structured_output_retry_exhausted" | "api_error" | "refusal" | "prompt_too_long" | "pause_turn_limit" | string;
665
701
  api_error_status?: number | null;
666
702
  /** THIS turn's main-loop usage -- claude's `result.usage` (dist-session fixes C1); see `WireResultUsage`. */
667
703
  usage?: WireResultUsage;
package/dist/query.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { SdkMessage as RuntimeSdkMessage } from "./protocol/frames.js";
2
- import type { AccountInfo, AgentInfo, ModelInfo, ModelFamilyListing, RewindFilesResult } from "./protocol/config.js";
2
+ import type { AccountInfo, AgentInfo, EffortLevel, ModelInfo, ModelFamilyListing, RewindFilesResult } from "./protocol/config.js";
3
3
  import { type Options } from "./options.js";
4
4
  import type { PermissionMode, PermissionResult } from "./permissions/types.js";
5
5
  import { type DeliveryOutcome, type GlobalAgentMessage, type ListedRuntimeObject, type PermissionClassLabel } from "./messaging/index.js";
@@ -118,6 +118,36 @@ export interface SessionMessagingFacet {
118
118
  export interface Query extends AsyncGenerator<SdkMessage> {
119
119
  interrupt(): Promise<void>;
120
120
  setModel(model?: string): Promise<void>;
121
+ /**
122
+ * WS-23 -- WINTER-ONLY, additive: change the session's effort level while it runs. Applied at the
123
+ * next quiescent boundary (immediately when idle), exactly like `setModel`. Omitted, `null` or
124
+ * `'default'` resets to the level the session started with.
125
+ *
126
+ * On a model whose catalog row documents per-message effort (Claude Fable 5.1, Opus 5.5, Opus 5)
127
+ * the change rides a mid-conversation `system` message and the cached prompt prefix survives it;
128
+ * elsewhere it is a new top-level value, which restarts the provider's prompt cache. A level the
129
+ * current model does not document rejects with an `invalid_effort` error.
130
+ *
131
+ * claude 2.1.282 has no method for this (it changes effort through its `apply_flag_settings`
132
+ * control request); it rides Winter's own `set_effort` control subtype.
133
+ */
134
+ setEffort(effort?: EffortLevel | null): Promise<void>;
135
+ /**
136
+ * WS-23 -- WINTER-ONLY, additive: compact the conversation NOW, on the model the session is live on,
137
+ * and resolve once it has finished (`retainedCount`: the messages kept beside the summary). A host
138
+ * calls it before a switch to another provider whose model cannot hold the conversation, so the model
139
+ * being left writes the summary. Rejects with `busy` while a turn (or another compaction) runs, and
140
+ * with `compaction_failed` when there was nothing to compact or the summarizer failed.
141
+ *
142
+ * OPTIONAL on the interface (every `Query` this package returns has it): a host's own structural
143
+ * `Query` double -- the router's test peers, a daemon's fakes -- keeps type-checking without it, and a
144
+ * caller checks for it before calling.
145
+ */
146
+ compact?(opts?: {
147
+ customInstructions?: string;
148
+ }): Promise<{
149
+ retainedCount: number;
150
+ }>;
121
151
  /**
122
152
  * Phase 6 Task 10 (derived-shapes-p6 item (d), `sdk.d.ts:2566`): the models this session may select.
123
153
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yanlinglabs/winter-agent-sdk",
3
- "version": "0.0.23",
3
+ "version": "0.0.27",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "engines": {
@@ -45,15 +45,15 @@
45
45
  }
46
46
  },
47
47
  "dependencies": {
48
- "@yanlinglabs/winter-provider-catalog": "0.0.23"
48
+ "@yanlinglabs/winter-provider-catalog": "0.0.27"
49
49
  },
50
50
  "optionalDependencies": {
51
- "@yanlinglabs/winter-agent-sdk-darwin-arm64": "0.0.23"
51
+ "@yanlinglabs/winter-agent-sdk-darwin-arm64": "0.0.27"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@types/node": "^26.4.0",
55
- "@yanlinglabs/winter-conformance": "0.0.23",
56
- "winter-agent-runtime": "0.0.23"
55
+ "@yanlinglabs/winter-agent-runtime": "0.0.27",
56
+ "@yanlinglabs/winter-conformance": "0.0.27"
57
57
  },
58
58
  "scripts": {}
59
59
  }