test: align manifest hot path fixtures

This commit is contained in:
Shakker
2026-05-01 23:20:52 +01:00
parent 6b6f140c42
commit d94889909c
11 changed files with 67 additions and 32 deletions

View File

@@ -26,6 +26,7 @@ function createParams(sessionFile: string, workspaceDir: string): EmbeddedRunAtt
disableTools: true,
timeoutMs: 5_000,
authStorage: {} as never,
authProfileStore: { version: 1, profiles: {} },
modelRegistry: {} as never,
} as EmbeddedRunAttemptParams;
}

View File

@@ -30,6 +30,7 @@ function createParams(sessionFile: string, workspaceDir: string): EmbeddedRunAtt
disableTools: true,
timeoutMs: 5_000,
authStorage: {} as never,
authProfileStore: { version: 1, profiles: {} },
modelRegistry: {} as never,
} as EmbeddedRunAttemptParams;
}

View File

@@ -50,6 +50,7 @@ function createParams(sessionFile: string, workspaceDir: string): EmbeddedRunAtt
disableTools: true,
timeoutMs: 5_000,
authStorage: {} as never,
authProfileStore: { version: 1, profiles: {} },
modelRegistry: {} as never,
} as EmbeddedRunAttemptParams;
}

View File

@@ -28,6 +28,7 @@ function createParams(sessionFile: string, workspaceDir: string): EmbeddedRunAtt
disableTools: true,
timeoutMs: 5_000,
authStorage: {} as never,
authProfileStore: { version: 1, profiles: {} },
modelRegistry: {} as never,
} as EmbeddedRunAttemptParams;
}

View File

