@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/README.md DELETED
@@ -1,145 +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
- Daytona is Open Source under the [GNU AFFERO GENERAL PUBLIC LICENSE](LICENSE), and is the [copyright of its contributors](NOTICE). If you would like to contribute to the software, read the Developer Certificate of Origin Version 1.1 (https://developercertificate.org/). Afterwards, navigate to the [contributing guide](CONTRIBUTING.md) to get started.
package/dist/Image.d.ts DELETED
@@ -1,261 +0,0 @@
1
- declare const SUPPORTED_PYTHON_SERIES: readonly ["3.9", "3.10", "3.11", "3.12", "3.13"];
2
- type SupportedPythonSeries = (typeof SUPPORTED_PYTHON_SERIES)[number];
3
- /**
4
- * Represents a context file to be added to the image.
5
- *
6
- * @interface
7
- * @property {string} sourcePath - The path to the source file or directory.
8
- * @property {string} archivePath - The path inside the archive file in object storage.
9
- */
10
- export interface Context {
11
- sourcePath: string;
12
- archivePath?: string;
13
- }
14
- /**
15
- * Options for the pip install command.
16
- *
17
- * @interface
18
- * @property {string[]} findLinks - The find-links to use for the pip install command.
19
- * @property {string} indexUrl - The index URL to use for the pip install command.
20
- * @property {string[]} extraIndexUrls - The extra index URLs to use for the pip install command.
21
- * @property {boolean} pre - Whether to install pre-release versions.
22
- * @property {string} extraOptions - The extra options to use for the pip install command. Given string is passed directly to the pip install command.
23
- */
24
- export interface PipInstallOptions {
25
- findLinks?: string[];
26
- indexUrl?: string;
27
- extraIndexUrls?: string[];
28
- pre?: boolean;
29
- extraOptions?: string;
30
- }
31
- /**
32
- * Options for the pip install command from a pyproject.toml file.
33
- *
34
- * @interface
35
- * @property {string[]} optionalDependencies - The optional dependencies to install.
36
- *
37
- * @extends {PipInstallOptions}
38
- */
39
- export interface PyprojectOptions extends PipInstallOptions {
40
- optionalDependencies?: string[];
41
- }
42
- /**
43
- * Represents an image definition for a Daytona sandbox.
44
- * Do not construct this class directly. Instead use one of its static factory methods,
45
- * such as `Image.base()`, `Image.debianSlim()` or `Image.fromDockerfile()`.
46
- *
47
- * @class
48
- * @property {string} dockerfile - The Dockerfile content.
49
- * @property {Context[]} contextList - The list of context files to be added to the image.
50
- */
51
- export declare class Image {
52
- private _dockerfile;
53
- private _contextList;
54
- private constructor();
55
- get dockerfile(): string;
56
- get contextList(): Context[];
57
- /**
58
- * Adds commands to install packages using pip.
59
- *
60
- * @param {string | string[]} packages - The packages to install.
61
- * @param {Object} options - The options for the pip install command.
62
- * @param {string[]} options.findLinks - The find-links to use for the pip install command.
63
- * @returns {Image} The Image instance.
64
- *
65
- * @example
66
- * const image = Image.debianSlim('3.12').pipInstall('numpy', { findLinks: ['https://pypi.org/simple'] })
67
- */
68
- pipInstall(packages: string | string[], options?: PipInstallOptions): Image;
69
- /**
70
- * Installs dependencies from a requirements.txt file.
71
- *
72
- * @param {string} requirementsTxt - The path to the requirements.txt file.
73
- * @param {PipInstallOptions} options - The options for the pip install command.
74
- * @returns {Image} The Image instance.
75
- *
76
- * @example
77
- * const image = Image.debianSlim('3.12')
78
- * image.pipInstallFromRequirements('requirements.txt', { findLinks: ['https://pypi.org/simple'] })
79
- */
80
- pipInstallFromRequirements(requirementsTxt: string, options?: PipInstallOptions): Image;
81
- /**
82
- * Installs dependencies from a pyproject.toml file.
83
- *
84
- * @param {string} pyprojectToml - The path to the pyproject.toml file.
85
- * @param {PyprojectOptions} options - The options for the pip install command.
86
- * @returns {Image} The Image instance.
87
- *
88
- * @example
89
- * const image = Image.debianSlim('3.12')
90
- * image.pipInstallFromPyproject('pyproject.toml', { optionalDependencies: ['dev'] })
91
- */
92
- pipInstallFromPyproject(pyprojectToml: string, options?: PyprojectOptions): Image;
93
- /**
94
- * Adds a local file to the image.
95
- *
96
- * @param {string} localPath - The path to the local file.
97
- * @param {string} remotePath - The path of the file in the image.
98
- * @returns {Image} The Image instance.
99
- *
100
- * @example
101
- * const image = Image
102
- * .debianSlim('3.12')
103
- * .addLocalFile('requirements.txt', '/home/daytona/requirements.txt')
104
- */
105
- addLocalFile(localPath: string, remotePath: string): Image;
106
- /**
107
- * Adds a local directory to the image.
108
- *
109
- * @param {string} localPath - The path to the local directory.
110
- * @param {string} remotePath - The path of the directory in the image.
111
- * @returns {Image} The Image instance.
112
- *
113
- * @example
114
- * const image = Image
115
- * .debianSlim('3.12')
116
- * .addLocalDir('src', '/home/daytona/src')
117
- */
118
- addLocalDir(localPath: string, remotePath: string): Image;
119
- /**
120
- * Runs commands in the image.
121
- *
122
- * @param {string | string[]} commands - The commands to run.
123
- * @returns {Image} The Image instance.
124
- *
125
- * @example
126
- * const image = Image
127
- * .debianSlim('3.12')
128
- * .runCommands('echo "Hello, world!"')
129
- */
130
- runCommands(...commands: (string | string[])[]): Image;
131
- /**
132
- * Sets environment variables in the image.
133
- *
134
- * @param {Record<string, string>} envVars - The environment variables to set.
135
- * @returns {Image} The Image instance.
136
- *
137
- * @example
138
- * const image = Image
139
- * .debianSlim('3.12')
140
- * .env({ FOO: 'bar' })
141
- */
142
- env(envVars: Record<string, string>): Image;
143
- /**
144
- * Sets the working directory in the image.
145
- *
146
- * @param {string} dirPath - The path to the working directory.
147
- * @returns {Image} The Image instance.
148
- *
149
- * @example
150
- * const image = Image
151
- * .debianSlim('3.12')
152
- * .workdir('/home/daytona')
153
- */
154
- workdir(dirPath: string): Image;
155
- /**
156
- * Sets the entrypoint for the image.
157
- *
158
- * @param {string[]} entrypointCommands - The commands to set as the entrypoint.
159
- * @returns {Image} The Image instance.
160
- *
161
- * @example
162
- * const image = Image
163
- * .debianSlim('3.12')
164
- * .entrypoint(['/bin/bash'])
165
- */
166
- entrypoint(entrypointCommands: string[]): Image;
167
- /**
168
- * Sets the default command for the image.
169
- *
170
- * @param {string[]} cmd - The command to set as the default command.
171
- * @returns {Image} The Image instance.
172
- *
173
- * @example
174
- * const image = Image
175
- * .debianSlim('3.12')
176
- * .cmd(['/bin/bash'])
177
- */
178
- cmd(cmd: string[]): Image;
179
- /**
180
- * Extends an image with arbitrary Dockerfile-like commands.
181
- *
182
- * @param {string | string[]} dockerfileCommands - The commands to add to the Dockerfile.
183
- * @param {string} contextDir - The path to the context directory.
184
- * @returns {Image} The Image instance.
185
- *
186
- * @example
187
- * const image = Image
188
- * .debianSlim('3.12')
189
- * .dockerfileCommands(['RUN echo "Hello, world!"'])
190
- */
191
- dockerfileCommands(dockerfileCommands: (string | string[])[], contextDir?: string): Image;
192
- /**
193
- * Creates an Image from an existing Dockerfile.
194
- *
195
- * @param {string} path - The path to the Dockerfile.
196
- * @returns {Image} The Image instance.
197
- *
198
- * @example
199
- * const image = Image.fromDockerfile('Dockerfile')
200
- */
201
- static fromDockerfile(path: string): Image;
202
- /**
203
- * Creates an Image from an existing base image.
204
- *
205
- * @param {string} image - The base image to use.
206
- * @returns {Image} The Image instance.
207
- *
208
- * @example
209
- * const image = Image.base('python:3.12-slim-bookworm')
210
- */
211
- static base(image: string): Image;
212
- /**
213
- * Creates a Debian slim image based on the official Python Docker image.
214
- *
215
- * @param {string} pythonVersion - The Python version to use.
216
- * @returns {Image} The Image instance.
217
- *
218
- * @example
219
- * const image = Image.debianSlim('3.12')
220
- */
221
- static debianSlim(pythonVersion?: SupportedPythonSeries): Image;
222
- /**
223
- * Formats pip install arguments in a single string.
224
- *
225
- * @param {PipInstallOptions} options - The options for the pip install command.
226
- * @returns {string} The formatted pip install arguments.
227
- */
228
- private formatPipInstallArgs;
229
- /**
230
- * Flattens a string argument.
231
- *
232
- * @param {string} functionName - The name of the function.
233
- * @param {string} argName - The name of the argument.
234
- * @param {any} args - The argument to flatten.
235
- * @returns {string[]} The flattened argument.
236
- */
237
- private flattenStringArgs;
238
- /**
239
- * Processes the Python version.
240
- *
241
- * @param {string} pythonVersion - The Python version to use.
242
- * @returns {string} The processed Python version.
243
- */
244
- private static processPythonVersion;
245
- /**
246
- * Extracts source files from COPY commands in a Dockerfile.
247
- *
248
- * @param {string} dockerfileContent - The content of the Dockerfile.
249
- * @param {string} pathPrefix - The path prefix to use for the sources.
250
- * @returns {Array<[string, string]>} The list of the actual file path and its corresponding COPY-command source path.
251
- */
252
- private static extractCopySources;
253
- /**
254
- * Parses a COPY command to extract sources and destination.
255
- *
256
- * @param {string} line - The line to parse.
257
- * @returns {Object} The parsed sources and destination.
258
- */
259
- private static parseCopyCommand;
260
- }
261
- export {};