@sailresearch/sdk 0.2.14

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.
Files changed (89) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +126 -0
  3. package/dist/app.d.ts +23 -0
  4. package/dist/app.d.ts.map +1 -0
  5. package/dist/app.js +40 -0
  6. package/dist/app.js.map +1 -0
  7. package/dist/client.d.ts +119 -0
  8. package/dist/client.d.ts.map +1 -0
  9. package/dist/client.js +291 -0
  10. package/dist/client.js.map +1 -0
  11. package/dist/config.d.ts +8 -0
  12. package/dist/config.d.ts.map +1 -0
  13. package/dist/config.js +15 -0
  14. package/dist/config.js.map +1 -0
  15. package/dist/default-client.d.ts +13 -0
  16. package/dist/default-client.d.ts.map +1 -0
  17. package/dist/default-client.js +22 -0
  18. package/dist/default-client.js.map +1 -0
  19. package/dist/errors.d.ts +88 -0
  20. package/dist/errors.d.ts.map +1 -0
  21. package/dist/errors.js +201 -0
  22. package/dist/errors.js.map +1 -0
  23. package/dist/exec-process.d.ts +56 -0
  24. package/dist/exec-process.d.ts.map +1 -0
  25. package/dist/exec-process.js +105 -0
  26. package/dist/exec-process.js.map +1 -0
  27. package/dist/exec-stream.d.ts +21 -0
  28. package/dist/exec-stream.d.ts.map +1 -0
  29. package/dist/exec-stream.js +47 -0
  30. package/dist/exec-stream.js.map +1 -0
  31. package/dist/file-stream.d.ts +41 -0
  32. package/dist/file-stream.d.ts.map +1 -0
  33. package/dist/file-stream.js +86 -0
  34. package/dist/file-stream.js.map +1 -0
  35. package/dist/image.d.ts +90 -0
  36. package/dist/image.d.ts.map +1 -0
  37. package/dist/image.js +193 -0
  38. package/dist/image.js.map +1 -0
  39. package/dist/index.d.ts +31 -0
  40. package/dist/index.d.ts.map +1 -0
  41. package/dist/index.js +55 -0
  42. package/dist/index.js.map +1 -0
  43. package/dist/native.d.ts +10 -0
  44. package/dist/native.d.ts.map +1 -0
  45. package/dist/native.js +24 -0
  46. package/dist/native.js.map +1 -0
  47. package/dist/sailbox.d.ts +210 -0
  48. package/dist/sailbox.d.ts.map +1 -0
  49. package/dist/sailbox.js +339 -0
  50. package/dist/sailbox.js.map +1 -0
  51. package/dist/ssh.d.ts +16 -0
  52. package/dist/ssh.d.ts.map +1 -0
  53. package/dist/ssh.js +3 -0
  54. package/dist/ssh.js.map +1 -0
  55. package/dist/types/config.d.ts +21 -0
  56. package/dist/types/config.d.ts.map +1 -0
  57. package/dist/types/config.js +4 -0
  58. package/dist/types/config.js.map +1 -0
  59. package/dist/types/exec.d.ts +41 -0
  60. package/dist/types/exec.d.ts.map +1 -0
  61. package/dist/types/exec.js +4 -0
  62. package/dist/types/exec.js.map +1 -0
  63. package/dist/types/image.d.ts +50 -0
  64. package/dist/types/image.d.ts.map +1 -0
  65. package/dist/types/image.js +12 -0
  66. package/dist/types/image.js.map +1 -0
  67. package/dist/types/listener.d.ts +38 -0
  68. package/dist/types/listener.d.ts.map +1 -0
  69. package/dist/types/listener.js +21 -0
  70. package/dist/types/listener.js.map +1 -0
  71. package/dist/types/sailbox.d.ts +62 -0
  72. package/dist/types/sailbox.d.ts.map +1 -0
  73. package/dist/types/sailbox.js +19 -0
  74. package/dist/types/sailbox.js.map +1 -0
  75. package/dist/util.d.ts +3 -0
  76. package/dist/util.d.ts.map +1 -0
  77. package/dist/util.js +10 -0
  78. package/dist/util.js.map +1 -0
  79. package/dist/validate.d.ts +35 -0
  80. package/dist/validate.d.ts.map +1 -0
  81. package/dist/validate.js +87 -0
  82. package/dist/validate.js.map +1 -0
  83. package/dist/volume.d.ts +42 -0
  84. package/dist/volume.d.ts.map +1 -0
  85. package/dist/volume.js +72 -0
  86. package/dist/volume.js.map +1 -0
  87. package/native/index.d.ts +733 -0
  88. package/native/index.js +601 -0
  89. package/package.json +77 -0
