<Self, S extends Hyperlink.Spec, HSelf, R = never>(
tag: Hyperlink.NodeBoundTag<Self, S, HSelf>,
impl:
| Hyperlink.ImplOf<S>
| Hyperlink.Driver<S, R>
| Effect.Effect<
Hyperlink.ImplOf<S> | Hyperlink.Driver<S, R>,
never,
R
>,
options?: ListenOptions
): Layer.Layer<Self | Hyperlink.Local<Self> | ListenNode, never, R>
<
Node extends AnyNode & { readonly [catalogSym]?: unknown },
const Serves extends ServeLayerList
>(
node: Node,
serves: Serves & ServesForCatalog<CatalogROut<Node>, Serves>,
options?: ListenOptions
): Layer.Layer<
Layer.Success<Serves[number]> | ListenNode,
Layer.Error<Serves[number]>,
Layer.Services<Serves[number]>
>Neutral catalog spine (C2) — no transport bind. Prefer unix / http / ws.
IpcSocket, Http, WebSocket, address-less, nameless, and Tag+impl fail with ListenUseProtocol → use the matching protocol entry.
export function function listen<Self, S extends Hyperlink.Spec, HSelf, R = never>(tag: Hyperlink.NodeBoundTag<Self, S, HSelf>, impl: Hyperlink.ImplOf<S> | Hyperlink.Driver<S, R> | Effect.Effect<Hyperlink.ImplOf<S> | Hyperlink.Driver<S, R>, never, R>, options?: ListenOptions): Layer.Layer<Self | Hyperlink.Local<Self> | ListenNode, never, R> (+1 overload)Neutral catalog spine (C2) — no transport bind. Prefer
unix
/
http
/
ws
.
**IpcSocket, Http, WebSocket, address-less, nameless, and Tag+impl fail with
ListenUseProtocol
** → use the matching protocol entry.
listen<
function (type parameter) Self in listen<Self, S extends Hyperlink.Spec, HSelf, R = never>(tag: Hyperlink.NodeBoundTag<Self, S, HSelf>, impl: Hyperlink.ImplOf<S> | Hyperlink.Driver<S, R> | Effect.Effect<Hyperlink.ImplOf<S> | Hyperlink.Driver<S, R>, never, R>, options?: ListenOptions): Layer.Layer<Self | Hyperlink.Local<Self> | ListenNode, never, R>Self,
function (type parameter) S in listen<Self, S extends Hyperlink.Spec, HSelf, R = never>(tag: Hyperlink.NodeBoundTag<Self, S, HSelf>, impl: Hyperlink.ImplOf<S> | Hyperlink.Driver<S, R> | Effect.Effect<Hyperlink.ImplOf<S> | Hyperlink.Driver<S, R>, never, R>, options?: ListenOptions): Layer.Layer<Self | Hyperlink.Local<Self> | ListenNode, never, R>S extends import HyperlinkHyperlink.Spec,
function (type parameter) HSelf in listen<Self, S extends Hyperlink.Spec, HSelf, R = never>(tag: Hyperlink.NodeBoundTag<Self, S, HSelf>, impl: Hyperlink.ImplOf<S> | Hyperlink.Driver<S, R> | Effect.Effect<Hyperlink.ImplOf<S> | Hyperlink.Driver<S, R>, never, R>, options?: ListenOptions): Layer.Layer<Self | Hyperlink.Local<Self> | ListenNode, never, R>HSelf,
function (type parameter) R in listen<Self, S extends Hyperlink.Spec, HSelf, R = never>(tag: Hyperlink.NodeBoundTag<Self, S, HSelf>, impl: Hyperlink.ImplOf<S> | Hyperlink.Driver<S, R> | Effect.Effect<Hyperlink.ImplOf<S> | Hyperlink.Driver<S, R>, never, R>, options?: ListenOptions): Layer.Layer<Self | Hyperlink.Local<Self> | ListenNode, never, R>R = never,
>(
tag: Hyperlink.NodeBoundTag<Self, S, HSelf>(parameter) tag: {
description: string | undefined;
key: Identifier;
of: (this: void, self: Simplify<{ readonly [K in keyof S]: S[K] extends Hyperlink.FromLocalMethod<infer M> ? Hyperlink.InjectLocal<M, Self> : S[K] extends Hyperlink.LocalMethod<infer T> ? Hyperlink.LocalEffect<T, never, Self> : S[K] extends Hy…;
context: (self: Simplify<{ readonly [K in keyof S]: S[K] extends Hyperlink.FromLocalMethod<infer M> ? Hyperlink.InjectLocal<M, Self> : S[K] extends Hyperlink.LocalMethod<infer T> ? Hyperlink.LocalEffect<T, never, Self> : S[K] extends Hyperlink.Defa…;
use: (f: (service: Simplify<{ readonly [K in keyof S]: S[K] extends Hyperlink.FromLocalMethod<infer M> ? Hyperlink.InjectLocal<M, Self> : S[K] extends Hyperlink.LocalMethod<infer T> ? Hyperlink.LocalEffect<T, never, Self> : S[K] extends Hyperli…;
useSync: (f: (service: Simplify<{ readonly [K in keyof S]: S[K] extends Hyperlink.FromLocalMethod<infer M> ? Hyperlink.InjectLocal<M, Self> : S[K] extends Hyperlink.LocalMethod<infer T> ? Hyperlink.LocalEffect<T, never, Self> : S[K] extends Hyperli…;
Identifier: Identifier;
Service: Shape;
stack: string | undefined;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
tag: import HyperlinkHyperlink.interface NodeBoundTag<Self, S extends Hyperlink.Spec, HSelf, Svc = Simplify<{ readonly [K in keyof S]: S[K] extends Hyperlink.FromLocalMethod<infer M> ? Hyperlink.InjectLocal<M, Self> : S[K] extends Hyperlink.LocalMethod<...> ? Hyperlink.LocalEffect<...> : S[K] extends Hyperlink.DefaultMethod<...> ? F : S[K] extends { ...; } ? SuccessOf<...> : S[K] extends { ...; } ? Hyperlink.Subscribable<...> : S[K] extends { ...; } ? ClientMethod<...> : S[K] extends Hyperlink.Spec ? Simplify<...> : never; }>>A
HyperlinkTag
bound to a concrete
Node
— its [nodeSym] narrowed to that node's
NodeKey<HSelf>, which is how
Hyperlink.client
discriminates the node-aware path. Returned
by the node-bearing tag constructors. It's a named type (not an inline & { [nodeSym] }) so a
consumer can export a node-bearing tag without leaking the internal symbol (TS4020).
NodeBoundTag<function (type parameter) Self in listen<Self, S extends Hyperlink.Spec, HSelf, R = never>(tag: Hyperlink.NodeBoundTag<Self, S, HSelf>, impl: Hyperlink.ImplOf<S> | Hyperlink.Driver<S, R> | Effect.Effect<Hyperlink.ImplOf<S> | Hyperlink.Driver<S, R>, never, R>, options?: ListenOptions): Layer.Layer<Self | Hyperlink.Local<Self> | ListenNode, never, R>Self, function (type parameter) S in listen<Self, S extends Hyperlink.Spec, HSelf, R = never>(tag: Hyperlink.NodeBoundTag<Self, S, HSelf>, impl: Hyperlink.ImplOf<S> | Hyperlink.Driver<S, R> | Effect.Effect<Hyperlink.ImplOf<S> | Hyperlink.Driver<S, R>, never, R>, options?: ListenOptions): Layer.Layer<Self | Hyperlink.Local<Self> | ListenNode, never, R>S, function (type parameter) HSelf in listen<Self, S extends Hyperlink.Spec, HSelf, R = never>(tag: Hyperlink.NodeBoundTag<Self, S, HSelf>, impl: Hyperlink.ImplOf<S> | Hyperlink.Driver<S, R> | Effect.Effect<Hyperlink.ImplOf<S> | Hyperlink.Driver<S, R>, never, R>, options?: ListenOptions): Layer.Layer<Self | Hyperlink.Local<Self> | ListenNode, never, R>HSelf>,
impl: | Hyperlink.ImplOf<S>
| Hyperlink.Driver<S, R>
| Effect.Effect<
| Hyperlink.ImplOf<S>
| Hyperlink.Driver<S, R>,
never,
R
>
impl:
| import HyperlinkHyperlink.type ImplOf<S extends Hyperlink.Spec> = { readonly [K in keyof S as S[K] extends Hyperlink.AnyDefaultMethod ? never : K]: S[K] extends Hyperlink.FromLocalMethod<infer M> ? M : S[K] extends Hyperlink.LocalMethod<infer T> ? T : S[K] extends {
readonly _tag: "ref";
} ? Hyperlink.Subscribable<SuccessOf<AsMethod<S[K]>>> : S[K] extends {
readonly kind: Hyperlink.MethodKind;
} ? Hyperlink.ServiceMethod<AsMethod<S[K]>> : S[K] extends Hyperlink.Spec ? Hyperlink.ImplOf<...> : never; }
The implementation a
localLayer
/
serve
expects: wire members are their
Effect/Stream/function, and each
LocalMethod
is its raw value T (the toolkit wraps
it to require the
Local
). When an impl needs a capability (e.g.
peers
) to
build, provide it via the Effect form of
Hyperlink.layer
/
Hyperlink.serve
— resolve it once, and the members close over it.
A
value
field's impl is the Effect<A, E> resolved once at acquire — that differs from how
it surfaces in
ServiceOf
(a plain A), so annotate an impl with ImplOf, not
ServiceOf. A
ref
's impl is the
Subscribable
(not the consumer shape alone).
default
members are Tag-baked — omitted from the impl. A nested group that is only
default members still appears as {} (pass an empty object). Piped
defaults
keys may
be overridden via
ImplWithDefaultOverrides
.
ImplOf<function (type parameter) S in listen<Self, S extends Hyperlink.Spec, HSelf, R = never>(tag: Hyperlink.NodeBoundTag<Self, S, HSelf>, impl: Hyperlink.ImplOf<S> | Hyperlink.Driver<S, R> | Effect.Effect<Hyperlink.ImplOf<S> | Hyperlink.Driver<S, R>, never, R>, options?: ListenOptions): Layer.Layer<Self | Hyperlink.Local<Self> | ListenNode, never, R>S>
| import HyperlinkHyperlink.interface Driver<S extends Hyperlink.Spec, R>A HyperService impl before worker-context discharge — the impl still carries requirement R on its
Effect methods, paired with the
Context.Context
captured at build time. Used by
WorkPool
,
Gate
, and
Daemon
(any toolkit HyperService that builds
its driver under ambient R).
layer
/
serve
grant locally via
grantLocal
;
serveRemote
defers discharge to each wire call via
invokeWireMethodWithContext
so
one materialization backs both paths.
Driver<function (type parameter) S in listen<Self, S extends Hyperlink.Spec, HSelf, R = never>(tag: Hyperlink.NodeBoundTag<Self, S, HSelf>, impl: Hyperlink.ImplOf<S> | Hyperlink.Driver<S, R> | Effect.Effect<Hyperlink.ImplOf<S> | Hyperlink.Driver<S, R>, never, R>, options?: ListenOptions): Layer.Layer<Self | Hyperlink.Local<Self> | ListenNode, never, R>S, function (type parameter) R in listen<Self, S extends Hyperlink.Spec, HSelf, R = never>(tag: Hyperlink.NodeBoundTag<Self, S, HSelf>, impl: Hyperlink.ImplOf<S> | Hyperlink.Driver<S, R> | Effect.Effect<Hyperlink.ImplOf<S> | Hyperlink.Driver<S, R>, never, R>, options?: ListenOptions): Layer.Layer<Self | Hyperlink.Local<Self> | ListenNode, never, R>R>
| import EffectEffect.interface Effect<out A, out E = never, out R = never>The Effect interface defines a value that lazily describes a workflow or
job. The workflow requires some context R, and may fail with an error of
type E, or succeed with a value of type A.
When to use
Use when you need to represent a lazy, composable workflow that can require
services, fail with a typed error, or succeed with a typed value.
Details
Effect values model resourceful interaction with the outside world,
including synchronous, asynchronous, concurrent, and parallel interaction.
They use a fiber-based concurrency model, with built-in support for
scheduling, fine-grained interruption, structured concurrency, and high
scalability.
To run an Effect value, you need a Runtime, which is a type that is
capable of executing Effect values.
Effect<
import HyperlinkHyperlink.type ImplOf<S extends Hyperlink.Spec> = { readonly [K in keyof S as S[K] extends Hyperlink.AnyDefaultMethod ? never : K]: S[K] extends Hyperlink.FromLocalMethod<infer M> ? M : S[K] extends Hyperlink.LocalMethod<infer T> ? T : S[K] extends {
readonly _tag: "ref";
} ? Hyperlink.Subscribable<SuccessOf<AsMethod<S[K]>>> : S[K] extends {
readonly kind: Hyperlink.MethodKind;
} ? Hyperlink.ServiceMethod<AsMethod<S[K]>> : S[K] extends Hyperlink.Spec ? Hyperlink.ImplOf<...> : never; }
The implementation a
localLayer
/
serve
expects: wire members are their
Effect/Stream/function, and each
LocalMethod
is its raw value T (the toolkit wraps
it to require the
Local
). When an impl needs a capability (e.g.
peers
) to
build, provide it via the Effect form of
Hyperlink.layer
/
Hyperlink.serve
— resolve it once, and the members close over it.
A
value
field's impl is the Effect<A, E> resolved once at acquire — that differs from how
it surfaces in
ServiceOf
(a plain A), so annotate an impl with ImplOf, not
ServiceOf. A
ref
's impl is the
Subscribable
(not the consumer shape alone).
default
members are Tag-baked — omitted from the impl. A nested group that is only
default members still appears as {} (pass an empty object). Piped
defaults
keys may
be overridden via
ImplWithDefaultOverrides
.
ImplOf<function (type parameter) S in listen<Self, S extends Hyperlink.Spec, HSelf, R = never>(tag: Hyperlink.NodeBoundTag<Self, S, HSelf>, impl: Hyperlink.ImplOf<S> | Hyperlink.Driver<S, R> | Effect.Effect<Hyperlink.ImplOf<S> | Hyperlink.Driver<S, R>, never, R>, options?: ListenOptions): Layer.Layer<Self | Hyperlink.Local<Self> | ListenNode, never, R>S> | import HyperlinkHyperlink.interface Driver<S extends Hyperlink.Spec, R>A HyperService impl before worker-context discharge — the impl still carries requirement R on its
Effect methods, paired with the
Context.Context
captured at build time. Used by
WorkPool
,
Gate
, and
Daemon
(any toolkit HyperService that builds
its driver under ambient R).
layer
/
serve
grant locally via
grantLocal
;
serveRemote
defers discharge to each wire call via
invokeWireMethodWithContext
so
one materialization backs both paths.
Driver<function (type parameter) S in listen<Self, S extends Hyperlink.Spec, HSelf, R = never>(tag: Hyperlink.NodeBoundTag<Self, S, HSelf>, impl: Hyperlink.ImplOf<S> | Hyperlink.Driver<S, R> | Effect.Effect<Hyperlink.ImplOf<S> | Hyperlink.Driver<S, R>, never, R>, options?: ListenOptions): Layer.Layer<Self | Hyperlink.Local<Self> | ListenNode, never, R>S, function (type parameter) R in listen<Self, S extends Hyperlink.Spec, HSelf, R = never>(tag: Hyperlink.NodeBoundTag<Self, S, HSelf>, impl: Hyperlink.ImplOf<S> | Hyperlink.Driver<S, R> | Effect.Effect<Hyperlink.ImplOf<S> | Hyperlink.Driver<S, R>, never, R>, options?: ListenOptions): Layer.Layer<Self | Hyperlink.Local<Self> | ListenNode, never, R>R>,
never,
function (type parameter) R in listen<Self, S extends Hyperlink.Spec, HSelf, R = never>(tag: Hyperlink.NodeBoundTag<Self, S, HSelf>, impl: Hyperlink.ImplOf<S> | Hyperlink.Driver<S, R> | Effect.Effect<Hyperlink.ImplOf<S> | Hyperlink.Driver<S, R>, never, R>, options?: ListenOptions): Layer.Layer<Self | Hyperlink.Local<Self> | ListenNode, never, R>R
>,
options: ListenOptionsoptions?: type ListenOptions = {
readonly path?: PathInput;
readonly serialization?: Layer.Layer<RpcSerialization>;
readonly health?: {
readonly path?: PathInput;
};
readonly node?: string | {
readonly key: string;
};
readonly unlink?: boolean;
readonly onConflict?: OnConflict;
readonly port?: number;
readonly url?: string;
readonly assumeToken?: string | Redacted<string>;
readonly onYield?: Effect.Effect<boolean>;
}
Shared options for
unix
/
http
/
ws
(and low-level *Server) —
rpc path / health / ipc unlink, plus optional fixed listen address for nameless Http/Ws.
ListenOptions,
): import LayerLayer.interface Layer<in ROut, out E = never, out RIn = never>A Layer describes how to build one or more services for dependency injection.
When to use
Use to model construction of application services for dependency injection,
especially when services have dependencies, can fail during construction, or
need scoped setup and release.
Details
A Layer<ROut, E, RIn> represents ROut as the services this layer
provides, E as the possible errors during layer construction, and RIn as
the services this layer requires as dependencies.
Layer<function (type parameter) Self in listen<Self, S extends Hyperlink.Spec, HSelf, R = never>(tag: Hyperlink.NodeBoundTag<Self, S, HSelf>, impl: Hyperlink.ImplOf<S> | Hyperlink.Driver<S, R> | Effect.Effect<Hyperlink.ImplOf<S> | Hyperlink.Driver<S, R>, never, R>, options?: ListenOptions): Layer.Layer<Self | Hyperlink.Local<Self> | ListenNode, never, R>Self | import HyperlinkHyperlink.interface Local<in out Self>Granted only by a HyperService's local layer (
Hyperlink.layer
/
serve
) — never by
Hyperlink.client
. Local to this runtime's materialized impl for the tag (not a remote
client, not a peer). A
LocalMethod
carries it in its requirement channel, so calling a
non-serializable method against a client is a compile error (unsatisfied requirement); the
same call resolves when the local layer is provided. Branded by Self so one HyperService's local
layer can't unlock another's.
Local<function (type parameter) Self in listen<Self, S extends Hyperlink.Spec, HSelf, R = never>(tag: Hyperlink.NodeBoundTag<Self, S, HSelf>, impl: Hyperlink.ImplOf<S> | Hyperlink.Driver<S, R> | Effect.Effect<Hyperlink.ImplOf<S> | Hyperlink.Driver<S, R>, never, R>, options?: ListenOptions): Layer.Layer<Self | Hyperlink.Local<Self> | ListenNode, never, R>Self> | class ListenNodeclass ListenNode {
Service: Service;
key: Identifier;
}
The Node a protocol listen (unix / http / ws) is binding (concrete or minted).
Identity claims prefer this over a Tag-bound Node when present.
ListenNode, never, function (type parameter) R in listen<Self, S extends Hyperlink.Spec, HSelf, R = never>(tag: Hyperlink.NodeBoundTag<Self, S, HSelf>, impl: Hyperlink.ImplOf<S> | Hyperlink.Driver<S, R> | Effect.Effect<Hyperlink.ImplOf<S> | Hyperlink.Driver<S, R>, never, R>, options?: ListenOptions): Layer.Layer<Self | Hyperlink.Local<Self> | ListenNode, never, R>R>;
export function function listen<Node extends AnyNode & {
readonly [catalogSym]?: unknown;
}, const Serves extends ServeLayerList>(node: Node, serves: Serves & ServesForCatalog<CatalogROut<Node>, Serves>, options?: ListenOptions): Layer.Layer<Layer.Success<Serves[number]> | ListenNode, Layer.Error<Serves[number]>, Layer.Services<Serves[number]>> (+1 overload)
Neutral catalog spine (C2) — no transport bind. Prefer
unix
/
http
/
ws
.
**IpcSocket, Http, WebSocket, address-less, nameless, and Tag+impl fail with
ListenUseProtocol
** → use the matching protocol entry.
listen<
function (type parameter) Node in listen<Node extends AnyNode & {
readonly [catalogSym]?: unknown;
}, const Serves extends ServeLayerList>(node: Node, serves: Serves & ServesForCatalog<CatalogROut<Node>, Serves>, options?: ListenOptions): Layer.Layer<Layer.Success<Serves[number]> | ListenNode, Layer.Error<Serves[number]>, Layer.Services<Serves[number]>>
Node extends type AnyNode = NodeKey<unknown> & {
readonly url: string | undefined;
readonly path: string | undefined;
readonly kind: ProtocolKind | undefined;
readonly endpoints?: Endpoints;
readonly onConflict?: OnConflict;
readonly [portSym]?: number;
}
A
Tag
erased — its transport endpoints set, plus the primary address
(url and/or Unix path) and
ProtocolKind
kind (the first-declared endpoint, kept for
single-protocol readers), so a tag's distributed set is self-describing about where AND how to
reach each one.
AnyNode & { readonly [const catalogSym: typeof catalogSymType-only catalog brand on a
Node
— ROut is erased at runtime (C2 / C4).
catalogSym]?: unknown },
const function (type parameter) Serves in listen<Node extends AnyNode & {
readonly [catalogSym]?: unknown;
}, const Serves extends ServeLayerList>(node: Node, serves: Serves & ServesForCatalog<CatalogROut<Node>, Serves>, options?: ListenOptions): Layer.Layer<Layer.Success<Serves[number]> | ListenNode, Layer.Error<Serves[number]>, Layer.Services<Serves[number]>>
Serves extends type ServeLayerList = readonly [Layer.Any, ...Layer.Any[]]Non-empty serve-layer list for
listen
/
unix
/
http
/
ws
/
nPipe
. Open in E/R — a HyperService may depend on other services (including other
HyperServices); callers Layer.provide outside. Uses
Layer.Any
(not closed never
channels) so deps remain expressible without expression-level any.
ServeLayerList,
>(
node: Node extends AnyNode & { readonly [catalogSym]?: unknown; }node: function (type parameter) Node in listen<Node extends AnyNode & {
readonly [catalogSym]?: unknown;
}, const Serves extends ServeLayerList>(node: Node, serves: Serves & ServesForCatalog<CatalogROut<Node>, Serves>, options?: ListenOptions): Layer.Layer<Layer.Success<Serves[number]> | ListenNode, Layer.Error<Serves[number]>, Layer.Services<Serves[number]>>
Node,
serves: Serves &
ServesForCatalog<CatalogROut<Node>, Serves>
serves: function (type parameter) Serves in listen<Node extends AnyNode & {
readonly [catalogSym]?: unknown;
}, const Serves extends ServeLayerList>(node: Node, serves: Serves & ServesForCatalog<CatalogROut<Node>, Serves>, options?: ListenOptions): Layer.Layer<Layer.Success<Serves[number]> | ListenNode, Layer.Error<Serves[number]>, Layer.Services<Serves[number]>>
Serves & type ServesForCatalog<ROut, Serves extends ServeLayerList> = [ROut] extends [never] ? Serves : [ROut] extends [Layer.Success<Serves[number]>] ? Serves : neverC3: every member of ROut must appear in the merged serve Layer.Success.
ServesForCatalog<type CatalogROut<Node> = Node extends {
readonly [catalogSym]?: infer R;
} ? Exclude<R, undefined> : never
ROut stamped on a catalog Node, or never when undeclared.
CatalogROut<function (type parameter) Node in listen<Node extends AnyNode & {
readonly [catalogSym]?: unknown;
}, const Serves extends ServeLayerList>(node: Node, serves: Serves & ServesForCatalog<CatalogROut<Node>, Serves>, options?: ListenOptions): Layer.Layer<Layer.Success<Serves[number]> | ListenNode, Layer.Error<Serves[number]>, Layer.Services<Serves[number]>>
Node>, function (type parameter) Serves in listen<Node extends AnyNode & {
readonly [catalogSym]?: unknown;
}, const Serves extends ServeLayerList>(node: Node, serves: Serves & ServesForCatalog<CatalogROut<Node>, Serves>, options?: ListenOptions): Layer.Layer<Layer.Success<Serves[number]> | ListenNode, Layer.Error<Serves[number]>, Layer.Services<Serves[number]>>
Serves>,
options: ListenOptionsoptions?: type ListenOptions = {
readonly path?: PathInput;
readonly serialization?: Layer.Layer<RpcSerialization>;
readonly health?: {
readonly path?: PathInput;
};
readonly node?: string | {
readonly key: string;
};
readonly unlink?: boolean;
readonly onConflict?: OnConflict;
readonly port?: number;
readonly url?: string;
readonly assumeToken?: string | Redacted<string>;
readonly onYield?: Effect.Effect<boolean>;
}
Shared options for
unix
/
http
/
ws
(and low-level *Server) —
rpc path / health / ipc unlink, plus optional fixed listen address for nameless Http/Ws.
ListenOptions,
): import LayerLayer.interface Layer<in ROut, out E = never, out RIn = never>A Layer describes how to build one or more services for dependency injection.
When to use
Use to model construction of application services for dependency injection,
especially when services have dependencies, can fail during construction, or
need scoped setup and release.
Details
A Layer<ROut, E, RIn> represents ROut as the services this layer
provides, E as the possible errors during layer construction, and RIn as
the services this layer requires as dependencies.
Layer<
import LayerLayer.type Success<T extends Layer.Any> =
T extends Layer.Layer<
infer _ROut,
infer _E,
infer _RIn
>
? _ROut
: never
Extracts the service output type (ROut) from a Layer type.
When to use
Use to derive the services provided by an existing or generic Layer without
restating its ROut type parameter.
Success<function (type parameter) Serves in listen<Node extends AnyNode & {
readonly [catalogSym]?: unknown;
}, const Serves extends ServeLayerList>(node: Node, serves: Serves & ServesForCatalog<CatalogROut<Node>, Serves>, options?: ListenOptions): Layer.Layer<Layer.Success<Serves[number]> | ListenNode, Layer.Error<Serves[number]>, Layer.Services<Serves[number]>>
Serves[number]> | class ListenNodeclass ListenNode {
Service: Service;
key: Identifier;
}
The Node a protocol listen (unix / http / ws) is binding (concrete or minted).
Identity claims prefer this over a Tag-bound Node when present.
ListenNode,
import LayerLayer.type Error<T extends Layer.Any> =
T extends Layer.Layer<
infer _ROut,
infer _E,
infer _RIn
>
? _E
: never
Extracts the error type (E) from a Layer type.
When to use
Use to derive a layer construction error type for helper types, wrappers, or
APIs that preserve a layer failure channel.
Error<function (type parameter) Serves in listen<Node extends AnyNode & {
readonly [catalogSym]?: unknown;
}, const Serves extends ServeLayerList>(node: Node, serves: Serves & ServesForCatalog<CatalogROut<Node>, Serves>, options?: ListenOptions): Layer.Layer<Layer.Success<Serves[number]> | ListenNode, Layer.Error<Serves[number]>, Layer.Services<Serves[number]>>
Serves[number]>,
import LayerLayer.type Services<T extends Layer.Any> =
T extends infer L
? L extends Layer.Layer<
infer _ROut,
infer _E,
infer _RIn
>
? _RIn
: never
: never
Extracts the service requirements (RIn) from a Layer type.
When to use
Use to derive the dependency requirements of a generic or inferred Layer
without restating its RIn type parameter.
Services<function (type parameter) Serves in listen<Node extends AnyNode & {
readonly [catalogSym]?: unknown;
}, const Serves extends ServeLayerList>(node: Node, serves: Serves & ServesForCatalog<CatalogROut<Node>, Serves>, options?: ListenOptions): Layer.Layer<Layer.Success<Serves[number]> | ListenNode, Layer.Error<Serves[number]>, Layer.Services<Serves[number]>>
Serves[number]>
>;
export function function listen<Self, S extends Hyperlink.Spec, HSelf, R = never>(tag: Hyperlink.NodeBoundTag<Self, S, HSelf>, impl: Hyperlink.ImplOf<S> | Hyperlink.Driver<S, R> | Effect.Effect<Hyperlink.ImplOf<S> | Hyperlink.Driver<S, R>, never, R>, options?: ListenOptions): Layer.Layer<Self | Hyperlink.Local<Self> | ListenNode, never, R> (+1 overload)Neutral catalog spine (C2) — no transport bind. Prefer
unix
/
http
/
ws
.
**IpcSocket, Http, WebSocket, address-less, nameless, and Tag+impl fail with
ListenUseProtocol
** → use the matching protocol entry.
listen(
nodeOrTag: AnyNode | Hyperlink.PipeableTagnodeOrTag: type AnyNode = NodeKey<unknown> & {
readonly url: string | undefined;
readonly path: string | undefined;
readonly kind: ProtocolKind | undefined;
readonly endpoints?: Endpoints;
readonly onConflict?: OnConflict;
readonly [portSym]?: number;
}
A
Tag
erased — its transport endpoints set, plus the primary address
(url and/or Unix path) and
ProtocolKind
kind (the first-declared endpoint, kept for
single-protocol readers), so a tag's distributed set is self-describing about where AND how to
reach each one.
AnyNode | import HyperlinkHyperlink.type PipeableTag = {
readonly [specSym]: Hyperlink.FlatSpec
}
PipeableTag,
_servesOrImpl: Layer.Any | ServeLayerList | object_servesOrImpl?: import LayerLayer.Any | type ServeLayerList = readonly [Layer.Any, ...Layer.Any[]]Non-empty serve-layer list for
listen
/
unix
/
http
/
ws
/
nPipe
. Open in E/R — a HyperService may depend on other services (including other
HyperServices); callers Layer.provide outside. Uses
Layer.Any
(not closed never
channels) so deps remain expressible without expression-level any.
ServeLayerList | object,
_options: ListenOptions_options?: type ListenOptions = {
readonly path?: PathInput;
readonly serialization?: Layer.Layer<RpcSerialization>;
readonly health?: {
readonly path?: PathInput;
};
readonly node?: string | {
readonly key: string;
};
readonly unlink?: boolean;
readonly onConflict?: OnConflict;
readonly port?: number;
readonly url?: string;
readonly assumeToken?: string | Redacted<string>;
readonly onYield?: Effect.Effect<boolean>;
}
Shared options for
unix
/
http
/
ws
(and low-level *Server) —
rpc path / health / ipc unlink, plus optional fixed listen address for nameless Http/Ws.
ListenOptions,
): import LayerLayer.Any {
if (function isHyperlinkTagArg(u: unknown): u is Hyperlink.PipeableTagTrue when the first arg is a
Hyperlink.Tag
(has
Hyperlink.specSym
).
isHyperlinkTagArg(nodeOrTag: AnyNode | Hyperlink.PipeableTagnodeOrTag)) {
const const tag: Hyperlink.PipeableTagtag = nodeOrTag: AnyNode | Hyperlink.PipeableTagnodeOrTag;
const const tagKey: stringtagKey = (() => {
const const key: unknownkey = (const tag: Hyperlink.PipeableTagtag as unknown as { readonly key?: unknownkey?: unknown }).key?: unknownkey;
return typeof const key: unknownkey === "string" ? const key: stringkey : "unknown";
})();
const const bound: NodeKey<unknown> | undefinedbound = import HyperlinkHyperlink.const nodeOf: (
tag: unknown
) => NodeKey<unknown> | undefined
The
Node
a tag is bound to (its transport key), or undefined for a nodeless/bare tag
or any non-tag. Accepts unknown so a Group member passes straight in — walk a group tree and
collect the distinct nodes to know which nodes back its services.
nodeOf(const tag: Hyperlink.PipeableTagtag);
const const fleet: ReadonlyArray<AnyNode>fleet = import HyperlinkHyperlink.const nodesOf: <Self, S extends Spec>(
tag: HyperlinkTag<Self, S>
) => ReadonlyArray<AnyNode>
Read a Tag's Node set (C1), or [] when undeclared.
nodesOf(
const tag: Hyperlink.PipeableTagtag as unknown as import HyperlinkHyperlink.interface HyperlinkTag<Self, S extends Hyperlink.Spec, Svc = Simplify<{ readonly [K in keyof S]: S[K] extends Hyperlink.FromLocalMethod<infer M> ? Hyperlink.InjectLocal<M, Self> : S[K] extends Hyperlink.LocalMethod<...> ? Hyperlink.LocalEffect<...> : S[K] extends Hyperlink.DefaultMethod<...> ? F : S[K] extends { ...; } ? SuccessOf<...> : S[K] extends { ...; } ? Hyperlink.Subscribable<...> : S[K] extends { ...; } ? ClientMethod<...> : S[K] extends Hyperlink.Spec ? Simplify<...> : never; }>>The type of a HyperService tag carrying spec S — what
Hyperlink.Tag
produces
(and what you extend). Lets a consumer write
<S extends Spec>(tag: HyperlinkTag<Self, S>) and read the spec through named types
(
specOf
/
groupOf
) instead of a Parameters<typeof specOf> workaround.
HyperlinkTag<unknown, import HyperlinkHyperlink.Spec>,
);
if (const bound: NodeKey<unknown> | undefinedbound === var undefinedundefined) {
return function failListenTagNode(fields: { readonly tag: string; readonly reason: 'missing' | 'ambiguous'; readonly count: number }): Layer.Layer<never, ListenTagNodeRequired>A Layer that fails with a tag-node resolution error (missing / ambiguous bound node).
failListenTagNode({
tag: stringtag: const tagKey: stringtagKey,
reason: "missing" | "ambiguous"reason: const fleet: ReadonlyArray<AnyNode>fleet.ReadonlyArray<AnyNode>.length: numberGets the length of the array. This is a number one higher than the highest element defined in an array.
length > 1 ? "ambiguous" : "missing",
count: numbercount: const fleet: ReadonlyArray<AnyNode>fleet.ReadonlyArray<AnyNode>.length: numberGets the length of the array. This is a number one higher than the highest element defined in an array.
length,
});
}
if (function isIpcListenNode(node: AnyNode): booleanNodes that need
unix
(IpcSocket / address-less ipc).
isIpcListenNode(const bound: NodeKey<unknown>const bound: {
key: string;
Service: {
protocol: Context.Service.Shape<typeof RpcClient.Protocol>;
ping: Effect.Effect<number, NodeUnreachable>;
status: { readonly get: Effect.Effect<NodeStatusSnapshot, NodeUnreachable>; readonly changes: Stream.Stream<NodeStatusSnapshot, NodeUnreachable> };
logs: { readonly stream: Stream.Stream<LogEntry, NodeUnreachable>; readonly query: (options: { readonly limit: number }) => Effect.Effect<ReadonlyArray<LogEntry>, NodeUnreachable> };
};
Identifier: Identifier;
stack: string | undefined;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
bound as type AnyNode = NodeKey<unknown> & {
readonly url: string | undefined;
readonly path: string | undefined;
readonly kind: ProtocolKind | undefined;
readonly endpoints?: Endpoints;
readonly onConflict?: OnConflict;
readonly [portSym]?: number;
}
A
Tag
erased — its transport endpoints set, plus the primary address
(url and/or Unix path) and
ProtocolKind
kind (the first-declared endpoint, kept for
single-protocol readers), so a tag's distributed set is self-describing about where AND how to
reach each one.
AnyNode)) {
return function failUseProtocol(protocol: 'unix' | 'http' | 'ws', detail: string): Layer.Layer<never, ListenUseProtocol>A Layer that fails with
ListenUseProtocol
— listen used where connect was meant.
failUseProtocol(
"unix",
`Tag "${const tagKey: stringtagKey}" is bound to an IpcSocket Node`,
);
}
if (function isHttpListenNode(node: AnyNode): booleanNodes that need
http
(Http kind / http(s) url).
isHttpListenNode(const bound: NodeKey<unknown>const bound: {
key: string;
Service: {
protocol: Context.Service.Shape<typeof RpcClient.Protocol>;
ping: Effect.Effect<number, NodeUnreachable>;
status: { readonly get: Effect.Effect<NodeStatusSnapshot, NodeUnreachable>; readonly changes: Stream.Stream<NodeStatusSnapshot, NodeUnreachable> };
logs: { readonly stream: Stream.Stream<LogEntry, NodeUnreachable>; readonly query: (options: { readonly limit: number }) => Effect.Effect<ReadonlyArray<LogEntry>, NodeUnreachable> };
};
Identifier: Identifier;
stack: string | undefined;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
bound as type AnyNode = NodeKey<unknown> & {
readonly url: string | undefined;
readonly path: string | undefined;
readonly kind: ProtocolKind | undefined;
readonly endpoints?: Endpoints;
readonly onConflict?: OnConflict;
readonly [portSym]?: number;
}
A
Tag
erased — its transport endpoints set, plus the primary address
(url and/or Unix path) and
ProtocolKind
kind (the first-declared endpoint, kept for
single-protocol readers), so a tag's distributed set is self-describing about where AND how to
reach each one.
AnyNode)) {
return function failUseProtocol(protocol: 'unix' | 'http' | 'ws', detail: string): Layer.Layer<never, ListenUseProtocol>A Layer that fails with
ListenUseProtocol
— listen used where connect was meant.
failUseProtocol(
"http",
`Tag "${const tagKey: stringtagKey}" is bound to an Http Node`,
);
}
if (function isWsListenNode(node: AnyNode): booleanNodes that need
ws
(WebSocket kind / ws(s) url).
isWsListenNode(const bound: NodeKey<unknown>const bound: {
key: string;
Service: {
protocol: Context.Service.Shape<typeof RpcClient.Protocol>;
ping: Effect.Effect<number, NodeUnreachable>;
status: { readonly get: Effect.Effect<NodeStatusSnapshot, NodeUnreachable>; readonly changes: Stream.Stream<NodeStatusSnapshot, NodeUnreachable> };
logs: { readonly stream: Stream.Stream<LogEntry, NodeUnreachable>; readonly query: (options: { readonly limit: number }) => Effect.Effect<ReadonlyArray<LogEntry>, NodeUnreachable> };
};
Identifier: Identifier;
stack: string | undefined;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
bound as type AnyNode = NodeKey<unknown> & {
readonly url: string | undefined;
readonly path: string | undefined;
readonly kind: ProtocolKind | undefined;
readonly endpoints?: Endpoints;
readonly onConflict?: OnConflict;
readonly [portSym]?: number;
}
A
Tag
erased — its transport endpoints set, plus the primary address
(url and/or Unix path) and
ProtocolKind
kind (the first-declared endpoint, kept for
single-protocol readers), so a tag's distributed set is self-describing about where AND how to
reach each one.
AnyNode)) {
return function failUseProtocol(protocol: 'unix' | 'http' | 'ws', detail: string): Layer.Layer<never, ListenUseProtocol>A Layer that fails with
ListenUseProtocol
— listen used where connect was meant.
failUseProtocol(
"ws",
`Tag "${const tagKey: stringtagKey}" is bound to a WebSocket Node`,
);
}
return function failUseProtocol(protocol: 'unix' | 'http' | 'ws', detail: string): Layer.Layer<never, ListenUseProtocol>A Layer that fails with
ListenUseProtocol
— listen used where connect was meant.
failUseProtocol(
"unix",
`Tag "${const tagKey: stringtagKey}" has no protocol-bound Node — use Node.unix / Node.http / Node.ws`,
);
}
const const node: AnyNodenode = nodeOrTag: AnyNode | Hyperlink.PipeableTagnodeOrTag as type AnyNode = NodeKey<unknown> & {
readonly url: string | undefined;
readonly path: string | undefined;
readonly kind: ProtocolKind | undefined;
readonly endpoints?: Endpoints;
readonly onConflict?: OnConflict;
readonly [portSym]?: number;
}
A
Tag
erased — its transport endpoints set, plus the primary address
(url and/or Unix path) and
ProtocolKind
kind (the first-declared endpoint, kept for
single-protocol readers), so a tag's distributed set is self-describing about where AND how to
reach each one.
AnyNode;
if (function isPrototypeNode(node: unknown): booleanTrue when node was built with
Node
.Prototype.
isPrototypeNode(const node: AnyNodenode)) {
return unaddressedLayer<A = never>(node: string): Layer.Layer<A, UnaddressedNode>Fail a Layer build with
UnaddressedNode
.
unaddressedLayer(const node: AnyNodenode.Key<unknown, NodeProtocol>.key: stringkey);
}
if (function isIpcListenNode(node: AnyNode): booleanNodes that need
unix
(IpcSocket / address-less ipc).
isIpcListenNode(const node: AnyNodenode) || function isDynamicInstanceNode(node: unknown): booleanTrue when node came from
Node
.Prototype.instance.
isDynamicInstanceNode(const node: AnyNodenode)) {
return function failUseProtocol(protocol: 'unix' | 'http' | 'ws', detail: string): Layer.Layer<never, ListenUseProtocol>A Layer that fails with
ListenUseProtocol
— listen used where connect was meant.
failUseProtocol(
"unix",
`node "${const node: AnyNodenode.Key<unknown, NodeProtocol>.key: stringkey}" needs IpcSocket bind`,
);
}
if (function isHttpListenNode(node: AnyNode): booleanNodes that need
http
(Http kind / http(s) url).
isHttpListenNode(const node: AnyNodenode)) {
return function failUseProtocol(protocol: 'unix' | 'http' | 'ws', detail: string): Layer.Layer<never, ListenUseProtocol>A Layer that fails with
ListenUseProtocol
— listen used where connect was meant.
failUseProtocol("http", `node "${const node: AnyNodenode.Key<unknown, NodeProtocol>.key: stringkey}" needs Http bind`);
}
if (function isWsListenNode(node: AnyNode): booleanNodes that need
ws
(WebSocket kind / ws(s) url).
isWsListenNode(const node: AnyNodenode)) {
return function failUseProtocol(protocol: 'unix' | 'http' | 'ws', detail: string): Layer.Layer<never, ListenUseProtocol>A Layer that fails with
ListenUseProtocol
— listen used where connect was meant.
failUseProtocol("ws", `node "${const node: AnyNodenode.Key<unknown, NodeProtocol>.key: stringkey}" needs WebSocket bind`);
}
return function failUseProtocol(protocol: 'unix' | 'http' | 'ws', detail: string): Layer.Layer<never, ListenUseProtocol>A Layer that fails with
ListenUseProtocol
— listen used where connect was meant.
failUseProtocol(
"unix",
`node "${const node: AnyNodenode.Key<unknown, NodeProtocol>.key: stringkey}" — use Node.unix / Node.http / Node.ws`,
);
}