@openclaw/ai 2026.7.2-beta.1 → 2026.7.2-beta.2

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.
@@ -7,7 +7,7 @@ import { r as createDeferredEventBuffer, t as notifyLlmRequestActivity } from ".
7
7
  import { t as headersToRecord } from "./headers-B_e4-1J0.mjs";
8
8
  import { n as parseStreamingJson, t as parseJsonWithRepair } from "./json-parse-BvXNt1-7.mjs";
9
9
  import { t as sanitizeSurrogates } from "./sanitize-unicode-DT5o51ur.mjs";
10
- import { b as splitSystemPromptCacheBoundary, f as prepareClaudeSonnet5RequestContext, g as usesClaudeStreamingRefusalContract, h as usesClaudeFable5MessagesContract, i as extractToolResultText, l as isRecord, n as describeToolResultMediaPlaceholder, o as adjustMaxTokensForThinking, p as requiresClaudeAdaptiveThinking, r as extractToolResultBlockText, s as buildBaseOptions, t as transformMessages, u as applyClaudeRequestContract, x as stripSystemPromptCacheBoundary } from "./transform-messages-DNWpwvXA.mjs";
10
+ import { C as stripSystemPromptCacheBoundary, S as splitSystemPromptCacheBoundary, _ as usesClaudeFable5MessagesContract, c as adjustMaxTokensForThinking, d as isRecord, f as applyClaudeRequestContract, h as requiresClaudeAdaptiveThinking, i as extractToolResultText, l as buildBaseOptions, m as prepareClaudeSonnet5RequestContext, n as describeToolResultMediaPlaceholder, o as isImageWithMediaPayload, r as extractToolResultBlockText, t as transformMessages, v as usesClaudeStreamingRefusalContract } from "./transform-messages-BmS70CP5.mjs";
11
11
  import { t as projectRuntimeToolInputSchema } from "./tool-schema-json-projection-BwNu3nDi.mjs";
12
12
  import { a as resolveCacheRetention, i as resolveCloudflareBaseUrl, n as hasCopilotVisionInput, t as buildCopilotDynamicHeaders } from "./github-copilot-headers-BsH5cqGj.mjs";
13
13
  import Anthropic from "@anthropic-ai/sdk";
