@blaxel/core 0.2.59-preview.42 → 0.2.59-preview.43

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 (63) hide show
  1. package/dist/cjs/.tsbuildinfo +1 -1
  2. package/dist/cjs/client/sdk.gen.js +142 -155
  3. package/dist/cjs/common/settings.js +2 -2
  4. package/dist/cjs/sandbox/action.js +2 -2
  5. package/dist/cjs/sandbox/client/sdk.gen.js +1 -103
  6. package/dist/cjs/sandbox/interpreter.js +7 -4
  7. package/dist/cjs/sandbox/preview.js +11 -8
  8. package/dist/cjs/sandbox/sandbox.js +3 -3
  9. package/dist/cjs/sandbox/session.js +11 -11
  10. package/dist/cjs/sandbox/types.js +4 -1
  11. package/dist/cjs/tools/index.js +1 -3
  12. package/dist/cjs/types/client/sdk.gen.d.ts +177 -166
  13. package/dist/cjs/types/client/types.gen.d.ts +1805 -1375
  14. package/dist/cjs/types/sandbox/client/sdk.gen.d.ts +1 -31
  15. package/dist/cjs/types/sandbox/client/types.gen.d.ts +0 -83
  16. package/dist/cjs/types/sandbox/preview.d.ts +2 -2
  17. package/dist/cjs/types/sandbox/sandbox.d.ts +3 -3
  18. package/dist/cjs/types/volume/index.d.ts +3 -3
  19. package/dist/cjs/volume/index.js +12 -14
  20. package/dist/cjs-browser/.tsbuildinfo +1 -1
  21. package/dist/cjs-browser/client/sdk.gen.js +142 -155
  22. package/dist/cjs-browser/common/settings.js +2 -2
  23. package/dist/cjs-browser/sandbox/action.js +2 -2
  24. package/dist/cjs-browser/sandbox/client/sdk.gen.js +1 -103
  25. package/dist/cjs-browser/sandbox/interpreter.js +7 -4
  26. package/dist/cjs-browser/sandbox/preview.js +11 -8
  27. package/dist/cjs-browser/sandbox/sandbox.js +3 -3
  28. package/dist/cjs-browser/sandbox/session.js +11 -11
  29. package/dist/cjs-browser/sandbox/types.js +4 -1
  30. package/dist/cjs-browser/tools/index.js +1 -3
  31. package/dist/cjs-browser/types/client/sdk.gen.d.ts +177 -166
  32. package/dist/cjs-browser/types/client/types.gen.d.ts +1805 -1375
  33. package/dist/cjs-browser/types/sandbox/client/sdk.gen.d.ts +1 -31
  34. package/dist/cjs-browser/types/sandbox/client/types.gen.d.ts +0 -83
  35. package/dist/cjs-browser/types/sandbox/preview.d.ts +2 -2
  36. package/dist/cjs-browser/types/sandbox/sandbox.d.ts +3 -3
  37. package/dist/cjs-browser/types/volume/index.d.ts +3 -3
  38. package/dist/cjs-browser/volume/index.js +12 -14
  39. package/dist/esm/.tsbuildinfo +1 -1
  40. package/dist/esm/client/sdk.gen.js +140 -151
  41. package/dist/esm/common/settings.js +2 -2
  42. package/dist/esm/sandbox/action.js +2 -2
  43. package/dist/esm/sandbox/client/sdk.gen.js +0 -96
  44. package/dist/esm/sandbox/interpreter.js +7 -4
  45. package/dist/esm/sandbox/preview.js +11 -8
  46. package/dist/esm/sandbox/sandbox.js +3 -3
  47. package/dist/esm/sandbox/session.js +11 -11
  48. package/dist/esm/sandbox/types.js +4 -1
  49. package/dist/esm/tools/index.js +1 -3
  50. package/dist/esm/volume/index.js +12 -14
  51. package/dist/esm-browser/.tsbuildinfo +1 -1
  52. package/dist/esm-browser/client/sdk.gen.js +140 -151
  53. package/dist/esm-browser/common/settings.js +2 -2
  54. package/dist/esm-browser/sandbox/action.js +2 -2
  55. package/dist/esm-browser/sandbox/client/sdk.gen.js +0 -96
  56. package/dist/esm-browser/sandbox/interpreter.js +7 -4
  57. package/dist/esm-browser/sandbox/preview.js +11 -8
  58. package/dist/esm-browser/sandbox/sandbox.js +3 -3
  59. package/dist/esm-browser/sandbox/session.js +11 -11
  60. package/dist/esm-browser/sandbox/types.js +4 -1
  61. package/dist/esm-browser/tools/index.js +1 -3
  62. package/dist/esm-browser/volume/index.js +12 -14
  63. package/package.json +1 -1
