@@ -171,7 +171,7 @@ type RunCliAgentPrepareParams = RunCliAgentParams & {
171171 systemAgentTool ?: import ( "../tools/system-agent-tool.js" ) . SystemAgentToolOptions ;
172172} ;
173173
174- const prepareDeps = {
174+ const defaultPrepareDeps = {
175175 isWorkspaceBootstrapPending : isWorkspaceBootstrapPendingImpl ,
176176 makeBootstrapWarn : makeBootstrapWarnImpl ,
177177 resolveBootstrapContextForRun : resolveBootstrapContextForRunImpl ,
@@ -195,6 +195,7 @@ const prepareDeps = {
195195 readExternalCliBootstrapCredential,
196196 resolveApiKeyForProfile,
197197} ;
198+ const prepareDeps = { ...defaultPrepareDeps } ;
198199
199200function resolveReusableCliSessionId ( reusableCliSession : CliReusableSession ) : string | undefined {
200201 return reusableCliSession . mode === "reuse" || reusableCliSession . mode === "reuse-with-drift"
@@ -320,6 +321,11 @@ function setCliRunnerPrepareTestDeps(overrides: Partial<typeof prepareDeps>): vo
320321 Object . assign ( prepareDeps , overrides ) ;
321322}
322323
324+ /** Restores preparation dependencies after CLI runner tests. */
325+ function resetCliRunnerPrepareTestDeps ( ) : void {
326+ Object . assign ( prepareDeps , defaultPrepareDeps ) ;
327+ }
328+
323329/** Returns whether profile-owned prepared execution should skip local CLI epoch hashing. */
324330function shouldSkipLocalCliCredentialEpoch ( params : {
325331 authEpochMode ?: CliBackendAuthEpochMode ;
@@ -337,6 +343,7 @@ function shouldSkipLocalCliCredentialEpoch(params: {
337343
338344if ( process . env . VITEST || process . env . NODE_ENV === "test" ) {
339345 ( globalThis as Record < PropertyKey , unknown > ) [ Symbol . for ( "openclaw.cliRunnerPrepareTestApi" ) ] = {
346+ resetCliRunnerPrepareTestDeps,
340347 setCliRunnerPrepareTestDeps : ( overrides : Record < string , unknown > ) => {
341348 setCliRunnerPrepareTestDeps ( overrides as Partial < typeof prepareDeps > ) ;
342349 } ,
0 commit comments