@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.
Files changed (44) hide show
  1. package/cjs/Daytona.d.ts +27 -2
  2. package/cjs/Daytona.js +64 -7
  3. package/cjs/Daytona.js.map +1 -1
  4. package/cjs/Process.js +52 -12
  5. package/cjs/Process.js.map +1 -1
  6. package/cjs/PtyHandle.d.ts +14 -0
  7. package/cjs/PtyHandle.js +100 -34
  8. package/cjs/PtyHandle.js.map +1 -1
  9. package/cjs/Sandbox.d.ts +149 -4
  10. package/cjs/Sandbox.js +523 -136
  11. package/cjs/Sandbox.js.map +1 -1
  12. package/cjs/index.d.ts +1 -1
  13. package/cjs/utils/EventDispatcher.d.ts +85 -0
  14. package/cjs/utils/EventDispatcher.js +398 -0
  15. package/cjs/utils/EventDispatcher.js.map +1 -0
  16. package/cjs/utils/EventSubscriptionManager.d.ts +14 -0
  17. package/cjs/utils/EventSubscriptionManager.js +98 -0
  18. package/cjs/utils/EventSubscriptionManager.js.map +1 -0
  19. package/cjs/utils/WebSocket.d.ts +2 -1
  20. package/cjs/utils/WebSocket.js +10 -3
  21. package/cjs/utils/WebSocket.js.map +1 -1
  22. package/esm/Daytona.d.ts +27 -2
  23. package/esm/Daytona.js +64 -7
  24. package/esm/Daytona.js.map +1 -1
  25. package/esm/Process.js +52 -12
  26. package/esm/Process.js.map +1 -1
  27. package/esm/PtyHandle.d.ts +14 -0
  28. package/esm/PtyHandle.js +100 -34
  29. package/esm/PtyHandle.js.map +1 -1
  30. package/esm/Sandbox.d.ts +149 -4
  31. package/esm/Sandbox.js +524 -137
  32. package/esm/Sandbox.js.map +1 -1
  33. package/esm/index.d.ts +1 -1
  34. package/esm/utils/EventDispatcher.d.ts +85 -0
  35. package/esm/utils/EventDispatcher.js +394 -0
  36. package/esm/utils/EventDispatcher.js.map +1 -0
  37. package/esm/utils/EventSubscriptionManager.d.ts +14 -0
  38. package/esm/utils/EventSubscriptionManager.js +94 -0
  39. package/esm/utils/EventSubscriptionManager.js.map +1 -0
  40. package/esm/utils/Import.js +1 -1
  41. package/esm/utils/WebSocket.d.ts +2 -1
  42. package/esm/utils/WebSocket.js +10 -3
  43. package/esm/utils/WebSocket.js.map +1 -1
  44. package/package.json +5 -3
