The best way to control Claude Code, Codex and more from any computer or phone
| 1 | /** Reconcile closes removed/replaced scopes before creating replacements: at most one live instance per id. */ |
| 2 | import type { |
| 3 | ProviderInstanceConfigMap, |
| 4 | ProviderInstanceId, |
| 5 | SecretReference, |
| 6 | } from "@t3tools/contracts"; |
| 7 | import * as Context from "effect/Context"; |
| 8 | import type * as Effect from "effect/Effect"; |
| 9 | |
| 10 | export interface ProviderInstanceRegistryMutatorShape { |
| 11 | readonly reconcile: (configMap: ProviderInstanceConfigMap) => Effect.Effect<void>; |
| 12 | /** Re-reads the secrets of every instance, or one, and rebuilds those whose secrets changed. */ |
| 13 | readonly reloadSecrets: (instanceId?: ProviderInstanceId) => Effect.Effect<void>; |
| 14 | /** Rebuilds these live instances from their current configuration and the host environment. */ |
| 15 | readonly rebuild: (instanceIds: ReadonlyArray<ProviderInstanceId>) => Effect.Effect<void>; |
| 16 | /** |
| 17 | * Rebuilds the instances that read `reference` with `value`, keeping the other secrets a live |
| 18 | * instance holds, and returns them. A parked instance reads its other secrets from the resolver. |
| 19 | */ |
| 20 | readonly applySecret: ( |
| 21 | reference: SecretReference, |
| 22 | value: string, |
| 23 | ) => Effect.Effect<ReadonlyArray<ProviderInstanceId>>; |
| 24 | } |
| 25 | |
| 26 | export class ProviderInstanceRegistryMutator extends Context.Service< |
| 27 | ProviderInstanceRegistryMutator, |
| 28 | ProviderInstanceRegistryMutatorShape |
| 29 | >()("t3/provider/ProviderInstanceRegistryMutator") {} |