@blaxel/core 0.2.50-dev.215 → 0.2.50-preview.115
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/agents/index.js +2 -2
- package/dist/cjs/authentication/clientcredentials.js +1 -4
- package/dist/cjs/common/internal.js +0 -40
- package/dist/cjs/common/settings.js +2 -5
- package/dist/cjs/jobs/jobs.js +2 -2
- package/dist/cjs/jobs/start.js +1 -32
- package/dist/cjs/sandbox/action.js +2 -1
- package/dist/cjs/sandbox/sandbox.js +10 -67
- package/dist/cjs/tools/mcpTool.js +2 -2
- package/dist/cjs/types/common/internal.d.ts +0 -2
- package/dist/cjs/types/common/settings.d.ts +0 -1
- package/dist/cjs/types/sandbox/sandbox.d.ts +6 -12
- package/dist/cjs/types/sandbox/types.d.ts +0 -3
- package/dist/cjs-browser/.tsbuildinfo +1 -1
- package/dist/cjs-browser/agents/index.js +2 -2
- package/dist/cjs-browser/authentication/clientcredentials.js +1 -4
- package/dist/cjs-browser/common/internal.js +0 -40
- package/dist/cjs-browser/common/settings.js +2 -5
- package/dist/cjs-browser/jobs/jobs.js +2 -2
- package/dist/cjs-browser/jobs/start.js +1 -32
- package/dist/cjs-browser/sandbox/action.js +2 -1
- package/dist/cjs-browser/sandbox/sandbox.js +10 -67
- package/dist/cjs-browser/tools/mcpTool.js +2 -2
- package/dist/cjs-browser/types/common/internal.d.ts +0 -2
- package/dist/cjs-browser/types/common/settings.d.ts +0 -1
- package/dist/cjs-browser/types/sandbox/sandbox.d.ts +6 -12
- package/dist/cjs-browser/types/sandbox/types.d.ts +0 -3
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/agents/index.js +3 -3
- package/dist/esm/authentication/clientcredentials.js +1 -4
- package/dist/esm/common/internal.js +0 -38
- package/dist/esm/common/settings.js +2 -5
- package/dist/esm/jobs/jobs.js +3 -3
- package/dist/esm/jobs/start.js +1 -32
- package/dist/esm/sandbox/action.js +3 -2
- package/dist/esm/sandbox/sandbox.js +10 -67
- package/dist/esm/tools/mcpTool.js +3 -3
- package/dist/esm-browser/.tsbuildinfo +1 -1
- package/dist/esm-browser/agents/index.js +3 -3
- package/dist/esm-browser/authentication/clientcredentials.js +1 -4
- package/dist/esm-browser/common/internal.js +0 -38
- package/dist/esm-browser/common/settings.js +2 -5
- package/dist/esm-browser/jobs/jobs.js +3 -3
- package/dist/esm-browser/jobs/start.js +1 -32
- package/dist/esm-browser/sandbox/action.js +3 -2
- package/dist/esm-browser/sandbox/sandbox.js +10 -67
- package/dist/esm-browser/tools/mcpTool.js +3 -3
- package/package.json +2 -2
- package/dist/cjs/sandbox/codegen/codegen-ws.js +0 -30
- package/dist/cjs/sandbox/filesystem/filesystem-ws.js +0 -106
- package/dist/cjs/sandbox/network/network-ws.js +0 -12
- package/dist/cjs/sandbox/process/process-ws.js +0 -139
- package/dist/cjs/sandbox/websocket/client.js +0 -269
- package/dist/cjs/sandbox/websocket/index.js +0 -17
- package/dist/cjs/types/sandbox/codegen/codegen-ws.d.ts +0 -10
- package/dist/cjs/types/sandbox/filesystem/filesystem-ws.d.ts +0 -35
- package/dist/cjs/types/sandbox/network/network-ws.d.ts +0 -7
- package/dist/cjs/types/sandbox/process/process-ws.d.ts +0 -27
- package/dist/cjs/types/sandbox/websocket/client.d.ts +0 -48
- package/dist/cjs/types/sandbox/websocket/index.d.ts +0 -1
- package/dist/cjs-browser/sandbox/codegen/codegen-ws.js +0 -30
- package/dist/cjs-browser/sandbox/filesystem/filesystem-ws.js +0 -106
- package/dist/cjs-browser/sandbox/network/network-ws.js +0 -12
- package/dist/cjs-browser/sandbox/process/process-ws.js +0 -139
- package/dist/cjs-browser/sandbox/websocket/client.js +0 -269
- package/dist/cjs-browser/sandbox/websocket/index.js +0 -17
- package/dist/cjs-browser/types/sandbox/codegen/codegen-ws.d.ts +0 -10
- package/dist/cjs-browser/types/sandbox/filesystem/filesystem-ws.d.ts +0 -35
- package/dist/cjs-browser/types/sandbox/network/network-ws.d.ts +0 -7
- package/dist/cjs-browser/types/sandbox/process/process-ws.d.ts +0 -27
- package/dist/cjs-browser/types/sandbox/websocket/client.d.ts +0 -48
- package/dist/cjs-browser/types/sandbox/websocket/index.d.ts +0 -1
- package/dist/esm/sandbox/codegen/codegen-ws.js +0 -26
- package/dist/esm/sandbox/filesystem/filesystem-ws.js +0 -102
- package/dist/esm/sandbox/network/network-ws.js +0 -8
- package/dist/esm/sandbox/process/process-ws.js +0 -135
- package/dist/esm/sandbox/websocket/client.js +0 -265
- package/dist/esm/sandbox/websocket/index.js +0 -1
- package/dist/esm-browser/sandbox/codegen/codegen-ws.js +0 -26
- package/dist/esm-browser/sandbox/filesystem/filesystem-ws.js +0 -102
- package/dist/esm-browser/sandbox/network/network-ws.js +0 -8
- package/dist/esm-browser/sandbox/process/process-ws.js +0 -135
- package/dist/esm-browser/sandbox/websocket/client.js +0 -265
- package/dist/esm-browser/sandbox/websocket/index.js +0 -1
|
@@ -54,13 +54,10 @@ class ClientCredentials extends credentials_js_1.Credentials {
|
|
|
54
54
|
}
|
|
55
55
|
catch (error) {
|
|
56
56
|
if (retry > 0) {
|
|
57
|
-
console.error(`Authentication failed, retrying... (${4 - retry}/3)`, error);
|
|
58
57
|
await this.sleep(1000);
|
|
59
58
|
return this.processWithRetry(retry - 1);
|
|
60
59
|
}
|
|
61
|
-
|
|
62
|
-
const originalMessage = error instanceof Error ? error.message : String(error);
|
|
63
|
-
throw new Error(`Authentication failed after 4 attempts: ${originalMessage}`, { cause: error });
|
|
60
|
+
throw error;
|
|
64
61
|
}
|
|
65
62
|
}
|
|
66
63
|
async process() {
|
|
@@ -5,8 +5,6 @@ exports.getAlphanumericLimitedHash = getAlphanumericLimitedHash;
|
|
|
5
5
|
exports.getGlobalUniqueHash = getGlobalUniqueHash;
|
|
6
6
|
exports.pluralize = pluralize;
|
|
7
7
|
exports.getForcedUrl = getForcedUrl;
|
|
8
|
-
exports.getWorkloadTypeShort = getWorkloadTypeShort;
|
|
9
|
-
exports.generateInternalUrl = generateInternalUrl;
|
|
10
8
|
const env_js_1 = require("./env.js");
|
|
11
9
|
// Pure JS MD5 implementation that matches standard crypto MD5
|
|
12
10
|
function md5(input) {
|
|
@@ -188,41 +186,3 @@ function getForcedUrl(type, name) {
|
|
|
188
186
|
}
|
|
189
187
|
return null;
|
|
190
188
|
}
|
|
191
|
-
function getWorkloadTypeShort(type) {
|
|
192
|
-
const lowerType = type.toLowerCase();
|
|
193
|
-
switch (lowerType) {
|
|
194
|
-
case 'agent':
|
|
195
|
-
case 'agents':
|
|
196
|
-
return 'agt';
|
|
197
|
-
case 'mcp':
|
|
198
|
-
case 'mcps':
|
|
199
|
-
case 'function':
|
|
200
|
-
case 'functions':
|
|
201
|
-
return 'mcp';
|
|
202
|
-
case 'sandbox':
|
|
203
|
-
case 'sandboxes':
|
|
204
|
-
return 'sbx';
|
|
205
|
-
case 'job':
|
|
206
|
-
case 'jobs':
|
|
207
|
-
return 'job';
|
|
208
|
-
case 'model':
|
|
209
|
-
case 'models':
|
|
210
|
-
return 'mdl';
|
|
211
|
-
default:
|
|
212
|
-
// fallback to first 3 letters of type
|
|
213
|
-
return lowerType.substring(0, 3);
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
function generateInternalUrl(workspace, type, name, env, protocol, hostname, blCloud, workspaceId) {
|
|
217
|
-
if (blCloud && workspaceId) {
|
|
218
|
-
// New cloud format: bl-ENV-WORKLOAD_CALLED_NAME-WORKLOAD_TYPE_SHORT-WORKSPACE_ID
|
|
219
|
-
const workloadTypeShort = getWorkloadTypeShort(type);
|
|
220
|
-
const subdomain = `bl-${env}-${name}-${workloadTypeShort}-${workspaceId}`;
|
|
221
|
-
return `${protocol}://${subdomain}.${hostname}`;
|
|
222
|
-
}
|
|
223
|
-
else {
|
|
224
|
-
// Legacy format: bl-ENV-HASH.internalhostname
|
|
225
|
-
const hash = getGlobalUniqueHash(workspace, type, name);
|
|
226
|
-
return `${protocol}://bl-${env}-${hash}.${hostname}`;
|
|
227
|
-
}
|
|
228
|
-
}
|
|
@@ -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.50-
|
|
13
|
+
const packageJson = {"version":"0.2.50-preview.115","commit":"a4290fe191702ee91d8ae3fcc45c094d86be553c"};
|
|
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.50-
|
|
65
|
+
const packageJson = {"version":"0.2.50-preview.115","commit":"a4290fe191702ee91d8ae3fcc45c094d86be553c"};
|
|
66
66
|
// Check for commit in various possible locations
|
|
67
67
|
const commit = packageJson.commit || packageJson.buildInfo?.commit;
|
|
68
68
|
if (commit) {
|
|
@@ -165,9 +165,6 @@ class Settings {
|
|
|
165
165
|
get blCloud() {
|
|
166
166
|
return env_js_1.env.BL_CLOUD === "true";
|
|
167
167
|
}
|
|
168
|
-
get workspaceId() {
|
|
169
|
-
return env_js_1.env.BL_WORKSPACE_ID || "";
|
|
170
|
-
}
|
|
171
168
|
get generation() {
|
|
172
169
|
return env_js_1.env.BL_GENERATION || "";
|
|
173
170
|
}
|
|
@@ -20,8 +20,8 @@ class BlJob {
|
|
|
20
20
|
return new URL(`${settings_js_1.settings.runUrl}/${settings_js_1.settings.workspace}/jobs/${this.jobName}`);
|
|
21
21
|
}
|
|
22
22
|
get internalUrl() {
|
|
23
|
-
const
|
|
24
|
-
return new URL(
|
|
23
|
+
const hash = (0, internal_js_1.getGlobalUniqueHash)(settings_js_1.settings.workspace, "job", this.jobName);
|
|
24
|
+
return new URL(`${settings_js_1.settings.runInternalProtocol}://bl-${settings_js_1.settings.env}-${hash}.${settings_js_1.settings.runInternalHostname}`);
|
|
25
25
|
}
|
|
26
26
|
get forcedUrl() {
|
|
27
27
|
return (0, internal_js_1.getForcedUrl)('job', this.jobName);
|
|
@@ -5,43 +5,12 @@ 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
|
-
}
|
|
39
8
|
async getArguments() {
|
|
40
9
|
if (!env_js_1.env.BL_EXECUTION_DATA_URL) {
|
|
41
10
|
const args = this.parseCommandLineArgs();
|
|
42
11
|
return args;
|
|
43
12
|
}
|
|
44
|
-
const response = await
|
|
13
|
+
const response = await fetch(env_js_1.env.BL_EXECUTION_DATA_URL);
|
|
45
14
|
const data = await response.json();
|
|
46
15
|
return data.tasks[this.index] ?? {};
|
|
47
16
|
}
|
|
@@ -48,7 +48,8 @@ class SandboxAction {
|
|
|
48
48
|
return this.sandbox.metadata?.url ?? `${settings_js_1.settings.runUrl}/${settings_js_1.settings.workspace}/sandboxes/${this.name}`;
|
|
49
49
|
}
|
|
50
50
|
get internalUrl() {
|
|
51
|
-
|
|
51
|
+
const hash = (0, internal_js_1.getGlobalUniqueHash)(settings_js_1.settings.workspace, "sandbox", this.name);
|
|
52
|
+
return `${settings_js_1.settings.runInternalProtocol}://bl-${settings_js_1.settings.env}-${hash}.${settings_js_1.settings.runInternalHostname}`;
|
|
52
53
|
}
|
|
53
54
|
get client() {
|
|
54
55
|
if (this.sandbox.forceUrl) {
|
|
@@ -5,16 +5,11 @@ const uuid_1 = require("uuid");
|
|
|
5
5
|
const index_js_1 = require("../client/index.js");
|
|
6
6
|
const logger_js_1 = require("../common/logger.js");
|
|
7
7
|
const index_js_2 = require("./filesystem/index.js");
|
|
8
|
-
const filesystem_ws_js_1 = require("./filesystem/filesystem-ws.js");
|
|
9
8
|
const index_js_3 = require("./network/index.js");
|
|
10
|
-
const network_ws_js_1 = require("./network/network-ws.js");
|
|
11
9
|
const preview_js_1 = require("./preview.js");
|
|
12
10
|
const index_js_4 = require("./process/index.js");
|
|
13
|
-
const process_ws_js_1 = require("./process/process-ws.js");
|
|
14
11
|
const index_js_5 = require("./codegen/index.js");
|
|
15
|
-
const codegen_ws_js_1 = require("./codegen/codegen-ws.js");
|
|
16
12
|
const session_js_1 = require("./session.js");
|
|
17
|
-
const index_js_6 = require("./websocket/index.js");
|
|
18
13
|
const types_js_1 = require("./types.js");
|
|
19
14
|
class SandboxInstance {
|
|
20
15
|
sandbox;
|
|
@@ -24,32 +19,14 @@ class SandboxInstance {
|
|
|
24
19
|
previews;
|
|
25
20
|
sessions;
|
|
26
21
|
codegen;
|
|
27
|
-
wsClient;
|
|
28
22
|
constructor(sandbox) {
|
|
29
23
|
this.sandbox = sandbox;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
this.wsClient = new index_js_6.WebSocketClient({
|
|
34
|
-
url,
|
|
35
|
-
headers: sandbox.headers,
|
|
36
|
-
});
|
|
37
|
-
// Initialize WebSocket-based action handlers
|
|
38
|
-
this.process = new process_ws_js_1.SandboxProcessWebSocket(sandbox, this.wsClient);
|
|
39
|
-
this.fs = new filesystem_ws_js_1.SandboxFileSystemWebSocket(sandbox, this.process, this.wsClient);
|
|
40
|
-
this.network = new network_ws_js_1.SandboxNetworkWebSocket(sandbox, this.wsClient);
|
|
41
|
-
this.codegen = new codegen_ws_js_1.SandboxCodegenWebSocket(sandbox, this.wsClient);
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
// Default to HTTP-based action handlers
|
|
45
|
-
this.process = new index_js_4.SandboxProcess(sandbox);
|
|
46
|
-
this.fs = new index_js_2.SandboxFileSystem(sandbox, this.process);
|
|
47
|
-
this.network = new index_js_3.SandboxNetwork(sandbox);
|
|
48
|
-
this.codegen = new index_js_5.SandboxCodegen(sandbox);
|
|
49
|
-
}
|
|
50
|
-
// These are always HTTP-based
|
|
24
|
+
this.process = new index_js_4.SandboxProcess(sandbox);
|
|
25
|
+
this.fs = new index_js_2.SandboxFileSystem(sandbox, this.process);
|
|
26
|
+
this.network = new index_js_3.SandboxNetwork(sandbox);
|
|
51
27
|
this.previews = new preview_js_1.SandboxPreviews(sandbox);
|
|
52
28
|
this.sessions = new session_js_1.SandboxSessions(sandbox);
|
|
29
|
+
this.codegen = new index_js_5.SandboxCodegen(sandbox);
|
|
53
30
|
}
|
|
54
31
|
get metadata() {
|
|
55
32
|
return this.sandbox.metadata;
|
|
@@ -68,17 +45,10 @@ class SandboxInstance {
|
|
|
68
45
|
logger_js_1.logger.warn("⚠️ Warning: sandbox.wait() is deprecated. You don't need to wait for the sandbox to be deployed anymore.");
|
|
69
46
|
return this;
|
|
70
47
|
}
|
|
71
|
-
closeConnection() {
|
|
72
|
-
if (this.wsClient) {
|
|
73
|
-
this.wsClient.close();
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
48
|
static async create(sandbox, { safe = true } = {}) {
|
|
77
49
|
const defaultName = `sandbox-${(0, uuid_1.v4)().replace(/-/g, '').substring(0, 8)}`;
|
|
78
50
|
const defaultImage = `blaxel/base-image:latest`;
|
|
79
51
|
const defaultMemory = 4096;
|
|
80
|
-
// Store connection type if provided
|
|
81
|
-
let connectionType;
|
|
82
52
|
// Handle SandboxCreateConfiguration or simple dict with name/image/memory/ports/envs/volumes keys
|
|
83
53
|
if (!sandbox ||
|
|
84
54
|
'name' in sandbox ||
|
|
@@ -88,8 +58,7 @@ class SandboxInstance {
|
|
|
88
58
|
'envs' in sandbox ||
|
|
89
59
|
'volumes' in sandbox ||
|
|
90
60
|
'lifecycle' in sandbox ||
|
|
91
|
-
'snapshotEnabled' in sandbox
|
|
92
|
-
'connectionType' in sandbox) {
|
|
61
|
+
'snapshotEnabled' in sandbox) {
|
|
93
62
|
if (!sandbox)
|
|
94
63
|
sandbox = {};
|
|
95
64
|
if (!sandbox.name)
|
|
@@ -98,7 +67,6 @@ class SandboxInstance {
|
|
|
98
67
|
sandbox.image = defaultImage;
|
|
99
68
|
if (!sandbox.memory)
|
|
100
69
|
sandbox.memory = defaultMemory;
|
|
101
|
-
connectionType = sandbox.connectionType;
|
|
102
70
|
const ports = (0, types_js_1.normalizePorts)(sandbox.ports);
|
|
103
71
|
const envs = (0, types_js_1.normalizeEnvs)(sandbox.envs);
|
|
104
72
|
const volumes = (0, types_js_1.normalizeVolumes)(sandbox.volumes);
|
|
@@ -147,16 +115,7 @@ class SandboxInstance {
|
|
|
147
115
|
body: sandbox,
|
|
148
116
|
throwOnError: true,
|
|
149
117
|
});
|
|
150
|
-
|
|
151
|
-
const config = {
|
|
152
|
-
...data,
|
|
153
|
-
connectionType: connectionType || "http",
|
|
154
|
-
};
|
|
155
|
-
const instance = new SandboxInstance(config);
|
|
156
|
-
// Connect WebSocket if needed
|
|
157
|
-
if (connectionType === "websocket" && instance.wsClient) {
|
|
158
|
-
await instance.wsClient.connect();
|
|
159
|
-
}
|
|
118
|
+
const instance = new SandboxInstance(data);
|
|
160
119
|
// TODO remove this part once we have a better way to handle this
|
|
161
120
|
if (safe) {
|
|
162
121
|
try {
|
|
@@ -166,34 +125,20 @@ class SandboxInstance {
|
|
|
166
125
|
}
|
|
167
126
|
return instance;
|
|
168
127
|
}
|
|
169
|
-
static async get(sandboxName
|
|
128
|
+
static async get(sandboxName) {
|
|
170
129
|
const { data } = await (0, index_js_1.getSandbox)({
|
|
171
130
|
path: {
|
|
172
131
|
sandboxName,
|
|
173
132
|
},
|
|
174
133
|
throwOnError: true,
|
|
175
134
|
});
|
|
176
|
-
|
|
177
|
-
const config = {
|
|
178
|
-
...data,
|
|
179
|
-
connectionType: connectionType || "http",
|
|
180
|
-
};
|
|
181
|
-
const instance = new SandboxInstance(config);
|
|
182
|
-
// Connect WebSocket if needed
|
|
183
|
-
if (connectionType === "websocket" && instance.wsClient) {
|
|
184
|
-
await instance.wsClient.connect();
|
|
185
|
-
}
|
|
186
|
-
return instance;
|
|
135
|
+
return new SandboxInstance(data);
|
|
187
136
|
}
|
|
188
137
|
static async list() {
|
|
189
138
|
const { data } = await (0, index_js_1.listSandboxes)({ throwOnError: true });
|
|
190
139
|
return data.map((sandbox) => new SandboxInstance(sandbox));
|
|
191
140
|
}
|
|
192
|
-
static async delete(sandboxName
|
|
193
|
-
// Close WebSocket connection if instance is provided
|
|
194
|
-
if (instance && instance.wsClient) {
|
|
195
|
-
instance.closeConnection();
|
|
196
|
-
}
|
|
141
|
+
static async delete(sandboxName) {
|
|
197
142
|
const { data } = await (0, index_js_1.deleteSandbox)({
|
|
198
143
|
path: {
|
|
199
144
|
sandboxName,
|
|
@@ -223,10 +168,8 @@ class SandboxInstance {
|
|
|
223
168
|
if (!name) {
|
|
224
169
|
throw new Error("Sandbox name is required");
|
|
225
170
|
}
|
|
226
|
-
// Get connection type if specified
|
|
227
|
-
const connectionType = 'connectionType' in sandbox ? sandbox.connectionType : undefined;
|
|
228
171
|
// Get the existing sandbox to check its status
|
|
229
|
-
const sandboxInstance = await SandboxInstance.get(name
|
|
172
|
+
const sandboxInstance = await SandboxInstance.get(name);
|
|
230
173
|
// If the sandbox is TERMINATED, treat it as not existing
|
|
231
174
|
if (sandboxInstance.status === "TERMINATED") {
|
|
232
175
|
// Create a new sandbox - backend will handle cleanup of the terminated one
|
|
@@ -54,8 +54,8 @@ class McpTool {
|
|
|
54
54
|
return new URL(`${settings_js_1.settings.runUrl}/${settings_js_1.settings.workspace}/${this.pluralType}/${this.name}`);
|
|
55
55
|
}
|
|
56
56
|
get internalUrl() {
|
|
57
|
-
const
|
|
58
|
-
return new URL(
|
|
57
|
+
const hash = (0, internal_js_1.getGlobalUniqueHash)(settings_js_1.settings.workspace, this.type, this.name);
|
|
58
|
+
return new URL(`${settings_js_1.settings.runInternalProtocol}://bl-${settings_js_1.settings.env}-${hash}.${settings_js_1.settings.runInternalHostname}`);
|
|
59
59
|
}
|
|
60
60
|
get forcedUrl() {
|
|
61
61
|
return (0, internal_js_1.getForcedUrl)(this.type, this.name);
|
|
@@ -2,5 +2,3 @@ export declare function getAlphanumericLimitedHash(input: string, maxSize?: numb
|
|
|
2
2
|
export declare function getGlobalUniqueHash(workspace: string, type: string, name: string): string;
|
|
3
3
|
export declare function pluralize(type: string): string;
|
|
4
4
|
export declare function getForcedUrl(type: string, name: string): import("url").URL | null;
|
|
5
|
-
export declare function getWorkloadTypeShort(type: string): string;
|
|
6
|
-
export declare function generateInternalUrl(workspace: string, type: string, name: string, env: string, protocol: string, hostname: string, blCloud: boolean, workspaceId: string): string;
|
|
@@ -1,24 +1,19 @@
|
|
|
1
1
|
import { Sandbox as SandboxModel } from "../client/index.js";
|
|
2
2
|
import { SandboxFileSystem } from "./filesystem/index.js";
|
|
3
|
-
import { SandboxFileSystemWebSocket } from "./filesystem/filesystem-ws.js";
|
|
4
3
|
import { SandboxNetwork } from "./network/index.js";
|
|
5
|
-
import { SandboxNetworkWebSocket } from "./network/network-ws.js";
|
|
6
4
|
import { SandboxPreviews } from "./preview.js";
|
|
7
5
|
import { SandboxProcess } from "./process/index.js";
|
|
8
|
-
import { SandboxProcessWebSocket } from "./process/process-ws.js";
|
|
9
6
|
import { SandboxCodegen } from "./codegen/index.js";
|
|
10
|
-
import { SandboxCodegenWebSocket } from "./codegen/codegen-ws.js";
|
|
11
7
|
import { SandboxSessions } from "./session.js";
|
|
12
8
|
import { SandboxConfiguration, SandboxCreateConfiguration, SandboxUpdateMetadata, SessionWithToken } from "./types.js";
|
|
13
9
|
export declare class SandboxInstance {
|
|
14
10
|
private sandbox;
|
|
15
|
-
fs: SandboxFileSystem
|
|
16
|
-
network: SandboxNetwork
|
|
17
|
-
process: SandboxProcess
|
|
11
|
+
fs: SandboxFileSystem;
|
|
12
|
+
network: SandboxNetwork;
|
|
13
|
+
process: SandboxProcess;
|
|
18
14
|
previews: SandboxPreviews;
|
|
19
15
|
sessions: SandboxSessions;
|
|
20
|
-
codegen: SandboxCodegen
|
|
21
|
-
private wsClient?;
|
|
16
|
+
codegen: SandboxCodegen;
|
|
22
17
|
constructor(sandbox: SandboxConfiguration);
|
|
23
18
|
get metadata(): import("../client/types.gen.js").Metadata | undefined;
|
|
24
19
|
get status(): string | undefined;
|
|
@@ -28,13 +23,12 @@ export declare class SandboxInstance {
|
|
|
28
23
|
maxWait?: number;
|
|
29
24
|
interval?: number;
|
|
30
25
|
}): Promise<this>;
|
|
31
|
-
closeConnection(): void;
|
|
32
26
|
static create(sandbox?: SandboxModel | SandboxCreateConfiguration, { safe }?: {
|
|
33
27
|
safe?: boolean;
|
|
34
28
|
}): Promise<SandboxInstance>;
|
|
35
|
-
static get(sandboxName: string
|
|
29
|
+
static get(sandboxName: string): Promise<SandboxInstance>;
|
|
36
30
|
static list(): Promise<SandboxInstance[]>;
|
|
37
|
-
static delete(sandboxName: string
|
|
31
|
+
static delete(sandboxName: string): Promise<SandboxModel>;
|
|
38
32
|
static updateMetadata(sandboxName: string, metadata: SandboxUpdateMetadata): Promise<SandboxInstance>;
|
|
39
33
|
static createIfNotExists(sandbox: SandboxModel | SandboxCreateConfiguration): Promise<SandboxInstance>;
|
|
40
34
|
static fromSession(session: SessionWithToken): Promise<SandboxInstance>;
|
|
@@ -20,12 +20,10 @@ export interface VolumeBinding {
|
|
|
20
20
|
mountPath: string;
|
|
21
21
|
readOnly?: boolean;
|
|
22
22
|
}
|
|
23
|
-
export type ConnectionType = "http" | "websocket";
|
|
24
23
|
export type SandboxConfiguration = {
|
|
25
24
|
forceUrl?: string;
|
|
26
25
|
headers?: Record<string, string>;
|
|
27
26
|
params?: Record<string, string>;
|
|
28
|
-
connectionType?: ConnectionType;
|
|
29
27
|
} & Sandbox;
|
|
30
28
|
export type SandboxUpdateMetadata = {
|
|
31
29
|
labels?: Record<string, string>;
|
|
@@ -43,7 +41,6 @@ export type SandboxCreateConfiguration = {
|
|
|
43
41
|
region?: string;
|
|
44
42
|
lifecycle?: SandboxLifecycle;
|
|
45
43
|
snapshotEnabled?: boolean;
|
|
46
|
-
connectionType?: ConnectionType;
|
|
47
44
|
};
|
|
48
45
|
export declare function normalizePorts(ports?: (Port | Record<string, any>)[]): Port[] | undefined;
|
|
49
46
|
export declare function normalizeEnvs(envs?: EnvVar[]): EnvVar[] | undefined;
|