Skip to content

Commit 0c18009

Browse files
committed
fix(models): classify externalized official provider endpoints without installed plugins
DashScope/Moonshot/Z.AI/DeepSeek/Groq/Cerebras/Chutes endpoint classes lived only in their provider plugin manifests. Those plugins are excluded from dist packaging, so dist gateways (and built source checkouts, where bundled discovery prefers dist/extensions) classified their base URLs as custom unless the plugin was installed: DashScope image describe prompts left user content, streaming-usage and developer-role compat defaults regressed, and src/media-understanding/image.test.ts plus the model-compat DashScope/Qwen cases failed deterministically after pnpm build, wedging local scripts/pr landing lanes. The official external provider catalog now mirrors each externalized plugin's manifest providerEndpoints, and provider attribution appends catalog metadata after installed/bundled manifests (first match wins, installed manifests stay authoritative). Classification reads the repo-bundled catalog only; hosted feeds never influence it. Endpoint classes core does not recognize (deepinfra-native, gmi-native, qwen-portal-native) stay inert via the existing allowlist filter, matching installed-manifest behavior. A contract test enforces the catalog-manifest mirror; a dist-simulation test covers classification without any plugin manifests. Repro fixed: pnpm build && pnpm test src/media-understanding/image.test.ts src/agents/model-compat.test.ts
1 parent f8dd649 commit 0c18009

7 files changed

Lines changed: 360 additions & 0 deletions

‎docs/plugins/manifest.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -940,6 +940,12 @@ Provider fields:
940940

941941
Use `providerEndpoints` for endpoint classification that generic request policy must know before provider runtime loads. Core still owns the meaning of each `endpointClass`; plugin manifests own the host and base URL metadata.
942942

943+
Officially externalized provider plugins are excluded from the core dist, so
944+
their manifests are invisible until installed. Their `providerEndpoints` must
945+
also be mirrored in `scripts/lib/official-external-provider-catalog.json` so
946+
endpoint classification keeps working without the plugin; a contract test
947+
enforces the mirror.
948+
943949
Endpoint fields:
944950

945951
| Field | Type | What it means |

