|
2 | 2 | import { beforeEach, describe, expect, it, vi } from "vitest"; |
3 | 3 | import type { ModelProviderConfig, OpenClawConfig } from "../../config/config.js"; |
4 | 4 | import { discoverModels } from "../agent-model-discovery.js"; |
| 5 | +import type { PreparedModelRuntimeSnapshot } from "../prepared-model-runtime.js"; |
5 | 6 | import { createProviderRuntimeTestMock } from "./model.provider-runtime.test-support.js"; |
6 | 7 |
|
7 | 8 | vi.mock("../../plugins/provider-runtime.js", () => ({ |
@@ -82,23 +83,42 @@ vi.mock("../model-suppression.js", () => ({ |
82 | 83 |
|
83 | 84 | vi.mock("../prepared-model-runtime.js", async () => { |
84 | 85 | const discovery = await import("../agent-model-discovery.js"); |
| 86 | + const { createPluginMetadataSnapshot } = |
| 87 | + await import("../../config/plugin-auto-enable.test-helpers.js"); |
85 | 88 | const createSnapshot = (input: { |
86 | 89 | agentDir: string; |
87 | 90 | config?: OpenClawConfig; |
88 | 91 | workspaceDir?: string; |
89 | | - }) => ({ |
90 | | - createStores: () => { |
91 | | - const authStorage = discovery.discoverAuthStorage(input.agentDir); |
92 | | - const modelRegistry = discovery.discoverModels(authStorage, input.agentDir, { |
93 | | - ...(input.config ? { config: input.config } : {}), |
| 92 | + }) => { |
| 93 | + const config = input.config ?? {}; |
| 94 | + return { |
| 95 | + agentDir: input.agentDir, |
| 96 | + ...(input.workspaceDir ? { workspaceDir: input.workspaceDir } : {}), |
| 97 | + activeProjectKeys: [], |
| 98 | + allowGatewaySubagentBinding: false, |
| 99 | + config, |
| 100 | + authModes: {}, |
| 101 | + metadataSnapshot: createPluginMetadataSnapshot({ |
| 102 | + config, |
| 103 | + manifestRegistry: { plugins: [], diagnostics: [] }, |
94 | 104 | ...(input.workspaceDir ? { workspaceDir: input.workspaceDir } : {}), |
95 | | - }); |
96 | | - if (!("fork" in modelRegistry)) { |
97 | | - Object.assign(modelRegistry, { fork: () => modelRegistry }); |
98 | | - } |
99 | | - return { authStorage, modelRegistry }; |
100 | | - }, |
101 | | - }); |
| 105 | + }), |
| 106 | + modelCatalog: { entries: [], routeVariants: [] }, |
| 107 | + configuredRuntimeModels: [], |
| 108 | + inlineProviderModels: [], |
| 109 | + createStores: () => { |
| 110 | + const authStorage = discovery.discoverAuthStorage(input.agentDir); |
| 111 | + const modelRegistry = discovery.discoverModels(authStorage, input.agentDir, { |
| 112 | + ...(input.config ? { config: input.config } : {}), |
| 113 | + ...(input.workspaceDir ? { workspaceDir: input.workspaceDir } : {}), |
| 114 | + }); |
| 115 | + if (!("fork" in modelRegistry)) { |
| 116 | + Object.assign(modelRegistry, { fork: () => modelRegistry }); |
| 117 | + } |
| 118 | + return { authStorage, modelRegistry }; |
| 119 | + }, |
| 120 | + } satisfies PreparedModelRuntimeSnapshot; |
| 121 | + }; |
102 | 122 | return { |
103 | 123 | getPreparedModelRuntimeSnapshot: createSnapshot, |
104 | 124 | loadPreparedModelRuntimeSnapshot: async (input: Parameters<typeof createSnapshot>[0]) => |
|
0 commit comments