@polyengine/wasi 0.1.0-pre.g633468a

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,169 @@
1
+ import { Stream } from "@polyengine/runtime/embedder";
2
+ /** The compatibility track the fragment registers on by default. */
3
+ export declare const HTTP_TRACK = "0.3";
4
+ /** `method` — case names verbatim (A10). */
5
+ export type Method = {
6
+ kind: "get";
7
+ } | {
8
+ kind: "head";
9
+ } | {
10
+ kind: "post";
11
+ } | {
12
+ kind: "put";
13
+ } | {
14
+ kind: "delete";
15
+ } | {
16
+ kind: "connect";
17
+ } | {
18
+ kind: "options";
19
+ } | {
20
+ kind: "trace";
21
+ } | {
22
+ kind: "patch";
23
+ } | {
24
+ kind: "other";
25
+ value: string;
26
+ };
27
+ /** `scheme` — case names verbatim (the WIT capitalizes HTTP/HTTPS). */
28
+ export type Scheme = {
29
+ kind: "HTTP";
30
+ } | {
31
+ kind: "HTTPS";
32
+ } | {
33
+ kind: "other";
34
+ value: string;
35
+ };
36
+ /**
37
+ * `error-code` — the case-name vocabulary, verbatim. Only the cases this
38
+ * provider can actually emit are listed with payload shapes; the guest
39
+ * switches against strings either way.
40
+ */
41
+ export type ErrorCode = {
42
+ kind: string;
43
+ value?: unknown;
44
+ };
45
+ /** `header-error` (0.3.1 added `size-exceeded` and `other`). */
46
+ export type HeaderError = {
47
+ kind: "invalid-syntax" | "forbidden" | "immutable" | "size-exceeded";
48
+ } | {
49
+ kind: "other";
50
+ value?: string;
51
+ };
52
+ /** `request-options-error` (0.3.1 added `other`). */
53
+ export type RequestOptionsError = {
54
+ kind: "not-supported" | "immutable";
55
+ } | {
56
+ kind: "other";
57
+ value?: string;
58
+ };
59
+ /**
60
+ * `result<option<trailers>, error-code>` AS A VALUE (trailers futures).
61
+ * The ok side CARRIES a payload (`option<trailers>`), so `ok(none)` is
62
+ * `{ kind: "ok", value: undefined }` — the `value` key must be present
63
+ * (outermost-option-as-undefined; the adapter requires the key on
64
+ * payload-carrying cases).
65
+ */
66
+ export type TrailersResult = {
67
+ kind: "ok";
68
+ value: Fields | undefined;
69
+ } | {
70
+ kind: "err";
71
+ value: ErrorCode;
72
+ };
73
+ /** `result<_, error-code>` AS A VALUE (transmission futures). */
74
+ export type HttpResult = {
75
+ kind: "ok";
76
+ } | {
77
+ kind: "err";
78
+ value: ErrorCode;
79
+ };
80
+ /** Map a fetch failure onto `error-code` (sniff table + honest catch-all). */
81
+ export declare function mapFetchError(e: unknown): ErrorCode;
82
+ /** What body params accept: the lifted handle, or any natural byte producer. */
83
+ export type BodySource = Stream<number> | AsyncIterable<Uint8Array | number[]> | Iterable<Uint8Array | number[]>;
84
+ /** What future params accept: the lifted handle or a promise of the value. */
85
+ export type FutureLike<T> = PromiseLike<T>;
86
+ export interface HttpOptions {
87
+ /**
88
+ * Override the registration keys for a guest pinned to a PRERELEASE
89
+ * snapshot (`0.3.0-rc-*`), which the resolver matches exactly — no
90
+ * track exists for prereleases. Default: the `@0.3` track, serving
91
+ * every released 0.3.x.
92
+ */
93
+ version?: string;
94
+ /** Observe every entry point the guest reaches (see sockets' onCall). */
95
+ onCall?: (call: string) => void;
96
+ }
97
+ /** What `http()` returns: the imports fragment plus the fragment's classes. */
98
+ export interface HttpFragment {
99
+ imports: Record<string, unknown>;
100
+ Fields: FieldsClass;
101
+ Request: RequestClass;
102
+ RequestOptions: RequestOptionsClass;
103
+ Response: ResponseClass;
104
+ /** The `client.send` impl, exposed so an embedder may re-key it (e.g. as a handler). */
105
+ send: HttpSend;
106
+ }
107
+ /** The `client.send` shape (module-scope names: the public interfaces). */
108
+ export type HttpSend = (request: Request) => Promise<Response>;
109
+ export interface Fields {
110
+ get(name: string): Uint8Array[];
111
+ has(name: string): boolean;
112
+ set(name: string, value: Uint8Array[]): void;
113
+ delete(name: string): void;
114
+ getAndDelete(name: string): Uint8Array[];
115
+ append(name: string, value: Uint8Array): void;
116
+ copyAll(): [string, Uint8Array][];
117
+ clone(): Fields;
118
+ [Symbol.dispose](): void;
119
+ }
120
+ export interface FieldsClass {
121
+ new (): Fields;
122
+ fromList(entries: [string, Uint8Array][]): Fields;
123
+ }
124
+ export interface Request {
125
+ getMethod(): Method;
126
+ setMethod(method: Method): void;
127
+ getPathWithQuery(): string | undefined;
128
+ setPathWithQuery(pathWithQuery: string | undefined): void;
129
+ getScheme(): Scheme | undefined;
130
+ setScheme(scheme: Scheme | undefined): void;
131
+ getAuthority(): string | undefined;
132
+ setAuthority(authority: string | undefined): void;
133
+ getOptions(): RequestOptions | undefined;
134
+ getHeaders(): Fields;
135
+ [Symbol.dispose](): void;
136
+ }
137
+ export interface RequestClass {
138
+ "new"(headers: Fields, contents: BodySource | undefined, trailers: FutureLike<TrailersResult>, options: RequestOptions | undefined): [Request, Promise<HttpResult>];
139
+ consumeBody(request: Request, res: FutureLike<HttpResult>): [AsyncIterable<Uint8Array>, Promise<TrailersResult>];
140
+ }
141
+ export interface RequestOptions {
142
+ getConnectTimeout(): bigint | undefined;
143
+ setConnectTimeout(duration: bigint | undefined): void;
144
+ getFirstByteTimeout(): bigint | undefined;
145
+ setFirstByteTimeout(duration: bigint | undefined): void;
146
+ getBetweenBytesTimeout(): bigint | undefined;
147
+ setBetweenBytesTimeout(duration: bigint | undefined): void;
148
+ clone(): RequestOptions;
149
+ [Symbol.dispose](): void;
150
+ }
151
+ export interface RequestOptionsClass {
152
+ new (): RequestOptions;
153
+ }
154
+ export interface Response {
155
+ getStatusCode(): number;
156
+ setStatusCode(statusCode: number): void;
157
+ getHeaders(): Fields;
158
+ [Symbol.dispose](): void;
159
+ }
160
+ export interface ResponseClass {
161
+ "new"(headers: Fields, contents: BodySource | undefined, trailers: FutureLike<TrailersResult>): [Response, Promise<HttpResult>];
162
+ consumeBody(response: Response, res: FutureLike<HttpResult>): [AsyncIterable<Uint8Array>, Promise<TrailersResult>];
163
+ }
164
+ /**
165
+ * `wasi:http` provider fragment (exact version keys — see the module
166
+ * header). The resource classes are built per fragment so the `onCall`
167
+ * observer is scoped to it.
168
+ */
169
+ export declare function http(options?: HttpOptions): HttpFragment;
@@ -0,0 +1,26 @@
1
+ import { Stream } from "@polyengine/runtime/embedder";
2
+ /** `wasi:cli/types@0.3`'s `error-code` ENUM: bare kebab-case strings (the
3
+ * A10 value table — enums are data strings, not `{kind}` variants; this
4
+ * type carried a `{kind}` wrapper until 2026-08-14, a latent bug no err
5
+ * path had exercised). */
6
+ export type CliErrorCode = "io" | "illegal-byte-sequence" | "pipe";
7
+ /** `result<_, error-code>` AS A VALUE (the 0.3 stdio futures). */
8
+ export type CliIoResult = {
9
+ kind: "ok";
10
+ } | {
11
+ kind: "err";
12
+ value: CliErrorCode;
13
+ };
14
+ /** What 0.3 write-via-stream accepts: the lifted handle or any byte producer. */
15
+ export type CliByteSource = Stream<number> | AsyncIterable<Uint8Array | number[]> | Iterable<Uint8Array | number[]>;
16
+ /** Raised by `exit()` when `throwOnExit` is set (contract: "option to throw a named ExitError"). */
17
+ export declare class ExitError extends Error {
18
+ readonly ok: boolean;
19
+ readonly code?: number | undefined;
20
+ constructor(ok: boolean, code?: number | undefined);
21
+ }
22
+ /** `terminal-input`/`terminal-output` are opaque resources; never produced (no terminal). */
23
+ export declare class TerminalInput {
24
+ }
25
+ export declare class TerminalOutput {
26
+ }
@@ -0,0 +1,174 @@
1
+ import { ComponentException, Stream } from "@polyengine/runtime/embedder";
2
+ import { IoError } from "../io.js";
3
+ /** `wasi:filesystem/types.error-code` labels. 0.2 (enum): all of these,
4
+ * bare. 0.3 (variant): all but `would-block`, as `{kind}` — this package
5
+ * never produces `would-block`, so the union serves both tracks. */
6
+ export type FsErrorCode = "access" | "would-block" | "already" | "bad-descriptor" | "busy" | "deadlock" | "quota" | "exist" | "file-too-large" | "illegal-byte-sequence" | "in-progress" | "interrupted" | "invalid" | "io" | "is-directory" | "loop" | "too-many-links" | "message-size" | "name-too-long" | "no-device" | "no-entry" | "no-lock" | "insufficient-memory" | "insufficient-space" | "not-directory" | "not-empty" | "not-recoverable" | "unsupported" | "no-tty" | "no-such-device" | "overflow" | "not-permitted" | "pipe" | "read-only" | "invalid-seek" | "text-file-busy" | "cross-device";
7
+ /** `descriptor-type` (enum: bare strings). */
8
+ export type DescriptorType = "unknown" | "block-device" | "character-device" | "directory" | "fifo" | "symbolic-link" | "regular-file" | "socket";
9
+ /** `wasi:clocks` wall-clock `datetime` record, as a value. */
10
+ export interface Datetime {
11
+ seconds: bigint;
12
+ nanoseconds: number;
13
+ }
14
+ /** What a backend reports from stat; absent timestamp = unavailable. */
15
+ export interface FsStat {
16
+ type: DescriptorType;
17
+ linkCount: bigint;
18
+ size: bigint;
19
+ atimeNs?: bigint;
20
+ mtimeNs?: bigint;
21
+ ctimeNs?: bigint;
22
+ }
23
+ /** A stable per-object identity (dev/ino-ish) for metadata-hash and
24
+ * is-same-object; backends without a native one synthesize (e.g. from
25
+ * the path). */
26
+ export interface FsIdentity {
27
+ a: bigint;
28
+ b: bigint;
29
+ }
30
+ /** A set-times instruction, backend-facing (ns since epoch). */
31
+ export type TimeSpec = {
32
+ kind: "no-change";
33
+ } | {
34
+ kind: "now";
35
+ } | {
36
+ kind: "timestamp";
37
+ ns: bigint;
38
+ };
39
+ /** Decoded open-at intent (path-flags + open-flags + descriptor-flags). */
40
+ export interface OpenOptions {
41
+ follow: boolean;
42
+ create: boolean;
43
+ directory: boolean;
44
+ exclusive: boolean;
45
+ truncate: boolean;
46
+ read: boolean;
47
+ write: boolean;
48
+ }
49
+ export interface Opened<H> {
50
+ handle: H;
51
+ type: DescriptorType;
52
+ }
53
+ export type MaybeAsync<T> = T | Promise<T>;
54
+ /**
55
+ * The backend seam. `isSync: true` promises every op returns a plain
56
+ * value (node); `false` allows promises everywhere and buys the 0.2
57
+ * track its suspending marks (OPFS). Ops receive validated, non-escaping
58
+ * segment lists (possibly empty = the base itself). Ops throw RAW
59
+ * platform errors; `mapError` names them.
60
+ */
61
+ export interface FsBackend<H> {
62
+ isSync: boolean;
63
+ mapError(e: unknown): FsErrorCode;
64
+ openAt(base: H, segments: string[], opts: OpenOptions): MaybeAsync<Opened<H>>;
65
+ close(h: H): void;
66
+ stat(h: H): MaybeAsync<FsStat>;
67
+ statAt(base: H, segments: string[], follow: boolean): MaybeAsync<FsStat>;
68
+ /** Short reads are fine; empty result with `length > 0` = EOF. */
69
+ read(h: H, length: number, offset: number): MaybeAsync<Uint8Array>;
70
+ write(h: H, buffer: Uint8Array, offset: number): MaybeAsync<number>;
71
+ append(h: H, buffer: Uint8Array): MaybeAsync<number>;
72
+ setSize(h: H, size: number): MaybeAsync<void>;
73
+ setTimes(h: H, atime: TimeSpec, mtime: TimeSpec): MaybeAsync<void>;
74
+ setTimesAt(base: H, segments: string[], follow: boolean, atime: TimeSpec, mtime: TimeSpec): MaybeAsync<void>;
75
+ syncAll(h: H): MaybeAsync<void>;
76
+ syncData(h: H): MaybeAsync<void>;
77
+ readDirectory(h: H): MaybeAsync<{
78
+ name: string;
79
+ type: DescriptorType;
80
+ }[]>;
81
+ createDirectoryAt(base: H, segments: string[]): MaybeAsync<void>;
82
+ removeDirectoryAt(base: H, segments: string[]): MaybeAsync<void>;
83
+ unlinkFileAt(base: H, segments: string[]): MaybeAsync<void>;
84
+ renameAt(oldBase: H, oldSegments: string[], newBase: H, newSegments: string[]): MaybeAsync<void>;
85
+ /** Optional families: absent = `unsupported`. */
86
+ linkAt?(oldBase: H, oldSegments: string[], follow: boolean, newBase: H, newSegments: string[]): MaybeAsync<void>;
87
+ symlinkAt?(target: string, base: H, segments: string[]): MaybeAsync<void>;
88
+ readlinkAt?(base: H, segments: string[]): MaybeAsync<string>;
89
+ identity(h: H): MaybeAsync<FsIdentity>;
90
+ identityAt(base: H, segments: string[], follow: boolean): MaybeAsync<FsIdentity>;
91
+ isSame(a: H, b: H): MaybeAsync<boolean>;
92
+ }
93
+ /** `descriptor-stat` record as a value (option fields: absent = none). */
94
+ export interface DescriptorStatValue {
95
+ type: DescriptorType;
96
+ linkCount: bigint;
97
+ size: bigint;
98
+ dataAccessTimestamp?: Datetime;
99
+ dataModificationTimestamp?: Datetime;
100
+ statusChangeTimestamp?: Datetime;
101
+ }
102
+ /** `descriptor-flags` as a value (flags record: camelCase booleans). */
103
+ export interface DescriptorFlagsValue {
104
+ read: boolean;
105
+ write: boolean;
106
+ fileIntegritySync: boolean;
107
+ dataIntegritySync: boolean;
108
+ requestedWriteSync: boolean;
109
+ mutateDirectory: boolean;
110
+ }
111
+ /** `directory-entry` record. */
112
+ export interface DirectoryEntryValue {
113
+ type: DescriptorType;
114
+ name: string;
115
+ }
116
+ export interface MetadataHashValue {
117
+ lower: bigint;
118
+ upper: bigint;
119
+ }
120
+ /** 0.3 `result<_, error-code>` as a future/tuple VALUE (A12 shapes). */
121
+ export type FsResult03 = {
122
+ kind: "ok";
123
+ } | {
124
+ kind: "err";
125
+ value: {
126
+ kind: FsErrorCode;
127
+ };
128
+ };
129
+ /** What 0.3 write/append-via-stream accepts (the lifted stream handle or
130
+ * any byte producer, mirroring cli's CliByteSource). */
131
+ export type FsByteSource = Stream<number> | AsyncIterable<Uint8Array | number[]> | Iterable<Uint8Array | number[]>;
132
+ /**
133
+ * The io `error` resource minted by filesystem STREAM failures, carrying
134
+ * the error-code so 0.2's `filesystem-error-code(borrow<error>)` can
135
+ * downcast it (SinkOutputStream preserves IoError subclasses).
136
+ */
137
+ export declare class FsIoError extends IoError {
138
+ readonly code: FsErrorCode;
139
+ constructor(code: FsErrorCode, message: string);
140
+ }
141
+ type ErrShape = (code: FsErrorCode) => ComponentException<unknown>;
142
+ /**
143
+ * Validate and normalize a guest path to non-escaping segments (module
144
+ * header). `shape` picks the track's error payload.
145
+ */
146
+ export declare function parsePath(path: string, shape: ErrShape): string[];
147
+ export interface FilesystemFragment {
148
+ imports: Record<string, unknown>;
149
+ }
150
+ /**
151
+ * Package-level capability options shared by every `wasi:filesystem`
152
+ * implementation (module header, "READ-ONLY BY DEFAULT").
153
+ */
154
+ export interface FilesystemAccessOptions {
155
+ /**
156
+ * Grant write access to the WHOLE implementation. Default `false`:
157
+ * every mutating operation refuses with the WIT `read-only` error
158
+ * code, `get-flags` never advertises `write`/`mutate-directory`, and
159
+ * `open-at` refuses write descriptor-flags as well as the
160
+ * `create`/`truncate`/`exclusive` open-flags.
161
+ *
162
+ * Deliberately NOT per-preopen: see the module header for why a
163
+ * global flag is the checkable design.
164
+ */
165
+ writable?: boolean;
166
+ }
167
+ /**
168
+ * Build the two-track `wasi:filesystem` import fragment over a backend.
169
+ * `preopens`: directory handles with their guest names, served (as fresh
170
+ * per-call descriptors) by both tracks' `preopens#get-directories`.
171
+ * `access.writable` (default false) is the package-level write grant.
172
+ */
173
+ export declare function makeFilesystem<H>(backend: FsBackend<H>, preopens: [H, string][], access?: FilesystemAccessOptions): FilesystemFragment;
174
+ export {};
@@ -0,0 +1,37 @@
1
+ import { IoError } from "../io.js";
2
+ import { type IpSocketAddress } from "./sockets_shared.js";
3
+ /** `wasi:sockets/network@0.2`'s `error-code` ENUM: bare strings. */
4
+ export type SocketErrorCode02 = "unknown" | "access-denied" | "not-supported" | "invalid-argument" | "out-of-memory" | "timeout" | "concurrency-conflict" | "not-in-progress" | "would-block" | "invalid-state" | "new-socket-limit" | "address-not-bindable" | "address-in-use" | "remote-unreachable" | "connection-refused" | "connection-reset" | "connection-aborted" | "datagram-too-large" | "name-unresolvable" | "temporary-resolver-failure" | "permanent-resolver-failure";
5
+ /**
6
+ * The io `error` resource minted by 0.2 socket STREAM failures, carrying
7
+ * the error-code so `network-error-code(borrow<error>)` can downcast it
8
+ * (the filesystem-error-code pattern; SinkOutputStream and
9
+ * FedInputStream preserve IoError subclasses).
10
+ */
11
+ export declare class SocketIoError extends IoError {
12
+ readonly code: SocketErrorCode02;
13
+ constructor(code: SocketErrorCode02, message: string);
14
+ }
15
+ /** `wasi:sockets/network@0.2`'s opaque capability resource. */
16
+ export declare class Network {
17
+ }
18
+ /** `shutdown-type` enum values. */
19
+ export type ShutdownType = "receive" | "send" | "both";
20
+ /** `incoming-datagram` / `outgoing-datagram` records. */
21
+ export interface IncomingDatagram {
22
+ data: Uint8Array;
23
+ remoteAddress: IpSocketAddress;
24
+ }
25
+ export interface OutgoingDatagram {
26
+ data: Uint8Array;
27
+ remoteAddress?: IpSocketAddress;
28
+ }
29
+ /** What `sockets02()` hands back for registration by `sockets()`. */
30
+ export interface Sockets02Fragment {
31
+ imports: Record<string, unknown>;
32
+ }
33
+ /**
34
+ * Build the `wasi:sockets@0.2` interfaces (module header). `onCall` is
35
+ * the same fragment-scoped observer the 0.3 track takes.
36
+ */
37
+ export declare function sockets02(onCall: (call: string) => void): Sockets02Fragment;
@@ -0,0 +1,12 @@
1
+ import { type IpAddress, type TcpSocketClass, type UdpSocketClass } from "./sockets_shared.js";
2
+ /**
3
+ * Build the `@0.3` track: `wasi:sockets/types@0.3` (UDP + TCP resource
4
+ * classes, per-fragment so the `onCall` observer is scoped) and
5
+ * `wasi:sockets/ip-name-lookup@0.3`.
6
+ */
7
+ export declare function sockets03(onCall: (call: string) => void): {
8
+ imports: Record<string, unknown>;
9
+ UdpSocket: UdpSocketClass;
10
+ TcpSocket: TcpSocketClass;
11
+ resolveAddresses: (name: string) => Promise<IpAddress[]>;
12
+ };
@@ -0,0 +1,112 @@
1
+ /** The address shape the socket backends speak. */
2
+ export interface NetAddr {
3
+ transport?: string;
4
+ hostname: string;
5
+ port: number;
6
+ }
7
+ /** The bound-datagram-socket seam. */
8
+ export interface DatagramConn {
9
+ readonly addr: NetAddr;
10
+ /** No `addr` = connected-mode send (valid only after `connect`). */
11
+ send(p: Uint8Array, addr?: NetAddr): Promise<number>;
12
+ receive(): Promise<[Uint8Array, NetAddr]>;
13
+ close(): void;
14
+ /** OS-level connected mode (kernel filters + default destination).
15
+ * Optional capability: absent = the provider answers `not-supported`. */
16
+ connect?(addr: NetAddr): Promise<void>;
17
+ disconnect?(): void;
18
+ /** IP_TTL / IPV6_UNICAST_HOPS. Optional capability. */
19
+ setTtl?(ttl: number): void;
20
+ /** SO_RCVBUF / SO_SNDBUF. Optional capabilities. */
21
+ getRecvBufferSize?(): number;
22
+ setRecvBufferSize?(size: number): void;
23
+ getSendBufferSize?(): number;
24
+ setSendBufferSize?(size: number): void;
25
+ /** Non-blocking queue access + readiness (the 0.2 datagram streams:
26
+ * poll-shaped receive instead of the promise-shaped one above).
27
+ * Optional capabilities. */
28
+ tryReceive?(): [Uint8Array, NetAddr] | undefined;
29
+ receiveReady?(): boolean;
30
+ /** The CURRENT epoch's wake promise (promise-swap: settles when a
31
+ * datagram arrives, the socket errors, or it closes; re-armed per event). */
32
+ waitReceive?(): Promise<void>;
33
+ }
34
+ export type ListenDatagram = (options: {
35
+ transport: "udp";
36
+ hostname: string;
37
+ port: number;
38
+ }) => DatagramConn;
39
+ /** The connected-TCP-socket seam. */
40
+ export interface TcpConn {
41
+ readonly localAddr: NetAddr;
42
+ readonly remoteAddr: NetAddr;
43
+ /** Up to `max` bytes (node's own buffer, no copy); `null` = peer FIN. */
44
+ read(max: number): Promise<Uint8Array | null>;
45
+ write(p: Uint8Array): Promise<number>;
46
+ closeWrite(): Promise<void>;
47
+ close(): void;
48
+ /** SO_KEEPALIVE + TCP_KEEPIDLE (node exposes exactly this pair).
49
+ * Optional capability: absent = the provider answers `not-supported`. */
50
+ setKeepAlive?(enabled: boolean, idleMs: number): void;
51
+ }
52
+ export type TcpConnect = (options: {
53
+ transport: "tcp";
54
+ hostname: string;
55
+ port: number;
56
+ /** Source binding (connect-from-bound); both or neither. */
57
+ localHostname?: string;
58
+ localPort?: number;
59
+ }) => Promise<TcpConn>;
60
+ /**
61
+ * The listening-TCP-socket seam. The OS bind is deferred (module header):
62
+ * `settled()` resolves once the listener is live (rejects with the bind
63
+ * failure), after which `addr` is non-null.
64
+ */
65
+ export interface TcpListener {
66
+ readonly addr: NetAddr | null;
67
+ settled(): Promise<void>;
68
+ accept(): Promise<TcpConn>;
69
+ close(): void;
70
+ /** Non-blocking accept + readiness (the 0.2 poll-shaped accept).
71
+ * Optional capabilities; same promise-swap contract as `waitReceive`. */
72
+ tryAccept?(): TcpConn | undefined;
73
+ acceptReady?(): boolean;
74
+ waitAccept?(): Promise<void>;
75
+ }
76
+ export type TcpListen = (options: {
77
+ transport: "tcp";
78
+ hostname: string;
79
+ port: number;
80
+ /** The accept queue hint (SOMAXCONN-clamped by the OS). */
81
+ backlog?: number;
82
+ }) => TcpListener;
83
+ /** One `getaddrinfo` answer. */
84
+ export interface LookupAnswer {
85
+ address: string;
86
+ family: number;
87
+ }
88
+ /** The name-resolution seam (node:dns `lookup` with `all: true`). */
89
+ export type DnsLookup = (name: string) => Promise<LookupAnswer[]>;
90
+ /** The datagram backend, re-detected per call. */
91
+ export declare function listenDatagram(): ListenDatagram | undefined;
92
+ /** The TCP-connect backend, re-detected per call. */
93
+ export declare function tcpConnect(): TcpConnect | undefined;
94
+ /** The TCP-listen backend, re-detected per call. */
95
+ export declare function tcpListen(): TcpListen | undefined;
96
+ /** The name-resolution backend, re-detected per call. */
97
+ export declare function dnsLookup(): DnsLookup | undefined;
98
+ /**
99
+ * Queued-but-unread datagrams past this bound are dropped (tail-drop, the
100
+ * kernel-buffer analogue). Node's `'message'` push keeps delivering
101
+ * whether or not the guest reads; unread datagrams must not accumulate
102
+ * without bound.
103
+ */
104
+ export declare const MAX_QUEUED_DATAGRAMS = 256;
105
+ /**
106
+ * Accepted-but-unread connections past this bound are REFUSED (destroyed)
107
+ * — node's `'connection'` push keeps accepting whether or not the guest
108
+ * reads the accept stream, and unlike datagrams an accepted connection is
109
+ * a live socket, so tail-drop here means an active refusal rather than a
110
+ * silent discard (the polymorph-iroh#56 stance).
111
+ */
112
+ export declare const MAX_QUEUED_CONNECTIONS = 64;