@slicervm/sdk 0.1.6 → 0.1.8

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.ts CHANGED
@@ -27,6 +27,15 @@ interface VMInfo {
27
27
  status?: string;
28
28
  persistent?: boolean;
29
29
  }
30
+ /**
31
+ * Per-launch network policy override for isolated host groups.
32
+ * Omitted lists inherit the host group's policy. Empty lists intentionally
33
+ * clear that list for this VM launch.
34
+ */
35
+ interface CreateVMNetworkPolicy {
36
+ allow?: string[];
37
+ drop?: string[];
38
+ }
30
39
  interface CreateVMRequest {
31
40
  ramBytes?: number;
32
41
  cpus?: number;
@@ -39,6 +48,7 @@ interface CreateVMRequest {
39
48
  ip?: string;
40
49
  tags?: string[];
41
50
  secrets?: string[];
51
+ network?: CreateVMNetworkPolicy;
42
52
  }
43
53
  interface CreateVMResponse {
44
54
  hostname: string;
@@ -53,6 +63,7 @@ interface AgentHealth {
53
63
  agentVersion?: string;
54
64
  systemUptime?: number;
55
65
  userdataRan?: boolean;
66
+ userdataExitCode?: number;
56
67
  }
57
68
  interface VMLogs {
58
69
  hostname: string;
@@ -267,6 +278,91 @@ interface FSWatchEvent {
267
278
  interface ShutdownRequest {
268
279
  action?: 'shutdown' | 'reboot';
269
280
  }
281
+ interface VMCommitOptions {
282
+ tags?: string[];
283
+ labels?: Record<string, string>;
284
+ cacheKey?: string;
285
+ }
286
+ interface VMCommitResponse {
287
+ hostname: string;
288
+ commitId: string;
289
+ status: string;
290
+ parentStatus?: string;
291
+ mode: string;
292
+ tags?: string[];
293
+ labels?: Record<string, string>;
294
+ cacheKey?: string;
295
+ }
296
+ interface VMCommitListOptions {
297
+ tags?: string[];
298
+ cacheKey?: string;
299
+ source?: string;
300
+ mode?: string;
301
+ }
302
+ interface VMCommitInfo {
303
+ commitId: string;
304
+ sourceHostname: string;
305
+ sourceHostGroup: string;
306
+ createdAt: string;
307
+ mode: string;
308
+ tags?: string[];
309
+ labels?: Record<string, string>;
310
+ cacheKey?: string;
311
+ }
312
+ interface VMCommitDeleteResponse {
313
+ commitId: string;
314
+ status: string;
315
+ }
316
+ /** Isolated-network policy override for a forked VM. */
317
+ interface VMForkNetworkPolicy {
318
+ /** Omit to inherit; pass an empty array to clear the allow list. */
319
+ allow?: string[];
320
+ /** Omit to inherit; pass an empty array to clear the drop list. */
321
+ drop?: string[];
322
+ }
323
+ interface VMForkOptions {
324
+ /** Agent-readiness timeout in seconds. Forks always wait for the child agent. */
325
+ waitTimeoutSec?: number;
326
+ network?: VMForkNetworkPolicy;
327
+ tags?: string[];
328
+ }
329
+ interface VMForkResponse {
330
+ hostname: string;
331
+ sourceHostname: string;
332
+ commitId?: string;
333
+ status: string;
334
+ parentStatus?: string;
335
+ childStatus?: string;
336
+ mode: string;
337
+ }
338
+ interface VMNetworkPolicy {
339
+ allow: string[];
340
+ drop: string[];
341
+ }
342
+ interface VMNetworkDescription {
343
+ mode?: string;
344
+ policySource?: string;
345
+ hostGroup: VMNetworkPolicy;
346
+ override?: CreateVMNetworkPolicy;
347
+ effective: VMNetworkPolicy;
348
+ }
349
+ interface VMDescription {
350
+ hostname: string;
351
+ hostGroup?: string;
352
+ ip?: string;
353
+ ramBytes?: number;
354
+ cpus?: number;
355
+ createdAt?: string;
356
+ arch?: string;
357
+ tags?: string[];
358
+ status?: string;
359
+ persistent?: boolean;
360
+ storage?: string;
361
+ image?: string;
362
+ commitId?: string;
363
+ parentCommitId?: string;
364
+ network: VMNetworkDescription;
365
+ }
270
366
  interface VMStat {
271
367
  hostname: string;
272
368
  ip: string;
@@ -534,6 +630,21 @@ interface VMInit {
534
630
  createdAt?: string;
535
631
  arch?: string;
536
632
  }
633
+ declare class CommittedVM {
634
+ private readonly transport;
635
+ readonly hostname: string;
636
+ readonly hostGroup: string;
637
+ readonly commitId: string;
638
+ readonly status: string;
639
+ readonly parentStatus?: string;
640
+ readonly mode: VMCommitResponse['mode'];
641
+ readonly tags?: string[];
642
+ readonly labels?: Record<string, string>;
643
+ readonly cacheKey?: string;
644
+ constructor(transport: TransportClient, hostGroup: string, response: VMCommitResponse);
645
+ fork(opts?: VMForkOptions): Promise<VM>;
646
+ forkRaw(opts?: VMForkOptions): Promise<VMForkResponse>;
647
+ }
537
648
  declare class VM {
538
649
  readonly hostname: string;
539
650
  readonly hostGroup: string;
@@ -547,6 +658,8 @@ declare class VM {
547
658
  delete(): Promise<void>;
548
659
  health(): Promise<AgentHealth>;
549
660
  logs(): Promise<VMLogs>;
661
+ /** Return configuration, fork lineage, and effective network policy. */
662
+ describe(): Promise<VMDescription>;
550
663
  waitForAgent(opts?: WaitOptions): Promise<AgentHealth>;
551
664
  waitForUserdata(opts?: WaitOptions): Promise<AgentHealth>;
552
665
  shutdown(req?: ShutdownRequest): Promise<void>;
@@ -557,6 +670,10 @@ declare class VM {
557
670
  suspend(): Promise<void>;
558
671
  /** Mac-only on current daemons. Throws `SlicerAPIError 404` on Linux. */
559
672
  restore(): Promise<void>;
673
+ /**
674
+ * Commit a stopped persistent VM disk into an immutable parent.
675
+ */
676
+ commit(opts?: VMCommitOptions): Promise<CommittedVM>;
560
677
  /**
561
678
  * Open one or more port forwards from the host to this VM. Each spec follows
562
679
  * the same syntax as `slicer vm forward -L`:
@@ -644,7 +761,7 @@ declare class VMBg {
644
761
  }
645
762
 
646
763
  /**
647
- * Top-level namespaces on SlicerClient: hostGroups, vms, secrets.
764
+ * Top-level namespaces on SlicerClient: hostGroups, vms, commits, secrets.
648
765
  * Keep control-plane operations here; per-VM operations live on the VM handle.
649
766
  */
650
767
 
@@ -676,6 +793,13 @@ declare class VMsAPI {
676
793
  */
677
794
  createRaw(hostGroup: string, req?: CreateVMRequest, opts?: CreateVMOptions): Promise<CreateVMResponse>;
678
795
  }
796
+ declare class CommitsAPI {
797
+ private readonly transport;
798
+ constructor(transport: TransportClient);
799
+ list(opts?: VMCommitListOptions): Promise<VMCommitInfo[]>;
800
+ delete(commitId: string): Promise<VMCommitDeleteResponse>;
801
+ fork(commitId: string, opts?: VMForkOptions): Promise<VMForkResponse>;
802
+ }
679
803
  declare class SecretsAPI {
680
804
  private readonly transport;
681
805
  constructor(transport: TransportClient);
@@ -685,18 +809,202 @@ declare class SecretsAPI {
685
809
  delete(name: string): Promise<void>;
686
810
  }
687
811
 
812
+ /**
813
+ * Slicer egress-proxy admin API.
814
+ *
815
+ * Three resources:
816
+ * - clients: opaque token holders. Each VM (or other consumer) presents
817
+ * the token via HTTPS_PROXY; the proxy resolves it to the client and
818
+ * walks the client's allow rules.
819
+ * - secrets: upstream credentials (bearer or basic). When an allow rule
820
+ * references a secret, the proxy strips the client's Authorization on
821
+ * the inner request and substitutes the secret's value.
822
+ * - allow rules: per-client. host (exact, *.suffix wildcard, or "*"),
823
+ * optional method/path filters, optional secret reference, optional
824
+ * TTL, optional `passthrough` (TCP-splice CONNECT, no MITM).
825
+ *
826
+ * Calls go through slicerd's `/proxy/v1/*` broker (the same transport
827
+ * SlicerClient already uses for every other API), so no extra
828
+ * configuration is needed beyond a working SlicerClient.
829
+ *
830
+ * Wire shapes mirror the Go SDK at github.com/slicervm/sdk/proxy.go.
831
+ * Field-name conversion (snake_case ↔ camelCase) is handled in the
832
+ * `*FromWire` / `*ToWire` helpers; user-facing types are camelCase.
833
+ */
834
+
835
+ /** Credential type for upstream injection. */
836
+ type ProxySecretType = 'bearer' | 'basic' | 'oauth-client-creds';
837
+ declare const ProxySecretBearer: ProxySecretType;
838
+ /** For basic auth, the secret value must be in `user:pass` form. */
839
+ declare const ProxySecretBasic: ProxySecretType;
840
+ /** OAuth 2.0 client credentials exchanged and renewed by the proxy host. */
841
+ declare const ProxySecretOAuthClientCredentials: ProxySecretType;
842
+ /** A registered proxy client. Tokens are never returned by list/get. */
843
+ interface ProxyClient {
844
+ name: string;
845
+ /** RFC 3339 timestamp. */
846
+ createdAt: string;
847
+ }
848
+ /**
849
+ * Returned only by `clients.create`. The token is shown once and never
850
+ * surfaced by any other endpoint — store it now or rotate the client.
851
+ */
852
+ interface ProxyClientCreated {
853
+ name: string;
854
+ token: string;
855
+ createdAt: string;
856
+ }
857
+ /**
858
+ * Optional input to `clients.create`. Pass `token` to bring your own
859
+ * literal (handy for demos and reproducible tests); omit for a
860
+ * server-minted high-entropy `spt_…` token (recommended).
861
+ */
862
+ interface CreateProxyClientOptions {
863
+ token?: string;
864
+ }
865
+ /** A registered upstream credential. `value` is never returned. */
866
+ interface ProxySecret {
867
+ name: string;
868
+ host: string;
869
+ /** Defaults to `bearer` when empty in older state files. */
870
+ type?: ProxySecretType;
871
+ createdAt: string;
872
+ }
873
+ interface CreateProxySecretRequest {
874
+ name: string;
875
+ host: string;
876
+ /** Defaults to `bearer` when omitted. */
877
+ type?: ProxySecretType;
878
+ /**
879
+ * Plaintext credential. For `bearer`, the raw token. For `basic`,
880
+ * must be in `user:pass` form (the proxy base64-encodes it on the
881
+ * inner request). For `oauth-client-creds`, pass top-level JSON containing
882
+ * `token_endpoint`, `client_id`, and `client_secret`; optional `scope` is
883
+ * supported. The proxy obtains, caches, and renews the bearer host-side.
884
+ */
885
+ value: string;
886
+ }
887
+ /**
888
+ * Per-client allow entry. First-match-wins by declaration order.
889
+ *
890
+ * - When `secret` is set, the proxy strips the client's Authorization
891
+ * on the inner request and substitutes the secret's value.
892
+ * - `methods`/`paths` are optional filters (any-of within each list,
893
+ * all-of across lists). Empty list = any.
894
+ * - When `passthrough` is true, the proxy splices TCP both ways at
895
+ * CONNECT without terminating TLS. Cert-pinned clients work
896
+ * unchanged. Mutually exclusive with `secret`, `methods`, `paths`;
897
+ * the admin API rejects rules that combine them.
898
+ */
899
+ interface ProxyAllowRule {
900
+ host: string;
901
+ secret?: string;
902
+ methods?: string[];
903
+ paths?: string[];
904
+ /** RFC 3339 timestamp; absent / zero-value when no expiry. */
905
+ expires?: string;
906
+ passthrough?: boolean;
907
+ }
908
+ /** Input to `allows.add`. */
909
+ interface AddProxyAllowRequest {
910
+ client: string;
911
+ host: string;
912
+ secret?: string;
913
+ methods?: string[];
914
+ paths?: string[];
915
+ /**
916
+ * Time-to-live in seconds. 0 / omitted = never expires. Resolved to
917
+ * an absolute `expires` timestamp on the returned rule.
918
+ */
919
+ ttlSeconds?: number;
920
+ /** See ProxyAllowRule.passthrough. Mutually exclusive with secret/methods/paths. */
921
+ passthrough?: boolean;
922
+ }
923
+ /**
924
+ * Input to `allows.removeByTuple`. Mirrors the create payload minus
925
+ * `ttlSeconds` (TTL is mutable lifetime, not part of identity). The
926
+ * proxy matches the rule by (host, methods, paths, passthrough) and
927
+ * removes the single matching rule. Use when several rules share a
928
+ * host and you want surgical removal of one — pass exactly the same
929
+ * fields you used at create time.
930
+ */
931
+ interface RemoveProxyAllowByTupleRequest {
932
+ client: string;
933
+ host: string;
934
+ secret?: string;
935
+ methods?: string[];
936
+ paths?: string[];
937
+ passthrough?: boolean;
938
+ }
939
+ declare class ProxyAPI {
940
+ private readonly transport;
941
+ readonly clients: ProxyClientsAPI;
942
+ readonly secrets: ProxySecretsAPI;
943
+ readonly allows: ProxyAllowsAPI;
944
+ constructor(transport: TransportClient);
945
+ }
946
+ declare class ProxyClientsAPI {
947
+ private readonly transport;
948
+ constructor(transport: TransportClient);
949
+ /** Mint a new proxy client. The returned token is shown once. */
950
+ create(name: string, opts?: CreateProxyClientOptions): Promise<ProxyClientCreated>;
951
+ list(): Promise<ProxyClient[]>;
952
+ /**
953
+ * Revoke the token, drop every allow rule the client owned, and
954
+ * remove the client.
955
+ */
956
+ delete(name: string): Promise<void>;
957
+ /** List a client's allow rules in declaration order (first-match-wins). */
958
+ rules(name: string): Promise<ProxyAllowRule[]>;
959
+ }
960
+ declare class ProxySecretsAPI {
961
+ private readonly transport;
962
+ constructor(transport: TransportClient);
963
+ create(req: CreateProxySecretRequest): Promise<void>;
964
+ list(): Promise<ProxySecret[]>;
965
+ /**
966
+ * Remove a secret. Allow rules that reference it stop matching until
967
+ * the secret is recreated or the rule is rewritten.
968
+ */
969
+ delete(name: string): Promise<void>;
970
+ }
971
+ declare class ProxyAllowsAPI {
972
+ private readonly transport;
973
+ constructor(transport: TransportClient);
974
+ /** Add an allow rule. Returns the resolved rule with absolute `expires`. */
975
+ add(req: AddProxyAllowRequest): Promise<ProxyAllowRule>;
976
+ /**
977
+ * Host-bulk revoke: removes **every** rule on the client whose host
978
+ * matches. For surgical removal of one rule among siblings on the
979
+ * same host (e.g. several path-scoped rules on `github.com`), use
980
+ * `removeByTuple` instead.
981
+ */
982
+ remove(client: string, host: string): Promise<void>;
983
+ /**
984
+ * Surgical revoke: removes the single rule whose
985
+ * (host, methods, paths, passthrough) tuple matches the request.
986
+ * Pass exactly the same fields you used at create time. Method and
987
+ * host casing are normalised server-side, so `"GET"` / `"get"` and
988
+ * `"github.com"` / `"GITHUB.COM"` all match the same stored rule.
989
+ *
990
+ * Returns 404 (surfaced as a SlicerAPIError) when no rule matches.
991
+ */
992
+ removeByTuple(req: RemoveProxyAllowByTupleRequest): Promise<void>;
993
+ }
994
+
688
995
  /**
689
996
  * SlicerClient — grouped TypeScript client for the Slicer VM API.
690
997
  *
691
998
  * Shape:
692
999
  * client.hostGroups.list() / find(name) / listVMs(name)
693
1000
  * client.vms.create(group, req, opts) → VM / get(name) / list() / stats() / attach(group, name)
1001
+ * client.commits.list() / fork(id) / delete(id)
694
1002
  * client.secrets.list / create / patch / delete
695
1003
  * client.getInfo()
696
1004
  *
697
1005
  * Per-VM operations live on the `VM` handle returned from `client.vms.create`
698
1006
  * or `client.vms.attach`: `vm.exec`, `vm.execBuffered`, `vm.fs.*`,
699
- * `vm.pause/resume/suspend/restore/shutdown/relaunch`, `vm.health/logs`,
1007
+ * `vm.pause/resume/suspend/restore/shutdown/relaunch`, `vm.commit/describe`, `vm.health/logs`,
700
1008
  * `vm.waitForAgent/waitForUserdata`, `vm.delete`.
701
1009
  */
702
1010
 
@@ -706,7 +1014,9 @@ declare class SlicerClient {
706
1014
  readonly transport: TransportClient;
707
1015
  readonly hostGroups: HostGroupsAPI;
708
1016
  readonly vms: VMsAPI;
1017
+ readonly commits: CommitsAPI;
709
1018
  readonly secrets: SecretsAPI;
1019
+ readonly proxy: ProxyAPI;
710
1020
  constructor(opts: SlicerClientOptions);
711
1021
  static fromEnv(overrides?: Partial<SlicerClientOptions>): SlicerClient;
712
1022
  getInfo(): Promise<SlicerInfo>;
@@ -778,4 +1088,4 @@ declare class SlicerShellSession {
778
1088
  private teardown;
779
1089
  }
780
1090
 
781
- export { type AddressMapping, type AgentHealth, type BgDeleteResponse, type BgExecInfo, type BgExecRequest, type BgExecResponse, type BgKillOptions, type BgKillResponse, type BgLogOptions, type BgWaitExitResponse, type CreateSecretRequest, type CreateVMOptions, type CreateVMRequest, type CreateVMResponse, type DeleteResponse, type ExecFrame, type ExecRequest, type ExecResult, type ExecResultBinary, type ExecStdio, ExecStdioBase64, ExecStdioText, FRAME_TYPE_DATA, FRAME_TYPE_HEARTBEAT, FRAME_TYPE_SESSION_CLOSE, FRAME_TYPE_SHUTDOWN, FRAME_TYPE_WINDOW_SIZE, type FSEntry, type FSMkdirRequest, type FSWatchEvent, type FSWatchEventType, type FSWatchRequest, Forwarder, type ForwarderListener, type ForwarderOptions, GiB, type HostGroup, HostGroupsAPI, type ListOptions, MiB, NonRootUser, type Secret, SecretExistsError, SecretsAPI, type ShellSessionOptions, type ShutdownRequest, SlicerAPIError, SlicerClient, type SlicerClientOptions, type SlicerInfo, SlicerShellSession, type UpdateSecretRequest, VM, VMBg, VMFileSystem, type VMInfo, type VMInit, type VMLogs, type VMSnapshot, type VMStat, VMsAPI, type WaitOptions, type XTermLike, encodeFrame, parseAddressMapping, parseFrame, resolveTransport };
1091
+ export { type AddProxyAllowRequest, type AddressMapping, type AgentHealth, type BgDeleteResponse, type BgExecInfo, type BgExecRequest, type BgExecResponse, type BgKillOptions, type BgKillResponse, type BgLogOptions, type BgWaitExitResponse, CommitsAPI, CommittedVM, type CreateProxyClientOptions, type CreateProxySecretRequest, type CreateSecretRequest, type CreateVMNetworkPolicy, type CreateVMOptions, type CreateVMRequest, type CreateVMResponse, type DeleteResponse, type ExecFrame, type ExecRequest, type ExecResult, type ExecResultBinary, type ExecStdio, ExecStdioBase64, ExecStdioText, FRAME_TYPE_DATA, FRAME_TYPE_HEARTBEAT, FRAME_TYPE_SESSION_CLOSE, FRAME_TYPE_SHUTDOWN, FRAME_TYPE_WINDOW_SIZE, type FSEntry, type FSMkdirRequest, type FSWatchEvent, type FSWatchEventType, type FSWatchRequest, Forwarder, type ForwarderListener, type ForwarderOptions, GiB, type HostGroup, HostGroupsAPI, type ListOptions, MiB, NonRootUser, ProxyAPI, type ProxyAllowRule, ProxyAllowsAPI, type ProxyClient, type ProxyClientCreated, ProxyClientsAPI, type ProxySecret, ProxySecretBasic, ProxySecretBearer, ProxySecretOAuthClientCredentials, type ProxySecretType, ProxySecretsAPI, type RemoveProxyAllowByTupleRequest, type Secret, SecretExistsError, SecretsAPI, type ShellSessionOptions, type ShutdownRequest, SlicerAPIError, SlicerClient, type SlicerClientOptions, type SlicerInfo, SlicerShellSession, type UpdateSecretRequest, VM, VMBg, type VMCommitDeleteResponse, type VMCommitInfo, type VMCommitListOptions, type VMCommitOptions, type VMCommitResponse, type VMDescription, VMFileSystem, type VMForkNetworkPolicy, type VMForkOptions, type VMForkResponse, type VMInfo, type VMInit, type VMLogs, type VMNetworkDescription, type VMNetworkPolicy, type VMSnapshot, type VMStat, VMsAPI, type WaitOptions, type XTermLike, encodeFrame, parseAddressMapping, parseFrame, resolveTransport };