@blaxel/core 0.2.42-preview.92 → 0.2.43-dev.194
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/index.js +30 -4
- package/dist/cjs/cache/index.js +15 -3
- package/dist/cjs/common/env.js +21 -6
- package/dist/cjs/common/internal.js +40 -0
- package/dist/cjs/common/settings.js +5 -2
- package/dist/cjs/index.js +0 -3
- package/dist/cjs/jobs/jobs.js +2 -2
- package/dist/cjs/sandbox/action.js +1 -2
- 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/types/index.d.ts +0 -1
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/agents/index.js +3 -3
- package/dist/esm/authentication/index.js +27 -1
- package/dist/esm/cache/index.js +14 -2
- package/dist/esm/common/env.js +16 -1
- package/dist/esm/common/internal.js +38 -0
- package/dist/esm/common/settings.js +5 -2
- package/dist/esm/index.js +0 -1
- package/dist/esm/jobs/jobs.js +3 -3
- package/dist/esm/sandbox/action.js +2 -3
- package/dist/esm/tools/mcpTool.js +3 -3
- package/package.json +2 -2
|
@@ -6,7 +6,33 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.authentication = authentication;
|
|
7
7
|
const yaml_1 = __importDefault(require("yaml"));
|
|
8
8
|
const env_js_1 = require("../common/env.js");
|
|
9
|
-
|
|
9
|
+
let fs = null;
|
|
10
|
+
let os = null;
|
|
11
|
+
let path = null;
|
|
12
|
+
try {
|
|
13
|
+
const proc = typeof process !== "undefined" ? process : undefined;
|
|
14
|
+
const gw = typeof globalThis !== "undefined" ? globalThis : undefined;
|
|
15
|
+
const hasNodeVersions = (p) => {
|
|
16
|
+
if (typeof p !== "object" || p === null)
|
|
17
|
+
return false;
|
|
18
|
+
const anyP = p;
|
|
19
|
+
if (!("versions" in anyP))
|
|
20
|
+
return false;
|
|
21
|
+
const v = anyP["versions"];
|
|
22
|
+
return !!v && typeof v["node"] === "string";
|
|
23
|
+
};
|
|
24
|
+
const isNode = hasNodeVersions(proc);
|
|
25
|
+
const isBrowser = typeof gw === "object" && gw !== null && typeof gw.window !== "undefined";
|
|
26
|
+
if (isNode && !isBrowser) {
|
|
27
|
+
const req = eval("require");
|
|
28
|
+
fs = req("fs");
|
|
29
|
+
os = req("os");
|
|
30
|
+
path = req("path");
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
// ignore
|
|
35
|
+
}
|
|
10
36
|
const apikey_js_1 = require("./apikey.js");
|
|
11
37
|
const clientcredentials_js_1 = require("./clientcredentials.js");
|
|
12
38
|
const credentials_js_1 = require("./credentials.js");
|
|
@@ -24,12 +50,12 @@ function getCredentials() {
|
|
|
24
50
|
workspace: env_js_1.env.BL_WORKSPACE,
|
|
25
51
|
};
|
|
26
52
|
}
|
|
27
|
-
if (
|
|
53
|
+
if (os === null || fs === null || path === null) {
|
|
28
54
|
return null;
|
|
29
55
|
}
|
|
30
56
|
try {
|
|
31
|
-
const homeDir =
|
|
32
|
-
const config =
|
|
57
|
+
const homeDir = os.homedir();
|
|
58
|
+
const config = fs.readFileSync(path.join(homeDir, ".blaxel/config.yaml"), "utf8");
|
|
33
59
|
const configJson = yaml_1.default.parse(config);
|
|
34
60
|
const workspaceName = env_js_1.env.BL_WORKSPACE || configJson.context.workspace;
|
|
35
61
|
const credentials = configJson.workspaces.find((wk) => wk.name === workspaceName)?.credentials;
|
package/dist/cjs/cache/index.js
CHANGED
|
@@ -5,11 +5,23 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.findFromCache = findFromCache;
|
|
7
7
|
const yaml_1 = __importDefault(require("yaml"));
|
|
8
|
-
|
|
8
|
+
let fs = null;
|
|
9
|
+
try {
|
|
10
|
+
const isNode = typeof process !== "undefined" && typeof process.versions?.node === "string";
|
|
11
|
+
const isBrowser = typeof globalThis !== "undefined" && typeof globalThis?.window !== "undefined";
|
|
12
|
+
if (isNode && !isBrowser) {
|
|
13
|
+
const req = eval("require");
|
|
14
|
+
const loaded = req("fs");
|
|
15
|
+
fs = loaded;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
// ignore
|
|
20
|
+
}
|
|
9
21
|
const cache = new Map();
|
|
10
22
|
try {
|
|
11
|
-
if (
|
|
12
|
-
const cacheString =
|
|
23
|
+
if (fs !== null) {
|
|
24
|
+
const cacheString = fs.readFileSync(".cache.yaml", "utf8");
|
|
13
25
|
const cacheData = yaml_1.default.parseAllDocuments(cacheString);
|
|
14
26
|
for (const doc of cacheData) {
|
|
15
27
|
const jsonDoc = doc.toJSON();
|
package/dist/cjs/common/env.js
CHANGED
|
@@ -6,12 +6,27 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.env = void 0;
|
|
7
7
|
/* eslint-disable */
|
|
8
8
|
const toml_1 = __importDefault(require("toml"));
|
|
9
|
-
|
|
9
|
+
// Avoid importing Node built-ins in environments that don't support them (e.g., Next.js client build)
|
|
10
|
+
const isNode = typeof process !== "undefined" && process.versions != null && process.versions.node != null;
|
|
11
|
+
const isBrowser = typeof globalThis !== "undefined" && globalThis?.window !== undefined;
|
|
12
|
+
let fs = null;
|
|
13
|
+
let dotenv = null;
|
|
14
|
+
if (isNode && !isBrowser) {
|
|
15
|
+
try {
|
|
16
|
+
// Use eval to avoid bundler static analysis of 'require(\"fs\")'
|
|
17
|
+
fs = eval("require")("fs");
|
|
18
|
+
}
|
|
19
|
+
catch { }
|
|
20
|
+
try {
|
|
21
|
+
dotenv = eval("require")("dotenv");
|
|
22
|
+
}
|
|
23
|
+
catch { }
|
|
24
|
+
}
|
|
10
25
|
const secretEnv = {};
|
|
11
26
|
const configEnv = {};
|
|
12
|
-
if (
|
|
27
|
+
if (fs !== null) {
|
|
13
28
|
try {
|
|
14
|
-
const configFile =
|
|
29
|
+
const configFile = fs.readFileSync("blaxel.toml", "utf8");
|
|
15
30
|
const configInfos = toml_1.default.parse(configFile);
|
|
16
31
|
for (const key in configInfos.env) {
|
|
17
32
|
configEnv[key] = configInfos.env[key];
|
|
@@ -19,9 +34,9 @@ if (node_js_1.fs !== null) {
|
|
|
19
34
|
}
|
|
20
35
|
catch (error) { }
|
|
21
36
|
try {
|
|
22
|
-
const secretFile =
|
|
23
|
-
if (
|
|
24
|
-
const parsed =
|
|
37
|
+
const secretFile = fs.readFileSync(".env", "utf8");
|
|
38
|
+
if (dotenv) {
|
|
39
|
+
const parsed = dotenv.parse(secretFile);
|
|
25
40
|
Object.assign(secretEnv, parsed);
|
|
26
41
|
}
|
|
27
42
|
else {
|
|
@@ -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.43-dev.194","commit":"eaaada70f38d291b78d12e2a295e9987cfc3d09b"};
|
|
14
14
|
return packageJson.version || "unknown";
|
|
15
15
|
}
|
|
16
16
|
else {
|
|
@@ -64,7 +64,7 @@ function getCommitHash() {
|
|
|
64
64
|
if (typeof require !== "undefined") {
|
|
65
65
|
// Try to require package.json and look for commit field (set during build)
|
|
66
66
|
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
67
|
-
const packageJson = {"version":"0.2.
|
|
67
|
+
const packageJson = {"version":"0.2.43-dev.194","commit":"eaaada70f38d291b78d12e2a295e9987cfc3d09b"};
|
|
68
68
|
// Check for commit in various possible locations
|
|
69
69
|
const commit = packageJson.commit || packageJson.buildInfo?.commit;
|
|
70
70
|
if (commit) {
|
|
@@ -167,6 +167,9 @@ class Settings {
|
|
|
167
167
|
get blCloud() {
|
|
168
168
|
return env_js_1.env.BL_CLOUD === "true";
|
|
169
169
|
}
|
|
170
|
+
get workspaceId() {
|
|
171
|
+
return env_js_1.env.BL_WORKSPACE_ID || "";
|
|
172
|
+
}
|
|
170
173
|
get generation() {
|
|
171
174
|
return env_js_1.env.BL_GENERATION || "";
|
|
172
175
|
}
|
package/dist/cjs/index.js
CHANGED
|
@@ -14,7 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.getWebSocket = void 0;
|
|
18
17
|
require("./common/autoload");
|
|
19
18
|
__exportStar(require("./agents/index.js"), exports);
|
|
20
19
|
__exportStar(require("./client/client.js"), exports);
|
|
@@ -23,8 +22,6 @@ __exportStar(require("./common/env.js"), exports);
|
|
|
23
22
|
__exportStar(require("./common/errors.js"), exports);
|
|
24
23
|
__exportStar(require("./common/internal.js"), exports);
|
|
25
24
|
__exportStar(require("./common/logger.js"), exports);
|
|
26
|
-
var node_js_1 = require("./common/node.js");
|
|
27
|
-
Object.defineProperty(exports, "getWebSocket", { enumerable: true, get: function () { return node_js_1.getWebSocket; } });
|
|
28
25
|
__exportStar(require("./common/settings.js"), exports);
|
|
29
26
|
__exportStar(require("./jobs/index.js"), exports);
|
|
30
27
|
__exportStar(require("./mcp/index.js"), exports);
|
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) {
|
|
@@ -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;
|
|
@@ -6,7 +6,6 @@ export * from "./common/env.js";
|
|
|
6
6
|
export * from "./common/errors.js";
|
|
7
7
|
export * from "./common/internal.js";
|
|
8
8
|
export * from "./common/logger.js";
|
|
9
|
-
export { getWebSocket } from "./common/node.js";
|
|
10
9
|
export * from "./common/settings.js";
|
|
11
10
|
export * from "./jobs/index.js";
|
|
12
11
|
export * from "./mcp/index.js";
|