@blaxel/core 0.2.71-dev.101 → 0.2.71-preview.102
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/cjs/.tsbuildinfo +1 -1
- package/dist/cjs/agents/index.js +19 -2
- package/dist/cjs/common/settings.js +2 -2
- package/dist/cjs/jobs/jobs.js +28 -10
- package/dist/cjs/mcp/server.js +65 -4
- package/dist/cjs/tools/index.js +1 -3
- package/dist/cjs/tools/mcpTool.js +43 -15
- package/dist/cjs/types/agents/index.d.ts +2 -1
- package/dist/cjs/types/jobs/jobs.d.ts +2 -1
- package/dist/cjs/types/sandbox/client/types.gen.d.ts +0 -11
- package/dist/cjs/types/tools/index.d.ts +0 -1
- package/dist/cjs-browser/.tsbuildinfo +1 -1
- package/dist/cjs-browser/agents/index.js +19 -2
- package/dist/cjs-browser/common/settings.js +2 -2
- package/dist/cjs-browser/jobs/jobs.js +28 -10
- package/dist/cjs-browser/mcp/server.js +65 -4
- package/dist/cjs-browser/tools/index.js +1 -3
- package/dist/cjs-browser/tools/mcpTool.js +43 -15
- package/dist/cjs-browser/types/agents/index.d.ts +2 -1
- package/dist/cjs-browser/types/jobs/jobs.d.ts +2 -1
- package/dist/cjs-browser/types/sandbox/client/types.gen.d.ts +0 -11
- package/dist/cjs-browser/types/tools/index.d.ts +0 -1
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/agents/index.js +19 -1
- package/dist/esm/common/settings.js +2 -2
- package/dist/esm/jobs/jobs.js +28 -9
- package/dist/esm/mcp/server.js +65 -4
- package/dist/esm/tools/index.js +0 -1
- package/dist/esm/tools/mcpTool.js +43 -15
- package/dist/esm-browser/.tsbuildinfo +1 -1
- package/dist/esm-browser/agents/index.js +19 -1
- package/dist/esm-browser/common/settings.js +2 -2
- package/dist/esm-browser/jobs/jobs.js +28 -9
- package/dist/esm-browser/mcp/server.js +65 -4
- package/dist/esm-browser/tools/index.js +0 -1
- package/dist/esm-browser/tools/mcpTool.js +43 -15
- package/package.json +1 -1
package/dist/cjs/agents/index.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getAgentMetadata = exports.blAgent =
|
|
3
|
+
exports.getAgentMetadata = exports.blAgent = void 0;
|
|
4
4
|
const index_js_1 = require("../cache/index.js");
|
|
5
5
|
const index_js_2 = require("../client/index.js");
|
|
6
6
|
const internal_js_1 = require("../common/internal.js");
|
|
7
7
|
const logger_js_1 = require("../common/logger.js");
|
|
8
8
|
const settings_js_1 = require("../common/settings.js");
|
|
9
|
+
const telemetry_js_1 = require("../telemetry/telemetry.js");
|
|
9
10
|
class BlAgent {
|
|
10
11
|
agentName;
|
|
11
12
|
constructor(agentName) {
|
|
@@ -56,28 +57,44 @@ class BlAgent {
|
|
|
56
57
|
}
|
|
57
58
|
async run(input, headers = {}, params = {}) {
|
|
58
59
|
logger_js_1.logger.debug(`Agent Calling: ${this.agentName}`);
|
|
60
|
+
const span = (0, telemetry_js_1.startSpan)(this.agentName, {
|
|
61
|
+
attributes: {
|
|
62
|
+
"agent.name": this.agentName,
|
|
63
|
+
"agent.args": JSON.stringify(input),
|
|
64
|
+
"span.type": "agent.run",
|
|
65
|
+
},
|
|
66
|
+
isRoot: false,
|
|
67
|
+
});
|
|
59
68
|
try {
|
|
60
69
|
const response = await this.call(this.url, input, headers, params);
|
|
70
|
+
span.setAttribute("agent.run.result", await response.text());
|
|
61
71
|
return await response.text();
|
|
62
72
|
}
|
|
63
73
|
catch (err) {
|
|
64
74
|
if (err instanceof Error) {
|
|
65
75
|
if (!this.fallbackUrl) {
|
|
76
|
+
span.setAttribute("agent.run.error", err.stack);
|
|
66
77
|
throw err;
|
|
67
78
|
}
|
|
68
79
|
try {
|
|
69
80
|
const response = await this.call(this.fallbackUrl, input, headers, params);
|
|
81
|
+
span.setAttribute("agent.run.result", await response.text());
|
|
70
82
|
return await response.text();
|
|
71
83
|
}
|
|
72
84
|
catch (err) {
|
|
85
|
+
if (err instanceof Error) {
|
|
86
|
+
span.setAttribute("agent.run.error", err.stack);
|
|
87
|
+
}
|
|
73
88
|
throw err;
|
|
74
89
|
}
|
|
75
90
|
}
|
|
76
91
|
throw err;
|
|
77
92
|
}
|
|
93
|
+
finally {
|
|
94
|
+
span.end();
|
|
95
|
+
}
|
|
78
96
|
}
|
|
79
97
|
}
|
|
80
|
-
exports.BlAgent = BlAgent;
|
|
81
98
|
const blAgent = (agentName) => {
|
|
82
99
|
return new BlAgent(agentName);
|
|
83
100
|
};
|
|
@@ -9,8 +9,8 @@ const index_js_1 = require("../authentication/index.js");
|
|
|
9
9
|
const env_js_1 = require("../common/env.js");
|
|
10
10
|
const node_js_1 = require("../common/node.js");
|
|
11
11
|
// Build info - these placeholders are replaced at build time by build:replace-imports
|
|
12
|
-
const BUILD_VERSION = "0.2.71-
|
|
13
|
-
const BUILD_COMMIT = "
|
|
12
|
+
const BUILD_VERSION = "0.2.71-preview.102";
|
|
13
|
+
const BUILD_COMMIT = "0e2cce73a323c7322baf2e2fd878f0819b40b862";
|
|
14
14
|
const BUILD_SENTRY_DSN = "https://fd5e60e1c9820e1eef5ccebb84a07127@o4508714045276160.ingest.us.sentry.io/4510465864564736";
|
|
15
15
|
// Cache for config.yaml tracking value
|
|
16
16
|
let configTrackingValue = null;
|
package/dist/cjs/jobs/jobs.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.blJob =
|
|
3
|
+
exports.blJob = void 0;
|
|
4
4
|
const index_js_1 = require("../client/index.js");
|
|
5
5
|
const logger_js_1 = require("../common/logger.js");
|
|
6
6
|
const settings_js_1 = require("../common/settings.js");
|
|
7
|
+
const telemetry_js_1 = require("../telemetry/telemetry.js");
|
|
7
8
|
class BlJob {
|
|
8
9
|
jobName;
|
|
9
10
|
constructor(jobName) {
|
|
@@ -11,14 +12,32 @@ class BlJob {
|
|
|
11
12
|
}
|
|
12
13
|
async run(tasks, options) {
|
|
13
14
|
logger_js_1.logger.debug(`Job Calling: ${this.jobName}`);
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
const span = (0, telemetry_js_1.startSpan)(this.jobName, {
|
|
16
|
+
attributes: {
|
|
17
|
+
"job.name": this.jobName,
|
|
18
|
+
"span.type": "job.run",
|
|
19
|
+
},
|
|
20
|
+
isRoot: false,
|
|
21
|
+
});
|
|
22
|
+
try {
|
|
23
|
+
const request = {
|
|
24
|
+
tasks,
|
|
25
|
+
...(options?.env && { env: options.env }),
|
|
26
|
+
...(options?.memory && { memory: options.memory }),
|
|
27
|
+
...(options?.executionId && { executionId: options.executionId }),
|
|
28
|
+
};
|
|
29
|
+
const executionId = await this.createExecution(request);
|
|
30
|
+
return executionId;
|
|
31
|
+
}
|
|
32
|
+
catch (err) {
|
|
33
|
+
if (err instanceof Error) {
|
|
34
|
+
span.setAttribute("job.run.error", err.stack);
|
|
35
|
+
}
|
|
36
|
+
throw err;
|
|
37
|
+
}
|
|
38
|
+
finally {
|
|
39
|
+
span.end();
|
|
40
|
+
}
|
|
22
41
|
}
|
|
23
42
|
/**
|
|
24
43
|
* Create a new execution for this job and return the execution ID
|
|
@@ -120,7 +139,6 @@ class BlJob {
|
|
|
120
139
|
throw new Error(`Execution ${executionId} did not complete within ${maxWait}ms`);
|
|
121
140
|
}
|
|
122
141
|
}
|
|
123
|
-
exports.BlJob = BlJob;
|
|
124
142
|
const blJob = (jobName) => {
|
|
125
143
|
return new BlJob(jobName);
|
|
126
144
|
};
|
package/dist/cjs/mcp/server.js
CHANGED
|
@@ -38,6 +38,8 @@ const uuid_1 = require("uuid");
|
|
|
38
38
|
const ws_1 = __importStar(require("ws"));
|
|
39
39
|
const env_js_1 = require("../common/env.js");
|
|
40
40
|
const logger_js_1 = require("../common/logger.js");
|
|
41
|
+
const telemetry_js_1 = require("../telemetry/telemetry.js");
|
|
42
|
+
const spans = new Map();
|
|
41
43
|
class BlaxelMcpServerTransport {
|
|
42
44
|
port;
|
|
43
45
|
wss;
|
|
@@ -72,10 +74,26 @@ class BlaxelMcpServerTransport {
|
|
|
72
74
|
ws,
|
|
73
75
|
});
|
|
74
76
|
this.onconnection?.(clientId);
|
|
75
|
-
ws.on("message",
|
|
77
|
+
ws.on("message", (data) => {
|
|
78
|
+
const span = (0, telemetry_js_1.startSpan)("message", {
|
|
79
|
+
attributes: {
|
|
80
|
+
"mcp.client.id": clientId,
|
|
81
|
+
"span.type": "mcp.message",
|
|
82
|
+
},
|
|
83
|
+
isRoot: false,
|
|
84
|
+
});
|
|
76
85
|
try {
|
|
77
86
|
const msg = JSON.parse(data.toString());
|
|
78
|
-
|
|
87
|
+
this.messageHandler?.(msg, clientId);
|
|
88
|
+
if ("method" in msg && "id" in msg && "params" in msg) {
|
|
89
|
+
span.setAttributes({
|
|
90
|
+
"mcp.message.parsed": true,
|
|
91
|
+
"mcp.method": msg.method,
|
|
92
|
+
"mcp.messageId": msg.id,
|
|
93
|
+
"mcp.toolName": msg.params?.name,
|
|
94
|
+
});
|
|
95
|
+
spans.set(clientId + ":" + msg.id, span);
|
|
96
|
+
}
|
|
79
97
|
// Handle msg.id safely
|
|
80
98
|
const msgId = msg.id ? String(msg.id) : "";
|
|
81
99
|
const [cId, parsedMsgId] = msgId.split(":");
|
|
@@ -83,7 +101,27 @@ class BlaxelMcpServerTransport {
|
|
|
83
101
|
// Use optional chaining for safe access
|
|
84
102
|
const client = this.clients.get(cId ?? "");
|
|
85
103
|
if (client?.ws?.readyState === ws_1.default.OPEN) {
|
|
86
|
-
|
|
104
|
+
const msgSpan = spans.get(cId + ":" + (msg.id ?? ""));
|
|
105
|
+
try {
|
|
106
|
+
client.ws.send(JSON.stringify(msg));
|
|
107
|
+
if (msgSpan) {
|
|
108
|
+
msgSpan.setAttributes({
|
|
109
|
+
"mcp.message.response_sent": true,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
catch (err) {
|
|
114
|
+
if (msgSpan) {
|
|
115
|
+
msgSpan.setStatus("error"); // Error status
|
|
116
|
+
msgSpan.recordException(err);
|
|
117
|
+
}
|
|
118
|
+
throw err;
|
|
119
|
+
}
|
|
120
|
+
finally {
|
|
121
|
+
if (msgSpan) {
|
|
122
|
+
msgSpan.end();
|
|
123
|
+
}
|
|
124
|
+
}
|
|
87
125
|
}
|
|
88
126
|
else {
|
|
89
127
|
this.clients.delete(cId);
|
|
@@ -92,11 +130,14 @@ class BlaxelMcpServerTransport {
|
|
|
92
130
|
}
|
|
93
131
|
catch (err) {
|
|
94
132
|
if (err instanceof Error) {
|
|
133
|
+
span.setStatus("error"); // Error status
|
|
134
|
+
span.recordException(err);
|
|
95
135
|
this.onerror?.(err);
|
|
96
136
|
}
|
|
97
137
|
else {
|
|
98
138
|
this.onerror?.(new Error(`Failed to parse message: ${String(err)}`));
|
|
99
139
|
}
|
|
140
|
+
span.end();
|
|
100
141
|
}
|
|
101
142
|
});
|
|
102
143
|
ws.on("close", () => {
|
|
@@ -118,7 +159,27 @@ class BlaxelMcpServerTransport {
|
|
|
118
159
|
// Send to specific client
|
|
119
160
|
const client = this.clients.get(cId);
|
|
120
161
|
if (client?.ws?.readyState === ws_1.default.OPEN) {
|
|
121
|
-
|
|
162
|
+
const msgSpan = spans.get(cId + ":" + msg.id);
|
|
163
|
+
try {
|
|
164
|
+
client.ws.send(data);
|
|
165
|
+
if (msgSpan) {
|
|
166
|
+
msgSpan.setAttributes({
|
|
167
|
+
"mcp.message.response_sent": true,
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
catch (err) {
|
|
172
|
+
if (msgSpan) {
|
|
173
|
+
msgSpan.setStatus("error"); // Error status
|
|
174
|
+
msgSpan.recordException(err);
|
|
175
|
+
}
|
|
176
|
+
throw err;
|
|
177
|
+
}
|
|
178
|
+
finally {
|
|
179
|
+
if (msgSpan) {
|
|
180
|
+
msgSpan.end();
|
|
181
|
+
}
|
|
182
|
+
}
|
|
122
183
|
}
|
|
123
184
|
else {
|
|
124
185
|
this.clients.delete(cId);
|
package/dist/cjs/tools/index.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getToolMetadata = exports.blTool = exports.blTools = exports.BLTools = exports.getTool =
|
|
3
|
+
exports.getToolMetadata = exports.blTool = exports.blTools = exports.BLTools = exports.getTool = void 0;
|
|
4
4
|
const index_js_1 = require("../cache/index.js");
|
|
5
5
|
const client_js_1 = require("../client/client.js");
|
|
6
6
|
const internal_js_1 = require("../common/internal.js");
|
|
7
7
|
const mcpTool_js_1 = require("./mcpTool.js");
|
|
8
|
-
var mcpTool_js_2 = require("./mcpTool.js");
|
|
9
|
-
Object.defineProperty(exports, "McpTool", { enumerable: true, get: function () { return mcpTool_js_2.McpTool; } });
|
|
10
8
|
const getTool = async (name, options) => {
|
|
11
9
|
return await (0, mcpTool_js_1.getMcpTool)(name, options);
|
|
12
10
|
};
|
|
@@ -9,6 +9,7 @@ const logger_js_1 = require("../common/logger.js");
|
|
|
9
9
|
const settings_js_1 = require("../common/settings.js");
|
|
10
10
|
const index_js_2 = require("../index.js");
|
|
11
11
|
const client_js_1 = require("../mcp/client.js");
|
|
12
|
+
const telemetry_js_1 = require("../telemetry/telemetry.js");
|
|
12
13
|
const zodSchema_js_1 = require("./zodSchema.js");
|
|
13
14
|
const McpToolCache = new Map();
|
|
14
15
|
class McpTool {
|
|
@@ -140,24 +141,47 @@ class McpTool {
|
|
|
140
141
|
}
|
|
141
142
|
}
|
|
142
143
|
async listTools() {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
const result = tools.map((tool) => {
|
|
148
|
-
return {
|
|
149
|
-
name: tool.name,
|
|
150
|
-
description: tool.description,
|
|
151
|
-
inputSchema: (0, zodSchema_js_1.schemaToZodSchema)(tool.inputSchema),
|
|
152
|
-
originalSchema: tool.inputSchema,
|
|
153
|
-
call: (input) => {
|
|
154
|
-
return this.call(tool.name, input);
|
|
155
|
-
},
|
|
156
|
-
};
|
|
144
|
+
const span = (0, telemetry_js_1.startSpan)(this.name, {
|
|
145
|
+
attributes: {
|
|
146
|
+
"span.type": "tool.list",
|
|
147
|
+
},
|
|
157
148
|
});
|
|
158
|
-
|
|
149
|
+
try {
|
|
150
|
+
logger_js_1.logger.debug(`MCP:${this.name}:Listing tools`);
|
|
151
|
+
await this.start();
|
|
152
|
+
const { tools } = (await this.client.listTools());
|
|
153
|
+
await this.close();
|
|
154
|
+
const result = tools.map((tool) => {
|
|
155
|
+
return {
|
|
156
|
+
name: tool.name,
|
|
157
|
+
description: tool.description,
|
|
158
|
+
inputSchema: (0, zodSchema_js_1.schemaToZodSchema)(tool.inputSchema),
|
|
159
|
+
originalSchema: tool.inputSchema,
|
|
160
|
+
call: (input) => {
|
|
161
|
+
return this.call(tool.name, input);
|
|
162
|
+
},
|
|
163
|
+
};
|
|
164
|
+
});
|
|
165
|
+
span.setAttribute("tool.list.result", JSON.stringify(result));
|
|
166
|
+
return result;
|
|
167
|
+
}
|
|
168
|
+
catch (err) {
|
|
169
|
+
span.setStatus("error");
|
|
170
|
+
span.recordException(err);
|
|
171
|
+
throw err;
|
|
172
|
+
}
|
|
173
|
+
finally {
|
|
174
|
+
span.end();
|
|
175
|
+
}
|
|
159
176
|
}
|
|
160
177
|
async call(toolName, args) {
|
|
178
|
+
const span = (0, telemetry_js_1.startSpan)(this.name + "." + toolName, {
|
|
179
|
+
attributes: {
|
|
180
|
+
"span.type": "tool.call",
|
|
181
|
+
"tool.name": toolName,
|
|
182
|
+
"tool.args": JSON.stringify(args),
|
|
183
|
+
},
|
|
184
|
+
});
|
|
161
185
|
try {
|
|
162
186
|
logger_js_1.logger.debug(`MCP:${this.name}:Tool calling`, toolName, JSON.stringify(args));
|
|
163
187
|
logger_js_1.logger.debug(`MCP:${this.name}:Tool calling:start`);
|
|
@@ -171,6 +195,7 @@ class McpTool {
|
|
|
171
195
|
logger_js_1.logger.debug(`MCP:${this.name}:Tool calling:result`);
|
|
172
196
|
await this.close();
|
|
173
197
|
logger_js_1.logger.debug(`MCP:${this.name}:Tool result`, toolName, JSON.stringify(args));
|
|
198
|
+
span.setAttribute("tool.call.result", JSON.stringify(result));
|
|
174
199
|
return result;
|
|
175
200
|
}
|
|
176
201
|
catch (err) {
|
|
@@ -185,6 +210,9 @@ class McpTool {
|
|
|
185
210
|
}
|
|
186
211
|
throw err;
|
|
187
212
|
}
|
|
213
|
+
finally {
|
|
214
|
+
span.end();
|
|
215
|
+
}
|
|
188
216
|
}
|
|
189
217
|
async getTransport(forcedUrl) {
|
|
190
218
|
if (!this.transportName) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Agent } from "../client/index.js";
|
|
2
|
-
|
|
2
|
+
declare class BlAgent {
|
|
3
3
|
agentName: string;
|
|
4
4
|
constructor(agentName: string);
|
|
5
5
|
get fallbackUrl(): import("url").URL | null;
|
|
@@ -12,3 +12,4 @@ export declare class BlAgent {
|
|
|
12
12
|
}
|
|
13
13
|
export declare const blAgent: (agentName: string) => BlAgent;
|
|
14
14
|
export declare const getAgentMetadata: (agent: string) => Promise<Agent | null>;
|
|
15
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CreateJobExecutionRequest, JobExecution } from "../client/index.js";
|
|
2
|
-
|
|
2
|
+
declare class BlJob {
|
|
3
3
|
jobName: string;
|
|
4
4
|
constructor(jobName: string);
|
|
5
5
|
run(tasks: Record<string, unknown>[], options?: {
|
|
@@ -39,3 +39,4 @@ export declare class BlJob {
|
|
|
39
39
|
}): Promise<JobExecution>;
|
|
40
40
|
}
|
|
41
41
|
export declare const blJob: (jobName: string) => BlJob;
|
|
42
|
+
export {};
|
|
@@ -137,16 +137,9 @@ export type ProcessRequest = {
|
|
|
137
137
|
env?: {
|
|
138
138
|
[key: string]: string;
|
|
139
139
|
};
|
|
140
|
-
/**
|
|
141
|
-
* Disable scale-to-zero while process runs. Default timeout is 600s (10 minutes). Set timeout to 0 for infinite.
|
|
142
|
-
*/
|
|
143
|
-
keepAlive?: boolean;
|
|
144
140
|
maxRestarts?: number;
|
|
145
141
|
name?: string;
|
|
146
142
|
restartOnFailure?: boolean;
|
|
147
|
-
/**
|
|
148
|
-
* Timeout in seconds. When keepAlive is true, defaults to 600s (10 minutes). Set to 0 for infinite (no auto-kill).
|
|
149
|
-
*/
|
|
150
143
|
timeout?: number;
|
|
151
144
|
waitForCompletion?: boolean;
|
|
152
145
|
waitForPorts?: Array<number>;
|
|
@@ -156,10 +149,6 @@ export type ProcessResponse = {
|
|
|
156
149
|
command: string;
|
|
157
150
|
completedAt: string;
|
|
158
151
|
exitCode: number;
|
|
159
|
-
/**
|
|
160
|
-
* Whether scale-to-zero is disabled for this process
|
|
161
|
-
*/
|
|
162
|
-
keepAlive?: boolean;
|
|
163
152
|
logs: string;
|
|
164
153
|
maxRestarts?: number;
|
|
165
154
|
name: string;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Function } from "../client/client.js";
|
|
2
2
|
import { ToolOptions } from "./mcpTool.js";
|
|
3
3
|
import { Tool } from "./types.js";
|
|
4
|
-
export { McpTool } from "./mcpTool.js";
|
|
5
4
|
export type { ToolOptions };
|
|
6
5
|
export declare const getTool: (name: string, options?: number | ToolOptions) => Promise<Tool[]>;
|
|
7
6
|
export declare class BLTools {
|