@daytonaio/sdk 0.127.0 → 0.128.0-alpha.1

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