@@ -374,13 +374,13 @@ const toClaudeCodeName = (name) => ccToolLookup.get(name.toLowerCase()) ?? name;
374
374
  function convertContentBlocks(content, isError) {
375
375
  const text = extractToolResultText(content);
376
376
  const mediaPlaceholder = describeToolResultMediaPlaceholder(content);
377
- if (!(Array.isArray(content) && content.some((item) => item && typeof item === "object" && item.type === "image"))) {
377
+ if (!content.some(isImageWithMediaPayload)) {
378
378
  const sanitized = sanitizeSurrogates(text);
379
379
  return sanitized.trim().length > 0 ? sanitized : mediaPlaceholder ?? (isError ? EMPTY_ERROR_TOOL_RESULT_TEXT : "");
380
380
  }
381
381
  const blocks = [];
382
382
  let hasTextBlock = false;
383
- for (const block of Array.isArray(content) ? content : []) {
383
+ for (const block of content) {
384
384
  if (!block || typeof block !== "object") continue;
385
385
  const record = block;
386
386
  const blockText = extractToolResultBlockText(block);
@@ -391,13 +391,13 @@ function convertContentBlocks(content, isError) {
391
391
  });
392
392
  hasTextBlock = true;
393
393
  }
394
- if (record.type !== "image") continue;
394
+ if (!isImageWithMediaPayload(record)) continue;
395
395
  blocks.push({
396
396
  type: "image",
397
397
  source: {
398
398
  type: "base64",
399
399
  media_type: typeof record.mimeType === "string" ? record.mimeType : "image/jpeg",
400
- data: typeof record.data === "string" ? record.data : ""
400
+ data: record.data
401
401
  }
402
402
  });
403
403
  }
@@ -1,10 +1,10 @@
1
1
  import { n as getEnvApiKey } from "./env-api-keys-DnhYpc27.mjs";
2
2
  import { t as AssistantMessageEventStream } from "./event-stream-D8n2uFee.mjs";
3
3
  import { n as getAiTransportHost } from "./host-4t713IeR.mjs";
4
- import { s as buildBaseOptions } from "./transform-messages-DNWpwvXA.mjs";
5
- import { a as resolveResponsesReasoningEffort, n as convertResponsesMessages, o as runResponsesStreamLifecycle, r as createResponsesAssistantOutput, t as applyCommonResponsesParams } from "./openai-responses-shared-B9mtGvXq.mjs";
4
+ import { l as buildBaseOptions } from "./transform-messages-BmS70CP5.mjs";
5
+ import { a as resolveResponsesReasoningEffort, n as convertResponsesMessages, o as runResponsesStreamLifecycle, r as createResponsesAssistantOutput, t as applyCommonResponsesParams } from "./openai-responses-shared-Befb4D6R.mjs";
6
6
  import { i as resolveAzureDeploymentNameFromMap, t as isOpenAICompatibleAzureResponsesBaseUrl } from "./azure-openai-responses-client-compat-C7K7QfUE.mjs";
7
- import { a as clampOpenAIPromptCacheKey } from "./openai-tool-projection-cTLC4F65.mjs";
7
+ import { a as clampOpenAIPromptCacheKey } from "./openai-tool-projection-CFqm42J2.mjs";
8
8
  import OpenAI, { AzureOpenAI } from "openai";
9
9
  //#region packages/ai/src/providers/azure-openai-responses.ts
10
10
  const DEFAULT_AZURE_API_VERSION = "v1";
@@ -1,8 +1,8 @@
1
1
  import { n as getEnvApiKey } from "./env-api-keys-DnhYpc27.mjs";
2
2
  import { t as AssistantMessageEventStream } from "./event-stream-D8n2uFee.mjs";
3
3
  import { n as getAiTransportHost, r as resolveAiTransportHeaderSentinels } from "./host-4t713IeR.mjs";
4
- import { s as buildBaseOptions } from "./transform-messages-DNWpwvXA.mjs";
5
- import { a as runGoogleGenerateContentLifecycle, i as getDisabledGoogleThinkingConfig, n as buildGoogleSimpleThinking, r as createGoogleAssistantOutput, t as buildGoogleGenerateContentParams } from "./google-shared-C7ohrmOI.mjs";
4
+ import { l as buildBaseOptions } from "./transform-messages-BmS70CP5.mjs";
5
+ import { a as runGoogleGenerateContentLifecycle, i as getDisabledGoogleThinkingConfig, n as buildGoogleSimpleThinking, r as createGoogleAssistantOutput, t as buildGoogleGenerateContentParams } from "./google-shared-Dx2aba47.mjs";
6
6
  import { GoogleGenAI } from "@google/genai";
7
7
  //#region packages/ai/src/providers/google.ts
8
8
  let toolCallCounter = 0;
@@ -1,6 +1,6 @@
1
1
  import { n as calculateCost, r as clampThinkingLevel } from "./model-utils-Q1LSRIdo.mjs";
2
2
  import { t as sanitizeSurrogates } from "./sanitize-unicode-DT5o51ur.mjs";
3
- import { i as extractToolResultText, n as describeToolResultMediaPlaceholder, t as transformMessages, x as stripSystemPromptCacheBoundary } from "./transform-messages-DNWpwvXA.mjs";
3
+ import { C as stripSystemPromptCacheBoundary, i as extractToolResultText, n as describeToolResultMediaPlaceholder, o as isImageWithMediaPayload, t as transformMessages } from "./transform-messages-BmS70CP5.mjs";
4
4
  import { FinishReason, FunctionCallingConfigMode, ThinkingLevel } from "@google/genai";
5
5
  //#region packages/ai/src/providers/google-shared.ts
6
6
  /**
@@ -145,7 +145,7 @@ function convertMessages(model, context) {
145
145
  });
146
146
  } else if (msg.role === "toolResult") {
147
147
  const textResult = extractToolResultText(msg.content);
148
- const imageContent = model.input.includes("image") ? msg.content.filter((c) => c.type === "image") : [];
148
+ const imageContent = model.input.includes("image") ? msg.content.filter(isImageWithMediaPayload) : [];
149
149
  const hasText = textResult.length > 0;
150
150
  const hasImages = imageContent.length > 0;
151
151
  const mediaPlaceholder = describeToolResultMediaPlaceholder(msg.content);
@@ -1,7 +1,7 @@
1
1
  import { t as AssistantMessageEventStream } from "./event-stream-D8n2uFee.mjs";
2
2
  import { n as getAiTransportHost, r as resolveAiTransportHeaderSentinels } from "./host-4t713IeR.mjs";
3
- import { s as buildBaseOptions } from "./transform-messages-DNWpwvXA.mjs";
4
- import { a as runGoogleGenerateContentLifecycle, n as buildGoogleSimpleThinking, r as createGoogleAssistantOutput, t as buildGoogleGenerateContentParams } from "./google-shared-C7ohrmOI.mjs";
3
+ import { l as buildBaseOptions } from "./transform-messages-BmS70CP5.mjs";
4
+ import { a as runGoogleGenerateContentLifecycle, n as buildGoogleSimpleThinking, r as createGoogleAssistantOutput, t as buildGoogleGenerateContentParams } from "./google-shared-Dx2aba47.mjs";
5
5
  import { GoogleGenAI, ResourceScope } from "@google/genai";
6
6
  //#region packages/ai/src/providers/google-vertex.ts
7
7
  const API_VERSION = "v1";
@@ -1,4 +1,4 @@
1
1
  import { a as resolveClaudeFable5ModelIdentity, c as resolveClaudeNativeThinkingLevelMap, d as supportsClaudeNativeMaxEffort, f as supportsClaudeNativeXhighEffort, i as requiresClaudeMandatoryAdaptiveThinking, l as resolveClaudeSonnet5ModelIdentity, o as resolveClaudeModelIdentity, r as requiresClaudeDefaultSampling, s as resolveClaudeMythos5ModelIdentity, u as supportsClaudeAdaptiveThinking } from "../src-CXno1H5g.mjs";
2
- import { d as defaultsClaudeAdaptiveThinking, f as prepareClaudeSonnet5RequestContext, g as usesClaudeStreamingRefusalContract, h as usesClaudeFable5MessagesContract, m as resolveModelBoundThinkingReplayMode, p as requiresClaudeAdaptiveThinking, u as applyClaudeRequestContract } from "../transform-messages-DNWpwvXA.mjs";
3
- import { _ as readAnthropicFallbackBoundary, a as readAnthropicUsageTokenCount, b as usesFoundryBearerAuth, c as reconcileAnthropicToolChoice, d as findActiveAnthropicToolTurnAssistantIndex, f as ANTHROPIC_SERVER_SIDE_FALLBACK_BETA, g as buildAnthropicServerSideFallbacks, h as applyAnthropicFallbackBoundary, i as readAnthropicPromptUsageSnapshot, l as resolveOriginalAnthropicToolName, m as CLAUDE_FABLE_5_FALLBACK_MODEL_COST, n as streamAnthropic, o as readLastAnthropicIterationUsage, p as CLAUDE_FABLE_5_FALLBACK_MODEL, r as streamSimpleAnthropic, s as projectAnthropicTools, u as ANTHROPIC_OMITTED_REASONING_TEXT, v as applyAnthropicRefusal, y as omitFoundryBearerCredentialHeaders } from "../anthropic-Cvm71xlk.mjs";
2
+ import { _ as usesClaudeFable5MessagesContract, f as applyClaudeRequestContract, g as resolveModelBoundThinkingReplayMode, h as requiresClaudeAdaptiveThinking, m as prepareClaudeSonnet5RequestContext, p as defaultsClaudeAdaptiveThinking, v as usesClaudeStreamingRefusalContract } from "../transform-messages-BmS70CP5.mjs";
3
+ import { _ as readAnthropicFallbackBoundary, a as readAnthropicUsageTokenCount, b as usesFoundryBearerAuth, c as reconcileAnthropicToolChoice, d as findActiveAnthropicToolTurnAssistantIndex, f as ANTHROPIC_SERVER_SIDE_FALLBACK_BETA, g as buildAnthropicServerSideFallbacks, h as applyAnthropicFallbackBoundary, i as readAnthropicPromptUsageSnapshot, l as resolveOriginalAnthropicToolName, m as CLAUDE_FABLE_5_FALLBACK_MODEL_COST, n as streamAnthropic, o as readLastAnthropicIterationUsage, p as CLAUDE_FABLE_5_FALLBACK_MODEL, r as streamSimpleAnthropic, s as projectAnthropicTools, u as ANTHROPIC_OMITTED_REASONING_TEXT, v as applyAnthropicRefusal, y as omitFoundryBearerCredentialHeaders } from "../anthropic-BIRSg5x9.mjs";
4
4
  export { ANTHROPIC_OMITTED_REASONING_TEXT, ANTHROPIC_SERVER_SIDE_FALLBACK_BETA, CLAUDE_FABLE_5_FALLBACK_MODEL, CLAUDE_FABLE_5_FALLBACK_MODEL_COST, applyAnthropicFallbackBoundary, applyAnthropicRefusal, applyClaudeRequestContract, buildAnthropicServerSideFallbacks, defaultsClaudeAdaptiveThinking, findActiveAnthropicToolTurnAssistantIndex, omitFoundryBearerCredentialHeaders, prepareClaudeSonnet5RequestContext, projectAnthropicTools, readAnthropicFallbackBoundary, readAnthropicPromptUsageSnapshot, readAnthropicUsageTokenCount, readLastAnthropicIterationUsage, reconcileAnthropicToolChoice, requiresClaudeAdaptiveThinking, requiresClaudeDefaultSampling, requiresClaudeMandatoryAdaptiveThinking, resolveClaudeFable5ModelIdentity, resolveClaudeModelIdentity, resolveClaudeMythos5ModelIdentity, resolveClaudeNativeThinkingLevelMap, resolveClaudeSonnet5ModelIdentity, resolveModelBoundThinkingReplayMode, resolveOriginalAnthropicToolName, streamAnthropic, streamSimpleAnthropic, supportsClaudeAdaptiveThinking, supportsClaudeNativeMaxEffort, supportsClaudeNativeXhighEffort, usesClaudeFable5MessagesContract, usesClaudeStreamingRefusalContract, usesFoundryBearerAuth };
@@ -198,6 +198,30 @@ declare function resolveResponsesMessageSnapshotCollapse(params: {
198
198
  nextPhase: string | undefined;
199
199
  }): ResponsesMessageSnapshotCollapse;
200
200
  //#endregion
201
+ //#region packages/ai/src/providers/openai-responses-tool-call-tracker.d.ts
202
+ type ResponsesToolCallIdentity = {
203
+ itemId?: string;
204
+ callId?: string;
205
+ };
206
+ type ResponsesToolCallState = ResponsesToolCallIdentity & {
207
+ argumentStreamReliable: boolean;
208
+ };
209
+ type ResponsesToolCallEvent = {
210
+ output_index?: unknown;
211
+ item_id?: unknown;
212
+ };
213
+ declare function readResponsesToolCallItemIdentity(item: {
214
+ id?: unknown;
215
+ call_id?: unknown;
216
+ }): ResponsesToolCallIdentity;
217
+ declare function createResponsesToolCallTracker<TState extends ResponsesToolCallState>(): {
218
+ register(event: ResponsesToolCallEvent, state: TState): void;
219
+ resolve(event: ResponsesToolCallEvent, identity?: ResponsesToolCallIdentity): TState | undefined;
220
+ forget(toolCall: TState): void;
221
+ markArgumentsUnreliable(): void;
222
+ hasActive(): boolean;
223
+ };
224
+ //#endregion
201
225
  //#region packages/ai/src/providers/openai-stop-reason.d.ts
202
226
  type OpenAIStopReasonResult = {
203
227
  stopReason: StopReason;
@@ -252,4 +276,4 @@ type RuntimeToolInputSchemaProjection = {
252
276
  /** Projects one runtime tool input schema to JSON and reports runtime incompatibilities. */
253
277
  declare function projectRuntimeToolInputSchema(schema: unknown, path?: string): RuntimeToolInputSchemaProjection;
254
278
  //#endregion
255
- export { AZURE_RESPONSES_TEXT_CONTENT_PART_TYPE, AZURE_RESPONSES_TEXT_DELTA_EVENT_TYPE, AzureResponsesTextContentPart, AzureResponsesTextDeltaEvent, GEMINI_UNSUPPORTED_SCHEMA_KEYWORDS, OPENAI_PROMPT_CACHE_KEY_MAX_LENGTH, OPENAI_RESPONSES_OUTPUT_TEXT_CONTENT_PART_TYPE, OPENAI_RESPONSES_OUTPUT_TEXT_DELTA_EVENT_TYPE, OpenAIApiReasoningEffort, OpenAICompletionsOptions, OpenAICompletionsToolChoice, OpenAIReasoningEffort, OpenAIResponsesOptions, OpenAIStopReasonResult, OpenAIToolProjection, ResponsesMessageSnapshotCollapse, ResponsesTextContentPartType, ResponsesTextDeltaEventType, RuntimeToolInputSchemaJson, RuntimeToolInputSchemaProjection, ToolParameterSchemaOptions, ToolSchemaModelCompat, clampOpenAIPromptCacheKey, cleanSchemaForGemini, clearOpenAIToolSchemaCacheForTest, convertMessages, extractToolSchemaModelCompat, findOpenAIStrictToolProjectionDiagnostics, isAzureResponsesTextDeltaEvent, isAzureResponsesTextDeltaEventType, isOpenAICompatibleAzureResponsesBaseUrl, isOpenAIGpt54MiniModel, isOpenAIGpt55Model, isOpenAIGpt56Model, isResponsesTextContentPartType, isResponsesTextDeltaEventType, isStrictOpenAIJsonSchemaCompatible, isTraditionalAzureOpenAIHost, mapOpenAIStopReason, normalizeOpenAIReasoningEffort, normalizeOpenAIStrictToolParameters, normalizeStrictOpenAIJsonSchema, normalizeToolParameterSchema, parseAzureDeploymentNameMap, projectOpenAITools, projectRuntimeToolInputSchema, reconcileOpenAICompletionsToolChoice, reconcileOpenAIResponsesToolChoice, resolveAzureDeploymentNameFromMap, resolveOpenAIProjectedToolsStrictToolFlag, resolveOpenAIReasoningEffortForModel, resolveOpenAISupportedReasoningEfforts, resolveResponsesMessageSnapshotCollapse, resolveUnsupportedToolSchemaKeywords, shouldOmitEmptyArrayItems, streamOpenAICompletions, streamOpenAIResponses, streamSimpleOpenAICompletions, streamSimpleOpenAIResponses, stripUnsupportedSchemaKeywords, supportsOpenAIReasoningEffort, supportsOpenAITemperature };
279
+ export { AZURE_RESPONSES_TEXT_CONTENT_PART_TYPE, AZURE_RESPONSES_TEXT_DELTA_EVENT_TYPE, AzureResponsesTextContentPart, AzureResponsesTextDeltaEvent, GEMINI_UNSUPPORTED_SCHEMA_KEYWORDS, OPENAI_PROMPT_CACHE_KEY_MAX_LENGTH, OPENAI_RESPONSES_OUTPUT_TEXT_CONTENT_PART_TYPE, OPENAI_RESPONSES_OUTPUT_TEXT_DELTA_EVENT_TYPE, OpenAIApiReasoningEffort, OpenAICompletionsOptions, OpenAICompletionsToolChoice, OpenAIReasoningEffort, OpenAIResponsesOptions, OpenAIStopReasonResult, OpenAIToolProjection, ResponsesMessageSnapshotCollapse, ResponsesTextContentPartType, ResponsesTextDeltaEventType, ResponsesToolCallIdentity, ResponsesToolCallState, RuntimeToolInputSchemaJson, RuntimeToolInputSchemaProjection, ToolParameterSchemaOptions, ToolSchemaModelCompat, clampOpenAIPromptCacheKey, cleanSchemaForGemini, clearOpenAIToolSchemaCacheForTest, convertMessages, createResponsesToolCallTracker, extractToolSchemaModelCompat, findOpenAIStrictToolProjectionDiagnostics, isAzureResponsesTextDeltaEvent, isAzureResponsesTextDeltaEventType, isOpenAICompatibleAzureResponsesBaseUrl, isOpenAIGpt54MiniModel, isOpenAIGpt55Model, isOpenAIGpt56Model, isResponsesTextContentPartType, isResponsesTextDeltaEventType, isStrictOpenAIJsonSchemaCompatible, isTraditionalAzureOpenAIHost, mapOpenAIStopReason, normalizeOpenAIReasoningEffort, normalizeOpenAIStrictToolParameters, normalizeStrictOpenAIJsonSchema, normalizeToolParameterSchema, parseAzureDeploymentNameMap, projectOpenAITools, projectRuntimeToolInputSchema, readResponsesToolCallItemIdentity, reconcileOpenAICompletionsToolChoice, reconcileOpenAIResponsesToolChoice, resolveAzureDeploymentNameFromMap, resolveOpenAIProjectedToolsStrictToolFlag, resolveOpenAIReasoningEffortForModel, resolveOpenAISupportedReasoningEfforts, resolveResponsesMessageSnapshotCollapse, resolveUnsupportedToolSchemaKeywords, shouldOmitEmptyArrayItems, streamOpenAICompletions, streamOpenAIResponses, streamSimpleOpenAICompletions, streamSimpleOpenAIResponses, stripUnsupportedSchemaKeywords, supportsOpenAIReasoningEffort, supportsOpenAITemperature };
@@ -1,7 +1,7 @@
1
1
  import { t as projectRuntimeToolInputSchema } from "../tool-schema-json-projection-BwNu3nDi.mjs";
2
- import { A as supportsOpenAITemperature, C as isOpenAIGpt54MiniModel, D as resolveOpenAIReasoningEffortForModel, E as normalizeOpenAIReasoningEffort, F as stripUnsupportedSchemaKeywords, I as GEMINI_UNSUPPORTED_SCHEMA_KEYWORDS, L as cleanSchemaForGemini, M as normalizeToolParameterSchema, N as resolveUnsupportedToolSchemaKeywords, O as resolveOpenAISupportedReasoningEfforts, P as shouldOmitEmptyArrayItems, S as resolveResponsesMessageSnapshotCollapse, T as isOpenAIGpt56Model, _ as OPENAI_RESPONSES_OUTPUT_TEXT_DELTA_EVENT_TYPE, b as isResponsesTextContentPartType, c as clearOpenAIToolSchemaCacheForTest, d as normalizeOpenAIStrictToolParameters, f as normalizeStrictOpenAIJsonSchema, g as OPENAI_RESPONSES_OUTPUT_TEXT_CONTENT_PART_TYPE, h as AZURE_RESPONSES_TEXT_DELTA_EVENT_TYPE, j as extractToolSchemaModelCompat, k as supportsOpenAIReasoningEffort, l as findOpenAIStrictToolProjectionDiagnostics, m as AZURE_RESPONSES_TEXT_CONTENT_PART_TYPE, p as resolveOpenAIProjectedToolsStrictToolFlag, u as isStrictOpenAIJsonSchemaCompatible, v as isAzureResponsesTextDeltaEvent, w as isOpenAIGpt55Model, x as isResponsesTextDeltaEventType, y as isAzureResponsesTextDeltaEventType } from "../openai-responses-shared-B9mtGvXq.mjs";
2
+ import { A as resolveOpenAISupportedReasoningEfforts, C as isResponsesTextDeltaEventType, D as isOpenAIGpt56Model, E as isOpenAIGpt55Model, F as resolveUnsupportedToolSchemaKeywords, I as shouldOmitEmptyArrayItems, L as stripUnsupportedSchemaKeywords, M as supportsOpenAITemperature, N as extractToolSchemaModelCompat, O as normalizeOpenAIReasoningEffort, P as normalizeToolParameterSchema, R as GEMINI_UNSUPPORTED_SCHEMA_KEYWORDS, S as isResponsesTextContentPartType, T as isOpenAIGpt54MiniModel, _ as AZURE_RESPONSES_TEXT_DELTA_EVENT_TYPE, b as isAzureResponsesTextDeltaEvent, c as clearOpenAIToolSchemaCacheForTest, d as normalizeOpenAIStrictToolParameters, f as normalizeStrictOpenAIJsonSchema, g as AZURE_RESPONSES_TEXT_CONTENT_PART_TYPE, h as readResponsesToolCallItemIdentity, j as supportsOpenAIReasoningEffort, k as resolveOpenAIReasoningEffortForModel, l as findOpenAIStrictToolProjectionDiagnostics, m as createResponsesToolCallTracker, p as resolveOpenAIProjectedToolsStrictToolFlag, u as isStrictOpenAIJsonSchemaCompatible, v as OPENAI_RESPONSES_OUTPUT_TEXT_CONTENT_PART_TYPE, w as resolveResponsesMessageSnapshotCollapse, x as isAzureResponsesTextDeltaEventType, y as OPENAI_RESPONSES_OUTPUT_TEXT_DELTA_EVENT_TYPE, z as cleanSchemaForGemini } from "../openai-responses-shared-Befb4D6R.mjs";
3
3
  import { i as resolveAzureDeploymentNameFromMap, n as isTraditionalAzureOpenAIHost, r as parseAzureDeploymentNameMap, t as isOpenAICompatibleAzureResponsesBaseUrl } from "../azure-openai-responses-client-compat-C7K7QfUE.mjs";
4
- import { a as clampOpenAIPromptCacheKey, i as OPENAI_PROMPT_CACHE_KEY_MAX_LENGTH, n as reconcileOpenAICompletionsToolChoice, r as reconcileOpenAIResponsesToolChoice, t as projectOpenAITools } from "../openai-tool-projection-cTLC4F65.mjs";
5
- import { a as mapOpenAIStopReason, i as streamSimpleOpenAICompletions, r as streamOpenAICompletions, t as convertMessages } from "../openai-completions-B2jr3vtJ.mjs";
6
- import { n as streamOpenAIResponses, r as streamSimpleOpenAIResponses } from "../openai-responses-DTpD8YVy.mjs";
7
- export { AZURE_RESPONSES_TEXT_CONTENT_PART_TYPE, AZURE_RESPONSES_TEXT_DELTA_EVENT_TYPE, GEMINI_UNSUPPORTED_SCHEMA_KEYWORDS, OPENAI_PROMPT_CACHE_KEY_MAX_LENGTH, OPENAI_RESPONSES_OUTPUT_TEXT_CONTENT_PART_TYPE, OPENAI_RESPONSES_OUTPUT_TEXT_DELTA_EVENT_TYPE, clampOpenAIPromptCacheKey, cleanSchemaForGemini, clearOpenAIToolSchemaCacheForTest, convertMessages, extractToolSchemaModelCompat, findOpenAIStrictToolProjectionDiagnostics, isAzureResponsesTextDeltaEvent, isAzureResponsesTextDeltaEventType, isOpenAICompatibleAzureResponsesBaseUrl, isOpenAIGpt54MiniModel, isOpenAIGpt55Model, isOpenAIGpt56Model, isResponsesTextContentPartType, isResponsesTextDeltaEventType, isStrictOpenAIJsonSchemaCompatible, isTraditionalAzureOpenAIHost, mapOpenAIStopReason, normalizeOpenAIReasoningEffort, normalizeOpenAIStrictToolParameters, normalizeStrictOpenAIJsonSchema, normalizeToolParameterSchema, parseAzureDeploymentNameMap, projectOpenAITools, projectRuntimeToolInputSchema, reconcileOpenAICompletionsToolChoice, reconcileOpenAIResponsesToolChoice, resolveAzureDeploymentNameFromMap, resolveOpenAIProjectedToolsStrictToolFlag, resolveOpenAIReasoningEffortForModel, resolveOpenAISupportedReasoningEfforts, resolveResponsesMessageSnapshotCollapse, resolveUnsupportedToolSchemaKeywords, shouldOmitEmptyArrayItems, streamOpenAICompletions, streamOpenAIResponses, streamSimpleOpenAICompletions, streamSimpleOpenAIResponses, stripUnsupportedSchemaKeywords, supportsOpenAIReasoningEffort, supportsOpenAITemperature };
4
+ import { a as clampOpenAIPromptCacheKey, i as OPENAI_PROMPT_CACHE_KEY_MAX_LENGTH, n as reconcileOpenAICompletionsToolChoice, r as reconcileOpenAIResponsesToolChoice, t as projectOpenAITools } from "../openai-tool-projection-CFqm42J2.mjs";
5
+ import { a as mapOpenAIStopReason, i as streamSimpleOpenAICompletions, r as streamOpenAICompletions, t as convertMessages } from "../openai-completions-DPR_O2RW.mjs";
6
+ import { n as streamOpenAIResponses, r as streamSimpleOpenAIResponses } from "../openai-responses-Cov-Vdc2.mjs";
7
+ export { AZURE_RESPONSES_TEXT_CONTENT_PART_TYPE, AZURE_RESPONSES_TEXT_DELTA_EVENT_TYPE, GEMINI_UNSUPPORTED_SCHEMA_KEYWORDS, OPENAI_PROMPT_CACHE_KEY_MAX_LENGTH, OPENAI_RESPONSES_OUTPUT_TEXT_CONTENT_PART_TYPE, OPENAI_RESPONSES_OUTPUT_TEXT_DELTA_EVENT_TYPE, clampOpenAIPromptCacheKey, cleanSchemaForGemini, clearOpenAIToolSchemaCacheForTest, convertMessages, createResponsesToolCallTracker, extractToolSchemaModelCompat, findOpenAIStrictToolProjectionDiagnostics, isAzureResponsesTextDeltaEvent, isAzureResponsesTextDeltaEventType, isOpenAICompatibleAzureResponsesBaseUrl, isOpenAIGpt54MiniModel, isOpenAIGpt55Model, isOpenAIGpt56Model, isResponsesTextContentPartType, isResponsesTextDeltaEventType, isStrictOpenAIJsonSchemaCompatible, isTraditionalAzureOpenAIHost, mapOpenAIStopReason, normalizeOpenAIReasoningEffort, normalizeOpenAIStrictToolParameters, normalizeStrictOpenAIJsonSchema, normalizeToolParameterSchema, parseAzureDeploymentNameMap, projectOpenAITools, projectRuntimeToolInputSchema, readResponsesToolCallItemIdentity, reconcileOpenAICompletionsToolChoice, reconcileOpenAIResponsesToolChoice, resolveAzureDeploymentNameFromMap, resolveOpenAIProjectedToolsStrictToolFlag, resolveOpenAIReasoningEffortForModel, resolveOpenAISupportedReasoningEfforts, resolveResponsesMessageSnapshotCollapse, resolveUnsupportedToolSchemaKeywords, shouldOmitEmptyArrayItems, streamOpenAICompletions, streamOpenAIResponses, streamSimpleOpenAICompletions, streamSimpleOpenAIResponses, stripUnsupportedSchemaKeywords, supportsOpenAIReasoningEffort, supportsOpenAITemperature };
@@ -15,6 +15,15 @@ declare function adjustMaxTokensForThinking(baseMaxTokens: number | undefined, m
15
15
  };
16
16
  //#endregion
17
17
  //#region packages/ai/src/providers/tool-result-text.d.ts
18
+ /** Media metadata alone is not an attachment; provider emitters need inline bytes. */
19
+ declare function hasMediaPayload(block: unknown): block is Record<string, unknown> & {
20
+ data: string;
21
+ };
22
+ /** Image metadata alone is not an attachment; provider emitters need inline bytes. */
23
+ declare function isImageWithMediaPayload<T>(block: T): block is T & {
24
+ type: "image";
25
+ data: string;
26
+ };
18
27
  declare function describeToolResultMediaPlaceholder(blocks: readonly unknown[]): string | undefined;
19
28
  declare function extractToolResultBlockText(block: unknown): string | undefined;
20
29
  declare function extractToolResultText(blocks: readonly unknown[]): string;
@@ -46,4 +55,4 @@ declare function prependSystemPromptAdditionAfterCacheBoundary(params: {
46
55
  systemPromptAddition?: string;
47
56
  }): string;
48
57
  //#endregion
49
- export { SYSTEM_PROMPT_CACHE_BOUNDARY, adjustMaxTokensForThinking, buildBaseOptions, clampReasoning, describeToolResultMediaPlaceholder, ensureSystemPromptCacheBoundary, extractToolResultBlockText, extractToolResultText, normalizePromptCapabilityIds, normalizeStructuredPromptSection, prependSystemPromptAdditionAfterCacheBoundary, sanitizeSurrogates, splitSystemPromptCacheBoundary, stripSystemPromptCacheBoundary, transformMessages };
58
+ export { SYSTEM_PROMPT_CACHE_BOUNDARY, adjustMaxTokensForThinking, buildBaseOptions, clampReasoning, describeToolResultMediaPlaceholder, ensureSystemPromptCacheBoundary, extractToolResultBlockText, extractToolResultText, hasMediaPayload, isImageWithMediaPayload, normalizePromptCapabilityIds, normalizeStructuredPromptSection, prependSystemPromptAdditionAfterCacheBoundary, sanitizeSurrogates, splitSystemPromptCacheBoundary, stripSystemPromptCacheBoundary, transformMessages };
@@ -1,3 +1,3 @@
1
1
  import { t as sanitizeSurrogates } from "../sanitize-unicode-DT5o51ur.mjs";
2
- import { C as normalizeStructuredPromptSection, S as normalizePromptCapabilityIds, _ as SYSTEM_PROMPT_CACHE_BOUNDARY, b as splitSystemPromptCacheBoundary, c as clampReasoning, i as extractToolResultText, n as describeToolResultMediaPlaceholder, o as adjustMaxTokensForThinking, r as extractToolResultBlockText, s as buildBaseOptions, t as transformMessages, v as ensureSystemPromptCacheBoundary, x as stripSystemPromptCacheBoundary, y as prependSystemPromptAdditionAfterCacheBoundary } from "../transform-messages-DNWpwvXA.mjs";
3
- export { SYSTEM_PROMPT_CACHE_BOUNDARY, adjustMaxTokensForThinking, buildBaseOptions, clampReasoning, describeToolResultMediaPlaceholder, ensureSystemPromptCacheBoundary, extractToolResultBlockText, extractToolResultText, normalizePromptCapabilityIds, normalizeStructuredPromptSection, prependSystemPromptAdditionAfterCacheBoundary, sanitizeSurrogates, splitSystemPromptCacheBoundary, stripSystemPromptCacheBoundary, transformMessages };
2
+ import { C as stripSystemPromptCacheBoundary, S as splitSystemPromptCacheBoundary, T as normalizeStructuredPromptSection, a as hasMediaPayload, b as ensureSystemPromptCacheBoundary, c as adjustMaxTokensForThinking, i as extractToolResultText, l as buildBaseOptions, n as describeToolResultMediaPlaceholder, o as isImageWithMediaPayload, r as extractToolResultBlockText, t as transformMessages, u as clampReasoning, w as normalizePromptCapabilityIds, x as prependSystemPromptAdditionAfterCacheBoundary, y as SYSTEM_PROMPT_CACHE_BOUNDARY } from "../transform-messages-BmS70CP5.mjs";
3
+ export { SYSTEM_PROMPT_CACHE_BOUNDARY, adjustMaxTokensForThinking, buildBaseOptions, clampReasoning, describeToolResultMediaPlaceholder, ensureSystemPromptCacheBoundary, extractToolResultBlockText, extractToolResultText, hasMediaPayload, isImageWithMediaPayload, normalizePromptCapabilityIds, normalizeStructuredPromptSection, prependSystemPromptAdditionAfterCacheBoundary, sanitizeSurrogates, splitSystemPromptCacheBoundary, stripSystemPromptCacheBoundary, transformMessages };
@@ -4,7 +4,7 @@ import { n as getAiTransportHost } from "./host-4t713IeR.mjs";
4
4
  import { n as calculateCost, r as clampThinkingLevel } from "./model-utils-Q1LSRIdo.mjs";
5
5
  import { n as parseStreamingJson } from "./json-parse-BvXNt1-7.mjs";
6
6
  import { t as sanitizeSurrogates } from "./sanitize-unicode-DT5o51ur.mjs";
7
- import { a as truncateUtf16Safe, i as extractToolResultText, n as describeToolResultMediaPlaceholder, s as buildBaseOptions, t as transformMessages, x as stripSystemPromptCacheBoundary } from "./transform-messages-DNWpwvXA.mjs";
7
+ import { C as stripSystemPromptCacheBoundary, i as extractToolResultText, l as buildBaseOptions, n as describeToolResultMediaPlaceholder, o as isImageWithMediaPayload, s as truncateUtf16Safe, t as transformMessages } from "./transform-messages-BmS70CP5.mjs";
8
8
  import { t as shortHash } from "./hash-CHgqbJmD.mjs";
9
9
  import { t as createSseByteGuard } from "./streaming-byte-guard-BrbkbwUu.mjs";
10
10
  import { randomUUID } from "node:crypto";
@@ -576,14 +576,14 @@ function toChatMessages(messages, supportsImages) {
576
576
  continue;
577
577
  }
578
578
  const toolContent = [];
579
- const toolText = buildToolResultText(extractToolResultText(msg.content), describeToolResultMediaPlaceholder(msg.content), msg.content.some((part) => part.type === "image"), supportsImages, msg.isError);
579
+ const toolText = buildToolResultText(extractToolResultText(msg.content), describeToolResultMediaPlaceholder(msg.content), msg.content.some(isImageWithMediaPayload), supportsImages, msg.isError);
580
580
  toolContent.push({
581
581
  type: "text",
582
582
  text: toolText
583
583
  });
584
584
  for (const part of msg.content) {
585
585
  if (!supportsImages) continue;
586
- if (part.type !== "image") continue;
586
+ if (!isImageWithMediaPayload(part)) continue;
587
587
  toolContent.push({
588
588
  type: "image_url",
589
589
  imageUrl: `data:${part.mimeType};base64,${part.data}`
@@ -3,10 +3,10 @@ import { i as formatThrownValue, n as createAssistantMessageDiagnostic, t as app
3
3
  import { t as AssistantMessageEventStream } from "./event-stream-D8n2uFee.mjs";
4
4
  import { n as getAiTransportHost, r as resolveAiTransportHeaderSentinels } from "./host-4t713IeR.mjs";
5
5
  import { t as headersToRecord } from "./headers-B_e4-1J0.mjs";
6
- import { s as buildBaseOptions, x as stripSystemPromptCacheBoundary } from "./transform-messages-DNWpwvXA.mjs";
7
- import { A as supportsOpenAITemperature, a as resolveResponsesReasoningEffort, i as processResponsesStream, n as convertResponsesMessages, s as convertResponsesToolPayload } from "./openai-responses-shared-B9mtGvXq.mjs";
6
+ import { C as stripSystemPromptCacheBoundary, l as buildBaseOptions } from "./transform-messages-BmS70CP5.mjs";
7
+ import { M as supportsOpenAITemperature, a as resolveResponsesReasoningEffort, i as processResponsesStream, n as convertResponsesMessages, s as convertResponsesToolPayload } from "./openai-responses-shared-Befb4D6R.mjs";
8
8
  import { i as getFirstStreamEventTimeoutMs, o as clampTimerTimeoutMs, r as getFirstStreamEventTimeoutHandler, s as resolveTimerTimeoutMs, t as createFirstStreamEventAbortController } from "./stream-first-event-timeout-RjWszj8c.mjs";
9
- import { a as clampOpenAIPromptCacheKey } from "./openai-tool-projection-cTLC4F65.mjs";
9
+ import { a as clampOpenAIPromptCacheKey } from "./openai-tool-projection-CFqm42J2.mjs";
10
10
  import { parseRetryAfterHttpDateMs } from "./internal/retry-after.mjs";
11
11
  import { i as registerSessionResourceCleanup, n as resolveOpenAICodexAccountId } from "./openai-chatgpt-jwt-DhAAzLkj.mjs";
12
12
  import { t as createSseByteGuard } from "./streaming-byte-guard-BrbkbwUu.mjs";
@@ -5,11 +5,11 @@ import { n as calculateCost, r as clampThinkingLevel, t as applyProviderReported
5
5
  import { t as headersToRecord } from "./headers-B_e4-1J0.mjs";
6
6
  import { n as parseStreamingJson } from "./json-parse-BvXNt1-7.mjs";
7
7
  import { t as sanitizeSurrogates } from "./sanitize-unicode-DT5o51ur.mjs";
8
- import { b as splitSystemPromptCacheBoundary, i as extractToolResultText, n as describeToolResultMediaPlaceholder, s as buildBaseOptions, t as transformMessages, x as stripSystemPromptCacheBoundary } from "./transform-messages-DNWpwvXA.mjs";
8
+ import { C as stripSystemPromptCacheBoundary, S as splitSystemPromptCacheBoundary, i as extractToolResultText, l as buildBaseOptions, n as describeToolResultMediaPlaceholder, o as isImageWithMediaPayload, t as transformMessages } from "./transform-messages-BmS70CP5.mjs";
9
9
  import { a as resolveCacheRetention, i as resolveCloudflareBaseUrl, n as hasCopilotVisionInput, r as isCloudflareProvider, t as buildCopilotDynamicHeaders } from "./github-copilot-headers-BsH5cqGj.mjs";
10
10
  import { t as createReasoningTagTextPartitioner } from "./reasoning-tag-text-partitioner-BlVe67g6.mjs";
11
11
  import { a as withFirstStreamEventTimeout, i as getFirstStreamEventTimeoutMs, r as getFirstStreamEventTimeoutHandler, t as createFirstStreamEventAbortController } from "./stream-first-event-timeout-RjWszj8c.mjs";
12
- import { a as clampOpenAIPromptCacheKey, n as reconcileOpenAICompletionsToolChoice, t as projectOpenAITools } from "./openai-tool-projection-cTLC4F65.mjs";
12
+ import { a as clampOpenAIPromptCacheKey, n as reconcileOpenAICompletionsToolChoice, t as projectOpenAITools } from "./openai-tool-projection-CFqm42J2.mjs";
13
13
  import OpenAI from "openai";
14
14
  //#region packages/ai/src/providers/openai-stop-reason.ts
15
15
  function mapOpenAIStopReason(reason, options) {
@@ -67,9 +67,6 @@ function isThinkingContentBlock(block) {
67
67
  function isToolCallBlock(block) {
68
68
  return block.type === "toolCall";
69
69
  }
70
- function isImageContentBlock(block) {
71
- return block.type === "image";
72
- }
73
70
  const EMPTY_TOOL_RESULT_TEXT = "(no output)";
74
71
  function sanitizeToolResultText(text, fallback) {
75
72
  const sanitized = sanitizeSurrogates(text);
@@ -472,7 +469,7 @@ function buildParams(model, context, options, compat = getCompat(model), cacheRe
472
469
  const toolChoice = reconcileOpenAICompletionsToolChoice(options.toolChoice, toolProjection ?? projectOpenAITools([]));
473
470
  if (toolChoice !== void 0) params.tool_choice = toolChoice;
474
471
  }
475
- if (compat.thinkingFormat === "zai" && model.reasoning) params.enable_thinking = Boolean(options?.reasoningEffort);
472
+ if (compat.thinkingFormat === "zai" && model.reasoning) params.thinking = { type: options?.reasoningEffort ? "enabled" : "disabled" };
476
473
  else if (compat.thinkingFormat === "qwen" && model.reasoning) params.enable_thinking = Boolean(options?.reasoningEffort);
477
474
  else if (compat.thinkingFormat === "qwen-chat-template" && model.reasoning) params.chat_template_kwargs = {
478
475
  enable_thinking: Boolean(options?.reasoningEffort),
@@ -699,7 +696,7 @@ function convertMessages(model, context, compat, options = {}) {
699
696
  if (toolMsg?.role !== "toolResult") break;
700
697
  const textResult = extractToolResultText(toolMsg.content);
701
698
  const mediaPlaceholder = describeToolResultMediaPlaceholder(toolMsg.content);
702
- const hasImages = toolMsg.content.some((c) => c.type === "image");
699
+ const hasImages = toolMsg.content.some(isImageWithMediaPayload);
703
700
  const toolResultMsg = {
704
701
  role: "tool",
705
702
  content: sanitizeToolResultText(textResult, mediaPlaceholder ?? EMPTY_TOOL_RESULT_TEXT),
@@ -708,7 +705,7 @@ function convertMessages(model, context, compat, options = {}) {
708
705
  if (compat.requiresToolResultName && toolMsg.toolName) toolResultMsg.name = toolMsg.toolName;
709
706
  params.push(toolResultMsg);
710
707
  if (hasImages && model.input.includes("image")) {
711
- for (const block of toolMsg.content) if (isImageContentBlock(block)) imageBlocks.push({
708
+ for (const block of toolMsg.content) if (isImageWithMediaPayload(block)) imageBlocks.push({
712
709
  type: "image_url",
713
710
  image_url: { url: `data:${block.mimeType};base64,${block.data}` }
714
711
  });
@@ -789,7 +786,7 @@ function detectCompat(model) {
789
786
  const isCloudflareWorkersAI = provider === "cloudflare-workers-ai" || baseUrl.includes("api.cloudflare.com");
790
787
  const isCloudflareAiGateway = provider === "cloudflare-ai-gateway" || baseUrl.includes("gateway.ai.cloudflare.com");
791
788
  const isNonStandard = provider === "cerebras" || baseUrl.includes("cerebras.ai") || provider === "xai" || baseUrl.includes("api.x.ai") || isTogether || baseUrl.includes("chutes.ai") || baseUrl.includes("deepseek.com") || isZai || isMoonshot || provider === "opencode" || baseUrl.includes("opencode.ai") || isCloudflareWorkersAI || isCloudflareAiGateway;
792
- const useMaxTokens = baseUrl.includes("chutes.ai") || isMoonshot || isCloudflareAiGateway || isTogether;
789
+ const useMaxTokens = baseUrl.includes("chutes.ai") || isMoonshot || isCloudflareAiGateway || isTogether || isZai;
793
790
  const isGrok = provider === "xai" || baseUrl.includes("api.x.ai");
794
791
  const isDeepSeek = provider === "deepseek" || baseUrl.includes("deepseek.com");
795
792
  const isXiaomi = provider === "xiaomi" || baseUrl.includes("xiaomimimo.com");
@@ -1,10 +1,10 @@
1
1
  import { n as getEnvApiKey, r as __exportAll } from "./env-api-keys-DnhYpc27.mjs";
2
2
  import { t as AssistantMessageEventStream } from "./event-stream-D8n2uFee.mjs";
3
3
  import { n as getAiTransportHost } from "./host-4t713IeR.mjs";
4
- import { s as buildBaseOptions } from "./transform-messages-DNWpwvXA.mjs";
4
+ import { l as buildBaseOptions } from "./transform-messages-BmS70CP5.mjs";
5
5
  import { a as resolveCacheRetention, i as resolveCloudflareBaseUrl, n as hasCopilotVisionInput, r as isCloudflareProvider, t as buildCopilotDynamicHeaders } from "./github-copilot-headers-BsH5cqGj.mjs";
6
- import { A as supportsOpenAITemperature, a as resolveResponsesReasoningEffort, n as convertResponsesMessages, o as runResponsesStreamLifecycle, r as createResponsesAssistantOutput, t as applyCommonResponsesParams } from "./openai-responses-shared-B9mtGvXq.mjs";
7
- import { a as clampOpenAIPromptCacheKey } from "./openai-tool-projection-cTLC4F65.mjs";
6
+ import { M as supportsOpenAITemperature, a as resolveResponsesReasoningEffort, n as convertResponsesMessages, o as runResponsesStreamLifecycle, r as createResponsesAssistantOutput, t as applyCommonResponsesParams } from "./openai-responses-shared-Befb4D6R.mjs";
7
+ import { a as clampOpenAIPromptCacheKey } from "./openai-tool-projection-CFqm42J2.mjs";
8
8
  import OpenAI from "openai";
9
9
  //#region packages/ai/src/providers/openai-responses.ts
10
10
  var openai_responses_exports = /* @__PURE__ */ __exportAll({
@@ -3,9 +3,9 @@ import { n as calculateCost, r as clampThinkingLevel } from "./model-utils-Q1LSR
3
3
  import { t as headersToRecord } from "./headers-B_e4-1J0.mjs";
4
4
  import { n as parseStreamingJson } from "./json-parse-BvXNt1-7.mjs";
5
5
  import { t as sanitizeSurrogates } from "./sanitize-unicode-DT5o51ur.mjs";
6
- import { T as normalizeOptionalString, i as extractToolResultText, l as isRecord, n as describeToolResultMediaPlaceholder, t as transformMessages, w as normalizeLowercaseStringOrEmpty, x as stripSystemPromptCacheBoundary } from "./transform-messages-DNWpwvXA.mjs";
6
+ import { C as stripSystemPromptCacheBoundary, D as normalizeOptionalString, E as normalizeLowercaseStringOrEmpty, d as isRecord, i as extractToolResultText, n as describeToolResultMediaPlaceholder, o as isImageWithMediaPayload, t as transformMessages } from "./transform-messages-BmS70CP5.mjs";
7
7
  import { a as withFirstStreamEventTimeout, i as getFirstStreamEventTimeoutMs, r as getFirstStreamEventTimeoutHandler, t as createFirstStreamEventAbortController } from "./stream-first-event-timeout-RjWszj8c.mjs";
8
- import { t as projectOpenAITools } from "./openai-tool-projection-cTLC4F65.mjs";
8
+ import { t as projectOpenAITools } from "./openai-tool-projection-CFqm42J2.mjs";
9
9
  import { t as shortHash } from "./hash-CHgqbJmD.mjs";
10
10
  import { createHash, randomUUID } from "node:crypto";
11
11
  //#region packages/normalization-core/src/string-normalization.ts
@@ -1076,6 +1076,82 @@ function resolveResponsesMessageSnapshotCollapse(params) {
1076
1076
  return { kind: "keep" };
1077
1077
  }
1078
1078
  //#endregion
1079
+ //#region packages/ai/src/providers/openai-responses-tool-call-tracker.ts
1080
+ function readIdentityValue(value) {
1081
+ return (typeof value === "string" ? value.trim() : "") || void 0;
1082
+ }
1083
+ function readOutputIndex(event) {
1084
+ return typeof event.output_index === "number" && Number.isInteger(event.output_index) && event.output_index >= 0 ? event.output_index : void 0;
1085
+ }
1086
+ function readEventIdentity(event) {
1087
+ return { itemId: readIdentityValue(event.item_id) };
1088
+ }
1089
+ function readResponsesToolCallItemIdentity(item) {
1090
+ return {
1091
+ itemId: readIdentityValue(item.id),
1092
+ callId: readIdentityValue(item.call_id)
1093
+ };
1094
+ }
1095
+ function createResponsesToolCallTracker() {
1096
+ const indexedCalls = /* @__PURE__ */ new Map();
1097
+ const unindexedCalls = /* @__PURE__ */ new Set();
1098
+ const identitiesConflict = (state, identity) => Boolean(state.itemId && identity.itemId && state.itemId !== identity.itemId || state.callId && identity.callId && state.callId !== identity.callId);
1099
+ const sharesIdentity = (state, identity) => Boolean(state.itemId && identity.itemId && state.itemId === identity.itemId || state.callId && identity.callId && state.callId === identity.callId);
1100
+ const adoptIdentity = (state, identity) => {
1101
+ state.itemId ??= identity.itemId;
1102
+ state.callId ??= identity.callId;
1103
+ return state;
1104
+ };
1105
+ const resolveCompatible = (candidates, identity) => {
1106
+ const uniqueCandidates = [...new Set(candidates)];
1107
+ if (!identity.itemId && !identity.callId) return uniqueCandidates.length === 1 ? uniqueCandidates.at(0) : void 0;
1108
+ const compatible = uniqueCandidates.filter((state) => !identitiesConflict(state, identity));
1109
+ const matches = compatible.filter((state) => sharesIdentity(state, identity));
1110
+ const matched = matches.length === 1 ? matches.at(0) : void 0;
1111
+ if (matched) return adoptIdentity(matched, identity);
1112
+ const soleCompatible = uniqueCandidates.length === 1 && compatible.length === 1 && matches.length === 0 ? compatible.at(0) : void 0;
1113
+ return soleCompatible ? adoptIdentity(soleCompatible, identity) : void 0;
1114
+ };
1115
+ return {
1116
+ register(event, state) {
1117
+ const outputIndex = readOutputIndex(event);
1118
+ if (outputIndex === void 0) {
1119
+ unindexedCalls.add(state);
1120
+ return;
1121
+ }
1122
+ if (indexedCalls.has(outputIndex)) throw new Error(`Responses stream reused active tool-call output index ${outputIndex}`);
1123
+ indexedCalls.set(outputIndex, state);
1124
+ },
1125
+ resolve(event, identity = readEventIdentity(event)) {
1126
+ const outputIndex = readOutputIndex(event);
1127
+ if (outputIndex !== void 0) {
1128
+ const indexed = indexedCalls.get(outputIndex);
1129
+ if (indexed) {
1130
+ if (indexed.callId && identity.callId && indexed.callId !== identity.callId) return;
1131
+ return adoptIdentity(indexed, identity);
1132
+ }
1133
+ const unindexed = resolveCompatible(unindexedCalls, identity);
1134
+ if (unindexed) {
1135
+ unindexedCalls.delete(unindexed);
1136
+ indexedCalls.set(outputIndex, unindexed);
1137
+ }
1138
+ return unindexed;
1139
+ }
1140
+ return resolveCompatible([...indexedCalls.values(), ...unindexedCalls], identity);
1141
+ },
1142
+ forget(toolCall) {
1143
+ for (const [outputIndex, tracked] of indexedCalls) if (tracked === toolCall) indexedCalls.delete(outputIndex);
1144
+ unindexedCalls.delete(toolCall);
1145
+ },
1146
+ markArgumentsUnreliable() {
1147
+ for (const toolCall of /* @__PURE__ */ new Set([...indexedCalls.values(), ...unindexedCalls])) toolCall.argumentStreamReliable = false;
1148
+ },
1149
+ hasActive() {
1150
+ return indexedCalls.size > 0 || unindexedCalls.size > 0;
1151
+ }
1152
+ };
1153
+ }
1154
+ //#endregion
1079
1155
  //#region packages/ai/src/providers/openai-tool-schema.ts
1080
1156
  /**
1081
1157
  * OpenAI strict JSON-schema normalization for tool inventories and request payloads.
@@ -1484,7 +1560,7 @@ function convertResponsesMessages(model, context, allowedToolCallProviders, opti
1484
1560
  } else if (msg.role === "toolResult") {
1485
1561
  const textResult = extractToolResultText(msg.content);
1486
1562
  const sanitizedTextResult = sanitizeSurrogates(textResult);
1487
- const hasImages = msg.content.some((c) => c.type === "image");
1563
+ const hasImages = msg.content.some(isImageWithMediaPayload);
1488
1564
  const mediaPlaceholder = describeToolResultMediaPlaceholder(msg.content);
1489
1565
  const hasText = sanitizedTextResult.trim().length > 0;
1490
1566
  const [callId] = splitResponsesToolCallId(msg.toolCallId);
@@ -1499,7 +1575,7 @@ function convertResponsesMessages(model, context, allowedToolCallProviders, opti
1499
1575
  type: "input_text",
1500
1576
  text: mediaPlaceholder
1501
1577
  });
1502
- for (const block of msg.content) if (block.type === "image") contentParts.push({
1578
+ for (const block of msg.content) if (isImageWithMediaPayload(block)) contentParts.push({
1503
1579
  type: "input_image",
1504
1580
  detail: "auto",
1505
1581
  image_url: `data:${block.mimeType};base64,${block.data}`
@@ -1637,60 +1713,14 @@ async function runResponsesStreamLifecycle(params) {
1637
1713
  async function processResponsesStream(openaiStream, output, stream, model, options) {
1638
1714
  let currentItem = null;
1639
1715
  let currentBlock = null;
1640
- const toolCallsByOutputIndex = /* @__PURE__ */ new Map();
1641
- const unindexedToolCalls = /* @__PURE__ */ new Set();
1716
+ const streamingToolCalls = createResponsesToolCallTracker();
1642
1717
  let lastTextBlock = null;
1643
1718
  let pendingMessageText = null;
1644
1719
  const blocks = output.content;
1645
1720
  const blockIndex = () => blocks.length - 1;
1646
- const readOutputIndex = (event) => typeof event.output_index === "number" && Number.isInteger(event.output_index) && event.output_index >= 0 ? event.output_index : void 0;
1647
1721
  const readIdentityValue = (value) => {
1648
1722
  return (typeof value === "string" ? value.trim() : "") || void 0;
1649
1723
  };
1650
- const readEventToolCallIdentity = (event) => ({ itemId: readIdentityValue(event.item_id) });
1651
- const readItemToolCallIdentity = (item) => ({
1652
- itemId: readIdentityValue(item.id),
1653
- callId: readIdentityValue(item.call_id)
1654
- });
1655
- const identitiesConflict = (state, identity) => Boolean(state.itemId && identity.itemId && state.itemId !== identity.itemId || state.callId && identity.callId && state.callId !== identity.callId);
1656
- const sharesIdentity = (state, identity) => Boolean(state.itemId && identity.itemId && state.itemId === identity.itemId || state.callId && identity.callId && state.callId === identity.callId);
1657
- const adoptToolCallIdentity = (state, identity) => {
1658
- state.itemId ??= identity.itemId;
1659
- state.callId ??= identity.callId;
1660
- return state;
1661
- };
1662
- const resolveCompatibleToolCall = (candidates, identity) => {
1663
- const uniqueCandidates = [...new Set(candidates)];
1664
- if (!identity.itemId && !identity.callId) return uniqueCandidates.length === 1 ? uniqueCandidates.at(0) : void 0;
1665
- const compatible = uniqueCandidates.filter((state) => !identitiesConflict(state, identity));
1666
- const matches = compatible.filter((state) => sharesIdentity(state, identity));
1667
- const matched = matches.length === 1 ? matches.at(0) : void 0;
1668
- if (matched) return adoptToolCallIdentity(matched, identity);
1669
- const soleCompatible = uniqueCandidates.length === 1 && compatible.length === 1 && matches.length === 0 ? compatible.at(0) : void 0;
1670
- return soleCompatible ? adoptToolCallIdentity(soleCompatible, identity) : void 0;
1671
- };
1672
- const resolveStreamingToolCall = (event, identity = readEventToolCallIdentity(event)) => {
1673
- const outputIndex = readOutputIndex(event);
1674
- if (outputIndex !== void 0) {
1675
- const indexed = toolCallsByOutputIndex.get(outputIndex);
1676
- if (indexed) return !identitiesConflict(indexed, identity) ? adoptToolCallIdentity(indexed, identity) : void 0;
1677
- const unindexed = resolveCompatibleToolCall(unindexedToolCalls, identity);
1678
- if (unindexed) {
1679
- unindexedToolCalls.delete(unindexed);
1680
- toolCallsByOutputIndex.set(outputIndex, unindexed);
1681
- }
1682
- return unindexed;
1683
- }
1684
- return resolveCompatibleToolCall([...toolCallsByOutputIndex.values(), ...unindexedToolCalls], identity);
1685
- };
1686
- const forgetStreamingToolCall = (toolCall) => {
1687
- for (const [trackedIndex, tracked] of toolCallsByOutputIndex) if (tracked === toolCall) toolCallsByOutputIndex.delete(trackedIndex);
1688
- unindexedToolCalls.delete(toolCall);
1689
- };
1690
- const markActiveToolCallArgumentsUnreliable = () => {
1691
- for (const toolCall of /* @__PURE__ */ new Set([...toolCallsByOutputIndex.values(), ...unindexedToolCalls])) toolCall.argumentStreamReliable = false;
1692
- };
1693
- const hasActiveStreamingToolCall = () => toolCallsByOutputIndex.size > 0 || unindexedToolCalls.size > 0;
1694
1724
  const resolveCompletedToolCallName = (toolCall, value) => {
1695
1725
  const streamedName = readIdentityValue(toolCall?.block.name);
1696
1726
  const completedName = readIdentityValue(value);
@@ -1770,26 +1800,24 @@ async function processResponsesStream(openaiStream, output, stream, model, optio
1770
1800
  });
1771
1801
  }
1772
1802
  } else if (item.type === "function_call") {
1773
- const outputIndex = readOutputIndex(event);
1774
- if (outputIndex !== void 0 && toolCallsByOutputIndex.has(outputIndex)) throw new Error(`Responses stream reused active tool-call output index ${outputIndex}`);
1775
- currentItem = item;
1776
- currentBlock = {
1803
+ const toolCallBlock = {
1777
1804
  type: "toolCall",
1778
1805
  id: resolveResponsesToolCallId(item),
1779
1806
  name: readIdentityValue(item.name) ?? "",
1780
1807
  arguments: {},
1781
1808
  partialJson: item.arguments || ""
1782
1809
  };
1783
- output.content.push(currentBlock);
1784
- const contentIndex = blockIndex();
1810
+ const contentIndex = output.content.length;
1785
1811
  const toolCallState = {
1786
- block: currentBlock,
1812
+ block: toolCallBlock,
1787
1813
  contentIndex,
1788
1814
  argumentStreamReliable: true,
1789
- ...readItemToolCallIdentity(item)
1815
+ ...readResponsesToolCallItemIdentity(item)
1790
1816
  };
1791
- if (outputIndex !== void 0) toolCallsByOutputIndex.set(outputIndex, toolCallState);
1792
- else unindexedToolCalls.add(toolCallState);
1817
+ streamingToolCalls.register(event, toolCallState);
1818
+ currentItem = item;
1819
+ currentBlock = toolCallBlock;
1820
+ output.content.push(toolCallBlock);
1793
1821
  stream.push({
1794
1822
  type: "toolcall_start",
1795
1823
  contentIndex,
@@ -1906,7 +1934,7 @@ async function processResponsesStream(openaiStream, output, stream, model, optio
1906
1934
  }
1907
1935
  }
1908
1936
  } else if (event.type === "response.function_call_arguments.delta") {
1909
- const toolCall = resolveStreamingToolCall(event);
1937
+ const toolCall = streamingToolCalls.resolve(event);
1910
1938
  if (toolCall) {
1911
1939
  toolCall.block.partialJson += event.delta;
1912
1940
  toolCall.block.arguments = parseStreamingJson(toolCall.block.partialJson);
@@ -1916,9 +1944,9 @@ async function processResponsesStream(openaiStream, output, stream, model, optio
1916
1944
  delta: event.delta,
1917
1945
  partial: output
1918
1946
  });
1919
- } else if (hasActiveStreamingToolCall()) markActiveToolCallArgumentsUnreliable();
1947
+ } else if (streamingToolCalls.hasActive()) streamingToolCalls.markArgumentsUnreliable();
1920
1948
  } else if (event.type === "response.function_call_arguments.done") {
1921
- const toolCall = resolveStreamingToolCall(event);
1949
+ const toolCall = streamingToolCalls.resolve(event);
1922
1950
  if (toolCall) {
1923
1951
  const previousPartialJson = toolCall.block.partialJson;
1924
1952
  const doneArguments = typeof event.arguments === "string" ? event.arguments : void 0;
@@ -1936,7 +1964,7 @@ async function processResponsesStream(openaiStream, output, stream, model, optio
1936
1964
  partial: output
1937
1965
  });
1938
1966
  }
1939
- } else if (hasActiveStreamingToolCall()) markActiveToolCallArgumentsUnreliable();
1967
+ } else if (streamingToolCalls.hasActive()) streamingToolCalls.markArgumentsUnreliable();
1940
1968
  } else if (event.type === "response.output_item.done") {
1941
1969
  const item = event.item;
1942
1970
  if (item.type !== "message") {
@@ -2006,8 +2034,8 @@ async function processResponsesStream(openaiStream, output, stream, model, optio
2006
2034
  }
2007
2035
  currentBlock = null;
2008
2036
  } else if (item.type === "function_call") {
2009
- const streamingToolCall = resolveStreamingToolCall(event, readItemToolCallIdentity(item));
2010
- if (!streamingToolCall && hasActiveStreamingToolCall()) continue;
2037
+ const streamingToolCall = streamingToolCalls.resolve(event, readResponsesToolCallItemIdentity(item));
2038
+ if (!streamingToolCall && streamingToolCalls.hasActive()) continue;
2011
2039
  const completedName = resolveCompletedToolCallName(streamingToolCall, item.name);
2012
2040
  const streamedArguments = streamingToolCall?.block.partialJson ?? "";
2013
2041
  const completedArguments = typeof item.arguments === "string" ? item.arguments : void 0;
@@ -2038,7 +2066,7 @@ async function processResponsesStream(openaiStream, output, stream, model, optio
2038
2066
  partial: output
2039
2067
  });
2040
2068
  }
2041
- if (streamingToolCall) forgetStreamingToolCall(streamingToolCall);
2069
+ if (streamingToolCall) streamingToolCalls.forget(streamingToolCall);
2042
2070
  if (currentBlock === toolCall) {
2043
2071
  currentBlock = null;
2044
2072
  currentItem = null;
@@ -2051,7 +2079,7 @@ async function processResponsesStream(openaiStream, output, stream, model, optio
2051
2079
  });
2052
2080
  }
2053
2081
  } else if (event.type === "response.completed") {
2054
- if (hasActiveStreamingToolCall()) throw new Error("Responses stream completed with unresolved tool calls");
2082
+ if (streamingToolCalls.hasActive()) throw new Error("Responses stream completed with unresolved tool calls");
2055
2083
  const response = event.response;
2056
2084
  if (response?.id) output.responseId = response.id;
2057
2085
  if (response?.usage) {
@@ -2087,7 +2115,7 @@ async function processResponsesStream(openaiStream, output, stream, model, optio
2087
2115
  const msg = error ? `${error.code || "unknown"}: ${error.message || "no message"}` : details?.reason ? `incomplete: ${details.reason}` : "Unknown error (no error details in response)";
2088
2116
  throw new Error(msg);
2089
2117
  }
2090
- if (hasActiveStreamingToolCall()) throw new Error("Responses stream ended with unresolved tool calls");
2118
+ if (streamingToolCalls.hasActive()) throw new Error("Responses stream ended with unresolved tool calls");
2091
2119
  }
2092
2120
  function mapStopReason(status) {
2093
2121
  if (!status) return "stop";
@@ -2102,4 +2130,4 @@ function mapStopReason(status) {
2102
2130
  }
2103
2131
  }
2104
2132
  //#endregion
2105
- export { supportsOpenAITemperature as A, isOpenAIGpt54MiniModel as C, resolveOpenAIReasoningEffortForModel as D, normalizeOpenAIReasoningEffort as E, stripUnsupportedSchemaKeywords as F, GEMINI_UNSUPPORTED_SCHEMA_KEYWORDS as I, cleanSchemaForGemini as L, normalizeToolParameterSchema as M, resolveUnsupportedToolSchemaKeywords as N, resolveOpenAISupportedReasoningEfforts as O, shouldOmitEmptyArrayItems as P, resolveResponsesMessageSnapshotCollapse as S, isOpenAIGpt56Model as T, OPENAI_RESPONSES_OUTPUT_TEXT_DELTA_EVENT_TYPE as _, resolveResponsesReasoningEffort as a, isResponsesTextContentPartType as b, clearOpenAIToolSchemaCacheForTest as c, normalizeOpenAIStrictToolParameters as d, normalizeStrictOpenAIJsonSchema as f, OPENAI_RESPONSES_OUTPUT_TEXT_CONTENT_PART_TYPE as g, AZURE_RESPONSES_TEXT_DELTA_EVENT_TYPE as h, processResponsesStream as i, extractToolSchemaModelCompat as j, supportsOpenAIReasoningEffort as k, findOpenAIStrictToolProjectionDiagnostics as l, AZURE_RESPONSES_TEXT_CONTENT_PART_TYPE as m, convertResponsesMessages as n, runResponsesStreamLifecycle as o, resolveOpenAIProjectedToolsStrictToolFlag as p, createResponsesAssistantOutput as r, convertResponsesToolPayload as s, applyCommonResponsesParams as t, isStrictOpenAIJsonSchemaCompatible as u, isAzureResponsesTextDeltaEvent as v, isOpenAIGpt55Model as w, isResponsesTextDeltaEventType as x, isAzureResponsesTextDeltaEventType as y };
2133
+ export { resolveOpenAISupportedReasoningEfforts as A, isResponsesTextDeltaEventType as C, isOpenAIGpt56Model as D, isOpenAIGpt55Model as E, resolveUnsupportedToolSchemaKeywords as F, shouldOmitEmptyArrayItems as I, stripUnsupportedSchemaKeywords as L, supportsOpenAITemperature as M, extractToolSchemaModelCompat as N, normalizeOpenAIReasoningEffort as O, normalizeToolParameterSchema as P, GEMINI_UNSUPPORTED_SCHEMA_KEYWORDS as R, isResponsesTextContentPartType as S, isOpenAIGpt54MiniModel as T, AZURE_RESPONSES_TEXT_DELTA_EVENT_TYPE as _, resolveResponsesReasoningEffort as a, isAzureResponsesTextDeltaEvent as b, clearOpenAIToolSchemaCacheForTest as c, normalizeOpenAIStrictToolParameters as d, normalizeStrictOpenAIJsonSchema as f, AZURE_RESPONSES_TEXT_CONTENT_PART_TYPE as g, readResponsesToolCallItemIdentity as h, processResponsesStream as i, supportsOpenAIReasoningEffort as j, resolveOpenAIReasoningEffortForModel as k, findOpenAIStrictToolProjectionDiagnostics as l, createResponsesToolCallTracker as m, convertResponsesMessages as n, runResponsesStreamLifecycle as o, resolveOpenAIProjectedToolsStrictToolFlag as p, createResponsesAssistantOutput as r, convertResponsesToolPayload as s, applyCommonResponsesParams as t, isStrictOpenAIJsonSchemaCompatible as u, OPENAI_RESPONSES_OUTPUT_TEXT_CONTENT_PART_TYPE as v, resolveResponsesMessageSnapshotCollapse as w, isAzureResponsesTextDeltaEventType as x, OPENAI_RESPONSES_OUTPUT_TEXT_DELTA_EVENT_TYPE as y, cleanSchemaForGemini as z };
@@ -1,4 +1,4 @@
1
- import { l as isRecord } from "./transform-messages-DNWpwvXA.mjs";
1
+ import { d as isRecord } from "./transform-messages-BmS70CP5.mjs";
2
2
  import { t as projectRuntimeToolInputSchema } from "./tool-schema-json-projection-BwNu3nDi.mjs";
3
3
  //#region packages/ai/src/providers/openai-prompt-cache.ts
4
4
  /** Maximum prompt cache key length accepted by OpenAI-compatible request metadata. */
@@ -63,35 +63,35 @@ function createLazyRegistration(api, importModule, select) {
63
63
  };
64
64
  }
65
65
  const registerBuiltIns = [
66
- createLazyRegistration("anthropic-messages", () => import("./anthropic-Cvm71xlk.mjs").then((n) => n.t), (module) => ({
66
+ createLazyRegistration("anthropic-messages", () => import("./anthropic-BIRSg5x9.mjs").then((n) => n.t), (module) => ({
67
67
  stream: module.streamAnthropic,
68
68
  streamSimple: module.streamSimpleAnthropic
69
69
  })),
70
- createLazyRegistration("openai-completions", () => import("./openai-completions-B2jr3vtJ.mjs").then((n) => n.n), (module) => ({
70
+ createLazyRegistration("openai-completions", () => import("./openai-completions-DPR_O2RW.mjs").then((n) => n.n), (module) => ({
71
71
  stream: module.streamOpenAICompletions,
72
72
  streamSimple: module.streamSimpleOpenAICompletions
73
73
  })),
74
- createLazyRegistration("mistral-conversations", () => import("./mistral-D-39Trax.mjs"), (module) => ({
74
+ createLazyRegistration("mistral-conversations", () => import("./mistral-DxMPt9q9.mjs"), (module) => ({
75
75
  stream: module.streamMistral,
76
76
  streamSimple: module.streamSimpleMistral
77
77
  })),
78
- createLazyRegistration("openai-responses", () => import("./openai-responses-DTpD8YVy.mjs").then((n) => n.t), (module) => ({
78
+ createLazyRegistration("openai-responses", () => import("./openai-responses-Cov-Vdc2.mjs").then((n) => n.t), (module) => ({
79
79
  stream: module.streamOpenAIResponses,
80
80
  streamSimple: module.streamSimpleOpenAIResponses
81
81
  })),
82
- createLazyRegistration("azure-openai-responses", () => import("./azure-openai-responses-b4lfJxYS.mjs"), (module) => ({
82
+ createLazyRegistration("azure-openai-responses", () => import("./azure-openai-responses-CHi7Wo4A.mjs"), (module) => ({
83
83
  stream: module.streamAzureOpenAIResponses,
84
84
  streamSimple: module.streamSimpleAzureOpenAIResponses
85
85
  })),
86
- createLazyRegistration("openai-chatgpt-responses", () => import("./openai-chatgpt-responses-DCA0K85L.mjs"), (module) => ({
86
+ createLazyRegistration("openai-chatgpt-responses", () => import("./openai-chatgpt-responses-BuH2NvsR.mjs"), (module) => ({
87
87
  stream: module.streamOpenAICodexResponses,
88
88
  streamSimple: module.streamSimpleOpenAICodexResponses
89
89
  })),
90
- createLazyRegistration("google-generative-ai", () => import("./google-C7PoDjpW.mjs"), (module) => ({
90
+ createLazyRegistration("google-generative-ai", () => import("./google-BmsqsNwR.mjs"), (module) => ({
91
91
  stream: module.streamGoogle,
92
92
  streamSimple: module.streamSimpleGoogle
93
93
  })),
94
- createLazyRegistration("google-vertex", () => import("./google-vertex-L_ABazIA.mjs"), (module) => ({
94
+ createLazyRegistration("google-vertex", () => import("./google-vertex-HZ_0rTwS.mjs"), (module) => ({
95
95
  stream: module.streamGoogleVertex,
96
96
  streamSimple: module.streamSimpleGoogleVertex
97
97
  }))
@@ -315,11 +315,19 @@ function truncateProviderToolText(text) {
315
315
  if (text.length <= PROVIDER_TOOL_RESULT_MAX_CHARS) return text;
316
316
  return `${truncateUtf16Safe(text, PROVIDER_TOOL_RESULT_MAX_CHARS)}\n…(truncated)…`;
317
317
  }
318
+ /** Media metadata alone is not an attachment; provider emitters need inline bytes. */
319
+ function hasMediaPayload(block) {
320
+ return isRecord(block) && typeof block.data === "string" && block.data.trim().length > 0;
321
+ }
322
+ /** Image metadata alone is not an attachment; provider emitters need inline bytes. */
323
+ function isImageWithMediaPayload(block) {
324
+ return isRecord(block) && block.type === "image" && hasMediaPayload(block);
325
+ }
318
326
  function describeToolResultMediaPlaceholder(blocks) {
319
327
  let hasImage = false;
320
328
  let hasAudio = false;
321
329
  for (const block of blocks) {
322
- if (!block || typeof block !== "object") continue;
330
+ if (!hasMediaPayload(block)) continue;
323
331
  const record = block;
324
332
  const type = typeof record.type === "string" ? record.type : void 0;
325
333
  const mimeType = readMimeType(record);
@@ -362,6 +370,7 @@ function replaceImagesWithPlaceholder(content, placeholder) {
362
370
  let previousWasPlaceholder = false;
363
371
  for (const block of content) {
364
372
  if (block.type === "image") {
373
+ if (!isImageWithMediaPayload(block)) continue;
365
374
  if (!previousWasPlaceholder) result.push({
366
375
  type: "text",
367
376
  text: placeholder
@@ -504,4 +513,4 @@ function transformMessages(messages, model, normalizeToolCallId) {
504
513
  return result;
505
514
  }
506
515
  //#endregion
507
- export { normalizeStructuredPromptSection as C, normalizePromptCapabilityIds as S, normalizeOptionalString as T, SYSTEM_PROMPT_CACHE_BOUNDARY as _, truncateUtf16Safe as a, splitSystemPromptCacheBoundary as b, clampReasoning as c, defaultsClaudeAdaptiveThinking as d, prepareClaudeSonnet5RequestContext as f, usesClaudeStreamingRefusalContract as g, usesClaudeFable5MessagesContract as h, extractToolResultText as i, isRecord as l, resolveModelBoundThinkingReplayMode as m, describeToolResultMediaPlaceholder as n, adjustMaxTokensForThinking as o, requiresClaudeAdaptiveThinking as p, extractToolResultBlockText as r, buildBaseOptions as s, transformMessages as t, applyClaudeRequestContract as u, ensureSystemPromptCacheBoundary as v, normalizeLowercaseStringOrEmpty as w, stripSystemPromptCacheBoundary as x, prependSystemPromptAdditionAfterCacheBoundary as y };
516
+ export { stripSystemPromptCacheBoundary as C, normalizeOptionalString as D, normalizeLowercaseStringOrEmpty as E, splitSystemPromptCacheBoundary as S, normalizeStructuredPromptSection as T, usesClaudeFable5MessagesContract as _, hasMediaPayload as a, ensureSystemPromptCacheBoundary as b, adjustMaxTokensForThinking as c, isRecord as d, applyClaudeRequestContract as f, resolveModelBoundThinkingReplayMode as g, requiresClaudeAdaptiveThinking as h, extractToolResultText as i, buildBaseOptions as l, prepareClaudeSonnet5RequestContext as m, describeToolResultMediaPlaceholder as n, isImageWithMediaPayload as o, defaultsClaudeAdaptiveThinking as p, extractToolResultBlockText as r, truncateUtf16Safe as s, transformMessages as t, clampReasoning as u, usesClaudeStreamingRefusalContract as v, normalizePromptCapabilityIds as w, prependSystemPromptAdditionAfterCacheBoundary as x, SYSTEM_PROMPT_CACHE_BOUNDARY as y };
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@openclaw/ai",
3
- "version": "2026.7.2-beta.1",
3
+ "version": "2026.7.2-beta.2",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@openclaw/ai",
9
- "version": "2026.7.2-beta.1",
9
+ "version": "2026.7.2-beta.2",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@anthropic-ai/sdk": "0.109.1",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openclaw/ai",
3
- "version": "2026.7.2-beta.1",
3
+ "version": "2026.7.2-beta.2",
4
4
  "description": "Reusable model provider adapters and streaming runtime from OpenClaw",
5
5
  "keywords": [
6
6
  "ai",