@@ -3,8 +3,8 @@ import { authentication } from "../authentication/index.js";
3
3
  import { env } from "../common/env.js";
4
4
  import { fs, os, path } from "../common/node.js";
5
5
  // Build info - these placeholders are replaced at build time by build:replace-imports
6
- const BUILD_VERSION = "0.2.59-preview.42";
7
- const BUILD_COMMIT = "c023a821d0d2d84c962e3f68ee6f77978339e7b8";
6
+ const BUILD_VERSION = "0.2.59-preview.43";
7
+ const BUILD_COMMIT = "b0ebd759d4036536a387b2f2150e1b348f17ef2f";
8
8
  const BUILD_SENTRY_DSN = "https://fd5e60e1c9820e1eef5ccebb84a07127@o4508714045276160.ingest.us.sentry.io/4510465864564736";
9
9
  // Cache for config.yaml tracking value
10
10
  let configTrackingValue = null;
@@ -32,7 +32,7 @@ export class SandboxAction {
32
32
  this.sandbox = sandbox;
33
33
  }
34
34
  get name() {
35
- return this.sandbox.metadata?.name ?? "";
35
+ return this.sandbox.metadata.name;
36
36
  }
37
37
  get fallbackUrl() {
38
38
  if (this.externalUrl != this.url) {
@@ -41,7 +41,7 @@ export class SandboxAction {
41
41
  return null;
42
42
  }
43
43
  get externalUrl() {
44
- return this.sandbox.metadata?.url ?? `${settings.runUrl}/${settings.workspace}/sandboxes/${this.name}`;
44
+ return this.sandbox.metadata.url ?? `${settings.runUrl}/${settings.workspace}/sandboxes/${this.name}`;
45
45
  }
46
46
  get internalUrl() {
47
47
  const hash = getGlobalUniqueHash(settings.workspace, "sandbox", this.name);
@@ -1,102 +1,6 @@
1
1
  // This file is auto-generated by @hey-api/openapi-ts
2
2
  import { formDataBodySerializer } from '@hey-api/client-fetch';
3
3
  import { client as _heyApiClient } from "./client.gen.js";
4
- /**
5
- * Welcome message
6
- * Returns a welcome message with links to documentation
7
- */
8
- export const delete_ = (options) => {
9
- return (options?.client ?? _heyApiClient).delete({
10
- security: [
11
- {
12
- scheme: 'bearer',
13
- type: 'http'
14
- }
15
- ],
16
- url: '/',
17
- ...options
18
- });
19
- };
20
- /**
21
- * Welcome message
22
- * Returns a welcome message with links to documentation
23
- */
24
- export const get = (options) => {
25
- return (options?.client ?? _heyApiClient).get({
26
- security: [
27
- {
28
- scheme: 'bearer',
29
- type: 'http'
30
- }
31
- ],
32
- url: '/',
33
- ...options
34
- });
35
- };
36
- /**
37
- * Welcome message
38
- * Returns a welcome message with links to documentation
39
- */
40
- export const options = (options) => {
41
- return (options?.client ?? _heyApiClient).options({
42
- security: [
43
- {
44
- scheme: 'bearer',
45
- type: 'http'
46
- }
47
- ],
48
- url: '/',
49
- ...options
50
- });
51
- };
52
- /**
53
- * Welcome message
54
- * Returns a welcome message with links to documentation
55
- */
56
- export const patch = (options) => {
57
- return (options?.client ?? _heyApiClient).patch({
58
- security: [
59
- {
60
- scheme: 'bearer',
61
- type: 'http'
62
- }
63
- ],
64
- url: '/',
65
- ...options
66
- });
67
- };
68
- /**
69
- * Welcome message
70
- * Returns a welcome message with links to documentation
71
- */
72
- export const post = (options) => {
73
- return (options?.client ?? _heyApiClient).post({
74
- security: [
75
- {
76
- scheme: 'bearer',
77
- type: 'http'
78
- }
79
- ],
80
- url: '/',
81
- ...options
82
- });
83
- };
84
- /**
85
- * Welcome message
86
- * Returns a welcome message with links to documentation
87
- */
88
- export const put = (options) => {
89
- return (options?.client ?? _heyApiClient).put({
90
- security: [
91
- {
92
- scheme: 'bearer',
93
- type: 'http'
94
- }
95
- ],
96
- url: '/',
97
- ...options
98
- });
99
- };
100
4
  /**
101
5
  * Apply code edit
102
6
  * Uses the configured LLM provider (Relace or Morph) to apply a code edit to the original content.
@@ -32,7 +32,7 @@ export class CodeInterpreter extends SandboxInstance {
32
32
  ports: CodeInterpreter.DEFAULT_PORTS,
33
33
  lifecycle: CodeInterpreter.DEFAULT_LIFECYCLE,
34
34
  };
35
- const allowedCopyKeys = new Set(["name", "envs", "memory", "region", "headers"]);
35
+ const allowedCopyKeys = new Set(["name", "envs", "memory", "region", "headers", "labels"]);
36
36
  if (sandbox && typeof sandbox === "object") {
37
37
  if (Array.isArray(sandbox)) {
38
38
  // Skip arrays
@@ -40,10 +40,13 @@ export class CodeInterpreter extends SandboxInstance {
40
40
  else if ("metadata" in sandbox || "spec" in sandbox) {
41
41
  // It's a Sandbox object
42
42
  const sandboxObj = sandbox;
43
- if (sandboxObj.metadata?.name) {
43
+ if (sandboxObj.metadata.name) {
44
44
  payload["name"] = sandboxObj.metadata.name;
45
45
  }
46
- if (sandboxObj.spec?.runtime) {
46
+ if (sandboxObj.metadata.labels) {
47
+ payload["labels"] = sandboxObj.metadata.labels;
48
+ }
49
+ if (sandboxObj.spec.runtime) {
47
50
  if (sandboxObj.spec.runtime.envs) {
48
51
  payload["envs"] = sandboxObj.spec.runtime.envs;
49
52
  }
@@ -51,7 +54,7 @@ export class CodeInterpreter extends SandboxInstance {
51
54
  payload["memory"] = sandboxObj.spec.runtime.memory;
52
55
  }
53
56
  }
54
- if (sandboxObj.spec?.region) {
57
+ if (sandboxObj.spec.region) {
55
58
  payload["region"] = sandboxObj.spec.region;
56
59
  }
57
60
  }
@@ -5,13 +5,13 @@ export class SandboxPreviewToken {
5
5
  this.previewToken = previewToken;
6
6
  }
7
7
  get value() {
8
- return this.previewToken.spec?.token ?? "";
8
+ return this.previewToken.spec.token ?? "";
9
9
  }
10
10
  get expiresAt() {
11
- return this.previewToken.spec?.expiresAt ?? new Date();
11
+ return this.previewToken.spec.expiresAt ?? new Date();
12
12
  }
13
13
  get expired() {
14
- return this.previewToken.spec?.expired ?? false;
14
+ return this.previewToken.spec.expired ?? false;
15
15
  }
16
16
  }
17
17
  export class SandboxPreviewTokens {
@@ -20,10 +20,10 @@ export class SandboxPreviewTokens {
20
20
  this.preview = preview;
21
21
  }
22
22
  get previewName() {
23
- return this.preview.metadata?.name ?? "";
23
+ return this.preview.metadata.name;
24
24
  }
25
25
  get resourceName() {
26
- return this.preview.metadata?.resourceName ?? "";
26
+ return this.preview.metadata.resourceName ?? "";
27
27
  }
28
28
  async create(expiresAt) {
29
29
  const { data } = await createSandboxPreviewToken({
@@ -32,6 +32,9 @@ export class SandboxPreviewTokens {
32
32
  previewName: this.previewName,
33
33
  },
34
34
  body: {
35
+ metadata: {
36
+ name: "token-" + Date.now(),
37
+ },
35
38
  spec: {
36
39
  expiresAt: expiresAt.toISOString(),
37
40
  },
@@ -70,7 +73,7 @@ export class SandboxPreview {
70
73
  this.tokens = new SandboxPreviewTokens(this);
71
74
  }
72
75
  get name() {
73
- return this.preview.metadata?.name ?? "";
76
+ return this.preview.metadata.name;
74
77
  }
75
78
  get metadata() {
76
79
  return this.preview.metadata;
@@ -85,7 +88,7 @@ export class SandboxPreviews {
85
88
  this.sandbox = sandbox;
86
89
  }
87
90
  get sandboxName() {
88
- return this.sandbox.metadata?.name ?? "";
91
+ return this.sandbox.metadata.name;
89
92
  }
90
93
  async list() {
91
94
  const { data } = await listSandboxPreviews({
@@ -108,7 +111,7 @@ export class SandboxPreviews {
108
111
  }
109
112
  async createIfNotExists(preview) {
110
113
  try {
111
- const previewInstance = await this.get(preview.metadata?.name ?? "");
114
+ const previewInstance = await this.get(preview.metadata.name);
112
115
  return previewInstance;
113
116
  }
114
117
  catch (e) {
@@ -108,7 +108,6 @@ export class SandboxInstance {
108
108
  }
109
109
  sandbox.spec.runtime.image = sandbox.spec.runtime.image || defaultImage;
110
110
  sandbox.spec.runtime.memory = sandbox.spec.runtime.memory || defaultMemory;
111
- sandbox.spec.runtime.generation = sandbox.spec.runtime.generation || "mk3";
112
111
  const { data } = await createSandbox({
113
112
  body: sandbox,
114
113
  throwOnError: true,
@@ -146,7 +145,7 @@ export class SandboxInstance {
146
145
  return data;
147
146
  }
148
147
  async delete() {
149
- return await SandboxInstance.delete(this.metadata?.name);
148
+ return await SandboxInstance.delete(this.metadata.name);
150
149
  }
151
150
  static async updateMetadata(sandboxName, metadata) {
152
151
  const sandbox = await SandboxInstance.get(sandboxName);
@@ -165,7 +164,7 @@ export class SandboxInstance {
165
164
  }
166
165
  catch (e) {
167
166
  if (typeof e === "object" && e !== null && "code" in e && (e.code === 409 || e.code === 'SANDBOX_ALREADY_EXISTS')) {
168
- const name = 'name' in sandbox ? sandbox.name : sandbox.metadata?.name;
167
+ const name = 'name' in sandbox ? sandbox.name : sandbox.metadata.name;
169
168
  if (!name) {
170
169
  throw new Error("Sandbox name is required");
171
170
  }
@@ -188,6 +187,7 @@ export class SandboxInstance {
188
187
  const sandboxName = session.name.includes("-") ? session.name.split("-")[0] : session.name;
189
188
  const sandbox = {
190
189
  metadata: { name: sandboxName },
190
+ spec: {},
191
191
  forceUrl: session.url,
192
192
  headers: { "X-Blaxel-Preview-Token": session.token },
193
193
  params: { bl_preview_token: session.token }
@@ -6,7 +6,7 @@ export class SandboxSessions {
6
6
  this.sandbox = sandbox;
7
7
  }
8
8
  get sandboxName() {
9
- return this.sandbox.metadata?.name ?? "";
9
+ return this.sandbox.metadata.name;
10
10
  }
11
11
  async create(options = {}) {
12
12
  const expiresAt = options.expiresAt ?? new Date(Date.now() + 24 * 60 * 60 * 1000); // 1 day from now
@@ -34,7 +34,7 @@ export class SandboxSessions {
34
34
  const tokenObj = await preview.tokens.create(expiresAt);
35
35
  return {
36
36
  name: body.metadata.name,
37
- url: preview.spec?.url ?? "",
37
+ url: preview.spec.url ?? "",
38
38
  token: tokenObj.value,
39
39
  expiresAt: typeof tokenObj.expiresAt === 'string' ? new Date(tokenObj.expiresAt) : tokenObj.expiresAt,
40
40
  };
@@ -69,13 +69,13 @@ export class SandboxSessions {
69
69
  });
70
70
  if (data === null)
71
71
  return [];
72
- return await Promise.all(data.filter((preview) => preview.metadata?.name?.includes("session-")).map(async (preview) => {
73
- const token = await this.getToken(preview.metadata?.name ?? "");
72
+ return await Promise.all(data.filter((preview) => preview.metadata.name?.includes("session-")).map(async (preview) => {
73
+ const token = await this.getToken(preview.metadata.name);
74
74
  return {
75
- name: preview.metadata?.name ?? "",
76
- url: preview.spec?.url ?? "",
77
- token: token?.spec?.token ?? "",
78
- expiresAt: token?.spec?.expiresAt ?? new Date(),
75
+ name: preview.metadata.name,
76
+ url: preview.spec.url ?? "",
77
+ token: token?.spec.token ?? "",
78
+ expiresAt: token?.spec.expiresAt ?? new Date(),
79
79
  };
80
80
  }));
81
81
  }
@@ -89,9 +89,9 @@ export class SandboxSessions {
89
89
  });
90
90
  const token = await this.getToken(name);
91
91
  return {
92
- url: data.spec?.url ?? "",
93
- token: token?.spec?.token ?? "",
94
- expiresAt: token?.spec?.expiresAt ?? new Date(),
92
+ url: data.spec.url ?? "",
93
+ token: token?.spec.token ?? "",
94
+ expiresAt: token?.spec.expiresAt ?? new Date(),
95
95
  };
96
96
  }
97
97
  async delete(name) {
@@ -6,10 +6,13 @@ export function normalizePorts(ports) {
6
6
  for (const port of ports) {
7
7
  if (typeof port === 'object' && port !== null) {
8
8
  if ('name' in port || 'target' in port || 'protocol' in port) {
9
+ if (typeof port.target !== 'number') {
10
+ throw new Error(`Port target must be a number: ${JSON.stringify(port)}`);
11
+ }
9
12
  // It's a Port-like object, ensure protocol defaults to HTTP
10
13
  const normalizedPort = {
11
14
  name: typeof port.name === 'string' ? port.name : undefined,
12
- target: typeof port.target === 'number' ? port.target : undefined,
15
+ target: port.target,
13
16
  protocol: typeof port.protocol === 'string' ? port.protocol : "HTTP"
14
17
  };
15
18
  portObjects.push(normalizedPort);
@@ -25,9 +25,7 @@ export const getToolMetadata = async (tool) => {
25
25
  name: tool,
26
26
  },
27
27
  spec: {
28
- runtime: {
29
- type: "mcp",
30
- },
28
+ runtime: {},
31
29
  },
32
30
  };
33
31
  }
@@ -15,16 +15,16 @@ export class VolumeInstance {
15
15
  return this.volume.status;
16
16
  }
17
17
  get name() {
18
- return this.volume.metadata?.name;
18
+ return this.volume.metadata.name;
19
19
  }
20
20
  get displayName() {
21
- return this.volume.metadata?.displayName;
21
+ return this.volume.metadata.displayName;
22
22
  }
23
23
  get size() {
24
- return this.volume.spec?.size;
24
+ return this.volume.spec.size;
25
25
  }
26
26
  get region() {
27
- return this.volume.spec?.region;
27
+ return this.volume.spec.region;
28
28
  }
29
29
  static async create(config) {
30
30
  const defaultName = `volume-${uuidv4().replace(/-/g, '').substring(0, 8)}`;
@@ -36,18 +36,16 @@ export class VolumeInstance {
36
36
  volume = config;
37
37
  }
38
38
  else {
39
- // It's a VolumeCreateConfiguration
40
- const volumeConfig = config;
41
39
  volume = {
42
40
  metadata: {
43
- name: volumeConfig.name || defaultName,
44
- displayName: volumeConfig.displayName || volumeConfig.name || defaultName,
45
- labels: volumeConfig.labels
41
+ name: config.name || defaultName,
42
+ displayName: config.displayName || config.name || defaultName,
43
+ labels: config.labels
46
44
  },
47
45
  spec: {
48
- size: volumeConfig.size || defaultSize,
49
- region: volumeConfig.region,
50
- template: volumeConfig.template
46
+ size: config.size || defaultSize,
47
+ region: config.region,
48
+ template: config.template
51
49
  }
52
50
  };
53
51
  }
@@ -93,7 +91,7 @@ export class VolumeInstance {
93
91
  return data;
94
92
  }
95
93
  async delete() {
96
- return await VolumeInstance.delete(this.metadata?.name ?? "");
94
+ return await VolumeInstance.delete(this.metadata.name);
97
95
  }
98
96
  static async createIfNotExists(config) {
99
97
  try {
@@ -101,7 +99,7 @@ export class VolumeInstance {
101
99
  }
102
100
  catch (e) {
103
101
  if (typeof e === "object" && e !== null && "code" in e && (e.code === 409 || e.code === 'VOLUME_ALREADY_EXISTS')) {
104
- const name = 'name' in config ? config.name : config.metadata?.name;
102
+ const name = 'name' in config ? config.name : config.metadata.name;
105
103
  if (!name) {
106
104
  throw new Error("Volume name is required");
107
105
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blaxel/core",
3
- "version": "0.2.59-preview.42",
3
+ "version": "0.2.59-preview.43",
4
4
  "description": "Blaxel Core SDK for TypeScript",
5
5
  "license": "MIT",
6
6
  "author": "Blaxel, INC (https://blaxel.ai)",