@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.
- package/README.md +180 -0
- package/package.json +56 -0
- package/src/CodeInterpreter.d.ts +94 -0
- package/src/CodeInterpreter.js +297 -0
- package/src/CodeInterpreter.js.map +1 -0
- package/src/ComputerUse.d.ts +538 -0
- package/src/ComputerUse.js +808 -0
- package/src/ComputerUse.js.map +1 -0
- package/src/Daytona.d.ts +340 -0
- package/src/Daytona.js +538 -0
- package/src/Daytona.js.map +1 -0
- package/src/FileSystem.d.ts +326 -0
- package/src/FileSystem.js +412 -0
- package/src/FileSystem.js.map +1 -0
- package/src/Git.d.ts +202 -0
- package/src/Git.js +326 -0
- package/src/Git.js.map +1 -0
- package/src/Image.d.ts +264 -0
- package/src/Image.js +546 -0
- package/src/Image.js.map +1 -0
- package/src/LspServer.d.ts +171 -0
- package/src/LspServer.js +258 -0
- package/src/LspServer.js.map +1 -0
- package/src/ObjectStorage.d.ts +78 -0
- package/src/ObjectStorage.js +199 -0
- package/src/ObjectStorage.js.map +1 -0
- package/src/Process.d.ts +490 -0
- package/src/Process.js +790 -0
- package/src/Process.js.map +1 -0
- package/src/PtyHandle.d.ts +154 -0
- package/src/PtyHandle.js +416 -0
- package/src/PtyHandle.js.map +1 -0
- package/src/Sandbox.d.ts +425 -0
- package/src/Sandbox.js +776 -0
- package/src/Sandbox.js.map +1 -0
- package/src/Snapshot.d.ts +139 -0
- package/src/Snapshot.js +248 -0
- package/src/Snapshot.js.map +1 -0
- package/src/Volume.d.ts +83 -0
- package/src/Volume.js +119 -0
- package/src/Volume.js.map +1 -0
- package/src/code-toolbox/SandboxJsCodeToolbox.d.ts +5 -0
- package/src/code-toolbox/SandboxJsCodeToolbox.js +20 -0
- package/src/code-toolbox/SandboxJsCodeToolbox.js.map +1 -0
- package/src/code-toolbox/SandboxPythonCodeToolbox.d.ts +11 -0
- package/src/code-toolbox/SandboxPythonCodeToolbox.js +359 -0
- package/src/code-toolbox/SandboxPythonCodeToolbox.js.map +1 -0
- package/src/code-toolbox/SandboxTsCodeToolbox.d.ts +5 -0
- package/src/code-toolbox/SandboxTsCodeToolbox.js +29 -0
- package/src/code-toolbox/SandboxTsCodeToolbox.js.map +1 -0
- package/src/errors/DaytonaError.d.ts +31 -0
- package/src/errors/DaytonaError.js +51 -0
- package/src/errors/DaytonaError.js.map +1 -0
- package/src/index.d.ts +21 -0
- package/src/index.js +45 -0
- package/src/index.js.map +1 -0
- package/src/types/Charts.d.ts +151 -0
- package/src/types/Charts.js +46 -0
- package/src/types/Charts.js.map +1 -0
- package/src/types/CodeInterpreter.d.ts +76 -0
- package/src/types/CodeInterpreter.js +7 -0
- package/src/types/CodeInterpreter.js.map +1 -0
- package/src/types/ExecuteResponse.d.ts +25 -0
- package/src/types/ExecuteResponse.js +7 -0
- package/src/types/ExecuteResponse.js.map +1 -0
- package/src/types/Pty.d.ts +47 -0
- package/src/types/Pty.js +7 -0
- package/src/types/Pty.js.map +1 -0
- package/src/utils/ArtifactParser.d.ts +13 -0
- package/src/utils/ArtifactParser.js +55 -0
- package/src/utils/ArtifactParser.js.map +1 -0
- package/src/utils/Binary.d.ts +38 -0
- package/src/utils/Binary.js +168 -0
- package/src/utils/Binary.js.map +1 -0
- package/src/utils/FileTransfer.d.ts +14 -0
- package/src/utils/FileTransfer.js +216 -0
- package/src/utils/FileTransfer.js.map +1 -0
- package/src/utils/Import.d.ts +97 -0
- package/src/utils/Import.js +79 -0
- package/src/utils/Import.js.map +1 -0
- package/src/utils/Multipart.d.ts +26 -0
- package/src/utils/Multipart.js +113 -0
- package/src/utils/Multipart.js.map +1 -0
- package/src/utils/Runtime.d.ts +43 -0
- package/src/utils/Runtime.js +95 -0
- package/src/utils/Runtime.js.map +1 -0
- package/src/utils/Stream.d.ts +19 -0
- package/src/utils/Stream.js +364 -0
- package/src/utils/Stream.js.map +1 -0
- package/src/utils/WebSocket.d.ts +9 -0
- package/src/utils/WebSocket.js +26 -0
- package/src/utils/WebSocket.js.map +1 -0
- package/src/utils/otel.decorator.d.ts +82 -0
- package/src/utils/otel.decorator.js +141 -0
- package/src/utils/otel.decorator.js.map +1 -0
|
@@ -0,0 +1,141 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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,EAAE;QACtF,MAAM,cAAc,GAAG,UAAU,CAAC,KAAK,CAAA;QACvC,MAAM,UAAU,GAAG,MAAM,CAAC,WAAW,CAAC,CAAA;QAEtC,UAAU,CAAC,KAAK,GAAG,KAAK,WAAW,GAAG,IAAW;YAC/C,MAAM,GAAG,GAAe,OAAO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