33 GATEWAY_CLIENT_MODES ,
44 GATEWAY_CLIENT_NAMES ,
55} from "../../packages/gateway-protocol/src/client-info.js" ;
6+ import type { OpenClawConfig } from "../config/types.openclaw.js" ;
67import { callGateway } from "../gateway/call.js" ;
78import type { GatewayRpcOpts } from "./gateway-rpc.types.js" ;
89import { parseTimeoutMsWithFallback } from "./parse-timeout.js" ;
@@ -16,29 +17,51 @@ type CallGatewayFromCliRuntimeExtra = {
1617 expectFinal ?: boolean ;
1718 progress ?: boolean ;
1819 scopes ?: Parameters < typeof callGateway > [ 0 ] [ "scopes" ] ;
20+ defaultTimeoutMs ?: number ;
21+ timeoutMs ?: number | null ;
22+ label ?: string ;
23+ useStoredDeviceAuth ?: boolean ;
24+ requiredStoredDeviceAuthScopes ?: Parameters <
25+ typeof callGateway
26+ > [ 0 ] [ "requiredStoredDeviceAuthScopes" ] ;
27+ requireLocalBackendSharedAuth ?: boolean ;
28+ } ;
29+
30+ type GatewayCliTransportRpcOpts = Omit < GatewayRpcOpts , "timeout" > & {
31+ config ?: OpenClawConfig ;
32+ timeout ?: string | null ;
33+ localPortOverride ?: number ;
1934} ;
2035
2136const DEFAULT_GATEWAY_RPC_TIMEOUT_MS = 30_000 ;
2237
2338export async function callGatewayFromCliRuntime (
2439 method : string ,
25- opts : GatewayRpcOpts ,
40+ opts : GatewayCliTransportRpcOpts ,
2641 params ?: unknown ,
2742 extra ?: CallGatewayFromCliRuntimeExtra ,
2843) {
2944 // Progress is disabled for JSON output so stdout stays parseable.
3045 const showProgress = extra ?. progress ?? opts . json !== true ;
31- const timeoutMs = parseTimeoutMsWithFallback ( opts . timeout , DEFAULT_GATEWAY_RPC_TIMEOUT_MS , {
32- invalidType : "error" ,
33- } ) ;
46+ const timeoutMs =
47+ extra ?. timeoutMs !== undefined
48+ ? extra . timeoutMs
49+ : opts . timeout === null
50+ ? null
51+ : parseTimeoutMsWithFallback (
52+ opts . timeout ,
53+ extra ?. defaultTimeoutMs ?? DEFAULT_GATEWAY_RPC_TIMEOUT_MS ,
54+ { invalidType : "error" } ,
55+ ) ;
3456 return await withProgress (
3557 {
36- label : `Gateway ${ method } ` ,
58+ label : extra ?. label ?? `Gateway ${ method } ` ,
3759 indeterminate : true ,
3860 enabled : showProgress ,
3961 } ,
4062 async ( ) =>
4163 await callGateway ( {
64+ config : opts . config ,
4265 url : opts . url ,
4366 token : opts . token ,
4467 password : opts . password ,
@@ -47,8 +70,12 @@ export async function callGatewayFromCliRuntime(
4770 deviceIdentity : extra ?. deviceIdentity ,
4871 expectFinal : extra ?. expectFinal ?? Boolean ( opts . expectFinal ) ,
4972 scopes : extra ?. scopes ,
73+ useStoredDeviceAuth : extra ?. useStoredDeviceAuth ,
74+ requiredStoredDeviceAuthScopes : extra ?. requiredStoredDeviceAuthScopes ,
75+ requireLocalBackendSharedAuth : extra ?. requireLocalBackendSharedAuth ,
5076 signal : extra ?. signal ,
5177 timeoutMs,
78+ localPortOverride : opts . localPortOverride ,
5279 clientName : extra ?. clientName ?? GATEWAY_CLIENT_NAMES . CLI ,
5380 mode : extra ?. mode ?? GATEWAY_CLIENT_MODES . CLI ,
5481 } ) ,
0 commit comments