@openclaw/ai 2026.11.3 → 2026.11.5-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.
Files changed (140) hide show
  1. package/README.md +11 -8
  2. package/dist/.source-module-urls/fe058cc430242ce2ab0dfbcbe153e240a52cf9c3072c3dc0a73e5f956b6ba49b.json +1 -0
  3. package/dist/anthropic-DEKgalVg.mjs +182 -0
  4. package/dist/{anthropic-payload-policy-C0ki72BT.d.mts → anthropic-payload-policy-CXCJ5Pmj.d.mts} +21 -4
  5. package/dist/{anthropic-stream-reducer-yWDb5Cct.mjs → anthropic-stream-lifecycle-DF2qVvg1.mjs} +845 -649
  6. package/dist/{anthropic-tool-projection-C2-d1eZ3.d.mts → anthropic-tool-projection-D5DyrL6C.d.mts} +6 -7
  7. package/dist/{anthropic-tool-projection-DZOKfAmL.mjs → anthropic-tool-projection-dGRfr4iT.mjs} +22 -32
  8. package/dist/{api-registry-gDt0faai.d.mts → api-registry-DY2MLUyg.d.mts} +2 -2
  9. package/dist/assistant-output-CD4kY9gu.mjs +16 -0
  10. package/dist/{azure-openai-responses-BvvXzZbi.mjs → azure-openai-responses-DbQV5RTx.mjs} +47 -53
  11. package/dist/{cloudflare-Dttf8jKq.mjs → cloudflare-BJ2_Xabx.mjs} +1 -1
  12. package/dist/{credential-redaction-XvsPf7Yi.d.mts → credential-redaction-DrgndwTJ.d.mts} +5 -3
  13. package/dist/{deferred-event-buffer-DAvyP7qA.mjs → deferred-event-buffer-tIGkTkTm.mjs} +1 -2
  14. package/dist/{diagnostics-v7oVEW59.mjs → diagnostics-CloVGQiK.mjs} +27 -20
  15. package/dist/{diagnostics-DzrF1h4J.mjs → diagnostics-o1PrVNQb.mjs} +11 -4
  16. package/dist/diagnostics.d.mts +6 -7
  17. package/dist/diagnostics.mjs +4 -4
  18. package/dist/{env-api-keys-Xd8dm_aV.mjs → env-api-keys-BuHc86ya.mjs} +1 -26
  19. package/dist/event-stream-B4ZcSvsu.d.mts +1 -0
  20. package/dist/{event-stream-CzpE1g_o.d.mts → event-stream-BYmtRe8-.d.mts} +1 -1
  21. package/dist/event-stream.d.mts +2 -2
  22. package/dist/event-stream.mjs +1 -2
  23. package/dist/expect-lbe3Hgrh.mjs +8 -0
  24. package/dist/{github-copilot-request-facts-F-EmvkpW.mjs → github-copilot-request-facts-BZ_EMo7X.mjs} +1 -1
  25. package/dist/{google-Cpi_cLKZ.mjs → google-B1g82bn4.mjs} +7 -8
  26. package/dist/{google-interactions-CGINbsjO.mjs → google-interactions-Ckr0Z99Z.mjs} +243 -269
  27. package/dist/{google-messages-DQMgG5yG.mjs → google-messages-A-9d3y5V.mjs} +52 -18
  28. package/dist/{google-provider-stream-BHd0cST9.mjs → google-provider-stream-CNVh4gpm.mjs} +19 -11
  29. package/dist/{google-shared-vtag8bj5.mjs → google-shared-WNM86ZcW.mjs} +72 -42
  30. package/dist/{google-vertex-eKoUnW7N.mjs → google-vertex-CXjleC6g.mjs} +3 -3
  31. package/dist/{google-video-slots-D8tPH8wX.mjs → google-video-slots-Bxt-OXO8.mjs} +1 -1
  32. package/dist/{host-CWt55nnF.mjs → host-DX7ORpeH.mjs} +46 -39
  33. package/dist/{host-jJOffdlW.d.mts → host-ccbwPC3A.d.mts} +17 -9
  34. package/dist/{host-policy-Dm7PM6AD.mjs → host-policy-jCZebuXx.mjs} +2 -2
  35. package/dist/index-Bczt0MnO.d.mts +17 -0
  36. package/dist/index.d.mts +8 -7
  37. package/dist/index.mjs +9 -7
  38. package/dist/internal/anthropic.d.mts +21 -26
  39. package/dist/internal/anthropic.mjs +6 -6
  40. package/dist/internal/google-model-family.mjs +1 -1
  41. package/dist/internal/google.d.mts +15 -0
  42. package/dist/internal/google.mjs +1 -0
  43. package/dist/internal/model-request-body.d.mts +37 -0
  44. package/dist/internal/model-request-body.mjs +106 -0
  45. package/dist/internal/openai-completions-compat.d.mts +1 -1
  46. package/dist/internal/openai-completions-compat.mjs +1 -1
  47. package/dist/internal/openai-responses-payload-policy.d.mts +2 -2
  48. package/dist/internal/openai-responses-payload-policy.mjs +2 -2
  49. package/dist/internal/openai.d.mts +14 -12
  50. package/dist/internal/openai.mjs +11 -10
  51. package/dist/internal/reasoning-tag-text-partitioner.d.mts +26 -0
  52. package/dist/{reasoning-tag-text-partitioner-CU9A4Lg8.mjs → internal/reasoning-tag-text-partitioner.mjs} +313 -111
  53. package/dist/internal/retry-after.d.mts +2 -2
  54. package/dist/internal/retry-after.mjs +96 -32
  55. package/dist/internal/runtime.d.mts +15 -41
  56. package/dist/internal/runtime.mjs +9 -10
  57. package/dist/internal/shared.d.mts +21 -25
  58. package/dist/internal/shared.mjs +9 -98
  59. package/dist/internal/tool-schema.d.mts +10 -10
  60. package/dist/internal/tool-schema.mjs +4 -4
  61. package/dist/{llm-request-activity-CfMuh5cC.mjs → llm-request-activity-DzaHoRAU.mjs} +2 -2
  62. package/dist/mistral-CjHkvsqR.mjs +3741 -0
  63. package/dist/{openai.LICENSE → mistral.LICENSE} +1 -1
  64. package/dist/{model-transport-url-BrsjjdjR.d.mts → model-transport-url-BdksnBqu.d.mts} +6 -8
  65. package/dist/{number-coercion-37gmNkuA.mjs → number-coercion-C7HsBgUL.mjs} +7 -2
  66. package/dist/observe-async-iterator-AlARO5wS.d.mts +178 -0
  67. package/dist/observe-async-iterator-DgmegcZR.mjs +181 -0
  68. package/dist/{openai-chatgpt-responses-BZa3SySh.mjs → openai-chatgpt-responses-CwS5JP7A.mjs} +61 -80
  69. package/dist/{openai-completions-compat-CBvb2eld.d.mts → openai-completions-compat-CJ-NsDzg.d.mts} +12 -6
  70. package/dist/{openai-completions-compat-bNQXF1y9.mjs → openai-completions-compat-CstlTQuF.mjs} +74 -50
  71. package/dist/{openai-completions-CCZ_UHCk.mjs → openai-completions-sj4S-RXQ.mjs} +5 -5
  72. package/dist/openai-completions-transport-BDAIA0_P.mjs +3406 -0
  73. package/dist/{openai-prompt-cache-DgjD-UL5.d.mts → openai-prompt-cache-BZGaIWYh.d.mts} +4 -4
  74. package/dist/{openai-prompt-cache-B9AvdoEo.mjs → openai-prompt-cache-CgDoFhO0.mjs} +5 -4
  75. package/dist/{openai-responses-compaction-replay-_sUXtcwU.d.mts → openai-responses-compaction-replay-CNHk6k53.d.mts} +4 -4
  76. package/dist/{openai-responses-contracts-B1nkeLL6.d.mts → openai-responses-contracts-BXMcvO7F.d.mts} +4 -10
  77. package/dist/{openai-responses-contracts-B5mGAbR6.mjs → openai-responses-contracts-xU-n9AJJ.mjs} +36 -37
  78. package/dist/{openai-responses-endpoint-CfKR6N5f.mjs → openai-responses-endpoint-DCkURKS0.mjs} +55 -8
  79. package/dist/openai-responses-ev_c6oTy.mjs +89 -0
  80. package/dist/{openai-responses-payload-policy-BzM52TTH.d.mts → openai-responses-payload-policy-DyE30gdD.d.mts} +7 -7
  81. package/dist/{openai-responses-request-lifecycle-CTqHc02t.mjs → openai-responses-request-lifecycle-BuOs0mwI.mjs} +12 -26
  82. package/dist/{openai-responses-shared-wx9v1MCn.mjs → openai-responses-shared-BmRQnUPP.mjs} +633 -1493
  83. package/dist/{openai-responses-terminal-usage-CpVjkqn-.d.mts → openai-responses-terminal-usage-D7IhRA6i.d.mts} +9 -3
  84. package/dist/{openai-tool-schema-BTEU2xmN.mjs → openai-tool-schema-CsoYgnWy.mjs} +97 -122
  85. package/dist/otel-Buswj0Mf.mjs +766 -0
  86. package/dist/{overflow-OF3PgPbw.mjs → overflow-CpApyjG2.mjs} +1 -1
  87. package/dist/{positive-integer-Bb4Evc7L.mjs → positive-integer-DiqE5vNi.mjs} +2 -3
  88. package/dist/{prompt-cache-stability-D_MeCQFI.mjs → prompt-cache-stability-w-ICeyOI.mjs} +1 -1
  89. package/dist/{provider-error-qtZD2inE.mjs → provider-error-DD-fo4Rz.mjs} +71 -234
  90. package/dist/{provider-options-DAzsyi49.d.mts → provider-options-Mo8NM5d1.d.mts} +16 -5
  91. package/dist/{provider-replay-context-4vxI7p4V.mjs → provider-replay-context-xyU7-CiT.mjs} +2 -2
  92. package/dist/provider-transcript-transform-DtaxNcC1.mjs +32 -0
  93. package/dist/{provider-transport-turn-state-D_GjPJHe.mjs → provider-transport-turn-state-BIS8maBK.mjs} +4 -4
  94. package/dist/{provider-types-CWl4VXvE.d.mts → provider-types-B1e98js5.d.mts} +3 -3
  95. package/dist/provider-types.d.mts +7 -6
  96. package/dist/providers.d.mts +2 -2
  97. package/dist/providers.mjs +26 -29
  98. package/dist/{record-coerce-CNDovvft.mjs → record-coerce-BQaoiN3r.mjs} +4 -1
  99. package/dist/request-headers-DO4Mqhw1.mjs +10 -0
  100. package/dist/{required-api-key-D088S4Cd.mjs → required-api-key-2zZTkmsi.mjs} +1 -1
  101. package/dist/{retry-after-BrmTv0jL.d.mts → retry-after-DnHBlFS2.d.mts} +21 -1
  102. package/dist/rolldown-runtime-D7D4PA-g.mjs +13 -0
  103. package/dist/{sanitize-unicode-ZqVLLEKC.d.mts → sanitize-unicode-BISmUlUv.d.mts} +2 -2
  104. package/dist/{simple-options-xJkqrG_E.mjs → simple-options-tLSeECry.mjs} +108 -82
  105. package/dist/src-BUsVkrNt.mjs +105 -0
  106. package/dist/{src-CyA0zJnt.mjs → src-CQ7nH2mL.mjs} +4 -7
  107. package/dist/stable-stringify-CchQEmeA.mjs +84 -0
  108. package/dist/{stream-C4YDqhFj.mjs → stream-DrtAWu7c.mjs} +2 -6
  109. package/dist/{stream-first-event-timeout-D_TfJHRJ.mjs → stream-first-event-timeout-B7RcufAV.mjs} +16 -13
  110. package/dist/{string-coerce-Cj8sqWHx.mjs → string-coerce-BCuWMIrk.mjs} +1 -1
  111. package/dist/string-normalization-B8TDDBX_.mjs +32 -0
  112. package/dist/telemetry-CvK1yQg7.mjs +582 -0
  113. package/dist/{tool-schema-json-projection-B1sTYwfH.mjs → tool-schema-json-projection-BQpiJlXJ.mjs} +53 -69
  114. package/dist/{transport-stream-shared-lhgkTOz3.mjs → transport-stream-shared-D2uFMhMc.mjs} +177 -93
  115. package/dist/{transport-stream-shared-8ru8eX4s.d.mts → transport-stream-shared-D3IAU4jn.d.mts} +29 -15
  116. package/dist/{transport-utils-DwOpuTjL.mjs → transport-utils-Da_39MYi.mjs} +23 -38
  117. package/dist/transports.d.mts +42 -39
  118. package/dist/transports.mjs +215 -296
  119. package/dist/{types-CVYzKrMl.d.mts → types-BVdTf0YV.d.mts} +38 -3
  120. package/dist/types-Cb3-5WM9.d.mts +1 -0
  121. package/dist/{types-BXd0kI8-.mjs → types-OVEWUaDh.mjs} +3 -1
  122. package/dist/types.d.mts +7 -6
  123. package/dist/types.mjs +7 -5
  124. package/dist/{validation-9FSkE8T-.mjs → validation-DGXqfvkj.mjs} +45 -27
  125. package/dist/{validation-BQ5u20Ru.d.mts → validation-QmyD0E5A.d.mts} +1 -1
  126. package/dist/validation.d.mts +1 -1
  127. package/dist/validation.mjs +1 -2
  128. package/package.json +40 -6
  129. package/dist/anthropic-lueA8LUg.mjs +0 -221
  130. package/dist/assistant-output-BnQm3fov.mjs +0 -47
  131. package/dist/event-stream-CDpFza-M.d.mts +0 -1
  132. package/dist/index-DSprYWaz.d.mts +0 -185
  133. package/dist/mistral-CQ7aoWg2.mjs +0 -512
  134. package/dist/model-request-body-BD5vy4rP.d.mts +0 -17
  135. package/dist/openai-CiRi-nVE.mjs +0 -20077
  136. package/dist/openai-completions-transport-DFvSBbUT.mjs +0 -10881
  137. package/dist/openai-responses-DQsZKUoI.mjs +0 -87
  138. package/dist/rolldown-runtime-B4iAMlE-.mjs +0 -35
  139. package/dist/types-CBJthzJX.d.mts +0 -1
  140. package/dist/ws.LICENSE +0 -20
