@blaxel/core 0.2.23-dev.170 → 0.2.23-dev.171
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mcp/client.d.ts +8 -1
- package/dist/mcp/client.js +16 -11
- package/dist/tools/mcpTool.js +1 -1
- package/package.json +1 -1
package/dist/mcp/client.d.ts
CHANGED
|
@@ -9,10 +9,17 @@ export declare class BlaxelMcpClientTransport implements Transport {
|
|
|
9
9
|
private _url;
|
|
10
10
|
private _headers;
|
|
11
11
|
private _isBrowser;
|
|
12
|
+
private _retry_max;
|
|
13
|
+
private _retry_delay;
|
|
12
14
|
onclose?: () => void;
|
|
13
15
|
onerror?: (error: Error) => void;
|
|
14
16
|
onmessage?: (message: JSONRPCMessage) => void;
|
|
15
|
-
constructor(url: string, headers?: Record<string, string
|
|
17
|
+
constructor(url: string, headers?: Record<string, string>, options?: {
|
|
18
|
+
retry: {
|
|
19
|
+
max?: number;
|
|
20
|
+
delay?: number;
|
|
21
|
+
};
|
|
22
|
+
});
|
|
16
23
|
start(): Promise<void>;
|
|
17
24
|
private _connect;
|
|
18
25
|
get isConnected(): boolean;
|
package/dist/mcp/client.js
CHANGED
|
@@ -21,8 +21,6 @@ if (!isBrowser) {
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
//const SUBPROTOCOL = "mcp";
|
|
24
|
-
const MAX_RETRIES = 3;
|
|
25
|
-
const RETRY_DELAY_MS = 1000;
|
|
26
24
|
// Helper function to wait
|
|
27
25
|
const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
28
26
|
/**
|
|
@@ -34,11 +32,15 @@ class BlaxelMcpClientTransport {
|
|
|
34
32
|
_url;
|
|
35
33
|
_headers;
|
|
36
34
|
_isBrowser;
|
|
35
|
+
_retry_max;
|
|
36
|
+
_retry_delay;
|
|
37
37
|
onclose;
|
|
38
38
|
onerror;
|
|
39
39
|
onmessage;
|
|
40
|
-
constructor(url, headers) {
|
|
40
|
+
constructor(url, headers, options) {
|
|
41
41
|
this._url = new URL(url.replace("http", "ws"));
|
|
42
|
+
this._retry_max = options?.retry?.max ?? 3;
|
|
43
|
+
this._retry_delay = options?.retry?.delay ?? 1000;
|
|
42
44
|
this._headers = headers ?? {};
|
|
43
45
|
this._isBrowser = isBrowser;
|
|
44
46
|
}
|
|
@@ -47,7 +49,7 @@ class BlaxelMcpClientTransport {
|
|
|
47
49
|
throw new Error("Blaxel already started! If using Client class, note that connect() calls start() automatically.");
|
|
48
50
|
}
|
|
49
51
|
let attempts = 0;
|
|
50
|
-
while (attempts <
|
|
52
|
+
while (attempts < this._retry_max) {
|
|
51
53
|
try {
|
|
52
54
|
await this._connect();
|
|
53
55
|
return;
|
|
@@ -57,11 +59,14 @@ class BlaxelMcpClientTransport {
|
|
|
57
59
|
logger_js_1.logger.warn(error.stack ?? error.message);
|
|
58
60
|
}
|
|
59
61
|
attempts++;
|
|
60
|
-
if (attempts ===
|
|
62
|
+
if (attempts === this._retry_max) {
|
|
61
63
|
throw error;
|
|
62
64
|
}
|
|
63
|
-
logger_js_1.logger.debug(`WebSocket connection attempt ${attempts} failed, retrying in ${
|
|
64
|
-
await delay(
|
|
65
|
+
logger_js_1.logger.debug(`WebSocket connection attempt ${attempts} failed, retrying in ${this._retry_delay}ms...`);
|
|
66
|
+
await delay(this._retry_delay);
|
|
67
|
+
}
|
|
68
|
+
finally {
|
|
69
|
+
attempts++;
|
|
65
70
|
}
|
|
66
71
|
}
|
|
67
72
|
}
|
|
@@ -192,7 +197,7 @@ class BlaxelMcpClientTransport {
|
|
|
192
197
|
}
|
|
193
198
|
async send(message) {
|
|
194
199
|
let attempts = 0;
|
|
195
|
-
while (attempts <
|
|
200
|
+
while (attempts < this._retry_max) {
|
|
196
201
|
try {
|
|
197
202
|
if (!this._socket || !this.isConnected) {
|
|
198
203
|
if (!this._socket) {
|
|
@@ -231,11 +236,11 @@ class BlaxelMcpClientTransport {
|
|
|
231
236
|
}
|
|
232
237
|
catch (error) {
|
|
233
238
|
attempts++;
|
|
234
|
-
if (attempts ===
|
|
239
|
+
if (attempts === this._retry_max) {
|
|
235
240
|
throw error;
|
|
236
241
|
}
|
|
237
|
-
logger_js_1.logger.warn(`WebSocket send attempt ${attempts} failed, retrying in ${
|
|
238
|
-
await delay(
|
|
242
|
+
logger_js_1.logger.warn(`WebSocket send attempt ${attempts} failed, retrying in ${this._retry_delay}ms...`);
|
|
243
|
+
await delay(this._retry_delay);
|
|
239
244
|
}
|
|
240
245
|
}
|
|
241
246
|
}
|
package/dist/tools/mcpTool.js
CHANGED
|
@@ -74,7 +74,7 @@ class McpTool {
|
|
|
74
74
|
await (0, index_js_2.authenticate)();
|
|
75
75
|
try {
|
|
76
76
|
logger_js_1.logger.debug(`MCP:${this.name}:Connecting::${this.url.toString()}`);
|
|
77
|
-
this.transport = new client_js_1.BlaxelMcpClientTransport(this.url.toString(), settings_js_1.settings.headers);
|
|
77
|
+
this.transport = new client_js_1.BlaxelMcpClientTransport(this.url.toString(), settings_js_1.settings.headers, { retry: { max: 0 } });
|
|
78
78
|
await this.client.connect(this.transport);
|
|
79
79
|
logger_js_1.logger.debug(`MCP:${this.name}:Connected`);
|
|
80
80
|
}
|