22import crypto from "node:crypto" ;
33import path from "node:path" ;
44import { expectDefined } from "@openclaw/normalization-core" ;
5- import { afterAll , afterEach , beforeAll , beforeEach , describe , expect , it , vi } from "vitest" ;
5+ import { afterEach , beforeEach , describe , expect , it , vi } from "vitest" ;
66import { TranscriptNotContinuableError } from "../../packages/agent-core/src/errors.js" ;
77import type { OpenClawConfig } from "../config/config.js" ;
88import { createAgentRunStaleLifecycleError } from "../infra/agent-lifecycle-error.js" ;
@@ -13,9 +13,6 @@ import {
1313} from "../infra/diagnostic-events.js" ;
1414import { resetLogger , setLoggerOverride } from "../logging/logger.js" ;
1515import { createWarnLogCapture } from "../logging/test-helpers/warn-log-capture.js" ;
16- import { setCurrentPluginMetadataSnapshot } from "../plugins/current-plugin-metadata-snapshot.js" ;
17- import { clearCurrentPluginMetadataSnapshot } from "../plugins/current-plugin-metadata-state.js" ;
18- import { loadPluginMetadataSnapshot } from "../plugins/plugin-metadata-snapshot.js" ;
1916import { GatewayDrainingError } from "../process/gateway-work-admission.js" ;
2017import { AgentRunTerminalOutcomeError } from "./agent-run-terminal-error.js" ;
2118import { AUTH_STORE_VERSION } from "./auth-profiles/constants.js" ;
@@ -50,13 +47,19 @@ import { resolveSessionSuspensionReason } from "./session-suspension.js";
5047import { SessionWriteLockTimeoutError } from "./session-write-lock-error.js" ;
5148import { makeModelFallbackCfg } from "./test-helpers/model-fallback-config-fixture.js" ;
5249
50+ const emptyManifestPlugins = [ ] as const ;
51+
52+ function resolveFallbackCandidateRoutes ( params : Parameters < typeof resolveModelCandidateChain > [ 0 ] ) {
53+ return resolveModelCandidateChain ( { manifestPlugins : emptyManifestPlugins , ...params } ) ;
54+ }
55+
5356function resolveFallbackCandidateRefs ( params : Parameters < typeof resolveModelCandidateChain > [ 0 ] ) {
54- return resolveModelCandidateChain ( params ) . map ( ( { provider, model } ) => ( { provider, model } ) ) ;
57+ return resolveFallbackCandidateRoutes ( params ) . map ( ( { provider, model } ) => ( { provider, model } ) ) ;
5558}
5659
5760const testing = {
5861 resolveFallbackCandidates : resolveFallbackCandidateRefs ,
59- resolveFallbackCandidateRoutes : resolveModelCandidateChain ,
62+ resolveFallbackCandidateRoutes,
6063 resolveSessionSuspensionReason,
6164 shouldDiscardDeferredSessionSuspension,
6265} ;
@@ -215,7 +218,6 @@ vi.mock("./auth-profiles.runtime.js", () => authRuntimeMock.runtime);
215218const makeCfg = makeModelFallbackCfg ;
216219let authTempRoot = "" ;
217220let authTempCounter = 0 ;
218- const emptyManifestPlugins = [ ] as const ;
219221
220222function registerFallbackHarness ( id : string ) : void {
221223 registerAgentHarness (
@@ -242,14 +244,6 @@ function createHarnessScopedPreflightError(harnessId: string): AgentHarnessPrefl
242244const runWithModelFallback : typeof runWithModelFallbackBase = ( params ) =>
243245 runWithModelFallbackBase ( { manifestPlugins : emptyManifestPlugins , ...params } ) ;
244246
245- beforeAll ( ( ) => {
246- setDefaultPluginMetadataSnapshot ( ) ;
247- } ) ;
248-
249- afterAll ( ( ) => {
250- clearCurrentPluginMetadataSnapshot ( ) ;
251- } ) ;
252-
253247function resetModelFallbackTestState ( ) : void {
254248 // Fallback state has process-level caches for skip markers, harnesses, auth,
255249 // and plugin normalization. Reset every surface between tests.
@@ -265,13 +259,6 @@ function resetModelFallbackTestState(): void {
265259 resetDiagnosticEventsForTest ( ) ;
266260}
267261
268- function setDefaultPluginMetadataSnapshot ( ) : void {
269- setCurrentPluginMetadataSnapshot ( loadPluginMetadataSnapshot ( { config : { } , env : process . env } ) , {
270- config : { } ,
271- env : process . env ,
272- } ) ;
273- }
274-
275262afterEach ( ( ) => {
276263 resetModelFallbackTestState ( ) ;
277264 cliBackendsTesting . resetDepsForTest ( ) ;
0 commit comments