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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/dist/{anthropic-Cvm71xlk.mjs → anthropic-D7SyZQ5v.mjs} +58 -39
  2. package/dist/{api-registry-Byvoz8Ha.d.mts → api-registry-DXBIXISf.d.mts} +1 -1
  3. package/dist/{azure-openai-responses-b4lfJxYS.mjs → azure-openai-responses-BkZgyZ3I.mjs} +5 -4
  4. package/dist/{event-stream-uQspnL8S.d.mts → event-stream-BPemFrFW.d.mts} +1 -1
  5. package/dist/event-stream.d.mts +1 -1
  6. package/dist/{google-C7PoDjpW.mjs → google-C_biGbV7.mjs} +2 -2
  7. package/dist/{google-shared-C7ohrmOI.mjs → google-shared-BK-NoHl8.mjs} +5 -4
  8. package/dist/{google-vertex-L_ABazIA.mjs → google-vertex-CvdzF1U7.mjs} +2 -2
  9. package/dist/index.d.mts +4 -4
  10. package/dist/internal/anthropic.d.mts +8 -2
  11. package/dist/internal/anthropic.mjs +3 -3
  12. package/dist/internal/openai.d.mts +27 -2
  13. package/dist/internal/openai.mjs +5 -5
  14. package/dist/internal/runtime.d.mts +2 -2
  15. package/dist/internal/runtime.mjs +3 -2
  16. package/dist/internal/shared.d.mts +13 -2
  17. package/dist/internal/shared.mjs +2 -2
  18. package/dist/{mistral-D-39Trax.mjs → mistral-BdrQmDWp.mjs} +25 -9
  19. package/dist/{model-utils-Q1LSRIdo.mjs → model-utils-1GiZ2_rr.mjs} +3 -1
  20. package/dist/{openai-chatgpt-responses-DCA0K85L.mjs → openai-chatgpt-responses-DP63Qt01.mjs} +11 -9
  21. package/dist/{openai-completions-B2jr3vtJ.mjs → openai-completions-zLDfebnN.mjs} +42 -21
  22. package/dist/{openai-responses-DTpD8YVy.mjs → openai-responses-ClspWt4I.mjs} +3 -3
  23. package/dist/{openai-responses-shared-B9mtGvXq.mjs → openai-responses-shared-CwnGU0KW.mjs} +412 -284
  24. package/dist/{openai-tool-projection-cTLC4F65.mjs → openai-tool-projection-WHf2nuOI.mjs} +1 -1
  25. package/dist/provider-error-LMfTEkfO.mjs +40 -0
  26. package/dist/providers.d.mts +1 -1
  27. package/dist/providers.mjs +8 -8
  28. package/dist/{transform-messages-DNWpwvXA.mjs → transform-messages-eb6lxDLB.mjs} +18 -3
  29. package/dist/{types-Cx2zJtyz.d.mts → types-CYORveZ7.d.mts} +6 -0
  30. package/dist/types.d.mts +3 -3
  31. package/dist/{validation-Cej7htKc.d.mts → validation-BX8euiDv.d.mts} +1 -1
  32. package/dist/validation.d.mts +1 -1
  33. package/npm-shrinkwrap.json +2 -2
  34. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import { l as isRecord } from "./transform-messages-DNWpwvXA.mjs";
1
+ import { f as isRecord } from "./transform-messages-eb6lxDLB.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. */
@@ -0,0 +1,40 @@
1
+ //#region packages/ai/src/utils/provider-error.ts
2
+ const MAX_ERROR_BODY_LENGTH = 4e3;
3
+ function stringify(value) {
4
+ try {
5
+ return JSON.stringify(value) ?? String(value);
6
+ } catch {
7
+ return String(value);
8
+ }
9
+ }
10
+ function readStatus(error) {
11
+ for (const value of [
12
+ error.status,
13
+ error.statusCode,
14
+ error.response?.status,
15
+ error.response?.statusCode
16
+ ]) if (typeof value === "number" && Number.isFinite(value)) return value;
17
+ }
18
+ function readBody(error) {
19
+ for (const value of [
20
+ error.body,
21
+ error.error,
22
+ error.response?.body,
23
+ error.response?.data
24
+ ]) {
25
+ if (value === void 0 || value === null) continue;
26
+ if (typeof value === "object" && !Array.isArray(value) && Object.keys(value).length === 0) continue;
27
+ const body = (typeof value === "string" ? value : stringify(value)).trim();
28
+ if (body.length > 0) return body.length <= MAX_ERROR_BODY_LENGTH ? body : `${body.slice(0, MAX_ERROR_BODY_LENGTH)}... [truncated]`;
29
+ }
30
+ }
31
+ function formatProviderError(error) {
32
+ if (!(error instanceof Error)) return stringify(error);
33
+ const httpError = error;
34
+ const status = readStatus(httpError);
35
+ const body = readBody(httpError);
36
+ if (status === void 0 || body === void 0 || error.message.includes(body)) return error.message;
37
+ return `${status}: ${body}`;
38
+ }
39
+ //#endregion
40
+ export { formatProviderError as t };
@@ -1,4 +1,4 @@
1
- import { n as ApiRegistry } from "./api-registry-Byvoz8Ha.mjs";
1
+ import { n as ApiRegistry } from "./api-registry-DXBIXISf.mjs";
2
2
 