@@ -0,0 +1,182 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
+ import { w as supportsClaudeAdaptiveThinking } from "./src-CQ7nH2mL.mjs";
3
+ import { t as AssistantMessageEventStream } from "./event-stream-X2gmsUWv.mjs";
4
+ import { _ as buildAnthropicClaudeCodeIdentity, a as resolveAiTransportHeaderSentinels, b as prepareClaudeNoPrefillRequestContext, r as getAiTransportHost } from "./host-DX7ORpeH.mjs";
5
+ import { a as streamFragmentError } from "./transport-utils-Da_39MYi.mjs";
6
+ import { B as usesFoundryBearerAuth, R as isAnthropicOAuthApiKey, j as supportsAnthropicServerSideFallback, n as applyAnthropicThinkingOptions, t as runAnthropicStreamLifecycle, w as isDirectAnthropicModel, z as omitFoundryBearerCredentialHeaders } from "./anthropic-stream-lifecycle-DF2qVvg1.mjs";
7
+ import { i as resolveCacheRetention, n as resolveCloudflareBaseUrl, r as buildCopilotDynamicHeaders } from "./cloudflare-BJ2_Xabx.mjs";
8
+ import { n as buildBaseOptions, r as clampMaxTokensToModel } from "./simple-options-tLSeECry.mjs";
9
+ import { k as parseJsonWithRepair } from "./transport-stream-shared-D2uFMhMc.mjs";
10
+ import { n as getEnvApiKey } from "./env-api-keys-BuHc86ya.mjs";
11
+ import { t as notifyLlmRequestActivity } from "./llm-request-activity-DzaHoRAU.mjs";
12
+ import { withModelRequestBodyBytes } from "./internal/model-request-body.mjs";
13
+ import { n as resolveOpencodeSessionHeaders } from "./session-affinity-DA4WHv1h.mjs";
14
+ import { t as requireApiKey } from "./required-api-key-2zZTkmsi.mjs";
15
+ import { Stream } from "@anthropic-ai/sdk/core/streaming.js";
16
+ //#region packages/ai/src/providers/anthropic.ts
17
+ var anthropic_exports = /* @__PURE__ */ __exportAll({
18
+ streamAnthropic: () => streamAnthropic,
19
+ streamSimpleAnthropic: () => streamSimpleAnthropic
20
+ });
21
+ const FINE_GRAINED_TOOL_STREAMING_BETA = "fine-grained-tool-streaming-2025-05-14";
22
+ const INTERLEAVED_THINKING_BETA = "interleaved-thinking-2025-05-14";
23
+ const ANTHROPIC_MIN_THINKING_BUDGET_TOKENS = 1024;
24
+ let anthropicSdkModule;
25
+ function getAnthropicCompat(model) {
26
+ const isFireworks = model.provider === "fireworks";
27
+ const isCloudflareAiGatewayAnthropic = model.provider === "cloudflare-ai-gateway" && model.baseUrl.includes("anthropic");
28
+ return {
29
+ supportsEagerToolInputStreaming: model.compat?.supportsEagerToolInputStreaming ?? !isFireworks,
30
+ sendSessionAffinityHeaders: model.compat?.sendSessionAffinityHeaders ?? (isFireworks || isCloudflareAiGatewayAnthropic)
31
+ };
32
+ }
33
+ const ANTHROPIC_MESSAGE_EVENTS = /* @__PURE__ */ new Set([
34
+ "message_start",
35
+ "message_delta",
36
+ "message_stop",
37
+ "content_block_start",
38
+ "content_block_delta",
39
+ "content_block_stop"
40
+ ]);
41
+ async function* iterateAnthropicEvents(response, signal) {
42
+ if (!response.body) throw new Error("Attempted to iterate over an Anthropic response with no body");
43
+ for await (const sse of Stream.rawEvents(response)) {
44
+ if (sse.event === "error") throw new Error(sse.data);
45
+ notifyLlmRequestActivity(signal);
46
+ if (!ANTHROPIC_MESSAGE_EVENTS.has(sse.event ?? "")) continue;
47
+ try {
48
+ yield parseJsonWithRepair(sse.data);
49
+ } catch (error) {
50
+ throw streamFragmentError(error);
51
+ }
52
+ }
53
+ }
54
+ const streamAnthropic = (model, context, options) => {
55
+ const stream = new AssistantMessageEventStream();
56
+ const requestContext = prepareClaudeNoPrefillRequestContext(model, context);
57
+ let requestOptions = options;
58
+ if (options?.thinkingEnabled === true && !supportsClaudeAdaptiveThinking(model)) {
59
+ const budgetTokens = options.thinkingBudgetTokens ?? ANTHROPIC_MIN_THINKING_BUDGET_TOKENS;
60
+ const maxTokens = options.maxTokens ?? model.maxTokens;
61
+ if (!(budgetTokens >= ANTHROPIC_MIN_THINKING_BUDGET_TOKENS && budgetTokens < maxTokens)) requestOptions = {
62
+ ...options,
63
+ thinkingEnabled: false,
64
+ thinkingBudgetTokens: void 0
65
+ };
66
+ }
67
+ runAnthropicStreamLifecycle({
68
+ model,
69
+ stream,
70
+ options: requestOptions,
71
+ profile: "provider",
72
+ prepare: async () => {
73
+ let client = requestOptions?.client;
74
+ let isOAuthToken = false;
75
+ let serverSideFallback = false;
76
+ let directApiKeyBetaHeader;
77
+ let claudeCodeVersion;
78
+ if (!client) {
79
+ const apiKey = requestOptions?.apiKey ?? getEnvApiKey(model.provider) ?? "";
80
+ const dynamicHeaders = model.provider === "github-copilot" ? buildCopilotDynamicHeaders(requestContext.messages) : void 0;
81
+ const sessionId = (requestOptions?.cacheRetention ?? resolveCacheRetention()) === "none" ? void 0 : requestOptions?.sessionId;
82
+ const thinkingEnabled = requestOptions?.thinkingEnabled === true;
83
+ const interleavedThinking = requestOptions?.interleavedThinking ?? true;
84
+ const useFineGrainedToolStreamingBeta = Boolean(requestContext.tools?.length) && !getAnthropicCompat(model).supportsEagerToolInputStreaming;
85
+ const optionsHeaders = resolveOpencodeSessionHeaders(model, requestOptions);
86
+ const needsInterleavedBeta = interleavedThinking && !supportsClaudeAdaptiveThinking(model);
87
+ const betaFeatures = [];
88
+ if (useFineGrainedToolStreamingBeta) betaFeatures.push(FINE_GRAINED_TOOL_STREAMING_BETA);
89
+ if (needsInterleavedBeta) betaFeatures.push(INTERLEAVED_THINKING_BETA);
90
+ const fetchOptions = /^kimi(?:-|$)/.test(model.provider) && thinkingEnabled ? { sanitizeSse: false } : void 0;
91
+ const modelFetch = getAiTransportHost().buildModelFetch(model, void 0, fetchOptions);
92
+ const clientOptions = {
93
+ baseURL: model.baseUrl,
94
+ dangerouslyAllowBrowser: true,
95
+ fetch: modelFetch ? withModelRequestBodyBytes(requestOptions, modelFetch) : void 0,
96
+ maxRetries: 0
97
+ };
98
+ const baseHeaders = {
99
+ accept: "application/json",
100
+ "anthropic-dangerous-direct-browser-access": "true",
101
+ ...betaFeatures.length > 0 ? { "anthropic-beta": betaFeatures.join(",") } : {}
102
+ };
103
+ let configuredApiKey = apiKey;
104
+ let authToken = null;
105
+ let defaultHeaders;
106
+ const isCopilot = model.provider === "github-copilot";
107
+ if (model.provider === "cloudflare-ai-gateway") {
108
+ clientOptions.baseURL = resolveCloudflareBaseUrl(model);
109
+ defaultHeaders = Object.assign({}, baseHeaders, { Authorization: null }, model.headers, optionsHeaders);
110
+ } else if (isCopilot || usesFoundryBearerAuth({
111
+ ...model,
112
+ headers: resolveAiTransportHeaderSentinels(model.headers)
113
+ })) {
114
+ configuredApiKey = null;
115
+ authToken = apiKey;
116
+ defaultHeaders = Object.assign({}, baseHeaders, isCopilot ? model.headers : omitFoundryBearerCredentialHeaders(model.headers), dynamicHeaders, optionsHeaders);
117
+ } else if (isAnthropicOAuthApiKey(apiKey)) {
118
+ const identity = buildAnthropicClaudeCodeIdentity([
119
+ "claude-code-20250219",
120
+ "oauth-2025-04-20",
121
+ ...betaFeatures
122
+ ].join(","), model.headers, optionsHeaders);
123
+ configuredApiKey = null;
124
+ authToken = apiKey;
125
+ defaultHeaders = identity.headers;
126
+ isOAuthToken = true;
127
+ claudeCodeVersion = identity.version;
128
+ } else {
129
+ serverSideFallback = model.provider === "anthropic" && supportsAnthropicServerSideFallback(model);
130
+ defaultHeaders = Object.assign({}, baseHeaders, sessionId && getAnthropicCompat(model).sendSessionAffinityHeaders ? { "x-session-affinity": sessionId } : {}, model.headers, optionsHeaders);
131
+ if (isDirectAnthropicModel(model)) directApiKeyBetaHeader = Object.entries(defaultHeaders).findLast(([name]) => name.toLowerCase() === "anthropic-beta")?.[1] ?? "";
132
+ }
133
+ const { default: Anthropic } = await (anthropicSdkModule ??= import("@anthropic-ai/sdk"));
134
+ client = new Anthropic({
135
+ ...clientOptions,
136
+ apiKey: configuredApiKey,
137
+ authToken,
138
+ defaultHeaders
139
+ });
140
+ }
141
+ return {
142
+ isOAuthToken,
143
+ serverSideFallback,
144
+ directApiKeyBetaHeader,
145
+ claudeCodeVersion,
146
+ context: requestContext,
147
+ options: requestOptions,
148
+ request: async (body, headers) => {
149
+ const response = await client.messages.create(body, {
150
+ ...requestOptions?.signal ? { signal: requestOptions.signal } : {},
151
+ ...requestOptions?.timeoutMs !== void 0 ? { timeout: requestOptions.timeoutMs } : {},
152
+ maxRetries: 0,
153
+ headers
154
+ }).asResponse();
155
+ return {
156
+ response,
157
+ events: iterateAnthropicEvents(response, requestOptions?.signal)
158
+ };
159
+ }
160
+ };
161
+ }
162
+ });
163
+ return stream;
164
+ };
165
+ const streamSimpleAnthropic = (model, context, options) => {
166
+ const apiKey = requireApiKey(model.provider, options?.apiKey);
167
+ const base = {
168
+ ...buildBaseOptions(model, options, apiKey),
169
+ anthropicServerCompaction: options?.anthropicServerCompaction,
170
+ anthropicCompactThreshold: options?.anthropicCompactThreshold,
171
+ cacheTtlPruning: options?.cacheTtlPruning,
172
+ onCompactionRejected: options?.onCompactionRejected,
173
+ authProfileId: options?.authProfileId,
174
+ maxTokens: clampMaxTokensToModel(model, options?.maxTokens ?? model.maxTokens),
175
+ toolChoice: options?.toolChoice,
176
+ thinkingDisplay: options?.thinkingDisplay
177
+ };
178
+ applyAnthropicThinkingOptions(model, base, options, "provider");
179
+ return streamAnthropic(model, context, base);
180
+ };
181
+ //#endregion
182
+ export { streamAnthropic as n, streamSimpleAnthropic as r, anthropic_exports as t };
@@ -1,7 +1,24 @@
1
- import "./index-DSprYWaz.mjs";
2
- import { k as Model } from "./types-CVYzKrMl.mjs";
3
- import { t as AnthropicContextManagementOptions } from "./provider-options-DAzsyi49.mjs";
1
+ import { k as Model, tt as SimpleStreamOptions } from "./types-BVdTf0YV.mjs";
2
+ import "./index-Bczt0MnO.mjs";
3
+ import { r as AnthropicOptions, t as AnthropicContextManagementOptions } from "./provider-options-Mo8NM5d1.mjs";
4
4
  import { TextBlockParam } from "@anthropic-ai/sdk/resources/messages.js";
