mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-25 11:55:47 -06:00
06f5f73e47
* refactor(agents): prepare model runtime catalogs Build lifecycle-owned model and auth snapshots, carry prepared stores into hot agent paths, and serialize config/auth publication. Credits @zeroaltitude's #90741 investigation and benchmark approach. * refactor: finish lifecycle-owned model discovery * fix: align prepared model catalog contracts * test: align lifecycle catalog mocks * test: fix prepared catalog type fixtures * refactor: split prepared model runtime ownership * fix: import prepared runtime replacement gate type * test: split media runtime coverage * test: preserve image auth fixture key types * test: isolate lifecycle gate fixtures * chore: keep release changelog owned * refactor: finish prepared model catalog migration * test: keep catalog review fixtures scanner-safe * refactor: preserve lifecycle model runtime ownership * fix: close prepared runtime lifecycle races * fix: preserve compaction workspace fallback * chore: document btw generation rebinding * fix: preserve prepared generation boundaries * fix: keep model-list discovery flag explicit * fix: serialize standalone model runtime activation * refactor: migrate subagent model catalog lookup * refactor: clarify doctor catalog lookup seam * chore: refresh plugin sdk api baseline * test: migrate swarm catalog dependency * refactor(telegram): rename runtime catalog seam * refactor: extract model-aware tool context * test(models): isolate lifecycle catalog fixtures * refactor(agents): avoid btw parameter rebinding * fix(net-policy): align root ipaddr dependency * fix(build): keep net policy dependency bundled * fix(deadcode): document net policy compile dependency
57 lines
1.6 KiB
TypeScript
57 lines
1.6 KiB
TypeScript
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
|
|
const mocks = vi.hoisted(() => ({
|
|
getSnapshot: vi.fn(),
|
|
loadCatalog: vi.fn(),
|
|
}));
|
|
|
|
vi.mock("../agents/prepared-model-catalog.js", () => ({
|
|
getPreparedModelCatalogSnapshot: (...args: unknown[]) => mocks.getSnapshot(...args),
|
|
loadPreparedModelCatalog: (...args: unknown[]) => mocks.loadCatalog(...args),
|
|
}));
|
|
|
|
import { loadModelCatalog } from "./agent-runtime.js";
|
|
|
|
describe("agent-runtime model catalog compatibility", () => {
|
|
beforeEach(() => {
|
|
mocks.getSnapshot.mockReset();
|
|
mocks.loadCatalog.mockReset();
|
|
});
|
|
|
|
it("keeps legacy cache-only reads nonblocking", async () => {
|
|
mocks.getSnapshot.mockReturnValue({
|
|
entries: [{ provider: "test", id: "cached", name: "Cached" }],
|
|
routeVariants: [],
|
|
});
|
|
|
|
await expect(loadModelCatalog({ cacheOnly: true, useCache: true })).resolves.toEqual([
|
|
{ provider: "test", id: "cached", name: "Cached" },
|
|
]);
|
|
expect(mocks.loadCatalog).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it("accepts legacy options without overriding lifecycle metadata", async () => {
|
|
mocks.loadCatalog.mockResolvedValue([]);
|
|
const config = {};
|
|
const env = { OPENCLAW_STATE_DIR: "/tmp/plugin-state" };
|
|
|
|
await loadModelCatalog({
|
|
agentDir: "/tmp/plugin-agent",
|
|
config,
|
|
env,
|
|
metadataSnapshot: {} as never,
|
|
readOnly: true,
|
|
useCache: false,
|
|
workspaceDir: "/tmp/plugin-workspace",
|
|
});
|
|
|
|
expect(mocks.loadCatalog).toHaveBeenCalledWith({
|
|
agentDir: "/tmp/plugin-agent",
|
|
config,
|
|
env,
|
|
readOnly: true,
|
|
workspaceDir: "/tmp/plugin-workspace",
|
|
});
|
|
});
|
|
});
|