@daytona/sdk 0.0.0-dev
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/LICENSE +190 -0
- package/README.md +180 -0
- package/cjs/CodeInterpreter.d.ts +95 -0
- package/cjs/CodeInterpreter.js +297 -0
- package/cjs/CodeInterpreter.js.map +1 -0
- package/cjs/ComputerUse.d.ts +539 -0
- package/cjs/ComputerUse.js +808 -0
- package/cjs/ComputerUse.js.map +1 -0
- package/cjs/Daytona.d.ts +357 -0
- package/cjs/Daytona.js +534 -0
- package/cjs/Daytona.js.map +1 -0
- package/cjs/FileSystem.d.ts +453 -0
- package/cjs/FileSystem.js +575 -0
- package/cjs/FileSystem.js.map +1 -0
- package/cjs/Git.d.ts +203 -0
- package/cjs/Git.js +326 -0
- package/cjs/Git.js.map +1 -0
- package/cjs/Image.d.ts +265 -0
- package/cjs/Image.js +586 -0
- package/cjs/Image.js.map +1 -0
- package/cjs/LspServer.d.ts +172 -0
- package/cjs/LspServer.js +259 -0
- package/cjs/LspServer.js.map +1 -0
- package/cjs/ObjectStorage.d.ts +79 -0
- package/cjs/ObjectStorage.js +199 -0
- package/cjs/ObjectStorage.js.map +1 -0
- package/cjs/Process.d.ts +490 -0
- package/cjs/Process.js +647 -0
- package/cjs/Process.js.map +1 -0
- package/cjs/PtyHandle.d.ts +155 -0
- package/cjs/PtyHandle.js +416 -0
- package/cjs/PtyHandle.js.map +1 -0
- package/cjs/README.md +180 -0
- package/cjs/Sandbox.d.ts +476 -0
- package/cjs/Sandbox.js +905 -0
- package/cjs/Sandbox.js.map +1 -0
- package/cjs/Snapshot.d.ts +140 -0
- package/cjs/Snapshot.js +248 -0
- package/cjs/Snapshot.js.map +1 -0
- package/cjs/Volume.d.ts +84 -0
- package/cjs/Volume.js +119 -0
- package/cjs/Volume.js.map +1 -0
- package/cjs/errors/DaytonaError.d.ts +171 -0
- package/cjs/errors/DaytonaError.js +258 -0
- package/cjs/errors/DaytonaError.js.map +1 -0
- package/cjs/index.d.ts +22 -0
- package/cjs/index.js +49 -0
- package/cjs/index.js.map +1 -0
- package/cjs/package.json +3 -0
- package/cjs/types/Charts.d.ts +38 -0
- package/cjs/types/Charts.js +37 -0
- package/cjs/types/Charts.js.map +1 -0
- package/cjs/types/CodeInterpreter.d.ts +77 -0
- package/cjs/types/CodeInterpreter.js +7 -0
- package/cjs/types/CodeInterpreter.js.map +1 -0
- package/cjs/types/ExecuteResponse.d.ts +26 -0
- package/cjs/types/ExecuteResponse.js +7 -0
- package/cjs/types/ExecuteResponse.js.map +1 -0
- package/cjs/types/Pty.d.ts +48 -0
- package/cjs/types/Pty.js +7 -0
- package/cjs/types/Pty.js.map +1 -0
- package/cjs/utils/Binary.d.ts +38 -0
- package/cjs/utils/Binary.js +174 -0
- package/cjs/utils/Binary.js.map +1 -0
- package/cjs/utils/FileTransfer.d.ts +39 -0
- package/cjs/utils/FileTransfer.js +521 -0
- package/cjs/utils/FileTransfer.js.map +1 -0
- package/cjs/utils/Import.d.ts +40 -0
- package/cjs/utils/Import.js +155 -0
- package/cjs/utils/Import.js.map +1 -0
- package/cjs/utils/Multipart.d.ts +29 -0
- package/cjs/utils/Multipart.js +115 -0
- package/cjs/utils/Multipart.js.map +1 -0
- package/cjs/utils/Runtime.d.ts +44 -0
- package/cjs/utils/Runtime.js +95 -0
- package/cjs/utils/Runtime.js.map +1 -0
- package/cjs/utils/Stream.d.ts +20 -0
- package/cjs/utils/Stream.js +364 -0
- package/cjs/utils/Stream.js.map +1 -0
- package/cjs/utils/WebSocket.d.ts +10 -0
- package/cjs/utils/WebSocket.js +26 -0
- package/cjs/utils/WebSocket.js.map +1 -0
- package/cjs/utils/otel.decorator.d.ts +83 -0
- package/cjs/utils/otel.decorator.js +141 -0
- package/cjs/utils/otel.decorator.js.map +1 -0
- package/esm/CodeInterpreter.d.ts +95 -0
- package/esm/CodeInterpreter.js +292 -0
- package/esm/CodeInterpreter.js.map +1 -0
- package/esm/ComputerUse.d.ts +539 -0
- package/esm/ComputerUse.js +799 -0
- package/esm/ComputerUse.js.map +1 -0
- package/esm/Daytona.d.ts +357 -0
- package/esm/Daytona.js +530 -0
- package/esm/Daytona.js.map +1 -0
- package/esm/FileSystem.d.ts +453 -0
- package/esm/FileSystem.js +571 -0
- package/esm/FileSystem.js.map +1 -0
- package/esm/Git.d.ts +203 -0
- package/esm/Git.js +322 -0
- package/esm/Git.js.map +1 -0
- package/esm/Image.d.ts +265 -0
- package/esm/Image.js +581 -0
- package/esm/Image.js.map +1 -0
- package/esm/LspServer.d.ts +172 -0
- package/esm/LspServer.js +255 -0
- package/esm/LspServer.js.map +1 -0
- package/esm/ObjectStorage.d.ts +79 -0
- package/esm/ObjectStorage.js +195 -0
- package/esm/ObjectStorage.js.map +1 -0
- package/esm/Process.d.ts +490 -0
- package/esm/Process.js +642 -0
- package/esm/Process.js.map +1 -0
- package/esm/PtyHandle.d.ts +155 -0
- package/esm/PtyHandle.js +412 -0
- package/esm/PtyHandle.js.map +1 -0
- package/esm/README.md +180 -0
- package/esm/Sandbox.d.ts +476 -0
- package/esm/Sandbox.js +901 -0
- package/esm/Sandbox.js.map +1 -0
- package/esm/Snapshot.d.ts +140 -0
- package/esm/Snapshot.js +244 -0
- package/esm/Snapshot.js.map +1 -0
- package/esm/Volume.d.ts +84 -0
- package/esm/Volume.js +115 -0
- package/esm/Volume.js.map +1 -0
- package/esm/errors/DaytonaError.d.ts +171 -0
- package/esm/errors/DaytonaError.js +243 -0
- package/esm/errors/DaytonaError.js.map +1 -0
- package/esm/index.d.ts +22 -0
- package/esm/index.js +21 -0
- package/esm/index.js.map +1 -0
- package/esm/package.json +3 -0
- package/esm/types/Charts.d.ts +38 -0
- package/esm/types/Charts.js +33 -0
- package/esm/types/Charts.js.map +1 -0
- package/esm/types/CodeInterpreter.d.ts +77 -0
- package/esm/types/CodeInterpreter.js +6 -0
- package/esm/types/CodeInterpreter.js.map +1 -0
- package/esm/types/ExecuteResponse.d.ts +26 -0
- package/esm/types/ExecuteResponse.js +6 -0
- package/esm/types/ExecuteResponse.js.map +1 -0
- package/esm/types/Pty.d.ts +48 -0
- package/esm/types/Pty.js +6 -0
- package/esm/types/Pty.js.map +1 -0
- package/esm/utils/Binary.d.ts +38 -0
- package/esm/utils/Binary.js +163 -0
- package/esm/utils/Binary.js.map +1 -0
- package/esm/utils/FileTransfer.d.ts +39 -0
- package/esm/utils/FileTransfer.js +512 -0
- package/esm/utils/FileTransfer.js.map +1 -0
- package/esm/utils/Import.d.ts +40 -0
- package/esm/utils/Import.js +119 -0
- package/esm/utils/Import.js.map +1 -0
- package/esm/utils/Multipart.d.ts +29 -0
- package/esm/utils/Multipart.js +109 -0
- package/esm/utils/Multipart.js.map +1 -0
- package/esm/utils/Runtime.d.ts +44 -0
- package/esm/utils/Runtime.js +89 -0
- package/esm/utils/Runtime.js.map +1 -0
- package/esm/utils/Stream.d.ts +20 -0
- package/esm/utils/Stream.js +360 -0
- package/esm/utils/Stream.js.map +1 -0
- package/esm/utils/WebSocket.d.ts +10 -0
- package/esm/utils/WebSocket.js +22 -0
- package/esm/utils/WebSocket.js.map +1 -0
- package/esm/utils/otel.decorator.d.ts +83 -0
- package/esm/utils/otel.decorator.js +136 -0
- package/esm/utils/otel.decorator.js.map +1 -0
- package/package.json +96 -0
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module Errors
|
|
3
|
+
*/
|
|
4
|
+
import { AxiosError, AxiosHeaders } from 'axios';
|
|
5
|
+
export type ResponseHeaders = InstanceType<typeof AxiosHeaders>;
|
|
6
|
+
/**
|
|
7
|
+
* Base error for Daytona SDK.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* try {
|
|
12
|
+
* await daytona.get('missing-sandbox')
|
|
13
|
+
* } catch (error) {
|
|
14
|
+
* if (error instanceof DaytonaError) {
|
|
15
|
+
* console.log(error.statusCode)
|
|
16
|
+
* console.log(error.errorCode)
|
|
17
|
+
* console.log(error.message)
|
|
18
|
+
* }
|
|
19
|
+
* }
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare class DaytonaError extends Error {
|
|
23
|
+
/** HTTP status code if available */
|
|
24
|
+
statusCode?: number;
|
|
25
|
+
/** Machine-readable error code if available */
|
|
26
|
+
errorCode?: string;
|
|
27
|
+
/** Response headers if available */
|
|
28
|
+
headers?: ResponseHeaders;
|
|
29
|
+
constructor(message: string, statusCode?: number, headers?: ResponseHeaders, errorCode?: string);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Error thrown when a resource is not found (HTTP 404).
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* try {
|
|
37
|
+
* await sandbox.fs.downloadFile('/workspace/missing.txt')
|
|
38
|
+
* } catch (error) {
|
|
39
|
+
* if (error instanceof DaytonaNotFoundError) {
|
|
40
|
+
* console.log(error.statusCode)
|
|
41
|
+
* }
|
|
42
|
+
* }
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export declare class DaytonaNotFoundError extends DaytonaError {
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Error thrown when rate limit is exceeded.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```ts
|
|
52
|
+
* try {
|
|
53
|
+
* await daytona.list()
|
|
54
|
+
* } catch (error) {
|
|
55
|
+
* if (error instanceof DaytonaRateLimitError) {
|
|
56
|
+
* console.log(error.errorCode)
|
|
57
|
+
* }
|
|
58
|
+
* }
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export declare class DaytonaRateLimitError extends DaytonaError {
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Error thrown when authentication fails (HTTP 401).
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```ts
|
|
68
|
+
* try {
|
|
69
|
+
* await daytona.list()
|
|
70
|
+
* } catch (error) {
|
|
71
|
+
* if (error instanceof DaytonaAuthenticationError) {
|
|
72
|
+
* console.log(error.statusCode)
|
|
73
|
+
* }
|
|
74
|
+
* }
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
export declare class DaytonaAuthenticationError extends DaytonaError {
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Error thrown when the request is forbidden (HTTP 403).
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```ts
|
|
84
|
+
* try {
|
|
85
|
+
* await daytona.get('sandbox-without-access')
|
|
86
|
+
* } catch (error) {
|
|
87
|
+
* if (error instanceof DaytonaAuthorizationError) {
|
|
88
|
+
* console.log(error.message)
|
|
89
|
+
* }
|
|
90
|
+
* }
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
export declare class DaytonaAuthorizationError extends DaytonaError {
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Error thrown when a resource conflict occurs (HTTP 409).
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```ts
|
|
100
|
+
* try {
|
|
101
|
+
* await daytona.create({ name: 'existing-sandbox' })
|
|
102
|
+
* } catch (error) {
|
|
103
|
+
* if (error instanceof DaytonaConflictError) {
|
|
104
|
+
* console.log(error.errorCode)
|
|
105
|
+
* }
|
|
106
|
+
* }
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
export declare class DaytonaConflictError extends DaytonaError {
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Error thrown when input validation fails (HTTP 400 or client-side validation).
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```ts
|
|
116
|
+
* try {
|
|
117
|
+
* Image.debianSlim('3.8' as never)
|
|
118
|
+
* } catch (error) {
|
|
119
|
+
* if (error instanceof DaytonaValidationError) {
|
|
120
|
+
* console.log(error.message)
|
|
121
|
+
* }
|
|
122
|
+
* }
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
export declare class DaytonaValidationError extends DaytonaError {
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Error thrown when a timeout occurs.
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* ```ts
|
|
132
|
+
* try {
|
|
133
|
+
* await sandbox.waitUntilStarted(1)
|
|
134
|
+
* } catch (error) {
|
|
135
|
+
* if (error instanceof DaytonaTimeoutError) {
|
|
136
|
+
* console.log(error.message)
|
|
137
|
+
* }
|
|
138
|
+
* }
|
|
139
|
+
* ```
|
|
140
|
+
*/
|
|
141
|
+
export declare class DaytonaTimeoutError extends DaytonaError {
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Error thrown when a network connection fails.
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* ```ts
|
|
148
|
+
* try {
|
|
149
|
+
* await ptyHandle.waitForConnection()
|
|
150
|
+
* } catch (error) {
|
|
151
|
+
* if (error instanceof DaytonaConnectionError) {
|
|
152
|
+
* console.log(error.message)
|
|
153
|
+
* }
|
|
154
|
+
* }
|
|
155
|
+
* ```
|
|
156
|
+
*/
|
|
157
|
+
export declare class DaytonaConnectionError extends DaytonaError {
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Maps an HTTP status code to the corresponding Daytona error class.
|
|
161
|
+
*/
|
|
162
|
+
export declare function errorClassFromStatusCode(statusCode?: number): typeof DaytonaError;
|
|
163
|
+
/**
|
|
164
|
+
* Creates the appropriate Daytona error subclass from structured error metadata.
|
|
165
|
+
*/
|
|
166
|
+
export declare function createDaytonaError(message: string, statusCode?: number, headers?: ResponseHeaders, errorCode?: string): DaytonaError;
|
|
167
|
+
/**
|
|
168
|
+
* Creates the appropriate Daytona error subclass from an Axios error.
|
|
169
|
+
*/
|
|
170
|
+
export declare function createAxiosDaytonaError(error: AxiosError): DaytonaError;
|
|
171
|
+
//# sourceMappingURL=DaytonaError.d.ts.map
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2025 Daytona Platforms Inc.
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.DaytonaConnectionError = exports.DaytonaTimeoutError = exports.DaytonaValidationError = exports.DaytonaConflictError = exports.DaytonaAuthorizationError = exports.DaytonaAuthenticationError = exports.DaytonaRateLimitError = exports.DaytonaNotFoundError = exports.DaytonaError = void 0;
|
|
8
|
+
exports.errorClassFromStatusCode = errorClassFromStatusCode;
|
|
9
|
+
exports.createDaytonaError = createDaytonaError;
|
|
10
|
+
exports.createAxiosDaytonaError = createAxiosDaytonaError;
|
|
11
|
+
/**
|
|
12
|
+
* Base error for Daytona SDK.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* try {
|
|
17
|
+
* await daytona.get('missing-sandbox')
|
|
18
|
+
* } catch (error) {
|
|
19
|
+
* if (error instanceof DaytonaError) {
|
|
20
|
+
* console.log(error.statusCode)
|
|
21
|
+
* console.log(error.errorCode)
|
|
22
|
+
* console.log(error.message)
|
|
23
|
+
* }
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
class DaytonaError extends Error {
|
|
28
|
+
/** HTTP status code if available */
|
|
29
|
+
statusCode;
|
|
30
|
+
/** Machine-readable error code if available */
|
|
31
|
+
errorCode;
|
|
32
|
+
/** Response headers if available */
|
|
33
|
+
headers;
|
|
34
|
+
constructor(message, statusCode, headers, errorCode) {
|
|
35
|
+
super(message);
|
|
36
|
+
this.name = new.target.name;
|
|
37
|
+
this.statusCode = statusCode;
|
|
38
|
+
this.headers = headers;
|
|
39
|
+
this.errorCode = errorCode;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.DaytonaError = DaytonaError;
|
|
43
|
+
/**
|
|
44
|
+
* Error thrown when a resource is not found (HTTP 404).
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* try {
|
|
49
|
+
* await sandbox.fs.downloadFile('/workspace/missing.txt')
|
|
50
|
+
* } catch (error) {
|
|
51
|
+
* if (error instanceof DaytonaNotFoundError) {
|
|
52
|
+
* console.log(error.statusCode)
|
|
53
|
+
* }
|
|
54
|
+
* }
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
class DaytonaNotFoundError extends DaytonaError {
|
|
58
|
+
}
|
|
59
|
+
exports.DaytonaNotFoundError = DaytonaNotFoundError;
|
|
60
|
+
/**
|
|
61
|
+
* Error thrown when rate limit is exceeded.
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```ts
|
|
65
|
+
* try {
|
|
66
|
+
* await daytona.list()
|
|
67
|
+
* } catch (error) {
|
|
68
|
+
* if (error instanceof DaytonaRateLimitError) {
|
|
69
|
+
* console.log(error.errorCode)
|
|
70
|
+
* }
|
|
71
|
+
* }
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
class DaytonaRateLimitError extends DaytonaError {
|
|
75
|
+
}
|
|
76
|
+
exports.DaytonaRateLimitError = DaytonaRateLimitError;
|
|
77
|
+
/**
|
|
78
|
+
* Error thrown when authentication fails (HTTP 401).
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```ts
|
|
82
|
+
* try {
|
|
83
|
+
* await daytona.list()
|
|
84
|
+
* } catch (error) {
|
|
85
|
+
* if (error instanceof DaytonaAuthenticationError) {
|
|
86
|
+
* console.log(error.statusCode)
|
|
87
|
+
* }
|
|
88
|
+
* }
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
class DaytonaAuthenticationError extends DaytonaError {
|
|
92
|
+
}
|
|
93
|
+
exports.DaytonaAuthenticationError = DaytonaAuthenticationError;
|
|
94
|
+
/**
|
|
95
|
+
* Error thrown when the request is forbidden (HTTP 403).
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```ts
|
|
99
|
+
* try {
|
|
100
|
+
* await daytona.get('sandbox-without-access')
|
|
101
|
+
* } catch (error) {
|
|
102
|
+
* if (error instanceof DaytonaAuthorizationError) {
|
|
103
|
+
* console.log(error.message)
|
|
104
|
+
* }
|
|
105
|
+
* }
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
class DaytonaAuthorizationError extends DaytonaError {
|
|
109
|
+
}
|
|
110
|
+
exports.DaytonaAuthorizationError = DaytonaAuthorizationError;
|
|
111
|
+
/**
|
|
112
|
+
* Error thrown when a resource conflict occurs (HTTP 409).
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```ts
|
|
116
|
+
* try {
|
|
117
|
+
* await daytona.create({ name: 'existing-sandbox' })
|
|
118
|
+
* } catch (error) {
|
|
119
|
+
* if (error instanceof DaytonaConflictError) {
|
|
120
|
+
* console.log(error.errorCode)
|
|
121
|
+
* }
|
|
122
|
+
* }
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
class DaytonaConflictError extends DaytonaError {
|
|
126
|
+
}
|
|
127
|
+
exports.DaytonaConflictError = DaytonaConflictError;
|
|
128
|
+
/**
|
|
129
|
+
* Error thrown when input validation fails (HTTP 400 or client-side validation).
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* ```ts
|
|
133
|
+
* try {
|
|
134
|
+
* Image.debianSlim('3.8' as never)
|
|
135
|
+
* } catch (error) {
|
|
136
|
+
* if (error instanceof DaytonaValidationError) {
|
|
137
|
+
* console.log(error.message)
|
|
138
|
+
* }
|
|
139
|
+
* }
|
|
140
|
+
* ```
|
|
141
|
+
*/
|
|
142
|
+
class DaytonaValidationError extends DaytonaError {
|
|
143
|
+
}
|
|
144
|
+
exports.DaytonaValidationError = DaytonaValidationError;
|
|
145
|
+
/**
|
|
146
|
+
* Error thrown when a timeout occurs.
|
|
147
|
+
*
|
|
148
|
+
* @example
|
|
149
|
+
* ```ts
|
|
150
|
+
* try {
|
|
151
|
+
* await sandbox.waitUntilStarted(1)
|
|
152
|
+
* } catch (error) {
|
|
153
|
+
* if (error instanceof DaytonaTimeoutError) {
|
|
154
|
+
* console.log(error.message)
|
|
155
|
+
* }
|
|
156
|
+
* }
|
|
157
|
+
* ```
|
|
158
|
+
*/
|
|
159
|
+
class DaytonaTimeoutError extends DaytonaError {
|
|
160
|
+
}
|
|
161
|
+
exports.DaytonaTimeoutError = DaytonaTimeoutError;
|
|
162
|
+
/**
|
|
163
|
+
* Error thrown when a network connection fails.
|
|
164
|
+
*
|
|
165
|
+
* @example
|
|
166
|
+
* ```ts
|
|
167
|
+
* try {
|
|
168
|
+
* await ptyHandle.waitForConnection()
|
|
169
|
+
* } catch (error) {
|
|
170
|
+
* if (error instanceof DaytonaConnectionError) {
|
|
171
|
+
* console.log(error.message)
|
|
172
|
+
* }
|
|
173
|
+
* }
|
|
174
|
+
* ```
|
|
175
|
+
*/
|
|
176
|
+
class DaytonaConnectionError extends DaytonaError {
|
|
177
|
+
}
|
|
178
|
+
exports.DaytonaConnectionError = DaytonaConnectionError;
|
|
179
|
+
const STATUS_CODE_TO_ERROR = {
|
|
180
|
+
400: DaytonaValidationError,
|
|
181
|
+
401: DaytonaAuthenticationError,
|
|
182
|
+
403: DaytonaAuthorizationError,
|
|
183
|
+
404: DaytonaNotFoundError,
|
|
184
|
+
409: DaytonaConflictError,
|
|
185
|
+
429: DaytonaRateLimitError,
|
|
186
|
+
};
|
|
187
|
+
/**
|
|
188
|
+
* Maps an HTTP status code to the corresponding Daytona error class.
|
|
189
|
+
*/
|
|
190
|
+
function errorClassFromStatusCode(statusCode) {
|
|
191
|
+
if (statusCode === undefined) {
|
|
192
|
+
return DaytonaError;
|
|
193
|
+
}
|
|
194
|
+
return STATUS_CODE_TO_ERROR[statusCode] || DaytonaError;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Creates the appropriate Daytona error subclass from structured error metadata.
|
|
198
|
+
*/
|
|
199
|
+
function createDaytonaError(message, statusCode, headers, errorCode) {
|
|
200
|
+
const ErrorClass = errorClassFromStatusCode(statusCode);
|
|
201
|
+
return new ErrorClass(message, statusCode, headers, errorCode);
|
|
202
|
+
}
|
|
203
|
+
function isAxiosTimeoutError(error) {
|
|
204
|
+
return error.code === 'ECONNABORTED' || error.code === 'ETIMEDOUT' || error.message.includes('timeout of');
|
|
205
|
+
}
|
|
206
|
+
function getAxiosResponseDataObject(error) {
|
|
207
|
+
if (!error.response?.data || typeof error.response.data !== 'object') {
|
|
208
|
+
return undefined;
|
|
209
|
+
}
|
|
210
|
+
return error.response.data;
|
|
211
|
+
}
|
|
212
|
+
function extractAxiosErrorCode(responseData) {
|
|
213
|
+
if (typeof responseData?.code === 'string') {
|
|
214
|
+
return responseData.code;
|
|
215
|
+
}
|
|
216
|
+
if (typeof responseData?.error_code === 'string') {
|
|
217
|
+
return responseData.error_code;
|
|
218
|
+
}
|
|
219
|
+
if (typeof responseData?.error === 'string') {
|
|
220
|
+
return responseData.error;
|
|
221
|
+
}
|
|
222
|
+
return undefined;
|
|
223
|
+
}
|
|
224
|
+
function extractAxiosErrorMessage(error) {
|
|
225
|
+
if (isAxiosTimeoutError(error)) {
|
|
226
|
+
return 'Operation timed out';
|
|
227
|
+
}
|
|
228
|
+
const responseData = getAxiosResponseDataObject(error);
|
|
229
|
+
const responseMessage = responseData?.message || error.response?.data;
|
|
230
|
+
const message = responseMessage || error.message || String(error);
|
|
231
|
+
if (typeof message === 'object') {
|
|
232
|
+
try {
|
|
233
|
+
return JSON.stringify(message);
|
|
234
|
+
}
|
|
235
|
+
catch {
|
|
236
|
+
return String(message);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
return String(message);
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Creates the appropriate Daytona error subclass from an Axios error.
|
|
243
|
+
*/
|
|
244
|
+
function createAxiosDaytonaError(error) {
|
|
245
|
+
const message = extractAxiosErrorMessage(error);
|
|
246
|
+
const statusCode = error.response?.status;
|
|
247
|
+
const headers = error.response?.headers;
|
|
248
|
+
const responseData = getAxiosResponseDataObject(error);
|
|
249
|
+
const errorCode = extractAxiosErrorCode(responseData);
|
|
250
|
+
if (isAxiosTimeoutError(error)) {
|
|
251
|
+
return new DaytonaTimeoutError(message, statusCode, headers, errorCode);
|
|
252
|
+
}
|
|
253
|
+
if (!error.response && (error.request || error.code)) {
|
|
254
|
+
return new DaytonaConnectionError(message, statusCode, headers, errorCode);
|
|
255
|
+
}
|
|
256
|
+
return createDaytonaError(message, statusCode, headers, errorCode);
|
|
257
|
+
}
|
|
258
|
+
//# sourceMappingURL=DaytonaError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DaytonaError.js","sourceRoot":"","sources":["../../../../../../libs/sdk-typescript/src/errors/DaytonaError.ts"],"names":[],"mappings":"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"}
|
package/cjs/index.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export { CodeLanguage, Daytona } from './Daytona';
|
|
2
|
+
export type { CreateSandboxBaseParams, CreateSandboxFromImageParams, CreateSandboxFromSnapshotParams, DaytonaConfig, Resources, VolumeMount, } from './Daytona';
|
|
3
|
+
export { FileSystem } from './FileSystem';
|
|
4
|
+
export type { DownloadProgress, DownloadMetadata, DownloadStreamOptions, UploadProgress, UploadStreamOptions, UploadSource, FileDownloadErrorDetails, FileDownloadRequest, FileDownloadResponse, FilePermissionsParams, FileUpload, } from './FileSystem';
|
|
5
|
+
export { Git } from './Git';
|
|
6
|
+
export { LspLanguageId } from './LspServer';
|
|
7
|
+
export { Process } from './Process';
|
|
8
|
+
export { DaytonaAuthenticationError, DaytonaAuthorizationError, DaytonaConflictError, DaytonaConnectionError, DaytonaError, DaytonaNotFoundError, DaytonaRateLimitError, DaytonaTimeoutError, DaytonaValidationError, } from './errors/DaytonaError';
|
|
9
|
+
export { Image } from './Image';
|
|
10
|
+
export { Sandbox } from './Sandbox';
|
|
11
|
+
export type { CreateSnapshotParams } from './Snapshot';
|
|
12
|
+
export { ComputerUse, Mouse, Keyboard, Screenshot, Display } from './ComputerUse';
|
|
13
|
+
export type { BarChart, BarData, BoxAndWhiskerChart, BoxAndWhiskerData, Chart, Chart2D, ChartElement, CompositeChart, LineChart, PieChart, PieData, PointChart, PointData, ScatterChart, } from './types/Charts';
|
|
14
|
+
export { ChartType } from './types/Charts';
|
|
15
|
+
export type { ExecutionError, ExecutionResult, OutputMessage, RunCodeOptions } from './types/CodeInterpreter';
|
|
16
|
+
export { SandboxState } from '@daytona/api-client';
|
|
17
|
+
export type { FileInfo, GitStatus, ListBranchResponse, Match, ReplaceResult, SearchFilesResponse, } from '@daytona/toolbox-api-client';
|
|
18
|
+
export type { ScreenshotRegion, ScreenshotOptions } from './ComputerUse';
|
|
19
|
+
export * from './Process';
|
|
20
|
+
export * from './PtyHandle';
|
|
21
|
+
export * from './types/Pty';
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
package/cjs/index.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2025 Daytona Platforms Inc.
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.SandboxState = exports.ChartType = exports.Display = exports.Screenshot = exports.Keyboard = exports.Mouse = exports.ComputerUse = exports.Sandbox = exports.Image = exports.DaytonaValidationError = exports.DaytonaTimeoutError = exports.DaytonaRateLimitError = exports.DaytonaNotFoundError = exports.DaytonaError = exports.DaytonaConnectionError = exports.DaytonaConflictError = exports.DaytonaAuthorizationError = exports.DaytonaAuthenticationError = exports.Process = exports.LspLanguageId = exports.Git = exports.FileSystem = exports.Daytona = exports.CodeLanguage = void 0;
|
|
8
|
+
const tslib_1 = require("tslib");
|
|
9
|
+
var Daytona_1 = require("./Daytona");
|
|
10
|
+
Object.defineProperty(exports, "CodeLanguage", { enumerable: true, get: function () { return Daytona_1.CodeLanguage; } });
|
|
11
|
+
Object.defineProperty(exports, "Daytona", { enumerable: true, get: function () { return Daytona_1.Daytona; } });
|
|
12
|
+
var FileSystem_1 = require("./FileSystem");
|
|
13
|
+
Object.defineProperty(exports, "FileSystem", { enumerable: true, get: function () { return FileSystem_1.FileSystem; } });
|
|
14
|
+
var Git_1 = require("./Git");
|
|
15
|
+
Object.defineProperty(exports, "Git", { enumerable: true, get: function () { return Git_1.Git; } });
|
|
16
|
+
var LspServer_1 = require("./LspServer");
|
|
17
|
+
Object.defineProperty(exports, "LspLanguageId", { enumerable: true, get: function () { return LspServer_1.LspLanguageId; } });
|
|
18
|
+
var Process_1 = require("./Process");
|
|
19
|
+
Object.defineProperty(exports, "Process", { enumerable: true, get: function () { return Process_1.Process; } });
|
|
20
|
+
// export { LspServer } from './LspServer'
|
|
21
|
+
// export type { LspLanguageId, Position } from './LspServer'
|
|
22
|
+
var DaytonaError_1 = require("./errors/DaytonaError");
|
|
23
|
+
Object.defineProperty(exports, "DaytonaAuthenticationError", { enumerable: true, get: function () { return DaytonaError_1.DaytonaAuthenticationError; } });
|
|
24
|
+
Object.defineProperty(exports, "DaytonaAuthorizationError", { enumerable: true, get: function () { return DaytonaError_1.DaytonaAuthorizationError; } });
|
|
25
|
+
Object.defineProperty(exports, "DaytonaConflictError", { enumerable: true, get: function () { return DaytonaError_1.DaytonaConflictError; } });
|
|
26
|
+
Object.defineProperty(exports, "DaytonaConnectionError", { enumerable: true, get: function () { return DaytonaError_1.DaytonaConnectionError; } });
|
|
27
|
+
Object.defineProperty(exports, "DaytonaError", { enumerable: true, get: function () { return DaytonaError_1.DaytonaError; } });
|
|
28
|
+
Object.defineProperty(exports, "DaytonaNotFoundError", { enumerable: true, get: function () { return DaytonaError_1.DaytonaNotFoundError; } });
|
|
29
|
+
Object.defineProperty(exports, "DaytonaRateLimitError", { enumerable: true, get: function () { return DaytonaError_1.DaytonaRateLimitError; } });
|
|
30
|
+
Object.defineProperty(exports, "DaytonaTimeoutError", { enumerable: true, get: function () { return DaytonaError_1.DaytonaTimeoutError; } });
|
|
31
|
+
Object.defineProperty(exports, "DaytonaValidationError", { enumerable: true, get: function () { return DaytonaError_1.DaytonaValidationError; } });
|
|
32
|
+
var Image_1 = require("./Image");
|
|
33
|
+
Object.defineProperty(exports, "Image", { enumerable: true, get: function () { return Image_1.Image; } });
|
|
34
|
+
var Sandbox_1 = require("./Sandbox");
|
|
35
|
+
Object.defineProperty(exports, "Sandbox", { enumerable: true, get: function () { return Sandbox_1.Sandbox; } });
|
|
36
|
+
var ComputerUse_1 = require("./ComputerUse");
|
|
37
|
+
Object.defineProperty(exports, "ComputerUse", { enumerable: true, get: function () { return ComputerUse_1.ComputerUse; } });
|
|
38
|
+
Object.defineProperty(exports, "Mouse", { enumerable: true, get: function () { return ComputerUse_1.Mouse; } });
|
|
39
|
+
Object.defineProperty(exports, "Keyboard", { enumerable: true, get: function () { return ComputerUse_1.Keyboard; } });
|
|
40
|
+
Object.defineProperty(exports, "Screenshot", { enumerable: true, get: function () { return ComputerUse_1.Screenshot; } });
|
|
41
|
+
Object.defineProperty(exports, "Display", { enumerable: true, get: function () { return ComputerUse_1.Display; } });
|
|
42
|
+
var Charts_1 = require("./types/Charts");
|
|
43
|
+
Object.defineProperty(exports, "ChartType", { enumerable: true, get: function () { return Charts_1.ChartType; } });
|
|
44
|
+
var api_client_1 = require("@daytona/api-client");
|
|
45
|
+
Object.defineProperty(exports, "SandboxState", { enumerable: true, get: function () { return api_client_1.SandboxState; } });
|
|
46
|
+
tslib_1.__exportStar(require("./Process"), exports);
|
|
47
|
+
tslib_1.__exportStar(require("./PtyHandle"), exports);
|
|
48
|
+
tslib_1.__exportStar(require("./types/Pty"), exports);
|
|
49
|
+
//# sourceMappingURL=index.js.map
|
package/cjs/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/sdk-typescript/src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;AAEH,qCAAiD;AAAxC,uGAAA,YAAY,OAAA;AAAE,kGAAA,OAAO,OAAA;AAS9B,2CAAyC;AAAhC,wGAAA,UAAU,OAAA;AAcnB,6BAA2B;AAAlB,0FAAA,GAAG,OAAA;AACZ,yCAA2C;AAAlC,0GAAA,aAAa,OAAA;AACtB,qCAAmC;AAA1B,kGAAA,OAAO,OAAA;AAChB,0CAA0C;AAC1C,6DAA6D;AAC7D,sDAU8B;AAT5B,0HAAA,0BAA0B,OAAA;AAC1B,yHAAA,yBAAyB,OAAA;AACzB,oHAAA,oBAAoB,OAAA;AACpB,sHAAA,sBAAsB,OAAA;AACtB,4GAAA,YAAY,OAAA;AACZ,oHAAA,oBAAoB,OAAA;AACpB,qHAAA,qBAAqB,OAAA;AACrB,mHAAA,mBAAmB,OAAA;AACnB,sHAAA,sBAAsB,OAAA;AAExB,iCAA+B;AAAtB,8FAAA,KAAK,OAAA;AACd,qCAAmC;AAA1B,kGAAA,OAAO,OAAA;AAEhB,6CAAiF;AAAxE,0GAAA,WAAW,OAAA;AAAE,oGAAA,KAAK,OAAA;AAAE,uGAAA,QAAQ,OAAA;AAAE,yGAAA,UAAU,OAAA;AAAE,sGAAA,OAAO,OAAA;AAiB1D,yCAA0C;AAAjC,mGAAA,SAAS,OAAA;AAGlB,kDAAkD;AAAzC,0GAAA,YAAY,OAAA;AAYrB,oDAAyB;AACzB,sDAA2B;AAC3B,sDAA2B"}
|
package/cjs/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Chart as GeneratedChart, ChartElement as GeneratedChartElement } from '@daytona/toolbox-api-client';
|
|
2
|
+
export declare enum ChartType {
|
|
3
|
+
LINE = "line",
|
|
4
|
+
SCATTER = "scatter",
|
|
5
|
+
BAR = "bar",
|
|
6
|
+
PIE = "pie",
|
|
7
|
+
BOX_AND_WHISKER = "box_and_whisker",
|
|
8
|
+
COMPOSITE_CHART = "composite_chart",
|
|
9
|
+
UNKNOWN = "unknown"
|
|
10
|
+
}
|
|
11
|
+
export type Chart = GeneratedChart;
|
|
12
|
+
export type ChartElement = GeneratedChartElement;
|
|
13
|
+
export type Chart2D = Pick<GeneratedChart, 'type' | 'title' | 'png' | 'x_label' | 'y_label' | 'elements'>;
|
|
14
|
+
export type PointChart = Pick<GeneratedChart, 'type' | 'title' | 'png' | 'x_label' | 'y_label' | 'x_ticks' | 'y_ticks' | 'x_tick_labels' | 'y_tick_labels' | 'x_scale' | 'y_scale' | 'elements'>;
|
|
15
|
+
export type LineChart = PointChart & {
|
|
16
|
+
type: 'line';
|
|
17
|
+
};
|
|
18
|
+
export type ScatterChart = PointChart & {
|
|
19
|
+
type: 'scatter';
|
|
20
|
+
};
|
|
21
|
+
export type BarChart = Chart2D & {
|
|
22
|
+
type: 'bar';
|
|
23
|
+
};
|
|
24
|
+
export type PieChart = Pick<GeneratedChart, 'type' | 'title' | 'png' | 'elements'> & {
|
|
25
|
+
type: 'pie';
|
|
26
|
+
};
|
|
27
|
+
export type BoxAndWhiskerChart = Chart2D & {
|
|
28
|
+
type: 'box_and_whisker';
|
|
29
|
+
};
|
|
30
|
+
export type CompositeChart = Pick<GeneratedChart, 'type' | 'title' | 'png' | 'elements'> & {
|
|
31
|
+
type: 'composite_chart';
|
|
32
|
+
};
|
|
33
|
+
export type PointData = Pick<GeneratedChartElement, 'label' | 'points'>;
|
|
34
|
+
export type BarData = Pick<GeneratedChartElement, 'group' | 'label' | 'value'>;
|
|
35
|
+
export type PieData = Pick<GeneratedChartElement, 'angle' | 'label' | 'radius'>;
|
|
36
|
+
export type BoxAndWhiskerData = Pick<GeneratedChartElement, 'first_quartile' | 'label' | 'max' | 'median' | 'min' | 'outliers'>;
|
|
37
|
+
export declare function parseChart(chart: GeneratedChart): Chart;
|
|
38
|
+
//# sourceMappingURL=Charts.d.ts.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2025 Daytona Platforms Inc.
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.ChartType = void 0;
|
|
8
|
+
exports.parseChart = parseChart;
|
|
9
|
+
var ChartType;
|
|
10
|
+
(function (ChartType) {
|
|
11
|
+
ChartType["LINE"] = "line";
|
|
12
|
+
ChartType["SCATTER"] = "scatter";
|
|
13
|
+
ChartType["BAR"] = "bar";
|
|
14
|
+
ChartType["PIE"] = "pie";
|
|
15
|
+
ChartType["BOX_AND_WHISKER"] = "box_and_whisker";
|
|
16
|
+
ChartType["COMPOSITE_CHART"] = "composite_chart";
|
|
17
|
+
ChartType["UNKNOWN"] = "unknown";
|
|
18
|
+
})(ChartType || (exports.ChartType = ChartType = {}));
|
|
19
|
+
function parseChart(chart) {
|
|
20
|
+
switch (chart.type) {
|
|
21
|
+
case ChartType.LINE:
|
|
22
|
+
return chart;
|
|
23
|
+
case ChartType.SCATTER:
|
|
24
|
+
return chart;
|
|
25
|
+
case ChartType.BAR:
|
|
26
|
+
return chart;
|
|
27
|
+
case ChartType.PIE:
|
|
28
|
+
return chart;
|
|
29
|
+
case ChartType.BOX_AND_WHISKER:
|
|
30
|
+
return chart;
|
|
31
|
+
case ChartType.COMPOSITE_CHART:
|
|
32
|
+
return chart;
|
|
33
|
+
default:
|
|
34
|
+
return chart;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=Charts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Charts.js","sourceRoot":"","sources":["../../../../../../libs/sdk-typescript/src/types/Charts.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAgDH,gCAiBC;AA7DD,IAAY,SAQX;AARD,WAAY,SAAS;IACnB,0BAAa,CAAA;IACb,gCAAmB,CAAA;IACnB,wBAAW,CAAA;IACX,wBAAW,CAAA;IACX,gDAAmC,CAAA;IACnC,gDAAmC,CAAA;IACnC,gCAAmB,CAAA;AACrB,CAAC,EARW,SAAS,yBAAT,SAAS,QAQpB;AAoCD,SAAgB,UAAU,CAAC,KAAqB;IAC9C,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;QACnB,KAAK,SAAS,CAAC,IAAI;YACjB,OAAO,KAAkB,CAAA;QAC3B,KAAK,SAAS,CAAC,OAAO;YACpB,OAAO,KAAqB,CAAA;QAC9B,KAAK,SAAS,CAAC,GAAG;YAChB,OAAO,KAAiB,CAAA;QAC1B,KAAK,SAAS,CAAC,GAAG;YAChB,OAAO,KAAiB,CAAA;QAC1B,KAAK,SAAS,CAAC,eAAe;YAC5B,OAAO,KAA2B,CAAA;QACpC,KAAK,SAAS,CAAC,eAAe;YAC5B,OAAO,KAAuB,CAAA;QAChC;YACE,OAAO,KAAK,CAAA;IAChB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module code-interpreter
|
|
3
|
+
*/
|
|
4
|
+
import { InterpreterContext } from '@daytona/toolbox-api-client';
|
|
5
|
+
/**
|
|
6
|
+
* Represents stdout or stderr output from code execution.
|
|
7
|
+
*/
|
|
8
|
+
export interface OutputMessage {
|
|
9
|
+
/**
|
|
10
|
+
* Output content.
|
|
11
|
+
*/
|
|
12
|
+
output: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Represents an error that occurred during code execution.
|
|
16
|
+
*/
|
|
17
|
+
export interface ExecutionError {
|
|
18
|
+
/**
|
|
19
|
+
* Error type/class name (e.g., "ValueError", "SyntaxError").
|
|
20
|
+
*/
|
|
21
|
+
name: string;
|
|
22
|
+
/**
|
|
23
|
+
* Error value/message.
|
|
24
|
+
*/
|
|
25
|
+
value: string;
|
|
26
|
+
/**
|
|
27
|
+
* Full traceback for the error, if available.
|
|
28
|
+
*/
|
|
29
|
+
traceback?: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Result of code execution.
|
|
33
|
+
*/
|
|
34
|
+
export interface ExecutionResult {
|
|
35
|
+
/**
|
|
36
|
+
* Standard output captured during execution.
|
|
37
|
+
*/
|
|
38
|
+
stdout: string;
|
|
39
|
+
/**
|
|
40
|
+
* Standard error captured during execution.
|
|
41
|
+
*/
|
|
42
|
+
stderr: string;
|
|
43
|
+
/**
|
|
44
|
+
* Details about an execution error, if one occurred.
|
|
45
|
+
*/
|
|
46
|
+
error?: ExecutionError;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Options for executing code in the interpreter.
|
|
50
|
+
*/
|
|
51
|
+
export interface RunCodeOptions {
|
|
52
|
+
/**
|
|
53
|
+
* Interpreter context to run code in.
|
|
54
|
+
*/
|
|
55
|
+
context?: InterpreterContext;
|
|
56
|
+
/**
|
|
57
|
+
* Environment variables for this execution.
|
|
58
|
+
*/
|
|
59
|
+
envs?: Record<string, string>;
|
|
60
|
+
/**
|
|
61
|
+
* Timeout in seconds. Set to 0 for no timeout. Default is 10 minutes.
|
|
62
|
+
*/
|
|
63
|
+
timeout?: number;
|
|
64
|
+
/**
|
|
65
|
+
* Callback for stdout messages.
|
|
66
|
+
*/
|
|
67
|
+
onStdout?: (message: OutputMessage) => any | Promise<any>;
|
|
68
|
+
/**
|
|
69
|
+
* Callback for stderr messages.
|
|
70
|
+
*/
|
|
71
|
+
onStderr?: (message: OutputMessage) => any | Promise<any>;
|
|
72
|
+
/**
|
|
73
|
+
* Callback for execution errors (e.g., runtime exceptions).
|
|
74
|
+
*/
|
|
75
|
+
onError?: (error: ExecutionError) => any | Promise<any>;
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=CodeInterpreter.d.ts.map
|