@alchemy.run/archil 0.0.0 → 2.0.0-beta.87
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/LICENSE +201 -0
- package/README.md +57 -4
- package/lib/AWS/S3Disk.d.ts +68 -0
- package/lib/AWS/S3Disk.d.ts.map +1 -0
- package/lib/AWS/S3Disk.js +100 -0
- package/lib/AWS/S3Disk.js.map +1 -0
- package/lib/AWS/index.d.ts +2 -0
- package/lib/AWS/index.d.ts.map +1 -0
- package/lib/AWS/index.js +2 -0
- package/lib/AWS/index.js.map +1 -0
- package/lib/ApiToken.d.ts +63 -0
- package/lib/ApiToken.d.ts.map +1 -0
- package/lib/ApiToken.js +121 -0
- package/lib/ApiToken.js.map +1 -0
- package/lib/ArchilBindings.d.ts +65 -0
- package/lib/ArchilBindings.d.ts.map +1 -0
- package/lib/ArchilBindings.js +128 -0
- package/lib/ArchilBindings.js.map +1 -0
- package/lib/AuthProvider.d.ts +40 -0
- package/lib/AuthProvider.d.ts.map +1 -0
- package/lib/AuthProvider.js +87 -0
- package/lib/AuthProvider.js.map +1 -0
- package/lib/Bootstrap.d.ts +8 -0
- package/lib/Bootstrap.d.ts.map +1 -0
- package/lib/Bootstrap.js +27 -0
- package/lib/Bootstrap.js.map +1 -0
- package/lib/Branch.d.ts +101 -0
- package/lib/Branch.d.ts.map +1 -0
- package/lib/Branch.js +117 -0
- package/lib/Branch.js.map +1 -0
- package/lib/BranchDisk.d.ts +42 -0
- package/lib/BranchDisk.d.ts.map +1 -0
- package/lib/BranchDisk.js +14 -0
- package/lib/BranchDisk.js.map +1 -0
- package/lib/Checkpoint.d.ts +78 -0
- package/lib/Checkpoint.d.ts.map +1 -0
- package/lib/Checkpoint.js +95 -0
- package/lib/Checkpoint.js.map +1 -0
- package/lib/Clients.d.ts +369 -0
- package/lib/Clients.d.ts.map +1 -0
- package/lib/Clients.js +334 -0
- package/lib/Clients.js.map +1 -0
- package/lib/ConnectSandbox.d.ts +69 -0
- package/lib/ConnectSandbox.d.ts.map +1 -0
- package/lib/ConnectSandbox.js +21 -0
- package/lib/ConnectSandbox.js.map +1 -0
- package/lib/Contributions.d.ts +7 -0
- package/lib/Contributions.d.ts.map +1 -0
- package/lib/Contributions.js +6 -0
- package/lib/Contributions.js.map +1 -0
- package/lib/CreateDisk.d.ts +90 -0
- package/lib/CreateDisk.d.ts.map +1 -0
- package/lib/CreateDisk.js +47 -0
- package/lib/CreateDisk.js.map +1 -0
- package/lib/CreateImage.d.ts +42 -0
- package/lib/CreateImage.d.ts.map +1 -0
- package/lib/CreateImage.js +19 -0
- package/lib/CreateImage.js.map +1 -0
- package/lib/CreateSandbox.d.ts +104 -0
- package/lib/CreateSandbox.d.ts.map +1 -0
- package/lib/CreateSandbox.js +98 -0
- package/lib/CreateSandbox.js.map +1 -0
- package/lib/Credentials.d.ts +44 -0
- package/lib/Credentials.d.ts.map +1 -0
- package/lib/Credentials.js +57 -0
- package/lib/Credentials.js.map +1 -0
- package/lib/Disk.d.ts +283 -0
- package/lib/Disk.d.ts.map +1 -0
- package/lib/Disk.js +294 -0
- package/lib/Disk.js.map +1 -0
- package/lib/DiskObjectsHttp.d.ts +20 -0
- package/lib/DiskObjectsHttp.d.ts.map +1 -0
- package/lib/DiskObjectsHttp.js +51 -0
- package/lib/DiskObjectsHttp.js.map +1 -0
- package/lib/DiskUser.d.ts +189 -0
- package/lib/DiskUser.d.ts.map +1 -0
- package/lib/DiskUser.js +243 -0
- package/lib/DiskUser.js.map +1 -0
- package/lib/ExecDisk.d.ts +57 -0
- package/lib/ExecDisk.d.ts.map +1 -0
- package/lib/ExecDisk.js +3 -0
- package/lib/ExecDisk.js.map +1 -0
- package/lib/ExecDiskHttp.d.ts +5 -0
- package/lib/ExecDiskHttp.d.ts.map +1 -0
- package/lib/ExecDiskHttp.js +18 -0
- package/lib/ExecDiskHttp.js.map +1 -0
- package/lib/ExecDisks.d.ts +54 -0
- package/lib/ExecDisks.d.ts.map +1 -0
- package/lib/ExecDisks.js +37 -0
- package/lib/ExecDisks.js.map +1 -0
- package/lib/Image.d.ts +188 -0
- package/lib/Image.d.ts.map +1 -0
- package/lib/Image.js +191 -0
- package/lib/Image.js.map +1 -0
- package/lib/InferEnv.d.ts +26 -0
- package/lib/InferEnv.d.ts.map +1 -0
- package/lib/InferEnv.js +1 -0
- package/lib/InferEnv.js.map +1 -0
- package/lib/MountDisk.d.ts +190 -0
- package/lib/MountDisk.d.ts.map +1 -0
- package/lib/MountDisk.js +227 -0
- package/lib/MountDisk.js.map +1 -0
- package/lib/Providers.d.ts +25 -0
- package/lib/Providers.d.ts.map +1 -0
- package/lib/Providers.js +48 -0
- package/lib/Providers.js.map +1 -0
- package/lib/ReadDisk.d.ts +55 -0
- package/lib/ReadDisk.d.ts.map +1 -0
- package/lib/ReadDisk.js +3 -0
- package/lib/ReadDisk.js.map +1 -0
- package/lib/ReadWriteDisk.d.ts +26 -0
- package/lib/ReadWriteDisk.d.ts.map +1 -0
- package/lib/ReadWriteDisk.js +3 -0
- package/lib/ReadWriteDisk.js.map +1 -0
- package/lib/Sandbox.d.ts +507 -0
- package/lib/Sandbox.d.ts.map +1 -0
- package/lib/Sandbox.js +729 -0
- package/lib/Sandbox.js.map +1 -0
- package/lib/SandboxOptions.d.ts +185 -0
- package/lib/SandboxOptions.d.ts.map +1 -0
- package/lib/SandboxOptions.js +102 -0
- package/lib/SandboxOptions.js.map +1 -0
- package/lib/SandboxPortToken.d.ts +64 -0
- package/lib/SandboxPortToken.d.ts.map +1 -0
- package/lib/SandboxPortToken.js +77 -0
- package/lib/SandboxPortToken.js.map +1 -0
- package/lib/WriteDisk.d.ts +37 -0
- package/lib/WriteDisk.d.ts.map +1 -0
- package/lib/WriteDisk.js +3 -0
- package/lib/WriteDisk.js.map +1 -0
- package/lib/index.d.ts +29 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +28 -0
- package/lib/index.js.map +1 -0
- package/lib/internal/DeployerKey.d.ts +21 -0
- package/lib/internal/DeployerKey.d.ts.map +1 -0
- package/lib/internal/DeployerKey.js +34 -0
- package/lib/internal/DeployerKey.js.map +1 -0
- package/lib/internal/archil.d.ts +87 -0
- package/lib/internal/archil.d.ts.map +1 -0
- package/lib/internal/archil.js +154 -0
- package/lib/internal/archil.js.map +1 -0
- package/lib/internal/hosted.d.ts +90 -0
- package/lib/internal/hosted.d.ts.map +1 -0
- package/lib/internal/hosted.js +291 -0
- package/lib/internal/hosted.js.map +1 -0
- package/package.json +79 -3
- package/src/AWS/S3Disk.ts +125 -0
- package/src/AWS/index.ts +1 -0
- package/src/ApiToken.ts +168 -0
- package/src/ArchilBindings.ts +179 -0
- package/src/AuthProvider.ts +122 -0
- package/src/Bootstrap.ts +54 -0
- package/src/Branch.ts +199 -0
- package/src/BranchDisk.ts +57 -0
- package/src/Checkpoint.ts +145 -0
- package/src/Clients.ts +954 -0
- package/src/ConnectSandbox.ts +91 -0
- package/src/Contributions.ts +9 -0
- package/src/CreateDisk.ts +165 -0
- package/src/CreateImage.ts +73 -0
- package/src/CreateSandbox.ts +258 -0
- package/src/Credentials.ts +101 -0
- package/src/Disk.ts +468 -0
- package/src/DiskObjectsHttp.ts +64 -0
- package/src/DiskUser.ts +369 -0
- package/src/ExecDisk.ts +62 -0
- package/src/ExecDiskHttp.ts +25 -0
- package/src/ExecDisks.ts +100 -0
- package/src/Image.ts +316 -0
- package/src/InferEnv.ts +27 -0
- package/src/MountDisk.ts +466 -0
- package/src/Providers.ts +75 -0
- package/src/ReadDisk.ts +61 -0
- package/src/ReadWriteDisk.ts +31 -0
- package/src/Sandbox.ts +1064 -0
- package/src/SandboxOptions.ts +230 -0
- package/src/SandboxPortToken.ts +125 -0
- package/src/WriteDisk.ts +42 -0
- package/src/globals.d.ts +2 -0
- package/src/index.ts +59 -0
- package/src/internal/DeployerKey.ts +63 -0
- package/src/internal/archil.ts +273 -0
- package/src/internal/hosted.ts +402 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import * as Binding from "alchemy/Binding";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Layer from "effect/Layer";
|
|
4
|
+
import { type BranchDiskClient } from "./Clients.ts";
|
|
5
|
+
import type { Disk } from "./Disk.ts";
|
|
6
|
+
export type { BranchDiskClient } from "./Clients.ts";
|
|
7
|
+
/**
|
|
8
|
+
* Fork one disk per session or task at run time: each branch is an
|
|
9
|
+
* independent, writable copy started from a committed checkpoint in about
|
|
10
|
+
* 35 ms, whatever the disk's size. Seed the disk once at deploy time with an
|
|
11
|
+
* {@link Checkpoint}, then branch from it per request.
|
|
12
|
+
*
|
|
13
|
+
* Mount a branch on your own machines with `MountDisk` and `branch`.
|
|
14
|
+
* Branches share the disk's credentials. Sandboxes can't mount a branch.
|
|
15
|
+
*
|
|
16
|
+
* ### Branching per Session
|
|
17
|
+
* **Example:** A fresh workspace for every session
|
|
18
|
+
* ```typescript
|
|
19
|
+
* export default class Api extends Cloudflare.Worker<Api>()(
|
|
20
|
+
* "Api",
|
|
21
|
+
* { main: import.meta.url },
|
|
22
|
+
* Effect.gen(function* () {
|
|
23
|
+
* const seeds = yield* Archil.BranchDisk(Seed);
|
|
24
|
+
* return {
|
|
25
|
+
* fetch: Effect.gen(function* () {
|
|
26
|
+
* const branch = yield* seeds.branch({ name: "session-42", fromCheckpoint: "base" });
|
|
27
|
+
* return yield* HttpServerResponse.json(branch);
|
|
28
|
+
* }),
|
|
29
|
+
* };
|
|
30
|
+
* }).pipe(Effect.provide(Archil.BranchDiskHttp)),
|
|
31
|
+
* ) {}
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* @binding
|
|
35
|
+
* @product Disk
|
|
36
|
+
*/
|
|
37
|
+
export interface BranchDisk extends Binding.Service<BranchDisk, "Archil.BranchDisk", (disk: Disk) => Effect.Effect<BranchDiskClient>> {
|
|
38
|
+
}
|
|
39
|
+
export declare const BranchDisk: BranchDisk;
|
|
40
|
+
/** {@link BranchDisk} over Archil's HTTP API, usable from any host. */
|
|
41
|
+
export declare const BranchDiskHttp: Layer.Layer<BranchDisk, never, never>;
|
|
42
|
+
//# sourceMappingURL=BranchDisk.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BranchDisk.d.ts","sources":["../src/BranchDisk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,iBAAiB,CAAC;AAC3C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAwB,KAAK,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC3E,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEtC,YAAY,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAErD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,WAAW,UAAW,SAAQ,OAAO,CAAC,OAAO,CACjD,UAAU,EACV,mBAAmB,EACnB,CAAC,IAAI,EAAE,IAAI,KAAK,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAChD;CAAG;AAEJ,eAAO,MAAM,UAAU,YAAmD,CAAC;AAE3E,uEAAuE;AACvE,eAAO,MAAM,cAAc,uCAQ1B,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as Binding from "alchemy/Binding";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Layer from "effect/Layer";
|
|
4
|
+
import { ApiAccess } from "./ArchilBindings.js";
|
|
5
|
+
import { makeBranchDiskClient } from "./Clients.js";
|
|
6
|
+
export const BranchDisk = Binding.Service("Archil.BranchDisk");
|
|
7
|
+
/** {@link BranchDisk} over Archil's HTTP API, usable from any host. */
|
|
8
|
+
export const BranchDiskHttp = Layer.effect(BranchDisk, Effect.gen(function* () {
|
|
9
|
+
const access = yield* ApiAccess;
|
|
10
|
+
return Effect.fn(function* (disk) {
|
|
11
|
+
return makeBranchDiskClient(yield* disk.diskId, yield* access());
|
|
12
|
+
});
|
|
13
|
+
}));
|
|
14
|
+
//# sourceMappingURL=BranchDisk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BranchDisk.js","sources":["../src/BranchDisk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,iBAAiB,CAAC;AAC3C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAyB,MAAM,cAAc,CAAC;AAyC3E,MAAM,CAAC,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAa,mBAAmB,CAAC,CAAC;AAE3E,uEAAuE;AACvE,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,CAAC,MAAM,CACxC,UAAU,EACV,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAClB,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,SAAS,CAAC;IAChC,OAAO,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,IAAU;QACpC,OAAO,oBAAoB,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;IACnE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CACH,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import * as archil from "@distilled.cloud/archil";
|
|
2
|
+
import * as Provider from "alchemy/Provider";
|
|
3
|
+
import { Resource } from "alchemy/Resource";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import type { Providers } from "./Providers.ts";
|
|
6
|
+
declare const CheckpointSetupFailed_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
7
|
+
readonly _tag: "Archil.CheckpointSetupFailed";
|
|
8
|
+
} & Readonly<A>;
|
|
9
|
+
/** A checkpoint's setup command exited non-zero. */
|
|
10
|
+
export declare class CheckpointSetupFailed extends CheckpointSetupFailed_base<{
|
|
11
|
+
readonly checkpoint: string;
|
|
12
|
+
readonly exitCode: number;
|
|
13
|
+
readonly stderr: string;
|
|
14
|
+
}> {
|
|
15
|
+
}
|
|
16
|
+
export interface CheckpointProps {
|
|
17
|
+
/** Id of the disk to checkpoint (e.g. `disk.diskId`). Changing it replaces the checkpoint. */
|
|
18
|
+
disk: string;
|
|
19
|
+
/**
|
|
20
|
+
* Checkpoint name, unique within its branch. If omitted, a unique name
|
|
21
|
+
* is generated from the stack, stage, and logical ID. Changing it
|
|
22
|
+
* replaces the checkpoint.
|
|
23
|
+
*/
|
|
24
|
+
name?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Shell commands that seed the disk before the checkpoint is taken. They
|
|
27
|
+
* run in a serverless microVM with the disk mounted at `/mnt/archil` (the
|
|
28
|
+
* working directory). Changing them takes a new checkpoint.
|
|
29
|
+
*/
|
|
30
|
+
run?: string[];
|
|
31
|
+
}
|
|
32
|
+
export interface CheckpointAttributes {
|
|
33
|
+
/** Id of the disk. */
|
|
34
|
+
diskId: string;
|
|
35
|
+
/** Checkpoint name. Pass it to a {@link Branch} or `BranchDisk` as `fromCheckpoint`. */
|
|
36
|
+
name: string;
|
|
37
|
+
}
|
|
38
|
+
export type Checkpoint = Resource<"Archil.Checkpoint", CheckpointProps, CheckpointAttributes, never, Providers>;
|
|
39
|
+
/**
|
|
40
|
+
* A named, point-in-time snapshot of a disk, the seeded base that branches
|
|
41
|
+
* fork from. Alchemy runs the `run` commands against the disk, then takes
|
|
42
|
+
* the checkpoint in the same microVM, so the checkpoint holds exactly what
|
|
43
|
+
* they produced. A checkpoint takes about 15 ms whatever the disk's size,
|
|
44
|
+
* and never changes after it's taken.
|
|
45
|
+
*
|
|
46
|
+
* Archil can't delete checkpoints yet, so destroying the resource only
|
|
47
|
+
* removes it from Alchemy's state.
|
|
48
|
+
* @see https://docs.archil.com/concepts/branches-and-checkpoints
|
|
49
|
+
*
|
|
50
|
+
* ### Seeding a Base
|
|
51
|
+
* **Example:** Clone and install once, branch per session
|
|
52
|
+
* ```typescript
|
|
53
|
+
* export const Seed = Archil.Disk("Seed", {});
|
|
54
|
+
* export const Base = Effect.gen(function* () {
|
|
55
|
+
* const seed = yield* Seed;
|
|
56
|
+
* return yield* Archil.Checkpoint("Base", {
|
|
57
|
+
* disk: seed.diskId,
|
|
58
|
+
* name: "base",
|
|
59
|
+
* run: [
|
|
60
|
+
* "git clone --depth 1 https://github.com/alchemy-run/alchemy repo",
|
|
61
|
+
* "cd repo && corepack enable && pnpm install --frozen-lockfile",
|
|
62
|
+
* ],
|
|
63
|
+
* });
|
|
64
|
+
* });
|
|
65
|
+
* ```
|
|
66
|
+
*
|
|
67
|
+
* @resource
|
|
68
|
+
* @product Disk
|
|
69
|
+
*/
|
|
70
|
+
export declare const Checkpoint: import("alchemy").ResourceClass<Checkpoint>;
|
|
71
|
+
/** Seed a disk and take a checkpoint of it in one serverless exec. */
|
|
72
|
+
export declare const takeCheckpoint: (diskId: string, name: string, run: readonly string[]) => Effect.Effect<{
|
|
73
|
+
diskId: string;
|
|
74
|
+
name: string;
|
|
75
|
+
}, CheckpointSetupFailed | archil.ExecDiskError, archil.ArchilOpContext>;
|
|
76
|
+
export declare const CheckpointProvider: () => import("effect/Layer").Layer<Provider.Provider<Checkpoint>, never, import("alchemy").Stack | import("alchemy").Stage | archil.ArchilOpContext>;
|
|
77
|
+
export {};
|
|
78
|
+
//# sourceMappingURL=Checkpoint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Checkpoint.d.ts","sources":["../src/Checkpoint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,yBAAyB,CAAC;AAGlD,OAAO,KAAK,QAAQ,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;;;;AAEhD,oDAAoD;AACpD,qBAAa,qBAAsB,SAAQ,2BAAiD;IAC1F,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB,CAAC;CAAG;AAEL,MAAM,WAAW,eAAe;IAC9B,8FAA8F;IAC9F,IAAI,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;CAChB;AAED,MAAM,WAAW,oBAAoB;IACnC,sBAAsB;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,wFAAwF;IACxF,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,MAAM,UAAU,GAAG,QAAQ,CAC/B,mBAAmB,EACnB,eAAe,EACf,oBAAoB,EACpB,KAAK,EACL,SAAS,CACV,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,eAAO,MAAM,UAAU,6CAA4C,CAAC;AAOpE,sEAAsE;AACtE,eAAO,MAAM,cAAc;;;wEAqBzB,CAAC;AAEH,eAAO,MAAM,kBAAkB,sJAkC5B,CAAC"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import * as archil from "@distilled.cloud/archil";
|
|
2
|
+
import { deepEqual, isResolved } from "alchemy/Diff";
|
|
3
|
+
import { createPhysicalName } from "alchemy/PhysicalName";
|
|
4
|
+
import * as Provider from "alchemy/Provider";
|
|
5
|
+
import { Resource } from "alchemy/Resource";
|
|
6
|
+
import * as Data from "effect/Data";
|
|
7
|
+
import * as Effect from "effect/Effect";
|
|
8
|
+
/** A checkpoint's setup command exited non-zero. */
|
|
9
|
+
export class CheckpointSetupFailed extends Data.TaggedError("Archil.CheckpointSetupFailed") {
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* A named, point-in-time snapshot of a disk, the seeded base that branches
|
|
13
|
+
* fork from. Alchemy runs the `run` commands against the disk, then takes
|
|
14
|
+
* the checkpoint in the same microVM, so the checkpoint holds exactly what
|
|
15
|
+
* they produced. A checkpoint takes about 15 ms whatever the disk's size,
|
|
16
|
+
* and never changes after it's taken.
|
|
17
|
+
*
|
|
18
|
+
* Archil can't delete checkpoints yet, so destroying the resource only
|
|
19
|
+
* removes it from Alchemy's state.
|
|
20
|
+
* @see https://docs.archil.com/concepts/branches-and-checkpoints
|
|
21
|
+
*
|
|
22
|
+
* ### Seeding a Base
|
|
23
|
+
* **Example:** Clone and install once, branch per session
|
|
24
|
+
* ```typescript
|
|
25
|
+
* export const Seed = Archil.Disk("Seed", {});
|
|
26
|
+
* export const Base = Effect.gen(function* () {
|
|
27
|
+
* const seed = yield* Seed;
|
|
28
|
+
* return yield* Archil.Checkpoint("Base", {
|
|
29
|
+
* disk: seed.diskId,
|
|
30
|
+
* name: "base",
|
|
31
|
+
* run: [
|
|
32
|
+
* "git clone --depth 1 https://github.com/alchemy-run/alchemy repo",
|
|
33
|
+
* "cd repo && corepack enable && pnpm install --frozen-lockfile",
|
|
34
|
+
* ],
|
|
35
|
+
* });
|
|
36
|
+
* });
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @resource
|
|
40
|
+
* @product Disk
|
|
41
|
+
*/
|
|
42
|
+
export const Checkpoint = Resource("Archil.Checkpoint");
|
|
43
|
+
const checkpointName = (id, name) => name ? Effect.succeed(name) : createPhysicalName({ id, maxLength: 63, delimiter: "-" });
|
|
44
|
+
const shellQuote = (value) => `'${value.replaceAll("'", `'"'"'`)}'`;
|
|
45
|
+
/** Seed a disk and take a checkpoint of it in one serverless exec. */
|
|
46
|
+
export const takeCheckpoint = Effect.fn(function* (diskId, name, run) {
|
|
47
|
+
const script = [
|
|
48
|
+
"set -e",
|
|
49
|
+
"cd /mnt/archil",
|
|
50
|
+
...run.map((command) => `(${command})`),
|
|
51
|
+
"sync",
|
|
52
|
+
`archil checkpoints create /mnt/archil ${shellQuote(name)}`,
|
|
53
|
+
].join("\n");
|
|
54
|
+
const { data } = yield* archil.execDisk({ id: diskId, command: script });
|
|
55
|
+
if (data.exitCode !== 0) {
|
|
56
|
+
return yield* new CheckpointSetupFailed({
|
|
57
|
+
checkpoint: name,
|
|
58
|
+
exitCode: data.exitCode,
|
|
59
|
+
stderr: data.stderr,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
return { diskId, name };
|
|
63
|
+
});
|
|
64
|
+
export const CheckpointProvider = () => Provider.effect(Checkpoint, Effect.gen(function* () {
|
|
65
|
+
return {
|
|
66
|
+
stables: ["diskId", "name"],
|
|
67
|
+
// No list or delete API: checkpoints go with their disk.
|
|
68
|
+
nuke: { skip: true },
|
|
69
|
+
diff: Effect.fn(function* ({ id, olds, news, output }) {
|
|
70
|
+
if (!isResolved(news) || olds === undefined)
|
|
71
|
+
return undefined;
|
|
72
|
+
const name = output?.name ?? (yield* checkpointName(id, olds.name));
|
|
73
|
+
if (news.disk !== olds.disk ||
|
|
74
|
+
(news.name !== undefined && news.name !== name) ||
|
|
75
|
+
!deepEqual(news.run ?? [], olds.run ?? [])) {
|
|
76
|
+
return { action: "replace" };
|
|
77
|
+
}
|
|
78
|
+
return undefined;
|
|
79
|
+
}),
|
|
80
|
+
// Checkpoints have no read API; state is authoritative.
|
|
81
|
+
read: Effect.fn(function* ({ output }) {
|
|
82
|
+
return output;
|
|
83
|
+
}),
|
|
84
|
+
reconcile: Effect.fn(function* ({ id, news, output, session }) {
|
|
85
|
+
if (output && output.diskId === news.disk)
|
|
86
|
+
return output;
|
|
87
|
+
const name = yield* checkpointName(id, news.name);
|
|
88
|
+
yield* session.note(`Seeding disk and taking checkpoint ${name}...`);
|
|
89
|
+
return yield* takeCheckpoint(news.disk, name, news.run ?? []);
|
|
90
|
+
}),
|
|
91
|
+
// Archil has no checkpoint delete API.
|
|
92
|
+
delete: () => Effect.void,
|
|
93
|
+
};
|
|
94
|
+
}));
|
|
95
|
+
//# sourceMappingURL=Checkpoint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Checkpoint.js","sources":["../src/Checkpoint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,QAAQ,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,IAAI,MAAM,aAAa,CAAC;AACpC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAGxC,oDAAoD;AACpD,MAAM,OAAO,qBAAsB,SAAQ,IAAI,CAAC,WAAW,CAAC,8BAA8B,CAIxF;CAAG;AAkCL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,QAAQ,CAAa,mBAAmB,CAAC,CAAC;AAEpE,MAAM,cAAc,GAAG,CAAC,EAAU,EAAE,IAAwB,EAAE,EAAE,CAC9D,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,kBAAkB,CAAC,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,CAAC;AAE1F,MAAM,UAAU,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,OAAO,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E,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI;KAC1B,CAAC;AACJ,CAAC,CAAC,CACH,CAAC"}
|
package/lib/Clients.d.ts
ADDED
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The run-time handles Archil bindings return. A disk or sandbox handle is
|
|
3
|
+
* the same shape whether it came from a deploy-time resource
|
|
4
|
+
* (`ExecDisk(Dataset)`, `ConnectSandbox(Preview)`) or was created at run
|
|
5
|
+
* time (`CreateDisk`, `CreateSandbox`), and takes Archil's own parameters.
|
|
6
|
+
*/
|
|
7
|
+
import * as archil from "@distilled.cloud/archil";
|
|
8
|
+
import * as Objects from "@distilled.cloud/archil/Objects";
|
|
9
|
+
import * as Process from "@distilled.cloud/archil/Process";
|
|
10
|
+
import type { RuntimeContext } from "alchemy/RuntimeContext";
|
|
11
|
+
import * as SandboxBase from "alchemy/Sandbox";
|
|
12
|
+
import * as Effect from "effect/Effect";
|
|
13
|
+
import * as Redacted from "effect/Redacted";
|
|
14
|
+
import type * as Scope from "effect/Scope";
|
|
15
|
+
import * as Stream from "effect/Stream";
|
|
16
|
+
import type { Authorize, ObjectsRunner } from "./ArchilBindings.ts";
|
|
17
|
+
import type { BranchAttributes } from "./Branch.ts";
|
|
18
|
+
import type { DiskAttributes } from "./Disk.ts";
|
|
19
|
+
import type { DiskUserAttributes } from "./DiskUser.ts";
|
|
20
|
+
import { type DiskUserSpec, type DiskUserUnexpectedResponse } from "./DiskUser.ts";
|
|
21
|
+
import { deleteSandbox, type SandboxAttributes } from "./Sandbox.ts";
|
|
22
|
+
import { type SandboxEgress } from "./SandboxOptions.ts";
|
|
23
|
+
import type { SandboxPortTokenAttributes } from "./SandboxPortToken.ts";
|
|
24
|
+
type R = RuntimeContext;
|
|
25
|
+
/** What a serverless exec printed, and its exit code. */
|
|
26
|
+
export interface ExecResult {
|
|
27
|
+
readonly exitCode: number;
|
|
28
|
+
readonly stdout: string;
|
|
29
|
+
readonly stderr: string;
|
|
30
|
+
/** Where the time went, as Archil reports it. */
|
|
31
|
+
readonly timing: archil.ExecTiming;
|
|
32
|
+
}
|
|
33
|
+
/** Search options for `grep`. */
|
|
34
|
+
export interface GrepOptions {
|
|
35
|
+
/** Directory on the disk to search. @default "/" */
|
|
36
|
+
readonly directory?: string;
|
|
37
|
+
/** Regular expression. */
|
|
38
|
+
readonly pattern: string;
|
|
39
|
+
/** Search subdirectories. @default false */
|
|
40
|
+
readonly recursive?: boolean;
|
|
41
|
+
/** Stop after this many seconds. @default 30 */
|
|
42
|
+
readonly maxDurationSeconds?: number;
|
|
43
|
+
/** Workers to fan out to. @default 50 */
|
|
44
|
+
readonly concurrency?: number;
|
|
45
|
+
/** Stop after this many matches. @default 1000 */
|
|
46
|
+
readonly maxResults?: number;
|
|
47
|
+
}
|
|
48
|
+
/** Serverless commands and search against one disk. */
|
|
49
|
+
export interface ExecDiskClient {
|
|
50
|
+
/**
|
|
51
|
+
* Run a shell command in a fresh microVM with the disk mounted at
|
|
52
|
+
* `/mnt/archil`. Blocks until it exits (up to five minutes).
|
|
53
|
+
*/
|
|
54
|
+
exec(command: string): Effect.Effect<ExecResult, archil.ExecDiskError, R>;
|
|
55
|
+
/** Constant-time parallel grep across the disk's files. */
|
|
56
|
+
grep(options: GrepOptions): Effect.Effect<archil.GrepDiskResult, archil.GrepDiskError, R>;
|
|
57
|
+
}
|
|
58
|
+
/** Read the disk's files as objects. */
|
|
59
|
+
export interface ReadDiskClient {
|
|
60
|
+
/** A file's bytes, optionally a byte range (`bytes=0-1023`). */
|
|
61
|
+
get(key: string, options?: {
|
|
62
|
+
readonly range?: string;
|
|
63
|
+
}): Effect.Effect<Uint8Array, Objects.ObjectsFailure | ObjectsTransportError, R>;
|
|
64
|
+
/** A file as UTF-8 text. */
|
|
65
|
+
getText(key: string): Effect.Effect<string, Objects.ObjectsFailure | ObjectsTransportError, R>;
|
|
66
|
+
/** A file's bytes as a stream, for files too big to hold in memory. */
|
|
67
|
+
getStream(key: string): Stream.Stream<Uint8Array, Objects.ObjectsFailure | ObjectsTransportError, R>;
|
|
68
|
+
/** A file's metadata, or `undefined` when it doesn't exist. */
|
|
69
|
+
head(key: string): Effect.Effect<Objects.ObjectMetadata | undefined, Objects.ObjectsFailure | ObjectsTransportError, R>;
|
|
70
|
+
/** Every file under a prefix, lazily paginated. */
|
|
71
|
+
list(prefix?: string, options?: {
|
|
72
|
+
readonly recursive?: boolean;
|
|
73
|
+
}): Stream.Stream<Objects.ObjectSummary, Objects.ObjectsFailure | ObjectsTransportError, R>;
|
|
74
|
+
/**
|
|
75
|
+
* A signed URL anyone can download one file from, valid for
|
|
76
|
+
* `expiresInSeconds` (1 to 604800; default one hour).
|
|
77
|
+
*/
|
|
78
|
+
share(key: string, expiresInSeconds?: number): Effect.Effect<Redacted.Redacted<string>, ShareError, R>;
|
|
79
|
+
}
|
|
80
|
+
/** What creating a share URL can fail with. */
|
|
81
|
+
export type ShareError = archil.CreateShareUrlError | Effect.Error<ReturnType<typeof Objects.presignGetObject>>;
|
|
82
|
+
/** Write the disk's files as objects. */
|
|
83
|
+
export interface WriteDiskClient {
|
|
84
|
+
/** Write a file (≤ 5 GiB). */
|
|
85
|
+
put(key: string, body: Uint8Array | string, options?: {
|
|
86
|
+
readonly contentType?: string;
|
|
87
|
+
} & Objects.PosixAttributes): Effect.Effect<{
|
|
88
|
+
etag: string | undefined;
|
|
89
|
+
}, Objects.ObjectsFailure | ObjectsTransportError, R>;
|
|
90
|
+
/** Append to a file, creating it when missing (≤ 1 MiB per call). */
|
|
91
|
+
append(key: string, body: Uint8Array | string): Effect.Effect<{
|
|
92
|
+
etag: string | undefined;
|
|
93
|
+
}, Objects.ObjectsFailure | ObjectsTransportError, R>;
|
|
94
|
+
/** Delete a file. Deleting a missing file succeeds. */
|
|
95
|
+
delete(key: string): Effect.Effect<void, Objects.ObjectsFailure | ObjectsTransportError, R>;
|
|
96
|
+
/** Delete many files; per-file failures are returned. */
|
|
97
|
+
deleteMany(keys: ReadonlyArray<string>): Effect.Effect<{
|
|
98
|
+
deleted: string[];
|
|
99
|
+
errors: Array<{
|
|
100
|
+
readonly key: string;
|
|
101
|
+
readonly code?: string;
|
|
102
|
+
readonly message?: string;
|
|
103
|
+
}>;
|
|
104
|
+
}, Objects.ObjectsFailure | ObjectsTransportError, R>;
|
|
105
|
+
/** Copy a file within the disk. */
|
|
106
|
+
copy(sourceKey: string, key: string): Effect.Effect<{
|
|
107
|
+
etag: string | undefined;
|
|
108
|
+
}, Objects.ObjectsFailure | ObjectsTransportError, R>;
|
|
109
|
+
/**
|
|
110
|
+
* Write a file of any size from a stream, as a multipart upload in
|
|
111
|
+
* 8 MiB parts. A failed upload is aborted, so no parts are left behind.
|
|
112
|
+
*/
|
|
113
|
+
upload<E>(key: string, body: Stream.Stream<Uint8Array, E>, options?: {
|
|
114
|
+
readonly contentType?: string;
|
|
115
|
+
} & Objects.PosixAttributes): Effect.Effect<{
|
|
116
|
+
etag: string | undefined;
|
|
117
|
+
}, Objects.ObjectsFailure | ObjectsTransportError | E, R>;
|
|
118
|
+
}
|
|
119
|
+
/** Write delegations on a disk: the paths a mounted client holds for writing. */
|
|
120
|
+
export interface DiskDelegationsClient {
|
|
121
|
+
/** Write delegations held on the disk, e.g. by a crashed mount. */
|
|
122
|
+
delegations(): Effect.Effect<archil.DelegationEntry[], archil.ListDelegationsError, R>;
|
|
123
|
+
/** Reclaim write access from a client that is gone. */
|
|
124
|
+
revokeDelegation(delegation: Pick<archil.DelegationEntry, "clientId" | "inodeId">): Effect.Effect<void, archil.RevokeDelegationError, R>;
|
|
125
|
+
}
|
|
126
|
+
/** Both {@link ReadDiskClient} and {@link WriteDiskClient}. */
|
|
127
|
+
export interface ReadWriteDiskClient extends ReadDiskClient, WriteDiskClient {
|
|
128
|
+
}
|
|
129
|
+
/** Errors from the HTTP transport underneath the objects API. */
|
|
130
|
+
export type ObjectsTransportError = Effect.Error<ReturnType<typeof Objects.headObject>>;
|
|
131
|
+
/** Branches of one disk. */
|
|
132
|
+
export interface BranchDiskClient {
|
|
133
|
+
/**
|
|
134
|
+
* Create a writable branch from a committed checkpoint, or return the
|
|
135
|
+
* branch with that name.
|
|
136
|
+
*/
|
|
137
|
+
branch(options: {
|
|
138
|
+
readonly name: string;
|
|
139
|
+
readonly fromCheckpoint: string;
|
|
140
|
+
readonly fromBranch?: string;
|
|
141
|
+
}): Effect.Effect<BranchAttributes, archil.CreateBranchError | archil.GetBranchError, R>;
|
|
142
|
+
/** A branch, or `undefined` when it doesn't exist. */
|
|
143
|
+
getBranch(name: string): Effect.Effect<BranchAttributes | undefined, archil.GetBranchError, R>;
|
|
144
|
+
/** Every branch of the disk, including branches of branches. */
|
|
145
|
+
listBranches(): Effect.Effect<BranchAttributes[], archil.ListBranchesError, R>;
|
|
146
|
+
}
|
|
147
|
+
/** One disk, with everything a run-time client can do to it. */
|
|
148
|
+
export interface DiskHandle extends ExecDiskClient, ReadWriteDiskClient, BranchDiskClient, DiskDelegationsClient {
|
|
149
|
+
readonly diskId: string;
|
|
150
|
+
readonly name: string;
|
|
151
|
+
/**
|
|
152
|
+
* A disk token for mounting this disk only, e.g. to hand to a machine
|
|
153
|
+
* that mounts with `MountDisk()`. `readOnly`, `expiresAt` and `oneUse`
|
|
154
|
+
* narrow it. Revoke it with `removeToken`.
|
|
155
|
+
*/
|
|
156
|
+
createToken(nickname: string, options?: Pick<DiskUserSpec, "readOnly" | "expiresAt" | "oneUse">): Effect.Effect<DiskUserAttributes, archil.AddDiskUserError | DiskUserUnexpectedResponse, R>;
|
|
157
|
+
/** Revoke a disk token. */
|
|
158
|
+
removeToken(identifier: string): Effect.Effect<void, archil.RemoveDiskUserError, R>;
|
|
159
|
+
}
|
|
160
|
+
/** A command: one shell line, or an argument vector (quoted for you). */
|
|
161
|
+
export type Command = SandboxBase.Command;
|
|
162
|
+
/** Options for a command run in a sandbox (`timeout` rounds up to whole seconds). */
|
|
163
|
+
export type ExecOptions = SandboxBase.ExecOptions;
|
|
164
|
+
/** Options for a process started in the background. */
|
|
165
|
+
export type StartOptions = Omit<ExecOptions, "stdin">;
|
|
166
|
+
/**
|
|
167
|
+
* What a process call on a sandbox handle can fail with. A paused sandbox
|
|
168
|
+
* is resumed first, so resuming can fail too.
|
|
169
|
+
*/
|
|
170
|
+
export type ProcessCallError = Process.ProcessError | archil.CreateSandboxConnectionError | archil.GetSandboxError | archil.ResumeSandboxError;
|
|
171
|
+
/** A chunk of process output, with its offset in the combined output (for `attach`). */
|
|
172
|
+
export interface SandboxProcessOutput extends SandboxBase.ProcessOutput {
|
|
173
|
+
readonly offset: number;
|
|
174
|
+
}
|
|
175
|
+
/** How an Archil process ended. */
|
|
176
|
+
export interface SandboxProcessExit {
|
|
177
|
+
/**
|
|
178
|
+
* The exit code. Archil reports none for a process it killed (a timeout,
|
|
179
|
+
* or `kill`); that is `-1` here, and `status` / `exitReason` say why.
|
|
180
|
+
*/
|
|
181
|
+
readonly exitCode: number;
|
|
182
|
+
readonly status: string;
|
|
183
|
+
readonly exitReason: string | undefined;
|
|
184
|
+
/** Output offset at exit, for a later `attach`. */
|
|
185
|
+
readonly cursor: number;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* A process running in a sandbox, attached over one connection. Closing
|
|
189
|
+
* the scope that started it detaches; the process keeps running and can be
|
|
190
|
+
* re-attached by `id`.
|
|
191
|
+
*/
|
|
192
|
+
export interface SandboxProcess extends SandboxBase.Process<ProcessCallError> {
|
|
193
|
+
readonly output: Stream.Stream<SandboxProcessOutput, ProcessCallError, R>;
|
|
194
|
+
/**
|
|
195
|
+
* Kill the process. Archil's process API kills without a choice of
|
|
196
|
+
* signal, so `signal` is ignored.
|
|
197
|
+
*/
|
|
198
|
+
kill(signal?: "SIGTERM" | "SIGKILL"): Effect.Effect<void, ProcessCallError, R>;
|
|
199
|
+
readonly wait: Effect.Effect<SandboxProcessExit, ProcessCallError, R>;
|
|
200
|
+
/** Close stdin. */
|
|
201
|
+
readonly closeStdin: Effect.Effect<void, ProcessCallError, R>;
|
|
202
|
+
}
|
|
203
|
+
/** A shell (or command) on a pseudo-terminal. */
|
|
204
|
+
export interface PtyConnection extends SandboxBase.PtyConnection<ProcessCallError> {
|
|
205
|
+
/** Kill the terminal's process. */
|
|
206
|
+
kill(): Effect.Effect<void, ProcessCallError, R>;
|
|
207
|
+
/** Wait for the terminal's process to exit. */
|
|
208
|
+
readonly wait: Effect.Effect<SandboxProcessExit, ProcessCallError, R>;
|
|
209
|
+
}
|
|
210
|
+
/** Options for a pseudo-terminal. `command` may also be an argument vector. */
|
|
211
|
+
export interface PtyOptions extends Omit<SandboxBase.PtyOptions, "command"> {
|
|
212
|
+
/** @default "bash" */
|
|
213
|
+
readonly command?: Command;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Files in the sandbox. Archil's process protocol has no file calls of its
|
|
217
|
+
* own: these run small POSIX shell commands over it (as Archil's own SDK
|
|
218
|
+
* does for uploads and downloads), so they work on any image with `sh`,
|
|
219
|
+
* `cat`, `stat`, `rm` and `mkdir`.
|
|
220
|
+
*/
|
|
221
|
+
export interface SandboxFiles extends SandboxBase.Files<ProcessCallError> {
|
|
222
|
+
/** Write a file (atomically: a temp file, then a rename), creating its directory. */
|
|
223
|
+
write(path: string, data: string | Uint8Array, options?: {
|
|
224
|
+
readonly mode?: number;
|
|
225
|
+
}): Effect.Effect<void, ProcessCallError, R>;
|
|
226
|
+
}
|
|
227
|
+
declare const SandboxPortNotExposed_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
228
|
+
readonly _tag: "Archil.SandboxPortNotExposed";
|
|
229
|
+
} & Readonly<A>;
|
|
230
|
+
/** The sandbox doesn't serve this port publicly (`exposePort` it first). */
|
|
231
|
+
export declare class SandboxPortNotExposed extends SandboxPortNotExposed_base<{
|
|
232
|
+
readonly port: number;
|
|
233
|
+
readonly message: string;
|
|
234
|
+
}> {
|
|
235
|
+
}
|
|
236
|
+
/** Why `getTcpPort` can fail. */
|
|
237
|
+
export type SandboxPortError = SandboxPortNotExposed | archil.ListSandboxPortsError;
|
|
238
|
+
/**
|
|
239
|
+
* A port the sandbox serves publicly, at its own `archil.app` hostname.
|
|
240
|
+
* `fetch` sends a client request there, or proxies the server request a
|
|
241
|
+
* handler received; either way the method, path, query, headers and body
|
|
242
|
+
* are kept. Anyone with the URL can call a public port, so hand browsers a
|
|
243
|
+
* port token (`createPortToken`) rather than your key.
|
|
244
|
+
*/
|
|
245
|
+
export interface SandboxPort extends SandboxBase.SandboxPort<SandboxPortError> {
|
|
246
|
+
/** The port inside the sandbox. */
|
|
247
|
+
readonly port: number;
|
|
248
|
+
/** Archil's public hostname for this port, e.g. `3000-<route>.<zone>.archil.app`. */
|
|
249
|
+
readonly hostname: string;
|
|
250
|
+
/** `https://` + `hostname`. */
|
|
251
|
+
readonly url: string;
|
|
252
|
+
}
|
|
253
|
+
/** Everything a run-time client can do to one sandbox. */
|
|
254
|
+
export interface SandboxOps extends SandboxBase.SandboxExec<ProcessCallError, Process.ProcessResult, ExecOptions>, SandboxBase.SandboxProcesses<ProcessCallError, StartOptions>, SandboxBase.SandboxFiles<ProcessCallError>, SandboxBase.SandboxPty<ProcessCallError, PtyOptions>, SandboxBase.SandboxPorts<SandboxPortError, SandboxPort> {
|
|
255
|
+
/** The sandbox's current attributes. */
|
|
256
|
+
refresh(): Effect.Effect<SandboxAttributes, archil.GetSandboxError, R>;
|
|
257
|
+
/**
|
|
258
|
+
* Run a command to completion and collect its output. A non-zero exit is
|
|
259
|
+
* returned in `exitCode`, not failed.
|
|
260
|
+
*/
|
|
261
|
+
exec(command: Command, options?: ExecOptions): Effect.Effect<Process.ProcessResult, ProcessCallError, R>;
|
|
262
|
+
/**
|
|
263
|
+
* Start a command in the background and attach to it. Closing the scope
|
|
264
|
+
* detaches; the process keeps running and can be re-attached by id.
|
|
265
|
+
*/
|
|
266
|
+
start(command: Command, options?: StartOptions): Effect.Effect<SandboxProcess, ProcessCallError, R | Scope.Scope>;
|
|
267
|
+
/** Re-attach to a running process, resuming its output at `offset`. */
|
|
268
|
+
attach(processId: string, offset?: number): Effect.Effect<SandboxProcess, ProcessCallError, R | Scope.Scope>;
|
|
269
|
+
/** Files in the sandbox. */
|
|
270
|
+
readonly files: SandboxFiles;
|
|
271
|
+
/** Pseudo-terminals. */
|
|
272
|
+
readonly pty: {
|
|
273
|
+
/** Open a shell (or `command`) on a terminal of `cols` × `rows`. */
|
|
274
|
+
open(options: PtyOptions): Effect.Effect<PtyConnection, ProcessCallError, R | Scope.Scope>;
|
|
275
|
+
};
|
|
276
|
+
/**
|
|
277
|
+
* A port the sandbox serves publicly. Fails with `SandboxPortNotExposed`
|
|
278
|
+
* until the port is exposed (`ports` on the resource, or `exposePort`).
|
|
279
|
+
*/
|
|
280
|
+
getTcpPort(port: number): Effect.Effect<SandboxPort, SandboxPortError, R>;
|
|
281
|
+
/** Start a stopped sandbox (Archil's `start`). */
|
|
282
|
+
boot(): Effect.Effect<SandboxAttributes, archil.StartSandboxError, R>;
|
|
283
|
+
/** Stop the sandbox (its disk survives; memory doesn't). */
|
|
284
|
+
stop(): Effect.Effect<SandboxAttributes, archil.StopSandboxError, R>;
|
|
285
|
+
/** Pause the sandbox, keeping its memory. */
|
|
286
|
+
pause(): Effect.Effect<SandboxAttributes, archil.PauseSandboxError, R>;
|
|
287
|
+
/** Resume a paused sandbox. */
|
|
288
|
+
resume(): Effect.Effect<SandboxAttributes, archil.ResumeSandboxError, R>;
|
|
289
|
+
/**
|
|
290
|
+
* Fork the sandbox (memory and disk) into a new one. Archil only forks a
|
|
291
|
+
* sandbox with mounts while it is stopped.
|
|
292
|
+
*/
|
|
293
|
+
fork(options?: {
|
|
294
|
+
readonly name?: string;
|
|
295
|
+
readonly checkpoint?: string;
|
|
296
|
+
}): Effect.Effect<SandboxHandle, archil.ForkSandboxError, R>;
|
|
297
|
+
/**
|
|
298
|
+
* Pause after `timeoutSeconds` from now, and/or after `idleTtlSeconds`
|
|
299
|
+
* without a connection (`0` disables idle expiry).
|
|
300
|
+
*/
|
|
301
|
+
setTimeout(options: {
|
|
302
|
+
readonly timeoutSeconds?: number;
|
|
303
|
+
readonly idleTtlSeconds?: number;
|
|
304
|
+
}): Effect.Effect<SandboxAttributes, archil.SetSandboxTimeoutError, R>;
|
|
305
|
+
/** Serve a port publicly. */
|
|
306
|
+
exposePort(port: number): Effect.Effect<{
|
|
307
|
+
port: number;
|
|
308
|
+
hostname: string;
|
|
309
|
+
}, archil.ExposeSandboxPortError, R>;
|
|
310
|
+
/** Stop serving a port. */
|
|
311
|
+
unexposePort(port: number): Effect.Effect<void, archil.DeleteSandboxPortError, R>;
|
|
312
|
+
/** Ports the sandbox serves. */
|
|
313
|
+
ports(): Effect.Effect<Array<{
|
|
314
|
+
port: number;
|
|
315
|
+
hostname: string;
|
|
316
|
+
}>, archil.ListSandboxPortsError, R>;
|
|
317
|
+
/** A token that opens one port for a client that shouldn't hold an API key. */
|
|
318
|
+
createPortToken(port: number, ttl?: string): Effect.Effect<SandboxPortTokenAttributes, archil.CreateSandboxPortTokenError, R>;
|
|
319
|
+
/** Revoke a port token. */
|
|
320
|
+
revokePortToken(tokenId: string): Effect.Effect<void, archil.DeleteSandboxPortTokenError, R>;
|
|
321
|
+
/**
|
|
322
|
+
* The sandbox's port tokens, without their secret values (Archil only
|
|
323
|
+
* shows a token when it's created).
|
|
324
|
+
*/
|
|
325
|
+
listPortTokens(): Stream.Stream<archil.SandboxPortToken, archil.ListSandboxPortTokensError, R>;
|
|
326
|
+
/** Replace the outbound network policy. Applies at once. */
|
|
327
|
+
setEgress(egress: SandboxEgress): Effect.Effect<void, archil.UpdateSandboxNetworkError, R>;
|
|
328
|
+
/**
|
|
329
|
+
* Stop (if it's live) and delete the sandbox. Deleting a missing sandbox
|
|
330
|
+
* succeeds.
|
|
331
|
+
*/
|
|
332
|
+
delete(): Effect.Effect<void, Effect.Error<ReturnType<typeof deleteSandbox>>, R>;
|
|
333
|
+
}
|
|
334
|
+
/** One sandbox known by id and name, with everything a run-time client can do to it. */
|
|
335
|
+
export interface SandboxHandle extends SandboxOps {
|
|
336
|
+
readonly sandboxId: string;
|
|
337
|
+
readonly name: string;
|
|
338
|
+
}
|
|
339
|
+
/** Serverless exec + grep on a disk whose id resolves at run time. */
|
|
340
|
+
export declare const makeExecDiskClient: (diskId: Effect.Effect<string, never, R>, authorize: Authorize) => ExecDiskClient;
|
|
341
|
+
/** How a read client makes share URLs. */
|
|
342
|
+
export type ShareStrategy = (ref: Objects.DiskRef, key: string, expiresInSeconds: number) => Effect.Effect<Redacted.Redacted<string>, ShareError, R>;
|
|
343
|
+
/** Share URLs presigned with the client's own S3 user keys. */
|
|
344
|
+
export declare const presignedShare: (run: ObjectsRunner) => ShareStrategy;
|
|
345
|
+
/** Share URLs from Archil's control plane (needs the API key). */
|
|
346
|
+
export declare const controlPlaneShare: (authorize: Authorize) => ShareStrategy;
|
|
347
|
+
/** Object reads on a disk (or branch) whose id resolves at run time. */
|
|
348
|
+
export declare const makeReadDiskClient: (ref: Effect.Effect<Objects.DiskRef, never, R>, run: ObjectsRunner, share: ShareStrategy) => ReadDiskClient;
|
|
349
|
+
/** Object writes on a disk (or branch) whose id resolves at run time. */
|
|
350
|
+
export declare const makeWriteDiskClient: (ref: Effect.Effect<Objects.DiskRef, never, R>, run: ObjectsRunner) => WriteDiskClient;
|
|
351
|
+
/** Write delegations on a disk whose id resolves at run time (needs the API key). */
|
|
352
|
+
export declare const makeDiskDelegationsClient: (ref: Effect.Effect<Objects.DiskRef, never, R>, authorize: Authorize) => DiskDelegationsClient;
|
|
353
|
+
/** Branches of a disk whose id resolves at run time. */
|
|
354
|
+
export declare const makeBranchDiskClient: (diskId: Effect.Effect<string, never, R>, authorize: Authorize) => BranchDiskClient;
|
|
355
|
+
/** A full handle on a disk known by id and name. */
|
|
356
|
+
export declare const makeDiskHandle: (disk: Pick<DiskAttributes, "diskId" | "name">, authorize: Authorize) => DiskHandle;
|
|
357
|
+
/**
|
|
358
|
+
* Everything a run-time client can do to the sandbox `sid` resolves to.
|
|
359
|
+
* `forkName` maps a fork's name (a binding puts its owner prefix on it,
|
|
360
|
+
* like on the sandboxes it creates).
|
|
361
|
+
*/
|
|
362
|
+
export declare const makeSandboxOps: (sid: Effect.Effect<string, never, R>, authorize: Authorize, forkName?: (name: string | undefined) => Effect.Effect<string | undefined>) => SandboxOps;
|
|
363
|
+
/** A full handle on a sandbox known by id and name. */
|
|
364
|
+
export declare const makeSandboxHandle: (sandbox: {
|
|
365
|
+
readonly sandboxId: string;
|
|
366
|
+
readonly name: string;
|
|
367
|
+
}, authorize: Authorize, forkName?: (name: string | undefined) => Effect.Effect<string | undefined>) => SandboxHandle;
|
|
368
|
+
export {};
|
|
369
|
+
//# sourceMappingURL=Clients.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Clients.d.ts","sources":["../src/Clients.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,MAAM,MAAM,yBAAyB,CAAC;AAClD,OAAO,KAAK,OAAO,MAAM,iCAAiC,CAAC;AAC3D,OAAO,KAAK,OAAO,MAAM,iCAAiC,CAAC;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,KAAK,WAAW,MAAM,iBAAiB,CAAC;AAG/C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAKxC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD,OAAO,KAAK,EAAE,cAAc,EAAE,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