@daytona/sdk 0.161.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 (95) hide show
  1. package/README.md +180 -0
  2. package/package.json +56 -0
  3. package/src/CodeInterpreter.d.ts +94 -0
  4. package/src/CodeInterpreter.js +297 -0
  5. package/src/CodeInterpreter.js.map +1 -0
  6. package/src/ComputerUse.d.ts +538 -0
  7. package/src/ComputerUse.js +808 -0
  8. package/src/ComputerUse.js.map +1 -0
  9. package/src/Daytona.d.ts +340 -0
  10. package/src/Daytona.js +538 -0
  11. package/src/Daytona.js.map +1 -0
  12. package/src/FileSystem.d.ts +326 -0
  13. package/src/FileSystem.js +412 -0
  14. package/src/FileSystem.js.map +1 -0
  15. package/src/Git.d.ts +202 -0
  16. package/src/Git.js +326 -0
  17. package/src/Git.js.map +1 -0
  18. package/src/Image.d.ts +264 -0
  19. package/src/Image.js +546 -0
  20. package/src/Image.js.map +1 -0
  21. package/src/LspServer.d.ts +171 -0
  22. package/src/LspServer.js +258 -0
  23. package/src/LspServer.js.map +1 -0
  24. package/src/ObjectStorage.d.ts +78 -0
  25. package/src/ObjectStorage.js +199 -0
  26. package/src/ObjectStorage.js.map +1 -0
  27. package/src/Process.d.ts +490 -0
  28. package/src/Process.js +790 -0
  29. package/src/Process.js.map +1 -0
  30. package/src/PtyHandle.d.ts +154 -0
  31. package/src/PtyHandle.js +416 -0
  32. package/src/PtyHandle.js.map +1 -0
  33. package/src/Sandbox.d.ts +425 -0
  34. package/src/Sandbox.js +776 -0
  35. package/src/Sandbox.js.map +1 -0
  36. package/src/Snapshot.d.ts +139 -0
  37. package/src/Snapshot.js +248 -0
  38. package/src/Snapshot.js.map +1 -0
  39. package/src/Volume.d.ts +83 -0
  40. package/src/Volume.js +119 -0
  41. package/src/Volume.js.map +1 -0
  42. package/src/code-toolbox/SandboxJsCodeToolbox.d.ts +5 -0
  43. package/src/code-toolbox/SandboxJsCodeToolbox.js +20 -0
  44. package/src/code-toolbox/SandboxJsCodeToolbox.js.map +1 -0
  45. package/src/code-toolbox/SandboxPythonCodeToolbox.d.ts +11 -0
  46. package/src/code-toolbox/SandboxPythonCodeToolbox.js +359 -0
  47. package/src/code-toolbox/SandboxPythonCodeToolbox.js.map +1 -0
  48. package/src/code-toolbox/SandboxTsCodeToolbox.d.ts +5 -0
  49. package/src/code-toolbox/SandboxTsCodeToolbox.js +29 -0
  50. package/src/code-toolbox/SandboxTsCodeToolbox.js.map +1 -0
  51. package/src/errors/DaytonaError.d.ts +31 -0
  52. package/src/errors/DaytonaError.js +51 -0
  53. package/src/errors/DaytonaError.js.map +1 -0
  54. package/src/index.d.ts +21 -0
  55. package/src/index.js +45 -0
  56. package/src/index.js.map +1 -0
  57. package/src/types/Charts.d.ts +151 -0
  58. package/src/types/Charts.js +46 -0
  59. package/src/types/Charts.js.map +1 -0
  60. package/src/types/CodeInterpreter.d.ts +76 -0
  61. package/src/types/CodeInterpreter.js +7 -0
  62. package/src/types/CodeInterpreter.js.map +1 -0
  63. package/src/types/ExecuteResponse.d.ts +25 -0
  64. package/src/types/ExecuteResponse.js +7 -0
  65. package/src/types/ExecuteResponse.js.map +1 -0
  66. package/src/types/Pty.d.ts +47 -0
  67. package/src/types/Pty.js +7 -0
  68. package/src/types/Pty.js.map +1 -0
  69. package/src/utils/ArtifactParser.d.ts +13 -0
  70. package/src/utils/ArtifactParser.js +55 -0
  71. package/src/utils/ArtifactParser.js.map +1 -0
  72. package/src/utils/Binary.d.ts +38 -0
  73. package/src/utils/Binary.js +168 -0
  74. package/src/utils/Binary.js.map +1 -0
  75. package/src/utils/FileTransfer.d.ts +14 -0
  76. package/src/utils/FileTransfer.js +216 -0
  77. package/src/utils/FileTransfer.js.map +1 -0
  78. package/src/utils/Import.d.ts +97 -0
  79. package/src/utils/Import.js +79 -0
  80. package/src/utils/Import.js.map +1 -0
  81. package/src/utils/Multipart.d.ts +26 -0
  82. package/src/utils/Multipart.js +113 -0
  83. package/src/utils/Multipart.js.map +1 -0
  84. package/src/utils/Runtime.d.ts +43 -0
  85. package/src/utils/Runtime.js +95 -0
  86. package/src/utils/Runtime.js.map +1 -0
  87. package/src/utils/Stream.d.ts +19 -0
  88. package/src/utils/Stream.js +364 -0
  89. package/src/utils/Stream.js.map +1 -0
  90. package/src/utils/WebSocket.d.ts +9 -0
  91. package/src/utils/WebSocket.js +26 -0
  92. package/src/utils/WebSocket.js.map +1 -0
  93. package/src/utils/otel.decorator.d.ts +82 -0
  94. package/src/utils/otel.decorator.js +141 -0
  95. package/src/utils/otel.decorator.js.map +1 -0
