@blaxel/core 0.2.44 → 0.2.45-dev.203

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.
Files changed (47) hide show
  1. package/dist/cjs/.tsbuildinfo +1 -1
  2. package/dist/cjs/agents/index.js +2 -2
  3. package/dist/cjs/client/sdk.gen.js +19 -2
  4. package/dist/cjs/common/internal.js +40 -0
  5. package/dist/cjs/common/settings.js +5 -2
  6. package/dist/cjs/jobs/jobs.js +2 -2
  7. package/dist/cjs/sandbox/action.js +1 -2
  8. package/dist/cjs/sandbox/sandbox.js +20 -5
  9. package/dist/cjs/tools/mcpTool.js +2 -2
  10. package/dist/cjs/types/client/sdk.gen.d.ts +9 -1
  11. package/dist/cjs/types/client/types.gen.d.ts +39 -0
  12. package/dist/cjs/types/common/internal.d.ts +2 -0
  13. package/dist/cjs/types/common/settings.d.ts +1 -0
  14. package/dist/cjs/types/sandbox/types.d.ts +1 -0
  15. package/dist/cjs-browser/.tsbuildinfo +1 -1
  16. package/dist/cjs-browser/agents/index.js +2 -2
  17. package/dist/cjs-browser/client/sdk.gen.js +19 -2
  18. package/dist/cjs-browser/common/internal.js +40 -0
  19. package/dist/cjs-browser/common/settings.js +5 -2
  20. package/dist/cjs-browser/jobs/jobs.js +2 -2
  21. package/dist/cjs-browser/sandbox/action.js +1 -2
  22. package/dist/cjs-browser/sandbox/sandbox.js +20 -5
  23. package/dist/cjs-browser/tools/mcpTool.js +2 -2
  24. package/dist/cjs-browser/types/client/sdk.gen.d.ts +9 -1
  25. package/dist/cjs-browser/types/client/types.gen.d.ts +39 -0
  26. package/dist/cjs-browser/types/common/internal.d.ts +2 -0
  27. package/dist/cjs-browser/types/common/settings.d.ts +1 -0
  28. package/dist/cjs-browser/types/sandbox/types.d.ts +1 -0
  29. package/dist/esm/.tsbuildinfo +1 -1
  30. package/dist/esm/agents/index.js +3 -3
  31. package/dist/esm/client/sdk.gen.js +16 -0
  32. package/dist/esm/common/internal.js +38 -0
  33. package/dist/esm/common/settings.js +5 -2
  34. package/dist/esm/jobs/jobs.js +3 -3
  35. package/dist/esm/sandbox/action.js +2 -3
  36. package/dist/esm/sandbox/sandbox.js +20 -5
  37. package/dist/esm/tools/mcpTool.js +3 -3
  38. package/dist/esm-browser/.tsbuildinfo +1 -1
  39. package/dist/esm-browser/agents/index.js +3 -3
  40. package/dist/esm-browser/client/sdk.gen.js +16 -0
  41. package/dist/esm-browser/common/internal.js +38 -0
  42. package/dist/esm-browser/common/settings.js +5 -2
  43. package/dist/esm-browser/jobs/jobs.js +3 -3
  44. package/dist/esm-browser/sandbox/action.js +2 -3
  45. package/dist/esm-browser/sandbox/sandbox.js +20 -5
  46. package/dist/esm-browser/tools/mcpTool.js +3 -3
  47. package/package.json +3 -3
@@ -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.44","commit":"52da44ff3b0537ad594caae9bcf6de874d6f96fb"};
10
+ const packageJson = {"version":"0.2.45-dev.203","commit":"8394b4a8092cc5decc5f7b5a2a37ce9007da9ceb"};
11
11
  return packageJson.version || "unknown";
12
12
  }
