@daytonaio/sdk 0.19.0-alpha.0 → 0.19.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/README.md +145 -0
- package/package.json +20 -15
package/README.md
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@daytonaio/sdk",
|
|
3
|
-
"version": "0.19.0-alpha.
|
|
3
|
+
"version": "0.19.0-alpha.3",
|
|
4
4
|
"description": "TypeScript SDK for Daytona",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"types": "./src/index.d.ts",
|
|
@@ -18,35 +18,40 @@
|
|
|
18
18
|
"docsDir": "../../apps/docs/content/sdk-typescript"
|
|
19
19
|
},
|
|
20
20
|
"scripts": {
|
|
21
|
-
"build": "tsc
|
|
21
|
+
"build": "tsc",
|
|
22
|
+
"prepare": "npm run build",
|
|
22
23
|
"docs": "bash -O extglob -c 'rm -rf $npm_package_config_docsDir/!(index.mdx)' && typedoc && rm -f $npm_package_config_docsDir/readme.mdx"
|
|
23
24
|
},
|
|
24
25
|
"files": [
|
|
25
26
|
"dist"
|
|
26
27
|
],
|
|
27
28
|
"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
|
+
},
|
|
28
43
|
"dependencies": {
|
|
44
|
+
"@daytonaio/api-client": "^0.19.1",
|
|
29
45
|
"@aws-sdk/client-s3": "^3.445.0",
|
|
30
46
|
"@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",
|
|
34
47
|
"@dotenvx/dotenvx": "^1.25.1",
|
|
35
48
|
"@iarna/toml": "^2.2.5",
|
|
36
|
-
"@types/shell-quote": "1.7.5",
|
|
37
|
-
"@types/tar": "6.1.13",
|
|
38
49
|
"axios": "^1.6.1",
|
|
39
|
-
"dotenv": "16.5.0",
|
|
40
50
|
"fast-glob": "^3.3.0",
|
|
41
51
|
"form-data": "^4.0.0",
|
|
42
52
|
"shell-quote": "^1.8.2",
|
|
43
53
|
"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
54
|
"untildify": "^5.0.0",
|
|
48
55
|
"uuid": "^11.0.3"
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
"type": "commonjs"
|
|
52
|
-
}
|
|
56
|
+
}
|
|
57
|
+
}
|