@daytona/sdk 0.196.0 → 0.198.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/cjs/Daytona.d.ts +27 -2
- package/cjs/Daytona.js +64 -7
- package/cjs/Daytona.js.map +1 -1
- package/cjs/Process.js +52 -12
- package/cjs/Process.js.map +1 -1
- package/cjs/PtyHandle.d.ts +14 -0
- package/cjs/PtyHandle.js +100 -34
- package/cjs/PtyHandle.js.map +1 -1
- package/cjs/Sandbox.d.ts +149 -4
- package/cjs/Sandbox.js +523 -136
- package/cjs/Sandbox.js.map +1 -1
- package/cjs/index.d.ts +1 -1
- package/cjs/utils/EventDispatcher.d.ts +85 -0
- package/cjs/utils/EventDispatcher.js +398 -0
- package/cjs/utils/EventDispatcher.js.map +1 -0
- package/cjs/utils/EventSubscriptionManager.d.ts +14 -0
- package/cjs/utils/EventSubscriptionManager.js +98 -0
- package/cjs/utils/EventSubscriptionManager.js.map +1 -0
- package/cjs/utils/WebSocket.d.ts +2 -1
- package/cjs/utils/WebSocket.js +10 -3
- package/cjs/utils/WebSocket.js.map +1 -1
- package/esm/Daytona.d.ts +27 -2
- package/esm/Daytona.js +64 -7
- package/esm/Daytona.js.map +1 -1
- package/esm/Process.js +52 -12
- package/esm/Process.js.map +1 -1
- package/esm/PtyHandle.d.ts +14 -0
- package/esm/PtyHandle.js +100 -34
- package/esm/PtyHandle.js.map +1 -1
- package/esm/Sandbox.d.ts +149 -4
- package/esm/Sandbox.js +524 -137
- package/esm/Sandbox.js.map +1 -1
- package/esm/index.d.ts +1 -1
- package/esm/utils/EventDispatcher.d.ts +85 -0
- package/esm/utils/EventDispatcher.js +394 -0
- package/esm/utils/EventDispatcher.js.map +1 -0
- package/esm/utils/EventSubscriptionManager.d.ts +14 -0
- package/esm/utils/EventSubscriptionManager.js +94 -0
- package/esm/utils/EventSubscriptionManager.js.map +1 -0
- package/esm/utils/Import.js +1 -1
- package/esm/utils/WebSocket.d.ts +2 -1
- package/esm/utils/WebSocket.js +10 -3
- package/esm/utils/WebSocket.js.map +1 -1
- package/package.json +5 -3
package/esm/PtyHandle.d.ts
CHANGED
|
@@ -43,6 +43,8 @@ export declare class PtyHandle {
|
|
|
43
43
|
private _error?;
|
|
44
44
|
private connected;
|
|
45
45
|
private connectionEstablished;
|
|
46
|
+
private _connectionResolvers;
|
|
47
|
+
private _exitResolvers;
|
|
46
48
|
constructor(ws: WebSocket, handleResize: (cols: number, rows: number) => Promise<PtySessionInfo>, handleKill: () => Promise<void>, onPty: (data: Uint8Array) => void | Promise<void>, sessionId: string);
|
|
47
49
|
/**
|
|
48
50
|
* Exit code of the PTY process (if terminated)
|
|
@@ -65,6 +67,14 @@ export declare class PtyHandle {
|
|
|
65
67
|
* @throws {Error} If connection times out (10 seconds) or connection fails
|
|
66
68
|
*/
|
|
67
69
|
waitForConnection(): Promise<void>;
|
|
70
|
+
/**
|
|
71
|
+
* Resolve all pending waitForConnection() callers and clear them.
|
|
72
|
+
*/
|
|
73
|
+
private resolveConnection;
|
|
74
|
+
/**
|
|
75
|
+
* Reject all pending waitForConnection() callers and clear them.
|
|
76
|
+
*/
|
|
77
|
+
private rejectConnection;
|
|
68
78
|
/**
|
|
69
79
|
* Send input data to the PTY session.
|
|
70
80
|
*
|
|
@@ -133,6 +143,10 @@ export declare class PtyHandle {
|
|
|
133
143
|
* }
|
|
134
144
|
*/
|
|
135
145
|
wait(): Promise<PtyResult>;
|
|
146
|
+
/**
|
|
147
|
+
* Resolve all pending wait() callers with the current exit result and clear them.
|
|
148
|
+
*/
|
|
149
|
+
private resolveExit;
|
|
136
150
|
/**
|
|
137
151
|
* Kill the PTY process and terminate the session.
|
|
138
152
|
*
|
package/esm/PtyHandle.js
CHANGED
|
@@ -72,6 +72,8 @@ let PtyHandle = (() => {
|
|
|
72
72
|
_error;
|
|
73
73
|
connected = false;
|
|
74
74
|
connectionEstablished = false; // Track control message received
|
|
75
|
+
_connectionResolvers = [];
|
|
76
|
+
_exitResolvers = [];
|
|
75
77
|
constructor(ws, handleResize, handleKill, onPty, sessionId) {
|
|
76
78
|
this.ws = ws;
|
|
77
79
|
this.handleResize = handleResize;
|
|
@@ -111,25 +113,58 @@ let PtyHandle = (() => {
|
|
|
111
113
|
return;
|
|
112
114
|
}
|
|
113
115
|
return new Promise((resolve, reject) => {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
const
|
|
118
|
-
|
|
116
|
+
// Each caller registers its own entry so concurrent waitForConnection()
|
|
117
|
+
// callers are all resolved/rejected together instead of overwriting one
|
|
118
|
+
// another (which left earlier callers hanging until their own timeout).
|
|
119
|
+
const entry = {
|
|
120
|
+
resolve: () => {
|
|
119
121
|
clearTimeout(timeout);
|
|
120
122
|
resolve();
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
+
},
|
|
124
|
+
reject: (err) => {
|
|
123
125
|
clearTimeout(timeout);
|
|
124
|
-
reject(
|
|
125
|
-
}
|
|
126
|
-
else {
|
|
127
|
-
setTimeout(checkConnection, 100);
|
|
128
|
-
}
|
|
126
|
+
reject(err);
|
|
127
|
+
},
|
|
129
128
|
};
|
|
130
|
-
|
|
129
|
+
const timeout = setTimeout(() => {
|
|
130
|
+
this._connectionResolvers = this._connectionResolvers.filter((r) => r !== entry);
|
|
131
|
+
reject(new DaytonaTimeoutError('PTY connection timeout'));
|
|
132
|
+
}, 10000); // 10 second timeout
|
|
133
|
+
// Check if already connected (race: message arrived before we set up handlers)
|
|
134
|
+
if (this.connectionEstablished) {
|
|
135
|
+
clearTimeout(timeout);
|
|
136
|
+
resolve();
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
// Check if already failed
|
|
140
|
+
if (this.ws.readyState === WebSocket.CLOSED || this._error) {
|
|
141
|
+
clearTimeout(timeout);
|
|
142
|
+
reject(new DaytonaConnectionError(this._error || 'Connection failed'));
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
this._connectionResolvers.push(entry);
|
|
131
146
|
});
|
|
132
147
|
}
|
|
148
|
+
/**
|
|
149
|
+
* Resolve all pending waitForConnection() callers and clear them.
|
|
150
|
+
*/
|
|
151
|
+
resolveConnection() {
|
|
152
|
+
const resolvers = this._connectionResolvers;
|
|
153
|
+
this._connectionResolvers = [];
|
|
154
|
+
for (const r of resolvers) {
|
|
155
|
+
r.resolve();
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Reject all pending waitForConnection() callers and clear them.
|
|
160
|
+
*/
|
|
161
|
+
rejectConnection(err) {
|
|
162
|
+
const resolvers = this._connectionResolvers;
|
|
163
|
+
this._connectionResolvers = [];
|
|
164
|
+
for (const r of resolvers) {
|
|
165
|
+
r.reject(err);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
133
168
|
/**
|
|
134
169
|
* Send input data to the PTY session.
|
|
135
170
|
*
|
|
@@ -225,31 +260,39 @@ let PtyHandle = (() => {
|
|
|
225
260
|
* }
|
|
226
261
|
*/
|
|
227
262
|
async wait() {
|
|
263
|
+
if (this._exitCode !== undefined) {
|
|
264
|
+
return { exitCode: this._exitCode, error: this._error };
|
|
265
|
+
}
|
|
228
266
|
return new Promise((resolve, reject) => {
|
|
267
|
+
// Check again in case it resolved between the sync check and the promise setup
|
|
229
268
|
if (this._exitCode !== undefined) {
|
|
230
|
-
resolve({
|
|
231
|
-
exitCode: this._exitCode,
|
|
232
|
-
error: this._error,
|
|
233
|
-
});
|
|
269
|
+
resolve({ exitCode: this._exitCode, error: this._error });
|
|
234
270
|
return;
|
|
235
271
|
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
reject(new DaytonaError(this._error));
|
|
245
|
-
}
|
|
246
|
-
else {
|
|
247
|
-
setTimeout(checkExit, 100);
|
|
248
|
-
}
|
|
249
|
-
};
|
|
250
|
-
checkExit();
|
|
272
|
+
// If there's already an error and no exit code, reject
|
|
273
|
+
if (this._error && this._exitCode === undefined) {
|
|
274
|
+
reject(new DaytonaError(this._error));
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
// Register this caller; all pending callers are resolved together on exit so
|
|
278
|
+
// concurrent wait() calls do not overwrite each other and hang forever.
|
|
279
|
+
this._exitResolvers.push(resolve);
|
|
251
280
|
});
|
|
252
281
|
}
|
|
282
|
+
/**
|
|
283
|
+
* Resolve all pending wait() callers with the current exit result and clear them.
|
|
284
|
+
*/
|
|
285
|
+
resolveExit() {
|
|
286
|
+
if (this._exitResolvers.length === 0) {
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
const result = { exitCode: this._exitCode, error: this._error };
|
|
290
|
+
const resolvers = this._exitResolvers;
|
|
291
|
+
this._exitResolvers = [];
|
|
292
|
+
for (const resolve of resolvers) {
|
|
293
|
+
resolve(result);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
253
296
|
/**
|
|
254
297
|
* Kill the PTY process and terminate the session.
|
|
255
298
|
*
|
|
@@ -289,11 +332,28 @@ let PtyHandle = (() => {
|
|
|
289
332
|
if (controlMsg.type === 'control') {
|
|
290
333
|
if (controlMsg.status === 'connected') {
|
|
291
334
|
this.connectionEstablished = true;
|
|
335
|
+
this.resolveConnection();
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
else if (controlMsg.status === 'exited') {
|
|
339
|
+
this._exitCode = controlMsg.exitCode ?? undefined;
|
|
340
|
+
if (controlMsg.exitReason) {
|
|
341
|
+
this._error = controlMsg.exitReason;
|
|
342
|
+
}
|
|
343
|
+
// An instantly-exiting PTY still means the connection was established;
|
|
344
|
+
// unblock any pending waitForConnection() so it does not hang/reject.
|
|
345
|
+
this.connectionEstablished = true;
|
|
346
|
+
// The PTY has exited: mark disconnected so isConnected() does not
|
|
347
|
+
// report true for a dead session between 'exited' and the WS close.
|
|
348
|
+
this.connected = false;
|
|
349
|
+
this.resolveConnection();
|
|
350
|
+
this.resolveExit();
|
|
292
351
|
return;
|
|
293
352
|
}
|
|
294
353
|
else if (controlMsg.status === 'error') {
|
|
295
354
|
this._error = controlMsg.error || 'Unknown connection error';
|
|
296
355
|
this.connected = false;
|
|
356
|
+
this.rejectConnection(new DaytonaConnectionError(this._error));
|
|
297
357
|
return;
|
|
298
358
|
}
|
|
299
359
|
}
|
|
@@ -346,12 +406,14 @@ let PtyHandle = (() => {
|
|
|
346
406
|
}
|
|
347
407
|
this._error = errorMessage;
|
|
348
408
|
this.connected = false;
|
|
409
|
+
// Reject pending waitForConnection() if still waiting
|
|
410
|
+
this.rejectConnection(new DaytonaConnectionError(errorMessage));
|
|
349
411
|
};
|
|
350
412
|
// Handle WebSocket close - parse structured exit data
|
|
351
413
|
const handleClose = async (event) => {
|
|
352
414
|
this.connected = false;
|
|
353
|
-
// Parse structured exit data from close reason
|
|
354
|
-
if (event && event.reason) {
|
|
415
|
+
// Parse structured exit data from close reason (only if not already set by control message)
|
|
416
|
+
if (this._exitCode === undefined && event && event.reason) {
|
|
355
417
|
try {
|
|
356
418
|
const exitData = JSON.parse(event.reason);
|
|
357
419
|
if (typeof exitData.exitCode === 'number') {
|
|
@@ -376,6 +438,10 @@ let PtyHandle = (() => {
|
|
|
376
438
|
if (this._exitCode === undefined && event && event.code === 1000) {
|
|
377
439
|
this._exitCode = 0;
|
|
378
440
|
}
|
|
441
|
+
// Resolve pending wait() if not already resolved by control message
|
|
442
|
+
this.resolveExit();
|
|
443
|
+
// Reject pending waitForConnection() if still waiting
|
|
444
|
+
this.rejectConnection(new DaytonaConnectionError(this._error || 'Connection closed'));
|
|
379
445
|
};
|
|
380
446
|
// Attach event listeners based on WebSocket implementation
|
|
381
447
|
if (this.ws.addEventListener) {
|
package/esm/PtyHandle.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PtyHandle.js","sourceRoot":"","sources":["../../../../sdk-typescript/src/PtyHandle.ts"],"names":[],"mappings":"AAAA;;;GAGG;;AA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,EAAE,CAAC,gBAAgB,CAAC,OAAO,EAAE,WAAW,CAAC,CAAA;gBAC9C,IAAI,CAAC,EAAE,CAAC,gBAAgB,CAAC,OAAO,EAAE,WAAW,CAAC,CAAA;YAChD,CAAC;iBAAM,IAAI,IAAI,IAAI,IAAI,CAAC,EAAE,IAAI,OAAO,IAAI,CAAC,EAAE,CAAC,EAAE,KAAK,UAAU,EAAE,CAAC;gBAC/D,oBAAoB;gBACpB,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;gBAC9B,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,SAAS,EAAE,aAAa,CAAC,CAAA;gBACpC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,CAAC,CAAA;gBAChC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,CAAC,CAAA;YAClC,CAAC;iBAAM,CAAC;gBACN,MAAM,IAAI,YAAY,CAAC,sCAAsC,CAAC,CAAA;YAChE,CAAC;QACH,CAAC;;;SAtaU,SAAS"}
|
package/esm/Sandbox.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { LspLanguageId, LspServer } from './LspServer.js';
|
|
|
8
8
|
import { ComputerUse } from './ComputerUse.js';
|
|
9
9
|
import type { AxiosInstance } from 'axios';
|
|
10
10
|
import { CodeInterpreter } from './CodeInterpreter.js';
|
|
11
|
+
import { EventSubscriptionManager } from './utils/EventSubscriptionManager.js';
|
|
11
12
|
/**
|
|
12
13
|
* Represents a Daytona Sandbox.
|
|
13
14
|
*
|
|
@@ -37,8 +38,10 @@ import { CodeInterpreter } from './CodeInterpreter.js';
|
|
|
37
38
|
* @property {string} [backupCreatedAt] - When the backup was created (not returned by list results;
|
|
38
39
|
* call `refreshData()` on each item to populate)
|
|
39
40
|
* @property {number} [autoStopInterval] - Auto-stop interval in minutes
|
|
41
|
+
* @property {number} [autoPauseInterval] - Auto-pause interval in minutes
|
|
40
42
|
* @property {number} [autoArchiveInterval] - Auto-archive interval in minutes
|
|
41
43
|
* @property {number} [autoDeleteInterval] - Auto-delete interval in minutes
|
|
44
|
+
* @property {string} [autoDestroyAt] - When the Sandbox will be automatically destroyed (only set when a TTL is configured)
|
|
42
45
|
* @property {Array<SandboxVolume>} [volumes] - Volumes attached to the Sandbox (not returned by
|
|
43
46
|
* list results; call `refreshData()` on each item to populate)
|
|
44
47
|
* @property {BuildInfo} [buildInfo] - Build information for the Sandbox if it was created from dynamic build
|
|
@@ -61,6 +64,8 @@ export declare class Sandbox {
|
|
|
61
64
|
private readonly clientConfig;
|
|
62
65
|
private readonly axiosInstance;
|
|
63
66
|
private readonly sandboxApi;
|
|
67
|
+
private readonly getAnalyticsApiUrl;
|
|
68
|
+
private readonly subscriptionManager;
|
|
64
69
|
readonly fs: FileSystem;
|
|
65
70
|
readonly git: Git;
|
|
66
71
|
readonly process: Process;
|
|
@@ -85,8 +90,10 @@ export declare class Sandbox {
|
|
|
85
90
|
backupState?: SandboxBackupStateEnum;
|
|
86
91
|
backupCreatedAt?: string;
|
|
87
92
|
autoStopInterval?: number;
|
|
93
|
+
autoPauseInterval?: number;
|
|
88
94
|
autoArchiveInterval?: number;
|
|
89
95
|
autoDeleteInterval?: number;
|
|
96
|
+
autoDestroyAt?: string;
|
|
90
97
|
volumes?: Array<SandboxVolume>;
|
|
91
98
|
buildInfo?: BuildInfo;
|
|
92
99
|
createdAt?: string;
|
|
@@ -99,12 +106,22 @@ export declare class Sandbox {
|
|
|
99
106
|
toolboxProxyUrl: string;
|
|
100
107
|
private infoApi;
|
|
101
108
|
private serverApi;
|
|
109
|
+
private systemApi;
|
|
110
|
+
private readonly stateWaiters;
|
|
111
|
+
private readonly stateWaiterErrorMessageFns;
|
|
112
|
+
private subId;
|
|
102
113
|
/**
|
|
103
|
-
* Creates a new Sandbox instance
|
|
114
|
+
* Creates a new Sandbox instance.
|
|
115
|
+
*
|
|
116
|
+
* Internal: obtain sandboxes via {@link Daytona.create}, {@link Daytona.get}, or
|
|
117
|
+
* {@link Daytona.list} rather than constructing directly.
|
|
104
118
|
*
|
|
105
119
|
* @param {SandboxDto} sandboxDto - The API Sandbox instance
|
|
120
|
+
* @param {SandboxApi} sandboxApi - API client for Sandbox operations
|
|
121
|
+
* @param {InfoApi} infoApi - API client for info operations
|
|
122
|
+
* @param {EventSubscriptionManager} subscriptionManager - Event subscription manager for real-time updates
|
|
106
123
|
*/
|
|
107
|
-
constructor(sandboxDto: SandboxDto | SandboxListItemDto, clientConfig: Configuration, axiosInstance: AxiosInstance, sandboxApi: SandboxApi);
|
|
124
|
+
constructor(sandboxDto: SandboxDto | SandboxListItemDto, clientConfig: Configuration, axiosInstance: AxiosInstance, sandboxApi: SandboxApi, getAnalyticsApiUrl: () => Promise<string | undefined>, subscriptionManager: EventSubscriptionManager);
|
|
108
125
|
/**
|
|
109
126
|
* Gets the user's home directory path for the logged in user inside the Sandbox.
|
|
110
127
|
*
|
|
@@ -115,6 +132,34 @@ export declare class Sandbox {
|
|
|
115
132
|
* console.log(`Sandbox user home: ${userHomeDir}`);
|
|
116
133
|
*/
|
|
117
134
|
getUserHomeDir(): Promise<string | undefined>;
|
|
135
|
+
/**
|
|
136
|
+
* Gets the most recent resource usage sample directly from the sandbox daemon.
|
|
137
|
+
*
|
|
138
|
+
* Unlike {@link getMetrics}, which returns aggregated historical samples, this returns the
|
|
139
|
+
* single current reading without going through the telemetry backend.
|
|
140
|
+
*
|
|
141
|
+
* @returns The current resource usage sample for the sandbox.
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* const m = await sandbox.getMetricsLatest()
|
|
145
|
+
* console.log(`CPU: ${m.cpuUsedPct}%, mem: ${m.memUsed}/${m.memTotal}`)
|
|
146
|
+
*/
|
|
147
|
+
getMetricsLatest(): Promise<SandboxMetrics>;
|
|
148
|
+
/**
|
|
149
|
+
* Gets historical time-series resource usage metrics for the Sandbox.
|
|
150
|
+
*
|
|
151
|
+
* @param {Date} [start] - Start of the time range. Defaults to the Sandbox creation time.
|
|
152
|
+
* @param {Date} [end] - End of the time range. Defaults to the current time.
|
|
153
|
+
* @returns Time-ordered usage samples over the requested range.
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* const samples = await sandbox.getMetrics()
|
|
157
|
+
* for (const s of samples) {
|
|
158
|
+
* console.log(`${s.timestamp.toISOString()} CPU: ${s.cpuUsedPct}% mem: ${s.memUsed}/${s.memTotal}`)
|
|
159
|
+
* }
|
|
160
|
+
*/
|
|
161
|
+
getMetrics(start?: Date, end?: Date): Promise<SandboxMetrics[]>;
|
|
162
|
+
private buildAnalyticsTelemetryApi;
|
|
118
163
|
/**
|
|
119
164
|
* @deprecated Use `getUserHomeDir` instead. This method will be removed in a future version.
|
|
120
165
|
*/
|
|
@@ -269,12 +314,20 @@ export declare class Sandbox {
|
|
|
269
314
|
* console.log('Sandbox paused successfully');
|
|
270
315
|
*/
|
|
271
316
|
pause(timeout?: number): Promise<void>;
|
|
272
|
-
private waitForPauseComplete;
|
|
273
317
|
/**
|
|
274
318
|
* Deletes the Sandbox.
|
|
319
|
+
*
|
|
320
|
+
* By default this returns as soon as the deletion request is accepted (matching
|
|
321
|
+
* historical behavior). Pass `wait = true` to block until the Sandbox reaches
|
|
322
|
+
* the 'destroyed' state.
|
|
323
|
+
*
|
|
324
|
+
* @param {number} [timeout] - Timeout in seconds for the request — and, when
|
|
325
|
+
* `wait` is true, for reaching 'destroyed'. 0 means no timeout.
|
|
326
|
+
* Defaults to 60-second timeout.
|
|
327
|
+
* @param {boolean} [wait] - If true, wait until the Sandbox is destroyed. Defaults to false.
|
|
275
328
|
* @returns {Promise<void>}
|
|
276
329
|
*/
|
|
277
|
-
delete(timeout?: number): Promise<void>;
|
|
330
|
+
delete(timeout?: number, wait?: boolean): Promise<void>;
|
|
278
331
|
/**
|
|
279
332
|
* Waits for the Sandbox to reach the 'started' state.
|
|
280
333
|
*
|
|
@@ -343,6 +396,49 @@ export declare class Sandbox {
|
|
|
343
396
|
* await sandbox.setAutostopInterval(0);
|
|
344
397
|
*/
|
|
345
398
|
setAutostopInterval(interval: number): Promise<void>;
|
|
399
|
+
/**
|
|
400
|
+
* Set the auto-pause interval for the Sandbox.
|
|
401
|
+
*
|
|
402
|
+
* The Sandbox will automatically pause after being idle (no new events) for the specified interval.
|
|
403
|
+
* Events include any state changes or interactions with the Sandbox through the sdk.
|
|
404
|
+
* Interactions using Sandbox Previews are not included.
|
|
405
|
+
*
|
|
406
|
+
* Only supported for sandbox classes that support pausing. At most one of the auto-stop
|
|
407
|
+
* and auto-pause intervals may be non-zero, so disable auto-stop first by setting its
|
|
408
|
+
* interval to 0.
|
|
409
|
+
*
|
|
410
|
+
* @param {number} interval - Number of minutes of inactivity before auto-pausing.
|
|
411
|
+
* Set to 0 to disable auto-pause. For pause-supporting sandbox
|
|
412
|
+
* classes, creation defaults to 60 minutes when neither interval is provided.
|
|
413
|
+
* @returns {Promise<void>}
|
|
414
|
+
* @throws {DaytonaError} - `DaytonaError` - If interval is not a non-negative integer
|
|
415
|
+
*
|
|
416
|
+
* @example
|
|
417
|
+
* // Auto-pause after 1 hour
|
|
418
|
+
* await sandbox.setAutoPauseInterval(60);
|
|
419
|
+
* // Or disable auto-pause
|
|
420
|
+
* await sandbox.setAutoPauseInterval(0);
|
|
421
|
+
*/
|
|
422
|
+
setAutoPauseInterval(interval: number): Promise<void>;
|
|
423
|
+
/**
|
|
424
|
+
* Set the TTL (maximum time to live) for the Sandbox.
|
|
425
|
+
*
|
|
426
|
+
* The Sandbox will be destroyed once the TTL elapses, counted as wall-clock time regardless of the
|
|
427
|
+
* Sandbox state - even if it is stopped, paused, or archived. Calling this method re-anchors the
|
|
428
|
+
* deadline from the current time. Call `refreshData()` afterwards to read the updated `autoDestroyAt`.
|
|
429
|
+
*
|
|
430
|
+
* @param {number} ttlMinutes - Number of minutes from now after which the Sandbox will be destroyed.
|
|
431
|
+
* Set to 0 to disable the TTL.
|
|
432
|
+
* @returns {Promise<void>}
|
|
433
|
+
* @throws {DaytonaError} - `DaytonaError` - If ttlMinutes is not a non-negative integer
|
|
434
|
+
*
|
|
435
|
+
* @example
|
|
436
|
+
* // Destroy the Sandbox 1 hour from now
|
|
437
|
+
* await sandbox.setTtl(60);
|
|
438
|
+
* // Or disable the TTL
|
|
439
|
+
* await sandbox.setTtl(0);
|
|
440
|
+
*/
|
|
441
|
+
setTtl(ttlMinutes: number): Promise<void>;
|
|
346
442
|
/**
|
|
347
443
|
* Set the auto-archive interval for the Sandbox.
|
|
348
444
|
*
|
|
@@ -530,6 +626,25 @@ export declare class Sandbox {
|
|
|
530
626
|
* @returns {Promise<SshAccessValidationDto>} The SSH access validation result.
|
|
531
627
|
*/
|
|
532
628
|
validateSshAccess(token: string): Promise<SshAccessValidationDto>;
|
|
629
|
+
/**
|
|
630
|
+
* Subscribes to real-time events for this sandbox.
|
|
631
|
+
* Auto-updates sandbox metadata on every event.
|
|
632
|
+
*/
|
|
633
|
+
private subscribeToEvents;
|
|
634
|
+
private ensureSubscribed;
|
|
635
|
+
private handleEvent;
|
|
636
|
+
/**
|
|
637
|
+
* Waits for the sandbox to reach one of the target states.
|
|
638
|
+
* Throws on error states or timeout.
|
|
639
|
+
*
|
|
640
|
+
* @param targetStates - States that indicate success.
|
|
641
|
+
* @param errorStates - States that indicate failure.
|
|
642
|
+
* @param timeout - Maximum time to wait in seconds. 0 means no timeout.
|
|
643
|
+
* @param timeoutMessage - Error message when timeout is reached.
|
|
644
|
+
* @param errorMessageFn - Function that produces an error message from the current state.
|
|
645
|
+
* @param safeRefresh - If true, use refreshDataSafe() for polling (for delete operations where 404 is expected).
|
|
646
|
+
*/
|
|
647
|
+
private waitForState;
|
|
533
648
|
/**
|
|
534
649
|
* Assigns the API sandbox data to the Sandbox object.
|
|
535
650
|
*
|
|
@@ -543,7 +658,15 @@ export declare class Sandbox {
|
|
|
543
658
|
*
|
|
544
659
|
* @returns {Promise<void>}
|
|
545
660
|
*/
|
|
661
|
+
/**
|
|
662
|
+
* @returns true when the refresh produced authoritative state (success, or 404
|
|
663
|
+
* mapped to DESTROYED); false when a transient error was swallowed and
|
|
664
|
+
* the cached state is stale.
|
|
665
|
+
*/
|
|
546
666
|
private refreshDataSafe;
|
|
667
|
+
private applyState;
|
|
668
|
+
private checkStateWaiter;
|
|
669
|
+
private removeStateWaiter;
|
|
547
670
|
}
|
|
548
671
|
export interface ListSandboxesQuery {
|
|
549
672
|
/**
|
|
@@ -631,4 +754,26 @@ export interface ListSandboxesQuery {
|
|
|
631
754
|
* */
|
|
632
755
|
lastActivityBefore?: Date;
|
|
633
756
|
}
|
|
757
|
+
/**
|
|
758
|
+
* A single point-in-time sample of historical Sandbox resource usage.
|
|
759
|
+
*
|
|
760
|
+
* @property {number} cpuCount - Number of CPU cores allocated to the Sandbox.
|
|
761
|
+
* @property {number} cpuUsedPct - CPU utilization as a percentage of the allocated limit.
|
|
762
|
+
* @property {number} diskTotal - Total disk space in bytes.
|
|
763
|
+
* @property {number} diskUsed - Used disk space in bytes.
|
|
764
|
+
* @property {number} memTotal - Total memory in bytes.
|
|
765
|
+
* @property {number} memUsed - Used memory in bytes.
|
|
766
|
+
* @property {number} memCache - Memory used by the page cache in bytes.
|
|
767
|
+
* @property {Date} timestamp - Timestamp of this sample.
|
|
768
|
+
*/
|
|
769
|
+
export interface SandboxMetrics {
|
|
770
|
+
cpuCount: number;
|
|
771
|
+
cpuUsedPct: number;
|
|
772
|
+
diskTotal: number;
|
|
773
|
+
diskUsed: number;
|
|
774
|
+
memTotal: number;
|
|
775
|
+
memUsed: number;
|
|
776
|
+
memCache: number;
|
|
777
|
+
timestamp: Date;
|
|
778
|
+
}
|
|
634
779
|
//# sourceMappingURL=Sandbox.d.ts.map
|