@daytonaio/sdk 0.19.0-alpha.4 → 0.19.0-alpha.6

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 (54) hide show
  1. package/package.json +14 -31
  2. package/{dist → src}/Daytona.d.ts +4 -73
  3. package/{dist → src}/Daytona.js +65 -185
  4. package/src/Daytona.js.map +1 -0
  5. package/{dist → src}/FileSystem.js +7 -39
  6. package/src/FileSystem.js.map +1 -0
  7. package/{dist → src}/Git.js +5 -0
  8. package/src/Git.js.map +1 -0
  9. package/{dist → src}/LspServer.js +5 -0
  10. package/src/LspServer.js.map +1 -0
  11. package/{dist → src}/Process.d.ts +1 -0
  12. package/{dist → src}/Process.js +84 -6
  13. package/src/Process.js.map +1 -0
  14. package/{dist → src}/Sandbox.d.ts +1 -1
  15. package/{dist → src}/Sandbox.js +31 -18
  16. package/src/Sandbox.js.map +1 -0
  17. package/{dist → src}/Volume.js +2 -0
  18. package/src/Volume.js.map +1 -0
  19. package/{dist → src}/code-toolbox/SandboxPythonCodeToolbox.js +2 -1
  20. package/src/code-toolbox/SandboxPythonCodeToolbox.js.map +1 -0
  21. package/{dist → src}/code-toolbox/SandboxTsCodeToolbox.js +2 -1
  22. package/src/code-toolbox/SandboxTsCodeToolbox.js.map +1 -0
  23. package/{dist → src}/errors/DaytonaError.js +1 -0
  24. package/src/errors/DaytonaError.js.map +1 -0
  25. package/{dist → src}/index.d.ts +0 -1
  26. package/{dist → src}/index.js +2 -3
  27. package/src/index.js.map +1 -0
  28. package/{dist → src}/types/Charts.js +1 -0
  29. package/src/types/Charts.js.map +1 -0
  30. package/{dist → src}/types/ExecuteResponse.js +1 -0
  31. package/src/types/ExecuteResponse.js.map +1 -0
  32. package/{dist → src}/utils/ArtifactParser.js +1 -0
  33. package/src/utils/ArtifactParser.js.map +1 -0
  34. package/src/utils/Path.js +28 -0
  35. package/src/utils/Path.js.map +1 -0
  36. package/README.md +0 -145
  37. package/dist/Image.d.ts +0 -261
  38. package/dist/Image.js +0 -563
  39. package/dist/ObjectStorage.d.ts +0 -85
  40. package/dist/ObjectStorage.js +0 -227
  41. package/dist/utils/Path.js +0 -60
  42. package/dist/utils/Stream.d.ts +0 -13
  43. package/dist/utils/Stream.js +0 -81
  44. /package/{dist → src}/FileSystem.d.ts +0 -0
  45. /package/{dist → src}/Git.d.ts +0 -0
  46. /package/{dist → src}/LspServer.d.ts +0 -0
  47. /package/{dist → src}/Volume.d.ts +0 -0
  48. /package/{dist → src}/code-toolbox/SandboxPythonCodeToolbox.d.ts +0 -0
  49. /package/{dist → src}/code-toolbox/SandboxTsCodeToolbox.d.ts +0 -0
  50. /package/{dist → src}/errors/DaytonaError.d.ts +0 -0
  51. /package/{dist → src}/types/Charts.d.ts +0 -0
  52. /package/{dist → src}/types/ExecuteResponse.d.ts +0 -0
  53. /package/{dist → src}/utils/ArtifactParser.d.ts +0 -0
  54. /package/{dist → src}/utils/Path.d.ts +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@daytonaio/sdk",
3
- "version": "0.19.0-alpha.4",
3
+ "version": "0.19.0-alpha.6",
4
4
  "description": "TypeScript SDK for Daytona",
5
5
  "main": "./src/index.js",
6
6
  "types": "./src/index.d.ts",
@@ -18,40 +18,23 @@
18
18
  "docsDir": "../../apps/docs/content/sdk-typescript"
19
19
  },
20
20
  "scripts": {
21
- "build": "tsc",
22
- "prepare": "npm run build",
21
+ "build": "tsc && tsc -p tsconfig.esm.json",
23
22
  "docs": "bash -O extglob -c 'rm -rf $npm_package_config_docsDir/!(index.mdx)' && typedoc && rm -f $npm_package_config_docsDir/readme.mdx"
24
23
  },
25
- "files": [
26
- "dist"
27
- ],
28
24
  "keywords": [],
