mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-24 11:25:50 -06:00
refactor(agents): remove stale provider attribution wrappers
This commit is contained in:
@@ -130,11 +130,9 @@ vi.mock("../plugins/manifest-metadata-scan.js", () => ({
|
||||
|
||||
import {
|
||||
listProviderAttributionPolicies,
|
||||
resolveProviderAttributionHeaders,
|
||||
resolveProviderAttributionIdentity,
|
||||
resolveProviderAttributionPolicy,
|
||||
resolveProviderEndpoint,
|
||||
resolveProviderRequestAttributionHeaders,
|
||||
resolveProviderRequestCapabilities,
|
||||
resolveProviderRequestPolicy,
|
||||
describeProviderRequestRoutingSummary,
|
||||
@@ -193,16 +191,16 @@ describe("provider attribution", () => {
|
||||
"X-BILLING-INVOKE-ORIGIN": "OpenClaw",
|
||||
},
|
||||
});
|
||||
expect(resolveProviderAttributionHeaders("NVIDIA", { OPENCLAW_VERSION: "2026.3.22" })).toEqual({
|
||||
expect(policy.headers).toEqual({
|
||||
"X-BILLING-INVOKE-ORIGIN": "OpenClaw",
|
||||
});
|
||||
});
|
||||
|
||||
it("normalizes aliases when resolving provider headers", () => {
|
||||
it("normalizes aliases when resolving provider policy headers", () => {
|
||||
expect(
|
||||
resolveProviderAttributionHeaders("OpenRouter", {
|
||||
resolveProviderAttributionPolicy("OpenRouter", {
|
||||
OPENCLAW_VERSION: "2026.3.22",
|
||||
}),
|
||||
})?.headers,
|
||||
).toEqual({
|
||||
"HTTP-Referer": "https://openclaw.ai",
|
||||
"X-OpenRouter-Title": "OpenClaw",
|
||||
@@ -227,7 +225,9 @@ describe("provider attribution", () => {
|
||||
"User-Agent": "openclaw/2026.3.22",
|
||||
},
|
||||
});
|
||||
expect(resolveProviderAttributionHeaders("openai", { OPENCLAW_VERSION: "2026.3.22" })).toEqual({
|
||||
expect(
|
||||
resolveProviderAttributionPolicy("openai", { OPENCLAW_VERSION: "2026.3.22" })?.headers,
|
||||
).toEqual({
|
||||
originator: "openclaw",
|
||||
version: "2026.3.22",
|
||||
"User-Agent": "openclaw/2026.3.22",
|
||||
@@ -268,7 +268,9 @@ describe("provider attribution", () => {
|
||||
"User-Agent": "openclaw/2026.3.22",
|
||||
},
|
||||
});
|
||||
expect(resolveProviderAttributionHeaders("xai", { OPENCLAW_VERSION: "2026.3.22" })).toEqual({
|
||||
expect(
|
||||
resolveProviderAttributionPolicy("xai", { OPENCLAW_VERSION: "2026.3.22" })?.headers,
|
||||
).toEqual({
|
||||
originator: "openclaw",
|
||||
version: "2026.3.22",
|
||||
"User-Agent": "openclaw/2026.3.22",
|
||||
@@ -316,7 +318,7 @@ describe("provider attribution", () => {
|
||||
},
|
||||
);
|
||||
expect(
|
||||
resolveProviderRequestAttributionHeaders(
|
||||
resolveProviderRequestPolicy(
|
||||
{
|
||||
provider: "xai",
|
||||
api: "openai-responses",
|
||||
@@ -325,7 +327,7 @@ describe("provider attribution", () => {
|
||||
capability: "llm",
|
||||
},
|
||||
{ OPENCLAW_VERSION: "2026.3.22" },
|
||||
),
|
||||
).attributionHeaders,
|
||||
).toEqual({
|
||||
originator: "openclaw",
|
||||
version: "2026.3.22",
|
||||
@@ -571,12 +573,12 @@ describe("provider attribution", () => {
|
||||
);
|
||||
|
||||
expect(
|
||||
resolveProviderRequestAttributionHeaders({
|
||||
resolveProviderRequestPolicy({
|
||||
provider: "openrouter",
|
||||
baseUrl: "https://proxy.example.com/v1",
|
||||
transport: "stream",
|
||||
capability: "llm",
|
||||
}),
|
||||
}).attributionHeaders,
|
||||
).toBeUndefined();
|
||||
});
|
||||
|
||||
@@ -598,25 +600,25 @@ describe("provider attribution", () => {
|
||||
);
|
||||
|
||||
expect(
|
||||
resolveProviderRequestAttributionHeaders({
|
||||
resolveProviderRequestPolicy({
|
||||
provider: "custom-nim",
|
||||
api: "openai-completions",
|
||||
baseUrl: "https://integrate.api.nvidia.com/v1",
|
||||
transport: "stream",
|
||||
capability: "llm",
|
||||
}),
|
||||
}).attributionHeaders,
|
||||
).toEqual({
|
||||
"X-BILLING-INVOKE-ORIGIN": "OpenClaw",
|
||||
});
|
||||
|
||||
expect(
|
||||
resolveProviderRequestAttributionHeaders({
|
||||
resolveProviderRequestPolicy({
|
||||
provider: "nvidia",
|
||||
api: "openai-completions",
|
||||
baseUrl: "https://proxy.example.com/v1",
|
||||
transport: "stream",
|
||||
capability: "llm",
|
||||
}),
|
||||
}).attributionHeaders,
|
||||
).toBeUndefined();
|
||||
});
|
||||
|
||||
|
||||
@@ -616,17 +616,6 @@ export function resolveProviderAttributionPolicy(
|
||||
return listProviderAttributionPolicies(env).find((policy) => policy.provider === canonical);
|
||||
}
|
||||
|
||||
export function resolveProviderAttributionHeaders(
|
||||
provider?: string | null,
|
||||
env: RuntimeVersionEnv = process.env as RuntimeVersionEnv,
|
||||
): Record<string, string> | undefined {
|
||||
const policy = resolveProviderAttributionPolicy(provider, env);
|
||||
if (!policy?.enabledByDefault) {
|
||||
return undefined;
|
||||
}
|
||||
return policy.headers;
|
||||
}
|
||||
|
||||
export function resolveProviderRequestPolicy(
|
||||
input: ProviderRequestPolicyInput,
|
||||
env: RuntimeVersionEnv = process.env as RuntimeVersionEnv,
|
||||
@@ -694,13 +683,6 @@ export function resolveProviderRequestPolicy(
|
||||
};
|
||||
}
|
||||
|
||||
export function resolveProviderRequestAttributionHeaders(
|
||||
input: ProviderRequestPolicyInput,
|
||||
env: RuntimeVersionEnv = process.env as RuntimeVersionEnv,
|
||||
): Record<string, string> | undefined {
|
||||
return resolveProviderRequestPolicy(input, env).attributionHeaders;
|
||||
}
|
||||
|
||||
export function resolveProviderRequestCapabilities(
|
||||
input: ProviderRequestCapabilitiesInput,
|
||||
env: RuntimeVersionEnv = process.env as RuntimeVersionEnv,
|
||||
|
||||
Reference in New Issue
Block a user