@blaxel/core 0.2.49-dev.212 → 0.2.49-dev.214

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.
@@ -10,7 +10,7 @@ function getPackageVersion() {
10
10
  if (typeof require !== "undefined") {
11
11
  // Try to require package.json (Node.js only, gracefully fails in browser)
12
12
  // eslint-disable-next-line @typescript-eslint/no-require-imports
13
- const packageJson = {"version":"0.2.49-dev.212","commit":"ffb14f0cc60bc71b20a21fe8bd537e30dd7616d0"};
13
+ const packageJson = {"version":"0.2.49-dev.214","commit":"3cd25c395e498b34304684d4d76a906f2cef14a9"};
14
14
  return packageJson.version || "unknown";
15
15
  }
16
16
  else {
@@ -62,7 +62,7 @@ function getCommitHash() {
62
62
  if (typeof require !== "undefined") {
63
63
  // Try to require package.json and look for commit field (set during build)
64
64
  // eslint-disable-next-line @typescript-eslint/no-require-imports
65
- const packageJson = {"version":"0.2.49-dev.212","commit":"ffb14f0cc60bc71b20a21fe8bd537e30dd7616d0"};
65
+ const packageJson = {"version":"0.2.49-dev.214","commit":"3cd25c395e498b34304684d4d76a906f2cef14a9"};
66
66
  // Check for commit in various possible locations
67
67
  const commit = packageJson.commit || packageJson.buildInfo?.commit;
68
68
  if (commit) {
@@ -5,12 +5,43 @@ const autoload_js_1 = require("../common/autoload.js");
5
5
  const env_js_1 = require("../common/env.js");
6
6
  const telemetry_js_1 = require("../telemetry/telemetry.js");
7
7
  class BlJobWrapper {
8
+ async fetchWithRetry(url, maxRetries = 3) {
9
+ let lastError;
10
+ for (let attempt = 0; attempt <= maxRetries; attempt++) {
11
+ try {
12
+ const response = await fetch(url);
13
+ // If the response is successful, return it
14
+ if (response.ok) {
15
+ return response;
16
+ }
17
+ // If it's not the last attempt and the status is retriable, retry
18
+ if (attempt < maxRetries && (response.status >= 500 || response.status === 429)) {
19
+ lastError = new Error(`HTTP ${response.status}: ${response.statusText}`);
20
+ }
21
+ else {
22
+ // For non-retriable errors or last attempt, return the response
23
+ return response;
24
+ }
25
+ }
26
+ catch (error) {
27
+ lastError = error instanceof Error ? error : new Error(String(error));
28
+ // If this is the last attempt, throw the error
29
+ if (attempt === maxRetries) {
30
+ throw lastError;
31
+ }
32
+ }
33
+ // Calculate exponential backoff delay: 2^attempt * 1000ms (1s, 2s, 4s)
34
+ const delay = Math.pow(2, attempt) * 1000;
35
+ await new Promise(resolve => setTimeout(resolve, delay));
36
+ }
37
+ throw lastError || new Error('Failed to fetch after retries');
38
+ }
8
39
  async getArguments() {
9
40
  if (!env_js_1.env.BL_EXECUTION_DATA_URL) {
10
41
  const args = this.parseCommandLineArgs();
11
42
  return args;
12
43
  }
13
- const response = await fetch(env_js_1.env.BL_EXECUTION_DATA_URL);
44
+ const response = await this.fetchWithRetry(env_js_1.env.BL_EXECUTION_DATA_URL);
14
45
  const data = await response.json();
15
46
  return data.tasks[this.index] ?? {};
16
47
  }
@@ -110,7 +110,7 @@ class SandboxProcessWebSocket extends action_js_1.SandboxAction {
110
110
  }
111
111
  async list() {
112
112
  const data = await this.wsClient.send("process:list", {});
113
- return data;
113
+ return data.processes || [];
114
114
  }
115
115
  async stop(identifier) {
116
116
  const data = await this.wsClient.send("process:stop", { identifier });
@@ -3,11 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.WebSocketClient = void 0;
4
4
  const uuid_1 = require("uuid");
5
5
  const node_js_1 = require("../../common/node.js");
6
+ const settings_js_1 = require("../../common/settings.js");
6
7
  class WebSocketClient {
7
8
  ws = null;
8
9
  WebSocketClass = null;
9
10
  url;
10
- headers;
11
11
  reconnect;
12
12
  reconnectInterval;
13
13
  maxReconnectAttempts;
@@ -21,7 +21,6 @@ class WebSocketClient {
21
21
  lastPongReceived = Date.now();
22
22
  constructor(options) {
23
23
  this.url = options.url;
24
- this.headers = options.headers || {};
25
24
  this.reconnect = options.reconnect ?? true;
26
25
  this.reconnectInterval = options.reconnectInterval ?? 5000;
27
26
  this.maxReconnectAttempts = options.maxReconnectAttempts ?? 5;
@@ -55,14 +54,9 @@ class WebSocketClient {
55
54
  if (!wsUrl.endsWith("/ws")) {
56
55
  wsUrl = `${wsUrl}/ws`;
57
56
  }
58
- // Create WebSocket with headers (if supported by the environment)
59
- const wsOptions = {};
60
- if (Object.keys(this.headers).length > 0) {
61
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
62
- wsOptions.headers = this.headers;
63
- }
57
+ wsUrl = `${wsUrl}?token=${settings_js_1.settings.token}`;
64
58
  // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call
65
- this.ws = new this.WebSocketClass(wsUrl, wsOptions);
59
+ this.ws = new this.WebSocketClass(wsUrl);
66
60
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
67
61
  this.ws.onopen = () => {
68
62
  this.reconnectAttempts = 0;
@@ -23,7 +23,6 @@ export declare class WebSocketClient {
23
23
  private ws;
24
24
  private WebSocketClass;
25
25
  private url;
26
- private headers;
27
26
  private reconnect;
28
27
  private reconnectInterval;
29
28
  private maxReconnectAttempts;