@@ -291,7 +291,7 @@ vi.mock("./lanes.js", () => ({
}));
vi.mock("./model-catalog.js", () => ({
loadManifestModelCatalog: (...args: unknown[]) => state.loadManifestModelCatalogMock(...args),
loadManifestModelCatalog: state.loadManifestModelCatalogMock,
}));
vi.mock("./model-selection.js", () => ({

View File

@@ -54,6 +54,7 @@ function createAttemptParams(config?: OpenClawConfig): EmbeddedRunAttemptParams
modelId: "gpt-5.4",
model: { id: "gpt-5.4", provider: "codex" } as Model<Api>,
authStorage: {} as never,
authProfileStore: { version: 1, profiles: {} },
modelRegistry: {} as never,
thinkLevel: "low",
config,

View File

@@ -24,6 +24,7 @@ function createAttemptParams(): AgentHarnessAttemptParams {
modelId: "gpt-5.4",
model: { id: "gpt-5.4", provider: "codex" } as Model<Api>,
authStorage: {} as never,
authProfileStore: { version: 1, profiles: {} },
modelRegistry: {} as never,
thinkLevel: "low",
messageChannel: "qa",

View File

@@ -83,11 +83,10 @@ describe("loadModelCatalog", () => {
currentPluginMetadataSnapshotMock = vi.fn();
loadPluginMetadataSnapshotMock = vi.fn();
vi.doMock("../plugins/current-plugin-metadata-snapshot.js", () => ({
getCurrentPluginMetadataSnapshot: (...args: unknown[]) =>
currentPluginMetadataSnapshotMock(...args),
getCurrentPluginMetadataSnapshot: currentPluginMetadataSnapshotMock,
}));
vi.doMock("../plugins/plugin-metadata-snapshot.js", () => ({
loadPluginMetadataSnapshot: (...args: unknown[]) => loadPluginMetadataSnapshotMock(...args),
loadPluginMetadataSnapshot: loadPluginMetadataSnapshotMock,
}));
({

View File

@@ -7,6 +7,7 @@ import {
setCurrentPluginMetadataSnapshot,
} from "../plugins/current-plugin-metadata-snapshot.js";
import { resolveInstalledPluginIndexPolicyHash } from "../plugins/installed-plugin-index-policy.js";
import type { InstalledPluginIndexRecord } from "../plugins/installed-plugin-index.js";
import type { PluginManifestRecord } from "../plugins/manifest-registry.js";
import type { PluginMetadataSnapshot } from "../plugins/plugin-metadata-snapshot.types.js";
import type { AuthProfileStore } from "./auth-profiles/types.js";
@@ -56,6 +57,39 @@ function createPlugin(params: {
};
}
function createInstalledPluginRecord(
plugin: PluginManifestRecord,
enabledPluginIds: string[],
): InstalledPluginIndexRecord {
const enabled = plugin.origin === "bundled" || enabledPluginIds.includes(plugin.id);
return {
pluginId: plugin.id,
manifestPath: plugin.manifestPath,
manifestHash: `test-${plugin.id}`,
source: plugin.source,
rootDir: plugin.rootDir,
origin: plugin.origin,
enabled,
startup: {
sidecar: false,
memory: false,
deferConfiguredChannelFullLoadUntilAfterListen: false,
agentHarnesses: [],
},
compat: [],
};
}
function legacyModelProviderConfig(provider: Record<string, unknown>): OpenClawConfig {
return {
models: {
providers: {
comfy: provider as never,
},
},
};
}
function installSnapshot(
config: OpenClawConfig,
plugins: PluginManifestRecord[],
@@ -68,11 +102,15 @@ function installSnapshot(
policyHash: resolveInstalledPluginIndexPolicyHash(config),
...(workspaceDir ? { workspaceDir } : {}),
index: {
plugins: plugins.map((plugin) => ({
pluginId: plugin.id,
origin: plugin.origin,
enabled: plugin.origin === "bundled" || enabledPluginIds.includes(plugin.id),
})),
version: 1,
hostContractVersion: "test",
compatRegistryVersion: "test",
migrationVersion: 1,
policyHash: "test",
generatedAtMs: 0,
installRecords: {},
plugins: plugins.map((plugin) => createInstalledPluginRecord(plugin, enabledPluginIds)),
diagnostics: [],
},
registryDiagnostics: [],
manifestRegistry: { plugins, diagnostics: [] },
@@ -530,16 +568,10 @@ describe("optional media tool factory planning", () => {
it.each([
{
name: "legacy local provider config",
config: {
models: {
providers: {
comfy: {
workflow: { "1": { inputs: {} } },
promptNodeId: "1",
},
},
},
} satisfies OpenClawConfig,
config: legacyModelProviderConfig({
workflow: { "1": { inputs: {} } },
promptNodeId: "1",
}),
},
{
name: "plugin cloud API key config",
@@ -560,18 +592,12 @@ describe("optional media tool factory planning", () => {
},
{
name: "legacy cloud API key config",
config: {
models: {
providers: {
comfy: {
mode: "cloud",
apiKey: "cloud-key",
workflow: { "1": { inputs: {} } },
promptNodeId: "1",
},
},
},
} satisfies OpenClawConfig,
config: legacyModelProviderConfig({
mode: "cloud",
apiKey: "cloud-key",
workflow: { "1": { inputs: {} } },
promptNodeId: "1",
}),
},
])(
"registers generation tools from Comfy $name without a current metadata snapshot",
@@ -596,6 +622,7 @@ describe("optional media tool factory planning", () => {
providers: {
openai: {
baseUrl: "http://localhost:11434/v1",
models: [],
},
},
},

View File

@@ -1027,6 +1027,7 @@ export async function createContextEngineAttemptRunner(params: {
modelId: "gpt-test",
model: testModel,
authStorage: testAuthStorage as never,
authProfileStore: { version: 1, profiles: {} },
modelRegistry: {} as never,
thinkLevel: "off",
senderIsOwner: true,

View File

@@ -32,7 +32,9 @@ const mocks = vi.hoisted(() => ({
() => createEmptyMockManifestRegistry(),
),
loadBundledCapabilityRuntimeRegistry: vi.fn(),
loadPluginRegistrySnapshot: vi.fn(() => ({ plugins: [] })),
loadPluginRegistrySnapshot: vi.fn<() => { plugins: Array<Record<string, unknown>> }>(() => ({
plugins: [],
})),
withBundledPluginAllowlistCompat: vi.fn(
({ config, pluginIds }: { config?: OpenClawConfig; pluginIds: string[] }) =>
({