3
3
  //#region packages/ai/src/providers/register-builtins.d.ts
4
4
  /** Source id used for built-in API provider registrations. */
@@ -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-D7SyZQ5v.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-zLDfebnN.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-BdrQmDWp.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-ClspWt4I.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-BkZgyZ3I.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-DP63Qt01.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-C_biGbV7.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-CvdzF1U7.mjs"), (module) => ({
95
95
  stream: module.streamGoogleVertex,
96
96
  streamSimple: module.streamSimpleGoogleVertex
97
97
  }))
@@ -183,6 +183,9 @@ function buildBaseOptions(model, options, apiKey) {
183
183
  metadata: options?.metadata
184
184
  };
185
185
  }
186
+ function clampMaxTokensToModel(model, requestedMaxTokens) {
187
+ return requestedMaxTokens === void 0 ? void 0 : Math.max(1, Math.min(requestedMaxTokens, model.maxTokens));
188
+ }
186
189
  function clampReasoning(effort) {
187
190
  return effort === "xhigh" ? "high" : effort;
188
191
  }
@@ -315,11 +318,19 @@ function truncateProviderToolText(text) {
315
318
  if (text.length <= PROVIDER_TOOL_RESULT_MAX_CHARS) return text;
316
319
  return `${truncateUtf16Safe(text, PROVIDER_TOOL_RESULT_MAX_CHARS)}\n…(truncated)…`;
317
320
  }