29
- "devDependencies": {
30
- "@babel/preset-env": "^7.22.0",
31
- "@babel/preset-typescript": "^7.22.0",
32
- "@types/jest": "^29.5.0",
33
- "@types/node": "^22.10.0",
34
- "@types/shell-quote": "^1.7.5",
35
- "@types/tar": "^6.1.13",
36
- "jest": "^29.5.0",
37
- "ts-jest": "^29.1.0",
38
- "typedoc": "~0.27.7",
39
- "typedoc-plugin-markdown": "~4.4.2",
40
- "typedoc-plugin-merge-modules": "~6.1.0",
41
- "typescript": "^5.0.0"
42
- },
43
25
  "dependencies": {
44
- "@daytonaio/api-client": "^0.19.1",
45
- "@aws-sdk/client-s3": "^3.445.0",
46
- "@aws-sdk/lib-storage": "^3.798.0",
26
+ "@babel/preset-env": "7.27.2",
27
+ "@babel/preset-typescript": "7.27.1",
47
28
  "@dotenvx/dotenvx": "^1.25.1",
48
- "@iarna/toml": "^2.2.5",
49
29
  "axios": "^1.6.1",
50
- "fast-glob": "^3.3.0",
30
+ "dotenv": "16.5.0",
51
31
  "form-data": "^4.0.0",
52
- "shell-quote": "^1.8.2",
53
- "tar": "^6.2.0",
54
- "untildify": "^5.0.0",
55
- "uuid": "^11.0.3"
56
- }
57
- }
32
+ "typedoc": "0.27.9",
33
+ "typedoc-plugin-markdown": "4.4.2",
34
+ "typedoc-plugin-merge-modules": "6.1.0",
35
+ "uuid": "^11.0.3",
36
+ "@daytonaio/api-client": "0.0.0-dev"
37
+ },
38
+ "packageManager": "yarn@4.6.0",
39
+ "type": "commonjs"
40
+ }
@@ -1,5 +1,4 @@
1
1
  import { CreateWorkspaceTargetEnum as SandboxTargetRegion, WorkspaceVolume } from '@daytonaio/api-client';
2
- import { Image } from './Image';
3
2
  import { Sandbox, Sandbox as Workspace } from './Sandbox';
4
3
  import { VolumeService } from './Volume';
5
4
  /**
@@ -89,7 +88,7 @@ export interface SandboxResources {
89
88
  * Parameters for creating a new Sandbox.
90
89
  *
91
90
  * @interface
92
- * @property {string | Image} [image] - Optional Docker image to use for the Sandbox or an Image instance
91
+ * @property {string} [image] - Optional Docker image to use for the Sandbox
93
92
  * @property {string} [user] - Optional os user to use for the Sandbox
94
93
  * @property {CodeLanguage | string} [language] - Programming language for direct code execution
95
94
  * @property {Record<string, string>} [envVars] - Optional environment variables to set in the Sandbox
@@ -113,8 +112,8 @@ export interface SandboxResources {
113
112
  * const sandbox = await daytona.create(params, 50);
114
113
  */
