@daytona/sdk 0.171.0-alpha.3 → 0.171.0-alpha.5

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 (147) hide show
  1. package/package.json +9 -3
  2. package/cjs/CodeInterpreter.d.ts.map +0 -1
  3. package/cjs/ComputerUse.d.ts.map +0 -1
  4. package/cjs/Daytona.d.ts.map +0 -1
  5. package/cjs/FileSystem.d.ts.map +0 -1
  6. package/cjs/Git.d.ts.map +0 -1
  7. package/cjs/Image.d.ts.map +0 -1
  8. package/cjs/LspServer.d.ts.map +0 -1
  9. package/cjs/ObjectStorage.d.ts.map +0 -1
  10. package/cjs/Process.d.ts.map +0 -1
  11. package/cjs/PtyHandle.d.ts.map +0 -1
  12. package/cjs/Sandbox.d.ts.map +0 -1
  13. package/cjs/Snapshot.d.ts.map +0 -1
  14. package/cjs/Volume.d.ts.map +0 -1
  15. package/cjs/__tests__/helpers.d.ts +0 -6
  16. package/cjs/__tests__/helpers.d.ts.map +0 -1
  17. package/cjs/__tests__/helpers.js +0 -26
  18. package/cjs/__tests__/helpers.js.map +0 -1
  19. package/cjs/errors/DaytonaError.d.ts.map +0 -1
  20. package/cjs/index.d.ts.map +0 -1
  21. package/cjs/types/Charts.d.ts.map +0 -1
  22. package/cjs/types/CodeInterpreter.d.ts.map +0 -1
  23. package/cjs/types/ExecuteResponse.d.ts.map +0 -1
  24. package/cjs/types/Pty.d.ts.map +0 -1
  25. package/cjs/utils/Binary.d.ts.map +0 -1
  26. package/cjs/utils/FileTransfer.d.ts.map +0 -1
  27. package/cjs/utils/Import.d.ts.map +0 -1
  28. package/cjs/utils/Multipart.d.ts.map +0 -1
  29. package/cjs/utils/Runtime.d.ts.map +0 -1
  30. package/cjs/utils/Stream.d.ts.map +0 -1
  31. package/cjs/utils/WebSocket.d.ts.map +0 -1
  32. package/cjs/utils/otel.decorator.d.ts.map +0 -1
  33. package/esm/CodeInterpreter.d.ts.map +0 -1
  34. package/esm/ComputerUse.d.ts.map +0 -1
  35. package/esm/Daytona.d.ts.map +0 -1
  36. package/esm/FileSystem.d.ts.map +0 -1
  37. package/esm/Git.d.ts.map +0 -1
  38. package/esm/Image.d.ts.map +0 -1
  39. package/esm/LspServer.d.ts.map +0 -1
  40. package/esm/ObjectStorage.d.ts.map +0 -1
  41. package/esm/Process.d.ts.map +0 -1
  42. package/esm/PtyHandle.d.ts.map +0 -1
  43. package/esm/Sandbox.d.ts.map +0 -1
  44. package/esm/Snapshot.d.ts.map +0 -1
  45. package/esm/Volume.d.ts.map +0 -1
  46. package/esm/__tests__/helpers.d.ts +0 -6
  47. package/esm/__tests__/helpers.d.ts.map +0 -1
  48. package/esm/__tests__/helpers.js +0 -20
  49. package/esm/__tests__/helpers.js.map +0 -1
  50. package/esm/errors/DaytonaError.d.ts.map +0 -1
  51. package/esm/index.d.ts.map +0 -1
  52. package/esm/types/Charts.d.ts.map +0 -1
  53. package/esm/types/CodeInterpreter.d.ts.map +0 -1
  54. package/esm/types/ExecuteResponse.d.ts.map +0 -1
  55. package/esm/types/Pty.d.ts.map +0 -1
  56. package/esm/utils/Binary.d.ts.map +0 -1
  57. package/esm/utils/FileTransfer.d.ts.map +0 -1
  58. package/esm/utils/Import.d.ts.map +0 -1
  59. package/esm/utils/Multipart.d.ts.map +0 -1
  60. package/esm/utils/Runtime.d.ts.map +0 -1
  61. package/esm/utils/Stream.d.ts.map +0 -1
  62. package/esm/utils/WebSocket.d.ts.map +0 -1
  63. package/esm/utils/otel.decorator.d.ts.map +0 -1
  64. package/src/CodeInterpreter.d.ts +0 -94
  65. package/src/CodeInterpreter.js +0 -297
  66. package/src/CodeInterpreter.js.map +0 -1
  67. package/src/ComputerUse.d.ts +0 -538
  68. package/src/ComputerUse.js +0 -808
  69. package/src/ComputerUse.js.map +0 -1
  70. package/src/Daytona.d.ts +0 -353
  71. package/src/Daytona.js +0 -521
  72. package/src/Daytona.js.map +0 -1
  73. package/src/FileSystem.d.ts +0 -344
  74. package/src/FileSystem.js +0 -420
  75. package/src/FileSystem.js.map +0 -1
  76. package/src/Git.d.ts +0 -202
  77. package/src/Git.js +0 -326
  78. package/src/Git.js.map +0 -1
  79. package/src/Image.d.ts +0 -264
  80. package/src/Image.js +0 -586
  81. package/src/Image.js.map +0 -1
  82. package/src/LspServer.d.ts +0 -171
  83. package/src/LspServer.js +0 -259
  84. package/src/LspServer.js.map +0 -1
  85. package/src/ObjectStorage.d.ts +0 -78
  86. package/src/ObjectStorage.js +0 -199
  87. package/src/ObjectStorage.js.map +0 -1
  88. package/src/Process.d.ts +0 -489
  89. package/src/Process.js +0 -647
  90. package/src/Process.js.map +0 -1
  91. package/src/PtyHandle.d.ts +0 -154
  92. package/src/PtyHandle.js +0 -416
  93. package/src/PtyHandle.js.map +0 -1
  94. package/src/Sandbox.d.ts +0 -458
  95. package/src/Sandbox.js +0 -876
  96. package/src/Sandbox.js.map +0 -1
  97. package/src/Snapshot.d.ts +0 -139
  98. package/src/Snapshot.js +0 -248
  99. package/src/Snapshot.js.map +0 -1
  100. package/src/Volume.d.ts +0 -83
  101. package/src/Volume.js +0 -119
  102. package/src/Volume.js.map +0 -1
  103. package/src/__tests__/helpers.d.ts +0 -5
  104. package/src/__tests__/helpers.js +0 -24
  105. package/src/__tests__/helpers.js.map +0 -1
  106. package/src/errors/DaytonaError.d.ts +0 -170
  107. package/src/errors/DaytonaError.js +0 -258
  108. package/src/errors/DaytonaError.js.map +0 -1
  109. package/src/index.d.ts +0 -21
  110. package/src/index.js +0 -49
  111. package/src/index.js.map +0 -1
  112. package/src/types/Charts.d.ts +0 -37
  113. package/src/types/Charts.js +0 -37
  114. package/src/types/Charts.js.map +0 -1
  115. package/src/types/CodeInterpreter.d.ts +0 -76
  116. package/src/types/CodeInterpreter.js +0 -7
  117. package/src/types/CodeInterpreter.js.map +0 -1
  118. package/src/types/ExecuteResponse.d.ts +0 -25
  119. package/src/types/ExecuteResponse.js +0 -7
  120. package/src/types/ExecuteResponse.js.map +0 -1
  121. package/src/types/Pty.d.ts +0 -47
  122. package/src/types/Pty.js +0 -7
  123. package/src/types/Pty.js.map +0 -1
  124. package/src/utils/Binary.d.ts +0 -38
  125. package/src/utils/Binary.js +0 -168
  126. package/src/utils/Binary.js.map +0 -1
  127. package/src/utils/FileTransfer.d.ts +0 -14
  128. package/src/utils/FileTransfer.js +0 -258
  129. package/src/utils/FileTransfer.js.map +0 -1
  130. package/src/utils/Import.d.ts +0 -97
  131. package/src/utils/Import.js +0 -79
  132. package/src/utils/Import.js.map +0 -1
  133. package/src/utils/Multipart.d.ts +0 -28
  134. package/src/utils/Multipart.js +0 -115
  135. package/src/utils/Multipart.js.map +0 -1
  136. package/src/utils/Runtime.d.ts +0 -43
  137. package/src/utils/Runtime.js +0 -95
  138. package/src/utils/Runtime.js.map +0 -1
  139. package/src/utils/Stream.d.ts +0 -19
  140. package/src/utils/Stream.js +0 -364
  141. package/src/utils/Stream.js.map +0 -1
  142. package/src/utils/WebSocket.d.ts +0 -9
  143. package/src/utils/WebSocket.js +0 -26
  144. package/src/utils/WebSocket.js.map +0 -1
  145. package/src/utils/otel.decorator.d.ts +0 -82
  146. package/src/utils/otel.decorator.js +0 -141
  147. package/src/utils/otel.decorator.js.map +0 -1
