@@ -4,11 +4,11 @@ import {
44 GATEWAY_CLIENT_MODES ,
55 GATEWAY_CLIENT_NAMES ,
66} from "../../packages/gateway-protocol/src/client-info.js" ;
7- import { listAgentIds , resolveDefaultAgentId } from "../agents/agent-scope.js" ;
7+ import { listAgentIds , resolveDefaultAgentId } from "../agents/agent-scope-config .js" ;
88import { formatCliCommand } from "../cli/command-format.js" ;
99import type { CliDeps } from "../cli/deps.types.js" ;
1010import { withProgress } from "../cli/progress.js" ;
11- import { getRuntimeConfig } from "../config/config .js" ;
11+ import { getRuntimeConfig } from "../config/io .js" ;
1212import type { OpenClawConfig } from "../config/types.openclaw.js" ;
1313import {
1414 callGateway ,
@@ -150,6 +150,12 @@ function parseTimeoutSeconds(opts: { cfg: OpenClawConfig; timeout?: string }) {
150150 return raw ;
151151}
152152
153+ function getGatewayDispatchConfig ( ) : OpenClawConfig {
154+ // Scoped gateway turns need core agent/session/gateway fields only. The
155+ // running gateway owns plugin validation and plugin metadata freshness.
156+ return getRuntimeConfig ( { skipPluginValidation : true , pin : false } ) ;
157+ }
158+
153159function formatPayloadForLog ( payload : {
154160 text ?: string ;
155161 mediaUrls ?: string [ ] ;
@@ -231,7 +237,9 @@ function normalizeSessionKeyOptsForDispatch(opts: AgentCliOpts): AgentCliOpts {
231237 isLegacySessionKey && ! agentIdRaw && ! isUnscopedSessionKeySentinel ( rawSessionKey ) ;
232238 const cfg =
233239 isLegacySessionKey && ( agentIdRaw || shouldScopeDefaultAgentKey )
234- ? getRuntimeConfig ( )
240+ ? opts . local === true
241+ ? getRuntimeConfig ( )
242+ : getGatewayDispatchConfig ( )
235243 : undefined ;
236244 const sessionKey = scopeLegacySessionKeyToAgent ( {
237245 agentId : agentIdRaw ?? ( shouldScopeDefaultAgentKey ? resolveDefaultAgentId ( cfg ! ) : undefined ) ,
@@ -401,6 +409,7 @@ async function abortAcceptedGatewayAgentRunWithGatewayCall(params: {
401409 signal : AgentCliSignal | undefined ;
402410 runtime : RuntimeEnv ;
403411 gatewayIdentity : AgentGatewayCallIdentity ;
412+ config : OpenClawConfig ;
404413} ) : Promise < void > {
405414 const request : GatewayRequestFunction = async < T = Record < string , unknown > > (
406415 method : string ,
@@ -412,6 +421,7 @@ async function abortAcceptedGatewayAgentRunWithGatewayCall(params: {
412421 params : requestParams ,
413422 timeoutMs : opts ?. timeoutMs ?? undefined ,
414423 expectFinal : opts ?. expectFinal ,
424+ config : params . config ,
415425 ...params . gatewayIdentity ,
416426 } ) ;
417427 for ( const [ attempt , retryDelayMs ] of [ ...GATEWAY_ABORT_RETRY_DELAYS_MS , 0 ] . entries ( ) ) {
@@ -495,7 +505,7 @@ async function resolveAgentIdForGatewayTimeoutFallback(
495505 return resolveAgentIdFromSessionKey ( explicitSessionKey ) ;
496506 }
497507 if ( isUnscopedSessionKeySentinel ( explicitSessionKey ) ) {
498- return resolveDefaultAgentId ( getRuntimeConfig ( ) ) ;
508+ return resolveDefaultAgentId ( getGatewayDispatchConfig ( ) ) ;
499509 }
500510
501511 const agentIdRaw = opts . agent ?. trim ( ) ;
@@ -506,7 +516,7 @@ async function resolveAgentIdForGatewayTimeoutFallback(
506516 if ( ! opts . to && ! opts . sessionId ) {
507517 return undefined ;
508518 }
509- const cfg = getRuntimeConfig ( ) ;
519+ const cfg = getGatewayDispatchConfig ( ) ;
510520 const { resolveSessionKeyForRequest } = await loadAgentSessionModule ( ) ;
511521 const resolvedSessionKey = resolveSessionKeyForRequest ( {
512522 cfg,
@@ -558,7 +568,7 @@ async function agentViaGatewayCommand(
558568 ) ;
559569 }
560570
561- const cfg = getRuntimeConfig ( ) ;
571+ const cfg = getGatewayDispatchConfig ( ) ;
562572 const agentIdRaw = opts . agent ?. trim ( ) ;
563573 const agentId = agentIdRaw ? normalizeAgentId ( agentIdRaw ) : undefined ;
564574 if ( agentId ) {
@@ -638,6 +648,7 @@ async function agentViaGatewayCommand(
638648 } ,
639649 expectFinal : true ,
640650 timeoutMs : gatewayTimeoutMs ,
651+ config : cfg ,
641652 signal : signalBridge . signal ,
642653 onAccepted : ( payload ) => {
643654 acceptedGatewayRun = true ;
@@ -670,6 +681,7 @@ async function agentViaGatewayCommand(
670681 signal : signalBridge . getReceivedSignal ( ) ,
671682 runtime,
672683 gatewayIdentity,
684+ config : cfg ,
673685 } ) ;
674686 }
675687 throw err ;
0 commit comments