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