@daytonaio/sdk 0.11.2 → 0.11.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 +3 -3
- package/dist/Daytona.d.ts +18 -59
- package/dist/Daytona.js +14 -54
- package/dist/FileSystem.d.ts +2 -68
- package/dist/FileSystem.js +1 -67
- package/dist/Git.d.ts +15 -61
- package/dist/Git.js +10 -62
- package/dist/LspServer.d.ts +13 -75
- package/dist/LspServer.js +11 -71
- package/dist/Process.d.ts +5 -35
- package/dist/Process.js +5 -35
- package/dist/Sandbox.d.ts +5 -47
- package/dist/Sandbox.js +2 -44
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Daytona SDK for TypeScript
|
|
2
2
|
|
|
3
|
-
A TypeScript SDK for interacting with Daytona
|
|
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
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -47,7 +47,7 @@ import { Daytona } from '@daytonaio/sdk'
|
|
|
47
47
|
// Initialize with configuration
|
|
48
48
|
const daytona = new Daytona({
|
|
49
49
|
apiKey: 'your-api-key',
|
|
50
|
-
|
|
50
|
+
apiUrl: 'your-api-url',
|
|
51
51
|
target: 'us',
|
|
52
52
|
})
|
|
53
53
|
```
|
|
@@ -55,7 +55,7 @@ const daytona = new Daytona({
|
|
|
55
55
|
Or using environment variables:
|
|
56
56
|
|
|
57
57
|
- `DAYTONA_API_KEY`: Your Daytona API key
|
|
58
|
-
- `
|
|
58
|
+
- `DAYTONA_API_URL`: The Daytona API URL
|
|
59
59
|
- `DAYTONA_TARGET`: Your target environment
|
|
60
60
|
|
|
61
61
|
You can also customize sandbox creation:
|
package/dist/Daytona.d.ts
CHANGED
|
@@ -1,72 +1,31 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Sandboxes are isolated development environments managed by Daytona.
|
|
3
|
-
* This guide covers how to create, manage, and remove Sandboxes using the SDK.
|
|
4
|
-
*
|
|
5
|
-
* @module Daytona
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* // Initialize using environment variables (DAYTONA_API_KEY, DAYTONA_SERVER_URL, DAYTONA_TARGET)
|
|
9
|
-
* const daytona = new Daytona();
|
|
10
|
-
*
|
|
11
|
-
* // Create and use a sandbox
|
|
12
|
-
* const sandbox = await daytona.create({
|
|
13
|
-
* language: 'typescript',
|
|
14
|
-
* envVars: { NODE_ENV: 'development' }
|
|
15
|
-
* });
|
|
16
|
-
*
|
|
17
|
-
* // Execute commands in the sandbox
|
|
18
|
-
* const response = await sandbox.process.executeCommand('echo "Hello, World!"');
|
|
19
|
-
* console.log(response.result);
|
|
20
|
-
*
|
|
21
|
-
* // Execute code in the sandbox
|
|
22
|
-
* const response = await sandbox.process.codeRun('console.log("Hello, World!")');
|
|
23
|
-
* console.log(response.result);
|
|
24
|
-
*
|
|
25
|
-
* @example
|
|
26
|
-
* // Initialize with explicit configuration
|
|
27
|
-
* const daytona = new Daytona({
|
|
28
|
-
* apiKey: process.env.CUSTOM_API_KEY,
|
|
29
|
-
* serverUrl: 'https://daytona.example.com',
|
|
30
|
-
* target: 'us'
|
|
31
|
-
* });
|
|
32
|
-
*
|
|
33
|
-
* // Create a custom sandbox
|
|
34
|
-
* const sandbox = await daytona.create({
|
|
35
|
-
* language: 'typescript',
|
|
36
|
-
* image: 'node:18',
|
|
37
|
-
* resources: {
|
|
38
|
-
* cpu: 2,
|
|
39
|
-
* memory: 4 // 4GB RAM
|
|
40
|
-
* },
|
|
41
|
-
* autoStopInterval: 60 // Auto-stop after 1 hour of inactivity
|
|
42
|
-
* });
|
|
43
|
-
*
|
|
44
|
-
* // Use sandbox features
|
|
45
|
-
* await sandbox.git.clone('https://github.com/user/repo.git');
|
|
46
|
-
* await sandbox.process.executeCommand('npm test');
|
|
47
|
-
*/
|
|
48
1
|
import { Sandbox, Sandbox as Workspace } from './Sandbox';
|
|
49
2
|
import { CreateWorkspaceTargetEnum as SandboxTargetRegion } from '@daytonaio/api-client';
|
|
50
3
|
/**
|
|
51
4
|
* Configuration options for initializing the Daytona client.
|
|
52
5
|
*
|
|
53
6
|
* @interface
|
|
54
|
-
* @property {string} apiKey - API key for authentication with Daytona
|
|
55
|
-
* @property {string}
|
|
7
|
+
* @property {string} apiKey - API key for authentication with the Daytona API
|
|
8
|
+
* @property {string} apiUrl - URL of the Daytona API. Defaults to 'https://app.daytona.io/api'
|
|
9
|
+
* if not set here and not set in environment variable DAYTONA_API_URL.
|
|
56
10
|
* @property {CreateSandboxTargetEnum} target - Target location for Sandboxes
|
|
57
11
|
*
|
|
58
12
|
* @example
|
|
59
13
|
* const config: DaytonaConfig = {
|
|
60
14
|
* apiKey: "your-api-key",
|
|
61
|
-
*
|
|
15
|
+
* apiUrl: "https://your-api.com",
|
|
62
16
|
* target: "us"
|
|
63
17
|
* };
|
|
64
18
|
* const daytona = new Daytona(config);
|
|
65
19
|
*/
|
|
66
20
|
export interface DaytonaConfig {
|
|
67
|
-
/** API key for authentication with Daytona
|
|
21
|
+
/** API key for authentication with the Daytona API */
|
|
68
22
|
apiKey?: string;
|
|
69
|
-
/** URL of the Daytona
|
|
23
|
+
/** URL of the Daytona API.
|
|
24
|
+
*/
|
|
25
|
+
apiUrl?: string;
|
|
26
|
+
/**
|
|
27
|
+
* @deprecated Use `apiUrl` instead. This property will be removed in future versions.
|
|
28
|
+
*/
|
|
70
29
|
serverUrl?: string;
|
|
71
30
|
/** Target environment for sandboxes */
|
|
72
31
|
target?: SandboxTargetRegion;
|
|
@@ -112,11 +71,11 @@ export interface SandboxResources {
|
|
|
112
71
|
* @property {string} [id] - Optional Sandbox ID. If not provided, a random ID will be generated
|
|
113
72
|
* @property {string} [image] - Optional Docker image to use for the Sandbox
|
|
114
73
|
* @property {string} [user] - Optional os user to use for the Sandbox
|
|
115
|
-
* @property {CodeLanguage} [language] - Programming language for direct code execution
|
|
74
|
+
* @property {CodeLanguage | string} [language] - Programming language for direct code execution
|
|
116
75
|
* @property {Record<string, string>} [envVars] - Optional environment variables to set in the Sandbox
|
|
117
76
|
* @property {Record<string, string>} [labels] - Sandbox labels
|
|
118
77
|
* @property {boolean} [public] - Is the Sandbox port preview public
|
|
119
|
-
* @property {string} [target] - Target location for the Sandbox
|
|
78
|
+
* @property {SandboxTargetRegion | string} [target] - Target location for the Sandbox
|
|
120
79
|
* @property {SandboxResources} [resources] - Resource allocation for the Sandbox
|
|
121
80
|
* @property {boolean} [async] - If true, will not wait for the Sandbox to be ready before returning
|
|
122
81
|
* @property {number} [timeout] - Timeout in seconds for the Sandbox to be ready (0 means no timeout)
|
|
@@ -164,7 +123,7 @@ export type CreateSandboxParams = {
|
|
|
164
123
|
autoStopInterval?: number;
|
|
165
124
|
};
|
|
166
125
|
/**
|
|
167
|
-
* Main class for interacting with Daytona
|
|
126
|
+
* Main class for interacting with the Daytona API.
|
|
168
127
|
*
|
|
169
128
|
* Provides methods for creating, managing, and interacting with Daytona Sandboxes.
|
|
170
129
|
* Can be initialized either with explicit configuration or using environment variables.
|
|
@@ -172,7 +131,7 @@ export type CreateSandboxParams = {
|
|
|
172
131
|
*
|
|
173
132
|
* @example
|
|
174
133
|
* // Using environment variables
|
|
175
|
-
* // Uses DAYTONA_API_KEY,
|
|
134
|
+
* // Uses DAYTONA_API_KEY, DAYTONA_API_URL, DAYTONA_TARGET
|
|
176
135
|
* const daytona = new Daytona();
|
|
177
136
|
* const sandbox = await daytona.create();
|
|
178
137
|
*
|
|
@@ -180,7 +139,7 @@ export type CreateSandboxParams = {
|
|
|
180
139
|
* // Using explicit configuration
|
|
181
140
|
* const config: DaytonaConfig = {
|
|
182
141
|
* apiKey: "your-api-key",
|
|
183
|
-
*
|
|
142
|
+
* apiUrl: "https://your-api.com",
|
|
184
143
|
* target: "us"
|
|
185
144
|
* };
|
|
186
145
|
* const daytona = new Daytona(config);
|
|
@@ -192,12 +151,12 @@ export declare class Daytona {
|
|
|
192
151
|
private readonly toolboxApi;
|
|
193
152
|
private readonly target;
|
|
194
153
|
private readonly apiKey;
|
|
195
|
-
private readonly
|
|
154
|
+
private readonly apiUrl;
|
|
196
155
|
/**
|
|
197
156
|
* Creates a new Daytona client instance.
|
|
198
157
|
*
|
|
199
158
|
* @param {DaytonaConfig} [config] - Configuration options
|
|
200
|
-
* @throws {DaytonaError} - `DaytonaError` - When API key
|
|
159
|
+
* @throws {DaytonaError} - `DaytonaError` - When API key is missing
|
|
201
160
|
*/
|
|
202
161
|
constructor(config?: DaytonaConfig);
|
|
203
162
|
/**
|
package/dist/Daytona.js
CHANGED
|
@@ -1,51 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Sandboxes are isolated development environments managed by Daytona.
|
|
4
|
-
* This guide covers how to create, manage, and remove Sandboxes using the SDK.
|
|
5
|
-
*
|
|
6
|
-
* @module Daytona
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* // Initialize using environment variables (DAYTONA_API_KEY, DAYTONA_SERVER_URL, DAYTONA_TARGET)
|
|
10
|
-
* const daytona = new Daytona();
|
|
11
|
-
*
|
|
12
|
-
* // Create and use a sandbox
|
|
13
|
-
* const sandbox = await daytona.create({
|
|
14
|
-
* language: 'typescript',
|
|
15
|
-
* envVars: { NODE_ENV: 'development' }
|
|
16
|
-
* });
|
|
17
|
-
*
|
|
18
|
-
* // Execute commands in the sandbox
|
|
19
|
-
* const response = await sandbox.process.executeCommand('echo "Hello, World!"');
|
|
20
|
-
* console.log(response.result);
|
|
21
|
-
*
|
|
22
|
-
* // Execute code in the sandbox
|
|
23
|
-
* const response = await sandbox.process.codeRun('console.log("Hello, World!")');
|
|
24
|
-
* console.log(response.result);
|
|
25
|
-
*
|
|
26
|
-
* @example
|
|
27
|
-
* // Initialize with explicit configuration
|
|
28
|
-
* const daytona = new Daytona({
|
|
29
|
-
* apiKey: process.env.CUSTOM_API_KEY,
|
|
30
|
-
* serverUrl: 'https://daytona.example.com',
|
|
31
|
-
* target: 'us'
|
|
32
|
-
* });
|
|
33
|
-
*
|
|
34
|
-
* // Create a custom sandbox
|
|
35
|
-
* const sandbox = await daytona.create({
|
|
36
|
-
* language: 'typescript',
|
|
37
|
-
* image: 'node:18',
|
|
38
|
-
* resources: {
|
|
39
|
-
* cpu: 2,
|
|
40
|
-
* memory: 4 // 4GB RAM
|
|
41
|
-
* },
|
|
42
|
-
* autoStopInterval: 60 // Auto-stop after 1 hour of inactivity
|
|
43
|
-
* });
|
|
44
|
-
*
|
|
45
|
-
* // Use sandbox features
|
|
46
|
-
* await sandbox.git.clone('https://github.com/user/repo.git');
|
|
47
|
-
* await sandbox.process.executeCommand('npm test');
|
|
48
|
-
*/
|
|
49
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
50
3
|
if (k2 === undefined) k2 = k;
|
|
51
4
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -101,7 +54,7 @@ var CodeLanguage;
|
|
|
101
54
|
CodeLanguage["JAVASCRIPT"] = "javascript";
|
|
102
55
|
})(CodeLanguage || (exports.CodeLanguage = CodeLanguage = {}));
|
|
103
56
|
/**
|
|
104
|
-
* Main class for interacting with Daytona
|
|
57
|
+
* Main class for interacting with the Daytona API.
|
|
105
58
|
*
|
|
106
59
|
* Provides methods for creating, managing, and interacting with Daytona Sandboxes.
|
|
107
60
|
* Can be initialized either with explicit configuration or using environment variables.
|
|
@@ -109,7 +62,7 @@ var CodeLanguage;
|
|
|
109
62
|
*
|
|
110
63
|
* @example
|
|
111
64
|
* // Using environment variables
|
|
112
|
-
* // Uses DAYTONA_API_KEY,
|
|
65
|
+
* // Uses DAYTONA_API_KEY, DAYTONA_API_URL, DAYTONA_TARGET
|
|
113
66
|
* const daytona = new Daytona();
|
|
114
67
|
* const sandbox = await daytona.create();
|
|
115
68
|
*
|
|
@@ -117,7 +70,7 @@ var CodeLanguage;
|
|
|
117
70
|
* // Using explicit configuration
|
|
118
71
|
* const config: DaytonaConfig = {
|
|
119
72
|
* apiKey: "your-api-key",
|
|
120
|
-
*
|
|
73
|
+
* apiUrl: "https://your-api.com",
|
|
121
74
|
* target: "us"
|
|
122
75
|
* };
|
|
123
76
|
* const daytona = new Daytona(config);
|
|
@@ -129,7 +82,7 @@ class Daytona {
|
|
|
129
82
|
* Creates a new Daytona client instance.
|
|
130
83
|
*
|
|
131
84
|
* @param {DaytonaConfig} [config] - Configuration options
|
|
132
|
-
* @throws {DaytonaError} - `DaytonaError` - When API key
|
|
85
|
+
* @throws {DaytonaError} - `DaytonaError` - When API key is missing
|
|
133
86
|
*/
|
|
134
87
|
constructor(config) {
|
|
135
88
|
dotenv_1.default.config();
|
|
@@ -138,14 +91,21 @@ class Daytona {
|
|
|
138
91
|
if (!apiKey) {
|
|
139
92
|
throw new DaytonaError_1.DaytonaError('API key is required');
|
|
140
93
|
}
|
|
141
|
-
const
|
|
94
|
+
const apiUrl = (config === null || config === void 0 ? void 0 : config.apiUrl) ||
|
|
95
|
+
(config === null || config === void 0 ? void 0 : config.serverUrl) ||
|
|
96
|
+
process.env.DAYTONA_API_URL ||
|
|
97
|
+
process.env.DAYTONA_SERVER_URL ||
|
|
98
|
+
'https://app.daytona.io/api';
|
|
142
99
|
const envTarget = process.env.DAYTONA_TARGET;
|
|
143
100
|
const target = (config === null || config === void 0 ? void 0 : config.target) || envTarget || api_client_1.CreateWorkspaceTargetEnum.US;
|
|
101
|
+
if (process.env.DAYTONA_SERVER_URL && !process.env.DAYTONA_API_URL) {
|
|
102
|
+
console.warn('[Deprecation Warning] Environment variable `DAYTONA_SERVER_URL` is deprecated and will be removed in future versions. Use `DAYTONA_API_URL` instead.');
|
|
103
|
+
}
|
|
144
104
|
this.apiKey = apiKey;
|
|
145
|
-
this.
|
|
105
|
+
this.apiUrl = apiUrl;
|
|
146
106
|
this.target = target;
|
|
147
107
|
const configuration = new api_client_1.Configuration({
|
|
148
|
-
basePath: this.
|
|
108
|
+
basePath: this.apiUrl,
|
|
149
109
|
baseOptions: {
|
|
150
110
|
headers: {
|
|
151
111
|
Authorization: `Bearer ${this.apiKey}`,
|
package/dist/FileSystem.d.ts
CHANGED
|
@@ -1,72 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The Daytona SDK provides comprehensive file system operations through the `fs` module in Sandboxes.
|
|
3
|
-
* You can perform various operations like listing files, creating directories, reading and writing files, and more.
|
|
4
|
-
* This guide covers all available file system operations and best practices.
|
|
5
|
-
*
|
|
6
|
-
* @module FileSystem
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* // Basic file operations
|
|
10
|
-
* // Create a sandbox
|
|
11
|
-
* const sandbox = await daytona.create();
|
|
12
|
-
*
|
|
13
|
-
* // Create a directory
|
|
14
|
-
* await sandbox.fs.createFolder('/workspace/data', '755');
|
|
15
|
-
*
|
|
16
|
-
* // Upload a file
|
|
17
|
-
* const fileContent = new File(['content'], 'local_file.txt');
|
|
18
|
-
* await sandbox.fs.uploadFile('/workspace/data/file.txt', fileContent);
|
|
19
|
-
*
|
|
20
|
-
* // List directory contents
|
|
21
|
-
* const files = await sandbox.fs.listFiles('/workspace');
|
|
22
|
-
* files.forEach(file => {
|
|
23
|
-
* console.log(`Name: ${file.name}`);
|
|
24
|
-
* console.log(`Is directory: ${file.isDir}`);
|
|
25
|
-
* console.log(`Size: ${file.size}`);
|
|
26
|
-
* console.log(`Modified: ${file.modTime}`);
|
|
27
|
-
* });
|
|
28
|
-
*
|
|
29
|
-
* // Search file contents
|
|
30
|
-
* const matches = await sandbox.fs.findFiles(
|
|
31
|
-
* '/workspace/src',
|
|
32
|
-
* 'text-of-interest'
|
|
33
|
-
* );
|
|
34
|
-
* matches.forEach(match => {
|
|
35
|
-
* console.log(`Absolute file path: ${match.file}`);
|
|
36
|
-
* console.log(`Line number: ${match.line}`);
|
|
37
|
-
* console.log(`Line content: ${match.content}\n`);
|
|
38
|
-
* });
|
|
39
|
-
*
|
|
40
|
-
* @example
|
|
41
|
-
* // File manipulation
|
|
42
|
-
* // Move files
|
|
43
|
-
* await sandbox.fs.moveFiles(
|
|
44
|
-
* '/workspace/data/old.txt',
|
|
45
|
-
* '/workspace/data/new.txt'
|
|
46
|
-
* );
|
|
47
|
-
*
|
|
48
|
-
* // Replace text in files
|
|
49
|
-
* const results = await sandbox.fs.replaceInFiles(
|
|
50
|
-
* ['/workspace/data/new.txt'],
|
|
51
|
-
* 'old_version',
|
|
52
|
-
* 'new_version'
|
|
53
|
-
* );
|
|
54
|
-
*
|
|
55
|
-
* // Set permissions
|
|
56
|
-
* await sandbox.fs.setFilePermissions(
|
|
57
|
-
* '/workspace/data/script.sh',
|
|
58
|
-
* {
|
|
59
|
-
* mode: '755',
|
|
60
|
-
* owner: 'daytona'
|
|
61
|
-
* }
|
|
62
|
-
* );
|
|
63
|
-
*/
|
|
64
1
|
import { FileInfo, Match, ReplaceResult, SearchFilesResponse, ToolboxApi } from '@daytonaio/api-client';
|
|
65
2
|
import { SandboxInstance } from './Sandbox';
|
|
66
3
|
/**
|
|
67
4
|
* Parameters for setting file permissions in the Sandbox.
|
|
68
5
|
*
|
|
69
|
-
* @interface
|
|
6
|
+
* @interface
|
|
70
7
|
* @property {string} [mode] - File mode/permissions in octal format (e.g. "644")
|
|
71
8
|
* @property {string} [owner] - User owner of the file
|
|
72
9
|
* @property {string} [group] - Group owner of the file
|
|
@@ -89,10 +26,7 @@ export type FilePermissionsParams = {
|
|
|
89
26
|
/**
|
|
90
27
|
* Provides file system operations within a Sandbox.
|
|
91
28
|
*
|
|
92
|
-
*
|
|
93
|
-
* be performed within a Daytona Sandbox. It supports common operations like
|
|
94
|
-
* creating, deleting, and moving files, as well as searching file contents and
|
|
95
|
-
* managing permissions.
|
|
29
|
+
* @class
|
|
96
30
|
*/
|
|
97
31
|
export declare class FileSystem {
|
|
98
32
|
private readonly instance;
|
package/dist/FileSystem.js
CHANGED
|
@@ -1,76 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* The Daytona SDK provides comprehensive file system operations through the `fs` module in Sandboxes.
|
|
4
|
-
* You can perform various operations like listing files, creating directories, reading and writing files, and more.
|
|
5
|
-
* This guide covers all available file system operations and best practices.
|
|
6
|
-
*
|
|
7
|
-
* @module FileSystem
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* // Basic file operations
|
|
11
|
-
* // Create a sandbox
|
|
12
|
-
* const sandbox = await daytona.create();
|
|
13
|
-
*
|
|
14
|
-
* // Create a directory
|
|
15
|
-
* await sandbox.fs.createFolder('/workspace/data', '755');
|
|
16
|
-
*
|
|
17
|
-
* // Upload a file
|
|
18
|
-
* const fileContent = new File(['content'], 'local_file.txt');
|
|
19
|
-
* await sandbox.fs.uploadFile('/workspace/data/file.txt', fileContent);
|
|
20
|
-
*
|
|
21
|
-
* // List directory contents
|
|
22
|
-
* const files = await sandbox.fs.listFiles('/workspace');
|
|
23
|
-
* files.forEach(file => {
|
|
24
|
-
* console.log(`Name: ${file.name}`);
|
|
25
|
-
* console.log(`Is directory: ${file.isDir}`);
|
|
26
|
-
* console.log(`Size: ${file.size}`);
|
|
27
|
-
* console.log(`Modified: ${file.modTime}`);
|
|
28
|
-
* });
|
|
29
|
-
*
|
|
30
|
-
* // Search file contents
|
|
31
|
-
* const matches = await sandbox.fs.findFiles(
|
|
32
|
-
* '/workspace/src',
|
|
33
|
-
* 'text-of-interest'
|
|
34
|
-
* );
|
|
35
|
-
* matches.forEach(match => {
|
|
36
|
-
* console.log(`Absolute file path: ${match.file}`);
|
|
37
|
-
* console.log(`Line number: ${match.line}`);
|
|
38
|
-
* console.log(`Line content: ${match.content}\n`);
|
|
39
|
-
* });
|
|
40
|
-
*
|
|
41
|
-
* @example
|
|
42
|
-
* // File manipulation
|
|
43
|
-
* // Move files
|
|
44
|
-
* await sandbox.fs.moveFiles(
|
|
45
|
-
* '/workspace/data/old.txt',
|
|
46
|
-
* '/workspace/data/new.txt'
|
|
47
|
-
* );
|
|
48
|
-
*
|
|
49
|
-
* // Replace text in files
|
|
50
|
-
* const results = await sandbox.fs.replaceInFiles(
|
|
51
|
-
* ['/workspace/data/new.txt'],
|
|
52
|
-
* 'old_version',
|
|
53
|
-
* 'new_version'
|
|
54
|
-
* );
|
|
55
|
-
*
|
|
56
|
-
* // Set permissions
|
|
57
|
-
* await sandbox.fs.setFilePermissions(
|
|
58
|
-
* '/workspace/data/script.sh',
|
|
59
|
-
* {
|
|
60
|
-
* mode: '755',
|
|
61
|
-
* owner: 'daytona'
|
|
62
|
-
* }
|
|
63
|
-
* );
|
|
64
|
-
*/
|
|
65
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
66
3
|
exports.FileSystem = void 0;
|
|
67
4
|
/**
|
|
68
5
|
* Provides file system operations within a Sandbox.
|
|
69
6
|
*
|
|
70
|
-
*
|
|
71
|
-
* be performed within a Daytona Sandbox. It supports common operations like
|
|
72
|
-
* creating, deleting, and moving files, as well as searching file contents and
|
|
73
|
-
* managing permissions.
|
|
7
|
+
* @class
|
|
74
8
|
*/
|
|
75
9
|
class FileSystem {
|
|
76
10
|
constructor(instance, toolboxApi) {
|
package/dist/Git.d.ts
CHANGED
|
@@ -1,56 +1,26 @@
|
|
|
1
|
+
import { ToolboxApi, ListBranchResponse, GitStatus } from '@daytonaio/api-client';
|
|
2
|
+
import { Sandbox, SandboxInstance } from './Sandbox';
|
|
1
3
|
/**
|
|
2
|
-
*
|
|
3
|
-
* operations and best practices. Daytona SDK provides an option to clone, check status,
|
|
4
|
-
* and manage Git repositories in Sandboxes. You can interact with Git repositories using
|
|
5
|
-
* the `git` module.
|
|
6
|
-
*
|
|
7
|
-
* @module Git
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* // Basic Git workflow
|
|
11
|
-
* // Create and initialize sandbox
|
|
12
|
-
* const sandbox = await daytona.create();
|
|
13
|
-
*
|
|
14
|
-
* // Clone a repository
|
|
15
|
-
* await sandbox.git.clone(
|
|
16
|
-
* 'https://github.com/user/repo.git',
|
|
17
|
-
* '/workspace/repo'
|
|
18
|
-
* );
|
|
4
|
+
* Response from the git commit.
|
|
19
5
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
*
|
|
28
|
-
* await sandbox.git.commit(
|
|
29
|
-
* '/workspace/repo',
|
|
30
|
-
* 'Add test file',
|
|
31
|
-
* 'John Doe',
|
|
32
|
-
* 'john@example.com'
|
|
33
|
-
* );
|
|
34
|
-
*
|
|
35
|
-
* // Push changes (with authentication)
|
|
36
|
-
* await sandbox.git.push(
|
|
37
|
-
* '/workspace/repo',
|
|
38
|
-
* 'user',
|
|
39
|
-
* 'token'
|
|
40
|
-
* );
|
|
6
|
+
* @interface
|
|
7
|
+
* @property {string} sha - The SHA of the commit
|
|
8
|
+
*/
|
|
9
|
+
export interface GitCommitResponse {
|
|
10
|
+
sha: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Provides Git operations within a Sandbox.
|
|
41
14
|
*
|
|
15
|
+
* @class
|
|
42
16
|
*/
|
|
43
|
-
import { ToolboxApi, ListBranchResponse, GitStatus } from '@daytonaio/api-client';
|
|
44
|
-
import { Sandbox, SandboxInstance } from './Sandbox';
|
|
45
17
|
export declare class Git {
|
|
46
18
|
private readonly sandbox;
|
|
47
19
|
private readonly toolboxApi;
|
|
48
20
|
private readonly instance;
|
|
49
21
|
constructor(sandbox: Sandbox, toolboxApi: ToolboxApi, instance: SandboxInstance);
|
|
50
22
|
/**
|
|
51
|
-
* Stages files for commit
|
|
52
|
-
*
|
|
53
|
-
* This method stages the specified files for the next commit, similar to
|
|
23
|
+
* Stages the specified files for the next commit, similar to
|
|
54
24
|
* running 'git add' on the command line.
|
|
55
25
|
*
|
|
56
26
|
* @param {string} path - Absolute path to the Git repository root
|
|
@@ -69,8 +39,6 @@ export declare class Git {
|
|
|
69
39
|
/**
|
|
70
40
|
* List branches in the repository.
|
|
71
41
|
*
|
|
72
|
-
* This method returns information about all branches in the repository.
|
|
73
|
-
*
|
|
74
42
|
* @param {string} path - Absolute path to the Git repository root
|
|
75
43
|
* @returns {Promise<ListBranchResponse>} List of branches in the repository
|
|
76
44
|
*
|
|
@@ -80,9 +48,7 @@ export declare class Git {
|
|
|
80
48
|
*/
|
|
81
49
|
branches(path: string): Promise<ListBranchResponse>;
|
|
82
50
|
/**
|
|
83
|
-
* Clones a Git repository.
|
|
84
|
-
*
|
|
85
|
-
* This method clones a Git repository into the specified path. It supports
|
|
51
|
+
* Clones a Git repository into the specified path. It supports
|
|
86
52
|
* cloning specific branches or commits, and can authenticate with the remote
|
|
87
53
|
* repository if credentials are provided.
|
|
88
54
|
*
|
|
@@ -123,9 +89,6 @@ export declare class Git {
|
|
|
123
89
|
/**
|
|
124
90
|
* Commits staged changes.
|
|
125
91
|
*
|
|
126
|
-
* This method creates a new commit with the staged changes. Make sure to stage
|
|
127
|
-
* changes using the add() method before committing.
|
|
128
|
-
*
|
|
129
92
|
* @param {string} path - Absolute path to the Git repository root
|
|
130
93
|
* @param {string} message - Commit message describing the changes
|
|
131
94
|
* @param {string} author - Name of the commit author
|
|
@@ -142,13 +105,10 @@ export declare class Git {
|
|
|
142
105
|
* 'john@example.com'
|
|
143
106
|
* );
|
|
144
107
|
*/
|
|
145
|
-
commit(path: string, message: string, author: string, email: string): Promise<
|
|
108
|
+
commit(path: string, message: string, author: string, email: string): Promise<GitCommitResponse>;
|
|
146
109
|
/**
|
|
147
110
|
* Push local changes to the remote repository.
|
|
148
111
|
*
|
|
149
|
-
* This method pushes committed changes to the remote repository. If the remote
|
|
150
|
-
* requires authentication, username and password/token must be provided.
|
|
151
|
-
*
|
|
152
112
|
* @param {string} path - Absolute path to the Git repository root
|
|
153
113
|
* @param {string} [username] - Git username for authentication
|
|
154
114
|
* @param {string} [password] - Git password or token for authentication
|
|
@@ -170,9 +130,6 @@ export declare class Git {
|
|
|
170
130
|
/**
|
|
171
131
|
* Pulls changes from the remote repository.
|
|
172
132
|
*
|
|
173
|
-
* This method fetches and merges changes from the remote repository. If the remote
|
|
174
|
-
* requires authentication, username and password/token must be provided.
|
|
175
|
-
*
|
|
176
133
|
* @param {string} path - Absolute path to the Git repository root
|
|
177
134
|
* @param {string} [username] - Git username for authentication
|
|
178
135
|
* @param {string} [password] - Git password or token for authentication
|
|
@@ -194,9 +151,6 @@ export declare class Git {
|
|
|
194
151
|
/**
|
|
195
152
|
* Gets the current status of the Git repository.
|
|
196
153
|
*
|
|
197
|
-
* This method returns information about the current state of the repository,
|
|
198
|
-
* including staged and unstaged changes, current branch, and untracked files.
|
|
199
|
-
*
|
|
200
154
|
* @param {string} path - Absolute path to the Git repository root
|
|
201
155
|
* @returns {Promise<GitStatus>} Current repository status including:
|
|
202
156
|
* - currentBranch: Name of the current branch
|
package/dist/Git.js
CHANGED
|
@@ -1,48 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Git = void 0;
|
|
2
4
|
/**
|
|
3
|
-
*
|
|
4
|
-
* operations and best practices. Daytona SDK provides an option to clone, check status,
|
|
5
|
-
* and manage Git repositories in Sandboxes. You can interact with Git repositories using
|
|
6
|
-
* the `git` module.
|
|
7
|
-
*
|
|
8
|
-
* @module Git
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* // Basic Git workflow
|
|
12
|
-
* // Create and initialize sandbox
|
|
13
|
-
* const sandbox = await daytona.create();
|
|
14
|
-
*
|
|
15
|
-
* // Clone a repository
|
|
16
|
-
* await sandbox.git.clone(
|
|
17
|
-
* 'https://github.com/user/repo.git',
|
|
18
|
-
* '/workspace/repo'
|
|
19
|
-
* );
|
|
20
|
-
*
|
|
21
|
-
* // Make some changes
|
|
22
|
-
* await sandbox.fs.uploadFile(
|
|
23
|
-
* '/workspace/repo/test.txt',
|
|
24
|
-
* new File([Buffer.from('Hello, World!')], 'test.txt')
|
|
25
|
-
* );
|
|
26
|
-
*
|
|
27
|
-
* // Stage and commit changes
|
|
28
|
-
* await sandbox.git.add('/workspace/repo', ['test.txt']);
|
|
29
|
-
* await sandbox.git.commit(
|
|
30
|
-
* '/workspace/repo',
|
|
31
|
-
* 'Add test file',
|
|
32
|
-
* 'John Doe',
|
|
33
|
-
* 'john@example.com'
|
|
34
|
-
* );
|
|
35
|
-
*
|
|
36
|
-
* // Push changes (with authentication)
|
|
37
|
-
* await sandbox.git.push(
|
|
38
|
-
* '/workspace/repo',
|
|
39
|
-
* 'user',
|
|
40
|
-
* 'token'
|
|
41
|
-
* );
|
|
5
|
+
* Provides Git operations within a Sandbox.
|
|
42
6
|
*
|
|
7
|
+
* @class
|
|
43
8
|
*/
|
|
44
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
-
exports.Git = void 0;
|
|
46
9
|
class Git {
|
|
47
10
|
constructor(sandbox, toolboxApi, instance) {
|
|
48
11
|
this.sandbox = sandbox;
|
|
@@ -50,9 +13,7 @@ class Git {
|
|
|
50
13
|
this.instance = instance;
|
|
51
14
|
}
|
|
52
15
|
/**
|
|
53
|
-
* Stages files for commit
|
|
54
|
-
*
|
|
55
|
-
* This method stages the specified files for the next commit, similar to
|
|
16
|
+
* Stages the specified files for the next commit, similar to
|
|
56
17
|
* running 'git add' on the command line.
|
|
57
18
|
*
|
|
58
19
|
* @param {string} path - Absolute path to the Git repository root
|
|
@@ -76,8 +37,6 @@ class Git {
|
|
|
76
37
|
/**
|
|
77
38
|
* List branches in the repository.
|
|
78
39
|
*
|
|
79
|
-
* This method returns information about all branches in the repository.
|
|
80
|
-
*
|
|
81
40
|
* @param {string} path - Absolute path to the Git repository root
|
|
82
41
|
* @returns {Promise<ListBranchResponse>} List of branches in the repository
|
|
83
42
|
*
|
|
@@ -90,9 +49,7 @@ class Git {
|
|
|
90
49
|
return response.data;
|
|
91
50
|
}
|
|
92
51
|
/**
|
|
93
|
-
* Clones a Git repository.
|
|
94
|
-
*
|
|
95
|
-
* This method clones a Git repository into the specified path. It supports
|
|
52
|
+
* Clones a Git repository into the specified path. It supports
|
|
96
53
|
* cloning specific branches or commits, and can authenticate with the remote
|
|
97
54
|
* repository if credentials are provided.
|
|
98
55
|
*
|
|
@@ -142,9 +99,6 @@ class Git {
|
|
|
142
99
|
/**
|
|
143
100
|
* Commits staged changes.
|
|
144
101
|
*
|
|
145
|
-
* This method creates a new commit with the staged changes. Make sure to stage
|
|
146
|
-
* changes using the add() method before committing.
|
|
147
|
-
*
|
|
148
102
|
* @param {string} path - Absolute path to the Git repository root
|
|
149
103
|
* @param {string} message - Commit message describing the changes
|
|
150
104
|
* @param {string} author - Name of the commit author
|
|
@@ -162,19 +116,19 @@ class Git {
|
|
|
162
116
|
* );
|
|
163
117
|
*/
|
|
164
118
|
async commit(path, message, author, email) {
|
|
165
|
-
await this.toolboxApi.gitCommitChanges(this.instance.id, {
|
|
119
|
+
const response = await this.toolboxApi.gitCommitChanges(this.instance.id, {
|
|
166
120
|
path,
|
|
167
121
|
message,
|
|
168
122
|
author,
|
|
169
123
|
email,
|
|
170
124
|
});
|
|
125
|
+
return {
|
|
126
|
+
sha: response.data.hash,
|
|
127
|
+
};
|
|
171
128
|
}
|
|
172
129
|
/**
|
|
173
130
|
* Push local changes to the remote repository.
|
|
174
131
|
*
|
|
175
|
-
* This method pushes committed changes to the remote repository. If the remote
|
|
176
|
-
* requires authentication, username and password/token must be provided.
|
|
177
|
-
*
|
|
178
132
|
* @param {string} path - Absolute path to the Git repository root
|
|
179
133
|
* @param {string} [username] - Git username for authentication
|
|
180
134
|
* @param {string} [password] - Git password or token for authentication
|
|
@@ -202,9 +156,6 @@ class Git {
|
|
|
202
156
|
/**
|
|
203
157
|
* Pulls changes from the remote repository.
|
|
204
158
|
*
|
|
205
|
-
* This method fetches and merges changes from the remote repository. If the remote
|
|
206
|
-
* requires authentication, username and password/token must be provided.
|
|
207
|
-
*
|
|
208
159
|
* @param {string} path - Absolute path to the Git repository root
|
|
209
160
|
* @param {string} [username] - Git username for authentication
|
|
210
161
|
* @param {string} [password] - Git password or token for authentication
|
|
@@ -232,9 +183,6 @@ class Git {
|
|
|
232
183
|
/**
|
|
233
184
|
* Gets the current status of the Git repository.
|
|
234
185
|
*
|
|
235
|
-
* This method returns information about the current state of the repository,
|
|
236
|
-
* including staged and unstaged changes, current branch, and untracked files.
|
|
237
|
-
*
|
|
238
186
|
* @param {string} path - Absolute path to the Git repository root
|
|
239
187
|
* @returns {Promise<GitStatus>} Current repository status including:
|
|
240
188
|
* - currentBranch: Name of the current branch
|
package/dist/LspServer.d.ts
CHANGED
|
@@ -1,42 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The Daytona SDK provides Language Server Protocol (LSP) support through Sandbox instances.
|
|
3
|
-
* This enables advanced language features like code completion, diagnostics, and more.
|
|
4
|
-
*
|
|
5
|
-
* The LSP server must be started with start() before using any other methods,
|
|
6
|
-
* and should be stopped with stop() when no longer needed to free resources.
|
|
7
|
-
*
|
|
8
|
-
* @module LspServer
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* // Basic LSP server usage
|
|
12
|
-
* // Create and initialize sandbox
|
|
13
|
-
* const sandbox = await daytona.create();
|
|
14
|
-
*
|
|
15
|
-
* // Create and start LSP server
|
|
16
|
-
* const lsp = sandbox.createLspServer('typescript', '/workspace/project');
|
|
17
|
-
* await lsp.start();
|
|
18
|
-
*
|
|
19
|
-
* // Open a file for editing
|
|
20
|
-
* await lsp.didOpen('/workspace/project/src/index.ts');
|
|
21
|
-
*
|
|
22
|
-
* // Get completions at a position
|
|
23
|
-
* const completions = await lsp.completions(
|
|
24
|
-
* '/workspace/project/src/index.ts',
|
|
25
|
-
* { line: 10, character: 15 }
|
|
26
|
-
* );
|
|
27
|
-
* console.log('Completions:', completions);
|
|
28
|
-
*
|
|
29
|
-
* // Get document symbols
|
|
30
|
-
* const symbols = await lsp.documentSymbols('/workspace/project/src/index.ts');
|
|
31
|
-
* symbols.forEach(symbol => {
|
|
32
|
-
* console.log(`${symbol.name}: ${symbol.kind}`);
|
|
33
|
-
* });
|
|
34
|
-
*
|
|
35
|
-
* // Clean up
|
|
36
|
-
* await lsp.didClose('/workspace/project/src/index.ts');
|
|
37
|
-
* await lsp.stop();
|
|
38
|
-
*
|
|
39
|
-
*/
|
|
40
1
|
import { CompletionList, LspSymbol, ToolboxApi } from '@daytonaio/api-client';
|
|
41
2
|
import { SandboxInstance } from './Sandbox';
|
|
42
3
|
/**
|
|
@@ -48,12 +9,10 @@ export declare enum LspLanguageId {
|
|
|
48
9
|
JAVASCRIPT = "javascript"
|
|
49
10
|
}
|
|
50
11
|
/**
|
|
51
|
-
* Represents a position
|
|
52
|
-
*
|
|
53
|
-
* This interface represents a zero-based position within a text document,
|
|
12
|
+
* Represents a zero-based position within a text document,
|
|
54
13
|
* specified by line number and character offset.
|
|
55
14
|
*
|
|
56
|
-
* @interface
|
|
15
|
+
* @interface
|
|
57
16
|
* @property {number} line - Zero-based line number in the document
|
|
58
17
|
* @property {number} character - Zero-based character offset on the line
|
|
59
18
|
*
|
|
@@ -70,17 +29,15 @@ export type Position = {
|
|
|
70
29
|
character: number;
|
|
71
30
|
};
|
|
72
31
|
/**
|
|
73
|
-
* Provides Language Server Protocol functionality for code intelligence
|
|
74
|
-
*
|
|
75
|
-
* This class implements a subset of the Language Server Protocol (LSP) to provide
|
|
32
|
+
* Provides Language Server Protocol functionality for code intelligence to provide
|
|
76
33
|
* IDE-like features such as code completion, symbol search, and more.
|
|
77
34
|
*
|
|
78
|
-
* @class LspServer
|
|
79
|
-
*
|
|
80
35
|
* @property {LspLanguageId} languageId - The language server type (e.g., "typescript")
|
|
81
36
|
* @property {string} pathToProject - Absolute path to the project root directory
|
|
82
37
|
* @property {ToolboxApi} toolboxApi - API client for Sandbox operations
|
|
83
38
|
* @property {SandboxInstance} instance - The Sandbox instance this server belongs to
|
|
39
|
+
*
|
|
40
|
+
* @class
|
|
84
41
|
*/
|
|
85
42
|
export declare class LspServer {
|
|
86
43
|
private readonly languageId;
|
|
@@ -89,9 +46,7 @@ export declare class LspServer {
|
|
|
89
46
|
private readonly instance;
|
|
90
47
|
constructor(languageId: LspLanguageId, pathToProject: string, toolboxApi: ToolboxApi, instance: SandboxInstance);
|
|
91
48
|
/**
|
|
92
|
-
* Starts the language server.
|
|
93
|
-
*
|
|
94
|
-
* This method must be called before using any other LSP functionality.
|
|
49
|
+
* Starts the language server, must be called before using any other LSP functionality.
|
|
95
50
|
* It initializes the language server for the specified language and project.
|
|
96
51
|
*
|
|
97
52
|
* @returns {Promise<void>}
|
|
@@ -103,9 +58,7 @@ export declare class LspServer {
|
|
|
103
58
|
*/
|
|
104
59
|
start(): Promise<void>;
|
|
105
60
|
/**
|
|
106
|
-
* Stops the language server
|
|
107
|
-
*
|
|
108
|
-
* This method should be called when the LSP server is no longer needed to
|
|
61
|
+
* Stops the language server, should be called when the LSP server is no longer needed to
|
|
109
62
|
* free up system resources.
|
|
110
63
|
*
|
|
111
64
|
* @returns {Promise<void>}
|
|
@@ -116,9 +69,7 @@ export declare class LspServer {
|
|
|
116
69
|
*/
|
|
117
70
|
stop(): Promise<void>;
|
|
118
71
|
/**
|
|
119
|
-
* Notifies the language server that a file has been opened
|
|
120
|
-
*
|
|
121
|
-
* This method should be called when a file is opened in the editor to enable
|
|
72
|
+
* Notifies the language server that a file has been opened, enabling
|
|
122
73
|
* language features like diagnostics and completions for that file. The server
|
|
123
74
|
* will begin tracking the file's contents and providing language features.
|
|
124
75
|
*
|
|
@@ -132,10 +83,8 @@ export declare class LspServer {
|
|
|
132
83
|
*/
|
|
133
84
|
didOpen(path: string): Promise<void>;
|
|
134
85
|
/**
|
|
135
|
-
* Notifies the language server that a file has been closed
|
|
136
|
-
*
|
|
137
|
-
* This method should be called when a file is closed in the editor to allow
|
|
138
|
-
* the language server to clean up any resources associated with that file.
|
|
86
|
+
* Notifies the language server that a file has been closed, should be called when a file is closed
|
|
87
|
+
* in the editor to allow the language server to clean up any resources associated with that file.
|
|
139
88
|
*
|
|
140
89
|
* @param {string} path - Absolute path to the closed file
|
|
141
90
|
* @returns {Promise<void>}
|
|
@@ -146,10 +95,7 @@ export declare class LspServer {
|
|
|
146
95
|
*/
|
|
147
96
|
didClose(path: string): Promise<void>;
|
|
148
97
|
/**
|
|
149
|
-
* Get symbol information from a document.
|
|
150
|
-
*
|
|
151
|
-
* This method returns information about all symbols (functions, classes,
|
|
152
|
-
* variables, etc.) defined in the specified document.
|
|
98
|
+
* Get symbol information (functions, classes, variables, etc.) from a document.
|
|
153
99
|
*
|
|
154
100
|
* @param {string} path - Absolute path to the file to get symbols from
|
|
155
101
|
* @returns {Promise<LspSymbol[]>} List of symbols in the document. Each symbol includes:
|
|
@@ -166,11 +112,7 @@ export declare class LspServer {
|
|
|
166
112
|
*/
|
|
167
113
|
documentSymbols(path: string): Promise<LspSymbol[]>;
|
|
168
114
|
/**
|
|
169
|
-
* Searches for symbols across the entire Sandbox.
|
|
170
|
-
*
|
|
171
|
-
* This method searches for symbols matching the query string across all files
|
|
172
|
-
* in the Sandbox. It's useful for finding declarations and definitions
|
|
173
|
-
* without knowing which file they're in.
|
|
115
|
+
* Searches for symbols matching the query string across the entire Sandbox.
|
|
174
116
|
*
|
|
175
117
|
* @param {string} query - Search query to match against symbol names
|
|
176
118
|
* @returns {Promise<LspSymbol[]>} List of matching symbols from all files. Each symbol includes:
|
|
@@ -182,11 +124,7 @@ export declare class LspServer {
|
|
|
182
124
|
*/
|
|
183
125
|
workspaceSymbols(query: string): Promise<LspSymbol[]>;
|
|
184
126
|
/**
|
|
185
|
-
* Searches for symbols across the entire Sandbox.
|
|
186
|
-
*
|
|
187
|
-
* This method searches for symbols matching the query string across all files
|
|
188
|
-
* in the Sandbox. It's useful for finding declarations and definitions
|
|
189
|
-
* without knowing which file they're in.
|
|
127
|
+
* Searches for symbols matching the query string across the entire Sandbox.
|
|
190
128
|
*
|
|
191
129
|
* @param {string} query - Search query to match against symbol names
|
|
192
130
|
* @returns {Promise<LspSymbol[]>} List of matching symbols from all files. Each symbol includes:
|
package/dist/LspServer.js
CHANGED
|
@@ -1,43 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* The Daytona SDK provides Language Server Protocol (LSP) support through Sandbox instances.
|
|
4
|
-
* This enables advanced language features like code completion, diagnostics, and more.
|
|
5
|
-
*
|
|
6
|
-
* The LSP server must be started with start() before using any other methods,
|
|
7
|
-
* and should be stopped with stop() when no longer needed to free resources.
|
|
8
|
-
*
|
|
9
|
-
* @module LspServer
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* // Basic LSP server usage
|
|
13
|
-
* // Create and initialize sandbox
|
|
14
|
-
* const sandbox = await daytona.create();
|
|
15
|
-
*
|
|
16
|
-
* // Create and start LSP server
|
|
17
|
-
* const lsp = sandbox.createLspServer('typescript', '/workspace/project');
|
|
18
|
-
* await lsp.start();
|
|
19
|
-
*
|
|
20
|
-
* // Open a file for editing
|
|
21
|
-
* await lsp.didOpen('/workspace/project/src/index.ts');
|
|
22
|
-
*
|
|
23
|
-
* // Get completions at a position
|
|
24
|
-
* const completions = await lsp.completions(
|
|
25
|
-
* '/workspace/project/src/index.ts',
|
|
26
|
-
* { line: 10, character: 15 }
|
|
27
|
-
* );
|
|
28
|
-
* console.log('Completions:', completions);
|
|
29
|
-
*
|
|
30
|
-
* // Get document symbols
|
|
31
|
-
* const symbols = await lsp.documentSymbols('/workspace/project/src/index.ts');
|
|
32
|
-
* symbols.forEach(symbol => {
|
|
33
|
-
* console.log(`${symbol.name}: ${symbol.kind}`);
|
|
34
|
-
* });
|
|
35
|
-
*
|
|
36
|
-
* // Clean up
|
|
37
|
-
* await lsp.didClose('/workspace/project/src/index.ts');
|
|
38
|
-
* await lsp.stop();
|
|
39
|
-
*
|
|
40
|
-
*/
|
|
41
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
3
|
exports.LspServer = exports.LspLanguageId = void 0;
|
|
43
4
|
/**
|
|
@@ -50,17 +11,15 @@ var LspLanguageId;
|
|
|
50
11
|
LspLanguageId["JAVASCRIPT"] = "javascript";
|
|
51
12
|
})(LspLanguageId || (exports.LspLanguageId = LspLanguageId = {}));
|
|
52
13
|
/**
|
|
53
|
-
* Provides Language Server Protocol functionality for code intelligence
|
|
54
|
-
*
|
|
55
|
-
* This class implements a subset of the Language Server Protocol (LSP) to provide
|
|
14
|
+
* Provides Language Server Protocol functionality for code intelligence to provide
|
|
56
15
|
* IDE-like features such as code completion, symbol search, and more.
|
|
57
16
|
*
|
|
58
|
-
* @class LspServer
|
|
59
|
-
*
|
|
60
17
|
* @property {LspLanguageId} languageId - The language server type (e.g., "typescript")
|
|
61
18
|
* @property {string} pathToProject - Absolute path to the project root directory
|
|
62
19
|
* @property {ToolboxApi} toolboxApi - API client for Sandbox operations
|
|
63
20
|
* @property {SandboxInstance} instance - The Sandbox instance this server belongs to
|
|
21
|
+
*
|
|
22
|
+
* @class
|
|
64
23
|
*/
|
|
65
24
|
class LspServer {
|
|
66
25
|
constructor(languageId, pathToProject, toolboxApi, instance) {
|
|
@@ -73,9 +32,7 @@ class LspServer {
|
|
|
73
32
|
}
|
|
74
33
|
}
|
|
75
34
|
/**
|
|
76
|
-
* Starts the language server.
|
|
77
|
-
*
|
|
78
|
-
* This method must be called before using any other LSP functionality.
|
|
35
|
+
* Starts the language server, must be called before using any other LSP functionality.
|
|
79
36
|
* It initializes the language server for the specified language and project.
|
|
80
37
|
*
|
|
81
38
|
* @returns {Promise<void>}
|
|
@@ -92,9 +49,7 @@ class LspServer {
|
|
|
92
49
|
});
|
|
93
50
|
}
|
|
94
51
|
/**
|
|
95
|
-
* Stops the language server
|
|
96
|
-
*
|
|
97
|
-
* This method should be called when the LSP server is no longer needed to
|
|
52
|
+
* Stops the language server, should be called when the LSP server is no longer needed to
|
|
98
53
|
* free up system resources.
|
|
99
54
|
*
|
|
100
55
|
* @returns {Promise<void>}
|
|
@@ -110,9 +65,7 @@ class LspServer {
|
|
|
110
65
|
});
|
|
111
66
|
}
|
|
112
67
|
/**
|
|
113
|
-
* Notifies the language server that a file has been opened
|
|
114
|
-
*
|
|
115
|
-
* This method should be called when a file is opened in the editor to enable
|
|
68
|
+
* Notifies the language server that a file has been opened, enabling
|
|
116
69
|
* language features like diagnostics and completions for that file. The server
|
|
117
70
|
* will begin tracking the file's contents and providing language features.
|
|
118
71
|
*
|
|
@@ -132,10 +85,8 @@ class LspServer {
|
|
|
132
85
|
});
|
|
133
86
|
}
|
|
134
87
|
/**
|
|
135
|
-
* Notifies the language server that a file has been closed
|
|
136
|
-
*
|
|
137
|
-
* This method should be called when a file is closed in the editor to allow
|
|
138
|
-
* the language server to clean up any resources associated with that file.
|
|
88
|
+
* Notifies the language server that a file has been closed, should be called when a file is closed
|
|
89
|
+
* in the editor to allow the language server to clean up any resources associated with that file.
|
|
139
90
|
*
|
|
140
91
|
* @param {string} path - Absolute path to the closed file
|
|
141
92
|
* @returns {Promise<void>}
|
|
@@ -152,10 +103,7 @@ class LspServer {
|
|
|
152
103
|
});
|
|
153
104
|
}
|
|
154
105
|
/**
|
|
155
|
-
* Get symbol information from a document.
|
|
156
|
-
*
|
|
157
|
-
* This method returns information about all symbols (functions, classes,
|
|
158
|
-
* variables, etc.) defined in the specified document.
|
|
106
|
+
* Get symbol information (functions, classes, variables, etc.) from a document.
|
|
159
107
|
*
|
|
160
108
|
* @param {string} path - Absolute path to the file to get symbols from
|
|
161
109
|
* @returns {Promise<LspSymbol[]>} List of symbols in the document. Each symbol includes:
|
|
@@ -175,11 +123,7 @@ class LspServer {
|
|
|
175
123
|
return response.data;
|
|
176
124
|
}
|
|
177
125
|
/**
|
|
178
|
-
* Searches for symbols across the entire Sandbox.
|
|
179
|
-
*
|
|
180
|
-
* This method searches for symbols matching the query string across all files
|
|
181
|
-
* in the Sandbox. It's useful for finding declarations and definitions
|
|
182
|
-
* without knowing which file they're in.
|
|
126
|
+
* Searches for symbols matching the query string across the entire Sandbox.
|
|
183
127
|
*
|
|
184
128
|
* @param {string} query - Search query to match against symbol names
|
|
185
129
|
* @returns {Promise<LspSymbol[]>} List of matching symbols from all files. Each symbol includes:
|
|
@@ -193,11 +137,7 @@ class LspServer {
|
|
|
193
137
|
return await this.sandboxSymbols(query);
|
|
194
138
|
}
|
|
195
139
|
/**
|
|
196
|
-
* Searches for symbols across the entire Sandbox.
|
|
197
|
-
*
|
|
198
|
-
* This method searches for symbols matching the query string across all files
|
|
199
|
-
* in the Sandbox. It's useful for finding declarations and definitions
|
|
200
|
-
* without knowing which file they're in.
|
|
140
|
+
* Searches for symbols matching the query string across the entire Sandbox.
|
|
201
141
|
*
|
|
202
142
|
* @param {string} query - Search query to match against symbol names
|
|
203
143
|
* @returns {Promise<LspSymbol[]>} List of matching symbols from all files. Each symbol includes:
|
package/dist/Process.d.ts
CHANGED
|
@@ -1,38 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The Daytona SDK provides powerful process and code execution capabilities through
|
|
3
|
-
* the `process` module in Sandboxes. This guide covers all available process operations
|
|
4
|
-
* and best practices.
|
|
5
|
-
*
|
|
6
|
-
* @module Process
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* // Execute a shell command
|
|
10
|
-
* const response = await sandbox.process.executeCommand('ls -la');
|
|
11
|
-
* console.log(response.result);
|
|
12
|
-
*
|
|
13
|
-
* // Run TypeScript code
|
|
14
|
-
* const response = await sandbox.process.codeRun('console.log("Hello, World!")');
|
|
15
|
-
* console.log(response.result);
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* // Using interactive sessions
|
|
19
|
-
* // Create a new session
|
|
20
|
-
* const sessionId = 'my-session';
|
|
21
|
-
* await sandbox.process.createSession(sessionId);
|
|
22
|
-
*
|
|
23
|
-
* // Execute commands in the session
|
|
24
|
-
* const response = await sandbox.process.executeSessionCommand(sessionId, {
|
|
25
|
-
* command: 'cd /workspace'
|
|
26
|
-
* });
|
|
27
|
-
*
|
|
28
|
-
* const response2 = await sandbox.process.executeSessionCommand(sessionId, {
|
|
29
|
-
* command: 'pwd'
|
|
30
|
-
* });
|
|
31
|
-
* console.log(response2.result); // Should print "/workspace"
|
|
32
|
-
*
|
|
33
|
-
* // Clean up
|
|
34
|
-
* await sandbox.process.deleteSession(sessionId);
|
|
35
|
-
*/
|
|
36
1
|
import { Command, ExecuteResponse, Session, SessionExecuteRequest, SessionExecuteResponse, ToolboxApi } from '@daytonaio/api-client';
|
|
37
2
|
import { SandboxCodeToolbox, SandboxInstance } from './Sandbox';
|
|
38
3
|
/**
|
|
@@ -48,6 +13,11 @@ export declare class CodeRunParams {
|
|
|
48
13
|
*/
|
|
49
14
|
env?: Record<string, string>;
|
|
50
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Handles process and code execution within a Sandbox.
|
|
18
|
+
*
|
|
19
|
+
* @class
|
|
20
|
+
*/
|
|
51
21
|
export declare class Process {
|
|
52
22
|
private readonly codeToolbox;
|
|
53
23
|
private readonly toolboxApi;
|
package/dist/Process.js
CHANGED
|
@@ -1,39 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* The Daytona SDK provides powerful process and code execution capabilities through
|
|
4
|
-
* the `process` module in Sandboxes. This guide covers all available process operations
|
|
5
|
-
* and best practices.
|
|
6
|
-
*
|
|
7
|
-
* @module Process
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* // Execute a shell command
|
|
11
|
-
* const response = await sandbox.process.executeCommand('ls -la');
|
|
12
|
-
* console.log(response.result);
|
|
13
|
-
*
|
|
14
|
-
* // Run TypeScript code
|
|
15
|
-
* const response = await sandbox.process.codeRun('console.log("Hello, World!")');
|
|
16
|
-
* console.log(response.result);
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* // Using interactive sessions
|
|
20
|
-
* // Create a new session
|
|
21
|
-
* const sessionId = 'my-session';
|
|
22
|
-
* await sandbox.process.createSession(sessionId);
|
|
23
|
-
*
|
|
24
|
-
* // Execute commands in the session
|
|
25
|
-
* const response = await sandbox.process.executeSessionCommand(sessionId, {
|
|
26
|
-
* command: 'cd /workspace'
|
|
27
|
-
* });
|
|
28
|
-
*
|
|
29
|
-
* const response2 = await sandbox.process.executeSessionCommand(sessionId, {
|
|
30
|
-
* command: 'pwd'
|
|
31
|
-
* });
|
|
32
|
-
* console.log(response2.result); // Should print "/workspace"
|
|
33
|
-
*
|
|
34
|
-
* // Clean up
|
|
35
|
-
* await sandbox.process.deleteSession(sessionId);
|
|
36
|
-
*/
|
|
37
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
3
|
exports.Process = exports.CodeRunParams = void 0;
|
|
39
4
|
/**
|
|
@@ -42,6 +7,11 @@ exports.Process = exports.CodeRunParams = void 0;
|
|
|
42
7
|
class CodeRunParams {
|
|
43
8
|
}
|
|
44
9
|
exports.CodeRunParams = CodeRunParams;
|
|
10
|
+
/**
|
|
11
|
+
* Handles process and code execution within a Sandbox.
|
|
12
|
+
*
|
|
13
|
+
* @class
|
|
14
|
+
*/
|
|
45
15
|
class Process {
|
|
46
16
|
constructor(codeToolbox, toolboxApi, instance) {
|
|
47
17
|
this.codeToolbox = codeToolbox;
|
package/dist/Sandbox.d.ts
CHANGED
|
@@ -1,43 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The Daytona SDK core Sandbox functionality.
|
|
3
|
-
*
|
|
4
|
-
* Provides the main Sandbox class representing a Daytona Sandbox that coordinates file system,
|
|
5
|
-
* Git, process execution, and LSP functionality. It serves as the central point
|
|
6
|
-
* for interacting with Daytona Sandboxes.
|
|
7
|
-
*
|
|
8
|
-
* The Sandbox must be in a 'started' state before performing operations.
|
|
9
|
-
*
|
|
10
|
-
* @module Sandbox
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* // Create and initialize sandbox
|
|
14
|
-
* const daytona = new Daytona();
|
|
15
|
-
* const sandbox = await daytona.create();
|
|
16
|
-
*
|
|
17
|
-
* // File operations
|
|
18
|
-
* await sandbox.fs.uploadFile(
|
|
19
|
-
* '/app/config.json',
|
|
20
|
-
* new File(['{"setting": "value"}'], 'config.json')
|
|
21
|
-
* );
|
|
22
|
-
* const contentBlob = await sandbox.fs.downloadFile('/app/config.json');
|
|
23
|
-
*
|
|
24
|
-
* // Git operations
|
|
25
|
-
* await sandbox.git.clone('https://github.com/user/repo.git');
|
|
26
|
-
*
|
|
27
|
-
* // Process execution
|
|
28
|
-
* const response = await sandbox.process.executeCommand('ls -la');
|
|
29
|
-
* console.log(response.result);
|
|
30
|
-
*
|
|
31
|
-
* // LSP functionality
|
|
32
|
-
* const lsp = sandbox.createLspServer('typescript', '/workspace/project');
|
|
33
|
-
* await lsp.didOpen('/workspace/project/src/index.ts');
|
|
34
|
-
* const completions = await lsp.completions('/workspace/project/src/index.ts', {
|
|
35
|
-
* line: 10,
|
|
36
|
-
* character: 15
|
|
37
|
-
* });
|
|
38
|
-
* console.log(completions);
|
|
39
|
-
*
|
|
40
|
-
*/
|
|
41
1
|
import { ToolboxApi, WorkspaceState as SandboxState, WorkspaceApi as SandboxApi, Workspace as ApiSandbox, WorkspaceInfo as ApiSandboxInfo, CreateNodeClassEnum as SandboxClass, CreateNodeRegionEnum as SandboxTargetRegion, Workspace as ApiWorkspace } from '@daytonaio/api-client';
|
|
42
2
|
import { FileSystem } from './FileSystem';
|
|
43
3
|
import { Git } from './Git';
|
|
@@ -51,7 +11,7 @@ export interface SandboxInstance extends Omit<ApiSandbox, 'info'> {
|
|
|
51
11
|
/**
|
|
52
12
|
* Resources allocated to a Sandbox
|
|
53
13
|
*
|
|
54
|
-
* @interface
|
|
14
|
+
* @interface
|
|
55
15
|
* @property {string} cpu - Number of CPU cores allocated (e.g., "1", "2")
|
|
56
16
|
* @property {string | null} gpu - Number of GPUs allocated (e.g., "1") or null if no GPU
|
|
57
17
|
* @property {string} memory - Amount of memory allocated with unit (e.g., "2Gi", "4Gi")
|
|
@@ -81,7 +41,7 @@ export interface SandboxResources {
|
|
|
81
41
|
* This interface provides detailed information about a Sandbox's configuration,
|
|
82
42
|
* resources, and current state.
|
|
83
43
|
*
|
|
84
|
-
* @interface
|
|
44
|
+
* @interface
|
|
85
45
|
* @property {string} id - Unique identifier for the Sandbox
|
|
86
46
|
* @property {string} name - Display name of the Sandbox
|
|
87
47
|
* @property {string} image - Docker image used for the Sandbox
|
|
@@ -148,7 +108,7 @@ export interface SandboxInfo extends ApiSandboxInfo {
|
|
|
148
108
|
}
|
|
149
109
|
/**
|
|
150
110
|
* Interface defining methods that a code toolbox must implement
|
|
151
|
-
* @interface
|
|
111
|
+
* @interface
|
|
152
112
|
*/
|
|
153
113
|
export interface SandboxCodeToolbox {
|
|
154
114
|
/** Generates a command to run the provided code */
|
|
@@ -157,10 +117,6 @@ export interface SandboxCodeToolbox {
|
|
|
157
117
|
/**
|
|
158
118
|
* Represents a Daytona Sandbox.
|
|
159
119
|
*
|
|
160
|
-
* A Sandbox provides file system operations, Git operations, process execution,
|
|
161
|
-
* and LSP functionality. It serves as the main interface for interacting with
|
|
162
|
-
* a Daytona sandbox.
|
|
163
|
-
*
|
|
164
120
|
* @property {string} id - Unique identifier for the Sandbox
|
|
165
121
|
* @property {SandboxInstance} instance - The underlying Sandbox instance
|
|
166
122
|
* @property {SandboxApi} sandboxApi - API client for Sandbox operations
|
|
@@ -169,6 +125,8 @@ export interface SandboxCodeToolbox {
|
|
|
169
125
|
* @property {FileSystem} fs - File system operations interface
|
|
170
126
|
* @property {Git} git - Git operations interface
|
|
171
127
|
* @property {Process} process - Process execution interface
|
|
128
|
+
*
|
|
129
|
+
* @class
|
|
172
130
|
*/
|
|
173
131
|
export declare class Sandbox {
|
|
174
132
|
readonly id: string;
|
package/dist/Sandbox.js
CHANGED
|
@@ -1,44 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* The Daytona SDK core Sandbox functionality.
|
|
4
|
-
*
|
|
5
|
-
* Provides the main Sandbox class representing a Daytona Sandbox that coordinates file system,
|
|
6
|
-
* Git, process execution, and LSP functionality. It serves as the central point
|
|
7
|
-
* for interacting with Daytona Sandboxes.
|
|
8
|
-
*
|
|
9
|
-
* The Sandbox must be in a 'started' state before performing operations.
|
|
10
|
-
*
|
|
11
|
-
* @module Sandbox
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* // Create and initialize sandbox
|
|
15
|
-
* const daytona = new Daytona();
|
|
16
|
-
* const sandbox = await daytona.create();
|
|
17
|
-
*
|
|
18
|
-
* // File operations
|
|
19
|
-
* await sandbox.fs.uploadFile(
|
|
20
|
-
* '/app/config.json',
|
|
21
|
-
* new File(['{"setting": "value"}'], 'config.json')
|
|
22
|
-
* );
|
|
23
|
-
* const contentBlob = await sandbox.fs.downloadFile('/app/config.json');
|
|
24
|
-
*
|
|
25
|
-
* // Git operations
|
|
26
|
-
* await sandbox.git.clone('https://github.com/user/repo.git');
|
|
27
|
-
*
|
|
28
|
-
* // Process execution
|
|
29
|
-
* const response = await sandbox.process.executeCommand('ls -la');
|
|
30
|
-
* console.log(response.result);
|
|
31
|
-
*
|
|
32
|
-
* // LSP functionality
|
|
33
|
-
* const lsp = sandbox.createLspServer('typescript', '/workspace/project');
|
|
34
|
-
* await lsp.didOpen('/workspace/project/src/index.ts');
|
|
35
|
-
* const completions = await lsp.completions('/workspace/project/src/index.ts', {
|
|
36
|
-
* line: 10,
|
|
37
|
-
* character: 15
|
|
38
|
-
* });
|
|
39
|
-
* console.log(completions);
|
|
40
|
-
*
|
|
41
|
-
*/
|
|
42
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
3
|
exports.Sandbox = void 0;
|
|
44
4
|
const FileSystem_1 = require("./FileSystem");
|
|
@@ -49,10 +9,6 @@ const DaytonaError_1 = require("./errors/DaytonaError");
|
|
|
49
9
|
/**
|
|
50
10
|
* Represents a Daytona Sandbox.
|
|
51
11
|
*
|
|
52
|
-
* A Sandbox provides file system operations, Git operations, process execution,
|
|
53
|
-
* and LSP functionality. It serves as the main interface for interacting with
|
|
54
|
-
* a Daytona sandbox.
|
|
55
|
-
*
|
|
56
12
|
* @property {string} id - Unique identifier for the Sandbox
|
|
57
13
|
* @property {SandboxInstance} instance - The underlying Sandbox instance
|
|
58
14
|
* @property {SandboxApi} sandboxApi - API client for Sandbox operations
|
|
@@ -61,6 +17,8 @@ const DaytonaError_1 = require("./errors/DaytonaError");
|
|
|
61
17
|
* @property {FileSystem} fs - File system operations interface
|
|
62
18
|
* @property {Git} git - Git operations interface
|
|
63
19
|
* @property {Process} process - Process execution interface
|
|
20
|
+
*
|
|
21
|
+
* @class
|
|
64
22
|
*/
|
|
65
23
|
class Sandbox {
|
|
66
24
|
/**
|