@@ -1,364 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.processStreamingResponse = processStreamingResponse;
4
- exports.stdDemuxStream = stdDemuxStream;
5
- const Process_1 = require("../Process");
6
- function isStreamTerminationError(err) {
7
- if (!err || typeof err !== 'object')
8
- return false;
9
- const e = err;
10
- // Typical Undici / fetch termination cases
11
- if (e.name === 'AbortError')
12
- return true;
13
- if (typeof e.message === 'string' && /terminated/i.test(e.message))
14
- return true;
15
- if (e.code === 'UND_ERR_SOCKET')
16
- return true;
17
- // Look into nested causes, Undici often nests errors
18
- if (e.cause)
19
- return isStreamTerminationError(e.cause);
20
- return false;
21
- }
22
- /**
23
- * Process a streaming response from fetch(), where getStream() returns a Fetch Response.
24
- *
25
- * @param getStream – zero-arg function that does `await fetch(...)` and returns the Response
26
- * @param onChunk – called with each decoded UTF-8 chunk
27
- * @param shouldTerminate – pollable; if true for two consecutive timeouts (or once if requireConsecutiveTermination=false), the loop breaks
28
- * @param chunkTimeout – milliseconds to wait for a new chunk before calling shouldTerminate()
29
- * @param requireConsecutiveTermination – whether you need two time-outs in a row to break
30
- */
31
- async function processStreamingResponse(getStream, onChunk, shouldTerminate, chunkTimeout = 2000, requireConsecutiveTermination = true) {
32
- const res = await getStream();
33
- if (!res.body)
34
- throw new Error('No streaming support');
35
- const reader = res.body.getReader();
36
- const decoder = new TextDecoder('utf-8');
37
- const TIMEOUT = Symbol();
38
- let exitCheckStreak = 0;
39
- // Only one pending read promise at a time:
40
- let readPromise = null;
41
- try {
42
- while (true) {
43
- // Start a read if none in flight
44
- if (!readPromise) {
45
- readPromise = reader.read().then((r) => (r.done ? null : (r.value ?? new Uint8Array(0))));
46
- }
47
- // Race that single read against your timeout
48
- const timeoutPromise = new Promise((r) => setTimeout(() => r(TIMEOUT), chunkTimeout));
49
- const result = await Promise.race([readPromise, timeoutPromise]);
50
- if (result === TIMEOUT) {
51
- // no data yet, but the readPromise is still pending
52
- const stop = await shouldTerminate();
53
- if (stop) {
54
- exitCheckStreak++;
55
- if (!requireConsecutiveTermination || exitCheckStreak > 1) {
56
- try {
57
- await reader.cancel();
58
- }
59
- catch {
60
- /* ignore */
61
- }
62
- readPromise = null;
63
- break;
64
- }
65
- }
66
- else {
67
- exitCheckStreak = 0;
68
- }
69
- // loop again—but do NOT overwrite readPromise!
70
- }
71
- else {
72
- // readPromise has resolved
73
- readPromise = null;
74
- if (result === null) {
75
- // stream closed
76
- break;
77
- }
78
- // valid chunk - use {stream: true} to buffer incomplete UTF-8 sequences
79
- onChunk(decoder.decode(result, { stream: true }));
80
- exitCheckStreak = 0;
81
- }
82
- }
83
- }
84
- catch (err) {
85
- if (!isStreamTerminationError(err)) {
86
- throw err;
87
- }
88
- }
89
- finally {
90
- // Flush any remaining buffered bytes from the decoder
91
- const remaining = decoder.decode();
92
- if (remaining) {
93
- onChunk(remaining);
94
- }
95
- try {
96
- await reader.cancel();
97
- }
98
- catch {
99
- /* ignore */
100
- }
101
- }
102
- }
103
- /**
104
- * Demultiplexes a WebSocket stream into separate stdout and stderr streams.
105
- *
106
- * @param socket - The WebSocket instance to demultiplex.
107
- * @param onStdout - Callback function for stdout messages.
108
- * @param onStderr - Callback function for stderr messages.
109
- */
110
- function stdDemuxStream(ws, onStdout, onStderr) {
111
- return new Promise((resolve, reject) => {
112
- // If running in a browser or any WebSocket supporting binaryType, use ArrayBuffer for binary data
113
- if ('binaryType' in ws) {
114
- ws.binaryType = 'arraybuffer'; // ensure binary frames yield ArrayBuffer, not Blob
115
- }
116
- // Separate decoders for stdout and stderr to maintain independent UTF-8 decoding state
117
- const stdoutDecoder = new TextDecoder('utf-8');
118
- const stderrDecoder = new TextDecoder('utf-8');
119
- const buf = []; // Buffer to accumulate incoming chunks
120
- let currentDataType = null; // Track current stream type
121
- // Helper function to emit payload data
122
- const emit = (payload) => {
123
- if (payload.length === 0)
124
- return;
125
- // Use {stream: true} to buffer incomplete UTF-8 sequences for the next chunk
126
- if (currentDataType === 'stdout') {
127
- const text = stdoutDecoder.decode(payload, { stream: true });
128
- onStdout(text);
129
- }
130
- else if (currentDataType === 'stderr') {
131
- const text = stderrDecoder.decode(payload, { stream: true });
132
- onStderr(text);
133
- }
134
- // If currentDataType is null, drop unlabeled bytes (shouldn't happen with proper labeling)
135
- };
136
- // Helper function to find a subarray within a larger array
137
- const findSubarray = (haystack, needle) => {
138
- if (needle.length === 0)
139
- return 0;
140
- if (haystack.length < needle.length)
141
- return -1;
142
- for (let i = 0; i <= haystack.length - needle.length; i++) {
143
- let found = true;
144
- for (let j = 0; j < needle.length; j++) {
145
- if (haystack[i + j] !== needle[j]) {
146
- found = false;
147
- break;
148
- }
149
- }
150
- if (found)
151
- return i;
152
- }
153
- return -1;
154
- };
155
- // Event handler for incoming messages (Node: Buffer/ArrayBuffer/String; Browser: event.data etc.)
156
- const handleMessage = (event) => {
157
- // Normalize event/data between Node (ws) and browser WebSocket
158
- const data = event && event instanceof Object && 'data' in event ? event.data : event;
159
- try {
160
- // Prepare a Uint8Array for the message data
161
- let bytes;
162
- if (typeof data === 'string') {
163
- // Convert string to bytes for consistent byte-based demuxing
164
- bytes = new TextEncoder().encode(data);
165
- }
166
- else if (data instanceof ArrayBuffer) {
167
- bytes = new Uint8Array(data);
168
- }
169
- else if (ArrayBuffer.isView(data)) {
170
- // Covers Node.js Buffer (Uint8Array subclass) and other TypedArrays
171
- bytes = new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
172
- }
173
- else if (data instanceof Blob) {
174
- // Browser binary frames might be Blob if binaryType wasn't set in time. Convert to ArrayBuffer asynchronously.
175
- data.arrayBuffer().then((buf) => {
176
- try {
177
- processChunk(new Uint8Array(buf));
178
- }
179
- catch (err) {
180
- handleError(err);
181
- }
182
- }, (err) => {
183
- handleError(err);
184
- });
185
- return; // will continue asynchronously once blob is read
186
- }
187
- else {
188
- throw new Error(`Unsupported message data type: ${Object.prototype.toString.call(data)}`);
189
- }
190
- // Process the chunk
191
- processChunk(bytes);
192
- }
193
- catch (err) {
194
- // On any synchronous error in processing, clean up and reject.
195
- cleanup();
196
- try {
197
- ws.close();
198
- }
199
- catch {
200
- /* ignore if already closed */
201
- }
202
- reject(err);
203
- }
204
- };
205
- // Process a chunk of data with buffering and safe region handling
206
- const processChunk = (chunk) => {
207
- if (chunk.length === 0)
208
- return;
209
- // Add chunk to buffer
210
- buf.push(...chunk);
211
- // Process as much as we can, preserving only bytes that could be part of a prefix
212
- while (true) {
213
- const bufArray = new Uint8Array(buf);
214
- // Calculate how many bytes we can safely process
215
- // We need to keep bytes that could potentially be the start of a prefix marker
216
- let safeLen = buf.length;
217
- // Check if the last few bytes could be part of a prefix marker
218
- if (buf.length >= Process_1.MAX_PREFIX_LEN) {
219
- // Check if the last byte could be part of a prefix (must be 0x01 or 0x02)
220
- const lastByte = buf[buf.length - 1];
221
- if (lastByte !== 0x01 && lastByte !== 0x02) {
222
- // Last byte can't be part of any prefix, safe to process everything
223
- safeLen = buf.length;
224
- }
225
- else if (buf.length >= Process_1.MAX_PREFIX_LEN + 1) {
226
- // Check second-to-last byte if buffer is long enough
227
- const secondLastByte = buf[buf.length - 2];
228
- if (secondLastByte !== 0x01 && secondLastByte !== 0x02) {
229
- // Second-to-last byte can't be part of any prefix, safe to process all but last byte
230
- safeLen = buf.length - 1;
231
- }
232
- else {
233
- // Both last bytes could be part of prefix, keep MAX_PREFIX_LEN - 1 bytes
234
- safeLen = buf.length - (Process_1.MAX_PREFIX_LEN - 1);
235
- }
236
- }
237
- else {
238
- // Buffer is exactly MAX_PREFIX_LEN, keep MAX_PREFIX_LEN - 1 bytes
239
- safeLen = buf.length - (Process_1.MAX_PREFIX_LEN - 1);
240
- }
241
- }
242
- else {
243
- // Buffer shorter than MAX_PREFIX_LEN, keep MAX_PREFIX_LEN - 1 bytes
244
- safeLen = buf.length - (Process_1.MAX_PREFIX_LEN - 1);
245
- }
246
- if (safeLen <= 0) {
247
- break;
248
- }
249
- // Find earliest next marker within the safe region
250
- const safeRegion = bufArray.subarray(0, safeLen);
251
- const stdoutIndex = findSubarray(safeRegion, Process_1.STDOUT_PREFIX_BYTES);
252
- const stderrIndex = findSubarray(safeRegion, Process_1.STDERR_PREFIX_BYTES);
253
- let nextIdx = -1;
254
- let nextKind = null;
255
- let nextLen = 0;
256
- if (stdoutIndex !== -1 && (stderrIndex === -1 || stdoutIndex < stderrIndex)) {
257
- nextIdx = stdoutIndex;
258
- nextKind = 'stdout';
259
- nextLen = Process_1.STDOUT_PREFIX_BYTES.length;
260
- }
261
- else if (stderrIndex !== -1) {
262
- nextIdx = stderrIndex;
263
- nextKind = 'stderr';
264
- nextLen = Process_1.STDERR_PREFIX_BYTES.length;
265
- }
266
- if (nextIdx === -1) {
267
- // No full marker in safe region: emit everything we safely can as payload
268
- const toEmit = bufArray.subarray(0, safeLen);
269
- emit(toEmit);
270
- buf.splice(0, safeLen);
271
- break; // wait for more data to resolve any partial marker at the end
272
- }
273
- // We found a marker. Emit preceding bytes (if any) under the current stream.
274
- if (nextIdx > 0) {
275
- const toEmit = bufArray.subarray(0, nextIdx);
276
- emit(toEmit);
277
- }
278
- // Advance past the marker and switch current stream
279
- buf.splice(0, nextIdx + nextLen);
280
- currentDataType = nextKind;
281
- }
282
- };
283
- // Event handler for errors
284
- const handleError = (error) => {
285
- // Convert Event or plain error to Error instance for consistency
286
- const err = error && error instanceof Event ? new Error('WebSocket error') : error;
287
- cleanup();
288
- try {
289
- ws.close();
290
- }
291
- catch {
292
- /* ignore if already closed */
293
- }
294
- reject(err);
295
- };
296
- // Event handler for socket closure
297
- const handleClose = () => {
298
- // Flush any remaining buffered payload on clean close
299
- if (buf.length > 0 && currentDataType) {
300
- const remainingBytes = new Uint8Array(buf);
301
- // Use {stream: false} or omit to flush any buffered incomplete UTF-8 sequences
302
- if (currentDataType === 'stdout') {
303
- const text = stdoutDecoder.decode(remainingBytes, { stream: false });
304
- onStdout(text);
305
- }
306
- else if (currentDataType === 'stderr') {
307
- const text = stderrDecoder.decode(remainingBytes, { stream: false });
308
- onStderr(text);
309
- }
310
- }
311
- else {
312
- // Flush any remaining bytes in the decoders even if buf is empty
313
- const stdoutFlushed = stdoutDecoder.decode();
314
- const stderrFlushed = stderrDecoder.decode();
315
- if (stdoutFlushed)
316
- onStdout(stdoutFlushed);
317
- if (stderrFlushed)
318
- onStderr(stderrFlushed);
319
- }
320
- cleanup();
321
- resolve();
322
- };
323
- // Cleanup function to remove all listeners to avoid memory leaks
324
- const cleanup = () => {
325
- if (ws.removeEventListener) {
326
- // Browser (EventTarget) style cleanup
327
- ws.removeEventListener('message', handleMessage);
328
- ws.removeEventListener('error', handleError);
329
- ws.removeEventListener('close', handleClose);
330
- }
331
- if (ws.off) {
332
- // Node.js ws (EventEmitter) style cleanup (supported in Node 14+)
333
- ws.off('message', handleMessage);
334
- ws.off('error', handleError);
335
- ws.off('close', handleClose);
336
- }
337
- else if (ws.removeListener) {
338
- // Node.js ws fallback for older Node versions
339
- ;
340
- ws.removeListener('message', handleMessage);
341
- ws.removeListener('error', handleError);
342
- ws.removeListener('close', handleClose);
343
- }
344
- };
345
- // Attach event listeners in a way compatible with both Node (EventEmitter) and browser (EventTarget):
346
- if (ws.addEventListener) {
347
- // Browser or WebSocket implementation with EventTarget interface
348
- ws.addEventListener('message', handleMessage);
349
- ws.addEventListener('error', handleError);
350
- ws.addEventListener('close', handleClose);
351
- }
352
- else if (ws.on) {
353
- // Node.js ws library (EventEmitter) interface
354
- ws.on('message', handleMessage); // ws@8+ yields Buffer for text frames, which we handle via TextDecoder
355
- ws.on('error', handleError);
356
- ws.on('close', handleClose);
357
- }
358
- else {
359
- // Unknown WebSocket interface - should not happen with isomorphic-ws
360
- throw new Error('Unsupported WebSocket implementation');
361
- }
362
- });
363
- }
364
- //# sourceMappingURL=Stream.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Stream.js","sourceRoot":"","sources":["../../../../../libs/sdk-typescript/src/utils/Stream.ts"],"names":[],"mappings":";;AAgCA,4DA0EC;AASD,wCA+PC;AA7WD,wCAAqF;AAErF,SAAS,wBAAwB,CAAC,GAAY;IAC5C,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAA;IAEjD,MAAM,CAAC,GAAG,GAAU,CAAA;IAEpB,2CAA2C;IAC3C,IAAI,CAAC,CAAC,IAAI,KAAK,YAAY;QAAE,OAAO,IAAI,CAAA;IACxC,IAAI,OAAO,CAAC,CAAC,OAAO,KAAK,QAAQ,IAAI,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC;QAAE,OAAO,IAAI,CAAA;IAC/E,IAAI,CAAC,CAAC,IAAI,KAAK,gBAAgB;QAAE,OAAO,IAAI,CAAA;IAE5C,qDAAqD;IACrD,IA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A;QAED,sGAAsG;QACtG,IAAI,EAAE,CAAC,gBAAgB,EAAE,CAAC;YACxB,iEAAiE;YACjE,EAAE,CAAC,gBAAgB,CAAC,SAAS,EAAE,aAAoB,CAAC,CAAA;YACpD,EAAE,CAAC,gBAAgB,CAAC,OAAO,EAAE,WAAkB,CAAC,CAAA;YAChD,EAAE,CAAC,gBAAgB,CAAC,OAAO,EAAE,WAAkB,CAAC,CAAA;QAClD,CAAC;aAAM,IAAK,EAAU,CAAC,EAAE,EAAE,CAAC;YAC1B,8CAA8C;YAC9C,EAAE,CAAC,EAAE,CAAC,SAAS,EAAE,aAAa,CAAC,CAAA,CAAC,uEAAuE;YACvG,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,CAAC,CAAA;YAC3B,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,CAAC,CAAA;QAC7B,CAAC;aAAM,CAAC;YACN,qEAAqE;YACrE,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAA;QACzD,CAAC;IACH,CAAC,CAAC,CAAA;AACJ,CAAC"}
@@ -1,9 +0,0 @@
1
- import WebSocket from 'isomorphic-ws';
2
- /**
3
- * Creates an authenticated WebSocket connection to the sandbox toolbox.
4
- *
5
- * @param url - The websocket URL (ws[s]://...)
6
- * @param headers - Headers to forward when running in Node environments
7
- * @param getPreviewToken - Lazy getter for preview tokens (required for browser/serverless runtimes)
8
- */
9
- export declare function createSandboxWebSocket(url: string, headers: Record<string, any>, getPreviewToken: () => Promise<string>): Promise<WebSocket>;
@@ -1,26 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright 2025 Daytona Platforms Inc.
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.createSandboxWebSocket = createSandboxWebSocket;
8
- const tslib_1 = require("tslib");
9
- const isomorphic_ws_1 = tslib_1.__importDefault(require("isomorphic-ws"));
10
- const Runtime_1 = require("./Runtime");
11
- /**
12
- * Creates an authenticated WebSocket connection to the sandbox toolbox.
13
- *
14
- * @param url - The websocket URL (ws[s]://...)
15
- * @param headers - Headers to forward when running in Node environments
16
- * @param getPreviewToken - Lazy getter for preview tokens (required for browser/serverless runtimes)
17
- */
18
- async function createSandboxWebSocket(url, headers, getPreviewToken) {
19
- if (Runtime_1.RUNTIME === Runtime_1.Runtime.BROWSER || Runtime_1.RUNTIME === Runtime_1.Runtime.DENO || Runtime_1.RUNTIME === Runtime_1.Runtime.SERVERLESS) {
20
- const previewToken = await getPreviewToken();
21
- const separator = url.includes('?') ? '&' : '?';
22
- return new isomorphic_ws_1.default(`${url}${separator}DAYTONA_SANDBOX_AUTH_KEY=${previewToken}`, `X-Daytona-SDK-Version~${String(headers['X-Daytona-SDK-Version'] ?? '')}`);
23
- }
24
- return new isomorphic_ws_1.default(url, { headers });
25
- }
26
- //# sourceMappingURL=WebSocket.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"WebSocket.js","sourceRoot":"","sources":["../../../../../libs/sdk-typescript/src/utils/WebSocket.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAYH,wDAeC;;AAzBD,0EAAqC;AACrC,uCAA4C;AAE5C;;;;;;GAMG;AACI,KAAK,UAAU,sBAAsB,CAC1C,GAAW,EACX,OAA4B,EAC5B,eAAsC;IAEtC,IAAI,iBAAO,KAAK,iBAAO,CAAC,OAAO,IAAI,iBAAO,KAAK,iBAAO,CAAC,IAAI,IAAI,iBAAO,KAAK,iBAAO,CAAC,UAAU,EAAE,CAAC;QAC9F,MAAM,YAAY,GAAG,MAAM,eAAe,EAAE,CAAA;QAC5C,MAAM,SAAS,GAAG,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAA;QAC/C,OAAO,IAAI,uBAAS,CAClB,GAAG,GAAG,GAAG,SAAS,4BAA4B,YAAY,EAAE,EAC5D,yBAAyB,MAAM,CAAC,OAAO,CAAC,uBAAuB,CAAC,IAAI,EAAE,CAAC,EAAE,CAC1E,CAAA;IACH,CAAC;IAED,OAAO,IAAI,uBAAS,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,CAAC,CAAA;AACxC,CAAC"}
@@ -1,82 +0,0 @@
1
- /**
2
- * Configuration options for span instrumentation
3
- */
4
- export interface SpanConfig {
5
- /**
6
- * Custom name for the span. If not provided, uses `ClassName.methodName` format
7
- */
8
- name?: string;
9
- /**
10
- * Additional attributes to attach to the span
11
- */
12
- attributes?: Record<string, string>;
13
- }
14
- /**
15
- * Configuration options for metric instrumentation
16
- */
17
- export interface MetricConfig {
18
- /**
19
- * Custom name for the metric. If not provided, uses `ClassName.methodName` format
20
- */
21
- name?: string;
22
- /**
23
- * Description for the metrics being collected
24
- */
25
- description?: string;
26
- /**
27
- * Additional labels to attach to the metrics
28
- */
29
- labels?: Record<string, string>;
30
- }
31
- /**
32
- * Configuration options for the combined instrumentation decorator
33
- */
34
- export interface InstrumentationConfig {
35
- /**
36
- * Custom name for the span and metric. If not provided, uses `ClassName.methodName` format
37
- */
38
- name?: string;
39
- /**
40
- * Description for the metrics being collected
41
- */
42
- description?: string;
43
- /**
44
- * Additional labels/attributes to attach to spans and metrics
45
- */
46
- labels?: Record<string, string>;
47
- /**
48
- * Enable trace collection (default: true)
49
- */
50
- enableTraces?: boolean;
51
- /**
52
- * Enable metrics collection (default: true)
53
- */
54
- enableMetrics?: boolean;
55
- }
56
- /**
57
- * Decorator for instrumenting methods with OpenTelemetry spans (traces only)
58
- *
59
- * @param config - Configuration object or string name for the span
60
- *
61
- */
62
- export declare function WithSpan(config?: string | SpanConfig): (target: object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => void;
63
- /**
64
- * Decorator for instrumenting methods with OpenTelemetry metrics (metrics only)
65
- *
66
- * Collects two metrics:
67
- * - Counter: `{name}_executions` - tracks number of executions with status (success/error)
68
- * - Histogram: `{name}_duration` - tracks execution duration in milliseconds
69
- *
70
- * @param config - Configuration object or string name for the metric
71
- *
72
- */
73
- export declare function WithMetric(config?: string | MetricConfig): (target: object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => void;
74
- /**
75
- * Decorator for instrumenting methods with both OpenTelemetry traces and metrics
76
- *
77
- * This decorator composes @WithSpan and @WithMetric to provide both trace and metric collection.
78
- * You can selectively enable/disable traces or metrics using the config options.
79
- *
80
- * @param config - Configuration object or string name for the instrumentation
81
- */
82
- export declare function WithInstrumentation(config?: string | InstrumentationConfig): MethodDecorator;
@@ -1,141 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright 2025 Daytona Platforms Inc.
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.WithSpan = WithSpan;
8
- exports.WithMetric = WithMetric;
9
- exports.WithInstrumentation = WithInstrumentation;
10
- const api_1 = require("@opentelemetry/api");
11
- // Lazy initialization to ensure SDK is started before getting tracer/meter
12
- const getTracer = () => api_1.trace.getTracer('');
13
- const getMeter = () => api_1.metrics.getMeter('');
14
- const executionHistograms = new Map();
15
- /**
16
- * Converts a string to snake_case for Prometheus-friendly metric names
17
- */
18
- function toSnakeCase(str) {
19
- return str
20
- .replace(/([A-Z])/g, '_$1')
21
- .toLowerCase()
22
- .replace(/^_/, '')
23
- .replace(/\./g, '_');
24
- }
25
- /**
26
- * Decorator for instrumenting methods with OpenTelemetry spans (traces only)
27
- *
28
- * @param config - Configuration object or string name for the span
29
- *
30
- */
31
- function WithSpan(config) {
32
- return (target, propertyKey, descriptor) => {
33
- const originalMethod = descriptor.value;
34
- const methodName = String(propertyKey);
35
- descriptor.value = async function (...args) {
36
- const cfg = typeof config === 'string' ? { name: config } : config || {};
37
- const { name, attributes = {} } = cfg;
38
- const spanName = name || `${target.constructor.name}.${methodName}`;
39
- const allAttributes = {
40
- component: target.constructor.name,
41
- method: methodName,
42
- ...attributes,
43
- };
44
- const span = getTracer().startSpan(spanName, {
45
- attributes: allAttributes,
46
- }, api_1.context.active());
47
- return api_1.context.with(api_1.trace.setSpan(api_1.context.active(), span), async () => {
48
- try {
49
- const result = await originalMethod.apply(this, args);
50
- span.setStatus({ code: api_1.SpanStatusCode.OK });
51
- return result;
52
- }
53
- catch (error) {
54
- span.setStatus({
55
- code: api_1.SpanStatusCode.ERROR,
56
- message: error instanceof Error ? error.message : String(error),
57
- });
58
- span.recordException(error instanceof Error ? error : new Error(String(error)));
59
- throw error;
60
- }
61
- finally {
62
- span.end();
63
- }
64
- });
65
- };
66
- };
67
- }
68
- /**
69
- * Decorator for instrumenting methods with OpenTelemetry metrics (metrics only)
70
- *
71
- * Collects two metrics:
72
- * - Counter: `{name}_executions` - tracks number of executions with status (success/error)
73
- * - Histogram: `{name}_duration` - tracks execution duration in milliseconds
74
- *
75
- * @param config - Configuration object or string name for the metric
76
- *
77
- */
78
- function WithMetric(config) {
79
- return (target, propertyKey, descriptor) => {
80
- const originalMethod = descriptor.value;
81
- const methodName = String(propertyKey);
82
- descriptor.value = async function (...args) {
83
- const cfg = typeof config === 'string' ? { name: config } : config || {};
84
- const { name, description, labels = {} } = cfg;
85
- const metricName = toSnakeCase(name || `${target.constructor.name}.${methodName}`);
86
- const allLabels = {
87
- component: target.constructor.name,
88
- method: methodName,
89
- ...labels,
90
- };
91
- // Get or create histogram for this method
92
- if (!executionHistograms.has(metricName)) {
93
- executionHistograms.set(metricName, getMeter().createHistogram(`${metricName}_duration`, {
94
- description: description || `Duration of executions for ${metricName}`,
95
- unit: 'ms',
96
- }));
97
- }
98
- const histogram = executionHistograms.get(metricName);
99
- if (!histogram) {
100
- throw new Error(`Histogram not found for metric: ${metricName}`);
101
- }
102
- const startTime = Date.now();
103
- let status = 'success';
104
- try {
105
- const result = await originalMethod.apply(this, args);
106
- return result;
107
- }
108
- catch (error) {
109
- status = 'error';
110
- throw error;
111
- }
112
- finally {
113
- const duration = Date.now() - startTime;
114
- histogram.record(duration, { ...allLabels, status });
115
- }
116
- };
117
- };
118
- }
119
- /**
120
- * Decorator for instrumenting methods with both OpenTelemetry traces and metrics
121
- *
122
- * This decorator composes @WithSpan and @WithMetric to provide both trace and metric collection.
123
- * You can selectively enable/disable traces or metrics using the config options.
124
- *
125
- * @param config - Configuration object or string name for the instrumentation
126
- */
127
- function WithInstrumentation(config) {
128
- const cfg = typeof config === 'string' ? { name: config } : config || {};
129
- const { enableTraces = true, enableMetrics = true, name, description, labels } = cfg;
130
- const decorators = [];
131
- if (enableTraces) {
132
- decorators.push(WithSpan({ name, attributes: labels }));
133
- }
134
- if (enableMetrics) {
135
- decorators.push(WithMetric({ name, description, labels }));
136
- }
137
- return (target, propertyKey, descriptor) => {
138
- decorators.forEach((decorator) => decorator(target, propertyKey, descriptor));
139
- };
140
- }
141
- //# sourceMappingURL=otel.decorator.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"otel.decorator.js","sourceRoot":"","sources":["../../../../../libs/sdk-typescript/src/utils/otel.decorator.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAqFH,4BA2CC;AAYD,gCA8CC;AAUD,kDAiBC;AAnND,4CAAuF;AAEvF,2EAA2E;AAC3E,MAAM,SAAS,GAAG,GAAG,EAAE,CAAC,WAAK,CAAC,SAAS,CAAC,EAAE,CAAC,CAAA;AAC3C,MAAM,QAAQ,GAAG,GAAG,EAAE,CAAC,aAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;AAE3C,MAAM,mBAAmB,GAAG,IAAI,GAAG,EAAqB,CAAA;AA4DxD;;GAEG;AACH,SAAS,WAAW,CAAC,GAAW;IAC9B,OAAO,GAAG;SACP,OAAO,CAAC,UAAU,EAAE,KAAK,CAAC;SAC1B,WAAW,EAAE;SACb,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;SACjB,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;AACxB,CAAC;AAED;;;;;GAKG;AACH,SAAgB,QAAQ,CAAC,MAA4B;IACnD,OAAO,CAAC,MAAc,EAAE,WAA4B,EAAE,UAA8B,EAAE,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