@openclaw/cloudflare-ai-gateway-provider 2026.9.6 → 2026.9.8
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/assets/icon.png +0 -0
- package/dist/catalog-provider.js +7 -18
- package/dist/stream-wrappers.js +3 -16
- package/openclaw.plugin.json +3 -0
- package/package.json +4 -4
package/assets/icon.png
CHANGED
|
Binary file
|
package/dist/catalog-provider.js
CHANGED
|
@@ -2,10 +2,6 @@ import { buildCloudflareAiGatewayModelDefinition, resolveCloudflareAiGatewayBase
|
|
|
2
2
|
import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
3
3
|
import { coerceSecretRef, resolveNonEnvSecretRefApiKeyMarker } from "openclaw/plugin-sdk/secret-input";
|
|
4
4
|
//#region extensions/cloudflare-ai-gateway/catalog-provider.ts
|
|
5
|
-
/**
|
|
6
|
-
* Builds runtime model catalog entries from stored Cloudflare AI Gateway auth
|
|
7
|
-
* profiles.
|
|
8
|
-
*/
|
|
9
5
|
function resolveCloudflareAiGatewayApiKey(cred) {
|
|
10
6
|
if (!cred || cred.type !== "api_key") return;
|
|
11
7
|
const keyRef = coerceSecretRef(cred.keyRef);
|
|
@@ -13,13 +9,6 @@ function resolveCloudflareAiGatewayApiKey(cred) {
|
|
|
13
9
|
if (keyRef && keyRefId) return keyRef.source === "env" ? keyRefId : resolveNonEnvSecretRefApiKeyMarker(keyRef.source);
|
|
14
10
|
return normalizeOptionalString(cred.key);
|
|
15
11
|
}
|
|
16
|
-
function resolveCloudflareAiGatewayMetadata(cred) {
|
|
17
|
-
if (!cred || cred.type !== "api_key") return {};
|
|
18
|
-
return {
|
|
19
|
-
accountId: normalizeOptionalString(cred.metadata?.accountId),
|
|
20
|
-
gatewayId: normalizeOptionalString(cred.metadata?.gatewayId)
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
12
|
/**
|
|
24
13
|
* Returns a provider catalog entry when credentials and Gateway metadata are
|
|
25
14
|
* complete enough to construct an Anthropic-compatible base URL.
|
|
@@ -27,15 +16,15 @@ function resolveCloudflareAiGatewayMetadata(cred) {
|
|
|
27
16
|
function buildCloudflareAiGatewayCatalogProvider(params) {
|
|
28
17
|
const apiKey = normalizeOptionalString(params.envApiKey) ?? resolveCloudflareAiGatewayApiKey(params.credential);
|
|
29
18
|
if (!apiKey) return null;
|
|
30
|
-
const
|
|
19
|
+
const metadata = params.credential?.type === "api_key" ? params.credential.metadata : void 0;
|
|
20
|
+
const accountId = normalizeOptionalString(metadata?.accountId);
|
|
21
|
+
const gatewayId = normalizeOptionalString(metadata?.gatewayId);
|
|
31
22
|
if (!accountId || !gatewayId) return null;
|
|
32
|
-
const baseUrl = resolveCloudflareAiGatewayBaseUrl({
|
|
33
|
-
accountId,
|
|
34
|
-
gatewayId
|
|
35
|
-
});
|
|
36
|
-
if (!baseUrl) return null;
|
|
37
23
|
return {
|
|
38
|
-
baseUrl
|
|
24
|
+
baseUrl: resolveCloudflareAiGatewayBaseUrl({
|
|
25
|
+
accountId,
|
|
26
|
+
gatewayId
|
|
27
|
+
}),
|
|
39
28
|
api: "anthropic-messages",
|
|
40
29
|
apiKey,
|
|
41
30
|
models: [buildCloudflareAiGatewayModelDefinition()]
|
package/dist/stream-wrappers.js
CHANGED
|
@@ -2,24 +2,11 @@ import { createAnthropicThinkingPrefillPayloadWrapper } from "openclaw/plugin-sd
|
|
|
2
2
|
import { createSubsystemLogger } from "openclaw/plugin-sdk/runtime-env";
|
|
3
3
|
//#region extensions/cloudflare-ai-gateway/stream-wrappers.ts
|
|
4
4
|
const log = createSubsystemLogger("cloudflare-ai-gateway-stream");
|
|
5
|
-
function
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Creates a wrapper that removes trailing assistant prefill messages before
|
|
10
|
-
* extended-thinking Anthropic requests are sent through Cloudflare.
|
|
11
|
-
*/
|
|
12
|
-
function createCloudflareAiGatewayAnthropicThinkingPrefillWrapper(baseStreamFn) {
|
|
13
|
-
return createAnthropicThinkingPrefillPayloadWrapper(baseStreamFn, (stripped) => {
|
|
5
|
+
function wrapCloudflareAiGatewayProviderStream(ctx) {
|
|
6
|
+
if (ctx.model?.api !== void 0 && ctx.model.api !== "anthropic-messages") return ctx.streamFn;
|
|
7
|
+
return createAnthropicThinkingPrefillPayloadWrapper(ctx.streamFn, (stripped) => {
|
|
14
8
|
log.warn(`removed ${stripped} trailing assistant prefill message${stripped === 1 ? "" : "s"} because Anthropic extended thinking requires conversations to end with a user turn`);
|
|
15
9
|
});
|
|
16
10
|
}
|
|
17
|
-
/**
|
|
18
|
-
* Applies the Anthropic payload wrapper only for Anthropic-compatible models.
|
|
19
|
-
*/
|
|
20
|
-
function wrapCloudflareAiGatewayProviderStream(ctx) {
|
|
21
|
-
if (!shouldPatchAnthropicMessagesPayload(ctx.model)) return ctx.streamFn;
|
|
22
|
-
return createCloudflareAiGatewayAnthropicThinkingPrefillWrapper(ctx.streamFn);
|
|
23
|
-
}
|
|
24
11
|
//#endregion
|
|
25
12
|
export { wrapCloudflareAiGatewayProviderStream };
|
package/openclaw.plugin.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/cloudflare-ai-gateway-provider",
|
|
3
|
-
"version": "2026.9.
|
|
3
|
+
"version": "2026.9.8",
|
|
4
4
|
"description": "OpenClaw Cloudflare AI Gateway provider plugin.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -18,10 +18,10 @@
|
|
|
18
18
|
"minHostVersion": ">=2026.6.8"
|
|
19
19
|
},
|
|
20
20
|
"compat": {
|
|
21
|
-
"pluginApi": ">=2026.9.
|
|
21
|
+
"pluginApi": ">=2026.9.8"
|
|
22
22
|
},
|
|
23
23
|
"build": {
|
|
24
|
-
"openclawVersion": "2026.9.
|
|
24
|
+
"openclawVersion": "2026.9.8",
|
|
25
25
|
"bundledDist": false
|
|
26
26
|
},
|
|
27
27
|
"release": {
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"assets/activity.svg"
|
|
41
41
|
],
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"openclaw": ">=2026.9.
|
|
43
|
+
"openclaw": ">=2026.9.8"
|
|
44
44
|
},
|
|
45
45
|
"peerDependenciesMeta": {
|
|
46
46
|
"openclaw": {
|