@insforge/instabox-sdk 0.9.0 → 0.11.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 {
@@ -573,6 +679,52 @@ declare class Commands {
573
679
  private waitJob;
574
680
  }
575
681
 
682
+ interface ComputerUseTool {
683
+ name: string;
684
+ description?: string;
685
+ /** JSON Schema of the tool's arguments. */
686
+ inputSchema?: Record<string, unknown>;
687
+ }
688
+ interface ComputerUseImage {
689
+ mimeType: string;
690
+ data: Uint8Array;
691
+ }
692
+ interface ComputerUseResult {
693
+ /** The text parts of the result, joined by newlines. */
694
+ text: string;
695
+ /** The image parts of the result (screenshots), decoded. */
696
+ images: ComputerUseImage[];
697
+ /** The tool reported an error; `text` says what. */
698
+ isError: boolean;
699
+ /** The tool's structured result, when it returns one. */
700
+ structuredContent?: unknown;
701
+ }
702
+ interface ComputerUseCallOptions {
703
+ /** Give up after this long (at most 600 000; default 60 s). */
704
+ timeoutMs?: number;
705
+ signal?: AbortSignal;
706
+ }
707
+ /**
708
+ * The sandbox's computer-use MCP server (`instabox-computer-use mcp`, on Linux, macOS and Windows
709
+ * desktop templates): its tools read apps' accessibility trees, take screenshots, and click and type
710
+ * into windows. Each call starts the server anew in the sandbox, so what one call read does not carry
711
+ * to the next; cua-driver's `run_steps` tool runs several actions in one call.
712
+ */
713
+ declare class ComputerUse {
714
+ private readonly commands;
715
+ /** @internal */
716
+ constructor(commands: Commands);
717
+ /** The server's tools, with their argument schemas. */
718
+ tools(opts?: ComputerUseCallOptions): Promise<ComputerUseTool[]>;
719
+ /**
720
+ * Calls one tool, for example `call('get_desktop_state')` for a screenshot of the whole screen or
721
+ * `call('list_windows')`. A tool that fails resolves with `isError: true`; it does not throw.
722
+ */
723
+ call(name: string, args?: Record<string, unknown>, opts?: ComputerUseCallOptions): Promise<ComputerUseResult>;
724
+ /** One request to a server started for it: the handshake and the request go in as stdin. */
725
+ private request;
726
+ }
727
+
576
728
  /**
577
729
  * Default cap of a buffered `files.read` (raise it with `maxBytes`, or use `readStream`), and the most
578
730
  * `files.write` moves on a server without the file routes (over exec). Over the file routes `write`
@@ -900,6 +1052,13 @@ declare class Ports {
900
1052
  declare const DEFAULT_TEMPLATE = "agent-browser";
901
1053
  /** The default when a server does not offer `DEFAULT_TEMPLATE` (an older or self-hosted one). */
902
1054
  declare const FALLBACK_TEMPLATE = "universal";
1055
+ /**
1056
+ * Wait in the GPU queue when no GPU of the type is free, instead of failing with `no_capacity`.
1057
+ * `true` waits up to an hour; `maxWaitMs` is sent as whole seconds, 60 s to 24 h.
1058
+ */
1059
+ type GpuQueueOpt = true | {
1060
+ maxWaitMs: number;
1061
+ };
903
1062
  interface SandboxOpts extends ConnectionOptions {
904
1063
  /** Machine name: lowercase letters, digits and `-`. Default `sbx-<random>`. */
905
1064
  name?: string;
@@ -931,6 +1090,19 @@ interface SandboxOpts extends ConnectionOptions {
931
1090
  * Default: the sandbox gets them. Cannot be turned on again later.
932
1091
  */
933
1092
  vault?: boolean;
1093
+ /**
1094
+ * GPUs for the sandbox (paid plans): `TYPE` or `TYPE:COUNT`, such as `'l4'` or `'h100:2'`; the types
1095
+ * and counts are in `Sandbox.listTemplates()` (`gpuTypes` of the templates with `gpu`). Without a
1096
+ * template argument the server picks the GPU type's default template.
1097
+ */
1098
+ gpu?: string;
1099
+ /**
1100
+ * With `gpu`: when no GPU of the type is free, the sandbox waits in the GPU queue (stopped,
1101
+ * `getInfo().queue` set) and `create` waits with it until the sandbox runs. If the wait ends first,
1102
+ * `create` throws `InstaboxError` with the entry's reason as `code` (`queue_expired`), and the sandbox
1103
+ * is deleted.
1104
+ */
1105
+ queue?: GpuQueueOpt;
934
1106
  /**
935
1107
  * @deprecated Removed in 0.6.0: sandboxes have no lifetime timeout since 2026-10-20. Passing it throws
936
1108
  * `InstaboxError` (`code: 'retired_option'`); use `autoSuspendMs`, `archiveMs` or `kill()` instead.
@@ -943,6 +1115,23 @@ interface SandboxConnectOpts extends ConnectionOptions {
943
1115
  /** Resume the sandbox if it is paused (suspended) or stopped. Default true. */
944
1116
  resume?: boolean;
945
1117
  envs?: Record<string, string>;
1118
+ /** Starting a stopped GPU sandbox: wait in the GPU queue when no GPU is free (see `SandboxOpts.queue`). */
1119
+ queue?: GpuQueueOpt;
1120
+ }
1121
+ interface ResumeOpts {
1122
+ /**
1123
+ * Starting a stopped GPU sandbox: wait in the GPU queue when no GPU is free. If the wait ends first,
1124
+ * this throws `InstaboxError` with the entry's reason as `code`, and the sandbox stays stopped with
1125
+ * its disks. A paused sandbox resumes on the GPU it holds and ignores it.
1126
+ */
1127
+ queue?: GpuQueueOpt;
1128
+ }
1129
+ interface GpuQueueListOpts extends ConnectionOptions {
1130
+ state?: GpuQueueEntry['state'];
1131
+ /** Page size, 1-200. Default: the server's (50). */
1132
+ limit?: number;
1133
+ /** `nextCursor` of the previous page. */
1134
+ cursor?: string;
946
1135
  }
947
1136
  interface SandboxListOpts extends ConnectionOptions {
948
1137
  /** Only sandboxes whose metadata has every one of these key/value pairs. */
@@ -965,6 +1154,13 @@ interface SandboxInfo {
965
1154
  /** Idle time after which the server pauses the sandbox; undefined when it never does. */
966
1155
  autoSuspendMs?: number;
967
1156
  state: MachineState;
1157
+ /** The sandbox's GPUs; absent on a sandbox without one. */
1158
+ gpu?: {
1159
+ type: string;
1160
+ count: number;
1161
+ };
1162
+ /** Its live GPU queue entry; absent unless it waits for a GPU. */
1163
+ queue?: MachineQueue;
968
1164
  /** The raw machine object from the API. */
969
1165
  machine: Machine;
970
1166
  }
@@ -992,6 +1188,13 @@ interface SandboxMetrics {
992
1188
  diskUsed?: number;
993
1189
  /** System disk plus /data disk size. */
994
1190
  diskTotal: number;
1191
+ /** 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. */
1192
+ gpuUsedPct?: number;
1193
+ /** GPU sandboxes: GPU memory in use, summed over its GPUs. */
1194
+ gpuMemUsed?: number;
1195
+ gpuCount?: number;
1196
+ /** GPU sandboxes: the GPU type's memory times `gpuCount`. */
1197
+ gpuMemTotal?: number;
995
1198
  }
996
1199
  interface SandboxMetricsOpts {
997
1200
  /** Start of the samples, at most 24 h ago. Default: 5 minutes ago. */
@@ -1014,6 +1217,13 @@ interface SandboxUsage {
1014
1217
  * Billed or not (the plan's free egress and free sandboxes included). Absent from older servers.
1015
1218
  */
1016
1219
  egressBytes?: number;
1220
+ /** The sandbox's GPUs and their type; absent without one. */
1221
+ gpus?: number;
1222
+ gpuType?: string;
1223
+ /** GPUs times running seconds. */
1224
+ gpuSeconds?: number;
1225
+ /** That GPU time at the type's price per GPU-hour. */
1226
+ gpuUSD?: number;
1017
1227
  }
1018
1228
  interface SandboxUsageOpts {
1019
1229
  /** Default: the start of the current calendar month (UTC). */
@@ -1044,6 +1254,8 @@ declare class Sandbox {
1044
1254
  readonly files: Files;
1045
1255
  /** See and control the sandbox's graphical desktop (screenshots, mouse, keyboard, a link to watch it). */
1046
1256
  readonly desktop: Desktop;
1257
+ /** The sandbox's computer-use MCP tools: accessibility trees, screenshots, clicks and typing in apps. */
1258
+ readonly computerUse: ComputerUse;
1047
1259
  /** Publish a port at an HTTPS URL, list published ports, unpublish them. */
1048
1260
  readonly ports: Ports;
1049
1261
  private machine;
@@ -1070,6 +1282,23 @@ declare class Sandbox {
1070
1282
  static getUsage(sandboxId: string, opts?: SandboxUsageOpts & ConnectionOptions): Promise<SandboxUsage>;
1071
1283
  /** Your account's counts, stored bytes (per sandbox in `storage`) and limits. Requires machines:read or images:read. */
1072
1284
  static usage(opts?: ConnectionOptions): Promise<Usage>;
1285
+ /**
1286
+ * The templates a create may name. Every version of a template is listed; `latest` marks the one a
1287
+ * create gets. GPU templates have `gpu` and list their GPU types in `gpuTypes`.
1288
+ */
1289
+ static listTemplates(opts?: ConnectionOptions): Promise<Template[]>;
1290
+ /**
1291
+ * A page of your GPU queue entries, newest first: live ones (`queued`, `dispatched`) with their place
1292
+ * in line, and ended ones with their `reason`. Requires machines:read.
1293
+ */
1294
+ static listGpuQueue(opts?: GpuQueueListOpts): Promise<GpuQueuePage>;
1295
+ /**
1296
+ * Stops a GPU queue entry's wait (`getInfo().queue.id`). A `create` entry's sandbox is deleted; a
1297
+ * `start` entry's stays stopped with its disks. Cancel this way, never with `kill()`, which deletes
1298
+ * a stopped sandbox's disks. Returns the entry, `cancelled`, or still `dispatched` with `cancelling`
1299
+ * when the sandbox was already starting. Requires machines:write.
1300
+ */
1301
+ static cancelGpuQueue(entryId: string, opts?: ConnectionOptions): Promise<GpuQueueEntry>;
1073
1302
  /** Lists the caller's private snapshots. Requires images:read. */
1074
1303
  static listSnapshots(opts?: ConnectionOptions): Promise<Snapshot[]>;
1075
1304
  /** Fetches a snapshot by ID. Requires images:read. */
@@ -1129,9 +1358,12 @@ declare class Sandbox {
1129
1358
  isRunning(): Promise<boolean>;
1130
1359
  /** Snapshots memory and stops the sandbox (suspend). `resume()` or `Sandbox.connect()` brings it back. */
1131
1360
  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. */
1361
+ /** Resumes a paused sandbox from its snapshot, or starts a stopped one (waiting for a GPU with `queue`). */
1362
+ resume(opts?: ResumeOpts): Promise<void>;
1363
+ /**
1364
+ * Resumes or starts based on the cached state; callers make sure the cache is fresh. A sandbox
1365
+ * already waiting for a GPU is waited for: starting it again would not move it up the line.
1366
+ */
1135
1367
  private wake;
1136
1368
  /** Stops the sandbox (guest shutdown; processes end, `/data` is kept). */
1137
1369
  stop(): Promise<void>;
@@ -1162,4 +1394,4 @@ declare class Sandbox {
1162
1394
  private mutate;
1163
1395
  }
1164
1396
 
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 };
1397
+ export { type ApiError, CommandExitError, type CommandHandle, type CommandOptions, type CommandResult, type CommandWaitOptions, Commands, ComputerUse, type ComputerUseCallOptions, type ComputerUseImage, type ComputerUseResult, type ComputerUseTool, 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 };