Skip to content

Commit c53aad8

Browse files
committed
test(agents): complete prepared runtime fixture
1 parent 662205f commit c53aad8

1 file changed

Lines changed: 32 additions & 12 deletions

File tree

‎src/agents/embedded-agent-runner/model.forward-compat.errors-and-overrides.test.ts‎

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import { beforeEach, describe, expect, it, vi } from "vitest";
33
import type { ModelProviderConfig, OpenClawConfig } from "../../config/config.js";
44
import { discoverModels } from "../agent-model-discovery.js";
5+
import type { PreparedModelRuntimeSnapshot } from "../prepared-model-runtime.js";
56
import { createProviderRuntimeTestMock } from "./model.provider-runtime.test-support.js";
67

78
vi.mock("../../plugins/provider-runtime.js", () => ({
@@ -82,23 +83,42 @@ vi.mock("../model-suppression.js", () => ({
8283

8384
vi.mock("../prepared-model-runtime.js", async () => {
8485
const discovery = await import("../agent-model-discovery.js");
86+
const { createPluginMetadataSnapshot } =
87+
await import("../../config/plugin-auto-enable.test-helpers.js");
8588
const createSnapshot = (input: {
8689
agentDir: string;
8790
config?: OpenClawConfig;
8891
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: [] },
94104
...(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+
};
102122
return {
103123
getPreparedModelRuntimeSnapshot: createSnapshot,
104124
loadPreparedModelRuntimeSnapshot: async (input: Parameters<typeof createSnapshot>[0]) =>

0 commit comments

Comments
 (0)