@blaxel/core 0.2.17-dev.130 → 0.2.17-dev.132
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/common/logger.js
CHANGED
|
@@ -31,7 +31,7 @@ function stringify(obj, maxDepth = 1, depth = 0) {
|
|
|
31
31
|
class Logger {
|
|
32
32
|
logger;
|
|
33
33
|
constructor() {
|
|
34
|
-
this.logger =
|
|
34
|
+
this.logger = null;
|
|
35
35
|
}
|
|
36
36
|
setLogger(logger) {
|
|
37
37
|
this.logger = logger;
|
|
@@ -45,16 +45,24 @@ class Logger {
|
|
|
45
45
|
}).join(" ");
|
|
46
46
|
}
|
|
47
47
|
info(...message) {
|
|
48
|
-
this.logger
|
|
48
|
+
if (this.logger) {
|
|
49
|
+
this.logger.info(this.parseArgs(message));
|
|
50
|
+
}
|
|
49
51
|
}
|
|
50
52
|
debug(...message) {
|
|
51
|
-
this.logger
|
|
53
|
+
if (this.logger) {
|
|
54
|
+
this.logger.debug(this.parseArgs(message));
|
|
55
|
+
}
|
|
52
56
|
}
|
|
53
57
|
warn(...message) {
|
|
54
|
-
this.logger
|
|
58
|
+
if (this.logger) {
|
|
59
|
+
this.logger.warn(this.parseArgs(message));
|
|
60
|
+
}
|
|
55
61
|
}
|
|
56
62
|
error(...message) {
|
|
57
|
-
this.logger
|
|
63
|
+
if (this.logger) {
|
|
64
|
+
this.logger.error(this.parseArgs(message));
|
|
65
|
+
}
|
|
58
66
|
}
|
|
59
67
|
}
|
|
60
68
|
const logger = new Logger();
|
package/dist/sandbox/sandbox.js
CHANGED
|
@@ -46,7 +46,7 @@ class SandboxInstance {
|
|
|
46
46
|
},
|
|
47
47
|
throwOnError: true,
|
|
48
48
|
});
|
|
49
|
-
logger_js_1.logger.
|
|
49
|
+
logger_js_1.logger.debug(`Waiting for sandbox to be deployed, status: ${data.status}`);
|
|
50
50
|
this.sandbox = data;
|
|
51
51
|
}
|
|
52
52
|
catch (e) {
|
|
@@ -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,9 +14,7 @@ class NoopSpan {
|
|
|
14
14
|
recordException() { }
|
|
15
15
|
setStatus() { }
|
|
16
16
|
end() { }
|
|
17
|
-
getContext() {
|
|
18
|
-
return null;
|
|
19
|
-
}
|
|
17
|
+
getContext() { return null; }
|
|
20
18
|
}
|
|
21
19
|
/**
|
|
22
20
|
* No-operation implementation of TelemetryProvider
|
|
@@ -68,16 +66,13 @@ async function withSpan(name, fn, options) {
|
|
|
68
66
|
const span = startSpan(name, options);
|
|
69
67
|
try {
|
|
70
68
|
const result = await fn();
|
|
71
|
-
span.
|
|
69
|
+
span.end();
|
|
72
70
|
return result;
|
|
73
71
|
}
|
|
74
72
|
catch (error) {
|
|
75
|
-
span.setStatus("error", error.message);
|
|
76
73
|
span.recordException(error);
|
|
77
|
-
throw error;
|
|
78
|
-
}
|
|
79
|
-
finally {
|
|
80
74
|
span.end();
|
|
75
|
+
throw error;
|
|
81
76
|
}
|
|
82
77
|
}
|
|
83
78
|
async function flush() {
|
package/dist/tools/mcpTool.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export declare class McpTool {
|
|
|
15
15
|
get forcedUrl(): import("url").URL | null;
|
|
16
16
|
get url(): import("url").URL;
|
|
17
17
|
start(): Promise<void>;
|
|
18
|
-
close(): Promise<void>;
|
|
18
|
+
close(now?: boolean): Promise<void>;
|
|
19
19
|
stopCloseTimer(): void;
|
|
20
20
|
listTools(): Promise<Tool[]>;
|
|
21
21
|
call(toolName: string, args: Record<string, unknown> | undefined): Promise<unknown>;
|
package/dist/tools/mcpTool.js
CHANGED
|
@@ -70,38 +70,38 @@ 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
|
-
|
|
94
|
-
}
|
|
95
|
-
})();
|
|
73
|
+
this.startPromise = this.startPromise || (async () => {
|
|
74
|
+
await (0, index_js_2.authenticate)();
|
|
75
|
+
try {
|
|
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);
|
|
78
|
+
await this.client.connect(this.transport);
|
|
79
|
+
logger_js_1.logger.debug(`MCP:${this.name}:Connected`);
|
|
80
|
+
}
|
|
81
|
+
catch (err) {
|
|
82
|
+
if (err instanceof Error) {
|
|
83
|
+
logger_js_1.logger.error(err.stack);
|
|
84
|
+
}
|
|
85
|
+
if (!this.fallbackUrl) {
|
|
86
|
+
throw err;
|
|
87
|
+
}
|
|
88
|
+
logger_js_1.logger.debug(`MCP:${this.name}:Connecting to fallback`);
|
|
89
|
+
this.transport = new client_js_1.BlaxelMcpClientTransport(this.fallbackUrl.toString(), settings_js_1.settings.headers);
|
|
90
|
+
await this.client.connect(this.transport);
|
|
91
|
+
logger_js_1.logger.debug(`MCP:${this.name}:Connected to fallback`);
|
|
92
|
+
}
|
|
93
|
+
})();
|
|
96
94
|
return await this.startPromise;
|
|
97
95
|
}
|
|
98
|
-
async close() {
|
|
99
|
-
logger_js_1.logger.debug(`MCP:${this.name}:Close in ${this.ms}ms`);
|
|
100
|
-
if (!this.ms) {
|
|
96
|
+
async close(now = false) {
|
|
97
|
+
logger_js_1.logger.debug(`MCP:${this.name}:Close in ${now ? 0 : this.ms}ms`);
|
|
98
|
+
if (now || !this.ms) {
|
|
99
|
+
if (this.timer) {
|
|
100
|
+
clearTimeout(this.timer);
|
|
101
|
+
}
|
|
101
102
|
delete this.startPromise;
|
|
102
103
|
return this.client.close();
|
|
103
104
|
}
|
|
104
|
-
// Use setTimeout with proper error handling
|
|
105
105
|
this.timer = setTimeout(() => {
|
|
106
106
|
logger_js_1.logger.debug(`MCP:${this.name}:CloseTimer`);
|
|
107
107
|
delete this.startPromise;
|
|
@@ -110,7 +110,7 @@ class McpTool {
|
|
|
110
110
|
logger_js_1.logger.error(err.stack);
|
|
111
111
|
}
|
|
112
112
|
});
|
|
113
|
-
}, this.ms);
|
|
113
|
+
}, now ? 0 : this.ms);
|
|
114
114
|
}
|
|
115
115
|
stopCloseTimer() {
|
|
116
116
|
logger_js_1.logger.debug(`MCP:${this.name}:StopCloseTimer`);
|
|
@@ -172,9 +172,7 @@ class McpTool {
|
|
|
172
172
|
});
|
|
173
173
|
logger_js_1.logger.debug(`MCP:${this.name}:Tool calling:result`);
|
|
174
174
|
await this.close();
|
|
175
|
-
logger_js_1.logger.debug(`MCP:${this.name}:Tool result`, toolName, JSON.stringify(args)
|
|
176
|
-
// result
|
|
177
|
-
);
|
|
175
|
+
logger_js_1.logger.debug(`MCP:${this.name}:Tool result`, toolName, JSON.stringify(args));
|
|
178
176
|
span.setAttribute("tool.call.result", JSON.stringify(result));
|
|
179
177
|
return result;
|
|
180
178
|
}
|