@openclaw/anthropic-vertex-provider 2026.7.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.
Files changed (216) hide show
  1. package/dist/index.js +2 -2
  2. package/dist/provider-catalog.js +2 -2
  3. package/dist/region.js +17 -9
  4. package/dist/stream-runtime.js +22 -3
  5. package/node_modules/undici/LICENSE +21 -0
  6. package/node_modules/undici/README.md +791 -0
  7. package/node_modules/undici/docs/docs/GettingStarted.md +278 -0
  8. package/node_modules/undici/docs/docs/api/Agent.md +87 -0
  9. package/node_modules/undici/docs/docs/api/BalancedPool.md +99 -0
  10. package/node_modules/undici/docs/docs/api/CacheStorage.md +30 -0
  11. package/node_modules/undici/docs/docs/api/CacheStore.md +164 -0
  12. package/node_modules/undici/docs/docs/api/Client.md +326 -0
  13. package/node_modules/undici/docs/docs/api/ClientStats.md +27 -0
  14. package/node_modules/undici/docs/docs/api/Connector.md +116 -0
  15. package/node_modules/undici/docs/docs/api/ContentType.md +57 -0
  16. package/node_modules/undici/docs/docs/api/Cookies.md +128 -0
  17. package/node_modules/undici/docs/docs/api/Debug.md +62 -0
  18. package/node_modules/undici/docs/docs/api/DiagnosticsChannel.md +315 -0
  19. package/node_modules/undici/docs/docs/api/Dispatcher.md +1444 -0
  20. package/node_modules/undici/docs/docs/api/EnvHttpProxyAgent.md +156 -0
  21. package/node_modules/undici/docs/docs/api/Errors.md +61 -0
  22. package/node_modules/undici/docs/docs/api/EventSource.md +92 -0
  23. package/node_modules/undici/docs/docs/api/Fetch.md +62 -0
  24. package/node_modules/undici/docs/docs/api/GlobalInstallation.md +141 -0
  25. package/node_modules/undici/docs/docs/api/H2CClient.md +263 -0
  26. package/node_modules/undici/docs/docs/api/MockAgent.md +603 -0
  27. package/node_modules/undici/docs/docs/api/MockCallHistory.md +197 -0
  28. package/node_modules/undici/docs/docs/api/MockCallHistoryLog.md +43 -0
  29. package/node_modules/undici/docs/docs/api/MockClient.md +81 -0
  30. package/node_modules/undici/docs/docs/api/MockErrors.md +12 -0
  31. package/node_modules/undici/docs/docs/api/MockPool.md +555 -0
  32. package/node_modules/undici/docs/docs/api/Pool.md +87 -0
  33. package/node_modules/undici/docs/docs/api/PoolStats.md +35 -0
  34. package/node_modules/undici/docs/docs/api/ProxyAgent.md +229 -0
  35. package/node_modules/undici/docs/docs/api/RedirectHandler.md +101 -0
  36. package/node_modules/undici/docs/docs/api/RetryAgent.md +49 -0
  37. package/node_modules/undici/docs/docs/api/RetryHandler.md +116 -0
  38. package/node_modules/undici/docs/docs/api/RoundRobinPool.md +145 -0
  39. package/node_modules/undici/docs/docs/api/SnapshotAgent.md +639 -0
  40. package/node_modules/undici/docs/docs/api/Socks5ProxyAgent.md +275 -0
  41. package/node_modules/undici/docs/docs/api/Util.md +25 -0
  42. package/node_modules/undici/docs/docs/api/WebSocket.md +141 -0
  43. package/node_modules/undici/docs/docs/api/api-lifecycle.md +91 -0
  44. package/node_modules/undici/docs/docs/best-practices/client-certificate.md +64 -0
  45. package/node_modules/undici/docs/docs/best-practices/crawling.md +58 -0
  46. package/node_modules/undici/docs/docs/best-practices/migrating-from-v7-to-v8.md +231 -0
  47. package/node_modules/undici/docs/docs/best-practices/mocking-request.md +190 -0
  48. package/node_modules/undici/docs/docs/best-practices/proxy.md +127 -0
  49. package/node_modules/undici/docs/docs/best-practices/undici-vs-builtin-fetch.md +224 -0
  50. package/node_modules/undici/docs/docs/best-practices/writing-tests.md +63 -0
  51. package/node_modules/undici/index-fetch.js +65 -0
  52. package/node_modules/undici/index.d.ts +3 -0
  53. package/node_modules/undici/index.js +236 -0
  54. package/node_modules/undici/lib/api/abort-signal.js +59 -0
  55. package/node_modules/undici/lib/api/api-connect.js +112 -0
  56. package/node_modules/undici/lib/api/api-pipeline.js +265 -0
  57. package/node_modules/undici/lib/api/api-request.js +238 -0
  58. package/node_modules/undici/lib/api/api-stream.js +270 -0
  59. package/node_modules/undici/lib/api/api-upgrade.js +121 -0
  60. package/node_modules/undici/lib/api/index.js +7 -0
  61. package/node_modules/undici/lib/api/readable.js +581 -0
  62. package/node_modules/undici/lib/cache/memory-cache-store.js +234 -0
  63. package/node_modules/undici/lib/cache/sqlite-cache-store.js +463 -0
  64. package/node_modules/undici/lib/core/connect.js +178 -0
  65. package/node_modules/undici/lib/core/constants.js +120 -0
  66. package/node_modules/undici/lib/core/diagnostics.js +227 -0
  67. package/node_modules/undici/lib/core/errors.js +477 -0
  68. package/node_modules/undici/lib/core/request.js +535 -0
  69. package/node_modules/undici/lib/core/socks5-client.js +422 -0
  70. package/node_modules/undici/lib/core/socks5-utils.js +212 -0
  71. package/node_modules/undici/lib/core/symbols.js +76 -0
  72. package/node_modules/undici/lib/core/tree.js +160 -0
  73. package/node_modules/undici/lib/core/util.js +1021 -0
  74. package/node_modules/undici/lib/dispatcher/agent.js +172 -0
  75. package/node_modules/undici/lib/dispatcher/balanced-pool.js +214 -0
  76. package/node_modules/undici/lib/dispatcher/client-h1.js +1736 -0
  77. package/node_modules/undici/lib/dispatcher/client-h2.js +1449 -0
  78. package/node_modules/undici/lib/dispatcher/client.js +695 -0
  79. package/node_modules/undici/lib/dispatcher/dispatcher-base.js +185 -0
  80. package/node_modules/undici/lib/dispatcher/dispatcher.js +44 -0
  81. package/node_modules/undici/lib/dispatcher/dispatcher1-wrapper.js +107 -0
  82. package/node_modules/undici/lib/dispatcher/env-http-proxy-agent.js +146 -0
  83. package/node_modules/undici/lib/dispatcher/fixed-queue.js +135 -0
  84. package/node_modules/undici/lib/dispatcher/h2c-client.js +51 -0
  85. package/node_modules/undici/lib/dispatcher/pool-base.js +232 -0
  86. package/node_modules/undici/lib/dispatcher/pool.js +143 -0
  87. package/node_modules/undici/lib/dispatcher/proxy-agent.js +344 -0
  88. package/node_modules/undici/lib/dispatcher/retry-agent.js +35 -0
  89. package/node_modules/undici/lib/dispatcher/round-robin-pool.js +159 -0
  90. package/node_modules/undici/lib/dispatcher/socks5-proxy-agent.js +266 -0
  91. package/node_modules/undici/lib/encoding/index.js +33 -0
  92. package/node_modules/undici/lib/global.js +62 -0
  93. package/node_modules/undici/lib/handler/cache-handler.js +586 -0
  94. package/node_modules/undici/lib/handler/cache-revalidation-handler.js +124 -0
  95. package/node_modules/undici/lib/handler/decorator-handler.js +66 -0
  96. package/node_modules/undici/lib/handler/deduplication-handler.js +460 -0
  97. package/node_modules/undici/lib/handler/redirect-handler.js +217 -0
  98. package/node_modules/undici/lib/handler/retry-handler.js +407 -0
  99. package/node_modules/undici/lib/interceptor/cache.js +508 -0
  100. package/node_modules/undici/lib/interceptor/decompress.js +285 -0
  101. package/node_modules/undici/lib/interceptor/deduplicate.js +117 -0
  102. package/node_modules/undici/lib/interceptor/dns.js +575 -0
  103. package/node_modules/undici/lib/interceptor/dump.js +112 -0
  104. package/node_modules/undici/lib/interceptor/redirect.js +21 -0
  105. package/node_modules/undici/lib/interceptor/response-error.js +95 -0
  106. package/node_modules/undici/lib/interceptor/retry.js +19 -0
  107. package/node_modules/undici/lib/llhttp/constants.d.ts +195 -0
  108. package/node_modules/undici/lib/llhttp/constants.js +531 -0
  109. package/node_modules/undici/lib/llhttp/llhttp-wasm.js +15 -0
  110. package/node_modules/undici/lib/llhttp/llhttp_simd-wasm.js +15 -0
  111. package/node_modules/undici/lib/llhttp/utils.d.ts +2 -0
  112. package/node_modules/undici/lib/llhttp/utils.js +12 -0
  113. package/node_modules/undici/lib/mock/mock-agent.js +232 -0
  114. package/node_modules/undici/lib/mock/mock-call-history.js +248 -0
  115. package/node_modules/undici/lib/mock/mock-client.js +68 -0
  116. package/node_modules/undici/lib/mock/mock-errors.js +29 -0
  117. package/node_modules/undici/lib/mock/mock-interceptor.js +209 -0
  118. package/node_modules/undici/lib/mock/mock-pool.js +68 -0
  119. package/node_modules/undici/lib/mock/mock-symbols.js +32 -0
  120. package/node_modules/undici/lib/mock/mock-utils.js +501 -0
  121. package/node_modules/undici/lib/mock/pending-interceptors-formatter.js +43 -0
  122. package/node_modules/undici/lib/mock/snapshot-agent.js +371 -0
  123. package/node_modules/undici/lib/mock/snapshot-recorder.js +623 -0
  124. package/node_modules/undici/lib/mock/snapshot-utils.js +158 -0
  125. package/node_modules/undici/lib/util/cache.js +414 -0
  126. package/node_modules/undici/lib/util/date.js +653 -0
  127. package/node_modules/undici/lib/util/runtime-features.js +93 -0
  128. package/node_modules/undici/lib/util/stats.js +32 -0
  129. package/node_modules/undici/lib/util/timers.js +425 -0
  130. package/node_modules/undici/lib/web/cache/cache.js +862 -0
  131. package/node_modules/undici/lib/web/cache/cachestorage.js +152 -0
  132. package/node_modules/undici/lib/web/cache/util.js +45 -0
  133. package/node_modules/undici/lib/web/cookies/constants.js +12 -0
  134. package/node_modules/undici/lib/web/cookies/index.js +199 -0
  135. package/node_modules/undici/lib/web/cookies/parse.js +314 -0
  136. package/node_modules/undici/lib/web/cookies/util.js +282 -0
  137. package/node_modules/undici/lib/web/eventsource/eventsource-stream.js +494 -0
  138. package/node_modules/undici/lib/web/eventsource/eventsource.js +490 -0
  139. package/node_modules/undici/lib/web/eventsource/util.js +60 -0
  140. package/node_modules/undici/lib/web/fetch/LICENSE +21 -0
  141. package/node_modules/undici/lib/web/fetch/body.js +546 -0
  142. package/node_modules/undici/lib/web/fetch/constants.js +131 -0
  143. package/node_modules/undici/lib/web/fetch/data-url.js +596 -0
  144. package/node_modules/undici/lib/web/fetch/formdata-parser.js +586 -0
  145. package/node_modules/undici/lib/web/fetch/formdata.js +278 -0
  146. package/node_modules/undici/lib/web/fetch/global.js +40 -0
  147. package/node_modules/undici/lib/web/fetch/headers.js +719 -0
  148. package/node_modules/undici/lib/web/fetch/index.js +2417 -0
  149. package/node_modules/undici/lib/web/fetch/request.js +1145 -0
  150. package/node_modules/undici/lib/web/fetch/response.js +641 -0
  151. package/node_modules/undici/lib/web/fetch/util.js +1522 -0
  152. package/node_modules/undici/lib/web/infra/index.js +229 -0
  153. package/node_modules/undici/lib/web/subresource-integrity/Readme.md +9 -0
  154. package/node_modules/undici/lib/web/subresource-integrity/subresource-integrity.js +307 -0
  155. package/node_modules/undici/lib/web/webidl/index.js +1004 -0
  156. package/node_modules/undici/lib/web/websocket/connection.js +329 -0
  157. package/node_modules/undici/lib/web/websocket/constants.js +126 -0
  158. package/node_modules/undici/lib/web/websocket/events.js +331 -0
  159. package/node_modules/undici/lib/web/websocket/frame.js +127 -0
  160. package/node_modules/undici/lib/web/websocket/permessage-deflate.js +100 -0
  161. package/node_modules/undici/lib/web/websocket/receiver.js +507 -0
  162. package/node_modules/undici/lib/web/websocket/sender.js +109 -0
  163. package/node_modules/undici/lib/web/websocket/stream/websocketerror.js +104 -0
  164. package/node_modules/undici/lib/web/websocket/stream/websocketstream.js +498 -0
  165. package/node_modules/undici/lib/web/websocket/util.js +347 -0
  166. package/node_modules/undici/lib/web/websocket/websocket.js +758 -0
  167. package/node_modules/undici/package.json +152 -0
  168. package/node_modules/undici/scripts/strip-comments.js +10 -0
  169. package/node_modules/undici/types/README.md +6 -0
  170. package/node_modules/undici/types/agent.d.ts +30 -0
  171. package/node_modules/undici/types/api.d.ts +43 -0
  172. package/node_modules/undici/types/balanced-pool.d.ts +30 -0
  173. package/node_modules/undici/types/cache-interceptor.d.ts +179 -0
  174. package/node_modules/undici/types/cache.d.ts +36 -0
  175. package/node_modules/undici/types/client-stats.d.ts +15 -0
  176. package/node_modules/undici/types/client.d.ts +134 -0
  177. package/node_modules/undici/types/connector.d.ts +37 -0
  178. package/node_modules/undici/types/content-type.d.ts +21 -0
  179. package/node_modules/undici/types/cookies.d.ts +30 -0
  180. package/node_modules/undici/types/diagnostics-channel.d.ts +74 -0
  181. package/node_modules/undici/types/dispatcher.d.ts +253 -0
  182. package/node_modules/undici/types/dispatcher1-wrapper.d.ts +7 -0
  183. package/node_modules/undici/types/env-http-proxy-agent.d.ts +22 -0
  184. package/node_modules/undici/types/errors.d.ts +177 -0
  185. package/node_modules/undici/types/eventsource.d.ts +66 -0
  186. package/node_modules/undici/types/fetch.d.ts +235 -0
  187. package/node_modules/undici/types/formdata.d.ts +108 -0
  188. package/node_modules/undici/types/global-dispatcher.d.ts +9 -0
  189. package/node_modules/undici/types/global-origin.d.ts +7 -0
  190. package/node_modules/undici/types/h2c-client.d.ts +73 -0
  191. package/node_modules/undici/types/handlers.d.ts +14 -0
  192. package/node_modules/undici/types/header.d.ts +165 -0
  193. package/node_modules/undici/types/index.d.ts +93 -0
  194. package/node_modules/undici/types/interceptors.d.ts +80 -0
  195. package/node_modules/undici/types/mock-agent.d.ts +68 -0
  196. package/node_modules/undici/types/mock-call-history.d.ts +111 -0
  197. package/node_modules/undici/types/mock-client.d.ts +27 -0
  198. package/node_modules/undici/types/mock-errors.d.ts +12 -0
  199. package/node_modules/undici/types/mock-interceptor.d.ts +94 -0
  200. package/node_modules/undici/types/mock-pool.d.ts +27 -0
  201. package/node_modules/undici/types/patch.d.ts +29 -0
  202. package/node_modules/undici/types/pool-stats.d.ts +19 -0
  203. package/node_modules/undici/types/pool.d.ts +39 -0
  204. package/node_modules/undici/types/proxy-agent.d.ts +29 -0
  205. package/node_modules/undici/types/readable.d.ts +68 -0
  206. package/node_modules/undici/types/retry-agent.d.ts +8 -0
  207. package/node_modules/undici/types/retry-handler.d.ts +125 -0
  208. package/node_modules/undici/types/round-robin-pool.d.ts +39 -0
  209. package/node_modules/undici/types/snapshot-agent.d.ts +113 -0
  210. package/node_modules/undici/types/socks5-proxy-agent.d.ts +25 -0
  211. package/node_modules/undici/types/util.d.ts +18 -0
  212. package/node_modules/undici/types/utility.d.ts +7 -0
  213. package/node_modules/undici/types/webidl.d.ts +346 -0
  214. package/node_modules/undici/types/websocket.d.ts +188 -0
  215. package/npm-shrinkwrap.json +14 -3
  216. package/package.json +10 -6
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import { normalizeAnthropicVertexResolvedModel } from "./provider-catalog.js";
3
3
  import { mergeImplicitAnthropicVertexProvider, resolveImplicitAnthropicVertexProvider } from "./api.js";
