@daytonaio/sdk 0.175.0 → 0.178.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.
- package/cjs/CodeInterpreter.d.ts +3 -2
- package/cjs/CodeInterpreter.js.map +1 -1
- package/cjs/ComputerUse.d.ts +104 -2
- package/cjs/ComputerUse.js +851 -763
- package/cjs/ComputerUse.js.map +1 -1
- package/cjs/Daytona.d.ts +4 -3
- package/cjs/Daytona.js +429 -443
- package/cjs/Daytona.js.map +1 -1
- package/cjs/FileSystem.d.ts +2 -2
- package/cjs/FileSystem.js +491 -521
- package/cjs/FileSystem.js.map +1 -1
- package/cjs/Git.d.ts +2 -1
- package/cjs/Git.js +287 -310
- package/cjs/Git.js.map +1 -1
- package/cjs/LspServer.d.ts +2 -1
- package/cjs/LspServer.js +209 -226
- package/cjs/LspServer.js.map +1 -1
- package/cjs/ObjectStorage.js +170 -166
- package/cjs/ObjectStorage.js.map +1 -1
- package/cjs/Process.d.ts +4 -3
- package/cjs/Process.js +562 -600
- package/cjs/Process.js.map +1 -1
- package/cjs/PtyHandle.d.ts +2 -2
- package/cjs/PtyHandle.js +327 -338
- package/cjs/PtyHandle.js.map +1 -1
- package/cjs/Sandbox.d.ts +4 -3
- package/cjs/Sandbox.js +756 -821
- package/cjs/Sandbox.js.map +1 -1
- package/cjs/Snapshot.d.ts +3 -2
- package/cjs/Snapshot.js +203 -213
- package/cjs/Snapshot.js.map +1 -1
- package/cjs/Volume.d.ts +2 -1
- package/cjs/Volume.js +90 -92
- package/cjs/Volume.js.map +1 -1
- package/cjs/errors/DaytonaError.d.ts +2 -1
- package/cjs/errors/DaytonaError.js.map +1 -1
- package/cjs/index.d.ts +2 -2
- package/cjs/index.js +2 -1
- package/cjs/index.js.map +1 -1
- package/cjs/types/CodeInterpreter.d.ts +1 -1
- package/cjs/utils/Binary.js +14 -2
- package/cjs/utils/Binary.js.map +1 -1
- package/cjs/utils/otel.decorator.d.ts +7 -8
- package/cjs/utils/otel.decorator.js +24 -30
- package/cjs/utils/otel.decorator.js.map +1 -1
- package/esm/CodeInterpreter.d.ts +3 -2
- package/esm/CodeInterpreter.js.map +1 -1
- package/esm/ComputerUse.d.ts +104 -2
- package/esm/ComputerUse.js +857 -763
- package/esm/ComputerUse.js.map +1 -1
- package/esm/Daytona.d.ts +4 -3
- package/esm/Daytona.js +431 -444
- package/esm/Daytona.js.map +1 -1
- package/esm/FileSystem.d.ts +2 -2
- package/esm/FileSystem.js +493 -522
- package/esm/FileSystem.js.map +1 -1
- package/esm/Git.d.ts +2 -1
- package/esm/Git.js +289 -311
- package/esm/Git.js.map +1 -1
- package/esm/LspServer.d.ts +2 -1
- package/esm/LspServer.js +211 -227
- package/esm/LspServer.js.map +1 -1
- package/esm/ObjectStorage.js +172 -167
- package/esm/ObjectStorage.js.map +1 -1
- package/esm/Process.d.ts +4 -3
- package/esm/Process.js +564 -601
- package/esm/Process.js.map +1 -1
- package/esm/PtyHandle.d.ts +2 -2
- package/esm/PtyHandle.js +329 -339
- package/esm/PtyHandle.js.map +1 -1
- package/esm/Sandbox.d.ts +4 -3
- package/esm/Sandbox.js +759 -823
- package/esm/Sandbox.js.map +1 -1
- package/esm/Snapshot.d.ts +3 -2
- package/esm/Snapshot.js +206 -215
- package/esm/Snapshot.js.map +1 -1
- package/esm/Volume.d.ts +2 -1
- package/esm/Volume.js +92 -93
- package/esm/Volume.js.map +1 -1
- package/esm/errors/DaytonaError.d.ts +2 -1
- package/esm/errors/DaytonaError.js.map +1 -1
- package/esm/index.d.ts +2 -2
- package/esm/index.js +1 -1
- package/esm/index.js.map +1 -1
- package/esm/types/CodeInterpreter.d.ts +1 -1
- package/esm/utils/Binary.js +14 -2
- package/esm/utils/Binary.js.map +1 -1
- package/esm/utils/otel.decorator.d.ts +7 -8
- package/esm/utils/otel.decorator.js +26 -32
- package/esm/utils/otel.decorator.js.map +1 -1
- package/package.json +3 -3
package/cjs/Daytona.js
CHANGED
|
@@ -61,474 +61,460 @@ var CodeLanguage;
|
|
|
61
61
|
* });
|
|
62
62
|
* @class
|
|
63
63
|
*/
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
this
|
|
88
|
-
this.
|
|
89
|
-
this.
|
|
90
|
-
|
|
91
|
-
this.target = config?.target;
|
|
64
|
+
let Daytona = (() => {
|
|
65
|
+
let _instanceExtraInitializers = [];
|
|
66
|
+
let _create_decorators;
|
|
67
|
+
let _get_decorators;
|
|
68
|
+
let _list_decorators;
|
|
69
|
+
let _start_decorators;
|
|
70
|
+
let _stop_decorators;
|
|
71
|
+
let __experimental_fork_decorators;
|
|
72
|
+
let _delete_decorators;
|
|
73
|
+
return class Daytona {
|
|
74
|
+
static {
|
|
75
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
76
|
+
_create_decorators = [(0, otel_decorator_1.WithInstrumentation)()];
|
|
77
|
+
_get_decorators = [(0, otel_decorator_1.WithInstrumentation)()];
|
|
78
|
+
_list_decorators = [(0, otel_decorator_1.WithInstrumentation)()];
|
|
79
|
+
_start_decorators = [(0, otel_decorator_1.WithInstrumentation)()];
|
|
80
|
+
_stop_decorators = [(0, otel_decorator_1.WithInstrumentation)()];
|
|
81
|
+
__experimental_fork_decorators = [(0, otel_decorator_1.WithInstrumentation)()];
|
|
82
|
+
_delete_decorators = [(0, otel_decorator_1.WithInstrumentation)()];
|
|
83
|
+
tslib_1.__esDecorate(this, null, _create_decorators, { kind: "method", name: "create", static: false, private: false, access: { has: obj => "create" in obj, get: obj => obj.create }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
84
|
+
tslib_1.__esDecorate(this, null, _get_decorators, { kind: "method", name: "get", static: false, private: false, access: { has: obj => "get" in obj, get: obj => obj.get }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
85
|
+
tslib_1.__esDecorate(this, null, _list_decorators, { kind: "method", name: "list", static: false, private: false, access: { has: obj => "list" in obj, get: obj => obj.list }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
86
|
+
tslib_1.__esDecorate(this, null, _start_decorators, { kind: "method", name: "start", static: false, private: false, access: { has: obj => "start" in obj, get: obj => obj.start }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
87
|
+
tslib_1.__esDecorate(this, null, _stop_decorators, { kind: "method", name: "stop", static: false, private: false, access: { has: obj => "stop" in obj, get: obj => obj.stop }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
88
|
+
tslib_1.__esDecorate(this, null, __experimental_fork_decorators, { kind: "method", name: "_experimental_fork", static: false, private: false, access: { has: obj => "_experimental_fork" in obj, get: obj => obj._experimental_fork }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
89
|
+
tslib_1.__esDecorate(this, null, _delete_decorators, { kind: "method", name: "delete", static: false, private: false, access: { has: obj => "delete" in obj, get: obj => obj.delete }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
90
|
+
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
92
91
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
92
|
+
clientConfig = tslib_1.__runInitializers(this, _instanceExtraInitializers);
|
|
93
|
+
sandboxApi;
|
|
94
|
+
objectStorageApi;
|
|
95
|
+
configApi;
|
|
96
|
+
target;
|
|
97
|
+
apiKey;
|
|
98
|
+
jwtToken;
|
|
99
|
+
organizationId;
|
|
100
|
+
apiUrl;
|
|
101
|
+
otelSdk;
|
|
102
|
+
volume;
|
|
103
|
+
snapshot;
|
|
104
|
+
/**
|
|
105
|
+
* Creates a new Daytona client instance.
|
|
106
|
+
*
|
|
107
|
+
* @param {DaytonaConfig} [config] - Configuration options
|
|
108
|
+
* @throws {DaytonaAuthenticationError} When no credentials are provided (neither API key nor JWT token)
|
|
109
|
+
* @throws {DaytonaAuthenticationError} When JWT token is provided without an organization ID
|
|
110
|
+
*/
|
|
111
|
+
constructor(config) {
|
|
112
|
+
let apiUrl;
|
|
113
|
+
if (config) {
|
|
114
|
+
this.apiKey = !config?.apiKey && config?.jwtToken ? undefined : config?.apiKey;
|
|
115
|
+
this.jwtToken = config?.jwtToken;
|
|
116
|
+
this.organizationId = config?.organizationId;
|
|
117
|
+
apiUrl = config?.apiUrl || config?.serverUrl;
|
|
118
|
+
this.target = config?.target;
|
|
97
119
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
this.
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
120
|
+
let _envReader;
|
|
121
|
+
const envReader = () => {
|
|
122
|
+
if (_envReader === undefined) {
|
|
123
|
+
_envReader = Runtime_1.RUNTIME !== Runtime_1.Runtime.BROWSER ? new Runtime_1.DaytonaEnvReader() : null;
|
|
124
|
+
}
|
|
125
|
+
return _envReader;
|
|
126
|
+
};
|
|
127
|
+
if (!config ||
|
|
128
|
+
(!(this.apiKey && apiUrl && this.target) && !(this.jwtToken && this.organizationId && apiUrl && this.target))) {
|
|
129
|
+
const reader = envReader();
|
|
130
|
+
if (reader) {
|
|
131
|
+
this.apiKey = this.apiKey || (this.jwtToken ? undefined : reader.get('DAYTONA_API_KEY'));
|
|
132
|
+
this.jwtToken = this.jwtToken || reader.get('DAYTONA_JWT_TOKEN');
|
|
133
|
+
this.organizationId = this.organizationId || reader.get('DAYTONA_ORGANIZATION_ID');
|
|
134
|
+
apiUrl = apiUrl || reader.get('DAYTONA_API_URL') || reader.get('DAYTONA_SERVER_URL');
|
|
135
|
+
this.target = this.target || reader.get('DAYTONA_TARGET');
|
|
136
|
+
if (reader.get('DAYTONA_SERVER_URL') && !reader.get('DAYTONA_API_URL')) {
|
|
137
|
+
console.warn('[Deprecation Warning] Environment variable `DAYTONA_SERVER_URL` is deprecated and will be removed in future versions. Use `DAYTONA_API_URL` instead.');
|
|
138
|
+
}
|
|
111
139
|
}
|
|
112
140
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
' These can also be provided via DaytonaConfig.');
|
|
118
|
-
}
|
|
119
|
-
const orgHeader = {};
|
|
120
|
-
if (!this.apiKey) {
|
|
121
|
-
if (!this.organizationId) {
|
|
122
|
-
throw new DaytonaError_1.DaytonaAuthenticationError('DAYTONA_ORGANIZATION_ID is required when authenticating with DAYTONA_JWT_TOKEN.' +
|
|
123
|
-
' It can also be provided via DaytonaConfig.');
|
|
141
|
+
this.apiUrl = apiUrl || 'https://app.daytona.io/api';
|
|
142
|
+
if (!this.apiKey && !this.jwtToken) {
|
|
143
|
+
throw new DaytonaError_1.DaytonaAuthenticationError('Authentication credentials not found. Set DAYTONA_API_KEY, or both DAYTONA_JWT_TOKEN and DAYTONA_ORGANIZATION_ID.' +
|
|
144
|
+
' These can also be provided via DaytonaConfig.');
|
|
124
145
|
}
|
|
125
|
-
orgHeader
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
146
|
+
const orgHeader = {};
|
|
147
|
+
if (!this.apiKey) {
|
|
148
|
+
if (!this.organizationId) {
|
|
149
|
+
throw new DaytonaError_1.DaytonaAuthenticationError('DAYTONA_ORGANIZATION_ID is required when authenticating with DAYTONA_JWT_TOKEN.' +
|
|
150
|
+
' It can also be provided via DaytonaConfig.');
|
|
151
|
+
}
|
|
152
|
+
orgHeader['X-Daytona-Organization-ID'] = this.organizationId;
|
|
153
|
+
}
|
|
154
|
+
const isLegacyPackage = packageJson.name === '@daytonaio/sdk';
|
|
155
|
+
const sdkLabel = isLegacyPackage ? 'sdk-typescript-legacy' : 'sdk-typescript';
|
|
156
|
+
const configuration = new api_client_1.Configuration({
|
|
157
|
+
basePath: this.apiUrl,
|
|
158
|
+
baseOptions: {
|
|
159
|
+
headers: {
|
|
160
|
+
Authorization: `Bearer ${this.apiKey || this.jwtToken}`,
|
|
161
|
+
'X-Daytona-Source': sdkLabel,
|
|
162
|
+
'X-Daytona-SDK-Version': packageJson.version,
|
|
163
|
+
'User-Agent': `${sdkLabel}/${packageJson.version}`,
|
|
164
|
+
...orgHeader,
|
|
165
|
+
},
|
|
138
166
|
},
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
[ATTR_SERVICE_NAME]: 'daytona-typescript-sdk',
|
|
170
|
-
}),
|
|
171
|
-
instrumentations: [
|
|
172
|
-
new HttpInstrumentation({
|
|
173
|
-
requireParentforOutgoingSpans: false,
|
|
167
|
+
});
|
|
168
|
+
const axiosInstance = Daytona.createAxiosInstance();
|
|
169
|
+
this.sandboxApi = new api_client_1.SandboxApi(configuration, '', axiosInstance);
|
|
170
|
+
this.objectStorageApi = new api_client_1.ObjectStorageApi(configuration, '', axiosInstance);
|
|
171
|
+
this.configApi = new api_client_1.ConfigApi(configuration, '', axiosInstance);
|
|
172
|
+
this.volume = new Volume_1.VolumeService(new api_client_1.VolumesApi(configuration, '', axiosInstance));
|
|
173
|
+
this.snapshot = new Snapshot_1.SnapshotService(configuration, new api_client_1.SnapshotsApi(configuration, '', axiosInstance), this.objectStorageApi, this.target);
|
|
174
|
+
this.clientConfig = configuration;
|
|
175
|
+
const env = envReader();
|
|
176
|
+
const otelEnabled = config?.otelEnabled ||
|
|
177
|
+
config?._experimental?.otelEnabled ||
|
|
178
|
+
env?.get('DAYTONA_OTEL_ENABLED') === 'true' ||
|
|
179
|
+
env?.get('DAYTONA_EXPERIMENTAL_OTEL_ENABLED') === 'true';
|
|
180
|
+
if (!otelEnabled) {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
const errPrefix = 'OpenTelemetry instrumentation is not supported: ';
|
|
184
|
+
const { diag, DiagConsoleLogger, DiagLogLevel } = (0, Import_1.dynamicRequire)('@opentelemetry/api', errPrefix);
|
|
185
|
+
const { NodeSDK } = (0, Import_1.dynamicRequire)('@opentelemetry/sdk-node', errPrefix);
|
|
186
|
+
const { HttpInstrumentation } = (0, Import_1.dynamicRequire)('@opentelemetry/instrumentation-http', errPrefix);
|
|
187
|
+
const { BatchSpanProcessor } = (0, Import_1.dynamicRequire)('@opentelemetry/sdk-trace-base', errPrefix);
|
|
188
|
+
const { OTLPTraceExporter } = (0, Import_1.dynamicRequire)('@opentelemetry/exporter-trace-otlp-http', errPrefix);
|
|
189
|
+
const { CompressionAlgorithm } = (0, Import_1.dynamicRequire)('@opentelemetry/otlp-exporter-base', errPrefix);
|
|
190
|
+
const { ATTR_SERVICE_NAME, ATTR_SERVICE_VERSION } = (0, Import_1.dynamicRequire)('@opentelemetry/semantic-conventions', errPrefix);
|
|
191
|
+
const { resourceFromAttributes } = (0, Import_1.dynamicRequire)('@opentelemetry/resources', errPrefix);
|
|
192
|
+
diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.INFO);
|
|
193
|
+
this.otelSdk = new NodeSDK({
|
|
194
|
+
resource: resourceFromAttributes({
|
|
195
|
+
[ATTR_SERVICE_VERSION]: packageJson.version,
|
|
196
|
+
[ATTR_SERVICE_NAME]: 'daytona-typescript-sdk',
|
|
174
197
|
}),
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
}
|
|
192
|
-
await this.otelSdk.shutdown();
|
|
193
|
-
}
|
|
194
|
-
async create(params, options = { timeout: 60 }) {
|
|
195
|
-
const startTime = Date.now();
|
|
196
|
-
options = typeof options === 'number' ? { timeout: options } : { ...options };
|
|
197
|
-
if (options.timeout == undefined || options.timeout == null) {
|
|
198
|
-
options.timeout = 60;
|
|
199
|
-
}
|
|
200
|
-
if (params == null) {
|
|
201
|
-
params = { language: 'python' };
|
|
202
|
-
}
|
|
203
|
-
if (!params.language) {
|
|
204
|
-
params.language = 'python';
|
|
198
|
+
instrumentations: [
|
|
199
|
+
new HttpInstrumentation({
|
|
200
|
+
requireParentforOutgoingSpans: false,
|
|
201
|
+
}),
|
|
202
|
+
],
|
|
203
|
+
spanProcessors: [
|
|
204
|
+
new BatchSpanProcessor(new OTLPTraceExporter({
|
|
205
|
+
compression: CompressionAlgorithm.GZIP,
|
|
206
|
+
})),
|
|
207
|
+
],
|
|
208
|
+
});
|
|
209
|
+
this.otelSdk.start();
|
|
210
|
+
// Flush and shutdown OTEL on process exit
|
|
211
|
+
process.on('SIGTERM', async () => {
|
|
212
|
+
await this.otelSdk?.shutdown();
|
|
213
|
+
});
|
|
205
214
|
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
if (!validLanguages.includes(params.language)) {
|
|
210
|
-
throw new DaytonaError_1.DaytonaValidationError(`Invalid ${exports.CODE_TOOLBOX_LANGUAGE_LABEL}: ${params.language}. Supported languages: ${validLanguages.join(', ')}`);
|
|
215
|
+
async [Symbol.asyncDispose]() {
|
|
216
|
+
if (!this.otelSdk) {
|
|
217
|
+
return;
|
|
211
218
|
}
|
|
212
|
-
|
|
213
|
-
}
|
|
214
|
-
if (options.timeout < 0) {
|
|
215
|
-
throw new DaytonaError_1.DaytonaValidationError('Timeout must be a non-negative number');
|
|
219
|
+
await this.otelSdk.shutdown();
|
|
216
220
|
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
if (params.autoDeleteInterval !== undefined && params.autoDeleteInterval !== 0) {
|
|
223
|
-
console.warn("'ephemeral' and 'autoDeleteInterval' cannot be used together. If ephemeral is true, autoDeleteInterval will be ignored and set to 0.");
|
|
221
|
+
async create(params, options = { timeout: 60 }) {
|
|
222
|
+
const startTime = Date.now();
|
|
223
|
+
options = typeof options === 'number' ? { timeout: options } : { ...options };
|
|
224
|
+
if (options.timeout == undefined || options.timeout == null) {
|
|
225
|
+
options.timeout = 60;
|
|
224
226
|
}
|
|
225
|
-
params
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
(!
|
|
229
|
-
|
|
230
|
-
}
|
|
231
|
-
try {
|
|
232
|
-
let buildInfo;
|
|
233
|
-
let snapshot;
|
|
234
|
-
let resources;
|
|
235
|
-
if ('snapshot' in params) {
|
|
236
|
-
snapshot = params.snapshot;
|
|
227
|
+
if (params == null) {
|
|
228
|
+
params = { language: 'python' };
|
|
229
|
+
}
|
|
230
|
+
if (!params.language) {
|
|
231
|
+
params.language = 'python';
|
|
237
232
|
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
};
|
|
233
|
+
const labels = params.labels || {};
|
|
234
|
+
if (params.language) {
|
|
235
|
+
const validLanguages = Object.values(CodeLanguage);
|
|
236
|
+
if (!validLanguages.includes(params.language)) {
|
|
237
|
+
throw new DaytonaError_1.DaytonaValidationError(`Invalid ${exports.CODE_TOOLBOX_LANGUAGE_LABEL}: ${params.language}. Supported languages: ${validLanguages.join(', ')}`);
|
|
243
238
|
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
239
|
+
labels[exports.CODE_TOOLBOX_LANGUAGE_LABEL] = params.language;
|
|
240
|
+
}
|
|
241
|
+
if (options.timeout < 0) {
|
|
242
|
+
throw new DaytonaError_1.DaytonaValidationError('Timeout must be a non-negative number');
|
|
243
|
+
}
|
|
244
|
+
if (params.autoStopInterval !== undefined &&
|
|
245
|
+
(!Number.isInteger(params.autoStopInterval) || params.autoStopInterval < 0)) {
|
|
246
|
+
throw new DaytonaError_1.DaytonaValidationError('autoStopInterval must be a non-negative integer');
|
|
247
|
+
}
|
|
248
|
+
if (params.ephemeral) {
|
|
249
|
+
if (params.autoDeleteInterval !== undefined && params.autoDeleteInterval !== 0) {
|
|
250
|
+
console.warn("'ephemeral' and 'autoDeleteInterval' cannot be used together. If ephemeral is true, autoDeleteInterval will be ignored and set to 0.");
|
|
250
251
|
}
|
|
252
|
+
params.autoDeleteInterval = 0;
|
|
251
253
|
}
|
|
252
|
-
if (
|
|
253
|
-
|
|
254
|
+
if (params.autoArchiveInterval !== undefined &&
|
|
255
|
+
(!Number.isInteger(params.autoArchiveInterval) || params.autoArchiveInterval < 0)) {
|
|
256
|
+
throw new DaytonaError_1.DaytonaValidationError('autoArchiveInterval must be a non-negative integer');
|
|
254
257
|
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
}, undefined, {
|
|
275
|
-
timeout: options.timeout * 1000,
|
|
276
|
-
});
|
|
277
|
-
let sandboxInstance = response.data;
|
|
278
|
-
if (sandboxInstance.state === api_client_1.SandboxState.PENDING_BUILD && options.onSnapshotCreateLogs) {
|
|
279
|
-
const terminalStates = [
|
|
280
|
-
api_client_1.SandboxState.STARTED,
|
|
281
|
-
api_client_1.SandboxState.STARTING,
|
|
282
|
-
api_client_1.SandboxState.ERROR,
|
|
283
|
-
api_client_1.SandboxState.BUILD_FAILED,
|
|
284
|
-
];
|
|
285
|
-
while (sandboxInstance.state === api_client_1.SandboxState.PENDING_BUILD) {
|
|
286
|
-
if (options.timeout) {
|
|
287
|
-
const elapsed = (Date.now() - startTime) / 1000;
|
|
288
|
-
if (elapsed > options.timeout) {
|
|
289
|
-
throw new DaytonaError_1.DaytonaTimeoutError(`Sandbox build has been pending for more than ${options.timeout} seconds. Please check the sandbox state again later.`);
|
|
290
|
-
}
|
|
258
|
+
try {
|
|
259
|
+
let buildInfo;
|
|
260
|
+
let snapshot;
|
|
261
|
+
let resources;
|
|
262
|
+
if ('snapshot' in params) {
|
|
263
|
+
snapshot = params.snapshot;
|
|
264
|
+
}
|
|
265
|
+
if ('image' in params) {
|
|
266
|
+
if (typeof params.image === 'string') {
|
|
267
|
+
buildInfo = {
|
|
268
|
+
dockerfileContent: Image_1.Image.base(params.image).dockerfile,
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
else if (params.image instanceof Image_1.Image) {
|
|
272
|
+
const contextHashes = await Snapshot_1.SnapshotService.processImageContext(this.objectStorageApi, params.image);
|
|
273
|
+
buildInfo = {
|
|
274
|
+
contextHashes,
|
|
275
|
+
dockerfileContent: params.image.dockerfile,
|
|
276
|
+
};
|
|
291
277
|
}
|
|
292
|
-
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
293
|
-
sandboxInstance = (await this.sandboxApi.getSandbox(sandboxInstance.id)).data;
|
|
294
278
|
}
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
279
|
+
if ('resources' in params) {
|
|
280
|
+
resources = params.resources;
|
|
281
|
+
}
|
|
282
|
+
const response = await this.sandboxApi.createSandbox({
|
|
283
|
+
name: params.name,
|
|
284
|
+
snapshot: snapshot,
|
|
285
|
+
buildInfo,
|
|
286
|
+
user: params.user,
|
|
287
|
+
env: params.envVars || {},
|
|
288
|
+
labels: labels,
|
|
289
|
+
public: params.public,
|
|
290
|
+
target: this.target,
|
|
291
|
+
cpu: resources?.cpu,
|
|
292
|
+
gpu: resources?.gpu,
|
|
293
|
+
memory: resources?.memory,
|
|
294
|
+
disk: resources?.disk,
|
|
295
|
+
autoStopInterval: params.autoStopInterval,
|
|
296
|
+
autoArchiveInterval: params.autoArchiveInterval,
|
|
297
|
+
autoDeleteInterval: params.autoDeleteInterval,
|
|
298
|
+
volumes: params.volumes,
|
|
299
|
+
networkBlockAll: params.networkBlockAll,
|
|
300
|
+
networkAllowList: params.networkAllowList,
|
|
301
|
+
}, undefined, {
|
|
302
|
+
timeout: options.timeout * 1000,
|
|
302
303
|
});
|
|
304
|
+
let sandboxInstance = response.data;
|
|
305
|
+
if (sandboxInstance.state === api_client_1.SandboxState.PENDING_BUILD && options.onSnapshotCreateLogs) {
|
|
306
|
+
const terminalStates = [
|
|
307
|
+
api_client_1.SandboxState.STARTED,
|
|
308
|
+
api_client_1.SandboxState.STARTING,
|
|
309
|
+
api_client_1.SandboxState.ERROR,
|
|
310
|
+
api_client_1.SandboxState.BUILD_FAILED,
|
|
311
|
+
];
|
|
312
|
+
while (sandboxInstance.state === api_client_1.SandboxState.PENDING_BUILD) {
|
|
313
|
+
if (options.timeout) {
|
|
314
|
+
const elapsed = (Date.now() - startTime) / 1000;
|
|
315
|
+
if (elapsed > options.timeout) {
|
|
316
|
+
throw new DaytonaError_1.DaytonaTimeoutError(`Sandbox build has been pending for more than ${options.timeout} seconds. Please check the sandbox state again later.`);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
320
|
+
sandboxInstance = (await this.sandboxApi.getSandbox(sandboxInstance.id)).data;
|
|
321
|
+
}
|
|
322
|
+
const response = await this.sandboxApi.getBuildLogsUrl(sandboxInstance.id);
|
|
323
|
+
await (0, Stream_1.processStreamingResponse)(() => fetch(response.data.url + '?follow=true', {
|
|
324
|
+
method: 'GET',
|
|
325
|
+
headers: this.clientConfig.baseOptions.headers,
|
|
326
|
+
}), (chunk) => options.onSnapshotCreateLogs?.(chunk.trimEnd()), async () => {
|
|
327
|
+
sandboxInstance = (await this.sandboxApi.getSandbox(sandboxInstance.id)).data;
|
|
328
|
+
return sandboxInstance.state !== undefined && terminalStates.includes(sandboxInstance.state);
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
const sandbox = new Sandbox_1.Sandbox(sandboxInstance, new api_client_1.Configuration(structuredClone(this.clientConfig)), Daytona.createAxiosInstance(), this.sandboxApi);
|
|
332
|
+
if (sandbox.state !== 'started') {
|
|
333
|
+
const timeElapsed = Date.now() - startTime;
|
|
334
|
+
await sandbox.waitUntilStarted(options.timeout ? Math.max(0.001, options.timeout - timeElapsed / 1000) : options.timeout);
|
|
335
|
+
}
|
|
336
|
+
return sandbox;
|
|
303
337
|
}
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
338
|
+
catch (error) {
|
|
339
|
+
if (error instanceof DaytonaError_1.DaytonaTimeoutError) {
|
|
340
|
+
const errMsg = `Failed to create and start sandbox within ${options.timeout} seconds. Operation timed out.`;
|
|
341
|
+
throw new DaytonaError_1.DaytonaTimeoutError(errMsg, error.statusCode, error.headers, error.errorCode);
|
|
342
|
+
}
|
|
343
|
+
throw error;
|
|
308
344
|
}
|
|
309
|
-
return sandbox;
|
|
310
345
|
}
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
346
|
+
/**
|
|
347
|
+
* Gets a Sandbox by its ID or name.
|
|
348
|
+
*
|
|
349
|
+
* @param {string} sandboxIdOrName - The ID or name of the Sandbox to retrieve
|
|
350
|
+
* @returns {Promise<Sandbox>} The Sandbox
|
|
351
|
+
*
|
|
352
|
+
* @example
|
|
353
|
+
* const sandbox = await daytona.get('my-sandbox-id-or-name');
|
|
354
|
+
* console.log(`Sandbox state: ${sandbox.state}`);
|
|
355
|
+
*/
|
|
356
|
+
async get(sandboxIdOrName) {
|
|
357
|
+
const response = await this.sandboxApi.getSandbox(sandboxIdOrName);
|
|
358
|
+
const sandboxInstance = response.data;
|
|
359
|
+
return new Sandbox_1.Sandbox(sandboxInstance, structuredClone(this.clientConfig), Daytona.createAxiosInstance(), this.sandboxApi);
|
|
317
360
|
}
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
axiosInstance.interceptors.request.use((requestConfig) => {
|
|
427
|
-
// Get the current active context (which may contain an active span)
|
|
428
|
-
const currentContext = api_1.context.active();
|
|
429
|
-
// Inject trace context into HTTP headers using W3C Trace Context propagation
|
|
430
|
-
// This adds headers like 'traceparent' and 'tracestate'
|
|
431
|
-
api_1.propagation.inject(currentContext, requestConfig.headers);
|
|
432
|
-
requestConfig.metadata = { startTime: Date.now() };
|
|
433
|
-
return requestConfig;
|
|
434
|
-
}, (error) => {
|
|
435
|
-
return Promise.reject(error);
|
|
436
|
-
});
|
|
437
|
-
axiosInstance.interceptors.response.use((response) => {
|
|
438
|
-
return response;
|
|
439
|
-
}, (error) => {
|
|
440
|
-
if (error instanceof axios_1.AxiosError) {
|
|
441
|
-
throw (0, DaytonaError_1.createAxiosDaytonaError)(error);
|
|
442
|
-
}
|
|
443
|
-
throw new DaytonaError_1.DaytonaError(error instanceof Error ? error.message : String(error));
|
|
444
|
-
});
|
|
445
|
-
axiosInstance.interceptors.response.use((response) => {
|
|
446
|
-
const startTime = response.config.metadata?.startTime;
|
|
447
|
-
if (startTime) {
|
|
448
|
-
const duration = Date.now() - startTime;
|
|
449
|
-
// Get the active span to add attributes
|
|
450
|
-
const activeSpan = api_1.trace.getActiveSpan();
|
|
451
|
-
// Only modify the span if it's still recording (not ended)
|
|
452
|
-
if (activeSpan && activeSpan.isRecording()) {
|
|
453
|
-
// Add response metadata to the span
|
|
454
|
-
activeSpan.setAttributes({
|
|
455
|
-
'http.response.status_code': response.status,
|
|
456
|
-
'http.response.duration_ms': duration,
|
|
457
|
-
// 'http.response.size_bytes': JSON.stringify(response.data).length,
|
|
458
|
-
});
|
|
361
|
+
/**
|
|
362
|
+
* Returns paginated list of Sandboxes filtered by labels.
|
|
363
|
+
*
|
|
364
|
+
* @param {Record<string, string>} [labels] - Labels to filter Sandboxes
|
|
365
|
+
* @param {number} [page] - Page number for pagination (starting from 1)
|
|
366
|
+
* @param {number} [limit] - Maximum number of items per page
|
|
367
|
+
* @returns {Promise<PaginatedSandboxes>} Paginated list of Sandboxes that match the labels.
|
|
368
|
+
*
|
|
369
|
+
* @example
|
|
370
|
+
* const result = await daytona.list({ 'my-label': 'my-value' }, 2, 10);
|
|
371
|
+
* for (const sandbox of result.items) {
|
|
372
|
+
* console.log(`${sandbox.id}: ${sandbox.state}`);
|
|
373
|
+
* }
|
|
374
|
+
*/
|
|
375
|
+
async list(labels, page, limit) {
|
|
376
|
+
const response = await this.sandboxApi.listSandboxesPaginated(undefined, page, limit, undefined, undefined, labels ? JSON.stringify(labels) : undefined);
|
|
377
|
+
return {
|
|
378
|
+
items: response.data.items.map((sandbox) => {
|
|
379
|
+
return new Sandbox_1.Sandbox(sandbox, structuredClone(this.clientConfig), Daytona.createAxiosInstance(), this.sandboxApi);
|
|
380
|
+
}),
|
|
381
|
+
total: response.data.total,
|
|
382
|
+
page: response.data.page,
|
|
383
|
+
totalPages: response.data.totalPages,
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* Starts a Sandbox and waits for it to be ready.
|
|
388
|
+
*
|
|
389
|
+
* @param {Sandbox} sandbox - The Sandbox to start
|
|
390
|
+
* @param {number} [timeout] - Optional timeout in seconds (0 means no timeout)
|
|
391
|
+
* @returns {Promise<void>}
|
|
392
|
+
*
|
|
393
|
+
* @example
|
|
394
|
+
* const sandbox = await daytona.get('my-sandbox-id');
|
|
395
|
+
* // Wait up to 60 seconds for the sandbox to start
|
|
396
|
+
* await daytona.start(sandbox, 60);
|
|
397
|
+
*/
|
|
398
|
+
async start(sandbox, timeout) {
|
|
399
|
+
await sandbox.start(timeout);
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* Stops a Sandbox.
|
|
403
|
+
*
|
|
404
|
+
* @param {Sandbox} sandbox - The Sandbox to stop
|
|
405
|
+
* @returns {Promise<void>}
|
|
406
|
+
*
|
|
407
|
+
* @example
|
|
408
|
+
* const sandbox = await daytona.get('my-sandbox-id');
|
|
409
|
+
* await daytona.stop(sandbox);
|
|
410
|
+
*/
|
|
411
|
+
async stop(sandbox) {
|
|
412
|
+
await sandbox.stop();
|
|
413
|
+
}
|
|
414
|
+
/**
|
|
415
|
+
* Forks a Sandbox, creating a new Sandbox with an identical filesystem.
|
|
416
|
+
*
|
|
417
|
+
* @param {Sandbox} sandbox - The Sandbox to fork
|
|
418
|
+
* @param {object} [params] - Fork parameters
|
|
419
|
+
* @param {string} [params.name] - Optional name for the forked Sandbox
|
|
420
|
+
* @param {number} [timeout] - Timeout in seconds (0 means no timeout, default is 60)
|
|
421
|
+
* @returns {Promise<Sandbox>} The forked Sandbox
|
|
422
|
+
*
|
|
423
|
+
* @example
|
|
424
|
+
* const sandbox = await daytona.get('my-sandbox-id');
|
|
425
|
+
* const forked = await daytona._experimental_fork(sandbox, { name: 'my-fork' });
|
|
426
|
+
* console.log(`Forked sandbox: ${forked.id}`);
|
|
427
|
+
*/
|
|
428
|
+
async _experimental_fork(sandbox, params, timeout = 60) {
|
|
429
|
+
return await sandbox._experimental_fork(params, timeout);
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* Deletes a Sandbox.
|
|
433
|
+
*
|
|
434
|
+
* @param {Sandbox} sandbox - The Sandbox to delete
|
|
435
|
+
* @param {number} timeout - Timeout in seconds (0 means no timeout, default is 60)
|
|
436
|
+
* @returns {Promise<void>}
|
|
437
|
+
*
|
|
438
|
+
* @example
|
|
439
|
+
* const sandbox = await daytona.get('my-sandbox-id');
|
|
440
|
+
* await daytona.delete(sandbox);
|
|
441
|
+
*/
|
|
442
|
+
async delete(sandbox, timeout = 60) {
|
|
443
|
+
await sandbox.delete(timeout);
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* @hidden
|
|
447
|
+
*/
|
|
448
|
+
static createAxiosInstance() {
|
|
449
|
+
const axiosInstance = axios_1.default.create({
|
|
450
|
+
timeout: 24 * 60 * 60 * 1000, // 24 hours
|
|
451
|
+
});
|
|
452
|
+
// Request interceptor: Inject trace context into headers
|
|
453
|
+
axiosInstance.interceptors.request.use((requestConfig) => {
|
|
454
|
+
// Get the current active context (which may contain an active span)
|
|
455
|
+
const currentContext = api_1.context.active();
|
|
456
|
+
// Inject trace context into HTTP headers using W3C Trace Context propagation
|
|
457
|
+
// This adds headers like 'traceparent' and 'tracestate'
|
|
458
|
+
api_1.propagation.inject(currentContext, requestConfig.headers);
|
|
459
|
+
requestConfig.metadata = { startTime: Date.now() };
|
|
460
|
+
return requestConfig;
|
|
461
|
+
}, (error) => {
|
|
462
|
+
return Promise.reject(error);
|
|
463
|
+
});
|
|
464
|
+
axiosInstance.interceptors.response.use((response) => {
|
|
465
|
+
return response;
|
|
466
|
+
}, (error) => {
|
|
467
|
+
if (error instanceof axios_1.AxiosError) {
|
|
468
|
+
throw (0, DaytonaError_1.createAxiosDaytonaError)(error);
|
|
459
469
|
}
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
'error.type': error.name,
|
|
477
|
-
'error.message': error.message,
|
|
478
|
-
});
|
|
479
|
-
if (error.response) {
|
|
480
|
-
activeSpan.setAttribute('http.response.status_code', error.response.status);
|
|
470
|
+
throw new DaytonaError_1.DaytonaError(error instanceof Error ? error.message : String(error));
|
|
471
|
+
});
|
|
472
|
+
axiosInstance.interceptors.response.use((response) => {
|
|
473
|
+
const startTime = response.config.metadata?.startTime;
|
|
474
|
+
if (startTime) {
|
|
475
|
+
const duration = Date.now() - startTime;
|
|
476
|
+
// Get the active span to add attributes
|
|
477
|
+
const activeSpan = api_1.trace.getActiveSpan();
|
|
478
|
+
// Only modify the span if it's still recording (not ended)
|
|
479
|
+
if (activeSpan && activeSpan.isRecording()) {
|
|
480
|
+
// Add response metadata to the span
|
|
481
|
+
activeSpan.setAttributes({
|
|
482
|
+
'http.response.status_code': response.status,
|
|
483
|
+
'http.response.duration_ms': duration,
|
|
484
|
+
// 'http.response.size_bytes': JSON.stringify(response.data).length,
|
|
485
|
+
});
|
|
481
486
|
}
|
|
482
|
-
// Record the exception on the span
|
|
483
|
-
activeSpan.recordException(error);
|
|
484
487
|
}
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
488
|
+
return response;
|
|
489
|
+
}, (error) => {
|
|
490
|
+
const startTime = error.config?.metadata?.startTime;
|
|
491
|
+
if (startTime) {
|
|
492
|
+
const duration = Date.now() - startTime;
|
|
493
|
+
// Get the active span to record the error
|
|
494
|
+
const activeSpan = api_1.trace.getActiveSpan();
|
|
495
|
+
// Only modify the span if it's still recording (not ended)
|
|
496
|
+
if (activeSpan && activeSpan.isRecording()) {
|
|
497
|
+
activeSpan.setStatus({
|
|
498
|
+
code: api_1.SpanStatusCode.ERROR,
|
|
499
|
+
message: error.message,
|
|
500
|
+
});
|
|
501
|
+
activeSpan.setAttributes({
|
|
502
|
+
'http.response.duration_ms': duration,
|
|
503
|
+
'error.type': error.name,
|
|
504
|
+
'error.message': error.message,
|
|
505
|
+
});
|
|
506
|
+
if (error.response) {
|
|
507
|
+
activeSpan.setAttribute('http.response.status_code', error.response.status);
|
|
508
|
+
}
|
|
509
|
+
// Record the exception on the span
|
|
510
|
+
activeSpan.recordException(error);
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
return Promise.reject(error);
|
|
514
|
+
});
|
|
515
|
+
return axiosInstance;
|
|
516
|
+
}
|
|
517
|
+
};
|
|
518
|
+
})();
|
|
491
519
|
exports.Daytona = Daytona;
|
|
492
|
-
tslib_1.__decorate([
|
|
493
|
-
(0, otel_decorator_1.WithInstrumentation)(),
|
|
494
|
-
tslib_1.__metadata("design:type", Function),
|
|
495
|
-
tslib_1.__metadata("design:paramtypes", [Object, Object]),
|
|
496
|
-
tslib_1.__metadata("design:returntype", Promise)
|
|
497
|
-
], Daytona.prototype, "create", null);
|
|
498
|
-
tslib_1.__decorate([
|
|
499
|
-
(0, otel_decorator_1.WithInstrumentation)(),
|
|
500
|
-
tslib_1.__metadata("design:type", Function),
|
|
501
|
-
tslib_1.__metadata("design:paramtypes", [String]),
|
|
502
|
-
tslib_1.__metadata("design:returntype", Promise)
|
|
503
|
-
], Daytona.prototype, "get", null);
|
|
504
|
-
tslib_1.__decorate([
|
|
505
|
-
(0, otel_decorator_1.WithInstrumentation)(),
|
|
506
|
-
tslib_1.__metadata("design:type", Function),
|
|
507
|
-
tslib_1.__metadata("design:paramtypes", [Object, Number, Number]),
|
|
508
|
-
tslib_1.__metadata("design:returntype", Promise)
|
|
509
|
-
], Daytona.prototype, "list", null);
|
|
510
|
-
tslib_1.__decorate([
|
|
511
|
-
(0, otel_decorator_1.WithInstrumentation)(),
|
|
512
|
-
tslib_1.__metadata("design:type", Function),
|
|
513
|
-
tslib_1.__metadata("design:paramtypes", [Sandbox_1.Sandbox, Number]),
|
|
514
|
-
tslib_1.__metadata("design:returntype", Promise)
|
|
515
|
-
], Daytona.prototype, "start", null);
|
|
516
|
-
tslib_1.__decorate([
|
|
517
|
-
(0, otel_decorator_1.WithInstrumentation)(),
|
|
518
|
-
tslib_1.__metadata("design:type", Function),
|
|
519
|
-
tslib_1.__metadata("design:paramtypes", [Sandbox_1.Sandbox]),
|
|
520
|
-
tslib_1.__metadata("design:returntype", Promise)
|
|
521
|
-
], Daytona.prototype, "stop", null);
|
|
522
|
-
tslib_1.__decorate([
|
|
523
|
-
(0, otel_decorator_1.WithInstrumentation)(),
|
|
524
|
-
tslib_1.__metadata("design:type", Function),
|
|
525
|
-
tslib_1.__metadata("design:paramtypes", [Sandbox_1.Sandbox, Object, Object]),
|
|
526
|
-
tslib_1.__metadata("design:returntype", Promise)
|
|
527
|
-
], Daytona.prototype, "_experimental_fork", null);
|
|
528
|
-
tslib_1.__decorate([
|
|
529
|
-
(0, otel_decorator_1.WithInstrumentation)(),
|
|
530
|
-
tslib_1.__metadata("design:type", Function),
|
|
531
|
-
tslib_1.__metadata("design:paramtypes", [Sandbox_1.Sandbox, Object]),
|
|
532
|
-
tslib_1.__metadata("design:returntype", Promise)
|
|
533
|
-
], Daytona.prototype, "delete", null);
|
|
534
520
|
//# sourceMappingURL=Daytona.js.map
|