mirror of
https://github.com/moltbot/moltbot.git
synced 2026-04-20 21:23:23 +00:00
Tests: fix provider artifact typing
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import type { ModelProviderConfig } from "openclaw/plugin-sdk/provider-entry";
|
||||
import type { ModelProviderConfig } from "openclaw/plugin-sdk/provider-model-shared";
|
||||
|
||||
export function normalizeConfig(params: { provider: string; providerConfig: ModelProviderConfig }) {
|
||||
return params.providerConfig;
|
||||
|
||||
@@ -1,6 +1,24 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import type { ModelDefinitionConfig } from "../config/types.models.js";
|
||||
import { resolveBundledProviderPolicySurface } from "./provider-public-artifacts.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 public artifacts", () => {
|
||||
it("loads bundled provider policy surfaces for anthropic", () => {
|
||||
const surface = resolveBundledProviderPolicySurface("anthropic");
|
||||
@@ -17,7 +35,7 @@ describe("provider public artifacts", () => {
|
||||
provider: "anthropic",
|
||||
providerConfig: {
|
||||
baseUrl: "https://api.anthropic.com",
|
||||
models: [{ id: "claude-sonnet-4-6", name: "Claude Sonnet 4.6" }],
|
||||
models: [createModel("claude-sonnet-4-6", "Claude Sonnet 4.6")],
|
||||
},
|
||||
});
|
||||
expect(normalized).toMatchObject({
|
||||
@@ -26,6 +44,7 @@ describe("provider public artifacts", () => {
|
||||
});
|
||||
|
||||
const nextConfig = surface?.applyConfigDefaults?.({
|
||||
provider: "anthropic",
|
||||
config: {
|
||||
auth: {
|
||||
profiles: {
|
||||
@@ -54,8 +73,8 @@ describe("provider public artifacts", () => {
|
||||
|
||||
const providerConfig = {
|
||||
baseUrl: "https://api.openai.com/v1",
|
||||
api: "openai-completions",
|
||||
models: [{ id: "gpt-5", name: "gpt-5" }],
|
||||
api: "openai-completions" as const,
|
||||
models: [createModel("gpt-5", "gpt-5")],
|
||||
};
|
||||
expect(
|
||||
surface?.normalizeConfig?.({
|
||||
|
||||
@@ -93,6 +93,8 @@ function configureTaskRegistryMaintenanceRuntimeForTest(params: {
|
||||
loadSessionStore: () => ({}),
|
||||
resolveStorePath: () => "",
|
||||
parseAgentSessionKey: () => null as ParsedAgentSessionKey | null,
|
||||
isCronJobActive: () => false,
|
||||
getAgentRunContext: () => undefined,
|
||||
deleteTaskRecordById: (taskId: string) => params.currentTasks.delete(taskId),
|
||||
ensureTaskRegistryReady: () => {},
|
||||
getTaskById: (taskId: string) => params.currentTasks.get(taskId),
|
||||
|
||||
Reference in New Issue
Block a user