115
114
  export type CreateSandboxParams = {
116
- /** Optional Docker image to use for the Sandbox or an Image instance */
117
- image?: string | Image;
115
+ /** Optional Docker image to use for the Sandbox */
116
+ image?: string;
118
117
  /** Optional os user to use for the Sandbox */
119
118
  user?: string;
120
119
  /** Programming language for direct code execution */
@@ -177,8 +176,6 @@ export type SandboxFilter = {
177
176
  export declare class Daytona {
178
177
  private readonly sandboxApi;
179
178
  private readonly toolboxApi;
180
- private readonly imagesApi;
181
- private readonly objectStorageApi;
182
179
  private readonly target;
183
180
  private readonly apiKey?;
184
181
  private readonly jwtToken?;
@@ -193,8 +190,6 @@ export declare class Daytona {
193
190
  */
194
191
  constructor(config?: DaytonaConfig);
195
192
  /**
196
- * @deprecated Use `create` with `options` object instead. This method will be removed in a future version.
197
- *
198
193
  * Creates Sandboxes with default or custom configurations. You can specify various parameters,
199
194
  * including language, image, resources, environment variables, and volumes for the Sandbox.
200
195
  *
@@ -223,45 +218,7 @@ export declare class Daytona {
223
218
  * };
224
219
  * const sandbox = await daytona.create(params, 40);
225
220
  */
226
- create(params?: CreateSandboxParams, options?: number): Promise<Sandbox>;
227
- /**
228
- * Creates Sandboxes with default or custom configurations. You can specify various parameters,
229
- * including language, image, resources, environment variables, and volumes for the Sandbox.
230
- *
231
- * @param {CreateSandboxParams} [params] - Parameters for Sandbox creation
232
- * @param {object} [options] - Options for the create operation
233
- * @param {number} [options.timeout] - Timeout in seconds (0 means no timeout, default is 60)
234
- * @param {function} [options.onImageBuildLogs] - Callback function to handle image build logs.
235
- * It's invoked only when `params.image` is an instance of `Image` and there's no existing
236
- * image in Daytona with the same configuration.
237
- * @returns {Promise<Sandbox>} The created Sandbox instance
238
- *
239
- * @example
240
- * const image = Image.debianSlim('3.12').pipInstall('numpy');
241
- * const sandbox = await daytona.create({ image }, { timeout: 90, onImageBuildLogs: console.log });
242
- *
243
- * @example
244
- * // Create a custom sandbox
245
- * const image = Image.debianSlim('3.12').pipInstall('numpy');
246
- * const params: CreateSandboxParams = {
247
- * language: 'typescript',
248
- * image,
249
- * envVars: {
250
- * NODE_ENV: 'development',
251
- * DEBUG: 'true'
252
- * },
253
- * resources: {
254
- * cpu: 2,
255
- * memory: 4 // 4GB RAM
256
- * },
257
- * autoStopInterval: 60
258
- * };
259
- * const sandbox = await daytona.create(params, { timeout: 100, onImageBuildLogs: console.log });
260
- */
261
- create(params?: CreateSandboxParams, options?: {
262
- onImageBuildLogs?: (chunk: string) => void;
263
- timeout?: number;
264
- }): Promise<Sandbox>;
221
+ create(params?: CreateSandboxParams, timeout?: number): Promise<Sandbox>;
265
222
  /**
266
223
  * Gets a Sandbox by its ID.
267
224
  *
@@ -355,24 +312,6 @@ export declare class Daytona {
355
312
  * console.log(`Current sandbox state: ${sandbox.instance.state}`);
356
313
  */
357
314
  getCurrentSandbox(sandboxId: string): Promise<Sandbox>;
358
- /**
359
- * Creates and registers a new image from the given Image definition.
360
- *
361
- * @param {string} name - The name of the image to create.
362
- * @param {Image} image - The Image instance.
363
- * @param {object} options - Options for the create operation.
364
- * @param {boolean} options.verbose - Default is false. Whether to log progress information upon each state change of the image.
365
- * @param {number} options.timeout - Default is no timeout. Timeout in seconds (0 means no timeout).
366
- * @returns {Promise<void>}
367
- *
368
- * @example
369
- * const image = Image.debianSlim('3.12').pipInstall('numpy');
370
- * await daytona.createImage('my-python-image', image);
371
- */
372
- createImage(name: string, image: Image, options?: {
373
- onLogs?: (chunk: string) => void;
374
- timeout?: number;
375
- }): Promise<void>;
376
315
  /**
377
316
  * Gets the appropriate code toolbox based on language.
378
317
  *
@@ -382,12 +321,4 @@ export declare class Daytona {
382
321
  * @throws {DaytonaError} - `DaytonaError` - When an unsupported language is specified
383
322
  */
384
323
  private getCodeToolbox;
385
- /**
386
- * Processes the image contexts by uploading them to object storage
387
- *
388
- * @private
389
- * @param {Image} image - The Image instance.
390
- * @returns {Promise<string[]>} The list of context hashes stored in object storage.
391
- */
392
- private processImageContext;
393
324
  }
@@ -3,51 +3,15 @@
3
3
  * Copyright 2025 Daytona Platforms Inc.
4
4
  * SPDX-License-Identifier: AGPL-3.0
5
5
  */
6
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
- if (k2 === undefined) k2 = k;
8
- var desc = Object.getOwnPropertyDescriptor(m, k);
9
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
10
- desc = { enumerable: true, get: function() { return m[k]; } };
11
- }
12
- Object.defineProperty(o, k2, desc);
13
- }) : (function(o, m, k, k2) {
14
- if (k2 === undefined) k2 = k;
15
- o[k2] = m[k];
16
- }));
17
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
18
- Object.defineProperty(o, "default", { enumerable: true, value: v });
19
- }) : function(o, v) {
20
- o["default"] = v;
21
- });
22
- var __importStar = (this && this.__importStar) || (function () {
23
- var ownKeys = function(o) {
24
- ownKeys = Object.getOwnPropertyNames || function (o) {
25
- var ar = [];
26
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
27
- return ar;
28
- };
29
- return ownKeys(o);
30
- };
31
- return function (mod) {
32
- if (mod && mod.__esModule) return mod;
33
- var result = {};
34
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
35
- __setModuleDefault(result, mod);
36
- return result;
37
- };
38
- })();
39
6
  Object.defineProperty(exports, "__esModule", { value: true });
40
7
  exports.Daytona = exports.CodeLanguage = void 0;
41
8
  const api_client_1 = require("@daytonaio/api-client");
42
- const axios_1 = __importStar(require("axios"));
43
- const dotenv = __importStar(require("dotenv"));
9
+ const axios_1 = require("axios");
10
+ const dotenv = require("dotenv");
44
11
  const SandboxPythonCodeToolbox_1 = require("./code-toolbox/SandboxPythonCodeToolbox");
