@blaxel/core 0.3.18-dev.283 → 0.3.18-preview.284

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.
@@ -30,8 +30,8 @@ function missingCredentialsMessage() {
30
30
  return "No Blaxel credentials found. Set the BL_API_KEY and BL_WORKSPACE environment variables, or run `bl login`.";
31
31
  }
32
32
  // Build info - these placeholders are replaced at build time by build:replace-imports
33
- const BUILD_VERSION = "0.3.18-dev.283";
34
- const BUILD_COMMIT = "fed607fe45d4a15407e77f7c40f31815d763df5a";
33
+ const BUILD_VERSION = "0.3.18-preview.284";
34
+ const BUILD_COMMIT = "57fc469276ceec702626782b675333c68e6bce4d";
35
35
  const BUILD_SENTRY_DSN = "https://fd5e60e1c9820e1eef5ccebb84a07127@o4508714045276160.ingest.us.sentry.io/4510465864564736";
36
36
  const BLAXEL_API_VERSION = "2026-04-28";
37
37
  // Bun < 1.3.11 never sends connection-level WINDOW_UPDATE: the pooled h2
@@ -100,11 +100,6 @@ function getOsArch() {
100
100
  }
101
101
  return "browser/unknown";
102
102
  }
103
- /**
104
- * An integration built on this SDK identifies itself with one User-Agent
105
- * product token: `<name>/<semver>`, lowercase name.
106
- */
107
- const INTEGRATION_TOKEN_PATTERN = /^[a-z0-9][a-z0-9._-]*\/\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/;
108
103
  class Settings {
109
104
  _credentials;
110
105
  config;
@@ -201,34 +196,14 @@ class Settings {
201
196
  get apiVersion() {
202
197
  return env_js_1.env.BL_API_VERSION || BLAXEL_API_VERSION;
203
198
  }
204
- /**
205
- * Product token identifying the integration built on this SDK, or `""`.
206
- * Resolved from `config.integration`, then `BL_INTEGRATION`. See `Config.integration`.
207
- */
208
- get integration() {
209
- const value = this.config.integration ?? env_js_1.env.BL_INTEGRATION ?? "";
210
- if (!value) {
211
- return "";
212
- }
213
- if (!INTEGRATION_TOKEN_PATTERN.test(value)) {
214
- logger_js_1.logger.warn(`Ignoring invalid Blaxel integration token "${value}": expected <name>/<semver> with a lowercase name`);
215
- return "";
216
- }
217
- return value;
218
- }
219
- set integration(value) {
220
- this.config.integration = value;
221
- }
222
199
  get headers() {
223
200
  this.assertCredentials();
224
201
  const osArch = getOsArch();
225
- const sdkUserAgent = `blaxel/sdk/typescript/${this.version} (${osArch}) blaxel/${this.commit}`;
226
- const integration = this.integration;
227
202
  return {
228
203
  "x-blaxel-authorization": this.authorization,
229
204
  "x-blaxel-workspace": this.workspace || "",
230
205
  "Blaxel-Version": this.apiVersion,
231
- "User-Agent": integration ? `${sdkUserAgent} ${integration}` : sdkUserAgent,
206
+ "User-Agent": `blaxel/sdk/typescript/${this.version} (${osArch}) blaxel/${this.commit}`,
232
207
  };
233
208
  }
234
209
  get name() {
@@ -251,53 +251,3 @@ const h2_runtime_js_1 = require("./h2-runtime.js");
251
251
  });
252
252
  });
253
253
  });
