@slicervm/sdk 0.1.5 → 0.1.7

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
@@ -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;
@@ -685,6 +695,185 @@ declare class SecretsAPI {
685
695
  delete(name: string): Promise<void>;
686
696
  }
687
697
 
698
+ /**
699
+ * Slicer egress-proxy admin API.
700
+ *
701
+ * Three resources:
702
+ * - clients: opaque token holders. Each VM (or other consumer) presents
703
+ * the token via HTTPS_PROXY; the proxy resolves it to the client and
704
+ * walks the client's allow rules.
705
+ * - secrets: upstream credentials (bearer or basic). When an allow rule
706
+ * references a secret, the proxy strips the client's Authorization on
707
+ * the inner request and substitutes the secret's value.
708
+ * - allow rules: per-client. host (exact, *.suffix wildcard, or "*"),
709
+ * optional method/path filters, optional secret reference, optional
710
+ * TTL, optional `passthrough` (TCP-splice CONNECT, no MITM).
711
+ *
712
+ * Calls go through slicerd's `/proxy/v1/*` broker (the same transport
713
+ * SlicerClient already uses for every other API), so no extra
714
+ * configuration is needed beyond a working SlicerClient.
715
+ *
716
+ * Wire shapes mirror the Go SDK at github.com/slicervm/sdk/proxy.go.
717
+ * Field-name conversion (snake_case ↔ camelCase) is handled in the
718
+ * `*FromWire` / `*ToWire` helpers; user-facing types are camelCase.
719
+ */
720
+
721
+ /** Credential type for upstream injection. */
722
+ type ProxySecretType = 'bearer' | 'basic';
723
+ declare const ProxySecretBearer: ProxySecretType;
724
+ /** For basic auth, the secret value must be in `user:pass` form. */
725
+ declare const ProxySecretBasic: ProxySecretType;
726
+ /** A registered proxy client. Tokens are never returned by list/get. */
727
+ interface ProxyClient {
728
+ name: string;
729
+ /** RFC 3339 timestamp. */
730
+ createdAt: string;
731
+ }
732
+ /**
733
+ * Returned only by `clients.create`. The token is shown once and never
734
+ * surfaced by any other endpoint — store it now or rotate the client.
735
+ */
736
+ interface ProxyClientCreated {
737
+ name: string;
738
+ token: string;
739
+ createdAt: string;
740
+ }
741
+ /**
742
+ * Optional input to `clients.create`. Pass `token` to bring your own
743
+ * literal (handy for demos and reproducible tests); omit for a
744
+ * server-minted high-entropy `spt_…` token (recommended).
745
+ */
746
+ interface CreateProxyClientOptions {
747
+ token?: string;
748
+ }
749
+ /** A registered upstream credential. `value` is never returned. */
750
+ interface ProxySecret {
751
+ name: string;
752
+ host: string;
753
+ /** Defaults to `bearer` when empty in older state files. */
754
+ type?: ProxySecretType;
755
+ createdAt: string;
756
+ }
757
+ interface CreateProxySecretRequest {
758
+ name: string;
759
+ host: string;
760
+ /** Defaults to `bearer` when omitted. */
761
+ type?: ProxySecretType;
762
+ /**
763
+ * Plaintext credential. For `bearer`, the raw token. For `basic`,
764
+ * must be in `user:pass` form (the proxy base64-encodes it on the
765
+ * inner request).
766
+ */
767
+ value: string;
768
+ }
769
+ /**
770
+ * Per-client allow entry. First-match-wins by declaration order.
771
+ *
772
+ * - When `secret` is set, the proxy strips the client's Authorization
773
+ * on the inner request and substitutes the secret's value.
774
+ * - `methods`/`paths` are optional filters (any-of within each list,
775
+ * all-of across lists). Empty list = any.
776
+ * - When `passthrough` is true, the proxy splices TCP both ways at
777
+ * CONNECT without terminating TLS. Cert-pinned clients work
778
+ * unchanged. Mutually exclusive with `secret`, `methods`, `paths`;
779
+ * the admin API rejects rules that combine them.
780
+ */
781
+ interface ProxyAllowRule {
782
+ host: string;
783
+ secret?: string;
784
+ methods?: string[];
785
+ paths?: string[];
786
+ /** RFC 3339 timestamp; absent / zero-value when no expiry. */
787
+ expires?: string;
788
+ passthrough?: boolean;
789
+ }
790
+ /** Input to `allows.add`. */
791
+ interface AddProxyAllowRequest {
792
+ client: string;
793
+ host: string;
794
+ secret?: string;
795
+ methods?: string[];
796
+ paths?: string[];
797
+ /**
798
+ * Time-to-live in seconds. 0 / omitted = never expires. Resolved to
799
+ * an absolute `expires` timestamp on the returned rule.
800
+ */
801
+ ttlSeconds?: number;
802
+ /** See ProxyAllowRule.passthrough. Mutually exclusive with secret/methods/paths. */
803
+ passthrough?: boolean;
804
+ }
805
+ /**
806
+ * Input to `allows.removeByTuple`. Mirrors the create payload minus
807
+ * `ttlSeconds` (TTL is mutable lifetime, not part of identity). The
808
+ * proxy matches the rule by (host, methods, paths, passthrough) and
809
+ * removes the single matching rule. Use when several rules share a
810
+ * host and you want surgical removal of one — pass exactly the same
811
+ * fields you used at create time.
812
+ */
813
+ interface RemoveProxyAllowByTupleRequest {
814
+ client: string;
815
+ host: string;
816
+ secret?: string;
817
+ methods?: string[];
818
+ paths?: string[];
819
+ passthrough?: boolean;
820
+ }
821
+ declare class ProxyAPI {
822
+ private readonly transport;
823
+ readonly clients: ProxyClientsAPI;
824
+ readonly secrets: ProxySecretsAPI;
825
+ readonly allows: ProxyAllowsAPI;
826
+ constructor(transport: TransportClient);
827
+ }
828
+ declare class ProxyClientsAPI {
829
+ private readonly transport;
830
+ constructor(transport: TransportClient);
831
+ /** Mint a new proxy client. The returned token is shown once. */
832
+ create(name: string, opts?: CreateProxyClientOptions): Promise<ProxyClientCreated>;
833
+ list(): Promise<ProxyClient[]>;
834
+ /**
835
+ * Revoke the token, drop every allow rule the client owned, and
836
+ * remove the client.
837
+ */
838
+ delete(name: string): Promise<void>;
839
+ /** List a client's allow rules in declaration order (first-match-wins). */
840
+ rules(name: string): Promise<ProxyAllowRule[]>;
841
+ }
842
+ declare class ProxySecretsAPI {
843
+ private readonly transport;
844
+ constructor(transport: TransportClient);
845
+ create(req: CreateProxySecretRequest): Promise<void>;
846
+ list(): Promise<ProxySecret[]>;
847
+ /**
848
+ * Remove a secret. Allow rules that reference it stop matching until
849
+ * the secret is recreated or the rule is rewritten.
850
+ */
851
+ delete(name: string): Promise<void>;
852
+ }
853
+ declare class ProxyAllowsAPI {
854
+ private readonly transport;
855
+ constructor(transport: TransportClient);
856
+ /** Add an allow rule. Returns the resolved rule with absolute `expires`. */
857
+ add(req: AddProxyAllowRequest): Promise<ProxyAllowRule>;
858
+ /**
859
+ * Host-bulk revoke: removes **every** rule on the client whose host
860
+ * matches. For surgical removal of one rule among siblings on the
861
+ * same host (e.g. several path-scoped rules on `github.com`), use
862
+ * `removeByTuple` instead.
863
+ */
864
+ remove(client: string, host: string): Promise<void>;
865
+ /**
866
+ * Surgical revoke: removes the single rule whose
867
+ * (host, methods, paths, passthrough) tuple matches the request.
868
+ * Pass exactly the same fields you used at create time. Method and
869
+ * host casing are normalised server-side, so `"GET"` / `"get"` and
870
+ * `"github.com"` / `"GITHUB.COM"` all match the same stored rule.
871
+ *
872
+ * Returns 404 (surfaced as a SlicerAPIError) when no rule matches.
873
+ */
874
+ removeByTuple(req: RemoveProxyAllowByTupleRequest): Promise<void>;
875
+ }
876
+
688
877
  /**
689
878
  * SlicerClient — grouped TypeScript client for the Slicer VM API.
690
879
  *
@@ -707,9 +896,76 @@ declare class SlicerClient {
707
896
  readonly hostGroups: HostGroupsAPI;
708
897
  readonly vms: VMsAPI;
709
898
  readonly secrets: SecretsAPI;
899
+ readonly proxy: ProxyAPI;
710
900
  constructor(opts: SlicerClientOptions);
711
901
  static fromEnv(overrides?: Partial<SlicerClientOptions>): SlicerClient;
712
902
  getInfo(): Promise<SlicerInfo>;
713
903
  }
714
904
 
715
- 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, 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 ShutdownRequest, SlicerAPIError, SlicerClient, type SlicerClientOptions, type SlicerInfo, type UpdateSecretRequest, VM, VMBg, VMFileSystem, type VMInfo, type VMInit, type VMLogs, type VMSnapshot, type VMStat, VMsAPI, type WaitOptions, parseAddressMapping, resolveTransport };
905
+ /**
906
+ * Browser-compatible shell adapter for Slicer VMs.
907
+ *
908
+ * Provides frame encode/decode helpers and a `SlicerShellSession` class that
909
+ * wires a standard browser WebSocket to an xterm.js Terminal instance using
910
+ * the Slicer binary shell protocol.
911
+ *
912
+ * This module intentionally avoids Node-only imports so it can be used in
913
+ * browser bundles.
914
+ */
915
+ declare const FRAME_TYPE_DATA = 1;
916
+ declare const FRAME_TYPE_WINDOW_SIZE = 2;
917
+ declare const FRAME_TYPE_SHUTDOWN = 3;
918
+ declare const FRAME_TYPE_HEARTBEAT = 4;
919
+ declare const FRAME_TYPE_SESSION_CLOSE = 5;
920
+ /** Encode a frame into the 5-byte-header binary protocol. */
921
+ declare function encodeFrame(frameType: number, payload?: Uint8Array): Uint8Array;
922
+ /** Parse a binary frame. Returns null if the data is malformed. */
923
+ declare function parseFrame(data: ArrayBuffer): {
924
+ frameType: number;
925
+ payload: Uint8Array;
926
+ } | null;
927
+ interface ShellSessionOptions {
928
+ /** WebSocket URL for the shell endpoint (ws:// or wss://). */
929
+ url: string;
930
+ /** Heartbeat interval in ms. Default 30000. */
931
+ heartbeatIntervalMs?: number;
932
+ /** Called when connection state changes. */
933
+ onStateChange?: (state: 'connecting' | 'connected' | 'disconnected') => void;
934
+ /** Called on error. */
935
+ onError?: (error: string) => void;
936
+ }
937
+ /**
938
+ * Minimal xterm.js Terminal interface — only the methods SlicerShellSession
939
+ * actually calls. Avoids requiring @xterm/xterm as a dependency.
940
+ */
941
+ interface XTermLike {
942
+ onData: (cb: (data: string) => void) => {
943
+ dispose: () => void;
944
+ };
945
+ write: (data: string) => void;
946
+ reset: () => void;
947
+ cols: number;
948
+ rows: number;
949
+ }
950
+ declare class SlicerShellSession {
951
+ private readonly terminal;
952
+ private readonly options;
953
+ private ws;
954
+ private heartbeatTimer;
955
+ private dataDisposable;
956
+ constructor(terminal: XTermLike, options: ShellSessionOptions);
957
+ /** True when the WebSocket is open and relaying. */
958
+ get connected(): boolean;
959
+ /** Open the WebSocket and begin relaying. */
960
+ connect(): void;
961
+ /** Send a graceful shutdown frame and close. */
962
+ disconnect(): void;
963
+ /** Send a window resize. Call this from FitAddon's onResize or a ResizeObserver. */
964
+ resize(cols: number, rows: number): void;
965
+ private sendResize;
966
+ private startHeartbeat;
967
+ private stopHeartbeat;
968
+ private teardown;
969
+ }
970
+
971
+ export { type AddProxyAllowRequest, type AddressMapping, type AgentHealth, type BgDeleteResponse, type BgExecInfo, type BgExecRequest, type BgExecResponse, type BgKillOptions, type BgKillResponse, type BgLogOptions, type BgWaitExitResponse, 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, type ProxySecretType, ProxySecretsAPI, type RemoveProxyAllowByTupleRequest, 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 };
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;
@@ -685,6 +695,185 @@ declare class SecretsAPI {
685
695
  delete(name: string): Promise<void>;
686
696
  }
