@daytonaio/sdk 0.170.0 → 0.171.0-alpha.3

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.
Files changed (237) hide show
  1. package/LICENSE +190 -0
  2. package/cjs/CodeInterpreter.d.ts +95 -0
  3. package/cjs/CodeInterpreter.d.ts.map +1 -0
  4. package/cjs/CodeInterpreter.js +297 -0
  5. package/cjs/CodeInterpreter.js.map +1 -0
  6. package/cjs/ComputerUse.d.ts +539 -0
  7. package/cjs/ComputerUse.d.ts.map +1 -0
  8. package/cjs/ComputerUse.js +808 -0
  9. package/cjs/ComputerUse.js.map +1 -0
  10. package/cjs/Daytona.d.ts +355 -0
  11. package/cjs/Daytona.d.ts.map +1 -0
  12. package/cjs/Daytona.js +527 -0
  13. package/cjs/Daytona.js.map +1 -0
  14. package/cjs/FileSystem.d.ts +371 -0
  15. package/cjs/FileSystem.d.ts.map +1 -0
  16. package/cjs/FileSystem.js +489 -0
  17. package/cjs/FileSystem.js.map +1 -0
  18. package/cjs/Git.d.ts +203 -0
  19. package/cjs/Git.d.ts.map +1 -0
  20. package/cjs/Git.js +326 -0
  21. package/cjs/Git.js.map +1 -0
  22. package/cjs/Image.d.ts +265 -0
  23. package/cjs/Image.d.ts.map +1 -0
  24. package/cjs/Image.js +586 -0
  25. package/cjs/Image.js.map +1 -0
  26. package/cjs/LspServer.d.ts +172 -0
  27. package/cjs/LspServer.d.ts.map +1 -0
  28. package/cjs/LspServer.js +259 -0
  29. package/cjs/LspServer.js.map +1 -0
  30. package/cjs/ObjectStorage.d.ts +79 -0
  31. package/cjs/ObjectStorage.d.ts.map +1 -0
  32. package/cjs/ObjectStorage.js +199 -0
  33. package/cjs/ObjectStorage.js.map +1 -0
  34. package/cjs/Process.d.ts +490 -0
  35. package/cjs/Process.d.ts.map +1 -0
  36. package/cjs/Process.js +647 -0
  37. package/cjs/Process.js.map +1 -0
  38. package/cjs/PtyHandle.d.ts +155 -0
  39. package/cjs/PtyHandle.d.ts.map +1 -0
  40. package/cjs/PtyHandle.js +416 -0
  41. package/cjs/PtyHandle.js.map +1 -0
  42. package/cjs/README.md +180 -0
  43. package/cjs/Sandbox.d.ts +476 -0
  44. package/cjs/Sandbox.d.ts.map +1 -0
  45. package/cjs/Sandbox.js +905 -0
  46. package/cjs/Sandbox.js.map +1 -0
  47. package/cjs/Snapshot.d.ts +140 -0
  48. package/cjs/Snapshot.d.ts.map +1 -0
  49. package/cjs/Snapshot.js +248 -0
  50. package/cjs/Snapshot.js.map +1 -0
  51. package/cjs/Volume.d.ts +84 -0
  52. package/cjs/Volume.d.ts.map +1 -0
  53. package/cjs/Volume.js +119 -0
  54. package/cjs/Volume.js.map +1 -0
  55. package/cjs/__tests__/helpers.d.ts +6 -0
  56. package/cjs/__tests__/helpers.d.ts.map +1 -0
  57. package/cjs/__tests__/helpers.js +26 -0
  58. package/cjs/__tests__/helpers.js.map +1 -0
  59. package/cjs/errors/DaytonaError.d.ts +171 -0
  60. package/cjs/errors/DaytonaError.d.ts.map +1 -0
  61. package/cjs/errors/DaytonaError.js +258 -0
  62. package/cjs/errors/DaytonaError.js.map +1 -0
  63. package/cjs/index.d.ts +22 -0
  64. package/cjs/index.d.ts.map +1 -0
  65. package/cjs/index.js +49 -0
  66. package/cjs/index.js.map +1 -0
  67. package/cjs/package.json +3 -0
  68. package/cjs/types/Charts.d.ts +38 -0
  69. package/cjs/types/Charts.d.ts.map +1 -0
  70. package/cjs/types/Charts.js +37 -0
  71. package/cjs/types/Charts.js.map +1 -0
  72. package/cjs/types/CodeInterpreter.d.ts +77 -0
  73. package/cjs/types/CodeInterpreter.d.ts.map +1 -0
  74. package/cjs/types/CodeInterpreter.js +7 -0
  75. package/cjs/types/CodeInterpreter.js.map +1 -0
  76. package/cjs/types/ExecuteResponse.d.ts +26 -0
  77. package/cjs/types/ExecuteResponse.d.ts.map +1 -0
  78. package/cjs/types/ExecuteResponse.js +7 -0
  79. package/cjs/types/ExecuteResponse.js.map +1 -0
  80. package/cjs/types/Pty.d.ts +48 -0
  81. package/cjs/types/Pty.d.ts.map +1 -0
  82. package/cjs/types/Pty.js +7 -0
  83. package/cjs/types/Pty.js.map +1 -0
  84. package/cjs/utils/Binary.d.ts +39 -0
  85. package/cjs/utils/Binary.d.ts.map +1 -0
  86. package/cjs/utils/Binary.js +168 -0
  87. package/cjs/utils/Binary.js.map +1 -0
  88. package/cjs/utils/FileTransfer.d.ts +15 -0
  89. package/cjs/utils/FileTransfer.d.ts.map +1 -0
  90. package/cjs/utils/FileTransfer.js +261 -0
  91. package/cjs/utils/FileTransfer.js.map +1 -0
  92. package/cjs/utils/Import.d.ts +125 -0
  93. package/cjs/utils/Import.d.ts.map +1 -0
  94. package/cjs/utils/Import.js +112 -0
  95. package/cjs/utils/Import.js.map +1 -0
  96. package/cjs/utils/Multipart.d.ts +29 -0
  97. package/cjs/utils/Multipart.d.ts.map +1 -0
  98. package/cjs/utils/Multipart.js +115 -0
  99. package/cjs/utils/Multipart.js.map +1 -0
  100. package/cjs/utils/Runtime.d.ts +44 -0
  101. package/cjs/utils/Runtime.d.ts.map +1 -0
  102. package/cjs/utils/Runtime.js +95 -0
  103. package/cjs/utils/Runtime.js.map +1 -0
  104. package/cjs/utils/Stream.d.ts +20 -0
  105. package/cjs/utils/Stream.d.ts.map +1 -0
  106. package/cjs/utils/Stream.js +364 -0
  107. package/cjs/utils/Stream.js.map +1 -0
  108. package/cjs/utils/WebSocket.d.ts +10 -0
  109. package/cjs/utils/WebSocket.d.ts.map +1 -0
  110. package/cjs/utils/WebSocket.js +26 -0
  111. package/cjs/utils/WebSocket.js.map +1 -0
  112. package/cjs/utils/otel.decorator.d.ts +83 -0
  113. package/cjs/utils/otel.decorator.d.ts.map +1 -0
  114. package/cjs/utils/otel.decorator.js +141 -0
  115. package/cjs/utils/otel.decorator.js.map +1 -0
  116. package/esm/CodeInterpreter.d.ts +95 -0
  117. package/esm/CodeInterpreter.d.ts.map +1 -0
  118. package/esm/CodeInterpreter.js +292 -0
  119. package/esm/CodeInterpreter.js.map +1 -0
  120. package/esm/ComputerUse.d.ts +539 -0
  121. package/esm/ComputerUse.d.ts.map +1 -0
  122. package/esm/ComputerUse.js +799 -0
  123. package/esm/ComputerUse.js.map +1 -0
  124. package/esm/Daytona.d.ts +355 -0
  125. package/esm/Daytona.d.ts.map +1 -0
  126. package/esm/Daytona.js +523 -0
  127. package/esm/Daytona.js.map +1 -0
  128. package/esm/FileSystem.d.ts +371 -0
  129. package/esm/FileSystem.d.ts.map +1 -0
  130. package/esm/FileSystem.js +485 -0
  131. package/esm/FileSystem.js.map +1 -0
  132. package/esm/Git.d.ts +203 -0
  133. package/esm/Git.d.ts.map +1 -0
  134. package/esm/Git.js +322 -0
  135. package/esm/Git.js.map +1 -0
  136. package/esm/Image.d.ts +265 -0
  137. package/esm/Image.d.ts.map +1 -0
  138. package/esm/Image.js +581 -0
  139. package/esm/Image.js.map +1 -0
  140. package/esm/LspServer.d.ts +172 -0
  141. package/esm/LspServer.d.ts.map +1 -0
  142. package/esm/LspServer.js +255 -0
  143. package/esm/LspServer.js.map +1 -0
  144. package/esm/ObjectStorage.d.ts +79 -0
  145. package/esm/ObjectStorage.d.ts.map +1 -0
  146. package/esm/ObjectStorage.js +195 -0
  147. package/esm/ObjectStorage.js.map +1 -0
  148. package/esm/Process.d.ts +490 -0
  149. package/esm/Process.d.ts.map +1 -0
  150. package/esm/Process.js +642 -0
  151. package/esm/Process.js.map +1 -0
  152. package/esm/PtyHandle.d.ts +155 -0
  153. package/esm/PtyHandle.d.ts.map +1 -0
  154. package/esm/PtyHandle.js +412 -0
  155. package/esm/PtyHandle.js.map +1 -0
  156. package/esm/README.md +180 -0
  157. package/esm/Sandbox.d.ts +476 -0
  158. package/esm/Sandbox.d.ts.map +1 -0
  159. package/esm/Sandbox.js +901 -0
  160. package/esm/Sandbox.js.map +1 -0
  161. package/esm/Snapshot.d.ts +140 -0
  162. package/esm/Snapshot.d.ts.map +1 -0
  163. package/esm/Snapshot.js +244 -0
  164. package/esm/Snapshot.js.map +1 -0
  165. package/esm/Volume.d.ts +84 -0
  166. package/esm/Volume.d.ts.map +1 -0
  167. package/esm/Volume.js +115 -0
  168. package/esm/Volume.js.map +1 -0
  169. package/esm/__tests__/helpers.d.ts +6 -0
  170. package/esm/__tests__/helpers.d.ts.map +1 -0
  171. package/esm/__tests__/helpers.js +20 -0
  172. package/esm/__tests__/helpers.js.map +1 -0
  173. package/esm/errors/DaytonaError.d.ts +171 -0
  174. package/esm/errors/DaytonaError.d.ts.map +1 -0
  175. package/esm/errors/DaytonaError.js +243 -0
  176. package/esm/errors/DaytonaError.js.map +1 -0
  177. package/esm/index.d.ts +22 -0
  178. package/esm/index.d.ts.map +1 -0
  179. package/esm/index.js +21 -0
  180. package/esm/index.js.map +1 -0
  181. package/esm/package.json +3 -0
  182. package/esm/types/Charts.d.ts +38 -0
  183. package/esm/types/Charts.d.ts.map +1 -0
  184. package/esm/types/Charts.js +33 -0
  185. package/esm/types/Charts.js.map +1 -0
  186. package/esm/types/CodeInterpreter.d.ts +77 -0
  187. package/esm/types/CodeInterpreter.d.ts.map +1 -0
  188. package/esm/types/CodeInterpreter.js +6 -0
  189. package/esm/types/CodeInterpreter.js.map +1 -0
  190. package/esm/types/ExecuteResponse.d.ts +26 -0
  191. package/esm/types/ExecuteResponse.d.ts.map +1 -0
  192. package/esm/types/ExecuteResponse.js +6 -0
  193. package/esm/types/ExecuteResponse.js.map +1 -0
  194. package/esm/types/Pty.d.ts +48 -0
  195. package/esm/types/Pty.d.ts.map +1 -0
  196. package/esm/types/Pty.js +6 -0
  197. package/esm/types/Pty.js.map +1 -0
  198. package/esm/utils/Binary.d.ts +39 -0
  199. package/esm/utils/Binary.d.ts.map +1 -0
  200. package/esm/utils/Binary.js +157 -0
  201. package/esm/utils/Binary.js.map +1 -0
  202. package/esm/utils/FileTransfer.d.ts +15 -0
  203. package/esm/utils/FileTransfer.d.ts.map +1 -0
  204. package/esm/utils/FileTransfer.js +254 -0
  205. package/esm/utils/FileTransfer.js.map +1 -0
  206. package/esm/utils/Import.d.ts +95 -0
  207. package/esm/utils/Import.d.ts.map +1 -0
  208. package/esm/utils/Import.js +77 -0
  209. package/esm/utils/Import.js.map +1 -0
  210. package/esm/utils/Multipart.d.ts +29 -0
  211. package/esm/utils/Multipart.d.ts.map +1 -0
  212. package/esm/utils/Multipart.js +109 -0
  213. package/esm/utils/Multipart.js.map +1 -0
  214. package/esm/utils/Runtime.d.ts +44 -0
  215. package/esm/utils/Runtime.d.ts.map +1 -0
  216. package/esm/utils/Runtime.js +89 -0
  217. package/esm/utils/Runtime.js.map +1 -0
  218. package/esm/utils/Stream.d.ts +20 -0
  219. package/esm/utils/Stream.d.ts.map +1 -0
  220. package/esm/utils/Stream.js +360 -0
  221. package/esm/utils/Stream.js.map +1 -0
  222. package/esm/utils/WebSocket.d.ts +10 -0
  223. package/esm/utils/WebSocket.d.ts.map +1 -0
  224. package/esm/utils/WebSocket.js +22 -0
  225. package/esm/utils/WebSocket.js.map +1 -0
  226. package/esm/utils/otel.decorator.d.ts +83 -0
  227. package/esm/utils/otel.decorator.d.ts.map +1 -0
  228. package/esm/utils/otel.decorator.js +136 -0
  229. package/esm/utils/otel.decorator.js.map +1 -0
  230. package/package.json +20 -8
  231. package/src/ComputerUse.d.ts +4 -4
  232. package/src/ComputerUse.js +4 -4
  233. package/src/Sandbox.d.ts +1 -18
  234. package/src/Sandbox.js +0 -29
  235. package/src/Sandbox.js.map +1 -1
  236. package/src/__tests__/helpers.js +0 -2
  237. package/src/__tests__/helpers.js.map +1 -1
