@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.
- package/LICENSE +190 -0
- package/cjs/CodeInterpreter.d.ts +95 -0
- package/cjs/CodeInterpreter.d.ts.map +1 -0
- package/cjs/CodeInterpreter.js +297 -0
- package/cjs/CodeInterpreter.js.map +1 -0
- package/cjs/ComputerUse.d.ts +539 -0
- package/cjs/ComputerUse.d.ts.map +1 -0
- package/cjs/ComputerUse.js +808 -0
- package/cjs/ComputerUse.js.map +1 -0
- package/cjs/Daytona.d.ts +355 -0
- package/cjs/Daytona.d.ts.map +1 -0
- package/cjs/Daytona.js +527 -0
- package/cjs/Daytona.js.map +1 -0
- package/cjs/FileSystem.d.ts +371 -0
- package/cjs/FileSystem.d.ts.map +1 -0
- package/cjs/FileSystem.js +489 -0
- package/cjs/FileSystem.js.map +1 -0
- package/cjs/Git.d.ts +203 -0
- package/cjs/Git.d.ts.map +1 -0
- package/cjs/Git.js +326 -0
- package/cjs/Git.js.map +1 -0
- package/cjs/Image.d.ts +265 -0
- package/cjs/Image.d.ts.map +1 -0
- package/cjs/Image.js +586 -0
- package/cjs/Image.js.map +1 -0
- package/cjs/LspServer.d.ts +172 -0
- package/cjs/LspServer.d.ts.map +1 -0
- package/cjs/LspServer.js +259 -0
- package/cjs/LspServer.js.map +1 -0
- package/cjs/ObjectStorage.d.ts +79 -0
- package/cjs/ObjectStorage.d.ts.map +1 -0
- package/cjs/ObjectStorage.js +199 -0
- package/cjs/ObjectStorage.js.map +1 -0
- package/cjs/Process.d.ts +490 -0
- package/cjs/Process.d.ts.map +1 -0
- package/cjs/Process.js +647 -0
- package/cjs/Process.js.map +1 -0
- package/cjs/PtyHandle.d.ts +155 -0
- package/cjs/PtyHandle.d.ts.map +1 -0
- package/cjs/PtyHandle.js +416 -0
- package/cjs/PtyHandle.js.map +1 -0
- package/cjs/README.md +180 -0
- package/cjs/Sandbox.d.ts +476 -0
- package/cjs/Sandbox.d.ts.map +1 -0
- package/cjs/Sandbox.js +905 -0
- package/cjs/Sandbox.js.map +1 -0
- package/cjs/Snapshot.d.ts +140 -0
- package/cjs/Snapshot.d.ts.map +1 -0
- package/cjs/Snapshot.js +248 -0
- package/cjs/Snapshot.js.map +1 -0
- package/cjs/Volume.d.ts +84 -0
- package/cjs/Volume.d.ts.map +1 -0
- package/cjs/Volume.js +119 -0
- package/cjs/Volume.js.map +1 -0
- package/cjs/__tests__/helpers.d.ts +6 -0
- package/cjs/__tests__/helpers.d.ts.map +1 -0
- package/cjs/__tests__/helpers.js +26 -0
- package/cjs/__tests__/helpers.js.map +1 -0
- package/cjs/errors/DaytonaError.d.ts +171 -0
- package/cjs/errors/DaytonaError.d.ts.map +1 -0
- package/cjs/errors/DaytonaError.js +258 -0
- package/cjs/errors/DaytonaError.js.map +1 -0
- package/cjs/index.d.ts +22 -0
- package/cjs/index.d.ts.map +1 -0
- package/cjs/index.js +49 -0
- package/cjs/index.js.map +1 -0
- package/cjs/package.json +3 -0
- package/cjs/types/Charts.d.ts +38 -0
- package/cjs/types/Charts.d.ts.map +1 -0
- package/cjs/types/Charts.js +37 -0
- package/cjs/types/Charts.js.map +1 -0
- package/cjs/types/CodeInterpreter.d.ts +77 -0
- package/cjs/types/CodeInterpreter.d.ts.map +1 -0
- package/cjs/types/CodeInterpreter.js +7 -0
- package/cjs/types/CodeInterpreter.js.map +1 -0
- package/cjs/types/ExecuteResponse.d.ts +26 -0
- package/cjs/types/ExecuteResponse.d.ts.map +1 -0
- package/cjs/types/ExecuteResponse.js +7 -0
- package/cjs/types/ExecuteResponse.js.map +1 -0
- package/cjs/types/Pty.d.ts +48 -0
- package/cjs/types/Pty.d.ts.map +1 -0
- package/cjs/types/Pty.js +7 -0
- package/cjs/types/Pty.js.map +1 -0
- package/cjs/utils/Binary.d.ts +39 -0
- package/cjs/utils/Binary.d.ts.map +1 -0
- package/cjs/utils/Binary.js +168 -0
- package/cjs/utils/Binary.js.map +1 -0
- package/cjs/utils/FileTransfer.d.ts +15 -0
- package/cjs/utils/FileTransfer.d.ts.map +1 -0
- package/cjs/utils/FileTransfer.js +261 -0
- package/cjs/utils/FileTransfer.js.map +1 -0
- package/cjs/utils/Import.d.ts +125 -0
- package/cjs/utils/Import.d.ts.map +1 -0
- package/cjs/utils/Import.js +112 -0
- package/cjs/utils/Import.js.map +1 -0
- package/cjs/utils/Multipart.d.ts +29 -0
- package/cjs/utils/Multipart.d.ts.map +1 -0
- package/cjs/utils/Multipart.js +115 -0
- package/cjs/utils/Multipart.js.map +1 -0
- package/cjs/utils/Runtime.d.ts +44 -0
- package/cjs/utils/Runtime.d.ts.map +1 -0
- package/cjs/utils/Runtime.js +95 -0
- package/cjs/utils/Runtime.js.map +1 -0
- package/cjs/utils/Stream.d.ts +20 -0
- package/cjs/utils/Stream.d.ts.map +1 -0
- package/cjs/utils/Stream.js +364 -0
- package/cjs/utils/Stream.js.map +1 -0
- package/cjs/utils/WebSocket.d.ts +10 -0
- package/cjs/utils/WebSocket.d.ts.map +1 -0
- package/cjs/utils/WebSocket.js +26 -0
- package/cjs/utils/WebSocket.js.map +1 -0
- package/cjs/utils/otel.decorator.d.ts +83 -0
- package/cjs/utils/otel.decorator.d.ts.map +1 -0
- package/cjs/utils/otel.decorator.js +141 -0
- package/cjs/utils/otel.decorator.js.map +1 -0
- package/esm/CodeInterpreter.d.ts +95 -0
- package/esm/CodeInterpreter.d.ts.map +1 -0
- package/esm/CodeInterpreter.js +292 -0
- package/esm/CodeInterpreter.js.map +1 -0
- package/esm/ComputerUse.d.ts +539 -0
- package/esm/ComputerUse.d.ts.map +1 -0
- package/esm/ComputerUse.js +799 -0
- package/esm/ComputerUse.js.map +1 -0
- package/esm/Daytona.d.ts +355 -0
- package/esm/Daytona.d.ts.map +1 -0
- package/esm/Daytona.js +523 -0
- package/esm/Daytona.js.map +1 -0
- package/esm/FileSystem.d.ts +371 -0
- package/esm/FileSystem.d.ts.map +1 -0
- package/esm/FileSystem.js +485 -0
- package/esm/FileSystem.js.map +1 -0
- package/esm/Git.d.ts +203 -0
- package/esm/Git.d.ts.map +1 -0
- package/esm/Git.js +322 -0
- package/esm/Git.js.map +1 -0
- package/esm/Image.d.ts +265 -0
- package/esm/Image.d.ts.map +1 -0
- package/esm/Image.js +581 -0
- package/esm/Image.js.map +1 -0
- package/esm/LspServer.d.ts +172 -0
- package/esm/LspServer.d.ts.map +1 -0
- package/esm/LspServer.js +255 -0
- package/esm/LspServer.js.map +1 -0
- package/esm/ObjectStorage.d.ts +79 -0
- package/esm/ObjectStorage.d.ts.map +1 -0
- package/esm/ObjectStorage.js +195 -0
- package/esm/ObjectStorage.js.map +1 -0
- package/esm/Process.d.ts +490 -0
- package/esm/Process.d.ts.map +1 -0
- package/esm/Process.js +642 -0
- package/esm/Process.js.map +1 -0
- package/esm/PtyHandle.d.ts +155 -0
- package/esm/PtyHandle.d.ts.map +1 -0
- package/esm/PtyHandle.js +412 -0
- package/esm/PtyHandle.js.map +1 -0
- package/esm/README.md +180 -0
- package/esm/Sandbox.d.ts +476 -0
- package/esm/Sandbox.d.ts.map +1 -0
- package/esm/Sandbox.js +901 -0
- package/esm/Sandbox.js.map +1 -0
- package/esm/Snapshot.d.ts +140 -0
- package/esm/Snapshot.d.ts.map +1 -0
- package/esm/Snapshot.js +244 -0
- package/esm/Snapshot.js.map +1 -0
- package/esm/Volume.d.ts +84 -0
- package/esm/Volume.d.ts.map +1 -0
- package/esm/Volume.js +115 -0
- package/esm/Volume.js.map +1 -0
- package/esm/__tests__/helpers.d.ts +6 -0
- package/esm/__tests__/helpers.d.ts.map +1 -0
- package/esm/__tests__/helpers.js +20 -0
- package/esm/__tests__/helpers.js.map +1 -0
- package/esm/errors/DaytonaError.d.ts +171 -0
- package/esm/errors/DaytonaError.d.ts.map +1 -0
- package/esm/errors/DaytonaError.js +243 -0
- package/esm/errors/DaytonaError.js.map +1 -0
- package/esm/index.d.ts +22 -0
- package/esm/index.d.ts.map +1 -0
- package/esm/index.js +21 -0
- package/esm/index.js.map +1 -0
- package/esm/package.json +3 -0
- package/esm/types/Charts.d.ts +38 -0
- package/esm/types/Charts.d.ts.map +1 -0
- package/esm/types/Charts.js +33 -0
- package/esm/types/Charts.js.map +1 -0
- package/esm/types/CodeInterpreter.d.ts +77 -0
- package/esm/types/CodeInterpreter.d.ts.map +1 -0
- package/esm/types/CodeInterpreter.js +6 -0
- package/esm/types/CodeInterpreter.js.map +1 -0
- package/esm/types/ExecuteResponse.d.ts +26 -0
- package/esm/types/ExecuteResponse.d.ts.map +1 -0
- package/esm/types/ExecuteResponse.js +6 -0
- package/esm/types/ExecuteResponse.js.map +1 -0
- package/esm/types/Pty.d.ts +48 -0
- package/esm/types/Pty.d.ts.map +1 -0
- package/esm/types/Pty.js +6 -0
- package/esm/types/Pty.js.map +1 -0
- package/esm/utils/Binary.d.ts +39 -0
- package/esm/utils/Binary.d.ts.map +1 -0
- package/esm/utils/Binary.js +157 -0
- package/esm/utils/Binary.js.map +1 -0
- package/esm/utils/FileTransfer.d.ts +15 -0
- package/esm/utils/FileTransfer.d.ts.map +1 -0
- package/esm/utils/FileTransfer.js +254 -0
- package/esm/utils/FileTransfer.js.map +1 -0
- package/esm/utils/Import.d.ts +95 -0
- package/esm/utils/Import.d.ts.map +1 -0
- package/esm/utils/Import.js +77 -0
- package/esm/utils/Import.js.map +1 -0
- package/esm/utils/Multipart.d.ts +29 -0
- package/esm/utils/Multipart.d.ts.map +1 -0
- package/esm/utils/Multipart.js +109 -0
- package/esm/utils/Multipart.js.map +1 -0
- package/esm/utils/Runtime.d.ts +44 -0
- package/esm/utils/Runtime.d.ts.map +1 -0
- package/esm/utils/Runtime.js +89 -0
- package/esm/utils/Runtime.js.map +1 -0
- package/esm/utils/Stream.d.ts +20 -0
- package/esm/utils/Stream.d.ts.map +1 -0
- package/esm/utils/Stream.js +360 -0
- package/esm/utils/Stream.js.map +1 -0
- package/esm/utils/WebSocket.d.ts +10 -0
- package/esm/utils/WebSocket.d.ts.map +1 -0
- package/esm/utils/WebSocket.js +22 -0
- package/esm/utils/WebSocket.js.map +1 -0
- package/esm/utils/otel.decorator.d.ts +83 -0
- package/esm/utils/otel.decorator.d.ts.map +1 -0
- package/esm/utils/otel.decorator.js +136 -0
- package/esm/utils/otel.decorator.js.map +1 -0
- package/package.json +20 -8
- package/src/ComputerUse.d.ts +4 -4
- package/src/ComputerUse.js +4 -4
- package/src/Sandbox.d.ts +1 -18
- package/src/Sandbox.js +0 -29
- package/src/Sandbox.js.map +1 -1
- package/src/__tests__/helpers.js +0 -2
- package/src/__tests__/helpers.js.map +1 -1
package/esm/README.md
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
# Daytona TypeScript SDK
|
|
2
|
+
|
|
3
|
+
The official TypeScript SDK for [Daytona](https://daytona.io), an open-source, secure and elastic infrastructure for running AI-generated code. Daytona provides full composable computers — [sandboxes](https://www.daytona.io/docs/en/sandboxes/) — that you can manage programmatically using the Daytona SDK.
|
|
4
|
+
|
|
5
|
+
The SDK provides an interface for sandbox management, file system operations, Git operations, language server protocol support, process and code execution, and computer use. For more information, see the [documentation](https://www.daytona.io/docs/en/typescript-sdk/).
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
Install the package using **npm**:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @daytona/sdk
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
or using **yarn**:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
yarn add @daytona/sdk
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Get API key
|
|
22
|
+
|
|
23
|
+
Generate an API key from the [Daytona Dashboard ↗](https://app.daytona.io/dashboard/keys) to authenticate SDK requests and access Daytona services. For more information, see the [API keys](https://www.daytona.io/docs/en/api-keys/) documentation.
|
|
24
|
+
|
|
25
|
+
## Configuration
|
|
26
|
+
|
|
27
|
+
Configure the SDK using [environment variables](https://www.daytona.io/docs/en/configuration/#environment-variables) or by passing a [configuration object](https://www.daytona.io/docs/en/configuration/#configuration-in-code):
|
|
28
|
+
|
|
29
|
+
- `DAYTONA_API_KEY`: Your Daytona [API key](https://www.daytona.io/docs/en/api-keys/)
|
|
30
|
+
- `DAYTONA_API_URL`: The Daytona [API URL](https://www.daytona.io/docs/en/tools/api/)
|
|
31
|
+
- `DAYTONA_TARGET`: Your target [region](https://www.daytona.io/docs/en/regions/) environment (e.g. `us`, `eu`)
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
import { Daytona } from '@daytona/sdk'
|
|
35
|
+
|
|
36
|
+
// Initialize with environment variables
|
|
37
|
+
const daytona = new Daytona();
|
|
38
|
+
|
|
39
|
+
// Initialize with configuration object
|
|
40
|
+
const daytona = new Daytona({
|
|
41
|
+
apiKey: 'YOUR_API_KEY',
|
|
42
|
+
apiUrl: 'YOUR_API_URL',
|
|
43
|
+
target: 'us',
|
|
44
|
+
});
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Create a sandbox
|
|
48
|
+
|
|
49
|
+
Create a sandbox to run your code securely in an isolated environment.
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
import { Daytona } from '@daytona/sdk'
|
|
53
|
+
|
|
54
|
+
const daytona = new Daytona({apiKey: "YOUR_API_KEY"});
|
|
55
|
+
const sandbox = await daytona.create({
|
|
56
|
+
language: 'typescript'
|
|
57
|
+
});
|
|
58
|
+
const response = await sandbox.process.codeRun('console.log("Hello World!")');
|
|
59
|
+
console.log(response.result);
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Examples and guides
|
|
63
|
+
|
|
64
|
+
Daytona provides [examples](https://www.daytona.io/docs/en/getting-started/#examples) and [guides](https://www.daytona.io/docs/en/guides/) for common sandbox operations, best practices, and a wide range of topics, from basic usage to advanced topics, showcasing various types of integrations between Daytona and other tools.
|
|
65
|
+
|
|
66
|
+
### Create a sandbox with custom resources
|
|
67
|
+
|
|
68
|
+
Create a sandbox with [custom resources](https://www.daytona.io/docs/en/sandboxes/#resources) (CPU, memory, disk).
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
import { Daytona, Image } from '@daytona/sdk';
|
|
72
|
+
|
|
73
|
+
const daytona = new Daytona();
|
|
74
|
+
const sandbox = await daytona.create({
|
|
75
|
+
image: Image.debianSlim('3.12'),
|
|
76
|
+
resources: { cpu: 2, memory: 4, disk: 8 }
|
|
77
|
+
});
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Create an ephemeral sandbox
|
|
81
|
+
|
|
82
|
+
Create an [ephemeral sandbox](https://www.daytona.io/docs/en/sandboxes/#ephemeral-sandboxes) that is automatically deleted when stopped.
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
import { Daytona } from '@daytona/sdk';
|
|
86
|
+
|
|
87
|
+
const daytona = new Daytona();
|
|
88
|
+
const sandbox = await daytona.create({
|
|
89
|
+
ephemeral: true,
|
|
90
|
+
autoStopInterval: 5
|
|
91
|
+
});
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Create a sandbox from a snapshot
|
|
95
|
+
|
|
96
|
+
Create a sandbox from a [snapshot](https://www.daytona.io/docs/en/snapshots/).
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
import { Daytona } from '@daytona/sdk';
|
|
100
|
+
|
|
101
|
+
const daytona = new Daytona();
|
|
102
|
+
const sandbox = await daytona.create({
|
|
103
|
+
snapshot: 'my-snapshot-name',
|
|
104
|
+
language: 'typescript'
|
|
105
|
+
});
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Execute commands
|
|
109
|
+
|
|
110
|
+
Execute commands in the sandbox.
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
// Execute a shell command
|
|
114
|
+
const response = await sandbox.process.executeCommand('echo "Hello, World!"')
|
|
115
|
+
console.log(response.result)
|
|
116
|
+
|
|
117
|
+
// Run TypeScript code
|
|
118
|
+
const response = await sandbox.process.codeRun(`
|
|
119
|
+
const x = 10
|
|
120
|
+
const y = 20
|
|
121
|
+
console.log(\`Sum: \${x + y}\`)
|
|
122
|
+
`)
|
|
123
|
+
console.log(response.result)
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### File operations
|
|
127
|
+
|
|
128
|
+
Upload, download, and search files in the sandbox.
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
// Upload a file
|
|
132
|
+
await sandbox.fs.uploadFile(Buffer.from('Hello, World!'), 'path/to/file.txt')
|
|
133
|
+
|
|
134
|
+
// Download a file
|
|
135
|
+
const content = await sandbox.fs.downloadFile('path/to/file.txt')
|
|
136
|
+
|
|
137
|
+
// Search for files
|
|
138
|
+
const matches = await sandbox.fs.findFiles(root_dir, 'search_pattern')
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Git operations
|
|
142
|
+
|
|
143
|
+
Clone, list branches, and add files to the sandbox.
|
|
144
|
+
|
|
145
|
+
```typescript
|
|
146
|
+
// Clone a repository
|
|
147
|
+
await sandbox.git.clone('https://github.com/example/repo', 'path/to/clone')
|
|
148
|
+
|
|
149
|
+
// List branches
|
|
150
|
+
const branches = await sandbox.git.branches('path/to/repo')
|
|
151
|
+
|
|
152
|
+
// Add files
|
|
153
|
+
await sandbox.git.add('path/to/repo', ['file1.txt', 'file2.txt'])
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### Language server protocol
|
|
157
|
+
|
|
158
|
+
Create and start a language server to get code completions, document symbols, and more.
|
|
159
|
+
|
|
160
|
+
```typescript
|
|
161
|
+
// Create and start a language server
|
|
162
|
+
const lsp = await sandbox.createLspServer('typescript', 'path/to/project')
|
|
163
|
+
await lsp.start()
|
|
164
|
+
|
|
165
|
+
// Notify the lsp for the file
|
|
166
|
+
await lsp.didOpen('path/to/file.ts')
|
|
167
|
+
|
|
168
|
+
// Get document symbols
|
|
169
|
+
const symbols = await lsp.documentSymbols('path/to/file.ts')
|
|
170
|
+
|
|
171
|
+
// Get completions
|
|
172
|
+
const completions = await lsp.completions('path/to/file.ts', {
|
|
173
|
+
line: 10,
|
|
174
|
+
character: 15,
|
|
175
|
+
})
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## Contributing
|
|
179
|
+
|
|
180
|
+
Daytona is Open Source under the [Apache License 2.0](./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/esm/Sandbox.d.ts
ADDED
|
@@ -0,0 +1,476 @@
|
|
|
1
|
+
import { SandboxState, SandboxApi, Sandbox as SandboxDto, PaginatedSandboxes as PaginatedSandboxesDto, PortPreviewUrl, SandboxVolume, BuildInfo, SandboxBackupStateEnum, Configuration, SshAccessDto, SshAccessValidationDto, SignedPortPreviewUrl, UpdateSandboxNetworkSettings } from '@daytona/api-client';
|
|
2
|
+
import { Resources } from './Daytona.js';
|
|
3
|
+
import { FileSystem } from './FileSystem.js';
|
|
4
|
+
import { Git } from './Git.js';
|
|
5
|
+
import { Process } from './Process.js';
|
|
6
|
+
import { LspLanguageId, LspServer } from './LspServer.js';
|
|
7
|
+
import { ComputerUse } from './ComputerUse.js';
|
|
8
|
+
import { AxiosInstance } from 'axios';
|
|
9
|
+
import { CodeInterpreter } from './CodeInterpreter.js';
|
|
10
|
+
/**
|
|
11
|
+
* Represents a Daytona Sandbox.
|
|
12
|
+
*
|
|
13
|
+
* @property {FileSystem} fs - File system operations interface
|
|
14
|
+
* @property {Git} git - Git operations interface
|
|
15
|
+
* @property {Process} process - Process execution interface
|
|
16
|
+
* @property {CodeInterpreter} codeInterpreter - Stateful interpreter interface for executing code.
|
|
17
|
+
* Currently supports only Python. For other languages, use the `process.codeRun` method.
|
|
18
|
+
* @property {ComputerUse} computerUse - Computer use operations interface for desktop automation
|
|
19
|
+
* @property {string} id - Unique identifier for the Sandbox
|
|
20
|
+
* @property {string} organizationId - Organization ID of the Sandbox
|
|
21
|
+
* @property {string} [snapshot] - Daytona snapshot used to create the Sandbox
|
|
22
|
+
* @property {string} user - OS user running in the Sandbox
|
|
23
|
+
* @property {Record<string, string>} env - Environment variables set in the Sandbox
|
|
24
|
+
* @property {Record<string, string>} labels - Custom labels attached to the Sandbox
|
|
25
|
+
* @property {boolean} public - Whether the Sandbox is publicly accessible
|
|
26
|
+
* @property {string} target - Target location of the runner where the Sandbox runs
|
|
27
|
+
* @property {number} cpu - Number of CPUs allocated to the Sandbox
|
|
28
|
+
* @property {number} gpu - Number of GPUs allocated to the Sandbox
|
|
29
|
+
* @property {number} memory - Amount of memory allocated to the Sandbox in GiB
|
|
30
|
+
* @property {number} disk - Amount of disk space allocated to the Sandbox in GiB
|
|
31
|
+
* @property {SandboxState} state - Current state of the Sandbox (e.g., "started", "stopped")
|
|
32
|
+
* @property {string} [errorReason] - Error message if Sandbox is in error state
|
|
33
|
+
* @property {boolean} [recoverable] - Whether the Sandbox error is recoverable.
|
|
34
|
+
* @property {SandboxBackupStateEnum} [backupState] - Current state of Sandbox backup
|
|
35
|
+
* @property {string} [backupCreatedAt] - When the backup was created
|
|
36
|
+
* @property {number} [autoStopInterval] - Auto-stop interval in minutes
|
|
37
|
+
* @property {number} [autoArchiveInterval] - Auto-archive interval in minutes
|
|
38
|
+
* @property {number} [autoDeleteInterval] - Auto-delete interval in minutes
|
|
39
|
+
* @property {Array<SandboxVolume>} [volumes] - Volumes attached to the Sandbox
|
|
40
|
+
* @property {BuildInfo} [buildInfo] - Build information for the Sandbox if it was created from dynamic build
|
|
41
|
+
* @property {string} [createdAt] - When the Sandbox was created
|
|
42
|
+
* @property {string} [updatedAt] - When the Sandbox was last updated
|
|
43
|
+
* @property {string} [lastActivityAt] - When the Sandbox last had activity
|
|
44
|
+
* @property {boolean} networkBlockAll - Whether to block all network access for the Sandbox
|
|
45
|
+
* @property {string} [networkAllowList] - Comma-separated list of allowed CIDR network addresses for the Sandbox
|
|
46
|
+
*
|
|
47
|
+
* @class
|
|
48
|
+
*/
|
|
49
|
+
export declare class Sandbox implements SandboxDto {
|
|
50
|
+
private readonly clientConfig;
|
|
51
|
+
private readonly axiosInstance;
|
|
52
|
+
private readonly sandboxApi;
|
|
53
|
+
readonly fs: FileSystem;
|
|
54
|
+
readonly git: Git;
|
|
55
|
+
readonly process: Process;
|
|
56
|
+
readonly computerUse: ComputerUse;
|
|
57
|
+
readonly codeInterpreter: CodeInterpreter;
|
|
58
|
+
id: string;
|
|
59
|
+
name: string;
|
|
60
|
+
organizationId: string;
|
|
61
|
+
snapshot?: string;
|
|
62
|
+
user: string;
|
|
63
|
+
env: Record<string, string>;
|
|
64
|
+
labels: Record<string, string>;
|
|
65
|
+
public: boolean;
|
|
66
|
+
target: string;
|
|
67
|
+
cpu: number;
|
|
68
|
+
gpu: number;
|
|
69
|
+
memory: number;
|
|
70
|
+
disk: number;
|
|
71
|
+
state?: SandboxState;
|
|
72
|
+
errorReason?: string;
|
|
73
|
+
recoverable?: boolean;
|
|
74
|
+
backupState?: SandboxBackupStateEnum;
|
|
75
|
+
backupCreatedAt?: string;
|
|
76
|
+
autoStopInterval?: number;
|
|
77
|
+
autoArchiveInterval?: number;
|
|
78
|
+
autoDeleteInterval?: number;
|
|
79
|
+
volumes?: Array<SandboxVolume>;
|
|
80
|
+
buildInfo?: BuildInfo;
|
|
81
|
+
createdAt?: string;
|
|
82
|
+
updatedAt?: string;
|
|
83
|
+
lastActivityAt?: string;
|
|
84
|
+
networkBlockAll: boolean;
|
|
85
|
+
networkAllowList?: string;
|
|
86
|
+
toolboxProxyUrl: string;
|
|
87
|
+
private infoApi;
|
|
88
|
+
/**
|
|
89
|
+
* Creates a new Sandbox instance
|
|
90
|
+
*
|
|
91
|
+
* @param {SandboxDto} sandboxDto - The API Sandbox instance
|
|
92
|
+
*/
|
|
93
|
+
constructor(sandboxDto: SandboxDto, clientConfig: Configuration, axiosInstance: AxiosInstance, sandboxApi: SandboxApi);
|
|
94
|
+
/**
|
|
95
|
+
* Gets the user's home directory path for the logged in user inside the Sandbox.
|
|
96
|
+
*
|
|
97
|
+
* @returns {Promise<string | undefined>} The absolute path to the Sandbox user's home directory for the logged in user
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* const userHomeDir = await sandbox.getUserHomeDir();
|
|
101
|
+
* console.log(`Sandbox user home: ${userHomeDir}`);
|
|
102
|
+
*/
|
|
103
|
+
getUserHomeDir(): Promise<string | undefined>;
|
|
104
|
+
/**
|
|
105
|
+
* @deprecated Use `getUserHomeDir` instead. This method will be removed in a future version.
|
|
106
|
+
*/
|
|
107
|
+
getUserRootDir(): Promise<string | undefined>;
|
|
108
|
+
/**
|
|
109
|
+
* Gets the working directory path inside the Sandbox.
|
|
110
|
+
*
|
|
111
|
+
* @returns {Promise<string | undefined>} The absolute path to the Sandbox working directory. Uses the WORKDIR specified
|
|
112
|
+
* in the Dockerfile if present, or falling back to the user's home directory if not.
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* const workDir = await sandbox.getWorkDir();
|
|
116
|
+
* console.log(`Sandbox working directory: ${workDir}`);
|
|
117
|
+
*/
|
|
118
|
+
getWorkDir(): Promise<string | undefined>;
|
|
119
|
+
/**
|
|
120
|
+
* Creates a new Language Server Protocol (LSP) server instance.
|
|
121
|
+
*
|
|
122
|
+
* The LSP server provides language-specific features like code completion,
|
|
123
|
+
* diagnostics, and more.
|
|
124
|
+
*
|
|
125
|
+
* @param {LspLanguageId} languageId - The language server type (e.g., "typescript")
|
|
126
|
+
* @param {string} pathToProject - Path to the project root directory. Relative paths are resolved based on the sandbox working directory.
|
|
127
|
+
* @returns {LspServer} A new LSP server instance configured for the specified language
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* const lsp = await sandbox.createLspServer('typescript', 'workspace/project');
|
|
131
|
+
*/
|
|
132
|
+
createLspServer(languageId: LspLanguageId | string, pathToProject: string): Promise<LspServer>;
|
|
133
|
+
/**
|
|
134
|
+
* Sets labels for the Sandbox.
|
|
135
|
+
*
|
|
136
|
+
* Labels are key-value pairs that can be used to organize and identify Sandboxes.
|
|
137
|
+
*
|
|
138
|
+
* @param {Record<string, string>} labels - Dictionary of key-value pairs representing Sandbox labels
|
|
139
|
+
* @returns {Promise<void>}
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* // Set sandbox labels
|
|
143
|
+
* await sandbox.setLabels({
|
|
144
|
+
* project: 'my-project',
|
|
145
|
+
* environment: 'development',
|
|
146
|
+
* team: 'backend'
|
|
147
|
+
* });
|
|
148
|
+
*/
|
|
149
|
+
setLabels(labels: Record<string, string>): Promise<Record<string, string>>;
|
|
150
|
+
/**
|
|
151
|
+
* Start the Sandbox.
|
|
152
|
+
*
|
|
153
|
+
* This method starts the Sandbox and waits for it to be ready.
|
|
154
|
+
*
|
|
155
|
+
* @param {number} [timeout] - Maximum time to wait in seconds. 0 means no timeout.
|
|
156
|
+
* Defaults to 60-second timeout.
|
|
157
|
+
* @returns {Promise<void>}
|
|
158
|
+
* @throws {DaytonaError} - `DaytonaError` - If Sandbox fails to start or times out
|
|
159
|
+
*
|
|
160
|
+
* @example
|
|
161
|
+
* const sandbox = await daytona.getCurrentSandbox('my-sandbox');
|
|
162
|
+
* await sandbox.start(40); // Wait up to 40 seconds
|
|
163
|
+
* console.log('Sandbox started successfully');
|
|
164
|
+
*/
|
|
165
|
+
start(timeout?: number): Promise<void>;
|
|
166
|
+
/**
|
|
167
|
+
* Recover the Sandbox from a recoverable error and wait for it to be ready.
|
|
168
|
+
*
|
|
169
|
+
* @param {number} [timeout] - Maximum time to wait in seconds. 0 means no timeout.
|
|
170
|
+
* Defaults to 60-second timeout.
|
|
171
|
+
* @returns {Promise<void>}
|
|
172
|
+
* @throws {DaytonaError} - `DaytonaError` - If Sandbox fails to recover or times out
|
|
173
|
+
*
|
|
174
|
+
* @example
|
|
175
|
+
* const sandbox = await daytona.get('my-sandbox-id');
|
|
176
|
+
* await sandbox.recover();
|
|
177
|
+
* console.log('Sandbox recovered successfully');
|
|
178
|
+
*/
|
|
179
|
+
recover(timeout?: number): Promise<void>;
|
|
180
|
+
/**
|
|
181
|
+
* Stops the Sandbox.
|
|
182
|
+
*
|
|
183
|
+
* This method stops the Sandbox and waits for it to be fully stopped.
|
|
184
|
+
*
|
|
185
|
+
* @param {number} [timeout] - Maximum time to wait in seconds. 0 means no timeout.
|
|
186
|
+
* Defaults to 60-second timeout.
|
|
187
|
+
* @param {boolean} [force] - If true, uses SIGKILL instead of SIGTERM. Defaults to false.
|
|
188
|
+
* @returns {Promise<void>}
|
|
189
|
+
*
|
|
190
|
+
* @example
|
|
191
|
+
* const sandbox = await daytona.get('my-sandbox-id');
|
|
192
|
+
* await sandbox.stop();
|
|
193
|
+
* console.log('Sandbox stopped successfully');
|
|
194
|
+
*/
|
|
195
|
+
stop(timeout?: number, force?: boolean): Promise<void>;
|
|
196
|
+
/**
|
|
197
|
+
* Forks the Sandbox, creating a new Sandbox with an identical filesystem.
|
|
198
|
+
*
|
|
199
|
+
* The forked Sandbox is a copy-on-write clone of the original. It starts
|
|
200
|
+
* with the same disk contents but operates independently from that point on.
|
|
201
|
+
*
|
|
202
|
+
* @param {object} [params] - Fork parameters
|
|
203
|
+
* @param {string} [params.name] - Optional name for the forked Sandbox. If not provided, a unique name will be generated.
|
|
204
|
+
* @param {number} [timeout] - Maximum time to wait in seconds. 0 means no timeout.
|
|
205
|
+
* Defaults to 60-second timeout.
|
|
206
|
+
* @returns {Promise<Sandbox>} The forked Sandbox.
|
|
207
|
+
* @throws {DaytonaValidationError} - If timeout is a negative number
|
|
208
|
+
* @throws {DaytonaError} - If the fork operation fails or times out
|
|
209
|
+
*
|
|
210
|
+
* @example
|
|
211
|
+
* const sandbox = await daytona.get('my-sandbox');
|
|
212
|
+
* const forked = await sandbox._experimental_fork({ name: 'my-fork' });
|
|
213
|
+
* console.log(`Forked sandbox: ${forked.id}`);
|
|
214
|
+
*/
|
|
215
|
+
_experimental_fork(params?: {
|
|
216
|
+
name?: string;
|
|
217
|
+
}, timeout?: number): Promise<Sandbox>;
|
|
218
|
+
/**
|
|
219
|
+
* Creates a snapshot from the current state of the Sandbox.
|
|
220
|
+
*
|
|
221
|
+
* This captures the Sandbox's filesystem into a reusable snapshot that can be
|
|
222
|
+
* used to create new Sandboxes. The Sandbox will temporarily enter a
|
|
223
|
+
* 'snapshotting' state and return to its previous state when complete.
|
|
224
|
+
*
|
|
225
|
+
* @param {string} name - Name for the new snapshot
|
|
226
|
+
* @param {number} [timeout] - Maximum time to wait in seconds. 0 means no timeout.
|
|
227
|
+
* Defaults to 60-second timeout.
|
|
228
|
+
* @returns {Promise<void>}
|
|
229
|
+
* @throws {DaytonaValidationError} - If timeout is a negative number
|
|
230
|
+
* @throws {DaytonaError} - If the snapshot operation fails or times out
|
|
231
|
+
*
|
|
232
|
+
* @example
|
|
233
|
+
* const sandbox = await daytona.get('my-sandbox');
|
|
234
|
+
* await sandbox._experimental_createSnapshot('my-snapshot');
|
|
235
|
+
* console.log('Snapshot created successfully');
|
|
236
|
+
*/
|
|
237
|
+
_experimental_createSnapshot(name: string, timeout?: number): Promise<void>;
|
|
238
|
+
private waitForSnapshotComplete;
|
|
239
|
+
/**
|
|
240
|
+
* Deletes the Sandbox.
|
|
241
|
+
* @returns {Promise<void>}
|
|
242
|
+
*/
|
|
243
|
+
delete(timeout?: number): Promise<void>;
|
|
244
|
+
/**
|
|
245
|
+
* Waits for the Sandbox to reach the 'started' state.
|
|
246
|
+
*
|
|
247
|
+
* This method polls the Sandbox status until it reaches the 'started' state
|
|
248
|
+
* or encounters an error.
|
|
249
|
+
*
|
|
250
|
+
* @param {number} [timeout] - Maximum time to wait in seconds. 0 means no timeout.
|
|
251
|
+
* Defaults to 60 seconds.
|
|
252
|
+
* @returns {Promise<void>}
|
|
253
|
+
* @throws {DaytonaError} - `DaytonaError` - If the sandbox ends up in an error state or fails to start within the timeout period.
|
|
254
|
+
*/
|
|
255
|
+
waitUntilStarted(timeout?: number): Promise<void>;
|
|
256
|
+
/**
|
|
257
|
+
* Wait for Sandbox to reach 'stopped' state.
|
|
258
|
+
*
|
|
259
|
+
* This method polls the Sandbox status until it reaches the 'stopped' state
|
|
260
|
+
* or encounters an error.
|
|
261
|
+
*
|
|
262
|
+
* @param {number} [timeout] - Maximum time to wait in seconds. 0 means no timeout.
|
|
263
|
+
* Defaults to 60 seconds.
|
|
264
|
+
* @returns {Promise<void>}
|
|
265
|
+
* @throws {DaytonaError} - `DaytonaError` - If the sandbox fails to stop within the timeout period.
|
|
266
|
+
*/
|
|
267
|
+
waitUntilStopped(timeout?: number): Promise<void>;
|
|
268
|
+
/**
|
|
269
|
+
* Refreshes the Sandbox data from the API.
|
|
270
|
+
*
|
|
271
|
+
* @returns {Promise<void>}
|
|
272
|
+
*
|
|
273
|
+
* @example
|
|
274
|
+
* await sandbox.refreshData();
|
|
275
|
+
* console.log(`Sandbox ${sandbox.id}:`);
|
|
276
|
+
* console.log(`State: ${sandbox.state}`);
|
|
277
|
+
* console.log(`Resources: ${sandbox.cpu} CPU, ${sandbox.memory} GiB RAM`);
|
|
278
|
+
*/
|
|
279
|
+
refreshData(): Promise<void>;
|
|
280
|
+
/**
|
|
281
|
+
* Refreshes the sandbox activity to reset the timer for automated lifecycle management actions.
|
|
282
|
+
*
|
|
283
|
+
* This method updates the sandbox's last activity timestamp without changing its state.
|
|
284
|
+
* It is useful for keeping long-running sessions alive while there is still user activity.
|
|
285
|
+
*
|
|
286
|
+
* @returns {Promise<void>}
|
|
287
|
+
*
|
|
288
|
+
* @example
|
|
289
|
+
* // Keep sandbox activity alive
|
|
290
|
+
* await sandbox.refreshActivity();
|
|
291
|
+
*/
|
|
292
|
+
refreshActivity(): Promise<void>;
|
|
293
|
+
/**
|
|
294
|
+
* Set the auto-stop interval for the Sandbox.
|
|
295
|
+
*
|
|
296
|
+
* The Sandbox will automatically stop after being idle (no new events) for the specified interval.
|
|
297
|
+
* Events include any state changes or interactions with the Sandbox through the sdk.
|
|
298
|
+
* Interactions using Sandbox Previews are not included.
|
|
299
|
+
*
|
|
300
|
+
* @param {number} interval - Number of minutes of inactivity before auto-stopping.
|
|
301
|
+
* Set to 0 to disable auto-stop. Default is 15 minutes.
|
|
302
|
+
* @returns {Promise<void>}
|
|
303
|
+
* @throws {DaytonaError} - `DaytonaError` - If interval is not a non-negative integer
|
|
304
|
+
*
|
|
305
|
+
* @example
|
|
306
|
+
* // Auto-stop after 1 hour
|
|
307
|
+
* await sandbox.setAutostopInterval(60);
|
|
308
|
+
* // Or disable auto-stop
|
|
309
|
+
* await sandbox.setAutostopInterval(0);
|
|
310
|
+
*/
|
|
311
|
+
setAutostopInterval(interval: number): Promise<void>;
|
|
312
|
+
/**
|
|
313
|
+
* Set the auto-archive interval for the Sandbox.
|
|
314
|
+
*
|
|
315
|
+
* The Sandbox will automatically archive after being continuously stopped for the specified interval.
|
|
316
|
+
*
|
|
317
|
+
* @param {number} interval - Number of minutes after which a continuously stopped Sandbox will be auto-archived.
|
|
318
|
+
* Set to 0 for the maximum interval. Default is 7 days.
|
|
319
|
+
* @returns {Promise<void>}
|
|
320
|
+
* @throws {DaytonaError} - `DaytonaError` - If interval is not a non-negative integer
|
|
321
|
+
*
|
|
322
|
+
* @example
|
|
323
|
+
* // Auto-archive after 1 hour
|
|
324
|
+
* await sandbox.setAutoArchiveInterval(60);
|
|
325
|
+
* // Or use the maximum interval
|
|
326
|
+
* await sandbox.setAutoArchiveInterval(0);
|
|
327
|
+
*/
|
|
328
|
+
setAutoArchiveInterval(interval: number): Promise<void>;
|
|
329
|
+
/**
|
|
330
|
+
* Set the auto-delete interval for the Sandbox.
|
|
331
|
+
*
|
|
332
|
+
* The Sandbox will automatically delete after being continuously stopped for the specified interval.
|
|
333
|
+
*
|
|
334
|
+
* @param {number} interval - Number of minutes after which a continuously stopped Sandbox will be auto-deleted.
|
|
335
|
+
* Set to negative value to disable auto-delete. Set to 0 to delete immediately upon stopping.
|
|
336
|
+
* By default, auto-delete is disabled.
|
|
337
|
+
* @returns {Promise<void>}
|
|
338
|
+
*
|
|
339
|
+
* @example
|
|
340
|
+
* // Auto-delete after 1 hour
|
|
341
|
+
* await sandbox.setAutoDeleteInterval(60);
|
|
342
|
+
* // Or delete immediately upon stopping
|
|
343
|
+
* await sandbox.setAutoDeleteInterval(0);
|
|
344
|
+
* // Or disable auto-delete
|
|
345
|
+
* await sandbox.setAutoDeleteInterval(-1);
|
|
346
|
+
*/
|
|
347
|
+
setAutoDeleteInterval(interval: number): Promise<void>;
|
|
348
|
+
/**
|
|
349
|
+
* Updates outbound network policy for this sandbox on the runner (for example block all traffic,
|
|
350
|
+
* restore general internet access, or apply a CIDR allow list) without stopping the sandbox.
|
|
351
|
+
*
|
|
352
|
+
* This maps to the same mechanism as creating a sandbox with `networkBlockAll` / `networkAllowList`:
|
|
353
|
+
* the runner applies iptables rules to the sandbox container.
|
|
354
|
+
*
|
|
355
|
+
* @param {UpdateSandboxNetworkSettings} settings - At least one of `networkBlockAll` or `networkAllowList` must be set.
|
|
356
|
+
* Set `networkBlockAll` to `false` to restore outbound access after a block (and clear a stored allow list).
|
|
357
|
+
*
|
|
358
|
+
* @example
|
|
359
|
+
* // Pause internet (outbound blocked)
|
|
360
|
+
* await sandbox.updateNetworkSettings({ networkBlockAll: true });
|
|
361
|
+
* // Resume internet
|
|
362
|
+
* await sandbox.updateNetworkSettings({ networkBlockAll: false });
|
|
363
|
+
*/
|
|
364
|
+
updateNetworkSettings(settings: UpdateSandboxNetworkSettings): Promise<void>;
|
|
365
|
+
/**
|
|
366
|
+
* Retrieves the preview link for the sandbox at the specified port. If the port is closed,
|
|
367
|
+
* it will be opened automatically. For private sandboxes, a token is included to grant access
|
|
368
|
+
* to the URL.
|
|
369
|
+
*
|
|
370
|
+
* @param {number} port - The port to open the preview link on.
|
|
371
|
+
* @returns {PortPreviewUrl} The response object for the preview link, which includes the `url`
|
|
372
|
+
* and the `token` (to access private sandboxes).
|
|
373
|
+
*
|
|
374
|
+
* @example
|
|
375
|
+
* const previewLink = await sandbox.getPreviewLink(3000);
|
|
376
|
+
* console.log(`Preview URL: ${previewLink.url}`);
|
|
377
|
+
* console.log(`Token: ${previewLink.token}`);
|
|
378
|
+
*/
|
|
379
|
+
getPreviewLink(port: number): Promise<PortPreviewUrl>;
|
|
380
|
+
/**
|
|
381
|
+
* Retrieves a signed preview url for the sandbox at the specified port.
|
|
382
|
+
*
|
|
383
|
+
* @param {number} port - The port to open the preview link on.
|
|
384
|
+
* @param {number} [expiresInSeconds] - The number of seconds the signed preview url will be valid for. Defaults to 60 seconds.
|
|
385
|
+
* @returns {Promise<SignedPortPreviewUrl>} The response object for the signed preview url.
|
|
386
|
+
*/
|
|
387
|
+
getSignedPreviewUrl(port: number, expiresInSeconds?: number): Promise<SignedPortPreviewUrl>;
|
|
388
|
+
/**
|
|
389
|
+
* Expires a signed preview url for the sandbox at the specified port.
|
|
390
|
+
*
|
|
391
|
+
* @param {number} port - The port to expire the signed preview url on.
|
|
392
|
+
* @param {string} token - The token to expire the signed preview url on.
|
|
393
|
+
* @returns {Promise<void>}
|
|
394
|
+
*/
|
|
395
|
+
expireSignedPreviewUrl(port: number, token: string): Promise<void>;
|
|
396
|
+
/**
|
|
397
|
+
* Archives the sandbox, making it inactive and preserving its state. When sandboxes are archived, the entire filesystem
|
|
398
|
+
* state is moved to cost-effective object storage, making it possible to keep sandboxes available for an extended period.
|
|
399
|
+
* The tradeoff between archived and stopped states is that starting an archived sandbox takes more time, depending on its size.
|
|
400
|
+
* Sandbox must be stopped before archiving.
|
|
401
|
+
*/
|
|
402
|
+
archive(): Promise<void>;
|
|
403
|
+
/**
|
|
404
|
+
* Resizes the Sandbox resources.
|
|
405
|
+
*
|
|
406
|
+
* Changes the CPU, memory, or disk allocation for the Sandbox. Hot resize (on running
|
|
407
|
+
* sandbox) only allows CPU/memory increases. Disk resize requires a stopped sandbox.
|
|
408
|
+
*
|
|
409
|
+
* @param {Resources} resources - New resource configuration. Only specified fields will be updated.
|
|
410
|
+
* - cpu: Number of CPU cores (minimum: 1). For hot resize, can only be increased.
|
|
411
|
+
* - memory: Memory in GiB (minimum: 1). For hot resize, can only be increased.
|
|
412
|
+
* - disk: Disk space in GiB (can only be increased, requires stopped sandbox).
|
|
413
|
+
* @param {number} [timeout=60] - Timeout in seconds for the resize operation. 0 means no timeout.
|
|
414
|
+
* @returns {Promise<void>}
|
|
415
|
+
* @throws {DaytonaError} - If hot resize constraints are violated, disk resize attempted on running sandbox,
|
|
416
|
+
* disk size decrease is attempted, no resource changes are specified, or resize operation times out.
|
|
417
|
+
*
|
|
418
|
+
* @example
|
|
419
|
+
* // Increase CPU/memory on running sandbox (hot resize)
|
|
420
|
+
* await sandbox.resize({ cpu: 4, memory: 8 });
|
|
421
|
+
*
|
|
422
|
+
* // Change disk (sandbox must be stopped)
|
|
423
|
+
* await sandbox.stop();
|
|
424
|
+
* await sandbox.resize({ cpu: 2, memory: 4, disk: 30 });
|
|
425
|
+
*/
|
|
426
|
+
resize(resources: Resources, timeout?: number): Promise<void>;
|
|
427
|
+
/**
|
|
428
|
+
* Waits for the Sandbox resize operation to complete.
|
|
429
|
+
*
|
|
430
|
+
* This method polls the Sandbox status until the state is no longer 'resizing'.
|
|
431
|
+
*
|
|
432
|
+
* @param {number} [timeout=60] - Maximum time to wait in seconds. 0 means no timeout.
|
|
433
|
+
* @returns {Promise<void>}
|
|
434
|
+
* @throws {DaytonaError} - If the sandbox ends up in an error state or resize times out.
|
|
435
|
+
*/
|
|
436
|
+
waitForResizeComplete(timeout?: number): Promise<void>;
|
|
437
|
+
/**
|
|
438
|
+
* Creates an SSH access token for the sandbox.
|
|
439
|
+
*
|
|
440
|
+
* @param {number} expiresInMinutes - The number of minutes the SSH access token will be valid for.
|
|
441
|
+
* @returns {Promise<SshAccessDto>} The SSH access token.
|
|
442
|
+
*/
|
|
443
|
+
createSshAccess(expiresInMinutes?: number): Promise<SshAccessDto>;
|
|
444
|
+
/**
|
|
445
|
+
* Revokes an SSH access token for the sandbox.
|
|
446
|
+
*
|
|
447
|
+
* @param {string} token - The token to revoke.
|
|
448
|
+
* @returns {Promise<void>}
|
|
449
|
+
*/
|
|
450
|
+
revokeSshAccess(token: string): Promise<void>;
|
|
451
|
+
/**
|
|
452
|
+
* Validates an SSH access token for the sandbox.
|
|
453
|
+
*
|
|
454
|
+
* @param {string} token - The token to validate.
|
|
455
|
+
* @returns {Promise<SshAccessValidationDto>} The SSH access validation result.
|
|
456
|
+
*/
|
|
457
|
+
validateSshAccess(token: string): Promise<SshAccessValidationDto>;
|
|
458
|
+
/**
|
|
459
|
+
* Assigns the API sandbox data to the Sandbox object.
|
|
460
|
+
*
|
|
461
|
+
* @param {SandboxDto} sandboxDto - The API sandbox instance to assign data from
|
|
462
|
+
* @returns {void}
|
|
463
|
+
*/
|
|
464
|
+
private processSandboxDto;
|
|
465
|
+
/**
|
|
466
|
+
* Refreshes the Sandbox data from the API, but does not throw an error if the sandbox has been deleted.
|
|
467
|
+
* Instead, it sets the state to destroyed.
|
|
468
|
+
*
|
|
469
|
+
* @returns {Promise<void>}
|
|
470
|
+
*/
|
|
471
|
+
private refreshDataSafe;
|
|
472
|
+
}
|
|
473
|
+
export interface PaginatedSandboxes extends Omit<PaginatedSandboxesDto, 'items'> {
|
|
474
|
+
items: Sandbox[];
|
|
475
|
+
}
|
|
476
|
+
//# sourceMappingURL=Sandbox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Sandbox.d.ts","sourceRoot":"","sources":["../../../../../libs/sdk-typescript/src/Sandbox.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,YAAY,EACZ,UAAU,EACV,OAAO,IAAI,UAAU,EACrB,kBAAkB,IAAI,qBAAqB,EAC3C,cAAc,EACd,aAAa,EACb,SAAS,EACT,sBAAsB,EACtB,aAAa,EACb,YAAY,EACZ,sBAAsB,EACtB,oBAAoB,EAGpB,4BAA4B,EAC7B,MAAM,qBAAqB,CAAA;AAC5B,OAA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