@daytonaio/sdk 0.18.0 → 0.19.0-alpha.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 CHANGED
@@ -1,43 +1,52 @@
1
1
  {
2
2
  "name": "@daytonaio/sdk",
3
- "version": "0.18.0",
4
- "description": "Daytona client library for AI Agents",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
3
+ "version": "0.19.0-alpha.0",
4
+ "description": "TypeScript SDK for Daytona",
5
+ "main": "./src/index.js",
6
+ "types": "./src/index.d.ts",
7
7
  "repository": {
8
8
  "type": "git",
9
- "url": "git+https://github.com/daytonaio/sdk.git"
9
+ "url": "git+https://github.com/daytonaio/daytona.git"
10
10
  },
11
- "author": "",
12
- "license": "MIT",
11
+ "author": "Daytona Platforms Inc.",
12
+ "license": "AGPL-3.0",
13
13
  "bugs": {
14
14
  "url": "https://github.com/daytonaio/sdk/issues"
15
15
  },
16
16
  "homepage": "https://github.com/daytonaio/sdk#readme",
17
+ "config": {
18
+ "docsDir": "../../apps/docs/content/sdk-typescript"
19
+ },
17
20
  "scripts": {
18
- "build": "tsc",
19
- "test": "jest",
20
- "prepare": "npm run build",
21
- "docs": "rm -rf ../../docs/typescript-sdk/* && typedoc && rm -f ../../docs/typescript-sdk/readme.mdx"
21
+ "build": "tsc && tsc -p tsconfig.esm.json",
22
+ "docs": "bash -O extglob -c 'rm -rf $npm_package_config_docsDir/!(index.mdx)' && typedoc && rm -f $npm_package_config_docsDir/readme.mdx"
22
23
  },
23
24
  "files": [
24
25
  "dist"
25
26
  ],
26
27
  "keywords": [],
27
- "devDependencies": {
28
- "@babel/preset-env": "^7.22.0",
29
- "@babel/preset-typescript": "^7.22.0",
30
- "@types/jest": "^29.5.0",
31
- "@types/node": "^22.10.0",
32
- "jest": "^29.5.0",
33
- "ts-jest": "^29.1.0",
34
- "typescript": "^5.0.0"
35
- },
36
28
  "dependencies": {
37
- "@daytonaio/api-client": "^0.19.1",
38
- "uuid": "^11.0.3",
29
+ "@aws-sdk/client-s3": "^3.445.0",
30
+ "@aws-sdk/lib-storage": "^3.798.0",
31
+ "@babel/preset-env": "7.27.2",
32
+ "@babel/preset-typescript": "7.27.1",
33
+ "@daytonaio/api-client": "^0.19.0-alpha.3",
39
34
  "@dotenvx/dotenvx": "^1.25.1",
40
- "axios": "^1.6.0",
41
- "form-data": "^4.0.0"
42
- }
43
- }
35
+ "@iarna/toml": "^2.2.5",
36
+ "@types/shell-quote": "1.7.5",
37
+ "@types/tar": "6.1.13",
38
+ "axios": "^1.6.1",
39
+ "dotenv": "16.5.0",
40
+ "fast-glob": "^3.3.0",
41
+ "form-data": "^4.0.0",
42
+ "shell-quote": "^1.8.2",
43
+ "tar": "^6.2.0",
44
+ "typedoc": "0.27.9",
45
+ "typedoc-plugin-markdown": "4.4.2",
46
+ "typedoc-plugin-merge-modules": "6.1.0",
47
+ "untildify": "^5.0.0",
48
+ "uuid": "^11.0.3"
49
+ },
50
+ "packageManager": "yarn@4.6.0",
51
+ "type": "commonjs"
52
+ }
package/LICENCE DELETED
@@ -1,43 +0,0 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- http://www.apache.org/licenses/
4
-
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
-
7
- 1. Definitions.
8
-
9
- "License" shall mean the terms and conditions for use, reproduction,
10
- and distribution as defined by Sections 1 through 9 of this document.
11
-
12
- "Licensor" shall mean the copyright owner or entity authorized by
13
- the copyright owner that is granting the License.
14
-
15
- "Legal Entity" shall mean the union of the acting entity and all
16
- other entities that control, are controlled by, or are under common
17
- control with that entity. For the purposes of this definition,
18
- "control" means (i) the power, direct or indirect, to cause the
19
- direction or management of such entity, whether by contract or
20
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
- outstanding shares, or (iii) beneficial ownership of such entity.
22
-
23
- "You" (or "Your") shall mean an individual or Legal Entity
24
- exercising permissions granted by this License.
25
-
26
- "Source" form shall mean the preferred form for making modifications,
27
- including but not limited to software source code, documentation
28
- source, and configuration files.
29
-
30
- "Object" form shall mean any form resulting from mechanical
31
- transformation or translation of a Source form, including but
32
- not limited to compiled object code, generated documentation,
33
- and conversions to other media types.
34
-
35
- "Work" shall mean the work of authorship, whether in Source or
36
- Object form, made available under the License, as indicated by a
37
- copyright notice that is included in or attached to the work
38
- (an example is provided in the Appendix below).
39
-
40
- "Derivative Works" shall mean any work, whether in Source or Object
41
- form, that is based on (or derived from) the Work and for which the
42
- editorial revisions, annotations, elaborations, or other modifications
43
- represent, as a whole, an original work of authorship
package/README.md DELETED
@@ -1,167 +0,0 @@
1
- # Daytona SDK for TypeScript
2
-
3
- A TypeScript SDK for interacting with the Daytona API, providing a simple interface for Daytona Sandbox management, Git operations, file system operations, and language server protocol support.
4
-
5
- ## Installation
6
-
7
- You can install the package using npm:
8
-
9
- ```bash
10
- npm install @daytonaio/sdk
11
- ```
12
-
13
- Or using yarn:
14
-
15
- ```bash
16
- yarn add @daytonaio/sdk
17
- ```
18
-
19
- ## Quick Start
20
-
21
- Here's a simple example of using the SDK:
22
-
23
- ```typescript
24
- import { Daytona } from '@daytonaio/sdk'
25
-
26
- // Initialize using environment variables
27
- const daytona = new Daytona()
28
-
29
- // Create a sandbox
30
- const sandbox = await daytona.create()
31
-
32
- // Run code in the sandbox
33
- const response = await sandbox.process.codeRun('console.log("Hello World!")')
34
- console.log(response.result)
35
-
36
- // Clean up when done
37
- await daytona.delete(sandbox)
38
- ```
39
-
40
- ## Configuration
41
-
42
- The SDK can be configured using environment variables or by passing a configuration object:
43
-
44
- ```typescript
45
- import { Daytona } from '@daytonaio/sdk'
46
-
47
- // Initialize with configuration
48
- const daytona = new Daytona({
49
- apiKey: 'your-api-key',
50
- apiUrl: 'your-api-url',
51
- target: 'us',
52
- })
53
- ```
54
-
55
- Or using environment variables:
56
-
57
- - `DAYTONA_API_KEY`: Your Daytona API key
58
- - `DAYTONA_API_URL`: The Daytona API URL
59
- - `DAYTONA_TARGET`: Your target environment
60
-
61
- You can also customize sandbox creation:
62
-
63
- ```typescript
64
- const sandbox = await daytona.create({
65
- language: 'typescript',
66
- envVars: { NODE_ENV: 'development' },
67
- autoStopInterval: 60, // Auto-stop after 1 hour of inactivity
68
- })
69
- ```
70
-
71
- ## Features
72
-
73
- - **Sandbox Management**: Create, manage and remove sandboxes
74
- - **Git Operations**: Clone repositories, manage branches, and more
75
- - **File System Operations**: Upload, download, search and manipulate files
76
- - **Language Server Protocol**: Interact with language servers for code intelligence
77
- - **Process Management**: Execute code and commands in sandboxes
78
-
79
- ## Examples
80
-
81
- ### Execute Commands
82
-
83
- ```typescript
84
- // Execute a shell command
85
- const response = await sandbox.process.executeCommand('echo "Hello, World!"')
86
- console.log(response.result)
87
-
88
- // Run TypeScript code
89
- const response = await sandbox.process.codeRun(`
90
- const x = 10
91
- const y = 20
92
- console.log(\`Sum: \${x + y}\`)
93
- `)
94
- console.log(response.result)
95
- ```
96
-
97
- ### File Operations
98
-
99
- ```typescript
100
- // Upload a file
101
- await sandbox.fs.uploadFile(Buffer.from('Hello, World!'), 'path/to/file.txt')
102
-
103
- // Download a file
104
- const content = await sandbox.fs.downloadFile('path/to/file.txt')
105
-
106
- // Search for files
107
- const matches = await sandbox.fs.findFiles(root_dir, 'search_pattern')
108
- ```
109
-
110
- ### Git Operations
111
-
112
- ```typescript
113
- // Clone a repository
114
- await sandbox.git.clone('https://github.com/example/repo', 'path/to/clone')
115
-
116
- // List branches
117
- const branches = await sandbox.git.branches('path/to/repo')
118
-
119
- // Add files
120
- await sandbox.git.add('path/to/repo', ['file1.txt', 'file2.txt'])
121
- ```
122
-
123
- ### Language Server Protocol
124
-
125
- ```typescript
126
- // Create and start a language server
127
- const lsp = await sandbox.createLspServer('typescript', 'path/to/project')
128
- await lsp.start()
129
-
130
- // Notify the lsp for the file
131
- await lsp.didOpen('path/to/file.ts')
132
-
133
- // Get document symbols
134
- const symbols = await lsp.documentSymbols('path/to/file.ts')
135
-
136
- // Get completions
137
- const completions = await lsp.completions('path/to/file.ts', {
138
- line: 10,
139
- character: 15,
140
- })
141
- ```
142
-
143
- ## Contributing
144
-
145
- Contributions are welcome! Please feel free to submit a Pull Request.
146
-
147
- ## License
148
-
149
- This project is licensed under the Apache License, Version 2.0 - see below for details:
150
-
151
- ```
152
- Copyright 2024 Daytona
153
-
154
- Licensed under the Apache License, Version 2.0 (the "License");
155
- you may not use this file except in compliance with the License.
156
- You may obtain a copy of the License at
157
-
158
- http://www.apache.org/licenses/LICENSE-2.0
159
-
160
- Unless required by applicable law or agreed to in writing, software
161
- distributed under the License is distributed on an "AS IS" BASIS,
162
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
163
- See the License for the specific language governing permissions and
164
- limitations under the License.
165
- ```
166
-
167
- For the full license text, please see the [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0).
package/dist/Daytona.d.ts DELETED
@@ -1,325 +0,0 @@
1
- import { CreateWorkspaceTargetEnum as SandboxTargetRegion, WorkspaceVolume } from '@daytonaio/api-client';
2
- import { Sandbox, Sandbox as Workspace } from './Sandbox';
3
- import { VolumeService } from './Volume';
4
- /**
5
- * Represents a volume mount for a Sandbox.
6
- *
7
- * @interface
8
- * @property {string} volumeId - ID of the Volume to mount
9
- * @property {string} mountPath - Path on the Sandbox to mount the Volume
10
- */
11
- export interface VolumeMount extends WorkspaceVolume {
12
- volumeId: string;
13
- mountPath: string;
14
- }
15
- /**
16
- * Configuration options for initializing the Daytona client.
17
- *
18
- * @interface
19
- * @property {string} apiKey - API key for authentication with the Daytona API
20
- * @property {string} jwtToken - JWT token for authentication with the Daytona API. If not set, it must be provided
21
- * via the environment variable `DAYTONA_JWT_TOKEN`, or an API key must be provided instead.
22
- * @property {string} organizationId - Organization ID used for JWT-based authentication. Required if a JWT token
23
- * is provided, and must be set either here or in the environment variable `DAYTONA_ORGANIZATION_ID`.
24
- * @property {string} apiUrl - URL of the Daytona API. Defaults to 'https://app.daytona.io/api'
25
- * if not set here and not set in environment variable DAYTONA_API_URL.
26
- * @property {CreateSandboxTargetEnum} target - Target location for Sandboxes
27
- *
28
- * @example
29
- * const config: DaytonaConfig = {
30
- * apiKey: "your-api-key",
31
- * apiUrl: "https://your-api.com",
32
- * target: "us"
33
- * };
34
- * const daytona = new Daytona(config);
35
- */
36
- export interface DaytonaConfig {
37
- /** API key for authentication with the Daytona API */
38
- apiKey?: string;
39
- /** JWT token for authentication with the Daytona API */
40
- jwtToken?: string;
41
- /** Organization ID for authentication with the Daytona API */
42
- organizationId?: string;
43
- /** URL of the Daytona API.
44
- */
45
- apiUrl?: string;
46
- /**
47
- * @deprecated Use `apiUrl` instead. This property will be removed in future versions.
48
- */
49
- serverUrl?: string;
50
- /** Target environment for sandboxes */
51
- target?: SandboxTargetRegion;
52
- }
53
- /**
54
- * Supported programming languages for code execution
55
- */
56
- export declare enum CodeLanguage {
57
- PYTHON = "python",
58
- TYPESCRIPT = "typescript",
59
- JAVASCRIPT = "javascript"
60
- }
61
- /**
62
- * Resource allocation for a Sandbox.
63
- *
64
- * @interface
65
- * @property {number} [cpu] - CPU allocation for the Sandbox in cores
66
- * @property {number} [gpu] - GPU allocation for the Sandbox in units
67
- * @property {number} [memory] - Memory allocation for the Sandbox in GB
68
- * @property {number} [disk] - Disk space allocation for the Sandbox in GB
69
- *
70
- * @example
71
- * const resources: SandboxResources = {
72
- * cpu: 2,
73
- * memory: 4, // 4GB RAM
74
- * disk: 20 // 20GB disk
75
- * };
76
- */
77
- export interface SandboxResources {
78
- /** CPU allocation for the Sandbox */
79
- cpu?: number;
80
- /** GPU allocation for the Sandbox */
81
- gpu?: number;
82
- /** Memory allocation for the Sandbox in GB */
83
- memory?: number;
84
- /** Disk space allocation for the Sandbox in GB */
85
- disk?: number;
86
- }
87
- /**
88
- * Parameters for creating a new Sandbox.
89
- *
90
- * @interface
91
- * @property {string} [image] - Optional Docker image to use for the Sandbox
92
- * @property {string} [user] - Optional os user to use for the Sandbox
93
- * @property {CodeLanguage | string} [language] - Programming language for direct code execution
94
- * @property {Record<string, string>} [envVars] - Optional environment variables to set in the Sandbox
95
- * @property {Record<string, string>} [labels] - Sandbox labels
96
- * @property {boolean} [public] - Is the Sandbox port preview public
97
- * @property {SandboxTargetRegion | string} [target] - Target location for the Sandbox
98
- * @property {SandboxResources} [resources] - Resource allocation for the Sandbox
99
- * @property {boolean} [async] - If true, will not wait for the Sandbox to be ready before returning
100
- * @property {number} [timeout] - Timeout in seconds for the Sandbox to be ready (0 means no timeout)
101
- * @property {number} [autoStopInterval] - Auto-stop interval in minutes (0 means disabled)
102
- *
103
- * @example
104
- * const params: CreateSandboxParams = {
105
- * language: 'typescript',
106
- * envVars: { NODE_ENV: 'development' },
107
- * resources: {
108
- * cpu: 2,
109
- * memory: 4 // 4GB RAM
110
- * },
111
- * autoStopInterval: 60 // Auto-stop after 1 hour of inactivity
112
- * };
113
- * const sandbox = await daytona.create(params, 50);
114
- */
115
- export type CreateSandboxParams = {
116
- /** Optional Docker image to use for the Sandbox */
117
- image?: string;
118
- /** Optional os user to use for the Sandbox */
119
- user?: string;
120
- /** Programming language for direct code execution */
121
- language?: CodeLanguage | string;
122
- /** Optional environment variables to set in the sandbox */
123
- envVars?: Record<string, string>;
124
- /** Sandbox labels */
125
- labels?: Record<string, string>;
126
- /** Is the Sandbox port preview public */
127
- public?: boolean;
128
- /** Resource allocation for the Sandbox */
129
- resources?: SandboxResources;
130
- /** If true, will not wait for the Sandbox to be ready before returning */
131
- async?: boolean;
132
- /**
133
- * Timeout in seconds, for the Sandbox to be ready (0 means no timeout)
134
- * @deprecated Use methods with `timeout` parameter instead
135
- */
136
- timeout?: number;
137
- /** Auto-stop interval in minutes (0 means disabled) (must be a non-negative integer) */
138
- autoStopInterval?: number;
139
- /** List of volumes to mount in the Sandbox */
140
- volumes?: VolumeMount[];
141
- };
142
- /**
143
- * Filter for Sandboxes.
144
- *
145
- * @interface
146
- * @property {string} [id] - The ID of the Sandbox to retrieve
147
- * @property {Record<string, string>} [labels] - Labels to filter Sandboxes
148
- */
149
- export type SandboxFilter = {
150
- id?: string;
151
- labels?: Record<string, string>;
152
- };
153
- /**
154
- * Main class for interacting with the Daytona API.
155
- * Provides methods for creating, managing, and interacting with Daytona Sandboxes.
156
- * Can be initialized either with explicit configuration or using environment variables.
157
- *
158
- * @property {VolumeService} volume - Service for managing Daytona Volumes
159
- *
160
- * @example
161
- * // Using environment variables
162
- * // Uses DAYTONA_API_KEY, DAYTONA_API_URL, DAYTONA_TARGET
163
- * const daytona = new Daytona();
164
- * const sandbox = await daytona.create();
165
- *
166
- * @example
167
- * // Using explicit configuration
168
- * const config: DaytonaConfig = {
169
- * apiKey: "your-api-key",
170
- * apiUrl: "https://your-api.com",
171
- * target: "us"
172
- * };
173
- * const daytona = new Daytona(config);
174
- *
175
- * @class
176
- */
177
- export declare class Daytona {
178
- private readonly sandboxApi;
179
- private readonly toolboxApi;
180
- private readonly target;
181
- private readonly apiKey?;
182
- private readonly jwtToken?;
183
- private readonly organizationId?;
184
- private readonly apiUrl;
185
- readonly volume: VolumeService;
186
- /**
187
- * Creates a new Daytona client instance.
188
- *
189
- * @param {DaytonaConfig} [config] - Configuration options
190
- * @throws {DaytonaError} - `DaytonaError` - When API key is missing
191
- */
192
- constructor(config?: DaytonaConfig);
193
- /**
194
- * Creates Sandboxes with default or custom configurations. You can specify various parameters,
195
- * including language, image, resources, environment variables, and volumes for the Sandbox.
196
- *
197
- * @param {CreateSandboxParams} [params] - Parameters for Sandbox creation
198
- * @param {number} [timeout] - Timeout in seconds (0 means no timeout, default is 60)
199
- * @returns {Promise<Sandbox>} The created Sandbox instance
200
- *
201
- * @example
202
- * // Create a default sandbox
203
- * const sandbox = await daytona.create();
204
- *
205
- * @example
206
- * // Create a custom sandbox
207
- * const params: CreateSandboxParams = {
208
- * language: 'typescript',
209
- * image: 'node:18',
210
- * envVars: {
211
- * NODE_ENV: 'development',
212
- * DEBUG: 'true'
213
- * },
214
- * resources: {
215
- * cpu: 2,
216
- * memory: 4 // 4GB RAM
217
- * },
218
- * autoStopInterval: 60
219
- * };
220
- * const sandbox = await daytona.create(params, 40);
221
- */
222
- create(params?: CreateSandboxParams, timeout?: number): Promise<Sandbox>;
223
- /**
224
- * Gets a Sandbox by its ID.
225
- *
226
- * @param {string} sandboxId - The ID of the Sandbox to retrieve
227
- * @returns {Promise<Sandbox>} The Sandbox
228
- *
229
- * @example
230
- * const sandbox = await daytona.get('my-sandbox-id');
231
- * console.log(`Sandbox state: ${sandbox.instance.state}`);
232
- */
233
- get(sandboxId: string): Promise<Sandbox>;
234
- /**
235
- * Finds a Sandbox by its ID or labels.
236
- *
237
- * @param {SandboxFilter} filter - Filter for Sandboxes
238
- * @returns {Promise<Sandbox>} First Sandbox that matches the ID or labels.
239
- *
240
- * @example
241
- * const sandbox = await daytona.findOne({ labels: { 'my-label': 'my-value' } });
242
- * console.log(`Sandbox: ${await sandbox.info()}`);
243
- */
244
- findOne(filter: SandboxFilter): Promise<Sandbox>;
245
- /**
246
- * Lists all Sandboxes filtered by labels.
247
- *
248
- * @param {Record<string, string>} [labels] - Labels to filter Sandboxes
249
- * @returns {Promise<Sandbox[]>} Array of Sandboxes that match the labels.
250
- *
251
- * @example
252
- * const sandboxes = await daytona.list({ 'my-label': 'my-value' });
253
- * for (const sandbox of sandboxes) {
254
- * console.log(`${sandbox.id}: ${sandbox.instance.state}`);
255
- * }
256
- */
257
- list(labels?: Record<string, string>): Promise<Sandbox[]>;
258
- /**
259
- * Starts a Sandbox and waits for it to be ready.
260
- *
261
- * @param {Sandbox} sandbox - The Sandbox to start
262
- * @param {number} [timeout] - Optional timeout in seconds (0 means no timeout)
263
- * @returns {Promise<void>}
264
- *
265
- * @example
266
- * const sandbox = await daytona.get('my-sandbox-id');
267
- * // Wait up to 60 seconds for the sandbox to start
268
- * await daytona.start(sandbox, 60);
269
- */
270
- start(sandbox: Sandbox, timeout?: number): Promise<void>;
271
- /**
272
- * Stops a Sandbox.
273
- *
274
- * @param {Sandbox} sandbox - The Sandbox to stop
275
- * @returns {Promise<void>}
276
- *
277
- * @example
278
- * const sandbox = await daytona.get('my-sandbox-id');
279
- * await daytona.stop(sandbox);
280
- */
281
- stop(sandbox: Sandbox): Promise<void>;
282
- /**
283
- * Deletes a Sandbox.
284
- *
285
- * @param {Sandbox} sandbox - The Sandbox to delete
286
- * @param {number} timeout - Timeout in seconds (0 means no timeout, default is 60)
287
- * @returns {Promise<void>}
288
- *
289
- * @example
290
- * const sandbox = await daytona.get('my-sandbox-id');
291
- * await daytona.delete(sandbox);
292
- */
293
- delete(sandbox: Sandbox, timeout?: number): Promise<void>;
294
- /** @hidden */
295
- remove: (sandbox: Sandbox, timeout?: number) => Promise<void>;
296
- /**
297
- * Gets the Sandbox by ID.
298
- *
299
- * @param {string} workspaceId - The ID of the Sandbox to retrieve
300
- * @returns {Promise<Workspace>} The Sandbox
301
- *
302
- * @deprecated Use `getCurrentSandbox` instead. This method will be removed in a future version.
303
- */
304
- getCurrentWorkspace(workspaceId: string): Promise<Workspace>;
305
- /**
306
- * Gets the Sandbox by ID.
307
- *
308
- * @param {string} sandboxId - The ID of the Sandbox to retrieve
309
- * @returns {Promise<Sandbox>} The Sandbox
310
- *
311
- * @example
312
- * const sandbox = await daytona.getCurrentSandbox('my-sandbox-id');
313
- * console.log(`Current sandbox state: ${sandbox.instance.state}`);
314
- */
315
- getCurrentSandbox(sandboxId: string): Promise<Sandbox>;
316
- /**
317
- * Gets the appropriate code toolbox based on language.
318
- *
319
- * @private
320
- * @param {CodeLanguage} [language] - Programming language for the toolbox
321
- * @returns {SandboxCodeToolbox} The appropriate code toolbox instance
322
- * @throws {DaytonaError} - `DaytonaError` - When an unsupported language is specified
323
- */
324
- private getCodeToolbox;
325
- }