254
- (0, vitest_1.describe)('Settings.integration', () => {
255
- const sdkUserAgent = /^blaxel\/sdk\/typescript\/\S+ \([^)]+\) blaxel\/\S+/;
256
- async function authenticated() {
257
- const { settings } = await Promise.resolve().then(() => __importStar(require('./settings.js')));
258
- settings.credentials = new apikey_js_1.ApiKey({ apiKey: 'test-key', workspace: 'test-ws' });
259
- delete settings.config.integration;
260
- delete process.env.BL_INTEGRATION;
261
- return settings;
262
- }
263
- (0, vitest_1.afterEach)(async () => {
264
- const { settings } = await Promise.resolve().then(() => __importStar(require('./settings.js')));
265
- delete settings.config.integration;
266
- delete process.env.BL_INTEGRATION;
267
- });
268
- (0, vitest_1.it)('sends the plain SDK User-Agent by default', async () => {
269
- const settings = await authenticated();
270
- (0, vitest_1.expect)(settings.integration).toBe('');
271
- (0, vitest_1.expect)(settings.headers['User-Agent']).toMatch(new RegExp(sdkUserAgent.source + '$'));
272
- });
273
- (0, vitest_1.it)('appends the token set programmatically, once', async () => {
274
- const settings = await authenticated();
275
- settings.integration = 'deepseek-harness-blaxel-sandbox/0.1.2';
276
- const userAgent = settings.headers['User-Agent'];
277
- (0, vitest_1.expect)(userAgent).toMatch(sdkUserAgent);
278
- (0, vitest_1.expect)(userAgent.endsWith(' deepseek-harness-blaxel-sandbox/0.1.2')).toBe(true);
279
- (0, vitest_1.expect)(userAgent.split('deepseek-harness-blaxel-sandbox').length).toBe(2);
280
- });
281
- (0, vitest_1.it)('reads BL_INTEGRATION when nothing is set programmatically, and config wins', async () => {
282
- const settings = await authenticated();
283
- process.env.BL_INTEGRATION = 'herdr/1.4.0-rc.1';
284
- (0, vitest_1.expect)(settings.headers['User-Agent'].endsWith(' herdr/1.4.0-rc.1')).toBe(true);
285
- settings.setConfig({ ...settings.config, integration: 'deepseek-harness-blaxel-sandbox/0.1.2' });
286
- (0, vitest_1.expect)(settings.headers['User-Agent'].endsWith(' deepseek-harness-blaxel-sandbox/0.1.2')).toBe(true);
287
- });
288
- vitest_1.it.each(['Deepseek/0.1.2', 'deepseek-harness', 'deepseek/0.1', 'a/1.0.0 b/1.0.0', 'deepseek/0.1.2 (extra)', ' x/1.0.0'])('ignores the invalid token %j', async (value) => {
289
- const settings = await authenticated();
290
- settings.integration = value;
291
- (0, vitest_1.expect)(settings.integration).toBe('');
292
- (0, vitest_1.expect)(settings.headers['User-Agent']).toMatch(new RegExp(sdkUserAgent.source + '$'));
293
- });
294
- (0, vitest_1.it)('changes no header other than User-Agent', async () => {
295
- const settings = await authenticated();
296
- const plain = { ...settings.headers };
297
- settings.integration = 'deepseek-harness-blaxel-sandbox/0.1.2';
298
- const tagged = { ...settings.headers };
299
- delete plain['User-Agent'];
300
- delete tagged['User-Agent'];
301
- (0, vitest_1.expect)(tagged).toEqual(plain);
302
- });
303
- });
@@ -261,6 +261,7 @@ class SandboxInstance {
261
261
  ...(options.customDomain !== undefined ? { customDomain: options.customDomain } : {}),
262
262
  ...(options.prefix !== undefined ? { prefix: options.prefix } : {}),
263
263
  ...(options.snapshotId !== undefined ? { snapshotId: options.snapshotId } : {}),
264
+ ...(options.envs !== undefined ? { envs: options.envs } : {}),
264
265
  },
265
266
  throwOnError: true,
266
267
  });
@@ -3707,6 +3707,10 @@ export type SandboxForkRequest = {
3707
3707
  * Custom domain for the application
3708
3708
  */
3709
3709
  customDomain?: string;
3710
+ /**
3711
+ * Environment variables the fork runs with, on top of the ones the source has. A variable the source already carries takes this value in the fork, one it does not is added, and every other variable of the source is kept.
3712
+ */
3713
+ envs?: Array<Env>;
3710
3714
  /**
3711
3715
  * Port to expose from the sandbox
3712
3716
  */
@@ -11,15 +11,6 @@ export type Config = {
11
11
  proxy?: string;
12
12
  apikey?: string;
13
13
  workspace?: string;
14
- /**
15
- * Product token identifying the integration built on this SDK, appended to
16
- * the `User-Agent` so Blaxel can attribute traffic to it. Format
17
- * `<name>/<semver>` with a lowercase name, e.g.
18
- * `"deepseek-harness-blaxel-sandbox/0.1.2"`. Also settable through
19
- * `BL_INTEGRATION` or `settings.integration`. An invalid value is ignored
20
- * with a warning.
21
- */
22
- integration?: string;
23
14
  /**
24
15
  * Disables the SDK-managed HTTP/2 transport. Defaults to `false` (H2 on);
25
16
  * set this to `true` (or `BL_DISABLE_H2=1`) to opt out of H2. Note that H2 is
@@ -113,12 +104,6 @@ declare class Settings {
113
104
  get commit(): string;
114
105
  get sentryDsn(): string;
115
106
  get apiVersion(): string;
116
- /**
117
- * Product token identifying the integration built on this SDK, or `""`.
118
- * Resolved from `config.integration`, then `BL_INTEGRATION`. See `Config.integration`.
119
- */
120
- get integration(): string;
121
- set integration(value: string | undefined);
122
107
  get headers(): Record<string, string>;
123
108
  get name(): string;
124
109
  get type(): string;
@@ -1,5 +1,5 @@
1
1
  import type http2 from "http2";
2
- import { type ListSandboxesData, type SandboxForkResponse, type SandboxLifecycle, type Sandbox as SandboxModel, type SandboxRestoreResponse, type SandboxSnapshot, type SandboxSnapshots } from "../client/index.js";
2
+ import { type Env, type ListSandboxesData, type SandboxForkResponse, type SandboxLifecycle, type Sandbox as SandboxModel, type SandboxRestoreResponse, type SandboxSnapshot, type SandboxSnapshots } from "../client/index.js";
3
3
  import { SandboxCodegen } from "./codegen/index.js";
4
4
  import { SandboxDrive } from "./drive/index.js";
5
5
  import { SandboxFileSystem } from "./filesystem/index.js";
@@ -28,6 +28,12 @@ export type SandboxForkOptions = {
28
28
  * sandbox from a snapshot.
29
29
  */
30
30
  snapshotId?: string;
31
+ /**
32
+ * Environment variables the fork runs with, on top of the ones the source
33
+ * has: a variable the source already carries takes this value in the fork,
34
+ * one it does not is added, and every other variable of the source is kept.
35
+ */
36
+ envs?: Env[];
31
37
  };
32
38
  /** How long to wait for an archive, or its restore, to finish. */
33
39
  export type SandboxArchiveOptions = {