4
4
  import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
5
5
  import { readConfiguredProviderCatalogEntries } from "openclaw/plugin-sdk/provider-catalog-shared";
6
- import { NATIVE_ANTHROPIC_REPLAY_HOOKS, resolveClaudeThinkingProfile } from "openclaw/plugin-sdk/provider-model-shared";
6
+ import { buildProviderReplayFamilyHooks, resolveClaudeThinkingProfile } from "openclaw/plugin-sdk/provider-model-shared";
7
7
  //#region extensions/anthropic-vertex/index.ts
8
8
  /**
9
9
  * Anthropic Vertex provider plugin entry. It registers implicit ADC-backed
@@ -34,7 +34,7 @@ var anthropic_vertex_default = definePluginEntry({
34
34
  }
35
35
  },
36
36
  resolveConfigApiKey: ({ env }) => resolveAnthropicVertexConfigApiKey(env),
37
- ...NATIVE_ANTHROPIC_REPLAY_HOOKS,
37
+ ...buildProviderReplayFamilyHooks({ family: "native-anthropic-by-model" }),
38
38
  normalizeResolvedModel: ({ modelId, model }) => normalizeAnthropicVertexResolvedModel(modelId, model),
39
39
  resolveThinkingProfile: ({ modelId, params }) => resolveClaudeThinkingProfile(modelId, params, { includeNativeMax: true }),
40
40
  resolveSyntheticAuth: () => {
@@ -1,5 +1,5 @@
1
1
  import { resolveAnthropicVertexClientRegion, resolveAnthropicVertexRegion } from "./region.js";
2
- import { resolveClaudeFable5ModelIdentity, resolveClaudeMythos5ModelIdentity, resolveClaudeSonnet5ModelIdentity } from "openclaw/plugin-sdk/provider-model-shared";
2
+ import { modelCostsEqual, resolveClaudeFable5ModelIdentity, resolveClaudeMythos5ModelIdentity, resolveClaudeSonnet5ModelIdentity } from "openclaw/plugin-sdk/provider-model-shared";
3
3
  import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/string-coerce-runtime";
4
4
  //#region extensions/anthropic-vertex/provider-catalog.ts
5
5
  /** Default Anthropic Vertex model used for implicit provider catalogs. */
