mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 17:20:45 +00:00
test: align manifest hot path fixtures
This commit is contained in:
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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", () => ({
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
@@ -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",
|
||||||
|
|||||||
@@ -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,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
({
|
({
|
||||||
|
|||||||
@@ -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: [],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
@@ -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[] }) =>
|
||||||
({
|
({
|
||||||
|
|||||||
Reference in New Issue
Block a user