@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.
- package/dist/index.js +2 -2
- package/dist/provider-catalog.js +2 -2
- package/dist/region.js +17 -9
- package/dist/stream-runtime.js +22 -3
- package/node_modules/undici/LICENSE +21 -0
- package/node_modules/undici/README.md +791 -0
- package/node_modules/undici/docs/docs/GettingStarted.md +278 -0
- package/node_modules/undici/docs/docs/api/Agent.md +87 -0
- package/node_modules/undici/docs/docs/api/BalancedPool.md +99 -0
- package/node_modules/undici/docs/docs/api/CacheStorage.md +30 -0
- package/node_modules/undici/docs/docs/api/CacheStore.md +164 -0
- package/node_modules/undici/docs/docs/api/Client.md +326 -0
- package/node_modules/undici/docs/docs/api/ClientStats.md +27 -0
- package/node_modules/undici/docs/docs/api/Connector.md +116 -0
- package/node_modules/undici/docs/docs/api/ContentType.md +57 -0
- package/node_modules/undici/docs/docs/api/Cookies.md +128 -0
- package/node_modules/undici/docs/docs/api/Debug.md +62 -0
- package/node_modules/undici/docs/docs/api/DiagnosticsChannel.md +315 -0
- package/node_modules/undici/docs/docs/api/Dispatcher.md +1444 -0
- package/node_modules/undici/docs/docs/api/EnvHttpProxyAgent.md +156 -0
- package/node_modules/undici/docs/docs/api/Errors.md +61 -0
- package/node_modules/undici/docs/docs/api/EventSource.md +92 -0
- package/node_modules/undici/docs/docs/api/Fetch.md +62 -0
- package/node_modules/undici/docs/docs/api/GlobalInstallation.md +141 -0
- package/node_modules/undici/docs/docs/api/H2CClient.md +263 -0
- package/node_modules/undici/docs/docs/api/MockAgent.md +603 -0
- package/node_modules/undici/docs/docs/api/MockCallHistory.md +197 -0
- package/node_modules/undici/docs/docs/api/MockCallHistoryLog.md +43 -0
- package/node_modules/undici/docs/docs/api/MockClient.md +81 -0
- package/node_modules/undici/docs/docs/api/MockErrors.md +12 -0
- package/node_modules/undici/docs/docs/api/MockPool.md +555 -0
- package/node_modules/undici/docs/docs/api/Pool.md +87 -0
- package/node_modules/undici/docs/docs/api/PoolStats.md +35 -0
- package/node_modules/undici/docs/docs/api/ProxyAgent.md +229 -0
- package/node_modules/undici/docs/docs/api/RedirectHandler.md +101 -0
- package/node_modules/undici/docs/docs/api/RetryAgent.md +49 -0
- package/node_modules/undici/docs/docs/api/RetryHandler.md +116 -0
- package/node_modules/undici/docs/docs/api/RoundRobinPool.md +145 -0
- package/node_modules/undici/docs/docs/api/SnapshotAgent.md +639 -0
- package/node_modules/undici/docs/docs/api/Socks5ProxyAgent.md +275 -0
- package/node_modules/undici/docs/docs/api/Util.md +25 -0
- package/node_modules/undici/docs/docs/api/WebSocket.md +141 -0
- package/node_modules/undici/docs/docs/api/api-lifecycle.md +91 -0
- package/node_modules/undici/docs/docs/best-practices/client-certificate.md +64 -0
- package/node_modules/undici/docs/docs/best-practices/crawling.md +58 -0
- package/node_modules/undici/docs/docs/best-practices/migrating-from-v7-to-v8.md +231 -0
- package/node_modules/undici/docs/docs/best-practices/mocking-request.md +190 -0
- package/node_modules/undici/docs/docs/best-practices/proxy.md +127 -0
- package/node_modules/undici/docs/docs/best-practices/undici-vs-builtin-fetch.md +224 -0
- package/node_modules/undici/docs/docs/best-practices/writing-tests.md +63 -0
- package/node_modules/undici/index-fetch.js +65 -0
- package/node_modules/undici/index.d.ts +3 -0
- package/node_modules/undici/index.js +236 -0
- package/node_modules/undici/lib/api/abort-signal.js +59 -0
- package/node_modules/undici/lib/api/api-connect.js +112 -0
- package/node_modules/undici/lib/api/api-pipeline.js +265 -0
- package/node_modules/undici/lib/api/api-request.js +238 -0
- package/node_modules/undici/lib/api/api-stream.js +270 -0
- package/node_modules/undici/lib/api/api-upgrade.js +121 -0
- package/node_modules/undici/lib/api/index.js +7 -0
- package/node_modules/undici/lib/api/readable.js +581 -0
- package/node_modules/undici/lib/cache/memory-cache-store.js +234 -0
- package/node_modules/undici/lib/cache/sqlite-cache-store.js +463 -0
- package/node_modules/undici/lib/core/connect.js +178 -0
- package/node_modules/undici/lib/core/constants.js +120 -0
- package/node_modules/undici/lib/core/diagnostics.js +227 -0
- package/node_modules/undici/lib/core/errors.js +477 -0
- package/node_modules/undici/lib/core/request.js +535 -0
- package/node_modules/undici/lib/core/socks5-client.js +422 -0
- package/node_modules/undici/lib/core/socks5-utils.js +212 -0
- package/node_modules/undici/lib/core/symbols.js +76 -0
- package/node_modules/undici/lib/core/tree.js +160 -0
- package/node_modules/undici/lib/core/util.js +1021 -0
- package/node_modules/undici/lib/dispatcher/agent.js +172 -0
- package/node_modules/undici/lib/dispatcher/balanced-pool.js +214 -0
- package/node_modules/undici/lib/dispatcher/client-h1.js +1736 -0
- package/node_modules/undici/lib/dispatcher/client-h2.js +1449 -0
- package/node_modules/undici/lib/dispatcher/client.js +695 -0
- package/node_modules/undici/lib/dispatcher/dispatcher-base.js +185 -0
- package/node_modules/undici/lib/dispatcher/dispatcher.js +44 -0
- package/node_modules/undici/lib/dispatcher/dispatcher1-wrapper.js +107 -0
- package/node_modules/undici/lib/dispatcher/env-http-proxy-agent.js +146 -0
- package/node_modules/undici/lib/dispatcher/fixed-queue.js +135 -0
- package/node_modules/undici/lib/dispatcher/h2c-client.js +51 -0
- package/node_modules/undici/lib/dispatcher/pool-base.js +232 -0
- package/node_modules/undici/lib/dispatcher/pool.js +143 -0
- package/node_modules/undici/lib/dispatcher/proxy-agent.js +344 -0
- package/node_modules/undici/lib/dispatcher/retry-agent.js +35 -0
- package/node_modules/undici/lib/dispatcher/round-robin-pool.js +159 -0
- package/node_modules/undici/lib/dispatcher/socks5-proxy-agent.js +266 -0
- package/node_modules/undici/lib/encoding/index.js +33 -0
- package/node_modules/undici/lib/global.js +62 -0
- package/node_modules/undici/lib/handler/cache-handler.js +586 -0
- package/node_modules/undici/lib/handler/cache-revalidation-handler.js +124 -0
- package/node_modules/undici/lib/handler/decorator-handler.js +66 -0
- package/node_modules/undici/lib/handler/deduplication-handler.js +460 -0
- package/node_modules/undici/lib/handler/redirect-handler.js +217 -0
- package/node_modules/undici/lib/handler/retry-handler.js +407 -0
- package/node_modules/undici/lib/interceptor/cache.js +508 -0
- package/node_modules/undici/lib/interceptor/decompress.js +285 -0
- package/node_modules/undici/lib/interceptor/deduplicate.js +117 -0
- package/node_modules/undici/lib/interceptor/dns.js +575 -0
- package/node_modules/undici/lib/interceptor/dump.js +112 -0
- package/node_modules/undici/lib/interceptor/redirect.js +21 -0
- package/node_modules/undici/lib/interceptor/response-error.js +95 -0
- package/node_modules/undici/lib/interceptor/retry.js +19 -0
- package/node_modules/undici/lib/llhttp/constants.d.ts +195 -0
- package/node_modules/undici/lib/llhttp/constants.js +531 -0
- package/node_modules/undici/lib/llhttp/llhttp-wasm.js +15 -0
- package/node_modules/undici/lib/llhttp/llhttp_simd-wasm.js +15 -0
- package/node_modules/undici/lib/llhttp/utils.d.ts +2 -0
- package/node_modules/undici/lib/llhttp/utils.js +12 -0
- package/node_modules/undici/lib/mock/mock-agent.js +232 -0
- package/node_modules/undici/lib/mock/mock-call-history.js +248 -0
- package/node_modules/undici/lib/mock/mock-client.js +68 -0
- package/node_modules/undici/lib/mock/mock-errors.js +29 -0
- package/node_modules/undici/lib/mock/mock-interceptor.js +209 -0
- package/node_modules/undici/lib/mock/mock-pool.js +68 -0
- package/node_modules/undici/lib/mock/mock-symbols.js +32 -0
- package/node_modules/undici/lib/mock/mock-utils.js +501 -0
- package/node_modules/undici/lib/mock/pending-interceptors-formatter.js +43 -0
- package/node_modules/undici/lib/mock/snapshot-agent.js +371 -0
- package/node_modules/undici/lib/mock/snapshot-recorder.js +623 -0
- package/node_modules/undici/lib/mock/snapshot-utils.js +158 -0
- package/node_modules/undici/lib/util/cache.js +414 -0
- package/node_modules/undici/lib/util/date.js +653 -0
- package/node_modules/undici/lib/util/runtime-features.js +93 -0
- package/node_modules/undici/lib/util/stats.js +32 -0
- package/node_modules/undici/lib/util/timers.js +425 -0
- package/node_modules/undici/lib/web/cache/cache.js +862 -0
- package/node_modules/undici/lib/web/cache/cachestorage.js +152 -0
- package/node_modules/undici/lib/web/cache/util.js +45 -0
- package/node_modules/undici/lib/web/cookies/constants.js +12 -0
- package/node_modules/undici/lib/web/cookies/index.js +199 -0
- package/node_modules/undici/lib/web/cookies/parse.js +314 -0
- package/node_modules/undici/lib/web/cookies/util.js +282 -0
- package/node_modules/undici/lib/web/eventsource/eventsource-stream.js +494 -0
- package/node_modules/undici/lib/web/eventsource/eventsource.js +490 -0
- package/node_modules/undici/lib/web/eventsource/util.js +60 -0
- package/node_modules/undici/lib/web/fetch/LICENSE +21 -0
- package/node_modules/undici/lib/web/fetch/body.js +546 -0
- package/node_modules/undici/lib/web/fetch/constants.js +131 -0
- package/node_modules/undici/lib/web/fetch/data-url.js +596 -0
- package/node_modules/undici/lib/web/fetch/formdata-parser.js +586 -0
- package/node_modules/undici/lib/web/fetch/formdata.js +278 -0
- package/node_modules/undici/lib/web/fetch/global.js +40 -0
- package/node_modules/undici/lib/web/fetch/headers.js +719 -0
- package/node_modules/undici/lib/web/fetch/index.js +2417 -0
- package/node_modules/undici/lib/web/fetch/request.js +1145 -0
- package/node_modules/undici/lib/web/fetch/response.js +641 -0
- package/node_modules/undici/lib/web/fetch/util.js +1522 -0
- package/node_modules/undici/lib/web/infra/index.js +229 -0
- package/node_modules/undici/lib/web/subresource-integrity/Readme.md +9 -0
- package/node_modules/undici/lib/web/subresource-integrity/subresource-integrity.js +307 -0
- package/node_modules/undici/lib/web/webidl/index.js +1004 -0
- package/node_modules/undici/lib/web/websocket/connection.js +329 -0
- package/node_modules/undici/lib/web/websocket/constants.js +126 -0
- package/node_modules/undici/lib/web/websocket/events.js +331 -0
- package/node_modules/undici/lib/web/websocket/frame.js +127 -0
- package/node_modules/undici/lib/web/websocket/permessage-deflate.js +100 -0
- package/node_modules/undici/lib/web/websocket/receiver.js +507 -0
- package/node_modules/undici/lib/web/websocket/sender.js +109 -0
- package/node_modules/undici/lib/web/websocket/stream/websocketerror.js +104 -0
- package/node_modules/undici/lib/web/websocket/stream/websocketstream.js +498 -0
- package/node_modules/undici/lib/web/websocket/util.js +347 -0
- package/node_modules/undici/lib/web/websocket/websocket.js +758 -0
- package/node_modules/undici/package.json +152 -0
- package/node_modules/undici/scripts/strip-comments.js +10 -0
- package/node_modules/undici/types/README.md +6 -0
- package/node_modules/undici/types/agent.d.ts +30 -0
- package/node_modules/undici/types/api.d.ts +43 -0
- package/node_modules/undici/types/balanced-pool.d.ts +30 -0
- package/node_modules/undici/types/cache-interceptor.d.ts +179 -0
- package/node_modules/undici/types/cache.d.ts +36 -0
- package/node_modules/undici/types/client-stats.d.ts +15 -0
- package/node_modules/undici/types/client.d.ts +134 -0
- package/node_modules/undici/types/connector.d.ts +37 -0
- package/node_modules/undici/types/content-type.d.ts +21 -0
- package/node_modules/undici/types/cookies.d.ts +30 -0
- package/node_modules/undici/types/diagnostics-channel.d.ts +74 -0
- package/node_modules/undici/types/dispatcher.d.ts +253 -0
- package/node_modules/undici/types/dispatcher1-wrapper.d.ts +7 -0
- package/node_modules/undici/types/env-http-proxy-agent.d.ts +22 -0
- package/node_modules/undici/types/errors.d.ts +177 -0
- package/node_modules/undici/types/eventsource.d.ts +66 -0
- package/node_modules/undici/types/fetch.d.ts +235 -0
- package/node_modules/undici/types/formdata.d.ts +108 -0
- package/node_modules/undici/types/global-dispatcher.d.ts +9 -0
- package/node_modules/undici/types/global-origin.d.ts +7 -0
- package/node_modules/undici/types/h2c-client.d.ts +73 -0
- package/node_modules/undici/types/handlers.d.ts +14 -0
- package/node_modules/undici/types/header.d.ts +165 -0
- package/node_modules/undici/types/index.d.ts +93 -0
- package/node_modules/undici/types/interceptors.d.ts +80 -0
- package/node_modules/undici/types/mock-agent.d.ts +68 -0
- package/node_modules/undici/types/mock-call-history.d.ts +111 -0
- package/node_modules/undici/types/mock-client.d.ts +27 -0
- package/node_modules/undici/types/mock-errors.d.ts +12 -0
- package/node_modules/undici/types/mock-interceptor.d.ts +94 -0
- package/node_modules/undici/types/mock-pool.d.ts +27 -0
- package/node_modules/undici/types/patch.d.ts +29 -0
- package/node_modules/undici/types/pool-stats.d.ts +19 -0
- package/node_modules/undici/types/pool.d.ts +39 -0
- package/node_modules/undici/types/proxy-agent.d.ts +29 -0
- package/node_modules/undici/types/readable.d.ts +68 -0
- package/node_modules/undici/types/retry-agent.d.ts +8 -0
- package/node_modules/undici/types/retry-handler.d.ts +125 -0
- package/node_modules/undici/types/round-robin-pool.d.ts +39 -0
- package/node_modules/undici/types/snapshot-agent.d.ts +113 -0
- package/node_modules/undici/types/socks5-proxy-agent.d.ts +25 -0
- package/node_modules/undici/types/util.d.ts +18 -0
- package/node_modules/undici/types/utility.d.ts +7 -0
- package/node_modules/undici/types/webidl.d.ts +346 -0
- package/node_modules/undici/types/websocket.d.ts +188 -0
- package/npm-shrinkwrap.json +14 -3
- 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 {
|
|
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
|
-
...
|
|
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: () => {
|
package/dist/provider-catalog.js
CHANGED
|
@@ -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
|
|
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
|
|
52
|
+
function resolveAnthropicVertexAdcCredentials(env = process.env) {
|
|
52
53
|
const credentialsPath = resolveAnthropicVertexAdcCredentialsPathCandidate(env);
|
|
53
|
-
|
|
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
|
-
|
|
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 =
|
|
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 };
|
package/dist/stream-runtime.js
CHANGED
|
@@ -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.
|