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, disableTools: true,
timeoutMs: 5_000, timeoutMs: 5_000,
authStorage: {} as never, authStorage: {} as never,
authProfileStore: { version: 1, profiles: {} },
modelRegistry: {} as never, modelRegistry: {} as never,
} as EmbeddedRunAttemptParams; } as EmbeddedRunAttemptParams;
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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