@blaxel/core 0.2.70 → 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.
Files changed (37) hide show
  1. package/dist/cjs/.tsbuildinfo +1 -1
  2. package/dist/cjs/agents/index.js +2 -19
  3. package/dist/cjs/common/settings.js +2 -2
  4. package/dist/cjs/jobs/jobs.js +10 -28
  5. package/dist/cjs/mcp/server.js +4 -65
  6. package/dist/cjs/tools/index.js +3 -1
  7. package/dist/cjs/tools/mcpTool.js +15 -43
  8. package/dist/cjs/types/agents/index.d.ts +1 -2
  9. package/dist/cjs/types/jobs/jobs.d.ts +1 -2
  10. package/dist/cjs/types/sandbox/client/types.gen.d.ts +11 -0
  11. package/dist/cjs/types/tools/index.d.ts +1 -0
  12. package/dist/cjs-browser/.tsbuildinfo +1 -1
  13. package/dist/cjs-browser/agents/index.js +2 -19
  14. package/dist/cjs-browser/common/settings.js +2 -2
  15. package/dist/cjs-browser/jobs/jobs.js +10 -28
  16. package/dist/cjs-browser/mcp/server.js +4 -65
  17. package/dist/cjs-browser/tools/index.js +3 -1
  18. package/dist/cjs-browser/tools/mcpTool.js +15 -43
  19. package/dist/cjs-browser/types/agents/index.d.ts +1 -2
  20. package/dist/cjs-browser/types/jobs/jobs.d.ts +1 -2
  21. package/dist/cjs-browser/types/sandbox/client/types.gen.d.ts +11 -0
  22. package/dist/cjs-browser/types/tools/index.d.ts +1 -0
  23. package/dist/esm/.tsbuildinfo +1 -1
  24. package/dist/esm/agents/index.js +1 -19
  25. package/dist/esm/common/settings.js +2 -2
  26. package/dist/esm/jobs/jobs.js +9 -28
  27. package/dist/esm/mcp/server.js +4 -65
  28. package/dist/esm/tools/index.js +1 -0
  29. package/dist/esm/tools/mcpTool.js +15 -43
  30. package/dist/esm-browser/.tsbuildinfo +1 -1
  31. package/dist/esm-browser/agents/index.js +1 -19
  32. package/dist/esm-browser/common/settings.js +2 -2
  33. package/dist/esm-browser/jobs/jobs.js +9 -28
  34. package/dist/esm-browser/mcp/server.js +4 -65
  35. package/dist/esm-browser/tools/index.js +1 -0
  36. package/dist/esm-browser/tools/mcpTool.js +15 -43
  37. package/package.json +1 -1
@@ -3,8 +3,7 @@ import { getAgent } from "../client/index.js";
3
3
  import { getForcedUrl, getGlobalUniqueHash } from "../common/internal.js";
4
4
  import { logger } from "../common/logger.js";
5
5
  import { settings } from "../common/settings.js";
