@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.
Files changed (237) hide show
  1. package/LICENSE +190 -0
  2. package/cjs/CodeInterpreter.d.ts +95 -0
  3. package/cjs/CodeInterpreter.d.ts.map +1 -0
  4. package/cjs/CodeInterpreter.js +297 -0
  5. package/cjs/CodeInterpreter.js.map +1 -0
  6. package/cjs/ComputerUse.d.ts +539 -0
  7. package/cjs/ComputerUse.d.ts.map +1 -0
  8. package/cjs/ComputerUse.js +808 -0
  9. package/cjs/ComputerUse.js.map +1 -0
  10. package/cjs/Daytona.d.ts +355 -0
  11. package/cjs/Daytona.d.ts.map +1 -0
  12. package/cjs/Daytona.js +527 -0
  13. package/cjs/Daytona.js.map +1 -0
  14. package/cjs/FileSystem.d.ts +371 -0
  15. package/cjs/FileSystem.d.ts.map +1 -0
  16. package/cjs/FileSystem.js +489 -0
  17. package/cjs/FileSystem.js.map +1 -0
  18. package/cjs/Git.d.ts +203 -0
  19. package/cjs/Git.d.ts.map +1 -0
  20. package/cjs/Git.js +326 -0
  21. package/cjs/Git.js.map +1 -0
  22. package/cjs/Image.d.ts +265 -0
  23. package/cjs/Image.d.ts.map +1 -0
  24. package/cjs/Image.js +586 -0
  25. package/cjs/Image.js.map +1 -0
  26. package/cjs/LspServer.d.ts +172 -0
  27. package/cjs/LspServer.d.ts.map +1 -0
  28. package/cjs/LspServer.js +259 -0
  29. package/cjs/LspServer.js.map +1 -0
  30. package/cjs/ObjectStorage.d.ts +79 -0
  31. package/cjs/ObjectStorage.d.ts.map +1 -0
  32. package/cjs/ObjectStorage.js +199 -0
  33. package/cjs/ObjectStorage.js.map +1 -0
  34. package/cjs/Process.d.ts +490 -0
  35. package/cjs/Process.d.ts.map +1 -0
  36. package/cjs/Process.js +647 -0
  37. package/cjs/Process.js.map +1 -0
  38. package/cjs/PtyHandle.d.ts +155 -0
  39. package/cjs/PtyHandle.d.ts.map +1 -0
  40. package/cjs/PtyHandle.js +416 -0
  41. package/cjs/PtyHandle.js.map +1 -0
  42. package/cjs/README.md +180 -0
  43. package/cjs/Sandbox.d.ts +476 -0
  44. package/cjs/Sandbox.d.ts.map +1 -0
  45. package/cjs/Sandbox.js +905 -0
  46. package/cjs/Sandbox.js.map +1 -0
  47. package/cjs/Snapshot.d.ts +140 -0
  48. package/cjs/Snapshot.d.ts.map +1 -0
  49. package/cjs/Snapshot.js +248 -0
  50. package/cjs/Snapshot.js.map +1 -0
  51. package/cjs/Volume.d.ts +84 -0
  52. package/cjs/Volume.d.ts.map +1 -0
  53. package/cjs/Volume.js +119 -0
  54. package/cjs/Volume.js.map +1 -0
  55. package/cjs/__tests__/helpers.d.ts +6 -0
  56. package/cjs/__tests__/helpers.d.ts.map +1 -0
  57. package/cjs/__tests__/helpers.js +26 -0
  58. package/cjs/__tests__/helpers.js.map +1 -0
  59. package/cjs/errors/DaytonaError.d.ts +171 -0
  60. package/cjs/errors/DaytonaError.d.ts.map +1 -0
  61. package/cjs/errors/DaytonaError.js +258 -0
  62. package/cjs/errors/DaytonaError.js.map +1 -0
  63. package/cjs/index.d.ts +22 -0
  64. package/cjs/index.d.ts.map +1 -0
  65. package/cjs/index.js +49 -0
  66. package/cjs/index.js.map +1 -0
  67. package/cjs/package.json +3 -0
  68. package/cjs/types/Charts.d.ts +38 -0
  69. package/cjs/types/Charts.d.ts.map +1 -0
  70. package/cjs/types/Charts.js +37 -0
  71. package/cjs/types/Charts.js.map +1 -0
  72. package/cjs/types/CodeInterpreter.d.ts +77 -0
  73. package/cjs/types/CodeInterpreter.d.ts.map +1 -0
  74. package/cjs/types/CodeInterpreter.js +7 -0
  75. package/cjs/types/CodeInterpreter.js.map +1 -0
  76. package/cjs/types/ExecuteResponse.d.ts +26 -0
  77. package/cjs/types/ExecuteResponse.d.ts.map +1 -0
  78. package/cjs/types/ExecuteResponse.js +7 -0
  79. package/cjs/types/ExecuteResponse.js.map +1 -0
  80. package/cjs/types/Pty.d.ts +48 -0
  81. package/cjs/types/Pty.d.ts.map +1 -0
  82. package/cjs/types/Pty.js +7 -0
  83. package/cjs/types/Pty.js.map +1 -0
  84. package/cjs/utils/Binary.d.ts +39 -0
  85. package/cjs/utils/Binary.d.ts.map +1 -0
  86. package/cjs/utils/Binary.js +168 -0
  87. package/cjs/utils/Binary.js.map +1 -0
  88. package/cjs/utils/FileTransfer.d.ts +15 -0
  89. package/cjs/utils/FileTransfer.d.ts.map +1 -0
  90. package/cjs/utils/FileTransfer.js +261 -0
  91. package/cjs/utils/FileTransfer.js.map +1 -0
  92. package/cjs/utils/Import.d.ts +125 -0
  93. package/cjs/utils/Import.d.ts.map +1 -0
  94. package/cjs/utils/Import.js +112 -0
  95. package/cjs/utils/Import.js.map +1 -0
  96. package/cjs/utils/Multipart.d.ts +29 -0
  97. package/cjs/utils/Multipart.d.ts.map +1 -0
  98. package/cjs/utils/Multipart.js +115 -0
  99. package/cjs/utils/Multipart.js.map +1 -0
  100. package/cjs/utils/Runtime.d.ts +44 -0
  101. package/cjs/utils/Runtime.d.ts.map +1 -0
  102. package/cjs/utils/Runtime.js +95 -0
  103. package/cjs/utils/Runtime.js.map +1 -0
  104. package/cjs/utils/Stream.d.ts +20 -0
  105. package/cjs/utils/Stream.d.ts.map +1 -0
  106. package/cjs/utils/Stream.js +364 -0
  107. package/cjs/utils/Stream.js.map +1 -0
  108. package/cjs/utils/WebSocket.d.ts +10 -0
  109. package/cjs/utils/WebSocket.d.ts.map +1 -0
  110. package/cjs/utils/WebSocket.js +26 -0
  111. package/cjs/utils/WebSocket.js.map +1 -0
  112. package/cjs/utils/otel.decorator.d.ts +83 -0
  113. package/cjs/utils/otel.decorator.d.ts.map +1 -0
  114. package/cjs/utils/otel.decorator.js +141 -0
  115. package/cjs/utils/otel.decorator.js.map +1 -0
  116. package/esm/CodeInterpreter.d.ts +95 -0
  117. package/esm/CodeInterpreter.d.ts.map +1 -0
  118. package/esm/CodeInterpreter.js +292 -0
  119. package/esm/CodeInterpreter.js.map +1 -0
  120. package/esm/ComputerUse.d.ts +539 -0
  121. package/esm/ComputerUse.d.ts.map +1 -0
  122. package/esm/ComputerUse.js +799 -0
  123. package/esm/ComputerUse.js.map +1 -0
  124. package/esm/Daytona.d.ts +355 -0
  125. package/esm/Daytona.d.ts.map +1 -0
  126. package/esm/Daytona.js +523 -0
  127. package/esm/Daytona.js.map +1 -0
  128. package/esm/FileSystem.d.ts +371 -0
  129. package/esm/FileSystem.d.ts.map +1 -0
  130. package/esm/FileSystem.js +485 -0
  131. package/esm/FileSystem.js.map +1 -0
  132. package/esm/Git.d.ts +203 -0
  133. package/esm/Git.d.ts.map +1 -0
  134. package/esm/Git.js +322 -0
  135. package/esm/Git.js.map +1 -0
  136. package/esm/Image.d.ts +265 -0
  137. package/esm/Image.d.ts.map +1 -0
  138. package/esm/Image.js +581 -0
  139. package/esm/Image.js.map +1 -0
  140. package/esm/LspServer.d.ts +172 -0
  141. package/esm/LspServer.d.ts.map +1 -0
  142. package/esm/LspServer.js +255 -0
  143. package/esm/LspServer.js.map +1 -0
  144. package/esm/ObjectStorage.d.ts +79 -0
  145. package/esm/ObjectStorage.d.ts.map +1 -0
  146. package/esm/ObjectStorage.js +195 -0
  147. package/esm/ObjectStorage.js.map +1 -0
  148. package/esm/Process.d.ts +490 -0
  149. package/esm/Process.d.ts.map +1 -0
  150. package/esm/Process.js +642 -0
  151. package/esm/Process.js.map +1 -0
  152. package/esm/PtyHandle.d.ts +155 -0
  153. package/esm/PtyHandle.d.ts.map +1 -0
  154. package/esm/PtyHandle.js +412 -0
  155. package/esm/PtyHandle.js.map +1 -0
  156. package/esm/README.md +180 -0
  157. package/esm/Sandbox.d.ts +476 -0
  158. package/esm/Sandbox.d.ts.map +1 -0
  159. package/esm/Sandbox.js +901 -0
  160. package/esm/Sandbox.js.map +1 -0
  161. package/esm/Snapshot.d.ts +140 -0
  162. package/esm/Snapshot.d.ts.map +1 -0
  163. package/esm/Snapshot.js +244 -0
  164. package/esm/Snapshot.js.map +1 -0
  165. package/esm/Volume.d.ts +84 -0
  166. package/esm/Volume.d.ts.map +1 -0
  167. package/esm/Volume.js +115 -0
  168. package/esm/Volume.js.map +1 -0
  169. package/esm/__tests__/helpers.d.ts +6 -0
  170. package/esm/__tests__/helpers.d.ts.map +1 -0
  171. package/esm/__tests__/helpers.js +20 -0
  172. package/esm/__tests__/helpers.js.map +1 -0
  173. package/esm/errors/DaytonaError.d.ts +171 -0
  174. package/esm/errors/DaytonaError.d.ts.map +1 -0
  175. package/esm/errors/DaytonaError.js +243 -0
  176. package/esm/errors/DaytonaError.js.map +1 -0
  177. package/esm/index.d.ts +22 -0
  178. package/esm/index.d.ts.map +1 -0
  179. package/esm/index.js +21 -0
  180. package/esm/index.js.map +1 -0
  181. package/esm/package.json +3 -0
  182. package/esm/types/Charts.d.ts +38 -0
  183. package/esm/types/Charts.d.ts.map +1 -0
  184. package/esm/types/Charts.js +33 -0
  185. package/esm/types/Charts.js.map +1 -0
  186. package/esm/types/CodeInterpreter.d.ts +77 -0
  187. package/esm/types/CodeInterpreter.d.ts.map +1 -0
  188. package/esm/types/CodeInterpreter.js +6 -0
  189. package/esm/types/CodeInterpreter.js.map +1 -0
  190. package/esm/types/ExecuteResponse.d.ts +26 -0
  191. package/esm/types/ExecuteResponse.d.ts.map +1 -0
  192. package/esm/types/ExecuteResponse.js +6 -0
  193. package/esm/types/ExecuteResponse.js.map +1 -0
  194. package/esm/types/Pty.d.ts +48 -0
  195. package/esm/types/Pty.d.ts.map +1 -0
  196. package/esm/types/Pty.js +6 -0
  197. package/esm/types/Pty.js.map +1 -0
  198. package/esm/utils/Binary.d.ts +39 -0
  199. package/esm/utils/Binary.d.ts.map +1 -0
  200. package/esm/utils/Binary.js +157 -0
  201. package/esm/utils/Binary.js.map +1 -0
  202. package/esm/utils/FileTransfer.d.ts +15 -0
  203. package/esm/utils/FileTransfer.d.ts.map +1 -0
  204. package/esm/utils/FileTransfer.js +254 -0
  205. package/esm/utils/FileTransfer.js.map +1 -0
  206. package/esm/utils/Import.d.ts +95 -0
  207. package/esm/utils/Import.d.ts.map +1 -0
  208. package/esm/utils/Import.js +77 -0
  209. package/esm/utils/Import.js.map +1 -0
  210. package/esm/utils/Multipart.d.ts +29 -0
  211. package/esm/utils/Multipart.d.ts.map +1 -0
  212. package/esm/utils/Multipart.js +109 -0
  213. package/esm/utils/Multipart.js.map +1 -0
  214. package/esm/utils/Runtime.d.ts +44 -0
  215. package/esm/utils/Runtime.d.ts.map +1 -0
  216. package/esm/utils/Runtime.js +89 -0
  217. package/esm/utils/Runtime.js.map +1 -0
  218. package/esm/utils/Stream.d.ts +20 -0
  219. package/esm/utils/Stream.d.ts.map +1 -0
  220. package/esm/utils/Stream.js +360 -0
  221. package/esm/utils/Stream.js.map +1 -0
  222. package/esm/utils/WebSocket.d.ts +10 -0
  223. package/esm/utils/WebSocket.d.ts.map +1 -0
  224. package/esm/utils/WebSocket.js +22 -0
  225. package/esm/utils/WebSocket.js.map +1 -0
  226. package/esm/utils/otel.decorator.d.ts +83 -0
  227. package/esm/utils/otel.decorator.d.ts.map +1 -0
  228. package/esm/utils/otel.decorator.js +136 -0
  229. package/esm/utils/otel.decorator.js.map +1 -0
  230. package/package.json +20 -8
  231. package/src/ComputerUse.d.ts +4 -4
  232. package/src/ComputerUse.js +4 -4
  233. package/src/Sandbox.d.ts +1 -18
  234. package/src/Sandbox.js +0 -29
  235. package/src/Sandbox.js.map +1 -1
  236. package/src/__tests__/helpers.js +0 -2
  237. package/src/__tests__/helpers.js.map +1 -1