13
13
  else {
@@ -59,7 +59,7 @@ function getCommitHash() {
59
59
  if (typeof require !== "undefined") {
60
60
  // Try to require package.json and look for commit field (set during build)
61
61
  // eslint-disable-next-line @typescript-eslint/no-require-imports
62
- const packageJson = {"version":"0.2.44","commit":"52da44ff3b0537ad594caae9bcf6de874d6f96fb"};
62
+ const packageJson = {"version":"0.2.45-dev.203","commit":"8394b4a8092cc5decc5f7b5a2a37ce9007da9ceb"};
63
63
  // Check for commit in various possible locations
64
64
  const commit = packageJson.commit || packageJson.buildInfo?.commit;
65
65
  if (commit) {
@@ -162,6 +162,9 @@ class Settings {
162
162
  get blCloud() {
163
163
  return env.BL_CLOUD === "true";
164
164
  }
165
+ get workspaceId() {
166
+ return env.BL_WORKSPACE_ID || "";
167
+ }
165
168
  get generation() {
166
169
  return env.BL_GENERATION || "";
167
170
  }
@@ -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 this.sandbox.metadata?.url ?? `${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,7 +1,6 @@
1
1
  import { v4 as uuidv4 } from "uuid";
2
2
  import { createSandbox, deleteSandbox, getSandbox, listSandboxes, updateSandbox } from "../client/index.js";
3
3
  import { logger } from "../common/logger.js";
4
- import { settings } from "../common/settings.js";
5
4
  import { SandboxFileSystem } from "./filesystem/index.js";
6
5
  import { SandboxNetwork } from "./network/index.js";
7
6
  import { SandboxPreviews } from "./preview.js";
@@ -41,12 +40,19 @@ export class SandboxInstance {
41
40
  return this;
42
41
  }
43
42
  static async create(sandbox, { safe = true } = {}) {
44
- const env = settings.env;
45
43
  const defaultName = `sandbox-${uuidv4().replace(/-/g, '').substring(0, 8)}`;
46
- const defaultImage = `blaxel/${env}-base:latest`;
44
+ const defaultImage = `blaxel/base:latest`;
47
45
  const defaultMemory = 4096;
48
46
  // Handle SandboxCreateConfiguration or simple dict with name/image/memory/ports/envs/volumes keys
49
- if (!sandbox || 'name' in sandbox || 'image' in sandbox || 'memory' in sandbox || 'ports' in sandbox || 'envs' in sandbox || 'volumes' in sandbox || 'lifecycle' in sandbox) {
47
+ if (!sandbox ||
48
+ 'name' in sandbox ||
49
+ 'image' in sandbox ||
50
+ 'memory' in sandbox ||
51
+ 'ports' in sandbox ||
52
+ 'envs' in sandbox ||
53
+ 'volumes' in sandbox ||
54
+ 'lifecycle' in sandbox ||
55
+ 'snapshotEnabled' in sandbox) {
50
56
  if (!sandbox)
51
57
  sandbox = {};
52
58
  if (!sandbox.name)
@@ -62,6 +68,7 @@ export class SandboxInstance {
62
68
  const expires = sandbox.expires;
63
69
  const region = sandbox.region;
64
70
  const lifecycle = sandbox.lifecycle;
71
+ const snapshotEnabled = sandbox.snapshotEnabled;
65
72
  sandbox = {
66
73
  metadata: { name: sandbox.name },
67
74
  spec: {
@@ -72,9 +79,10 @@ export class SandboxInstance {
72
79
  ports: ports,
73
80
  envs: envs,
74
81
  generation: "mk3",
82
+ snapshotEnabled,
75
83
  },
76
84
  volumes: volumes,
77
- lifecycle: lifecycle
85
+ lifecycle: lifecycle,
78
86
  }
79
87
  };
80
88
  if (ttl) {
@@ -154,7 +162,14 @@ export class SandboxInstance {
154
162
  if (!name) {
155
163
  throw new Error("Sandbox name is required");
156
164
  }
165
+ // Get the existing sandbox to check its status
157
166
  const sandboxInstance = await SandboxInstance.get(name);
167
+ // If the sandbox is TERMINATED, treat it as not existing
168
+ if (sandboxInstance.status === "TERMINATED") {
169
+ // Create a new sandbox - backend will handle cleanup of the terminated one
170
+ return await SandboxInstance.create(sandbox);
171
+ }
172
+ // Otherwise return the existing running sandbox
158
173
  return sandboxInstance;
159
174
  }
160
175
  throw e;
@@ -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";
@@ -55,8 +55,8 @@ export class McpTool {
55
55
  return new URL(`${settings.runUrl}/${settings.workspace}/${this.pluralType}/${this.name}`);
56
56
  }
57
57
  get internalUrl() {
58
- const hash = getGlobalUniqueHash(settings.workspace, this.type, this.name);
59
- return new URL(`${settings.runInternalProtocol}://bl-${settings.env}-${hash}.${settings.runInternalHostname}`);
58
+ const url = generateInternalUrl(settings.workspace, this.type, this.name, settings.env, settings.runInternalProtocol, settings.runInternalHostname, settings.blCloud, settings.workspaceId);
59
+ return new URL(url);
60
60
  }
61
61
  get forcedUrl() {
62
62
  return getForcedUrl(this.type, this.name);