@yanlinglabs/winter-agent-sdk 0.0.15 → 0.0.16

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/README.md CHANGED
@@ -68,6 +68,57 @@ plus two canonical standing-server twins, and `@yanlinglabs/winter-runtime-sdk`
68
68
  definitions under Claude's built-in names. Handlers return `{ text, isError? }` for each host to
69
69
  wrap in its own result shape.
70
70
 
71
+ ## Environment variables and settings
72
+
73
+ The runtime child reads a handful of environment variables at spawn/per-turn, plus a few
74
+ `Options`/`RuntimeConfig` fields. Every variable name below is `WINTER_`-prefixed for Winter's own
75
+ build (`BrandProfile.envPrefix`); a rebranded host reads the identical suffix under its own prefix.
76
+
77
+ | Variable | Default | Effect |
78
+ | --- | --- | --- |
79
+ | `WINTER_DISABLE_BACKGROUND_TASKS` | off | A hard kill switch with two effects together: it drops `run_in_background` from the Agent tool's own advertised schema entirely, and it forces every subagent spawn to the foreground unconditionally (outranking a definition's own `background: true`, a fork, and an explicit `run_in_background: true` alike). |
80
+ | `WINTER_BACKGROUND_BY_DEFAULT` | on (background) | A softer opt-out than the kill switch above: a falsy value (`0`/`false`/`no`/`off`, case-insensitive) restores the pre-0.0.16 default (an unflagged spawn runs in the FOREGROUND) without removing `run_in_background` from the schema — the model can still ask for either explicitly either way. `Options.backgroundByDefault` (see below) wins over this variable in either direction when both are set. |
81
+ | `WINTER_PRINT_BG_WAIT_CEILING_MS` | `600000` (10 minutes) | How long a closed-input session holds its result for a still-running background agent/workflow before sweeping it as stopped. `0` waits indefinitely. |
82
+ | `WINTER_EMIT_SESSION_STATE_EVENTS` | off | Truthy (`1`/`true`) emits `system/session_state_changed` frames (`running`/`idle`) as a turn starts and ends. Absent, the frame stream is unchanged from before this existed. |
83
+ | `WINTER_DISABLE_GIT_INSTRUCTIONS` | off | Truthy disables the git status/instructions section of the system prompt outright, overriding `Settings.includeGitInstructions` in either direction. A falsy value (`0`/`false`/`no`/`off`) explicitly re-enables it even when the setting says otherwise. |
84
+ | `WINTER_DISABLE_EXPLORE_INHERIT_CAP` | off | Truthy opts a first-party Anthropic session out of the Explore built-in's own model cap (which otherwise caps a Fable-tier session's Explore spawn down to Opus). |
85
+ | `WINTER_FORK_SUBAGENT` | off | Truthy enables `subagent_type: "fork"` for the session (mirrors `CLAUDE_CODE_FORK_SUBAGENT`). `Options.forkSubagent` (below) wins over this variable in either direction. |
86
+ | `WINTER_WEB_FETCH_AGENT` | off | Truthy makes the `web-fetch` built-in agent type available (off by default, like claude's own). |
87
+ | `WINTER_AGENT_SDK_DISABLE_BUILTIN_AGENTS` | off | Truthy withholds every built-in `subagent_type` (gated or not) for the session. |
88
+ | `WINTER_DISABLE_EXPLORE_PLAN_AGENTS` | off | Truthy withholds the `Explore` and `Plan` built-ins together. |
89
+ | `WINTER_DISABLE_AGENT_VIEW` | off | Truthy withholds the `claude` catch-all built-in (mirrors `CLAUDE_CODE_DISABLE_AGENT_VIEW`). |
90
+ | `WINTER_MAX_SUBAGENT_SPAWN_DEPTH` | `3` | How many levels of subagent nesting are allowed beneath the top-level session before a spawn is refused. |
91
+ | `WINTER_MAX_CONCURRENT_SUBAGENTS` | `20` | How many subagents may run at once (across the whole nesting tree) before a spawn is refused. |
92
+
93
+ A handful of `Options`/settings fields carry the same weight as their env counterparts, and a
94
+ RuntimeConfig field always wins over its own env fallback in either direction when both are set:
95
+
96
+ - **`Settings.includeGitInstructions`** (default `true`) — the setting `WINTER_DISABLE_GIT_INSTRUCTIONS` overrides above.
97
+ - **`Options.forkSubagent`** (`boolean`, default unset → env fallback) — the RuntimeConfig field behind `WINTER_FORK_SUBAGENT`.
98
+ - **`Options.backgroundByDefault`** (`boolean`, default unset → env fallback) — the RuntimeConfig field behind `WINTER_BACKGROUND_BY_DEFAULT`, above.
99
+
100
+ `RuntimeConfig.allowedAgentTypes` (`string[]`) is a different shape of field, not a host-settable
101
+ one: there is no `Options.allowedAgentTypes` and no env fallback to win over. It exists only on the
102
+ wire `RuntimeConfig`, and the engine — never a host — populates it: when a running agent's own
103
+ definition restricts `tools` with an `Agent(a, b)` entry, `allowedAgentTypesFromTools` parses that
104
+ restriction and threads the resulting list onto the CHILD it spawns for that agent's own
105
+ `RuntimeConfig`, so the child's listing / `init.agents` / Agent-tool resolution sees only `[a, b]`,
106
+ never the full universe of types its parent session could otherwise reach. Absent (every top-level
107
+ session, and any child whose parent definition named no `Agent(...)` restriction) means
108
+ unrestricted, the behavior every session had before this field existed.
109
+
110
+ ### The 0.0.16 background-default change
111
+
112
+ Before 0.0.16, an Agent tool call with no `run_in_background` ran in the **foreground** (this call
113
+ does not return until the spawned agent finishes). From 0.0.16 on, matching claude, the same
114
+ unflagged call runs in the **background** by default: the call returns immediately with a task id,
115
+ and the model is told about the result later as a task notification (mid-turn, or as its own
116
+ unsolicited turn). `run_in_background: false` still asks for the old, synchronous behavior on any
117
+ one call. A host that wants the *default* itself to stay foreground — without losing the
118
+ `run_in_background` field or forcing every call to name it explicitly — sets
119
+ `Options.backgroundByDefault: false` (or `WINTER_BACKGROUND_BY_DEFAULT=false`); the kill switch,
120
+ `WINTER_DISABLE_BACKGROUND_TASKS`, is unrelated and unaffected by this knob in either direction.
121
+
71
122
  ## License
72
123
 
73
124
  MIT — see [`LICENSE`](./LICENSE), which ships in the published tarball.
package/dist/index.d.ts CHANGED
@@ -24,7 +24,7 @@ export { SDK_VERSION } from "./version.js";
24
24
  export { MESSAGING_CONTROL_SUBTYPES, MESSAGING_CONTROL_SUBTYPE_LIST, MESSAGING_HOST_REQUEST_SUBTYPES, MESSAGING_RUNTIME_REQUEST_SUBTYPES, resolveFacetTarget } from "./protocol/messaging.js";
25
25
  export { isRuntimeAddress, isGlobalAgentMessage, isDeliveryOutcome, isListedRuntimeObjectArray, isPermissionClassLabel, isMessagingDeliverRequest, isMessagingChildRequest, isMessagingSubscribeIdleRequest, isMessagingReadNotificationsRequest, isMessagingNotificationsPage, isMessagingIdleNoticePayload, isNotificationRecord, } from "./protocol/messaging.js";
26
26
  export type { MessagingControlSubtype, MessagingDeliverRequest, MessagingChildRequest, MessagingSubscribeIdleRequest, MessagingSenderClassResponse, MessagingReadNotificationsRequest, MessagingNotificationsPage, MessagingIdleNoticePayload, } from "./protocol/messaging.js";
27
- export type { ProtocolVersion, WinterFrame, SdkMessage as ProtocolSdkMessage, InitFrame, UserFrame, DataFrame, ControlRequestFrame, ControlResponseFrame, UnknownFrame, SDKHookStartedMessage, SDKHookProgressMessage, SDKHookResponseMessage, SDKPermissionDeniedMessage, SDKPermissionDenial, SDKTaskStartedMessage, SDKTaskNotificationMessage, SDKTaskUpdatedMessage, SDKTaskProgressMessage, SDKBackgroundTasksChangedMessage, SDKLocalCommandOutputMessage, BackgroundTaskMessage, SDKCompactBoundaryMessage, WireContentBlock, WireStreamEvent, WireStreamEventDelta, SDKPartialAssistantMessage, SDKAssistantMessageError, SDKAPIRetryMessage, SDKRateLimitEvent, SDKRateLimitInfo, SDKAuthStatusMessage, SDKThinkingTokensMessage, SDKModelRefusalFallbackMessage, SDKModelRefusalNoFallbackMessage, SDKReasoningSummaryMessage, SDKModelSwitchMessage, SDKContinuityWarningMessage, } from "./protocol/frames.js";
27
+ export type { ProtocolVersion, WinterFrame, SdkMessage as ProtocolSdkMessage, InitFrame, UserFrame, DataFrame, ControlRequestFrame, ControlResponseFrame, 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";
28
28
  export { resolveWinterHome, resolveKeychainServiceForProfile, isUnset } from "./paths/home.js";
29
29
  export { transcriptProjectKey, TRANSCRIPT_PROJECT_KEY_MAX_LENGTH, isVendorCompliantProjectKey } from "./paths/project-key.js";
30
30
  export { compatibilityKeys } from "./paths/keys.js";
package/dist/index.js CHANGED
@@ -579,6 +579,7 @@ function query(args) {
579
579
  ...options.agents !== undefined ? { agents: options.agents } : {},
580
580
  ...options.forwardSubagentText !== undefined ? { forwardSubagentText: options.forwardSubagentText } : {},
581
581
  ...options.forkSubagent !== undefined ? { forkSubagent: options.forkSubagent } : {},
582
+ ...options.backgroundByDefault !== undefined ? { backgroundByDefault: options.backgroundByDefault } : {},
582
583
  ...options.systemPrompt !== undefined ? { systemPrompt: options.systemPrompt } : {},
583
584
  ...options.plugins !== undefined ? { plugins: options.plugins } : {},
584
585
  ...options.skills !== undefined ? { skills: options.skills } : {},
@@ -966,7 +967,7 @@ function query(args) {
966
967
  return gen;
967
968
  }
968
969
  // src/version.ts
969
- var SDK_VERSION = "0.0.15";
970
+ var SDK_VERSION = "0.0.16";
970
971
  // src/paths/project-key.ts
971
972
  var TRANSCRIPT_PROJECT_KEY_MAX_LENGTH = 64;
972
973
  var VENDOR_PROJECT_KEY_PATTERN = /^[A-Za-z0-9_-]{1,64}$/;
package/dist/options.d.ts CHANGED
@@ -103,6 +103,21 @@ export interface Options {
103
103
  * `CLAUDE_CODE_FORK_SUBAGENT`), and is off when that is unset.
104
104
  */
105
105
  forkSubagent?: boolean;
106
+ /**
107
+ * I4 (fix wave): a programmatic opt-out for the Agent tool's own background default (SDK 0.0.16,
108
+ * `subagents/policy.ts`'s `resolveForegroundBackground` -- "background unless `run_in_background`
109
+ * is explicitly false"). `false` restores the 0.0.15 default (foreground) for every spawn this
110
+ * knob's stage of the chain decides; `true` is the 0.0.16 default, spelled out. Omitted = the
111
+ * runtime reads `WINTER_BACKGROUND_BY_DEFAULT` (falsy -- "0"/"false"/"no"/"off" -- restores
112
+ * foreground; anything else, including absent, keeps background), the SAME `forkSubagent`
113
+ * precedent: the field wins in either direction, the env is only the fallback.
114
+ *
115
+ * Distinct from `WINTER_DISABLE_BACKGROUND_TASKS` (which keeps its own, unrelated meaning -- a
116
+ * hard kill switch that ALSO removes `run_in_background` from the advertised schema entirely):
117
+ * this knob changes only which way an OMITTED `run_in_background` resolves, and the field stays
118
+ * on the schema either way.
119
+ */
120
+ backgroundByDefault?: boolean;
106
121
  onElicitation?: (request: {
107
122
  serverName: string;
108
123
  message: string;
@@ -197,6 +197,14 @@ export interface RuntimeAgentDefinition {
197
197
  * every pre-existing definition's context, unchanged.
198
198
  */
199
199
  omitProjectContext?: boolean;
200
+ /**
201
+ * SDK 0.0.16 Lane P (R3b §5): claude's `whenToUseLean` -- used in place of `description` in the
202
+ * Agent-tool listing when the session's own model takes the lean prompt (`leanModel`, computed
203
+ * by `context/agent-listing.ts`'s own caller). Set only on Winter's built-in Explore; every other
204
+ * definition (Winter's own, or a filesystem/programmatic one) has none, and the listing falls
205
+ * back to `description` exactly as it always has.
206
+ */
207
+ whenToUseLean?: string;
200
208
  }
201
209
  export interface RuntimeConfig {
202
210
  sessionId: string;
@@ -240,6 +248,16 @@ export interface RuntimeConfig {
240
248
  toolAliases?: Record<string, string>;
241
249
  agents?: Record<string, RuntimeAgentDefinition>;
242
250
  forwardSubagentText?: boolean;
251
+ /**
252
+ * SDK 0.0.16 Lane P (R3b §4): the RUNNING agent's own `Agent(a, b)` restriction, parsed from its
253
+ * `AgentDefinition.tools` entries by `subagents/definitions.ts`'s own `allowedAgentTypesFromTools`
254
+ * and threaded onto a CHILD's own RuntimeConfig at spawn (`child-engine.ts`) -- so a session
255
+ * spawned from a definition with `tools: ["*", "Agent(Explore, Plan)"]` sees only [Explore, Plan]
256
+ * in ITS OWN listing / `init.agents` / Agent-tool resolution, never the full universe of types
257
+ * this session could otherwise reach. Absent = unrestricted, the pre-existing behaviour every
258
+ * session before this field existed keeps. Pure passthrough; query.ts never interprets it.
259
+ */
260
+ allowedAgentTypes?: string[];
243
261
  agentId?: string;
244
262
  isolationPinnedCwd?: boolean;
245
263
  /**
@@ -254,6 +272,13 @@ export interface RuntimeConfig {
254
272
  * a forked worker may not fork again (claude's own refusal). Never set by `query()`.
255
273
  */
256
274
  insideFork?: boolean;
275
+ /**
276
+ * I4 (fix wave): mirrors `Options.backgroundByDefault` exactly -- see that field's own comment.
277
+ * `subagents/policy.ts`'s `resolveForegroundBackground` reads it at its own stage 5, AFTER the
278
+ * `WINTER_DISABLE_BACKGROUND_TASKS` kill switch (stage 2, unrelated and unaffected) and the
279
+ * invocation's own explicit `run_in_background` (stage 4, always wins when given).
280
+ */
281
+ backgroundByDefault?: boolean;
257
282
  systemPrompt?: SystemPromptOption;
258
283
  plugins?: SdkPluginConfig[];
259
284
  skills?: SkillsOption;
@@ -544,6 +544,24 @@ export interface SDKContinuityWarningMessage {
544
544
  uuid: string;
545
545
  session_id: string;
546
546
  }
547
+ /**
548
+ * SDK 0.0.16 Lane N: `notifySessionStateChanged` (pinned `sdk.d.ts`: "Mirrors notifySessionStateChanged.
549
+ * 'idle' fires after heldBackResult flushes and the bg-agent do-while exits -- authoritative turn-over
550
+ * signal"). ENV-GATED on both runtimes: the pinned binary emits it only under
551
+ * `CLAUDE_CODE_EMIT_SESSION_STATE_EVENTS`, Winter only under `WINTER_EMIT_SESSION_STATE_EVENTS`, so a
552
+ * default session's frame stream is byte-identical with or without this variant existing.
553
+ *
554
+ * `requires_action` is declared (it is in the pinned union) but has no Winter producer: Winter's
555
+ * approval prompts ride `control_request`, not a session-state transition.
556
+ */
557
+ export interface SDKSessionStateChangedMessage {
558
+ type: "system";
559
+ subtype: "session_state_changed";
560
+ state: "idle" | "running" | "requires_action";
561
+ uuid: string;
562
+ session_id: string;
563
+ [k: string]: unknown;
564
+ }
547
565
  export type SdkMessage = {
548
566
  type: "system";
549
567
  subtype: "init";
@@ -568,7 +586,7 @@ export type SdkMessage = {
568
586
  */
569
587
  agents?: string[];
570
588
  [k: string]: unknown;
571
- } | SDKHookStartedMessage | SDKHookProgressMessage | SDKHookResponseMessage | SDKPermissionDeniedMessage | SDKStatusMessage | SDKCompactBoundaryMessage | BackgroundTaskMessage | SDKPartialAssistantMessage | SDKAPIRetryMessage | SDKRateLimitEvent | SDKAuthStatusMessage | SDKThinkingTokensMessage | SDKModelRefusalFallbackMessage | SDKModelRefusalNoFallbackMessage | SDKReasoningSummaryMessage | SDKModelSwitchMessage | SDKContinuityWarningMessage | {
589
+ } | SDKHookStartedMessage | SDKHookProgressMessage | SDKHookResponseMessage | SDKPermissionDeniedMessage | SDKStatusMessage | SDKCompactBoundaryMessage | SDKSessionStateChangedMessage | BackgroundTaskMessage | SDKPartialAssistantMessage | SDKAPIRetryMessage | SDKRateLimitEvent | SDKAuthStatusMessage | SDKThinkingTokensMessage | SDKModelRefusalFallbackMessage | SDKModelRefusalNoFallbackMessage | SDKReasoningSummaryMessage | SDKModelSwitchMessage | SDKContinuityWarningMessage | {
572
590
  type: "assistant";
573
591
  message: {
574
592
  content: Array<{
@@ -76,6 +76,11 @@ export interface Settings {
76
76
  skillListingMaxDescChars?: number;
77
77
  /** `sdk.d.ts:5503`. The listing's share of the context window (default 0.01). */
78
78
  skillListingBudgetFraction?: number;
79
+ /**
80
+ * `sdk.d.ts:5539`. SDK 0.0.16: whether the systemContext `gitStatus` snapshot is sent (default
81
+ * true). `<PREFIX>DISABLE_GIT_INSTRUCTIONS` overrides it either way.
82
+ */
83
+ includeGitInstructions?: boolean;
79
84
  /**
80
85
  * A settings-tier MCP server block. Deliberately `Record<string, unknown>` rather than a typed
81
86
  * server union: `settings/loaders/mcp-config.ts` validates each entry and `resolveMcpServerSources`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yanlinglabs/winter-agent-sdk",
3
- "version": "0.0.15",
3
+ "version": "0.0.16",
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.15"
48
+ "@yanlinglabs/winter-provider-catalog": "0.0.16"
49
49
  },
50
50
  "optionalDependencies": {
51
- "@yanlinglabs/winter-agent-sdk-darwin-arm64": "0.0.15"
51
+ "@yanlinglabs/winter-agent-sdk-darwin-arm64": "0.0.16"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@types/node": "^26.4.0",
55
- "@yanlinglabs/winter-conformance": "0.0.15",
56
- "winter-agent-runtime": "0.0.15"
55
+ "winter-agent-runtime": "0.0.16",
56
+ "@yanlinglabs/winter-conformance": "0.0.16"
57
57
  },
58
58
  "scripts": {}
59
59
  }