@daytonaio/sdk 0.164.0-alpha.1 → 0.164.0

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.
@@ -1,4 +1,6 @@
1
- import type { Chart as GeneratedChart, ChartElement as GeneratedChartElement } from '@daytona/toolbox-api-client';
1
+ /**
2
+ * Chart types
3
+ */
2
4
  export declare enum ChartType {
3
5
  LINE = "line",
4
6
  SCATTER = "scatter",
@@ -8,30 +10,142 @@ export declare enum ChartType {
8
10
  COMPOSITE_CHART = "composite_chart",
9
11
  UNKNOWN = "unknown"
10
12
  }
11
- export type Chart = GeneratedChart;
12
- export type ChartElement = GeneratedChartElement;
13
- export type Chart2D = Pick<GeneratedChart, 'type' | 'title' | 'png' | 'x_label' | 'y_label' | 'elements'>;
14
- export type PointChart = Pick<GeneratedChart, 'type' | 'title' | 'png' | 'x_label' | 'y_label' | 'x_ticks' | 'y_ticks' | 'x_tick_labels' | 'y_tick_labels' | 'x_scale' | 'y_scale' | 'elements'>;
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
+ */
15
66
  export type LineChart = PointChart & {
16
- type: 'line';
67
+ /** The type of chart */
68
+ type: ChartType.LINE;
17
69
  };
70
+ /**
71
+ * Represents a scatter chart with metadata.
72
+ */
18
73
  export type ScatterChart = PointChart & {
19
- type: 'scatter';
74
+ /** The type of chart */
75
+ type: ChartType.SCATTER;
20
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
+ */
21
91
  export type BarChart = Chart2D & {
22
- type: 'bar';
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[];
23
116
  };
24
- export type PieChart = Pick<GeneratedChart, 'type' | 'title' | 'png' | 'elements'> & {
25
- type: 'pie';
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[];
26
132
  };
133
+ /**
134
+ * Represents a box and whisker chart with metadata.
135
+ */
27
136
  export type BoxAndWhiskerChart = Chart2D & {
28
- type: 'box_and_whisker';
137
+ /** The type of chart */
138
+ type: ChartType.BOX_AND_WHISKER;
139
+ /** The box and whiskers of the chart */
140
+ elements: BoxAndWhiskerData[];
29
141
  };
30
- export type CompositeChart = Pick<GeneratedChart, 'type' | 'title' | 'png' | 'elements'> & {
31
- type: 'composite_chart';
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[];
32
150
  };
33
- export type PointData = Pick<GeneratedChartElement, 'label' | 'points'>;
34
- export type BarData = Pick<GeneratedChartElement, 'group' | 'label' | 'value'>;
35
- export type PieData = Pick<GeneratedChartElement, 'angle' | 'label' | 'radius'>;
36
- export type BoxAndWhiskerData = Pick<GeneratedChartElement, 'first_quartile' | 'label' | 'max' | 'median' | 'min' | 'outliers'>;
37
- export declare function parseChart(chart: GeneratedChart): Chart;
151
+ export declare function parseChart(data: any): Chart;
@@ -6,6 +6,9 @@
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.ChartType = void 0;
8
8
  exports.parseChart = parseChart;
9
+ /**
10
+ * Chart types
11
+ */
9
12
  var ChartType;
10
13
  (function (ChartType) {
11
14
  ChartType["LINE"] = "line";
@@ -16,22 +19,28 @@ var ChartType;
16
19
  ChartType["COMPOSITE_CHART"] = "composite_chart";
17
20
  ChartType["UNKNOWN"] = "unknown";
18
21
  })(ChartType || (exports.ChartType = ChartType = {}));
19
- function parseChart(chart) {
20
- switch (chart.type) {
22
+ function parseChart(data) {
23
+ switch (data.type) {
21
24
  case ChartType.LINE:
22
- return chart;
25
+ return { ...data };
23
26
  case ChartType.SCATTER:
24
- return chart;
27
+ return { ...data };
25
28
  case ChartType.BAR:
26
- return chart;
29
+ return { ...data };
27
30
  case ChartType.PIE:
28
- return chart;
31
+ return { ...data };
29
32
  case ChartType.BOX_AND_WHISKER:
30
- return chart;
33
+ return { ...data };
31
34
  case ChartType.COMPOSITE_CHART:
32
- return 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
+ };
33
42
  default:
34
- return chart;
43
+ return { ...data, type: ChartType.UNKNOWN };
35
44
  }
36
45
  }
37
46
  //# sourceMappingURL=Charts.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Charts.js","sourceRoot":"","sources":["../../../../../libs/sdk-typescript/src/types/Charts.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAgDH,gCAiBC;AA7DD,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;AAoCD,SAAgB,UAAU,CAAC,KAAqB;IAC9C,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;QACnB,KAAK,SAAS,CAAC,IAAI;YACjB,OAAO,KAAkB,CAAA;QAC3B,KAAK,SAAS,CAAC,OAAO;YACpB,OAAO,KAAqB,CAAA;QAC9B,KAAK,SAAS,CAAC,GAAG;YAChB,OAAO,KAAiB,CAAA;QAC1B,KAAK,SAAS,CAAC,GAAG;YAChB,OAAO,KAAiB,CAAA;QAC1B,KAAK,SAAS,CAAC,eAAe;YAC5B,OAAO,KAA2B,CAAA;QACpC,KAAK,SAAS,CAAC,eAAe;YAC5B,OAAO,KAAuB,CAAA;QAChC;YACE,OAAO,KAAK,CAAA;IAChB,CAAC;AACH,CAAC"}
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"}
@@ -1,4 +1,4 @@
1
- import type { Chart } from './Charts';
1
+ import { Chart } from './Charts';
2
2
  /**
3
3
  * Artifacts from the command execution.
4
4
  *
@@ -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"}