687
697
 
698
+ /**
699
+ * Slicer egress-proxy admin API.
700
+ *
701
+ * Three resources:
702
+ * - clients: opaque token holders. Each VM (or other consumer) presents
703
+ * the token via HTTPS_PROXY; the proxy resolves it to the client and
704
+ * walks the client's allow rules.
705
+ * - secrets: upstream credentials (bearer or basic). When an allow rule
706
+ * references a secret, the proxy strips the client's Authorization on
707
+ * the inner request and substitutes the secret's value.
708
+ * - allow rules: per-client. host (exact, *.suffix wildcard, or "*"),
709
+ * optional method/path filters, optional secret reference, optional
710
+ * TTL, optional `passthrough` (TCP-splice CONNECT, no MITM).
711
+ *
712
+ * Calls go through slicerd's `/proxy/v1/*` broker (the same transport
713
+ * SlicerClient already uses for every other API), so no extra
714
+ * configuration is needed beyond a working SlicerClient.
715
+ *
716
+ * Wire shapes mirror the Go SDK at github.com/slicervm/sdk/proxy.go.
717
+ * Field-name conversion (snake_case ↔ camelCase) is handled in the
718
+ * `*FromWire` / `*ToWire` helpers; user-facing types are camelCase.
719
+ */
720
+
721
+ /** Credential type for upstream injection. */
722
+ type ProxySecretType = 'bearer' | 'basic';
723
+ declare const ProxySecretBearer: ProxySecretType;
724
+ /** For basic auth, the secret value must be in `user:pass` form. */
725
+ declare const ProxySecretBasic: ProxySecretType;
726
+ /** A registered proxy client. Tokens are never returned by list/get. */
727
+ interface ProxyClient {
728
+ name: string;
729
+ /** RFC 3339 timestamp. */
730
+ createdAt: string;
731
+ }
732
+ /**
733
+ * Returned only by `clients.create`. The token is shown once and never
734
+ * surfaced by any other endpoint — store it now or rotate the client.
735
+ */
736
+ interface ProxyClientCreated {
737
+ name: string;
738
+ token: string;
739
+ createdAt: string;
740
+ }
741
+ /**
742
+ * Optional input to `clients.create`. Pass `token` to bring your own
743
+ * literal (handy for demos and reproducible tests); omit for a
744
+ * server-minted high-entropy `spt_…` token (recommended).
745
+ */
746
+ interface CreateProxyClientOptions {
747
+ token?: string;
748
+ }
749
+ /** A registered upstream credential. `value` is never returned. */
750
+ interface ProxySecret {
751
+ name: string;
752
+ host: string;
753
+ /** Defaults to `bearer` when empty in older state files. */
754
+ type?: ProxySecretType;
755
+ createdAt: string;
756
+ }
757
+ interface CreateProxySecretRequest {
758
+ name: string;
759
+ host: string;
760
+ /** Defaults to `bearer` when omitted. */
761
+ type?: ProxySecretType;
762
+ /**
763
+ * Plaintext credential. For `bearer`, the raw token. For `basic`,
764
+ * must be in `user:pass` form (the proxy base64-encodes it on the
765
+ * inner request).
766
+ */
767
+ value: string;
768
+ }
769
+ /**
770
+ * Per-client allow entry. First-match-wins by declaration order.
771
+ *
772
+ * - When `secret` is set, the proxy strips the client's Authorization
773
+ * on the inner request and substitutes the secret's value.
774
+ * - `methods`/`paths` are optional filters (any-of within each list,
775
+ * all-of across lists). Empty list = any.
776
+ * - When `passthrough` is true, the proxy splices TCP both ways at
777
+ * CONNECT without terminating TLS. Cert-pinned clients work
778
+ * unchanged. Mutually exclusive with `secret`, `methods`, `paths`;
779
+ * the admin API rejects rules that combine them.
780
+ */
781
+ interface ProxyAllowRule {
782
+ host: string;
783
+ secret?: string;
784
+ methods?: string[];
785
+ paths?: string[];
786
+ /** RFC 3339 timestamp; absent / zero-value when no expiry. */
787
+ expires?: string;
788
+ passthrough?: boolean;
789
+ }
790
+ /** Input to `allows.add`. */
791
+ interface AddProxyAllowRequest {
792
+ client: string;
793
+ host: string;
794
+ secret?: string;
795
+ methods?: string[];
796
+ paths?: string[];
797
+ /**
798
+ * Time-to-live in seconds. 0 / omitted = never expires. Resolved to
799
+ * an absolute `expires` timestamp on the returned rule.
800
+ */
801
+ ttlSeconds?: number;
802
+ /** See ProxyAllowRule.passthrough. Mutually exclusive with secret/methods/paths. */
803
+ passthrough?: boolean;
804
+ }
805
+ /**
806
+ * Input to `allows.removeByTuple`. Mirrors the create payload minus
807
+ * `ttlSeconds` (TTL is mutable lifetime, not part of identity). The
808
+ * proxy matches the rule by (host, methods, paths, passthrough) and
809
+ * removes the single matching rule. Use when several rules share a
810
+ * host and you want surgical removal of one — pass exactly the same
811
+ * fields you used at create time.
812
+ */
813
+ interface RemoveProxyAllowByTupleRequest {
814
+ client: string;
815
+ host: string;
816
+ secret?: string;
817
+ methods?: string[];
818
+ paths?: string[];
819
+ passthrough?: boolean;
820
+ }
821
+ declare class ProxyAPI {
822
+ private readonly transport;
823
+ readonly clients: ProxyClientsAPI;
824
+ readonly secrets: ProxySecretsAPI;
825
+ readonly allows: ProxyAllowsAPI;
826
+ constructor(transport: TransportClient);
827
+ }
828
+ declare class ProxyClientsAPI {
829
+ private readonly transport;
830
+ constructor(transport: TransportClient);
831
+ /** Mint a new proxy client. The returned token is shown once. */
832
+ create(name: string, opts?: CreateProxyClientOptions): Promise<ProxyClientCreated>;
833
+ list(): Promise<ProxyClient[]>;
834
+ /**
835
+ * Revoke the token, drop every allow rule the client owned, and
836
+ * remove the client.
837
+ */
838
+ delete(name: string): Promise<void>;
839
+ /** List a client's allow rules in declaration order (first-match-wins). */
840
+ rules(name: string): Promise<ProxyAllowRule[]>;
841
+ }
842
+ declare class ProxySecretsAPI {
843
+ private readonly transport;
844
+ constructor(transport: TransportClient);
845
+ create(req: CreateProxySecretRequest): Promise<void>;
846
+ list(): Promise<ProxySecret[]>;
847
+ /**
848
+ * Remove a secret. Allow rules that reference it stop matching until
849
+ * the secret is recreated or the rule is rewritten.
850
+ */
851
+ delete(name: string): Promise<void>;
852
+ }
853
+ declare class ProxyAllowsAPI {
854
+ private readonly transport;
855
+ constructor(transport: TransportClient);
856
+ /** Add an allow rule. Returns the resolved rule with absolute `expires`. */
857
+ add(req: AddProxyAllowRequest): Promise<ProxyAllowRule>;
858
+ /**
859
+ * Host-bulk revoke: removes **every** rule on the client whose host
860
+ * matches. For surgical removal of one rule among siblings on the
861
+ * same host (e.g. several path-scoped rules on `github.com`), use
862
+ * `removeByTuple` instead.
863
+ */
864
+ remove(client: string, host: string): Promise<void>;
865
+ /**
866
+ * Surgical revoke: removes the single rule whose
867
+ * (host, methods, paths, passthrough) tuple matches the request.
868
+ * Pass exactly the same fields you used at create time. Method and
869
+ * host casing are normalised server-side, so `"GET"` / `"get"` and
870
+ * `"github.com"` / `"GITHUB.COM"` all match the same stored rule.
871
+ *
872
+ * Returns 404 (surfaced as a SlicerAPIError) when no rule matches.
873
+ */
874
+ removeByTuple(req: RemoveProxyAllowByTupleRequest): Promise<void>;
875
+ }
876
+
688
877
  /**
689
878
  * SlicerClient — grouped TypeScript client for the Slicer VM API.
690
879
  *
@@ -707,9 +896,76 @@ declare class SlicerClient {
707
896
  readonly hostGroups: HostGroupsAPI;
708
897
  readonly vms: VMsAPI;
709
898
  readonly secrets: SecretsAPI;
899
+ readonly proxy: ProxyAPI;
710
900
  constructor(opts: SlicerClientOptions);
711
901
  static fromEnv(overrides?: Partial<SlicerClientOptions>): SlicerClient;
712
902
  getInfo(): Promise<SlicerInfo>;
713
903
  }
714
904
 
715
- 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, 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 ShutdownRequest, SlicerAPIError, SlicerClient, type SlicerClientOptions, type SlicerInfo, type UpdateSecretRequest, VM, VMBg, VMFileSystem, type VMInfo, type VMInit, type VMLogs, type VMSnapshot, type VMStat, VMsAPI, type WaitOptions, parseAddressMapping, resolveTransport };
905
+ /**
906
+ * Browser-compatible shell adapter for Slicer VMs.
907
+ *
908
+ * Provides frame encode/decode helpers and a `SlicerShellSession` class that
909
+ * wires a standard browser WebSocket to an xterm.js Terminal instance using
910
+ * the Slicer binary shell protocol.
911
+ *
912
+ * This module intentionally avoids Node-only imports so it can be used in
913
+ * browser bundles.
914
+ */
915
+ declare const FRAME_TYPE_DATA = 1;
916
+ declare const FRAME_TYPE_WINDOW_SIZE = 2;
917
+ declare const FRAME_TYPE_SHUTDOWN = 3;
918
+ declare const FRAME_TYPE_HEARTBEAT = 4;
919
+ declare const FRAME_TYPE_SESSION_CLOSE = 5;
920
+ /** Encode a frame into the 5-byte-header binary protocol. */
921
+ declare function encodeFrame(frameType: number, payload?: Uint8Array): Uint8Array;
922
+ /** Parse a binary frame. Returns null if the data is malformed. */
923
+ declare function parseFrame(data: ArrayBuffer): {
924
+ frameType: number;
925
+ payload: Uint8Array;
926
+ } | null;
927
+ interface ShellSessionOptions {
928
+ /** WebSocket URL for the shell endpoint (ws:// or wss://). */
929
+ url: string;
930
+ /** Heartbeat interval in ms. Default 30000. */
931
+ heartbeatIntervalMs?: number;
932
+ /** Called when connection state changes. */
933
+ onStateChange?: (state: 'connecting' | 'connected' | 'disconnected') => void;
934
+ /** Called on error. */
935
+ onError?: (error: string) => void;
936
+ }
937
+ /**
938
+ * Minimal xterm.js Terminal interface — only the methods SlicerShellSession
939
+ * actually calls. Avoids requiring @xterm/xterm as a dependency.
940
+ */
941
+ interface XTermLike {
942
+ onData: (cb: (data: string) => void) => {
943
+ dispose: () => void;
944
+ };
945
+ write: (data: string) => void;
946
+ reset: () => void;
947
+ cols: number;
948
+ rows: number;
949
+ }
950
+ declare class SlicerShellSession {
951
+ private readonly terminal;
952
+ private readonly options;
953
+ private ws;
954
+ private heartbeatTimer;
955
+ private dataDisposable;
956
+ constructor(terminal: XTermLike, options: ShellSessionOptions);
957
+ /** True when the WebSocket is open and relaying. */
958
+ get connected(): boolean;
959
+ /** Open the WebSocket and begin relaying. */
960
+ connect(): void;
961
+ /** Send a graceful shutdown frame and close. */
962
+ disconnect(): void;
963
+ /** Send a window resize. Call this from FitAddon's onResize or a ResizeObserver. */
964
+ resize(cols: number, rows: number): void;
965
+ private sendResize;
966
+ private startHeartbeat;
967
+ private stopHeartbeat;
968
+ private teardown;
969
+ }
970
+
971
+ export { type AddProxyAllowRequest, type AddressMapping, type AgentHealth, type BgDeleteResponse, type BgExecInfo, type BgExecRequest, type BgExecResponse, type BgKillOptions, type BgKillResponse, type BgLogOptions, type BgWaitExitResponse, 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, type ProxySecretType, ProxySecretsAPI, type RemoveProxyAllowByTupleRequest, 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 };