@arker-ai/sdk 0.3.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,15 +1,33 @@
1
1
  interface components {
2
2
  schemas: {
3
- /** @description Standard API error. Backends use code "unsupported_operation" when the request is valid but names an operation or option this backend cannot support. */
3
+ /**
4
+ * @description Stable machine-readable error code. `unsupported_operation` means the backend doesn't implement the requested optional feature.
5
+ * @enum {string}
6
+ */
7
+ ErrorCode: "unsupported_operation" | "bad_request" | "unauthorized" | "forbidden" | "not_found" | "conflict" | "payload_too_large" | "not_implemented" | "resource_pressure" | "internal" | "unavailable" | "network_error";
4
8
  ErrorResponse: {
5
- /**
6
- * @description Stable machine-readable error code. "unsupported_operation" means the backend does not implement the requested optional feature.
7
- * @example unsupported_operation
8
- */
9
- code: string;
10
- /** @description Human-readable error message. */
9
+ code: components["schemas"]["ErrorCode"];
11
10
  message: string;
12
11
  };
12
+ /**
13
+ * @description Unified lifecycle state for a VM or a Session. `idle` means no command is currently executing; `running` means a command is in flight.
14
+ * @enum {string}
15
+ */
16
+ VmState: "idle" | "running";
17
+ SessionState: components["schemas"]["VmState"];
18
+ /**
19
+ * @description Lifecycle state for a Run. `running` = command in flight. `completed` = ran to completion; `exit_code` conveys success (0) or a non-zero program exit (still `completed`). `failed` = the platform could not run/finish the command (worker died, evicted mid-run); `fail_reason` explains why, distinct from the program's `stderr`. `cancelled` = cancelled by the client.
20
+ * @enum {string}
21
+ */
22
+ RunState: "running" | "completed" | "failed" | "cancelled";
23
+ /**
24
+ * @description `starting` = backend is allocating the tunnel; `open` = accepting
25
+ * connections; `closed` = torn down or never came up.
26
+ * @enum {string}
27
+ */
28
+ TunnelState: "starting" | "open" | "closed";
29
+ /** @enum {string} */
30
+ ResourceKind: "cpu" | "memory" | "disk";
13
31
  NetworkPolicy: components["schemas"]["NetworkPolicyOpen"] | components["schemas"]["NetworkPolicyBlocked"] | components["schemas"]["NetworkPolicyAllow"] | components["schemas"]["NetworkPolicyBlock"];
14
32
  NetworkPolicyOpen: {
15
33
  /** @constant */
@@ -31,8 +49,16 @@ interface components {
31
49
  };
32
50
  NetworkPolicyInput: boolean | string | components["schemas"]["NetworkPolicy"];
33
51
  ForkRequest: {
52
+ /** @description Global VM identifier. Org is inferred from the row. */
53
+ source_vm_id?: string | null;
54
+ /** @description VM name within an org. Defaults `source_org_id` to the caller's org. A different org must be either the Arker org (for the public goldens `arkuntu` / `ubuntu`) or one with a `public: true` VM by that name. */
55
+ source_vm_name?: string | null;
56
+ /** @description Optional explicit org context for `source_vm_name`. SDK auto-fills the Arker org when forking the public goldens. */
57
+ source_org_id?: string | null;
58
+ /** @description Optional name for the new VM, scoped to the caller's org. */
34
59
  name?: string | null;
35
- image?: string | null;
60
+ /** @description Make the new VM publicly forkable from other orgs. */
61
+ public?: boolean | null;
36
62
  network?: components["schemas"]["NetworkPolicyInput"] | null;
37
63
  /** @default true */
38
64
  disk?: boolean;
@@ -40,53 +66,59 @@ interface components {
40
66
  memory_mib?: number | null;
41
67
  max_memory_mib?: number | null;
42
68
  disk_mib?: number | null;
43
- /**
44
- * @description Request a durable VM. If the underlying host fails mid-run, the run resumes on a healthy host with the VM's filesystem state preserved. Use for long-running or non-idempotent work. Forked children default to non-durable. Backends without durability support return ErrorResponse code "unsupported_operation".
45
- * @default false
46
- */
47
69
  durable?: boolean | null;
48
70
  };
49
- SessionInfo: {
71
+ Session: {
50
72
  session_id: string;
51
- state: string;
73
+ /** @default 0 */
74
+ session_idx?: number;
75
+ state: components["schemas"]["SessionState"];
52
76
  cwd: string;
53
- };
54
- ListSessionsResponse: components["schemas"]["SessionInfo"][];
55
- GoldenInfo: {
56
- vm_id: string;
57
- name: string;
58
- source_golden: string;
59
- memory_mib?: number | null;
60
- vcpu_count?: number | null;
61
- disk_mib?: number | null;
62
- };
63
- ListGoldensResponse: {
64
- goldens: components["schemas"]["GoldenInfo"][];
65
- };
66
- VmInfo: {
77
+ /** @description Optional environment-variable overrides for this session. */
78
+ env?: {
79
+ [key: string]: string;
80
+ } | null;
81
+ started_at?: string | null;
82
+ vm_id?: string | null;
83
+ vm_name?: string | null;
84
+ source_org_id?: string | null;
85
+ region?: string | null;
86
+ /** @enum {string|null} */
87
+ provider?: "aws" | "aws-burst" | null;
88
+ };
89
+ ListSessionsResponse: {
90
+ sessions: components["schemas"]["Session"][];
91
+ next_cursor?: string | null;
92
+ };
93
+ Vm: {
67
94
  vm_id: string;
68
- owner_id: string;
95
+ /** @description Org that owns this VM. */
96
+ owner_org_id: string;
69
97
  created_at: string;
98
+ /** @description VM name, scoped to `owner_org_id`. */
70
99
  name?: string | null;
71
- source_golden?: string | null;
72
- state: string;
73
- last_activity?: string | null;
100
+ /** @description When `true`, other orgs can fork this VM (but cannot run on it). */
101
+ public: boolean;
102
+ /** @description ID of the root (deepest-ancestor) source VM, if this VM was created by a chain of forks. None for VMs forked directly from an image. */
103
+ root_source_vm_id?: string | null;
104
+ /** @description Name of the root source VM. Populated together with `root_source_vm_id`. */
105
+ root_source_vm_name?: string | null;
106
+ state: components["schemas"]["VmState"];
107
+ region?: string | null;
108
+ /** @enum {string|null} */
109
+ provider?: "aws" | "aws-burst" | null;
110
+ started_at?: string | null;
74
111
  vcpu_count?: number | null;
75
112
  memory_mib?: number | null;
76
113
  disk_mib?: number | null;
77
- sessions: components["schemas"]["SessionInfo"][];
114
+ /** @description Worker host that owns this VM. Used by routers to populate caches without a fresh PlanetScale lookup. */
115
+ worker_id?: string | null;
116
+ sessions: components["schemas"]["Session"][];
117
+ tunnels?: components["schemas"]["Tunnel"][];
78
118
  };
79
119
  ListVmsResponse: {
80
- vms: components["schemas"]["VmInfo"][];
81
- };
82
- ForkVmResponse: {
83
- vm_id: string;
84
- owner_id: string;
85
- created_at: string;
86
- sessions: components["schemas"]["SessionInfo"][];
87
- ssh_private_key?: string | null;
88
- tunnels?: components["schemas"]["RunTunnelStatus"][];
89
- network?: components["schemas"]["RunNetworkStatus"] | null;
120
+ vms: components["schemas"]["Vm"][];
121
+ next_cursor?: string | null;
90
122
  };
91
123
  DeleteVmResponse: {
92
124
  deleted: boolean;
@@ -94,154 +126,201 @@ interface components {
94
126
  DeleteSessionResponse: {
95
127
  deleted: boolean;
96
128
  };
97
- MountRequest: {
98
- uri: string;
99
- mount_point: string;
100
- /** @default dir */
101
- format?: string;
102
- };
103
- /** @description Foreground command execution is the portable baseline. Optional session, background, mount, resource, network, signal, release, and runtime fields may return ErrorResponse code "unsupported_operation" on backends that do not support them. */
104
129
  RunRequest: {
105
- /** @description Optional persistent session id. Backends without persistent sessions return unsupported_operation when this is requested. */
106
130
  session_id?: string | null;
131
+ session_idx?: number | null;
107
132
  command: string;
108
- /**
109
- * @description Run asynchronously. Backends without background execution return unsupported_operation and must not silently run the command synchronously.
110
- * @default false
111
- */
133
+ /** @default false */
112
134
  background?: boolean;
113
135
  timeout?: number | null;
114
136
  /** @default auto */
115
137
  end_symbol?: string | null;
116
- /**
117
- * @description Optional external mounts. Backends without mount support return unsupported_operation when this is non-empty.
118
- * @default []
119
- */
120
- mounts?: components["schemas"]["MountRequest"][];
121
- /** @description Optional per-run resource override. Backends without resource override support return unsupported_operation when this is requested. */
122
138
  vcpu_count?: number | null;
123
- /** @description Optional per-run resource override. Backends without resource override support return unsupported_operation when this is requested. */
124
139
  memory_mib?: number | null;
125
- /** @description Optional per-run resource override. Backends without resource override support return unsupported_operation when this is requested. */
126
140
  disk_mib?: number | null;
127
- /** @description Optional network/tunnel request. Backends without networking support return unsupported_operation when this is requested. */
128
- network?: components["schemas"]["RunNetworkRequest"] | null;
129
- /** @description Optional release selection. Backends without release selection support return unsupported_operation when this is requested. */
141
+ network?: components["schemas"]["NetworkRequest"] | null;
142
+ /**
143
+ * @description Comma-separated list of resources to ensure are
144
+ * pre-allocated (warm) before the run starts. Values: `cpu`,
145
+ * `memory`, `disk`. Example: `"cpu,memory"`.
146
+ */
147
+ acquire?: string | null;
148
+ /**
149
+ * @description Comma-separated list of resources to release after the run
150
+ * finishes. Values: `cpu`, `memory`, `disk`. `"cpu"` frees
151
+ * vCPU but keeps memory hot for the next run on this VM;
152
+ * `"cpu,memory,disk"` is a full release (closest to a
153
+ * suspend).
154
+ */
130
155
  release?: string | null;
131
- /** @description Optional session signal. Backends without signal support return unsupported_operation when this is requested. */
132
156
  signal?: string | null;
133
- /** @description Optional runtime selection. Backends without runtime selection support return unsupported_operation when this is requested. */
134
- runtime?: string | null;
135
- /** @description Optional runtime override. Backends without runtime overrides return unsupported_operation when this is requested. */
136
- runtime_override?: string | null;
137
157
  };
138
- RunNetworkRequest: {
139
- inbound?: components["schemas"]["RunInboundRequest"] | null;
158
+ NetworkRequest: {
159
+ inbound?: components["schemas"]["InboundRequest"] | null;
140
160
  };
141
- RunInboundRequest: {
161
+ InboundRequest: {
142
162
  /** @default {} */
143
163
  ports?: {
144
- [key: string]: components["schemas"]["RunInboundPortRequest"];
164
+ [key: string]: components["schemas"]["InboundPortRequest"];
145
165
  };
146
166
  };
147
- RunInboundPortRequest: {
167
+ InboundPortRequest: {
148
168
  /** @default private */
149
169
  visibility?: string;
150
170
  /** @default http */
151
171
  protocol?: string;
152
172
  };
153
- /** @description Successful run result. BackgroundRunResponse and PtyRunResponse are returned only by backends that support those modes; unsupported modes return ErrorResponse code "unsupported_operation". */
154
- RunResponse: components["schemas"]["CompletedRunResponse"] | components["schemas"]["BackgroundRunResponse"] | components["schemas"]["PtyRunResponse"];
173
+ RunResponse: components["schemas"]["CompletedRunResponse"] | components["schemas"]["BackgroundRunResponse"];
155
174
  CompletedRunResponse: {
156
175
  stdout: string;
176
+ /**
177
+ * @description TODO(encoding-normalize): goal is to always emit utf-8 from
178
+ * every source so this field becomes unnecessary. Until then
179
+ * the SDK uses it to decode.
180
+ */
157
181
  stdout_encoding: string;
158
182
  stderr: string;
159
183
  stderr_encoding: string;
160
184
  exit_code: number;
161
- completed: boolean;
185
+ dispatch?: string | null;
162
186
  };
163
187
  BackgroundRunResponse: {
164
188
  run_id: string;
165
- completed: boolean;
166
189
  /** @default [] */
167
- tunnels?: components["schemas"]["RunTunnelStatus"][];
168
- network?: components["schemas"]["RunNetworkStatus"] | null;
190
+ tunnels?: components["schemas"]["Tunnel"][];
169
191
  };
170
- PtyRunResponse: {
171
- /** @constant */
172
- pty: true;
173
- session_id: string;
174
- ws_url: string;
175
- };
176
- RunStatusResponse: {
192
+ Run: {
177
193
  run_id: string;
194
+ session_id?: string | null;
195
+ command?: string | null;
196
+ state: components["schemas"]["RunState"];
197
+ started_at: string;
198
+ completed_at?: string | null;
199
+ exit_code: number | null;
200
+ /** @description System failure explanation when `state` is `failed` (e.g. "worker died: <id>"). Distinct from `stderr`, which is the program's own output. */
201
+ fail_reason?: string | null;
178
202
  stdout: string;
179
203
  stdout_encoding: string;
180
204
  stderr: string;
181
205
  stderr_encoding: string;
182
- exit_code: number | null;
183
- completed: boolean;
184
- tunnels: components["schemas"]["RunTunnelStatus"][];
185
- network?: components["schemas"]["RunNetworkStatus"] | null;
186
- /**
187
- * @description Number of times this run has been automatically retried after an infrastructure failure. 0 for runs that completed without interruption. Backends without durability support omit this field; clients should treat it as 0 when absent.
188
- * @default 0
189
- */
206
+ tunnels: components["schemas"]["Tunnel"][];
207
+ /** @default 0 */
190
208
  retry_count?: number;
191
- };
192
- RunNetworkStatus: {
193
- inbound: components["schemas"]["RunInboundStatus"];
194
- };
195
- RunInboundStatus: {
209
+ vm_id?: string | null;
210
+ vm_name?: string | null;
211
+ source_org_id?: string | null;
212
+ region?: string | null;
213
+ /** @enum {string|null} */
214
+ provider?: "aws" | "aws-burst" | null;
215
+ };
216
+ RunSummary: {
217
+ run_id: string;
218
+ session_id?: string | null;
219
+ command?: string | null;
220
+ state: components["schemas"]["RunState"];
221
+ started_at: string;
222
+ completed_at?: string | null;
223
+ exit_code: number | null;
224
+ /** @description System failure explanation when `state` is `failed` (e.g. "worker died: <id>"). Distinct from `stderr`, which is the program's own output. */
225
+ fail_reason?: string | null;
226
+ vm_id?: string | null;
227
+ vm_name?: string | null;
228
+ source_org_id?: string | null;
229
+ region?: string | null;
230
+ /** @enum {string|null} */
231
+ provider?: "aws" | "aws-burst" | null;
232
+ };
233
+ ListRunsResponse: {
234
+ runs: components["schemas"]["RunSummary"][];
235
+ next_cursor?: string | null;
236
+ };
237
+ NetworkStatus: {
238
+ inbound: components["schemas"]["InboundStatus"];
239
+ };
240
+ InboundStatus: {
196
241
  ports: {
197
- [key: string]: components["schemas"]["RunInboundPortStatus"];
242
+ [key: string]: components["schemas"]["InboundPortStatus"];
198
243
  };
199
244
  };
200
- RunInboundPortStatus: {
245
+ InboundPortStatus: {
201
246
  requested: string;
202
247
  observed: string;
203
248
  effective: string;
204
249
  protocol: string;
205
250
  url?: string | null;
206
251
  };
207
- RunTunnelStatus: {
208
- /** @default */
209
- run_id?: string;
252
+ Tunnel: {
253
+ /** @description The VM this tunnel belongs to. Always populated, including when embedded in `Run.tunnels`. */
254
+ vm_id: string;
255
+ /** @description Unique-per-VM identifier. */
210
256
  port: number;
257
+ /** @description The Run that opened this tunnel, if any. Tunnels allocated at fork time have `run_id: null`. */
258
+ run_id?: string | null;
211
259
  visibility: string;
212
260
  protocol: string;
213
261
  url?: string | null;
214
- status: string;
262
+ state: components["schemas"]["TunnelState"];
215
263
  message?: string | null;
264
+ started_at?: string | null;
265
+ vm_name?: string | null;
266
+ source_org_id?: string | null;
267
+ region?: string | null;
268
+ /** @enum {string|null} */
269
+ provider?: "aws" | "aws-burst" | null;
270
+ };
271
+ ListTunnelsResponse: {
272
+ tunnels: components["schemas"]["Tunnel"][];
273
+ next_cursor?: string | null;
274
+ };
275
+ DeleteTunnelResponse: {
276
+ deleted: boolean;
216
277
  };
217
278
  CancelRunResponse: {
218
279
  cancelled: boolean;
219
280
  };
220
- /** @description Create a persistent session. Backends without persistent sessions return unsupported_operation. */
221
281
  CreateSessionRequest: {
222
282
  env?: {
223
283
  [key: string]: string;
224
284
  } | null;
225
285
  cwd?: string | null;
226
286
  };
227
- /** @description Resize a PTY session. Backends without PTY sessions return unsupported_operation. */
228
- ResizePtyRequest: {
229
- cols: number;
230
- rows: number;
231
- };
232
- ResizePtyResponse: {
233
- resized: boolean;
234
- };
235
- /** @description Resize VM resources. Backends without VM resize support return unsupported_operation. */
236
287
  ResizeRequest: {
237
288
  vcpu_count?: number | null;
238
289
  memory_mib?: number | null;
239
290
  disk_mib?: number | null;
240
291
  };
241
292
  ResizeResponse: {
242
- ok: boolean;
293
+ resized: boolean;
294
+ };
295
+ Sync: {
296
+ sync_id: string;
297
+ vm_id: string;
298
+ filesystem_id: string;
299
+ /** @description VM-side path where the filesystem is mounted. Same field name as used by `SyncReadRequest.path`. */
300
+ path: string;
301
+ created_at: string;
302
+ vm_name?: string | null;
303
+ filesystem_name?: string | null;
304
+ source_org_id?: string | null;
305
+ region?: string | null;
306
+ /** @enum {string|null} */
307
+ provider?: "aws" | "aws-burst" | null;
308
+ live?: boolean;
309
+ live_error?: string;
310
+ idempotent?: boolean;
311
+ };
312
+ ListSyncsResponse: {
313
+ syncs: components["schemas"]["Sync"][];
314
+ next_cursor?: string | null;
315
+ };
316
+ DeleteSyncResponse: {
317
+ deleted: boolean;
318
+ };
319
+ SyncCreateRequest: {
320
+ filesystem_id: string;
321
+ /** @description VM-side path. Returns `ErrorResponse` code `conflict` if a sync already exists at this path. */
322
+ path?: string;
243
323
  };
244
- SyncRequest: components["schemas"]["SyncReadRequest"] | components["schemas"]["SyncWriteRequest"];
245
324
  SyncReadRequest: {
246
325
  /** @constant */
247
326
  op: "read";
@@ -277,21 +356,14 @@ interface components {
277
356
  upload_id: string;
278
357
  sha256?: string | null;
279
358
  };
280
- SyncResponse: components["schemas"]["SyncReadResponse"] | components["schemas"]["SyncWriteResponse"];
281
359
  SyncReadResponse: components["schemas"]["SyncReadInlineResponse"] | components["schemas"]["SyncReadPresignedResponse"];
282
360
  SyncReadInlineResponse: {
283
- ok: boolean;
284
- /** @constant */
285
- op: "read";
286
361
  path: string;
287
362
  size: number;
288
363
  content: string;
289
364
  encoding: string;
290
365
  };
291
366
  SyncReadPresignedResponse: {
292
- ok: boolean;
293
- /** @constant */
294
- op: "read";
295
367
  path: string;
296
368
  size: number;
297
369
  presigned_url: string;
@@ -299,9 +371,6 @@ interface components {
299
371
  method: string;
300
372
  };
301
373
  SyncWriteResponse: {
302
- ok: boolean;
303
- /** @constant */
304
- op: "write";
305
374
  results: components["schemas"]["SyncWriteResult"][];
306
375
  };
307
376
  SyncWriteResult: components["schemas"]["SyncChunkWriteResult"] | components["schemas"]["SyncPresignedWriteRequestResult"] | components["schemas"]["SyncCommitWriteResult"];
@@ -340,6 +409,30 @@ interface components {
340
409
  code: string;
341
410
  message: string;
342
411
  };
412
+ Filesystem: {
413
+ filesystem_id: string;
414
+ name: string;
415
+ owner_org_id: string;
416
+ created_at: string;
417
+ size_bytes?: number | null;
418
+ /** @default us-west-2 */
419
+ region?: string | null;
420
+ /**
421
+ * @default aws
422
+ * @enum {string|null}
423
+ */
424
+ provider?: "aws" | "aws-burst" | null;
425
+ };
426
+ ListFilesystemsResponse: {
427
+ filesystems: components["schemas"]["Filesystem"][];
428
+ next_cursor?: string | null;
429
+ };
430
+ DeleteFilesystemResponse: {
431
+ deleted: boolean;
432
+ };
433
+ FilesystemCreateRequest: {
434
+ name: string;
435
+ };
343
436
  };
344
437
  responses: {
345
438
  /** @description API error. */
@@ -351,7 +444,7 @@ interface components {
351
444
  "application/json": components["schemas"]["ErrorResponse"];
352
445
  };
353
446
  };
354
- /** @description The request is valid, but this backend does not support the requested operation or option. The response body uses ErrorResponse with code "unsupported_operation". */
447
+ /** @description The request is valid, but this backend does not support the requested operation or option. */
355
448
  UnsupportedOperation: {
356
449
  headers: {
357
450
  [name: string]: unknown;
@@ -365,8 +458,13 @@ interface components {
365
458
  VmId: string;
366
459
  RunId: string;
367
460
  SessionId: string;
368
- /** @description Optional idempotency key for safe retries of POST /v1/vms/{id}/run. A retry with the same key and the same request returns the original run. A different request under the same key returns ErrorResponse code "conflict" with the original run_id. Keys expire 24h after the run completes. */
369
- IdempotencyKey: string;
461
+ SyncId: string;
462
+ TunnelPort: number;
463
+ FilesystemId: string;
464
+ /** @description Opaque pagination cursor returned by the previous page's `next_cursor`. */
465
+ Cursor: string | null;
466
+ /** @description Max items per page. Backend caps may apply. */
467
+ Limit: number;
370
468
  };
371
469
  requestBodies: never;
372
470
  headers: never;
@@ -382,6 +480,14 @@ interface components {
382
480
 
383
481
  type ApiSchema<Name extends keyof components["schemas"]> = components["schemas"][Name];
384
482
  declare const CHUNK_SIZE: number;
483
+ /**
484
+ * Org id for the "Arker" org — the org that owns the public golden VMs
485
+ * (`arkuntu`, `ubuntu`, `ubuntu-full`, `ubuntu-py-repl`, …). Pass it as
486
+ * `sourceOrgId` to fork a public golden:
487
+ *
488
+ * arker.fork({ sourceVmName: "ubuntu-full", sourceOrgId: ARKER_ORG_ID })
489
+ */
490
+ declare const ARKER_ORG_ID = "ArkerHQ";
385
491
  type FetchLike = typeof fetch;
386
492
  type HttpMethod = "GET" | "POST" | "DELETE";
387
493
  interface RetryOptions {
@@ -392,107 +498,206 @@ interface RetryOptions {
392
498
  }
393
499
  interface ArkerOptions {
394
500
  apiKey?: string;
501
+ /** Region (e.g. `"us-west-2"`). Combined with `provider` to build the
502
+ * compute endpoint. Back-compat: accepts the legacy combined form
503
+ * `"aws-us-west-2"`. */
504
+ region?: string;
505
+ /** Provider for compute calls. Defaults to `"aws"` (arkerd-managed
506
+ * VMs). Use `"aws-burst"` to target the Lambda burst backend
507
+ * directly. Has no effect on the burst-classified routing — a fork
508
+ * of `arkuntu` in the Arker org still goes to burst regardless. */
509
+ provider?: "aws" | "aws-burst";
510
+ /** Override the compute base URL (e.g. for internal / dev targets).
511
+ * If set, `provider` + `region` are ignored for compute. */
395
512
  baseUrl?: string;
513
+ /** Override the burst compute base URL. */
396
514
  burstBaseUrl?: string;
515
+ /** Override the control-plane URL — the CF Worker that owns
516
+ * administrative endpoints like `GET /v1/vms` (cross-provider list)
517
+ * and `/v1/filesystems`. Default `https://arker.ai/api`. */
518
+ controlBaseUrl?: string;
397
519
  fetch?: FetchLike;
398
- region?: string;
399
520
  retry?: RetryOptions | false;
400
521
  }
522
+ type VmState = ApiSchema<"VmState">;
523
+ type SessionState = ApiSchema<"SessionState">;
524
+ type RunState = ApiSchema<"RunState">;
525
+ type TunnelState = ApiSchema<"TunnelState">;
526
+ type ResourceKind = ApiSchema<"ResourceKind">;
527
+ type ErrorCode = ApiSchema<"ErrorCode">;
401
528
  type NetworkPolicy = ApiSchema<"NetworkPolicy">;
402
529
  type NetworkPolicyInput = ApiSchema<"NetworkPolicyInput">;
403
530
  type ForkRequest = ApiSchema<"ForkRequest">;
404
531
  type ForkOptions = ForkRequest;
405
- type SessionInfo = ApiSchema<"SessionInfo">;
406
- type GoldenInfo = ApiSchema<"GoldenInfo">;
407
- type ListGoldensResponse = ApiSchema<"ListGoldensResponse">;
408
- type VmInfo = ApiSchema<"VmInfo">;
532
+ type Session = ApiSchema<"Session">;
533
+ type Vm = ApiSchema<"Vm">;
409
534
  type ListVmsResponse = ApiSchema<"ListVmsResponse">;
410
535
  type ListSessionsResponse = ApiSchema<"ListSessionsResponse">;
411
- type VmSummary = VmInfo;
412
- type VmList = ListVmsResponse;
413
- type ForkVmResponse = ApiSchema<"ForkVmResponse">;
414
536
  type DeleteVmResponse = ApiSchema<"DeleteVmResponse">;
415
537
  type DeleteSessionResponse = ApiSchema<"DeleteSessionResponse">;
416
- type MountRequest = ApiSchema<"MountRequest">;
538
+ type Filesystem = ApiSchema<"Filesystem">;
539
+ type ListFilesystemsResponse = ApiSchema<"ListFilesystemsResponse">;
540
+ type DeleteFilesystemResponse = ApiSchema<"DeleteFilesystemResponse">;
541
+ type FilesystemCreateRequest = ApiSchema<"FilesystemCreateRequest">;
542
+ type Sync = ApiSchema<"Sync">;
543
+ type ListSyncsResponse = ApiSchema<"ListSyncsResponse">;
544
+ type DeleteSyncResponse = ApiSchema<"DeleteSyncResponse">;
545
+ type SyncCreateRequest = ApiSchema<"SyncCreateRequest">;
546
+ type SyncReadRequest = ApiSchema<"SyncReadRequest">;
547
+ type SyncWriteRequest = ApiSchema<"SyncWriteRequest">;
548
+ type SyncReadResponse = ApiSchema<"SyncReadResponse">;
549
+ type SyncReadInlineResponse = ApiSchema<"SyncReadInlineResponse">;
550
+ type SyncReadPresignedResponse = ApiSchema<"SyncReadPresignedResponse">;
551
+ type SyncWriteResponse = ApiSchema<"SyncWriteResponse">;
552
+ type SyncWriteResult = ApiSchema<"SyncWriteResult">;
553
+ type SyncChunkWriteResult = ApiSchema<"SyncChunkWriteResult">;
554
+ type SyncPresignedWriteRequestResult = ApiSchema<"SyncPresignedWriteRequestResult">;
555
+ type SyncCommitWriteResult = ApiSchema<"SyncCommitWriteResult">;
556
+ type SyncByteRange = ApiSchema<"SyncByteRange">;
417
557
  type RunRequest = ApiSchema<"RunRequest">;
418
- type RunOptions = Omit<RunRequest, "command"> & {
558
+ type RunOptions = Partial<Omit<RunRequest, "command">> & {
419
559
  /**
420
- * Optional idempotency key for retrying POST /v1/vms/{id}/run.
421
- * Sent as the `Idempotency-Key` HTTP header. Retries with the same
422
- * key and the same semantic request return the original run; a
423
- * different semantic request under the same key returns
424
- * ArkerError code "conflict" with the original run_id.
560
+ * Optional idempotency key for retrying the run. Sent as the
561
+ * `Idempotency-Key` HTTP header.
425
562
  */
426
563
  idempotencyKey?: string;
427
564
  };
428
- type RunInboundPortRequest = ApiSchema<"RunInboundPortRequest">;
429
- type RunNetworkRequest = ApiSchema<"RunNetworkRequest">;
430
- type RunTunnelStatus = ApiSchema<"RunTunnelStatus">;
431
- type RunNetworkStatus = ApiSchema<"RunNetworkStatus">;
565
+ type InboundPortRequest = ApiSchema<"InboundPortRequest">;
566
+ type NetworkRequest = ApiSchema<"NetworkRequest">;
567
+ type Tunnel = ApiSchema<"Tunnel">;
568
+ type ListTunnelsResponse = ApiSchema<"ListTunnelsResponse">;
569
+ type DeleteTunnelResponse = ApiSchema<"DeleteTunnelResponse">;
570
+ type NetworkStatus = ApiSchema<"NetworkStatus">;
432
571
  type RunResponse = ApiSchema<"RunResponse">;
433
572
  type CompletedRunResponse = ApiSchema<"CompletedRunResponse">;
434
573
  type BackgroundRunResponse = ApiSchema<"BackgroundRunResponse">;
435
- type PtyRunResponse = ApiSchema<"PtyRunResponse">;
436
- type RawRunResponse = RunResponse;
574
+ type Run = ApiSchema<"Run">;
575
+ type RunSummary = ApiSchema<"RunSummary">;
576
+ type ListRunsResponse = ApiSchema<"ListRunsResponse">;
577
+ type CancelRunResponse = ApiSchema<"CancelRunResponse">;
578
+ type CreateSessionRequest = ApiSchema<"CreateSessionRequest">;
579
+ type ResizeRequest = ApiSchema<"ResizeRequest">;
580
+ type ResizeResponse = ApiSchema<"ResizeResponse">;
581
+ type ErrorResponse = ApiSchema<"ErrorResponse">;
582
+ /** @deprecated Use `Session`. */
583
+ type SessionInfo = Session;
584
+ /** @deprecated Use `Run`. */
585
+ type RunStatusResponse = Run;
586
+ /** @deprecated Use `NetworkRequest`. */
587
+ type RunNetworkRequest = NetworkRequest;
588
+ /** @deprecated Use `NetworkStatus`. */
589
+ type RunNetworkStatus = NetworkStatus;
590
+ /** @deprecated Use `InboundPortRequest`. */
591
+ type RunInboundPortRequest = InboundPortRequest;
592
+ /** @deprecated Use `Tunnel`. */
593
+ type RunTunnelStatus = Tunnel;
437
594
  interface CompletedRunResult {
438
595
  type: "completed";
439
- completed: true;
596
+ /** The run's own id. Present for executed runs; absent for operation acks. */
597
+ runId?: string;
598
+ /** Lifecycle state — "completed" or "failed". Mirrors the run-status (`Run`) shape. */
599
+ state: string;
440
600
  stdout: Uint8Array;
441
601
  stdoutEncoding: string;
442
602
  stderr: Uint8Array;
443
603
  stderrEncoding: string;
444
604
  exitCode: number;
605
+ /** System failure explanation when `state` is "failed". Distinct from
606
+ * `stderr` (the program's own error output); null otherwise. */
607
+ failReason?: string | null;
445
608
  }
446
609
  interface BackgroundRunResult {
447
610
  type: "background";
448
- completed: boolean;
449
611
  runId: string;
450
- tunnels: RunTunnelStatus[];
451
- network?: RunNetworkStatus | null;
612
+ /** Lifecycle state — "running". */
613
+ state: string;
614
+ tunnels: Tunnel[];
452
615
  }
453
- interface PtyRunResult {
454
- type: "pty";
455
- pty: true;
456
- sessionId: string;
457
- wsUrl: string;
458
- }
459
- type RunResult = CompletedRunResult | BackgroundRunResult | PtyRunResult;
460
- type RunStatusResponse = ApiSchema<"RunStatusResponse">;
461
- type CancelRunResponse = ApiSchema<"CancelRunResponse">;
462
- type CreateSessionRequest = ApiSchema<"CreateSessionRequest">;
463
- type ResizePtyRequest = ApiSchema<"ResizePtyRequest">;
464
- type ResizePtyResponse = ApiSchema<"ResizePtyResponse">;
465
- type ResizeRequest = ApiSchema<"ResizeRequest">;
466
- type ResizeResponse = ApiSchema<"ResizeResponse">;
467
- type SyncRequest = ApiSchema<"SyncRequest">;
468
- type SyncResponse = ApiSchema<"SyncResponse">;
469
- type SyncReadResponse = ApiSchema<"SyncReadResponse">;
470
- type SyncReadInlineResponse = ApiSchema<"SyncReadInlineResponse">;
471
- type SyncReadPresignedResponse = ApiSchema<"SyncReadPresignedResponse">;
472
- type SyncByteRange = ApiSchema<"SyncByteRange">;
473
- type ErrorResponse = ApiSchema<"ErrorResponse">;
474
- type SyncChunkWriteResult = ApiSchema<"SyncChunkWriteResult">;
475
- type SyncPresignedWriteRequestResult = ApiSchema<"SyncPresignedWriteRequestResult">;
476
- type SyncCommitWriteResult = ApiSchema<"SyncCommitWriteResult">;
477
- type SyncWriteResult = ApiSchema<"SyncWriteResult">;
478
- type SyncWriteResponse = ApiSchema<"SyncWriteResponse">;
616
+ type RunResult = CompletedRunResult | BackgroundRunResult;
479
617
  declare class ArkerError extends Error {
480
618
  readonly code: string;
481
619
  readonly status: number;
482
620
  constructor(code: string, message: string, status: number);
483
621
  }
622
+ /** Source for `Arker.fork()`. Exactly one of `sourceVmId` or
623
+ * `sourceVmName` must be set. When `sourceVmName` is set,
624
+ * `sourceOrgId` selects which org to look the name up in (defaults
625
+ * server-side to the caller's org; pass `ARKER_ORG_ID` to fork the
626
+ * public goldens like `"arkuntu"` / `"ubuntu"`).
627
+ *
628
+ * Distinct from the new VM's `name`, which is the *destination* name. */
629
+ interface ForkSource {
630
+ sourceVmId?: string;
631
+ sourceVmName?: string;
632
+ sourceOrgId?: string;
633
+ }
484
634
  declare class Arker {
635
+ /** Compute base URL for `provider` + `region` — used for fork/run/
636
+ * per-VM ops. SDK calls go straight to this host, skipping the CF
637
+ * Worker control plane. */
485
638
  readonly baseUrl: string;
639
+ /** Compute base URL for the burst provider in this region. */
486
640
  readonly burstBaseUrl?: string;
641
+ /** CF Worker control-plane URL — used for cross-cutting admin calls
642
+ * like list-VMs and filesystems. */
643
+ readonly controlBaseUrl: string;
487
644
  readonly region?: string;
645
+ readonly provider: "aws" | "aws-burst";
488
646
  private readonly apiKey;
489
647
  private readonly fetchImpl;
490
648
  private readonly retry;
491
649
  constructor(opts?: ArkerOptions);
492
- vm(vmId: string): Computer;
493
- goldens(): Promise<ListGoldensResponse>;
494
- list(): Promise<ListVmsResponse>;
495
- get(vmId: string): Promise<VmInfo>;
650
+ /**
651
+ * Address an existing VM. Doesn't make any network calls; returns a
652
+ * lightweight handle.
653
+ */
654
+ vm(vmId: string): VM;
655
+ /**
656
+ * Create a new VM by forking from a source.
657
+ *
658
+ * fork("ubuntu-full") // public golden by name
659
+ * fork("base") // a VM by name in your org
660
+ * fork(vm) // an existing VM (uses its id)
661
+ * fork({ sourceVmId: "vm_abc..." })
662
+ * fork({ sourceVmName: "base", sourceOrgId: "org_..." })
663
+ *
664
+ * The source can be a name string, a `VM` handle, or a `ForkSource`
665
+ * object. `sourceOrgId` defaults to the Arker org when `sourceVmName`
666
+ * is a known public golden, otherwise to your own org; an explicit
667
+ * value always wins, and it's irrelevant when forking by id. Forking a
668
+ * VM in another org requires that VM to be `public: true`. The new VM's
669
+ * name (in your org) is passed as `name`. When the source is a name or
670
+ * `VM`, extra fork options go in the second `opts` argument.
671
+ */
672
+ fork(source: string | VM | (ForkSource & Partial<Omit<ForkRequest, "source_vm_id" | "source_vm_name" | "source_org_id">>), opts?: Partial<Omit<ForkRequest, "source_vm_id" | "source_vm_name" | "source_org_id">>): Promise<VM>;
673
+ /**
674
+ * List VMs visible to the authenticated caller. **Admin call** —
675
+ * goes through the control plane (`controlBaseUrl`) so it can
676
+ * aggregate across providers and regions. Pass `?provider=` /
677
+ * `?region=` to narrow.
678
+ */
679
+ listVms(opts?: ListOpts & {
680
+ region?: string;
681
+ provider?: "aws" | "aws-burst";
682
+ state?: VmState;
683
+ sourceOrgId?: string;
684
+ startedAfter?: string;
685
+ startedBefore?: string;
686
+ }): Promise<{
687
+ vms: VM[];
688
+ nextCursor: string | null;
689
+ }>;
690
+ /** Compute call — goes direct to the backend hosting this VM (no
691
+ * control-plane hop). Returns a fully-populated VM handle. */
692
+ getVm(vmId: string): Promise<VM>;
693
+ listFilesystems(opts?: ListOpts & {
694
+ namePrefix?: string;
695
+ }): Promise<ListFilesystemsResponse>;
696
+ createFilesystem(request: {
697
+ name: string;
698
+ }): Promise<Filesystem>;
699
+ getFilesystem(filesystemId: string): Promise<Filesystem>;
700
+ deleteFilesystem(filesystemId: string): Promise<DeleteFilesystemResponse>;
496
701
  /** @internal */
497
702
  _request<T>(method: HttpMethod, path: string, body?: unknown, baseUrl?: string, extraHeaders?: Record<string, string | undefined>): Promise<T>;
498
703
  /** @internal */
@@ -504,30 +709,89 @@ declare class Arker {
504
709
  /** @internal */
505
710
  _baseUrlFor(ref: string): string;
506
711
  }
507
- declare class Computer {
712
+ interface ListOpts {
713
+ cursor?: string;
714
+ limit?: number;
715
+ }
716
+ declare class VM {
508
717
  readonly id: string;
509
718
  readonly baseUrl: string;
510
- readonly sync: Sync;
511
719
  /** @internal */
512
720
  readonly _client: Arker;
513
- constructor(client: Arker, vmId: string, baseUrl?: string);
514
- fork(request?: ForkOptions): Promise<Computer>;
721
+ readonly vm_id?: string;
722
+ readonly name?: string | null;
723
+ readonly state?: VmState;
724
+ readonly owner_org_id?: string;
725
+ readonly created_at?: string;
726
+ readonly public?: boolean;
727
+ readonly region?: string | null;
728
+ readonly provider?: string | null;
729
+ readonly vcpu_count?: number | null;
730
+ readonly memory_mib?: number | null;
731
+ readonly disk_mib?: number | null;
732
+ readonly started_at?: string | null;
733
+ readonly root_source_vm_id?: string | null;
734
+ readonly root_source_vm_name?: string | null;
735
+ readonly worker_id?: string | null;
736
+ readonly sessions?: Session[];
737
+ readonly tunnels?: Tunnel[];
738
+ constructor(client: Arker, vmId: string, baseUrl?: string, data?: Vm);
739
+ /** Re-fetch this VM and return a fresh, fully-populated handle. */
740
+ refresh(): Promise<VM>;
741
+ /**
742
+ * @deprecated Use `Arker.fork({ sourceVmId: this.id, ... })`.
743
+ * Kept for back-compat with older user code that called `.fork()` on
744
+ * a VM instance.
745
+ */
746
+ fork(request?: Partial<ForkRequest>): Promise<VM>;
515
747
  run(command: string, options?: RunOptions): Promise<RunResult>;
516
- runStatus(runId: string): Promise<RunStatusResponse>;
517
- cancelRun(runId: string): Promise<CancelRunResponse>;
518
- delete(): Promise<DeleteVmResponse>;
519
- }
520
- declare class Sync {
521
- /** @internal */
522
- readonly _vm: Computer;
523
- constructor(vm: Computer);
524
- readFile(path: string): Promise<Uint8Array>;
525
- writeFile(path: string, data: Uint8Array | string): Promise<void>;
526
- private path;
527
- private writeInline;
528
- private writePresigned;
748
+ /**
749
+ * Read or write a file in this VM over `POST /v1/vms/{id}/sync`.
750
+ * Omit `data` to read; pass `data` (string or bytes) to write. The
751
+ * client picks inline transfer for small files and presigned uploads
752
+ * for large ones automatically.
753
+ *
754
+ * const bytes = await vm.sync("/home/user/out.txt"); // read
755
+ * await vm.sync("/home/user/in.txt", "hello\n"); // write
756
+ *
757
+ * To mount a standalone filesystem into the VM, use `vm.syncs.create`.
758
+ */
759
+ sync(path: string): Promise<Uint8Array>;
760
+ sync(path: string, data: Uint8Array | string): Promise<void>;
761
+ private syncRead;
762
+ private syncWriteInline;
763
+ private syncWritePresigned;
529
764
  private putPresigned;
530
765
  private sendOneWrite;
766
+ resize(request: ResizeRequest): Promise<ResizeResponse>;
767
+ delete(): Promise<DeleteVmResponse>;
768
+ listSyncs(opts?: ListOpts & {
769
+ filesystemId?: string;
770
+ }): Promise<ListSyncsResponse>;
771
+ createSync(request: {
772
+ filesystemId: string;
773
+ path?: string;
774
+ }): Promise<Sync>;
775
+ deleteSync(syncId: string): Promise<DeleteSyncResponse>;
776
+ listRuns(opts?: ListOpts & {
777
+ state?: RunState;
778
+ startedAfter?: string;
779
+ startedBefore?: string;
780
+ completedAfter?: string;
781
+ }): Promise<ListRunsResponse>;
782
+ getRun(runId: string): Promise<Run>;
783
+ cancelRun(runId: string): Promise<CancelRunResponse>;
784
+ listSessions(opts?: ListOpts & {
785
+ state?: SessionState;
786
+ }): Promise<ListSessionsResponse>;
787
+ createSession(request?: CreateSessionRequest): Promise<Session>;
788
+ getSession(sessionId: string): Promise<Session>;
789
+ deleteSession(sessionId: string): Promise<DeleteSessionResponse>;
790
+ listTunnels(opts?: ListOpts & {
791
+ state?: TunnelState;
792
+ }): Promise<ListTunnelsResponse>;
793
+ getTunnel(port: number): Promise<Tunnel>;
794
+ deleteTunnel(port: number): Promise<DeleteTunnelResponse>;
531
795
  }
532
796
 
533
- export { Arker, ArkerError, type ArkerOptions, type BackgroundRunResponse, type BackgroundRunResult, CHUNK_SIZE, type CancelRunResponse, type CompletedRunResponse, type CompletedRunResult, Computer, type CreateSessionRequest, type DeleteSessionResponse, type DeleteVmResponse, type ErrorResponse, type ForkOptions, type ForkRequest, type ForkVmResponse, type GoldenInfo, type ListGoldensResponse, type ListSessionsResponse, type ListVmsResponse, type MountRequest, type NetworkPolicy, type NetworkPolicyInput, type PtyRunResponse, type PtyRunResult, type RawRunResponse, type ResizePtyRequest, type ResizePtyResponse, type ResizeRequest, type ResizeResponse, type RetryOptions, type RunInboundPortRequest, type RunNetworkRequest, type RunNetworkStatus, type RunOptions, type RunRequest, type RunResponse, type RunResult, type RunStatusResponse, type RunTunnelStatus, type SessionInfo, Sync, type SyncByteRange, type SyncChunkWriteResult, type SyncCommitWriteResult, type SyncPresignedWriteRequestResult, type SyncReadInlineResponse, type SyncReadPresignedResponse, type SyncReadResponse, type SyncRequest, type SyncResponse, type SyncWriteResponse, type SyncWriteResult, type VmInfo, type VmList, type VmSummary };
797
+ export { ARKER_ORG_ID, Arker, ArkerError, type ArkerOptions, type BackgroundRunResponse, type BackgroundRunResult, CHUNK_SIZE, type CancelRunResponse, type CompletedRunResponse, type CompletedRunResult, type CreateSessionRequest, type DeleteFilesystemResponse, type DeleteSessionResponse, type DeleteSyncResponse, type DeleteTunnelResponse, type DeleteVmResponse, type ErrorCode, type ErrorResponse, type Filesystem, type FilesystemCreateRequest, type ForkOptions, type ForkRequest, type ForkSource, type InboundPortRequest, type ListFilesystemsResponse, type ListOpts, type ListRunsResponse, type ListSessionsResponse, type ListSyncsResponse, type ListTunnelsResponse, type ListVmsResponse, type NetworkPolicy, type NetworkPolicyInput, type NetworkRequest, type NetworkStatus, type ResizeRequest, type ResizeResponse, type ResourceKind, type RetryOptions, type Run, type RunInboundPortRequest, type RunNetworkRequest, type RunNetworkStatus, type RunOptions, type RunRequest, type RunResponse, type RunResult, type RunState, type RunStatusResponse, type RunSummary, type RunTunnelStatus, type Session, type SessionInfo, type SessionState, type Sync, type SyncByteRange, type SyncChunkWriteResult, type SyncCommitWriteResult, type SyncCreateRequest, type SyncPresignedWriteRequestResult, type SyncReadInlineResponse, type SyncReadPresignedResponse, type SyncReadRequest, type SyncReadResponse, type SyncWriteRequest, type SyncWriteResponse, type SyncWriteResult, type Tunnel, type TunnelState, VM, type Vm, type VmState };