@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.
- package/dist/cjs/.tsbuildinfo +1 -1
- package/dist/cjs/common/settings.js +2 -2
- package/dist/cjs/sandbox/client/sdk.gen.js +44 -1
- package/dist/cjs/sandbox/index.js +1 -0
- package/dist/cjs/sandbox/preview.js +23 -0
- package/dist/cjs/sandbox/sandbox.js +3 -0
- package/dist/cjs/sandbox/system.js +20 -0
- package/dist/cjs/types/client/types.gen.d.ts +5 -1
- package/dist/cjs/types/sandbox/client/sdk.gen.d.ts +16 -1
- package/dist/cjs/types/sandbox/client/types.gen.d.ts +95 -0
- package/dist/cjs/types/sandbox/index.d.ts +1 -0
- package/dist/cjs/types/sandbox/preview.d.ts +1 -0
- package/dist/cjs/types/sandbox/sandbox.d.ts +2 -0
- package/dist/cjs/types/sandbox/system.d.ts +7 -0
- package/dist/cjs/volume/index.js +2 -0
- package/dist/cjs-browser/.tsbuildinfo +1 -1
- package/dist/cjs-browser/common/settings.js +2 -2
- package/dist/cjs-browser/sandbox/client/sdk.gen.js +44 -1
- package/dist/cjs-browser/sandbox/index.js +1 -0
- package/dist/cjs-browser/sandbox/preview.js +23 -0
- package/dist/cjs-browser/sandbox/sandbox.js +3 -0
- package/dist/cjs-browser/sandbox/system.js +20 -0
- package/dist/cjs-browser/types/client/types.gen.d.ts +5 -1
- package/dist/cjs-browser/types/sandbox/client/sdk.gen.d.ts +16 -1
- package/dist/cjs-browser/types/sandbox/client/types.gen.d.ts +95 -0
- package/dist/cjs-browser/types/sandbox/index.d.ts +1 -0
- package/dist/cjs-browser/types/sandbox/preview.d.ts +1 -0
- package/dist/cjs-browser/types/sandbox/sandbox.d.ts +2 -0
- package/dist/cjs-browser/types/sandbox/system.d.ts +7 -0
- package/dist/cjs-browser/volume/index.js +2 -0
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/common/settings.js +2 -2
- package/dist/esm/sandbox/client/sdk.gen.js +41 -0
- package/dist/esm/sandbox/index.js +1 -0
- package/dist/esm/sandbox/preview.js +23 -0
- package/dist/esm/sandbox/sandbox.js +3 -0
- package/dist/esm/sandbox/system.js +16 -0
- package/dist/esm/volume/index.js +2 -0
- package/dist/esm-browser/.tsbuildinfo +1 -1
- package/dist/esm-browser/common/settings.js +2 -2
- package/dist/esm-browser/sandbox/client/sdk.gen.js +41 -0
- package/dist/esm-browser/sandbox/index.js +1 -0
- package/dist/esm-browser/sandbox/preview.js +23 -0
- package/dist/esm-browser/sandbox/sandbox.js +3 -0
- package/dist/esm-browser/sandbox/system.js +16 -0
- package/dist/esm-browser/volume/index.js +2 -0
- 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
|
|
7
|
-
const BUILD_COMMIT = "
|
|
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) {
|