@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 06:00 UTC

main
ts 27 lines 1014 Bytes
Raw
1 import * as Context from "effect/Context";
2 import * as Effect from "effect/Effect";
3 import * as Layer from "effect/Layer";
4 import * as Option from "effect/Option";
5 import type { AuthProvider } from "./AuthProvider.ts";
6
7 // Kept apart from `AuthProvider.ts` because `Stack.ts`, which every runtime
8 // imports, provides the registry: this module pulls in nothing but Effect.
9
10 /** Every registered {@link AuthProvider}, by provider name. */
11 export class AuthProviders extends Context.Service<
12 AuthProviders,
13 {
14 [providerName: string]: AuthProvider;
15 }
16 >()("AuthProviders") {}
17
18 /**
19 * The registry a provider layer registers into: the ambient one when the
20 * caller supplies it (to read the registrations back, as `alchemy profile`
21 * does), otherwise a fresh one for this build. `Stack.build` provides it,
22 * so callers never supply an empty registry.
23 */
24 export const AuthProvidersLive = Layer.effect(
25 AuthProviders,
26 Effect.serviceOption(AuthProviders).pipe(Effect.map(Option.getOrElse(() => ({})))),
27 );