45
12
  const SandboxTsCodeToolbox_1 = require("./code-toolbox/SandboxTsCodeToolbox");
46
13
  const DaytonaError_1 = require("./errors/DaytonaError");
47
- const Image_1 = require("./Image");
48
- const ObjectStorage_1 = require("./ObjectStorage");
49
14
  const Sandbox_1 = require("./Sandbox");
50
- const Stream_1 = require("./utils/Stream");
51
15
  const Volume_1 = require("./Volume");
52
16
  /**
53
17
  * Supported programming languages for code execution
@@ -83,6 +47,14 @@ var CodeLanguage;
83
47
  * @class
84
48
  */
85
49
  class Daytona {
50
+ sandboxApi;
51
+ toolboxApi;
52
+ target;
53
+ apiKey;
54
+ jwtToken;
55
+ organizationId;
56
+ apiUrl;
57
+ volume;
86
58
  /**
87
59
  * Creates a new Daytona client instance.
88
60
  *
@@ -93,20 +65,20 @@ class Daytona {
93
65
  this.remove = this.delete.bind(this);
94
66
  dotenv.config();
95
67
  dotenv.config({ path: '.env.local', override: true });
96
- const apiKey = !(config === null || config === void 0 ? void 0 : config.apiKey) && (config === null || config === void 0 ? void 0 : config.jwtToken) ? undefined : (config === null || config === void 0 ? void 0 : config.apiKey) || (process === null || process === void 0 ? void 0 : process.env['DAYTONA_API_KEY']);
97
- const jwtToken = (config === null || config === void 0 ? void 0 : config.jwtToken) || (process === null || process === void 0 ? void 0 : process.env['DAYTONA_JWT_TOKEN']);
98
- const organizationId = (config === null || config === void 0 ? void 0 : config.organizationId) || (process === null || process === void 0 ? void 0 : process.env['DAYTONA_ORGANIZATION_ID']);
68
+ const apiKey = !config?.apiKey && config?.jwtToken ? undefined : config?.apiKey || process?.env['DAYTONA_API_KEY'];
69
+ const jwtToken = config?.jwtToken || process?.env['DAYTONA_JWT_TOKEN'];
70
+ const organizationId = config?.organizationId || process?.env['DAYTONA_ORGANIZATION_ID'];
99
71
  if (!apiKey && !jwtToken) {
100
72
  throw new DaytonaError_1.DaytonaError('API key or JWT token is required');
101
73
  }
102
- const apiUrl = (config === null || config === void 0 ? void 0 : config.apiUrl) ||
103
- (config === null || config === void 0 ? void 0 : config.serverUrl) ||
104
- (process === null || process === void 0 ? void 0 : process.env['DAYTONA_API_URL']) ||
105
- (process === null || process === void 0 ? void 0 : process.env['DAYTONA_SERVER_URL']) ||
74
+ const apiUrl = config?.apiUrl ||
75
+ config?.serverUrl ||
76
+ process?.env['DAYTONA_API_URL'] ||
77
+ process?.env['DAYTONA_SERVER_URL'] ||
106
78
  'https://app.daytona.io/api';
107
- const envTarget = process === null || process === void 0 ? void 0 : process.env['DAYTONA_TARGET'];
108
- const target = (config === null || config === void 0 ? void 0 : config.target) || envTarget || api_client_1.CreateWorkspaceTargetEnum.US;
109
- if ((process === null || process === void 0 ? void 0 : process.env['DAYTONA_SERVER_URL']) && !(process === null || process === void 0 ? void 0 : process.env['DAYTONA_API_URL'])) {
79
+ const envTarget = process?.env['DAYTONA_TARGET'];
80
+ const target = config?.target || envTarget || api_client_1.CreateWorkspaceTargetEnum.US;
81
+ if (process?.env['DAYTONA_SERVER_URL'] && !process?.env['DAYTONA_API_URL']) {
110
82
  console.warn('[Deprecation Warning] Environment variable `DAYTONA_SERVER_URL` is deprecated and will be removed in future versions. Use `DAYTONA_API_URL` instead.');
111
83
  }
112
84
  this.apiKey = apiKey;
@@ -137,21 +109,20 @@ class Daytona {
137
109
  axiosInstance.interceptors.response.use((response) => {
138
110
  return response;
139
111
  }, (error) => {
140
- var _a, _b, _c, _d, _e;
141
112
  let errorMessage;
142
113
  if (error instanceof axios_1.AxiosError && error.message.includes('timeout of')) {
143
114
  errorMessage = 'Operation timed out';
144
115
  }
145
116
  else {
146
- errorMessage = ((_b = (_a = error.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.message) || ((_c = error.response) === null || _c === void 0 ? void 0 : _c.data) || error.message || String(error);
117
+ errorMessage = error.response?.data?.message || error.response?.data || error.message || String(error);
147
118
  }
148
119
  try {
149
120
  errorMessage = JSON.stringify(errorMessage);
150
121
  }
151
- catch (_f) {
122
+ catch {
152
123
  errorMessage = String(errorMessage);
153
124
  }
154
- switch ((_e = (_d = error.response) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.statusCode) {
125
+ switch (error.response?.data?.statusCode) {
155
126
  case 404:
156
127
  throw new DaytonaError_1.DaytonaNotFoundError(errorMessage);
157
128
  default:
@@ -161,16 +132,38 @@ class Daytona {
161
132
  this.sandboxApi = new api_client_1.WorkspaceApi(configuration, '', axiosInstance);
162
133
  this.toolboxApi = new api_client_1.ToolboxApi(configuration, '', axiosInstance);
163
134
  this.volume = new Volume_1.VolumeService(new api_client_1.VolumesApi(configuration, '', axiosInstance));
164
- this.imagesApi = new api_client_1.ImagesApi(configuration, '', axiosInstance);
165
- this.objectStorageApi = new api_client_1.ObjectStorageApi(configuration, '', axiosInstance);
166
135
  }
167
- async create(params, options = { timeout: 60 }) {
168
- var _a, _b, _c, _d;
136
+ /**
137
+ * Creates Sandboxes with default or custom configurations. You can specify various parameters,
138
+ * including language, image, resources, environment variables, and volumes for the Sandbox.
139
+ *
140
+ * @param {CreateSandboxParams} [params] - Parameters for Sandbox creation
141
+ * @param {number} [timeout] - Timeout in seconds (0 means no timeout, default is 60)
142
+ * @returns {Promise<Sandbox>} The created Sandbox instance
143
+ *
144
+ * @example
145
+ * // Create a default sandbox
146
+ * const sandbox = await daytona.create();
147
+ *
148
+ * @example
149
+ * // Create a custom sandbox
150
+ * const params: CreateSandboxParams = {
151
+ * language: 'typescript',
152
+ * image: 'node:18',
153
+ * envVars: {
154
+ * NODE_ENV: 'development',
155
+ * DEBUG: 'true'
156
+ * },
157
+ * resources: {
158
+ * cpu: 2,
159
+ * memory: 4 // 4GB RAM
160
+ * },
161
+ * autoStopInterval: 60
162
+ * };
163
+ * const sandbox = await daytona.create(params, 40);
164
+ */
165
+ async create(params, timeout = 60) {
169
166
  const startTime = Date.now();
170
- options = typeof options === 'number' ? { timeout: options } : { ...options };
171
- if (options.timeout == undefined || options.timeout == null) {
172
- options.timeout = 60;
173
- }
174
167
  if (params == null) {
175
168
  params = { language: 'python' };
176
169
  }
@@ -179,7 +172,7 @@ class Daytona {
179
172
  labels['code-toolbox-language'] = params.language;
180
173
  }
181
174
  // remove this when params.timeout is removed
182
- const effectiveTimeout = params.timeout || options.timeout;
175
+ const effectiveTimeout = params.timeout || timeout;
183
176
  if (effectiveTimeout < 0) {
184
177
  throw new DaytonaError_1.DaytonaError('Timeout must be a non-negative number');
185
178
  }
@@ -189,55 +182,30 @@ class Daytona {
189
182
  }
190
183
  const codeToolbox = this.getCodeToolbox(params.language);
191
184
  try {
192
- // Handle Image instance if provided
193
- let imageStr;
194
- let buildInfo;
195
- if (typeof params.image === 'string') {
196
- imageStr = params.image;
197
- }
198
- else if (params.image instanceof Image_1.Image) {
199
- const contextHashes = await this.processImageContext(params.image);
200
- buildInfo = {
201
- contextHashes,
202
- dockerfileContent: params.image.dockerfile,
203
- };
204
- }
205
185
  const response = await this.sandboxApi.createWorkspace({
206
- image: imageStr,
207
- buildInfo,
186
+ image: params.image,
208
187
  user: params.user,
209
188
  env: params.envVars || {},
210
189
  labels: params.labels,
211
190
  public: params.public,
212
191
  target: this.target,
213
- cpu: (_a = params.resources) === null || _a === void 0 ? void 0 : _a.cpu,
214
- gpu: (_b = params.resources) === null || _b === void 0 ? void 0 : _b.gpu,
215
- memory: (_c = params.resources) === null || _c === void 0 ? void 0 : _c.memory,
216
- disk: (_d = params.resources) === null || _d === void 0 ? void 0 : _d.disk,
192
+ cpu: params.resources?.cpu,
193
+ gpu: params.resources?.gpu,
194
+ memory: params.resources?.memory,
195
+ disk: params.resources?.disk,
217
196
  autoStopInterval: params.autoStopInterval,
218
197
  volumes: params.volumes,
219
198
  }, undefined, {
220
199
  timeout: effectiveTimeout * 1000,
221
200
  });
222
- let sandboxInstance = response.data;
223
- if (sandboxInstance.state === api_client_1.WorkspaceState.PENDING_BUILD && options.onImageBuildLogs) {
224
- const terminalStates = [api_client_1.WorkspaceState.STARTED, api_client_1.WorkspaceState.STARTING, api_client_1.WorkspaceState.ERROR];
225
- while (sandboxInstance.state === api_client_1.WorkspaceState.PENDING_BUILD) {
226
- await new Promise((resolve) => setTimeout(resolve, 1000));
227
- sandboxInstance = (await this.sandboxApi.getWorkspace(sandboxInstance.id)).data;
228
- }
229
- await (0, Stream_1.processStreamingResponse)(() => this.sandboxApi.getBuildLogs(sandboxInstance.id, undefined, true, { responseType: 'stream' }), options.onImageBuildLogs, async () => {
230
- sandboxInstance = (await this.sandboxApi.getWorkspace(sandboxInstance.id)).data;
231
- return sandboxInstance.state !== undefined && terminalStates.includes(sandboxInstance.state);
232
- });
233
- }
201
+ const sandboxInstance = response.data;
234
202
  const sandboxInfo = Sandbox_1.Sandbox.toSandboxInfo(sandboxInstance);
235
203
  sandboxInstance.info = {
236
204
  ...sandboxInfo,
237
205
  name: '',
238
206
  };
239
207
  const sandbox = new Sandbox_1.Sandbox(sandboxInstance.id, sandboxInstance, this.sandboxApi, this.toolboxApi, codeToolbox);
240
- if (!params.async && sandbox.instance.state !== 'started') {
208
+ if (!params.async) {
241
209
  const timeElapsed = Date.now() - startTime;
242
210
  await sandbox.waitUntilStarted(effectiveTimeout ? effectiveTimeout - timeElapsed / 1000 : 0);
243
211
  }
@@ -307,8 +275,7 @@ class Daytona {
307
275
  async list(labels) {
308
276
  const response = await this.sandboxApi.listWorkspaces(undefined, undefined, labels ? JSON.stringify(labels) : undefined);
309
277
  return response.data.map((sandbox) => {
310
- var _a;
311
- const language = (_a = sandbox.labels) === null || _a === void 0 ? void 0 : _a['code-toolbox-language'];
278
+ const language = sandbox.labels?.['code-toolbox-language'];
312
279
  const sandboxInfo = Sandbox_1.Sandbox.toSandboxInfo(sandbox);
313
280
  sandbox.info = {
314
281
  ...sandboxInfo,
@@ -359,6 +326,8 @@ class Daytona {
359
326
  async delete(sandbox, timeout = 60) {
360
327
  await this.sandboxApi.deleteWorkspace(sandbox.id, true, undefined, { timeout: timeout * 1000 });
361
328
  }
329
+ /** @hidden */
330
+ remove;
362
331
  /**
363
332
  * Gets the Sandbox by ID.
364
333
  *
@@ -383,70 +352,6 @@ class Daytona {
383
352
  async getCurrentSandbox(sandboxId) {
384
353
  return await this.get(sandboxId);
385
354
  }
386
- /**
387
- * Creates and registers a new image from the given Image definition.
388
- *
389
- * @param {string} name - The name of the image to create.
390
- * @param {Image} image - The Image instance.
391
- * @param {object} options - Options for the create operation.
392
- * @param {boolean} options.verbose - Default is false. Whether to log progress information upon each state change of the image.
393
- * @param {number} options.timeout - Default is no timeout. Timeout in seconds (0 means no timeout).
394
- * @returns {Promise<void>}
395
- *
396
- * @example
397
- * const image = Image.debianSlim('3.12').pipInstall('numpy');
398
- * await daytona.createImage('my-python-image', image);
399
- */
400
- async createImage(name, image, options = {}) {
401
- const contextHashes = await this.processImageContext(image);
402
- let builtImage = (await this.imagesApi.buildImage({
403
- name,
404
- buildInfo: {
405
- contextHashes,
406
- dockerfileContent: image.dockerfile,
407
- },
408
- }, undefined, {
409
- timeout: (options.timeout || 0) * 1000,
410
- })).data;
411
- const terminalStates = [api_client_1.ImageState.ACTIVE, api_client_1.ImageState.ERROR];
412
- const imageRef = { builtImage };
413
- let streamPromise;
414
- const startLogStreaming = async () => {
415
- if (!streamPromise) {
416
- streamPromise = (0, Stream_1.processStreamingResponse)(() => this.imagesApi.getImageBuildLogs(builtImage.id, undefined, true, { responseType: 'stream' }), options.onLogs, async () => terminalStates.includes(imageRef.builtImage.state));
417
- }
418
- };
419
- if (options.onLogs) {
420
- options.onLogs(`Building image ${builtImage.name} (${builtImage.state})`);
421
- if (builtImage.state !== api_client_1.ImageState.BUILD_PENDING) {
422
- await startLogStreaming();
423
- }
424
- }
425
- let previousState = builtImage.state;
426
- while (!terminalStates.includes(builtImage.state)) {
427
- if (options.onLogs && previousState !== builtImage.state) {
428
- if (builtImage.state !== api_client_1.ImageState.BUILD_PENDING && !streamPromise) {
429
- await startLogStreaming();
430
- }
431
- options.onLogs(`Building image ${builtImage.name} (${builtImage.state})`);
432
- previousState = builtImage.state;
433
- }
434
- await new Promise((resolve) => setTimeout(resolve, 1000));
435
- builtImage = (await this.imagesApi.getImage(builtImage.id)).data;
436
- imageRef.builtImage = builtImage;
437
- }
438
- if (options.onLogs) {
439
- if (streamPromise) {
440
- await streamPromise;
441
- }
442
- if (builtImage.state === api_client_1.ImageState.ACTIVE) {
443
- options.onLogs(`Built image ${builtImage.name} (${builtImage.state})`);
444
- }
445
- }
446
- if (builtImage.state === api_client_1.ImageState.ERROR) {
447
- throw new DaytonaError_1.DaytonaError(`Failed to build image. Image ended in the ERROR state. name: ${builtImage.name}; error reason: ${builtImage.errorReason}`);
448
- }
449
- }
450
355
  /**
451
356
  * Gets the appropriate code toolbox based on language.
452
357
  *
@@ -467,31 +372,6 @@ class Daytona {
467
372
  throw new DaytonaError_1.DaytonaError(`Unsupported language: ${language}, supported languages: ${Object.values(CodeLanguage).join(', ')}`);
468
373
  }
469
374
  }
470
- /**
471
- * Processes the image contexts by uploading them to object storage
472
- *
473
- * @private
474
- * @param {Image} image - The Image instance.
475
- * @returns {Promise<string[]>} The list of context hashes stored in object storage.
476
- */
477
- async processImageContext(image) {
478
- if (!image.contextList || !image.contextList.length) {
479
- return [];
480
- }
481
- const pushAccessCreds = (await this.objectStorageApi.getPushAccess()).data;
482
- const objectStorage = new ObjectStorage_1.ObjectStorage({
483
- endpointUrl: pushAccessCreds.storageUrl,
484
- accessKeyId: pushAccessCreds.accessKey,
485
- secretAccessKey: pushAccessCreds.secret,
486
- sessionToken: pushAccessCreds.sessionToken,
487
- bucketName: pushAccessCreds.bucket,
488
- });
489
- const contextHashes = [];
490
- for (const context of image.contextList) {
491
- const contextHash = await objectStorage.upload(context.sourcePath, pushAccessCreds.organizationId, context.archivePath);
492
- contextHashes.push(contextHash);
493
- }
494
- return contextHashes;
495
- }
496
375
  }
497
376
  exports.Daytona = Daytona;
377
+ //# 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;;;AA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IAAI,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,EAAE,CAAC,CAAA;IACjG,CAAC;IAED,cAAc;IACP,MAAM,CAAwD;IAErE;;;;;;;OAOG;IACI,KAAK,CAAC,mBAAmB,CAAC,WAAmB;QAClD,OAAO,MAAM,IAAI,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAA;IAClD,CAAC;IAED;;;;;;;;;OASG;IACI,KAAK,CAAC,iBAAiB,CAAC,SAAiB;QAC9C,OAAO,MAAM,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;IAClC,CAAC;IAED;;;;;;;OAOG;IACK,cAAc,CAAC,QAAuB;QAC5C,QAAQ,QAAQ,EAAE,CAAC;YACjB,KAAK,YAAY,CAAC,UAAU,CAAC;YAC7B,KAAK,YAAY,CAAC,UAAU;gBAC1B,OAAO,IAAI,2CAAoB,EAAE,CAAA;YACnC,KAAK,YAAY,CAAC,MAAM,CAAC;YACzB,KAAK,SAAS;gBACZ,OAAO,IAAI,mDAAwB,EAAE,CAAA;YACvC;gBACE,MAAM,IAAI,2BAAY,CACpB,yBAAyB,QAAQ,0BAA0B,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACpG,CAAA;QACL,CAAC;IACH,CAAC;CACF;AAtYD,0BAsYC"}
@@ -3,54 +3,21 @@
3
3
  * Copyright 2025 Daytona Platforms Inc.
4
4
  * SPDX-License-Identifier: AGPL-3.0
5
5
  */
6
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
- if (k2 === undefined) k2 = k;
8
- var desc = Object.getOwnPropertyDescriptor(m, k);
9
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
10
- desc = { enumerable: true, get: function() { return m[k]; } };
11
- }
12
- Object.defineProperty(o, k2, desc);
13
- }) : (function(o, m, k, k2) {
14
- if (k2 === undefined) k2 = k;
15
- o[k2] = m[k];
16
- }));
17
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
18
- Object.defineProperty(o, "default", { enumerable: true, value: v });
19
- }) : function(o, v) {
20
- o["default"] = v;
21
- });
22
- var __importStar = (this && this.__importStar) || (function () {
23
- var ownKeys = function(o) {
24
- ownKeys = Object.getOwnPropertyNames || function (o) {
25
- var ar = [];
26
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
27
- return ar;
28
- };
29
- return ownKeys(o);
30
- };
31
- return function (mod) {
32
- if (mod && mod.__esModule) return mod;
33
- var result = {};
34
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
35
- __setModuleDefault(result, mod);
36
- return result;
37
- };
38
- })();
39
- var __importDefault = (this && this.__importDefault) || function (mod) {
40
- return (mod && mod.__esModule) ? mod : { "default": mod };
41
- };
42
6
  Object.defineProperty(exports, "__esModule", { value: true });
43
7
  exports.FileSystem = void 0;
44
8
  const Path_1 = require("./utils/Path");
45
- const fs = __importStar(require("fs"));
9
+ const fs = require("fs");
46
10
  const stream_1 = require("stream");
47
- const form_data_1 = __importDefault(require("form-data"));
11
+ const FormData = require("form-data");
48
12
  /**
49
13
  * Provides file system operations within a Sandbox.
50
14
  *
51
15
  * @class
52
16
  */
53
17
  class FileSystem {
18
+ instance;
19
+ toolboxApi;
20
+ getRootDir;
54
21
  constructor(instance, toolboxApi, getRootDir) {
55
22
  this.instance = instance;
56
23
  this.toolboxApi = toolboxApi;
@@ -279,7 +246,7 @@ class FileSystem {
279
246
  * await fs.uploadFiles(files);
280
247
  */
281
248
  async uploadFiles(files, timeout = 30 * 60) {
282
- const form = new form_data_1.default();
249
+ const form = new FormData();
283
250
  const rootDir = await this.getRootDir();
284
251
  files.forEach(({ source, destination }, i) => {
285
252
  const dst = (0, Path_1.prefixRelativePath)(rootDir, destination);
@@ -296,3 +263,4 @@ class FileSystem {
296
263
  }
297
264
  }
298
265
  exports.FileSystem = FileSystem;
266
+ //# sourceMappingURL=FileSystem.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FileSystem.js","sourceRoot":"","sources":["../../../../libs/sdk-typescript/src/FileSystem.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,uCAAiD;AACjD,yBAAwB;AACxB,mCAAiC;AACjC,sCAAqC;AAwCrC;;;;GAIG;AACH,MAAa,UAAU;IAEF;IACA;IACA;IAHnB,YACmB,QAAyB,EACzB,UAAsB,EACtB,UAAiC;QAFjC,aAAQ,GAAR,QAAQ,CAAiB;QACzB,eAAU,GAAV,UAAU,CAAY;QACtB,eAAU,GAAV,UAAU,CAAuB;IACjD,CAAC;IAEJ;;;;;;;;;;;OAWG;IACI,KAAK,CAAC,YAAY,CAAC,IAAY,EAAE,IAAY;QAClD,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,YAAY,CACjD,IAAI,CAAC,QAAQ,CAAC,EAAE,EAChB,IAAA,yBAAkB,EAAC,MAAM,IAAI,CAAC,UAAU,EAAE,EAAE,IAAI,CAAC,EACjD,IAAI,CACL,CAAA;QACD,OAAO,QAAQ,CAAC,IAAI,CAAA;IACtB,CAAC;IAED;;;;;;;;;;OAUG;IACI,KAAK,CAAC,UAAU,CAAC,IAAY;QAClC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,UAAU,CAC/C,IAAI,CAAC,QAAQ,CAAC,EAAE,EAChB,IAAA,yBAAkB,EAAC,MAAM,IAAI,CAAC,UAAU,EAAE,EAAE,IAAI,CAAC,CAClD,CAAA;QACD,OAAO,QAAQ,CAAC,IAAI,CAAA;IACtB,CAAC;IAkCM,KAAK,CAAC,YAAY,CAAC,GAAW,EAAE,GAAqB,EAAE,UAAkB,EAAE,GAAG,EAAE;QACrF,MAAM,UAAU,GAAG,IAAA,yBAAkB,EAAC,MAAM,IAAI,CAAC,UAAU,EAAE,EAAE,GAAG,CAAC,CAAA;Q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