1import * as ConfigProvider from "effect/ConfigProvider";
2import * as Layer from "effect/Layer";
3import * as FetchHttpClient from "effect/http/FetchHttpClient";
4import { AlchemyContextLive } from "../AlchemyContext.ts";
5import { ArtifactStore, createArtifactStore } from "../Artifacts.ts";
6import { CredentialsStoreLive } from "../Auth/Credentials.ts";
7import { ProfileStoreLive } from "../Auth/Profile.ts";
8import * as Interaction from "../Interaction.ts";
9import { PlatformServices } from "../Util/PlatformServices.ts";
10import { 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 */
28export 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 );