package/cjs/PtyHandle.js CHANGED
@@ -75,6 +75,8 @@ let PtyHandle = (() => {
75
75
  _error;
76
76
  connected = false;
77
77
  connectionEstablished = false; // Track control message received
78
+ _connectionResolvers = [];
79
+ _exitResolvers = [];
78
80
  constructor(ws, handleResize, handleKill, onPty, sessionId) {
79
81
  this.ws = ws;
80
82
  this.handleResize = handleResize;
@@ -114,25 +116,58 @@ let PtyHandle = (() => {
114
116
  return;
115
117
  }
116
118
  return new Promise((resolve, reject) => {
117
- const timeout = setTimeout(() => {
118
- reject(new DaytonaError_1.DaytonaTimeoutError('PTY connection timeout'));
119
- }, 10000); // 10 second timeout
120
- const checkConnection = () => {
121
- if (this.connectionEstablished) {
119
+ // Each caller registers its own entry so concurrent waitForConnection()
120
+ // callers are all resolved/rejected together instead of overwriting one
121
+ // another (which left earlier callers hanging until their own timeout).
122
+ const entry = {
123
+ resolve: () => {
122
124
  clearTimeout(timeout);
123
125
  resolve();
124
- }
125
- else if (this.ws.readyState === isomorphic_ws_1.default.CLOSED || this._error) {
126
+ },
127
+ reject: (err) => {
126
128
  clearTimeout(timeout);
127
- reject(new DaytonaError_1.DaytonaConnectionError(this._error || 'Connection failed'));
128
- }
129
- else {
130
- setTimeout(checkConnection, 100);
131
- }
129
+ reject(err);
130
+ },
132
131
  };
133
- checkConnection();
132
+ const timeout = setTimeout(() => {
133
+ this._connectionResolvers = this._connectionResolvers.filter((r) => r !== entry);
134
+ reject(new DaytonaError_1.DaytonaTimeoutError('PTY connection timeout'));
135
+ }, 10000); // 10 second timeout
136
+ // Check if already connected (race: message arrived before we set up handlers)
137
+ if (this.connectionEstablished) {
138
+ clearTimeout(timeout);
139
+ resolve();
140
+ return;
141
+ }
142
+ // Check if already failed
143
+ if (this.ws.readyState === isomorphic_ws_1.default.CLOSED || this._error) {
144
+ clearTimeout(timeout);
145
+ reject(new DaytonaError_1.DaytonaConnectionError(this._error || 'Connection failed'));
146
+ return;
147
+ }
148
+ this._connectionResolvers.push(entry);
134
149
  });
135
150
  }
151
+ /**
152
+ * Resolve all pending waitForConnection() callers and clear them.
153
+ */
154
+ resolveConnection() {
155
+ const resolvers = this._connectionResolvers;
156
+ this._connectionResolvers = [];
157
+ for (const r of resolvers) {
158
+ r.resolve();
159
+ }
160
+ }
161
+ /**
162
+ * Reject all pending waitForConnection() callers and clear them.
163
+ */
164
+ rejectConnection(err) {
165
+ const resolvers = this._connectionResolvers;
166
+ this._connectionResolvers = [];
167
+ for (const r of resolvers) {
168
+ r.reject(err);
169
+ }
170
+ }
136
171
  /**
137
172
  * Send input data to the PTY session.
138
173
  *
@@ -228,31 +263,39 @@ let PtyHandle = (() => {
228
263
  * }
229
264
  */
230
265
  async wait() {
266
+ if (this._exitCode !== undefined) {
267
+ return { exitCode: this._exitCode, error: this._error };
268
+ }
231
269
  return new Promise((resolve, reject) => {
270
+ // Check again in case it resolved between the sync check and the promise setup
232
271
  if (this._exitCode !== undefined) {
233
- resolve({
234
- exitCode: this._exitCode,
235
- error: this._error,
236
- });
272
+ resolve({ exitCode: this._exitCode, error: this._error });
237
273
  return;
238
274
  }
239
- const checkExit = () => {
240
- if (this._exitCode !== undefined) {
241
- resolve({
242
- exitCode: this._exitCode,
243
- error: this._error,
244
- });
245
- }
246
- else if (this._error) {
247
- reject(new DaytonaError_1.DaytonaError(this._error));
248
- }
249
- else {
250
- setTimeout(checkExit, 100);
251
- }
252
- };
253
- checkExit();
275
+ // If there's already an error and no exit code, reject
276
+ if (this._error && this._exitCode === undefined) {
277
+ reject(new DaytonaError_1.DaytonaError(this._error));
278
+ return;
279
+ }
280
+ // Register this caller; all pending callers are resolved together on exit so
281
+ // concurrent wait() calls do not overwrite each other and hang forever.
282
+ this._exitResolvers.push(resolve);
254
283
  });
255
284
  }
285
+ /**
286
+ * Resolve all pending wait() callers with the current exit result and clear them.
287
+ */
288
+ resolveExit() {
289
+ if (this._exitResolvers.length === 0) {
290
+ return;
291
+ }
292
+ const result = { exitCode: this._exitCode, error: this._error };
293
+ const resolvers = this._exitResolvers;
294
+ this._exitResolvers = [];
295
+ for (const resolve of resolvers) {
296
+ resolve(result);
297
+ }
298
+ }
256
299
  /**
257
300
  * Kill the PTY process and terminate the session.
258
301
  *
@@ -292,11 +335,28 @@ let PtyHandle = (() => {
292
335
  if (controlMsg.type === 'control') {
293
336
  if (controlMsg.status === 'connected') {
294
337
  this.connectionEstablished = true;
338
+ this.resolveConnection();
339
+ return;
340
+ }
341
+ else if (controlMsg.status === 'exited') {
342
+ this._exitCode = controlMsg.exitCode ?? undefined;
343
+ if (controlMsg.exitReason) {
344
+ this._error = controlMsg.exitReason;
345
+ }
346
+ // An instantly-exiting PTY still means the connection was established;
347
+ // unblock any pending waitForConnection() so it does not hang/reject.
348
+ this.connectionEstablished = true;
349
+ // The PTY has exited: mark disconnected so isConnected() does not
350
+ // report true for a dead session between 'exited' and the WS close.
351
+ this.connected = false;
352
+ this.resolveConnection();
353
+ this.resolveExit();
295
354
  return;
296
355
  }
297
356
  else if (controlMsg.status === 'error') {
298
357
  this._error = controlMsg.error || 'Unknown connection error';
299
358
  this.connected = false;
359
+ this.rejectConnection(new DaytonaError_1.DaytonaConnectionError(this._error));
300
360
  return;
301
361
  }
302
362
  }
@@ -349,12 +409,14 @@ let PtyHandle = (() => {
349
409
  }
350
410
  this._error = errorMessage;
351
411
  this.connected = false;
412
+ // Reject pending waitForConnection() if still waiting
413
+ this.rejectConnection(new DaytonaError_1.DaytonaConnectionError(errorMessage));
352
414
  };
353
415
  // Handle WebSocket close - parse structured exit data
354
416
  const handleClose = async (event) => {
355
417
  this.connected = false;
356
- // Parse structured exit data from close reason
357
- if (event && event.reason) {
418
+ // Parse structured exit data from close reason (only if not already set by control message)
419
+ if (this._exitCode === undefined && event && event.reason) {
358
420
  try {
359
421
  const exitData = JSON.parse(event.reason);
360
422
  if (typeof exitData.exitCode === 'number') {
@@ -379,6 +441,10 @@ let PtyHandle = (() => {
379
441
  if (this._exitCode === undefined && event && event.code === 1000) {
380
442
  this._exitCode = 0;
381
443
  }
444
+ // Resolve pending wait() if not already resolved by control message
445
+ this.resolveExit();
446
+ // Reject pending waitForConnection() if still waiting
447
+ this.rejectConnection(new DaytonaError_1.DaytonaConnectionError(this._error || 'Connection closed'));
382
448
  };
383
449
  // Attach event listeners based on WebSocket implementation
384
450
  if (this.ws.addEventListener) {
@@ -1 +1 @@
1
- {"version":3,"file":"PtyHandle.js","sourceRoot":"","sources":["../../../../sdk-typescript/src/PtyHandle.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;AAEH,0EAAqC;AAErC,wDAAiG;AAEjG,2DAA4D;AAE5D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;IACU,SAAS;;;;;;;;iBAAT,SAAS;;;6CA6CnB,IAAA,oCAAmB,GAAE;qCA2CrB,IAAA,oCAAmB,GAAE;kCA+BrB,IAAA,oCAAmB,GAAE;sCAmBrB,IAAA,oCAAmB,GAAE;gCAgCrB,IAAA,oCAAmB,GAAE;gCA4CrB,IAAA,oCAAmB,GAAE;YAxKtB,8MAAM,iBAAiB,6DAwBtB;YAmBD,sLAAM,SAAS,6DAed;YAgBD,6KAAM,MAAM,6DAEX;YAiBD,yLAAM,UAAU,6DAQf;YAwBD,uKAAM,IAAI,6DAyBT;YAmBD,uKAAM,IAAI,6DAET;;;QAlNkB,EAAE,GAPV,2DAAS;QAQD,YAAY;QACZ,UAAU;QACV,KAAK;QACb,SAAS;QAVZ,SAAS,CAAS;QAClB,MAAM,CAAS;QACf,SAAS,GAAG,KAAK,CAAA;QACjB,qBAAqB,GAAG,KAAK,CAAA,CAAC,iCAAiC;QAEvE,YACmB,EAAa,EACb,YAAqE,EACrE,UAA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AAC;;;AAtaU,8BAAS"}
package/cjs/Sandbox.d.ts CHANGED
@@ -8,6 +8,7 @@ import { LspLanguageId, LspServer } from './LspServer';
8
8
  import { ComputerUse } from './ComputerUse';
9
9
  import type { AxiosInstance } from 'axios';
10
10
  import { CodeInterpreter } from './CodeInterpreter';
11
+ import { EventSubscriptionManager } from './utils/EventSubscriptionManager';
11
12
  /**
12
13
  * Represents a Daytona Sandbox.
13
14
  *
@@ -37,8 +38,10 @@ import { CodeInterpreter } from './CodeInterpreter';
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