@openclaw/ai 2026.7.2-beta.2 → 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-BIRSg5x9.mjs → anthropic-D7SyZQ5v.mjs} +54 -35
  2. package/dist/{api-registry-Byvoz8Ha.d.mts → api-registry-DXBIXISf.d.mts} +1 -1
  3. package/dist/{azure-openai-responses-CHi7Wo4A.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-BmsqsNwR.mjs → google-C_biGbV7.mjs} +2 -2
  7. package/dist/{google-shared-Dx2aba47.mjs → google-shared-BK-NoHl8.mjs} +4 -3
  8. package/dist/{google-vertex-HZ_0rTwS.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 +2 -1
  13. package/dist/internal/openai.mjs +4 -4
  14. package/dist/internal/runtime.d.mts +2 -2
  15. package/dist/internal/runtime.mjs +3 -2
  16. package/dist/internal/shared.d.mts +4 -2
  17. package/dist/internal/shared.mjs +2 -2
  18. package/dist/{mistral-DxMPt9q9.mjs → mistral-BdrQmDWp.mjs} +23 -7
  19. package/dist/{model-utils-Q1LSRIdo.mjs → model-utils-1GiZ2_rr.mjs} +3 -1
  20. package/dist/{openai-chatgpt-responses-BuH2NvsR.mjs → openai-chatgpt-responses-DP63Qt01.mjs} +11 -9
  21. package/dist/{openai-completions-DPR_O2RW.mjs → openai-completions-zLDfebnN.mjs} +39 -15
  22. package/dist/{openai-responses-Cov-Vdc2.mjs → openai-responses-ClspWt4I.mjs} +3 -3
  23. package/dist/{openai-responses-shared-Befb4D6R.mjs → openai-responses-shared-CwnGU0KW.mjs} +323 -223
  24. package/dist/{openai-tool-projection-CFqm42J2.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-BmS70CP5.mjs → transform-messages-eb6lxDLB.mjs} +8 -2
  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 { d as isRecord } from "./transform-messages-BmS70CP5.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-BIRSg5x9.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-DPR_O2RW.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-DxMPt9q9.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-Cov-Vdc2.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-CHi7Wo4A.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-BuH2NvsR.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-BmsqsNwR.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-HZ_0rTwS.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
  }
@@ -404,7 +407,10 @@ function downgradeUnsupportedImages(messages, model) {
404
407
  */
405
408
  function transformMessages(messages, model, normalizeToolCallId) {
406
409
  const toolCallIdMap = /* @__PURE__ */ new Map();
407
- 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) => {
408
414
  if (msg.role === "user") return msg;
409
415
  if (msg.role === "toolResult") {
410
416
  const normalizedId = toolCallIdMap.get(msg.toolCallId);
@@ -513,4 +519,4 @@ function transformMessages(messages, model, normalizeToolCallId) {
513
519
  return result;
514
520
  }
515
521
  //#endregion
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 };
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.2",
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.2",
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.2",
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",