@boxlite-ai/boxlite 0.1.0
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/README.md +434 -0
- package/dist/browserbox.d.ts +145 -0
- package/dist/browserbox.d.ts.map +1 -0
- package/dist/browserbox.js +234 -0
- package/dist/browserbox.js.map +1 -0
- package/dist/codebox.d.ts +144 -0
- package/dist/codebox.d.ts.map +1 -0
- package/dist/codebox.js +202 -0
- package/dist/codebox.js.map +1 -0
- package/dist/computerbox.d.ts +271 -0
- package/dist/computerbox.d.ts.map +1 -0
- package/dist/computerbox.js +406 -0
- package/dist/computerbox.js.map +1 -0
- package/dist/constants.d.ts +24 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +32 -0
- package/dist/constants.js.map +1 -0
- package/dist/errors.d.ts +82 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +114 -0
- package/dist/errors.js.map +1 -0
- package/dist/exec.d.ts +32 -0
- package/dist/exec.d.ts.map +1 -0
- package/dist/exec.js +3 -0
- package/dist/exec.js.map +1 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +61 -0
- package/dist/index.js.map +1 -0
- package/dist/interactivebox.d.ts +155 -0
- package/dist/interactivebox.d.ts.map +1 -0
- package/dist/interactivebox.js +299 -0
- package/dist/interactivebox.js.map +1 -0
- package/dist/native.d.ts +20 -0
- package/dist/native.d.ts.map +1 -0
- package/dist/native.js +41 -0
- package/dist/native.js.map +1 -0
- package/dist/simplebox.d.ts +175 -0
- package/dist/simplebox.d.ts.map +1 -0
- package/dist/simplebox.js +232 -0
- package/dist/simplebox.js.map +1 -0
- package/package.json +57 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default configuration constants for BoxLite specialized boxes.
|
|
3
|
+
*
|
|
4
|
+
* These values match the Python SDK for consistency across language bindings.
|
|
5
|
+
*/
|
|
6
|
+
export declare const COMPUTERBOX_IMAGE = "ghcr.io/boxlite-labs/computerbox:latest";
|
|
7
|
+
export declare const COMPUTERBOX_CPUS = 2;
|
|
8
|
+
export declare const COMPUTERBOX_MEMORY_MIB = 2048;
|
|
9
|
+
export declare const COMPUTERBOX_DISPLAY_NUMBER = ":1";
|
|
10
|
+
export declare const COMPUTERBOX_DISPLAY_WIDTH = 1024;
|
|
11
|
+
export declare const COMPUTERBOX_DISPLAY_HEIGHT = 768;
|
|
12
|
+
export declare const COMPUTERBOX_GUI_HTTP_PORT = 3000;
|
|
13
|
+
export declare const COMPUTERBOX_GUI_HTTPS_PORT = 3001;
|
|
14
|
+
export declare const DESKTOP_READY_TIMEOUT = 60;
|
|
15
|
+
export declare const DESKTOP_READY_RETRY_DELAY = 2;
|
|
16
|
+
export declare const BROWSERBOX_IMAGE_CHROMIUM = "browserless/chrome:latest";
|
|
17
|
+
export declare const BROWSERBOX_IMAGE_FIREFOX = "browserless/firefox:latest";
|
|
18
|
+
export declare const BROWSERBOX_IMAGE_WEBKIT = "browserless/webkit:latest";
|
|
19
|
+
export declare const BROWSERBOX_PORT_CHROMIUM = 9222;
|
|
20
|
+
export declare const BROWSERBOX_PORT_FIREFOX = 9223;
|
|
21
|
+
export declare const BROWSERBOX_PORT_WEBKIT = 9224;
|
|
22
|
+
export declare const DEFAULT_CPUS = 1;
|
|
23
|
+
export declare const DEFAULT_MEMORY_MIB = 512;
|
|
24
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../lib/constants.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,eAAO,MAAM,iBAAiB,4CAA4C,CAAC;AAC3E,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAClC,eAAO,MAAM,sBAAsB,OAAO,CAAC;AAC3C,eAAO,MAAM,0BAA0B,OAAO,CAAC;AAC/C,eAAO,MAAM,yBAAyB,OAAO,CAAC;AAC9C,eAAO,MAAM,0BAA0B,MAAM,CAAC;AAC9C,eAAO,MAAM,yBAAyB,OAAO,CAAC;AAC9C,eAAO,MAAM,0BAA0B,OAAO,CAAC;AAG/C,eAAO,MAAM,qBAAqB,KAAK,CAAC;AACxC,eAAO,MAAM,yBAAyB,IAAI,CAAC;AAG3C,eAAO,MAAM,yBAAyB,8BAA8B,CAAC;AACrE,eAAO,MAAM,wBAAwB,+BAA+B,CAAC;AACrE,eAAO,MAAM,uBAAuB,8BAA8B,CAAC;AAGnE,eAAO,MAAM,wBAAwB,OAAO,CAAC;AAC7C,eAAO,MAAM,uBAAuB,OAAO,CAAC;AAC5C,eAAO,MAAM,sBAAsB,OAAO,CAAC;AAG3C,eAAO,MAAM,YAAY,IAAI,CAAC;AAC9B,eAAO,MAAM,kBAAkB,MAAM,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Default configuration constants for BoxLite specialized boxes.
|
|
4
|
+
*
|
|
5
|
+
* These values match the Python SDK for consistency across language bindings.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.DEFAULT_MEMORY_MIB = exports.DEFAULT_CPUS = exports.BROWSERBOX_PORT_WEBKIT = exports.BROWSERBOX_PORT_FIREFOX = exports.BROWSERBOX_PORT_CHROMIUM = exports.BROWSERBOX_IMAGE_WEBKIT = exports.BROWSERBOX_IMAGE_FIREFOX = exports.BROWSERBOX_IMAGE_CHROMIUM = exports.DESKTOP_READY_RETRY_DELAY = exports.DESKTOP_READY_TIMEOUT = exports.COMPUTERBOX_GUI_HTTPS_PORT = exports.COMPUTERBOX_GUI_HTTP_PORT = exports.COMPUTERBOX_DISPLAY_HEIGHT = exports.COMPUTERBOX_DISPLAY_WIDTH = exports.COMPUTERBOX_DISPLAY_NUMBER = exports.COMPUTERBOX_MEMORY_MIB = exports.COMPUTERBOX_CPUS = exports.COMPUTERBOX_IMAGE = void 0;
|
|
9
|
+
// ComputerBox (Desktop Automation) defaults
|
|
10
|
+
exports.COMPUTERBOX_IMAGE = 'ghcr.io/boxlite-labs/computerbox:latest';
|
|
11
|
+
exports.COMPUTERBOX_CPUS = 2;
|
|
12
|
+
exports.COMPUTERBOX_MEMORY_MIB = 2048;
|
|
13
|
+
exports.COMPUTERBOX_DISPLAY_NUMBER = ':1';
|
|
14
|
+
exports.COMPUTERBOX_DISPLAY_WIDTH = 1024;
|
|
15
|
+
exports.COMPUTERBOX_DISPLAY_HEIGHT = 768;
|
|
16
|
+
exports.COMPUTERBOX_GUI_HTTP_PORT = 3000;
|
|
17
|
+
exports.COMPUTERBOX_GUI_HTTPS_PORT = 3001;
|
|
18
|
+
// Desktop readiness detection
|
|
19
|
+
exports.DESKTOP_READY_TIMEOUT = 60; // seconds
|
|
20
|
+
exports.DESKTOP_READY_RETRY_DELAY = 2; // seconds
|
|
21
|
+
// BrowserBox defaults
|
|
22
|
+
exports.BROWSERBOX_IMAGE_CHROMIUM = 'browserless/chrome:latest';
|
|
23
|
+
exports.BROWSERBOX_IMAGE_FIREFOX = 'browserless/firefox:latest';
|
|
24
|
+
exports.BROWSERBOX_IMAGE_WEBKIT = 'browserless/webkit:latest';
|
|
25
|
+
// Browser CDP ports
|
|
26
|
+
exports.BROWSERBOX_PORT_CHROMIUM = 9222;
|
|
27
|
+
exports.BROWSERBOX_PORT_FIREFOX = 9223;
|
|
28
|
+
exports.BROWSERBOX_PORT_WEBKIT = 9224;
|
|
29
|
+
// Default resource limits
|
|
30
|
+
exports.DEFAULT_CPUS = 1;
|
|
31
|
+
exports.DEFAULT_MEMORY_MIB = 512;
|
|
32
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../lib/constants.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,4CAA4C;AAC/B,QAAA,iBAAiB,GAAG,yCAAyC,CAAC;AAC9D,QAAA,gBAAgB,GAAG,CAAC,CAAC;AACrB,QAAA,sBAAsB,GAAG,IAAI,CAAC;AAC9B,QAAA,0BAA0B,GAAG,IAAI,CAAC;AAClC,QAAA,yBAAyB,GAAG,IAAI,CAAC;AACjC,QAAA,0BAA0B,GAAG,GAAG,CAAC;AACjC,QAAA,yBAAyB,GAAG,IAAI,CAAC;AACjC,QAAA,0BAA0B,GAAG,IAAI,CAAC;AAE/C,8BAA8B;AACjB,QAAA,qBAAqB,GAAG,EAAE,CAAC,CAAC,UAAU;AACtC,QAAA,yBAAyB,GAAG,CAAC,CAAC,CAAC,UAAU;AAEtD,sBAAsB;AACT,QAAA,yBAAyB,GAAG,2BAA2B,CAAC;AACxD,QAAA,wBAAwB,GAAG,4BAA4B,CAAC;AACxD,QAAA,uBAAuB,GAAG,2BAA2B,CAAC;AAEnE,oBAAoB;AACP,QAAA,wBAAwB,GAAG,IAAI,CAAC;AAChC,QAAA,uBAAuB,GAAG,IAAI,CAAC;AAC/B,QAAA,sBAAsB,GAAG,IAAI,CAAC;AAE3C,0BAA0B;AACb,QAAA,YAAY,GAAG,CAAC,CAAC;AACjB,QAAA,kBAAkB,GAAG,GAAG,CAAC"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base error class for all BoxLite-related errors.
|
|
3
|
+
*
|
|
4
|
+
* All BoxLite errors inherit from this class, allowing easy error type checking:
|
|
5
|
+
* ```typescript
|
|
6
|
+
* try {
|
|
7
|
+
* await box.exec('invalid-command');
|
|
8
|
+
* } catch (err) {
|
|
9
|
+
* if (err instanceof BoxliteError) {
|
|
10
|
+
* console.error('BoxLite error:', err.message);
|
|
11
|
+
* }
|
|
12
|
+
* }
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export declare class BoxliteError extends Error {
|
|
16
|
+
constructor(message: string);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Execution error thrown when a command fails (non-zero exit code).
|
|
20
|
+
*
|
|
21
|
+
* Contains details about the failed command, exit code, and stderr output.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* try {
|
|
26
|
+
* const result = await box.exec('false');
|
|
27
|
+
* } catch (err) {
|
|
28
|
+
* if (err instanceof ExecError) {
|
|
29
|
+
* console.error(`Command '${err.command}' failed with exit code ${err.exitCode}`);
|
|
30
|
+
* console.error(`Stderr: ${err.stderr}`);
|
|
31
|
+
* }
|
|
32
|
+
* }
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare class ExecError extends BoxliteError {
|
|
36
|
+
readonly command: string;
|
|
37
|
+
readonly exitCode: number;
|
|
38
|
+
readonly stderr: string;
|
|
39
|
+
/**
|
|
40
|
+
* @param command - The command that failed
|
|
41
|
+
* @param exitCode - The non-zero exit code
|
|
42
|
+
* @param stderr - Standard error output
|
|
43
|
+
*/
|
|
44
|
+
constructor(command: string, exitCode: number, stderr: string);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Timeout error thrown when an operation exceeds its time limit.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```typescript
|
|
51
|
+
* try {
|
|
52
|
+
* await waitForDesktopReady(box, 60); // 60 second timeout
|
|
53
|
+
* } catch (err) {
|
|
54
|
+
* if (err instanceof TimeoutError) {
|
|
55
|
+
* console.error('Operation timed out:', err.message);
|
|
56
|
+
* }
|
|
57
|
+
* }
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export declare class TimeoutError extends BoxliteError {
|
|
61
|
+
constructor(message: string);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Parse error thrown when unable to parse command output.
|
|
65
|
+
*
|
|
66
|
+
* Used when parsing structured output (JSON, coordinates, etc.) fails.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```typescript
|
|
70
|
+
* try {
|
|
71
|
+
* const position = parseCursorPosition(output);
|
|
72
|
+
* } catch (err) {
|
|
73
|
+
* if (err instanceof ParseError) {
|
|
74
|
+
* console.error('Failed to parse output:', err.message);
|
|
75
|
+
* }
|
|
76
|
+
* }
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
export declare class ParseError extends BoxliteError {
|
|
80
|
+
constructor(message: string);
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../lib/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,qBAAa,YAAa,SAAQ,KAAK;gBACzB,OAAO,EAAE,MAAM;CAQ5B;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,SAAU,SAAQ,YAAY;aAOvB,OAAO,EAAE,MAAM;aACf,QAAQ,EAAE,MAAM;aAChB,MAAM,EAAE,MAAM;IARhC;;;;OAIG;gBAEe,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM;CAQjC;AAED;;;;;;;;;;;;;GAaG;AACH,qBAAa,YAAa,SAAQ,YAAY;gBAChC,OAAO,EAAE,MAAM;CAO5B;AAED;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,UAAW,SAAQ,YAAY;gBAC9B,OAAO,EAAE,MAAM;CAO5B"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ParseError = exports.TimeoutError = exports.ExecError = exports.BoxliteError = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Base error class for all BoxLite-related errors.
|
|
6
|
+
*
|
|
7
|
+
* All BoxLite errors inherit from this class, allowing easy error type checking:
|
|
8
|
+
* ```typescript
|
|
9
|
+
* try {
|
|
10
|
+
* await box.exec('invalid-command');
|
|
11
|
+
* } catch (err) {
|
|
12
|
+
* if (err instanceof BoxliteError) {
|
|
13
|
+
* console.error('BoxLite error:', err.message);
|
|
14
|
+
* }
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
class BoxliteError extends Error {
|
|
19
|
+
constructor(message) {
|
|
20
|
+
super(message);
|
|
21
|
+
this.name = 'BoxliteError';
|
|
22
|
+
// Maintain proper stack trace for where our error was thrown (V8 only)
|
|
23
|
+
if (Error.captureStackTrace) {
|
|
24
|
+
Error.captureStackTrace(this, BoxliteError);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.BoxliteError = BoxliteError;
|
|
29
|
+
/**
|
|
30
|
+
* Execution error thrown when a command fails (non-zero exit code).
|
|
31
|
+
*
|
|
32
|
+
* Contains details about the failed command, exit code, and stderr output.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* try {
|
|
37
|
+
* const result = await box.exec('false');
|
|
38
|
+
* } catch (err) {
|
|
39
|
+
* if (err instanceof ExecError) {
|
|
40
|
+
* console.error(`Command '${err.command}' failed with exit code ${err.exitCode}`);
|
|
41
|
+
* console.error(`Stderr: ${err.stderr}`);
|
|
42
|
+
* }
|
|
43
|
+
* }
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
class ExecError extends BoxliteError {
|
|
47
|
+
/**
|
|
48
|
+
* @param command - The command that failed
|
|
49
|
+
* @param exitCode - The non-zero exit code
|
|
50
|
+
* @param stderr - Standard error output
|
|
51
|
+
*/
|
|
52
|
+
constructor(command, exitCode, stderr) {
|
|
53
|
+
super(`Command '${command}' failed with exit code ${exitCode}: ${stderr}`);
|
|
54
|
+
this.command = command;
|
|
55
|
+
this.exitCode = exitCode;
|
|
56
|
+
this.stderr = stderr;
|
|
57
|
+
this.name = 'ExecError';
|
|
58
|
+
if (Error.captureStackTrace) {
|
|
59
|
+
Error.captureStackTrace(this, ExecError);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.ExecError = ExecError;
|
|
64
|
+
/**
|
|
65
|
+
* Timeout error thrown when an operation exceeds its time limit.
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```typescript
|
|
69
|
+
* try {
|
|
70
|
+
* await waitForDesktopReady(box, 60); // 60 second timeout
|
|
71
|
+
* } catch (err) {
|
|
72
|
+
* if (err instanceof TimeoutError) {
|
|
73
|
+
* console.error('Operation timed out:', err.message);
|
|
74
|
+
* }
|
|
75
|
+
* }
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
class TimeoutError extends BoxliteError {
|
|
79
|
+
constructor(message) {
|
|
80
|
+
super(message);
|
|
81
|
+
this.name = 'TimeoutError';
|
|
82
|
+
if (Error.captureStackTrace) {
|
|
83
|
+
Error.captureStackTrace(this, TimeoutError);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
exports.TimeoutError = TimeoutError;
|
|
88
|
+
/**
|
|
89
|
+
* Parse error thrown when unable to parse command output.
|
|
90
|
+
*
|
|
91
|
+
* Used when parsing structured output (JSON, coordinates, etc.) fails.
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```typescript
|
|
95
|
+
* try {
|
|
96
|
+
* const position = parseCursorPosition(output);
|
|
97
|
+
* } catch (err) {
|
|
98
|
+
* if (err instanceof ParseError) {
|
|
99
|
+
* console.error('Failed to parse output:', err.message);
|
|
100
|
+
* }
|
|
101
|
+
* }
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
class ParseError extends BoxliteError {
|
|
105
|
+
constructor(message) {
|
|
106
|
+
super(message);
|
|
107
|
+
this.name = 'ParseError';
|
|
108
|
+
if (Error.captureStackTrace) {
|
|
109
|
+
Error.captureStackTrace(this, ParseError);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
exports.ParseError = ParseError;
|
|
114
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../lib/errors.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;GAaG;AACH,MAAa,YAAa,SAAQ,KAAK;IACrC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;QAC3B,uEAAuE;QACvE,IAAI,KAAK,CAAC,iBAAiB,EAAE,CAAC;YAC5B,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;QAC9C,CAAC;IACH,CAAC;CACF;AATD,oCASC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAa,SAAU,SAAQ,YAAY;IACzC;;;;OAIG;IACH,YACkB,OAAe,EACf,QAAgB,EAChB,MAAc;QAE9B,KAAK,CAAC,YAAY,OAAO,2BAA2B,QAAQ,KAAK,MAAM,EAAE,CAAC,CAAC;QAJ3D,YAAO,GAAP,OAAO,CAAQ;QACf,aAAQ,GAAR,QAAQ,CAAQ;QAChB,WAAM,GAAN,MAAM,CAAQ;QAG9B,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;QACxB,IAAI,KAAK,CAAC,iBAAiB,EAAE,CAAC;YAC5B,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QAC3C,CAAC;IACH,CAAC;CACF;AAjBD,8BAiBC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAa,YAAa,SAAQ,YAAY;IAC5C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;QAC3B,IAAI,KAAK,CAAC,iBAAiB,EAAE,CAAC;YAC5B,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;QAC9C,CAAC;IACH,CAAC;CACF;AARD,oCAQC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAa,UAAW,SAAQ,YAAY;IAC1C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;QACzB,IAAI,KAAK,CAAC,iBAAiB,EAAE,CAAC;YAC5B,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC;CACF;AARD,gCAQC"}
|
package/dist/exec.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Result of a completed command execution.
|
|
3
|
+
*
|
|
4
|
+
* Contains the exit code and collected stdout/stderr output.
|
|
5
|
+
* Used by SimpleBox and specialized box classes that collect
|
|
6
|
+
* output into strings rather than streaming.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* const result = await simpleBox.exec('ls', '-la');
|
|
11
|
+
* console.log(`Exit code: ${result.exitCode}`);
|
|
12
|
+
* console.log(`Output:\n${result.stdout}`);
|
|
13
|
+
* if (result.stderr) {
|
|
14
|
+
* console.error(`Errors:\n${result.stderr}`);
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export interface ExecResult {
|
|
19
|
+
/**
|
|
20
|
+
* Process exit code (0 = success, non-zero = error)
|
|
21
|
+
*/
|
|
22
|
+
exitCode: number;
|
|
23
|
+
/**
|
|
24
|
+
* Standard output (stdout) as a string
|
|
25
|
+
*/
|
|
26
|
+
stdout: string;
|
|
27
|
+
/**
|
|
28
|
+
* Standard error (stderr) as a string
|
|
29
|
+
*/
|
|
30
|
+
stderr: string;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=exec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exec.d.ts","sourceRoot":"","sources":["../lib/exec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,UAAU;IACzB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;CAChB"}
|
package/dist/exec.js
ADDED
package/dist/exec.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exec.js","sourceRoot":"","sources":["../lib/exec.ts"],"names":[],"mappings":""}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BoxLite Node.js SDK
|
|
3
|
+
*
|
|
4
|
+
* Embeddable VM runtime for secure, isolated code execution environments.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* import { SimpleBox } from '@boxlite/boxlite';
|
|
9
|
+
*
|
|
10
|
+
* const box = new SimpleBox({ image: 'alpine:latest' });
|
|
11
|
+
* try {
|
|
12
|
+
* const result = await box.exec('echo', 'Hello from BoxLite!');
|
|
13
|
+
* console.log(result.stdout);
|
|
14
|
+
* } finally {
|
|
15
|
+
* await box.stop();
|
|
16
|
+
* }
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @packageDocumentation
|
|
20
|
+
*/
|
|
21
|
+
import { getNativeModule, getJsBoxlite } from './native';
|
|
22
|
+
export declare const JsBoxlite: any;
|
|
23
|
+
export { getNativeModule, getJsBoxlite };
|
|
24
|
+
export { SimpleBox, type SimpleBoxOptions } from './simplebox';
|
|
25
|
+
export { type ExecResult } from './exec';
|
|
26
|
+
export { BoxliteError, ExecError, TimeoutError, ParseError } from './errors';
|
|
27
|
+
export * from './constants';
|
|
28
|
+
export { CodeBox, type CodeBoxOptions } from './codebox';
|
|
29
|
+
export { BrowserBox, type BrowserBoxOptions, type BrowserType } from './browserbox';
|
|
30
|
+
export { ComputerBox, type ComputerBoxOptions, type Screenshot } from './computerbox';
|
|
31
|
+
export { InteractiveBox, type InteractiveBoxOptions } from './interactivebox';
|
|
32
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAGzD,eAAO,MAAM,SAAS,KAAiB,CAAC;AAGxC,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,CAAC;AAGzC,OAAO,EAAE,SAAS,EAAE,KAAK,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC7E,cAAc,aAAa,CAAC;AAG5B,OAAO,EAAE,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,KAAK,iBAAiB,EAAE,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AACpF,OAAO,EAAE,WAAW,EAAE,KAAK,kBAAkB,EAAE,KAAK,UAAU,EAAE,MAAM,eAAe,CAAC;AACtF,OAAO,EAAE,cAAc,EAAE,KAAK,qBAAqB,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* BoxLite Node.js SDK
|
|
4
|
+
*
|
|
5
|
+
* Embeddable VM runtime for secure, isolated code execution environments.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { SimpleBox } from '@boxlite/boxlite';
|
|
10
|
+
*
|
|
11
|
+
* const box = new SimpleBox({ image: 'alpine:latest' });
|
|
12
|
+
* try {
|
|
13
|
+
* const result = await box.exec('echo', 'Hello from BoxLite!');
|
|
14
|
+
* console.log(result.stdout);
|
|
15
|
+
* } finally {
|
|
16
|
+
* await box.stop();
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @packageDocumentation
|
|
21
|
+
*/
|
|
22
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
23
|
+
if (k2 === undefined) k2 = k;
|
|
24
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
25
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
26
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
27
|
+
}
|
|
28
|
+
Object.defineProperty(o, k2, desc);
|
|
29
|
+
}) : (function(o, m, k, k2) {
|
|
30
|
+
if (k2 === undefined) k2 = k;
|
|
31
|
+
o[k2] = m[k];
|
|
32
|
+
}));
|
|
33
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
34
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
35
|
+
};
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
exports.InteractiveBox = exports.ComputerBox = exports.BrowserBox = exports.CodeBox = exports.ParseError = exports.TimeoutError = exports.ExecError = exports.BoxliteError = exports.SimpleBox = exports.getJsBoxlite = exports.getNativeModule = exports.JsBoxlite = void 0;
|
|
38
|
+
const native_1 = require("./native");
|
|
39
|
+
Object.defineProperty(exports, "getNativeModule", { enumerable: true, get: function () { return native_1.getNativeModule; } });
|
|
40
|
+
Object.defineProperty(exports, "getJsBoxlite", { enumerable: true, get: function () { return native_1.getJsBoxlite; } });
|
|
41
|
+
// Re-export native bindings
|
|
42
|
+
exports.JsBoxlite = (0, native_1.getJsBoxlite)();
|
|
43
|
+
// Re-export TypeScript wrappers
|
|
44
|
+
var simplebox_1 = require("./simplebox");
|
|
45
|
+
Object.defineProperty(exports, "SimpleBox", { enumerable: true, get: function () { return simplebox_1.SimpleBox; } });
|
|
46
|
+
var errors_1 = require("./errors");
|
|
47
|
+
Object.defineProperty(exports, "BoxliteError", { enumerable: true, get: function () { return errors_1.BoxliteError; } });
|
|
48
|
+
Object.defineProperty(exports, "ExecError", { enumerable: true, get: function () { return errors_1.ExecError; } });
|
|
49
|
+
Object.defineProperty(exports, "TimeoutError", { enumerable: true, get: function () { return errors_1.TimeoutError; } });
|
|
50
|
+
Object.defineProperty(exports, "ParseError", { enumerable: true, get: function () { return errors_1.ParseError; } });
|
|
51
|
+
__exportStar(require("./constants"), exports);
|
|
52
|
+
// Specialized boxes
|
|
53
|
+
var codebox_1 = require("./codebox");
|
|
54
|
+
Object.defineProperty(exports, "CodeBox", { enumerable: true, get: function () { return codebox_1.CodeBox; } });
|
|
55
|
+
var browserbox_1 = require("./browserbox");
|
|
56
|
+
Object.defineProperty(exports, "BrowserBox", { enumerable: true, get: function () { return browserbox_1.BrowserBox; } });
|
|
57
|
+
var computerbox_1 = require("./computerbox");
|
|
58
|
+
Object.defineProperty(exports, "ComputerBox", { enumerable: true, get: function () { return computerbox_1.ComputerBox; } });
|
|
59
|
+
var interactivebox_1 = require("./interactivebox");
|
|
60
|
+
Object.defineProperty(exports, "InteractiveBox", { enumerable: true, get: function () { return interactivebox_1.InteractiveBox; } });
|
|
61
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;;;;;;;;;;;;;;;AAEH,qCAAyD;AAMhD,gGANA,wBAAe,OAMA;AAAE,6FANA,qBAAY,OAMA;AAJtC,4BAA4B;AACf,QAAA,SAAS,GAAG,IAAA,qBAAY,GAAE,CAAC;AAKxC,gCAAgC;AAChC,yCAA+D;AAAtD,sGAAA,SAAS,OAAA;AAElB,mCAA6E;AAApE,sGAAA,YAAY,OAAA;AAAE,mGAAA,SAAS,OAAA;AAAE,sGAAA,YAAY,OAAA;AAAE,oGAAA,UAAU,OAAA;AAC1D,8CAA4B;AAE5B,oBAAoB;AACpB,qCAAyD;AAAhD,kGAAA,OAAO,OAAA;AAChB,2CAAoF;AAA3E,wGAAA,UAAU,OAAA;AACnB,6CAAsF;AAA7E,0GAAA,WAAW,OAAA;AACpB,mDAA8E;AAArE,gHAAA,cAAc,OAAA"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* InteractiveBox - Interactive terminal sessions with PTY support.
|
|
3
|
+
*
|
|
4
|
+
* Provides automatic PTY-based interactive sessions, similar to `docker exec -it`.
|
|
5
|
+
*/
|
|
6
|
+
import { SimpleBoxOptions } from './simplebox';
|
|
7
|
+
type Boxlite = any;
|
|
8
|
+
type Box = any;
|
|
9
|
+
type Execution = any;
|
|
10
|
+
/**
|
|
11
|
+
* Options for creating an InteractiveBox.
|
|
12
|
+
*/
|
|
13
|
+
export interface InteractiveBoxOptions extends SimpleBoxOptions {
|
|
14
|
+
/** Shell to run (default: '/bin/sh') */
|
|
15
|
+
shell?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Control terminal I/O forwarding behavior:
|
|
18
|
+
* - undefined (default): Auto-detect - forward I/O if stdin is a TTY
|
|
19
|
+
* - true: Force I/O forwarding (manual interactive mode)
|
|
20
|
+
* - false: No I/O forwarding (programmatic control only)
|
|
21
|
+
*/
|
|
22
|
+
tty?: boolean;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Interactive box with automatic PTY and terminal forwarding.
|
|
26
|
+
*
|
|
27
|
+
* When used as a context manager, automatically:
|
|
28
|
+
* 1. Auto-detects terminal size (like Docker)
|
|
29
|
+
* 2. Starts a shell with PTY
|
|
30
|
+
* 3. Sets local terminal to raw mode
|
|
31
|
+
* 4. Forwards stdin/stdout bidirectionally
|
|
32
|
+
* 5. Restores terminal mode on exit
|
|
33
|
+
*
|
|
34
|
+
* ## Example
|
|
35
|
+
*
|
|
36
|
+
* ```typescript
|
|
37
|
+
* const box = new InteractiveBox({ image: 'alpine:latest' });
|
|
38
|
+
* try {
|
|
39
|
+
* await box.start();
|
|
40
|
+
* // You're now in an interactive shell!
|
|
41
|
+
* // Type commands, see output in real-time
|
|
42
|
+
* // Type "exit" to close
|
|
43
|
+
* await box.wait();
|
|
44
|
+
* } finally {
|
|
45
|
+
* await box.stop();
|
|
46
|
+
* }
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* Or with async disposal (TypeScript 5.2+):
|
|
50
|
+
*
|
|
51
|
+
* ```typescript
|
|
52
|
+
* await using box = new InteractiveBox({ image: 'alpine:latest' });
|
|
53
|
+
* await box.start();
|
|
54
|
+
* await box.wait();
|
|
55
|
+
* // Automatically stopped when leaving scope
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export declare class InteractiveBox {
|
|
59
|
+
protected _runtime: Boxlite;
|
|
60
|
+
protected _box: Box;
|
|
61
|
+
protected _shell: string;
|
|
62
|
+
protected _env?: Record<string, string>;
|
|
63
|
+
protected _tty: boolean;
|
|
64
|
+
protected _execution?: Execution;
|
|
65
|
+
protected _stdin?: any;
|
|
66
|
+
protected _stdout?: any;
|
|
67
|
+
protected _stderr?: any;
|
|
68
|
+
protected _ioTasks: Promise<void>[];
|
|
69
|
+
protected _exited: boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Create an interactive box.
|
|
72
|
+
*
|
|
73
|
+
* @param options - InteractiveBox configuration options
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```typescript
|
|
77
|
+
* const box = new InteractiveBox({
|
|
78
|
+
* image: 'alpine:latest',
|
|
79
|
+
* shell: '/bin/sh',
|
|
80
|
+
* tty: true,
|
|
81
|
+
* memoryMib: 512,
|
|
82
|
+
* cpus: 1
|
|
83
|
+
* });
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
constructor(options: InteractiveBoxOptions);
|
|
87
|
+
/**
|
|
88
|
+
* Get the box ID (ULID format).
|
|
89
|
+
*/
|
|
90
|
+
get id(): string;
|
|
91
|
+
/**
|
|
92
|
+
* Start the interactive shell session.
|
|
93
|
+
*
|
|
94
|
+
* This method:
|
|
95
|
+
* 1. Starts the shell with PTY
|
|
96
|
+
* 2. Sets terminal to raw mode (if tty=true)
|
|
97
|
+
* 3. Begins I/O forwarding
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```typescript
|
|
101
|
+
* await box.start();
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
start(): Promise<void>;
|
|
105
|
+
/**
|
|
106
|
+
* Wait for the shell to exit.
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```typescript
|
|
110
|
+
* await box.start();
|
|
111
|
+
* await box.wait(); // Blocks until shell exits
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
wait(): Promise<void>;
|
|
115
|
+
/**
|
|
116
|
+
* Stop the box and restore terminal settings.
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```typescript
|
|
120
|
+
* await box.stop();
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
123
|
+
stop(): Promise<void>;
|
|
124
|
+
/**
|
|
125
|
+
* Implement async disposable pattern (TypeScript 5.2+).
|
|
126
|
+
*
|
|
127
|
+
* Allows using `await using` syntax for automatic cleanup.
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* ```typescript
|
|
131
|
+
* await using box = new InteractiveBox({ image: 'alpine' });
|
|
132
|
+
* await box.start();
|
|
133
|
+
* // Box automatically stopped when leaving scope
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
136
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
137
|
+
/**
|
|
138
|
+
* Forward stdin to PTY (internal).
|
|
139
|
+
*/
|
|
140
|
+
private _forwardStdin;
|
|
141
|
+
/**
|
|
142
|
+
* Forward PTY output to stdout (internal).
|
|
143
|
+
*/
|
|
144
|
+
private _forwardOutput;
|
|
145
|
+
/**
|
|
146
|
+
* Forward PTY stderr to stderr (internal).
|
|
147
|
+
*/
|
|
148
|
+
private _forwardStderr;
|
|
149
|
+
/**
|
|
150
|
+
* Wait for the shell to exit (internal).
|
|
151
|
+
*/
|
|
152
|
+
private _waitForExit;
|
|
153
|
+
}
|
|
154
|
+
export {};
|
|
155
|
+
//# sourceMappingURL=interactivebox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interactivebox.d.ts","sourceRoot":"","sources":["../lib/interactivebox.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAI/C,KAAK,OAAO,GAAG,GAAG,CAAC;AACnB,KAAK,GAAG,GAAG,GAAG,CAAC;AACf,KAAK,SAAS,GAAG,GAAG,CAAC;AAErB;;GAEG;AACH,MAAM,WAAW,qBAAsB,SAAQ,gBAAgB;IAC7D,wCAAwC;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;;;;OAKG;IACH,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,qBAAa,cAAc;IACzB,SAAS,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC5B,SAAS,CAAC,IAAI,EAAE,GAAG,CAAC;IACpB,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxC,SAAS,CAAC,IAAI,EAAE,OAAO,CAAC;IACxB,SAAS,CAAC,UAAU,CAAC,EAAE,SAAS,CAAC;IACjC,SAAS,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC;IACvB,SAAS,CAAC,OAAO,CAAC,EAAE,GAAG,CAAC;IACxB,SAAS,CAAC,OAAO,CAAC,EAAE,GAAG,CAAC;IACxB,SAAS,CAAC,QAAQ,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,CAAM;IACzC,SAAS,CAAC,OAAO,EAAE,OAAO,CAAS;IAEnC;;;;;;;;;;;;;;;OAeG;gBACS,OAAO,EAAE,qBAAqB;IAyB1C;;OAEG;IACH,IAAI,EAAE,IAAI,MAAM,CAEf;IAED;;;;;;;;;;;;OAYG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IA+C5B;;;;;;;;OAQG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAI3B;;;;;;;OAOG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAyB3B;;;;;;;;;;;OAWG;IACG,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5C;;OAEG;YACW,aAAa;IA4B3B;;OAEG;YACW,cAAc;IAoB5B;;OAEG;YACW,cAAc;IAoB5B;;OAEG;YACW,YAAY;CAW3B"}
|