@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,151 @@
1
+ /**
2
+ * Chart types
3
+ */
4
+ export declare enum ChartType {
5
+ LINE = "line",
6
+ SCATTER = "scatter",
7
+ BAR = "bar",
8
+ PIE = "pie",
9
+ BOX_AND_WHISKER = "box_and_whisker",
10
+ COMPOSITE_CHART = "composite_chart",
11
+ UNKNOWN = "unknown"
12
+ }
13
+ /**
14
+ * Represents a chart with metadata from matplotlib.
15
+ */
16
+ export type Chart = {
17
+ /** The type of chart */
18
+ type: ChartType;
19
+ /** The title of the chart */
20
+ title: string;
21
+ /** The elements of the chart */
22
+ elements: any[];
23
+ /** The PNG representation of the chart encoded in base64 */
24
+ png?: string;
25
+ };
26
+ /**
27
+ * Represents a 2D chart with metadata.
28
+ */
29
+ export type Chart2D = Chart & {
30
+ /** The label of the x-axis */
31
+ x_label?: string;
32
+ /** The label of the y-axis */
33
+ y_label?: string;
34
+ };
35
+ /**
36
+ * Represents a point in a 2D chart.
37
+ */
38
+ export type PointData = {
39
+ /** The label of the point */
40
+ label: string;
41
+ /** The points of the chart */
42
+ points: [number | string, number | string][];
43
+ };
44
+ /**
45
+ * Represents a point chart with metadata.
46
+ */
47
+ export type PointChart = Chart2D & {
48
+ /** The ticks of the x-axis */
49
+ x_ticks: (number | string)[];
50
+ /** The scale of the x-axis */
51
+ x_scale: string;
52
+ /** The labels of the x-axis */
53
+ x_tick_labels: string[];
54
+ /** The ticks of the y-axis */
55
+ y_ticks: (number | string)[];
56
+ /** The scale of the y-axis */
57
+ y_scale: string;
58
+ /** The labels of the y-axis */
59
+ y_tick_labels: string[];
60
+ /** The points of the chart */
61
+ elements: PointData[];
62
+ };
63
+ /**
64
+ * Represents a line chart with metadata.
65
+ */
66
+ export type LineChart = PointChart & {
67
+ /** The type of chart */
68
+ type: ChartType.LINE;
69
+ };
70
+ /**
71
+ * Represents a scatter chart with metadata.
72
+ */
73
+ export type ScatterChart = PointChart & {
74
+ /** The type of chart */
75
+ type: ChartType.SCATTER;
76
+ };
77
+ /**
78
+ * Represents a bar in a bar chart.
79
+ */
80
+ export type BarData = {
81
+ /** The label of the bar */
82
+ label: string;
83
+ /** The value of the bar */
84
+ value: string;
85
+ /** The group of the bar */
86
+ group: string;
87
+ };
88
+ /**
89
+ * Represents a bar chart with metadata.
90
+ */
91
+ export type BarChart = Chart2D & {
92
+ /** The type of chart */
93
+ type: ChartType.BAR;
94
+ /** The bars of the chart */
95
+ elements: BarData[];
96
+ };
97
+ /**
98
+ * Represents a pie slice in a pie chart.
99
+ */
100
+ export type PieData = {
101
+ /** The label of the pie slice */
102
+ label: string;
103
+ /** The angle of the pie slice */
104
+ angle: number;
105
+ /** The radius of the pie slice */
106
+ radius: number;
107
+ };
108
+ /**
109
+ * Represents a pie chart with metadata.
110
+ */
111
+ export type PieChart = Chart & {
112
+ /** The type of chart */
113
+ type: ChartType.PIE;
114
+ /** The pie slices of the chart */
115
+ elements: PieData[];
116
+ };
117
+ /**
118
+ * Represents a box and whisker in a box and whisker chart.
119
+ */
120
+ export type BoxAndWhiskerData = {
121
+ /** The label of the box and whisker */
122
+ label: string;
123
+ /** The minimum value of the box and whisker */
124
+ min: number;
125
+ /** The first quartile of the box and whisker */
126
+ first_quartile: number;
127
+ /** The median of the box and whisker */
128
+ median: number;
129
+ /** The third quartile of the box and whisker */
130
+ max: number;
131
+ outliers: number[];
132
+ };
133
+ /**
134
+ * Represents a box and whisker chart with metadata.
135
+ */
136
+ export type BoxAndWhiskerChart = Chart2D & {
137
+ /** The type of chart */
138
+ type: ChartType.BOX_AND_WHISKER;
139
+ /** The box and whiskers of the chart */
140
+ elements: BoxAndWhiskerData[];
141
+ };
142
+ /**
143
+ * Represents a composite chart with metadata.
144
+ */
145
+ export type CompositeChart = Chart & {
146
+ /** The type of chart */
147
+ type: ChartType.COMPOSITE_CHART;
148
+ /** The charts of the composite chart */
149
+ elements: Chart[];
150
+ };
151
+ export declare function parseChart(data: any): Chart;
@@ -0,0 +1,46 @@
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.ChartType = void 0;
8
+ exports.parseChart = parseChart;
9
+ /**
10
+ * Chart types
11
+ */
12
+ var ChartType;
13
+ (function (ChartType) {
14
+ ChartType["LINE"] = "line";
15
+ ChartType["SCATTER"] = "scatter";
16
+ ChartType["BAR"] = "bar";
17
+ ChartType["PIE"] = "pie";
18
+ ChartType["BOX_AND_WHISKER"] = "box_and_whisker";
19
+ ChartType["COMPOSITE_CHART"] = "composite_chart";
20
+ ChartType["UNKNOWN"] = "unknown";
21
+ })(ChartType || (exports.ChartType = ChartType = {}));
22
+ function parseChart(data) {
23
+ switch (data.type) {
24
+ case ChartType.LINE:
25
+ return { ...data };
26
+ case ChartType.SCATTER:
27
+ return { ...data };
28
+ case ChartType.BAR:
29
+ return { ...data };
30
+ case ChartType.PIE:
31
+ return { ...data };
32
+ case ChartType.BOX_AND_WHISKER:
33
+ return { ...data };
34
+ case ChartType.COMPOSITE_CHART:
35
+ // eslint-disable-next-line no-case-declarations
36
+ const charts = data.elements.map((g) => parseChart(g));
37
+ delete data.data;
38
+ return {
39
+ ...data,
40
+ data: charts,
41
+ };
42
+ default:
43
+ return { ...data, type: ChartType.UNKNOWN };
44
+ }
45
+ }
46
+ //# sourceMappingURL=Charts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Charts.js","sourceRoot":"","sources":["../../../../../libs/sdk-typescript/src/types/Charts.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAsKH,gCAuBC;AA3LD;;GAEG;AACH,IAAY,SAQX;AARD,WAAY,SAAS;IACnB,0BAAa,CAAA;IACb,gCAAmB,CAAA;IACnB,wBAAW,CAAA;IACX,wBAAW,CAAA;IACX,gDAAmC,CAAA;IACnC,gDAAmC,CAAA;IACnC,gCAAmB,CAAA;AACrB,CAAC,EARW,SAAS,yBAAT,SAAS,QAQpB;AAyJD,SAAgB,UAAU,CAAC,IAAS;IAClC,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;QAClB,KAAK,SAAS,CAAC,IAAI;YACjB,OAAO,EAAE,GAAG,IAAI,EAAe,CAAA;QACjC,KAAK,SAAS,CAAC,OAAO;YACpB,OAAO,EAAE,GAAG,IAAI,EAAkB,CAAA;QACpC,KAAK,SAAS,CAAC,GAAG;YAChB,OAAO,EAAE,GAAG,IAAI,EAAc,CAAA;QAChC,KAAK,SAAS,CAAC,GAAG;YAChB,OAAO,EAAE,GAAG,IAAI,EAAc,CAAA;QAChC,KAAK,SAAS,CAAC,eAAe;YAC5B,OAAO,EAAE,GAAG,IAAI,EAAwB,CAAA;QAC1C,KAAK,SAAS,CAAC,eAAe;YAC5B,gDAAgD;YAChD,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAA;YAC3D,OAAO,IAAI,CAAC,IAAI,CAAA;YAChB,OAAO;gBACL,GAAG,IAAI;gBACP,IAAI,EAAE,MAAM;aACK,CAAA;QACrB;YACE,OAAO,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,SAAS,CAAC,OAAO,EAAW,CAAA;IACxD,CAAC;AACH,CAAC"}
@@ -0,0 +1,76 @@
1
+ /**
2
+ * @module code-interpreter
3
+ */
4
+ import { InterpreterContext } from '@daytonaio/toolbox-api-client';
5
+ /**
6
+ * Represents stdout or stderr output from code execution.
7
+ */
8
+ export interface OutputMessage {
9
+ /**
10
+ * Output content.
11
+ */
12
+ output: string;
13
+ }
14
+ /**
15
+ * Represents an error that occurred during code execution.
16
+ */
17
+ export interface ExecutionError {
18
+ /**
19
+ * Error type/class name (e.g., "ValueError", "SyntaxError").
20
+ */
21
+ name: string;
22
+ /**
23
+ * Error value/message.
24
+ */
25
+ value: string;
26
+ /**
27
+ * Full traceback for the error, if available.
28
+ */
29
+ traceback?: string;
30
+ }
31
+ /**
32
+ * Result of code execution.
33
+ */
34
+ export interface ExecutionResult {
35
+ /**
36
+ * Standard output captured during execution.
37
+ */
38
+ stdout: string;
39
+ /**
40
+ * Standard error captured during execution.
41
+ */
42
+ stderr: string;
43
+ /**
44
+ * Details about an execution error, if one occurred.
45
+ */
46
+ error?: ExecutionError;
47
+ }
48
+ /**
49
+ * Options for executing code in the interpreter.
50
+ */
51
+ export interface RunCodeOptions {
52
+ /**
53
+ * Interpreter context to run code in.
54
+ */
55
+ context?: InterpreterContext;
56
+ /**
57
+ * Environment variables for this execution.
58
+ */
59
+ envs?: Record<string, string>;
60
+ /**
61
+ * Timeout in seconds. Set to 0 for no timeout. Default is 10 minutes.
62
+ */
63
+ timeout?: number;
64
+ /**
65
+ * Callback for stdout messages.
66
+ */
67
+ onStdout?: (message: OutputMessage) => any | Promise<any>;
68
+ /**
69
+ * Callback for stderr messages.
70
+ */
71
+ onStderr?: (message: OutputMessage) => any | Promise<any>;
72
+ /**
73
+ * Callback for execution errors (e.g., runtime exceptions).
74
+ */
75
+ onError?: (error: ExecutionError) => any | Promise<any>;
76
+ }
@@ -0,0 +1,7 @@
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
+ //# sourceMappingURL=CodeInterpreter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CodeInterpreter.js","sourceRoot":"","sources":["../../../../../libs/sdk-typescript/src/types/CodeInterpreter.ts"],"names":[],"mappings":";AAAA;;;GAGG"}
@@ -0,0 +1,25 @@
1
+ import { Chart } from './Charts';
2
+ /**
3
+ * Artifacts from the command execution.
4
+ *
5
+ * @interface
6
+ * @property stdout - Standard output from the command, same as `result` in `ExecuteResponse`
7
+ * @property charts - List of chart metadata from matplotlib
8
+ */
9
+ export interface ExecutionArtifacts {
10
+ stdout: string;
11
+ charts?: Chart[];
12
+ }
13
+ /**
14
+ * Response from the command execution.
15
+ *
16
+ * @interface
17
+ * @property exitCode - The exit code from the command execution
18
+ * @property result - The output from the command execution
19
+ * @property artifacts - Artifacts from the command execution
20
+ */
21
+ export interface ExecuteResponse {
22
+ exitCode: number;
23
+ result: string;
24
+ artifacts?: ExecutionArtifacts;
25
+ }
@@ -0,0 +1,7 @@
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
+ //# sourceMappingURL=ExecuteResponse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExecuteResponse.js","sourceRoot":"","sources":["../../../../../libs/sdk-typescript/src/types/ExecuteResponse.ts"],"names":[],"mappings":";AAAA;;;GAGG"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Options for creating a PTY session
3
+ */
4
+ export interface PtyCreateOptions {
5
+ /**
6
+ * The unique identifier for the PTY session
7
+ */
8
+ id: string;
9
+ /**
10
+ * Starting directory for the PTY session, defaults to the sandbox's working directory
11
+ */
12
+ cwd?: string;
13
+ /**
14
+ * Environment variables for the PTY session
15
+ */
16
+ envs?: Record<string, string>;
17
+ /**
18
+ * Number of terminal columns
19
+ */
20
+ cols?: number;
21
+ /**
22
+ * Number of terminal rows
23
+ */
24
+ rows?: number;
25
+ }
26
+ /**
27
+ * Options for connecting to a PTY session
28
+ */
29
+ export interface PtyConnectOptions {
30
+ /**
31
+ * Callback to handle PTY output data
32
+ */
33
+ onData: (data: Uint8Array) => void | Promise<void>;
34
+ }
35
+ /**
36
+ * PTY session result on exit
37
+ */
38
+ export interface PtyResult {
39
+ /**
40
+ * Exit code when the PTY process ends
41
+ */
42
+ exitCode?: number;
43
+ /**
44
+ * Error message if the PTY failed
45
+ */
46
+ error?: string;
47
+ }
@@ -0,0 +1,7 @@
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
+ //# sourceMappingURL=Pty.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Pty.js","sourceRoot":"","sources":["../../../../../libs/sdk-typescript/src/types/Pty.ts"],"names":[],"mappings":";AAAA;;;GAGG"}
@@ -0,0 +1,13 @@
1
+ import { ExecutionArtifacts } from '../types/ExecuteResponse';
2
+ /**
3
+ * Utility class for parsing artifacts from command output
4
+ */
5
+ export declare class ArtifactParser {
6
+ /**
7
+ * Parses artifacts from command output text
8
+ *
9
+ * @param output - Raw output from command execution
10
+ * @returns Parsed artifacts including stdout and charts
11
+ */
12
+ static parseArtifacts(output: string): ExecutionArtifacts;
13
+ }
@@ -0,0 +1,55 @@
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.ArtifactParser = void 0;
8
+ const Charts_1 = require("../types/Charts");
9
+ /**
10
+ * Utility class for parsing artifacts from command output
11
+ */
12
+ class ArtifactParser {
13
+ /**
14
+ * Parses artifacts from command output text
15
+ *
16
+ * @param output - Raw output from command execution
17
+ * @returns Parsed artifacts including stdout and charts
18
+ */
19
+ static parseArtifacts(output) {
20
+ const charts = [];
21
+ let stdout = output;
22
+ // Split output by lines to find artifact markers
23
+ const lines = output.split('\n');
24
+ const artifactLines = [];
25
+ for (const line of lines) {
26
+ // Look for the artifact marker pattern
27
+ if (line.startsWith('dtn_artifact_k39fd2:')) {
28
+ artifactLines.push(line);
29
+ try {
30
+ const artifactJson = line.substring('dtn_artifact_k39fd2:'.length).trim();
31
+ const artifactData = JSON.parse(artifactJson);
32
+ if (artifactData.type === 'chart' && artifactData.value) {
33
+ const chartData = artifactData.value;
34
+ charts.push((0, Charts_1.parseChart)(chartData));
35
+ }
36
+ }
37
+ catch (error) {
38
+ // Skip invalid artifacts
39
+ console.warn('Failed to parse artifact:', error);
40
+ }
41
+ }
42
+ }
43
+ // Remove artifact lines from stdout along with their following newlines
44
+ for (const line of artifactLines) {
45
+ stdout = stdout.replace(line + '\n', '');
46
+ stdout = stdout.replace(line, '');
47
+ }
48
+ return {
49
+ stdout,
50
+ charts: charts.length > 0 ? charts : undefined,
51
+ };
52
+ }
53
+ }
54
+ exports.ArtifactParser = ArtifactParser;
55
+ //# sourceMappingURL=ArtifactParser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ArtifactParser.js","sourceRoot":"","sources":["../../../../../libs/sdk-typescript/src/utils/ArtifactParser.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,4CAAmD;AAGnD;;GAEG;AACH,MAAa,cAAc;IACzB;;;;;OAKG;IACI,MAAM,CAAC,cAAc,CAAC,MAAc;QACzC,MAAM,MAAM,GAAY,EAAE,CAAA;QAC1B,IAAI,MAAM,GAAG,MAAM,CAAA;QAEnB,iDAAiD;QACjD,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QAChC,MAAM,aAAa,GAAa,EAAE,CAAA;QAElC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,uCAAuC;YACvC,IAAI,IAAI,CAAC,UAAU,CAAC,sBAAsB,CAAC,EAAE,CAAC;gBAC5C,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;gBAExB,IAAI,CAAC;oBACH,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,CAAC,sBAAsB,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAA;oBACzE,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAA;oBAE7C,IAAI,YAAY,CAAC,IAAI,KAAK,OAAO,IAAI,YAAY,CAAC,KAAK,EAAE,CAAC;wBACxD,MAAM,SAAS,GAAG,YAAY,CAAC,KAAK,CAAA;wBACpC,MAAM,CAAC,IAAI,CAAC,IAAA,mBAAU,EAAC,SAAS,CAAC,CAAC,CAAA;oBACpC,CAAC;gBACH,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,yBAAyB;oBACzB,OAAO,CAAC,IAAI,CAAC,2BAA2B,EAAE,KAAK,CAAC,CAAA;gBAClD,CAAC;YACH,CAAC;QACH,CAAC;QAED,wEAAwE;QACxE,KAAK,MAAM,IAAI,IAAI,aAAa,EAAE,CAAC;YACjC,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,GAAG,IAAI,EAAE,EAAE,CAAC,CAAA;YACxC,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAA;QACnC,CAAC;QAED,OAAO;YACL,MAAM;YACN,MAAM,EAAE,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;SAC/C,CAAA;IACH,CAAC;CACF;AA9CD,wCA8CC"}
@@ -0,0 +1,38 @@
1
+ import { Buffer } from 'buffer';
2
+ /**
3
+ * Converts various data types to Uint8Array
4
+ */
5
+ export declare function toUint8Array(data: string | ArrayBuffer | ArrayBufferView): Uint8Array;
6
+ /**
7
+ * Concatenates multiple Uint8Array chunks into a single Uint8Array
8
+ */
9
+ export declare function concatUint8Arrays(parts: Uint8Array[]): Uint8Array;
10
+ /**
11
+ * Converts Uint8Array to Buffer (uses polyfill in non-Node environments)
12
+ */
13
+ export declare function toBuffer(data: Uint8Array): Buffer;
14
+ /**
15
+ * Decodes Uint8Array to UTF-8 string
16
+ */
17
+ export declare function utf8Decode(data: Uint8Array): string;
18
+ /**
19
+ * Finds all occurrences of a pattern in a byte buffer
20
+ */
21
+ export declare function findAllBytes(buffer: Uint8Array, pattern: Uint8Array): number[];
22
+ /**
23
+ * Finds the first occurrence of a pattern in a byte buffer within a range
24
+ */
25
+ export declare function findBytesInRange(buffer: Uint8Array, start: number, end: number, pattern: Uint8Array): number;
26
+ /**
27
+ * Checks if a sequence starts at a given position in a byte buffer
28
+ * Returns the position after the sequence if found, -1 otherwise
29
+ */
30
+ export declare function indexAfterSequence(buffer: Uint8Array, start: number, sequence: Uint8Array): number;
31
+ /**
32
+ * Collects all bytes from various stream types into a single Uint8Array
33
+ */
34
+ export declare function collectStreamBytes(stream: any): Promise<Uint8Array>;
35
+ /**
36
+ * Checks if value is a File object (browser environment)
37
+ */
38
+ export declare function isFile(value: any): boolean;
@@ -0,0 +1,168 @@
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.toUint8Array = toUint8Array;
8
+ exports.concatUint8Arrays = concatUint8Arrays;
9
+ exports.toBuffer = toBuffer;
10
+ exports.utf8Decode = utf8Decode;
11
+ exports.findAllBytes = findAllBytes;
12
+ exports.findBytesInRange = findBytesInRange;
13
+ exports.indexAfterSequence = indexAfterSequence;
14
+ exports.collectStreamBytes = collectStreamBytes;
15
+ exports.isFile = isFile;
16
+ const buffer_1 = require("buffer");
17
+ const DaytonaError_1 = require("../errors/DaytonaError");
18
+ /**
19
+ * Converts various data types to Uint8Array
20
+ */
21
+ function toUint8Array(data) {
22
+ if (typeof data === 'string') {
23
+ return new TextEncoder().encode(data);
24
+ }
25
+ if (data instanceof ArrayBuffer) {
26
+ return new Uint8Array(data);
27
+ }
28
+ if (ArrayBuffer.isView(data)) {
29
+ return new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
30
+ }
31
+ throw new DaytonaError_1.DaytonaError('Unsupported data type for byte conversion.');
32
+ }
33
+ /**
34
+ * Concatenates multiple Uint8Array chunks into a single Uint8Array
35
+ */
36
+ function concatUint8Arrays(parts) {
37
+ const size = parts.reduce((sum, part) => sum + part.byteLength, 0);
38
+ const result = new Uint8Array(size);
39
+ let offset = 0;
40
+ for (const part of parts) {
41
+ result.set(part, offset);
42
+ offset += part.byteLength;
43
+ }
44
+ return result;
45
+ }
46
+ /**
47
+ * Converts Uint8Array to Buffer (uses polyfill in non-Node environments)
48
+ */
49
+ function toBuffer(data) {
50
+ return buffer_1.Buffer.from(data);
51
+ }
52
+ /**
53
+ * Decodes Uint8Array to UTF-8 string
54
+ */
55
+ function utf8Decode(data) {
56
+ return new TextDecoder('utf-8').decode(data);
57
+ }
58
+ /**
59
+ * Finds all occurrences of a pattern in a byte buffer
60
+ */
61
+ function findAllBytes(buffer, pattern) {
62
+ const results = [];
63
+ let i = 0;
64
+ while (i <= buffer.length - pattern.length) {
65
+ let match = true;
66
+ for (let j = 0; j < pattern.length; j++) {
67
+ if (buffer[i + j] !== pattern[j]) {
68
+ match = false;
69
+ break;
70
+ }
71
+ }
72
+ if (match) {
73
+ results.push(i);
74
+ i += pattern.length;
75
+ }
76
+ else {
77
+ i++;
78
+ }
79
+ }
80
+ return results;
81
+ }
82
+ /**
83
+ * Finds the first occurrence of a pattern in a byte buffer within a range
84
+ */
85
+ function findBytesInRange(buffer, start, end, pattern) {
86
+ let i = start;
87
+ while (i <= end - pattern.length) {
88
+ let match = true;
89
+ for (let j = 0; j < pattern.length; j++) {
90
+ if (buffer[i + j] !== pattern[j]) {
91
+ match = false;
92
+ break;
93
+ }
94
+ }
95
+ if (match)
96
+ return i;
97
+ i++;
98
+ }
99
+ return -1;
100
+ }
101
+ /**
102
+ * Checks if a sequence starts at a given position in a byte buffer
103
+ * Returns the position after the sequence if found, -1 otherwise
104
+ */
105
+ function indexAfterSequence(buffer, start, sequence) {
106
+ for (let j = 0; j < sequence.length; j++) {
107
+ if (buffer[start + j] !== sequence[j])
108
+ return -1;
109
+ }
110
+ return start + sequence.length;
111
+ }
112
+ /**
113
+ * Collects all bytes from various stream types into a single Uint8Array
114
+ */
115
+ async function collectStreamBytes(stream) {
116
+ if (!stream)
117
+ return new Uint8Array(0);
118
+ // ReadableStream (WHATWG)
119
+ if (typeof stream.getReader === 'function') {
120
+ const reader = stream.getReader();
121
+ const chunks = [];
122
+ try {
123
+ while (true) {
124
+ const { done, value } = await reader.read();
125
+ if (done)
126
+ break;
127
+ if (value?.byteLength) {
128
+ chunks.push(value);
129
+ }
130
+ }
131
+ }
132
+ finally {
133
+ await reader.cancel();
134
+ }
135
+ return concatUint8Arrays(chunks);
136
+ }
137
+ // AsyncIterable
138
+ if (stream?.[Symbol.asyncIterator]) {
139
+ const chunks = [];
140
+ for await (const chunk of stream) {
141
+ chunks.push(toUint8Array(chunk));
142
+ }
143
+ return concatUint8Arrays(chunks);
144
+ }
145
+ // Direct data types
146
+ if (typeof stream === 'string' || stream instanceof ArrayBuffer || ArrayBuffer.isView(stream)) {
147
+ return toUint8Array(stream);
148
+ }
149
+ // Blob
150
+ if (typeof Blob !== 'undefined' && stream instanceof Blob) {
151
+ const arrayBuffer = await stream.arrayBuffer();
152
+ return new Uint8Array(arrayBuffer);
153
+ }
154
+ // Response
155
+ if (typeof Response !== 'undefined' && stream instanceof Response) {
156
+ const arrayBuffer = await stream.arrayBuffer();
157
+ return new Uint8Array(arrayBuffer);
158
+ }
159
+ throw new DaytonaError_1.DaytonaError('Unsupported stream type for byte collection.');
160
+ }
161
+ /**
162
+ * Checks if value is a File object (browser environment)
163
+ */
164
+ function isFile(value) {
165
+ const FileConstructor = globalThis.File;
166
+ return typeof FileConstructor !== 'undefined' && value instanceof FileConstructor;
167
+ }
168
+ //# sourceMappingURL=Binary.js.map
@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