microsandbox 0.1.1 → 0.3.7

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.
@@ -1,59 +0,0 @@
1
- /**
2
- * Class representing command execution results in a sandbox environment.
3
- */
4
- import { OutputData } from "./types";
5
- export declare class CommandExecution {
6
- private outputLines;
7
- private _command;
8
- private _args;
9
- private _exitCode;
10
- private _success;
11
- /**
12
- * Initialize a command execution instance.
13
- *
14
- * @param outputData - Output data from the sandbox.command.run response
15
- */
16
- constructor(outputData?: OutputData);
17
- /**
18
- * Process output data from the sandbox.command.run response.
19
- *
20
- * @param outputData - Dictionary containing the output data
21
- */
22
- private processOutputData;
23
- /**
24
- * Get the standard output from the command execution.
25
- *
26
- * @returns String containing the stdout output of the command
27
- */
28
- output(): Promise<string>;
29
- /**
30
- * Get the error output from the command execution.
31
- *
32
- * @returns String containing the stderr output of the command
33
- */
34
- error(): Promise<string>;
35
- /**
36
- * Get the exit code of the command execution.
37
- *
38
- * @returns Integer containing the exit code
39
- */
40
- get exitCode(): number;
41
- /**
42
- * Check if the command executed successfully.
43
- *
44
- * @returns Boolean indicating whether the command succeeded (exit code 0)
45
- */
46
- get success(): boolean;
47
- /**
48
- * Get the command that was executed.
49
- *
50
- * @returns String containing the command
51
- */
52
- get command(): string;
53
- /**
54
- * Get the arguments used for the command.
55
- *
56
- * @returns List of strings containing the command arguments
57
- */
58
- get args(): string[];
59
- }
@@ -1,102 +0,0 @@
1
- "use strict";
2
- /**
3
- * Class representing command execution results in a sandbox environment.
4
- */
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.CommandExecution = void 0;
7
- class CommandExecution {
8
- /**
9
- * Initialize a command execution instance.
10
- *
11
- * @param outputData - Output data from the sandbox.command.run response
12
- */
13
- constructor(outputData) {
14
- this.outputLines = [];
15
- this._command = "";
16
- this._args = [];
17
- this._exitCode = -1;
18
- this._success = false;
19
- if (outputData) {
20
- this.processOutputData(outputData);
21
- }
22
- }
23
- /**
24
- * Process output data from the sandbox.command.run response.
25
- *
26
- * @param outputData - Dictionary containing the output data
27
- */
28
- processOutputData(outputData) {
29
- // Extract output lines from the response
30
- this.outputLines = outputData.output || [];
31
- // Store command-specific metadata
32
- this._command = outputData.command || "";
33
- this._args = outputData.args || [];
34
- this._exitCode =
35
- outputData.exit_code !== undefined ? outputData.exit_code : -1;
36
- this._success = outputData.success || false;
37
- }
38
- /**
39
- * Get the standard output from the command execution.
40
- *
41
- * @returns String containing the stdout output of the command
42
- */
43
- async output() {
44
- // Combine the stdout output lines into a single string
45
- let outputText = "";
46
- for (const line of this.outputLines) {
47
- if (line.stream === "stdout") {
48
- outputText += line.text + "\n";
49
- }
50
- }
51
- return outputText.trim();
52
- }
53
- /**
54
- * Get the error output from the command execution.
55
- *
56
- * @returns String containing the stderr output of the command
57
- */
58
- async error() {
59
- // Combine the stderr output lines into a single string
60
- let errorText = "";
61
- for (const line of this.outputLines) {
62
- if (line.stream === "stderr") {
63
- errorText += line.text + "\n";
64
- }
65
- }
66
- return errorText.trim();
67
- }
68
- /**
69
- * Get the exit code of the command execution.
70
- *
71
- * @returns Integer containing the exit code
72
- */
73
- get exitCode() {
74
- return this._exitCode;
75
- }
76
- /**
77
- * Check if the command executed successfully.
78
- *
79
- * @returns Boolean indicating whether the command succeeded (exit code 0)
80
- */
81
- get success() {
82
- return this._success;
83
- }
84
- /**
85
- * Get the command that was executed.
86
- *
87
- * @returns String containing the command
88
- */
89
- get command() {
90
- return this._command;
91
- }
92
- /**
93
- * Get the arguments used for the command.
94
- *
95
- * @returns List of strings containing the command arguments
96
- */
97
- get args() {
98
- return this._args;
99
- }
100
- }
101
- exports.CommandExecution = CommandExecution;
102
- //# sourceMappingURL=command-execution.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"command-execution.js","sourceRoot":"","sources":["../src/command-execution.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAIH,MAAa,gBAAgB;IAO3B;;;;OAIG;IACH,YAAY,UAA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CAAC;YACpC,IAAI,IAAI,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;gBAC7B,SAAS,IAAI,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;YAChC,CAAC;QACH,CAAC;QAED,OAAO,SAAS,CAAC,IAAI,EAAE,CAAC;IAC1B,CAAC;IAED;;;;OAIG;IACH,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED;;;;OAIG;IACH,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED;;;;OAIG;IACH,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED;;;;OAIG;IACH,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;CACF;AAxGD,4CAwGC"}
package/dist/command.d.ts DELETED
@@ -1,24 +0,0 @@
1
- /**
2
- * Command execution interface for the Microsandbox TypeScript SDK.
3
- */
4
- import { CommandExecution } from "./command-execution";
5
- import { BaseSandbox } from "./base-sandbox";
6
- export declare class Command {
7
- private sandbox;
8
- /**
9
- * Initialize the command instance.
10
- *
11
- * @param sandboxInstance - The sandbox instance this command belongs to
12
- */
13
- constructor(sandboxInstance: BaseSandbox);
14
- /**
15
- * Execute a shell command in the sandbox.
16
- *
17
- * @param command - The command to execute
18
- * @param args - Optional list of command arguments
19
- * @param timeout - Optional timeout in seconds
20
- * @returns A CommandExecution object containing the results
21
- * @throws Error if the sandbox is not started or execution fails
22
- */
23
- run(command: string, args?: string[], timeout?: number): Promise<CommandExecution>;
24
- }
package/dist/command.js DELETED
@@ -1,84 +0,0 @@
1
- "use strict";
2
- /**
3
- * Command execution interface for the Microsandbox TypeScript SDK.
4
- */
5
- var __importDefault = (this && this.__importDefault) || function (mod) {
6
- return (mod && mod.__esModule) ? mod : { "default": mod };
7
- };
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.Command = void 0;
10
- const uuid_1 = require("uuid");
11
- const node_fetch_1 = __importDefault(require("node-fetch"));
12
- const command_execution_1 = require("./command-execution");
13
- class Command {
14
- /**
15
- * Initialize the command instance.
16
- *
17
- * @param sandboxInstance - The sandbox instance this command belongs to
18
- */
19
- constructor(sandboxInstance) {
20
- this.sandbox = sandboxInstance;
21
- }
22
- /**
23
- * Execute a shell command in the sandbox.
24
- *
25
- * @param command - The command to execute
26
- * @param args - Optional list of command arguments
27
- * @param timeout - Optional timeout in seconds
28
- * @returns A CommandExecution object containing the results
29
- * @throws Error if the sandbox is not started or execution fails
30
- */
31
- async run(command, args, timeout) {
32
- if (!this.sandbox.isStarted) {
33
- throw new Error("Sandbox is not started. Call start() first.");
34
- }
35
- const headers = {
36
- "Content-Type": "application/json",
37
- };
38
- if (this.sandbox.apiKey) {
39
- headers["Authorization"] = `Bearer ${this.sandbox.apiKey}`;
40
- }
41
- // Prepare the request data
42
- const requestData = {
43
- jsonrpc: "2.0",
44
- method: "sandbox.command.run",
45
- params: {
46
- sandbox: this.sandbox.name,
47
- namespace: this.sandbox.namespace,
48
- command,
49
- args: args || [],
50
- },
51
- id: (0, uuid_1.v4)(),
52
- };
53
- // Add timeout if specified
54
- if (timeout !== undefined) {
55
- requestData.params.timeout = timeout;
56
- }
57
- try {
58
- const response = await (0, node_fetch_1.default)(`${this.sandbox.serverUrl}/api/v1/rpc`, {
59
- method: "POST",
60
- headers,
61
- body: JSON.stringify(requestData),
62
- });
63
- if (!response.ok) {
64
- const errorText = await response.text();
65
- throw new Error(`Failed to execute command: ${errorText}`);
66
- }
67
- const responseData = await response.json();
68
- if ("error" in responseData) {
69
- throw new Error(`Failed to execute command: ${responseData.error.message}`);
70
- }
71
- const result = responseData.result || {};
72
- // Create and return a CommandExecution object with the output data
73
- return new command_execution_1.CommandExecution(result);
74
- }
75
- catch (e) {
76
- if (e instanceof Error) {
77
- throw new Error(`Failed to execute command: ${e.message}`);
78
- }
79
- throw new Error("Failed to execute command: Unknown error");
80
- }
81
- }
82
- }
83
- exports.Command = Command;
84
- //# sourceMappingURL=command.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"command.js","sourceRoot":"","sources":["../src/command.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;AAEH,+BAAoC;AACpC,4DAA+B;AAE/B,2DAAuD;AAGvD,MAAa,OAAO;IAGlB;;;;OAIG;IACH,YAAY,eAA4B;QACtC,IAAI,CAAC,OAAO,GAAG,eAAe,CAAC;IACjC,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,GAAG,CACP,OAAe,EACf,IAAe,EACf,OAAgB;QAEhB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC;YAC5B,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;QACjE,CAAC;QAED,MAAM,OAAO,GAA2B;YACtC,cAAc,EAAE,kBAAkB;SACnC,CAAC;QAEF,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;YACxB,OAAO,CAAC,eAAe,CAAC,GAAG,UAAU,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;QAC7D,CAAC;QAED,2BAA2B;QAC3B,MAAM,WAAW,GAWb;YACF,OAAO,EAAE,KAAK;YACd,MAAM,EAAE,qBAAqB;YAC7B,MAAM,EAAE;gBACN,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI;gBAC1B,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,SAAS;gBACjC,OAAO;gBACP,IAAI,EAAE,IAAI,IAAI,EAAE;aACjB;YACD,EAAE,EAAE,IAAA,SAAM,GAAE;SACb,CAAC;QAEF,2BAA2B;QAC3B,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC1B,WAAW,CAAC,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC;QACvC,CAAC;QAED,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,IAAA,oBAAK,EAAC,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,aAAa,EAAE;gBACnE,MAAM,EAAE,MAAM;gBACd,OAAO;gBACP,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC;aAClC,CAAC,CAAC;YAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;gBACjB,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;gBACxC,MAAM,IAAI,KAAK,CAAC,8BAA8B,SAAS,EAAE,CAAC,CAAC;YAC7D,CAAC;YAED,MAAM,YAAY,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;YAE3C,IAAI,OAAO,IAAI,YAAY,EAAE,CAAC;gBAC5B,MAAM,IAAI,KAAK,CACb,8BAA8B,YAAY,CAAC,KAAK,CAAC,OAAO,EAAE,CAC3D,CAAC;YACJ,CAAC;YAED,MAAM,MAAM,GAAG,YAAY,CAAC,MAAM,IAAI,EAAE,CAAC;YAEzC,mEAAmE;YACnE,OAAO,IAAI,oCAAgB,CAAC,MAAM,CAAC,CAAC;QACtC,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,IAAI,CAAC,YAAY,KAAK,EAAE,CAAC;gBACvB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;YAC7D,CAAC;YACD,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;QAC9D,CAAC;IACH,CAAC;CACF;AAlGD,0BAkGC"}
@@ -1,52 +0,0 @@
1
- /**
2
- * Class representing code execution results in a sandbox environment.
3
- */
4
- import { OutputData } from "./types";
5
- export declare class Execution {
6
- private outputLines;
7
- private _status;
8
- private _language;
9
- private _hasError;
10
- /**
11
- * Initialize an execution instance.
12
- *
13
- * @param outputData - Output data from the sandbox.repl.run response
14
- */
15
- constructor(outputData?: OutputData);
16
- /**
17
- * Process output data from the sandbox.repl.run response.
18
- *
19
- * @param outputData - Dictionary containing the output data
20
- */
21
- private processOutputData;
22
- /**
23
- * Get the standard output from the execution.
24
- *
25
- * @returns String containing the stdout output of the execution
26
- */
27
- output(): Promise<string>;
28
- /**
29
- * Get the error output from the execution.
30
- *
31
- * @returns String containing the stderr output of the execution
32
- */
33
- error(): Promise<string>;
34
- /**
35
- * Check if the execution contains an error.
36
- *
37
- * @returns Boolean indicating whether the execution encountered an error
38
- */
39
- hasError(): boolean;
40
- /**
41
- * Get the status of the execution.
42
- *
43
- * @returns String containing the execution status (e.g., "success")
44
- */
45
- get status(): string;
46
- /**
47
- * Get the language used for the execution.
48
- *
49
- * @returns String containing the execution language (e.g., "python")
50
- */
51
- get language(): string;
52
- }
package/dist/execution.js DELETED
@@ -1,103 +0,0 @@
1
- "use strict";
2
- /**
3
- * Class representing code execution results in a sandbox environment.
4
- */
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Execution = void 0;
7
- class Execution {
8
- /**
9
- * Initialize an execution instance.
10
- *
11
- * @param outputData - Output data from the sandbox.repl.run response
12
- */
13
- constructor(outputData) {
14
- this.outputLines = [];
15
- this._status = "unknown";
16
- this._language = "unknown";
17
- this._hasError = false;
18
- if (outputData) {
19
- this.processOutputData(outputData);
20
- }
21
- }
22
- /**
23
- * Process output data from the sandbox.repl.run response.
24
- *
25
- * @param outputData - Dictionary containing the output data
26
- */
27
- processOutputData(outputData) {
28
- // Extract output lines from the response
29
- this.outputLines = outputData.output || [];
30
- // Store additional metadata that might be useful
31
- this._status = outputData.status || "unknown";
32
- this._language = outputData.language || "unknown";
33
- // Check for errors in the output or status
34
- if (this._status === "error" || this._status === "exception") {
35
- this._hasError = true;
36
- }
37
- else {
38
- // Check if there's any stderr output
39
- for (const line of this.outputLines) {
40
- if (line.stream === "stderr" && line.text) {
41
- this._hasError = true;
42
- break;
43
- }
44
- }
45
- }
46
- }
47
- /**
48
- * Get the standard output from the execution.
49
- *
50
- * @returns String containing the stdout output of the execution
51
- */
52
- async output() {
53
- // Combine the stdout output lines into a single string
54
- let outputText = "";
55
- for (const line of this.outputLines) {
56
- if (line.stream === "stdout") {
57
- outputText += line.text + "\n";
58
- }
59
- }
60
- return outputText.trim();
61
- }
62
- /**
63
- * Get the error output from the execution.
64
- *
65
- * @returns String containing the stderr output of the execution
66
- */
67
- async error() {
68
- // Combine the stderr output lines into a single string
69
- let errorText = "";
70
- for (const line of this.outputLines) {
71
- if (line.stream === "stderr") {
72
- errorText += line.text + "\n";
73
- }
74
- }
75
- return errorText.trim();
76
- }
77
- /**
78
- * Check if the execution contains an error.
79
- *
80
- * @returns Boolean indicating whether the execution encountered an error
81
- */
82
- hasError() {
83
- return this._hasError;
84
- }
85
- /**
86
- * Get the status of the execution.
87
- *
88
- * @returns String containing the execution status (e.g., "success")
89
- */
90
- get status() {
91
- return this._status;
92
- }
93
- /**
94
- * Get the language used for the execution.
95
- *
96
- * @returns String containing the execution language (e.g., "python")
97
- */
98
- get language() {
99
- return this._language;
100
- }
101
- }
102
- exports.Execution = Execution;
103
- //# sourceMappingURL=execution.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"execution.js","sourceRoot":"","sources":["../src/execution.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAIH,MAAa,SAAS;IAMpB;;;;OAIG;IACH,YAAY,UAAuB;QAV3B,gBAAW,GAAiB,EAAE,CAAC;QAC/B,YAAO,GAAW,SAAS,CAAC;QAC5B,cAAS,GAAW,SAAS,CAAC;QAC9B,cAAS,GAAY,KAAK,CAAC;QAQjC,IAAI,UAAU,EAAE,CAAC;YACf,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;QACrC,CAAC;IACH,CAAC;IAED;;;;OAIG;IACK,iBAAiB,CAAC,UAAsB;QAC9C,yCAAyC;QACzC,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC,MAAM,IAAI,EAAE,CAAC;QAE3C,iDAAiD;QACjD,IAAI,CAAC,OAAO,GAAG,UAAU,CAAC,MAAM,IAAI,SAAS,CAAC;QAC9C,IAAI,CAAC,SAAS,GAAG,UAA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,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED;;;;OAIG;IACH,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;CACF;AAxGD,8BAwGC"}
package/dist/index.d.ts DELETED
@@ -1,13 +0,0 @@
1
- /**
2
- * Microsandbox TypeScript SDK
3
- *
4
- * A TypeScript SDK for creating and managing secure sandboxes for code execution.
5
- */
6
- export { BaseSandbox } from "./base-sandbox";
7
- export { Command } from "./command";
8
- export { CommandExecution } from "./command-execution";
9
- export { Execution } from "./execution";
10
- export { Metrics } from "./metrics";
11
- export { NodeSandbox } from "./node-sandbox";
12
- export { PythonSandbox } from "./python-sandbox";
13
- export { SandboxOptions } from "./types";
package/dist/index.js DELETED
@@ -1,25 +0,0 @@
1
- "use strict";
2
- /**
3
- * Microsandbox TypeScript SDK
4
- *
5
- * A TypeScript SDK for creating and managing secure sandboxes for code execution.
6
- */
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.SandboxOptions = exports.PythonSandbox = exports.NodeSandbox = exports.Metrics = exports.Execution = exports.CommandExecution = exports.Command = exports.BaseSandbox = void 0;
9
- var base_sandbox_1 = require("./base-sandbox");
10
- Object.defineProperty(exports, "BaseSandbox", { enumerable: true, get: function () { return base_sandbox_1.BaseSandbox; } });
11
- var command_1 = require("./command");
12
- Object.defineProperty(exports, "Command", { enumerable: true, get: function () { return command_1.Command; } });
13
- var command_execution_1 = require("./command-execution");
14
- Object.defineProperty(exports, "CommandExecution", { enumerable: true, get: function () { return command_execution_1.CommandExecution; } });
15
- var execution_1 = require("./execution");
16
- Object.defineProperty(exports, "Execution", { enumerable: true, get: function () { return execution_1.Execution; } });
17
- var metrics_1 = require("./metrics");
18
- Object.defineProperty(exports, "Metrics", { enumerable: true, get: function () { return metrics_1.Metrics; } });
19
- var node_sandbox_1 = require("./node-sandbox");
20
- Object.defineProperty(exports, "NodeSandbox", { enumerable: true, get: function () { return node_sandbox_1.NodeSandbox; } });
21
- var python_sandbox_1 = require("./python-sandbox");
22
- Object.defineProperty(exports, "PythonSandbox", { enumerable: true, get: function () { return python_sandbox_1.PythonSandbox; } });
23
- var types_1 = require("./types");
24
- Object.defineProperty(exports, "SandboxOptions", { enumerable: true, get: function () { return types_1.SandboxOptions; } });
25
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,+CAA6C;AAApC,2GAAA,WAAW,OAAA;AACpB,qCAAoC;AAA3B,kGAAA,OAAO,OAAA;AAChB,yDAAuD;AAA9C,qHAAA,gBAAgB,OAAA;AACzB,yCAAwC;AAA/B,sGAAA,SAAS,OAAA;AAClB,qCAAoC;AAA3B,kGAAA,OAAO,OAAA;AAChB,+CAA6C;AAApC,2GAAA,WAAW,OAAA;AACpB,mDAAiD;AAAxC,+GAAA,aAAa,OAAA;AACtB,iCAAyC;AAAhC,uGAAA,cAAc,OAAA"}
package/dist/metrics.d.ts DELETED
@@ -1,69 +0,0 @@
1
- /**
2
- * Metrics interface for the Microsandbox TypeScript SDK.
3
- */
4
- import { BaseSandbox } from "./base-sandbox";
5
- export declare class Metrics {
6
- private sandbox;
7
- /**
8
- * Initialize the metrics instance.
9
- *
10
- * @param sandboxInstance - The sandbox instance this metrics object belongs to
11
- */
12
- constructor(sandboxInstance: BaseSandbox);
13
- /**
14
- * Internal method to fetch current metrics from the server.
15
- *
16
- * @returns A dictionary containing the metrics data for the sandbox
17
- * @throws Error if the request to the server fails
18
- */
19
- private getMetrics;
20
- /**
21
- * Get all metrics for the current sandbox.
22
- *
23
- * @returns A dictionary containing all metrics for the sandbox:
24
- * {
25
- * "name": string,
26
- * "namespace": string,
27
- * "running": boolean,
28
- * "cpu_usage": number | null,
29
- * "memory_usage": number | null,
30
- * "disk_usage": number | null
31
- * }
32
- *
33
- * @throws Error if the sandbox is not started or if the request fails
34
- */
35
- all(): Promise<any>;
36
- /**
37
- * Get CPU usage percentage for the current sandbox.
38
- *
39
- * @returns CPU usage as a percentage (0-100) or undefined if not available.
40
- * May return 0.0 for idle sandboxes or when metrics are not precise.
41
- *
42
- * @throws Error if the sandbox is not started or if the request fails
43
- */
44
- cpu(): Promise<number | undefined>;
45
- /**
46
- * Get memory usage for the current sandbox.
47
- *
48
- * @returns Memory usage in MiB or undefined if not available
49
- *
50
- * @throws Error if the sandbox is not started or if the request fails
51
- */
52
- memory(): Promise<number | undefined>;
53
- /**
54
- * Get disk usage for the current sandbox.
55
- *
56
- * @returns Disk usage in bytes or undefined if not available
57
- *
58
- * @throws Error if the sandbox is not started or if the request fails
59
- */
60
- disk(): Promise<number | undefined>;
61
- /**
62
- * Check if the sandbox is currently running.
63
- *
64
- * @returns True if the sandbox is running, False otherwise
65
- *
66
- * @throws Error if the request to the server fails
67
- */
68
- isRunning(): Promise<boolean>;
69
- }