@yanlinglabs/winter-agent-runtime 0.0.34 → 0.0.36

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.
@@ -1,4 +1,4 @@
1
- import"./index-rprst8z5.js";
1
+ import"./index-c8j57y8v.js";
2
2
  import {
3
3
  liveProcessGroups,
4
4
  onProcessGroupChange
@@ -6,10 +6,10 @@ import {
6
6
  import"./index-mwew595z.js";
7
7
  import"./index-2wgfv0pa.js";
8
8
  import"./index-bef62z3r.js";
9
- import"./index-dske1c00.js";
9
+ import"./index-83p1g9ap.js";
10
10
  import {
11
11
  runEmbeddedSession2
12
- } from "./index-1bcfabm4.js";
12
+ } from "./index-1nhzy5e2.js";
13
13
  import {
14
14
  Queue
15
15
  } from "./index-97t2rmtf.js";
package/dist/embedded.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  runEmbeddedSession2
3
- } from "./index-1bcfabm4.js";
4
- import"./index-dske1c00.js";
5
- import"./index-rprst8z5.js";
3
+ } from "./index-1nhzy5e2.js";
4
+ import"./index-83p1g9ap.js";
5
+ import"./index-c8j57y8v.js";
6
6
  import"./index-2wgfv0pa.js";
7
7
  import"./index-bef62z3r.js";
8
8
  import"./index-1hef2gff.js";
package/dist/engine.d.ts CHANGED
@@ -25,6 +25,7 @@ import { type HookAuditRecord } from "./hooks/runner.js";
25
25
  import { type DurableApprovalStore } from "./permissions/approvals.js";
26
26
  import "./tools/descriptors/index.ts";
27
27
  import "./tools/impl/index.ts";
28
+ import { type ToolResultBlock } from "./tools/registry.js";
28
29
  import { type ResolvedReviewer } from "./tools/impl/advisor.js";
29
30
  import type { AuxiliaryModelResolution } from "./provider/session-provider.js";
30
31
  import type { ToolSecretResolver } from "./provider/tool-secret.js";
