@insforge/instabox-sdk 0.9.0 → 0.10.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/dist/index.d.cts CHANGED
@@ -83,6 +83,76 @@ interface MachineSpec {
83
83
  memMiB: number;
84
84
  persistentDiskGiB: number;
85
85
  rootDiskGiB?: number;
86
+ /** GPUs of `gpuType` the sandbox has; absent on a sandbox without one. */
87
+ gpus?: number;
88
+ /** The GPU type of its GPUs (a `TemplateGpuType.type`); absent on a sandbox without one. */
89
+ gpuType?: string;
90
+ }
91
+ /**
92
+ * A sandbox's live GPU queue entry (`Machine.queue`): a create or start with `queue` found no GPU of
93
+ * its type free, so the sandbox waits, stopped and holding no GPU, for one.
94
+ */
95
+ interface MachineQueue {
96
+ /** Cancel it with `Sandbox.cancelGpuQueue(id)`, never by killing the sandbox (that deletes a stopped one's disks). */
97
+ id: string;
98
+ /** `create`: the sandbox has no disks yet, and an expiry or a cancel deletes it. `start`: it stays stopped with its disks. */
99
+ kind: 'create' | 'start';
100
+ gpuType?: string;
101
+ gpus?: number;
102
+ /** `queued`: waiting for a GPU. `dispatched`: a GPU is claimed and the sandbox is starting. */
103
+ state: 'queued' | 'offered' | 'dispatched' | (string & {});
104
+ /** Place in line among the type's queued entries, from 1; absent unless queued. */
105
+ position?: number;
106
+ enqueuedAt: string;
107
+ /** When a still queued entry gives up. */
108
+ expiresAt: string;
109
+ /** A cancel was asked while the sandbox was starting: it is stopped (or deleted) when the start ends. */
110
+ cancelling?: boolean;
111
+ }
112
+ /** One entry of `Sandbox.listGpuQueue()`. */
113
+ interface GpuQueueEntry {
114
+ id: string;
115
+ orgId: string;
116
+ machineId: string;
117
+ /** Absent once the sandbox is deleted. */
118
+ machineName?: string;
119
+ kind: 'create' | 'start';
120
+ gpuType: string;
121
+ gpus: number;
122
+ /** `queued` and `dispatched` are live; `placed` (the sandbox ran), `expired`, `cancelled` and `failed` are ends. */
123
+ state: 'queued' | 'dispatched' | 'placed' | 'expired' | 'cancelled' | 'failed' | (string & {});
124
+ position?: number;
125
+ enqueuedAt: string;
126
+ expiresAt: string;
127
+ /** When the entry ended; absent while live. */
128
+ resolvedAt?: string;
129
+ /** Why an ended entry ended: `queue_expired`, `user` or `machine_deleted`, or for `failed` the refusal's error code. */
130
+ reason?: string;
131
+ cancelling?: boolean;
132
+ }
133
+ /** Response of `GET /v1/gpu-queue`. */
134
+ interface GpuQueuePage {
135
+ entries: GpuQueueEntry[];
136
+ /** Pass as `cursor` for the next page; absent on the last page. */
137
+ nextCursor?: string;
138
+ }
139
+ /** A GPU type a GPU template offers (`Template.gpuTypes`). */
140
+ interface TemplateGpuType {
141
+ /** What `gpu` names on create, such as `l4`. */
142
+ type: string;
143
+ /** Such as `NVIDIA L4`. */
144
+ model: string;
145
+ /** GPU memory per GPU. */
146
+ memGiB: number;
147
+ /** The sizes a create may pick, per GPU: N GPUs get N times the vCPUs and memory, and the disk once. */
148
+ sizes: MachineSpec[];
149
+ maxPerMachine: number;
150
+ /** The GPU counts a create may ask for (`l4:2`), such as `[1, 2, 4]`. */
151
+ counts?: number[];
152
+ /** This template is the one a create with this GPU type and no template gets. */
153
+ default?: boolean;
154
+ /** GPUs of this type waiting in the GPU queue now. */
155
+ queued?: number;
86
156
  }
