From bb912daaed9579da4be5650a635a66b048dd3b64 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Wed, 1 Apr 2026 03:58:03 +0900 Subject: [PATCH] test(openai): fix ModelRegistry constructor typing --- extensions/openai/index.test.ts | 5 ++++- extensions/openrouter/index.test.ts | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/extensions/openai/index.test.ts b/extensions/openai/index.test.ts index da5df9c6b38..dc7847eaaca 100644 --- a/extensions/openai/index.test.ts +++ b/extensions/openai/index.test.ts @@ -43,6 +43,9 @@ const LIVE_VISION_MODEL = process.env.OPENCLAW_LIVE_OPENAI_VISION_MODEL?.trim() const liveEnabled = OPENAI_API_KEY.trim().length > 0 && process.env.OPENCLAW_LIVE_TEST === "1"; const describeLive = liveEnabled ? describe : describe.skip; const EMPTY_AUTH_STORE = { version: 1, profiles: {} } as const; +const ModelRegistryCtor = ModelRegistry as unknown as { + new (authStorage: AuthStorage, modelsJsonPath?: string): ModelRegistry; +}; function resolveTemplateModelId(modelId: string) { switch (modelId) { @@ -58,7 +61,7 @@ function resolveTemplateModelId(modelId: string) { } function createTemplateModelRegistry(modelId: string): ModelRegistry { - const registry = ModelRegistry.inMemory(AuthStorage.inMemory()); + const registry = new ModelRegistryCtor(AuthStorage.inMemory()); const template = getModel("openai", resolveTemplateModelId(modelId)); registry.registerProvider("openai", { apiKey: "test", diff --git a/extensions/openrouter/index.test.ts b/extensions/openrouter/index.test.ts index 6a3c24a1ea3..227e469049e 100644 --- a/extensions/openrouter/index.test.ts +++ b/extensions/openrouter/index.test.ts @@ -12,6 +12,9 @@ const LIVE_MODEL_ID = process.env.OPENCLAW_LIVE_OPENROUTER_PLUGIN_MODEL?.trim() || "openai/gpt-5.4-nano"; const liveEnabled = OPENROUTER_API_KEY.trim().length > 0 && process.env.OPENCLAW_LIVE_TEST === "1"; const describeLive = liveEnabled ? describe : describe.skip; +const ModelRegistryCtor = ModelRegistry as unknown as { + new (authStorage: AuthStorage, modelsJsonPath?: string): ModelRegistry; +}; const registerOpenRouterPlugin = () => registerProviderPlugin({ @@ -41,7 +44,7 @@ describeLive("openrouter plugin live", () => { const resolved = provider.resolveDynamicModel?.({ provider: "openrouter", modelId: LIVE_MODEL_ID, - modelRegistry: ModelRegistry.inMemory(AuthStorage.inMemory()), + modelRegistry: new ModelRegistryCtor(AuthStorage.inMemory()), }); if (!resolved) { throw new Error(`openrouter provider did not resolve ${LIVE_MODEL_ID}`);