UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

3 lines • 2.39 kB
import{n as getDatabaseEngineSelection}from"./context-DZjni16e.mjs";import{i as GATEWAY_CLIENT_NAMES,r as GATEWAY_CLIENT_MODES}from"./client-info-Dr3-kuD1.mjs";import{r as resolveGatewayLocalPortOverride}from"./gateway-port-option-DyC2pgY0.mjs";import{f as isImplicitLocalGatewayTarget,m as assertGatewayCliMessageContext,r as callGateway}from"./call-CVqWsTxX.mjs";import{r as withProgress}from"./progress-BcNIavn6.mjs";import{n as parseTimeoutMsWithFallback}from"./parse-timeout-euv6DhlU.mjs"; //!src/cli/gateway-rpc.runtime.ts const DEFAULT_GATEWAY_RPC_TIMEOUT_MS=3e4;async function prepareCliGatewayStateAccess(){if(getDatabaseEngineSelection())return;const{readConfigSnapshotForEngineSelection:e}=await import(`./config-preflight-snapshot-CYPXIJMO.mjs`);const t=await e(process.env,{isolateEnv:false});if(!getDatabaseEngineSelection()){const{createConfigReadError:e}=await import(`./io.invalid-config-Cw04snJA.mjs`);throw e(t)}}async function isImplicitLocalGatewayTargetFromCliRuntime(e){return await isImplicitLocalGatewayTarget({config:e.config,url:e.url,localPortOverride:resolveGatewayLocalPortOverride(e)})}async function callGatewayFromCliRuntime(e,t,n,r){assertGatewayCliMessageContext(e,n);const i=resolveGatewayLocalPortOverride(t);const a=r?.progress??t.json!==true;const o=r?.timeoutMs!==void 0?r.timeoutMs:t.timeout===null?null:parseTimeoutMsWithFallback(t.timeout,r?.defaultTimeoutMs??DEFAULT_GATEWAY_RPC_TIMEOUT_MS,{invalidType:`error`});return await withProgress({label:r?.label??`Gateway ${e}`,indeterminate:true,enabled:a},async()=>await callGateway({config:t.config,url:t.url,expectUrl:t.expectUrl,token:t.token,password:t.password,method:e,onResponse:r?.onResponse,params:n,deviceIdentity:r?.deviceIdentity,beforeDeviceIdentityLoad:prepareCliGatewayStateAccess,expectFinal:r?.expectFinal??Boolean(t.expectFinal),scopes:r?.scopes,useStoredDeviceAuth:r?.useStoredDeviceAuth,requiredStoredDeviceAuthScopes:r?.requiredStoredDeviceAuthScopes,requireLocalBackendSharedAuth:r?.requireLocalBackendSharedAuth,allowLocalBackendAuthNone:r?.clientName===void 0&&r?.mode===void 0,sharedStateMode:r?.sharedStateMode,signal:r?.signal,timeoutMs:o,localPortOverride:i,clientName:r?.clientName??GATEWAY_CLIENT_NAMES.CLI,mode:r?.mode??GATEWAY_CLIENT_MODES.CLI}))}export{isImplicitLocalGatewayTargetFromCliRuntime as n,prepareCliGatewayStateAccess as r,callGatewayFromCliRuntime as t};