From 9aafff73780d4a12c219841c602f57ff8fa772e2 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sun, 22 Mar 2026 19:07:20 -0700 Subject: [PATCH] fix: restore main gate after type updates --- src/channels/plugins/setup-wizard-helpers.ts | 5 +-- src/plugin-sdk/provider-entry.test.ts | 27 +++++++++++++--- .../provider-onboarding-config.test.ts | 32 +++++++++++++------ 3 files changed, 48 insertions(+), 16 deletions(-) diff --git a/src/channels/plugins/setup-wizard-helpers.ts b/src/channels/plugins/setup-wizard-helpers.ts index 0c5f5b6960e..19cc7b5b9bb 100644 --- a/src/channels/plugins/setup-wizard-helpers.ts +++ b/src/channels/plugins/setup-wizard-helpers.ts @@ -1264,8 +1264,9 @@ export function createTopLevelChannelParsedAllowFromPrompt(params: { parseEntries: params.parseEntries, getExistingAllowFrom: ({ cfg }) => params.getExistingAllowFrom?.(cfg) ?? - (((cfg.channels?.[params.channel] as { allowFrom?: Array } | undefined) - ?.allowFrom ?? []) as Array), + (cfg.channels?.[params.channel] as { allowFrom?: Array } | undefined) + ?.allowFrom ?? + [], ...(params.mergeEntries ? { mergeEntries: params.mergeEntries } : {}), applyAllowFrom: ({ cfg, allowFrom }) => setAllowFrom(cfg, allowFrom), }); diff --git a/src/plugin-sdk/provider-entry.test.ts b/src/plugin-sdk/provider-entry.test.ts index d09a62ab876..1d2050b205a 100644 --- a/src/plugin-sdk/provider-entry.test.ts +++ b/src/plugin-sdk/provider-entry.test.ts @@ -1,8 +1,26 @@ import { describe, expect, it } from "vitest"; +import type { ModelDefinitionConfig } from "../config/types.models.js"; import { capturePluginRegistration } from "../plugins/captured-registration.js"; import type { ProviderCatalogContext } from "../plugins/types.js"; import { defineSingleProviderPluginEntry } from "./provider-entry.js"; +function createModel(id: string, name: string): ModelDefinitionConfig { + return { + id, + name, + reasoning: false, + input: ["text"], + cost: { + input: 0, + output: 0, + cacheRead: 0, + cacheWrite: 0, + }, + contextWindow: 128_000, + maxTokens: 8_192, + }; +} + function createCatalogContext( config: ProviderCatalogContext["config"] = {}, ): ProviderCatalogContext { @@ -43,7 +61,7 @@ describe("defineSingleProviderPluginEntry", () => { buildProvider: () => ({ api: "openai-completions", baseUrl: "https://api.demo.test/v1", - models: [{ id: "default", name: "Default" }], + models: [createModel("default", "Default")], }), }, }, @@ -79,7 +97,7 @@ describe("defineSingleProviderPluginEntry", () => { api: "openai-completions", apiKey: "test-key", baseUrl: "https://api.demo.test/v1", - models: [{ id: "default", name: "Default" }], + models: [createModel("default", "Default")], }, }); }); @@ -114,7 +132,7 @@ describe("defineSingleProviderPluginEntry", () => { buildProvider: () => ({ api: "openai-completions", baseUrl: "https://gateway.test/v1", - models: [{ id: "router", name: "Router" }], + models: [createModel("router", "Router")], }), allowExplicitBaseUrl: true, }, @@ -169,6 +187,7 @@ describe("defineSingleProviderPluginEntry", () => { providers: { gateway: { baseUrl: "https://override.test/v1", + models: [createModel("router", "Router")], }, }, }, @@ -179,7 +198,7 @@ describe("defineSingleProviderPluginEntry", () => { api: "openai-completions", apiKey: "test-key", baseUrl: "https://override.test/v1", - models: [{ id: "router", name: "Router" }], + models: [createModel("router", "Router")], }, }); }); diff --git a/src/plugins/provider-onboarding-config.test.ts b/src/plugins/provider-onboarding-config.test.ts index c95ef384f7b..9191f93a5bc 100644 --- a/src/plugins/provider-onboarding-config.test.ts +++ b/src/plugins/provider-onboarding-config.test.ts @@ -1,10 +1,28 @@ import { describe, expect, it } from "vitest"; +import type { ModelDefinitionConfig } from "../config/types.models.js"; import { createDefaultModelPresetAppliers, createDefaultModelsPresetAppliers, createModelCatalogPresetAppliers, } from "./provider-onboarding-config.js"; +function createModel(id: string, name: string): ModelDefinitionConfig { + return { + id, + name, + reasoning: false, + input: ["text"], + cost: { + input: 0, + output: 0, + cacheRead: 0, + cacheWrite: 0, + }, + contextWindow: 128_000, + maxTokens: 8_192, + }; +} + describe("provider onboarding preset appliers", () => { it("creates provider and primary-model appliers for a default model preset", () => { const appliers = createDefaultModelPresetAppliers({ @@ -13,10 +31,7 @@ describe("provider onboarding preset appliers", () => { providerId: "demo", api: "openai-completions" as const, baseUrl: "https://demo.test/v1", - defaultModel: { - id: "demo-default", - name: "Demo Default", - }, + defaultModel: createModel("demo-default", "Demo Default"), defaultModelId: "demo-default", aliases: [{ modelRef: "demo/demo-default", alias: "Demo" }], }), @@ -43,10 +58,7 @@ describe("provider onboarding preset appliers", () => { providerId: "demo", api: "openai-completions" as const, baseUrl, - defaultModels: [ - { id: "a", name: "Model A" }, - { id: "b", name: "Model B" }, - ], + defaultModels: [createModel("a", "Model A"), createModel("b", "Model B")], aliases: [{ modelRef: "demo/a", alias: "Demo A" }], }), }); @@ -72,8 +84,8 @@ describe("provider onboarding preset appliers", () => { api: "openai-completions" as const, baseUrl: "https://catalog.test/v1", catalogModels: [ - { id: "default", name: "Catalog Default" }, - { id: "backup", name: "Catalog Backup" }, + createModel("default", "Catalog Default"), + createModel("backup", "Catalog Backup"), ], aliases: ["catalog/default", { modelRef: "catalog/default", alias: "Catalog Default" }], }),