@@ -0,0 +1,41 @@
1
+ /** Exec types: streaming-session options and the authoritative result. */
2
+ import type * as native from "../native.js";
3
+ /** Options for running a command in a sailbox. The `cwd`/`background` shell
4
+ * conveniences apply to string commands and are implemented in the core. */
5
+ export type ExecOptions = native.ExecStartOptions;
6
+ /**
7
+ * The authoritative result of an exec.
8
+ *
9
+ * The buffered `stdout`/`stderr` here are a capped, drop-oldest tail (the
10
+ * server keeps a bounded ring). If you need the complete output of a
11
+ * large-output command, stream it live via {@link ExecProcess.stdout} /
12
+ * {@link ExecProcess.stderr} and consult the `*Truncated` / `*Complete` flags.
13
+ */
14
+ export type ExecResult = native.ExecResult;
15
+ /** Options for cancelling an exec. */
16
+ export interface CancelOptions {
17
+ /** Send SIGKILL instead of SIGINT. */
18
+ force?: boolean;
19
+ /** Budget in seconds for retrying the cancel against a waking/migrating box. */
20
+ retryTimeoutSeconds?: number;
21
+ }
22
+ /** Options for uploading a file. */
23
+ export interface WriteOptions {
24
+ /** Create missing parent directories. */
25
+ createParents?: boolean;
26
+ /** Unix mode bits for the written file. */
27
+ mode?: number;
28
+ }
29
+ /** Options for {@link Sailbox.shell}. */
30
+ export interface ShellOptions {
31
+ /** Login shell to run when no command is given (default: the guest's
32
+ * `$SHELL`, else `/bin/bash`). Ignored when a command is given. */
33
+ shell?: string;
34
+ /** `$TERM` for the remote pty (default: the local `$TERM`). */
35
+ term?: string;
36
+ /** Working directory for the session. */
37
+ cwd?: string;
38
+ /** Wall-clock limit for the session in seconds; omit for no limit. */
39
+ timeoutSeconds?: number;
40
+ }
41
+ //# sourceMappingURL=exec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exec.d.ts","sourceRoot":"","sources":["../../src/types/exec.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAE1E,OAAO,KAAK,KAAK,MAAM,MAAM,cAAc,CAAC;AAE5C;4EAC4E;AAC5E,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,gBAAgB,CAAC;AAElD;;;;;;;GAOG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;AAE3C,sCAAsC;AACtC,MAAM,WAAW,aAAa;IAC5B,sCAAsC;IACtC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,gFAAgF;IAChF,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,oCAAoC;AACpC,MAAM,WAAW,YAAY;IAC3B,yCAAyC;IACzC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,2CAA2C;IAC3C,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,yCAAyC;AACzC,MAAM,WAAW,YAAY;IAC3B;uEACmE;IACnE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+DAA+D;IAC/D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,yCAAyC;IACzC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,sEAAsE;IACtE,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB"}
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ /** Exec types: streaming-session options and the authoritative result. */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ //# sourceMappingURL=exec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exec.js","sourceRoot":"","sources":["../../src/types/exec.ts"],"names":[],"mappings":";AAAA,0EAA0E"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Typed image specification. The step payloads are generated from the native
3
+ * core; {@link ImageBuildStep} is narrowed to a union so a step is exactly one
4
+ * operation, which the plain generated shape (five optional fields) cannot
5
+ * express. The higher-level file-hashing DSL lives on {@link Image}; this is
6
+ * the spec the backend accepts. `addLocalFile`/`addLocalDir` steps reference
7
+ * already-uploaded content by sha256, so they are not usable standalone
8
+ * without a separate upload step.
9
+ */
10
+ import type * as native from "../native.js";
11
+ export type BaseImage = "debian" | "devbox";
12
+ export type ImageArchitecture = "amd64" | "arm64";
13
+ /** A set of packages to install (apt or pip). */
14
+ export type PackageInstall = native.PackageInstall;
15
+ /** A shell command to run during the build. */
16
+ export type RunCommand = native.RunCommand;
17
+ /** One local file copied into the image, referenced by content hash. */
18
+ export type AddLocalFile = native.AddLocalFile;
19
+ /** One file within an {@link AddLocalDir}. */
20
+ export type AddLocalDirFile = native.AddLocalDirFile;
21
+ /** A tree of local files copied into the image. */
22
+ export type AddLocalDir = native.AddLocalDir;
23
+ /** One build step: exactly one operation. */
24
+ export type ImageBuildStep = {
25
+ aptInstall: PackageInstall;
26
+ } | {
27
+ pipInstall: PackageInstall;
28
+ } | {
29
+ runCommand: RunCommand;
30
+ } | {
31
+ addLocalFile: AddLocalFile;
32
+ } | {
33
+ addLocalDir: AddLocalDir;
34
+ };
35
+ /** A sailbox image: a base image plus ordered build steps. */
36
+ export interface ImageSpec extends Omit<native.ImageSpec, "base" | "buildSteps" | "architecture"> {
37
+ /** Base image to build on. */
38
+ base?: BaseImage;
39
+ /** Ordered build steps applied on top of the base image. */
40
+ buildSteps?: ImageBuildStep[];
41
+ /** Target CPU architecture; unset lets the backend choose. */
42
+ architecture?: ImageArchitecture;
43
+ }
44
+ /** The status of a custom image build. */
45
+ export type ImageBuildStatus = "unspecified" | "queued" | "building" | "ready" | "failed";
46
+ /** The state of a custom image build. */
47
+ export interface ImageBuild extends Omit<native.ImageBuild, "status"> {
48
+ status: ImageBuildStatus;
49
+ }
50
+ //# sourceMappingURL=image.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../src/types/image.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,KAAK,MAAM,MAAM,cAAc,CAAC;AAG5C,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAE5C,MAAM,MAAM,iBAAiB,GAAG,OAAO,GAAG,OAAO,CAAC;AAElD,iDAAiD;AACjD,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,cAAc,CAAC;AAEnD,+CAA+C;AAC/C,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;AAE3C,wEAAwE;AACxE,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,YAAY,CAAC;AAE/C,8CAA8C;AAC9C,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,eAAe,CAAC;AAErD,mDAAmD;AACnD,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;AAE7C,6CAA6C;AAC7C,MAAM,MAAM,cAAc,GACtB;IAAE,UAAU,EAAE,cAAc,CAAA;CAAE,GAC9B;IAAE,UAAU,EAAE,cAAc,CAAA;CAAE,GAC9B;IAAE,UAAU,EAAE,UAAU,CAAA;CAAE,GAC1B;IAAE,YAAY,EAAE,YAAY,CAAA;CAAE,GAC9B;IAAE,WAAW,EAAE,WAAW,CAAA;CAAE,CAAC;AAEjC,8DAA8D;AAC9D,MAAM,WAAW,SAAU,SAAQ,IAAI,CACrC,MAAM,CAAC,SAAS,EAChB,MAAM,GAAG,YAAY,GAAG,cAAc,CACvC;IACC,8BAA8B;IAC9B,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,4DAA4D;IAC5D,UAAU,CAAC,EAAE,cAAc,EAAE,CAAC;IAC9B,8DAA8D;IAC9D,YAAY,CAAC,EAAE,iBAAiB,CAAC;CAClC;AAED,0CAA0C;AAC1C,MAAM,MAAM,gBAAgB,GACxB,aAAa,GACb,QAAQ,GACR,UAAU,GACV,OAAO,GACP,QAAQ,CAAC;AAEb,yCAAyC;AACzC,MAAM,WAAW,UAAW,SAAQ,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,QAAQ,CAAC;IACnE,MAAM,EAAE,gBAAgB,CAAC;CAC1B"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ /**
3
+ * Typed image specification. The step payloads are generated from the native
4
+ * core; {@link ImageBuildStep} is narrowed to a union so a step is exactly one
5
+ * operation, which the plain generated shape (five optional fields) cannot
6
+ * express. The higher-level file-hashing DSL lives on {@link Image}; this is
7
+ * the spec the backend accepts. `addLocalFile`/`addLocalDir` steps reference
8
+ * already-uploaded content by sha256, so they are not usable standalone
9
+ * without a separate upload step.
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ //# sourceMappingURL=image.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image.js","sourceRoot":"","sources":["../../src/types/image.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG"}
@@ -0,0 +1,38 @@
1
+ /** Ingress listener types, generated from the native core and narrowed here. */
2
+ import type * as native from "../native.js";
3
+ /** The protocol you request when exposing a port. */
4
+ export type IngressProtocol = "tcp" | "http";
5
+ /** The protocol reported on a listener (open: tolerates unknown values). */
6
+ export type Protocol = "tcp" | "http" | (string & {});
7
+ /** Status of a listener's ingress route (open: tolerates unknown values). */
8
+ export type ListenerRouteStatus = "unspecified" | "pending" | "active" | "restoring" | "unavailable" | (string & {});
9
+ /** The routable HTTPS address of an `http` listener. */
10
+ export interface HttpEndpoint {
11
+ kind: "http";
12
+ /** The HTTPS URL to reach the guest service. */
13
+ url: string;
14
+ }
15
+ /** The address to dial for a `tcp` listener. */
16
+ export interface TcpEndpoint {
17
+ kind: "tcp";
18
+ /** Hostname to dial. */
19
+ host: string;
20
+ /** Port to dial. */
21
+ port: number;
22
+ }
23
+ /** How to reach an exposed listener; discriminate on `kind`. */
24
+ export type ListenerEndpoint = HttpEndpoint | TcpEndpoint;
25
+ /** An exposed guest port and how to reach it. */
26
+ export interface Listener {
27
+ /** The in-guest port traffic is forwarded to. */
28
+ guestPort: number;
29
+ /** Wire protocol exposed. */
30
+ protocol: Protocol;
31
+ /** Status of the listener's ingress route. */
32
+ routeStatus: ListenerRouteStatus;
33
+ /** How to reach the port; `undefined` until the listener is routable. */
34
+ endpoint?: ListenerEndpoint;
35
+ }
36
+ /** Map a native listener (flat public fields) to the typed shape. */
37
+ export declare function toListener(listener: native.Listener): Listener;
38
+ //# sourceMappingURL=listener.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"listener.d.ts","sourceRoot":"","sources":["../../src/types/listener.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAEhF,OAAO,KAAK,KAAK,MAAM,MAAM,cAAc,CAAC;AAE5C,qDAAqD;AACrD,MAAM,MAAM,eAAe,GAAG,KAAK,GAAG,MAAM,CAAC;AAE7C,4EAA4E;AAC5E,MAAM,MAAM,QAAQ,GAAG,KAAK,GAAG,MAAM,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAEtD,6EAA6E;AAC7E,MAAM,MAAM,mBAAmB,GAC3B,aAAa,GACb,SAAS,GACT,QAAQ,GACR,WAAW,GACX,aAAa,GACb,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAElB,wDAAwD;AACxD,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,gDAAgD;IAChD,GAAG,EAAE,MAAM,CAAC;CACb;AAED,gDAAgD;AAChD,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,KAAK,CAAC;IACZ,wBAAwB;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,oBAAoB;IACpB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,gEAAgE;AAChE,MAAM,MAAM,gBAAgB,GAAG,YAAY,GAAG,WAAW,CAAC;AAE1D,iDAAiD;AACjD,MAAM,WAAW,QAAQ;IACvB,iDAAiD;IACjD,SAAS,EAAE,MAAM,CAAC;IAClB,6BAA6B;IAC7B,QAAQ,EAAE,QAAQ,CAAC;IACnB,8CAA8C;IAC9C,WAAW,EAAE,mBAAmB,CAAC;IACjC,yEAAyE;IACzE,QAAQ,CAAC,EAAE,gBAAgB,CAAC;CAC7B;AAED,qEAAqE;AACrE,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,GAAG,QAAQ,CAW9D"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ /** Ingress listener types, generated from the native core and narrowed here. */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.toListener = toListener;
5
+ /** Map a native listener (flat public fields) to the typed shape. */
6
+ function toListener(listener) {
7
+ return {
8
+ guestPort: listener.guestPort,
9
+ protocol: listener.protocol,
10
+ routeStatus: listener.routeStatus,
11
+ endpoint: toEndpoint(listener.publicUrl, listener.publicHost, listener.publicPort),
12
+ };
13
+ }
14
+ function toEndpoint(url, host, port) {
15
+ if (url)
16
+ return { kind: "http", url };
17
+ if (host && port)
18
+ return { kind: "tcp", host, port };
19
+ return undefined;
20
+ }
21
+ //# sourceMappingURL=listener.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"listener.js","sourceRoot":"","sources":["../../src/types/listener.ts"],"names":[],"mappings":";AAAA,gFAAgF;;AAmDhF,gCAWC;AAZD,qEAAqE;AACrE,SAAgB,UAAU,CAAC,QAAyB;IAClD,OAAO;QACL,SAAS,EAAE,QAAQ,CAAC,SAAS;QAC7B,QAAQ,EAAE,QAAQ,CAAC,QAAQ;QAC3B,WAAW,EAAE,QAAQ,CAAC,WAAW;QACjC,QAAQ,EAAE,UAAU,CAClB,QAAQ,CAAC,SAAS,EAClB,QAAQ,CAAC,UAAU,EACnB,QAAQ,CAAC,UAAU,CACpB;KACF,CAAC;AACJ,CAAC;AAED,SAAS,UAAU,CACjB,GAA8B,EAC9B,IAA+B,EAC/B,IAA+B;IAE/B,IAAI,GAAG;QAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC;IACtC,IAAI,IAAI,IAAI,IAAI;QAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IACrD,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Sailbox API types. The interfaces are generated from the native core (field
3
+ * names, optionality, and docs come from the bridge), re-exported here with
4
+ * server-controlled strings narrowed to open string-literal unions: they
5
+ * autocomplete the known values but tolerate ones added server-side.
6
+ */
7
+ import type * as native from "../native.js";
8
+ import type { ImageSpec } from "./image.js";
9
+ import type { IngressProtocol } from "./listener.js";
10
+ /** Lifecycle status of a sailbox. Open: tolerates values added server-side. */
11
+ export type SailboxStatus = "running" | "paused" | "sleeping" | "failed" | "terminated" | (string & {});
12
+ /** The closed set of statuses accepted as a list filter. */
13
+ export type SailboxStatusFilter = "running" | "paused" | "sleeping" | "failed" | "terminated";
14
+ /** Returned by create / resume / fromCheckpoint: carries the live exec endpoint. */
15
+ export interface SailboxHandle extends Omit<native.SailboxHandle, "status"> {
16
+ status: SailboxStatus;
17
+ }
18
+ /** A read snapshot of a sailbox (get / list). Timestamps are RFC 3339 strings. */
19
+ export interface SailboxInfo extends Omit<native.SailboxInfo, "status"> {
20
+ status: SailboxStatus;
21
+ }
22
+ /** One page of list results plus the pagination envelope. */
23
+ export interface SailboxInfoPage extends Omit<native.SailboxInfoPage, "items"> {
24
+ items: SailboxInfo[];
25
+ }
26
+ /** A durable checkpoint handle. */
27
+ export interface SailboxCheckpoint extends Omit<native.SailboxCheckpoint, "status" | "expiresAt"> {
28
+ status: SailboxStatus;
29
+ /** When the handle becomes eligible for garbage collection, if bounded. */
30
+ expiresAt?: Date;
31
+ }
32
+ /** Map a native checkpoint (RFC 3339 expiry) to the typed shape. */
33
+ export declare function toCheckpoint(checkpoint: native.SailboxCheckpoint): SailboxCheckpoint;
34
+ /** The outcome of an in-guest agent upgrade. */
35
+ export interface UpgradeResult extends Omit<native.UpgradeResult, "status"> {
36
+ status: SailboxStatus;
37
+ }
38
+ /** A guest port to reserve for ingress at create time. */
39
+ export interface IngressPortInput extends Omit<native.IngressPortInput, "protocol"> {
40
+ /** `http` or `tcp`. */
41
+ protocol: IngressProtocol;
42
+ }
43
+ /** An NFS volume to mount at create time. */
44
+ export type VolumeMountInput = native.VolumeMountInput;
45
+ /** Named resource size; each sets the vCPU count plus default memory/disk. */
46
+ export type SailboxSize = "s" | "m";
47
+ export interface CreateSailboxRequest extends Omit<native.CreateSailboxRequest, "image" | "ingressPorts" | "size"> {
48
+ /** Image to boot; defaults to a plain Debian base when omitted. */
49
+ image?: ImageSpec;
50
+ /** Guest ports to reserve for ingress. */
51
+ ingressPorts?: IngressPortInput[];
52
+ /** Resource size ("m" is the platform default when omitted). */
53
+ size?: SailboxSize;
54
+ }
55
+ /** Filters for listing sailboxes. */
56
+ export interface ListSailboxesQuery extends Omit<native.ListSailboxesQuery, "status"> {
57
+ /** Filter by lifecycle status. */
58
+ status?: SailboxStatusFilter;
59
+ }
60
+ /** Options for creating a sailbox from a checkpoint. */
61
+ export type FromCheckpointRequest = native.FromCheckpointRequest;
62
+ //# sourceMappingURL=sailbox.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sailbox.d.ts","sourceRoot":"","sources":["../../src/types/sailbox.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,KAAK,MAAM,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAErD,+EAA+E;AAC/E,MAAM,MAAM,aAAa,GACrB,SAAS,GACT,QAAQ,GACR,UAAU,GACV,QAAQ,GACR,YAAY,GACZ,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAElB,4DAA4D;AAC5D,MAAM,MAAM,mBAAmB,GAC3B,SAAS,GACT,QAAQ,GACR,UAAU,GACV,QAAQ,GACR,YAAY,CAAC;AAEjB,oFAAoF;AACpF,MAAM,WAAW,aAAc,SAAQ,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,QAAQ,CAAC;IACzE,MAAM,EAAE,aAAa,CAAC;CACvB;AAED,kFAAkF;AAClF,MAAM,WAAW,WAAY,SAAQ,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,QAAQ,CAAC;IACrE,MAAM,EAAE,aAAa,CAAC;CACvB;AAED,6DAA6D;AAC7D,MAAM,WAAW,eAAgB,SAAQ,IAAI,CAAC,MAAM,CAAC,eAAe,EAAE,OAAO,CAAC;IAC5E,KAAK,EAAE,WAAW,EAAE,CAAC;CACtB;AAED,mCAAmC;AACnC,MAAM,WAAW,iB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
3
+ * Sailbox API types. The interfaces are generated from the native core (field
4
+ * names, optionality, and docs come from the bridge), re-exported here with
5
+ * server-controlled strings narrowed to open string-literal unions: they
6
+ * autocomplete the known values but tolerate ones added server-side.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.toCheckpoint = toCheckpoint;
10
+ /** Map a native checkpoint (RFC 3339 expiry) to the typed shape. */
11
+ function toCheckpoint(checkpoint) {
12
+ return {
13
+ ...checkpoint,
14
+ expiresAt: checkpoint.expiresAt
15
+ ? new Date(checkpoint.expiresAt)
16
+ : undefined,
17
+ };
18
+ }
19
+ //# sourceMappingURL=sailbox.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sailbox.js","sourceRoot":"","sources":["../../src/types/sailbox.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAiDH,oCASC;AAVD,oEAAoE;AACpE,SAAgB,YAAY,CAC1B,UAAoC;IAEpC,OAAO;QACL,GAAG,UAAU;QACb,SAAS,EAAE,UAAU,CAAC,SAAS;YAC7B,CAAC,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC;YAChC,CAAC,CAAC,SAAS;KACd,CAAC;AACJ,CAAC"}
package/dist/util.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ /** Coerce accepted byte inputs to a Buffer (a string is encoded as UTF-8). */
2
+ export declare function toBuffer(data: Buffer | Uint8Array | string): Buffer;
3
+ //# sourceMappingURL=util.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,MAAM,GAAG,MAAM,CAGnE"}
package/dist/util.js ADDED
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toBuffer = toBuffer;
4
+ /** Coerce accepted byte inputs to a Buffer (a string is encoded as UTF-8). */
5
+ function toBuffer(data) {
6
+ if (typeof data === "string")
7
+ return Buffer.from(data);
8
+ return Buffer.isBuffer(data) ? data : Buffer.from(data);
9
+ }
10
+ //# sourceMappingURL=util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";;AACA,4BAGC;AAJD,8EAA8E;AAC9E,SAAgB,QAAQ,CAAC,IAAkC;IACzD,IAAI,OAAO,IAAI,KAAK,QAAQ;QAAE,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACvD,OAAO,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1D,CAAC"}
@@ -0,0 +1,35 @@
1
+ import type { IngressPortInput, VolumeMountInput } from "./types/sailbox.js";
2
+ /**
3
+ * Validate the numeric create options are whole numbers (so `NaN`/`Infinity`/
4
+ * fractionals fail loudly instead of silently crossing the boundary and
5
+ * falling back to platform defaults) and that autosleep is in range. Shared by
6
+ * the high-level `Sailbox.create` preflight and the low-level
7
+ * `Client.createSailbox`.
8
+ */
9
+ export declare function validateCreateNumbers(req: {
10
+ size?: string;
11
+ autosleepTimeoutMinutes?: number;
12
+ memoryGib?: number;
13
+ diskGib?: number;
14
+ }): void;
15
+ /**
16
+ * Validate a create timeout: finite and non-negative, where `0` disables the
17
+ * client-side bound. Anything else (negative, `NaN`, `Infinity`) fails loudly:
18
+ * the native bridge would otherwise treat it as "no timeout" and let a
19
+ * miscomputed value hang create through capacity/boot instead of failing fast.
20
+ */
21
+ export declare function validateCreateTimeout(timeoutSeconds?: number): void;
22
+ /** Reject a `NaN` retry budget: it would cross the native boundary and be
23
+ * treated as an unbounded budget, turning a transient outage into
24
+ * retry-forever instead of failing fast. (`Infinity` stays allowed: retrying
25
+ * forever on purpose is a supported choice.) */
26
+ export declare function validateRetryBudget(retryTimeoutSeconds?: number): void;
27
+ /**
28
+ * Validate ingress ports against the core's reserved/duplicate/protocol/
29
+ * allowlist rules (the shared source of truth across the Sail SDKs), so create
30
+ * fails fast before a custom-image build.
31
+ */
32
+ export declare function validateIngressPorts(ports?: IngressPortInput[]): void;
33
+ /** Validate volume mounts against the core's path/overlap rules. */
34
+ export declare function validateVolumeMounts(mounts?: VolumeMountInput[]): void;
35
+ //# sourceMappingURL=validate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE7E;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE;IACzC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,GAAG,IAAI,CA+BP;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CASnE;AAED;;;gDAGgD;AAChD,wBAAgB,mBAAmB,CAAC,mBAAmB,CAAC,EAAE,MAAM,GAAG,IAAI,CAItE;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,CAAC,EAAE,gBAAgB,EAAE,GAAG,IAAI,CAgBrE;AAED,oEAAoE;AACpE,wBAAgB,oBAAoB,CAAC,MAAM,CAAC,EAAE,gBAAgB,EAAE,GAAG,IAAI,CAGtE"}
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateCreateNumbers = validateCreateNumbers;
4
+ exports.validateCreateTimeout = validateCreateTimeout;
5
+ exports.validateRetryBudget = validateRetryBudget;
6
+ exports.validateIngressPorts = validateIngressPorts;
7
+ exports.validateVolumeMounts = validateVolumeMounts;
8
+ const native_js_1 = require("./native.js");
9
+ const errors_js_1 = require("./errors.js");
10
+ /**
11
+ * Validate the numeric create options are whole numbers (so `NaN`/`Infinity`/
12
+ * fractionals fail loudly instead of silently crossing the boundary and
13
+ * falling back to platform defaults) and that autosleep is in range. Shared by
14
+ * the high-level `Sailbox.create` preflight and the low-level
15
+ * `Client.createSailbox`.
16
+ */
17
+ function validateCreateNumbers(req) {
18
+ // A value past u32 would coerce at the native boundary (2**32 + 64 becomes
19
+ // 64) and create a differently sized box than the caller asked for, so
20
+ // bound it here; the core's ladder check then enforces the real range.
21
+ for (const [field, value] of [
22
+ ["memoryGib", req.memoryGib],
23
+ ["diskGib", req.diskGib],
24
+ ]) {
25
+ if (value !== undefined &&
26
+ (!Number.isInteger(value) || value <= 0 || value > 0xffffffff)) {
27
+ throw new errors_js_1.InvalidArgumentError(`${field} must be a positive integer`);
28
+ }
29
+ }
30
+ // The shared core range check runs here too, so create fails fast before
31
+ // an image build rather than after it.
32
+ (0, errors_js_1.guardSync)(() => (0, native_js_1.validateSizeLimits)(req.size, req.memoryGib, req.diskGib));
33
+ if (req.autosleepTimeoutMinutes !== undefined &&
34
+ !Number.isInteger(req.autosleepTimeoutMinutes)) {
35
+ throw new errors_js_1.InvalidArgumentError("autosleepTimeoutMinutes must be an integer");
36
+ }
37
+ // The shared core range check (1..1440) runs here too, so create fails
38
+ // fast before an image build rather than after it.
39
+ (0, errors_js_1.guardSync)(() => (0, native_js_1.validateAutosleepTimeout)(req.autosleepTimeoutMinutes));
40
+ }
41
+ /**
42
+ * Validate a create timeout: finite and non-negative, where `0` disables the
43
+ * client-side bound. Anything else (negative, `NaN`, `Infinity`) fails loudly:
44
+ * the native bridge would otherwise treat it as "no timeout" and let a
45
+ * miscomputed value hang create through capacity/boot instead of failing fast.
46
+ */
47
+ function validateCreateTimeout(timeoutSeconds) {
48
+ if (timeoutSeconds !== undefined &&
49
+ (!Number.isFinite(timeoutSeconds) || timeoutSeconds < 0)) {
50
+ throw new errors_js_1.InvalidArgumentError("timeoutSeconds must be a non-negative number (0 disables the timeout)");
51
+ }
52
+ }
53
+ /** Reject a `NaN` retry budget: it would cross the native boundary and be
54
+ * treated as an unbounded budget, turning a transient outage into
55
+ * retry-forever instead of failing fast. (`Infinity` stays allowed: retrying
56
+ * forever on purpose is a supported choice.) */
57
+ function validateRetryBudget(retryTimeoutSeconds) {
58
+ if (Number.isNaN(retryTimeoutSeconds)) {
59
+ throw new errors_js_1.InvalidArgumentError("retryTimeoutSeconds must not be NaN");
60
+ }
61
+ }
62
+ /**
63
+ * Validate ingress ports against the core's reserved/duplicate/protocol/
64
+ * allowlist rules (the shared source of truth across the Sail SDKs), so create
65
+ * fails fast before a custom-image build.
66
+ */
67
+ function validateIngressPorts(ports) {
68
+ if (!ports?.length)
69
+ return;
70
+ // A fractional or out-of-range port would coerce at the native u32 boundary
71
+ // and validate (then create) a different port than the caller wrote.
72
+ for (const port of ports) {
73
+ if (!Number.isInteger(port.guestPort) ||
74
+ port.guestPort < 1 ||
75
+ port.guestPort > 65535) {
76
+ throw new errors_js_1.InvalidArgumentError("guestPort must be an integer between 1 and 65535");
77
+ }
78
+ }
79
+ (0, errors_js_1.guardSync)(() => (0, native_js_1.validateIngressPorts)(ports));
80
+ }
81
+ /** Validate volume mounts against the core's path/overlap rules. */
82
+ function validateVolumeMounts(mounts) {
83
+ if (!mounts?.length)
84
+ return;
85
+ (0, errors_js_1.guardSync)(() => (0, native_js_1.validateVolumeMounts)(mounts));
86
+ }
87
+ //# sourceMappingURL=validate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.js","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":";;AAgBA,sDAoCC;AAQD,sDASC;AAMD,kDAIC;AAOD,oDAgBC;AAGD,oDAGC;AA5GD,2CAKqB;AACrB,2CAA8D;AAG9D;;;;;;GAMG;AACH,SAAgB,qBAAqB,CAAC,GAKrC;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gB,mBAAmB,CAAC,mBAA4B;IAC9D,IAAI,MAAM,CAAC,KAAK,CAAC,mBAAmB,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,gCAAoB,CAAC,qCAAqC,CAAC,CAAC;IACxE,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,SAAgB,oBAAoB,CAAC,KAA0B;IAC7D,IAAI,CAAC,KAAK,EAAE,MAAM;QAAE,OAAO;IAC3B,4EAA4E;IAC5E,qEAAqE;IACrE,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IACE,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC;YACjC,IAAI,CAAC,SAAS,GAAG,CAAC;YAClB,IAAI,CAAC,SAAS,GAAG,KAAK,EACtB,CAAC;YACD,MAAM,IAAI,gCAAoB,CAC5B,kDAAkD,CACnD,CAAC;QACJ,CAAC;IACH,CAAC;IACD,IAAA,qBAAS,EAAC,GAAG,EAAE,CAAC,IAAA,gCAA0B,EAAC,KAAK,CAAC,CAAC,CAAC;AACrD,CAAC;AAED,oEAAoE;AACpE,SAAgB,oBAAoB,CAAC,MAA2B;IAC9D,IAAI,CAAC,MAAM,EAAE,MAAM;QAAE,OAAO;IAC5B,IAAA,qBAAS,EAAC,GAAG,EAAE,CAAC,IAAA,gCAA0B,EAAC,MAAM,CAAC,CAAC,CAAC;AACtD,CAAC"}
@@ -0,0 +1,42 @@
1
+ import type { ClientOptions } from "./types/config.js";
2
+ /**
3
+ * A managed NFS volume that can be mounted into sailboxes. Look one up (or
4
+ * mint it) with {@link Volume.find}, then pass it (or its {@link Volume.id})
5
+ * in a sailbox's `volumes` mapping.
6
+ */
7
+ export declare class Volume {
8
+ private readonly client;
9
+ /** Stable volume id. */
10
+ readonly id: string;
11
+ /** Volume name. */
12
+ readonly name: string;
13
+ /** Storage backend serving the volume. */
14
+ readonly backend: string;
15
+ /** Lifecycle status. */
16
+ readonly status: string;
17
+ /** Creation time, if reported. */
18
+ readonly createdAt: Date | null;
19
+ /** Last-update time, if reported. */
20
+ readonly updatedAt: Date | null;
21
+ /** Guest mount path, when loaded via {@link Volume.fromMount}. */
22
+ readonly mountPath: string | null;
23
+ private constructor();
24
+ /** Guest-side: load the volume handle for a path mounted into this
25
+ * sailbox (reads the mount's metadata; only available inside a guest). */
26
+ static fromMount(path: string): Volume;
27
+ private static from;
28
+ /** Look up an NFS volume by name, optionally minting it if missing. */
29
+ static find(name: string, options?: ClientOptions & {
30
+ mintIfMissing?: boolean;
31
+ }): Promise<Volume>;
32
+ /** List NFS volumes in the current org. */
33
+ static list(options?: ClientOptions & {
34
+ maxObjects?: number;
35
+ }): Promise<Volume[]>;
36
+ /** Delete this volume. Resolves `true` if it was deleted, `false` if it was
37
+ * already gone (only possible with `allowMissing`). */
38
+ delete(options?: {
39
+ allowMissing?: boolean;
40
+ }): Promise<boolean>;
41
+ }
42
+ //# sourceMappingURL=volume.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"volume.d.ts","sourceRoot":"","sources":["../src/volume.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD;;;;GAIG;AACH,qBAAa,MAAM;IAEf,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,wBAAwB;IACxB,QAAQ,CAAC,EAAE,EAAE,MAAM;IACnB,mBAAmB;IACnB,QAAQ,CAAC,IAAI,EAAE,MAAM;IACrB,0CAA0C;IAC1C,QAAQ,CAAC,OAAO,EAAE,MAAM;IACxB,wBAAwB;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM;IACvB,kCAAkC;IAClC,QAAQ,CAAC,SAAS,EAAE,IAAI,GAAG,IAAI;IAC/B,qCAAqC;IACrC,QAAQ,CAAC,SAAS,EAAE,IAAI,GAAG,IAAI;IAC/B,kEAAkE;IAClE,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAfnC,OAAO;IAkBP;8EAC0E;IAC1E,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAKtC,OAAO,CAAC,MAAM,CAAC,IAAI;IAiBnB,uEAAuE;WAC1D,IAAI,CACf,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,aAAa,GAAG;QAAE,aAAa,CAAC,EAAE,OAAO,CAAA;KAAO,GACxD,OAAO,CAAC,MAAM,CAAC;IAQlB,2CAA2C;WAC9B,IAAI,CACf,OAAO,GAAE,aAAa,GAAG;QAAE,UAAU,CAAC,EAAE,MAAM,CAAA;KAAO,GACpD,OAAO,CAAC,MAAM,EAAE,CAAC;IAOpB;2DACuD;IACjD,MAAM,CAAC,OAAO,GAAE;QAAE,YAAY,CAAC,EAAE,OAAO,CAAA;KAAO,GAAG,OAAO,CAAC,OAAO,CAAC;CAOzE"}
package/dist/volume.js ADDED
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Volume = void 0;
4
+ const default_client_js_1 = require("./default-client.js");
5
+ const native_js_1 = require("./native.js");
6
+ const errors_js_1 = require("./errors.js");
7
+ /**
8
+ * A managed NFS volume that can be mounted into sailboxes. Look one up (or
9
+ * mint it) with {@link Volume.find}, then pass it (or its {@link Volume.id})
10
+ * in a sailbox's `volumes` mapping.
11
+ */
12
+ class Volume {
13
+ client;
14
+ id;
15
+ name;
16
+ backend;
17
+ status;
18
+ createdAt;
19
+ updatedAt;
20
+ mountPath;
21
+ constructor(client,
22
+ /** Stable volume id. */
23
+ id,
24
+ /** Volume name. */
25
+ name,
26
+ /** Storage backend serving the volume. */
27
+ backend,
28
+ /** Lifecycle status. */
29
+ status,
30
+ /** Creation time, if reported. */
31
+ createdAt,
32
+ /** Last-update time, if reported. */
33
+ updatedAt,
34
+ /** Guest mount path, when loaded via {@link Volume.fromMount}. */
35
+ mountPath = null) {
36
+ this.client = client;
37
+ this.id = id;
38
+ this.name = name;
39
+ this.backend = backend;
40
+ this.status = status;
41
+ this.createdAt = createdAt;
42
+ this.updatedAt = updatedAt;
43
+ this.mountPath = mountPath;
44
+ }
45
+ /** Guest-side: load the volume handle for a path mounted into this
46
+ * sailbox (reads the mount's metadata; only available inside a guest). */
47
+ static fromMount(path) {
48
+ const data = (0, errors_js_1.guardSync)(() => (0, native_js_1.volumeFromMount)(path));
49
+ return Volume.from(undefined, data, path);
50
+ }
51
+ static from(client, data, mountPath = null) {
52
+ return new Volume(client, data.volumeId, data.name, data.backend, data.status, data.createdAt ? new Date(data.createdAt) : null, data.updatedAt ? new Date(data.updatedAt) : null, mountPath);
53
+ }
54
+ /** Look up an NFS volume by name, optionally minting it if missing. */
55
+ static async find(name, options = {}) {
56
+ const client = options.client ?? (0, default_client_js_1.defaultClient)();
57
+ return Volume.from(client, await client.getVolume(name, options.mintIfMissing ?? false));
58
+ }
59
+ /** List NFS volumes in the current org. */
60
+ static async list(options = {}) {
61
+ const client = options.client ?? (0, default_client_js_1.defaultClient)();
62
+ return (await client.listVolumes(options.maxObjects)).map((data) => Volume.from(client, data));
63
+ }
64
+ /** Delete this volume. Resolves `true` if it was deleted, `false` if it was
65
+ * already gone (only possible with `allowMissing`). */
66
+ async delete(options = {}) {
67
+ const result = await (this.client ?? (0, default_client_js_1.defaultClient)()).deleteVolume(this.id, options.allowMissing ?? false);
68
+ return result !== null;
69
+ }
70
+ }
71
+ exports.Volume = Volume;
72
+ //# sourceMappingURL=volume.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"volume.js","sourceRoot":"","sources":["../src/volume.ts"],"names":[],"mappings":";;;AACA,2DAAoD;AACpD,2CAGqB;AACrB,2CAAwC;AAIxC;;;;GAIG;AACH,MAAa,MAAM;IAEE;IAER;IAEA;IAEA;IAEA;IAEA;IAEA;IAEA;IAfX,YACmB,MAA0B;IAC3C,wBAAwB;IACf,EAAU;IACnB,mBAAmB;IACV,IAAY;IACrB,0CAA0C;IACjC,OAAe;IACxB,wBAAwB;IACf,MAAc;IACvB,kCAAkC;IACzB,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