@@ -196,7 +196,7 @@ function normalizeAnthropicVertexResolvedModel(modelId, model) {
196
196
  };
197
197
  const nativeThinkingLevelsMatch = model.thinkingLevelMap?.xhigh === "xhigh" && model.thinkingLevelMap.max === "max" && (!(fable5 || mythos5) || model.thinkingLevelMap.off === "low" && model.thinkingLevelMap.minimal === "low");
198
198
  const cost = sonnet5 ? resolveSonnet5Cost(resolveAnthropicVertexClientRegion({ baseUrl: model.baseUrl })) : void 0;
199
- const costMatches = !cost || model.cost.input === cost.input && model.cost.output === cost.output && model.cost.cacheRead === cost.cacheRead && model.cost.cacheWrite === cost.cacheWrite;
199
+ const costMatches = !cost || modelCostsEqual(model.cost, cost);
200
200
  if (model.reasoning && input === model.input && model.contextWindow === ANTHROPIC_VERTEX_DEFAULT_CONTEXT_WINDOW && model.contextTokens === ANTHROPIC_VERTEX_DEFAULT_CONTEXT_WINDOW && (model.maxTokens ?? 0) >= ANTHROPIC_VERTEX_CLAUDE_5_MAX_TOKENS && nativeThinkingLevelsMatch && costMatches) return;
