惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

月光博客
月光博客
云风的 BLOG
云风的 BLOG
小众软件
小众软件
雷峰网
雷峰网
博客园 - 【当耐特】
V
V2EX
WordPress大学
WordPress大学
IT之家
IT之家
Last Week in AI
Last Week in AI
罗磊的独立博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Apple Machine Learning Research
Apple Machine Learning Research
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
V
Visual Studio Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
有赞技术团队
有赞技术团队
The Cloudflare Blog
Jina AI
Jina AI
博客园 - 司徒正美
阮一峰的网络日志
阮一峰的网络日志
博客园 - 聂微东
大猫的无限游戏
大猫的无限游戏
博客园 - 三生石上(FineUI控件)
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix: discover self-hosted provider wildcards · openclaw/o...
rendrag-git · 2026-05-13 · via Recent Commits to openclaw:main

@@ -1,128 +1,7 @@

1-

import type { OpenClawPluginApi } from "openclaw/plugin-sdk/plugin-entry";

2-

import { beforeEach, describe, expect, it, vi } from "vitest";

1+

import { fileURLToPath } from "node:url";

2+

import { describeVllmProviderDiscoveryContract } from "openclaw/plugin-sdk/provider-test-contracts";

334-

const buildVllmProviderMock = vi.hoisted(() => vi.fn());

5-

type DiscoverOpenAICompatibleSelfHostedProviderParams = {

6-

buildProvider: (args: { apiKey?: string }) => Promise<Record<string, unknown>>;

7-

ctx: {

8-

resolveProviderApiKey: () => {

9-

apiKey?: string;

10-

};

11-

resolveProviderAuth: () => {

12-

discoveryApiKey?: string;

13-

};

14-

};

15-

providerId: string;

16-

};

17-

const discoverOpenAICompatibleSelfHostedProviderMock = vi.hoisted(() =>

18-

vi.fn(async (params: DiscoverOpenAICompatibleSelfHostedProviderParams) => ({

19-

provider: {

20-

...(await params.buildProvider({

21-

apiKey: params.ctx.resolveProviderAuth().discoveryApiKey,

22-

})),

23-

apiKey: params.ctx.resolveProviderApiKey().apiKey,

24-

},

25-

})),

26-

);

27-28-

vi.mock("./api.js", () => ({

29-

VLLM_DEFAULT_API_KEY_ENV_VAR: "VLLM_API_KEY",

30-

VLLM_DEFAULT_BASE_URL: "http://127.0.0.1:8000/v1",

31-

VLLM_MODEL_PLACEHOLDER: "meta-llama/Meta-Llama-3-8B-Instruct",

32-

VLLM_PROVIDER_LABEL: "vLLM",

33-

buildVllmProvider: (...args: unknown[]) => buildVllmProviderMock(...args),

34-

}));

35-36-

vi.mock("openclaw/plugin-sdk/provider-setup", () => ({

37-

discoverOpenAICompatibleSelfHostedProvider: (

38-

params: DiscoverOpenAICompatibleSelfHostedProviderParams,

39-

) => discoverOpenAICompatibleSelfHostedProviderMock(params),

40-

}));

41-42-

type ProviderDiscoveryRun = (ctx: {

43-

config: Record<string, unknown>;

44-

env: NodeJS.ProcessEnv;

45-

resolveProviderApiKey: () => {

46-

apiKey: string | undefined;

47-

discoveryApiKey?: string;

48-

};

49-

resolveProviderAuth: () => {

50-

apiKey: string | undefined;

51-

discoveryApiKey?: string;

52-

mode: "api_key" | "oauth" | "token" | "none";

53-

source: "env" | "profile" | "none";

54-

};

55-

}) => Promise<unknown>;

56-57-

type RegisteredVllmProvider = {

58-

id: string;

59-

catalog?: {

60-

order?: string;

61-

run: ProviderDiscoveryRun;

62-

};

63-

};

64-65-

describe("vllm provider discovery contract", () => {

66-

beforeEach(() => {

67-

buildVllmProviderMock.mockReset();

68-

discoverOpenAICompatibleSelfHostedProviderMock.mockClear();

69-

});

70-71-

it("keeps self-hosted discovery provider-owned", async () => {

72-

const { default: plugin } = await import("./index.js");

73-

let provider: RegisteredVllmProvider | undefined;

74-

plugin.register({

75-

registerProvider: (registeredProvider) => {

76-

provider = registeredProvider as RegisteredVllmProvider;

77-

},

78-

} as OpenClawPluginApi);

79-

expect(provider?.id).toBe("vllm");

80-

expect(provider?.catalog?.order).toBe("late");

81-

const catalog = provider?.catalog;

82-

if (!catalog) {

83-

throw new Error("expected vllm provider catalog hook");

84-

}

85-86-

buildVllmProviderMock.mockResolvedValueOnce({

87-

baseUrl: "http://127.0.0.1:8000/v1",

88-

api: "openai-completions",

89-

models: [{ id: "meta-llama/Meta-Llama-3-8B-Instruct", name: "Meta Llama 3" }],

90-

});

91-92-

await expect(

93-

catalog.run({

94-

config: {},

95-

env: {

96-

VLLM_API_KEY: "env-vllm-key",

97-

} as NodeJS.ProcessEnv,

98-

resolveProviderApiKey: () => ({

99-

apiKey: "VLLM_API_KEY",

100-

discoveryApiKey: "env-vllm-key",

101-

}),

102-

resolveProviderAuth: () => ({

103-

apiKey: "VLLM_API_KEY",

104-

discoveryApiKey: "env-vllm-key",

105-

mode: "api_key",

106-

source: "env",

107-

}),

108-

}),

109-

).resolves.toEqual({

110-

provider: {

111-

baseUrl: "http://127.0.0.1:8000/v1",

112-

api: "openai-completions",

113-

apiKey: "VLLM_API_KEY",

114-

models: [{ id: "meta-llama/Meta-Llama-3-8B-Instruct", name: "Meta Llama 3" }],

115-

},

116-

});

117-

expect(buildVllmProviderMock).toHaveBeenCalledWith({

118-

apiKey: "env-vllm-key",

119-

});

120-

expect(discoverOpenAICompatibleSelfHostedProviderMock).toHaveBeenCalledTimes(1);

121-

const [discoveryParams] = discoverOpenAICompatibleSelfHostedProviderMock.mock.calls.at(0) ?? [];

122-

if (discoveryParams === undefined) {

123-

throw new Error("expected discovery parameters");

124-

}

125-

expect(discoveryParams.providerId).toBe("vllm");

126-

expect(discoveryParams.buildProvider).toBeTypeOf("function");

127-

});

4+

describeVllmProviderDiscoveryContract({

5+

load: () => import("./index.js"),

6+

apiModuleId: fileURLToPath(new URL("./api.js", import.meta.url)),

1287

});