@@ -0,0 +1,14 @@
1
+ import { DownloadMetadata } from '../FileSystem';
2
+ /**
3
+ * Safely aborts a stream
4
+ */
5
+ export declare function abortStream(stream: any): void;
6
+ /**
7
+ * Normalizes response data to extract the actual stream
8
+ */
9
+ export declare function normalizeResponseStream(responseData: any): any;
10
+ /**
11
+ * Processes multipart response using busboy (Node.js path)
12
+ */
13
+ export declare function processDownloadFilesResponseWithBusboy(stream: any, headers: Record<string, string>, metadataMap: Map<string, DownloadMetadata>): Promise<void>;
14
+ export declare function processDownloadFilesResponseWithBuffered(stream: any, headers: Record<string, string>, metadataMap: Map<string, DownloadMetadata>): Promise<void>;
@@ -0,0 +1,216 @@
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.abortStream = abortStream;
8
+ exports.normalizeResponseStream = normalizeResponseStream;
9
+ exports.processDownloadFilesResponseWithBusboy = processDownloadFilesResponseWithBusboy;
10
+ exports.processDownloadFilesResponseWithBuffered = processDownloadFilesResponseWithBuffered;
11
+ const tslib_1 = require("tslib");
12
+ const buffer_1 = require("buffer");
13
+ const busboy_1 = tslib_1.__importDefault(require("busboy"));
14
+ const DaytonaError_1 = require("../errors/DaytonaError");
15
+ const Import_1 = require("./Import");
16
+ const Binary_1 = require("./Binary");
17
+ const Multipart_1 = require("./Multipart");
18
+ const Multipart_2 = require("./Multipart");
19
+ /**
20
+ * Safely aborts a stream
21
+ */
22
+ function abortStream(stream) {
23
+ if (stream && typeof stream.destroy === 'function') {
24
+ stream.destroy();
25
+ }
26
+ else if (stream && typeof stream.cancel === 'function') {
27
+ stream.cancel();
28
+ }
29
+ }
30
+ /**
31
+ * Normalizes response data to extract the actual stream
32
+ */
33
+ function normalizeResponseStream(responseData) {
34
+ if (!responseData || typeof responseData !== 'object') {
35
+ return responseData;
36
+ }
37
+ // WHATWG ReadableStream
38
+ if (responseData.body && typeof responseData.body.getReader === 'function') {
39
+ return responseData.body;
40
+ }
41
+ // Some adapters use .stream
42
+ if (responseData.stream) {
43
+ return responseData.stream;
44
+ }
45
+ return responseData;
46
+ }
47
+ /**
48
+ * Processes multipart response using busboy (Node.js path)
49
+ */
50
+ async function processDownloadFilesResponseWithBusboy(stream, headers, metadataMap) {
51
+ const fileTasks = [];
52
+ await new Promise((resolve, reject) => {
53
+ const bb = (0, busboy_1.default)({
54
+ headers,
55
+ preservePath: true,
56
+ });
57
+ bb.on('file', (fieldName, fileStream, fileInfo) => {
58
+ const source = fileInfo?.filename;
59
+ if (!source) {
60
+ abortStream(stream);
61
+ reject(new DaytonaError_1.DaytonaError(`Received unexpected file "${fileInfo?.filename}".`));
62
+ return;
63
+ }
64
+ const metadata = metadataMap.get(source);
65
+ if (!metadata) {
66
+ abortStream(stream);
67
+ reject(new DaytonaError_1.DaytonaError(`Target metadata missing for valid source: ${source}`));
68
+ return;
69
+ }
70
+ if (fieldName === 'error') {
71
+ // Collect error message
72
+ const chunks = [];
73
+ fileStream.on('data', (chunk) => chunks.push(chunk));
74
+ fileStream.on('end', () => {
75
+ metadata.error = buffer_1.Buffer.concat(chunks).toString('utf-8').trim();
76
+ });
77
+ fileStream.on('error', (err) => {
78
+ metadata.error = `Stream error: ${err.message}`;
79
+ });
80
+ }
81
+ else if (fieldName === 'file') {
82
+ if (metadata.destination) {
83
+ // Stream to file
84
+ fileTasks.push(new Promise((resolveTask) => {
85
+ (0, Import_1.dynamicImport)('fs', 'Downloading files to local files is not supported: ').then((fs) => {
86
+ const writeStream = fs.createWriteStream(metadata.destination, { autoClose: true });
87
+ fileStream.pipe(writeStream);
88
+ writeStream.on('finish', () => {
89
+ metadata.result = metadata.destination;
90
+ resolveTask();
91
+ });
92
+ writeStream.on('error', (err) => {
93
+ metadata.error = `Write stream failed: ${err.message}`;
94
+ resolveTask();
95
+ });
96
+ fileStream.on('error', (err) => {
97
+ metadata.error = `Read stream failed: ${err.message}`;
98
+ });
99
+ });
100
+ }));
101
+ }
102
+ else {
103
+ // Collect to buffer
104
+ const chunks = [];
105
+ fileStream.on('data', (chunk) => {
106
+ chunks.push(buffer_1.Buffer.isBuffer(chunk) ? chunk : buffer_1.Buffer.from(chunk));
107
+ });
108
+ fileStream.on('end', () => {
109
+ metadata.result = buffer_1.Buffer.concat(chunks);
110
+ });
111
+ fileStream.on('error', (err) => {
112
+ metadata.error = `Read failed: ${err.message}`;
113
+ });
114
+ }
115
+ }
116
+ else {
117
+ // Unknown field, drain it
118
+ fileStream.resume();
119
+ }
120
+ });
121
+ bb.on('error', (err) => {
122
+ abortStream(stream);
123
+ reject(err);
124
+ });
125
+ bb.on('finish', resolve);
126
+ // Feed stream into busboy
127
+ feedStreamToBusboy(stream, bb).catch((err) => bb.destroy(err));
128
+ });
129
+ await Promise.all(fileTasks);
130
+ }
131
+ /**
132
+ * Feeds various stream types into busboy
133
+ */
134
+ async function feedStreamToBusboy(stream, bb) {
135
+ // Node.js stream (piping)
136
+ if (typeof stream?.pipe === 'function') {
137
+ stream.pipe(bb);
138
+ return;
139
+ }
140
+ // Direct buffer-like data
141
+ if (typeof stream === 'string' || stream instanceof ArrayBuffer || ArrayBuffer.isView(stream)) {
142
+ const data = (0, Binary_1.toUint8Array)(stream);
143
+ bb.write(buffer_1.Buffer.from(data));
144
+ bb.end();
145
+ return;
146
+ }
147
+ // WHATWG ReadableStream
148
+ if (typeof stream?.getReader === 'function') {
149
+ const reader = stream.getReader();
150
+ while (true) {
151
+ const { done, value } = await reader.read();
152
+ if (done)
153
+ break;
154
+ bb.write(buffer_1.Buffer.from(value));
155
+ }
156
+ bb.end();
157
+ return;
158
+ }
159
+ // AsyncIterable
160
+ if (stream?.[Symbol.asyncIterator]) {
161
+ for await (const chunk of stream) {
162
+ const buffer = buffer_1.Buffer.isBuffer(chunk) ? chunk : buffer_1.Buffer.from((0, Binary_1.toUint8Array)(chunk));
163
+ bb.write(buffer);
164
+ }
165
+ bb.end();
166
+ return;
167
+ }
168
+ // Unsupported stream type
169
+ throw new DaytonaError_1.DaytonaError(`Unsupported stream type: ${stream?.constructor?.name || typeof stream}`);
170
+ }
171
+ async function processDownloadFilesResponseWithBuffered(stream, headers, metadataMap) {
172
+ const contentType = (0, Multipart_1.getHeader)(headers, 'content-type') || '';
173
+ const bodyBytes = await (0, Binary_1.collectStreamBytes)(stream);
174
+ // Try native FormData parsing for multipart/form-data
175
+ if (/^multipart\/form-data/i.test(contentType) && typeof Response !== 'undefined') {
176
+ try {
177
+ const formDataMap = await (0, Multipart_1.parseMultipartWithFormData)(bodyBytes, contentType);
178
+ formDataMap.forEach((value, fieldName) => {
179
+ const metadata = metadataMap.get(value.filename);
180
+ if (!metadata)
181
+ return;
182
+ if (fieldName.includes('error')) {
183
+ metadata.error = new TextDecoder('utf-8').decode(value.data).trim();
184
+ }
185
+ else {
186
+ metadata.result = (0, Binary_1.toBuffer)(value.data);
187
+ }
188
+ });
189
+ return;
190
+ }
191
+ catch {
192
+ // Fall through to manual parsing
193
+ }
194
+ }
195
+ // Manual multipart parsing (handles multipart/mixed, etc.)
196
+ const boundary = (0, Multipart_1.extractBoundary)(contentType);
197
+ if (!boundary) {
198
+ throw new DaytonaError_1.DaytonaError(`Missing multipart boundary in Content-Type: "${contentType}"`);
199
+ }
200
+ const parts = (0, Multipart_2.parseMultipart)(bodyBytes, boundary);
201
+ for (const part of parts) {
202
+ if (!part.filename)
203
+ continue;
204
+ const metadata = metadataMap.get(part.filename);
205
+ if (!metadata)
206
+ continue;
207
+ if (part.name === 'error') {
208
+ metadata.error = new TextDecoder('utf-8').decode(part.data).trim();
209
+ }
210
+ else if (part.name === 'file') {
211
+ metadata.result = (0, Binary_1.toBuffer)(part.data);
212
+ }
213
+ }
214
+ return;
215
+ }
216
+ //# sourceMappingURL=FileTransfer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FileTransfer.js","sourceRoot":"","sources":["../../../../../libs/sdk-typescript/src/utils/FileTransfer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAcH,kCAMC;AAKD,0DAgBC;AAKD,wFA2FC;AA8CD,4FAkDC;;AAvOD,mCAA+B;AAC/B,4DAA2B;AAC3B,yDAAqD;AACrD,qCAAwC;AACxC,qCAAqE;AACrE,2CAAoF;AACpF,2CAA4C;AAG5C;;GAEG;AACH,SAAgB,WAAW,CAAC,MAAW;IACrC,IAAI,MAAM,IAAI,OAAO,MAAM,CAAC,OAAO,KAAK,UAAU,EAAE,CAAC;QACnD,MAAM,CAAC,OAAO,EAAE,CAAA;IAClB,CAAC;SAAM,IAAI,MAAM,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;QACzD,MAAM,CAAC,MAAM,EAAE,CAAA;IACjB,CAAC;AACH,CAAC;AAED;;GAEG;AACH,SAAgB,uBAAuB,CAAC,YAAiB;IACvD,IAAI,CAAC,YAAY,IAAI,OAAO,YAAY,KAAK,QAAQ,EAAE,CAAC;QACtD,OAAO,YAAY,CAAA;IACrB,CAAC;IAED,wBAAwB;IACxB,IAAI,YAAY,CAAC,IAAI,IAAI,OAAO,YAAY,CAAC,IAAI,CAAC,SAAS,KAAK,UAAU,EAAE,CAAC;QAC3E,OAAO,YAAY,CAAC,IAAI,CAAA;IAC1B,CAAC;IAED,4BAA4B;IAC5B,IAAI,YAAY,CAAC,MAAM,EAAE,CAAC;QACxB,OAAO,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AM,GAAG,IAAA,iBAAQ,EAAC,KAAK,CAAC,IAAI,CAAC,CAAA;gBACxC,CAAC;YACH,CAAC,CAAC,CAAA;YAEF,OAAM;QACR,CAAC;QAAC,MAAM,CAAC;YACP,iCAAiC;QACnC,CAAC;IACH,CAAC;IAED,2DAA2D;IAC3D,MAAM,QAAQ,GAAG,IAAA,2BAAe,EAAC,WAAW,CAAC,CAAA;IAC7C,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,2BAAY,CAAC,gDAAgD,WAAW,GAAG,CAAC,CAAA;IACxF,CAAC;IAED,MAAM,KAAK,GAAG,IAAA,0BAAc,EAAC,SAAS,EAAE,QAAQ,CAAC,CAAA;IACjD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,CAAC,IAAI,CAAC,QAAQ;YAAE,SAAQ;QAC5B,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QAC/C,IAAI,CAAC,QAAQ;YAAE,SAAQ;QAEvB,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;YAC1B,QAAQ,CAAC,KAAK,GAAG,IAAI,WAAW,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAA;QACpE,CAAC;aAAM,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;YAChC,QAAQ,CAAC,MAAM,GAAG,IAAA,iBAAQ,EAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACvC,CAAC;IACH,CAAC;IAED,OAAM;AACR,CAAC"}
@@ -0,0 +1,97 @@
1
+ declare const loaderMap: {
2
+ 'fast-glob': () => Promise<{
3
+ default: typeof import("fast-glob");
4
+ sync(source: import("fast-glob/out/types").Pattern | import("fast-glob/out/types").Pattern[], options: import("fast-glob/out/settings").Options & ({
5
+ objectMode: true;
6
+ } | {
7
+ stats: true;
8
+ })): import("fast-glob/out/types").Entry[];
9
+ sync(source: import("fast-glob/out/types").Pattern | import("fast-glob/out/types").Pattern[], options?: import("fast-glob/out/settings").Options): string[];
10
+ stream(source: import("fast-glob/out/types").Pattern | import("fast-glob/out/types").Pattern[], options?: import("fast-glob/out/settings").Options): NodeJS.ReadableStream;
11
+ generateTasks(source: import("fast-glob/out/types").Pattern | import("fast-glob/out/types").Pattern[], options?: import("fast-glob/out/settings").Options): import("fast-glob").Task[];
12
+ isDynamicPattern(source: import("fast-glob/out/types").Pattern, options?: import("fast-glob/out/settings").Options): boolean;
13
+ escapePath(source: string): import("fast-glob/out/types").Pattern;
14
+ convertPathToPattern(source: string): import("fast-glob/out/types").Pattern;
15
+ glob: typeof import("fast-glob");
16
+ globSync: typeof import("fast-glob").sync;
17
+ globStream: typeof import("fast-glob").stream;
18
+ async: typeof import("fast-glob");
19
+ posix: typeof import("fast-glob").posix;
20
+ win32: typeof import("fast-glob").win32;
21
+ }>;
22
+ '@iarna/toml': () => Promise<{
23
+ default: typeof import("@iarna/toml");
24
+ parse: import("@iarna/toml").FuncParse;
25
+ stringify: import("@iarna/toml").FuncStringify;
26
+ }>;
27
+ stream: () => Promise<{
28
+ default: typeof import("stream");
29
+ Stream: typeof import("stream");
30
+ promises: typeof import("node:stream/promises");
31
+ duplexPair(options?: import("stream").DuplexOptions): [import("stream").Duplex, import("stream").Duplex];
32
+ addAbortSignal<T extends import("stream")>(signal: AbortSignal, stream: T): T;
33
+ getDefaultHighWaterMark(objectMode: boolean): number;
34
+ setDefaultHighWaterMark(objectMode: boolean, value: number): void;
35
+ finished: typeof import("stream").finished;
36
+ pipeline: typeof import("stream").pipeline;
37
+ isErrored(stream: import("stream").Readable | import("stream").Writable | NodeJS.ReadableStream | NodeJS.WritableStream): boolean;
38
+ isReadable(stream: import("stream").Readable | NodeJS.ReadableStream): boolean;
39
+ Readable: typeof import("stream").Readable;
40
+ Writable: typeof import("stream").Writable;
41
+ Duplex: typeof import("stream").Duplex;
42
+ Transform: typeof import("stream").Transform;
43
+ PassThrough: typeof import("stream").PassThrough;
44
+ errorMonitor: typeof import("events").errorMonitor;
45
+ captureRejectionSymbol: typeof import("events").captureRejectionSymbol;
46
+ captureRejections: boolean;
47
+ defaultMaxListeners: number;
48
+ EventEmitter: typeof import("events");
49
+ EventEmitterAsyncResource: typeof import("events").EventEmitterAsyncResource;
50
+ }>;
51
+ tar: () => Promise<typeof import("tar", { with: { "resolution-mode": "import" } })>;
52
+ 'expand-tilde': () => Promise<any>;
53
+ ObjectStorage: () => Promise<{
54
+ default: typeof import("../ObjectStorage");
55
+ ObjectStorage: typeof import("../ObjectStorage").ObjectStorage;
56
+ }>;
57
+ fs: () => Promise<typeof import("fs")>;
58
+ 'form-data': () => Promise<{
59
+ default: typeof import("form-data");
60
+ Stream: typeof import("stream");
61
+ promises: typeof import("node:stream/promises");
62
+ duplexPair(options?: import("stream").DuplexOptions): [import("stream").Duplex, import("stream").Duplex];
63
+ addAbortSignal<T extends import("stream")>(signal: AbortSignal, stream: T): T;
64
+ getDefaultHighWaterMark(objectMode: boolean): number;
65
+ setDefaultHighWaterMark(objectMode: boolean, value: number): void;
66
+ finished: typeof import("stream").finished;
67
+ pipeline: typeof import("stream").pipeline;
68
+ isErrored(stream: import("stream").Readable | import("stream").Writable | NodeJS.ReadableStream | NodeJS.WritableStream): boolean;
69
+ isReadable(stream: import("stream").Readable | NodeJS.ReadableStream): boolean;
70
+ Readable: typeof import("stream").Readable;
71
+ Writable: typeof import("stream").Writable;
72
+ Duplex: typeof import("stream").Duplex;
73
+ Transform: typeof import("stream").Transform;
74
+ PassThrough: typeof import("stream").PassThrough;
75
+ errorMonitor: typeof import("events").errorMonitor;
76
+ captureRejectionSymbol: typeof import("events").captureRejectionSymbol;
77
+ captureRejections: boolean;
78
+ defaultMaxListeners: number;
79
+ EventEmitter: typeof import("events");
80
+ EventEmitterAsyncResource: typeof import("events").EventEmitterAsyncResource;
81
+ }>;
82
+ util: () => Promise<typeof import("util")>;
83
+ };
84
+ declare const requireMap: {
85
+ 'fast-glob': () => any;
86
+ '@iarna/toml': () => any;
87
+ stream: () => any;
88
+ tar: () => any;
89
+ 'expand-tilde': () => any;
90
+ fs: () => any;
91
+ 'form-data': () => any;
92
+ };
93
+ type ModuleMap = typeof loaderMap;
94
+ export declare function dynamicImport<K extends keyof ModuleMap>(name: K, errorPrefix?: string): Promise<Awaited<ReturnType<ModuleMap[K]>>>;
95
+ type RequireMap = typeof requireMap;
96
+ export declare function dynamicRequire<K extends keyof RequireMap>(name: K, errorPrefix?: string): ReturnType<RequireMap[K]>;
97
+ export {};
@@ -0,0 +1,79 @@
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.dynamicImport = dynamicImport;
8
+ exports.dynamicRequire = dynamicRequire;
9
+ const DaytonaError_1 = require("../errors/DaytonaError");
10
+ const Runtime_1 = require("./Runtime");
11
+ const loaderMap = {
12
+ 'fast-glob': () => import('fast-glob'),
13
+ '@iarna/toml': () => import('@iarna/toml'),
14
+ stream: () => import('stream'),
15
+ tar: () => import('tar'),
16
+ 'expand-tilde': () => import('expand-tilde'),
17
+ ObjectStorage: () => import('../ObjectStorage.js'),
18
+ fs: () => import('fs'),
19
+ 'form-data': () => import('form-data'),
20
+ util: () => import('util'),
21
+ };
22
+ const requireMap = {
23
+ 'fast-glob': () => require('fast-glob'),
24
+ '@iarna/toml': () => require('@iarna/toml'),
25
+ stream: () => require('stream'),
26
+ tar: () => require('tar'),
27
+ 'expand-tilde': () => require('expand-tilde'),
28
+ fs: () => require('fs'),
29
+ 'form-data': () => require('form-data'),
30
+ };
31
+ const validateMap = {
32
+ 'fast-glob': (mod) => typeof mod === 'function' && typeof mod?.sync === 'function',
33
+ '@iarna/toml': (mod) => typeof mod.parse === 'function' && typeof mod.stringify === 'function',
34
+ stream: (mod) => typeof mod.Readable === 'function' && typeof mod.Writable === 'function',
35
+ tar: (mod) => typeof mod.extract === 'function' && typeof mod.create === 'function',
36
+ 'expand-tilde': (mod) => typeof mod === 'function',
37
+ fs: (mod) => typeof mod.createReadStream === 'function' && typeof mod.readFile === 'function',
38
+ 'form-data': (mod) => typeof mod === 'function',
39
+ util: (mod) => typeof mod.promisify === 'function',
40
+ };
41
+ async function dynamicImport(name, errorPrefix) {
42
+ const loader = loaderMap[name];
43
+ if (!loader) {
44
+ throw new DaytonaError_1.DaytonaError(`${errorPrefix || ''} Unknown module "${name}"`);
45
+ }
46
+ let mod;
47
+ try {
48
+ mod = (await loader());
49
+ mod = mod?.default ?? mod;
50
+ }
51
+ catch (err) {
52
+ const msg = err instanceof Error ? err.message : String(err);
53
+ throw new DaytonaError_1.DaytonaError(`${errorPrefix || ''} Module "${name}" is not available in the "${Runtime_1.RUNTIME}" runtime: ${msg}`);
54
+ }
55
+ if (validateMap[name] && !validateMap[name](mod)) {
56
+ throw new DaytonaError_1.DaytonaError(`${errorPrefix || ''} Module "${name}" didn't pass import validation in the "${Runtime_1.RUNTIME}" runtime`);
57
+ }
58
+ return mod;
59
+ }
60
+ function dynamicRequire(name, errorPrefix) {
61
+ const loader = requireMap[name];
62
+ if (!loader) {
63
+ throw new DaytonaError_1.DaytonaError(`${errorPrefix || ''} Unknown module "${name}"`);
64
+ }
65
+ let mod;
66
+ try {
67
+ mod = loader();
68
+ mod = mod?.default ?? mod;
69
+ }
70
+ catch (err) {
71
+ const msg = err instanceof Error ? err.message : String(err);
72
+ throw new DaytonaError_1.DaytonaError(`${errorPrefix || ''} Module "${name}" is not available in the "${Runtime_1.RUNTIME}" runtime: ${msg}`);
73
+ }
74
+ if (validateMap[name] && !validateMap[name](mod)) {
75
+ throw new DaytonaError_1.DaytonaError(`${errorPrefix || ''} Module "${name}" didn't pass import validation in the "${Runtime_1.RUNTIME}" runtime`);
76
+ }
77
+ return mod;
78
+ }
79
+ //# sourceMappingURL=Import.js.map
@@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,CAAC,CAAA;IACtH,CAAC;IAED,IAAI,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC;QACjD,MAAM,IAAI,2BAAY,CACpB,GAAG,WAAW,IAAI,EAAE,YAAY,IAAI,2CAA2C,iBAAO,WAAW,CAClG,CAAA;IACH,CAAC;IAED,OAAO,GAAG,CAAA;AACZ,CAAC"}
@@ -0,0 +1,26 @@
1
+ export interface MultipartPart {
2
+ name: string | undefined;
3
+ filename: string | undefined;
4
+ headers: Record<string, string>;
5
+ data: Uint8Array;
6
+ }
7
+ /**
8
+ * Extracts the boundary from a Content-Type header
9
+ */
10
+ export declare function extractBoundary(contentType: string): string | null;
11
+ /**
12
+ * Parses multipart/form-data or multipart/mixed response body
13
+ */
14
+ export declare function parseMultipart(body: Uint8Array, boundary: string): MultipartPart[];
15
+ /**
16
+ * Parses multipart response using browser's native FormData API
17
+ * This is more reliable than manual parsing when available
18
+ */
19
+ export declare function parseMultipartWithFormData(bodyBytes: Uint8Array, contentType: string): Promise<Map<string, {
20
+ filename: string;
21
+ data: Uint8Array;
22
+ }>>;
23
+ /**
24
+ * Extracts a header value from response headers (case-insensitive)
25
+ */
26
+ export declare function getHeader(headers: any, key: string): string | undefined;
@@ -0,0 +1,113 @@
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.extractBoundary = extractBoundary;
8
+ exports.parseMultipart = parseMultipart;
9
+ exports.parseMultipartWithFormData = parseMultipartWithFormData;
10
+ exports.getHeader = getHeader;
11
+ const Binary_1 = require("./Binary");
12
+ /**
13
+ * Extracts the boundary from a Content-Type header
14
+ */
15
+ function extractBoundary(contentType) {
16
+ const match = /boundary="?([^";]+)"?/i.exec(contentType || '');
17
+ return match ? match[1] : null;
18
+ }
19
+ /**
20
+ * Extracts a parameter value from Content-Disposition header
21
+ */
22
+ function getDispositionParam(disposition, paramName) {
23
+ const match = disposition.match(new RegExp(`${paramName}\\*?=([^;]+)`, 'i'));
24
+ if (!match)
25
+ return undefined;
26
+ return match[1].replace(/^"|"$/g, '').trim();
27
+ }
28
+ /**
29
+ * Parses multipart/form-data or multipart/mixed response body
30
+ */
31
+ function parseMultipart(body, boundary) {
32
+ const encoder = new TextEncoder();
33
+ const dashBoundary = encoder.encode(`--${boundary}`);
34
+ const crlf = encoder.encode('\r\n');
35
+ const boundaryLine = (0, Binary_1.concatUint8Arrays)([dashBoundary, crlf]);
36
+ const boundaryPositions = (0, Binary_1.findAllBytes)(body, dashBoundary);
37
+ if (boundaryPositions.length === 0)
38
+ return [];
39
+ const parts = [];
40
+ for (let i = 0; i < boundaryPositions.length; i++) {
41
+ const start = boundaryPositions[i];
42
+ // Headers start after "--boundary\r\n"
43
+ const headerStart = (0, Binary_1.indexAfterSequence)(body, start, boundaryLine);
44
+ if (headerStart < 0)
45
+ continue;
46
+ // Part ends before next boundary
47
+ const nextBoundary = boundaryPositions[i + 1] ?? body.length;
48
+ let partEnd = nextBoundary - 2; // Remove trailing CRLF
49
+ if (partEnd < headerStart)
50
+ partEnd = headerStart;
51
+ // Find headers/body separator (\r\n\r\n)
52
+ const separator = (0, Binary_1.findBytesInRange)(body, headerStart, partEnd, encoder.encode('\r\n\r\n'));
53
+ if (separator < 0)
54
+ continue;
55
+ // Parse headers
56
+ const headersText = (0, Binary_1.utf8Decode)(body.subarray(headerStart, separator));
57
+ const headers = {};
58
+ headersText.split(/\r\n/).forEach((line) => {
59
+ const [key, ...valueParts] = line.split(':');
60
+ if (valueParts.length > 0) {
61
+ headers[key.trim().toLowerCase()] = valueParts.join(':').trim();
62
+ }
63
+ });
64
+ // Extract body
65
+ const dataStart = separator + 4;
66
+ const data = body.subarray(dataStart, partEnd);
67
+ // Extract name and filename from Content-Disposition
68
+ const disposition = headers['content-disposition'] || '';
69
+ const name = getDispositionParam(disposition, 'name');
70
+ const filename = getDispositionParam(disposition, 'filename');
71
+ parts.push({ name, filename, headers, data });
72
+ }
73
+ return parts;
74
+ }
75
+ /**
76
+ * Parses multipart response using browser's native FormData API
77
+ * This is more reliable than manual parsing when available
78
+ */
79
+ async function parseMultipartWithFormData(bodyBytes, contentType) {
80
+ const result = new Map();
81
+ // Create a Blob and parse with FormData API
82
+ const blob = new Blob([bodyBytes.slice()], { type: contentType });
83
+ const formData = await new Response(blob).formData();
84
+ // Process FormData entries (forEach is more universally supported than entries())
85
+ const filePromises = [];
86
+ formData.forEach((value, fieldName) => {
87
+ if ((0, Binary_1.isFile)(value)) {
88
+ filePromises.push((async () => {
89
+ const file = value;
90
+ const arrayBuffer = await file.arrayBuffer();
91
+ result.set(fieldName, {
92
+ filename: file.name,
93
+ data: new Uint8Array(arrayBuffer),
94
+ });
95
+ })());
96
+ }
97
+ });
98
+ await Promise.all(filePromises);
99
+ return result;
100
+ }
101
+ /**
102
+ * Extracts a header value from response headers (case-insensitive)
103
+ */
104
+ function getHeader(headers, key) {
105
+ if (!headers)
106
+ return undefined;
107
+ const headerKey = Object.keys(headers).find((h) => h.toLowerCase() === key.toLowerCase());
108
+ if (!headerKey)
109
+ return undefined;
110
+ const value = headers[headerKey];
111
+ return Array.isArray(value) ? value[0] : value;
112
+ }
113
+ //# sourceMappingURL=Multipart.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Multipart.js","sourceRoot":"","sources":["../../../../../libs/sdk-typescript/src/utils/Multipart.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAcH,0CAGC;AAcD,wCAmDC;AAMD,gEA6BC;AAKD,8BAMC;AA9HD,qCAAoH;AASpH;;GAEG;AACH,SAAgB,eAAe,CAAC,WAAmB;IACjD,MAAM,KAAK,GAAG,wBAAwB,CAAC,IAAI,CAAC,WAAW,IAAI,EAAE,CAAC,CAAA;IAC9D,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC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AACH,SAAgB,SAAS,CAAC,OAAY,EAAE,GAAW;IACjD,IAAI,CAAC,OAAO;QAAE,OAAO,SAAS,CAAA;IAC9B,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,KAAK,GAAG,CAAC,WAAW,EAAE,CAAC,CAAA;IACzF,IAAI,CAAC,SAAS;QAAE,OAAO,SAAS,CAAA;IAChC,MAAM,KAAK,GAAG,OAAO,CAAC,SAAS,CAAC,CAAA;IAChC,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAA;AAChD,CAAC"}
@@ -0,0 +1,43 @@
1
+ declare global {
2
+ /**
3
+ * In Deno this global exists and has a `version.deno` string;
4
+ * in all other runtimes it will be `undefined`.
5
+ */
6
+ var Deno: {
7
+ version: {
8
+ deno: string;
9
+ };
10
+ env: {
11
+ get(name: string): string | undefined;
12
+ toObject(): Record<string, string>;
13
+ };
14
+ } | undefined;
15
+ /**
16
+ * In Bun this global exists and has a `version.bun` string;
17
+ * in all other runtimes it will be `undefined`.
18
+ */
19
+ var Bun: {
20
+ version: {
21
+ bun: string;
22
+ };
23
+ file: (path: string) => File;
24
+ } | undefined;
25
+ }
26
+ export declare enum Runtime {
27
+ NODE = "node",
28
+ DENO = "deno",
29
+ BUN = "bun",
30
+ BROWSER = "browser",
31
+ SERVERLESS = "serverless",
32
+ UNKNOWN = "unknown"
33
+ }
34
+ export declare const RUNTIME: Runtime;
35
+ export declare function getEnvVar(name: string): string | undefined;
36
+ export declare class DaytonaEnvReader {
37
+ private readonly envLocalVars;
38
+ private readonly envVars;
39
+ constructor();
40
+ get(name: string): string | undefined;
41
+ private static parseFileVars;
42
+ }
43
+ export declare function isServerlessRuntime(): boolean;