22import { normalizeOptionalString } from "@openclaw/normalization-core/string-coerce" ;
33import type { VerboseLevel } from "../auto-reply/thinking.js" ;
44import type { CliDeps } from "../cli/deps.types.js" ;
5- import { getRuntimeConfig } from "../config/io.js" ;
65import { resolveSessionWorkStartError } from "../config/sessions/lifecycle.js" ;
76import { buildRestartRecoveryClaimCleanupPatch } from "../config/sessions/restart-recovery-state.js" ;
87import type { RestartRecoveryTerminalDeliveryEvidenceResult } from "../config/sessions/restart-recovery-types.js" ;
98import type { SessionEntry } from "../config/sessions/types.js" ;
10- import { withLocalGatewayRequestScope } from "../gateway/local-request-context.js" ;
119import {
1210 assertAgentRunLifecycleGenerationCurrent ,
1311 captureAgentRunLifecycleGeneration ,
@@ -25,6 +23,7 @@ import { beginSessionWorkAdmission } from "../sessions/session-lifecycle-admissi
2523import { classifySessionStateActor } from "../sessions/session-state-events.js" ;
2624import { sessionDeliveryChannel , type DeliveryContext } from "../utils/delivery-context.shared.js" ;
2725import { executionIdentity } from "./agent-command-execution-identity.js" ;
26+ import { runLocalAgentCommand } from "./agent-command-local.js" ;
2827import { runWithAgentCommandRecoveryOwner } from "./agent-command-recovery-owner.js" ;
2928import {
3029 buildCurrentRunRestartRecoveryClaim ,
@@ -599,43 +598,13 @@ async function agentCommandWithAdmissionIngress(
599598 runtime : RuntimeEnv = defaultRuntime ,
600599 deps ?: CliDeps ,
601600) {
602- const resolvedDeps = await measureAgentStartup ( "command-dependencies" , ( ) =>
603- resolveAgentCommandDeps ( deps ) ,
604- ) ;
605- const lifecycleGeneration =
606- opts . lifecycleGeneration ?? captureAgentRunLifecycleGeneration ( opts . runId ?? "" ) ;
607- return await withAgentRunLifecycleGeneration ( lifecycleGeneration , ( ) =>
608- withLocalGatewayRequestScope (
609- {
610- deps : resolvedDeps ,
611- getRuntimeConfig,
612- } ,
613- async ( ) =>
614- await runWithAgentCommandRecoveryOwner ( {
615- lifecycleGeneration,
616- mode : "reject_uncoordinated" ,
617- opts : {
618- ...opts ,
619- lifecycleGeneration,
620- // Only the local entrypoint may inherit trusted-operator defaults.
621- senderIsOwner : opts . senderIsOwner ?? true ,
622- allowModelOverride : opts . allowModelOverride ?? true ,
623- } ,
624- prepare : async ( preparedOpts ) =>
625- await measureAgentStartup ( "command-prepare" , ( ) =>
626- prepareAgentCommandExecution ( preparedOpts , runtime ) ,
627- ) ,
628- run : async ( prepared ) =>
629- await agentCommandInternal (
630- prepared ,
631- prepared . opts ,
632- admissionIngress ,
633- runtime ,
634- resolvedDeps ,
635- ) ,
636- } ) ,
637- ) ,
638- ) ;
601+ return await runLocalAgentCommand ( {
602+ opts,
603+ runtime,
604+ deps,
605+ run : async ( prepared , resolvedDeps ) =>
606+ await agentCommandInternal ( prepared , prepared . opts , admissionIngress , runtime , resolvedDeps ) ,
607+ } ) ;
639608}
640609
641610export async function agentCommand (
0 commit comments