@blaxel/core 0.2.48 → 0.2.49-dev.206
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 +4 -1
- package/dist/cjs/common/internal.js +40 -0
- package/dist/cjs/common/settings.js +5 -2
- package/dist/cjs/jobs/jobs.js +2 -2
- package/dist/cjs/sandbox/action.js +1 -2
- package/dist/cjs/sandbox/filesystem/filesystem.js +3 -14
- package/dist/cjs/tools/mcpTool.js +2 -2
- package/dist/cjs/types/common/internal.d.ts +2 -0
- package/dist/cjs/types/common/settings.d.ts +1 -0
- package/dist/cjs-browser/.tsbuildinfo +1 -1
- package/dist/cjs-browser/agents/index.js +2 -2
- package/dist/cjs-browser/authentication/clientcredentials.js +4 -1
- package/dist/cjs-browser/common/internal.js +40 -0
- package/dist/cjs-browser/common/settings.js +5 -2
- package/dist/cjs-browser/jobs/jobs.js +2 -2
- package/dist/cjs-browser/sandbox/action.js +1 -2
- package/dist/cjs-browser/sandbox/filesystem/filesystem.js +3 -14
- package/dist/cjs-browser/tools/mcpTool.js +2 -2
- package/dist/cjs-browser/types/common/internal.d.ts +2 -0
- package/dist/cjs-browser/types/common/settings.d.ts +1 -0
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/agents/index.js +3 -3
- package/dist/esm/authentication/clientcredentials.js +4 -1
- package/dist/esm/common/internal.js +38 -0
- package/dist/esm/common/settings.js +5 -2
- package/dist/esm/jobs/jobs.js +3 -3
- package/dist/esm/sandbox/action.js +2 -3
- package/dist/esm/sandbox/filesystem/filesystem.js +3 -14
- 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 +4 -1
- package/dist/esm-browser/common/internal.js +38 -0
- package/dist/esm-browser/common/settings.js +5 -2
- package/dist/esm-browser/jobs/jobs.js +3 -3
- package/dist/esm-browser/sandbox/action.js +2 -3
- package/dist/esm-browser/sandbox/filesystem/filesystem.js +3 -14
- package/dist/esm-browser/tools/mcpTool.js +3 -3
- package/package.json +2 -2
|
@@ -54,10 +54,13 @@ 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);
|
|
57
58
|
await this.sleep(1000);
|
|
58
59
|
return this.processWithRetry(retry - 1);
|
|
59
60
|
}
|
|
60
|
-
|
|
61
|
+
this.currentPromise = null;
|
|
62
|
+
const originalMessage = error instanceof Error ? error.message : String(error);
|
|
63
|
+
throw new Error(`Authentication failed after 4 attempts: ${originalMessage}`, { cause: error });
|
|
61
64
|
}
|
|
62
65
|
}
|
|
63
66
|
async process() {
|
|
@@ -5,6 +5,8 @@ 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;
|
|
8
10
|
const env_js_1 = require("./env.js");
|
|
9
11
|
// Pure JS MD5 implementation that matches standard crypto MD5
|
|
10
12
|
function md5(input) {
|
|
@@ -186,3 +188,41 @@ function getForcedUrl(type, name) {
|
|
|
186
188
|
}
|
|
187
189
|
return null;
|
|
188
190
|
}
|
|
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.
|
|
13
|
+
const packageJson = {"version":"0.2.49-dev.206","commit":"017e4a324642a0030cb54183ad590a845ec9694e"};
|
|
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.
|
|
65
|
+
const packageJson = {"version":"0.2.49-dev.206","commit":"017e4a324642a0030cb54183ad590a845ec9694e"};
|
|
66
66
|
// Check for commit in various possible locations
|
|
67
67
|
const commit = packageJson.commit || packageJson.buildInfo?.commit;
|
|
68
68
|
if (commit) {
|
|
@@ -165,6 +165,9 @@ 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
|
+
}
|
|
168
171
|
get generation() {
|
|
169
172
|
return env_js_1.env.BL_GENERATION || "";
|
|
170
173
|
}
|
package/dist/cjs/jobs/jobs.js
CHANGED
|
@@ -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 url = (0, internal_js_1.generateInternalUrl)(settings_js_1.settings.workspace, "job", this.jobName, settings_js_1.settings.env, settings_js_1.settings.runInternalProtocol, settings_js_1.settings.runInternalHostname, settings_js_1.settings.blCloud, settings_js_1.settings.workspaceId);
|
|
24
|
+
return new URL(url);
|
|
25
25
|
}
|
|
26
26
|
get forcedUrl() {
|
|
27
27
|
return (0, internal_js_1.getForcedUrl)('job', this.jobName);
|
|
@@ -48,8 +48,7 @@ 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
|
-
|
|
52
|
-
return `${settings_js_1.settings.runInternalProtocol}://bl-${settings_js_1.settings.env}-${hash}.${settings_js_1.settings.runInternalHostname}`;
|
|
51
|
+
return (0, internal_js_1.generateInternalUrl)(settings_js_1.settings.workspace, "sandbox", this.name, settings_js_1.settings.env, settings_js_1.settings.runInternalProtocol, settings_js_1.settings.runInternalHostname, settings_js_1.settings.blCloud, settings_js_1.settings.workspaceId);
|
|
53
52
|
}
|
|
54
53
|
get client() {
|
|
55
54
|
if (this.sandbox.forceUrl) {
|
|
@@ -8,7 +8,7 @@ const index_js_1 = require("../client/index.js");
|
|
|
8
8
|
// Multipart upload constants
|
|
9
9
|
const MULTIPART_THRESHOLD = 5 * 1024 * 1024; // 5MB
|
|
10
10
|
const CHUNK_SIZE = 5 * 1024 * 1024; // 5MB per part
|
|
11
|
-
const MAX_PARALLEL_UPLOADS =
|
|
11
|
+
const MAX_PARALLEL_UPLOADS = 10; // Number of parallel part uploads
|
|
12
12
|
class SandboxFileSystem extends action_js_1.SandboxAction {
|
|
13
13
|
process;
|
|
14
14
|
constructor(sandbox, process) {
|
|
@@ -304,7 +304,6 @@ class SandboxFileSystem extends action_js_1.SandboxAction {
|
|
|
304
304
|
// Multipart upload helper methods
|
|
305
305
|
async initiateMultipartUpload(path, permissions = "0644") {
|
|
306
306
|
path = this.formatPath(path);
|
|
307
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call
|
|
308
307
|
const { data } = await (0, index_js_1.postFilesystemMultipartInitiateByPath)({
|
|
309
308
|
path: { path },
|
|
310
309
|
body: { permissions },
|
|
@@ -315,7 +314,6 @@ class SandboxFileSystem extends action_js_1.SandboxAction {
|
|
|
315
314
|
return data;
|
|
316
315
|
}
|
|
317
316
|
async uploadPart(uploadId, partNumber, fileBlob) {
|
|
318
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call
|
|
319
317
|
const { data } = await (0, index_js_1.putFilesystemMultipartByUploadIdPart)({
|
|
320
318
|
path: { uploadId },
|
|
321
319
|
query: { partNumber },
|
|
@@ -327,7 +325,6 @@ class SandboxFileSystem extends action_js_1.SandboxAction {
|
|
|
327
325
|
return data;
|
|
328
326
|
}
|
|
329
327
|
async completeMultipartUpload(uploadId, parts) {
|
|
330
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call
|
|
331
328
|
const { data } = await (0, index_js_1.postFilesystemMultipartByUploadIdComplete)({
|
|
332
329
|
path: { uploadId },
|
|
333
330
|
body: { parts },
|
|
@@ -338,19 +335,17 @@ class SandboxFileSystem extends action_js_1.SandboxAction {
|
|
|
338
335
|
return data;
|
|
339
336
|
}
|
|
340
337
|
async abortMultipartUpload(uploadId) {
|
|
341
|
-
|
|
342
|
-
await (0, index_js_1.deleteFilesystemMultipartByUploadIdAbort)({
|
|
338
|
+
const { data } = await (0, index_js_1.deleteFilesystemMultipartByUploadIdAbort)({
|
|
343
339
|
path: { uploadId },
|
|
344
340
|
baseUrl: this.url,
|
|
345
341
|
client: this.client,
|
|
346
342
|
throwOnError: true,
|
|
347
343
|
});
|
|
344
|
+
return data;
|
|
348
345
|
}
|
|
349
346
|
async uploadWithMultipart(path, blob, permissions = "0644") {
|
|
350
347
|
// Initiate multipart upload
|
|
351
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
352
348
|
const initResponse = await this.initiateMultipartUpload(path, permissions);
|
|
353
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
|
|
354
349
|
const uploadId = initResponse.uploadId;
|
|
355
350
|
if (!uploadId) {
|
|
356
351
|
throw new Error("Failed to get upload ID from initiate response");
|
|
@@ -367,26 +362,20 @@ class SandboxFileSystem extends action_js_1.SandboxAction {
|
|
|
367
362
|
const start = (partNumber - 1) * CHUNK_SIZE;
|
|
368
363
|
const end = Math.min(start + CHUNK_SIZE, size);
|
|
369
364
|
const chunk = blob.slice(start, end);
|
|
370
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
371
365
|
batch.push(this.uploadPart(uploadId, partNumber, chunk));
|
|
372
366
|
}
|
|
373
367
|
// Wait for batch to complete
|
|
374
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
375
368
|
const batchResults = await Promise.all(batch);
|
|
376
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-argument
|
|
377
369
|
parts.push(...batchResults.map((r) => ({ partNumber: r.partNumber, etag: r.etag })));
|
|
378
370
|
}
|
|
379
371
|
// Sort parts by partNumber to ensure correct order
|
|
380
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
381
372
|
parts.sort((a, b) => (a.partNumber ?? 0) - (b.partNumber ?? 0));
|
|
382
373
|
// Complete the upload
|
|
383
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
384
374
|
return await this.completeMultipartUpload(uploadId, parts);
|
|
385
375
|
}
|
|
386
376
|
catch (error) {
|
|
387
377
|
// Abort the upload on failure
|
|
388
378
|
try {
|
|
389
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
390
379
|
await this.abortMultipartUpload(uploadId);
|
|
391
380
|
}
|
|
392
381
|
catch (abortError) {
|
|
@@ -58,8 +58,8 @@ class McpTool {
|
|
|
58
58
|
return new URL(`${settings_js_1.settings.runUrl}/${settings_js_1.settings.workspace}/${this.pluralType}/${this.name}`);
|
|
59
59
|
}
|
|
60
60
|
get internalUrl() {
|
|
61
|
-
const
|
|
62
|
-
return new URL(
|
|
61
|
+
const url = (0, internal_js_1.generateInternalUrl)(settings_js_1.settings.workspace, this.type, this.name, settings_js_1.settings.env, settings_js_1.settings.runInternalProtocol, settings_js_1.settings.runInternalHostname, settings_js_1.settings.blCloud, settings_js_1.settings.workspaceId);
|
|
62
|
+
return new URL(url);
|
|
63
63
|
}
|
|
64
64
|
get forcedUrl() {
|
|
65
65
|
return (0, internal_js_1.getForcedUrl)(this.type, this.name);
|
|
@@ -2,3 +2,5 @@ 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;
|