@arker-ai/sdk 0.5.2 → 0.6.3

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
@@ -7,6 +7,7 @@ interface components {
7
7
  ErrorCode: "unsupported_operation" | "bad_request" | "unauthorized" | "forbidden" | "not_found" | "conflict" | "payload_too_large" | "not_implemented" | "resource_pressure" | "internal" | "unavailable" | "network_error";
8
8
  ErrorResponse: {
9
9
  code: components["schemas"]["ErrorCode"];
10
+ /** @description Human-readable, client-safe error message. For `code: "internal"`, this is intentionally generic; server logs retain the underlying cause. */
10
11
  message: string;
11
12
  };
12
13
  /**
@@ -26,34 +27,26 @@ interface components {
26
27
  * @enum {string}
27
28
  */
28
29
  RunState: "running" | "completed" | "failed" | "cancelled";
29
- /**
30
- * @description `starting` = backend is allocating the tunnel; `open` = accepting
31
- * connections; `closed` = torn down or never came up.
32
- * @enum {string}
33
- */
34
- TunnelState: "starting" | "open" | "closed";
35
30
  /** @enum {string} */
36
31
  ResourceKind: "cpu" | "memory" | "disk";
37
- NetworkPolicy: components["schemas"]["NetworkPolicyOpen"] | components["schemas"]["NetworkPolicyBlocked"] | components["schemas"]["NetworkPolicyAllow"] | components["schemas"]["NetworkPolicyBlock"];
38
- NetworkPolicyOpen: {
32
+ /** @description Outbound egress policy stored on the VM. */
33
+ NetworkPolicy: {
39
34
  /** @constant */
40
35
  type: "open";
41
- };
42
- NetworkPolicyBlocked: {
36
+ } | {
43
37
  /** @constant */
44
38
  type: "blocked";
45
- };
46
- NetworkPolicyAllow: {
39
+ } | {
47
40
  /** @constant */
48
41
  type: "allow";
49
42
  allow: string[];
50
- };
51
- NetworkPolicyBlock: {
43
+ } | {
52
44
  /** @constant */
53
45
  type: "block";
54
46
  block: string[];
55
47
  };
56
- NetworkPolicyInput: boolean | string | components["schemas"]["NetworkPolicy"];
48
+ /** @description Outbound egress policy input. `true`/`open` means unrestricted; `false`/`blocked`/`none` means deny all. */
49
+ NetworkPolicyInput: boolean | ("open" | "blocked" | "true" | "false" | "none") | components["schemas"]["NetworkPolicy"];
57
50
  ForkRequest: {
58
51
  /** @description Global VM identifier. Org is inferred from the row. */
59
52
  source_vm_id?: string | null;
@@ -65,16 +58,14 @@ interface components {
65
58
  name?: string | null;
66
59
  /** @description Make the new VM publicly forkable from other orgs. */
67
60
  public?: boolean | null;
68
- network?: components["schemas"]["NetworkPolicyInput"] | null;
69
- /** @default true */
70
- disk?: boolean;
71
- vcpu_count?: number | null;
72
- memory_mib?: number | null;
73
- max_memory_mib?: number | null;
74
- disk_mib?: number | null;
61
+ /** @description Inbound reachability and SSH authorized keys for the new VM. */
62
+ network?: components["schemas"]["NetworkInput"] | null;
63
+ /** @description Outbound egress policy for the new VM. Omit to inherit from the source VM, or default to open for image-created VMs with no source. */
64
+ egress?: components["schemas"]["NetworkPolicyInput"] | null;
65
+ disk?: boolean | null;
75
66
  durable?: boolean | null;
76
- /** @description Optional VM-scoped tunnel customization. Omitting it allocates an open any-port tunnel where supported. */
77
- tunnel?: components["schemas"]["TunnelRequest"] | null;
67
+ /** @description Resource shape for the new VM. */
68
+ resources?: components["schemas"]["VmResources"] | null;
78
69
  };
79
70
  Session: {
80
71
  session_id: string;
@@ -116,21 +107,25 @@ interface components {
116
107
  /** @enum {string|null} */
117
108
  provider?: "aws" | "aws-burst" | null;
118
109
  started_at?: string | null;
119
- vcpu_count?: number | null;
120
- memory_mib?: number | null;
121
- disk_mib?: number | null;
122
- /** @description Effective VM fork-time egress policy. */
123
- network?: components["schemas"]["NetworkPolicy"];
110
+ /** @description Inbound reachability settings for this VM. */
111
+ network: components["schemas"]["VmNetwork"];
112
+ /** @description Outbound egress policy for this VM. */
113
+ egress?: components["schemas"]["NetworkPolicy"] | null;
124
114
  /** @description Hard vCPU ceiling for a fork of this VM (KVM slot count). Requesting more fails the run. */
125
115
  max_vcpus?: number | null;
116
+ /** @description Smallest vCPU count accepted for this VM. */
117
+ min_vcpus?: number | null;
126
118
  /** @description Hard memory ceiling (MiB) a fork can hotplug up to. */
127
119
  max_memory_mib?: number | null;
128
120
  /** @description Non-hotpluggable base memory (MiB). */
129
121
  min_memory_mib?: number | null;
130
- /** @description Worker host that owns this VM. Used by routers to populate caches without a fresh PlanetScale lookup. */
131
- worker_id?: string | null;
122
+ /** @description Smallest disk size (MiB) accepted for this VM. `0` means nodisk. */
123
+ min_disk_mib?: number | null;
124
+ /** @description Largest disk size (MiB) accepted for this VM. `0` means nodisk. */
125
+ max_disk_mib?: number | null;
132
126
  sessions: components["schemas"]["Session"][];
133
- tunnels?: components["schemas"]["Tunnel"][];
127
+ /** @description Current VM resource allocation. */
128
+ resources: components["schemas"]["VmResources"];
134
129
  };
135
130
  ListVmsResponse: {
136
131
  vms: components["schemas"]["Vm"][];
@@ -203,6 +198,12 @@ interface components {
203
198
  stderr_encoding: string;
204
199
  exit_code: number;
205
200
  dispatch?: string | null;
201
+ /** @description ARK-107: requested total memory (MiB) when this run carried an explicit memory override. Absent when the run had no memory override. */
202
+ memory_requested_mib?: number | null;
203
+ /** @description ARK-107: achieved total memory (MiB) after the run's resize. Memory shrink is best-effort, so this can exceed memory_requested_mib when guest pages are pinned. Absent when the run had no memory override. */
204
+ memory_achieved_mib?: number | null;
205
+ /** @description ARK-107: true when the run's memory shrink was partial (achieved differs from requested beyond the virtio-mem block granularity). The command still ran at the achieved footprint (best-effort); this flags the gap instead of a silent success. Defaults false. */
206
+ memory_partial?: boolean;
206
207
  };
207
208
  BackgroundRunResponse: {
208
209
  run_id: string;
@@ -310,41 +311,6 @@ interface components {
310
311
  protocol: string;
311
312
  url?: string | null;
312
313
  };
313
- Tunnel: {
314
- /** @description The VM this tunnel belongs to. Always populated so flat tunnel listings work without restructuring. */
315
- vm_id: string;
316
- /** @description Unique-per-VM identifier. */
317
- port: number;
318
- /** @description The Run that opened this tunnel, if any. VM-scoped tunnels created at fork time or via `POST /vms/{id}/tunnels` have `run_id: null`. */
319
- run_id?: string | null;
320
- visibility: string;
321
- protocol: string;
322
- url?: string | null;
323
- state: components["schemas"]["TunnelState"];
324
- message?: string | null;
325
- started_at?: string | null;
326
- vm_name?: string | null;
327
- source_org_id?: string | null;
328
- region?: string | null;
329
- /** @enum {string|null} */
330
- provider?: "aws" | "aws-burst" | null;
331
- /** @description Recoverable tunnel identity embedded in URLs (`p{port}-{key}`). Not a secret. Present on VM-scoped tunnel responses. */
332
- tunnel_key?: string | null;
333
- /**
334
- * @description `open` or `authenticated` for VM-scoped tunnels.
335
- * @enum {string|null}
336
- */
337
- auth_mode?: "open" | "authenticated" | null;
338
- /** @description One-time bearer secret returned only when allocating an authenticated tunnel; never echoed on listings. */
339
- auth_token?: string | null;
340
- };
341
- ListTunnelsResponse: {
342
- tunnels: components["schemas"]["Tunnel"][];
343
- next_cursor?: string | null;
344
- };
345
- DeleteTunnelResponse: {
346
- deleted: boolean;
347
- };
348
314
  CancelRunResponse: {
349
315
  cancelled: boolean;
350
316
  };
@@ -354,14 +320,6 @@ interface components {
354
320
  } | null;
355
321
  cwd?: string | null;
356
322
  };
357
- ResizeRequest: {
358
- vcpu_count?: number | null;
359
- memory_mib?: number | null;
360
- disk_mib?: number | null;
361
- };
362
- ResizeResponse: {
363
- resized: boolean;
364
- };
365
323
  Sync: {
366
324
  sync_id: string;
367
325
  vm_id: string;
@@ -489,18 +447,31 @@ interface components {
489
447
  FilesystemCreateRequest: {
490
448
  name: string;
491
449
  };
492
- TunnelRequest: {
493
- /**
494
- * @description Allowed VM ports for this tunnel. Omitted, null, or empty means any port.
495
- * @default []
496
- */
497
- ports?: number[] | null;
498
- /**
499
- * @description `open` allows unauthenticated tunnel requests. `authenticated` returns a one-time bearer `auth_token` and requires it on tunnel requests.
500
- * @default open
501
- * @enum {string|null}
502
- */
503
- auth_mode?: "open" | "authenticated" | null;
450
+ VmResources: {
451
+ vcpu?: number | null;
452
+ memory_mib?: number | null;
453
+ disk_mib?: number | null;
454
+ };
455
+ NetworkInput: {
456
+ /** @description Enable inbound reachability for this VM. Defaults to false. */
457
+ reachable?: boolean | null;
458
+ /** @description OpenSSH public keys authorized for terminator auth and in-VM sshd injection. */
459
+ ssh_public_keys?: string[];
460
+ };
461
+ SshPublicKeyInfo: {
462
+ public_key: string;
463
+ fingerprint: string;
464
+ };
465
+ VmNetwork: {
466
+ reachable: boolean;
467
+ /** @description Stable per-VM hostname, present when reachable is true. */
468
+ hostname?: string | null;
469
+ /** @description Authorized SSH keys with fingerprints. Returned by GET /v1/vms/{id}; omitted from list responses when empty. */
470
+ ssh_public_keys?: components["schemas"]["SshPublicKeyInfo"][];
471
+ };
472
+ PatchVmRequest: {
473
+ resources?: components["schemas"]["VmResources"] | null;
474
+ network?: components["schemas"]["NetworkInput"] | null;
504
475
  };
505
476
  };
506
477
  responses: {
@@ -533,8 +504,6 @@ interface components {
533
504
  Cursor: string | null;
534
505
  /** @description Max items per page. Backend caps may apply. */
535
506
  Limit: number;
536
- /** @description Recoverable tunnel identity returned as `Tunnel.tunnel_key` and embedded in tunnel URLs. */
537
- TunnelKey: string;
538
507
  };
539
508
  requestBodies: never;
540
509
  headers: never;
@@ -559,7 +528,7 @@ declare const CHUNK_SIZE: number;
559
528
  */
560
529
  declare const ARKER_ORG_ID = "ArkerHQ";
561
530
  type FetchLike = typeof fetch;
562
- type HttpMethod = "GET" | "POST" | "DELETE";
531
+ type HttpMethod = "GET" | "POST" | "PATCH" | "DELETE";
563
532
  interface RetryOptions {
564
533
  attempts?: number;
565
534
  baseDelayMs?: number;
@@ -592,13 +561,15 @@ interface ArkerOptions {
592
561
  type VmState = ApiSchema<"VmState">;
593
562
  type SessionState = ApiSchema<"SessionState">;
594
563
  type RunState = ApiSchema<"RunState">;
595
- type TunnelState = ApiSchema<"TunnelState">;
596
564
  type ResourceKind = ApiSchema<"ResourceKind">;
597
565
  type ErrorCode = ApiSchema<"ErrorCode">;
598
566
  type NetworkPolicy = ApiSchema<"NetworkPolicy">;
599
567
  type NetworkPolicyInput = ApiSchema<"NetworkPolicyInput">;
600
568
  type ForkRequest = ApiSchema<"ForkRequest">;
601
569
  type ForkOptions = ForkRequest;
570
+ type VmResources = ApiSchema<"VmResources">;
571
+ type VmNetwork = ApiSchema<"VmNetwork">;
572
+ type NetworkInput = ApiSchema<"NetworkInput">;
602
573
  type Session = ApiSchema<"Session">;
603
574
  type Vm = ApiSchema<"Vm">;
604
575
  type ListVmsResponse = ApiSchema<"ListVmsResponse">;
@@ -634,10 +605,6 @@ type RunOptions = Partial<Omit<RunRequest, "command">> & {
634
605
  };
635
606
  type InboundPortRequest = ApiSchema<"InboundPortRequest">;
636
607
  type NetworkRequest = ApiSchema<"NetworkRequest">;
637
- type TunnelRequest = ApiSchema<"TunnelRequest">;
638
- type Tunnel = ApiSchema<"Tunnel">;
639
- type ListTunnelsResponse = ApiSchema<"ListTunnelsResponse">;
640
- type DeleteTunnelResponse = ApiSchema<"DeleteTunnelResponse">;
641
608
  type NetworkStatus = ApiSchema<"NetworkStatus">;
642
609
  type RunResponse = ApiSchema<"RunResponse">;
643
610
  type CompletedRunResponse = ApiSchema<"CompletedRunResponse">;
@@ -650,8 +617,7 @@ type ListOrgRunsResponse = ApiSchema<"ListOrgRunsResponse">;
650
617
  type RunListRow = OrgRunListRow;
651
618
  type CancelRunResponse = ApiSchema<"CancelRunResponse">;
652
619
  type CreateSessionRequest = ApiSchema<"CreateSessionRequest">;
653
- type ResizeRequest = ApiSchema<"ResizeRequest">;
654
- type ResizeResponse = ApiSchema<"ResizeResponse">;
620
+ type PatchVmRequest = ApiSchema<"PatchVmRequest">;
655
621
  type ErrorResponse = ApiSchema<"ErrorResponse">;
656
622
  /** @deprecated Use `Session`. */
657
623
  type SessionInfo = Session;
@@ -663,8 +629,6 @@ type RunNetworkRequest = NetworkRequest;
663
629
  type RunNetworkStatus = NetworkStatus;
664
630
  /** @deprecated Use `InboundPortRequest`. */
665
631
  type RunInboundPortRequest = InboundPortRequest;
666
- /** @deprecated Use `Tunnel`. */
667
- type RunTunnelStatus = Tunnel;
668
632
  interface CompletedRunResult {
669
633
  type: "completed";
670
634
  /** The run's own id. Present for executed runs; absent for operation acks. */
@@ -679,6 +643,12 @@ interface CompletedRunResult {
679
643
  /** System failure explanation when `state` is "failed". Distinct from
680
644
  * `stderr` (the program's own error output); null otherwise. */
681
645
  failReason?: string | null;
646
+ /** Requested total memory (MiB), present when the run carried a memory override. */
647
+ memoryRequestedMib?: number | null;
648
+ /** Achieved total memory (MiB) after the run's resize. */
649
+ memoryAchievedMib?: number | null;
650
+ /** True when the runtime could not reach the requested memory target exactly. */
651
+ memoryPartial?: boolean;
682
652
  }
683
653
  interface BackgroundRunResult {
684
654
  type: "background";
@@ -708,6 +678,56 @@ interface ListOrgRunsOptions {
708
678
  sort?: "when" | "status" | "path" | "total" | "queue" | "your_code" | "runtime";
709
679
  dir?: "asc" | "desc";
710
680
  }
681
+ type PtyInput = string | Uint8Array | ArrayBuffer;
682
+ interface PtyConnectOptions {
683
+ /** Existing session to attach. Omit to create a new session first. */
684
+ sessionId?: string;
685
+ cols?: number;
686
+ rows?: number;
687
+ command?: string;
688
+ /** Defaults to the backend's persistent detach semantics. */
689
+ persist?: boolean;
690
+ /**
691
+ * Auto-cancel the PTY run after this many seconds with no terminal I/O. When
692
+ * the window elapses the server completes the underlying run and DESTROYS the
693
+ * shell (not just a detach) — a reconnect to the same `sessionId` starts
694
+ * fresh. Unset (default) means no auto-cancel.
695
+ */
696
+ cancelTtlSecs?: number;
697
+ /** @internal Test/runtime override for browser-ticket vs Node-header auth. */
698
+ useTicket?: boolean;
699
+ /** @internal Test/runtime override for WebSocket construction. */
700
+ webSocketFactory?: PtyWebSocketFactory;
701
+ }
702
+ interface PtyCloseEvent {
703
+ code?: number;
704
+ reason?: string;
705
+ }
706
+ interface PtyConnection {
707
+ readonly sessionId: string;
708
+ readonly ready: Promise<void>;
709
+ onData(listener: (data: Uint8Array) => void): () => void;
710
+ onClose(listener: (event: PtyCloseEvent) => void): () => void;
711
+ onError(listener: (error: unknown) => void): () => void;
712
+ send(data: PtyInput): void;
713
+ resize(cols: number, rows: number): void;
714
+ kill(): void;
715
+ close(code?: number, reason?: string): void;
716
+ }
717
+ interface PtyWebSocketFactoryInit {
718
+ headers?: Record<string, string>;
719
+ }
720
+ type PtyWebSocketFactory = (url: string, init: PtyWebSocketFactoryInit) => PtyWebSocketLike | Promise<PtyWebSocketLike>;
721
+ interface PtyWebSocketLike {
722
+ binaryType?: string;
723
+ readyState?: number;
724
+ send(data: string | Uint8Array | ArrayBuffer): void;
725
+ close(code?: number, reason?: string): void;
726
+ addEventListener?: (type: string, listener: (event: unknown) => void) => void;
727
+ removeEventListener?: (type: string, listener: (event: unknown) => void) => void;
728
+ on?: (type: string, listener: (...args: unknown[]) => void) => void;
729
+ off?: (type: string, listener: (...args: unknown[]) => void) => void;
730
+ }
711
731
  declare class ArkerError extends Error {
712
732
  readonly code: string;
713
733
  readonly status: number;
@@ -806,6 +826,8 @@ declare class Arker {
806
826
  /** @internal */
807
827
  _retryDelay(attempt: number): number;
808
828
  /** @internal */
829
+ _authHeaders(): Record<string, string>;
830
+ /** @internal */
809
831
  _baseUrlFor(ref: string): string;
810
832
  }
811
833
  interface ListOpts {
@@ -837,7 +859,6 @@ declare class VM {
837
859
  readonly root_source_vm_name?: string | null;
838
860
  readonly worker_id?: string | null;
839
861
  readonly sessions?: Session[];
840
- readonly tunnels?: Tunnel[];
841
862
  constructor(client: Arker, vmId: string, baseUrl?: string, data?: Vm);
842
863
  /** Re-fetch this VM and return a fresh, fully-populated handle. */
843
864
  refresh(): Promise<VM>;
@@ -866,7 +887,15 @@ declare class VM {
866
887
  private syncWritePresigned;
867
888
  private putPresigned;
868
889
  private sendOneWrite;
869
- resize(request: ResizeRequest): Promise<ResizeResponse>;
890
+ /**
891
+ * Update this VM's resource allocation and/or network settings via
892
+ * `PATCH /v1/vms/{id}`. Returns the updated `Vm`.
893
+ *
894
+ * Accepts either a `PatchVmRequest` (`{ resources, network }`) or, for
895
+ * convenience, flat resource fields (`{ vcpu, memory_mib, disk_mib }`)
896
+ * which are folded into `resources`.
897
+ */
898
+ resize(request: PatchVmRequest | (VmResources & Pick<PatchVmRequest, "network">)): Promise<Vm>;
870
899
  delete(): Promise<DeleteVmResponse>;
871
900
  listSyncs(opts?: ListOpts & {
872
901
  filesystemId?: string;
@@ -890,12 +919,7 @@ declare class VM {
890
919
  createSession(request?: CreateSessionRequest): Promise<Session>;
891
920
  getSession(sessionId: string): Promise<Session>;
892
921
  deleteSession(sessionId: string): Promise<DeleteSessionResponse>;
893
- listTunnels(opts?: ListOpts & {
894
- state?: TunnelState;
895
- }): Promise<ListTunnelsResponse>;
896
- createTunnel(request?: TunnelRequest): Promise<Tunnel>;
897
- getTunnel(key: string): Promise<Tunnel>;
898
- deleteTunnel(key: string): Promise<DeleteTunnelResponse>;
922
+ connectPty(options?: PtyConnectOptions): Promise<PtyConnection>;
899
923
  }
900
924
 
901
- 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 ListOrgRunsOptions, type ListOrgRunsResponse, type ListRunsResponse, type ListSessionsResponse, type ListSyncsResponse, type ListTunnelsResponse, type ListVmsResponse, type NetworkPolicy, type NetworkPolicyInput, type NetworkRequest, type NetworkStatus, type OrgRunListRow, type ResizeRequest, type ResizeResponse, type ResourceKind, type RetryOptions, type Run, type RunInboundPortRequest, type RunListRow, 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 TunnelRequest, type TunnelState, VM, type Vm, type VmState };
925
+ 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 DeleteVmResponse, type ErrorCode, type ErrorResponse, type Filesystem, type FilesystemCreateRequest, type ForkOptions, type ForkRequest, type ForkSource, type InboundPortRequest, type ListFilesystemsResponse, type ListOpts, type ListOrgRunsOptions, type ListOrgRunsResponse, type ListRunsResponse, type ListSessionsResponse, type ListSyncsResponse, type ListVmsResponse, type NetworkInput, type NetworkPolicy, type NetworkPolicyInput, type NetworkRequest, type NetworkStatus, type OrgRunListRow, type PatchVmRequest, type PtyCloseEvent, type PtyConnectOptions, type PtyConnection, type PtyInput, type PtyWebSocketFactory, type ResourceKind, type RetryOptions, type Run, type RunInboundPortRequest, type RunListRow, type RunNetworkRequest, type RunNetworkStatus, type RunOptions, type RunRequest, type RunResponse, type RunResult, type RunState, type RunStatusResponse, type RunSummary, 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, VM, type Vm, type VmNetwork, type VmResources, type VmState };