@daytona/sdk 0.163.0-alpha.1 → 0.163.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/package.json +3 -3
- package/src/CodeInterpreter.js +4 -4
- package/src/CodeInterpreter.js.map +1 -1
- package/src/Daytona.d.ts +9 -1
- package/src/Daytona.js +45 -44
- package/src/Daytona.js.map +1 -1
- package/src/FileSystem.d.ts +19 -1
- package/src/FileSystem.js +11 -3
- package/src/FileSystem.js.map +1 -1
- package/src/Image.js +51 -11
- package/src/Image.js.map +1 -1
- package/src/LspServer.js +2 -1
- package/src/LspServer.js.map +1 -1
- package/src/ObjectStorage.js +1 -1
- package/src/ObjectStorage.js.map +1 -1
- package/src/Process.d.ts +3 -2
- package/src/Process.js +177 -42
- package/src/Process.js.map +1 -1
- package/src/PtyHandle.js +4 -4
- package/src/PtyHandle.js.map +1 -1
- package/src/Sandbox.d.ts +14 -2
- package/src/Sandbox.js +19 -16
- package/src/Sandbox.js.map +1 -1
- package/src/code-toolbox/SandboxJsCodeToolbox.d.ts +5 -0
- package/src/code-toolbox/SandboxJsCodeToolbox.js +20 -0
- package/src/code-toolbox/SandboxJsCodeToolbox.js.map +1 -0
- package/src/code-toolbox/SandboxPythonCodeToolbox.d.ts +11 -0
- package/src/code-toolbox/SandboxPythonCodeToolbox.js +359 -0
- package/src/code-toolbox/SandboxPythonCodeToolbox.js.map +1 -0
- package/src/code-toolbox/SandboxTsCodeToolbox.d.ts +5 -0
- package/src/code-toolbox/SandboxTsCodeToolbox.js +29 -0
- package/src/code-toolbox/SandboxTsCodeToolbox.js.map +1 -0
- package/src/errors/DaytonaError.d.ts +146 -7
- package/src/errors/DaytonaError.js +222 -15
- package/src/errors/DaytonaError.js.map +1 -1
- package/src/index.d.ts +5 -3
- package/src/index.js +7 -1
- package/src/index.js.map +1 -1
- package/src/types/Charts.d.ts +132 -18
- package/src/types/Charts.js +18 -9
- package/src/types/Charts.js.map +1 -1
- package/src/types/ExecuteResponse.d.ts +1 -1
- package/src/utils/ArtifactParser.d.ts +13 -0
- package/src/utils/ArtifactParser.js +55 -0
- package/src/utils/ArtifactParser.js.map +1 -0
- package/src/utils/FileTransfer.d.ts +1 -1
- package/src/utils/FileTransfer.js +54 -12
- package/src/utils/FileTransfer.js.map +1 -1
- package/src/utils/Multipart.d.ts +3 -1
- package/src/utils/Multipart.js +4 -2
- package/src/utils/Multipart.js.map +1 -1
|
@@ -4,48 +4,255 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.DaytonaTimeoutError = exports.DaytonaRateLimitError = exports.DaytonaNotFoundError = exports.DaytonaError = void 0;
|
|
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;
|
|
8
11
|
/**
|
|
9
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
|
+
* ```
|
|
10
26
|
*/
|
|
11
27
|
class DaytonaError extends Error {
|
|
12
28
|
/** HTTP status code if available */
|
|
13
29
|
statusCode;
|
|
30
|
+
/** Machine-readable error code if available */
|
|
31
|
+
errorCode;
|
|
14
32
|
/** Response headers if available */
|
|
15
33
|
headers;
|
|
16
|
-
constructor(message, statusCode, headers) {
|
|
34
|
+
constructor(message, statusCode, headers, errorCode) {
|
|
17
35
|
super(message);
|
|
18
|
-
this.name =
|
|
36
|
+
this.name = new.target.name;
|
|
19
37
|
this.statusCode = statusCode;
|
|
20
38
|
this.headers = headers;
|
|
39
|
+
this.errorCode = errorCode;
|
|
21
40
|
}
|
|
22
41
|
}
|
|
23
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
|
+
*/
|
|
24
57
|
class DaytonaNotFoundError extends DaytonaError {
|
|
25
|
-
constructor(message, statusCode, headers) {
|
|
26
|
-
super(message, statusCode, headers);
|
|
27
|
-
this.name = 'DaytonaNotFoundError';
|
|
28
|
-
}
|
|
29
58
|
}
|
|
30
59
|
exports.DaytonaNotFoundError = DaytonaNotFoundError;
|
|
31
60
|
/**
|
|
32
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
|
+
* ```
|
|
33
73
|
*/
|
|
34
74
|
class DaytonaRateLimitError extends DaytonaError {
|
|
35
|
-
constructor(message, statusCode, headers) {
|
|
36
|
-
super(message, statusCode, headers);
|
|
37
|
-
this.name = 'DaytonaRateLimitError';
|
|
38
|
-
}
|
|
39
75
|
}
|
|
40
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;
|
|
41
145
|
/**
|
|
42
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
|
+
* ```
|
|
43
158
|
*/
|
|
44
159
|
class DaytonaTimeoutError extends DaytonaError {
|
|
45
|
-
constructor(message, statusCode, headers) {
|
|
46
|
-
super(message, statusCode, headers);
|
|
47
|
-
this.name = 'DaytonaTimeoutError';
|
|
48
|
-
}
|
|
49
160
|
}
|
|
50
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
|
+
}
|
|
51
258
|
//# sourceMappingURL=DaytonaError.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DaytonaError.js","sourceRoot":"","sources":["../../../../../libs/sdk-typescript/src/errors/DaytonaError.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;
|
|
1
|
+
{"version":3,"file":"DaytonaError.js","sourceRoot":"","sources":["../../../../../libs/sdk-typescript/src/errors/DaytonaError.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AA+LH,4DAMC;AAKD,gDAQC;AAqDD,0DAgBC;AA7QD;;;;;;;;;;;;;;;GAeG;AACH,MAAa,YAAa,SAAQ,KAAK;IACrC,oCAAoC;IAC7B,UAAU,CAAS;IAC1B,+CAA+C;IACxC,SAAS,CAAS;IACzB,oCAAoC;IAC7B,OAAO,CAAkB;IAEhC,YAAY,OAAe,EAAE,UAAmB,EAAE,OAAyB,EAAE,SAAkB;QAC7F,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAA;QAC3B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAC5B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;IAC5B,CAAC;CACF;AAfD,oCAeC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAa,oBAAqB,SAAQ,YAAY;CACrD;AADD,oDACC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAa,qBAAsB,SAAQ,YAAY;CACtD;AADD,sDACC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAa,0BAA2B,SAAQ,YAAY;CAC3D;AADD,gEACC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAa,yBAA0B,SAAQ,YAAY;CAC1D;AADD,8DACC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAa,oBAAqB,SAAQ,YAAY;CACrD;AADD,oDACC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAa,sBAAuB,SAAQ,YAAY;CACvD;AADD,wDACC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAa,mBAAoB,SAAQ,YAAY;CACpD;AADD,kDACC;AAED;;;;;;;;;;;;;GAaG;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Y,CAAC,CAAA;IAErD,IAAI,mBAAmB,CAAC,KAAK,CAAC,EAAE,CAAC;QAC/B,OAAO,IAAI,mBAAmB,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS,CAAC,CAAA;IACzE,CAAC;IAED,IAAI,CAAC,KAAK,CAAC,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QACrD,OAAO,IAAI,sBAAsB,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS,CAAC,CAAA;IAC5E,CAAC;IAED,OAAO,kBAAkB,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS,CAAC,CAAA;AACpE,CAAC"}
|
package/src/index.d.ts
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
export { CodeLanguage, Daytona } from './Daytona';
|
|
2
2
|
export type { CreateSandboxBaseParams, CreateSandboxFromImageParams, CreateSandboxFromSnapshotParams, DaytonaConfig, Resources, VolumeMount, } from './Daytona';
|
|
3
3
|
export { FileSystem } from './FileSystem';
|
|
4
|
+
export type { DownloadMetadata, FileDownloadErrorDetails, FileDownloadRequest, FileDownloadResponse, FilePermissionsParams, FileUpload, } from './FileSystem';
|
|
4
5
|
export { Git } from './Git';
|
|
5
6
|
export { LspLanguageId } from './LspServer';
|
|
6
7
|
export { Process } from './Process';
|
|
7
|
-
export { DaytonaError, DaytonaNotFoundError, DaytonaRateLimitError, DaytonaTimeoutError } from './errors/DaytonaError';
|
|
8
|
+
export { DaytonaAuthenticationError, DaytonaAuthorizationError, DaytonaConflictError, DaytonaConnectionError, DaytonaError, DaytonaNotFoundError, DaytonaRateLimitError, DaytonaTimeoutError, DaytonaValidationError, } from './errors/DaytonaError';
|
|
8
9
|
export { Image } from './Image';
|
|
9
10
|
export { Sandbox } from './Sandbox';
|
|
11
|
+
export type { SandboxCodeToolbox } from './Sandbox';
|
|
10
12
|
export type { CreateSnapshotParams } from './Snapshot';
|
|
11
13
|
export { ComputerUse, Mouse, Keyboard, Screenshot, Display } from './ComputerUse';
|
|
12
|
-
export type { BarChart, BarData, BoxAndWhiskerChart, BoxAndWhiskerData, Chart, Chart2D, ChartElement, CompositeChart, LineChart, PieChart, PieData, PointChart, PointData, ScatterChart, } from './types/Charts';
|
|
13
|
-
export { ChartType } from './types/Charts';
|
|
14
14
|
export type { ExecutionError, ExecutionResult, OutputMessage, RunCodeOptions } from './types/CodeInterpreter';
|
|
15
|
+
export { ChartType } from './types/Charts';
|
|
16
|
+
export type { BarChart, BoxAndWhiskerChart, Chart, CompositeChart, LineChart, PieChart, ScatterChart, } from './types/Charts';
|
|
15
17
|
export { SandboxState } from '@daytona/api-client';
|
|
16
18
|
export type { FileInfo, GitStatus, ListBranchResponse, Match, ReplaceResult, SearchFilesResponse, } from '@daytona/toolbox-api-client';
|
|
17
19
|
export type { ScreenshotRegion, ScreenshotOptions } from './ComputerUse';
|
package/src/index.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
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.DaytonaTimeoutError = exports.DaytonaRateLimitError = exports.DaytonaNotFoundError = exports.DaytonaError = exports.Process = exports.LspLanguageId = exports.Git = exports.FileSystem = exports.Daytona = exports.CodeLanguage = void 0;
|
|
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
8
|
const tslib_1 = require("tslib");
|
|
9
9
|
var Daytona_1 = require("./Daytona");
|
|
10
10
|
Object.defineProperty(exports, "CodeLanguage", { enumerable: true, get: function () { return Daytona_1.CodeLanguage; } });
|
|
@@ -20,10 +20,15 @@ Object.defineProperty(exports, "Process", { enumerable: true, get: function () {
|
|
|
20
20
|
// export { LspServer } from './LspServer'
|
|
21
21
|
// export type { LspLanguageId, Position } from './LspServer'
|
|
22
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; } });
|
|
23
27
|
Object.defineProperty(exports, "DaytonaError", { enumerable: true, get: function () { return DaytonaError_1.DaytonaError; } });
|
|
24
28
|
Object.defineProperty(exports, "DaytonaNotFoundError", { enumerable: true, get: function () { return DaytonaError_1.DaytonaNotFoundError; } });
|
|
25
29
|
Object.defineProperty(exports, "DaytonaRateLimitError", { enumerable: true, get: function () { return DaytonaError_1.DaytonaRateLimitError; } });
|
|
26
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; } });
|
|
27
32
|
var Image_1 = require("./Image");
|
|
28
33
|
Object.defineProperty(exports, "Image", { enumerable: true, get: function () { return Image_1.Image; } });
|
|
29
34
|
var Sandbox_1 = require("./Sandbox");
|
|
@@ -34,6 +39,7 @@ Object.defineProperty(exports, "Mouse", { enumerable: true, get: function () { r
|
|
|
34
39
|
Object.defineProperty(exports, "Keyboard", { enumerable: true, get: function () { return ComputerUse_1.Keyboard; } });
|
|
35
40
|
Object.defineProperty(exports, "Screenshot", { enumerable: true, get: function () { return ComputerUse_1.Screenshot; } });
|
|
36
41
|
Object.defineProperty(exports, "Display", { enumerable: true, get: function () { return ComputerUse_1.Display; } });
|
|
42
|
+
// Chart and artifact types
|
|
37
43
|
var Charts_1 = require("./types/Charts");
|
|
38
44
|
Object.defineProperty(exports, "ChartType", { enumerable: true, get: function () { return Charts_1.ChartType; } });
|
|
39
45
|
var api_client_1 = require("@daytona/api-client");
|
package/src/index.js.map
CHANGED
|
@@ -1 +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;
|
|
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;AASnB,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;AAGhB,6CAAiF;AAAxE,0GAAA,WAAW,OAAA;AAAE,oGAAA,KAAK,OAAA;AAAE,uGAAA,QAAQ,OAAA;AAAE,yGAAA,UAAU,OAAA;AAAE,sGAAA,OAAO,OAAA;AAG1D,2BAA2B;AAC3B,yCAA0C;AAAjC,mGAAA,SAAS,OAAA;AAWlB,kDAAkD;AAAzC,0GAAA,YAAY,OAAA;AAYrB,oDAAyB;AACzB,sDAA2B;AAC3B,sDAA2B"}
|
package/src/types/Charts.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Chart types
|
|
3
|
+
*/
|
|
2
4
|
export declare enum ChartType {
|
|
3
5
|
LINE = "line",
|
|
4
6
|
SCATTER = "scatter",
|
|
@@ -8,30 +10,142 @@ export declare enum ChartType {
|
|
|
8
10
|
COMPOSITE_CHART = "composite_chart",
|
|
9
11
|
UNKNOWN = "unknown"
|
|
10
12
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
export type
|
|
13
|
+
/**
|
|
14
|
+
* Represents a chart with metadata from matplotlib.
|
|
15
|
+
*/
|
|
16
|
+
export type Chart = {
|
|
17
|
+
/** The type of chart */
|
|
18
|
+
type: ChartType;
|
|
19
|
+
/** The title of the chart */
|
|
20
|
+
title: string;
|
|
21
|
+
/** The elements of the chart */
|
|
22
|
+
elements: any[];
|
|
23
|
+
/** The PNG representation of the chart encoded in base64 */
|
|
24
|
+
png?: string;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Represents a 2D chart with metadata.
|
|
28
|
+
*/
|
|
29
|
+
export type Chart2D = Chart & {
|
|
30
|
+
/** The label of the x-axis */
|
|
31
|
+
x_label?: string;
|
|
32
|
+
/** The label of the y-axis */
|
|
33
|
+
y_label?: string;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Represents a point in a 2D chart.
|
|
37
|
+
*/
|
|
38
|
+
export type PointData = {
|
|
39
|
+
/** The label of the point */
|
|
40
|
+
label: string;
|
|
41
|
+
/** The points of the chart */
|
|
42
|
+
points: [number | string, number | string][];
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Represents a point chart with metadata.
|
|
46
|
+
*/
|
|
47
|
+
export type PointChart = Chart2D & {
|
|
48
|
+
/** The ticks of the x-axis */
|
|
49
|
+
x_ticks: (number | string)[];
|
|
50
|
+
/** The scale of the x-axis */
|
|
51
|
+
x_scale: string;
|
|
52
|
+
/** The labels of the x-axis */
|
|
53
|
+
x_tick_labels: string[];
|
|
54
|
+
/** The ticks of the y-axis */
|
|
55
|
+
y_ticks: (number | string)[];
|
|
56
|
+
/** The scale of the y-axis */
|
|
57
|
+
y_scale: string;
|
|
58
|
+
/** The labels of the y-axis */
|
|
59
|
+
y_tick_labels: string[];
|
|
60
|
+
/** The points of the chart */
|
|
61
|
+
elements: PointData[];
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Represents a line chart with metadata.
|
|
65
|
+
*/
|
|
15
66
|
export type LineChart = PointChart & {
|
|
16
|
-
type
|
|
67
|
+
/** The type of chart */
|
|
68
|
+
type: ChartType.LINE;
|
|
17
69
|
};
|
|
70
|
+
/**
|
|
71
|
+
* Represents a scatter chart with metadata.
|
|
72
|
+
*/
|
|
18
73
|
export type ScatterChart = PointChart & {
|
|
19
|
-
type
|
|
74
|
+
/** The type of chart */
|
|
75
|
+
type: ChartType.SCATTER;
|
|
20
76
|
};
|
|
77
|
+
/**
|
|
78
|
+
* Represents a bar in a bar chart.
|
|
79
|
+
*/
|
|
80
|
+
export type BarData = {
|
|
81
|
+
/** The label of the bar */
|
|
82
|
+
label: string;
|
|
83
|
+
/** The value of the bar */
|
|
84
|
+
value: string;
|
|
85
|
+
/** The group of the bar */
|
|
86
|
+
group: string;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Represents a bar chart with metadata.
|
|
90
|
+
*/
|
|
21
91
|
export type BarChart = Chart2D & {
|
|
22
|
-
type
|
|
92
|
+
/** The type of chart */
|
|
93
|
+
type: ChartType.BAR;
|
|
94
|
+
/** The bars of the chart */
|
|
95
|
+
elements: BarData[];
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* Represents a pie slice in a pie chart.
|
|
99
|
+
*/
|
|
100
|
+
export type PieData = {
|
|
101
|
+
/** The label of the pie slice */
|
|
102
|
+
label: string;
|
|
103
|
+
/** The angle of the pie slice */
|
|
104
|
+
angle: number;
|
|
105
|
+
/** The radius of the pie slice */
|
|
106
|
+
radius: number;
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Represents a pie chart with metadata.
|
|
110
|
+
*/
|
|
111
|
+
export type PieChart = Chart & {
|
|
112
|
+
/** The type of chart */
|
|
113
|
+
type: ChartType.PIE;
|
|
114
|
+
/** The pie slices of the chart */
|
|
115
|
+
elements: PieData[];
|
|
23
116
|
};
|
|
24
|
-
|
|
25
|
-
|
|
117
|
+
/**
|
|
118
|
+
* Represents a box and whisker in a box and whisker chart.
|
|
119
|
+
*/
|
|
120
|
+
export type BoxAndWhiskerData = {
|
|
121
|
+
/** The label of the box and whisker */
|
|
122
|
+
label: string;
|
|
123
|
+
/** The minimum value of the box and whisker */
|
|
124
|
+
min: number;
|
|
125
|
+
/** The first quartile of the box and whisker */
|
|
126
|
+
first_quartile: number;
|
|
127
|
+
/** The median of the box and whisker */
|
|
128
|
+
median: number;
|
|
129
|
+
/** The third quartile of the box and whisker */
|
|
130
|
+
max: number;
|
|
131
|
+
outliers: number[];
|
|
26
132
|
};
|
|
133
|
+
/**
|
|
134
|
+
* Represents a box and whisker chart with metadata.
|
|
135
|
+
*/
|
|
27
136
|
export type BoxAndWhiskerChart = Chart2D & {
|
|
28
|
-
type
|
|
137
|
+
/** The type of chart */
|
|
138
|
+
type: ChartType.BOX_AND_WHISKER;
|
|
139
|
+
/** The box and whiskers of the chart */
|
|
140
|
+
elements: BoxAndWhiskerData[];
|
|
29
141
|
};
|
|
30
|
-
|
|
31
|
-
|
|
142
|
+
/**
|
|
143
|
+
* Represents a composite chart with metadata.
|
|
144
|
+
*/
|
|
145
|
+
export type CompositeChart = Chart & {
|
|
146
|
+
/** The type of chart */
|
|
147
|
+
type: ChartType.COMPOSITE_CHART;
|
|
148
|
+
/** The charts of the composite chart */
|
|
149
|
+
elements: Chart[];
|
|
32
150
|
};
|
|
33
|
-
export
|
|
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;
|
|
151
|
+
export declare function parseChart(data: any): Chart;
|
package/src/types/Charts.js
CHANGED
|
@@ -6,6 +6,9 @@
|
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.ChartType = void 0;
|
|
8
8
|
exports.parseChart = parseChart;
|
|
9
|
+
/**
|
|
10
|
+
* Chart types
|
|
11
|
+
*/
|
|
9
12
|
var ChartType;
|
|
10
13
|
(function (ChartType) {
|
|
11
14
|
ChartType["LINE"] = "line";
|
|
@@ -16,22 +19,28 @@ var ChartType;
|
|
|
16
19
|
ChartType["COMPOSITE_CHART"] = "composite_chart";
|
|
17
20
|
ChartType["UNKNOWN"] = "unknown";
|
|
18
21
|
})(ChartType || (exports.ChartType = ChartType = {}));
|
|
19
|
-
function parseChart(
|
|
20
|
-
switch (
|
|
22
|
+
function parseChart(data) {
|
|
23
|
+
switch (data.type) {
|
|
21
24
|
case ChartType.LINE:
|
|
22
|
-
return
|
|
25
|
+
return { ...data };
|
|
23
26
|
case ChartType.SCATTER:
|
|
24
|
-
return
|
|
27
|
+
return { ...data };
|
|
25
28
|
case ChartType.BAR:
|
|
26
|
-
return
|
|
29
|
+
return { ...data };
|
|
27
30
|
case ChartType.PIE:
|
|
28
|
-
return
|
|
31
|
+
return { ...data };
|
|
29
32
|
case ChartType.BOX_AND_WHISKER:
|
|
30
|
-
return
|
|
33
|
+
return { ...data };
|
|
31
34
|
case ChartType.COMPOSITE_CHART:
|
|
32
|
-
|
|
35
|
+
// eslint-disable-next-line no-case-declarations
|
|
36
|
+
const charts = data.elements.map((g) => parseChart(g));
|
|
37
|
+
delete data.data;
|
|
38
|
+
return {
|
|
39
|
+
...data,
|
|
40
|
+
data: charts,
|
|
41
|
+
};
|
|
33
42
|
default:
|
|
34
|
-
return
|
|
43
|
+
return { ...data, type: ChartType.UNKNOWN };
|
|
35
44
|
}
|
|
36
45
|
}
|
|
37
46
|
//# sourceMappingURL=Charts.js.map
|
package/src/types/Charts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Charts.js","sourceRoot":"","sources":["../../../../../libs/sdk-typescript/src/types/Charts.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;
|
|
1
|
+
{"version":3,"file":"Charts.js","sourceRoot":"","sources":["../../../../../libs/sdk-typescript/src/types/Charts.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAsKH,gCAuBC;AA3LD;;GAEG;AACH,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;AAyJD,SAAgB,UAAU,CAAC,IAAS;IAClC,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;QAClB,KAAK,SAAS,CAAC,IAAI;YACjB,OAAO,EAAE,GAAG,IAAI,EAAe,CAAA;QACjC,KAAK,SAAS,CAAC,OAAO;YACpB,OAAO,EAAE,GAAG,IAAI,EAAkB,CAAA;QACpC,KAAK,SAAS,CAAC,GAAG;YAChB,OAAO,EAAE,GAAG,IAAI,EAAc,CAAA;QAChC,KAAK,SAAS,CAAC,GAAG;YAChB,OAAO,EAAE,GAAG,IAAI,EAAc,CAAA;QAChC,KAAK,SAAS,CAAC,eAAe;YAC5B,OAAO,EAAE,GAAG,IAAI,EAAwB,CAAA;QAC1C,KAAK,SAAS,CAAC,eAAe;YAC5B,gDAAgD;YAChD,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAA;YAC3D,OAAO,IAAI,CAAC,IAAI,CAAA;YAChB,OAAO;gBACL,GAAG,IAAI;gBACP,IAAI,EAAE,MAAM;aACK,CAAA;QACrB;YACE,OAAO,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,SAAS,CAAC,OAAO,EAAW,CAAA;IACxD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ExecutionArtifacts } from '../types/ExecuteResponse';
|
|
2
|
+
/**
|
|
3
|
+
* Utility class for parsing artifacts from command output
|
|
4
|
+
*/
|
|
5
|
+
export declare class ArtifactParser {
|
|
6
|
+
/**
|
|
7
|
+
* Parses artifacts from command output text
|
|
8
|
+
*
|
|
9
|
+
* @param output - Raw output from command execution
|
|
10
|
+
* @returns Parsed artifacts including stdout and charts
|
|
11
|
+
*/
|
|
12
|
+
static parseArtifacts(output: string): ExecutionArtifacts;
|
|
13
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
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.ArtifactParser = void 0;
|
|
8
|
+
const Charts_1 = require("../types/Charts");
|
|
9
|
+
/**
|
|
10
|
+
* Utility class for parsing artifacts from command output
|
|
11
|
+
*/
|
|
12
|
+
class ArtifactParser {
|
|
13
|
+
/**
|
|
14
|
+
* Parses artifacts from command output text
|
|
15
|
+
*
|
|
16
|
+
* @param output - Raw output from command execution
|
|
17
|
+
* @returns Parsed artifacts including stdout and charts
|
|
18
|
+
*/
|
|
19
|
+
static parseArtifacts(output) {
|
|
20
|
+
const charts = [];
|
|
21
|
+
let stdout = output;
|
|
22
|
+
// Split output by lines to find artifact markers
|
|
23
|
+
const lines = output.split('\n');
|
|
24
|
+
const artifactLines = [];
|
|
25
|
+
for (const line of lines) {
|
|
26
|
+
// Look for the artifact marker pattern
|
|
27
|
+
if (line.startsWith('dtn_artifact_k39fd2:')) {
|
|
28
|
+
artifactLines.push(line);
|
|
29
|
+
try {
|
|
30
|
+
const artifactJson = line.substring('dtn_artifact_k39fd2:'.length).trim();
|
|
31
|
+
const artifactData = JSON.parse(artifactJson);
|
|
32
|
+
if (artifactData.type === 'chart' && artifactData.value) {
|
|
33
|
+
const chartData = artifactData.value;
|
|
34
|
+
charts.push((0, Charts_1.parseChart)(chartData));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
// Skip invalid artifacts
|
|
39
|
+
console.warn('Failed to parse artifact:', error);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
// Remove artifact lines from stdout along with their following newlines
|
|
44
|
+
for (const line of artifactLines) {
|
|
45
|
+
stdout = stdout.replace(line + '\n', '');
|
|
46
|
+
stdout = stdout.replace(line, '');
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
stdout,
|
|
50
|
+
charts: charts.length > 0 ? charts : undefined,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.ArtifactParser = ArtifactParser;
|
|
55
|
+
//# sourceMappingURL=ArtifactParser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ArtifactParser.js","sourceRoot":"","sources":["../../../../../libs/sdk-typescript/src/utils/ArtifactParser.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,4CAAmD;AAGnD;;GAEG;AACH,MAAa,cAAc;IACzB;;;;;OAKG;IACI,MAAM,CAAC,cAAc,CAAC,MAAc;QACzC,MAAM,MAAM,GAAY,EAAE,CAAA;QAC1B,IAAI,MAAM,GAAG,MAAM,CAAA;QAEnB,iDAAiD;QACjD,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QAChC,MAAM,aAAa,GAAa,EAAE,CAAA;QAElC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,uCAAuC;YACvC,IAAI,IAAI,CAAC,UAAU,CAAC,sBAAsB,CAAC,EAAE,CAAC;gBAC5C,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;gBAExB,IAAI,CAAC;oBACH,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,CAAC,sBAAsB,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAA;oBACzE,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAA;oBAE7C,IAAI,YAAY,CAAC,IAAI,KAAK,OAAO,IAAI,YAAY,CAAC,KAAK,EAAE,CAAC;wBACxD,MAAM,SAAS,GAAG,YAAY,CAAC,KAAK,CAAA;wBACpC,MAAM,CAAC,IAAI,CAAC,IAAA,mBAAU,EAAC,SAAS,CAAC,CAAC,CAAA;oBACpC,CAAC;gBACH,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,yBAAyB;oBACzB,OAAO,CAAC,IAA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