@blaxel/core 0.2.38 → 0.2.39-dev.192

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.
@@ -1,6 +1,6 @@
1
1
  import { findFromCache } from "../cache/index.js";
2
2
  import { getAgent } from "../client/index.js";
3
- import { getForcedUrl, getGlobalUniqueHash } from "../common/internal.js";
3
+ import { generateInternalUrl, getForcedUrl } from "../common/internal.js";
4
4
  import { logger } from "../common/logger.js";
5
5
  import { settings } from "../common/settings.js";
6
6
  import { startSpan } from '../telemetry/telemetry.js';
@@ -19,8 +19,8 @@ class BlAgent {
19
19
  return new URL(`${settings.runUrl}/${settings.workspace}/agents/${this.agentName}`);
20
20
  }
21
21
  get internalUrl() {
22
- const hash = getGlobalUniqueHash(settings.workspace, "agent", this.agentName);
23
- return new URL(`${settings.runInternalProtocol}://bl-${settings.env}-${hash}.${settings.runInternalHostname}`);
22
+ const url = generateInternalUrl(settings.workspace, "agent", this.agentName, settings.env, settings.runInternalProtocol, settings.runInternalHostname, settings.blCloud, settings.workspaceId);
23
+ return new URL(url);
24
24
  }
25
25
  get forcedUrl() {
26
26
  return getForcedUrl('function', this.agentName);
@@ -180,3 +180,41 @@ export function getForcedUrl(type, name) {
180
180
  }
181
181
  return null;
182
182
  }