package/cjs/Daytona.js ADDED
@@ -0,0 +1,527 @@
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.Daytona = exports.CodeLanguage = exports.CODE_TOOLBOX_LANGUAGE_LABEL = void 0;
8
+ const tslib_1 = require("tslib");
9
+ const api_client_1 = require("@daytona/api-client");
10
+ const axios_1 = tslib_1.__importStar(require("axios"));
11
+ const DaytonaError_1 = require("./errors/DaytonaError");
12
+ const Image_1 = require("./Image");
13
+ const Sandbox_1 = require("./Sandbox");
14
+ const Snapshot_1 = require("./Snapshot");
15
+ const Volume_1 = require("./Volume");
16
+ const packageJson = tslib_1.__importStar(require("../package.json"));
17
+ const Stream_1 = require("./utils/Stream");
18
+ const Runtime_1 = require("./utils/Runtime");
19
+ const otel_decorator_1 = require("./utils/otel.decorator");
20
+ const api_1 = require("@opentelemetry/api");
21
+ const sdk_node_1 = require("@opentelemetry/sdk-node");
22
+ const instrumentation_http_1 = require("@opentelemetry/instrumentation-http");
23
+ const sdk_trace_base_1 = require("@opentelemetry/sdk-trace-base");
24
+ const exporter_trace_otlp_http_1 = require("@opentelemetry/exporter-trace-otlp-http");
25
+ const otlp_exporter_base_1 = require("@opentelemetry/otlp-exporter-base");
26
+ const semantic_conventions_1 = require("@opentelemetry/semantic-conventions");
27
+ const resources_1 = require("@opentelemetry/resources");
28
+ const api_2 = require("@opentelemetry/api");
29
+ exports.CODE_TOOLBOX_LANGUAGE_LABEL = 'code-toolbox-language';
30
+ /**
31
+ * Supported programming languages for code execution
32
+ *
33
+ * Python is used as the default sandbox language when no language is explicitly specified.
34
+ */
35
+ var CodeLanguage;
36
+ (function (CodeLanguage) {
37
+ CodeLanguage["PYTHON"] = "python";
38
+ CodeLanguage["TYPESCRIPT"] = "typescript";
39
+ CodeLanguage["JAVASCRIPT"] = "javascript";
40
+ })(CodeLanguage || (exports.CodeLanguage = CodeLanguage = {}));
41
+ /**
42
+ * Main class for interacting with the Daytona API.
43
+ * Provides methods for creating, managing, and interacting with Daytona Sandboxes.
44
+ * Can be initialized either with explicit configuration or using environment variables.
45
+ *
46
+ * @property {VolumeService} volume - Service for managing Daytona Volumes
47
+ * @property {SnapshotService} snapshot - Service for managing Daytona Snapshots
48
+ *
49
+ * @example
50
+ * // Using environment variables
51
+ * // Uses DAYTONA_API_KEY, DAYTONA_API_URL, DAYTONA_TARGET
52
+ * const daytona = new Daytona();
53
+ * const sandbox = await daytona.create();
54
+ *
55
+ * @example
56
+ * // Using explicit configuration
57
+ * const config: DaytonaConfig = {
58
+ * apiKey: "your-api-key",
59
+ * apiUrl: "https://your-api.com",
60
+ * target: "us"
61
+ * };
62
+ * const daytona = new Daytona(config);
63
+ *
64
+ * @example
65
+ * // Disposes daytona and flushes traces when done
66
+ * await using daytona = new Daytona({
67
+ * otelEnabled: true,
68
+ * });
69
+ * @class
70
+ */
71
+ class Daytona {
72
+ clientConfig;
73
+ sandboxApi;
74
+ objectStorageApi;
75
+ configApi;
76
+ target;
77
+ apiKey;
78
+ jwtToken;
79
+ organizationId;
80
+ apiUrl;
81
+ otelSdk;
82
+ volume;
83
+ snapshot;
84
+ /**
85
+ * Creates a new Daytona client instance.
86
+ *
87
+ * @param {DaytonaConfig} [config] - Configuration options
88
+ * @throws {DaytonaAuthenticationError} When no credentials are provided (neither API key nor JWT token)
89
+ * @throws {DaytonaAuthenticationError} When JWT token is provided without an organization ID
90
+ */
91
+ constructor(config) {
92
+ let apiUrl;
93
+ if (config) {
94
+ this.apiKey = !config?.apiKey && config?.jwtToken ? undefined : config?.apiKey;
95
+ this.jwtToken = config?.jwtToken;
96
+ this.organizationId = config?.organizationId;
97
+ apiUrl = config?.apiUrl || config?.serverUrl;
98
+ this.target = config?.target;
99
+ }
100
+ let _envReader;
101
+ const envReader = () => {
102
+ if (_envReader === undefined) {
103
+ _envReader = Runtime_1.RUNTIME !== Runtime_1.Runtime.BROWSER ? new Runtime_1.DaytonaEnvReader() : null;
104
+ }
105
+ return _envReader;
106
+ };
107
+ if (!config ||
108
+ (!(this.apiKey && apiUrl && this.target) && !(this.jwtToken && this.organizationId && apiUrl && this.target))) {
109
+ const reader = envReader();
110
+ if (reader) {
111
+ this.apiKey = this.apiKey || (this.jwtToken ? undefined : reader.get('DAYTONA_API_KEY'));
112
+ this.jwtToken = this.jwtToken || reader.get('DAYTONA_JWT_TOKEN');
113
+ this.organizationId = this.organizationId || reader.get('DAYTONA_ORGANIZATION_ID');
114
+ apiUrl = apiUrl || reader.get('DAYTONA_API_URL') || reader.get('DAYTONA_SERVER_URL');
115
+ this.target = this.target || reader.get('DAYTONA_TARGET');
116
+ if (reader.get('DAYTONA_SERVER_URL') && !reader.get('DAYTONA_API_URL')) {
117
+ console.warn('[Deprecation Warning] Environment variable `DAYTONA_SERVER_URL` is deprecated and will be removed in future versions. Use `DAYTONA_API_URL` instead.');
118
+ }
119
+ }
120
+ }
121
+ this.apiUrl = apiUrl || 'https://app.daytona.io/api';
122
+ if (!this.apiKey && !this.jwtToken) {
123
+ throw new DaytonaError_1.DaytonaAuthenticationError('Authentication credentials not found. Set DAYTONA_API_KEY, or both DAYTONA_JWT_TOKEN and DAYTONA_ORGANIZATION_ID.' +
124
+ ' These can also be provided via DaytonaConfig.');
125
+ }
126
+ const orgHeader = {};
127
+ if (!this.apiKey) {
128
+ if (!this.organizationId) {
129
+ throw new DaytonaError_1.DaytonaAuthenticationError('DAYTONA_ORGANIZATION_ID is required when authenticating with DAYTONA_JWT_TOKEN.' +
130
+ ' It can also be provided via DaytonaConfig.');
131
+ }
132
+ orgHeader['X-Daytona-Organization-ID'] = this.organizationId;
133
+ }
134
+ const isLegacyPackage = packageJson.name === '@daytonaio/sdk';
135
+ const sdkLabel = isLegacyPackage ? 'sdk-typescript-legacy' : 'sdk-typescript';
136
+ const configuration = new api_client_1.Configuration({
137
+ basePath: this.apiUrl,
138
+ baseOptions: {
139
+ headers: {
140
+ Authorization: `Bearer ${this.apiKey || this.jwtToken}`,
141
+ 'X-Daytona-Source': sdkLabel,
142
+ 'X-Daytona-SDK-Version': packageJson.version,
143
+ 'User-Agent': `${sdkLabel}/${packageJson.version}`,
144
+ ...orgHeader,
145
+ },
146
+ },
147
+ });
148
+ const axiosInstance = Daytona.createAxiosInstance();
149
+ this.sandboxApi = new api_client_1.SandboxApi(configuration, '', axiosInstance);
150
+ this.objectStorageApi = new api_client_1.ObjectStorageApi(configuration, '', axiosInstance);
151
+ this.configApi = new api_client_1.ConfigApi(configuration, '', axiosInstance);
152
+ this.volume = new Volume_1.VolumeService(new api_client_1.VolumesApi(configuration, '', axiosInstance));
153
+ this.snapshot = new Snapshot_1.SnapshotService(configuration, new api_client_1.SnapshotsApi(configuration, '', axiosInstance), this.objectStorageApi, this.target);
154
+ this.clientConfig = configuration;
155
+ if (!config?._experimental?.otelEnabled && envReader()?.get('DAYTONA_EXPERIMENTAL_OTEL_ENABLED') !== 'true') {
156
+ return;
157
+ }
158
+ api_2.diag.setLogger(new api_2.DiagConsoleLogger(), api_2.DiagLogLevel.INFO);
159
+ this.otelSdk = new sdk_node_1.NodeSDK({
160
+ resource: (0, resources_1.resourceFromAttributes)({
161
+ [semantic_conventions_1.ATTR_SERVICE_VERSION]: packageJson.version,
162
+ [semantic_conventions_1.ATTR_SERVICE_NAME]: 'daytona-typescript-sdk',
163
+ }),
164
+ instrumentations: [
165
+ new instrumentation_http_1.HttpInstrumentation({
166
+ requireParentforOutgoingSpans: false,
167
+ }),
168
+ ],
169
+ spanProcessors: [
170
+ new sdk_trace_base_1.BatchSpanProcessor(new exporter_trace_otlp_http_1.OTLPTraceExporter({
171
+ compression: otlp_exporter_base_1.CompressionAlgorithm.GZIP,
172
+ })),
173
+ ],
174
+ });
175
+ this.otelSdk.start();
176
+ // Flush and shutdown OTEL on process exit
177
+ process.on('SIGTERM', async () => {
178
+ await this.otelSdk?.shutdown();
179
+ });
180
+ }
181
+ async [Symbol.asyncDispose]() {
182
+ if (!this.otelSdk) {
183
+ return;
184
+ }
185
+ await this.otelSdk.shutdown();
186
+ }
187
+ async create(params, options = { timeout: 60 }) {
188
+ const startTime = Date.now();
189
+ options = typeof options === 'number' ? { timeout: options } : { ...options };
190
+ if (options.timeout == undefined || options.timeout == null) {
191
+ options.timeout = 60;
192
+ }
193
+ if (params == null) {
194
+ params = { language: 'python' };
195
+ }
196
+ if (!params.language) {
197
+ params.language = 'python';
198
+ }
199
+ const labels = params.labels || {};
200
+ if (params.language) {
201
+ const validLanguages = Object.values(CodeLanguage);
202
+ if (!validLanguages.includes(params.language)) {
203
+ throw new DaytonaError_1.DaytonaValidationError(`Invalid ${exports.CODE_TOOLBOX_LANGUAGE_LABEL}: ${params.language}. Supported languages: ${validLanguages.join(', ')}`);
204
+ }
205
+ labels[exports.CODE_TOOLBOX_LANGUAGE_LABEL] = params.language;
206
+ }
207
+ if (options.timeout < 0) {
208
+ throw new DaytonaError_1.DaytonaValidationError('Timeout must be a non-negative number');
209
+ }
210
+ if (params.autoStopInterval !== undefined &&
211
+ (!Number.isInteger(params.autoStopInterval) || params.autoStopInterval < 0)) {
212
+ throw new DaytonaError_1.DaytonaValidationError('autoStopInterval must be a non-negative integer');
213
+ }
214
+ if (params.ephemeral) {
215
+ if (params.autoDeleteInterval !== undefined && params.autoDeleteInterval !== 0) {
216
+ console.warn("'ephemeral' and 'autoDeleteInterval' cannot be used together. If ephemeral is true, autoDeleteInterval will be ignored and set to 0.");
217
+ }
218
+ params.autoDeleteInterval = 0;
219
+ }
220
+ if (params.autoArchiveInterval !== undefined &&
221
+ (!Number.isInteger(params.autoArchiveInterval) || params.autoArchiveInterval < 0)) {
222
+ throw new DaytonaError_1.DaytonaValidationError('autoArchiveInterval must be a non-negative integer');
223
+ }
224
+ try {
225
+ let buildInfo;
226
+ let snapshot;
227
+ let resources;
228
+ if ('snapshot' in params) {
229
+ snapshot = params.snapshot;
230
+ }
231
+ if ('image' in params) {
232
+ if (typeof params.image === 'string') {
233
+ buildInfo = {
234
+ dockerfileContent: Image_1.Image.base(params.image).dockerfile,
235
+ };
236
+ }
237
+ else if (params.image instanceof Image_1.Image) {
238
+ const contextHashes = await Snapshot_1.SnapshotService.processImageContext(this.objectStorageApi, params.image);
239
+ buildInfo = {
240
+ contextHashes,
241
+ dockerfileContent: params.image.dockerfile,
242
+ };
243
+ }
244
+ }
245
+ if ('resources' in params) {
246
+ resources = params.resources;
247
+ }
248
+ const response = await this.sandboxApi.createSandbox({
249
+ name: params.name,
250
+ snapshot: snapshot,
251
+ buildInfo,
252
+ user: params.user,
253
+ env: params.envVars || {},
254
+ labels: labels,
255
+ public: params.public,
256
+ target: this.target,
257
+ cpu: resources?.cpu,
258
+ gpu: resources?.gpu,
259
+ memory: resources?.memory,
260
+ disk: resources?.disk,
261
+ autoStopInterval: params.autoStopInterval,
262
+ autoArchiveInterval: params.autoArchiveInterval,
263
+ autoDeleteInterval: params.autoDeleteInterval,
264
+ volumes: params.volumes,
265
+ networkBlockAll: params.networkBlockAll,
266
+ networkAllowList: params.networkAllowList,
267
+ }, undefined, {
268
+ timeout: options.timeout * 1000,
269
+ });
270
+ let sandboxInstance = response.data;
271
+ if (sandboxInstance.state === api_client_1.SandboxState.PENDING_BUILD && options.onSnapshotCreateLogs) {
272
+ const terminalStates = [
273
+ api_client_1.SandboxState.STARTED,
274
+ api_client_1.SandboxState.STARTING,
275
+ api_client_1.SandboxState.ERROR,
276
+ api_client_1.SandboxState.BUILD_FAILED,
277
+ ];
278
+ while (sandboxInstance.state === api_client_1.SandboxState.PENDING_BUILD) {
279
+ if (options.timeout) {
280
+ const elapsed = (Date.now() - startTime) / 1000;
281
+ if (elapsed > options.timeout) {
282
+ throw new DaytonaError_1.DaytonaTimeoutError(`Sandbox build has been pending for more than ${options.timeout} seconds. Please check the sandbox state again later.`);
283
+ }
284
+ }
285
+ await new Promise((resolve) => setTimeout(resolve, 1000));
286
+ sandboxInstance = (await this.sandboxApi.getSandbox(sandboxInstance.id)).data;
287
+ }
288
+ const response = await this.sandboxApi.getBuildLogsUrl(sandboxInstance.id);
289
+ await (0, Stream_1.processStreamingResponse)(() => fetch(response.data.url + '?follow=true', {
290
+ method: 'GET',
291
+ headers: this.clientConfig.baseOptions.headers,
292
+ }), (chunk) => options.onSnapshotCreateLogs?.(chunk.trimEnd()), async () => {
293
+ sandboxInstance = (await this.sandboxApi.getSandbox(sandboxInstance.id)).data;
294
+ return sandboxInstance.state !== undefined && terminalStates.includes(sandboxInstance.state);
295
+ });
296
+ }
297
+ const sandbox = new Sandbox_1.Sandbox(sandboxInstance, new api_client_1.Configuration(structuredClone(this.clientConfig)), Daytona.createAxiosInstance(), this.sandboxApi);
298
+ if (sandbox.state !== 'started') {
299
+ const timeElapsed = Date.now() - startTime;
300
+ await sandbox.waitUntilStarted(options.timeout ? Math.max(0.001, options.timeout - timeElapsed / 1000) : options.timeout);
301
+ }
302
+ return sandbox;
303
+ }
304
+ catch (error) {
305
+ if (error instanceof DaytonaError_1.DaytonaTimeoutError) {
306
+ const errMsg = `Failed to create and start sandbox within ${options.timeout} seconds. Operation timed out.`;
307
+ throw new DaytonaError_1.DaytonaTimeoutError(errMsg, error.statusCode, error.headers, error.errorCode);
308
+ }
309
+ throw error;
310
+ }
311
+ }
312
+ /**
313
+ * Gets a Sandbox by its ID or name.
314
+ *
315
+ * @param {string} sandboxIdOrName - The ID or name of the Sandbox to retrieve
316
+ * @returns {Promise<Sandbox>} The Sandbox
317
+ *
318
+ * @example
319
+ * const sandbox = await daytona.get('my-sandbox-id-or-name');
320
+ * console.log(`Sandbox state: ${sandbox.state}`);
321
+ */
322
+ async get(sandboxIdOrName) {
323
+ const response = await this.sandboxApi.getSandbox(sandboxIdOrName);
324
+ const sandboxInstance = response.data;
325
+ return new Sandbox_1.Sandbox(sandboxInstance, structuredClone(this.clientConfig), Daytona.createAxiosInstance(), this.sandboxApi);
326
+ }
327
+ /**
328
+ * Returns paginated list of Sandboxes filtered by labels.
329
+ *
330
+ * @param {Record<string, string>} [labels] - Labels to filter Sandboxes
331
+ * @param {number} [page] - Page number for pagination (starting from 1)
332
+ * @param {number} [limit] - Maximum number of items per page
333
+ * @returns {Promise<PaginatedSandboxes>} Paginated list of Sandboxes that match the labels.
334
+ *
335
+ * @example
336
+ * const result = await daytona.list({ 'my-label': 'my-value' }, 2, 10);
337
+ * for (const sandbox of result.items) {
338
+ * console.log(`${sandbox.id}: ${sandbox.state}`);
339
+ * }
340
+ */
341
+ async list(labels, page, limit) {
342
+ const response = await this.sandboxApi.listSandboxesPaginated(undefined, page, limit, undefined, undefined, labels ? JSON.stringify(labels) : undefined);
343
+ return {
344
+ items: response.data.items.map((sandbox) => {
345
+ return new Sandbox_1.Sandbox(sandbox, structuredClone(this.clientConfig), Daytona.createAxiosInstance(), this.sandboxApi);
346
+ }),
347
+ total: response.data.total,
348
+ page: response.data.page,
349
+ totalPages: response.data.totalPages,
350
+ };
351
+ }
352
+ /**
353
+ * Starts a Sandbox and waits for it to be ready.
354
+ *
355
+ * @param {Sandbox} sandbox - The Sandbox to start
356
+ * @param {number} [timeout] - Optional timeout in seconds (0 means no timeout)
357
+ * @returns {Promise<void>}
358
+ *
359
+ * @example
360
+ * const sandbox = await daytona.get('my-sandbox-id');
361
+ * // Wait up to 60 seconds for the sandbox to start
362
+ * await daytona.start(sandbox, 60);
363
+ */
364
+ async start(sandbox, timeout) {
365
+ await sandbox.start(timeout);
366
+ }
367
+ /**
368
+ * Stops a Sandbox.
369
+ *
370
+ * @param {Sandbox} sandbox - The Sandbox to stop
371
+ * @returns {Promise<void>}
372
+ *
373
+ * @example
374
+ * const sandbox = await daytona.get('my-sandbox-id');
375
+ * await daytona.stop(sandbox);
376
+ */
377
+ async stop(sandbox) {
378
+ await sandbox.stop();
379
+ }
380
+ /**
381
+ * Forks a Sandbox, creating a new Sandbox with an identical filesystem.
382
+ *
383
+ * @param {Sandbox} sandbox - The Sandbox to fork
384
+ * @param {object} [params] - Fork parameters
385
+ * @param {string} [params.name] - Optional name for the forked Sandbox
386
+ * @param {number} [timeout] - Timeout in seconds (0 means no timeout, default is 60)
387
+ * @returns {Promise<Sandbox>} The forked Sandbox
388
+ *
389
+ * @example
390
+ * const sandbox = await daytona.get('my-sandbox-id');
391
+ * const forked = await daytona._experimental_fork(sandbox, { name: 'my-fork' });
392
+ * console.log(`Forked sandbox: ${forked.id}`);
393
+ */
394
+ async _experimental_fork(sandbox, params, timeout = 60) {
395
+ return await sandbox._experimental_fork(params, timeout);
396
+ }
397
+ /**
398
+ * Deletes a Sandbox.
399
+ *
400
+ * @param {Sandbox} sandbox - The Sandbox to delete
401
+ * @param {number} timeout - Timeout in seconds (0 means no timeout, default is 60)
402
+ * @returns {Promise<void>}
403
+ *
404
+ * @example
405
+ * const sandbox = await daytona.get('my-sandbox-id');
406
+ * await daytona.delete(sandbox);
407
+ */
408
+ async delete(sandbox, timeout = 60) {
409
+ await sandbox.delete(timeout);
410
+ }
411
+ /**
412
+ * @hidden
413
+ */
414
+ static createAxiosInstance() {
415
+ const axiosInstance = axios_1.default.create({
416
+ timeout: 24 * 60 * 60 * 1000, // 24 hours
417
+ });
418
+ // Request interceptor: Inject trace context into headers
419
+ axiosInstance.interceptors.request.use((requestConfig) => {
420
+ // Get the current active context (which may contain an active span)
421
+ const currentContext = api_1.context.active();
422
+ // Inject trace context into HTTP headers using W3C Trace Context propagation
423
+ // This adds headers like 'traceparent' and 'tracestate'
424
+ api_1.propagation.inject(currentContext, requestConfig.headers);
425
+ requestConfig.metadata = { startTime: Date.now() };
426
+ return requestConfig;
427
+ }, (error) => {
428
+ return Promise.reject(error);
429
+ });
430
+ axiosInstance.interceptors.response.use((response) => {
431
+ return response;
432
+ }, (error) => {
433
+ if (error instanceof axios_1.AxiosError) {
434
+ throw (0, DaytonaError_1.createAxiosDaytonaError)(error);
435
+ }
436
+ throw new DaytonaError_1.DaytonaError(error instanceof Error ? error.message : String(error));
437
+ });
438
+ axiosInstance.interceptors.response.use((response) => {
439
+ const startTime = response.config.metadata?.startTime;
440
+ if (startTime) {
441
+ const duration = Date.now() - startTime;
442
+ // Get the active span to add attributes
443
+ const activeSpan = api_1.trace.getActiveSpan();
444
+ // Only modify the span if it's still recording (not ended)
445
+ if (activeSpan && activeSpan.isRecording()) {
446
+ // Add response metadata to the span
447
+ activeSpan.setAttributes({
448
+ 'http.response.status_code': response.status,
449
+ 'http.response.duration_ms': duration,
450
+ // 'http.response.size_bytes': JSON.stringify(response.data).length,
451
+ });
452
+ }
453
+ }
454
+ return response;
455
+ }, (error) => {
456
+ const startTime = error.config?.metadata?.startTime;
457
+ if (startTime) {
458
+ const duration = Date.now() - startTime;
459
+ // Get the active span to record the error
460
+ const activeSpan = api_1.trace.getActiveSpan();
461
+ // Only modify the span if it's still recording (not ended)
462
+ if (activeSpan && activeSpan.isRecording()) {
463
+ activeSpan.setStatus({
464
+ code: api_1.SpanStatusCode.ERROR,
465
+ message: error.message,
466
+ });
467
+ activeSpan.setAttributes({
468
+ 'http.response.duration_ms': duration,
469
+ 'error.type': error.name,
470
+ 'error.message': error.message,
471
+ });
472
+ if (error.response) {
473
+ activeSpan.setAttribute('http.response.status_code', error.response.status);
474
+ }
475
+ // Record the exception on the span
476
+ activeSpan.recordException(error);
477
+ }
478
+ }
479
+ return Promise.reject(error);
480
+ });
481
+ return axiosInstance;
482
+ }
483
+ }
484
+ exports.Daytona = Daytona;
485
+ tslib_1.__decorate([
486
+ (0, otel_decorator_1.WithInstrumentation)(),
487
+ tslib_1.__metadata("design:type", Function),
488
+ tslib_1.__metadata("design:paramtypes", [Object, Object]),
489
+ tslib_1.__metadata("design:returntype", Promise)
490
+ ], Daytona.prototype, "create", null);
491
+ tslib_1.__decorate([
492
+ (0, otel_decorator_1.WithInstrumentation)(),
493
+ tslib_1.__metadata("design:type", Function),
494
+ tslib_1.__metadata("design:paramtypes", [String]),
495
+ tslib_1.__metadata("design:returntype", Promise)
496
+ ], Daytona.prototype, "get", null);
497
+ tslib_1.__decorate([
498
+ (0, otel_decorator_1.WithInstrumentation)(),
499
+ tslib_1.__metadata("design:type", Function),
500
+ tslib_1.__metadata("design:paramtypes", [Object, Number, Number]),
501
+ tslib_1.__metadata("design:returntype", Promise)
502
+ ], Daytona.prototype, "list", null);
503
+ tslib_1.__decorate([
504
+ (0, otel_decorator_1.WithInstrumentation)(),
505
+ tslib_1.__metadata("design:type", Function),
506
+ tslib_1.__metadata("design:paramtypes", [Sandbox_1.Sandbox, Number]),
507
+ tslib_1.__metadata("design:returntype", Promise)
508
+ ], Daytona.prototype, "start", null);
509
+ tslib_1.__decorate([
510
+ (0, otel_decorator_1.WithInstrumentation)(),
511
+ tslib_1.__metadata("design:type", Function),
512
+ tslib_1.__metadata("design:paramtypes", [Sandbox_1.Sandbox]),
513
+ tslib_1.__metadata("design:returntype", Promise)
514
+ ], Daytona.prototype, "stop", null);
515
+ tslib_1.__decorate([
516
+ (0, otel_decorator_1.WithInstrumentation)(),
517
+ tslib_1.__metadata("design:type", Function),
518
+ tslib_1.__metadata("design:paramtypes", [Sandbox_1.Sandbox, Object, Object]),
519
+ tslib_1.__metadata("design:returntype", Promise)
520
+ ], Daytona.prototype, "_experimental_fork", null);
521
+ tslib_1.__decorate([
522
+ (0, otel_decorator_1.WithInstrumentation)(),
523
+ tslib_1.__metadata("design:type", Function),
524
+ tslib_1.__metadata("design:paramtypes", [Sandbox_1.Sandbox, Object]),
525
+ tslib_1.__metadata("design:returntype", Promise)
526
+ ], Daytona.prototype, "delete", null);
527
+ //# sourceMappingURL=Daytona.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Daytona.js","sourceRoot":"","sources":["../../../../../libs/sdk-typescript/src/Daytona.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;AAEH,oDAS4B;AAC5B,uDAAoF;AACpF,wDAM8B;AAC9B,mCAA+B;AAC/B,uCAAuD;AACvD,yCAA4C;AAC5C,qCAAwC;AACxC,qEAA8C;AAC9C,2CAAyD;AACzD,6CAAoE;AACpE,2DAA4D;AAC5D,4CAAgF;AAChF,sDAAiD;AACjD,8EAAyE;AACzE,kEAAkE;AAClE,sFAA2E;AAC3E,0EAAwE;AACxE,8EAA6F;AAC7F,wDAAiE;AACjE,4CAA0E;AAE7D,QAAA,2BAA2B,GAAG,uBAAuB,CAAA;AA0DlE;;;;GAIG;AACH,IAAY,YAIX;AAJD,WAAY,YAAY;IACtB,iCAAiB,CAAA;IACjB,y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