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

PeerLinks.ts

620 lines23.8 KB

1import {
2 AuthMcpClientAccess,
3 AuthMcpRegistrationError,
4 AuthMcpTokenError,
5 EnvironmentHttpApi,
6 EnvironmentId,
7 type ExecutionEnvironmentCapabilities,
8 MCP_PEER_LINK_SOFTWARE_ID,
9 type PeerLink,
10 type PeerLinkCreateInput,
11 PeerLinkError,
12 type PeerLinkStatus,
13 type PeerLinkSummary,
14} from "@t3tools/contracts";
15import * as Context from "effect/Context";
16import * as Crypto from "effect/Crypto";
17import * as DateTime from "effect/DateTime";
18import * as Duration from "effect/Duration";
19import * as Effect from "effect/Effect";
20import * as Base64Url from "effect/encoding/Base64Url";
21import * as Hex from "effect/encoding/Hex";
22import * as Layer from "effect/Layer";
23import * as Option from "effect/Option";
24import * as Redacted from "effect/Redacted";
25import * as Result from "effect/Result";
26import * as Schema from "effect/Schema";
27import * as SqlClient from "effect/sql/SqlClient";
28import * as FetchHttpClient from "effect/http/FetchHttpClient";
29import * as HttpClient from "effect/http/HttpClient";
30import * as HttpApiClient from "effect/http-api/HttpApiClient";
31import { isLocalLoopbackHost, isTailnetHost } from "@t3tools/shared/hostClassification";
32​
33import * as ServerSecretStore from "../auth/ServerSecretStore.ts";
34import * as ServerEnvironment from "../environment/ServerEnvironment.ts";
35import * as ServerSettings from "../serverSettings.ts";
36​
37/** The redirect registered for a link. Nothing ever listens there: the code comes back in the response. */
38const LINK_REDIRECT_URI = "http://127.0.0.1/t3code-peer-link";
39/**
40 * How long a peer's descriptor may take before a route counts as unreachable.
41 * A tailnet or relayed route to a machine that is waking up takes longer.
42 */
43const probeTimeout = (origin: string) =>
44 isLocalLoopbackHost(new URL(origin).hostname) ? Duration.seconds(3) : Duration.seconds(10);
45​
46/** A usable link: where to reach the peer and the token to send there. */
47export interface ResolvedPeerLink {
48 readonly link: PeerLink;
49 /** The first address that answered as this peer. */
50 readonly url: string;
51 readonly token: string;
53​
54export const LINKED_ENVIRONMENTS_OFF =
55 "Linked environments is off on this machine. Turn it on in Settings → Labs.";
56​
57/**
58 * Links from this environment to others. Linking signs this environment in to
59 * the peer's `/mcp` as an outside agent with a pairing code from the peer, the
60 * same MCP OAuth flow an outside agent uses, without a browser. The peer's
61 * session token is kept in the server secret store; the table keeps the rest.
62 */
63export class PeerLinks extends Context.Service<
64 PeerLinks,
65 {
66 /** Whether the Linked environments beta (Settings → Labs) is on here. */
67 readonly enabled: Effect.Effect<boolean>;
68 readonly link: (input: PeerLinkCreateInput) => Effect.Effect<PeerLink, PeerLinkError>;
69 /**
70 * The environment answering at `url`, or nothing when it is not a usable
71 * address or does not answer as T3 Code. Sends no credential.
72 */
73 readonly describe: (
74 url: string,
75 ) => Effect.Effect<
76 Option.Option<{ readonly environmentId: EnvironmentId; readonly label: string }>
77 >;
78 readonly list: Effect.Effect<ReadonlyArray<PeerLinkSummary>, PeerLinkError>;
79 /** The stored link, without asking the peer whether it answers. */
80 readonly get: (
81 environmentId: EnvironmentId,
82 ) => Effect.Effect<Option.Option<PeerLink>, PeerLinkError>;
83 /** Forgets the link here. The peer still lists the session until it is revoked there. */
84 readonly unlink: (environmentId: EnvironmentId) => Effect.Effect<boolean, PeerLinkError>;
85 /** An address that answers as the linked peer, with its token, ready to call. */
86 readonly resolve: (
87 environmentId: EnvironmentId,
88 ) => Effect.Effect<ResolvedPeerLink, PeerLinkError>;
89 /** Records the outcome of a call, so listing shows whether the peer answered last time. */
90 readonly recordOutcome: (
91 environmentId: EnvironmentId,
92 outcome: { readonly error: string | null },
93 ) => Effect.Effect<void>;
94 }
95>()("t3/peer/PeerLinks") {}
96​
97interface PeerLinkRow {
98 readonly environment_id: string;
99 readonly secret_name: string;
100 readonly label: string;
101 readonly urls_json: string;
102 readonly access: string;
103 readonly linked_at: string;
104 readonly expires_at: string;
105 readonly last_reached_at: string | null;
106 readonly last_error: string | null;
107 readonly fenced: number;
109​
110const decodeUrls = Schema.decodeUnknownEffect(Schema.fromJsonString(Schema.Array(Schema.String)));
111const encodeUrls = Schema.encodeEffect(Schema.fromJsonString(Schema.Array(Schema.String)));
112const decodeAccess = Schema.decodeUnknownEffect(AuthMcpClientAccess);
113​
114/** Fails with a fixed storage error that keeps its cause; the log gets the details. */
115const failStorage = (cause: unknown) =>
116 Effect.logWarning("Peer link storage failed", cause).pipe(
117 Effect.andThen(
118 Effect.fail(
119 new PeerLinkError({
120 reason: "storage",
121 message:
122 "Linked environments could not be read or saved here. The server log has details.",
123 cause,
124 }),
125 ),
126 ),
127 );
128​
129/**
130 * The base URL a peer is reached at, normalised to its origin. The pairing
131 * code and then the link's token travel to it, so plain http is accepted only
132 * where the network already encrypts: this machine, or a Tailscale address.
133 */
134const peerOrigin = (url: string) => {
135 const parsed = URL.parse(url);
136 if (parsed === null || (parsed.protocol !== "https:" && parsed.protocol !== "http:")) {
137 return Effect.fail(
138 new PeerLinkError({
139 reason: "unreachable",
140 message: `${url} is not an http or https address.`,
141 }),
142 );
143 }
144 if (
145 parsed.protocol === "http:" &&
146 !isLocalLoopbackHost(parsed.hostname) &&
147 !isTailnetHost(parsed.hostname)
148 ) {
149 return Effect.fail(
150 new PeerLinkError({
151 reason: "unreachable",
152 message: `${url} is plain http, which would send the link's credentials unencrypted. Use its https address, or its Tailscale address.`,
153 }),
154 );
155 }
156 return Effect.succeed(parsed.origin);
157};
158​
159/** Whether a peer holds a linked agent to its limits and keeps its work within its link. */
160const linkLimitsHold = (peer: { readonly capabilities: ExecutionEnvironmentCapabilities }) =>
161 peer.capabilities.mcpModeLimitHeader === true && peer.capabilities.linkFence === true;
162​
163const make = Effect.gen(function* () {
164 const sql = yield* SqlClient.SqlClient;
165 const secrets = yield* ServerSecretStore.ServerSecretStore;
166 const crypto = yield* Crypto.Crypto;
167 const httpClient = yield* HttpClient.HttpClient;
168 const environment = yield* ServerEnvironment.ServerEnvironment;
169 const serverSettings = yield* ServerSettings.ServerSettingsService;
170 const enabled = serverSettings.getSettings.pipe(
171 Effect.map((settings) => settings.linkedEnvironmentsEnabled),
172 Effect.orElseSucceed(() => false),
173 );
174​
175 /** A fresh name for one link's token; the row records it. */
176 const newSecretName = crypto.randomBytes(16).pipe(
177 Effect.map((bytes) => `peer-link-${Hex.encode(bytes)}`),
178 Effect.orDie,
179 );
180​
181 // Only the origin `peerOrigin` checked may receive a pairing code or token:
182 // a redirect could forward them anywhere, including plain http.
183 const peerHttpClient = HttpClient.transform(httpClient, (response) =>
184 Effect.provideService(response, FetchHttpClient.RequestInit, { redirect: "manual" }),
185 );
186​
187 const clientFor = (origin: string) =>
188 HttpApiClient.make(EnvironmentHttpApi, { baseUrl: origin }).pipe(
189 Effect.provideService(HttpClient.HttpClient, peerHttpClient),
190 );
191​
192 /** The environment answering at `origin`, or nothing when it does not answer as T3 Code. */
193 const describe = (origin: string) =>
194 clientFor(origin).pipe(
195 Effect.flatMap((client) => client.metadata.descriptor()),
196 Effect.timeout(probeTimeout(origin)),
197 Effect.option,
198 );
199​
200 const toLink = Effect.fn("PeerLinks.toLink")(function* (row: PeerLinkRow) {
201 return {
202 environmentId: EnvironmentId.make(row.environment_id),
203 label: row.label,
204 urls: yield* decodeUrls(row.urls_json),
205 access: yield* decodeAccess(row.access),
206 linkedAt: DateTime.makeUnsafe(row.linked_at),
207 // Its token predates link fencing, so the peer would not fence its work:
208 // like an expired link, only a new pairing code brings it back.
209 expiresAt: DateTime.makeUnsafe(row.fenced === 1 ? row.expires_at : row.linked_at),
210 lastReachedAt: row.last_reached_at === null ? null : DateTime.makeUnsafe(row.last_reached_at),
211 lastError: row.last_error,
212 } satisfies PeerLink;
213 }, Effect.catch(failStorage));
214​
215 const readRows = sql<PeerLinkRow>`
216 SELECT * FROM peer_environment_links ORDER BY label, environment_id
217 `.pipe(Effect.catch(failStorage));
218​
219 const readRow = (environmentId: EnvironmentId) =>
220 sql<PeerLinkRow>`
221 SELECT * FROM peer_environment_links WHERE environment_id = ${environmentId}
222 `.pipe(
223 Effect.catch(failStorage),
224 Effect.map((rows) => Option.fromNullishOr(rows[0])),
225 );
226​
227 /** Signs in to the peer's `/mcp` with a pairing code: register, decide, exchange. */
228 const signIn = Effect.fn("PeerLinks.signIn")(
229 function* (origin: string, input: PeerLinkCreateInput, clientName: string) {
230 const client = yield* clientFor(origin);
231 // Only the peer's own refusals are rejections. A dropped connection or
232 // an answer this version cannot read is classified below.
233 const registered = yield* client.mcpOAuth
234 .register({
235 payload: {
236 client_name: clientName,
237 redirect_uris: [LINK_REDIRECT_URI],
238 software_id: MCP_PEER_LINK_SOFTWARE_ID,
239 },
240 })
241 .pipe(
242 // A plain Schema.Error has no tag to catch by.
243 Effect.catchIf(Schema.is(AuthMcpRegistrationError), (error) =>
244 Effect.fail(
245 new PeerLinkError({
246 reason: "pairing_rejected",
247 message: `The peer refused to register this environment: ${error.message}`,
248 }),
249 ),
250 ),
251 );
252 const verifier = Base64Url.encode(yield* crypto.randomBytes(32).pipe(Effect.orDie));
253 const challenge = Base64Url.encode(
254 yield* crypto.digest("SHA-256", new TextEncoder().encode(verifier)).pipe(Effect.orDie),
255 );
256 const state = Base64Url.encode(yield* crypto.randomBytes(16).pipe(Effect.orDie));
257 const resource = `${origin}/mcp`;
258 const decided = yield* client.mcpOAuth
259 .decision({
260 payload: {
261 authorization: {
262 response_type: "code",
263 client_id: registered.client_id,
264 redirect_uri: LINK_REDIRECT_URI,
265 code_challenge: challenge,
266 code_challenge_method: "S256",
267 state: Redacted.make(state),
268 resource,
269 },
270 decision: { _tag: "pairing-code", access: input.access, code: input.pairingCode },
271 },
272 })
273 .pipe(
274 Effect.catchTags({
275 AuthMcpApprovalError: (error) =>
276 Effect.fail(
277 new PeerLinkError({ reason: "pairing_rejected", message: error.message }),
278 ),
279 }),
280 );
281 const redirect = URL.parse(decided.redirectTo);
282 if (redirect === null) {
283 return yield* new PeerLinkError({
284 reason: "incompatible",
285 message: `${origin} answered the sign-in with an address this version cannot read. Update both environments.`,
286 });
287 }
288 const code = redirect.searchParams.get("code");
289 if (code === null || redirect.searchParams.get("state") !== state) {
290 return yield* new PeerLinkError({
291 reason: "pairing_rejected",
292 message:
293 redirect.searchParams.get("error_description") ??
294 "The peer did not approve the link. Check the pairing code and try again.",
295 });
296 }
297 return yield* client.mcpOAuth
298 .token({
299 payload: {
300 grant_type: "authorization_code",
301 code: Redacted.make(code),
302 redirect_uri: LINK_REDIRECT_URI,
303 client_id: registered.client_id,
304 code_verifier: Redacted.make(verifier),
305 resource,
306 },
307 })
308 .pipe(
309 Effect.catchIf(Schema.is(AuthMcpTokenError), (error) =>
310 Effect.fail(
311 new PeerLinkError({
312 reason: "pairing_rejected",
313 message: `The peer refused the sign-in: ${error.message}`,
314 }),
315 ),
316 ),
317 );
318 },
319 (effect, origin) =>
320 effect.pipe(
321 // Endpoint errors are mapped above; what is left is the transport or an
322 // answer this version cannot decode.
323 Effect.catchTags({
324 SchemaError: (cause) =>
325 Effect.fail(
326 new PeerLinkError({
327 reason: "incompatible",
328 message: `${origin} answered in a shape this version does not understand. Update both environments.`,
329 cause,
330 }),
331 ),
332 HttpClientError: (cause) =>
333 Effect.fail(
334 new PeerLinkError({
335 reason: "unreachable",
336 message: `${origin} stopped answering while linking.`,
337 cause,
338 }),
339 ),
340 }),
341 ),
342 );
343​
344 /**
345 * The addresses that answer as `environmentId`, in the order given, with
346 * what the first one answered. Addresses this environment would not send
347 * credentials to are skipped; when every one is, the failure says why.
348 */
349 const answeringAs = Effect.fn("PeerLinks.answeringAs")(function* (
350 urls: ReadonlyArray<string>,
351 environmentId: EnvironmentId,
352 name: string,
353 ) {
354 const checked = yield* Effect.forEach(
355 urls,
356 (url) =>
357 Effect.gen(function* () {
358 const origin = yield* peerOrigin(url);
359 return { origin, descriptor: yield* describe(origin) };
360 }).pipe(Effect.result),
361 { concurrency: "unbounded" },
362 );
363 const matching = checked.flatMap((result) =>
364 Result.isSuccess(result) &&
365 Option.isSome(result.success.descriptor) &&
366 result.success.descriptor.value.environmentId === environmentId
367 ? [{ origin: result.success.origin, descriptor: result.success.descriptor.value }]
368 : [],
369 );
370 const first = matching[0];
371 if (first === undefined) {
372 const refusals = checked.flatMap((result) =>
373 Result.isFailure(result) ? [result.failure.message] : [],
374 );
375 return yield* new PeerLinkError({
376 reason: "unreachable",
377 message:
378 refusals.length === checked.length
379 ? `This environment could not reach ${name}: ${refusals.join(" ")}`
380 : `This environment could not reach ${name} at ${urls.join(", ")}.`,
381 });
382 }
383 // Each address is kept once, even when two spellings share an origin.
384 const origins = [...new Set(matching.map((found) => found.origin))];
385 return { primary: first.origin, peer: first.descriptor, origins };
386 });
387​
388 /** The peer at `url`, with every address checked for credentials first. */
389 const answeringAt = Effect.fn("PeerLinks.answeringAt")(function* (urls: ReadonlyArray<string>) {
390 const origins = yield* Effect.forEach(urls, peerOrigin);
391 const primary = origins[0]!;
392 const descriptor = yield* describe(primary);
393 if (Option.isNone(descriptor)) {
394 return yield* new PeerLinkError({
395 reason: "not_a_t3_environment",
396 message: `Nothing at ${primary} answered as a T3 Code environment.`,
397 });
398 }
399 return { primary, peer: descriptor.value, origins };
400 });
401​
402 const link: PeerLinks["Service"]["link"] = Effect.fn("PeerLinks.link")(function* (input) {
403 if (!(yield* enabled)) {
404 return yield* new PeerLinkError({ reason: "disabled", message: LINKED_ENVIRONMENTS_OFF });
405 }
406 const urls = [input.url, ...(input.alternateUrls ?? [])];
407 // The user picked a machine: link through the addresses that prove to
408 // be it, so a reused LAN address never receives the pairing code.
409 const { primary, peer, origins } =
410 input.expectedEnvironmentId === undefined
411 ? yield* answeringAt(urls)
412 : yield* answeringAs(
413 urls,
414 input.expectedEnvironmentId,
415 input.expectedLabel ?? input.expectedEnvironmentId,
416 );
417 const self = yield* environment.getDescriptor;
418 if (peer.environmentId === self.environmentId) {
419 return yield* new PeerLinkError({
420 reason: "self",
421 message: "That address is this environment.",
422 });
423 }
424 if (!linkLimitsHold(peer)) {
425 return yield* new PeerLinkError({
426 reason: "incompatible",
427 message: `${peer.label} runs a T3 Code version that cannot keep a linked agent's limits. Update it, then link again.`,
428 });
429 }
430 const issued = yield* signIn(primary, input, `T3 Code · ${self.label}`);
431 const now = yield* DateTime.now;
432 const linked: PeerLink = {
433 environmentId: peer.environmentId,
434 label: peer.label,
435 urls: origins,
436 access: input.access,
437 linkedAt: now,
438 expiresAt: DateTime.add(now, { seconds: issued.expires_in }),
439 lastReachedAt: now,
440 lastError: null,
441 };
442 // The token goes under a name of its own before the row points at it,
443 // so the row and its token are replaced together.
444 const secretName = yield* newSecretName;
445 yield* secrets
446 .set(secretName, new TextEncoder().encode(issued.access_token))
447 .pipe(Effect.catch(failStorage));
448 // A token no row names could never be removed.
449 const previous = yield* Effect.gen(function* () {
450 const urlsJson = yield* encodeUrls(origins).pipe(Effect.catch(failStorage));
451 const previous = yield* readRow(peer.environmentId);
452 yield* sql`
453 INSERT INTO peer_environment_links (
454 environment_id, secret_name, label, urls_json, access, linked_at, expires_at,
455 last_reached_at, last_error, fenced
456 ) VALUES (
457 ${linked.environmentId}, ${secretName}, ${linked.label}, ${urlsJson}, ${linked.access},
458 ${DateTime.formatIso(linked.linkedAt)}, ${DateTime.formatIso(linked.expiresAt)},
459 ${DateTime.formatIso(now)}, NULL, 1
460 )
461 ON CONFLICT (environment_id) DO UPDATE SET
462 secret_name = excluded.secret_name,
463 fenced = excluded.fenced,
464 label = excluded.label,
465 urls_json = excluded.urls_json,
466 access = excluded.access,
467 linked_at = excluded.linked_at,
468 expires_at = excluded.expires_at,
469 last_reached_at = excluded.last_reached_at,
470 last_error = NULL
471 `.pipe(Effect.catch(failStorage));
472 return previous;
473 }).pipe(Effect.onError(() => secrets.remove(secretName).pipe(Effect.ignore)));
474 // Linking again replaces the old token. A racing link may leave its own
475 // behind; it is unused either way.
476 if (Option.isSome(previous) && previous.value.secret_name !== secretName) {
477 yield* secrets.remove(previous.value.secret_name).pipe(Effect.ignore);
478 }
479 return linked;
480 });
481​
482 const describeUrl: PeerLinks["Service"]["describe"] = (url) =>
483 peerOrigin(url).pipe(
484 Effect.flatMap(describe),
485 Effect.map(Option.map((peer) => ({ environmentId: peer.environmentId, label: peer.label }))),
486 Effect.orElseSucceed(() => Option.none()),
487 );
488​
489 const statusOf = (link: PeerLink, now: DateTime.Utc) =>
490 DateTime.isLessThanOrEqualTo(link.expiresAt, now)
491 ? Effect.succeed<PeerLinkStatus>("expired")
492 : Effect.findFirst(link.urls, (url) =>
493 describe(url).pipe(
494 Effect.map(
495 (found) => Option.isSome(found) && found.value.environmentId === link.environmentId,
496 ),
497 ),
498 ).pipe(
499 Effect.map((answered): PeerLinkStatus =>
500 Option.isSome(answered) ? "reachable" : "unreachable",
501 ),
502 );
503​
504 const list: PeerLinks["Service"]["list"] = Effect.gen(function* () {
505 const links = yield* Effect.forEach(yield* readRows, toLink);
506 const now = yield* DateTime.now;
507 return yield* Effect.forEach(
508 links,
509 (link) => statusOf(link, now).pipe(Effect.map((status) => ({ ...link, status }))),
510 { concurrency: "unbounded" },
511 );
512 });
513​
514 const get: PeerLinks["Service"]["get"] = (environmentId) =>
515 readRow(environmentId).pipe(
516 Effect.flatMap(
517 Option.match({
518 onNone: () => Effect.succeedNone,
519 onSome: (row) => Effect.asSome(toLink(row)),
520 }),
521 ),
522 );
523​
524 const unlink: PeerLinks["Service"]["unlink"] = Effect.fn("PeerLinks.unlink")(
525 function* (environmentId) {
526 const deleted = yield* sql<{ secret_name: string }>`
527 DELETE FROM peer_environment_links WHERE environment_id = ${environmentId}
528 RETURNING secret_name
529 `.pipe(Effect.catch(failStorage));
530 for (const row of deleted) {
531 yield* secrets.remove(row.secret_name).pipe(Effect.catch(failStorage));
532 }
533 return deleted.length > 0;
534 },
535 );
536​
537 const resolve: PeerLinks["Service"]["resolve"] = Effect.fn("PeerLinks.resolve")(
538 function* (environmentId) {
539 const row = yield* readRow(environmentId);
540 if (Option.isNone(row)) {
541 return yield* new PeerLinkError({
542 reason: "unknown_link",
543 message: `This environment is not linked to ${environmentId}. t3_environment_links lists the linked ones.`,
544 });
545 }
546 const link = yield* toLink(row.value);
547 if (DateTime.isLessThanOrEqualTo(link.expiresAt, yield* DateTime.now)) {
548 return yield* new PeerLinkError({
549 reason: "expired",
550 message: `The link to ${link.label} expired. Link it again with a new pairing code from ${link.label}.`,
551 });
552 }
553 const stored = yield* secrets.get(row.value.secret_name).pipe(Effect.catch(failStorage));
554 if (Option.isNone(stored)) {
555 return yield* new PeerLinkError({
556 reason: "unknown_link",
557 message: `The link to ${link.label} lost its credential. Link it again.`,
558 });
559 }
560 // The token goes only to an address that proves it is this peer, so a
561 // reused LAN address or a moved hostname never receives it.
562 let fenced = true;
563 const url = yield* Effect.findFirst(link.urls, (candidate) =>
564 describe(candidate).pipe(
565 Effect.map((found) => {
566 if (Option.isNone(found) || found.value.environmentId !== environmentId) return false;
567 fenced = linkLimitsHold(found.value);
568 return true;
569 }),
570 ),
571 );
572 if (Option.isNone(url)) {
573 return yield* new PeerLinkError({
574 reason: "unreachable",
575 message: `${link.label} did not answer at ${link.urls.join(", ")}.`,
576 });
577 }
578 // A link made before the peer had to fence linked work, or a peer moved
579 // back to such a version, would carry work past those limits.
580 if (!fenced) {
581 return yield* new PeerLinkError({
582 reason: "incompatible",
583 message: `${link.label} runs a T3 Code version that cannot keep a linked agent's limits. Update it, then link again.`,
584 });
585 }
586 return { link, url: url.value, token: new TextDecoder().decode(stored.value) };
587 },
588 );
589​
590 const recordOutcome: PeerLinks["Service"]["recordOutcome"] = (environmentId, outcome) =>
591 DateTime.now.pipe(
592 Effect.flatMap((now) =>
593 outcome.error === null
594 ? sql`
595 UPDATE peer_environment_links
596 SET last_reached_at = ${DateTime.formatIso(now)}, last_error = NULL
597 WHERE environment_id = ${environmentId}
598 `
599 : sql`
600 UPDATE peer_environment_links SET last_error = ${outcome.error}
601 WHERE environment_id = ${environmentId}
602 `,
603 ),
604 Effect.asVoid,
605 Effect.ignoreCause({ log: true }),
606 );
607​
608 return PeerLinks.of({
609 enabled,
610 link,
611 describe: describeUrl,
612 list,
613 get,
614 unlink,
615 resolve,
616 recordOutcome,
617 });
618});
619​
620export const layer = Layer.effect(PeerLinks, make);