201
201
  return {
202
202
  ...model,
package/dist/region.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/string-coerce-runtime";
2
- import { readFileSync } from "node:fs";
3
2
  import { homedir, platform } from "node:os";
4
3
  import { join } from "node:path";
5
4
  import { resolveProviderEndpoint } from "openclaw/plugin-sdk/provider-http";
5
+ import { tryReadSecretFileSync } from "openclaw/plugin-sdk/secret-file-runtime";
6
6
  //#region extensions/anthropic-vertex/region.ts
7
7
  /**
8
8
  * Anthropic Vertex region, project, and ADC auth detection helpers. They keep
@@ -11,6 +11,7 @@ import { resolveProviderEndpoint } from "openclaw/plugin-sdk/provider-http";
11
11
  const ANTHROPIC_VERTEX_DEFAULT_REGION = "global";
12
12
  const ANTHROPIC_VERTEX_REGION_RE = /^[a-z0-9-]+$/;
13
13
  const GCP_VERTEX_CREDENTIALS_MARKER = "gcp-vertex-credentials";
14
+ const ANTHROPIC_VERTEX_ADC_FILE_MAX_BYTES = 1024 * 1024;
14
15
  function normalizeOptionalSecretInput(value) {
15
16
  if (typeof value !== "string") return;
16
17
  return value.trim() || void 0;
@@ -48,21 +49,28 @@ function resolveAnthropicVertexAdcCredentialsPathCandidate(env = process.env) {
48
49
  if (explicit) return explicit;
49
50
  return resolveAnthropicVertexDefaultAdcPath(env);
50
51
  }
51
- function canReadAnthropicVertexAdc(env = process.env) {
52
+ function resolveAnthropicVertexAdcCredentials(env = process.env) {
52
53
  const credentialsPath = resolveAnthropicVertexAdcCredentialsPathCandidate(env);
53
- if (!credentialsPath) return false;
54
+ const text = tryReadSecretFileSync(credentialsPath, "Anthropic Vertex ADC credentials", {
55
+ maxBytes: ANTHROPIC_VERTEX_ADC_FILE_MAX_BYTES,
56
+ rejectHardlinks: false
57
+ });
58
+ if (!text) return;
59
+ const parsed = JSON.parse(text);
60
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) throw new Error(`Anthropic Vertex ADC credentials must be a JSON object: ${credentialsPath}`);
61
+ return parsed;
62
+ }
63
+ function canReadAnthropicVertexAdc(env = process.env) {
54
64
  try {
55
- readFileSync(credentialsPath, "utf8");
56
- return true;
65
+ return resolveAnthropicVertexAdcCredentials(env) !== void 0;
57
66
  } catch {
58
67
  return false;
59
68
  }
60
69
  }
61
70
  function resolveAnthropicVertexProjectIdFromAdc(env = process.env) {
62
- const credentialsPath = resolveAnthropicVertexAdcCredentialsPathCandidate(env);
63
- if (!credentialsPath) return;
64
71
  try {
65
- const parsed = JSON.parse(readFileSync(credentialsPath, "utf8"));
72
+ const parsed = resolveAnthropicVertexAdcCredentials(env);
73
+ if (!parsed) return;
66
74
  return normalizeOptionalSecretInput(parsed.project_id) || normalizeOptionalSecretInput(parsed.quota_project_id);
67
75
  } catch {
68
76
  return;
@@ -81,4 +89,4 @@ function resolveAnthropicVertexConfigApiKey(env = process.env) {
81
89
  return hasAnthropicVertexAvailableAuth(env) ? GCP_VERTEX_CREDENTIALS_MARKER : void 0;
82
90
  }
83
91
  //#endregion
84
- export { hasAnthropicVertexAvailableAuth, hasAnthropicVertexCredentials, resolveAnthropicVertexClientRegion, resolveAnthropicVertexConfigApiKey, resolveAnthropicVertexProjectId, resolveAnthropicVertexRegion, resolveAnthropicVertexRegionFromBaseUrl };
92
+ export { hasAnthropicVertexAvailableAuth, hasAnthropicVertexCredentials, resolveAnthropicVertexAdcCredentials, resolveAnthropicVertexClientRegion, resolveAnthropicVertexConfigApiKey, resolveAnthropicVertexProjectId, resolveAnthropicVertexRegion, resolveAnthropicVertexRegionFromBaseUrl };
@@ -1,14 +1,26 @@
1
- import { resolveAnthropicVertexClientRegion, resolveAnthropicVertexProjectId } from "./region.js";
1
+ import { resolveAnthropicVertexAdcCredentials, resolveAnthropicVertexClientRegion, resolveAnthropicVertexProjectId } from "./region.js";
2
2
  import { requiresClaudeMandatoryAdaptiveThinking, resolveClaudeFable5ModelIdentity, resolveClaudeModelIdentity, resolveClaudeMythos5ModelIdentity, resolveClaudeSonnet5ModelIdentity, supportsClaudeAdaptiveThinking, supportsClaudeNativeMaxEffort, supportsClaudeNativeXhighEffort } from "openclaw/plugin-sdk/provider-model-shared";
3
3
  import { AnthropicVertex } from "@anthropic-ai/vertex-sdk";
4
+ import { GoogleAuth } from "google-auth-library";
4
5
  import { clampThinkingLevel, stream } from "openclaw/plugin-sdk/llm";
6
+ import { EnvHttpProxyAgent, fetch } from "undici";
5
7
  //#region extensions/anthropic-vertex/stream-runtime.ts
6
8
  /**
7
9
  * Anthropic Vertex stream runtime. It constructs Vertex SDK clients and adapts
8
10
  * OpenClaw stream options for the shared Anthropic Messages transport.
9
11
  */
12
+ const GOOGLE_CLOUD_PLATFORM_SCOPE = "https://www.googleapis.com/auth/cloud-platform";
13
+ let googleAuthDispatcher;
14
+ const googleAuthFetch = (input, init) => {
15
+ googleAuthDispatcher ??= new EnvHttpProxyAgent();
16
+ const fetchInit = { ...init };
17
+ delete fetchInit.agent;
18
+ fetchInit.dispatcher = googleAuthDispatcher;
19
+ return fetch(input, fetchInit);
20
+ };
10
21
  const defaultAnthropicVertexStreamDeps = {
11
22
  AnthropicVertex,
23
+ GoogleAuth,
12
24
  streamAnthropic: stream
13
25
  };
14
26
  function isClaudeOpus47OrNewerModel(modelId) {
@@ -55,8 +67,15 @@ function resolveAnthropicVertexMaxTokens(params) {
55
67
  * event handling is handled by the shared model runtime - we only supply the GCP-authenticated
56
68
  * client and provider transport options.
57
69
  */
58
- function createAnthropicVertexStreamFn(projectId, region, baseURL, deps = defaultAnthropicVertexStreamDeps) {
70
+ function createAnthropicVertexStreamFn(projectId, region, baseURL, deps = defaultAnthropicVertexStreamDeps, env = process.env) {
71
+ const adcConfig = resolveAnthropicVertexAdcCredentials(env);
72
+ const googleAuth = new deps.GoogleAuth({
73
+ scopes: [GOOGLE_CLOUD_PLATFORM_SCOPE],
74
+ ...adcConfig ? { credentials: adcConfig } : {},
75
+ clientOptions: { transporterOptions: { fetchImplementation: googleAuthFetch } }
76
+ });
59
77
  const client = new deps.AnthropicVertex({
78
+ googleAuth,
60
79
  region,
61
80
  ...baseURL ? { baseURL } : {},
62
81
  ...projectId ? { projectId } : {}
@@ -130,7 +149,7 @@ function createAnthropicVertexStreamFnForModel(model, env = process.env, deps) {
130
149
  return createAnthropicVertexStreamFn(resolveAnthropicVertexProjectId(env), resolveAnthropicVertexClientRegion({
131
150
  baseUrl: model.baseUrl,
132
151
  env
133
- }), resolveAnthropicVertexSdkBaseUrl(model.baseUrl), deps);
152
+ }), resolveAnthropicVertexSdkBaseUrl(model.baseUrl), deps, env);
134
153
  }
135
154
  //#endregion
136
155
  export { createAnthropicVertexStreamFn, createAnthropicVertexStreamFnForModel };
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Matteo Collina and Undici contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.