11import { randomUUID } from "node:crypto" ;
22import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js" ;
33import type { OpenClawConfig } from "../config/types.openclaw.js" ;
4- import { resolveGatewayClientBootstrap } from "../gateway/client-bootstrap.js" ;
5- import { GatewayClient , GatewayClientRequestError } from "../gateway/client.js" ;
6- import { APPROVALS_SCOPE , READ_SCOPE , WRITE_SCOPE } from "../gateway/method-scopes.js" ;
7- import { GATEWAY_CLIENT_MODES , GATEWAY_CLIENT_NAMES } from "../gateway/protocol/client-info.js" ;
4+ import type { GatewayClient } from "../gateway/client.js" ;
85import type { EventFrame } from "../gateway/protocol/index.js" ;
96import { extractFirstTextBlock } from "../shared/chat-message-content.js" ;
107import {
@@ -88,6 +85,17 @@ export class OpenClawChannelBridge {
8885 return ;
8986 }
9087 this . started = true ;
88+ const [
89+ { resolveGatewayClientBootstrap } ,
90+ { GatewayClient : GatewayClientCtor } ,
91+ { APPROVALS_SCOPE , READ_SCOPE , WRITE_SCOPE } ,
92+ { GATEWAY_CLIENT_MODES , GATEWAY_CLIENT_NAMES } ,
93+ ] = await Promise . all ( [
94+ import ( "../gateway/client-bootstrap.js" ) ,
95+ import ( "../gateway/client.js" ) ,
96+ import ( "../gateway/method-scopes.js" ) ,
97+ import ( "../gateway/protocol/client-info.js" ) ,
98+ ] ) ;
9199 const bootstrap = await resolveGatewayClientBootstrap ( {
92100 config : this . cfg ,
93101 gatewayUrl : this . params . gatewayUrl ,
@@ -102,7 +110,7 @@ export class OpenClawChannelBridge {
102110 return ;
103111 }
104112
105- this . gateway = new GatewayClient ( {
113+ this . gateway = new GatewayClientCtor ( {
106114 url : bootstrap . url ,
107115 token : bootstrap . auth . token ,
108116 password : bootstrap . auth . password ,
@@ -525,7 +533,11 @@ export class OpenClawChannelBridge {
525533}
526534
527535export function shouldRetryInitialMcpGatewayConnect ( error : Error ) : boolean {
528- if ( error instanceof GatewayClientRequestError ) {
536+ if (
537+ error . name === "GatewayClientRequestError" &&
538+ "retryable" in error &&
539+ typeof error . retryable === "boolean"
540+ ) {
529541 return error . retryable ;
530542 }
531543 const message = error . message . toLowerCase ( ) ;
0 commit comments