| 1 | import * as ConfigProvider from "effect/ConfigProvider"; |
| 2 | import * as Layer from "effect/Layer"; |
| 3 | import * as FetchHttpClient from "effect/http/FetchHttpClient"; |
| 4 | import { AlchemyContextLive } from "../AlchemyContext.ts"; |
| 5 | import { ArtifactStore, createArtifactStore } from "../Artifacts.ts"; |
| 6 | import { CredentialsStoreLive } from "../Auth/Credentials.ts"; |
| 7 | import { ProfileStoreLive } from "../Auth/Profile.ts"; |
| 8 | import * as Interaction from "../Interaction.ts"; |
| 9 | import { PlatformServices } from "../Util/PlatformServices.ts"; |
| 10 | import { routeCacheLayer } from "./Session.ts"; |
| 11 | |
| 12 | /** |
| 13 | * All services required by the programmatic Alchemist API. |
| 14 | * |
| 15 | * Progress reporting remains caller-controlled: without an override the |
| 16 | * default reporter is a no-op, while interactive and plain renderers can |
| 17 | * provide {@link import("./Progress.ts").Progress} around individual calls. |
| 18 | * The non-interactive Interaction default serves the engine paths that need |
| 19 | * one (state-store confirms fail typed; profile probes never prompt). |
| 20 | * |
| 21 | * @example |
| 22 | * ```ts |
| 23 | * Effect.runPromise( |
| 24 | * program.pipe(Effect.provide(Alchemist.layer()), Effect.scoped), |
| 25 | * ) |
| 26 | * ``` |
| 27 | */ |
| 28 | export const layer = () => |
| 29 | Layer.mergeAll( |
| 30 | Layer.mergeAll( |
| 31 | AlchemyContextLive, |
| 32 | ProfileStoreLive, |
| 33 | CredentialsStoreLive, |
| 34 | ).pipe(Layer.provideMerge(PlatformServices)), |
| 35 | FetchHttpClient.layer, |
| 36 | ConfigProvider.layer(ConfigProvider.fromEnv()), |
| 37 | Layer.succeed(ArtifactStore, createArtifactStore()), |
| 38 | routeCacheLayer, |
| 39 | Interaction.layerNonInteractive(), |
| 40 | ); |