@blaxel/core 0.3.1 → 0.3.2-preview.215

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.
@@ -22,8 +22,8 @@ function missingCredentialsMessage() {
22
22
  return "No Blaxel credentials found. Set the BL_API_KEY and BL_WORKSPACE environment variables, or run `bl login`.";
23
23
  }
24
24
  // Build info - these placeholders are replaced at build time by build:replace-imports
25
- const BUILD_VERSION = "0.3.1";
26
- const BUILD_COMMIT = "06b4bb451ef8797cbc2cd3e3a957d62c45f2cc12";
25
+ const BUILD_VERSION = "0.3.2-preview.215";
26
+ const BUILD_COMMIT = "eeeafbbd89c8ddbb2cb3785162b95be5a4e86f59";
27
27
  const BUILD_SENTRY_DSN = "https://fd5e60e1c9820e1eef5ccebb84a07127@o4508714045276160.ingest.us.sentry.io/4510465864564736";
28
28
  const BLAXEL_API_VERSION = "2026-04-28";
29
29
  // Cache for config.yaml tracking value
@@ -18,6 +18,40 @@ export function retryOnTransient(fn) {
18
18
  // otherwise defaults to the higher idempotent-read budget (sandboxReadRetries).
19
19
  return retryOnTransientReset(fn, { retries: settings.fsPartRetries });
20
20
  }
21
+ async function blobFromReadableStream(stream) {
22
+ const reader = stream.getReader();
23
+ const chunks = [];
24
+ try {
25
+ while (true) {
26
+ const { value, done } = await reader.read();
27
+ if (done)
28
+ break;
29
+ if (value)
30
+ chunks.push(value);
31
+ }
32
+ }
33
+ finally {
34
+ reader.releaseLock();
35
+ }
36
+ return new Blob(chunks);
37
+ }
38
+ async function normalizeBinaryDownload(data, response) {
39
+ if (data instanceof Blob)
40
+ return data;
41
+ if (typeof data === "string")
42
+ return new Blob([data]);
43
+ if (data instanceof ArrayBuffer)
44
+ return new Blob([data]);
45
+ if (ArrayBuffer.isView(data)) {
46
+ const bytes = new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
47
+ return new Blob([bytes]);
48
+ }
49
+ if (data instanceof ReadableStream)
50
+ return blobFromReadableStream(data);
51
+ if (response.body)
52
+ return blobFromReadableStream(response.body);
53
+ throw new Error(`Unsupported binary download response: ${data === null ? "null" : typeof data}`);
54
+ }
21
55
  export class SandboxFileSystem extends SandboxAction {
22
56
  process;
23
57
  constructor(sandbox, process) {
@@ -184,12 +218,10 @@ export class SandboxFileSystem extends SandboxAction {
184
218
  headers: {
185
219
  'Accept': 'application/octet-stream',
186
220
  },
221
+ parseAs: 'blob',
187
222
  }));
188
223
  this.handleResponseError(response, data, error);
189
- if (typeof data === 'string') {
190
- return new Blob([data]);
191
- }
192
- return data;
224
+ return normalizeBinaryDownload(data, response);
193
225
  });
194
226
  }
195
227
  async download(src, destinationPath, { mode = 0o644 } = {}) {