@blaxel/core 0.2.73 → 0.2.74
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/interpreter.js +29 -40
- package/dist/cjs/sandbox/sandbox.js +3 -3
- package/dist/cjs/types/sandbox/interpreter.d.ts +1 -0
- package/dist/cjs-browser/.tsbuildinfo +1 -1
- package/dist/cjs-browser/common/settings.js +2 -2
- package/dist/cjs-browser/sandbox/interpreter.js +29 -40
- package/dist/cjs-browser/sandbox/sandbox.js +3 -3
- package/dist/cjs-browser/types/sandbox/interpreter.d.ts +1 -0
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/common/settings.js +2 -2
- package/dist/esm/sandbox/interpreter.js +29 -40
- package/dist/esm/sandbox/sandbox.js +3 -3
- package/dist/esm-browser/.tsbuildinfo +1 -1
- package/dist/esm-browser/common/settings.js +2 -2
- package/dist/esm-browser/sandbox/interpreter.js +29 -40
- package/dist/esm-browser/sandbox/sandbox.js +3 -3
- 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.
|
|
7
|
-
const BUILD_COMMIT = "
|
|
6
|
+
const BUILD_VERSION = "0.2.74";
|
|
7
|
+
const BUILD_COMMIT = "796e20f3a5a0e5f67783655f1d75250b32fd8694";
|
|
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;
|
|
@@ -29,54 +29,40 @@ export class CodeInterpreter extends SandboxInstance {
|
|
|
29
29
|
return new CodeInterpreter(config);
|
|
30
30
|
}
|
|
31
31
|
static async create(sandbox, { safe = true } = {}) {
|
|
32
|
-
|
|
32
|
+
// Build a SandboxCreateConfiguration with CodeInterpreter defaults
|
|
33
|
+
const defaults = {
|
|
33
34
|
image: CodeInterpreter.DEFAULT_IMAGE,
|
|
34
35
|
ports: CodeInterpreter.DEFAULT_PORTS,
|
|
35
36
|
lifecycle: CodeInterpreter.DEFAULT_LIFECYCLE,
|
|
36
37
|
};
|
|
37
|
-
|
|
38
|
-
if (sandbox && typeof sandbox === "object") {
|
|
39
|
-
if (
|
|
40
|
-
//
|
|
41
|
-
}
|
|
42
|
-
else if ("metadata" in sandbox || "spec" in sandbox) {
|
|
43
|
-
// It's a Sandbox object
|
|
38
|
+
let merged;
|
|
39
|
+
if (sandbox && typeof sandbox === "object" && !Array.isArray(sandbox)) {
|
|
40
|
+
if ("metadata" in sandbox || "spec" in sandbox) {
|
|
41
|
+
// It's a Sandbox object - inject defaults into spec
|
|
44
42
|
const sandboxObj = sandbox;
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
if (sandboxObj.spec.region) {
|
|
60
|
-
payload["region"] = sandboxObj.spec.region;
|
|
61
|
-
}
|
|
43
|
+
merged = {
|
|
44
|
+
...sandboxObj,
|
|
45
|
+
spec: {
|
|
46
|
+
...sandboxObj.spec,
|
|
47
|
+
runtime: {
|
|
48
|
+
image: defaults.image,
|
|
49
|
+
ports: defaults.ports,
|
|
50
|
+
...sandboxObj.spec?.runtime,
|
|
51
|
+
},
|
|
52
|
+
lifecycle: sandboxObj.spec?.lifecycle || defaults.lifecycle,
|
|
53
|
+
},
|
|
54
|
+
};
|
|
62
55
|
}
|
|
63
|
-
else
|
|
64
|
-
// It's a SandboxCreateConfiguration or dict-like object
|
|
65
|
-
|
|
66
|
-
for (const k of allowedCopyKeys) {
|
|
67
|
-
const value = sandboxDict[k];
|
|
68
|
-
if (value !== null && value !== undefined) {
|
|
69
|
-
payload[k] = value;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
56
|
+
else {
|
|
57
|
+
// It's a SandboxCreateConfiguration or dict-like object - merge with defaults
|
|
58
|
+
merged = { ...defaults, ...sandbox };
|
|
72
59
|
}
|
|
73
60
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
payload["region"] = settings.region;
|
|
61
|
+
else {
|
|
62
|
+
merged = defaults;
|
|
77
63
|
}
|
|
78
|
-
const baseInstance = await
|
|
79
|
-
// Create config from the instance
|
|
64
|
+
const baseInstance = await super.create(merged, { safe });
|
|
65
|
+
// Create config from the instance
|
|
80
66
|
const config = {
|
|
81
67
|
metadata: baseInstance.metadata,
|
|
82
68
|
spec: baseInstance.spec,
|
|
@@ -84,7 +70,7 @@ export class CodeInterpreter extends SandboxInstance {
|
|
|
84
70
|
events: baseInstance.events,
|
|
85
71
|
h2Session: baseInstance.h2Session,
|
|
86
72
|
};
|
|
87
|
-
// Preserve forceUrl and
|
|
73
|
+
// Preserve forceUrl, headers, and params from input if provided
|
|
88
74
|
if (sandbox && typeof sandbox === "object" && !Array.isArray(sandbox)) {
|
|
89
75
|
if ("forceUrl" in sandbox && typeof sandbox.forceUrl === "string") {
|
|
90
76
|
config.forceUrl = sandbox.forceUrl;
|
|
@@ -98,6 +84,9 @@ export class CodeInterpreter extends SandboxInstance {
|
|
|
98
84
|
}
|
|
99
85
|
return new CodeInterpreter(config);
|
|
100
86
|
}
|
|
87
|
+
static async createIfNotExists(sandbox) {
|
|
88
|
+
return await super.createIfNotExists(sandbox);
|
|
89
|
+
}
|
|
101
90
|
get _jupyterUrl() {
|
|
102
91
|
return this.process.url;
|
|
103
92
|
}
|
|
@@ -243,7 +243,7 @@ export class SandboxInstance {
|
|
|
243
243
|
}
|
|
244
244
|
static async createIfNotExists(sandbox) {
|
|
245
245
|
try {
|
|
246
|
-
return await
|
|
246
|
+
return await this.create(sandbox);
|
|
247
247
|
}
|
|
248
248
|
catch (e) {
|
|
249
249
|
if (typeof e === "object" && e !== null && "code" in e && (e.code === 409 || e.code === 'SANDBOX_ALREADY_EXISTS')) {
|
|
@@ -252,11 +252,11 @@ export class SandboxInstance {
|
|
|
252
252
|
throw new Error("Sandbox name is required");
|
|
253
253
|
}
|
|
254
254
|
// Get the existing sandbox to check its status
|
|
255
|
-
const sandboxInstance = await
|
|
255
|
+
const sandboxInstance = await this.get(name);
|
|
256
256
|
// If the sandbox is TERMINATED, treat it as not existing
|
|
257
257
|
if (sandboxInstance.status === "TERMINATED") {
|
|
258
258
|
// Create a new sandbox - backend will handle cleanup of the terminated one
|
|
259
|
-
return await
|
|
259
|
+
return await this.create(sandbox);
|
|
260
260
|
}
|
|
261
261
|
// Otherwise return the existing running sandbox
|
|
262
262
|
return sandboxInstance;
|