mirror of https://github.com/openclaw/openclaw.git
fix(ci): await async provider test registration
This commit is contained in:
parent
4812b9d2e2
commit
f4855baf35
|
|
@ -7,10 +7,12 @@ import type { PluginRuntime } from "../../src/plugins/runtime/types.js";
|
|||
import { registerSingleProviderPlugin } from "../../test/helpers/plugins/plugin-registration.js";
|
||||
import amazonBedrockPlugin from "./index.js";
|
||||
|
||||
type RegisteredProviderPlugin = ReturnType<typeof registerSingleProviderPlugin>;
|
||||
type RegisteredProviderPlugin = Awaited<ReturnType<typeof registerSingleProviderPlugin>>;
|
||||
|
||||
/** Register the amazon-bedrock plugin with an optional pluginConfig override. */
|
||||
function registerWithConfig(pluginConfig?: Record<string, unknown>): RegisteredProviderPlugin {
|
||||
async function registerWithConfig(
|
||||
pluginConfig?: Record<string, unknown>,
|
||||
): Promise<RegisteredProviderPlugin> {
|
||||
const providers: RegisteredProviderPlugin[] = [];
|
||||
const noopLogger = { info() {}, warn() {}, error() {}, debug() {} };
|
||||
const api = buildPluginApi({
|
||||
|
|
@ -29,7 +31,7 @@ function registerWithConfig(pluginConfig?: Record<string, unknown>): RegisteredP
|
|||
},
|
||||
},
|
||||
});
|
||||
amazonBedrockPlugin.register(api);
|
||||
await amazonBedrockPlugin.register(api);
|
||||
const provider = providers[0];
|
||||
if (!provider) throw new Error("provider registration missing");
|
||||
return provider;
|
||||
|
|
@ -88,8 +90,8 @@ function callWrappedStream(
|
|||
}
|
||||
|
||||
describe("amazon-bedrock provider plugin", () => {
|
||||
it("marks Claude 4.6 Bedrock models as adaptive by default", () => {
|
||||
const provider = registerSingleProviderPlugin(amazonBedrockPlugin);
|
||||
it("marks Claude 4.6 Bedrock models as adaptive by default", async () => {
|
||||
const provider = await registerSingleProviderPlugin(amazonBedrockPlugin);
|
||||
|
||||
expect(
|
||||
provider.resolveDefaultThinkingLevel?.({
|
||||
|
|
@ -105,8 +107,8 @@ describe("amazon-bedrock provider plugin", () => {
|
|||
).toBeUndefined();
|
||||
});
|
||||
|
||||
it("owns Anthropic-style replay policy for Claude Bedrock models", () => {
|
||||
const provider = registerSingleProviderPlugin(amazonBedrockPlugin);
|
||||
it("owns Anthropic-style replay policy for Claude Bedrock models", async () => {
|
||||
const provider = await registerSingleProviderPlugin(amazonBedrockPlugin);
|
||||
|
||||
expect(
|
||||
provider.buildReplayPolicy?.({
|
||||
|
|
@ -126,8 +128,8 @@ describe("amazon-bedrock provider plugin", () => {
|
|||
});
|
||||
});
|
||||
|
||||
it("disables prompt caching for non-Anthropic Bedrock models", () => {
|
||||
const provider = registerSingleProviderPlugin(amazonBedrockPlugin);
|
||||
it("disables prompt caching for non-Anthropic Bedrock models", async () => {
|
||||
const provider = await registerSingleProviderPlugin(amazonBedrockPlugin);
|
||||
const wrapped = provider.wrapStreamFn?.({
|
||||
provider: "amazon-bedrock",
|
||||
modelId: "amazon.nova-micro-v1:0",
|
||||
|
|
@ -180,8 +182,8 @@ describe("amazon-bedrock provider plugin", () => {
|
|||
});
|
||||
|
||||
describe("guardrail payload injection", () => {
|
||||
it("does not inject guardrailConfig when guardrail is absent from plugin config", () => {
|
||||
const provider = registerWithConfig(undefined);
|
||||
it("does not inject guardrailConfig when guardrail is absent from plugin config", async () => {
|
||||
const provider = await registerWithConfig(undefined);
|
||||
const result = callWrappedStream(provider, NON_ANTHROPIC_MODEL, MODEL_DESCRIPTOR);
|
||||
|
||||
expect(result).not.toHaveProperty("_capturedPayload");
|
||||
|
|
@ -189,8 +191,8 @@ describe("amazon-bedrock provider plugin", () => {
|
|||
expect(result).toMatchObject({ cacheRetention: "none" });
|
||||
});
|
||||
|
||||
it("injects all four fields when guardrail config includes optional fields", () => {
|
||||
const provider = registerWithConfig({
|
||||
it("injects all four fields when guardrail config includes optional fields", async () => {
|
||||
const provider = await registerWithConfig({
|
||||
guardrail: {
|
||||
guardrailIdentifier: "my-guardrail-id",
|
||||
guardrailVersion: "1",
|
||||
|
|
@ -210,8 +212,8 @@ describe("amazon-bedrock provider plugin", () => {
|
|||
});
|
||||
});
|
||||
|
||||
it("injects only required fields when optional fields are omitted", () => {
|
||||
const provider = registerWithConfig({
|
||||
it("injects only required fields when optional fields are omitted", async () => {
|
||||
const provider = await registerWithConfig({
|
||||
guardrail: {
|
||||
guardrailIdentifier: "abc123",
|
||||
guardrailVersion: "DRAFT",
|
||||
|
|
@ -227,8 +229,8 @@ describe("amazon-bedrock provider plugin", () => {
|
|||
});
|
||||
});
|
||||
|
||||
it("injects guardrailConfig for Anthropic models without cacheRetention: none", () => {
|
||||
const provider = registerWithConfig({
|
||||
it("injects guardrailConfig for Anthropic models without cacheRetention: none", async () => {
|
||||
const provider = await registerWithConfig({
|
||||
guardrail: {
|
||||
guardrailIdentifier: "guardrail-anthropic",
|
||||
guardrailVersion: "2",
|
||||
|
|
@ -251,8 +253,8 @@ describe("amazon-bedrock provider plugin", () => {
|
|||
expect(result).not.toHaveProperty("cacheRetention", "none");
|
||||
});
|
||||
|
||||
it("injects guardrailConfig for non-Anthropic models with cacheRetention: none", () => {
|
||||
const provider = registerWithConfig({
|
||||
it("injects guardrailConfig for non-Anthropic models with cacheRetention: none", async () => {
|
||||
const provider = await registerWithConfig({
|
||||
guardrail: {
|
||||
guardrailIdentifier: "guardrail-nova",
|
||||
guardrailVersion: "3",
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ import { registerSingleProviderPlugin } from "../../test/helpers/plugins/plugin-
|
|||
import anthropicVertexPlugin from "./index.js";
|
||||
|
||||
describe("anthropic-vertex provider plugin", () => {
|
||||
it("resolves the ADC marker through the provider hook", () => {
|
||||
const provider = registerSingleProviderPlugin(anthropicVertexPlugin);
|
||||
it("resolves the ADC marker through the provider hook", async () => {
|
||||
const provider = await registerSingleProviderPlugin(anthropicVertexPlugin);
|
||||
|
||||
expect(
|
||||
provider.resolveConfigApiKey?.({
|
||||
|
|
@ -17,7 +17,7 @@ describe("anthropic-vertex provider plugin", () => {
|
|||
});
|
||||
|
||||
it("merges the implicit Vertex catalog into explicit provider overrides", async () => {
|
||||
const provider = registerSingleProviderPlugin(anthropicVertexPlugin);
|
||||
const provider = await registerSingleProviderPlugin(anthropicVertexPlugin);
|
||||
|
||||
const result = await provider.catalog?.run({
|
||||
config: {
|
||||
|
|
@ -57,8 +57,8 @@ describe("anthropic-vertex provider plugin", () => {
|
|||
});
|
||||
});
|
||||
|
||||
it("owns Anthropic-style replay policy", () => {
|
||||
const provider = registerSingleProviderPlugin(anthropicVertexPlugin);
|
||||
it("owns Anthropic-style replay policy", async () => {
|
||||
const provider = await registerSingleProviderPlugin(anthropicVertexPlugin);
|
||||
|
||||
expect(
|
||||
provider.buildReplayPolicy?.({
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ import { registerSingleProviderPlugin } from "../../test/helpers/plugins/plugin-
|
|||
import anthropicPlugin from "./index.js";
|
||||
|
||||
describe("anthropic provider replay hooks", () => {
|
||||
it("owns native reasoning output mode for Claude transports", () => {
|
||||
const provider = registerSingleProviderPlugin(anthropicPlugin);
|
||||
it("owns native reasoning output mode for Claude transports", async () => {
|
||||
const provider = await registerSingleProviderPlugin(anthropicPlugin);
|
||||
|
||||
expect(
|
||||
provider.resolveReasoningOutputMode?.({
|
||||
|
|
@ -15,8 +15,8 @@ describe("anthropic provider replay hooks", () => {
|
|||
).toBe("native");
|
||||
});
|
||||
|
||||
it("owns replay policy for Claude transports", () => {
|
||||
const provider = registerSingleProviderPlugin(anthropicPlugin);
|
||||
it("owns replay policy for Claude transports", async () => {
|
||||
const provider = await registerSingleProviderPlugin(anthropicPlugin);
|
||||
|
||||
expect(
|
||||
provider.buildReplayPolicy?.({
|
||||
|
|
@ -36,8 +36,8 @@ describe("anthropic provider replay hooks", () => {
|
|||
});
|
||||
});
|
||||
|
||||
it("defaults provider api through plugin config normalization", () => {
|
||||
const provider = registerSingleProviderPlugin(anthropicPlugin);
|
||||
it("defaults provider api through plugin config normalization", async () => {
|
||||
const provider = await registerSingleProviderPlugin(anthropicPlugin);
|
||||
|
||||
expect(
|
||||
provider.normalizeConfig?.({
|
||||
|
|
@ -51,8 +51,8 @@ describe("anthropic provider replay hooks", () => {
|
|||
});
|
||||
});
|
||||
|
||||
it("applies Anthropic pruning defaults through plugin hooks", () => {
|
||||
const provider = registerSingleProviderPlugin(anthropicPlugin);
|
||||
it("applies Anthropic pruning defaults through plugin hooks", async () => {
|
||||
const provider = await registerSingleProviderPlugin(anthropicPlugin);
|
||||
|
||||
const next = provider.applyConfigDefaults?.({
|
||||
provider: "anthropic",
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ import { registerSingleProviderPlugin } from "../../test/helpers/plugins/plugin-
|
|||
import deepseekPlugin from "./index.js";
|
||||
|
||||
describe("deepseek provider plugin", () => {
|
||||
it("registers DeepSeek with api-key auth wizard metadata", () => {
|
||||
const provider = registerSingleProviderPlugin(deepseekPlugin);
|
||||
it("registers DeepSeek with api-key auth wizard metadata", async () => {
|
||||
const provider = await registerSingleProviderPlugin(deepseekPlugin);
|
||||
const resolved = resolveProviderPluginChoice({
|
||||
providers: [provider],
|
||||
choice: "deepseek-api-key",
|
||||
|
|
@ -21,7 +21,7 @@ describe("deepseek provider plugin", () => {
|
|||
});
|
||||
|
||||
it("builds the static DeepSeek model catalog", async () => {
|
||||
const provider = registerSingleProviderPlugin(deepseekPlugin);
|
||||
const provider = await registerSingleProviderPlugin(deepseekPlugin);
|
||||
expect(provider.catalog).toBeDefined();
|
||||
|
||||
const catalog = await provider.catalog!.run({
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import googlePlugin from "./index.js";
|
|||
|
||||
describe("google provider plugin hooks", () => {
|
||||
it("owns replay policy and reasoning mode for the direct Gemini provider", async () => {
|
||||
const { providers } = registerProviderPlugin({
|
||||
const { providers } = await registerProviderPlugin({
|
||||
plugin: googlePlugin,
|
||||
id: "google",
|
||||
name: "Google Provider",
|
||||
|
|
@ -81,8 +81,8 @@ describe("google provider plugin hooks", () => {
|
|||
expect(customEntries[0]?.customType).toBe("google-turn-ordering-bootstrap");
|
||||
});
|
||||
|
||||
it("owns Gemini CLI tool schema normalization", () => {
|
||||
const { providers } = registerProviderPlugin({
|
||||
it("owns Gemini CLI tool schema normalization", async () => {
|
||||
const { providers } = await registerProviderPlugin({
|
||||
plugin: googlePlugin,
|
||||
id: "google",
|
||||
name: "Google Provider",
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ import {
|
|||
import minimaxPlugin from "./index.js";
|
||||
|
||||
describe("minimax provider hooks", () => {
|
||||
it("keeps native reasoning mode for MiniMax transports", () => {
|
||||
const { providers } = registerProviderPlugin({
|
||||
it("keeps native reasoning mode for MiniMax transports", async () => {
|
||||
const { providers } = await registerProviderPlugin({
|
||||
plugin: minimaxPlugin,
|
||||
id: "minimax",
|
||||
name: "MiniMax Provider",
|
||||
|
|
@ -36,8 +36,8 @@ describe("minimax provider hooks", () => {
|
|||
).toBe("native");
|
||||
});
|
||||
|
||||
it("owns replay policy for Anthropic and OpenAI-compatible MiniMax transports", () => {
|
||||
const { providers } = registerProviderPlugin({
|
||||
it("owns replay policy for Anthropic and OpenAI-compatible MiniMax transports", async () => {
|
||||
const { providers } = await registerProviderPlugin({
|
||||
plugin: minimaxPlugin,
|
||||
id: "minimax",
|
||||
name: "MiniMax Provider",
|
||||
|
|
@ -73,8 +73,8 @@ describe("minimax provider hooks", () => {
|
|||
});
|
||||
});
|
||||
|
||||
it("owns fast-mode stream wrapping for MiniMax transports", () => {
|
||||
const { providers } = registerProviderPlugin({
|
||||
it("owns fast-mode stream wrapping for MiniMax transports", async () => {
|
||||
const { providers } = await registerProviderPlugin({
|
||||
plugin: minimaxPlugin,
|
||||
id: "minimax",
|
||||
name: "MiniMax Provider",
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ import { registerSingleProviderPlugin } from "../../test/helpers/plugins/plugin-
|
|||
import plugin from "./index.js";
|
||||
|
||||
describe("moonshot provider plugin", () => {
|
||||
it("owns replay policy for OpenAI-compatible Moonshot transports", () => {
|
||||
const provider = registerSingleProviderPlugin(plugin);
|
||||
it("owns replay policy for OpenAI-compatible Moonshot transports", async () => {
|
||||
const provider = await registerSingleProviderPlugin(plugin);
|
||||
|
||||
expect(
|
||||
provider.buildReplayPolicy?.({
|
||||
|
|
|
|||
|
|
@ -31,16 +31,16 @@ vi.mock("@mariozechner/pi-ai/oauth", async () => {
|
|||
|
||||
import { refreshOpenAICodexToken } from "./openai-codex-provider.runtime.js";
|
||||
|
||||
const registerOpenAIPlugin = () =>
|
||||
const registerOpenAIPlugin = async () =>
|
||||
registerProviderPlugin({
|
||||
plugin,
|
||||
id: "openai",
|
||||
name: "OpenAI Provider",
|
||||
});
|
||||
|
||||
function registerOpenAIPluginWithHook(params?: { pluginConfig?: Record<string, unknown> }) {
|
||||
async function registerOpenAIPluginWithHook(params?: { pluginConfig?: Record<string, unknown> }) {
|
||||
const on = vi.fn();
|
||||
plugin.register(
|
||||
await plugin.register(
|
||||
createTestPluginApi({
|
||||
id: "openai",
|
||||
name: "OpenAI Provider",
|
||||
|
|
@ -241,7 +241,7 @@ describe("openai plugin", () => {
|
|||
});
|
||||
|
||||
it("registers the friendly prompt overlay by default and scopes it to OpenAI providers", async () => {
|
||||
const { on } = registerOpenAIPluginWithHook();
|
||||
const { on } = await registerOpenAIPluginWithHook();
|
||||
|
||||
expect(on).toHaveBeenCalledWith("before_prompt_build", expect.any(Function));
|
||||
const beforePromptBuild = on.mock.calls.find((call) => call[0] === "before_prompt_build")?.[1];
|
||||
|
|
@ -268,8 +268,8 @@ describe("openai plugin", () => {
|
|||
expect(nonOpenAIResult).toBeUndefined();
|
||||
});
|
||||
|
||||
it("supports opting out of the prompt overlay via plugin config", () => {
|
||||
const { on } = registerOpenAIPluginWithHook({
|
||||
it("supports opting out of the prompt overlay via plugin config", async () => {
|
||||
const { on } = await registerOpenAIPluginWithHook({
|
||||
pluginConfig: { personalityOverlay: "off" },
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ async function createTempAgentDir(): Promise<string> {
|
|||
|
||||
describeLive("openai plugin live", () => {
|
||||
it("registers an OpenAI provider that can complete a live request", async () => {
|
||||
const { providers } = registerOpenAIPlugin();
|
||||
const { providers } = await registerOpenAIPlugin();
|
||||
const provider = requireRegisteredProvider(providers, "openai");
|
||||
|
||||
const resolved = provider.resolveDynamicModel?.({
|
||||
|
|
@ -182,7 +182,7 @@ describeLive("openai plugin live", () => {
|
|||
}, 30_000);
|
||||
|
||||
it("lists voices and synthesizes audio through the registered speech provider", async () => {
|
||||
const { speechProviders } = registerOpenAIPlugin();
|
||||
const { speechProviders } = await registerOpenAIPlugin();
|
||||
const speechProvider = requireRegisteredProvider(speechProviders, "openai");
|
||||
|
||||
const voices = await speechProvider.listVoices?.({});
|
||||
|
|
@ -217,7 +217,7 @@ describeLive("openai plugin live", () => {
|
|||
}, 45_000);
|
||||
|
||||
it("transcribes synthesized speech through the registered media provider", async () => {
|
||||
const { speechProviders, mediaProviders } = registerOpenAIPlugin();
|
||||
const { speechProviders, mediaProviders } = await registerOpenAIPlugin();
|
||||
const speechProvider = requireRegisteredProvider(speechProviders, "openai");
|
||||
const mediaProvider = requireRegisteredProvider(mediaProviders, "openai");
|
||||
|
||||
|
|
@ -247,7 +247,7 @@ describeLive("openai plugin live", () => {
|
|||
}, 45_000);
|
||||
|
||||
it("generates an image through the registered image provider", async () => {
|
||||
const { imageProviders } = registerOpenAIPlugin();
|
||||
const { imageProviders } = await registerOpenAIPlugin();
|
||||
const imageProvider = requireRegisteredProvider(imageProviders, "openai");
|
||||
|
||||
const cfg = createLiveConfig();
|
||||
|
|
@ -275,7 +275,7 @@ describeLive("openai plugin live", () => {
|
|||
}, 60_000);
|
||||
|
||||
it("edits a reference image through the registered image provider", async () => {
|
||||
const { imageProviders } = registerOpenAIPlugin();
|
||||
const { imageProviders } = await registerOpenAIPlugin();
|
||||
const imageProvider = requireRegisteredProvider(imageProviders, "openai");
|
||||
|
||||
const cfg = createLiveConfig();
|
||||
|
|
@ -311,7 +311,7 @@ describeLive("openai plugin live", () => {
|
|||
}, 60_000);
|
||||
|
||||
it("describes a deterministic image through the registered media provider", async () => {
|
||||
const { mediaProviders } = registerOpenAIPlugin();
|
||||
const { mediaProviders } = await registerOpenAIPlugin();
|
||||
const mediaProvider = requireRegisteredProvider(mediaProviders, "openai");
|
||||
|
||||
const cfg = createLiveConfig();
|
||||
|
|
|
|||
|
|
@ -62,11 +62,13 @@ export function describeOpenAIProviderCatalogContract() {
|
|||
pluginId: "openai",
|
||||
artifactBasename: "index.js",
|
||||
});
|
||||
openaiProviders = registerProviderPlugin({
|
||||
plugin: openaiPlugin.default,
|
||||
id: "openai",
|
||||
name: "OpenAI",
|
||||
}).providers;
|
||||
openaiProviders = (
|
||||
await registerProviderPlugin({
|
||||
plugin: openaiPlugin.default,
|
||||
id: "openai",
|
||||
name: "OpenAI",
|
||||
})
|
||||
).providers;
|
||||
openaiProvider = requireRegisteredProvider(openaiProviders, "openai", "provider");
|
||||
({
|
||||
augmentModelCatalogWithProviderPlugins,
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ import { registerSingleProviderPlugin } from "../../test/helpers/plugins/plugin-
|
|||
import openrouterPlugin from "./index.js";
|
||||
|
||||
describe("openrouter provider hooks", () => {
|
||||
it("owns native reasoning output mode", () => {
|
||||
const provider = registerSingleProviderPlugin(openrouterPlugin);
|
||||
it("owns native reasoning output mode", async () => {
|
||||
const provider = await registerSingleProviderPlugin(openrouterPlugin);
|
||||
|
||||
expect(
|
||||
provider.resolveReasoningOutputMode?.({
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ const ModelRegistryCtor = ModelRegistry as unknown as {
|
|||
new (authStorage: AuthStorage, modelsJsonPath?: string): ModelRegistry;
|
||||
};
|
||||
|
||||
const registerOpenRouterPlugin = () =>
|
||||
const registerOpenRouterPlugin = async () =>
|
||||
registerProviderPlugin({
|
||||
plugin,
|
||||
id: "openrouter",
|
||||
|
|
@ -25,7 +25,7 @@ const registerOpenRouterPlugin = () =>
|
|||
|
||||
describeLive("openrouter plugin live", () => {
|
||||
it("registers an OpenRouter provider that can complete a live request", async () => {
|
||||
const { providers } = registerOpenRouterPlugin();
|
||||
const { providers } = await registerOpenRouterPlugin();
|
||||
const provider = requireRegisteredProvider(providers, "openrouter");
|
||||
|
||||
const resolved = provider.resolveDynamicModel?.({
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ import { registerSingleProviderPlugin } from "../../test/helpers/plugins/plugin-
|
|||
import plugin from "./index.js";
|
||||
|
||||
describe("xai provider plugin", () => {
|
||||
it("owns replay policy for xAI OpenAI-compatible transports", () => {
|
||||
const provider = registerSingleProviderPlugin(plugin);
|
||||
it("owns replay policy for xAI OpenAI-compatible transports", async () => {
|
||||
const provider = await registerSingleProviderPlugin(plugin);
|
||||
|
||||
expect(
|
||||
provider.buildReplayPolicy?.({
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ import { registerSingleProviderPlugin } from "../../test/helpers/plugins/plugin-
|
|||
import plugin from "./index.js";
|
||||
|
||||
describe("zai provider plugin", () => {
|
||||
it("owns replay policy for OpenAI-compatible Z.ai transports", () => {
|
||||
const provider = registerSingleProviderPlugin(plugin);
|
||||
it("owns replay policy for OpenAI-compatible Z.ai transports", async () => {
|
||||
const provider = await registerSingleProviderPlugin(plugin);
|
||||
|
||||
expect(
|
||||
provider.buildReplayPolicy?.({
|
||||
|
|
@ -35,8 +35,8 @@ describe("zai provider plugin", () => {
|
|||
});
|
||||
});
|
||||
|
||||
it("resolves persisted GLM-5 family models with provider-owned metadata", () => {
|
||||
const provider = registerSingleProviderPlugin(plugin);
|
||||
it("resolves persisted GLM-5 family models with provider-owned metadata", async () => {
|
||||
const provider = await registerSingleProviderPlugin(plugin);
|
||||
const template = {
|
||||
id: "glm-4.7",
|
||||
name: "GLM-4.7",
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ describe("createCacheTrace", () => {
|
|||
options,
|
||||
})) as never);
|
||||
|
||||
wrapped?.(
|
||||
void wrapped?.(
|
||||
{
|
||||
id: "gpt-5.4",
|
||||
provider: "openai",
|
||||
|
|
|
|||
|
|
@ -4,14 +4,14 @@ import type { OpenClawPluginApi, ProviderPlugin } from "../plugins/types.js";
|
|||
export { createCapturedPluginRegistration };
|
||||
|
||||
type RegistrablePlugin = {
|
||||
register(api: OpenClawPluginApi): void;
|
||||
register(api: OpenClawPluginApi): void | Promise<void>;
|
||||
};
|
||||
|
||||
export function registerSingleProviderPlugin(params: {
|
||||
register(api: OpenClawPluginApi): void;
|
||||
}): ProviderPlugin {
|
||||
export async function registerSingleProviderPlugin(params: {
|
||||
register(api: OpenClawPluginApi): void | Promise<void>;
|
||||
}): Promise<ProviderPlugin> {
|
||||
const captured = createCapturedPluginRegistration();
|
||||
params.register(captured.api);
|
||||
await params.register(captured.api);
|
||||
const provider = captured.providers[0];
|
||||
if (!provider) {
|
||||
throw new Error("provider registration missing");
|
||||
|
|
@ -19,10 +19,12 @@ export function registerSingleProviderPlugin(params: {
|
|||
return provider;
|
||||
}
|
||||
|
||||
export function registerProviderPlugins(...plugins: RegistrablePlugin[]): ProviderPlugin[] {
|
||||
export async function registerProviderPlugins(
|
||||
...plugins: RegistrablePlugin[]
|
||||
): Promise<ProviderPlugin[]> {
|
||||
const captured = createCapturedPluginRegistration();
|
||||
for (const plugin of plugins) {
|
||||
plugin.register(captured.api);
|
||||
await plugin.register(captured.api);
|
||||
}
|
||||
return captured.providers;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -170,7 +170,7 @@ export function describeOpenAICodexProviderAuthContract() {
|
|||
const { default: openAIPlugin } = await importBundledProviderPlugin<{
|
||||
default: Parameters<typeof registerProviders>[0];
|
||||
}>(providerAuthContractModules.openAIIndexModuleUrl);
|
||||
const provider = requireProvider(registerProviders(openAIPlugin), "openai-codex");
|
||||
const provider = requireProvider(await registerProviders(openAIPlugin), "openai-codex");
|
||||
loginOpenAICodexOAuthMock.mockResolvedValueOnce({
|
||||
refresh: "refresh-token",
|
||||
access: params.access,
|
||||
|
|
@ -191,7 +191,7 @@ export function describeOpenAICodexProviderAuthContract() {
|
|||
const { default: openAIPlugin } = await importBundledProviderPlugin<{
|
||||
default: Parameters<typeof registerProviders>[0];
|
||||
}>(providerAuthContractModules.openAIIndexModuleUrl);
|
||||
return requireProvider(registerProviders(openAIPlugin), "openai-codex");
|
||||
return requireProvider(await registerProviders(openAIPlugin), "openai-codex");
|
||||
}
|
||||
|
||||
it("keeps OAuth auth results provider-owned", async () => {
|
||||
|
|
@ -323,7 +323,7 @@ export function describeGithubCopilotProviderAuthContract() {
|
|||
const { default: githubCopilotPlugin } = await importBundledProviderPlugin<{
|
||||
default: Parameters<typeof registerProviders>[0];
|
||||
}>(providerAuthContractModules.githubCopilotIndexModuleUrl);
|
||||
return requireProvider(registerProviders(githubCopilotPlugin), "github-copilot");
|
||||
return requireProvider(await registerProviders(githubCopilotPlugin), "github-copilot");
|
||||
}
|
||||
|
||||
it("keeps device auth results provider-owned", async () => {
|
||||
|
|
|
|||
|
|
@ -217,24 +217,22 @@ function installDiscoveryHooks(state: DiscoveryState) {
|
|||
default: Parameters<typeof registerProviders>[0];
|
||||
}>(bundledProviderModules.cloudflareAiGatewayIndexModuleUrl),
|
||||
]);
|
||||
state.githubCopilotProvider = requireProvider(
|
||||
registerProviders(githubCopilotPlugin),
|
||||
"github-copilot",
|
||||
);
|
||||
state.ollamaProvider = requireProvider(registerProviders(ollamaPlugin), "ollama");
|
||||
state.vllmProvider = requireProvider(registerProviders(vllmPlugin), "vllm");
|
||||
state.sglangProvider = requireProvider(registerProviders(sglangPlugin), "sglang");
|
||||
state.minimaxProvider = requireProvider(registerProviders(minimaxPlugin), "minimax");
|
||||
state.minimaxPortalProvider = requireProvider(
|
||||
registerProviders(minimaxPlugin),
|
||||
"minimax-portal",
|
||||
);
|
||||
state.modelStudioProvider = requireProvider(
|
||||
registerProviders(modelStudioPlugin),
|
||||
"modelstudio",
|
||||
);
|
||||
const githubCopilotProviders = await registerProviders(githubCopilotPlugin);
|
||||
const ollamaProviders = await registerProviders(ollamaPlugin);
|
||||
const vllmProviders = await registerProviders(vllmPlugin);
|
||||
const sglangProviders = await registerProviders(sglangPlugin);
|
||||
const minimaxProviders = await registerProviders(minimaxPlugin);
|
||||
const modelStudioProviders = await registerProviders(modelStudioPlugin);
|
||||
const cloudflareAiGatewayProviders = await registerProviders(cloudflareAiGatewayPlugin);
|
||||
state.githubCopilotProvider = requireProvider(githubCopilotProviders, "github-copilot");
|
||||
state.ollamaProvider = requireProvider(ollamaProviders, "ollama");
|
||||
state.vllmProvider = requireProvider(vllmProviders, "vllm");
|
||||
state.sglangProvider = requireProvider(sglangProviders, "sglang");
|
||||
state.minimaxProvider = requireProvider(minimaxProviders, "minimax");
|
||||
state.minimaxPortalProvider = requireProvider(minimaxProviders, "minimax-portal");
|
||||
state.modelStudioProvider = requireProvider(modelStudioProviders, "modelstudio");
|
||||
state.cloudflareAiGatewayProvider = requireProvider(
|
||||
registerProviders(cloudflareAiGatewayPlugin),
|
||||
cloudflareAiGatewayProviders,
|
||||
"cloudflare-ai-gateway",
|
||||
);
|
||||
setRuntimeAuthStore();
|
||||
|
|
|
|||
|
|
@ -14,20 +14,20 @@ type RegisteredProviderCollections = {
|
|||
};
|
||||
|
||||
type ProviderPluginModule = {
|
||||
register(api: ReturnType<typeof createTestPluginApi>): void;
|
||||
register(api: ReturnType<typeof createTestPluginApi>): void | Promise<void>;
|
||||
};
|
||||
|
||||
export function registerProviderPlugin(params: {
|
||||
export async function registerProviderPlugin(params: {
|
||||
plugin: ProviderPluginModule;
|
||||
id: string;
|
||||
name: string;
|
||||
}): RegisteredProviderCollections {
|
||||
}): Promise<RegisteredProviderCollections> {
|
||||
const providers: ProviderPlugin[] = [];
|
||||
const speechProviders: SpeechProviderPlugin[] = [];
|
||||
const mediaProviders: MediaUnderstandingProviderPlugin[] = [];
|
||||
const imageProviders: ImageGenerationProviderPlugin[] = [];
|
||||
|
||||
params.plugin.register(
|
||||
await params.plugin.register(
|
||||
createTestPluginApi({
|
||||
id: params.id,
|
||||
name: params.name,
|
||||
|
|
|
|||
|
|
@ -173,11 +173,13 @@ function installRuntimeHooks() {
|
|||
const plugin = await fixture.load();
|
||||
return {
|
||||
fixture,
|
||||
providers: registerProviderPlugin({
|
||||
plugin: plugin.default,
|
||||
id: fixture.pluginId,
|
||||
name: fixture.name,
|
||||
}).providers,
|
||||
providers: (
|
||||
await registerProviderPlugin({
|
||||
plugin: plugin.default,
|
||||
id: fixture.pluginId,
|
||||
name: fixture.name,
|
||||
})
|
||||
).providers,
|
||||
};
|
||||
}),
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in New Issue