Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

registry.ts

679 lines23.9 KB

1import { EnvironmentId } from "@t3tools/contracts";
2import * as Context from "effect/Context";
3import * as Effect from "effect/Effect";
4import * as Equal from "effect/Equal";
5import * as Exit from "effect/Exit";
6import * as Layer from "effect/Layer";
7import * as Option from "effect/Option";
8import * as Ref from "effect/Ref";
9import * as Schema from "effect/Schema";
10import * as Scope from "effect/Scope";
11import * as Semaphore from "effect/Semaphore";
12import * as Stream from "effect/Stream";
13import * as SubscriptionRef from "effect/SubscriptionRef";
14​
15import * as ClientCapabilities from "../platform/capabilities.ts";
16import {
17 type ConnectionCatalogEntry,
18 type ConnectionRegistration,
19 type PlatformConnectionRegistration,
20 type PrimaryConnectionRegistration,
21 SshConnectionProfile,
22 connectionRegistrationCatalogEntry,
23} from "./catalog.ts";
24import * as ConnectionCredentialStore from "./credentialStore.ts";
25import * as ConnectionProfileStore from "./profileStore.ts";
26import * as Connectivity from "./connectivity.ts";
27import type {
28 ConnectionAttemptError,
29 ConnectionTarget,
30 NetworkStatus,
31 SupervisorConnectionState,
32} from "./model.ts";
33import * as Persistence from "../platform/persistence.ts";
34import * as EnvironmentSupervisor from "./supervisor.ts";
35import * as ConnectionDriver from "./driver.ts";
36import * as ConnectionWakeups from "./wakeups.ts";
37​
38const isSshConnectionProfile = Schema.is(SshConnectionProfile);
39​
40export class EnvironmentNotRegisteredError extends Schema.TaggedErrorClass<EnvironmentNotRegisteredError>()(
41 "EnvironmentNotRegisteredError",
42 {
43 environmentId: EnvironmentId,
44 },
45) {
46 override get message(): string {
47 return `Environment ${this.environmentId} is not registered.`;
48 }
50​
51export class PlatformEnvironmentRemovalError extends Schema.TaggedErrorClass<PlatformEnvironmentRemovalError>()(
52 "PlatformEnvironmentRemovalError",
53 {
54 environmentId: EnvironmentId,
55 },
56) {
57 override get message(): string {
58 return `Platform-managed environment ${this.environmentId} cannot be removed.`;
59 }
61​
62export class EnvironmentRegistry extends Context.Service<
63 EnvironmentRegistry,
64 {
65 readonly entries: SubscriptionRef.SubscriptionRef<
66 ReadonlyMap<EnvironmentId, ConnectionCatalogEntry>
67 >;
68 readonly networkStatus: SubscriptionRef.SubscriptionRef<NetworkStatus>;
69 readonly start: Effect.Effect<void>;
70 readonly register: (
71 registration: ConnectionRegistration,
72 ) => Effect.Effect<void, Persistence.ConnectionPersistenceError>;
73 readonly registerPlatform: (registration: PrimaryConnectionRegistration) => Effect.Effect<void>;
74 readonly reconcilePlatform: (
75 registrations: ReadonlyArray<PlatformConnectionRegistration>,
76 ) => Effect.Effect<void>;
77 readonly remove: (
78 environmentId: EnvironmentId,
79 ) => Effect.Effect<
80 void,
81 | Persistence.ConnectionPersistenceError
82 | ConnectionAttemptError
83 | EnvironmentNotRegisteredError
84 | PlatformEnvironmentRemovalError
85 >;
86 readonly removeRelayEnvironments: () => Effect.Effect<
87 void,
88 | Persistence.ConnectionPersistenceError
89 | ConnectionAttemptError
90 | PlatformEnvironmentRemovalError
91 >;
92 readonly retryNow: (environmentId: EnvironmentId) => Effect.Effect<void>;
93 readonly state: (
94 environmentId: EnvironmentId,
95 ) => Effect.Effect<SupervisorConnectionState, EnvironmentNotRegisteredError>;
96 readonly stateChanges: (
97 environmentId: EnvironmentId,
98 ) => Stream.Stream<SupervisorConnectionState, EnvironmentNotRegisteredError>;
99 readonly run: <A, E, R>(
100 environmentId: EnvironmentId,
101 effect: Effect.Effect<A, E, R>,
102 ) => Effect.Effect<
103 A,
104 E | EnvironmentNotRegisteredError,
105 Exclude<R, EnvironmentSupervisor.EnvironmentSupervisor>
106 >;
107 readonly runStream: <A, E, R>(
108 environmentId: EnvironmentId,
109 stream: Stream.Stream<A, E, R>,
110 ) => Stream.Stream<
111 A,
112 E | EnvironmentNotRegisteredError,
113 Exclude<R, EnvironmentSupervisor.EnvironmentSupervisor>
114 >;
115 readonly followStream: <A, E, R>(
116 environmentId: EnvironmentId,
117 stream: Stream.Stream<A, E, R>,
118 ) => Stream.Stream<A, E, Exclude<R, EnvironmentSupervisor.EnvironmentSupervisor>>;
119 }
120>()("@t3tools/client-runtime/connection/registry/EnvironmentRegistry") {}
121​
122interface EnvironmentServiceScope {
123 readonly entry: ConnectionCatalogEntry;
124 readonly supervisor: EnvironmentSupervisor.EnvironmentSupervisor["Service"];
125 readonly scope: Scope.Closeable;
127​
128export const make = Effect.gen(function* () {
129 const registryScope = yield* Scope.Scope;
130 const storage = yield* Persistence.ConnectionTargetStore;
131 const registrations = yield* Persistence.ConnectionRegistrationStore;
132 const cache = yield* Persistence.EnvironmentCacheStore;
133 const ownedDataCleanup = yield* Persistence.EnvironmentOwnedDataCleanup;
134 const profiles = yield* ConnectionProfileStore.ConnectionProfileStore;
135 const credentials = yield* ConnectionCredentialStore.ConnectionCredentialStore;
136 const connectivity = yield* Connectivity.Connectivity;
137 const driver = yield* ConnectionDriver.ConnectionDriver;
138 const wakeups = yield* ConnectionWakeups.ConnectionWakeups;
139 const ssh = yield* ClientCapabilities.SshEnvironmentGateway;
140 const persistedTargets = yield* storage.list;
141 const initialEntries = new Map(
142 yield* Effect.forEach(
143 persistedTargets,
144 Effect.fn("EnvironmentRegistry.loadCatalogEntry")(function* (target) {
145 const profile =
146 target._tag === "BearerConnectionTarget" || target._tag === "SshConnectionTarget"
147 ? yield* profiles.get(target.connectionId)
148 : Option.none();
149 return [
150 target.environmentId,
151 { target, profile } satisfies ConnectionCatalogEntry,
152 ] as const;
153 }),
154 { concurrency: "unbounded" },
155 ),
156 );
157 const entries =
158 yield* SubscriptionRef.make<ReadonlyMap<EnvironmentId, ConnectionCatalogEntry>>(initialEntries);
159 const networkStatus = yield* SubscriptionRef.make(yield* connectivity.status);
160 const serviceScopes = yield* SubscriptionRef.make<
161 ReadonlyMap<EnvironmentId, EnvironmentServiceScope>
162 >(new Map());
163 const platformEnvironmentIds = yield* Ref.make<ReadonlySet<EnvironmentId>>(new Set());
164 const persistedTargetsByEnvironment = yield* Ref.make<
165 ReadonlyMap<EnvironmentId, ConnectionTarget>
166 >(new Map(persistedTargets.map((target) => [target.environmentId, target])));
167 interface LeaseLock {
168 readonly semaphore: Semaphore.Semaphore;
169 readonly users: number;
170 }
171​
172 const leaseLocks = yield* Ref.make<ReadonlyMap<EnvironmentId, LeaseLock>>(new Map());
173 const leaseLocksGuard = yield* Semaphore.make(1);
174 const started = yield* Ref.make(false);
175​
176 const withLeaseLock = <A, E, R>(
177 environmentId: EnvironmentId,
178 effect: Effect.Effect<A, E, R>,
179 ): Effect.Effect<A, E, R> =>
180 Effect.acquireUseRelease(
181 leaseLocksGuard.withPermits(1)(
182 Effect.gen(function* () {
183 const current = yield* Ref.get(leaseLocks);
184 const existing = current.get(environmentId);
185 if (existing !== undefined) {
186 yield* Ref.set(
187 leaseLocks,
188 new Map(current).set(environmentId, {
189 semaphore: existing.semaphore,
190 users: existing.users + 1,
191 }),
192 );
193 return existing.semaphore;
194 }
195 const semaphore = yield* Semaphore.make(1);
196 yield* Ref.set(leaseLocks, new Map(current).set(environmentId, { semaphore, users: 1 }));
197 return semaphore;
198 }),
199 ),
200 (semaphore) => semaphore.withPermits(1)(effect),
201 (semaphore) =>
202 leaseLocksGuard.withPermits(1)(
203 Ref.update(leaseLocks, (current) => {
204 const existing = current.get(environmentId);
205 if (existing === undefined || existing.semaphore !== semaphore) {
206 return current;
207 }
208 const next = new Map(current);
209 if (existing.users === 1) {
210 next.delete(environmentId);
211 } else {
212 next.set(environmentId, {
213 semaphore,
214 users: existing.users - 1,
215 });
216 }
217 return next;
218 }),
219 ),
220 ).pipe(Effect.withSpan("EnvironmentRegistry.withLeaseLock"));
221​
222 const getEntry = Effect.fn("EnvironmentRegistry.getEntry")(function* (
223 environmentId: EnvironmentId,
224 ) {
225 const entry = (yield* SubscriptionRef.get(entries)).get(environmentId);
226 if (entry === undefined) {
227 return yield* new EnvironmentNotRegisteredError({
228 environmentId,
229 });
230 }
231 return entry;
232 });
233​
234 const closeServiceScope = Effect.fn("EnvironmentRegistry.closeServiceScope")(function* (
235 environmentId: EnvironmentId,
236 ) {
237 const current = yield* SubscriptionRef.get(serviceScopes);
238 const lease = current.get(environmentId);
239 if (lease === undefined) {
240 return;
241 }
242 const next = new Map(current);
243 next.delete(environmentId);
244 yield* SubscriptionRef.set(serviceScopes, next);
245 yield* Scope.close(lease.scope, Exit.void);
246 });
247​
248 const createServiceScope = Effect.fn("EnvironmentRegistry.createServiceScope")(
249 (entry: ConnectionCatalogEntry) =>
250 Effect.uninterruptible(
251 Effect.gen(function* () {
252 const environmentId = entry.target.environmentId;
253 const scope = yield* Scope.fork(registryScope);
254 const supervisor = yield* EnvironmentSupervisor.make(entry, {
255 initiallyDesired: false,
256 }).pipe(
257 Effect.provideService(Connectivity.Connectivity, connectivity),
258 Effect.provideService(ConnectionDriver.ConnectionDriver, driver),
259 Effect.provideService(ConnectionWakeups.ConnectionWakeups, wakeups),
260 Scope.provide(scope),
261 Effect.onError(() => Scope.close(scope, Exit.void)),
262 );
263 yield* supervisor.connect;
264 yield* SubscriptionRef.update(serviceScopes, (current) => {
265 const next = new Map(current);
266 next.set(environmentId, { entry, supervisor, scope });
267 return next;
268 });
269 return supervisor;
270 }),
271 ),
272 );
273​
274 const acquireSupervisor = Effect.fn("EnvironmentRegistry.acquireSupervisor")(function* (
275 environmentId: EnvironmentId,
276 ) {
277 return yield* withLeaseLock(
278 environmentId,
279 Effect.gen(function* () {
280 const entry = yield* getEntry(environmentId);
281 const existing = (yield* SubscriptionRef.get(serviceScopes)).get(environmentId);
282 if (existing !== undefined) {
283 if (Equal.equals(existing.entry, entry)) {
284 return existing.supervisor;
285 }
286 yield* closeServiceScope(environmentId);
287 }
288 return yield* createServiceScope(entry);
289 }),
290 );
291 });
292​
293 const run: EnvironmentRegistry["Service"]["run"] = Effect.fn("EnvironmentRegistry.run")(
294 function* <A, E, R>(environmentId: EnvironmentId, effect: Effect.Effect<A, E, R>) {
295 const supervisor = yield* acquireSupervisor(environmentId);
296 return yield* Effect.provideService(
297 effect,
298 EnvironmentSupervisor.EnvironmentSupervisor,
299 supervisor,
300 );
301 },
302 );
303​
304 const runStream: EnvironmentRegistry["Service"]["runStream"] = <A, E, R>(
305 environmentId: EnvironmentId,
306 stream: Stream.Stream<A, E, R>,
307 ) =>
308 Stream.unwrap(
309 acquireSupervisor(environmentId).pipe(
310 Effect.map((supervisor) =>
311 Stream.provideService(stream, EnvironmentSupervisor.EnvironmentSupervisor, supervisor),
312 ),
313 ),
314 );
315​
316 const followStream: EnvironmentRegistry["Service"]["followStream"] = <A, E, R>(
317 environmentId: EnvironmentId,
318 stream: Stream.Stream<A, E, R>,
319 ) =>
320 Stream.concat(
321 Stream.fromEffect(SubscriptionRef.get(entries)),
322 SubscriptionRef.changes(entries),
323 ).pipe(
324 Stream.map((current) => Option.fromUndefinedOr(current.get(environmentId))),
325 Stream.changes,
326 Stream.switchMap(
327 Option.match({
328 onNone: () => Stream.empty,
329 onSome: () =>
330 Stream.unwrap(
331 acquireSupervisor(environmentId).pipe(
332 Effect.match({
333 onFailure: () => Stream.empty,
334 onSuccess: (supervisor) =>
335 Stream.provideService(
336 stream,
337 EnvironmentSupervisor.EnvironmentSupervisor,
338 supervisor,
339 ),
340 }),
341 ),
342 ),
343 }),
344 ),
345 );
346​
347 const start = Effect.gen(function* () {
348 if (yield* Ref.getAndSet(started, true)) {
349 return;
350 }
351 yield* Effect.forEach(
352 persistedTargets,
353 (target) =>
354 acquireSupervisor(target.environmentId).pipe(
355 Effect.catchTag("EnvironmentNotRegisteredError", () => Effect.void),
356 ),
357 {
358 concurrency: "unbounded",
359 discard: true,
360 },
361 );
362 }).pipe(Effect.withSpan("EnvironmentRegistry.start"));
363​
364 const installEntryLocked = Effect.fn("EnvironmentRegistry.installEntryLocked")(function* (
365 entry: ConnectionCatalogEntry,
366 options?: { readonly retainEquivalentRuntime?: boolean },
367 ) {
368 const target = entry.target;
369 const previous = (yield* SubscriptionRef.get(entries)).get(target.environmentId);
370 const existingScope = (yield* SubscriptionRef.get(serviceScopes)).get(target.environmentId);
371 if (
372 options?.retainEquivalentRuntime === true &&
373 previous !== undefined &&
374 Equal.equals(previous, entry) &&
375 existingScope !== undefined &&
376 Equal.equals(existingScope.entry, entry)
377 ) {
378 return;
379 }
380​
381 yield* closeServiceScope(target.environmentId);
382 yield* SubscriptionRef.update(entries, (current) => {
383 const next = new Map(current);
384 next.set(target.environmentId, entry);
385 return next;
386 });
387 yield* createServiceScope(entry);
388 });
389​
390 const register = Effect.fn("EnvironmentRegistry.register")(function* (
391 registration: ConnectionRegistration,
392 ) {
393 const entry = connectionRegistrationCatalogEntry(registration);
394 const environmentId = entry.target.environmentId;
395 yield* withLeaseLock(
396 environmentId,
397 Effect.gen(function* () {
398 if ((yield* Ref.get(platformEnvironmentIds)).has(environmentId)) {
399 return;
400 }
401 yield* registrations.register(registration);
402 yield* Ref.update(persistedTargetsByEnvironment, (current) => {
403 const next = new Map(current);
404 next.set(environmentId, registration.target);
405 return next;
406 });
407 yield* installEntryLocked(entry);
408 }),
409 );
410 });
411​
412 const installPlatformRegistration = Effect.fn("EnvironmentRegistry.installPlatformRegistration")(
413 function* (registration: PlatformConnectionRegistration) {
414 const entry = connectionRegistrationCatalogEntry(registration);
415 const target = entry.target;
416 yield* withLeaseLock(
417 target.environmentId,
418 Effect.gen(function* () {
419 yield* Ref.update(platformEnvironmentIds, (current) => {
420 const next = new Set(current);
421 next.add(target.environmentId);
422 return next;
423 });
424​
425 // Secondary desktop-local backends (e.g. a parallel WSL backend) live
426 // on their own loopback origin, so they authenticate with a bearer
427 // token instead of the primary's same-origin cookie. Stash it where
428 // the resolver's bearer broker looks it up.
429 if (registration._tag === "BearerConnectionRegistration") {
430 yield* credentials.put(registration.target.connectionId, registration.credential).pipe(
431 Effect.catch((error) =>
432 Effect.logWarning("Could not store the platform bearer credential.", {
433 environmentId: target.environmentId,
434 error,
435 }),
436 ),
437 );
438 }
439​
440 const persistedTarget = (yield* Ref.get(persistedTargetsByEnvironment)).get(
441 target.environmentId,
442 );
443 if (persistedTarget !== undefined) {
444 yield* registrations.remove(persistedTarget).pipe(
445 Effect.tap(() =>
446 Ref.update(persistedTargetsByEnvironment, (current) => {
447 const next = new Map(current);
448 next.delete(target.environmentId);
449 return next;
450 }),
451 ),
452 Effect.catch((error) =>
453 Effect.logWarning(
454 "Could not remove a persisted registration shadowed by a platform environment.",
455 {
456 environmentId: target.environmentId,
457 error,
458 },
459 ),
460 ),
461 );
462 }
463​
464 yield* installEntryLocked(entry, { retainEquivalentRuntime: true });
465 }),
466 );
467 },
468 );
469​
470 // Tear down a platform-managed environment that the host no longer reports
471 // (e.g. the user turned the parallel WSL backend off). Platform environments
472 // bypass the user-facing `remove` guard since they are reconciled from the
473 // bootstrap rather than removed by hand.
474 const removePlatformEnvironment = Effect.fn("EnvironmentRegistry.removePlatformEnvironment")(
475 function* (environmentId: EnvironmentId) {
476 yield* withLeaseLock(
477 environmentId,
478 Effect.gen(function* () {
479 const entry = (yield* SubscriptionRef.get(entries)).get(environmentId);
480 yield* Ref.update(platformEnvironmentIds, (current) => {
481 const next = new Set(current);
482 next.delete(environmentId);
483 return next;
484 });
485 yield* closeServiceScope(environmentId);
486 yield* SubscriptionRef.update(entries, (current) => {
487 const next = new Map(current);
488 next.delete(environmentId);
489 return next;
490 });
491 if (entry !== undefined && entry.target._tag === "BearerConnectionTarget") {
492 yield* credentials.remove(entry.target.connectionId).pipe(
493 Effect.catch((error) =>
494 Effect.logWarning("Could not clear the platform bearer credential.", {
495 environmentId,
496 error,
497 }),
498 ),
499 );
500 }
501 yield* Effect.all(
502 [
503 cache.clear(environmentId).pipe(
504 Effect.catch((error) =>
505 Effect.logWarning("Could not clear cached environment data after removal.", {
506 environmentId,
507 error,
508 }),
509 ),
510 ),
511 ownedDataCleanup.clear(environmentId),
512 ],
513 { concurrency: "unbounded", discard: true },
514 );
515 }),
516 );
517 },
518 );
519​
520 const registerPlatform = Effect.fn("EnvironmentRegistry.registerPlatform")(function* (
521 registration: PrimaryConnectionRegistration,
522 ) {
523 yield* installPlatformRegistration(registration);
524 });
525​
526 // Reconcile the full set of platform-managed environments against what the
527 // host currently reports: add/refresh the desired ones and tear down any
528 // platform environment that disappeared (WSL toggled off, distro switched).
529 const reconcilePlatform = Effect.fn("EnvironmentRegistry.reconcilePlatform")(function* (
530 platformRegistrations: ReadonlyArray<PlatformConnectionRegistration>,
531 ) {
532 const desiredIds = new Set(
533 platformRegistrations.map((registration) => registration.target.environmentId),
534 );
535 const currentPlatformIds = yield* Ref.get(platformEnvironmentIds);
536 yield* Effect.forEach(
537 currentPlatformIds,
538 (environmentId) =>
539 desiredIds.has(environmentId) ? Effect.void : removePlatformEnvironment(environmentId),
540 { discard: true },
541 );
542 yield* Effect.forEach(platformRegistrations, installPlatformRegistration, { discard: true });
543 });
544​
545 const remove = Effect.fn("EnvironmentRegistry.remove")(function* (environmentId: EnvironmentId) {
546 return yield* withLeaseLock(
547 environmentId,
548 Effect.gen(function* () {
549 if ((yield* Ref.get(platformEnvironmentIds)).has(environmentId)) {
550 return yield* new PlatformEnvironmentRemovalError({
551 environmentId,
552 });
553 }
554 const target = (yield* getEntry(environmentId)).target;
555 const profile =
556 target._tag === "BearerConnectionTarget" || target._tag === "SshConnectionTarget"
557 ? yield* profiles.get(target.connectionId)
558 : Option.none();
559​
560 yield* registrations.remove(target);
561 yield* Ref.update(persistedTargetsByEnvironment, (current) => {
562 const next = new Map(current);
563 next.delete(environmentId);
564 return next;
565 });
566 yield* closeServiceScope(environmentId);
567 yield* SubscriptionRef.update(entries, (current) => {
568 const next = new Map(current);
569 next.delete(environmentId);
570 return next;
571 });
572 yield* Effect.all(
573 [
574 cache.clear(environmentId).pipe(
575 Effect.catch((error) =>
576 Effect.logWarning("Could not clear cached environment data after removal.", {
577 environmentId,
578 error,
579 }),
580 ),
581 ),
582 ownedDataCleanup.clear(environmentId),
583 ],
584 { concurrency: "unbounded", discard: true },
585 );
586​
587 if (
588 target._tag === "SshConnectionTarget" &&
589 Option.isSome(profile) &&
590 isSshConnectionProfile(profile.value)
591 ) {
592 yield* ssh.disconnect(profile.value.target).pipe(
593 Effect.tapError((error) =>
594 Effect.logWarning("Could not disconnect the managed SSH environment.", {
595 environmentId,
596 error,
597 }),
598 ),
599 Effect.ignore,
600 );
601 }
602 }),
603 );
604 });
605​
606 const removeRelayEnvironments = Effect.fn("EnvironmentRegistry.removeRelayEnvironments")(
607 function* () {
608 const relayEnvironmentIds = [...(yield* SubscriptionRef.get(entries)).values()]
609 .filter((entry) => entry.target._tag === "RelayConnectionTarget")
610 .map((entry) => entry.target.environmentId);
611​
612 yield* Effect.forEach(
613 relayEnvironmentIds,
614 (environmentId) =>
615 remove(environmentId).pipe(
616 Effect.catchTag("EnvironmentNotRegisteredError", () => Effect.void),
617 ),
618 {
619 concurrency: "unbounded",
620 discard: true,
621 },
622 );
623 },
624 );
625​
626 const retryNow = (environmentId: EnvironmentId) =>
627 acquireSupervisor(environmentId).pipe(
628 Effect.flatMap((supervisor) => supervisor.retryNow),
629 Effect.catchTag("EnvironmentNotRegisteredError", () => Effect.void),
630 Effect.withSpan("EnvironmentRegistry.retryNow"),
631 );
632 const state = Effect.fn("EnvironmentRegistry.state")(function* (environmentId: EnvironmentId) {
633 const supervisor = yield* acquireSupervisor(environmentId);
634 return yield* SubscriptionRef.get(supervisor.state);
635 });
636 const stateChanges = (environmentId: EnvironmentId) =>
637 followStream(
638 environmentId,
639 Stream.unwrap(
640 EnvironmentSupervisor.EnvironmentSupervisor.pipe(
641 Effect.map((supervisor) => SubscriptionRef.changes(supervisor.state)),
642 ),
643 ),
644 );
645​
646 yield* Effect.addFinalizer(() =>
647 SubscriptionRef.get(serviceScopes).pipe(
648 Effect.flatMap((current) =>
649 Effect.forEach(current.values(), (lease) => Scope.close(lease.scope, Exit.void), {
650 concurrency: "unbounded",
651 discard: true,
652 }),
653 ),
654 ),
655 );
656 yield* connectivity.changes.pipe(
657 Stream.runForEach((status) => SubscriptionRef.set(networkStatus, status)),
658 Effect.forkScoped,
659 );
660​
661 return EnvironmentRegistry.of({
662 entries,
663 networkStatus,
664 start,
665 register,
666 registerPlatform,
667 reconcilePlatform,
668 remove,
669 removeRelayEnvironments,
670 retryNow,
671 state,
672 stateChanges,
673 run,
674 runStream,
675 followStream,
676 });
677});
678​
679export const layer = Layer.effect(EnvironmentRegistry, make);