@blaxel/core 0.2.70-preview.99 → 0.2.71-dev.101
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 +2 -19
- package/dist/cjs/common/settings.js +2 -2
- package/dist/cjs/jobs/jobs.js +10 -28
- package/dist/cjs/mcp/server.js +4 -65
- package/dist/cjs/tools/index.js +3 -1
- package/dist/cjs/tools/mcpTool.js +15 -43
- package/dist/cjs/types/agents/index.d.ts +1 -2
- package/dist/cjs/types/jobs/jobs.d.ts +1 -2
- package/dist/cjs/types/sandbox/client/types.gen.d.ts +11 -0
- package/dist/cjs/types/tools/index.d.ts +1 -0
- package/dist/cjs-browser/.tsbuildinfo +1 -1
- package/dist/cjs-browser/agents/index.js +2 -19
- package/dist/cjs-browser/common/settings.js +2 -2
- package/dist/cjs-browser/jobs/jobs.js +10 -28
- package/dist/cjs-browser/mcp/server.js +4 -65
- package/dist/cjs-browser/tools/index.js +3 -1
- package/dist/cjs-browser/tools/mcpTool.js +15 -43
- package/dist/cjs-browser/types/agents/index.d.ts +1 -2
- package/dist/cjs-browser/types/jobs/jobs.d.ts +1 -2
- package/dist/cjs-browser/types/sandbox/client/types.gen.d.ts +11 -0
- package/dist/cjs-browser/types/tools/index.d.ts +1 -0
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/agents/index.js +1 -19
- package/dist/esm/common/settings.js +2 -2
- package/dist/esm/jobs/jobs.js +9 -28
- package/dist/esm/mcp/server.js +4 -65
- package/dist/esm/tools/index.js +1 -0
- package/dist/esm/tools/mcpTool.js +15 -43
- package/dist/esm-browser/.tsbuildinfo +1 -1
- package/dist/esm-browser/agents/index.js +1 -19
- package/dist/esm-browser/common/settings.js +2 -2
- package/dist/esm-browser/jobs/jobs.js +9 -28
- package/dist/esm-browser/mcp/server.js +4 -65
- package/dist/esm-browser/tools/index.js +1 -0
- package/dist/esm-browser/tools/mcpTool.js +15 -43
- package/package.json +1 -1
package/dist/cjs/agents/index.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getAgentMetadata = exports.blAgent = void 0;
|
|
3
|
+
exports.getAgentMetadata = exports.blAgent = 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");
|
|
10
9
|
class BlAgent {
|
|
11
10
|
agentName;
|
|
12
11
|
constructor(agentName) {
|
|
@@ -57,44 +56,28 @@ class BlAgent {
|
|
|
57
56
|
}
|
|
58
57
|
async run(input, headers = {}, params = {}) {
|
|
59
58
|
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
|
-
});
|
|
68
59
|
try {
|
|
69
60
|
const response = await this.call(this.url, input, headers, params);
|
|
70
|
-
span.setAttribute("agent.run.result", await response.text());
|
|
71
61
|
return await response.text();
|
|
72
62
|
}
|
|
73
63
|
catch (err) {
|
|
74
64
|
if (err instanceof Error) {
|
|
75
65
|
if (!this.fallbackUrl) {
|
|
76
|
-
span.setAttribute("agent.run.error", err.stack);
|
|
77
66
|
throw err;
|
|
78
67
|
}
|
|
79
68
|
try {
|
|
80
69
|
const response = await this.call(this.fallbackUrl, input, headers, params);
|
|
81
|
-
span.setAttribute("agent.run.result", await response.text());
|
|
82
70
|
return await response.text();
|
|
83
71
|
}
|
|
84
72
|
catch (err) {
|
|
85
|
-
if (err instanceof Error) {
|
|
86
|
-
span.setAttribute("agent.run.error", err.stack);
|
|
87
|
-
}
|
|
88
73
|
throw err;
|
|
89
74
|
}
|
|
90
75
|
}
|
|
91
76
|
throw err;
|
|
92
77
|
}
|
|
93
|
-
finally {
|
|
94
|
-
span.end();
|
|
95
|
-
}
|
|
96
78
|
}
|
|
97
79
|
}
|
|
80
|
+
exports.BlAgent = BlAgent;
|
|
98
81
|
const blAgent = (agentName) => {
|
|
99
82
|
return new BlAgent(agentName);
|
|
100
83
|
};
|
|
@@ -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.
|
|
13
|
-
const BUILD_COMMIT = "
|
|
12
|
+
const BUILD_VERSION = "0.2.71-dev.101";
|
|
13
|
+
const BUILD_COMMIT = "dccf33c2f51602cd1cd06116b55d326f4645465a";
|
|
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,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.blJob = void 0;
|
|
3
|
+
exports.blJob = 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");
|
|
8
7
|
class BlJob {
|
|
9
8
|
jobName;
|
|
10
9
|
constructor(jobName) {
|
|
@@ -12,32 +11,14 @@ class BlJob {
|
|
|
12
11
|
}
|
|
13
12
|
async run(tasks, options) {
|
|
14
13
|
logger_js_1.logger.debug(`Job Calling: ${this.jobName}`);
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
},
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
}
|
|
14
|
+
const request = {
|
|
15
|
+
tasks,
|
|
16
|
+
...(options?.env && { env: options.env }),
|
|
17
|
+
...(options?.memory && { memory: options.memory }),
|
|
18
|
+
...(options?.executionId && { executionId: options.executionId }),
|
|
19
|
+
};
|
|
20
|
+
const executionId = await this.createExecution(request);
|
|
21
|
+
return executionId;
|
|
41
22
|
}
|
|
42
23
|
/**
|
|
43
24
|
* Create a new execution for this job and return the execution ID
|
|
@@ -139,6 +120,7 @@ class BlJob {
|
|
|
139
120
|
throw new Error(`Execution ${executionId} did not complete within ${maxWait}ms`);
|
|
140
121
|
}
|
|
141
122
|
}
|
|
123
|
+
exports.BlJob = BlJob;
|
|
142
124
|
const blJob = (jobName) => {
|
|
143
125
|
return new BlJob(jobName);
|
|
144
126
|
};
|
package/dist/cjs/mcp/server.js
CHANGED
|
@@ -38,8 +38,6 @@ 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();
|
|
43
41
|
class BlaxelMcpServerTransport {
|
|
44
42
|
port;
|
|
45
43
|
wss;
|
|
@@ -74,26 +72,10 @@ class BlaxelMcpServerTransport {
|
|
|
74
72
|
ws,
|
|
75
73
|
});
|
|
76
74
|
this.onconnection?.(clientId);
|
|
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
|
-
});
|
|
75
|
+
ws.on("message", async (data) => {
|
|
85
76
|
try {
|
|
86
77
|
const msg = JSON.parse(data.toString());
|
|
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
|
-
}
|
|
78
|
+
await this.messageHandler?.(msg, clientId);
|
|
97
79
|
// Handle msg.id safely
|
|
98
80
|
const msgId = msg.id ? String(msg.id) : "";
|
|
99
81
|
const [cId, parsedMsgId] = msgId.split(":");
|
|
@@ -101,27 +83,7 @@ class BlaxelMcpServerTransport {
|
|
|
101
83
|
// Use optional chaining for safe access
|
|
102
84
|
const client = this.clients.get(cId ?? "");
|
|
103
85
|
if (client?.ws?.readyState === ws_1.default.OPEN) {
|
|
104
|
-
|
|
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
|
-
}
|
|
86
|
+
client.ws.send(JSON.stringify(msg));
|
|
125
87
|
}
|
|
126
88
|
else {
|
|
127
89
|
this.clients.delete(cId);
|
|
@@ -130,14 +92,11 @@ class BlaxelMcpServerTransport {
|
|
|
130
92
|
}
|
|
131
93
|
catch (err) {
|
|
132
94
|
if (err instanceof Error) {
|
|
133
|
-
span.setStatus("error"); // Error status
|
|
134
|
-
span.recordException(err);
|
|
135
95
|
this.onerror?.(err);
|
|
136
96
|
}
|
|
137
97
|
else {
|
|
138
98
|
this.onerror?.(new Error(`Failed to parse message: ${String(err)}`));
|
|
139
99
|
}
|
|
140
|
-
span.end();
|
|
141
100
|
}
|
|
142
101
|
});
|
|
143
102
|
ws.on("close", () => {
|
|
@@ -159,27 +118,7 @@ class BlaxelMcpServerTransport {
|
|
|
159
118
|
// Send to specific client
|
|
160
119
|
const client = this.clients.get(cId);
|
|
161
120
|
if (client?.ws?.readyState === ws_1.default.OPEN) {
|
|
162
|
-
|
|
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
|
-
}
|
|
121
|
+
client.ws.send(data);
|
|
183
122
|
}
|
|
184
123
|
else {
|
|
185
124
|
this.clients.delete(cId);
|
package/dist/cjs/tools/index.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getToolMetadata = exports.blTool = exports.blTools = exports.BLTools = exports.getTool = void 0;
|
|
3
|
+
exports.getToolMetadata = exports.blTool = exports.blTools = exports.BLTools = exports.getTool = exports.McpTool = 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; } });
|
|
8
10
|
const getTool = async (name, options) => {
|
|
9
11
|
return await (0, mcpTool_js_1.getMcpTool)(name, options);
|
|
10
12
|
};
|
|
@@ -9,7 +9,6 @@ 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");
|
|
13
12
|
const zodSchema_js_1 = require("./zodSchema.js");
|
|
14
13
|
const McpToolCache = new Map();
|
|
15
14
|
class McpTool {
|
|
@@ -141,47 +140,24 @@ class McpTool {
|
|
|
141
140
|
}
|
|
142
141
|
}
|
|
143
142
|
async listTools() {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
143
|
+
logger_js_1.logger.debug(`MCP:${this.name}:Listing tools`);
|
|
144
|
+
await this.start();
|
|
145
|
+
const { tools } = (await this.client.listTools());
|
|
146
|
+
await this.close();
|
|
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
|
+
};
|
|
148
157
|
});
|
|
149
|
-
|
|
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
|
-
}
|
|
158
|
+
return result;
|
|
176
159
|
}
|
|
177
160
|
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
|
-
});
|
|
185
161
|
try {
|
|
186
162
|
logger_js_1.logger.debug(`MCP:${this.name}:Tool calling`, toolName, JSON.stringify(args));
|
|
187
163
|
logger_js_1.logger.debug(`MCP:${this.name}:Tool calling:start`);
|
|
@@ -195,7 +171,6 @@ class McpTool {
|
|
|
195
171
|
logger_js_1.logger.debug(`MCP:${this.name}:Tool calling:result`);
|
|
196
172
|
await this.close();
|
|
197
173
|
logger_js_1.logger.debug(`MCP:${this.name}:Tool result`, toolName, JSON.stringify(args));
|
|
198
|
-
span.setAttribute("tool.call.result", JSON.stringify(result));
|
|
199
174
|
return result;
|
|
200
175
|
}
|
|
201
176
|
catch (err) {
|
|
@@ -210,9 +185,6 @@ class McpTool {
|
|
|
210
185
|
}
|
|
211
186
|
throw err;
|
|
212
187
|
}
|
|
213
|
-
finally {
|
|
214
|
-
span.end();
|
|
215
|
-
}
|
|
216
188
|
}
|
|
217
189
|
async getTransport(forcedUrl) {
|
|
218
190
|
if (!this.transportName) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Agent } from "../client/index.js";
|
|
2
|
-
declare class BlAgent {
|
|
2
|
+
export declare class BlAgent {
|
|
3
3
|
agentName: string;
|
|
4
4
|
constructor(agentName: string);
|
|
5
5
|
get fallbackUrl(): import("url").URL | null;
|
|
@@ -12,4 +12,3 @@ 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
|
-
declare class BlJob {
|
|
2
|
+
export declare class BlJob {
|
|
3
3
|
jobName: string;
|
|
4
4
|
constructor(jobName: string);
|
|
5
5
|
run(tasks: Record<string, unknown>[], options?: {
|
|
@@ -39,4 +39,3 @@ declare class BlJob {
|
|
|
39
39
|
}): Promise<JobExecution>;
|
|
40
40
|
}
|
|
41
41
|
export declare const blJob: (jobName: string) => BlJob;
|
|
42
|
-
export {};
|
|
@@ -137,9 +137,16 @@ 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;
|
|
140
144
|
maxRestarts?: number;
|
|
141
145
|
name?: string;
|
|
142
146
|
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
|
+
*/
|
|
143
150
|
timeout?: number;
|
|
144
151
|
waitForCompletion?: boolean;
|
|
145
152
|
waitForPorts?: Array<number>;
|
|
@@ -149,6 +156,10 @@ export type ProcessResponse = {
|
|
|
149
156
|
command: string;
|
|
150
157
|
completedAt: string;
|
|
151
158
|
exitCode: number;
|
|
159
|
+
/**
|
|
160
|
+
* Whether scale-to-zero is disabled for this process
|
|
161
|
+
*/
|
|
162
|
+
keepAlive?: boolean;
|
|
152
163
|
logs: string;
|
|
153
164
|
maxRestarts?: number;
|
|
154
165
|
name: string;
|
|
@@ -1,6 +1,7 @@
|
|
|
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";
|
|
4
5
|
export type { ToolOptions };
|
|
5
6
|
export declare const getTool: (name: string, options?: number | ToolOptions) => Promise<Tool[]>;
|
|
6
7
|
export declare class BLTools {
|