mirror of https://github.com/openclaw/openclaw.git
fix: restore main gate after type updates
This commit is contained in:
parent
96d61aa50c
commit
9aafff7378
|
|
@ -1264,8 +1264,9 @@ export function createTopLevelChannelParsedAllowFromPrompt(params: {
|
|||
parseEntries: params.parseEntries,
|
||||
getExistingAllowFrom: ({ cfg }) =>
|
||||
params.getExistingAllowFrom?.(cfg) ??
|
||||
(((cfg.channels?.[params.channel] as { allowFrom?: Array<string | number> } | undefined)
|
||||
?.allowFrom ?? []) as Array<string | number>),
|
||||
(cfg.channels?.[params.channel] as { allowFrom?: Array<string | number> } | undefined)
|
||||
?.allowFrom ??
|
||||
[],
|
||||
...(params.mergeEntries ? { mergeEntries: params.mergeEntries } : {}),
|
||||
applyAllowFrom: ({ cfg, allowFrom }) => setAllowFrom(cfg, allowFrom),
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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")],
|
||||
},
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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" }],
|
||||
}),
|
||||
|
|
|
|||
Loading…
Reference in New Issue