1import * as AWS from "@/AWS";
2import * as Cloudflare from "@/Cloudflare";
3import * as Alchemy from "@/index.ts";
4import * as Effect from "effect/Effect";
5import * as Layer from "effect/Layer";
6import Orchestrator from "./orchestrator.ts";
7import SandboxLive from "./sandbox.ts";
8import MicrovmWorker from "./worker.ts";
9
10/**
11 * Effectful MicroVM stack: deploys the bundled {@link SandboxLive} image plus
12 * two orchestrators that drive its MicroVM instance operations —
13 *
14 * - {@link Orchestrator}: an AWS Lambda (uses its execution role).
15 * - {@link MicrovmWorker}: a Cloudflare Worker (cross-cloud — Alchemy mints an
16 * IAM User + AccessKey + assume-role Role and the worker assumes it).
17 *
18 * Needs BOTH provider sets. Exposes each orchestrator's URL so the test can
19 * drive the lifecycle over HTTP against either host.
20 */
21export default Alchemy.Stack(
22 "MicrovmEffectfulStack",
23 {
24 providers: Layer.mergeAll(AWS.providers(), Cloudflare.providers()),
25 state: Alchemy.localState(),
26 },
27 Effect.gen(function* () {
28 const fn = yield* Orchestrator;
29 const worker = yield* MicrovmWorker;
30 return {
31 url: fn.functionUrl.as<string>(),
32 workerUrl: worker.url.as<string>(),
33 };
34 }).pipe(Effect.provide(SandboxLive)),
35);