183
+ export function getWorkloadTypeShort(type) {
184
+ const lowerType = type.toLowerCase();
185
+ switch (lowerType) {
186
+ case 'agent':
187
+ case 'agents':
188
+ return 'agt';
189
+ case 'mcp':
190
+ case 'mcps':
191
+ case 'function':
192
+ case 'functions':
193
+ return 'mcp';
194
+ case 'sandbox':
195
+ case 'sandboxes':
196
+ return 'sbx';
197
+ case 'job':
198
+ case 'jobs':
199
+ return 'job';
200
+ case 'model':
201
+ case 'models':
202
+ return 'mdl';
203
+ default:
204
+ // fallback to first 3 letters of type
205
+ return lowerType.substring(0, 3);
206
+ }
207
+ }
208
+ export function generateInternalUrl(workspace, type, name, env, protocol, hostname, blCloud, workspaceId) {
209
+ if (blCloud && workspaceId) {
210
+ // New cloud format: bl-ENV-WORKLOAD_CALLED_NAME-WORKLOAD_TYPE_SHORT-WORKSPACE_ID
211
+ const workloadTypeShort = getWorkloadTypeShort(type);
212
+ const subdomain = `bl-${env}-${name}-${workloadTypeShort}-${workspaceId}`;
213
+ return `${protocol}://${subdomain}.${hostname}`;
214
+ }
215
+ else {
216
+ // Legacy format: bl-ENV-HASH.internalhostname
217
+ const hash = getGlobalUniqueHash(workspace, type, name);
218
+ return `${protocol}://bl-${env}-${hash}.${hostname}`;
219
+ }
220
+ }
@@ -7,7 +7,7 @@ function getPackageVersion() {
7
7
  if (typeof require !== "undefined") {
8
8
  // Try to require package.json (Node.js only, gracefully fails in browser)
9
9
  // eslint-disable-next-line @typescript-eslint/no-require-imports
10
- const packageJson = {"version":"0.2.38","commit":"c701e3df0f8c8fbce1dd509c59b2ed4ec296e566"};
10
+ const packageJson = {"version":"0.2.39-dev.192","commit":"981e099b0e22503c22c9a53d5e84133c4fb0959f"};
11
11
  return packageJson.version || "unknown";
12
12
  }
13
13
  else {
@@ -61,7 +61,7 @@ function getCommitHash() {
61
61
  if (typeof require !== "undefined") {
62
62
  // Try to require package.json and look for commit field (set during build)
63
63
  // eslint-disable-next-line @typescript-eslint/no-require-imports
64
- const packageJson = {"version":"0.2.38","commit":"c701e3df0f8c8fbce1dd509c59b2ed4ec296e566"};
64
+ const packageJson = {"version":"0.2.39-dev.192","commit":"981e099b0e22503c22c9a53d5e84133c4fb0959f"};
65
65
  // Check for commit in various possible locations
66
66
  const commit = packageJson.commit || packageJson.buildInfo?.commit;
67
67
  if (commit) {
@@ -164,6 +164,9 @@ class Settings {
164
164
  get blCloud() {
165
165
  return env.BL_CLOUD === "true";
166
166
  }
167
+ get workspaceId() {
168
+ return env.BL_WORKSPACE_ID || "";
169
+ }
167
170
  get generation() {
168
171
  return env.BL_GENERATION || "";
169
172
  }
@@ -1,4 +1,4 @@
1
- import { getForcedUrl, getGlobalUniqueHash } from "../common/internal.js";
1
+ import { generateInternalUrl, getForcedUrl } from "../common/internal.js";
2
2
  import { logger } from "../common/logger.js";
3
3
  import { settings } from "../common/settings.js";
4
4
  import { startSpan } from '../telemetry/telemetry.js';
@@ -17,8 +17,8 @@ class BlJob {
17
17
  return new URL(`${settings.runUrl}/${settings.workspace}/jobs/${this.jobName}`);
18
18
  }
19
19
  get internalUrl() {
20
- const hash = getGlobalUniqueHash(settings.workspace, "job", this.jobName);
21
- return new URL(`${settings.runInternalProtocol}://bl-${settings.env}-${hash}.${settings.runInternalHostname}`);
20
+ const url = generateInternalUrl(settings.workspace, "job", this.jobName, settings.env, settings.runInternalProtocol, settings.runInternalHostname, settings.blCloud, settings.workspaceId);
21
+ return new URL(url);
22
22
  }
23
23
  get forcedUrl() {
24
24
  return getForcedUrl('job', this.jobName);
@@ -1,5 +1,5 @@
1
1
  import { createClient } from "@hey-api/client-fetch";
2
- import { getForcedUrl, getGlobalUniqueHash } from "../common/internal.js";
2
+ import { generateInternalUrl, getForcedUrl } from "../common/internal.js";
3
3
  import { settings } from "../common/settings.js";
4
4
  import { client as defaultClient } from "./client/client.gen.js";
5
5
  export class ResponseError extends Error {
@@ -44,8 +44,7 @@ export class SandboxAction {
44
44
  return `${settings.runUrl}/${settings.workspace}/sandboxes/${this.name}`;
45
45
  }
46
46
  get internalUrl() {
47
- const hash = getGlobalUniqueHash(settings.workspace, "sandbox", this.name);
48
- return `${settings.runInternalProtocol}://bl-${settings.env}-${hash}.${settings.runInternalHostname}`;
47
+ return generateInternalUrl(settings.workspace, "sandbox", this.name, settings.env, settings.runInternalProtocol, settings.runInternalHostname, settings.blCloud, settings.workspaceId);
49
48
  }
50
49
  get client() {
51
50
  if (this.sandbox.forceUrl) {
@@ -1,6 +1,6 @@
1
1
  import { Client as ModelContextProtocolClient } from "@modelcontextprotocol/sdk/client/index.js";
2
2
  import { env } from "../common/env.js";
3
- import { getForcedUrl, getGlobalUniqueHash } from "../common/internal.js";
3
+ import { generateInternalUrl, getForcedUrl } from "../common/internal.js";
4
4
  import { logger } from "../common/logger.js";
5
5
  import { settings } from "../common/settings.js";
6
6
  import { authenticate } from "../index.js";
@@ -53,8 +53,8 @@ export class McpTool {
53
53
  return new URL(`${settings.runUrl}/${settings.workspace}/${this.pluralType}/${this.name}`);
54
54
  }
55
55
  get internalUrl() {
56
- const hash = getGlobalUniqueHash(settings.workspace, this.type, this.name);
57
- return new URL(`${settings.runInternalProtocol}://bl-${settings.env}-${hash}.${settings.runInternalHostname}`);
56
+ const url = generateInternalUrl(settings.workspace, this.type, this.name, settings.env, settings.runInternalProtocol, settings.runInternalHostname, settings.blCloud, settings.workspaceId);
57
+ return new URL(url);
58
58
  }
59
59
  get forcedUrl() {
60
60
  return getForcedUrl(this.type, this.name);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blaxel/core",
3
- "version": "0.2.38",
3
+ "version": "0.2.39-dev.192",
4
4
  "description": "Blaxel Core SDK for TypeScript",
5
5
  "license": "MIT",
6
6
  "author": "Blaxel, INC (https://blaxel.ai)",
@@ -63,7 +63,7 @@
63
63
  "vite": "^5.2.0",
64
64
  "vitest": "^1.5.0"
65
65
  },
66
- "commit": "c701e3df0f8c8fbce1dd509c59b2ed4ec296e566",
66
+ "commit": "981e099b0e22503c22c9a53d5e84133c4fb0959f",
67
67
  "scripts": {
68
68
  "lint": "eslint src/",
69
69
  "dev": "tsc --watch",