@blaxel/core 0.2.64-preview.73 → 0.2.64

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 (47) hide show
  1. package/dist/cjs/.tsbuildinfo +1 -1
  2. package/dist/cjs/common/settings.js +2 -2
  3. package/dist/cjs/sandbox/client/sdk.gen.js +44 -1
  4. package/dist/cjs/sandbox/index.js +1 -0
  5. package/dist/cjs/sandbox/preview.js +23 -0
  6. package/dist/cjs/sandbox/sandbox.js +3 -0
  7. package/dist/cjs/sandbox/system.js +20 -0
  8. package/dist/cjs/types/client/types.gen.d.ts +5 -1
  9. package/dist/cjs/types/sandbox/client/sdk.gen.d.ts +16 -1
  10. package/dist/cjs/types/sandbox/client/types.gen.d.ts +95 -0
  11. package/dist/cjs/types/sandbox/index.d.ts +1 -0
  12. package/dist/cjs/types/sandbox/preview.d.ts +1 -0
  13. package/dist/cjs/types/sandbox/sandbox.d.ts +2 -0
  14. package/dist/cjs/types/sandbox/system.d.ts +7 -0
  15. package/dist/cjs/volume/index.js +2 -0
  16. package/dist/cjs-browser/.tsbuildinfo +1 -1
  17. package/dist/cjs-browser/common/settings.js +2 -2
  18. package/dist/cjs-browser/sandbox/client/sdk.gen.js +44 -1
  19. package/dist/cjs-browser/sandbox/index.js +1 -0
  20. package/dist/cjs-browser/sandbox/preview.js +23 -0
  21. package/dist/cjs-browser/sandbox/sandbox.js +3 -0
  22. package/dist/cjs-browser/sandbox/system.js +20 -0
  23. package/dist/cjs-browser/types/client/types.gen.d.ts +5 -1
  24. package/dist/cjs-browser/types/sandbox/client/sdk.gen.d.ts +16 -1
  25. package/dist/cjs-browser/types/sandbox/client/types.gen.d.ts +95 -0
  26. package/dist/cjs-browser/types/sandbox/index.d.ts +1 -0
  27. package/dist/cjs-browser/types/sandbox/preview.d.ts +1 -0
  28. package/dist/cjs-browser/types/sandbox/sandbox.d.ts +2 -0
  29. package/dist/cjs-browser/types/sandbox/system.d.ts +7 -0
  30. package/dist/cjs-browser/volume/index.js +2 -0
  31. package/dist/esm/.tsbuildinfo +1 -1
  32. package/dist/esm/common/settings.js +2 -2
  33. package/dist/esm/sandbox/client/sdk.gen.js +41 -0
  34. package/dist/esm/sandbox/index.js +1 -0
  35. package/dist/esm/sandbox/preview.js +23 -0
  36. package/dist/esm/sandbox/sandbox.js +3 -0
  37. package/dist/esm/sandbox/system.js +16 -0
  38. package/dist/esm/volume/index.js +2 -0
  39. package/dist/esm-browser/.tsbuildinfo +1 -1
  40. package/dist/esm-browser/common/settings.js +2 -2
  41. package/dist/esm-browser/sandbox/client/sdk.gen.js +41 -0
  42. package/dist/esm-browser/sandbox/index.js +1 -0
  43. package/dist/esm-browser/sandbox/preview.js +23 -0
  44. package/dist/esm-browser/sandbox/sandbox.js +3 -0
  45. package/dist/esm-browser/sandbox/system.js +16 -0
  46. package/dist/esm-browser/volume/index.js +2 -0
  47. package/package.json +1 -1
@@ -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.64-preview.73";
7
- const BUILD_COMMIT = "3150b4697960882ea382e8b84c6cd5b297806c28";
6
+ const BUILD_VERSION = "0.2.64";
7
+ const BUILD_COMMIT = "7443ee7bede975319d35683d26daf39073323b14";
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;
@@ -329,6 +329,23 @@ export const putFilesystemTreeByPath = (options) => {
329
329
  }
330
330
  });
331
331
  };
