@daytonaio/sdk 0.11.2 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/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
- * The Daytona SDK provides built-in Git support. This guide covers all available Git
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
@@ -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 in a text document.
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 Position
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,42 +1,8 @@
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
- import { Command, ExecuteResponse, Session, SessionExecuteRequest, SessionExecuteResponse, ToolboxApi } from '@daytonaio/api-client';
1
+ import { Command, Session, SessionExecuteRequest, SessionExecuteResponse, ToolboxApi } from '@daytonaio/api-client';
37
2
  import { SandboxCodeToolbox, SandboxInstance } from './Sandbox';
3
+ import { ExecuteResponse } from './types/ExecuteResponse';
38
4
  /**
39
- * Parameters for code execution
5
+ * Parameters for code execution.
40
6
  */
41
7
  export declare class CodeRunParams {
42
8
  /**
@@ -48,6 +14,11 @@ export declare class CodeRunParams {
48
14
  */
49
15
  env?: Record<string, string>;
50
16
  }
17
+ /**
18
+ * Handles process and code execution within a Sandbox.
19
+ *
20
+ * @class
21
+ */
51
22
  export declare class Process {
52
23
  private readonly codeToolbox;
53
24
  private readonly toolboxApi;
@@ -62,11 +33,12 @@ export declare class Process {
62
33
  * @returns {Promise<ExecuteResponse>} Command execution results containing:
63
34
  * - exitCode: The command's exit status
64
35
  * - result: Standard output from the command
36
+ * - artifacts: ExecutionArtifacts object containing `stdout` (same as result) and `charts` (matplotlib charts metadata)
65
37
  *
66
38
  * @example
67
39
  * // Simple command
68
40
  * const response = await process.executeCommand('echo "Hello"');
69
- * console.log(response.result); // Prints: Hello
41
+ * console.log(response.artifacts.stdout); // Prints: Hello
70
42
  *
71
43
  * @example
72
44
  * // Command with working directory
@@ -82,9 +54,11 @@ export declare class Process {
82
54
  *
83
55
  * @param {string} code - Code to execute
84
56
  * @param {CodeRunParams} params - Parameters for code execution
57
+ * @param {number} [timeout] - Maximum time in seconds to wait for execution to complete
85
58
  * @returns {Promise<ExecuteResponse>} Code execution results containing:
86
59
  * - exitCode: The execution's exit status
87
60
  * - result: Standard output from the code
61
+ * - artifacts: ExecutionArtifacts object containing `stdout` (same as result) and `charts` (matplotlib charts metadata)
88
62
  *
89
63
  * @example
90
64
  * // Run TypeScript code
@@ -93,7 +67,45 @@ export declare class Process {
93
67
  * const y = 20;
94
68
  * console.log(\`Sum: \${x + y}\`);
95
69
  * `);
96
- * console.log(response.result); // Prints: Sum: 30
70
+ * console.log(response.artifacts.stdout); // Prints: Sum: 30
71
+ *
72
+ * @example
73
+ * // Run Python code with matplotlib
74
+ * const response = await process.codeRun(`
75
+ * import matplotlib.pyplot as plt
76
+ * import numpy as np
77
+ *
78
+ * x = np.linspace(0, 10, 30)
79
+ * y = np.sin(x)
80
+ *
81
+ * plt.figure(figsize=(8, 5))
82
+ * plt.plot(x, y, 'b-', linewidth=2)
83
+ * plt.title('Line Chart')
84
+ * plt.xlabel('X-axis (seconds)')
85
+ * plt.ylabel('Y-axis (amplitude)')
86
+ * plt.grid(True)
87
+ * plt.show()
88
+ * `);
89
+ *
90
+ * if (response.artifacts?.charts) {
91
+ * const chart = response.artifacts.charts[0];
92
+ *
93
+ * console.log(`Type: ${chart.type}`);
94
+ * console.log(`Title: ${chart.title}`);
95
+ * if (chart.type === ChartType.LINE) {
96
+ * const lineChart = chart as LineChart
97
+ * console.log('X Label:', lineChart.x_label)
98
+ * console.log('Y Label:', lineChart.y_label)
99
+ * console.log('X Ticks:', lineChart.x_ticks)
100
+ * console.log('Y Ticks:', lineChart.y_ticks)
101
+ * console.log('X Tick Labels:', lineChart.x_tick_labels)
102
+ * console.log('Y Tick Labels:', lineChart.y_tick_labels)
103
+ * console.log('X Scale:', lineChart.x_scale)
104
+ * console.log('Y Scale:', lineChart.y_scale)
105
+ * console.log('Elements:')
106
+ * console.dir(lineChart.elements, { depth: null })
107
+ * }
108
+ * }
97
109
  */
98
110
  codeRun(code: string, params?: CodeRunParams, timeout?: number): Promise<ExecuteResponse>;
99
111
  /**