‎scripts/lib/official-external-provider-catalog.json‎

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,14 @@
151151
"id": "cerebras",
152152
"label": "Cerebras"
153153
},
154+
"providerEndpoints": [
155+
{
156+
"endpointClass": "cerebras-native",
157+
"hosts": [
158+
"api.cerebras.ai"
159+
]
160+
}
161+
],
154162
"providers": [
155163
{
156164
"id": "cerebras",
@@ -200,6 +208,14 @@
200208
"id": "chutes",
201209
"label": "Chutes"
202210
},
211+
"providerEndpoints": [
212+
{
213+
"endpointClass": "chutes-native",
214+
"hosts": [
215+
"llm.chutes.ai"
216+
]
217+
}
218+
],
203219
"providers": [
204220
{
205221
"id": "chutes",
@@ -400,6 +416,14 @@
400416
"id": "deepinfra",
401417
"label": "DeepInfra"
402418
},
419+
"providerEndpoints": [
420+
{
421+
"endpointClass": "deepinfra-native",
422+
"hosts": [
423+
"api.deepinfra.com"
424+
]
425+
}
426+
],
403427
"providers": [
404428
{
405429
"id": "deepinfra",
@@ -467,6 +491,14 @@
467491
"id": "deepseek",
468492
"label": "DeepSeek"
469493
},
494+
"providerEndpoints": [
495+
{
496+
"endpointClass": "deepseek-native",
497+
"hosts": [
498+
"api.deepseek.com"
499+
]
500+
}
501+
],
470502
"providers": [
471503
{
472504
"id": "deepseek",
@@ -516,6 +548,14 @@
516548
"id": "gmi",
517549
"label": "GMI Cloud"
518550
},
551+
"providerEndpoints": [
552+
{
553+
"endpointClass": "gmi-native",
554+
"hosts": [
555+
"api.gmi-serving.com"
556+
]
557+
}
558+
],
519559
"providers": [
520560
{
521561
"id": "gmi",
@@ -559,6 +599,14 @@
559599
"id": "groq",
560600
"label": "Groq"
561601
},
602+
"providerEndpoints": [
603+
{
604+
"endpointClass": "groq-native",
605+
"hosts": [
606+
"api.groq.com"
607+
]
608+
}
609+
],
562610
"providers": [
563611
{
564612
"id": "groq",
@@ -806,6 +854,23 @@
806854
"id": "qwen",
807855
"label": "Qwen Cloud"
808856
},
857+
"providerEndpoints": [
858+
{
859+
"endpointClass": "modelstudio-native",
860+
"baseUrls": [
861+
"https://coding-intl.dashscope.aliyuncs.com/v1",
862+
"https://coding.dashscope.aliyuncs.com/v1",
863+
"https://dashscope.aliyuncs.com/compatible-mode/v1",
864+
"https://dashscope-intl.aliyuncs.com/compatible-mode/v1"
865+
]
866+
},
867+
{
868+
"endpointClass": "qwen-portal-native",
869+
"baseUrls": [
870+
"https://portal.qwen.ai/v1"
871+
]
872+
}
873+
],
809874
"providers": [
810875
{
811876
"id": "qwen",
@@ -1018,6 +1083,15 @@
10181083
"id": "moonshot",
10191084
"label": "Moonshot"
10201085
},
1086+
"providerEndpoints": [
1087+
{
1088+
"endpointClass": "moonshot-native",
1089+
"baseUrls": [
1090+
"https://api.moonshot.ai/v1",
1091+
"https://api.moonshot.cn/v1"
1092+
]
1093+
}
1094+
],
10211095
"providers": [
10221096
{
10231097
"id": "moonshot",
@@ -1267,6 +1341,14 @@
12671341
"id": "zai",
12681342
"label": "Z.AI"
12691343
},
1344+
"providerEndpoints": [
1345+
{
1346+
"endpointClass": "zai-native",
1347+
"hosts": [
1348+
"api.z.ai"
1349+
]
1350+
}
1351+
],
12701352
"providers": [
12711353
{
12721354
"id": "zai",
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
// Verifies catalog-backed endpoint classification for externalized official providers.
2+
import { describe, expect, it, vi } from "vitest";
3+
4+
// Simulates a built dist tree: externalized provider plugins (qwen, moonshot,
5+
// zai, ...) are excluded from dist packaging, so no plugin manifest supplies
6+
// their endpoint metadata. Classification must come from the bundled catalog.
7+
// The single conflicting manifest entry proves installed manifests stay
8+
// authoritative over catalog metadata (first match wins).
9+
vi.mock("../plugins/manifest-metadata-scan.js", () => ({
10+
listOpenClawPluginManifestMetadata: () => [
11+
{
12+
pluginDir: "installed-conflict-fixture",
13+
manifest: {
14+
providerEndpoints: [
15+
{ endpointClass: "openai-public", hosts: ["coding.dashscope.aliyuncs.com"] },
16+
],
17+
},
18+
origin: "installed",
19+
},
20+
],
21+
}));
22+
23+
import {
24+
resolveProviderEndpoint,
25+
resolveProviderRequestCapabilities,
26+
} from "./provider-attribution.js";
27+
28+
describe("catalog-backed provider endpoint classification", () => {
29+
it.each([
30+
["https://dashscope.aliyuncs.com/compatible-mode/v1", "modelstudio-native"],
31+
["https://dashscope-intl.aliyuncs.com/compatible-mode/v1", "modelstudio-native"],
32+
["https://coding-intl.dashscope.aliyuncs.com/v1", "modelstudio-native"],
33+
["https://api.moonshot.ai/v1", "moonshot-native"],
34+
["https://api.moonshot.cn/v1", "moonshot-native"],
35+
["https://api.z.ai/api/coding/paas/v4", "zai-native"],
36+
["https://api.deepseek.com", "deepseek-native"],
37+
["https://api.groq.com/openai/v1", "groq-native"],
38+
["https://api.cerebras.ai/v1", "cerebras-native"],
39+
["https://llm.chutes.ai/v1", "chutes-native"],
40+
])("classifies %s as %s without an installed plugin manifest", (baseUrl, endpointClass) => {
41+
expect(resolveProviderEndpoint(baseUrl).endpointClass).toBe(endpointClass);
42+
});
43+
44+
it("resolves DashScope request capabilities from catalog metadata", () => {
45+
// Image describe placement and streaming-usage compat both key off this
46+
// classification; see shouldPlaceImagePromptInUserContent and
47+
// normalizeModelCompat regressions when qwen was externalized.
48+
const capabilities = resolveProviderRequestCapabilities({
49+
provider: "qwen",
50+
api: "openai-completions",
51+
baseUrl: "https://dashscope.aliyuncs.com/compatible-mode/v1",
52+
capability: "image",
53+
transport: "media-understanding",
54+
});
55+
expect(capabilities.endpointClass).toBe("modelstudio-native");
56+
expect(capabilities.supportsNativeStreamingUsageCompat).toBe(true);
57+
expect(capabilities.isKnownNativeEndpoint).toBe(true);
58+
});
59+
60+
it("prefers installed plugin manifest endpoints over catalog metadata", () => {
61+
expect(resolveProviderEndpoint("https://coding.dashscope.aliyuncs.com/v1").endpointClass).toBe(
62+
"openai-public",
63+
);
64+
});
65+
66+
it("keeps unknown hosts classified as custom", () => {
67+
expect(resolveProviderEndpoint("https://proxy.example.com/v1").endpointClass).toBe("custom");
68+
});
69+
70+
it("drops catalog endpoint classes core does not recognize", () => {
71+
// qwen-portal-native, deepinfra-native, and gmi-native are mirrored
72+
// faithfully from their manifests but are not core ProviderEndpointClass
73+
// members, so they must stay inert (same filtering as installed manifests).
74+
expect(resolveProviderEndpoint("https://portal.qwen.ai/v1").endpointClass).toBe("custom");
75+
expect(resolveProviderEndpoint("https://api.deepinfra.com/v1/openai").endpointClass).toBe(
76+
"custom",
77+
);
78+
expect(resolveProviderEndpoint("https://api.gmi-serving.com/v1").endpointClass).toBe("custom");
79+
});
80+
});

‎src/agents/provider-attribution.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
} from "@openclaw/normalization-core/string-coerce";
1313
import { normalizeTrimmedStringList } from "@openclaw/normalization-core/string-normalization";
1414
import { listOpenClawPluginManifestMetadata } from "../plugins/manifest-metadata-scan.js";
15+
import { listOfficialExternalProviderEndpointManifests } from "../plugins/official-external-provider-endpoints.js";
1516
import { asBoolean } from "../utils/boolean.js";
1617
import type { RuntimeVersionEnv } from "../version.js";
1718
import { resolveRuntimeServiceVersion } from "../version.js";
@@ -331,6 +332,14 @@ function collectManifestProviderEndpoints(): ManifestProviderEndpointCacheEntry[
331332
for (const { manifest } of listOpenClawPluginManifestMetadata()) {
332333
entries.push(...readManifestProviderEndpoints(manifest));
333334
}
335+
// Externalized official provider plugins are excluded from dist builds, so
336+
// their manifests are invisible unless installed. The bundled catalog keeps
337+
// their endpoint classes resolvable: users can point a generic provider key
338+
// at DashScope/Moonshot/... and still need native request policy. Matching
339+
// is first-wins, so installed/bundled manifests stay authoritative.
340+
for (const manifest of listOfficialExternalProviderEndpointManifests()) {
341+
entries.push(...readManifestProviderEndpoints(manifest));
342+
}
334343
return entries;
335344
}
336345

‎src/plugins/official-external-plugin-catalog.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { isRecord } from "../utils.js";
1111
import type {
1212
PluginManifestChannelConfig,
1313
PluginManifestContracts,
14+
PluginManifestProviderEndpoint,
1415
PluginPackageInstall,
1516
} from "./manifest.js";
1617

@@ -81,6 +82,11 @@ export type OfficialExternalPluginCatalogManifest = {
8182
envVars?: readonly string[];
8283
};
8384
providers?: readonly OfficialExternalProviderCatalogProvider[];
85+
/**
86+
* Mirrors the plugin manifest's providerEndpoints so endpoint classification
87+
* keeps working when the plugin is not installed (dist excludes it).
88+
*/
89+
providerEndpoints?: readonly PluginManifestProviderEndpoint[];
8490
webSearchProviders?: readonly OfficialExternalWebSearchProvider[];
8591
install?: PluginPackageInstall & { sourceRef?: string };
8692
contracts?: PluginManifestContracts;

0 commit comments

Comments
 (0)