321
+ /** Media metadata alone is not an attachment; provider emitters need inline bytes. */
322
+ function hasMediaPayload(block) {
323
+ return isRecord(block) && typeof block.data === "string" && block.data.trim().length > 0;
324
+ }
325
+ /** Image metadata alone is not an attachment; provider emitters need inline bytes. */
326
+ function isImageWithMediaPayload(block) {
327
+ return isRecord(block) && block.type === "image" && hasMediaPayload(block);
328
+ }
318
329
  function describeToolResultMediaPlaceholder(blocks) {
319
330
  let hasImage = false;
320
331
  let hasAudio = false;
321
332
  for (const block of blocks) {
322
- if (!block || typeof block !== "object") continue;
333
+ if (!hasMediaPayload(block)) continue;
323
334
  const record = block;
324
335
  const type = typeof record.type === "string" ? record.type : void 0;
325
336
  const mimeType = readMimeType(record);
@@ -362,6 +373,7 @@ function replaceImagesWithPlaceholder(content, placeholder) {
362
373
  let previousWasPlaceholder = false;
363
374
  for (const block of content) {
364
375
  if (block.type === "image") {
376
+ if (!isImageWithMediaPayload(block)) continue;
365
377
  if (!previousWasPlaceholder) result.push({
366
378
  type: "text",
367
379
  text: placeholder
@@ -395,7 +407,10 @@ function downgradeUnsupportedImages(messages, model) {
395
407
  */
396
408
  function transformMessages(messages, model, normalizeToolCallId) {
397
409
  const toolCallIdMap = /* @__PURE__ */ new Map();
398
- const transformed = downgradeUnsupportedImages(messages, model).map((msg) => {
410
+ const transformed = downgradeUnsupportedImages(messages.map((msg) => msg.content == null ? {
411
+ ...msg,
412
+ content: []
413
+ } : msg), model).map((msg) => {
399
414
  if (msg.role === "user") return msg;
400
415
  if (msg.role === "toolResult") {
401
416
  const normalizedId = toolCallIdMap.get(msg.toolCallId);
@@ -504,4 +519,4 @@ function transformMessages(messages, model, normalizeToolCallId) {
504
519
  return result;
505
520
  }
506
521
  //#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 };
522
+ export { splitSystemPromptCacheBoundary as C, normalizeLowercaseStringOrEmpty as D, normalizeStructuredPromptSection as E, normalizeOptionalString as O, prependSystemPromptAdditionAfterCacheBoundary as S, normalizePromptCapabilityIds as T, resolveModelBoundThinkingReplayMode as _, hasMediaPayload as a, SYSTEM_PROMPT_CACHE_BOUNDARY as b, adjustMaxTokensForThinking as c, clampReasoning as d, isRecord as f, requiresClaudeAdaptiveThinking as g, prepareClaudeSonnet5RequestContext as h, extractToolResultText as i, buildBaseOptions as l, defaultsClaudeAdaptiveThinking as m, describeToolResultMediaPlaceholder as n, isImageWithMediaPayload as o, applyClaudeRequestContract as p, extractToolResultBlockText as r, truncateUtf16Safe as s, transformMessages as t, clampMaxTokensToModel as u, usesClaudeFable5MessagesContract as v, stripSystemPromptCacheBoundary as w, ensureSystemPromptCacheBoundary as x, usesClaudeStreamingRefusalContract as y };
@@ -212,6 +212,8 @@ interface Usage {
212
212
  output: number;
213
213
  cacheRead: number;
214
214
  cacheWrite: number;
215
+ /** Subset of `cacheWrite` written with 1-hour retention when reported. */
216
+ cacheWrite1h?: number;
215
217
  /** Exact context snapshot for the final provider iteration. */
216
218
  contextUsage?: {
217
219
  state: "available";
@@ -435,6 +437,8 @@ interface OpenAICompletionsCompat {
435
437
  }
436
438
  /** Compatibility settings for OpenAI Responses APIs. */
437
439
  interface OpenAIResponsesCompat {
440
+ /** Whether the provider supports the `developer` role (vs `system`). Default: true. */
441
+ supportsDeveloperRole?: boolean;
438
442
  /** Whether the model accepts the `temperature` parameter. Default: true. */
439
443
  supportsTemperature?: boolean;
440
444
  /** Whether to send the OpenAI `session_id` cache-affinity header from `options.sessionId` when caching is enabled. Default: true. */
@@ -470,6 +474,8 @@ interface AnthropicMessagesCompat {
470
474
  * Default: true.
471
475
  */
472
476
  supportsCacheControlOnTools?: boolean;
477
+ /** Whether empty thinking signatures can be replayed as native thinking blocks. Default: false. */
478
+ allowEmptySignature?: boolean;
473
479
  }
474
480
  /**
475
481
  * OpenRouter provider routing preferences.
package/dist/types.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { a as resolveClaudeFable5ModelIdentity, c as resolveClaudeNativeThinkingLevelMap, d as supportsClaudeNativeMaxEffort, f as supportsClaudeNativeXhighEffort, i as requiresClaudeMandatoryAdaptiveThinking, l as resolveClaudeSonnet5ModelIdentity, n as CLAUDE_SONNET_5_THINKING_PROFILE, o as resolveClaudeModelIdentity, r as requiresClaudeDefaultSampling, s as resolveClaudeMythos5ModelIdentity, t as CLAUDE_FABLE_5_THINKING_PROFILE, u as supportsClaudeAdaptiveThinking } from "./index-BoTnz8cv.mjs";
2
2
  import { a as extractDiagnosticError, i as createAssistantMessageDiagnostic, n as DiagnosticErrorInfo, o as formatThrownValue, r as appendAssistantMessageDiagnostic, t as AssistantMessageDiagnostic } from "./diagnostics-BaTA9eVl.mjs";
3
- import { $ as VercelGatewayRouting, A as OpenRouterRouting, B as TextContent, C as KnownImagesProvider, D as ModelThinkingLevel, E as Model, F as SimpleStreamOptions, G as ThinkingLevelMap, H as ThinkingBudgets, I as StopReason, J as ToolResultMessage, K as Tool, L as StreamFn, M as ProviderImagesOptions, N as ProviderResponse, O as OpenAICompletionsCompat, P as ProviderStreamOptions, Q as ValidateToolArgumentsFn, R as StreamFunction, S as KnownImagesApi, T as Message, U as ThinkingContent, V as TextSignatureV1, W as ThinkingLevel, X as Usage, Y as Transport, Z as UserMessage, _ as ImagesOptions, a as AssistantMessageEvent, b as ImagesStopReason, c as CacheRetention, d as ImageContent, f as ImagesApi, g as ImagesModel, h as ImagesInputContent, i as AssistantMessage, j as Provider, k as OpenAIResponsesCompat, l as CompleteSimpleFn, m as ImagesFunction, n as Api, o as AssistantMessageEventStreamContract, p as ImagesContext, q as ToolCall, r as AssistantImages, s as AssistantMessageEventStreamLike, t as AnthropicMessagesCompat, u as Context, v as ImagesOutputContent, w as MaybePromise, x as KnownApi, y as ImagesProvider, z as StreamOptions } from "./types-Cx2zJtyz.mjs";
4
- import { n as EventStream, r as createAssistantMessageEventStream, t as AssistantMessageEventStream } from "./event-stream-uQspnL8S.mjs";
5
- import { n as validateToolCall, t as validateToolArguments } from "./validation-Cej7htKc.mjs";
3
+ import { $ as VercelGatewayRouting, A as OpenRouterRouting, B as TextContent, C as KnownImagesProvider, D as ModelThinkingLevel, E as Model, F as SimpleStreamOptions, G as ThinkingLevelMap, H as ThinkingBudgets, I as StopReason, J as ToolResultMessage, K as Tool, L as StreamFn, M as ProviderImagesOptions, N as ProviderResponse, O as OpenAICompletionsCompat, P as ProviderStreamOptions, Q as ValidateToolArgumentsFn, R as StreamFunction, S as KnownImagesApi, T as Message, U as ThinkingContent, V as TextSignatureV1, W as ThinkingLevel, X as Usage, Y as Transport, Z as UserMessage, _ as ImagesOptions, a as AssistantMessageEvent, b as ImagesStopReason, c as CacheRetention, d as ImageContent, f as ImagesApi, g as ImagesModel, h as ImagesInputContent, i as AssistantMessage, j as Provider, k as OpenAIResponsesCompat, l as CompleteSimpleFn, m as ImagesFunction, n as Api, o as AssistantMessageEventStreamContract, p as ImagesContext, q as ToolCall, r as AssistantImages, s as AssistantMessageEventStreamLike, t as AnthropicMessagesCompat, u as Context, v as ImagesOutputContent, w as MaybePromise, x as KnownApi, y as ImagesProvider, z as StreamOptions } from "./types-CYORveZ7.mjs";
4
+ import { n as EventStream, r as createAssistantMessageEventStream, t as AssistantMessageEventStream } from "./event-stream-BPemFrFW.mjs";
5
+ import { n as validateToolCall, t as validateToolArguments } from "./validation-BX8euiDv.mjs";
6
6
  export { AnthropicMessagesCompat, Api, AssistantImages, AssistantMessage, AssistantMessageDiagnostic, AssistantMessageEvent, AssistantMessageEventStream, AssistantMessageEventStreamContract, AssistantMessageEventStreamLike, CLAUDE_FABLE_5_THINKING_PROFILE, CLAUDE_SONNET_5_THINKING_PROFILE, CacheRetention, CompleteSimpleFn, Context, DiagnosticErrorInfo, EventStream, ImageContent, ImagesApi, ImagesContext, ImagesFunction, ImagesInputContent, ImagesModel, ImagesOptions, ImagesOutputContent, ImagesProvider, ImagesStopReason, KnownApi, KnownImagesApi, KnownImagesProvider, MaybePromise, Message, Model, ModelThinkingLevel, OpenAICompletionsCompat, OpenAIResponsesCompat, OpenRouterRouting, Provider, ProviderImagesOptions, ProviderResponse, ProviderStreamOptions, SimpleStreamOptions, StopReason, StreamFn, StreamFunction, StreamOptions, TextContent, TextSignatureV1, ThinkingBudgets, ThinkingContent, ThinkingLevel, ThinkingLevelMap, Tool, ToolCall, ToolResultMessage, Transport, Usage, UserMessage, ValidateToolArgumentsFn, VercelGatewayRouting, appendAssistantMessageDiagnostic, createAssistantMessageDiagnostic, createAssistantMessageEventStream, extractDiagnosticError, formatThrownValue, requiresClaudeDefaultSampling, requiresClaudeMandatoryAdaptiveThinking, resolveClaudeFable5ModelIdentity, resolveClaudeModelIdentity, resolveClaudeMythos5ModelIdentity, resolveClaudeNativeThinkingLevelMap, resolveClaudeSonnet5ModelIdentity, supportsClaudeAdaptiveThinking, supportsClaudeNativeMaxEffort, supportsClaudeNativeXhighEffort, validateToolArguments, validateToolCall };
@@ -1,4 +1,4 @@
1
- import { K as Tool, q as ToolCall } from "./types-Cx2zJtyz.mjs";
1
+ import { K as Tool, q as ToolCall } from "./types-CYORveZ7.mjs";
2
2
 
3
3
  //#region packages/llm-core/src/validation.d.ts
4
4
  /** Finds the target tool and validates/coerces a model-emitted tool call. */
@@ -1,2 +1,2 @@
1
- import { n as validateToolCall, t as validateToolArguments } from "./validation-Cej7htKc.mjs";
1
+ import { n as validateToolCall, t as validateToolArguments } from "./validation-BX8euiDv.mjs";
2
2
  export { validateToolArguments, validateToolCall };
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@openclaw/ai",
3
- "version": "2026.7.2-beta.1",
3
+ "version": "2026.7.2-beta.3",
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.3",
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.3",
4
4
  "description": "Reusable model provider adapters and streaming runtime from OpenClaw",
5
5
  "keywords": [
6
6
  "ai",