6
- import { startSpan } from '../telemetry/telemetry.js';
7
- class BlAgent {
6
+ export class BlAgent {
8
7
  agentName;
9
8
  constructor(agentName) {
10
9
  this.agentName = agentName;
@@ -54,42 +53,25 @@ class BlAgent {
54
53
  }
55
54
  async run(input, headers = {}, params = {}) {
56
55
  logger.debug(`Agent Calling: ${this.agentName}`);
57
- const span = startSpan(this.agentName, {
58
- attributes: {
59
- "agent.name": this.agentName,
60
- "agent.args": JSON.stringify(input),
61
- "span.type": "agent.run",
62
- },
63
- isRoot: false,
64
- });
65
56
  try {
66
57
  const response = await this.call(this.url, input, headers, params);
67
- span.setAttribute("agent.run.result", await response.text());
68
58
  return await response.text();
69
59
  }
70
60
  catch (err) {
71
61
  if (err instanceof Error) {
72
62
  if (!this.fallbackUrl) {
73
- span.setAttribute("agent.run.error", err.stack);
74
63
  throw err;
75
64
  }
76
65
  try {
77
66
  const response = await this.call(this.fallbackUrl, input, headers, params);
78
- span.setAttribute("agent.run.result", await response.text());
79
67
  return await response.text();
80
68
  }
81
69
  catch (err) {
82
- if (err instanceof Error) {
83
- span.setAttribute("agent.run.error", err.stack);
84
- }
85
70
  throw err;
86
71
  }
87
72
  }
88
73
  throw err;
89
74
  }
90
- finally {
91
- span.end();
92
- }
93
75
  }
94
76
  }
95
77
  export const blAgent = (agentName) => {
@@ -3,8 +3,8 @@ import { authentication } from "../authentication/index.js";
3
3
  import { env } from "../common/env.js";
4
4
  import { fs, os, path } from "../common/node.js";
5
5
  // Build info - these placeholders are replaced at build time by build:replace-imports
6
- const BUILD_VERSION = "0.2.70";
7
- const BUILD_COMMIT = "a3bbb13aa4ec149d33f1662d30dfb10ce3683baf";
6
+ const BUILD_VERSION = "0.2.71-dev.101";
7
+ const BUILD_COMMIT = "dccf33c2f51602cd1cd06116b55d326f4645465a";
8
8
  const BUILD_SENTRY_DSN = "https://fd5e60e1c9820e1eef5ccebb84a07127@o4508714045276160.ingest.us.sentry.io/4510465864564736";
9
9
  // Cache for config.yaml tracking value
10
10
  let configTrackingValue = null;
@@ -1,40 +1,21 @@
1
1
  import { createJobExecution, deleteJobExecution, getJobExecution, listJobExecutions, } from "../client/index.js";
2
2
  import { logger } from "../common/logger.js";
3
3
  import { settings } from "../common/settings.js";
4
- import { startSpan } from "../telemetry/telemetry.js";
5
- class BlJob {
4
+ export class BlJob {
6
5
  jobName;
7
6
  constructor(jobName) {
8
7
  this.jobName = jobName;
9
8
  }
10
9
  async run(tasks, options) {
11
10
  logger.debug(`Job Calling: ${this.jobName}`);
12
- const span = startSpan(this.jobName, {
13
- attributes: {
14
- "job.name": this.jobName,
15
- "span.type": "job.run",
16
- },
17
- isRoot: false,
18
- });
19
- try {
20
- const request = {
21
- tasks,
22
- ...(options?.env && { env: options.env }),
23
- ...(options?.memory && { memory: options.memory }),
24
- ...(options?.executionId && { executionId: options.executionId }),
25
- };
26
- const executionId = await this.createExecution(request);
27
- return executionId;
28
- }
29
- catch (err) {
30
- if (err instanceof Error) {
31
- span.setAttribute("job.run.error", err.stack);
32
- }
33
- throw err;
34
- }
35
- finally {
36
- span.end();
37
- }
11
+ const request = {
12
+ tasks,
13
+ ...(options?.env && { env: options.env }),
14
+ ...(options?.memory && { memory: options.memory }),
15
+ ...(options?.executionId && { executionId: options.executionId }),
16
+ };
17
+ const executionId = await this.createExecution(request);
18
+ return executionId;
38
19
  }
39
20
  /**
40
21
  * Create a new execution for this job and return the execution ID
@@ -2,8 +2,6 @@ import { v4 as uuidv4 } from "uuid";
2
2
  import WebSocket, { WebSocketServer } from "ws";
3
3
  import { env } from "../common/env.js";
4
4
  import { logger } from "../common/logger.js";
5
- import { startSpan } from "../telemetry/telemetry.js";
6
- const spans = new Map();
7
5
  export class BlaxelMcpServerTransport {
8
6
  port;
9
7
  wss;
@@ -38,26 +36,10 @@ export class BlaxelMcpServerTransport {
38
36
  ws,
39
37
  });
40
38
  this.onconnection?.(clientId);
41
- ws.on("message", (data) => {
42
- const span = startSpan("message", {
43
- attributes: {
44
- "mcp.client.id": clientId,
45
- "span.type": "mcp.message",
46
- },
47
- isRoot: false,
48
- });
39
+ ws.on("message", async (data) => {
49
40
  try {
50
41
  const msg = JSON.parse(data.toString());
51
- this.messageHandler?.(msg, clientId);
52
- if ("method" in msg && "id" in msg && "params" in msg) {
53
- span.setAttributes({
54
- "mcp.message.parsed": true,
55
- "mcp.method": msg.method,
56
- "mcp.messageId": msg.id,
57
- "mcp.toolName": msg.params?.name,
58
- });
59
- spans.set(clientId + ":" + msg.id, span);
60
- }
42
+ await this.messageHandler?.(msg, clientId);
61
43
  // Handle msg.id safely
62
44
  const msgId = msg.id ? String(msg.id) : "";
63
45
  const [cId, parsedMsgId] = msgId.split(":");
@@ -65,27 +47,7 @@ export class BlaxelMcpServerTransport {
65
47
  // Use optional chaining for safe access
66
48
  const client = this.clients.get(cId ?? "");
67
49
  if (client?.ws?.readyState === WebSocket.OPEN) {
68
- const msgSpan = spans.get(cId + ":" + (msg.id ?? ""));
69
- try {
70
- client.ws.send(JSON.stringify(msg));
71
- if (msgSpan) {
72
- msgSpan.setAttributes({
73
- "mcp.message.response_sent": true,
74
- });
75
- }
76
- }
77
- catch (err) {
78
- if (msgSpan) {
79
- msgSpan.setStatus("error"); // Error status
80
- msgSpan.recordException(err);
81
- }
82
- throw err;
83
- }
84
- finally {
85
- if (msgSpan) {
86
- msgSpan.end();
87
- }
88
- }
50
+ client.ws.send(JSON.stringify(msg));
89
51
  }
90
52
  else {
91
53
  this.clients.delete(cId);
@@ -94,14 +56,11 @@ export class BlaxelMcpServerTransport {
94
56
  }
95
57
  catch (err) {
96
58
  if (err instanceof Error) {
97
- span.setStatus("error"); // Error status
98
- span.recordException(err);
99
59
  this.onerror?.(err);
100
60
  }
101
61
  else {
102
62
  this.onerror?.(new Error(`Failed to parse message: ${String(err)}`));
103
63
  }
104
- span.end();
105
64
  }
106
65
  });
107
66
  ws.on("close", () => {
@@ -123,27 +82,7 @@ export class BlaxelMcpServerTransport {
123
82
  // Send to specific client
124
83
  const client = this.clients.get(cId);
125
84
  if (client?.ws?.readyState === WebSocket.OPEN) {
126
- const msgSpan = spans.get(cId + ":" + msg.id);
127
- try {
128
- client.ws.send(data);
129
- if (msgSpan) {
130
- msgSpan.setAttributes({
131
- "mcp.message.response_sent": true,
132
- });
133
- }
134
- }
135
- catch (err) {
136
- if (msgSpan) {
137
- msgSpan.setStatus("error"); // Error status
138
- msgSpan.recordException(err);
139
- }
140
- throw err;
141
- }
142
- finally {
143
- if (msgSpan) {
144
- msgSpan.end();
145
- }
146
- }
85
+ client.ws.send(data);
147
86
  }
148
87
  else {
149
88
  this.clients.delete(cId);
@@ -2,6 +2,7 @@ import { findFromCache } from "../cache/index.js";
2
2
  import { getFunction } from "../client/client.js";
3
3
  import { getForcedUrl } from "../common/internal.js";
4
4
  import { getMcpTool } from "./mcpTool.js";
5
+ export { McpTool } from "./mcpTool.js";
5
6
  export const getTool = async (name, options) => {
6
7
  return await getMcpTool(name, options);
7
8
  };
@@ -6,7 +6,6 @@ import { logger } from "../common/logger.js";
6
6
  import { settings } from "../common/settings.js";
7
7
  import { authenticate, SandboxInstance } from "../index.js";
8
8
  import { BlaxelMcpClientTransport } from "../mcp/client.js";
9
- import { startSpan } from "../telemetry/telemetry.js";
10
9
  import { schemaToZodSchema } from "./zodSchema.js";
11
10
  const McpToolCache = new Map();
12
11
  export class McpTool {
@@ -138,47 +137,24 @@ export class McpTool {
138
137
  }
139
138
  }
140
139
  async listTools() {
141
- const span = startSpan(this.name, {
142
- attributes: {
143
- "span.type": "tool.list",
144
- },
140
+ logger.debug(`MCP:${this.name}:Listing tools`);
141
+ await this.start();
142
+ const { tools } = (await this.client.listTools());
143
+ await this.close();
144
+ const result = tools.map((tool) => {
145
+ return {
146
+ name: tool.name,
147
+ description: tool.description,
148
+ inputSchema: schemaToZodSchema(tool.inputSchema),
149
+ originalSchema: tool.inputSchema,
150
+ call: (input) => {
151
+ return this.call(tool.name, input);
152
+ },
153
+ };
145
154
  });
146
- try {
147
- logger.debug(`MCP:${this.name}:Listing tools`);
148
- await this.start();
149
- const { tools } = (await this.client.listTools());
150
- await this.close();
151
- const result = tools.map((tool) => {
152
- return {
153
- name: tool.name,
154
- description: tool.description,
155
- inputSchema: schemaToZodSchema(tool.inputSchema),
156
- originalSchema: tool.inputSchema,
157
- call: (input) => {
158
- return this.call(tool.name, input);
159
- },
160
- };
161
- });
162
- span.setAttribute("tool.list.result", JSON.stringify(result));
163
- return result;
164
- }
165
- catch (err) {
166
- span.setStatus("error");
167
- span.recordException(err);
168
- throw err;
169
- }
170
- finally {
171
- span.end();
172
- }
155
+ return result;
173
156
  }
174
157
  async call(toolName, args) {
175
- const span = startSpan(this.name + "." + toolName, {
176
- attributes: {
177
- "span.type": "tool.call",
178
- "tool.name": toolName,
179
- "tool.args": JSON.stringify(args),
180
- },
181
- });
182
158
  try {
183
159
  logger.debug(`MCP:${this.name}:Tool calling`, toolName, JSON.stringify(args));
184
160
  logger.debug(`MCP:${this.name}:Tool calling:start`);
@@ -192,7 +168,6 @@ export class McpTool {
192
168
  logger.debug(`MCP:${this.name}:Tool calling:result`);
193
169
  await this.close();
194
170
  logger.debug(`MCP:${this.name}:Tool result`, toolName, JSON.stringify(args));
195
- span.setAttribute("tool.call.result", JSON.stringify(result));
196
171
  return result;
197
172
  }
198
173
  catch (err) {
@@ -207,9 +182,6 @@ export class McpTool {
207
182
  }
208
183
  throw err;
209
184
  }
210
- finally {
211
- span.end();
212
- }
213
185
  }
214
186
  async getTransport(forcedUrl) {
215
187
  if (!this.transportName) {