@daytona/sdk 0.196.0 → 0.198.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/Daytona.d.ts +25 -2
- package/cjs/Daytona.js +60 -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 +128 -4
- package/cjs/Sandbox.js +493 -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 +25 -2
- package/esm/Daytona.js +60 -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 +128 -4
- package/esm/Sandbox.js +494 -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;;AAEH,OAA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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,6 +38,7 @@ 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
|
|
42
44
|
* @property {Array<SandboxVolume>} [volumes] - Volumes attached to the Sandbox (not returned by
|
|
@@ -61,6 +63,8 @@ export declare class Sandbox {
|
|
|
61
63
|
private readonly clientConfig;
|
|
62
64
|
private readonly axiosInstance;
|
|
63
65
|
private readonly sandboxApi;
|
|
66
|
+
private readonly getAnalyticsApiUrl;
|
|
67
|
+
private readonly subscriptionManager;
|
|
64
68
|
readonly fs: FileSystem;
|
|
65
69
|
readonly git: Git;
|
|
66
70
|
readonly process: Process;
|
|
@@ -85,6 +89,7 @@ export declare class Sandbox {
|
|
|
85
89
|
backupState?: SandboxBackupStateEnum;
|
|
86
90
|
backupCreatedAt?: string;
|
|
87
91
|
autoStopInterval?: number;
|
|
92
|
+
autoPauseInterval?: number;
|
|
88
93
|
autoArchiveInterval?: number;
|
|
89
94
|
autoDeleteInterval?: number;
|
|
90
95
|
volumes?: Array<SandboxVolume>;
|
|
@@ -99,12 +104,22 @@ export declare class Sandbox {
|
|
|
99
104
|
toolboxProxyUrl: string;
|
|
100
105
|
private infoApi;
|
|
101
106
|
private serverApi;
|
|
107
|
+
private systemApi;
|
|
108
|
+
private readonly stateWaiters;
|
|
109
|
+
private readonly stateWaiterErrorMessageFns;
|
|
110
|
+
private subId;
|
|
102
111
|
/**
|
|
103
|
-
* Creates a new Sandbox instance
|
|
112
|
+
* Creates a new Sandbox instance.
|
|
113
|
+
*
|
|
114
|
+
* Internal: obtain sandboxes via {@link Daytona.create}, {@link Daytona.get}, or
|
|
115
|
+
* {@link Daytona.list} rather than constructing directly.
|
|
104
116
|
*
|
|
105
117
|
* @param {SandboxDto} sandboxDto - The API Sandbox instance
|
|
118
|
+
* @param {SandboxApi} sandboxApi - API client for Sandbox operations
|
|
119
|
+
* @param {InfoApi} infoApi - API client for info operations
|
|
120
|
+
* @param {EventSubscriptionManager} subscriptionManager - Event subscription manager for real-time updates
|
|
106
121
|
*/
|
|
107
|
-
constructor(sandboxDto: SandboxDto | SandboxListItemDto, clientConfig: Configuration, axiosInstance: AxiosInstance, sandboxApi: SandboxApi);
|
|
122
|
+
constructor(sandboxDto: SandboxDto | SandboxListItemDto, clientConfig: Configuration, axiosInstance: AxiosInstance, sandboxApi: SandboxApi, getAnalyticsApiUrl: () => Promise<string | undefined>, subscriptionManager: EventSubscriptionManager);
|
|
108
123
|
/**
|
|
109
124
|
* Gets the user's home directory path for the logged in user inside the Sandbox.
|
|
110
125
|
*
|
|
@@ -115,6 +130,34 @@ export declare class Sandbox {
|
|
|
115
130
|
* console.log(`Sandbox user home: ${userHomeDir}`);
|
|
116
131
|
*/
|
|
117
132
|
getUserHomeDir(): Promise<string | undefined>;
|
|
133
|
+
/**
|
|
134
|
+
* Gets the most recent resource usage sample directly from the sandbox daemon.
|
|
135
|
+
*
|
|
136
|
+
* Unlike {@link getMetrics}, which returns aggregated historical samples, this returns the
|
|
137
|
+
* single current reading without going through the telemetry backend.
|
|
138
|
+
*
|
|
139
|
+
* @returns The current resource usage sample for the sandbox.
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* const m = await sandbox.getMetricsLatest()
|
|
143
|
+
* console.log(`CPU: ${m.cpuUsedPct}%, mem: ${m.memUsed}/${m.memTotal}`)
|
|
144
|
+
*/
|
|
145
|
+
getMetricsLatest(): Promise<SandboxMetrics>;
|
|
146
|
+
/**
|
|
147
|
+
* Gets historical time-series resource usage metrics for the Sandbox.
|
|
148
|
+
*
|
|
149
|
+
* @param {Date} [start] - Start of the time range. Defaults to the Sandbox creation time.
|
|
150
|
+
* @param {Date} [end] - End of the time range. Defaults to the current time.
|
|
151
|
+
* @returns Time-ordered usage samples over the requested range.
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* const samples = await sandbox.getMetrics()
|
|
155
|
+
* for (const s of samples) {
|
|
156
|
+
* console.log(`${s.timestamp.toISOString()} CPU: ${s.cpuUsedPct}% mem: ${s.memUsed}/${s.memTotal}`)
|
|
157
|
+
* }
|
|
158
|
+
*/
|
|
159
|
+
getMetrics(start?: Date, end?: Date): Promise<SandboxMetrics[]>;
|
|
160
|
+
private buildAnalyticsTelemetryApi;
|
|
118
161
|
/**
|
|
119
162
|
* @deprecated Use `getUserHomeDir` instead. This method will be removed in a future version.
|
|
120
163
|
*/
|
|
@@ -269,12 +312,20 @@ export declare class Sandbox {
|
|
|
269
312
|
* console.log('Sandbox paused successfully');
|
|
270
313
|
*/
|
|
271
314
|
pause(timeout?: number): Promise<void>;
|
|
272
|
-
private waitForPauseComplete;
|
|
273
315
|
/**
|
|
274
316
|
* Deletes the Sandbox.
|
|
317
|
+
*
|
|
318
|
+
* By default this returns as soon as the deletion request is accepted (matching
|
|
319
|
+
* historical behavior). Pass `wait = true` to block until the Sandbox reaches
|
|
320
|
+
* the 'destroyed' state.
|
|
321
|
+
*
|
|
322
|
+
* @param {number} [timeout] - Timeout in seconds for the request — and, when
|
|
323
|
+
* `wait` is true, for reaching 'destroyed'. 0 means no timeout.
|
|
324
|
+
* Defaults to 60-second timeout.
|
|
325
|
+
* @param {boolean} [wait] - If true, wait until the Sandbox is destroyed. Defaults to false.
|
|
275
326
|
* @returns {Promise<void>}
|
|
276
327
|
*/
|
|
277
|
-
delete(timeout?: number): Promise<void>;
|
|
328
|
+
delete(timeout?: number, wait?: boolean): Promise<void>;
|
|
278
329
|
/**
|
|
279
330
|
* Waits for the Sandbox to reach the 'started' state.
|
|
280
331
|
*
|
|
@@ -343,6 +394,30 @@ export declare class Sandbox {
|
|
|
343
394
|
* await sandbox.setAutostopInterval(0);
|
|
344
395
|
*/
|
|
345
396
|
setAutostopInterval(interval: number): Promise<void>;
|
|
397
|
+
/**
|
|
398
|
+
* Set the auto-pause interval for the Sandbox.
|
|
399
|
+
*
|
|
400
|
+
* The Sandbox will automatically pause after being idle (no new events) for the specified interval.
|
|
401
|
+
* Events include any state changes or interactions with the Sandbox through the sdk.
|
|
402
|
+
* Interactions using Sandbox Previews are not included.
|
|
403
|
+
*
|
|
404
|
+
* Only supported for sandbox classes that support pausing. At most one of the auto-stop
|
|
405
|
+
* and auto-pause intervals may be non-zero, so disable auto-stop first by setting its
|
|
406
|
+
* interval to 0.
|
|
407
|
+
*
|
|
408
|
+
* @param {number} interval - Number of minutes of inactivity before auto-pausing.
|
|
409
|
+
* Set to 0 to disable auto-pause. For pause-supporting sandbox
|
|
410
|
+
* classes, creation defaults to 60 minutes when neither interval is provided.
|
|
411
|
+
* @returns {Promise<void>}
|
|
412
|
+
* @throws {DaytonaError} - `DaytonaError` - If interval is not a non-negative integer
|
|
413
|
+
*
|
|
414
|
+
* @example
|
|
415
|
+
* // Auto-pause after 1 hour
|
|
416
|
+
* await sandbox.setAutoPauseInterval(60);
|
|
417
|
+
* // Or disable auto-pause
|
|
418
|
+
* await sandbox.setAutoPauseInterval(0);
|
|
419
|
+
*/
|
|
420
|
+
setAutoPauseInterval(interval: number): Promise<void>;
|
|
346
421
|
/**
|
|
347
422
|
* Set the auto-archive interval for the Sandbox.
|
|
348
423
|
*
|
|
@@ -530,6 +605,25 @@ export declare class Sandbox {
|
|
|
530
605
|
* @returns {Promise<SshAccessValidationDto>} The SSH access validation result.
|
|
531
606
|
*/
|
|
532
607
|
validateSshAccess(token: string): Promise<SshAccessValidationDto>;
|
|
608
|
+
/**
|
|
609
|
+
* Subscribes to real-time events for this sandbox.
|
|
610
|
+
* Auto-updates sandbox metadata on every event.
|
|
611
|
+
*/
|
|
612
|
+
private subscribeToEvents;
|
|
613
|
+
private ensureSubscribed;
|
|
614
|
+
private handleEvent;
|
|
615
|
+
/**
|
|
616
|
+
* Waits for the sandbox to reach one of the target states.
|
|
617
|
+
* Throws on error states or timeout.
|
|
618
|
+
*
|
|
619
|
+
* @param targetStates - States that indicate success.
|
|
620
|
+
* @param errorStates - States that indicate failure.
|
|
621
|
+
* @param timeout - Maximum time to wait in seconds. 0 means no timeout.
|
|
622
|
+
* @param timeoutMessage - Error message when timeout is reached.
|
|
623
|
+
* @param errorMessageFn - Function that produces an error message from the current state.
|
|
624
|
+
* @param safeRefresh - If true, use refreshDataSafe() for polling (for delete operations where 404 is expected).
|
|
625
|
+
*/
|
|
626
|
+
private waitForState;
|
|
533
627
|
/**
|
|
534
628
|
* Assigns the API sandbox data to the Sandbox object.
|
|
535
629
|
*
|
|
@@ -543,7 +637,15 @@ export declare class Sandbox {
|
|
|
543
637
|
*
|
|
544
638
|
* @returns {Promise<void>}
|
|
545
639
|
*/
|
|
640
|
+
/**
|
|
641
|
+
* @returns true when the refresh produced authoritative state (success, or 404
|
|
642
|
+
* mapped to DESTROYED); false when a transient error was swallowed and
|
|
643
|
+
* the cached state is stale.
|
|
644
|
+
*/
|
|
546
645
|
private refreshDataSafe;
|
|
646
|
+
private applyState;
|
|
647
|
+
private checkStateWaiter;
|
|
648
|
+
private removeStateWaiter;
|
|
547
649
|
}
|
|
548
650
|
export interface ListSandboxesQuery {
|
|
549
651
|
/**
|
|
@@ -631,4 +733,26 @@ export interface ListSandboxesQuery {
|
|
|
631
733
|
* */
|
|
632
734
|
lastActivityBefore?: Date;
|
|
633
735
|
}
|
|
736
|
+
/**
|
|
737
|
+
* A single point-in-time sample of historical Sandbox resource usage.
|
|
738
|
+
*
|
|
739
|
+
* @property {number} cpuCount - Number of CPU cores allocated to the Sandbox.
|
|
740
|
+
* @property {number} cpuUsedPct - CPU utilization as a percentage of the allocated limit.
|
|
741
|
+
* @property {number} diskTotal - Total disk space in bytes.
|
|
742
|
+
* @property {number} diskUsed - Used disk space in bytes.
|
|
743
|
+
* @property {number} memTotal - Total memory in bytes.
|
|
744
|
+
* @property {number} memUsed - Used memory in bytes.
|
|
745
|
+
* @property {number} memCache - Memory used by the page cache in bytes.
|
|
746
|
+
* @property {Date} timestamp - Timestamp of this sample.
|
|
747
|
+
*/
|
|
748
|
+
export interface SandboxMetrics {
|
|
749
|
+
cpuCount: number;
|
|
750
|
+
cpuUsedPct: number;
|
|
751
|
+
diskTotal: number;
|
|
752
|
+
diskUsed: number;
|
|
753
|
+
memTotal: number;
|
|
754
|
+
memUsed: number;
|
|
755
|
+
memCache: number;
|
|
756
|
+
timestamp: Date;
|
|
757
|
+
}
|
|
634
758
|
//# sourceMappingURL=Sandbox.d.ts.map
|