@blaxel/core 0.2.79-preview.130 → 0.2.79-preview.132
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.
- package/dist/cjs/.tsbuildinfo +1 -1
- package/dist/cjs/common/settings.js +2 -2
- package/dist/cjs/sandbox/network/network.js +32 -0
- package/dist/cjs/sandbox/process/process.js +70 -22
- package/dist/cjs/sandbox/sandbox.js +10 -0
- package/dist/cjs/types/sandbox/network/network.d.ts +9 -0
- package/dist/cjs/types/sandbox/sandbox.d.ts +8 -0
- package/dist/cjs-browser/.tsbuildinfo +1 -1
- package/dist/cjs-browser/common/settings.js +2 -2
- package/dist/cjs-browser/sandbox/network/network.js +32 -0
- package/dist/cjs-browser/sandbox/process/process.js +70 -22
- package/dist/cjs-browser/sandbox/sandbox.js +10 -0
- package/dist/cjs-browser/types/sandbox/network/network.d.ts +9 -0
- package/dist/cjs-browser/types/sandbox/sandbox.d.ts +8 -0
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/common/settings.js +2 -2
- package/dist/esm/sandbox/network/network.js +32 -0
- package/dist/esm/sandbox/process/process.js +70 -22
- package/dist/esm/sandbox/sandbox.js +10 -0
- package/dist/esm-browser/.tsbuildinfo +1 -1
- package/dist/esm-browser/common/settings.js +2 -2
- package/dist/esm-browser/sandbox/network/network.js +32 -0
- package/dist/esm-browser/sandbox/process/process.js +70 -22
- package/dist/esm-browser/sandbox/sandbox.js +10 -0
- package/package.json +1 -1
|
@@ -11,8 +11,8 @@ const index_js_1 = require("../authentication/index.js");
|
|
|
11
11
|
const env_js_1 = require("../common/env.js");
|
|
12
12
|
const node_js_1 = require("../common/node.js");
|
|
13
13
|
// Build info - these placeholders are replaced at build time by build:replace-imports
|
|
14
|
-
const BUILD_VERSION = "0.2.79-preview.
|
|
15
|
-
const BUILD_COMMIT = "
|
|
14
|
+
const BUILD_VERSION = "0.2.79-preview.132";
|
|
15
|
+
const BUILD_COMMIT = "5fb1f8667d2d0bc7b45ca640257677c647eb5e59";
|
|
16
16
|
const BUILD_SENTRY_DSN = "https://fd5e60e1c9820e1eef5ccebb84a07127@o4508714045276160.ingest.us.sentry.io/4510465864564736";
|
|
17
17
|
// Cache for config.yaml tracking value
|
|
18
18
|
let configTrackingValue = null;
|
|
@@ -1,10 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SandboxNetwork = void 0;
|
|
4
|
+
const settings_js_1 = require("../../common/settings.js");
|
|
4
5
|
const action_js_1 = require("../action.js");
|
|
5
6
|
class SandboxNetwork extends action_js_1.SandboxAction {
|
|
6
7
|
constructor(sandbox) {
|
|
7
8
|
super(sandbox);
|
|
8
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* Fetch a resource served on a sandbox port.
|
|
12
|
+
* The request is proxied through the sandbox's `/port/{port}` endpoint.
|
|
13
|
+
*
|
|
14
|
+
* @param port - The port number inside the sandbox
|
|
15
|
+
* @param path - Optional path appended after the port (default: "/")
|
|
16
|
+
* @param init - Standard RequestInit options forwarded to fetch
|
|
17
|
+
*/
|
|
18
|
+
async fetch(port, path = "/", init) {
|
|
19
|
+
const normalizedPath = path.startsWith("/") ? path : `/${path}`;
|
|
20
|
+
const url = `${this.url}/port/${port}${normalizedPath}`;
|
|
21
|
+
const headers = (this.sandbox.forceUrl ? this.sandbox.headers : undefined) ?? settings_js_1.settings.headers;
|
|
22
|
+
const initHeaders = {};
|
|
23
|
+
if (init?.headers) {
|
|
24
|
+
const entries = init.headers instanceof Headers
|
|
25
|
+
? init.headers.entries()
|
|
26
|
+
: Array.isArray(init.headers)
|
|
27
|
+
? init.headers.values()
|
|
28
|
+
: Object.entries(init.headers).values();
|
|
29
|
+
for (const [key, value] of entries) {
|
|
30
|
+
initHeaders[key] = value;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return this.h2Fetch(url, {
|
|
34
|
+
...init,
|
|
35
|
+
headers: {
|
|
36
|
+
...headers,
|
|
37
|
+
...initHeaders,
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
}
|
|
9
41
|
}
|
|
10
42
|
exports.SandboxNetwork = SandboxNetwork;
|
|
@@ -18,7 +18,24 @@ class SandboxProcess extends action_js_1.SandboxAction {
|
|
|
18
18
|
console.error("Stream error:", err);
|
|
19
19
|
}
|
|
20
20
|
};
|
|
21
|
+
const processLine = (line) => {
|
|
22
|
+
if (line.startsWith("[keepalive]")) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (line.startsWith('stdout:')) {
|
|
26
|
+
options.onStdout?.(line.slice(7));
|
|
27
|
+
options.onLog?.(line.slice(7));
|
|
28
|
+
}
|
|
29
|
+
else if (line.startsWith('stderr:')) {
|
|
30
|
+
options.onStderr?.(line.slice(7));
|
|
31
|
+
options.onLog?.(line.slice(7));
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
options.onLog?.(line);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
21
37
|
const done = (async () => {
|
|
38
|
+
let buffer = '';
|
|
22
39
|
try {
|
|
23
40
|
const headers = this.sandbox.forceUrl ? this.sandbox.headers : settings_js_1.settings.headers;
|
|
24
41
|
const stream = await this.h2Fetch(`${this.url}/process/${identifier}/logs/stream`, {
|
|
@@ -36,7 +53,6 @@ class SandboxProcess extends action_js_1.SandboxAction {
|
|
|
36
53
|
}
|
|
37
54
|
const reader = stream.body.getReader();
|
|
38
55
|
const decoder = new TextDecoder();
|
|
39
|
-
let buffer = '';
|
|
40
56
|
while (true) {
|
|
41
57
|
const result = await reader.read();
|
|
42
58
|
if (result.done)
|
|
@@ -47,25 +63,21 @@ class SandboxProcess extends action_js_1.SandboxAction {
|
|
|
47
63
|
const lines = buffer.split(/\r?\n/);
|
|
48
64
|
buffer = lines.pop();
|
|
49
65
|
for (const line of lines) {
|
|
50
|
-
|
|
51
|
-
continue;
|
|
52
|
-
}
|
|
53
|
-
if (line.startsWith('stdout:')) {
|
|
54
|
-
options.onStdout?.(line.slice(7));
|
|
55
|
-
options.onLog?.(line.slice(7));
|
|
56
|
-
}
|
|
57
|
-
else if (line.startsWith('stderr:')) {
|
|
58
|
-
options.onStderr?.(line.slice(7));
|
|
59
|
-
options.onLog?.(line.slice(7));
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
options.onLog?.(line);
|
|
63
|
-
}
|
|
66
|
+
processLine(line);
|
|
64
67
|
}
|
|
65
68
|
}
|
|
69
|
+
// Flush the TextDecoder and process any remaining buffered data
|
|
70
|
+
buffer += decoder.decode();
|
|
71
|
+
if (buffer.trim()) {
|
|
72
|
+
processLine(buffer);
|
|
73
|
+
}
|
|
66
74
|
}
|
|
67
75
|
catch (err) {
|
|
68
76
|
if (err && typeof err === 'object' && 'name' in err && err.name === 'AbortError') {
|
|
77
|
+
// Process remaining buffer before returning on abort
|
|
78
|
+
if (buffer.trim()) {
|
|
79
|
+
processLine(buffer);
|
|
80
|
+
}
|
|
69
81
|
return;
|
|
70
82
|
}
|
|
71
83
|
handleError(err instanceof Error ? err : new Error('Unknown stream error'));
|
|
@@ -215,15 +227,51 @@ class SandboxProcess extends action_js_1.SandboxAction {
|
|
|
215
227
|
}
|
|
216
228
|
}
|
|
217
229
|
}
|
|
218
|
-
//
|
|
230
|
+
// Flush the TextDecoder and process any remaining buffered data
|
|
231
|
+
buffer += decoder.decode();
|
|
219
232
|
if (buffer.trim()) {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
233
|
+
let parsed = null;
|
|
234
|
+
try {
|
|
235
|
+
parsed = JSON.parse(buffer.trim());
|
|
236
|
+
}
|
|
237
|
+
catch (e) {
|
|
238
|
+
// Not valid JSON — try legacy result: prefix format
|
|
239
|
+
if (buffer.startsWith('result:')) {
|
|
240
|
+
const jsonStr = buffer.slice(7);
|
|
241
|
+
try {
|
|
242
|
+
result = JSON.parse(jsonStr);
|
|
243
|
+
}
|
|
244
|
+
catch {
|
|
245
|
+
throw new Error(`Failed to parse result JSON: ${jsonStr}`);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
// Not a legacy result line — surface the original parse error
|
|
250
|
+
throw e;
|
|
224
251
|
}
|
|
225
|
-
|
|
226
|
-
|
|
252
|
+
}
|
|
253
|
+
if (parsed) {
|
|
254
|
+
switch (parsed.type) {
|
|
255
|
+
case 'stdout':
|
|
256
|
+
if (parsed.data) {
|
|
257
|
+
options.onStdout?.(parsed.data);
|
|
258
|
+
options.onLog?.(parsed.data);
|
|
259
|
+
}
|
|
260
|
+
break;
|
|
261
|
+
case 'stderr':
|
|
262
|
+
if (parsed.data) {
|
|
263
|
+
options.onStderr?.(parsed.data);
|
|
264
|
+
options.onLog?.(parsed.data);
|
|
265
|
+
}
|
|
266
|
+
break;
|
|
267
|
+
case 'result':
|
|
268
|
+
try {
|
|
269
|
+
result = JSON.parse(parsed.data);
|
|
270
|
+
}
|
|
271
|
+
catch {
|
|
272
|
+
throw new Error(`Failed to parse result JSON: ${parsed.data}`);
|
|
273
|
+
}
|
|
274
|
+
break;
|
|
227
275
|
}
|
|
228
276
|
}
|
|
229
277
|
}
|
|
@@ -110,6 +110,16 @@ class SandboxInstance {
|
|
|
110
110
|
get expiresIn() {
|
|
111
111
|
return this.sandbox.expiresIn;
|
|
112
112
|
}
|
|
113
|
+
/**
|
|
114
|
+
* Fetch a resource served on a sandbox port.
|
|
115
|
+
*
|
|
116
|
+
* @param port - The port number inside the sandbox
|
|
117
|
+
* @param path - Optional path appended after the port (default: "/")
|
|
118
|
+
* @param init - Standard RequestInit options forwarded to fetch
|
|
119
|
+
*/
|
|
120
|
+
async fetch(port, path = "/", init) {
|
|
121
|
+
return this.network.fetch(port, path, init);
|
|
122
|
+
}
|
|
113
123
|
/* eslint-disable */
|
|
114
124
|
async wait({ maxWait = 60000, interval = 1000 } = {}) {
|
|
115
125
|
logger_js_1.logger.warn("⚠️ Warning: sandbox.wait() is deprecated. You don't need to wait for the sandbox to be deployed anymore.");
|
|
@@ -2,4 +2,13 @@ import { Sandbox } from "../../client/types.gen.js";
|
|
|
2
2
|
import { SandboxAction } from "../action.js";
|
|
3
3
|
export declare class SandboxNetwork extends SandboxAction {
|
|
4
4
|
constructor(sandbox: Sandbox);
|
|
5
|
+
/**
|
|
6
|
+
* Fetch a resource served on a sandbox port.
|
|
7
|
+
* The request is proxied through the sandbox's `/port/{port}` endpoint.
|
|
8
|
+
*
|
|
9
|
+
* @param port - The port number inside the sandbox
|
|
10
|
+
* @param path - Optional path appended after the port (default: "/")
|
|
11
|
+
* @param init - Standard RequestInit options forwarded to fetch
|
|
12
|
+
*/
|
|
13
|
+
fetch(port: number, path?: string, init?: RequestInit): Promise<Response>;
|
|
5
14
|
}
|
|
@@ -31,6 +31,14 @@ export declare class SandboxInstance {
|
|
|
31
31
|
*/
|
|
32
32
|
private static attachH2Session;
|
|
33
33
|
get expiresIn(): number | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Fetch a resource served on a sandbox port.
|
|
36
|
+
*
|
|
37
|
+
* @param port - The port number inside the sandbox
|
|
38
|
+
* @param path - Optional path appended after the port (default: "/")
|
|
39
|
+
* @param init - Standard RequestInit options forwarded to fetch
|
|
40
|
+
*/
|
|
41
|
+
fetch(port: number, path?: string, init?: RequestInit): Promise<Response>;
|
|
34
42
|
wait({ maxWait, interval }?: {
|
|
35
43
|
maxWait?: number;
|
|
36
44
|
interval?: number;
|