@@ -10,6 +10,7 @@ import {
1010 loadGatewayModelCatalogSnapshot,
1111 loadPreparedGatewayModelCatalogSnapshot,
1212} from "../gateway/server-model-catalog.js";
13+ import { loadPluginMetadataSnapshot } from "../plugins/plugin-metadata-snapshot.js";
1314import { closeOpenClawAgentDatabasesForTest } from "../state/openclaw-agent-db.js";
1415import { OPENAI_CODEX_DEFAULT_PROFILE_ID } from "./auth-profiles/constants.js";
1516import { getRuntimeExternalCliProfileIds } from "./auth-profiles/runtime-external-profile-references.js";
@@ -201,7 +202,10 @@ module.exports = {
201202async function createStaticSnapshot(
202203 spinMs: number,
203204 envOverride: NodeJS.ProcessEnv = {},
204- options?: { hydrateExternalCliProviderIds?: readonly string[] },
205+ options?: {
206+ hydrateExternalCliProviderIds?: readonly string[];
207+ metadataWorkspace?: "gateway" | "none" | "activation";
208+ },
205209) {
206210 const root = tempDirs.make("openclaw-model-catalog-worker-");
207211 const stateDir = path.join(root, "state");
@@ -293,6 +297,20 @@ async function createStaticSnapshot(
293297 30_000,
294298 "static",
295299 () => current,
300+ false,
301+ undefined,
302+ options?.metadataWorkspace
303+ ? loadPluginMetadataSnapshot({
304+ config:
305+ options.metadataWorkspace === "activation"
306+ ? { ...config, plugins: { ...config.plugins, entries: {} } }
307+ : config,
308+ env,
309+ ...(options.metadataWorkspace === "gateway"
310+ ? { workspaceDir: path.join(root, "gateway-workspace") }
311+ : {}),
312+ })
313+ : undefined,
296314 ).pending;
297315 return {
298316 agentDir,
@@ -314,6 +332,32 @@ async function waitForMarker(marker: string): Promise<void> {
314332}
315333
316334describe("prepared model catalog worker boundary", () => {
335+ it.each([
336+ ["gateway", "catalog"],
337+ ["gateway", "auth-refresh"],
338+ ["none", "catalog"],
339+ ["none", "auth-refresh"],
340+ ["activation", "catalog"],
341+ ["activation", "auth-refresh"],
342+ ] as const)(
343+ "keeps %s metadata discovery scope with %s first",
344+ async (metadataWorkspace, first) => {
345+ const fixture = await createStaticSnapshot(0, {}, { metadataWorkspace });
346+ if (first === "auth-refresh") {
347+ const auth = await loadPreparedModelRuntimeAuth(fixture.snapshot, {
348+ providerIds: [PROVIDER_ID],
349+ });
350+ expect(auth?.authStore.profiles[EXTERNAL_AUTH_PROFILE_ID]).toMatchObject({
351+ access: "v1:A",
352+ });
353+ }
354+ const catalog = await fixture.snapshot.loadFullModelCatalog?.();
355+ expect(catalog?.entries).toContainEqual(
356+ expect.objectContaining({ provider: PROVIDER_ID, id: "plugin-generation-v1" }),
357+ );
358+ },
359+ );
360+
317361 it("publishes account-scoped harness models only in the full catalog", async () => {
318362 const fixture = await createStaticSnapshot(0);
319363
0 commit comments