@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
|
@@ -9,8 +9,8 @@ const index_js_1 = require("../authentication/index.js");
|
|
|
9
9
|
const env_js_1 = require("../common/env.js");
|
|
10
10
|
const node_js_1 = require("../common/node.js");
|
|
11
11
|
// Build info - these placeholders are replaced at build time by build:replace-imports
|
|
12
|
-
const BUILD_VERSION = "0.2.
|
|
13
|
-
const BUILD_COMMIT = "
|
|
12
|
+
const BUILD_VERSION = "0.2.74";
|
|
13
|
+
const BUILD_COMMIT = "796e20f3a5a0e5f67783655f1d75250b32fd8694";
|
|
14
14
|
const BUILD_SENTRY_DSN = "https://fd5e60e1c9820e1eef5ccebb84a07127@o4508714045276160.ingest.us.sentry.io/4510465864564736";
|
|
15
15
|
// Cache for config.yaml tracking value
|
|
16
16
|
let configTrackingValue = null;
|
|
@@ -32,54 +32,40 @@ class CodeInterpreter extends sandbox_js_1.SandboxInstance {
|
|
|
32
32
|
return new CodeInterpreter(config);
|
|
33
33
|
}
|
|
34
34
|
static async create(sandbox, { safe = true } = {}) {
|
|
35
|
-
|
|
35
|
+
// Build a SandboxCreateConfiguration with CodeInterpreter defaults
|
|
36
|
+
const defaults = {
|
|
36
37
|
image: CodeInterpreter.DEFAULT_IMAGE,
|
|
37
38
|
ports: CodeInterpreter.DEFAULT_PORTS,
|
|
38
39
|
lifecycle: CodeInterpreter.DEFAULT_LIFECYCLE,
|
|
39
40
|
};
|
|
40
|
-
|
|
41
|
-
if (sandbox && typeof sandbox === "object") {
|
|
42
|
-
if (
|
|
43
|
-
//
|
|
44
|
-
}
|
|
45
|
-
else if ("metadata" in sandbox || "spec" in sandbox) {
|
|
46
|
-
// It's a Sandbox object
|
|
41
|
+
let merged;
|
|
42
|
+
if (sandbox && typeof sandbox === "object" && !Array.isArray(sandbox)) {
|
|
43
|
+
if ("metadata" in sandbox || "spec" in sandbox) {
|
|
44
|
+
// It's a Sandbox object - inject defaults into spec
|
|
47
45
|
const sandboxObj = sandbox;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
if (sandboxObj.spec.region) {
|
|
63
|
-
payload["region"] = sandboxObj.spec.region;
|
|
64
|
-
}
|
|
46
|
+
merged = {
|
|
47
|
+
...sandboxObj,
|
|
48
|
+
spec: {
|
|
49
|
+
...sandboxObj.spec,
|
|
50
|
+
runtime: {
|
|
51
|
+
image: defaults.image,
|
|
52
|
+
ports: defaults.ports,
|
|
53
|
+
...sandboxObj.spec?.runtime,
|
|
54
|
+
},
|
|
55
|
+
lifecycle: sandboxObj.spec?.lifecycle || defaults.lifecycle,
|
|
56
|
+
},
|
|
57
|
+
};
|
|
65
58
|
}
|
|
66
|
-
else
|
|
67
|
-
// It's a SandboxCreateConfiguration or dict-like object
|
|
68
|
-
|
|
69
|
-
for (const k of allowedCopyKeys) {
|
|
70
|
-
const value = sandboxDict[k];
|
|
71
|
-
if (value !== null && value !== undefined) {
|
|
72
|
-
payload[k] = value;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
59
|
+
else {
|
|
60
|
+
// It's a SandboxCreateConfiguration or dict-like object - merge with defaults
|
|
61
|
+
merged = { ...defaults, ...sandbox };
|
|
75
62
|
}
|
|
76
63
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
payload["region"] = settings_js_1.settings.region;
|
|
64
|
+
else {
|
|
65
|
+
merged = defaults;
|
|
80
66
|
}
|
|
81
|
-
const baseInstance = await
|
|
82
|
-
// Create config from the instance
|
|
67
|
+
const baseInstance = await super.create(merged, { safe });
|
|
68
|
+
// Create config from the instance
|
|
83
69
|
const config = {
|
|
84
70
|
metadata: baseInstance.metadata,
|
|
85
71
|
spec: baseInstance.spec,
|
|
@@ -87,7 +73,7 @@ class CodeInterpreter extends sandbox_js_1.SandboxInstance {
|
|
|
87
73
|
events: baseInstance.events,
|
|
88
74
|
h2Session: baseInstance.h2Session,
|
|
89
75
|
};
|
|
90
|
-
// Preserve forceUrl and
|
|
76
|
+
// Preserve forceUrl, headers, and params from input if provided
|
|
91
77
|
if (sandbox && typeof sandbox === "object" && !Array.isArray(sandbox)) {
|
|
92
78
|
if ("forceUrl" in sandbox && typeof sandbox.forceUrl === "string") {
|
|
93
79
|
config.forceUrl = sandbox.forceUrl;
|
|
@@ -101,6 +87,9 @@ class CodeInterpreter extends sandbox_js_1.SandboxInstance {
|
|
|
101
87
|
}
|
|
102
88
|
return new CodeInterpreter(config);
|
|
103
89
|
}
|
|
90
|
+
static async createIfNotExists(sandbox) {
|
|
91
|
+
return await super.createIfNotExists(sandbox);
|
|
92
|
+
}
|
|
104
93
|
get _jupyterUrl() {
|
|
105
94
|
return this.process.url;
|
|
106
95
|
}
|
|
@@ -279,7 +279,7 @@ class SandboxInstance {
|
|
|
279
279
|
}
|
|
280
280
|
static async createIfNotExists(sandbox) {
|
|
281
281
|
try {
|
|
282
|
-
return await
|
|
282
|
+
return await this.create(sandbox);
|
|
283
283
|
}
|
|
284
284
|
catch (e) {
|
|
285
285
|
if (typeof e === "object" && e !== null && "code" in e && (e.code === 409 || e.code === 'SANDBOX_ALREADY_EXISTS')) {
|
|
@@ -288,11 +288,11 @@ class SandboxInstance {
|
|
|
288
288
|
throw new Error("Sandbox name is required");
|
|
289
289
|
}
|
|
290
290
|
// Get the existing sandbox to check its status
|
|
291
|
-
const sandboxInstance = await
|
|
291
|
+
const sandboxInstance = await this.get(name);
|
|
292
292
|
// If the sandbox is TERMINATED, treat it as not existing
|
|
293
293
|
if (sandboxInstance.status === "TERMINATED") {
|
|
294
294
|
// Create a new sandbox - backend will handle cleanup of the terminated one
|
|
295
|
-
return await
|
|
295
|
+
return await this.create(sandbox);
|
|
296
296
|
}
|
|
297
297
|
// Otherwise return the existing running sandbox
|
|
298
298
|
return sandboxInstance;
|
|
@@ -11,6 +11,7 @@ export declare class CodeInterpreter extends SandboxInstance {
|
|
|
11
11
|
static create(sandbox?: Sandbox | SandboxCreateConfiguration | Record<string, any> | null, { safe }?: {
|
|
12
12
|
safe?: boolean;
|
|
13
13
|
}): Promise<CodeInterpreter>;
|
|
14
|
+
static createIfNotExists(sandbox: Sandbox | SandboxCreateConfiguration): Promise<CodeInterpreter>;
|
|
14
15
|
get _jupyterUrl(): string;
|
|
15
16
|
private _fetch;
|
|
16
17
|
static OutputMessage: {
|