5
+ //#region packages/ai/src/transports/anthropic-transport-options.d.ts
6
+ /** Keep both entry points on one thinking mode while retaining their output-budget policies. */
7
+ declare function applyAnthropicThinkingOptions(model: Model<"anthropic-messages">, resolved: Pick<AnthropicOptions, "thinkingEnabled" | "thinkingBudgetTokens" | "effort"> & {
8
+ maxTokens: number;
9
+ }, options: Pick<SimpleStreamOptions, "reasoning" | "thinkingBudgets"> | undefined, profile: "provider" | "transport"): SimpleStreamOptions["reasoning"];
10
+ /**
11
+ * Largest completion a request may ask for once transport thinking options
12
+ * apply, for callers that size the prompt before dispatch. Claude transports
13
+ * (Anthropic Messages, Vertex, Bedrock, Bedrock Mantle) may add a thinking
14
+ * budget to `maxTokens`, capped at the model's output limit; some add it even
15
+ * for adaptive models, and their Claude detection is plugin-owned, so every
16
+ * request on these APIs reserves the default budget for its level. Other
17
+ * transports keep `maxTokens` as the total output limit. Over-reserving only
18
+ * shrinks the prompt; it never overflows the window.
19
+ */
20
+ declare function resolveCompletionTokenReservation(model: Model, maxTokens: number, reasoning: SimpleStreamOptions["reasoning"]): number;
21
+ //#endregion
5
22
  //#region packages/ai/src/transports/anthropic-payload-policy.d.ts