87
157
  interface TemplateRef {
88
158
  id: string;
@@ -100,6 +170,8 @@ interface Machine {
100
170
  snapshot?: {
101
171
  id: string;
102
172
  };
173
+ /** The org the sandbox counts against. */
174
+ orgId?: string;
103
175
  spec: MachineSpec;
104
176
  storage: {
105
177
  sizeGiB: number;
@@ -125,6 +197,8 @@ interface Machine {
125
197
  * Absent on servers without the Vault: treat as true.
126
198
  */
127
199
  vault?: boolean;
200
+ /** The sandbox's live GPU queue entry; absent unless it waits for a GPU. */
201
+ queue?: MachineQueue;
128
202
  createdAt: string;
129
203
  updatedAt: string;
130
204
  }
@@ -205,6 +279,14 @@ interface Template {
205
279
  defaultSpec: MachineSpec;
206
280
  /** True when the server's release no longer builds it: listed, but new sandboxes are refused. */
207
281
  hidden?: boolean;
282
+ /** The version a create naming this template gets. Every version is listed; one per template has this. */
283
+ latest?: boolean;
284
+ /** A GPU template: a create from it needs `gpu`, and a create with `gpu` takes only a GPU template. */
285
+ gpu?: boolean;
286
+ /** On a GPU template: `vm` (absent means `vm`) or `metal` (whole GPUs on bare metal). */
287
+ gpuMode?: 'vm' | 'metal' | (string & {});
288
+ /** On a GPU template, the GPU types a create from it may ask for. */
289
+ gpuTypes?: TemplateGpuType[];
208
290
  }
209
291
  interface SnapshotList {
210
292
  snapshots: Snapshot[];
@@ -235,6 +317,12 @@ interface MachineMetric {
235
317
  /** Not reported yet; absent. */
236
318
  diskUsed?: number;
237
319
  diskTotal: number;
320
+ /** GPU sandboxes: share of the time a kernel ran on its GPUs, averaged over them (0-100). */
321
+ gpuUsedPct?: number;
322
+ /** GPU sandboxes: GPU memory in use, summed over its GPUs. */
323
+ gpuMemUsed?: number;
324
+ gpuCount?: number;
325
+ gpuMemTotal?: number;
238
326
  }
239
327
  /** Response of `GET /v1/machines/{id}/metrics`. */
240
328
  interface MachineMetrics {
@@ -249,6 +337,10 @@ interface MachineUsage {
249
337
  memGiBSeconds: number;
250
338
  diskGiBSeconds: number;
251
339
  egressBytes?: number;
340
+ gpus?: number;
341
+ gpuType?: string;
342
+ gpuSeconds?: number;
343
+ gpuUSD?: number;
252
344
  }
253
345
  /** One sandbox's share of `Usage.storedBytes`. */
254
346
  interface UsageMachineStorage {
@@ -280,6 +372,16 @@ interface UsageLimits {
280
372
  maxBytes: number;
281
373
  };
282
374
  }
375
+ /** One GPU type's usage this month (`UsageCost.gpu`). */
376
+ interface GpuUsage {
377
+ type: string;
378
+ model?: string;
379
+ /** Running time times GPUs. */
380
+ gpuHours: number;
381
+ /** The current price per GPU-hour (0: not priced). */
382
+ hourUSD: number;
383
+ usd: number;
384
+ }
283
385
  /**
284
386
  * `Usage.cost`: the workspace's usage this calendar month (UTC) in USD, as the hourly rating priced
285
387
  * it, with its allowance and credit balance. The same figures as `GET /v1/orgs/{id}` `usage`.
@@ -336,6 +438,10 @@ interface UsageCost {
336
438
  creditsUsedUSD: number;
337
439
  /** Usage beyond the allowance already charged this month (threshold billing). */
338
440
  chargedUSD?: number;
441
+ /** This month's GPU time by GPU type; absent without GPU usage this month. */
442
+ gpu?: GpuUsage[];
443
+ /** The GPU part of `costUSD`. */
444
+ gpuUSD?: number;
339
445
  }
340
446
  /** Response of `GET /v1/usage`: your counts, stored bytes (measured about hourly) and limits. */
341
447
  interface Usage {
@@ -900,6 +1006,13 @@ declare class Ports {
900
1006
  declare const DEFAULT_TEMPLATE = "agent-browser";
901
1007
  /** The default when a server does not offer `DEFAULT_TEMPLATE` (an older or self-hosted one). */
902
1008
  declare const FALLBACK_TEMPLATE = "universal";
1009
+ /**
1010
+ * Wait in the GPU queue when no GPU of the type is free, instead of failing with `no_capacity`.
1011
+ * `true` waits up to an hour; `maxWaitMs` is sent as whole seconds, 60 s to 24 h.
1012
+ */
1013
+ type GpuQueueOpt = true | {
1014
+ maxWaitMs: number;
1015
+ };
903
1016
  interface SandboxOpts extends ConnectionOptions {
904
1017
  /** Machine name: lowercase letters, digits and `-`. Default `sbx-<random>`. */
905
1018
  name?: string;
@@ -931,6 +1044,19 @@ interface SandboxOpts extends ConnectionOptions {
931
1044
  * Default: the sandbox gets them. Cannot be turned on again later.
932
1045
  */
933
1046
  vault?: boolean;
1047
+ /**
1048
+ * GPUs for the sandbox (paid plans): `TYPE` or `TYPE:COUNT`, such as `'l4'` or `'h100:2'`; the types
1049
+ * and counts are in `Sandbox.listTemplates()` (`gpuTypes` of the templates with `gpu`). Without a
1050
+ * template argument the server picks the GPU type's default template.
1051
+ */
1052
+ gpu?: string;
1053
+ /**
1054
+ * With `gpu`: when no GPU of the type is free, the sandbox waits in the GPU queue (stopped,
1055
+ * `getInfo().queue` set) and `create` waits with it until the sandbox runs. If the wait ends first,
1056
+ * `create` throws `InstaboxError` with the entry's reason as `code` (`queue_expired`), and the sandbox
1057
+ * is deleted.
1058
+ */
1059
+ queue?: GpuQueueOpt;
934
1060
  /**
935
1061
  * @deprecated Removed in 0.6.0: sandboxes have no lifetime timeout since 2026-10-20. Passing it throws
936
1062
  * `InstaboxError` (`code: 'retired_option'`); use `autoSuspendMs`, `archiveMs` or `kill()` instead.
@@ -943,6 +1069,23 @@ interface SandboxConnectOpts extends ConnectionOptions {
943
1069
  /** Resume the sandbox if it is paused (suspended) or stopped. Default true. */
944
1070
  resume?: boolean;
945
1071
  envs?: Record<string, string>;
1072
+ /** Starting a stopped GPU sandbox: wait in the GPU queue when no GPU is free (see `SandboxOpts.queue`). */
1073
+ queue?: GpuQueueOpt;
1074
+ }
1075
+ interface ResumeOpts {
1076
+ /**
1077
+ * Starting a stopped GPU sandbox: wait in the GPU queue when no GPU is free. If the wait ends first,
1078
+ * this throws `InstaboxError` with the entry's reason as `code`, and the sandbox stays stopped with
1079
+ * its disks. A paused sandbox resumes on the GPU it holds and ignores it.
1080
+ */
1081
+ queue?: GpuQueueOpt;
1082
+ }
1083
+ interface GpuQueueListOpts extends ConnectionOptions {
1084
+ state?: GpuQueueEntry['state'];
1085
+ /** Page size, 1-200. Default: the server's (50). */
1086
+ limit?: number;
1087
+ /** `nextCursor` of the previous page. */
1088
+ cursor?: string;
946
1089
  }
947
1090
  interface SandboxListOpts extends ConnectionOptions {
948
1091
  /** Only sandboxes whose metadata has every one of these key/value pairs. */
@@ -965,6 +1108,13 @@ interface SandboxInfo {
965
1108
  /** Idle time after which the server pauses the sandbox; undefined when it never does. */
966
1109
  autoSuspendMs?: number;
967
1110
  state: MachineState;
1111
+ /** The sandbox's GPUs; absent on a sandbox without one. */
1112
+ gpu?: {
1113
+ type: string;
1114
+ count: number;
1115
+ };
1116
+ /** Its live GPU queue entry; absent unless it waits for a GPU. */
1117
+ queue?: MachineQueue;
968
1118
  /** The raw machine object from the API. */
969
1119
  machine: Machine;
970
1120
  }
@@ -992,6 +1142,13 @@ interface SandboxMetrics {
992
1142
  diskUsed?: number;
993
1143
  /** System disk plus /data disk size. */
994
1144
  diskTotal: number;
1145
+ /** GPU sandboxes: share of the time a kernel ran on its GPUs, averaged over them (0-100). Absent where the host did not read it. */
1146
+ gpuUsedPct?: number;
1147
+ /** GPU sandboxes: GPU memory in use, summed over its GPUs. */
1148
+ gpuMemUsed?: number;
1149
+ gpuCount?: number;
1150
+ /** GPU sandboxes: the GPU type's memory times `gpuCount`. */
1151
+ gpuMemTotal?: number;
995
1152
  }
996
1153
  interface SandboxMetricsOpts {
997
1154
  /** Start of the samples, at most 24 h ago. Default: 5 minutes ago. */
@@ -1014,6 +1171,13 @@ interface SandboxUsage {
1014
1171
  * Billed or not (the plan's free egress and free sandboxes included). Absent from older servers.
1015
1172
  */
1016
1173
  egressBytes?: number;
1174
+ /** The sandbox's GPUs and their type; absent without one. */
1175
+ gpus?: number;
1176
+ gpuType?: string;
1177
+ /** GPUs times running seconds. */
1178
+ gpuSeconds?: number;
1179
+ /** That GPU time at the type's price per GPU-hour. */
1180
+ gpuUSD?: number;
1017
1181
  }
1018
1182
  interface SandboxUsageOpts {
1019
1183
  /** Default: the start of the current calendar month (UTC). */
@@ -1070,6 +1234,23 @@ declare class Sandbox {
1070
1234
  static getUsage(sandboxId: string, opts?: SandboxUsageOpts & ConnectionOptions): Promise<SandboxUsage>;
1071
1235
  /** Your account's counts, stored bytes (per sandbox in `storage`) and limits. Requires machines:read or images:read. */
1072
1236
  static usage(opts?: ConnectionOptions): Promise<Usage>;
1237
+ /**
1238
+ * The templates a create may name. Every version of a template is listed; `latest` marks the one a
1239
+ * create gets. GPU templates have `gpu` and list their GPU types in `gpuTypes`.
1240
+ */
1241
+ static listTemplates(opts?: ConnectionOptions): Promise<Template[]>;
1242
+ /**
1243
+ * A page of your GPU queue entries, newest first: live ones (`queued`, `dispatched`) with their place
1244
+ * in line, and ended ones with their `reason`. Requires machines:read.
1245
+ */
1246
+ static listGpuQueue(opts?: GpuQueueListOpts): Promise<GpuQueuePage>;
1247
+ /**
1248
+ * Stops a GPU queue entry's wait (`getInfo().queue.id`). A `create` entry's sandbox is deleted; a
1249
+ * `start` entry's stays stopped with its disks. Cancel this way, never with `kill()`, which deletes
1250
+ * a stopped sandbox's disks. Returns the entry, `cancelled`, or still `dispatched` with `cancelling`
1251
+ * when the sandbox was already starting. Requires machines:write.
1252
+ */
1253
+ static cancelGpuQueue(entryId: string, opts?: ConnectionOptions): Promise<GpuQueueEntry>;
1073
1254
  /** Lists the caller's private snapshots. Requires images:read. */
1074
1255
  static listSnapshots(opts?: ConnectionOptions): Promise<Snapshot[]>;
1075
1256
  /** Fetches a snapshot by ID. Requires images:read. */
@@ -1129,9 +1310,12 @@ declare class Sandbox {
1129
1310
  isRunning(): Promise<boolean>;
1130
1311
  /** Snapshots memory and stops the sandbox (suspend). `resume()` or `Sandbox.connect()` brings it back. */
1131
1312
  pause(): Promise<void>;
1132
- /** Resumes a paused sandbox from its snapshot, or starts a stopped one. */
1133
- resume(): Promise<void>;
1134
- /** Resumes or starts based on the cached state; callers make sure the cache is fresh. */
1313
+ /** Resumes a paused sandbox from its snapshot, or starts a stopped one (waiting for a GPU with `queue`). */
1314
+ resume(opts?: ResumeOpts): Promise<void>;
1315
+ /**
1316
+ * Resumes or starts based on the cached state; callers make sure the cache is fresh. A sandbox
1317
+ * already waiting for a GPU is waited for: starting it again would not move it up the line.
1318
+ */
1135
1319
  private wake;
1136
1320
  /** Stops the sandbox (guest shutdown; processes end, `/data` is kept). */
1137
1321
  stop(): Promise<void>;
@@ -1162,4 +1346,4 @@ declare class Sandbox {
1162
1346
  private mutate;
1163
1347
  }
1164
1348
 
1165
- export { type ApiError, CommandExitError, type CommandHandle, type CommandOptions, type CommandResult, type CommandWaitOptions, Commands, type Connection, type ConnectionOptions, type CreateSnapshotOpts, DEFAULT_API_URL, DEFAULT_TEMPLATE, DESKTOP_DISPLAY, Desktop, type DesktopStatus, type DesktopStream, type DownloadInfo, type DownloadOptions, type EntryInfo, type ExecResponse, FALLBACK_TEMPLATE, type FileStream, Files, type HostTrust, InstaboxAuthError, InstaboxError, type InstaboxErrorInit, InstaboxNotUtf8Error, InstaboxQuotaError, InstaboxTimeoutError, LIMIT_CODES, MAX_FILE_BYTES, MAX_STDIN_BYTES, MAX_UPLOAD_BYTES, type Machine, type MachineList, type MachineMetric, type MachineMetrics, type MachineSpec, type MachineState, type MachineUsage, type MachineVault, type MachineVaultItem, type MouseButton, type Operation, type PortAccess, Ports, type PublicPort, type PublishPortOpts, type ReadStreamOptions, type ResizeOpts, Sandbox, type SandboxConnectOpts, type SandboxInfo, type SandboxListOpts, type SandboxMetrics, type SandboxMetricsOpts, type SandboxOpts, type SandboxUsage, type SandboxUsageOpts, type ScrollDirection, type Snapshot, type SnapshotList, type SshCredentials, type Template, type TemplateRef, type UploadInfo, type UploadOptions, type Usage, type UsageCost, type UsageLimits, type UsageMachineStorage, type UsageStorage, type VaultApplied, type VaultFile, type VaultKept, type WriteData, type WriteInfo, type WriteOptions, isLimitCode };
1349
+ export { type ApiError, CommandExitError, type CommandHandle, type CommandOptions, type CommandResult, type CommandWaitOptions, Commands, type Connection, type ConnectionOptions, type CreateSnapshotOpts, DEFAULT_API_URL, DEFAULT_TEMPLATE, DESKTOP_DISPLAY, Desktop, type DesktopStatus, type DesktopStream, type DownloadInfo, type DownloadOptions, type EntryInfo, type ExecResponse, FALLBACK_TEMPLATE, type FileStream, Files, type GpuQueueEntry, type GpuQueueListOpts, type GpuQueueOpt, type GpuQueuePage, type GpuUsage, type HostTrust, InstaboxAuthError, InstaboxError, type InstaboxErrorInit, InstaboxNotUtf8Error, InstaboxQuotaError, InstaboxTimeoutError, LIMIT_CODES, MAX_FILE_BYTES, MAX_STDIN_BYTES, MAX_UPLOAD_BYTES, type Machine, type MachineList, type MachineMetric, type MachineMetrics, type MachineQueue, type MachineSpec, type MachineState, type MachineUsage, type MachineVault, type MachineVaultItem, type MouseButton, type Operation, type PortAccess, Ports, type PublicPort, type PublishPortOpts, type ReadStreamOptions, type ResizeOpts, type ResumeOpts, Sandbox, type SandboxConnectOpts, type SandboxInfo, type SandboxListOpts, type SandboxMetrics, type SandboxMetricsOpts, type SandboxOpts, type SandboxUsage, type SandboxUsageOpts, type ScrollDirection, type Snapshot, type SnapshotList, type SshCredentials, type Template, type TemplateGpuType, type TemplateRef, type UploadInfo, type UploadOptions, type Usage, type UsageCost, type UsageLimits, type UsageMachineStorage, type UsageStorage, type VaultApplied, type VaultFile, type VaultKept, type WriteData, type WriteInfo, type WriteOptions, isLimitCode };
package/dist/index.d.ts CHANGED
@@ -83,6 +83,76 @@ interface MachineSpec {
83
83
  memMiB: number;
84
84
  persistentDiskGiB: number;
85
85
  rootDiskGiB?: number;
86
+ /** GPUs of `gpuType` the sandbox has; absent on a sandbox without one. */
87
+ gpus?: number;
88
+ /** The GPU type of its GPUs (a `TemplateGpuType.type`); absent on a sandbox without one. */
89
+ gpuType?: string;
90
+ }
91
+ /**
92
+ * A sandbox's live GPU queue entry (`Machine.queue`): a create or start with `queue` found no GPU of
93
+ * its type free, so the sandbox waits, stopped and holding no GPU, for one.
94
+ */
95
+ interface MachineQueue {
96
+ /** Cancel it with `Sandbox.cancelGpuQueue(id)`, never by killing the sandbox (that deletes a stopped one's disks). */
97
+ id: string;
98
+ /** `create`: the sandbox has no disks yet, and an expiry or a cancel deletes it. `start`: it stays stopped with its disks. */
99
+ kind: 'create' | 'start';
100
+ gpuType?: string;
101
+ gpus?: number;
102
+ /** `queued`: waiting for a GPU. `dispatched`: a GPU is claimed and the sandbox is starting. */
103
+ state: 'queued' | 'offered' | 'dispatched' | (string & {});
104
+ /** Place in line among the type's queued entries, from 1; absent unless queued. */
105
+ position?: number;
106
+ enqueuedAt: string;
107
+ /** When a still queued entry gives up. */
108
+ expiresAt: string;
109
+ /** A cancel was asked while the sandbox was starting: it is stopped (or deleted) when the start ends. */
110
+ cancelling?: boolean;
111
+ }
112
+ /** One entry of `Sandbox.listGpuQueue()`. */
113
+ interface GpuQueueEntry {
114
+ id: string;
115
+ orgId: string;
116
+ machineId: string;
117
+ /** Absent once the sandbox is deleted. */
118
+ machineName?: string;
119
+ kind: 'create' | 'start';
120
+ gpuType: string;
121
+ gpus: number;
122
+ /** `queued` and `dispatched` are live; `placed` (the sandbox ran), `expired`, `cancelled` and `failed` are ends. */
123
+ state: 'queued' | 'dispatched' | 'placed' | 'expired' | 'cancelled' | 'failed' | (string & {});
124
+ position?: number;
125
+ enqueuedAt: string;
126
+ expiresAt: string;
127
+ /** When the entry ended; absent while live. */
128
+ resolvedAt?: string;
129
+ /** Why an ended entry ended: `queue_expired`, `user` or `machine_deleted`, or for `failed` the refusal's error code. */
130
+ reason?: string;
131
+ cancelling?: boolean;
132
+ }
133
+ /** Response of `GET /v1/gpu-queue`. */
134
+ interface GpuQueuePage {
135
+ entries: GpuQueueEntry[];
136
+ /** Pass as `cursor` for the next page; absent on the last page. */
137
+ nextCursor?: string;
138
+ }
139
+ /** A GPU type a GPU template offers (`Template.gpuTypes`). */
140
+ interface TemplateGpuType {
141
+ /** What `gpu` names on create, such as `l4`. */
142
+ type: string;
143
+ /** Such as `NVIDIA L4`. */
144
+ model: string;
145
+ /** GPU memory per GPU. */
146
+ memGiB: number;
147
+ /** The sizes a create may pick, per GPU: N GPUs get N times the vCPUs and memory, and the disk once. */
148
+ sizes: MachineSpec[];
149
+ maxPerMachine: number;
150
+ /** The GPU counts a create may ask for (`l4:2`), such as `[1, 2, 4]`. */
151
+ counts?: number[];
152
+ /** This template is the one a create with this GPU type and no template gets. */
153
+ default?: boolean;
154
+ /** GPUs of this type waiting in the GPU queue now. */
155
+ queued?: number;
86
156
  }
87
157
  interface TemplateRef {
88
158
  id: string;
@@ -100,6 +170,8 @@ interface Machine {
100
170
  snapshot?: {
101
171
  id: string;
102
172
  };
173
+ /** The org the sandbox counts against. */
174
+ orgId?: string;
103
175
  spec: MachineSpec;
104
176
  storage: {
105
177
  sizeGiB: number;
@@ -125,6 +197,8 @@ interface Machine {
125
197
  * Absent on servers without the Vault: treat as true.
126
198
  */
127
199
  vault?: boolean;
200
+ /** The sandbox's live GPU queue entry; absent unless it waits for a GPU. */
201
+ queue?: MachineQueue;
128
202
  createdAt: string;
129
203
  updatedAt: string;
130
204
  }
@@ -205,6 +279,14 @@ interface Template {
205
279
  defaultSpec: MachineSpec;
206
280
  /** True when the server's release no longer builds it: listed, but new sandboxes are refused. */
207
281
  hidden?: boolean;
282
+ /** The version a create naming this template gets. Every version is listed; one per template has this. */
283
+ latest?: boolean;
284
+ /** A GPU template: a create from it needs `gpu`, and a create with `gpu` takes only a GPU template. */
285
+ gpu?: boolean;
286
+ /** On a GPU template: `vm` (absent means `vm`) or `metal` (whole GPUs on bare metal). */
287
+ gpuMode?: 'vm' | 'metal' | (string & {});
288
+ /** On a GPU template, the GPU types a create from it may ask for. */
289
+ gpuTypes?: TemplateGpuType[];
208
290
  }
209
291
  interface SnapshotList {
210
292
  snapshots: Snapshot[];
@@ -235,6 +317,12 @@ interface MachineMetric {
235
317
  /** Not reported yet; absent. */
236
318
  diskUsed?: number;
237
319
  diskTotal: number;
320
+ /** GPU sandboxes: share of the time a kernel ran on its GPUs, averaged over them (0-100). */
321
+ gpuUsedPct?: number;
322
+ /** GPU sandboxes: GPU memory in use, summed over its GPUs. */
323
+ gpuMemUsed?: number;
324
+ gpuCount?: number;
325
+ gpuMemTotal?: number;
238
326
  }
239
327
  /** Response of `GET /v1/machines/{id}/metrics`. */
240
328
  interface MachineMetrics {
@@ -249,6 +337,10 @@ interface MachineUsage {
249
337
  memGiBSeconds: number;
250
338
  diskGiBSeconds: number;
251
339
  egressBytes?: number;
340
+ gpus?: number;
341
+ gpuType?: string;
342
+ gpuSeconds?: number;
343
+ gpuUSD?: number;
252
344
  }
253
345
  /** One sandbox's share of `Usage.storedBytes`. */
254
346
  interface UsageMachineStorage {
@@ -280,6 +372,16 @@ interface UsageLimits {
280
372
  maxBytes: number;
281
373
  };
282
374
  }
375
+ /** One GPU type's usage this month (`UsageCost.gpu`). */
376
+ interface GpuUsage {
377
+ type: string;
378
+ model?: string;
379
+ /** Running time times GPUs. */
380
+ gpuHours: number;
381
+ /** The current price per GPU-hour (0: not priced). */
382
+ hourUSD: number;
383
+ usd: number;
384
+ }
283
385
  /**
284
386
  * `Usage.cost`: the workspace's usage this calendar month (UTC) in USD, as the hourly rating priced
285
387
  * it, with its allowance and credit balance. The same figures as `GET /v1/orgs/{id}` `usage`.
@@ -336,6 +438,10 @@ interface UsageCost {
336
438
  creditsUsedUSD: number;
337
439
  /** Usage beyond the allowance already charged this month (threshold billing). */
338
440
  chargedUSD?: number;
441
+ /** This month's GPU time by GPU type; absent without GPU usage this month. */
442
+ gpu?: GpuUsage[];
443
+ /** The GPU part of `costUSD`. */
444
+ gpuUSD?: number;
339
445
  }
340
446
  /** Response of `GET /v1/usage`: your counts, stored bytes (measured about hourly) and limits. */
341
447
  interface Usage {
@@ -900,6 +1006,13 @@ declare class Ports {
900
1006
  declare const DEFAULT_TEMPLATE = "agent-browser";
901
1007
  /** The default when a server does not offer `DEFAULT_TEMPLATE` (an older or self-hosted one). */
902
1008
  declare const FALLBACK_TEMPLATE = "universal";
1009
+ /**
1010
+ * Wait in the GPU queue when no GPU of the type is free, instead of failing with `no_capacity`.
1011
+ * `true` waits up to an hour; `maxWaitMs` is sent as whole seconds, 60 s to 24 h.
1012
+ */
1013
+ type GpuQueueOpt = true | {
1014
+ maxWaitMs: number;
1015
+ };
903
1016
  interface SandboxOpts extends ConnectionOptions {
904
1017
  /** Machine name: lowercase letters, digits and `-`. Default `sbx-<random>`. */
905
1018
  name?: string;
@@ -931,6 +1044,19 @@ interface SandboxOpts extends ConnectionOptions {
931
1044
  * Default: the sandbox gets them. Cannot be turned on again later.
932
1045
  */
933
1046
  vault?: boolean;
1047
+ /**
1048
+ * GPUs for the sandbox (paid plans): `TYPE` or `TYPE:COUNT`, such as `'l4'` or `'h100:2'`; the types
1049
+ * and counts are in `Sandbox.listTemplates()` (`gpuTypes` of the templates with `gpu`). Without a
1050
+ * template argument the server picks the GPU type's default template.
1051
+ */
1052
+ gpu?: string;
1053
+ /**
1054
+ * With `gpu`: when no GPU of the type is free, the sandbox waits in the GPU queue (stopped,
1055
+ * `getInfo().queue` set) and `create` waits with it until the sandbox runs. If the wait ends first,
1056
+ * `create` throws `InstaboxError` with the entry's reason as `code` (`queue_expired`), and the sandbox
1057
+ * is deleted.
1058
+ */
1059
+ queue?: GpuQueueOpt;
934
1060
  /**
935
1061
  * @deprecated Removed in 0.6.0: sandboxes have no lifetime timeout since 2026-10-20. Passing it throws
936
1062
  * `InstaboxError` (`code: 'retired_option'`); use `autoSuspendMs`, `archiveMs` or `kill()` instead.
@@ -943,6 +1069,23 @@ interface SandboxConnectOpts extends ConnectionOptions {
943
1069
  /** Resume the sandbox if it is paused (suspended) or stopped. Default true. */
944
1070
  resume?: boolean;
945
1071
  envs?: Record<string, string>;
1072
+ /** Starting a stopped GPU sandbox: wait in the GPU queue when no GPU is free (see `SandboxOpts.queue`). */
1073
+ queue?: GpuQueueOpt;
1074
+ }
1075
+ interface ResumeOpts {
1076
+ /**
1077
+ * Starting a stopped GPU sandbox: wait in the GPU queue when no GPU is free. If the wait ends first,
1078
+ * this throws `InstaboxError` with the entry's reason as `code`, and the sandbox stays stopped with
1079
+ * its disks. A paused sandbox resumes on the GPU it holds and ignores it.
1080
+ */
1081
+ queue?: GpuQueueOpt;
1082
+ }
1083
+ interface GpuQueueListOpts extends ConnectionOptions {
1084
+ state?: GpuQueueEntry['state'];
1085
+ /** Page size, 1-200. Default: the server's (50). */
1086
+ limit?: number;
1087
+ /** `nextCursor` of the previous page. */
1088
+ cursor?: string;
946
1089
  }
947
1090
  interface SandboxListOpts extends ConnectionOptions {
948
1091
  /** Only sandboxes whose metadata has every one of these key/value pairs. */
@@ -965,6 +1108,13 @@ interface SandboxInfo {
965
1108
  /** Idle time after which the server pauses the sandbox; undefined when it never does. */
966
1109
  autoSuspendMs?: number;
967
1110
  state: MachineState;
1111
+ /** The sandbox's GPUs; absent on a sandbox without one. */
1112
+ gpu?: {
1113
+ type: string;
1114
+ count: number;
1115
+ };
1116
+ /** Its live GPU queue entry; absent unless it waits for a GPU. */
1117
+ queue?: MachineQueue;
968
1118
  /** The raw machine object from the API. */
969
1119
  machine: Machine;
970
1120
  }
@@ -992,6 +1142,13 @@ interface SandboxMetrics {
992
1142
  diskUsed?: number;
993
1143
  /** System disk plus /data disk size. */
994
1144
  diskTotal: number;
1145
+ /** GPU sandboxes: share of the time a kernel ran on its GPUs, averaged over them (0-100). Absent where the host did not read it. */
1146
+ gpuUsedPct?: number;
1147
+ /** GPU sandboxes: GPU memory in use, summed over its GPUs. */
1148
+ gpuMemUsed?: number;
1149
+ gpuCount?: number;
1150
+ /** GPU sandboxes: the GPU type's memory times `gpuCount`. */
1151
+ gpuMemTotal?: number;
995
1152
  }
996
1153
  interface SandboxMetricsOpts {
997
1154
  /** Start of the samples, at most 24 h ago. Default: 5 minutes ago. */
@@ -1014,6 +1171,13 @@ interface SandboxUsage {
1014
1171
  * Billed or not (the plan's free egress and free sandboxes included). Absent from older servers.
1015
1172
  */
1016
1173
  egressBytes?: number;
1174
+ /** The sandbox's GPUs and their type; absent without one. */
1175
+ gpus?: number;
1176
+ gpuType?: string;
1177
+ /** GPUs times running seconds. */
1178
+ gpuSeconds?: number;
1179
+ /** That GPU time at the type's price per GPU-hour. */
1180
+ gpuUSD?: number;
1017
1181
  }
1018
1182
  interface SandboxUsageOpts {
1019
1183
  /** Default: the start of the current calendar month (UTC). */
@@ -1070,6 +1234,23 @@ declare class Sandbox {
1070
1234
  static getUsage(sandboxId: string, opts?: SandboxUsageOpts & ConnectionOptions): Promise<SandboxUsage>;
1071
1235
  /** Your account's counts, stored bytes (per sandbox in `storage`) and limits. Requires machines:read or images:read. */
1072
1236
  static usage(opts?: ConnectionOptions): Promise<Usage>;
1237
+ /**
1238
+ * The templates a create may name. Every version of a template is listed; `latest` marks the one a
1239
+ * create gets. GPU templates have `gpu` and list their GPU types in `gpuTypes`.
1240
+ */
1241
+ static listTemplates(opts?: ConnectionOptions): Promise<Template[]>;
1242
+ /**
1243
+ * A page of your GPU queue entries, newest first: live ones (`queued`, `dispatched`) with their place
1244
+ * in line, and ended ones with their `reason`. Requires machines:read.
1245
+ */
1246
+ static listGpuQueue(opts?: GpuQueueListOpts): Promise<GpuQueuePage>;
1247
+ /**
1248
+ * Stops a GPU queue entry's wait (`getInfo().queue.id`). A `create` entry's sandbox is deleted; a
1249
+ * `start` entry's stays stopped with its disks. Cancel this way, never with `kill()`, which deletes
1250
+ * a stopped sandbox's disks. Returns the entry, `cancelled`, or still `dispatched` with `cancelling`
1251
+ * when the sandbox was already starting. Requires machines:write.
1252
+ */
1253
+ static cancelGpuQueue(entryId: string, opts?: ConnectionOptions): Promise<GpuQueueEntry>;
1073
1254
  /** Lists the caller's private snapshots. Requires images:read. */
1074
1255
  static listSnapshots(opts?: ConnectionOptions): Promise<Snapshot[]>;
1075
1256
  /** Fetches a snapshot by ID. Requires images:read. */
@@ -1129,9 +1310,12 @@ declare class Sandbox {
1129
1310
  isRunning(): Promise<boolean>;
1130
1311
  /** Snapshots memory and stops the sandbox (suspend). `resume()` or `Sandbox.connect()` brings it back. */
1131
1312
  pause(): Promise<void>;
1132
- /** Resumes a paused sandbox from its snapshot, or starts a stopped one. */
1133
- resume(): Promise<void>;
1134
- /** Resumes or starts based on the cached state; callers make sure the cache is fresh. */
1313
+ /** Resumes a paused sandbox from its snapshot, or starts a stopped one (waiting for a GPU with `queue`). */
1314
+ resume(opts?: ResumeOpts): Promise<void>;
1315
+ /**
1316
+ * Resumes or starts based on the cached state; callers make sure the cache is fresh. A sandbox
1317
+ * already waiting for a GPU is waited for: starting it again would not move it up the line.
1318
+ */
1135
1319
  private wake;
1136
1320
  /** Stops the sandbox (guest shutdown; processes end, `/data` is kept). */
1137
1321
  stop(): Promise<void>;
@@ -1162,4 +1346,4 @@ declare class Sandbox {
1162
1346
  private mutate;
1163
1347
  }
1164
1348
 
1165
- export { type ApiError, CommandExitError, type CommandHandle, type CommandOptions, type CommandResult, type CommandWaitOptions, Commands, type Connection, type ConnectionOptions, type CreateSnapshotOpts, DEFAULT_API_URL, DEFAULT_TEMPLATE, DESKTOP_DISPLAY, Desktop, type DesktopStatus, type DesktopStream, type DownloadInfo, type DownloadOptions, type EntryInfo, type ExecResponse, FALLBACK_TEMPLATE, type FileStream, Files, type HostTrust, InstaboxAuthError, InstaboxError, type InstaboxErrorInit, InstaboxNotUtf8Error, InstaboxQuotaError, InstaboxTimeoutError, LIMIT_CODES, MAX_FILE_BYTES, MAX_STDIN_BYTES, MAX_UPLOAD_BYTES, type Machine, type MachineList, type MachineMetric, type MachineMetrics, type MachineSpec, type MachineState, type MachineUsage, type MachineVault, type MachineVaultItem, type MouseButton, type Operation, type PortAccess, Ports, type PublicPort, type PublishPortOpts, type ReadStreamOptions, type ResizeOpts, Sandbox, type SandboxConnectOpts, type SandboxInfo, type SandboxListOpts, type SandboxMetrics, type SandboxMetricsOpts, type SandboxOpts, type SandboxUsage, type SandboxUsageOpts, type ScrollDirection, type Snapshot, type SnapshotList, type SshCredentials, type Template, type TemplateRef, type UploadInfo, type UploadOptions, type Usage, type UsageCost, type UsageLimits, type UsageMachineStorage, type UsageStorage, type VaultApplied, type VaultFile, type VaultKept, type WriteData, type WriteInfo, type WriteOptions, isLimitCode };
1349
+ export { type ApiError, CommandExitError, type CommandHandle, type CommandOptions, type CommandResult, type CommandWaitOptions, Commands, type Connection, type ConnectionOptions, type CreateSnapshotOpts, DEFAULT_API_URL, DEFAULT_TEMPLATE, DESKTOP_DISPLAY, Desktop, type DesktopStatus, type DesktopStream, type DownloadInfo, type DownloadOptions, type EntryInfo, type ExecResponse, FALLBACK_TEMPLATE, type FileStream, Files, type GpuQueueEntry, type GpuQueueListOpts, type GpuQueueOpt, type GpuQueuePage, type GpuUsage, type HostTrust, InstaboxAuthError, InstaboxError, type InstaboxErrorInit, InstaboxNotUtf8Error, InstaboxQuotaError, InstaboxTimeoutError, LIMIT_CODES, MAX_FILE_BYTES, MAX_STDIN_BYTES, MAX_UPLOAD_BYTES, type Machine, type MachineList, type MachineMetric, type MachineMetrics, type MachineQueue, type MachineSpec, type MachineState, type MachineUsage, type MachineVault, type MachineVaultItem, type MouseButton, type Operation, type PortAccess, Ports, type PublicPort, type PublishPortOpts, type ReadStreamOptions, type ResizeOpts, type ResumeOpts, Sandbox, type SandboxConnectOpts, type SandboxInfo, type SandboxListOpts, type SandboxMetrics, type SandboxMetricsOpts, type SandboxOpts, type SandboxUsage, type SandboxUsageOpts, type ScrollDirection, type Snapshot, type SnapshotList, type SshCredentials, type Template, type TemplateGpuType, type TemplateRef, type UploadInfo, type UploadOptions, type Usage, type UsageCost, type UsageLimits, type UsageMachineStorage, type UsageStorage, type VaultApplied, type VaultFile, type VaultKept, type WriteData, type WriteInfo, type WriteOptions, isLimitCode };