




















@@ -16,12 +16,23 @@ function readManifest(): NvidiaManifest {
1616) as NvidiaManifest;
1717}
181819-describe("nvidia provider plugin", () => {
20-it("registers API-key auth metadata", async () => {
21-const provider = await registerSingleProviderPlugin(plugin);
19+async function registerNvidiaProvider() {
20+return registerSingleProviderPlugin(plugin);
21+}
22+23+describe("nvidia provider hooks", () => {
24+it("registers the nvidia provider with correct metadata", async () => {
25+const provider = await registerNvidiaProvider();
22262327expect(provider.id).toBe("nvidia");
28+expect(provider.label).toBe("NVIDIA");
29+expect(provider.docsPath).toBe("/providers/nvidia");
2430expect(provider.envVars).toEqual(["NVIDIA_API_KEY"]);
31+});
32+33+it("registers API-key auth choice metadata", async () => {
34+const provider = await registerNvidiaProvider();
35+2536expect(provider.auth?.map((method) => method.id)).toEqual(["api-key"]);
26372738const choice = resolveProviderPluginChoice({
@@ -40,4 +51,107 @@ describe("nvidia provider plugin", () => {
4051]),
4152);
4253});
54+55+it("keeps nvidia auth setup metadata aligned", async () => {
56+const provider = await registerNvidiaProvider();
57+58+expect(
59+provider.auth.map((method) => ({
60+id: method.id,
61+label: method.label,
62+hint: method.hint,
63+choiceId: method.wizard?.choiceId,
64+groupId: method.wizard?.groupId,
65+groupLabel: method.wizard?.groupLabel,
66+groupHint: method.wizard?.groupHint,
67+})),
68+).toEqual([
69+{
70+id: "api-key",
71+label: "NVIDIA API key",
72+hint: "Direct API key",
73+choiceId: "nvidia-api-key",
74+groupId: "nvidia",
75+groupLabel: "NVIDIA",
76+groupHint: "Direct API key",
77+},
78+]);
79+});
80+81+it("keeps nvidia wizard setup metadata aligned", async () => {
82+const provider = await registerNvidiaProvider();
83+84+expect(provider.wizard?.setup).toMatchObject({
85+choiceId: "nvidia-api-key",
86+choiceLabel: "NVIDIA API key",
87+groupId: "nvidia",
88+groupLabel: "NVIDIA",
89+groupHint: "Direct API key",
90+methodId: "api-key",
91+});
92+});
93+94+it("keeps nvidia model picker metadata aligned", async () => {
95+const provider = await registerNvidiaProvider();
96+97+expect(provider.wizard?.modelPicker).toMatchObject({
98+label: "NVIDIA (custom)",
99+hint: "Use NVIDIA-hosted open models",
100+methodId: "api-key",
101+});
102+});
103+104+it("does not override replay policy for standard openai-compatible transport", async () => {
105+const provider = await registerNvidiaProvider();
106+107+// NVIDIA uses standard OpenAI-compatible API without custom replay logic
108+expect(provider.buildReplayPolicy).toBeUndefined();
109+});
110+111+it("does not override stream wrapper for standard models", async () => {
112+const provider = await registerNvidiaProvider();
113+114+// NVIDIA uses standard streaming without custom wrappers
115+expect(provider.wrapStreamFn).toBeUndefined();
116+});
117+118+it("surfaces the bundled NVIDIA models via augmentModelCatalog", async () => {
119+const provider = await registerNvidiaProvider();
120+121+const entries = await provider.augmentModelCatalog?.({
122+env: process.env,
123+entries: [],
124+});
125+126+expect(entries?.map((entry) => entry.id)).toEqual([
127+"nvidia/nemotron-3-super-120b-a12b",
128+"moonshotai/kimi-k2.5",
129+"minimaxai/minimax-m2.5",
130+"z-ai/glm5",
131+]);
132+expect(entries?.every((entry) => entry.provider === "nvidia")).toBe(true);
133+});
134+135+it("opts into literal provider-prefix preservation", async () => {
136+const provider = await registerNvidiaProvider();
137+138+// NVIDIA's ids like nvidia/nemotron-... sit alongside moonshotai/...,
139+// minimaxai/..., z-ai/... in the same catalog, so the leading nvidia/
140+// is a vendor namespace rather than a redundant provider prefix. The
141+// flag keeps the canonical ref as nvidia/nvidia/nemotron-... instead
142+// of letting the default string-based dedupe collapse it.
143+expect(provider.preserveLiteralProviderPrefix).toBe(true);
144+});
145+146+it("registers nvidia provider through the plugin api", () => {
147+const registeredProviders: string[] = [];
148+149+plugin.register({
150+registerProvider(provider: { id: string }) {
151+registeredProviders.push(provider.id);
152+},
153+} as any);
154+155+expect(registeredProviders).toContain("nvidia");
156+});
43157});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。