6
23
  /** @deprecated Anthropic-family provider payload helper; do not use from third-party plugins. */
7
24
  type AnthropicServiceTier = "auto" | "standard_only";
@@ -93,4 +110,4 @@ declare function applyAnthropicPayloadPolicyToParams(payloadObj: Record<string,
93
110
  /** @deprecated Anthropic-family provider payload helper; do not use from third-party plugins. */
94
111
  declare function applyAnthropicEphemeralCacheControlMarkers(payloadObj: Record<string, unknown>, cacheControl?: AnthropicEphemeralCacheControl | null): void;
95
112
  //#endregion
96
- export { buildAnthropicSystemBlocks as a, logAnthropicContextEdits as c, resolveAnthropicPayloadPolicy as d, resolveAnthropicRequestBetaHeader as f, applyAnthropicRequestCacheControl as i, resolveAnthropicCacheOptions as l, supportsAnthropicServerSideFallback as m, applyAnthropicEphemeralCacheControlMarkers as n, isAnthropicServerToolClearingEnabled as o, resolveAnthropicServerCompactionPlan as p, applyAnthropicPayloadPolicyToParams as r, isDirectAnthropicModel as s, applyAnthropicContextManagementToRequest as t, resolveAnthropicEphemeralCacheControl as u };
113
+ export { buildAnthropicSystemBlocks as a, logAnthropicContextEdits as c, resolveAnthropicPayloadPolicy as d, resolveAnthropicRequestBetaHeader as f, resolveCompletionTokenReservation as g, applyAnthropicThinkingOptions as h, applyAnthropicRequestCacheControl as i, resolveAnthropicCacheOptions as l, supportsAnthropicServerSideFallback as m, applyAnthropicEphemeralCacheControlMarkers as n, isAnthropicServerToolClearingEnabled as o, resolveAnthropicServerCompactionPlan as p, applyAnthropicPayloadPolicyToParams as r, isDirectAnthropicModel as s, applyAnthropicContextManagementToRequest as t, resolveAnthropicEphemeralCacheControl as u };