@@ -416,6 +417,12 @@ export declare class ProviderTurnError extends Error {
416
417
  * the engine answers it with one reactive compaction and one retry. `undefined` for any other failure.
417
418
  */
418
419
  readonly contextOverflow: true | undefined;
420
+ /**
421
+ * Code-mode images: the provider refused the request for its IMAGES (too many, or past a many-image
422
+ * size limit). The engine answers it with ONE retry that sends every image but the newest as a note
423
+ * (`imagesOnlyNewest`), sticky for the rest of the run. `undefined` for any other failure.
424
+ */
425
+ readonly imageOverflow: true | undefined;
419
426
  constructor(message: string, opts?: {
420
427
  status?: number;
421
428
  providerCode?: string;
@@ -423,6 +430,7 @@ export declare class ProviderTurnError extends Error {
423
430
  retryable?: boolean;
424
431
  committed?: boolean;
425
432
  contextOverflow?: true;
433
+ imageOverflow?: true;
426
434
  cause?: unknown;
427
435
  });
428
436
  }
@@ -528,6 +536,17 @@ export declare function inStreamOrder(turn: ProviderTurn): ContentBlock[] | unde
528
536
  * so a host that renders "thinking…" or "[redacted]" keeps working.
529
537
  */
530
538
  export declare function contentForHost(content: ContentBlock[]): ContentBlock[];
539
+ /**
540
+ * Code-mode images: a tool round's results as the HOST sees them on the `user` frame -- every image block
541
+ * (top level or inside a `tool_result`) keeps its shape and `media_type` and loses its bytes: `data`
542
+ * becomes `""`. The bytes exist for one reader, the provider on the next request, and they reach it from
543
+ * the engine's history and the session transcript. The frame is one NDJSON line on the child's stdout, and
544
+ * the host SDK bounds an unterminated line at `maxBufferSize` (1 MiB by default, `sdk/src/query.ts`): an
545
+ * image Read's base64 (up to ~5.2 MB) would end the session with a `ProtocolDecodeError`. A host that
546
+ * renders "[image]" keeps working, and the transcript (which the host can read) holds the real bytes.
547
+ * Everything else is returned by identity.
548
+ */
549
+ export declare function toolResultsForHost(content: ContentBlock[]): ContentBlock[];
531
550
  /**
532
551
  * Phase 6 (R6-9), widened by the fix wave: the session's RESOLVED provider identity as the engine
533
552
  * carries it -- the `MessageOrigin` half every `origin` record and `providerAnnotations` read, plus
@@ -663,6 +682,7 @@ export interface ToolExecutor {
663
682
  explicitApproval?: "prompt" | "rule";
664
683
  }): Promise<{
665
684
  output: string;
685
+ blocks?: ToolResultBlock[];
666
686
  isError?: boolean;
667
687
  }>;
668
688
  }
@@ -9,14 +9,14 @@ import {
9
9
  resolveEngineSession2,
10
10
  resolveProductionWinterHome2,
11
11
  resolveProductionStoreHome
12
- } from "./index-rprst8z5.js";
12
+ } from "./index-c8j57y8v.js";
13
13
  import {
14
14
  registerDefaultChildEngineFactory,
15
15
  loadResumedChain,
16
16
  buildProductionWiring,
17
17
  withAutoSkillPermissions,
18
18
  restoreChildRoster
19
- } from "./index-dske1c00.js";
19
+ } from "./index-83p1g9ap.js";
20
20
 
21
21
  // src/embedded.ts
22
22
  import { splitFrames, encodeFrame } from "@yanlinglabs/winter-agent-sdk";
@@ -15,6 +15,10 @@ import {
15
15
  mcpServerHasRegistrations,
16
16
  STRUCTURED_OUTPUT_TOOL_NAME,
17
17
  looksLikeCommand,
18
+ matchFileRule,
19
+ resolveFileRuleAbsolutePath,
20
+ resolveFileRuleAbsoluteGlobText,
21
+ resolvesWithinPluginRoot,
18
22
  capBytes,
19
23
  neutralizeReminderTags,
20
24
  readWhole,
@@ -22,12 +26,8 @@ import {
22
26
  registerAttachmentRenderer,
23
27
  attachmentsIn,
24
28
  registerChildEngineFactory,
25
- matchFileRule,
26
29
  rawToRuleValue,
27
30
  sourceRule,
28
- resolveFileRuleAbsolutePath,
29
- resolveFileRuleAbsoluteGlobText,
30
- resolvesWithinPluginRoot,
31
31
  parseFrontmatter,
32
32
  parseAgentDefinitionFile,
33
33
  allowedAgentTypesFromTools,
@@ -85,7 +85,7 @@ import {
85
85
  providerCredentialRef2,
86
86
  createModelClassifier2,
87
87
  selectClassifierRoute2
88
- } from "./index-rprst8z5.js";
88
+ } from "./index-c8j57y8v.js";
89
89
  import {
90
90
  createKeychainCredentialStore,
91
91
  createKeychainSecretReader,
@@ -1264,7 +1264,7 @@ function createToolSecretResolver(deps) {
1264
1264
  }
1265
1265
 
1266
1266
  // src/provider/bridge.ts
1267
- import { normalizeThrown, shouldRequestSummary, stripOpaque } from "@yanlinglabs/winter-provider-runtime";
1267
+ import { imageBudgetFor, normalizeThrown, shouldRequestSummary, stripOpaque, withinImageBudget } from "@yanlinglabs/winter-provider-runtime";
1268
1268
  function createIdentityHistoryRenderer() {
1269
1269
  return {
1270
1270
  render(messages, _chain, target) {
@@ -1299,9 +1299,14 @@ function adapterAsProvider(resolved, ctx, opts = {}) {
1299
1299
  modelKey: resolved.modelKey,
1300
1300
  ...Array.isArray(resolved.descriptor?.inputModalities?.value) ? { readsImages: resolved.descriptor.inputModalities.value.includes("image") } : {}
1301
1301
  };
1302
+ const imageBudget = imageBudgetFor({
1303
+ family: adapter.family,
1304
+ providerId: resolved.providerId,
1305
+ ...typeof resolved.descriptor?.contextWindow?.value === "number" ? { contextWindow: resolved.descriptor.contextWindow.value } : {}
1306
+ });
1302
1307
  return {
1303
1308
  async generate(input) {
1304
- const rendered = renderer.render(input.messages, opts.chain?.() ?? new Map, target);
1309
+ const rendered = withinImageBudget(renderer.render(input.messages, opts.chain?.() ?? new Map, target), imageBudget);
1305
1310
  const request = {
1306
1311
  model: input.model === undefined || input.model === resolved.modelKey ? resolved.providerModelId : input.model,
1307
1312
  messages: rendered,
@@ -1452,7 +1457,7 @@ async function foldProviderStream(stream, sink) {
1452
1457
  emitter.messageStop(event.stopReason);
1453
1458
  break;
1454
1459
  case "error":
1455
- throw providerErrorToTurnError(event.error, committed && !(event.error.contextOverflow === true && ordered.length === 0));
1460
+ throw providerErrorToTurnError(event.error, committed && !((event.error.contextOverflow === true || event.error.imageOverflow === true) && ordered.length === 0));
1456
1461
  }
1457
1462
  }
1458
1463
  } catch (err) {
@@ -1604,7 +1609,8 @@ function providerErrorToTurnError(error, committed = false) {
1604
1609
  code: error.code,
1605
1610
  retryable: error.retryable,
1606
1611
  committed,
1607
- ...error.contextOverflow === true ? { contextOverflow: true } : {}
1612
+ ...error.contextOverflow === true ? { contextOverflow: true } : {},
1613
+ ...error.imageOverflow === true ? { imageOverflow: true } : {}
1608
1614
  });
1609
1615
  }
1610
1616
  function toProviderTurnError(err, committed = false) {
@@ -1618,7 +1624,14 @@ function toProviderTurnError(err, committed = false) {
1618
1624
  const message = raw.length > MAX_ERROR_MESSAGE_CHARS ? `${raw.slice(0, MAX_ERROR_MESSAGE_CHARS)}...` : raw;
1619
1625
  const normalized = normalizeThrown(err);
1620
1626
  const status = typeof err === "object" && err !== null && typeof err.status === "number" ? err.status : normalized.status;
1621
- return new ProviderTurnError(`provider request failed: ${message}`, { ...status !== undefined ? { status } : {}, code: normalized.code, retryable: normalized.retryable, committed });
1627
+ return new ProviderTurnError(`provider request failed: ${message}`, {
1628
+ ...status !== undefined ? { status } : {},
1629
+ code: normalized.code,
1630
+ retryable: normalized.retryable,
1631
+ committed,
1632
+ ...normalized.contextOverflow === true ? { contextOverflow: true } : {},
1633
+ ...normalized.imageOverflow === true ? { imageOverflow: true } : {}
1634
+ });
1622
1635
  }
1623
1636
  function stampNativeState(turn, origin) {
1624
1637
  if (turn.nativeState === undefined)