@@ -0,0 +1,490 @@
1
+ import { Configuration, ProcessApi, Command, Session, SessionExecuteRequest, SessionExecuteResponse as ApiSessionExecuteResponse, PtySessionInfo } from '@daytona/toolbox-api-client';
2
+ import { ExecuteResponse } from './types/ExecuteResponse.js';
3
+ import { PtyHandle } from './PtyHandle.js';
4
+ import { PtyCreateOptions, PtyConnectOptions } from './types/Pty.js';
5
+ export declare const STDOUT_PREFIX_BYTES: Uint8Array<ArrayBuffer>;
6
+ export declare const STDERR_PREFIX_BYTES: Uint8Array<ArrayBuffer>;
7
+ export declare const MAX_PREFIX_LEN: number;
8
+ /**
9
+ * Parameters for code execution.
10
+ */
11
+ export declare class CodeRunParams {
12
+ /**
13
+ * Command line arguments
14
+ */
15
+ argv?: string[];
16
+ /**
17
+ * Environment variables
18
+ */
19
+ env?: Record<string, string>;
20
+ }
21
+ export interface SessionExecuteResponse extends ApiSessionExecuteResponse {
22
+ stdout?: string;
23
+ stderr?: string;
24
+ }
25
+ export interface SessionCommandLogsResponse {
26
+ output?: string;
27
+ stdout?: string;
28
+ stderr?: string;
29
+ }
30
+ /**
31
+ * Handles process and code execution within a Sandbox.
32
+ *
33
+ * @class
34
+ */
35
+ export declare class Process {
36
+ private readonly clientConfig;
37
+ private readonly apiClient;
38
+ private readonly getPreviewToken;
39
+ private readonly language?;
40
+ constructor(clientConfig: Configuration, apiClient: ProcessApi, getPreviewToken: () => Promise<string>, language?: string);
41
+ /**
42
+ * Executes a shell command in the Sandbox.
43
+ *
44
+ * @param {string} command - Shell command to execute
45
+ * @param {string} [cwd] - Working directory for command execution. If not specified, uses the sandbox working directory.
46
+ * @param {Record<string, string>} [env] - Environment variables to set for the command
47
+ * @param {number} [timeout] - Maximum time in seconds to wait for the command to complete.
48
+ * @returns {Promise<ExecuteResponse>} Command execution results containing:
49
+ * - exitCode: The command's exit status
50
+ * - result: Standard output from the command
51
+ * - artifacts: ExecutionArtifacts object containing `stdout` (same as result) and `charts` (matplotlib charts metadata)
52
+ *
53
+ * @example
54
+ * // Simple command
55
+ * const response = await process.executeCommand('echo "Hello"');
56
+ * console.log(response.artifacts.stdout); // Prints: Hello
57
+ *
58
+ * @example
59
+ * // Command with working directory
60
+ * const result = await process.executeCommand('ls', 'workspace/src');
61
+ *
62
+ * @example
63
+ * // Command with timeout
64
+ * const result = await process.executeCommand('sleep 10', undefined, 5);
65
+ */
66
+ executeCommand(command: string, cwd?: string, env?: Record<string, string>, timeout?: number): Promise<ExecuteResponse>;
67
+ /**
68
+ * Executes code in the Sandbox using the appropriate language runtime.
69
+ *
70
+ * @param {string} code - Code to execute
71
+ * @param {CodeRunParams} params - Parameters for code execution
72
+ * @param {number} [timeout] - Maximum time in seconds to wait for execution to complete
73
+ * @returns {Promise<ExecuteResponse>} Code execution results containing:
74
+ * - exitCode: The execution's exit status
75
+ * - result: Standard output from the code
76
+ * - artifacts: ExecutionArtifacts object containing `stdout` (same as result) and `charts` (matplotlib charts metadata)
77
+ *
78
+ * @example
79
+ * // Run TypeScript code
80
+ * const response = await process.codeRun(`
81
+ * const x = 10;
82
+ * const y = 20;
83
+ * console.log(\`Sum: \${x + y}\`);
84
+ * `);
85
+ * console.log(response.artifacts.stdout); // Prints: Sum: 30
86
+ *
87
+ * @example
88
+ * // Run Python code with matplotlib
89
+ * const response = await process.codeRun(`
90
+ * import matplotlib.pyplot as plt
91
+ * import numpy as np
92
+ *
93
+ * x = np.linspace(0, 10, 30)
94
+ * y = np.sin(x)
95
+ *
96
+ * plt.figure(figsize=(8, 5))
97
+ * plt.plot(x, y, 'b-', linewidth=2)
98
+ * plt.title('Line Chart')
99
+ * plt.xlabel('X-axis (seconds)')
100
+ * plt.ylabel('Y-axis (amplitude)')
101
+ * plt.grid(True)
102
+ * plt.show()
103
+ * `);
104
+ *
105
+ * if (response.artifacts?.charts) {
106
+ * const chart = response.artifacts.charts[0];
107
+ *
108
+ * console.log(`Type: ${chart.type}`);
109
+ * console.log(`Title: ${chart.title}`);
110
+ * if (chart.type === ChartType.LINE) {
111
+ * const lineChart = chart as LineChart
112
+ * console.log('X Label:', lineChart.x_label)
113
+ * console.log('Y Label:', lineChart.y_label)
114
+ * console.log('X Ticks:', lineChart.x_ticks)
115
+ * console.log('Y Ticks:', lineChart.y_ticks)
116
+ * console.log('X Tick Labels:', lineChart.x_tick_labels)
117
+ * console.log('Y Tick Labels:', lineChart.y_tick_labels)
118
+ * console.log('X Scale:', lineChart.x_scale)
119
+ * console.log('Y Scale:', lineChart.y_scale)
120
+ * console.log('Elements:')
121
+ * console.dir(lineChart.elements, { depth: null })
122
+ * }
123
+ * }
124
+ */
125
+ codeRun(code: string, params?: CodeRunParams, timeout?: number): Promise<ExecuteResponse>;
126
+ /**
127
+ * Creates a new long-running background session in the Sandbox.
128
+ *
129
+ * Sessions are background processes that maintain state between commands, making them ideal for
130
+ * scenarios requiring multiple related commands or persistent environment setup. You can run
131
+ * long-running commands and monitor process status.
132
+ *
133
+ * @param {string} sessionId - Unique identifier for the new session
134
+ * @returns {Promise<void>}
135
+ *
136
+ * @example
137
+ * // Create a new session
138
+ * const sessionId = 'my-session';
139
+ * await process.createSession(sessionId);
140
+ * const session = await process.getSession(sessionId);
141
+ * // Do work...
142
+ * await process.deleteSession(sessionId);
143
+ */
144
+ createSession(sessionId: string): Promise<void>;
145
+ /**
146
+ * Get a session in the sandbox.
147
+ *
148
+ * @param {string} sessionId - Unique identifier of the session to retrieve
149
+ * @returns {Promise<Session>} Session information including:
150
+ * - sessionId: The session's unique identifier
151
+ * - commands: List of commands executed in the session
152
+ *
153
+ * @example
154
+ * const session = await process.getSession('my-session');
155
+ * session.commands.forEach(cmd => {
156
+ * console.log(`Command: ${cmd.command}`);
157
+ * });
158
+ */
159
+ getSession(sessionId: string): Promise<Session>;
160
+ /**
161
+ * Get the sandbox entrypoint session
162
+ *
163
+ * @returns {Promise<Session>} Entrypoint session information including:
164
+ * - sessionId: The entrypoint session's unique identifier
165
+ * - commands: List of commands executed in the entrypoint session
166
+ *
167
+ * @example
168
+ * const session = await process.getEntrypointSession();
169
+ * session.commands.forEach(cmd => {
170
+ * console.log(`Command: ${cmd.command}`);
171
+ * });
172
+ */
173
+ getEntrypointSession(): Promise<Session>;
174
+ /**
175
+ * Gets information about a specific command executed in a session.
176
+ *
177
+ * @param {string} sessionId - Unique identifier of the session
178
+ * @param {string} commandId - Unique identifier of the command
179
+ * @returns {Promise<Command>} Command information including:
180
+ * - id: The command's unique identifier
181
+ * - command: The executed command string
182
+ * - exitCode: Command's exit status (if completed)
183
+ *
184
+ * @example
185
+ * const cmd = await process.getSessionCommand('my-session', 'cmd-123');
186
+ * if (cmd.exitCode === 0) {
187
+ * console.log(`Command ${cmd.command} completed successfully`);
188
+ * }
189
+ */
190
+ getSessionCommand(sessionId: string, commandId: string): Promise<Command>;
191
+ /**
192
+ * Executes a command in an existing session.
193
+ *
194
+ * @param {string} sessionId - Unique identifier of the session to use
195
+ * @param {SessionExecuteRequest} req - Command execution request containing:
196
+ * - command: The command to execute
197
+ * - runAsync: Whether to execute asynchronously
198
+ * - suppressInputEcho: Whether to suppress input echo. Default is `false`.
199
+ * @param {number} timeout - Timeout in seconds
200
+ * @returns {Promise<SessionExecuteResponse>} Command execution results containing:
201
+ * - cmdId: Unique identifier for the executed command
202
+ * - output: Combined command output (stdout and stderr) (if synchronous execution)
203
+ * - stdout: Standard output from the command
204
+ * - stderr: Standard error from the command
205
+ * - exitCode: Command exit status (if synchronous execution)
206
+ *
207
+ * @example
208
+ * // Execute commands in sequence, maintaining state
209
+ * const sessionId = 'my-session';
210
+ *
211
+ * // Change directory
212
+ * await process.executeSessionCommand(sessionId, {
213
+ * command: 'cd /home/daytona'
214
+ * });
215
+ *
216
+ * // Run command in new directory
217
+ * const result = await process.executeSessionCommand(sessionId, {
218
+ * command: 'pwd'
219
+ * });
220
+ * console.log('[STDOUT]:', result.stdout);
221
+ * console.log('[STDERR]:', result.stderr);
222
+ */
223
+ executeSessionCommand(sessionId: string, req: SessionExecuteRequest, timeout?: number): Promise<SessionExecuteResponse>;
224
+ /**
225
+ * Get the logs for a command executed in a session.
226
+ *
227
+ * @param {string} sessionId - Unique identifier of the session
228
+ * @param {string} commandId - Unique identifier of the command
229
+ * @returns {Promise<SessionCommandLogsResponse>} Command logs containing: output (combined stdout and stderr), stdout and stderr
230
+ *
231
+ * @example
232
+ * const logs = await process.getSessionCommandLogs('my-session', 'cmd-123');
233
+ * console.log('[STDOUT]:', logs.stdout);
234
+ * console.log('[STDERR]:', logs.stderr);
235
+ */
236
+ getSessionCommandLogs(sessionId: string, commandId: string): Promise<SessionCommandLogsResponse>;
237
+ /**
238
+ * Asynchronously retrieve and process the logs for a command executed in a session as they become available.
239
+ *
240
+ * @param {string} sessionId - Unique identifier of the session
241
+ * @param {string} commandId - Unique identifier of the command
242
+ * @param {function} onStdout - Callback function to handle stdout log chunks
243
+ * @param {function} onStderr - Callback function to handle stderr log chunks
244
+ * @returns {Promise<void>}
245
+ *
246
+ * @example
247
+ * const logs = await process.getSessionCommandLogs('my-session', 'cmd-123', (chunk) => {
248
+ * console.log('[STDOUT]:', chunk);
249
+ * }, (chunk) => {
250
+ * console.log('[STDERR]:', chunk);
251
+ * });
252
+ */
253
+ getSessionCommandLogs(sessionId: string, commandId: string, onStdout: (chunk: string) => void, onStderr: (chunk: string) => void): Promise<void>;
254
+ /**
255
+ * Get the logs for the sandbox entrypoint session.
256
+ *
257
+ * @returns {Promise<SessionCommandLogsResponse>} Command logs containing: output (combined stdout and stderr), stdout and stderr
258
+ *
259
+ * @example
260
+ * const logs = await process.getEntrypointLogs();
261
+ * console.log('[STDOUT]:', logs.stdout);
262
+ * console.log('[STDERR]:', logs.stderr);
263
+ */
264
+ getEntrypointLogs(): Promise<SessionCommandLogsResponse>;
265
+ /**
266
+ * Asynchronously retrieve and process the logs for the entrypoint session as they become available.
267
+ *
268
+ * @param {function} onStdout - Callback function to handle stdout log chunks
269
+ * @param {function} onStderr - Callback function to handle stderr log chunks
270
+ * @returns {Promise<void>}
271
+ *
272
+ * @example
273
+ * const logs = await process.getEntrypointLogs((chunk) => {
274
+ * console.log('[STDOUT]:', chunk);
275
+ * }, (chunk) => {
276
+ * console.log('[STDERR]:', chunk);
277
+ * });
278
+ */
279
+ getEntrypointLogs(onStdout: (chunk: string) => void, onStderr: (chunk: string) => void): Promise<void>;
280
+ /**
281
+ * Sends input data to a command executed in a session.
282
+ *
283
+ * @param {string} sessionId - Unique identifier of the session
284
+ * @param {string} commandId - Unique identifier of the command
285
+ * @param {string} data - Input data to send
286
+ * @returns {Promise<void>}
287
+ */
288
+ sendSessionCommandInput(sessionId: string, commandId: string, data: string): Promise<void>;
289
+ /**
290
+ * Lists all active sessions in the Sandbox.
291
+ *
292
+ * @returns {Promise<Session[]>} Array of active sessions
293
+ *
294
+ * @example
295
+ * const sessions = await process.listSessions();
296
+ * sessions.forEach(session => {
297
+ * console.log(`Session ${session.sessionId}:`);
298
+ * session.commands.forEach(cmd => {
299
+ * console.log(`- ${cmd.command} (${cmd.exitCode})`);
300
+ * });
301
+ * });
302
+ */
303
+ listSessions(): Promise<Session[]>;
304
+ /**
305
+ * Delete a session from the Sandbox.
306
+ *
307
+ * @param {string} sessionId - Unique identifier of the session to delete
308
+ * @returns {Promise<void>}
309
+ *
310
+ * @example
311
+ * // Clean up a completed session
312
+ * await process.deleteSession('my-session');
313
+ */
314
+ deleteSession(sessionId: string): Promise<void>;
315
+ /**
316
+ * Create a new PTY (pseudo-terminal) session in the sandbox.
317
+ *
318
+ * Creates an interactive terminal session that can execute commands and handle user input.
319
+ * The PTY session behaves like a real terminal, supporting features like command history.
320
+ *
321
+ * @param {PtyCreateOptions & PtyConnectOptions} options - PTY session configuration including creation and connection options
322
+ * @returns {Promise<PtyHandle>} PTY handle for managing the session
323
+ *
324
+ * @example
325
+ * // Create a PTY session with custom configuration
326
+ * const ptyHandle = await process.createPty({
327
+ * id: 'my-interactive-session',
328
+ * cwd: '/workspace',
329
+ * envs: { TERM: 'xterm-256color', LANG: 'en_US.UTF-8' },
330
+ * cols: 120,
331
+ * rows: 30,
332
+ * onData: (data) => {
333
+ * // Handle terminal output
334
+ * const text = new TextDecoder().decode(data);
335
+ * process.stdout.write(text);
336
+ * },
337
+ * });
338
+ *
339
+ * // Wait for connection to be established
340
+ * await ptyHandle.waitForConnection();
341
+ *
342
+ * // Send commands to the terminal
343
+ * await ptyHandle.sendInput('ls -la\n');
344
+ * await ptyHandle.sendInput('echo "Hello, PTY!"\n');
345
+ * await ptyHandle.sendInput('exit\n');
346
+ *
347
+ * // Wait for completion and get result
348
+ * const result = await ptyHandle.wait();
349
+ * console.log(`PTY session completed with exit code: ${result.exitCode}`);
350
+ *
351
+ * // Clean up
352
+ * await ptyHandle.disconnect();
353
+ */
354
+ createPty(options?: PtyCreateOptions & PtyConnectOptions): Promise<PtyHandle>;
355
+ /**
356
+ * Connect to an existing PTY session in the sandbox.
357
+ *
358
+ * Establishes a WebSocket connection to an existing PTY session, allowing you to
359
+ * interact with a previously created terminal session.
360
+ *
361
+ * @param {string} sessionId - ID of the PTY session to connect to
362
+ * @param {PtyConnectOptions} options - Options for the connection including data handler
363
+ * @returns {Promise<PtyHandle>} PTY handle for managing the session
364
+ *
365
+ * @example
366
+ * // Connect to an existing PTY session
367
+ * const handle = await process.connectPty('my-session', {
368
+ * onData: (data) => {
369
+ * // Handle terminal output
370
+ * const text = new TextDecoder().decode(data);
371
+ * process.stdout.write(text);
372
+ * },
373
+ * });
374
+ *
375
+ * // Wait for connection to be established
376
+ * await handle.waitForConnection();
377
+ *
378
+ * // Send commands to the existing session
379
+ * await handle.sendInput('pwd\n');
380
+ * await handle.sendInput('ls -la\n');
381
+ * await handle.sendInput('exit\n');
382
+ *
383
+ * // Wait for completion
384
+ * const result = await handle.wait();
385
+ * console.log(`Session exited with code: ${result.exitCode}`);
386
+ *
387
+ * // Clean up
388
+ * await handle.disconnect();
389
+ */
390
+ connectPty(sessionId: string, options?: PtyConnectOptions): Promise<PtyHandle>;
391
+ /**
392
+ * List all PTY sessions in the sandbox.
393
+ *
394
+ * Retrieves information about all PTY sessions, both active and inactive,
395
+ * that have been created in this sandbox.
396
+ *
397
+ * @returns {Promise<PtySessionInfo[]>} Array of PTY session information
398
+ *
399
+ * @example
400
+ * // List all PTY sessions
401
+ * const sessions = await process.listPtySessions();
402
+ *
403
+ * for (const session of sessions) {
404
+ * console.log(`Session ID: ${session.id}`);
405
+ * console.log(`Active: ${session.active}`);
406
+ * console.log(`Created: ${session.createdAt}`);
407
+ * }
408
+ * console.log('---');
409
+ * }
410
+ */
411
+ listPtySessions(): Promise<PtySessionInfo[]>;
412
+ /**
413
+ * Get detailed information about a specific PTY session.
414
+ *
415
+ * Retrieves comprehensive information about a PTY session including its current state,
416
+ * configuration, and metadata.
417
+ *
418
+ * @param {string} sessionId - ID of the PTY session to retrieve information for
419
+ * @returns {Promise<PtySessionInfo>} PTY session information
420
+ *
421
+ * @throws {Error} If the PTY session doesn't exist
422
+ *
423
+ * @example
424
+ * // Get details about a specific PTY session
425
+ * const session = await process.getPtySessionInfo('my-session');
426
+ *
427
+ * console.log(`Session ID: ${session.id}`);
428
+ * console.log(`Active: ${session.active}`);
429
+ * console.log(`Working Directory: ${session.cwd}`);
430
+ * console.log(`Terminal Size: ${session.cols}x${session.rows}`);
431
+ *
432
+ * if (session.processId) {
433
+ * console.log(`Process ID: ${session.processId}`);
434
+ * }
435
+ */
436
+ getPtySessionInfo(sessionId: string): Promise<PtySessionInfo>;
437
+ /**
438
+ * Kill a PTY session and terminate its associated process.
439
+ *
440
+ * Forcefully terminates the PTY session and cleans up all associated resources.
441
+ * This will close any active connections and kill the underlying shell process.
442
+ *
443
+ * @param {string} sessionId - ID of the PTY session to kill
444
+ * @returns {Promise<void>}
445
+ *
446
+ * @throws {Error} If the PTY session doesn't exist or cannot be killed
447
+ *
448
+ * @note This operation is irreversible. Any unsaved work in the terminal session will be lost.
449
+ *
450
+ * @example
451
+ * // Kill a specific PTY session
452
+ * await process.killPtySession('my-session');
453
+ *
454
+ * // Verify the session is no longer active
455
+ * try {
456
+ * const info = await process.getPtySessionInfo('my-session');
457
+ * console.log(`Session still exists but active: ${info.active}`);
458
+ * } catch (error) {
459
+ * console.log('Session has been completely removed');
460
+ * }
461
+ */
462
+ killPtySession(sessionId: string): Promise<void>;
463
+ /**
464
+ * Resize a PTY session's terminal dimensions.
465
+ *
466
+ * Changes the terminal size of an active PTY session. This is useful when the
467
+ * client terminal is resized or when you need to adjust the display for different
468
+ * output requirements.
469
+ *
470
+ * @param {string} sessionId - ID of the PTY session to resize
471
+ * @param {number} cols - New number of terminal columns
472
+ * @param {number} rows - New number of terminal rows
473
+ * @returns {Promise<PtySessionInfo>} Updated session information reflecting the new terminal size
474
+ *
475
+ * @throws {Error} If the PTY session doesn't exist or resize operation fails
476
+ *
477
+ * @note The resize operation will send a SIGWINCH signal to the shell process,
478
+ * allowing terminal applications to adapt to the new size.
479
+ *
480
+ * @example
481
+ * // Resize a PTY session to a larger terminal
482
+ * const updatedInfo = await process.resizePtySession('my-session', 150, 40);
483
+ * console.log(`Terminal resized to ${updatedInfo.cols}x${updatedInfo.rows}`);
484
+ *
485
+ * // You can also use the PtyHandle's resize method
486
+ * await ptyHandle.resize(150, 40); // cols, rows
487
+ */
488
+ resizePtySession(sessionId: string, cols: number, rows: number): Promise<PtySessionInfo>;
489
+ }
490
+ //# sourceMappingURL=Process.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Process.d.ts","sourceRoot":"","sources":["../../../../../libs/sdk-typescript/src/Process.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,aAAa,EACb,UAAU,EACV,OAAO,EACP,OAAO,EACP,qBAAqB,EACrB,sBAAsB,IAAI,yBAAyB,EAGnD,cAAc,EACf,MAAM,6BAA6B,CAAA;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAGzD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAKjE,eAAO,MAAM,mBAAmB,yBAAqC,CAAA;AACrE,eAAO,MAAM,mBAAmB,yBAAqC,CAAA;AACrE,eAAO,MAAM,cAAc,QAAmE,CAAA;AAE9F;;GAEG;AACH,qBAAa,aAAa;IACxB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;IACf;;OAEG;IACH,GAAG,CAAC,EAAE,MAA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