332
+ /**
333
+ * Health check
334
+ * Returns health status and system information including upgrade count and binary details
335
+ * Also includes last upgrade attempt status with detailed error information if available
336
+ */
337
+ export const getHealth = (options) => {
338
+ return (options?.client ?? _heyApiClient).get({
339
+ security: [
340
+ {
341
+ scheme: 'bearer',
342
+ type: 'http'
343
+ }
344
+ ],
345
+ url: '/health',
346
+ ...options
347
+ });
348
+ };
332
349
  /**
333
350
  * Stop monitoring ports for a process
334
351
  * Stop monitoring for new ports opened by a process
@@ -497,6 +514,30 @@ export const getProcessByIdentifierLogsStream = (options) => {
497
514
  ...options
498
515
  });
499
516
  };
517
+ /**
518
+ * Upgrade the sandbox-api
519
+ * Triggers an upgrade of the sandbox-api process. Returns 200 immediately before upgrading.
520
+ * The upgrade will: download the specified binary from GitHub releases, validate it, and restart.
521
+ * All running processes will be preserved across the upgrade.
522
+ * Available versions: "develop" (default), "main", "latest", or specific tag like "v1.0.0"
523
+ * You can also specify a custom baseUrl for forks (defaults to https://github.com/blaxel-ai/sandbox/releases)
524
+ */
525
+ export const postUpgrade = (options) => {
526
+ return (options?.client ?? _heyApiClient).post({
527
+ security: [
528
+ {
529
+ scheme: 'bearer',
530
+ type: 'http'
531
+ }
532
+ ],
533
+ url: '/upgrade',
534
+ ...options,
535
+ headers: {
536
+ 'Content-Type': 'application/json',
537
+ ...options?.headers
538
+ }
539
+ });
540
+ };
500
541
  /**
501
542
  * Stream file modification events in a directory
502
543
  * Streams the path of modified files (one per line) in the given directory. Closes when the client disconnects.
@@ -4,6 +4,7 @@ deleteFilesystemByPath, deleteNetworkProcessByPidMonitor, deleteProcessByIdentif
4
4
  export * from "./filesystem/index.js";
5
5
  export * from "./codegen/index.js";
6
6
  export * from "./sandbox.js";
7
+ export * from "./system.js";
7
8
  export * from "./types.js";
8
9
  export * from "./interpreter.js";
9
10
  // Re-export everything from client except ClientOptions to avoid conflict
@@ -139,6 +139,29 @@ export class SandboxPreviews {
139
139
  },
140
140
  throwOnError: true,
141
141
  });
142
+ if (data.status === 'DELETING') {
143
+ await this.waitForDeletion(previewName);
144
+ }
142
145
  return data;
143
146
  }
147
+ async waitForDeletion(previewName, timeoutMs = 10000) {
148
+ console.log(`Waiting for preview deletion: ${previewName}`);
149
+ const pollInterval = 500; // Poll every 500ms
150
+ const startTime = Date.now();
151
+ while (Date.now() - startTime < timeoutMs) {
152
+ const { response } = await getSandboxPreview({
153
+ path: {
154
+ sandboxName: this.sandboxName,
155
+ previewName,
156
+ },
157
+ });
158
+ if (response.status === 404) {
159
+ return;
160
+ }
161
+ // Preview still exists, wait and retry
162
+ await new Promise(resolve => setTimeout(resolve, pollInterval));
163
+ }
164
+ // Timeout reached, but deletion was initiated
165
+ throw new Error(`Preview deletion timeout: ${previewName} is still in DELETING state after ${timeoutMs}ms`);
166
+ }
144
167
  }
@@ -8,6 +8,7 @@ import { SandboxNetwork } from "./network/index.js";
8
8
  import { SandboxPreviews } from "./preview.js";
9
9
  import { SandboxProcess } from "./process/index.js";
10
10
  import { SandboxSessions } from "./session.js";
11
+ import { SandboxSystem } from "./system.js";
11
12
  import { normalizeEnvs, normalizePorts, normalizeVolumes } from "./types.js";
12
13
  export class SandboxInstance {
13
14
  sandbox;
@@ -17,6 +18,7 @@ export class SandboxInstance {
17
18
  previews;
18
19
  sessions;
19
20
  codegen;
21
+ system;
20
22
  constructor(sandbox) {
21
23
  this.sandbox = sandbox;
22
24
  this.process = new SandboxProcess(sandbox);
@@ -25,6 +27,7 @@ export class SandboxInstance {
25
27
  this.previews = new SandboxPreviews(sandbox);
26
28
  this.sessions = new SandboxSessions(sandbox);
27
29
  this.codegen = new SandboxCodegen(sandbox);
30
+ this.system = new SandboxSystem(sandbox);
28
31
  }
29
32
  get metadata() {
30
33
  return this.sandbox.metadata;
@@ -0,0 +1,16 @@
1
+ import { SandboxAction } from "./action.js";
2
+ import { postUpgrade } from "./client/index.js";
3
+ export class SandboxSystem extends SandboxAction {
4
+ constructor(sandbox) {
5
+ super(sandbox);
6
+ }
7
+ async upgrade(body) {
8
+ const { response, data, error } = await postUpgrade({
9
+ baseUrl: this.url,
10
+ client: this.client,
11
+ body,
12
+ });
13
+ this.handleResponseError(response, data, error);
14
+ return data;
15
+ }
16
+ }
@@ -154,6 +154,8 @@ export class VolumeInstance {
154
154
  status: data.status,
155
155
  terminatedAt: data.terminatedAt,
156
156
  };
157
+ // This is for safe update
158
+ await new Promise(resolve => setTimeout(resolve, 500));
157
159
  return new VolumeInstance(newVolume);
158
160
  }
159
161
  async update(updates) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blaxel/core",
3
- "version": "0.2.64-preview.73",
3
+ "version": "0.2.64",
4
4
  "description": "Blaxel Core SDK for TypeScript",
5
5
  "license": "MIT",
6
6
  "author": "Blaxel, INC (https://blaxel.ai)",