@blaxel/core 0.2.17-dev.107 → 0.2.17-dev.109
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.
|
@@ -20,7 +20,7 @@ export interface BlaxelSpan {
|
|
|
20
20
|
/** Record an error on the span */
|
|
21
21
|
recordException(error: Error): void;
|
|
22
22
|
/** Set the status of the span */
|
|
23
|
-
setStatus(status:
|
|
23
|
+
setStatus(status: "ok" | "error", message?: string): void;
|
|
24
24
|
/** End the span */
|
|
25
25
|
end(): void;
|
|
26
26
|
/** Get the span context (for passing to child spans) */
|
|
@@ -14,7 +14,9 @@ class NoopSpan {
|
|
|
14
14
|
recordException() { }
|
|
15
15
|
setStatus() { }
|
|
16
16
|
end() { }
|
|
17
|
-
getContext() {
|
|
17
|
+
getContext() {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
18
20
|
}
|
|
19
21
|
/**
|
|
20
22
|
* No-operation implementation of TelemetryProvider
|
|
@@ -66,14 +68,17 @@ async function withSpan(name, fn, options) {
|
|
|
66
68
|
const span = startSpan(name, options);
|
|
67
69
|
try {
|
|
68
70
|
const result = await fn();
|
|
69
|
-
span.
|
|
71
|
+
span.setStatus("ok");
|
|
70
72
|
return result;
|
|
71
73
|
}
|
|
72
74
|
catch (error) {
|
|
75
|
+
span.setStatus("error", error.message);
|
|
73
76
|
span.recordException(error);
|
|
74
|
-
span.end();
|
|
75
77
|
throw error;
|
|
76
78
|
}
|
|
79
|
+
finally {
|
|
80
|
+
span.end();
|
|
81
|
+
}
|
|
77
82
|
}
|
|
78
83
|
async function flush() {
|
|
79
84
|
await exports.telemetryRegistry.getProvider().flush();
|
package/dist/tools/mcpTool.js
CHANGED
|
@@ -70,27 +70,29 @@ class McpTool {
|
|
|
70
70
|
async start() {
|
|
71
71
|
logger_js_1.logger.debug(`MCP:${this.name}:start`);
|
|
72
72
|
this.stopCloseTimer();
|
|
73
|
-
this.startPromise =
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
73
|
+
this.startPromise =
|
|
74
|
+
this.startPromise ||
|
|
75
|
+
(async () => {
|
|
76
|
+
await (0, index_js_2.authenticate)();
|
|
77
|
+
try {
|
|
78
|
+
logger_js_1.logger.debug(`MCP:${this.name}:Connecting::${this.url.toString()}`);
|
|
79
|
+
this.transport = new client_js_1.BlaxelMcpClientTransport(this.url.toString(), settings_js_1.settings.headers);
|
|
80
|
+
await this.client.connect(this.transport);
|
|
81
|
+
logger_js_1.logger.debug(`MCP:${this.name}:Connected`);
|
|
82
|
+
}
|
|
83
|
+
catch (err) {
|
|
84
|
+
if (err instanceof Error) {
|
|
85
|
+
logger_js_1.logger.error(err.stack);
|
|
86
|
+
}
|
|
87
|
+
if (!this.fallbackUrl) {
|
|
88
|
+
throw err;
|
|
89
|
+
}
|
|
90
|
+
logger_js_1.logger.debug(`MCP:${this.name}:Connecting to fallback`);
|
|
91
|
+
this.transport = new client_js_1.BlaxelMcpClientTransport(this.fallbackUrl.toString(), settings_js_1.settings.headers);
|
|
92
|
+
await this.client.connect(this.transport);
|
|
93
|
+
logger_js_1.logger.debug(`MCP:${this.name}:Connected to fallback`);
|
|
94
|
+
}
|
|
95
|
+
})();
|
|
94
96
|
return await this.startPromise;
|
|
95
97
|
}
|
|
96
98
|
async close() {
|
|
@@ -99,6 +101,7 @@ class McpTool {
|
|
|
99
101
|
delete this.startPromise;
|
|
100
102
|
return this.client.close();
|
|
101
103
|
}
|
|
104
|
+
// Use setTimeout with proper error handling
|
|
102
105
|
this.timer = setTimeout(() => {
|
|
103
106
|
logger_js_1.logger.debug(`MCP:${this.name}:CloseTimer`);
|
|
104
107
|
delete this.startPromise;
|
|
@@ -169,7 +172,9 @@ class McpTool {
|
|
|
169
172
|
});
|
|
170
173
|
logger_js_1.logger.debug(`MCP:${this.name}:Tool calling:result`);
|
|
171
174
|
await this.close();
|
|
172
|
-
logger_js_1.logger.debug(`MCP:${this.name}:Tool result`, toolName, JSON.stringify(args)
|
|
175
|
+
logger_js_1.logger.debug(`MCP:${this.name}:Tool result`, toolName, JSON.stringify(args)
|
|
176
|
+
// result
|
|
177
|
+
);
|
|
173
178
|
span.setAttribute("tool.call.result", JSON.stringify(result));
|
|
174
179
|
return result;
|
|
175
180
|
}
|