@scriptc/compiler 0.0.0 → 0.0.2

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.
Files changed (206) hide show
  1. package/LICENSE +202 -0
  2. package/ambient/package.json +3 -0
  3. package/ambient/scriptc-node-fallback.d.ts +3001 -0
  4. package/ambient/scriptc-overrides.d.ts +95 -0
  5. package/ambient/scriptc.d.ts +74 -0
  6. package/dist/backend/cc.d.ts +169 -0
  7. package/dist/backend/cc.js +897 -0
  8. package/dist/backend/cc.js.map +1 -0
  9. package/dist/backend/emission/emit-async.d.ts +145 -0
  10. package/dist/backend/emission/emit-async.js +996 -0
  11. package/dist/backend/emission/emit-async.js.map +1 -0
  12. package/dist/backend/emission/emit-exprs.d.ts +3 -0
  13. package/dist/backend/emission/emit-exprs.js +5949 -0
  14. package/dist/backend/emission/emit-exprs.js.map +1 -0
  15. package/dist/backend/emission/emit-island.d.ts +45 -0
  16. package/dist/backend/emission/emit-island.js +271 -0
  17. package/dist/backend/emission/emit-island.js.map +1 -0
  18. package/dist/backend/emission/emit-shapes.d.ts +142 -0
  19. package/dist/backend/emission/emit-shapes.js +575 -0
  20. package/dist/backend/emission/emit-shapes.js.map +1 -0
  21. package/dist/backend/emission/emit-stmts.d.ts +78 -0
  22. package/dist/backend/emission/emit-stmts.js +960 -0
  23. package/dist/backend/emission/emit-stmts.js.map +1 -0
  24. package/dist/backend/emission/emit-types.d.ts +65 -0
  25. package/dist/backend/emission/emit-types.js +652 -0
  26. package/dist/backend/emission/emit-types.js.map +1 -0
  27. package/dist/backend/emission/emit-walkers.d.ts +154 -0
  28. package/dist/backend/emission/emit-walkers.js +1587 -0
  29. package/dist/backend/emission/emit-walkers.js.map +1 -0
  30. package/dist/backend/emission/emitter.d.ts +452 -0
  31. package/dist/backend/emission/emitter.js +1249 -0
  32. package/dist/backend/emission/emitter.js.map +1 -0
  33. package/dist/backend/emission/may-throw.d.ts +15 -0
  34. package/dist/backend/emission/may-throw.js +250 -0
  35. package/dist/backend/emission/may-throw.js.map +1 -0
  36. package/dist/backend/llvm/blocks.d.ts +21 -0
  37. package/dist/backend/llvm/blocks.js +68 -0
  38. package/dist/backend/llvm/blocks.js.map +1 -0
  39. package/dist/backend/llvm/classes.d.ts +84 -0
  40. package/dist/backend/llvm/classes.js +438 -0
  41. package/dist/backend/llvm/classes.js.map +1 -0
  42. package/dist/backend/llvm/dyn.d.ts +123 -0
  43. package/dist/backend/llvm/dyn.js +2624 -0
  44. package/dist/backend/llvm/dyn.js.map +1 -0
  45. package/dist/backend/llvm/emitter.d.ts +3 -0
  46. package/dist/backend/llvm/emitter.js +10102 -0
  47. package/dist/backend/llvm/emitter.js.map +1 -0
  48. package/dist/backend/llvm/shapes.d.ts +78 -0
  49. package/dist/backend/llvm/shapes.js +754 -0
  50. package/dist/backend/llvm/shapes.js.map +1 -0
  51. package/dist/backend/llvm/unsupported.d.ts +6 -0
  52. package/dist/backend/llvm/unsupported.js +12 -0
  53. package/dist/backend/llvm/unsupported.js.map +1 -0
  54. package/dist/backend/llvm/walkers.d.ts +58 -0
  55. package/dist/backend/llvm/walkers.js +793 -0
  56. package/dist/backend/llvm/walkers.js.map +1 -0
  57. package/dist/backend/mangle.d.ts +124 -0
  58. package/dist/backend/mangle.js +232 -0
  59. package/dist/backend/mangle.js.map +1 -0
  60. package/dist/coverage/report.d.ts +65 -0
  61. package/dist/coverage/report.js +238 -0
  62. package/dist/coverage/report.js.map +1 -0
  63. package/dist/diagnostics/diagnostic.d.ts +140 -0
  64. package/dist/diagnostics/diagnostic.js +458 -0
  65. package/dist/diagnostics/diagnostic.js.map +1 -0
  66. package/dist/diagnostics/render.d.ts +11 -0
  67. package/dist/diagnostics/render.js +58 -0
  68. package/dist/diagnostics/render.js.map +1 -0
  69. package/dist/frontend/cjs-lexer.d.ts +20 -0
  70. package/dist/frontend/cjs-lexer.js +813 -0
  71. package/dist/frontend/cjs-lexer.js.map +1 -0
  72. package/dist/frontend/lowering/http2-constants.d.ts +1 -0
  73. package/dist/frontend/lowering/http2-constants.js +251 -0
  74. package/dist/frontend/lowering/http2-constants.js.map +1 -0
  75. package/dist/frontend/lowering/lib-boundary.d.ts +6 -0
  76. package/dist/frontend/lowering/lib-boundary.js +143 -0
  77. package/dist/frontend/lowering/lib-boundary.js.map +1 -0
  78. package/dist/frontend/lowering/lower-assert.d.ts +18 -0
  79. package/dist/frontend/lowering/lower-assert.js +1269 -0
  80. package/dist/frontend/lowering/lower-assert.js.map +1 -0
  81. package/dist/frontend/lowering/lower-builtins.d.ts +511 -0
  82. package/dist/frontend/lowering/lower-builtins.js +5249 -0
  83. package/dist/frontend/lowering/lower-builtins.js.map +1 -0
  84. package/dist/frontend/lowering/lower-calls.d.ts +581 -0
  85. package/dist/frontend/lowering/lower-calls.js +6286 -0
  86. package/dist/frontend/lowering/lower-calls.js.map +1 -0
  87. package/dist/frontend/lowering/lower-classes.d.ts +727 -0
  88. package/dist/frontend/lowering/lower-classes.js +4701 -0
  89. package/dist/frontend/lowering/lower-classes.js.map +1 -0
  90. package/dist/frontend/lowering/lower-comptime.d.ts +53 -0
  91. package/dist/frontend/lowering/lower-comptime.js +244 -0
  92. package/dist/frontend/lowering/lower-comptime.js.map +1 -0
  93. package/dist/frontend/lowering/lower-containers.d.ts +486 -0
  94. package/dist/frontend/lowering/lower-containers.js +6345 -0
  95. package/dist/frontend/lowering/lower-containers.js.map +1 -0
  96. package/dist/frontend/lowering/lower-dgram.d.ts +20 -0
  97. package/dist/frontend/lowering/lower-dgram.js +319 -0
  98. package/dist/frontend/lowering/lower-dgram.js.map +1 -0
  99. package/dist/frontend/lowering/lower-emitter.d.ts +10 -0
  100. package/dist/frontend/lowering/lower-emitter.js +688 -0
  101. package/dist/frontend/lowering/lower-emitter.js.map +1 -0
  102. package/dist/frontend/lowering/lower-enums.d.ts +22 -0
  103. package/dist/frontend/lowering/lower-enums.js +235 -0
  104. package/dist/frontend/lowering/lower-enums.js.map +1 -0
  105. package/dist/frontend/lowering/lower-expando.d.ts +35 -0
  106. package/dist/frontend/lowering/lower-expando.js +276 -0
  107. package/dist/frontend/lowering/lower-expando.js.map +1 -0
  108. package/dist/frontend/lowering/lower-exprs.d.ts +524 -0
  109. package/dist/frontend/lowering/lower-exprs.js +8111 -0
  110. package/dist/frontend/lowering/lower-exprs.js.map +1 -0
  111. package/dist/frontend/lowering/lower-generators.d.ts +50 -0
  112. package/dist/frontend/lowering/lower-generators.js +421 -0
  113. package/dist/frontend/lowering/lower-generators.js.map +1 -0
  114. package/dist/frontend/lowering/lower-inspect.d.ts +20 -0
  115. package/dist/frontend/lowering/lower-inspect.js +1074 -0
  116. package/dist/frontend/lowering/lower-inspect.js.map +1 -0
  117. package/dist/frontend/lowering/lower-island.d.ts +108 -0
  118. package/dist/frontend/lowering/lower-island.js +650 -0
  119. package/dist/frontend/lowering/lower-island.js.map +1 -0
  120. package/dist/frontend/lowering/lower-mixins.d.ts +96 -0
  121. package/dist/frontend/lowering/lower-mixins.js +534 -0
  122. package/dist/frontend/lowering/lower-mixins.js.map +1 -0
  123. package/dist/frontend/lowering/lower-modules.d.ts +135 -0
  124. package/dist/frontend/lowering/lower-modules.js +1613 -0
  125. package/dist/frontend/lowering/lower-modules.js.map +1 -0
  126. package/dist/frontend/lowering/lower-namespaces.d.ts +168 -0
  127. package/dist/frontend/lowering/lower-namespaces.js +706 -0
  128. package/dist/frontend/lowering/lower-namespaces.js.map +1 -0
  129. package/dist/frontend/lowering/lower-server.d.ts +90 -0
  130. package/dist/frontend/lowering/lower-server.js +3471 -0
  131. package/dist/frontend/lowering/lower-server.js.map +1 -0
  132. package/dist/frontend/lowering/lower-stmts.d.ts +361 -0
  133. package/dist/frontend/lowering/lower-stmts.js +5341 -0
  134. package/dist/frontend/lowering/lower-stmts.js.map +1 -0
  135. package/dist/frontend/lowering/lower-stream.d.ts +88 -0
  136. package/dist/frontend/lowering/lower-stream.js +1533 -0
  137. package/dist/frontend/lowering/lower-stream.js.map +1 -0
  138. package/dist/frontend/lowering/lower-test.d.ts +27 -0
  139. package/dist/frontend/lowering/lower-test.js +353 -0
  140. package/dist/frontend/lowering/lower-test.js.map +1 -0
  141. package/dist/frontend/lowering/lowerer.d.ts +1748 -0
  142. package/dist/frontend/lowering/lowerer.js +6257 -0
  143. package/dist/frontend/lowering/lowerer.js.map +1 -0
  144. package/dist/frontend/lowering/surfaces.d.ts +272 -0
  145. package/dist/frontend/lowering/surfaces.js +1096 -0
  146. package/dist/frontend/lowering/surfaces.js.map +1 -0
  147. package/dist/frontend/npm-static.d.ts +55 -0
  148. package/dist/frontend/npm-static.js +300 -0
  149. package/dist/frontend/npm-static.js.map +1 -0
  150. package/dist/frontend/npm.d.ts +330 -0
  151. package/dist/frontend/npm.js +1259 -0
  152. package/dist/frontend/npm.js.map +1 -0
  153. package/dist/frontend/program.d.ts +186 -0
  154. package/dist/frontend/program.js +2255 -0
  155. package/dist/frontend/program.js.map +1 -0
  156. package/dist/frontend/provenance-registry.d.ts +48 -0
  157. package/dist/frontend/provenance-registry.js +87 -0
  158. package/dist/frontend/provenance-registry.js.map +1 -0
  159. package/dist/frontend/provenance.d.ts +6 -0
  160. package/dist/frontend/provenance.js +459 -0
  161. package/dist/frontend/provenance.js.map +1 -0
  162. package/dist/frontend/resolve.d.ts +56 -0
  163. package/dist/frontend/resolve.js +682 -0
  164. package/dist/frontend/resolve.js.map +1 -0
  165. package/dist/frontend/shared.d.ts +67 -0
  166. package/dist/frontend/shared.js +241 -0
  167. package/dist/frontend/shared.js.map +1 -0
  168. package/dist/frontend/ts7/adapter.d.ts +7 -0
  169. package/dist/frontend/ts7/adapter.js +54 -0
  170. package/dist/frontend/ts7/adapter.js.map +1 -0
  171. package/dist/frontend/ts7/ast.d.ts +50 -0
  172. package/dist/frontend/ts7/ast.js +211 -0
  173. package/dist/frontend/ts7/ast.js.map +1 -0
  174. package/dist/frontend/ts7/census-check.d.ts +1 -0
  175. package/dist/frontend/ts7/census-check.js +12 -0
  176. package/dist/frontend/ts7/census-check.js.map +1 -0
  177. package/dist/frontend/ts7/checker.d.ts +140 -0
  178. package/dist/frontend/ts7/checker.js +544 -0
  179. package/dist/frontend/ts7/checker.js.map +1 -0
  180. package/dist/frontend/ts7/enums.d.ts +18 -0
  181. package/dist/frontend/ts7/enums.js +43 -0
  182. package/dist/frontend/ts7/enums.js.map +1 -0
  183. package/dist/frontend/ts7/program.d.ts +99 -0
  184. package/dist/frontend/ts7/program.js +278 -0
  185. package/dist/frontend/ts7/program.js.map +1 -0
  186. package/dist/frontend/ts7/world-check.d.ts +3 -0
  187. package/dist/frontend/ts7/world-check.js +34 -0
  188. package/dist/frontend/ts7/world-check.js.map +1 -0
  189. package/dist/frontend/types.d.ts +205 -0
  190. package/dist/frontend/types.js +2485 -0
  191. package/dist/frontend/types.js.map +1 -0
  192. package/dist/index.d.ts +85 -0
  193. package/dist/index.js +429 -0
  194. package/dist/index.js.map +1 -0
  195. package/dist/ir/nodes.d.ts +4334 -0
  196. package/dist/ir/nodes.js +1906 -0
  197. package/dist/ir/nodes.js.map +1 -0
  198. package/dist/ir/serialize.d.ts +4 -0
  199. package/dist/ir/serialize.js +34 -0
  200. package/dist/ir/serialize.js.map +1 -0
  201. package/dist/ir/validate.d.ts +36 -0
  202. package/dist/ir/validate.js +4885 -0
  203. package/dist/ir/validate.js.map +1 -0
  204. package/package.json +30 -6
  205. package/README.md +0 -3
  206. package/index.js +0 -2
@@ -0,0 +1,3001 @@
1
+ /* The FALLBACK Node-ish declarations — shipped into the program ONLY when
2
+ * the target project has no @types/node (see loadProgram): console, the
3
+ * process global, and the "node:fs" module, typed as exactly the supported
4
+ * surface so unsupported uses are honest TYPE errors.
5
+ *
6
+ * When the project's node_modules contains @types/node, this file STANDS
7
+ * DOWN — its declarations would collide with @types/node's own (`declare
8
+ * var process`, `declare var console`, `declare module "node:fs"`), and
9
+ * the project's real types win. The LOWERED surface does not change: the
10
+ * lowerer recognizes the same members by name + provenance (shipped
11
+ * ambient OR @types/node — see isStdlibFile/isNodeTypesPath), and
12
+ * everything else @types/node declares hits the SC2020-family fence at
13
+ * its use site. scriptc.d.ts holds the always-shipped core (divergence
14
+ * overrides, comptime, __island_eval, setTimeout — which MERGES with
15
+ * @types/node's as an overload instead of colliding). */
16
+
17
+ /* NodeJS.ErrnoException — the Error shape @types/node attaches to fs and
18
+ * child failures. The TYPE maps to the runtime Error root; only `code`
19
+ * has a lowering (throw sites stamp the errno name — "ENOENT" and
20
+ * friends; reads answer `string | undefined`), errno/syscall/path
21
+ * typecheck and fence per member. */
22
+ declare namespace NodeJS {
23
+ /* The process introspection records — named interfaces so the type
24
+ * mapper interns their record shapes (the RemoteInfo pattern; the
25
+ * names match @types/node's, so the mappings hold when it adopts). */
26
+ interface CpuUsage {
27
+ user: number;
28
+ system: number;
29
+ }
30
+ interface ResourceUsage {
31
+ userCPUTime: number;
32
+ systemCPUTime: number;
33
+ maxRSS: number;
34
+ sharedMemorySize: number;
35
+ unsharedDataSize: number;
36
+ unsharedStackSize: number;
37
+ minorPageFault: number;
38
+ majorPageFault: number;
39
+ swappedOut: number;
40
+ fsRead: number;
41
+ fsWrite: number;
42
+ ipcSent: number;
43
+ ipcReceived: number;
44
+ signalsCount: number;
45
+ voluntaryContextSwitches: number;
46
+ involuntaryContextSwitches: number;
47
+ }
48
+ interface ErrnoException extends Error {
49
+ errno?: number | undefined;
50
+ code?: string | undefined;
51
+ path?: string | undefined;
52
+ syscall?: string | undefined;
53
+ }
54
+ /* The piped child-output stream (child.stdout / child.stderr under
55
+ * stdio ["ignore", "pipe", "pipe"]): 'data' fires one Buffer chunk per
56
+ * read (≤64KB, consumer-driven — no listener, no read), 'end' fires
57
+ * once at EOF and always BEFORE the child's 'exit'. A flowing stream
58
+ * keeps the loop alive. */
59
+ interface ReadableStream {
60
+ on(event: "data", listener: (chunk: Buffer) => void): void;
61
+ on(event: "end", listener: () => void): void;
62
+ once(event: "data", listener: (chunk: Buffer) => void): void;
63
+ once(event: "end", listener: () => void): void;
64
+ /* Declared surface without a lowering (chunks stay bytes; decode
65
+ * with TextDecoder) — string-mode consumers typecheck and fence at
66
+ * the reached site. With setEncoding in force Node hands strings to
67
+ * 'data', hence the string arm on the listener above being absent:
68
+ * the lowered surface is bytes-only. */
69
+ setEncoding(encoding: string): void;
70
+ }
71
+ }
72
+
73
+ /* log writes stdout; error and warn are ONE stream in Node (warn IS error
74
+ * under another name) and write stderr with the exact same formatting.
75
+ * stderr is unbuffered (stdout flushes first, so merged 2>&1 output keeps
76
+ * source order). */
77
+ declare const console: {
78
+ log(...args: (number | string | boolean)[]): void;
79
+ error(...args: (number | string | boolean)[]): void;
80
+ warn(...args: (number | string | boolean)[]): void;
81
+ };
82
+
83
+ /* The process global (Node-like, deliberately tiny). Every member lowers to
84
+ * a `libCall` and is implemented in the runtime's scr_lib.c. `argv` is one
85
+ * interned array (identity and mutation semantics match Node's stable
86
+ * process.argv); `exit` flushes stdout and ends the process immediately.
87
+ * `env` reads (`process.env.NAME` / `process.env[name]`) are getenv(3)
88
+ * behind a `string | undefined` union — narrow with `!== undefined` before
89
+ * use — and writes are setenv(3): later reads and spawned children observe
90
+ * them, like Node. `process.env` as a WHOLE value is a fresh
91
+ * `{ [k: string]: string | undefined }` SNAPSHOT record over environ
92
+ * (spreads, Object.keys, spawn-env flows). `pid`/`getuid()` are the POSIX
93
+ * identities (getuid is declared optional to match @types/node — the
94
+ * `?.()` call lowers as the plain call on this POSIX-only target), and
95
+ * `kill` has Node's exact semantics: signal names or numbers, SIGTERM
96
+ * default, signal 0 as an existence probe, and Node's error shapes
97
+ * (`kill ESRCH`/`kill EPERM` Errors, TypeErrors for unknown signals and
98
+ * non-int32 pids). */
99
+ declare var process: {
100
+ argv: string[];
101
+ platform: string;
102
+ /* The binary's OWN architecture ("arm64", "x64") — Node's answer for
103
+ * its own build on the same machine. */
104
+ readonly arch: string;
105
+ /* versions.node is the runtime's Node COMPATIBILITY TARGET — no Node
106
+ * exists under a compiled binary (SEMANTICS.md divergence 60); the
107
+ * other components @types/node lists (v8, openssl, ...) do not exist
108
+ * here. openssl and sqlite are DECLARED (optional, so absence reads
109
+ * undefined) and LOWER to undefined — the honest capability probe
110
+ * (`Boolean(process.versions.openssl)`) answers false: no OpenSSL and
111
+ * no SQLite ship in a scriptc binary. Other members fence per site. */
112
+ readonly versions: { readonly node: string; readonly openssl?: string; readonly sqlite?: string };
113
+ /* The build-configuration snapshot Node exposes from its gyp config.
114
+ * A scriptc binary has no V8 and no gyp, so `variables` answers the
115
+ * honest capability record (v8_enable_i18n_support: 0 — no ICU; asan
116
+ * mirrors the sanitizer build flag) and `target_defaults` is absent —
117
+ * probe code takes its documented fallbacks. Reads of undeclared
118
+ * variables go through the index signature (string | number | boolean
119
+ * | undefined) and answer undefined. */
120
+ readonly config: {
121
+ readonly variables: { readonly [name: string]: string | number | boolean | undefined };
122
+ readonly target_defaults?: { readonly default_configuration: string };
123
+ };
124
+ /* Node's feature probes — a compiled binary has no inspector and is
125
+ * not a debug build; undeclared members read undefined through the
126
+ * index signature. */
127
+ readonly features: { readonly [name: string]: boolean | undefined };
128
+ /* umask(2) — sets the file-mode creation mask and returns the previous
129
+ * one; the no-argument form reads without setting (Node's shape). */
130
+ umask(mask?: number): number;
131
+ /* chdir(2) — failures throw Node's fs-shaped catchable error. */
132
+ chdir(directory: string): void;
133
+ /* The extra CLI arguments Node itself consumed (--expose-internals,
134
+ * ...): a compiled binary consumed none, so this is always []. */
135
+ readonly execArgv: string[];
136
+ /* Node's internal "exit sequence started" flag (real, undocumented
137
+ * surface — the test harness reads it): true while 'exit' listeners
138
+ * run, false otherwise. */
139
+ readonly _exiting: boolean;
140
+ /* Node's raw synchronous stderr write (internal surface the test
141
+ * harness uses on its failure paths). */
142
+ _rawDebug(...args: unknown[]): void;
143
+ pid: number;
144
+ /* The compiled binary's own resolved absolute path — Node's is the node
145
+ * executable's (SEMANTICS.md divergence 12, the argv[0]/argv[1] story). */
146
+ readonly execPath: string;
147
+ getuid?(): number;
148
+ getgid?(): number;
149
+ /* signal admits null (Node treats it as the SIGTERM default) — real
150
+ * callers forward a `string | null` result field. */
151
+ kill(pid: number, signal?: string | number | null): true;
152
+ env: { [name: string]: string | undefined };
153
+ /* `never`, like @types/node: code behind an early-exit guard narrows
154
+ * (`if (!x) process.exit(1)` proves x afterwards) — typed `void` the
155
+ * guard narrows nothing and correct programs fail preflight. The
156
+ * lowering already handles the optional code (bare exit() is exit(0),
157
+ * Node's behavior when exitCode was never set). */
158
+ exit(code?: number | null): never;
159
+ cwd(): string;
160
+ /* The user tick queue: callbacks run before promise jobs at every loop
161
+ * checkpoint (Node's tick-then-microtask order); trailing arguments
162
+ * pass to the callback at fire time, like Node. */
163
+ nextTick(callback: (...args: any[]) => void, ...args: any[]): void;
164
+ /* The process introspection statics — Node's shapes and units. */
165
+ uptime(): number;
166
+ cpuUsage(previousValue?: NodeJS.CpuUsage): NodeJS.CpuUsage;
167
+ threadCpuUsage(previousValue?: NodeJS.CpuUsage): NodeJS.CpuUsage;
168
+ resourceUsage(): NodeJS.ResourceUsage;
169
+ availableMemory(): number;
170
+ constrainedMemory(): number;
171
+ /* The loop's own bookkeeping: 'Timeout' per armed timer, 'Immediate'
172
+ * per queued unfired immediate; unmodeled kinds absent (SEMANTICS.md). */
173
+ getActiveResourcesInfo(): string[];
174
+ /* The raw byte writes — no newline, no formatting. stdout shares
175
+ * console.log's stream and buffer, so ordering is preserved; stderr is
176
+ * unbuffered like Node's. The boolean is Node's backpressure signal —
177
+ * these synchronous writes always return true. The Uint8Array overload
178
+ * and isTTY exist so real CLIs TYPECHECK (they are @types/node surface);
179
+ * only the one-string form has a lowering — everything else fences at
180
+ * its use site. */
181
+ stdout: { write(data: string): boolean; write(data: Uint8Array): boolean; readonly isTTY: boolean };
182
+ stderr: { write(data: string): boolean; write(data: Uint8Array): boolean; readonly isTTY: boolean };
183
+ /* The stdin stream, the piped-input slice: the TTY probe, the
184
+ * data/end/error events (on and once — a 'data' listener keeps the
185
+ * event loop alive until EOF, like Node's flowing stdin), destroy()
186
+ * (full teardown: nothing fires after, the loop stops waiting), and
187
+ * async iteration (`for await (const chunk of process.stdin)` — chunks
188
+ * are Uint8Array values, ending at EOF). setEncoding has no lowering
189
+ * (chunks stay bytes; decode with TextDecoder). */
190
+ stdin: {
191
+ readonly isTTY: boolean;
192
+ on(event: "data", listener: (chunk: Uint8Array) => void): void;
193
+ on(event: "end", listener: () => void): void;
194
+ on(event: "error", listener: (err: Error) => void): void;
195
+ once(event: "data", listener: (chunk: Uint8Array) => void): void;
196
+ once(event: "end", listener: () => void): void;
197
+ once(event: "error", listener: (err: Error) => void): void;
198
+ destroy(): void;
199
+ setEncoding(encoding: "utf8"): void;
200
+ /* Termios raw mode on a TTY stdin (libuv's UV_TTY_MODE_RAW, the mode
201
+ * Node applies); on a NON-TTY stdin the member does not exist in Node
202
+ * and the call throws Node's exact catchable TypeError. Node returns
203
+ * `this` for chaining; here the call is statement-position only. */
204
+ setRawMode(mode: boolean): void;
205
+ [Symbol.asyncIterator](): AsyncIterableIterator<Uint8Array>;
206
+ };
207
+ /* Process events, the CLI slice: SIGINT/SIGTERM handlers (watching a
208
+ * signal replaces its default disposition; removing the last listener
209
+ * restores it; signal listeners never keep the loop alive — all Node's
210
+ * rules) and the 'exit' hook (runs synchronously at termination with
211
+ * the exit code; scheduling anything from it is too late, like Node).
212
+ * `once` auto-removes after the first delivery; `off` removes by
213
+ * listener identity — bind the listener to a const so registration and
214
+ * removal see the same value. */
215
+ on(event: "SIGINT" | "SIGTERM", listener: () => void): void;
216
+ on(event: "exit", listener: (code: number) => void): void;
217
+ /* 'warning' — Node's process-warning channel: listeners receive the
218
+ * warning Error (as a DOM value); emitWarning and the runtime's
219
+ * deprecation sites dispatch synchronously (SEMANTICS.md). */
220
+ on(event: "warning", listener: (warning: Error & { code?: string }) => void): void;
221
+ /* 'unhandledRejection' — dispatched per never-observed rejection at
222
+ * loop end (reason, promise), suppressing the default report. */
223
+ on(event: "unhandledRejection", listener: (reason: unknown, promise: unknown) => void): void;
224
+ once(event: "SIGINT" | "SIGTERM", listener: () => void): void;
225
+ once(event: "exit", listener: (code: number) => void): void;
226
+ off(event: "SIGINT" | "SIGTERM", listener: () => void): void;
227
+ off(event: "exit", listener: (code: number) => void): void;
228
+ off(event: "warning", listener: (warning: Error & { code?: string }) => void): void;
229
+ /* removeListener IS off — Node aliases them; both lower identically. */
230
+ removeListener(event: "SIGINT" | "SIGTERM", listener: () => void): void;
231
+ removeListener(event: "exit", listener: (code: number) => void): void;
232
+ removeListener(event: "warning", listener: (warning: Error & { code?: string }) => void): void;
233
+ /* emitWarning — Node's full grammar (string or Error warning; type/
234
+ * ctor/options second; code/ctor third). */
235
+ emitWarning(warning: string | Error, ...args: any[]): void;
236
+ };
237
+
238
+ /* ── globals a real CLI's sources reference (all @types/node or DOM-lib
239
+ * territory; the fallback declares the slice so projects PREFLIGHT and
240
+ * every reached use lands on the SC2020 fence — or a real lowering where
241
+ * one exists — instead of "Cannot find name"). With @types/node these
242
+ * stand down with the rest of the file. ─────────────────────────────── */
243
+
244
+ /* The CommonJS module globals. `__dirname`/`__filename` are compile-time
245
+ * constants — each MODULE's real directory/file path (Node's per-module
246
+ * values exactly; the build machine's paths are baked in, which is also
247
+ * what Node answers when the same tree runs in place). In a file with ESM
248
+ * syntax they fence: Node throws ReferenceError there. */
249
+ declare var __dirname: string;
250
+ declare var __filename: string;
251
+
252
+ /* `global` IS globalThis (Node's alias), and `declare var process` above
253
+ * puts process on `typeof globalThis` — so `globalThis.process` and
254
+ * `global.process` read the same object as the bare name. */
255
+ declare var global: typeof globalThis;
256
+
257
+ /* The `require` VALUE's non-call surface. require() CALLS are module
258
+ * edges (the checker models them as imports); the object's own members
259
+ * are declared here so harness idioms typecheck. `require.main` lowers
260
+ * to the ENTRY module's record ({ filename } — a compiled binary's main
261
+ * module is always the entry, Node's answer for a directly-run script);
262
+ * the rest fences per site. */
263
+ declare var require: {
264
+ /* The call signature types NON-IMPORT-SHAPED require expressions (the
265
+ * checker models import-shaped requires as module aliases regardless,
266
+ * exactly like under @types/node's NodeRequire). `any`, like
267
+ * @types/node: the value's home is the module system, not the static
268
+ * value model — reached uses fence per site. */
269
+ (id: string): any;
270
+ main: { filename: string } | undefined;
271
+ resolve(id: string): string;
272
+ cache: { [id: string]: unknown };
273
+ };
274
+
275
+ /* setImmediate/clearImmediate — Node's macrotask pair (fires after I/O
276
+ * events of the current loop turn, before timers due later). The handle
277
+ * follows the Timeout pattern: loop-liveness bookkeeping. */
278
+ interface Immediate {
279
+ ref(): Immediate;
280
+ unref(): Immediate;
281
+ hasRef(): boolean;
282
+ }
283
+ declare function setImmediate(callback: () => void): Immediate;
284
+ /* The trailing-argument form — Node passes the extras to the callback. */
285
+ declare function setImmediate(callback: (...args: never[]) => void, ...args: unknown[]): Immediate;
286
+ declare function clearImmediate(handle?: Immediate | null | undefined): void;
287
+
288
+ /* queueMicrotask — the microtask queue (the promise-continuation queue:
289
+ * runs before any timer/immediate/I/O callback scheduled later). */
290
+ declare function queueMicrotask(callback: () => void): void;
291
+
292
+ /* structuredClone — the JSON-safe + bytes subset clones deep (cycles
293
+ * fence; functions throw the spec's DataCloneError; DOMException clones
294
+ * per WebIDL serialization). `value` is optional and `options` is
295
+ * `unknown` so Node's own RUNTIME errors fire (ERR_MISSING_ARGS for the
296
+ * zero-argument call, the dictionary/sequence TypeErrors for bad
297
+ * options) where a tighter signature would reject at compile time —
298
+ * the suite exercises exactly those. */
299
+ declare function structuredClone<T = undefined>(value?: T, options?: unknown): T;
300
+
301
+ /* AbortController — the signal factory for the fetch-cancellation slice
302
+ * (AbortSignal above). */
303
+ interface AbortController {
304
+ readonly signal: AbortSignal;
305
+ abort(reason?: unknown): void;
306
+ }
307
+ declare var AbortController: { new (): AbortController };
308
+
309
+ /* atob/btoa — Node globals since v16 (the "buffer" module re-exports
310
+ * them below): base64 → binary string and back, Latin-1 domain like the
311
+ * WHATWG originals. The parameter is `unknown` because WebIDL ToStrings
312
+ * whatever arrives (Node's atob(null) decodes "null") — the coercion
313
+ * runs in the runtime over the DOM kind, and the Node suite exercises
314
+ * it; malformed input throws the catchable DOMException
315
+ * InvalidCharacterError, the zero-argument call Node's TypeError
316
+ * [ERR_MISSING_ARGS]. */
317
+ declare function atob(data?: unknown): string;
318
+ declare function btoa(data?: unknown): string;
319
+
320
+ /* DOMException — the web-standard error shape (a Node global since
321
+ * v17): an Error subclass whose `code` is the WebIDL legacy NUMBER
322
+ * (InvalidCharacterError = 5, 0 for off-table names) and whose options
323
+ * form carries `cause`. `new DOMException(msg)` has name "Error" like
324
+ * the spec's default. Subclassing is fenced (the runtime layout carries
325
+ * hidden slots) — extend Error instead. */
326
+ interface DOMException extends Error {
327
+ readonly code: number;
328
+ }
329
+ declare var DOMException: {
330
+ new (message?: unknown, nameOrOptions?: unknown): DOMException;
331
+ readonly prototype: DOMException;
332
+ };
333
+
334
+ /* Capability-gated globals harness code probes behind feature guards
335
+ * (globalThis.crypto under a hasCrypto check, the SQLite-backed storage
336
+ * pair): typed `unknown` — no lowering exists, the guard is expected to
337
+ * be false in a compiled binary, and any reached use fences per site. */
338
+ declare var crypto: unknown;
339
+ declare var Crypto: unknown;
340
+ declare var CryptoKey: unknown;
341
+ declare var SubtleCrypto: unknown;
342
+ declare var localStorage: unknown;
343
+ declare var sessionStorage: unknown;
344
+
345
+ /* Node's Buffer, typed as a Uint8Array subtype with the members CLI code
346
+ * touches — ONE runtime representation with Uint8Array (the u8 bytes
347
+ * kind); the members beyond the lowered surface fence per site. */
348
+ /* Node's encoding-name union (aliases included — the compiler folds them
349
+ * to the runtime's canonical spellings at the call site). */
350
+ type BufferEncoding =
351
+ | "utf8"
352
+ | "utf-8"
353
+ | "hex"
354
+ | "base64"
355
+ | "base64url"
356
+ | "latin1"
357
+ | "ascii"
358
+ | "binary"
359
+ | "utf16le"
360
+ | "utf-16le"
361
+ | "ucs2"
362
+ | "ucs-2";
363
+ interface Buffer<TArrayBuffer extends ArrayBufferLike = ArrayBufferLike> extends Uint8Array<TArrayBuffer> {
364
+ toString(encoding?: BufferEncoding, start?: number, end?: number): string;
365
+ equals(otherBuffer: Uint8Array): boolean;
366
+ compare(target: Uint8Array, targetStart?: number, targetEnd?: number, sourceStart?: number, sourceEnd?: number): number;
367
+ indexOf(value: string | number | Uint8Array, byteOffset?: number | BufferEncoding, encoding?: BufferEncoding): number;
368
+ lastIndexOf(value: string | number | Uint8Array, byteOffset?: number | BufferEncoding, encoding?: BufferEncoding): number;
369
+ includes(value: string | number | Buffer, byteOffset?: number | BufferEncoding, encoding?: BufferEncoding): boolean;
370
+ fill(value: string | number | Uint8Array, offset?: number | BufferEncoding, end?: number | BufferEncoding, encoding?: BufferEncoding): this;
371
+ copy(target: Uint8Array, targetStart?: number, sourceStart?: number, sourceEnd?: number): number;
372
+ swap16(): Buffer;
373
+ swap32(): Buffer;
374
+ swap64(): Buffer;
375
+ write(string: string, offset?: number | BufferEncoding, length?: number | BufferEncoding, encoding?: BufferEncoding): number;
376
+ subarray(start?: number, end?: number): Buffer<TArrayBuffer>;
377
+ /* @types/node's spelling — the ArrayBuffer instantiation keeps the
378
+ * override compatible with the lib's Uint8Array.slice. */
379
+ slice(start?: number, end?: number): Buffer<ArrayBuffer>;
380
+ writeUInt8(value: number, offset?: number): number;
381
+ writeUInt16BE(value: number, offset?: number): number;
382
+ writeUInt16LE(value: number, offset?: number): number;
383
+ writeUInt32BE(value: number, offset?: number): number;
384
+ writeUInt32LE(value: number, offset?: number): number;
385
+ writeInt8(value: number, offset?: number): number;
386
+ writeInt16BE(value: number, offset?: number): number;
387
+ writeInt16LE(value: number, offset?: number): number;
388
+ writeInt32BE(value: number, offset?: number): number;
389
+ writeInt32LE(value: number, offset?: number): number;
390
+ writeFloatBE(value: number, offset?: number): number;
391
+ writeFloatLE(value: number, offset?: number): number;
392
+ writeDoubleBE(value: number, offset?: number): number;
393
+ writeDoubleLE(value: number, offset?: number): number;
394
+ writeUIntBE(value: number, offset: number, byteLength: number): number;
395
+ writeUIntLE(value: number, offset: number, byteLength: number): number;
396
+ writeIntBE(value: number, offset: number, byteLength: number): number;
397
+ writeIntLE(value: number, offset: number, byteLength: number): number;
398
+ readUInt8(offset?: number): number;
399
+ readUInt16BE(offset?: number): number;
400
+ readUInt16LE(offset?: number): number;
401
+ readUInt32BE(offset?: number): number;
402
+ readUInt32LE(offset?: number): number;
403
+ readInt8(offset?: number): number;
404
+ readInt16BE(offset?: number): number;
405
+ readInt16LE(offset?: number): number;
406
+ readInt32BE(offset?: number): number;
407
+ readInt32LE(offset?: number): number;
408
+ readFloatBE(offset?: number): number;
409
+ readFloatLE(offset?: number): number;
410
+ readDoubleBE(offset?: number): number;
411
+ readDoubleLE(offset?: number): number;
412
+ readUIntBE(offset: number, byteLength: number): number;
413
+ readUIntLE(offset: number, byteLength: number): number;
414
+ readIntBE(offset: number, byteLength: number): number;
415
+ readIntLE(offset: number, byteLength: number): number;
416
+ }
417
+ interface BufferConstructor {
418
+ from(data: string, encoding?: BufferEncoding): Buffer;
419
+ from(data: Uint8Array | ArrayBuffer | readonly number[]): Buffer;
420
+ alloc(size: number, fill?: string | number | Uint8Array, encoding?: BufferEncoding): Buffer;
421
+ compare(buf1: Uint8Array, buf2: Uint8Array): number;
422
+ /* alloc without the zero-fill guarantee — the lowering zero-fills
423
+ * anyway (never handing out uninitialized memory costs one memset). */
424
+ allocUnsafe(size: number): Buffer;
425
+ concat(list: readonly Uint8Array[], totalLength?: number): Buffer;
426
+ isBuffer(obj: unknown): obj is Buffer;
427
+ byteLength(input: string | Uint8Array, encoding?: BufferEncoding): number;
428
+ isEncoding(encoding: string): boolean;
429
+ }
430
+ declare var Buffer: BufferConstructor;
431
+
432
+ /* The WHATWG encoders (Node globals). Only the COMPOSED forms lower —
433
+ * `new TextEncoder().encode(s)` and `new TextDecoder().decode(bytes)`;
434
+ * the label is typed as the utf-8 spellings (the one supported decoder;
435
+ * other labels and the fatal/ignoreBOM options fence at the use site). */
436
+ interface TextEncoder {
437
+ encode(input?: string): Uint8Array;
438
+ }
439
+ declare var TextEncoder: { new (): TextEncoder };
440
+ interface TextDecoder {
441
+ decode(input?: ArrayBufferView | ArrayBuffer): string;
442
+ }
443
+ declare var TextDecoder: { new (label?: "utf-8" | "utf8"): TextDecoder };
444
+
445
+ /* The WHATWG event surface (Node globals since v15): declared so the
446
+ * suite's event-plumbing tests typecheck and fence per SITE with the
447
+ * member's own name. The dynamic island's web prelude implements
448
+ * Event/CustomEvent/EventTarget/DOMException/AbortController for real;
449
+ * the static tier has no lowering yet — construction and members fence
450
+ * honestly (SC2020). */
451
+ interface Event {
452
+ readonly type: string;
453
+ readonly bubbles: boolean;
454
+ readonly cancelable: boolean;
455
+ readonly composed: boolean;
456
+ readonly defaultPrevented: boolean;
457
+ readonly eventPhase: number;
458
+ readonly target: EventTarget | null;
459
+ readonly currentTarget: EventTarget | null;
460
+ readonly srcElement: EventTarget | null;
461
+ readonly isTrusted: boolean;
462
+ readonly timeStamp: number;
463
+ cancelBubble: boolean;
464
+ returnValue: boolean;
465
+ preventDefault(): void;
466
+ stopPropagation(): void;
467
+ stopImmediatePropagation(): void;
468
+ composedPath(): unknown[];
469
+ }
470
+ declare var Event: {
471
+ new (type: string, eventInitDict?: { bubbles?: boolean; cancelable?: boolean; composed?: boolean }): Event;
472
+ readonly prototype: Event;
473
+ readonly NONE: 0;
474
+ readonly CAPTURING_PHASE: 1;
475
+ readonly AT_TARGET: 2;
476
+ readonly BUBBLING_PHASE: 3;
477
+ };
478
+ interface CustomEvent<T = unknown> extends Event {
479
+ readonly detail: T;
480
+ }
481
+ declare var CustomEvent: {
482
+ new <T = unknown>(type: string, eventInitDict?: { detail?: T; bubbles?: boolean; cancelable?: boolean; composed?: boolean }): CustomEvent<T>;
483
+ readonly prototype: CustomEvent;
484
+ };
485
+ interface MessageEvent<T = unknown> extends Event {
486
+ readonly data: T;
487
+ readonly origin: string;
488
+ readonly lastEventId: string;
489
+ readonly ports: readonly MessagePort[];
490
+ }
491
+ declare var MessageEvent: {
492
+ new <T = unknown>(type: string, eventInitDict?: { data?: T; origin?: string; lastEventId?: string }): MessageEvent<T>;
493
+ readonly prototype: MessageEvent;
494
+ };
495
+ interface AddEventListenerOptions {
496
+ capture?: boolean;
497
+ once?: boolean;
498
+ passive?: boolean;
499
+ signal?: AbortSignal;
500
+ }
501
+ interface EventTarget {
502
+ addEventListener(
503
+ type: string,
504
+ listener: ((event: Event) => void) | { handleEvent(event: Event): void } | null,
505
+ options?: AddEventListenerOptions | boolean,
506
+ ): void;
507
+ removeEventListener(
508
+ type: string,
509
+ listener: ((event: Event) => void) | { handleEvent(event: Event): void } | null,
510
+ options?: { capture?: boolean } | boolean,
511
+ ): void;
512
+ dispatchEvent(event: Event): boolean;
513
+ }
514
+ declare var EventTarget: {
515
+ new (): EventTarget;
516
+ readonly prototype: EventTarget;
517
+ };
518
+
519
+ /* MessagePort/MessageChannel — the worker_threads pair Node exposes as
520
+ * globals (v15+). The island's worker_threads shim implements the
521
+ * same-thread subset (postMessage delivers structured-clone copies on a
522
+ * microtask); the web prelude exposes the classes as engine globals.
523
+ * Statically declared-not-lowered: per-site fences. */
524
+ interface MessagePort extends EventTarget {
525
+ postMessage(value: unknown, transferOrOptions?: unknown): void;
526
+ start(): void;
527
+ close(): void;
528
+ ref(): void;
529
+ unref(): void;
530
+ onmessage: ((event: MessageEvent) => void) | null;
531
+ onmessageerror: ((event: MessageEvent) => void) | null;
532
+ onclose: ((event: Event) => void) | null;
533
+ }
534
+ declare var MessagePort: {
535
+ readonly prototype: MessagePort;
536
+ };
537
+ interface MessageChannel {
538
+ readonly port1: MessagePort;
539
+ readonly port2: MessagePort;
540
+ }
541
+ declare var MessageChannel: {
542
+ new (): MessageChannel;
543
+ readonly prototype: MessageChannel;
544
+ };
545
+
546
+ /* AbortSignal, the fetch-cancellation slice (AbortSignal.timeout is the
547
+ * whole surface real CLIs construct; the statics beyond it — abort/any —
548
+ * and the instance events are declared for the suite and fence per site
549
+ * statically, with the island's real implementation behind --dynamic). */
550
+ interface AbortSignal extends EventTarget {
551
+ readonly aborted: boolean;
552
+ readonly reason: unknown;
553
+ onabort: ((event: Event) => void) | null;
554
+ throwIfAborted(): void;
555
+ }
556
+ declare var AbortSignal: {
557
+ timeout(ms: number): AbortSignal;
558
+ abort(reason?: unknown): AbortSignal;
559
+ any(signals: readonly AbortSignal[]): AbortSignal;
560
+ readonly prototype: AbortSignal;
561
+ };
562
+
563
+ /* fetch, typed as the JSON-API slice: one URL, an optional init with the
564
+ * members CLI requests carry, a Response with the probe members and body
565
+ * readers. json() returns unknown — the same dynamic boundary as
566
+ * JSON.parse: cast and validate. Response, AbortSignal, and RequestInit
567
+ * are ISLAND-BACKED ambients: under --dynamic their values are handles
568
+ * into the embedded engine (the engine's own fetch executes; member reads
569
+ * and calls are engine ops with validated exits at typed boundaries), so
570
+ * `body` is honestly `any` — the streaming world lives entirely in the
571
+ * island. The named RequestInit interface is what routes init object
572
+ * literals through the island literal builder. */
573
+ interface Response {
574
+ readonly ok: boolean;
575
+ readonly status: number;
576
+ readonly statusText: string;
577
+ readonly body: any;
578
+ json(): Promise<unknown>;
579
+ text(): Promise<string>;
580
+ }
581
+ interface RequestInit {
582
+ method?: string;
583
+ headers?: Record<string, string>;
584
+ body?: string;
585
+ signal?: AbortSignal;
586
+ }
587
+ declare function fetch(input: string | URL, init?: RequestInit): Promise<Response>;
588
+
589
+ /* The repeating timer pair (setTimeout lives in scriptc.d.ts — always
590
+ * shipped). The handle is the Timeout interface, like Node's — it maps to
591
+ * the numeric timer id, so ReturnType<typeof setInterval> stays a
592
+ * representable type and `.unref()/.ref()/.hasRef()/.refresh()` chain over
593
+ * setInterval results exactly like setTimeout's. clearInterval keeps the
594
+ * historic number arm (the id IS the handle) alongside Node's undefined
595
+ * tolerance. */
596
+ declare function setInterval(callback: () => void, ms?: number): Timeout;
597
+ /* The trailing-argument form — setTimeout's exact story, every tick. */
598
+ declare function setInterval(callback: (...args: never[]) => void, ms?: number, ...args: unknown[]): Timeout;
599
+ declare function clearInterval(handle?: Timeout | number | null | undefined): void;
600
+
601
+ /* node:timers — the module twins of the timer globals (Node's timers
602
+ * module re-exports them: require('timers').setTimeout IS setTimeout).
603
+ * Named imports, destructured requires, and namespace calls all lower to
604
+ * the same libCalls as the globals; the surface beyond these six
605
+ * (enroll/unenroll, promises) fences per member. */
606
+ declare module "node:timers" {
607
+ export function setTimeout(callback: () => void, ms?: number): Timeout;
608
+ export function setTimeout(callback: (...args: never[]) => void, ms?: number, ...args: unknown[]): Timeout;
609
+ export function clearTimeout(handle?: Timeout | number | null | undefined): void;
610
+ export function setInterval(callback: () => void, ms?: number): Timeout;
611
+ export function setInterval(callback: (...args: never[]) => void, ms?: number, ...args: unknown[]): Timeout;
612
+ export function clearInterval(handle?: Timeout | number | null | undefined): void;
613
+ export function setImmediate(callback: () => void): Immediate;
614
+ export function setImmediate(callback: (...args: never[]) => void, ...args: unknown[]): Immediate;
615
+ export function clearImmediate(handle?: Immediate | null | undefined): void;
616
+ }
617
+ declare module "timers" {
618
+ export * from "node:timers";
619
+ }
620
+
621
+ /* node:timers/promises — the promisified pair the Node test harness leans
622
+ * on (`await setTimeout(ms)` as a sleep). setTimeout's delay-only form and
623
+ * setImmediate's bare form lower (a void promise the shared timer heap
624
+ * settles); the resolve-value, options (AbortSignal), and setInterval
625
+ * async-iterator forms are declared surface that fences per site. */
626
+ declare module "node:timers/promises" {
627
+ export function setTimeout(delay?: number): Promise<void>;
628
+ export function setImmediate(): Promise<void>;
629
+ export function setInterval(delay?: number, value?: unknown, options?: unknown): unknown;
630
+ export const scheduler: {
631
+ wait(delay?: number): Promise<void>;
632
+ yield(): Promise<void>;
633
+ };
634
+ }
635
+ declare module "timers/promises" {
636
+ export * from "node:timers/promises";
637
+ }
638
+
639
+ /* node:diagnostics_channel — the in-process pub/sub core: named channels,
640
+ * subscribe/unsubscribe (module-level and channel-level), publish with any
641
+ * dyn-convertible message. Channel values are f64 handles into the
642
+ * runtime's channel registry (the readline.Interface precedent — channels
643
+ * are process-lived in Node too, its WeakRef machinery aside).
644
+ * The store-binding surface (bindStore/unbindStore/runStores) lowers onto
645
+ * the AsyncLocalStorage integration (dc.chan* libCalls).
646
+ *
647
+ * TracingChannel (tracingChannel) is the five-event-channel collection:
648
+ * an f64 handle into the runtime's tracing registry (types.ts maps the
649
+ * name like Channel). subscribe/unsubscribe walk a handlers object;
650
+ * traceSync/traceCallback run Node's publish choreography in the runtime
651
+ * (context defaults to a fresh {}); tracePromise is declared (the member
652
+ * exists in Node) but fences at the call site — the traced function's
653
+ * promise cannot cross the DOM boundary yet. */
654
+ declare module "node:diagnostics_channel" {
655
+ export type ChannelListener = (message: unknown, name: string) => void;
656
+ export interface Channel {
657
+ readonly name: string;
658
+ readonly hasSubscribers: boolean;
659
+ publish(message: unknown): void;
660
+ subscribe(onMessage: ChannelListener): void;
661
+ unsubscribe(onMessage: ChannelListener): boolean;
662
+ bindStore(store: import("async_hooks").AsyncLocalStorage<any>, transform?: (context: any) => any): void;
663
+ unbindStore(store: import("async_hooks").AsyncLocalStorage<any>): boolean;
664
+ runStores(context: unknown, fn: (...args: any[]) => any, thisArg?: any, ...args: any[]): any;
665
+ }
666
+ export function channel(name: string): Channel;
667
+ export function subscribe(name: string, onMessage: ChannelListener): void;
668
+ export function unsubscribe(name: string, onMessage: ChannelListener): boolean;
669
+ export function hasSubscribers(name: string): boolean;
670
+ export interface TracingChannelSubscribers {
671
+ start?: (message: any) => void;
672
+ end?: (message: any) => void;
673
+ asyncStart?: (message: any) => void;
674
+ asyncEnd?: (message: any) => void;
675
+ error?: (message: any) => void;
676
+ }
677
+ export interface TracingChannelCollection {
678
+ start: Channel;
679
+ end: Channel;
680
+ asyncStart: Channel;
681
+ asyncEnd: Channel;
682
+ error: Channel;
683
+ }
684
+ export interface TracingChannel {
685
+ start: Channel;
686
+ end: Channel;
687
+ asyncStart: Channel;
688
+ asyncEnd: Channel;
689
+ error: Channel;
690
+ readonly hasSubscribers: boolean;
691
+ subscribe(subscribers: TracingChannelSubscribers): void;
692
+ /** True when every present handler was found and removed (Node's
693
+ * all-found conjunction; @types/node under-declares this as void). */
694
+ unsubscribe(subscribers: TracingChannelSubscribers): boolean;
695
+ traceSync<ThisArg = any, Args extends any[] = any[], Result = any>(
696
+ fn: (this: ThisArg, ...args: Args) => Result,
697
+ context?: object,
698
+ thisArg?: ThisArg,
699
+ ...args: Args
700
+ ): Result;
701
+ tracePromise<ThisArg = any, Args extends any[] = any[], Result = any>(
702
+ fn: (this: ThisArg, ...args: Args) => Promise<Result>,
703
+ context?: object,
704
+ thisArg?: ThisArg,
705
+ ...args: Args
706
+ ): Promise<Result>;
707
+ traceCallback<ThisArg = any, Args extends any[] = any[], Result = any>(
708
+ fn: (this: ThisArg, ...args: Args) => Result,
709
+ position?: number,
710
+ context?: object,
711
+ thisArg?: ThisArg,
712
+ ...args: Args
713
+ ): Result;
714
+ }
715
+ export function tracingChannel(nameOrChannels: string | TracingChannelCollection): TracingChannel;
716
+ }
717
+ declare module "diagnostics_channel" {
718
+ export * from "node:diagnostics_channel";
719
+ }
720
+
721
+ /* The synchronous node:fs surface — utf8-only, no options objects, no
722
+ * Buffers. Importing "node:fs" resolves here (preflight allowlists exactly
723
+ * the ambient-declared node: modules); every function lowers to a `libCall`
724
+ * with a scr_fs_* runtime implementation. Failures throw CATCHABLE string
725
+ * values formatted like Node's error messages ("ENOENT: no such file or
726
+ * directory, open 'x'"). `rmSync` removes FILES only (like Node without
727
+ * `recursive`); empty directories go through `rmdirSync`. */
728
+ declare module "node:fs" {
729
+ /* The lowered forms first. The string-encoding overload's result is
730
+ * CONDITIONAL so a runtime encoding value (an untyped JS parameter —
731
+ * test/common fixtures.js's readFixtureKey(name, enc)) infers `any`
732
+ * (the lowering dispatches at runtime: undefined/null read Buffers,
733
+ * utf8 a string, anything else throws) while a literal utf8 keeps the
734
+ * string result TypeScript callers chain on. The encoding-less
735
+ * overload is the Buffer read. */
736
+ export function readFileSync<T extends string>(
737
+ path: string,
738
+ encoding: T,
739
+ ): T extends "utf8" ? string : T extends "utf-8" ? string : any;
740
+ export function readFileSync(path: string): Buffer;
741
+ /* The file-descriptor forms — a read(2) loop to EOF from the current
742
+ * position; the stdin pattern is readFileSync(0, "utf8"). */
743
+ export function readFileSync(fd: number, encoding: "utf8" | "utf-8"): string;
744
+ export function readFileSync(fd: number): Buffer;
745
+ /* The options-object spelling of the utf8 form. */
746
+ export function readFileSync(path: string, options: { encoding: "utf8" | "utf-8" }): string;
747
+ /* The options form carries the mode (applied at CREATION only, like
748
+ * Node — an existing file keeps its permissions) and/or the utf8
749
+ * encoding spelling. */
750
+ export function writeFileSync(
751
+ path: string,
752
+ data: string,
753
+ /* The options-record stance (see http.RequestOptions): flag fences
754
+ * by name at the call site; undocumented keys drop like Node. */
755
+ options?: { mode?: number; encoding?: "utf8" | "utf-8"; flag?: string; [option: string]: unknown },
756
+ ): void;
757
+ /* The bare-encoding spelling — the options record's encoding key alone. */
758
+ export function writeFileSync(path: string, data: string, encoding: "utf8" | "utf-8"): void;
759
+ export function writeFileSync(path: string, data: Uint8Array): void;
760
+ export function appendFileSync(path: string, data: string): void;
761
+ export function existsSync(path: string): boolean;
762
+ export function mkdirSync(path: string): void;
763
+ export function mkdirSync(path: string, options: { recursive?: boolean; mode?: number }): void;
764
+ export function unlinkSync(path: string): void;
765
+ export function chmodSync(path: string, mode: number): void;
766
+ export function chownSync(path: string, uid: number, gid: number): void;
767
+ /* The 2-argument form only (Node's mode flags have no lowering). The
768
+ * destination is created or truncated carrying the SOURCE's mode. */
769
+ export function copyFileSync(src: string, dest: string): void;
770
+ export function rmSync(path: string): void;
771
+ /* maxRetries/retryDelay are accepted no-ops (Node retries around
772
+ * EBUSY-class races; the synchronous lowering has no re-entrancy that
773
+ * needs them). */
774
+ export function rmSync(path: string, options: { recursive?: boolean; force?: boolean; maxRetries?: number; retryDelay?: number }): void;
775
+ export function rmdirSync(path: string): void;
776
+ export function readdirSync(path: string): string[];
777
+ /* The withFileTypes form: Dirent rows (name + parentPath + the type
778
+ * probes — the honest subset of Node's Dirent surface). The type is
779
+ * interned explicitly in types.ts (the record's hidden %dtype field
780
+ * carries the entry kind; isFile/isDirectory/isSymbolicLink lower as
781
+ * reads of it in lower-builtins.ts). */
782
+ export interface Dirent {
783
+ name: string;
784
+ parentPath: string;
785
+ isFile(): boolean;
786
+ isDirectory(): boolean;
787
+ isSymbolicLink(): boolean;
788
+ }
789
+ export function readdirSync(
790
+ path: string,
791
+ /* The options-record stance (see http.RequestOptions): recursive
792
+ * fences by name at the call site; undocumented keys drop like Node. */
793
+ options: { withFileTypes: true; recursive?: boolean; [option: string]: unknown },
794
+ ): Dirent[];
795
+ export function accessSync(path: string, mode?: number): void;
796
+ export function mkdtempSync(prefix: string): string;
797
+ export const constants: {
798
+ readonly F_OK: number;
799
+ readonly R_OK: number;
800
+ readonly W_OK: number;
801
+ readonly X_OK: number;
802
+ };
803
+ /* A stat(2) snapshot (statSync follows symlinks, lstatSync does not —
804
+ * Node's split) — immutable; the supported surface is exactly these
805
+ * members. mtimeMs is milliseconds with the nanosecond fraction. */
806
+ export interface Stats {
807
+ isFile(): boolean;
808
+ isDirectory(): boolean;
809
+ isSymbolicLink(): boolean;
810
+ readonly size: number;
811
+ readonly mtimeMs: number;
812
+ }
813
+ export function statSync(path: string): Stats;
814
+ export function lstatSync(path: string): Stats;
815
+ /* The fd pair behind spawn's fd-stdio form: openSync(path, flags) →
816
+ * the raw fd (string flags only — "r", "w", "a" and the +/x/s
817
+ * variants), closeSync(fd). */
818
+ export function openSync(path: string, flags: string): number;
819
+ export function closeSync(fd: number): void;
820
+ /* read(2) into a caller buffer from the fd's current position (the
821
+ * position argument is declared for parity and fences when non-null);
822
+ * answers the byte count, 0 at EOF. */
823
+ export function readSync(fd: number, buffer: Uint8Array, offset: number, length: number, position?: number | null): number;
824
+ /* statSync over an open fd — the same Stats snapshot. */
825
+ export function fstatSync(fd: number): Stats;
826
+ /* realpath(3) — resolves symlinks, `.`/`..`, throwing Node's fs error
827
+ * shapes for missing paths. */
828
+ export function realpathSync(path: string): string;
829
+ /* statfs(2)/statvfs(3) — the filesystem-capacity snapshot (the fields
830
+ * Node's statfsSync reports; bavail × bsize is the free-space probe). */
831
+ export interface StatsFs {
832
+ readonly type: number;
833
+ readonly bsize: number;
834
+ readonly blocks: number;
835
+ readonly bfree: number;
836
+ readonly bavail: number;
837
+ readonly files: number;
838
+ readonly ffree: number;
839
+ }
840
+ export function statfsSync(path: string): StatsFs;
841
+ /* fs.watch — the file-watching slice (scr_watch.c, kqueue EVFILT_VNODE):
842
+ * "rename"/"change" events on ONE path, watcher.close() to stop. The
843
+ * listener takes zero parameters or the eventType string (the filename
844
+ * parameter has no lowering); an open watcher keeps the loop alive. A
845
+ * path that cannot be opened THROWS Node's fs error synchronously. */
846
+ export interface FSWatcher {
847
+ close(): void;
848
+ }
849
+ /* The options-record stance (see http.RequestOptions): persistent: true,
850
+ * recursive: false, and encoding: "utf8" state the lowered behavior and
851
+ * are accepted; persistent: false, recursive: true, and signal fence by
852
+ * name at the call site; undocumented keys drop like Node. */
853
+ export interface WatchOptions {
854
+ persistent?: boolean;
855
+ recursive?: boolean;
856
+ encoding?: string;
857
+ [option: string]: unknown;
858
+ }
859
+ export function watch(path: string, listener?: (eventType: string) => void): FSWatcher;
860
+ export function watch(
861
+ path: string,
862
+ options: WatchOptions,
863
+ listener?: (eventType: string) => void,
864
+ ): FSWatcher;
865
+ /* fs.promises IS the fs/promises module (Node's rule) — the namespace-
866
+ * import form `fs.promises.readFile(...)` lowers through the same
867
+ * fs/promises table as `import { readFile } from "node:fs/promises"`. */
868
+ export const promises: typeof import("node:fs/promises");
869
+ }
870
+ /* Every builtin answers to BOTH specifier forms, like in Node: the bare
871
+ * module re-exports its node:-prefixed twin (or holds the declarations
872
+ * itself — one of the pair forwards). The lowerer recognizes members by
873
+ * their import SPECIFIER, so both forms lower identically. */
874
+ declare module "fs" {
875
+ export * from "node:fs";
876
+ }
877
+
878
+ /* fs/promises — the SAME synchronous operations behind already-settled
879
+ * promises: success fulfills, failure REJECTS with the would-be thrown
880
+ * error (catchable at the await, like Node). DOCUMENTED DIVERGENCE
881
+ * (SEMANTICS.md): the syscall blocks the event loop, so I/O never
882
+ * interleaves with timers or other fibers — observable only in concurrent
883
+ * code. readFile is utf8-only, like readFileSync. */
884
+ declare module "fs/promises" {
885
+ export function readFile(path: string, encoding: "utf8" | "utf-8"): Promise<string>;
886
+ export function readFile(path: string): Promise<Buffer>;
887
+ export function writeFile(path: string, data: string): Promise<void>;
888
+ export function mkdir(path: string, options?: { recursive?: boolean; mode?: number }): Promise<void>;
889
+ export function readdir(path: string): Promise<string[]>;
890
+ export function rm(path: string): Promise<void>;
891
+ export function stat(path: string): Promise<import("node:fs").Stats>;
892
+ export function unlink(path: string): Promise<void>;
893
+ export function chmod(path: string, mode: number): Promise<void>;
894
+ }
895
+ declare module "node:fs/promises" {
896
+ export * from "fs/promises";
897
+ }
898
+
899
+ /* node:path — the TARGET platform's implementation (Node's rule): posix
900
+ * on posix triples, path.win32 under a win32 triple, with the posix and
901
+ * win32 namespaces answering their own platform anywhere. Every function
902
+ * is a pure string algorithm matching Node's implementations
903
+ * byte-for-byte; join/resolve are variadic like Node's. */
904
+ declare module "path" {
905
+ export function join(...paths: string[]): string;
906
+ export function resolve(...paths: string[]): string;
907
+ export function normalize(path: string): string;
908
+ export function dirname(path: string): string;
909
+ export function basename(path: string, suffix?: string): string;
910
+ export function extname(path: string): string;
911
+ export function isAbsolute(path: string): boolean;
912
+ export function relative(from: string, to: string): string;
913
+ export function toNamespacedPath(path: string): string;
914
+ /* The union @types/node declares: the bare module answers the TARGET
915
+ * platform's value (a compile-time constant — "\\"/";" under a win32
916
+ * triple, "/"/":" everywhere else). */
917
+ export const sep: "\\" | "/";
918
+ export const delimiter: ";" | ":";
919
+ /* The platform-specific namespaces (real Node submodules too —
920
+ * "node:path/posix" resolves). Each carries the FULL surface and
921
+ * answers ITS platform's rules on any target, Node's own contract;
922
+ * the bare module IS the target platform's implementation. */
923
+ export const posix: typeof import("path/posix");
924
+ export const win32: typeof import("path/win32");
925
+ }
926
+ declare module "node:path" {
927
+ export * from "path";
928
+ }
929
+ declare module "path/posix" {
930
+ export function join(...paths: string[]): string;
931
+ export function resolve(...paths: string[]): string;
932
+ export function normalize(path: string): string;
933
+ export function dirname(path: string): string;
934
+ export function basename(path: string, suffix?: string): string;
935
+ export function extname(path: string): string;
936
+ export function isAbsolute(path: string): boolean;
937
+ export function relative(from: string, to: string): string;
938
+ export function toNamespacedPath(path: string): string;
939
+ export const sep: "/";
940
+ export const delimiter: ":";
941
+ }
942
+ declare module "node:path/posix" {
943
+ export * from "path/posix";
944
+ }
945
+ declare module "path/win32" {
946
+ export function join(...paths: string[]): string;
947
+ export function resolve(...paths: string[]): string;
948
+ export function normalize(path: string): string;
949
+ export function dirname(path: string): string;
950
+ export function basename(path: string, suffix?: string): string;
951
+ export function extname(path: string): string;
952
+ export function isAbsolute(path: string): boolean;
953
+ export function relative(from: string, to: string): string;
954
+ export function toNamespacedPath(path: string): string;
955
+ export const sep: "\\";
956
+ export const delimiter: ";";
957
+ }
958
+ declare module "node:path/win32" {
959
+ export * from "path/win32";
960
+ }
961
+
962
+ /* node:os — the slice a CLI needs: platform() (same implementation as
963
+ * process.platform), homedir(), tmpdir() (Node's env cascade), EOL
964
+ * (always "\n" — POSIX pinned, like path.sep), and networkInterfaces()
965
+ * (getifaddrs(3); the interface shapes mirror @types/node's exactly so
966
+ * both type worlds map to the same IR structure). */
967
+ declare module "os" {
968
+ export function platform(): string;
969
+ export function homedir(): string;
970
+ export function tmpdir(): string;
971
+ /* uname(2)'s release field — Node's own implementation. */
972
+ export function release(): string;
973
+ /* uname(2)'s sysname field ("Darwin", "Linux") — Node's os.type(). */
974
+ export function type(): string;
975
+ /* Total system memory in bytes (sysctl hw.memsize / sysconf). */
976
+ export function totalmem(): number;
977
+ /* The passwd-entry snapshot (uv_os_get_passwd): shell is `string |
978
+ * null` to match @types/node (POSIX always answers the string arm);
979
+ * homedir is pw_dir — NOT os.homedir()'s $HOME-first cascade. The type
980
+ * is interned explicitly in types.ts (the AddressInfo pattern — this
981
+ * concrete form and @types/node's UserInfo<string> both), and the call
982
+ * assembles field-by-field in lowerOsUserInfoCall. */
983
+ export interface UserInfo {
984
+ username: string;
985
+ uid: number;
986
+ gid: number;
987
+ shell: string | null;
988
+ homedir: string;
989
+ }
990
+ export function userInfo(): UserInfo;
991
+ /* The TARGET platform's line terminator (a compile-time constant:
992
+ * "\r\n" under a win32 triple, "\n" everywhere else). */
993
+ export const EOL: "\r\n" | "\n";
994
+ export interface NetworkInterfaceBase {
995
+ address: string;
996
+ netmask: string;
997
+ mac: string;
998
+ internal: boolean;
999
+ cidr: string | null;
1000
+ scopeid?: number;
1001
+ }
1002
+ export interface NetworkInterfaceInfoIPv4 extends NetworkInterfaceBase {
1003
+ family: "IPv4";
1004
+ }
1005
+ export interface NetworkInterfaceInfoIPv6 extends NetworkInterfaceBase {
1006
+ family: "IPv6";
1007
+ scopeid: number;
1008
+ }
1009
+ export type NetworkInterfaceInfo = NetworkInterfaceInfoIPv4 | NetworkInterfaceInfoIPv6;
1010
+ export function networkInterfaces(): { [name: string]: NetworkInterfaceInfo[] | undefined };
1011
+ }
1012
+ declare module "node:os" {
1013
+ export * from "os";
1014
+ }
1015
+
1016
+ /* The WHATWG URL class (a Node global; the es2023 lib doesn't declare it),
1017
+ * typed as exactly the supported surface: construction from ONE absolute-
1018
+ * URL string (invalid input throws a catchable TypeError, like Node), the
1019
+ * protocol/pathname/href/host/hostname/search getters, searchParams (the
1020
+ * LIVE query view — mutations through it re-serialize into the URL, so
1021
+ * href reflects immediately; every read answers the same object, Node's
1022
+ * caching), and toString() (the href serialization).
1023
+ * URL values have no SETTERS — the component fields are read-only (the
1024
+ * one supported mutation path is searchParams) — and participate in
1025
+ * unions (URL | undefined). The parser covers the common CLI schemes
1026
+ * exactly (http/https/ws/wss/ftp/file authority URLs, opaque paths like
1027
+ * data: and mailto:) — divergences from the full WHATWG algorithm are
1028
+ * documented in SEMANTICS.md. */
1029
+ interface URL {
1030
+ readonly protocol: string;
1031
+ readonly pathname: string;
1032
+ readonly href: string;
1033
+ readonly host: string;
1034
+ readonly hostname: string;
1035
+ readonly search: string;
1036
+ readonly searchParams: URLSearchParams;
1037
+ toString(): string;
1038
+ }
1039
+ declare var URL: {
1040
+ new (input: string): URL;
1041
+ };
1042
+
1043
+ /* URLSearchParams — the WHATWG application/x-www-form-urlencoded list.
1044
+ * Constructed standalone (string / string[][] pairs / inline record
1045
+ * literal / another URLSearchParams) or read live off a URL via
1046
+ * url.searchParams. keys()/values()/entries() lower when a for-of head
1047
+ * consumes them directly; stored iterator OBJECTS have no lowering. */
1048
+ interface URLSearchParams {
1049
+ readonly size: number;
1050
+ append(name: string, value: string): void;
1051
+ delete(name: string, value?: string): void;
1052
+ get(name: string): string | null;
1053
+ getAll(name: string): string[];
1054
+ has(name: string, value?: string): boolean;
1055
+ set(name: string, value: string): void;
1056
+ sort(): void;
1057
+ toString(): string;
1058
+ forEach(callback: (value: string, name: string, searchParams: URLSearchParams) => void): void;
1059
+ keys(): IterableIterator<string>;
1060
+ values(): IterableIterator<string>;
1061
+ entries(): IterableIterator<[string, string]>;
1062
+ [Symbol.iterator](): IterableIterator<[string, string]>;
1063
+ }
1064
+ declare var URLSearchParams: {
1065
+ new (init?: string | string[][] | { [key: string]: string } | URLSearchParams): URLSearchParams;
1066
+ };
1067
+
1068
+ /* node:url — the file-URL bridge pair. fileURLToPath accepts a URL value
1069
+ * or a URL string and throws Node's TypeErrors (non-file scheme, encoded
1070
+ * slashes, non-empty host); pathToFileURL resolves the path and percent-
1071
+ * encodes it into a file: URL. */
1072
+ declare module "url" {
1073
+ export function fileURLToPath(url: string | URL): string;
1074
+ export function pathToFileURL(path: string): URL;
1075
+ }
1076
+ declare module "node:url" {
1077
+ export * from "url";
1078
+ }
1079
+
1080
+ /* node:crypto: randomUUID(), and randomBytes returning a REAL Buffer —
1081
+ * the composed randomBytes(n).toString("hex" | "base64") still lowers as
1082
+ * one fused string-producing operation (the Buffer never materializes
1083
+ * there); every other use gets an ordinary Buffer value. */
1084
+ declare module "crypto" {
1085
+ export function randomUUID(): string;
1086
+ export function randomBytes(size: number): Buffer;
1087
+ /* The lowered Hash surface is exactly the COMPOSED chain
1088
+ * createHash("sha256" | "sha1").update(data).digest("hex" | "base64")
1089
+ * — fused into one call, the Hash handle never materializes (holding
1090
+ * one fences). sha1 exists for the RFC 6455 Sec-WebSocket-Accept
1091
+ * hash. */
1092
+ export interface Hash {
1093
+ update(data: string | Uint8Array): Hash;
1094
+ digest(encoding: "hex" | "base64"): string;
1095
+ }
1096
+ export function createHash(algorithm: string): Hash;
1097
+ /* The lowered X509Certificate surface is the data-record slice:
1098
+ * fingerprint (the SHA-1 of the DER, uppercase colon-separated) and
1099
+ * the validFrom/validTo validity window (Node's ASN1_TIME_print
1100
+ * strings — "Jul 1 00:00:00 2026 GMT"; the cert-expiry idiom composes
1101
+ * them with new Date(...).getTime()). All compute at construction;
1102
+ * unparseable input throws Node's ERR_OSSL_PEM_NO_START_LINE Error. */
1103
+ export class X509Certificate {
1104
+ constructor(buffer: Uint8Array | string);
1105
+ readonly fingerprint: string;
1106
+ readonly validFrom: string;
1107
+ readonly validTo: string;
1108
+ }
1109
+ }
1110
+ declare module "node:crypto" {
1111
+ export * from "crypto";
1112
+ }
1113
+
1114
+ /* node:child_process — the synchronous slice: spawnSync(command, args?)
1115
+ * runs the child to completion (posix_spawn + waitpid) with stdout/stderr
1116
+ * captured as utf8 strings. `status` is the exit code, or null when the
1117
+ * child died to a signal OR could not be spawned at all (nonexistent
1118
+ * binary, permission denied) — Node reports spawn failure through the
1119
+ * result's `error` property, which this surface does not carry, and types
1120
+ * stdout/stderr null there where scriptc returns "" (SEMANTICS.md).
1121
+ * No shell, no options object: the command runs directly (PATH-searched,
1122
+ * like Node). */
1123
+ declare module "child_process" {
1124
+ export interface SpawnSyncReturns {
1125
+ readonly status: number | null;
1126
+ readonly stdout: string;
1127
+ readonly stderr: string;
1128
+ /* The termination signal's name ("SIGTERM", ...) when a signal
1129
+ * killed the child (a timeout's killSignal included), null otherwise
1130
+ * — Node's shape. */
1131
+ readonly signal: string | null;
1132
+ /* Node's spawn-failure carrier: a real Error ("spawnSync <file>
1133
+ * ENOENT", `code` stamped) when the spawn itself failed — status is
1134
+ * null and both outputs "" then — or ETIMEDOUT after a timeout kill;
1135
+ * undefined otherwise. */
1136
+ readonly error?: Error;
1137
+ }
1138
+ /* scriptc always captures utf8 strings; pass { encoding: "utf8" }
1139
+ * whenever stdout/stderr is READ so plain Node agrees (without it Node
1140
+ * hands Buffers). The other supported options: timeout (ms — sends
1141
+ * killSignal at the deadline and the result carries error: ETIMEDOUT +
1142
+ * the signal, never a throw), killSignal (a signal NAME literal),
1143
+ * stdio ("ignore"/"inherit"/"pipe" or a 3-tuple of those — captures
1144
+ * read "" for non-piped streams), and windowsHide (a POSIX no-op). */
1145
+ export function spawnSync(
1146
+ command: string,
1147
+ args?: string[],
1148
+ options?: {
1149
+ encoding?: "utf8" | "utf-8";
1150
+ timeout?: number;
1151
+ killSignal?: string;
1152
+ stdio?: "pipe" | "ignore" | "inherit" | ("pipe" | "ignore" | "inherit")[];
1153
+ windowsHide?: boolean;
1154
+ },
1155
+ ): SpawnSyncReturns;
1156
+
1157
+ /* The asynchronous slice: spawn with stdio "ignore"/"inherit"/fd/"pipe"
1158
+ * tuples (piped stdout/stderr deliver through child.stdout/stderr) and
1159
+ * the two terminal events. "exit" fires once with the exit code, or
1160
+ * null when the child died to a signal; "error" fires ONLY when the
1161
+ * child could not be spawned at all (Node's split: a spawn failure
1162
+ * emits "error" and never "exit"). Listeners take at most one
1163
+ * parameter; Node's second "exit" parameter (the signal name) has no
1164
+ * lowering. `on` returns void here (Node returns the child; chaining
1165
+ * is fenced). The event loop keeps the process alive until every
1166
+ * spawned child is reaped, like Node — reaping polls at loop
1167
+ * quiescence (SEMANTICS.md documents the divergence). An "error"
1168
+ * event with no registered listener prints the error and exits 1,
1169
+ * exactly the unhandled-'error' EventEmitter behavior. */
1170
+ export interface ChildProcess {
1171
+ /* The exit listener may also take Node's second parameter — the
1172
+ * terminating signal's name, null for a normal exit. */
1173
+ on(event: "exit", listener: (code: number | null, signal: string | null) => void): void;
1174
+ on(event: "error", listener: (err: Error) => void): void;
1175
+ /* The lifecycle members, Node's exact shapes: pid is undefined exactly
1176
+ * when the spawn failed; exitCode is null while running, the code
1177
+ * after a normal exit, null for a signal death, and -errno once a
1178
+ * spawn failure's "error" event has fired; kill resolves signal names
1179
+ * through Node's table (unknown names throw the Unknown signal
1180
+ * TypeError), answers true when the signal was sent, false once the
1181
+ * child was reaped (or never spawned), and sets `killed` on success;
1182
+ * unref() drops the child from the event loop's keep-alive set (it is
1183
+ * still reaped while the loop runs for other reasons — SEMANTICS.md
1184
+ * has the reap story). */
1185
+ readonly pid: number | undefined;
1186
+ readonly exitCode: number | null;
1187
+ readonly killed: boolean;
1188
+ kill(signal?: string | number): boolean;
1189
+ unref(): void;
1190
+ /* The piped-output streams — non-null exactly when the matching
1191
+ * stdio slot was "pipe" (Node's shape). */
1192
+ readonly stdout: NodeJS.ReadableStream | null;
1193
+ readonly stderr: NodeJS.ReadableStream | null;
1194
+ }
1195
+ export function spawn(
1196
+ command: string,
1197
+ args?: string[],
1198
+ options?: {
1199
+ /* The 3-tuple form admits number fds in the stdout/stderr slots —
1200
+ * openSync results dup2'd into the child (the daemon-log idiom
1201
+ * ["ignore", logFd, logFd]) — and "pipe" there too (child.stdout/
1202
+ * child.stderr streams); piped STDIN stays a compile fence. */
1203
+ stdio: "ignore" | "inherit" | "pipe" | ("ignore" | "inherit" | "pipe" | number)[];
1204
+ /* detached gives the child its own session and process group
1205
+ * (POSIX_SPAWN_SETSID); env REPLACES the child environment; cwd
1206
+ * sets its working directory; windowsHide is a POSIX no-op. */
1207
+ detached?: boolean;
1208
+ env?: { [k: string]: string | undefined };
1209
+ cwd?: string;
1210
+ windowsHide?: boolean;
1211
+ },
1212
+ ): ChildProcess;
1213
+
1214
+ /* The synchronous exec pair: execFileSync runs a file directly (no
1215
+ * shell), execSync runs a command through /bin/sh -c. Both capture
1216
+ * stdout as a utf8 string (pass { encoding: "utf8" } so plain Node
1217
+ * agrees — without it Node returns a Buffer) and THROW on a non-zero
1218
+ * exit / signal death — the Error's message is Node's "Command failed:
1219
+ * <cmd>" (with the captured stderr appended). Supported options:
1220
+ * encoding ("utf8"), cwd, env (REPLACES the child environment), input
1221
+ * (fed to stdin), timeout (ms — SIGTERMs the child, then throws
1222
+ * ETIMEDOUT), stdio ("pipe"/"ignore" or a 3-tuple of those — the
1223
+ * default captures stderr AND echoes it to the parent, like Node), and
1224
+ * maxBuffer (accepted, not enforced). Node's status/stdout/stderr error
1225
+ * properties are not carried (SEMANTICS.md). */
1226
+ interface ExecSyncOptions {
1227
+ encoding?: "utf8" | "utf-8";
1228
+ cwd?: string;
1229
+ env?: { [k: string]: string | undefined };
1230
+ input?: string;
1231
+ timeout?: number;
1232
+ stdio?: "pipe" | "ignore" | "inherit" | ("pipe" | "ignore" | "inherit")[];
1233
+ maxBuffer?: number;
1234
+ killSignal?: string;
1235
+ windowsHide?: boolean;
1236
+ shell?: boolean;
1237
+ }
1238
+ /* The named options interface for the string-encoding exec form —
1239
+ * @types/node's ExecFileSyncOptionsWithStringEncoding, narrowed to the
1240
+ * honestly-implemented members. VALUES of this type are a real record
1241
+ * (types.ts interns the shape), so a typed const or a runner function's
1242
+ * options parameter flows to execFileSync at runtime — the windows-ca
1243
+ * command-runner idiom. */
1244
+ export interface ExecFileSyncOptionsWithStringEncoding {
1245
+ encoding: "utf8" | "utf-8";
1246
+ cwd?: string;
1247
+ input?: string;
1248
+ timeout?: number;
1249
+ stdio?: "pipe" | "ignore" | "inherit" | ("pipe" | "ignore" | "inherit")[];
1250
+ maxBuffer?: number;
1251
+ windowsHide?: boolean;
1252
+ }
1253
+ export function execFileSync(file: string, args?: string[], options?: ExecSyncOptions): string;
1254
+ export function execSync(command: string, options?: ExecSyncOptions): string;
1255
+ /* The callback form exists to be PROMISIFIED — `const execFileAsync =
1256
+ * promisify(execFile)` is the one lowered use (see "util"); calling it
1257
+ * directly with a callback has no lowering and fences per site. */
1258
+ export function execFile(
1259
+ file: string,
1260
+ args?: string[] | null,
1261
+ options?: ExecSyncOptions,
1262
+ ): unknown;
1263
+ /* The async shell form — declared surface without full lowering (the
1264
+ * type-level tolerance story): harness code on paths tests don't reach
1265
+ * must typecheck; a reached call fences at its site. */
1266
+ export function exec(
1267
+ command: string,
1268
+ options?: ExecSyncOptions | ((error: Error | null, stdout: string, stderr: string) => void),
1269
+ callback?: (error: Error | null, stdout: string, stderr: string) => void,
1270
+ ): ChildProcess;
1271
+ }
1272
+ declare module "node:child_process" {
1273
+ export * from "child_process";
1274
+ }
1275
+
1276
+ /* node:util — promisify, for exactly ONE target: child_process.execFile.
1277
+ * `const execFileAsync = promisify(execFile)` binds an async exec whose
1278
+ * calls run the file (no shell, PATH-searched) and settle with
1279
+ * { stdout, stderr } — fulfilled on exit 0, rejected with Node's
1280
+ * Command-failed / spawn-ENOENT errors otherwise. Other promisify
1281
+ * targets and bare promisify values fence per site. */
1282
+ declare module "util" {
1283
+ export function promisify(
1284
+ fn: (file: string, args?: string[] | null, options?: object) => unknown,
1285
+ ): (
1286
+ file: string,
1287
+ args?: string[],
1288
+ options?: {
1289
+ encoding?: "utf8" | "utf-8";
1290
+ cwd?: string;
1291
+ env?: { [k: string]: string | undefined };
1292
+ timeout?: number;
1293
+ maxBuffer?: number;
1294
+ killSignal?: string;
1295
+ windowsHide?: boolean;
1296
+ },
1297
+ ) => Promise<{ stdout: string; stderr: string }>;
1298
+ /* Declared surface without full lowering (the type-level tolerance
1299
+ * story: guarded/diagnostic-path code must TYPECHECK; a reached use
1300
+ * without a lowering fences at its site). inspect's options carry the
1301
+ * documented knobs through an index signature. */
1302
+ export function inspect(object: unknown, options?: { depth?: number | null; colors?: boolean; [k: string]: unknown }): string;
1303
+ export function format(format?: unknown, ...args: unknown[]): string;
1304
+ export function formatWithOptions(
1305
+ inspectOptions: { depth?: number | null; colors?: boolean; [k: string]: unknown },
1306
+ format?: unknown,
1307
+ ...args: unknown[]
1308
+ ): string;
1309
+ /* util.getCallSites (Node ≥22.9): the captured-frame slice harness
1310
+ * code reads. No stack bookkeeping exists in a compiled binary — every
1311
+ * reached call fences per site. */
1312
+ export interface CallSite {
1313
+ readonly functionName: string;
1314
+ readonly scriptName: string;
1315
+ readonly lineNumber: number;
1316
+ readonly column: number;
1317
+ }
1318
+ export function getCallSites(frameCount?: number): CallSite[];
1319
+ }
1320
+ declare module "node:util" {
1321
+ export * from "util";
1322
+ }
1323
+
1324
+ /* node:util/types — the type probes. isModuleNamespaceObject answers a
1325
+ * REAL question about compiled modules and fences until it lowers; the
1326
+ * rest of Node's surface is undeclared (honest type errors). */
1327
+ declare module "util/types" {
1328
+ export function isModuleNamespaceObject(value: unknown): boolean;
1329
+ }
1330
+ declare module "node:util/types" {
1331
+ export * from "util/types";
1332
+ }
1333
+
1334
+ /* node:assert — the static assertion surface. The module object IS a
1335
+ * callable function (`assert(x)` is `assert.ok(x)`), so the declaration
1336
+ * is the callable-namespace `export =` shape and BOTH `import assert
1337
+ * from "node:assert"` and `const assert = require("assert")` bind the
1338
+ * callable; named imports take the members. Failures throw
1339
+ * AssertionError (name "AssertionError", code "ERR_ASSERTION" — catch and
1340
+ * read .name/.message/.code). strictEqual/deepStrictEqual compare with
1341
+ * Object.is over scalars; deepStrictEqual compares composites
1342
+ * structurally per their static types. The messages here are plain
1343
+ * strings (Node accepts Errors — that form fences per site), and the
1344
+ * loose-equality quartet (equal/notEqual/deepEqual/notDeepEqual) is
1345
+ * declared so real code typechecks but fences at its use sites (== has
1346
+ * no lowering; assert/strict's equal IS strictEqual and lowers). */
1347
+ /* node:test — the in-process test runner (prefix-only in Node too:
1348
+ * require("test") is MODULE_NOT_FOUND). test/it register tests (sync and
1349
+ * async bodies, skip/todo/only options and method twins), describe/suite
1350
+ * group them (bodies run at registration, Node's collection phase),
1351
+ * before/after/beforeEach/afterEach hook the enclosing suite, and the
1352
+ * TestContext argument carries subtests (t.test), t.skip/t.todo,
1353
+ * t.diagnostic, and t.assert. mock/run/snapshot are DECLARED so real
1354
+ * suites typecheck but fence at their use sites (no lowering). */
1355
+ declare module "node:test" {
1356
+ type TestFn = (t: TestContext) => void | Promise<void>;
1357
+ type SuiteFn = () => void;
1358
+ type HookFn = () => void | Promise<void>;
1359
+ interface TestOptions {
1360
+ skip?: boolean | string;
1361
+ todo?: boolean | string;
1362
+ only?: boolean;
1363
+ concurrency?: number | boolean;
1364
+ timeout?: number;
1365
+ plan?: number;
1366
+ }
1367
+ interface TestContext {
1368
+ readonly name: string;
1369
+ readonly assert: TestContextAssert;
1370
+ test(name: string, fn?: TestFn): Promise<void>;
1371
+ test(name: string, options: TestOptions, fn?: TestFn): Promise<void>;
1372
+ skip(message?: string): void;
1373
+ todo(message?: string): void;
1374
+ diagnostic(message: string): void;
1375
+ plan(count: number): void;
1376
+ after(fn: HookFn): void;
1377
+ before(fn: HookFn): void;
1378
+ beforeEach(fn: HookFn): void;
1379
+ afterEach(fn: HookFn): void;
1380
+ }
1381
+ interface TestContextAssert {
1382
+ ok(value: unknown, message?: string): void;
1383
+ strictEqual(actual: unknown, expected: unknown, message?: string): void;
1384
+ notStrictEqual(actual: unknown, expected: unknown, message?: string): void;
1385
+ deepStrictEqual(actual: unknown, expected: unknown, message?: string): void;
1386
+ notDeepStrictEqual(actual: unknown, expected: unknown, message?: string): void;
1387
+ equal(actual: unknown, expected: unknown, message?: string): void;
1388
+ notEqual(actual: unknown, expected: unknown, message?: string): void;
1389
+ deepEqual(actual: unknown, expected: unknown, message?: string): void;
1390
+ notDeepEqual(actual: unknown, expected: unknown, message?: string): void;
1391
+ fail(message?: string): never;
1392
+ throws(fn: () => unknown, expected?: unknown, message?: string): void;
1393
+ match(value: string, regExp: RegExp, message?: string): void;
1394
+ doesNotMatch(value: string, regExp: RegExp, message?: string): void;
1395
+ }
1396
+ function test(name: string, fn?: TestFn): Promise<void>;
1397
+ function test(name: string, options: TestOptions, fn?: TestFn): Promise<void>;
1398
+ namespace test {
1399
+ function skip(name: string, fn?: TestFn): Promise<void>;
1400
+ function skip(name: string, options: TestOptions, fn?: TestFn): Promise<void>;
1401
+ function todo(name: string, fn?: TestFn): Promise<void>;
1402
+ function todo(name: string, options: TestOptions, fn?: TestFn): Promise<void>;
1403
+ function only(name: string, fn?: TestFn): Promise<void>;
1404
+ function only(name: string, options: TestOptions, fn?: TestFn): Promise<void>;
1405
+ }
1406
+ const it: typeof test;
1407
+ function describe(name: string, fn?: SuiteFn): void;
1408
+ function describe(name: string, options: TestOptions, fn?: SuiteFn): void;
1409
+ namespace describe {
1410
+ function skip(name: string, fn?: SuiteFn): void;
1411
+ function todo(name: string, fn?: SuiteFn): void;
1412
+ function only(name: string, fn?: SuiteFn): void;
1413
+ }
1414
+ const suite: typeof describe;
1415
+ function before(fn: HookFn): void;
1416
+ function after(fn: HookFn): void;
1417
+ function beforeEach(fn: HookFn): void;
1418
+ function afterEach(fn: HookFn): void;
1419
+ /* Declared for typechecking only — every use fences (no lowering).
1420
+ * `assert` is the module-level custom-assertion registry (v24's
1421
+ * `const { assert } = require('node:test')`), not TestContext.assert. */
1422
+ const mock: unknown;
1423
+ const assert: { register(name: string, fn: (...args: unknown[]) => unknown): void };
1424
+ function run(options?: unknown): unknown;
1425
+ function snapshot(...args: unknown[]): unknown;
1426
+ export {
1427
+ test, it, describe, suite, before, after, beforeEach, afterEach,
1428
+ mock, assert, run, snapshot, TestContext, TestOptions,
1429
+ };
1430
+ export default test;
1431
+ }
1432
+
1433
+ declare module "assert" {
1434
+ function assert(value: unknown, message?: string): void;
1435
+ namespace assert {
1436
+ function ok(value: unknown, message?: string): void;
1437
+ function strictEqual(actual: unknown, expected: unknown, message?: string): void;
1438
+ function notStrictEqual(actual: unknown, expected: unknown, message?: string): void;
1439
+ function deepStrictEqual(actual: unknown, expected: unknown, message?: string): void;
1440
+ function notDeepStrictEqual(actual: unknown, expected: unknown, message?: string): void;
1441
+ function equal(actual: unknown, expected: unknown, message?: string): void;
1442
+ function notEqual(actual: unknown, expected: unknown, message?: string): void;
1443
+ function deepEqual(actual: unknown, expected: unknown, message?: string): void;
1444
+ function notDeepEqual(actual: unknown, expected: unknown, message?: string): void;
1445
+ function fail(message?: string): never;
1446
+ function throws(fn: () => unknown, expected?: unknown, message?: string): void;
1447
+ function rejects(fn: (() => Promise<unknown>) | Promise<unknown>, expected?: unknown, message?: string): Promise<void>;
1448
+ function doesNotReject(fn: (() => Promise<unknown>) | Promise<unknown>, expected?: unknown, message?: string): Promise<void>;
1449
+ function match(value: string, regExp: RegExp, message?: string): void;
1450
+ function doesNotMatch(value: string, regExp: RegExp, message?: string): void;
1451
+ function ifError(value: unknown): void;
1452
+ const strict: typeof import("assert/strict");
1453
+ }
1454
+ export = assert;
1455
+ }
1456
+ declare module "node:assert" {
1457
+ import assert = require("assert");
1458
+ export = assert;
1459
+ }
1460
+ /* node:assert/strict — the same surface with the loose names bound to the
1461
+ * strict comparisons (equal IS strictEqual, ...), exactly Node's aliasing;
1462
+ * the module object is callable like assert's. */
1463
+ declare module "assert/strict" {
1464
+ function strict(value: unknown, message?: string): void;
1465
+ namespace strict {
1466
+ function ok(value: unknown, message?: string): void;
1467
+ function equal(actual: unknown, expected: unknown, message?: string): void;
1468
+ function notEqual(actual: unknown, expected: unknown, message?: string): void;
1469
+ function deepEqual(actual: unknown, expected: unknown, message?: string): void;
1470
+ function notDeepEqual(actual: unknown, expected: unknown, message?: string): void;
1471
+ function strictEqual(actual: unknown, expected: unknown, message?: string): void;
1472
+ function notStrictEqual(actual: unknown, expected: unknown, message?: string): void;
1473
+ function deepStrictEqual(actual: unknown, expected: unknown, message?: string): void;
1474
+ function notDeepStrictEqual(actual: unknown, expected: unknown, message?: string): void;
1475
+ function fail(message?: string): never;
1476
+ function throws(fn: () => unknown, expected?: unknown, message?: string): void;
1477
+ function rejects(fn: (() => Promise<unknown>) | Promise<unknown>, expected?: unknown, message?: string): Promise<void>;
1478
+ function doesNotReject(fn: (() => Promise<unknown>) | Promise<unknown>, expected?: unknown, message?: string): Promise<void>;
1479
+ function match(value: string, regExp: RegExp, message?: string): void;
1480
+ function doesNotMatch(value: string, regExp: RegExp, message?: string): void;
1481
+ function ifError(value: unknown): void;
1482
+ const strict: typeof import("assert/strict");
1483
+ }
1484
+ export = strict;
1485
+ }
1486
+ declare module "node:assert/strict" {
1487
+ import strict = require("assert/strict");
1488
+ export = strict;
1489
+ }
1490
+
1491
+ /* node:string_decoder — StringDecoder over Node's whole encoding set:
1492
+ * write() decodes complete sequences and buffers a trailing partial one
1493
+ * across chunk boundaries (utf8's truncated sequence, base64's mod-3
1494
+ * remainder, utf16le's odd byte / trailing lead surrogate; latin1, ascii
1495
+ * and hex are stateless); end() flushes the buffered partial. `encoding`
1496
+ * answers the normalized name. Node's exact algorithms (SEMANTICS.md);
1497
+ * the encoding must be a literal, and end(buffer) fences — write the
1498
+ * buffer, then end(). */
1499
+ declare module "string_decoder" {
1500
+ export class StringDecoder {
1501
+ constructor(encoding?: BufferEncoding);
1502
+ readonly encoding: string;
1503
+ write(buffer: Uint8Array): string;
1504
+ end(buffer?: Uint8Array): string;
1505
+ }
1506
+ }
1507
+ declare module "node:string_decoder" {
1508
+ export * from "string_decoder";
1509
+ }
1510
+
1511
+ /* node:readline — the question/close slice: createInterface over exactly
1512
+ * { input: process.stdin, output: process.stdout }, question(query, cb)
1513
+ * (the query writes to stdout, the callback gets the next line's text),
1514
+ * close() (fires 'close' synchronously, like Node's inline emit), and
1515
+ * on("close", cb). An open interface keeps the process alive until
1516
+ * close()/EOF, Node's semantics; lines split on \n and \r\n. */
1517
+ declare module "readline" {
1518
+ export interface Interface {
1519
+ question(query: string, callback: (answer: string) => void): void;
1520
+ close(): void;
1521
+ on(event: "close", listener: () => void): void;
1522
+ }
1523
+ export function createInterface(options: {
1524
+ input: unknown;
1525
+ output?: unknown;
1526
+ terminal?: boolean;
1527
+ /* crlfDelay: Infinity is accepted — the lowered splitter already
1528
+ * holds a trailing \r for the next chunk, Node's Infinity behavior;
1529
+ * completer and the history knobs fence by name (no interactive
1530
+ * terminal). The options-record stance (see http.RequestOptions)
1531
+ * admits every key; the walk decides. */
1532
+ crlfDelay?: number;
1533
+ completer?: unknown;
1534
+ [option: string]: unknown;
1535
+ }): Interface;
1536
+ }
1537
+ declare module "node:readline" {
1538
+ export * from "readline";
1539
+ }
1540
+
1541
+ /* node:zlib — deflateSync/inflateSync lower (Buffer in, Buffer out,
1542
+ * Node's default options; libz links only into zlib-using binaries);
1543
+ * gzip and friends typecheck and fence at their use sites. */
1544
+ declare module "zlib" {
1545
+ export function deflateSync(data: string | Uint8Array): Buffer;
1546
+ export function inflateSync(data: Uint8Array): Buffer;
1547
+ export function gzipSync(data: string | Uint8Array): Buffer;
1548
+ export function gunzipSync(data: Uint8Array): Buffer;
1549
+ }
1550
+ declare module "node:zlib" {
1551
+ export * from "zlib";
1552
+ }
1553
+
1554
+ /* node:net — the inbound-networking slice (scr_net.c links only into
1555
+ * net-using binaries). TCP only, Node's shapes narrowed to what lowers:
1556
+ * createServer with an optional connection handler; listen(port[, cb])
1557
+ * with the real port discoverable as address().port (the composed read
1558
+ * is the lowered form — bare address() has no lowering); close([cb])
1559
+ * firing once connections drain; socket write/end/destroy/pipe and the
1560
+ * data/end/close/error/connect events (on and once — listeners take at
1561
+ * most the declared parameter). write/end return void here (Node returns
1562
+ * the backpressure boolean / the socket); on/once return void (chaining
1563
+ * is fenced). connect's host is a numeric IP or "localhost" (pinned to
1564
+ * 127.0.0.1 — SEMANTICS.md); every failure is the async 'error' event,
1565
+ * and an 'error' with no listener exits 1 like an unhandled EventEmitter
1566
+ * 'error'. */
1567
+ declare module "net" {
1568
+ export interface Socket {
1569
+ readonly remoteAddress: string | undefined;
1570
+ /* true once the fd is gone (destroy() or full close) — Node's flag. */
1571
+ readonly destroyed: boolean;
1572
+ /* the write half is open: no end() yet, no FIN sent, fd alive. */
1573
+ readonly writable: boolean;
1574
+ write(data: string | Uint8Array): void;
1575
+ end(data?: string | Uint8Array): void;
1576
+ destroy(): void;
1577
+ /* setEncoding('utf8'): 'data' delivers strings — the IncomingMessage
1578
+ * twin's contract. */
1579
+ setEncoding(encoding: string): void;
1580
+ /* socket→socket, and socket→response (the extended-CONNECT bridge
1581
+ * leg: raw chunks become response body writes; EOF ends it). */
1582
+ pipe(destination: Socket | import("http").ServerResponse | import("http2").Http2ServerResponse): void;
1583
+ setTimeout(ms: number): void;
1584
+ /* The paused-mode demux surface: once('readable') + read(1) +
1585
+ * unshift — read answers exactly n buffered bytes or null. */
1586
+ read(size?: number): Buffer | null;
1587
+ unshift(chunk: Uint8Array): void;
1588
+ /* secureConnect/session are TLS-socket events declared on the shared
1589
+ * socket surface (the lowering collapses TLSSocket onto this kind):
1590
+ * the runtime gates on the transport, so a plain socket's
1591
+ * registration never fires — Node's exact split. 'session' fires
1592
+ * once with the serialized session (the received-ticket event). */
1593
+ on(event: "data", listener: (chunk: Buffer) => void): void;
1594
+ on(event: "end" | "close" | "connect" | "timeout" | "readable" | "secureConnect", listener: () => void): void;
1595
+ on(event: "error", listener: (err: Error) => void): void;
1596
+ on(event: "session", listener: (session: Buffer) => void): void;
1597
+ /* addListener IS on (Node aliases them) — the suite spells both. */
1598
+ addListener(event: "data", listener: (chunk: Buffer) => void): void;
1599
+ addListener(event: "end" | "close" | "connect" | "timeout" | "readable" | "secureConnect", listener: () => void): void;
1600
+ addListener(event: "error", listener: (err: Error) => void): void;
1601
+ addListener(event: "session", listener: (session: Buffer) => void): void;
1602
+ once(event: "data", listener: (chunk: Buffer) => void): void;
1603
+ once(event: "end" | "close" | "connect" | "timeout" | "readable" | "secureConnect", listener: () => void): void;
1604
+ once(event: "error", listener: (err: Error) => void): void;
1605
+ once(event: "session", listener: (session: Buffer) => void): void;
1606
+ }
1607
+ export interface Server {
1608
+ /* Node answers the server itself (`return this` chaining). */
1609
+ listen(port: number, callback?: () => void): Server;
1610
+ /* The positional bind address (the options form's host in argument
1611
+ * spelling). */
1612
+ listen(port: number, host: string, callback?: () => void): Server;
1613
+ /* The explicit-interface bind: host is an IP literal (absent = the
1614
+ * host-less dual-stack any); ipv6Only sets IPV6_V6ONLY. */
1615
+ listen(options: { port: number; host?: string; ipv6Only?: boolean }, callback?: () => void): Server;
1616
+ close(callback?: () => void): void;
1617
+ /* The bound AddressInfo (Node answers null before listen — this
1618
+ * surface answers the record with port 0 there, the serverPort
1619
+ * stance). */
1620
+ address(): import("node:dgram").AddressInfo;
1621
+ /* The demux route: hand an accepted socket to another server. */
1622
+ emit(event: "connection", socket: Socket): boolean;
1623
+ on(event: "connection" | "secureConnection", listener: (socket: Socket) => void): void;
1624
+ on(event: "close" | "listening", listener: () => void): void;
1625
+ on(event: "error", listener: (err: Error) => void): void;
1626
+ /* The WebSocket handover: fires INSTEAD of 'request' for
1627
+ * Connection: upgrade requests, with the raw socket + head bytes. */
1628
+ on(event: "upgrade", listener: (req: import("http").IncomingMessage, socket: Socket, head: Buffer) => void): void;
1629
+ /* http.createServer(handler)'s event twin (a no-parser net server
1630
+ * never fires it, like Node). */
1631
+ on(event: "request", listener: (req: import("http").IncomingMessage, res: import("http").ServerResponse) => void): void;
1632
+ /* addListener IS on (Node aliases them) — the suite spells both. */
1633
+ addListener(event: "connection" | "secureConnection", listener: (socket: Socket) => void): void;
1634
+ addListener(event: "close" | "listening", listener: () => void): void;
1635
+ addListener(event: "error", listener: (err: Error) => void): void;
1636
+ addListener(event: "upgrade", listener: (req: import("http").IncomingMessage, socket: Socket, head: Buffer) => void): void;
1637
+ addListener(event: "request", listener: (req: import("http").IncomingMessage, res: import("http").ServerResponse) => void): void;
1638
+ once(event: "connection" | "secureConnection", listener: (socket: Socket) => void): void;
1639
+ once(event: "close" | "listening", listener: () => void): void;
1640
+ once(event: "error", listener: (err: Error) => void): void;
1641
+ once(event: "upgrade", listener: (req: import("http").IncomingMessage, socket: Socket, head: Buffer) => void): void;
1642
+ once(event: "request", listener: (req: import("http").IncomingMessage, res: import("http").ServerResponse) => void): void;
1643
+ }
1644
+ /* The Socket VALUE — the `x instanceof net.Socket` narrowing target
1645
+ * (the h2 compat 'connect' listener's test). Constructing bare sockets
1646
+ * has no lowering; the construct signature exists for instanceof. */
1647
+ export const Socket: abstract new () => Socket;
1648
+ export function createServer(connectionListener?: (socket: Socket) => void): Server;
1649
+ export function connect(port: number, host?: string, connectListener?: () => void): Socket;
1650
+ export function createConnection(port: number, host?: string, connectListener?: () => void): Socket;
1651
+ /* The caller-resolver dial (@types/node's net.LookupFunction, narrowed
1652
+ * to the lowered shape): the runtime invokes it as Node does and dials
1653
+ * the answered addresses in order under autoSelectFamily: true. */
1654
+ export type LookupFunction = (
1655
+ hostname: string,
1656
+ options: unknown,
1657
+ callback: (err: NodeJS.ErrnoException | null, addresses: { address: string; family: number }[]) => void,
1658
+ ) => void;
1659
+ export function connect(options: {
1660
+ port: number;
1661
+ host?: string;
1662
+ autoSelectFamily?: boolean;
1663
+ lookup?: LookupFunction;
1664
+ }, connectListener?: () => void): Socket;
1665
+ export function createConnection(options: {
1666
+ port: number;
1667
+ host?: string;
1668
+ autoSelectFamily?: boolean;
1669
+ lookup?: LookupFunction;
1670
+ }, connectListener?: () => void): Socket;
1671
+ /* The happy-eyeballs attempt budget (Node's process-wide knob; the
1672
+ * autoSelectFamily dial consults it): one runtime int, default 250ms
1673
+ * like Node's. */
1674
+ export function getDefaultAutoSelectFamilyAttemptTimeout(): number;
1675
+ export function setDefaultAutoSelectFamilyAttemptTimeout(value: number): void;
1676
+ }
1677
+ declare module "node:net" {
1678
+ export * from "net";
1679
+ }
1680
+
1681
+ /* node:http — the SERVER and CLIENT slices (scr_http.c layers a
1682
+ * hand-written HTTP/1.1 parser + serializer on scr_net.c; both link only
1683
+ * into using binaries). createServer(handler) returns a net.Server —
1684
+ * listen/close/address().port/'error' are the same lowered surface. The
1685
+ * request carries url/method (always present on server requests),
1686
+ * statusCode (a number on client responses, undefined on server
1687
+ * requests), the underlying socket, and lowercased headers read as
1688
+ * `string | undefined`; the body streams through on("data"/"end"). The
1689
+ * response is setHeader/writeHead/write/end/destroy with Node's framing
1690
+ * (Content-Length for a single end(body), chunked after writeHead/write)
1691
+ * and the auto Date/Connection headers; writeHead's headers argument is
1692
+ * an object literal or a Record<string, string>. request/get dial one
1693
+ * connection per call (no agent pooling) with Node's exact wire head. */
1694
+ declare module "http" {
1695
+ import { Server as NetServer, Socket } from "net";
1696
+ export type Server = NetServer;
1697
+ /* The Server VALUE — Node's constructor works with and without `new`
1698
+ * (test/parallel's http.Server(fn) spelling); both route to the
1699
+ * createServer lowering. */
1700
+ export const Server: {
1701
+ new (requestListener?: (req: IncomingMessage, res: ServerResponse) => void): NetServer;
1702
+ new (options: ServerOptions, requestListener?: (req: IncomingMessage, res: ServerResponse) => void): NetServer;
1703
+ (requestListener?: (req: IncomingMessage, res: ServerResponse) => void): NetServer;
1704
+ (options: ServerOptions, requestListener?: (req: IncomingMessage, res: ServerResponse) => void): NetServer;
1705
+ };
1706
+ /* The options-record stance (the RequestOptions precedent): every
1707
+ * documented key typechecks; the lowering's option walk decides per
1708
+ * key — requireHostHeader: false and joinDuplicateHeaders lower,
1709
+ * documented-but-unlowered keys fence by name, unknown keys drop. */
1710
+ export interface ServerOptions {
1711
+ requireHostHeader?: boolean;
1712
+ joinDuplicateHeaders?: boolean;
1713
+ [option: string]: unknown;
1714
+ }
1715
+ /* The outgoing-header shape, @types/node's matrix: numbers format via
1716
+ * String(n), arrays write one line per element (set-cookie's shape).
1717
+ * Incoming headers stay `string | undefined` — what the parser answers
1718
+ * (under @types/node the two SLOTS unify so `{ ...req.headers }`
1719
+ * merges into outgoing literals as a copy; the fallback keeps reads
1720
+ * simple and spreads target the same string | undefined slot). */
1721
+ export type OutgoingHttpHeaders = { [name: string]: number | string | string[] | undefined };
1722
+ export interface IncomingMessage {
1723
+ readonly url: string;
1724
+ readonly method: string;
1725
+ readonly statusCode: number | undefined;
1726
+ readonly statusMessage: string | undefined;
1727
+ readonly socket: Socket;
1728
+ readonly headers: { [name: string]: string | undefined };
1729
+ readonly rawHeaders: string[];
1730
+ resume(): void;
1731
+ destroy(): void;
1732
+ /* setEncoding('utf8'): 'data' delivers strings (other real encodings
1733
+ * fence loudly at runtime; unknown names throw ERR_UNKNOWN_ENCODING). */
1734
+ setEncoding(encoding: string): void;
1735
+ /* The proxy legs: the body streams into a ServerResponse, a
1736
+ * ClientRequest, or a raw Socket; natural end ends the destination. */
1737
+ pipe(destination: ServerResponse | ClientRequest | Socket): void;
1738
+ on(event: "data", listener: (chunk: any) => void): void;
1739
+ on(event: "end" | "close", listener: () => void): void;
1740
+ on(event: "error", listener: (err: Error) => void): void;
1741
+ /* addListener IS on (Node aliases them) — the suite spells both. */
1742
+ addListener(event: "data", listener: (chunk: any) => void): void;
1743
+ addListener(event: "end" | "close", listener: () => void): void;
1744
+ addListener(event: "error", listener: (err: Error) => void): void;
1745
+ once(event: "data", listener: (chunk: any) => void): void;
1746
+ once(event: "end" | "close", listener: () => void): void;
1747
+ once(event: "error", listener: (err: Error) => void): void;
1748
+ }
1749
+ export interface ServerResponse {
1750
+ readonly headersSent: boolean;
1751
+ /* Node's writable head properties: the implicit head reads them. */
1752
+ statusCode: number;
1753
+ statusMessage: string;
1754
+ setHeader(name: string, value: string | number): void;
1755
+ getHeader(name: string): string | undefined;
1756
+ hasHeader(name: string): boolean;
1757
+ removeHeader(name: string): void;
1758
+ /* Both overloads answer the response (`return this` chaining); the
1759
+ * headers argument also takes Node's flat [name, value, ...] array. */
1760
+ writeHead(statusCode: number, headers?: OutgoingHttpHeaders | string[]): ServerResponse;
1761
+ writeHead(statusCode: number, statusMessage: string, headers?: OutgoingHttpHeaders | string[]): ServerResponse;
1762
+ write(data: string | Uint8Array): void;
1763
+ /* end's callback forms fire once the body went out (the 'finish'
1764
+ * emit, deferred past the handler's synchronous tail). */
1765
+ end(data?: string | Uint8Array, callback?: () => void): void;
1766
+ end(callback: () => void): void;
1767
+ destroy(): void;
1768
+ on(event: "close", listener: () => void): void;
1769
+ /* addListener IS on (Node aliases them) — the suite spells both. */
1770
+ addListener(event: "close", listener: () => void): void;
1771
+ once(event: "close", listener: () => void): void;
1772
+ }
1773
+ /* The CLIENT slice (http.request/http.get): the options-object form
1774
+ * with hostname/host, port, path, method, timeout, and headers; the
1775
+ * callback receives the response as an IncomingMessage (statusCode,
1776
+ * headers, body via on("data"/"end")). */
1777
+ export interface RequestOptions {
1778
+ hostname?: string;
1779
+ host?: string;
1780
+ port?: number;
1781
+ path?: string;
1782
+ method?: string;
1783
+ timeout?: number;
1784
+ headers?: OutgoingHttpHeaders;
1785
+ /* The caller's own dialer (the proxy's loopback dial): invoked once,
1786
+ * synchronously; its socket carries the exchange. */
1787
+ createConnection?: () => Socket;
1788
+ /* agent: false is lowered (a one-shot dial with Connection: close —
1789
+ * exactly the compiled client's model); null/undefined are the
1790
+ * default; Agent INSTANCES fence at the call site (no pooling). */
1791
+ agent?: Agent | boolean | null;
1792
+ /* The options-record stance: Node ignores an options record's
1793
+ * unknown keys, so every key typechecks here — the option WALK in
1794
+ * the lowering decides per key (lower, fence by name, or drop
1795
+ * undocumented keys exactly like Node). */
1796
+ [option: string]: unknown;
1797
+ }
1798
+ /* Declared surface without a lowering: the compiled client dials one
1799
+ * connection per exchange and closes it with the response (the
1800
+ * agent: false shape), so pooling Agents cannot be honored —
1801
+ * constructing one fences at the site. */
1802
+ export interface AgentOptions {
1803
+ keepAlive?: boolean;
1804
+ keepAliveMsecs?: number;
1805
+ maxSockets?: number;
1806
+ maxFreeSockets?: number;
1807
+ maxTotalSockets?: number;
1808
+ scheduling?: string;
1809
+ timeout?: number;
1810
+ [option: string]: unknown;
1811
+ }
1812
+ export class Agent {
1813
+ constructor(options?: AgentOptions);
1814
+ destroy(): void;
1815
+ maxSockets: number;
1816
+ maxFreeSockets: number;
1817
+ readonly sockets: { [key: string]: unknown };
1818
+ readonly freeSockets: { [key: string]: unknown };
1819
+ readonly requests: { [key: string]: unknown };
1820
+ }
1821
+ export const globalAgent: Agent;
1822
+ export interface ClientRequest {
1823
+ readonly destroyed: boolean;
1824
+ write(data: string | Uint8Array): void;
1825
+ end(data?: string | Uint8Array): void;
1826
+ destroy(): void;
1827
+ on(event: "response", listener: (res: IncomingMessage) => void): void;
1828
+ on(event: "upgrade", listener: (res: IncomingMessage, socket: Socket, head: Buffer) => void): void;
1829
+ on(event: "timeout" | "close", listener: () => void): void;
1830
+ on(event: "error", listener: (err: Error) => void): void;
1831
+ /* addListener IS on (Node aliases them) — the suite spells both. */
1832
+ addListener(event: "response", listener: (res: IncomingMessage) => void): void;
1833
+ addListener(event: "upgrade", listener: (res: IncomingMessage, socket: Socket, head: Buffer) => void): void;
1834
+ addListener(event: "timeout" | "close", listener: () => void): void;
1835
+ addListener(event: "error", listener: (err: Error) => void): void;
1836
+ once(event: "response", listener: (res: IncomingMessage) => void): void;
1837
+ once(event: "upgrade", listener: (res: IncomingMessage, socket: Socket, head: Buffer) => void): void;
1838
+ once(event: "timeout" | "close", listener: () => void): void;
1839
+ once(event: "error", listener: (err: Error) => void): void;
1840
+ }
1841
+ export function createServer(
1842
+ requestListener?: (req: IncomingMessage, res: ServerResponse) => void,
1843
+ ): Server;
1844
+ export function createServer(
1845
+ options: ServerOptions,
1846
+ requestListener?: (req: IncomingMessage, res: ServerResponse) => void,
1847
+ ): Server;
1848
+ export function request(
1849
+ options: RequestOptions,
1850
+ callback?: (res: IncomingMessage) => void,
1851
+ ): ClientRequest;
1852
+ export function get(
1853
+ options: RequestOptions,
1854
+ callback?: (res: IncomingMessage) => void,
1855
+ ): ClientRequest;
1856
+ }
1857
+ declare module "node:http" {
1858
+ export * from "http";
1859
+ }
1860
+
1861
+ /* node:tls — the TLS server slice (scr_tls.c over scr_net.c with the
1862
+ * vendored mbedTLS; linked only into using binaries).
1863
+ * createServer({ cert, key }, handler) returns a net.Server; the handler
1864
+ * is Node's 'secureConnection' — it fires post-handshake with a socket
1865
+ * that behaves exactly like a net socket (write/end/destroy/pipe and the
1866
+ * data/end/close/error events are the same lowered surface). cert/key
1867
+ * are PEM strings or Buffers. Handshake failures tear the socket down
1868
+ * silently, Node's default for 'tlsClientError' with no listener. */
1869
+ declare module "tls" {
1870
+ import { Server, Socket } from "net";
1871
+ export { Server };
1872
+ export interface TlsOptions {
1873
+ /* Optional in the DECLARATION only (real Node programs build these
1874
+ * literals with every TLS knob): the lowering still requires both —
1875
+ * a literal without them fences at the call site. */
1876
+ cert?: string | Uint8Array;
1877
+ key?: string | Uint8Array;
1878
+ /* The options-record stance (see http.RequestOptions): every key
1879
+ * typechecks; the option walk fences documented-but-unlowered keys
1880
+ * by name and drops undocumented ones like Node. */
1881
+ [option: string]: unknown;
1882
+ }
1883
+ export function createServer(
1884
+ options: TlsOptions,
1885
+ secureConnectionListener?: (socket: Socket) => void,
1886
+ ): Server;
1887
+ /** TLSSocket — post-handshake it IS a net socket to every lowered
1888
+ * member (the mapping collapses it onto the socket kind; the
1889
+ * secureConnect/session events ride the shared socket declarations).
1890
+ * The TLS extras: authorized/authorizationError answer Node's verify
1891
+ * split — authorizationError is the verify-failure CODE STRING
1892
+ * (DEPTH_ZERO_SELF_SIGNED_CERT, ...), or null. */
1893
+ export interface TLSSocket extends Socket {
1894
+ authorized: boolean;
1895
+ authorizationError: string | null;
1896
+ }
1897
+ /** tls.connect options — the RUNTIME options record (members read at
1898
+ * runtime; port/host/rejectUnauthorized/ca/servername are the
1899
+ * honestly-implemented set, every other documented member throws the
1900
+ * runtime fence — the options-record stance's divergence-66 shape). */
1901
+ export interface ConnectionOptions {
1902
+ port?: number;
1903
+ host?: string;
1904
+ rejectUnauthorized?: boolean;
1905
+ ca?: string | Uint8Array | ReadonlyArray<string | Uint8Array>;
1906
+ servername?: string;
1907
+ [option: string]: unknown;
1908
+ }
1909
+ export function connect(options: ConnectionOptions, secureConnectListener?: () => void): TLSSocket;
1910
+ export function connect(port: number, options?: ConnectionOptions, secureConnectListener?: () => void): TLSSocket;
1911
+ export function connect(port: number, host?: string, options?: ConnectionOptions, secureConnectListener?: () => void): TLSSocket;
1912
+ /** An opaque parsed cert/key pair — what an SNI callback answers with
1913
+ * (the value is a runtime handle; the members are runtime-internal). */
1914
+ export interface SecureContext {}
1915
+ export function createSecureContext(options: TlsOptions): SecureContext;
1916
+ }
1917
+ declare module "node:tls" {
1918
+ export * from "tls";
1919
+ }
1920
+
1921
+ /* node:https — http over the TLS transport (scr_tls.c).
1922
+ * createServer({ cert, key }, handler) is the http server behind a
1923
+ * handshake; request/get are the http client with port 443 default and
1924
+ * the local-CA knobs: `ca` (PEM string/Buffer) replaces the trust
1925
+ * anchors, rejectUnauthorized: false disables verification (the
1926
+ * self-signed probe shape). With neither, /etc/ssl/cert.pem stands in
1927
+ * for Node's bundled roots. */
1928
+ declare module "https" {
1929
+ import { Server } from "net";
1930
+ import { Agent, ClientRequest, IncomingMessage, ServerResponse } from "http";
1931
+ export { Agent, Server };
1932
+ export interface ServerOptions {
1933
+ cert: string | Uint8Array;
1934
+ key: string | Uint8Array;
1935
+ /* The options-record stance (see http.RequestOptions). */
1936
+ [option: string]: unknown;
1937
+ }
1938
+ export interface RequestOptions {
1939
+ hostname?: string;
1940
+ host?: string;
1941
+ port?: number;
1942
+ path?: string;
1943
+ method?: string;
1944
+ timeout?: number;
1945
+ headers?: { [name: string]: string };
1946
+ rejectUnauthorized?: boolean;
1947
+ ca?: string | Uint8Array;
1948
+ agent?: Agent | boolean | null;
1949
+ /* The options-record stance (see http.RequestOptions). */
1950
+ [option: string]: unknown;
1951
+ }
1952
+ export function createServer(
1953
+ options: ServerOptions,
1954
+ requestListener: (req: IncomingMessage, res: ServerResponse) => void,
1955
+ ): Server;
1956
+ export function request(
1957
+ options: RequestOptions,
1958
+ callback?: (res: IncomingMessage) => void,
1959
+ ): ClientRequest;
1960
+ export function get(
1961
+ options: RequestOptions,
1962
+ callback?: (res: IncomingMessage) => void,
1963
+ ): ClientRequest;
1964
+ }
1965
+ declare module "node:https" {
1966
+ export * from "https";
1967
+ }
1968
+
1969
+ /* node:http2 — the COMPATIBILITY slice (SEMANTICS.md divergence 57):
1970
+ * createSecureServer({ allowHTTP1: true, cert, key }) is the https
1971
+ * server without an eager handler — ALPN advertises http/1.1 ONLY, so
1972
+ * h2-capable clients negotiate down and every connection serves
1973
+ * HTTP/1.1 (h2-only clients fail the handshake; no multiplexing, no
1974
+ * server push). The handler arrives via server.on("request", ...);
1975
+ * Http2ServerRequest/Response ARE the http req/res surface (exactly
1976
+ * what Node hands an allowHTTP1 server's HTTP/1.1 connections), with
1977
+ * the h2-only members (stream, session) answering undefined behind a
1978
+ * '?.' guard and fencing unguarded. 'sessionError' registers and never
1979
+ * fires (no h2 session ever exists). h2 sessions themselves — connect,
1980
+ * the h2c createServer — have no lowering. */
1981
+ declare module "http2" {
1982
+ import { Socket } from "net";
1983
+ export interface Http2Stream {
1984
+ on(event: "error" | "close", listener: (err: Error) => void): void;
1985
+ once(event: "error" | "close", listener: (err: Error) => void): void;
1986
+ destroy(): void;
1987
+ }
1988
+ export interface Http2ServerRequest {
1989
+ readonly url: string;
1990
+ readonly method: string;
1991
+ readonly statusCode: number | undefined;
1992
+ readonly socket: Socket;
1993
+ readonly headers: { [name: string]: string | undefined };
1994
+ readonly stream: Http2Stream;
1995
+ /* The h2 compat request's version triple ("2.0" over real h2 streams;
1996
+ * the allowHTTP1 lowering's HTTP/1.1 connections answer 1.x). */
1997
+ readonly httpVersion: string;
1998
+ readonly httpVersionMajor: number;
1999
+ readonly httpVersionMinor: number;
2000
+ readonly aborted: boolean;
2001
+ readonly complete: boolean;
2002
+ resume(): void;
2003
+ destroy(): void;
2004
+ setEncoding(encoding: string): void;
2005
+ pipe(destination: Socket | import("http").ClientRequest): void;
2006
+ on(event: "data", listener: (chunk: Buffer) => void): void;
2007
+ on(event: "end" | "close" | "aborted", listener: () => void): void;
2008
+ on(event: "error", listener: (err: Error) => void): void;
2009
+ /* addListener IS on (Node aliases them) — and the compat req IS the
2010
+ * http.IncomingMessage surface, so the alias mirrors here too. */
2011
+ addListener(event: "data", listener: (chunk: Buffer) => void): void;
2012
+ addListener(event: "end" | "close" | "aborted", listener: () => void): void;
2013
+ addListener(event: "error", listener: (err: Error) => void): void;
2014
+ once(event: "data", listener: (chunk: Buffer) => void): void;
2015
+ once(event: "end" | "close" | "aborted", listener: () => void): void;
2016
+ once(event: "error", listener: (err: Error) => void): void;
2017
+ }
2018
+ export interface Http2ServerResponse {
2019
+ readonly headersSent: boolean;
2020
+ /* The same lowered surface as http.ServerResponse — the allowHTTP1
2021
+ * lowering serves every connection as HTTP/1.1, where the compat
2022
+ * response IS this parser's response handle. */
2023
+ statusCode: number;
2024
+ statusMessage: string;
2025
+ setHeader(name: string, value: string | number): void;
2026
+ getHeader(name: string): string | undefined;
2027
+ hasHeader(name: string): boolean;
2028
+ removeHeader(name: string): void;
2029
+ writeHead(statusCode: number, headers?: import("http").OutgoingHttpHeaders | string[]): Http2ServerResponse;
2030
+ writeHead(statusCode: number, statusMessage: string, headers?: import("http").OutgoingHttpHeaders | string[]): Http2ServerResponse;
2031
+ write(data: string | Uint8Array): void;
2032
+ end(data?: string | Uint8Array, callback?: () => void): void;
2033
+ end(callback: () => void): void;
2034
+ destroy(): void;
2035
+ on(event: "close", listener: () => void): void;
2036
+ /* addListener IS on (Node aliases them) — and the compat res IS the
2037
+ * http.ServerResponse surface (assignability into ServerResponse
2038
+ * unions — IncomingMessage.pipe's destination — needs the alias). */
2039
+ addListener(event: "close", listener: () => void): void;
2040
+ once(event: "close", listener: () => void): void;
2041
+ }
2042
+ export interface Http2SecureServer {
2043
+ listen(port: number, callback?: () => void): void;
2044
+ close(callback?: () => void): void;
2045
+ /* The bound AddressInfo (Node answers null before listen — this
2046
+ * surface answers the record with port 0 there, the serverPort
2047
+ * stance). */
2048
+ address(): import("node:dgram").AddressInfo;
2049
+ emit(event: "connection", socket: Socket): void;
2050
+ on(event: "connection", listener: (socket: Socket) => void): void;
2051
+ on(event: "request", listener: (req: Http2ServerRequest, res: Http2ServerResponse) => void): void;
2052
+ on(event: "error", listener: (err: Error) => void): void;
2053
+ on(event: "close", listener: () => void): void;
2054
+ on(event: "sessionError", listener: () => void): void;
2055
+ /* The ALPN=h2 server's surface (createSecureServer WITHOUT
2056
+ * allowHTTP1 — the real h2-over-TLS stack): per-stream and
2057
+ * per-session listeners, exactly the h2c server's. */
2058
+ on(event: "stream", listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void): void;
2059
+ on(event: "session", listener: (session: ServerHttp2Session) => void): void;
2060
+ once(event: "stream", listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void): void;
2061
+ once(event: "session", listener: (session: ServerHttp2Session) => void): void;
2062
+ /* HTTP CONNECT (and, in Node, the h2 extended CONNECT — which the
2063
+ * allowHTTP1 lowering never sees): the second argument is the raw
2064
+ * socket on HTTP/1.1 connections; narrow with instanceof. */
2065
+ on(event: "connect", listener: (req: Http2ServerRequest | import("http").IncomingMessage, resOrSocket: Http2ServerResponse | Socket) => void): void;
2066
+ once(event: "connection", listener: (socket: Socket) => void): void;
2067
+ once(event: "request", listener: (req: Http2ServerRequest, res: Http2ServerResponse) => void): void;
2068
+ once(event: "error", listener: (err: Error) => void): void;
2069
+ once(event: "close", listener: () => void): void;
2070
+ }
2071
+ export interface SecureServerOptions {
2072
+ allowHTTP1?: boolean;
2073
+ cert?: string | Uint8Array;
2074
+ key?: string | Uint8Array;
2075
+ SNICallback?: (
2076
+ servername: string,
2077
+ cb: (err: Error | null, ctx?: import("tls").SecureContext) => void,
2078
+ ) => void;
2079
+ /* The options-record stance (see http.RequestOptions): h2 session-
2080
+ * tuning knobs are accepted as literals and ignored (no h2 session
2081
+ * ever exists under the allowHTTP1 lowering); other documented keys
2082
+ * fence by name; undocumented keys drop like Node. */
2083
+ [option: string]: unknown;
2084
+ }
2085
+ /* The full Node v24 constants table (240 members), literal-typed so
2086
+ * computed header keys ([HTTP2_HEADER_PATH]: value) stay literal keys.
2087
+ * Every ACCESS bakes as its literal at lowering; the object itself
2088
+ * never materializes (bare http2.constants value uses fence). */
2089
+ export interface Http2Constants {
2090
+ readonly NGHTTP2_ERR_FRAME_SIZE_ERROR: -522;
2091
+ readonly NGHTTP2_SESSION_SERVER: 0;
2092
+ readonly NGHTTP2_SESSION_CLIENT: 1;
2093
+ readonly NGHTTP2_STREAM_STATE_IDLE: 1;
2094
+ readonly NGHTTP2_STREAM_STATE_OPEN: 2;
2095
+ readonly NGHTTP2_STREAM_STATE_RESERVED_LOCAL: 3;
2096
+ readonly NGHTTP2_STREAM_STATE_RESERVED_REMOTE: 4;
2097
+ readonly NGHTTP2_STREAM_STATE_HALF_CLOSED_LOCAL: 5;
2098
+ readonly NGHTTP2_STREAM_STATE_HALF_CLOSED_REMOTE: 6;
2099
+ readonly NGHTTP2_STREAM_STATE_CLOSED: 7;
2100
+ readonly NGHTTP2_FLAG_NONE: 0;
2101
+ readonly NGHTTP2_FLAG_END_STREAM: 1;
2102
+ readonly NGHTTP2_FLAG_END_HEADERS: 4;
2103
+ readonly NGHTTP2_FLAG_ACK: 1;
2104
+ readonly NGHTTP2_FLAG_PADDED: 8;
2105
+ readonly NGHTTP2_FLAG_PRIORITY: 32;
2106
+ readonly DEFAULT_SETTINGS_HEADER_TABLE_SIZE: 4096;
2107
+ readonly DEFAULT_SETTINGS_ENABLE_PUSH: 1;
2108
+ readonly DEFAULT_SETTINGS_MAX_CONCURRENT_STREAMS: 4294967295;
2109
+ readonly DEFAULT_SETTINGS_INITIAL_WINDOW_SIZE: 65535;
2110
+ readonly DEFAULT_SETTINGS_MAX_FRAME_SIZE: 16384;
2111
+ readonly DEFAULT_SETTINGS_MAX_HEADER_LIST_SIZE: 65535;
2112
+ readonly DEFAULT_SETTINGS_ENABLE_CONNECT_PROTOCOL: 0;
2113
+ readonly MAX_MAX_FRAME_SIZE: 16777215;
2114
+ readonly MIN_MAX_FRAME_SIZE: 16384;
2115
+ readonly MAX_INITIAL_WINDOW_SIZE: 2147483647;
2116
+ readonly NGHTTP2_SETTINGS_HEADER_TABLE_SIZE: 1;
2117
+ readonly NGHTTP2_SETTINGS_ENABLE_PUSH: 2;
2118
+ readonly NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS: 3;
2119
+ readonly NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE: 4;
2120
+ readonly NGHTTP2_SETTINGS_MAX_FRAME_SIZE: 5;
2121
+ readonly NGHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE: 6;
2122
+ readonly NGHTTP2_SETTINGS_ENABLE_CONNECT_PROTOCOL: 8;
2123
+ readonly PADDING_STRATEGY_NONE: 0;
2124
+ readonly PADDING_STRATEGY_ALIGNED: 1;
2125
+ readonly PADDING_STRATEGY_MAX: 2;
2126
+ readonly PADDING_STRATEGY_CALLBACK: 1;
2127
+ readonly NGHTTP2_NO_ERROR: 0;
2128
+ readonly NGHTTP2_PROTOCOL_ERROR: 1;
2129
+ readonly NGHTTP2_INTERNAL_ERROR: 2;
2130
+ readonly NGHTTP2_FLOW_CONTROL_ERROR: 3;
2131
+ readonly NGHTTP2_SETTINGS_TIMEOUT: 4;
2132
+ readonly NGHTTP2_STREAM_CLOSED: 5;
2133
+ readonly NGHTTP2_FRAME_SIZE_ERROR: 6;
2134
+ readonly NGHTTP2_REFUSED_STREAM: 7;
2135
+ readonly NGHTTP2_CANCEL: 8;
2136
+ readonly NGHTTP2_COMPRESSION_ERROR: 9;
2137
+ readonly NGHTTP2_CONNECT_ERROR: 10;
2138
+ readonly NGHTTP2_ENHANCE_YOUR_CALM: 11;
2139
+ readonly NGHTTP2_INADEQUATE_SECURITY: 12;
2140
+ readonly NGHTTP2_HTTP_1_1_REQUIRED: 13;
2141
+ readonly NGHTTP2_DEFAULT_WEIGHT: 16;
2142
+ readonly HTTP2_HEADER_STATUS: ":status";
2143
+ readonly HTTP2_HEADER_METHOD: ":method";
2144
+ readonly HTTP2_HEADER_AUTHORITY: ":authority";
2145
+ readonly HTTP2_HEADER_SCHEME: ":scheme";
2146
+ readonly HTTP2_HEADER_PATH: ":path";
2147
+ readonly HTTP2_HEADER_PROTOCOL: ":protocol";
2148
+ readonly HTTP2_HEADER_ACCEPT_ENCODING: "accept-encoding";
2149
+ readonly HTTP2_HEADER_ACCEPT_LANGUAGE: "accept-language";
2150
+ readonly HTTP2_HEADER_ACCEPT_RANGES: "accept-ranges";
2151
+ readonly HTTP2_HEADER_ACCEPT: "accept";
2152
+ readonly HTTP2_HEADER_ACCESS_CONTROL_ALLOW_CREDENTIALS: "access-control-allow-credentials";
2153
+ readonly HTTP2_HEADER_ACCESS_CONTROL_ALLOW_HEADERS: "access-control-allow-headers";
2154
+ readonly HTTP2_HEADER_ACCESS_CONTROL_ALLOW_METHODS: "access-control-allow-methods";
2155
+ readonly HTTP2_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN: "access-control-allow-origin";
2156
+ readonly HTTP2_HEADER_ACCESS_CONTROL_EXPOSE_HEADERS: "access-control-expose-headers";
2157
+ readonly HTTP2_HEADER_ACCESS_CONTROL_REQUEST_HEADERS: "access-control-request-headers";
2158
+ readonly HTTP2_HEADER_ACCESS_CONTROL_REQUEST_METHOD: "access-control-request-method";
2159
+ readonly HTTP2_HEADER_AGE: "age";
2160
+ readonly HTTP2_HEADER_AUTHORIZATION: "authorization";
2161
+ readonly HTTP2_HEADER_CACHE_CONTROL: "cache-control";
2162
+ readonly HTTP2_HEADER_CONNECTION: "connection";
2163
+ readonly HTTP2_HEADER_CONTENT_DISPOSITION: "content-disposition";
2164
+ readonly HTTP2_HEADER_CONTENT_ENCODING: "content-encoding";
2165
+ readonly HTTP2_HEADER_CONTENT_LENGTH: "content-length";
2166
+ readonly HTTP2_HEADER_CONTENT_TYPE: "content-type";
2167
+ readonly HTTP2_HEADER_COOKIE: "cookie";
2168
+ readonly HTTP2_HEADER_DATE: "date";
2169
+ readonly HTTP2_HEADER_ETAG: "etag";
2170
+ readonly HTTP2_HEADER_FORWARDED: "forwarded";
2171
+ readonly HTTP2_HEADER_HOST: "host";
2172
+ readonly HTTP2_HEADER_IF_MODIFIED_SINCE: "if-modified-since";
2173
+ readonly HTTP2_HEADER_IF_NONE_MATCH: "if-none-match";
2174
+ readonly HTTP2_HEADER_IF_RANGE: "if-range";
2175
+ readonly HTTP2_HEADER_LAST_MODIFIED: "last-modified";
2176
+ readonly HTTP2_HEADER_LINK: "link";
2177
+ readonly HTTP2_HEADER_LOCATION: "location";
2178
+ readonly HTTP2_HEADER_RANGE: "range";
2179
+ readonly HTTP2_HEADER_REFERER: "referer";
2180
+ readonly HTTP2_HEADER_SERVER: "server";
2181
+ readonly HTTP2_HEADER_SET_COOKIE: "set-cookie";
2182
+ readonly HTTP2_HEADER_STRICT_TRANSPORT_SECURITY: "strict-transport-security";
2183
+ readonly HTTP2_HEADER_TRANSFER_ENCODING: "transfer-encoding";
2184
+ readonly HTTP2_HEADER_TE: "te";
2185
+ readonly HTTP2_HEADER_UPGRADE_INSECURE_REQUESTS: "upgrade-insecure-requests";
2186
+ readonly HTTP2_HEADER_UPGRADE: "upgrade";
2187
+ readonly HTTP2_HEADER_USER_AGENT: "user-agent";
2188
+ readonly HTTP2_HEADER_VARY: "vary";
2189
+ readonly HTTP2_HEADER_X_CONTENT_TYPE_OPTIONS: "x-content-type-options";
2190
+ readonly HTTP2_HEADER_X_FRAME_OPTIONS: "x-frame-options";
2191
+ readonly HTTP2_HEADER_KEEP_ALIVE: "keep-alive";
2192
+ readonly HTTP2_HEADER_PROXY_CONNECTION: "proxy-connection";
2193
+ readonly HTTP2_HEADER_X_XSS_PROTECTION: "x-xss-protection";
2194
+ readonly HTTP2_HEADER_ALT_SVC: "alt-svc";
2195
+ readonly HTTP2_HEADER_CONTENT_SECURITY_POLICY: "content-security-policy";
2196
+ readonly HTTP2_HEADER_EARLY_DATA: "early-data";
2197
+ readonly HTTP2_HEADER_EXPECT_CT: "expect-ct";
2198
+ readonly HTTP2_HEADER_ORIGIN: "origin";
2199
+ readonly HTTP2_HEADER_PURPOSE: "purpose";
2200
+ readonly HTTP2_HEADER_TIMING_ALLOW_ORIGIN: "timing-allow-origin";
2201
+ readonly HTTP2_HEADER_X_FORWARDED_FOR: "x-forwarded-for";
2202
+ readonly HTTP2_HEADER_PRIORITY: "priority";
2203
+ readonly HTTP2_HEADER_ACCEPT_CHARSET: "accept-charset";
2204
+ readonly HTTP2_HEADER_ACCESS_CONTROL_MAX_AGE: "access-control-max-age";
2205
+ readonly HTTP2_HEADER_ALLOW: "allow";
2206
+ readonly HTTP2_HEADER_CONTENT_LANGUAGE: "content-language";
2207
+ readonly HTTP2_HEADER_CONTENT_LOCATION: "content-location";
2208
+ readonly HTTP2_HEADER_CONTENT_MD5: "content-md5";
2209
+ readonly HTTP2_HEADER_CONTENT_RANGE: "content-range";
2210
+ readonly HTTP2_HEADER_DNT: "dnt";
2211
+ readonly HTTP2_HEADER_EXPECT: "expect";
2212
+ readonly HTTP2_HEADER_EXPIRES: "expires";
2213
+ readonly HTTP2_HEADER_FROM: "from";
2214
+ readonly HTTP2_HEADER_IF_MATCH: "if-match";
2215
+ readonly HTTP2_HEADER_IF_UNMODIFIED_SINCE: "if-unmodified-since";
2216
+ readonly HTTP2_HEADER_MAX_FORWARDS: "max-forwards";
2217
+ readonly HTTP2_HEADER_PREFER: "prefer";
2218
+ readonly HTTP2_HEADER_PROXY_AUTHENTICATE: "proxy-authenticate";
2219
+ readonly HTTP2_HEADER_PROXY_AUTHORIZATION: "proxy-authorization";
2220
+ readonly HTTP2_HEADER_REFRESH: "refresh";
2221
+ readonly HTTP2_HEADER_RETRY_AFTER: "retry-after";
2222
+ readonly HTTP2_HEADER_TRAILER: "trailer";
2223
+ readonly HTTP2_HEADER_TK: "tk";
2224
+ readonly HTTP2_HEADER_VIA: "via";
2225
+ readonly HTTP2_HEADER_WARNING: "warning";
2226
+ readonly HTTP2_HEADER_WWW_AUTHENTICATE: "www-authenticate";
2227
+ readonly HTTP2_HEADER_HTTP2_SETTINGS: "http2-settings";
2228
+ readonly HTTP2_METHOD_ACL: "ACL";
2229
+ readonly HTTP2_METHOD_BASELINE_CONTROL: "BASELINE-CONTROL";
2230
+ readonly HTTP2_METHOD_BIND: "BIND";
2231
+ readonly HTTP2_METHOD_CHECKIN: "CHECKIN";
2232
+ readonly HTTP2_METHOD_CHECKOUT: "CHECKOUT";
2233
+ readonly HTTP2_METHOD_CONNECT: "CONNECT";
2234
+ readonly HTTP2_METHOD_COPY: "COPY";
2235
+ readonly HTTP2_METHOD_DELETE: "DELETE";
2236
+ readonly HTTP2_METHOD_GET: "GET";
2237
+ readonly HTTP2_METHOD_HEAD: "HEAD";
2238
+ readonly HTTP2_METHOD_LABEL: "LABEL";
2239
+ readonly HTTP2_METHOD_LINK: "LINK";
2240
+ readonly HTTP2_METHOD_LOCK: "LOCK";
2241
+ readonly HTTP2_METHOD_MERGE: "MERGE";
2242
+ readonly HTTP2_METHOD_MKACTIVITY: "MKACTIVITY";
2243
+ readonly HTTP2_METHOD_MKCALENDAR: "MKCALENDAR";
2244
+ readonly HTTP2_METHOD_MKCOL: "MKCOL";
2245
+ readonly HTTP2_METHOD_MKREDIRECTREF: "MKREDIRECTREF";
2246
+ readonly HTTP2_METHOD_MKWORKSPACE: "MKWORKSPACE";
2247
+ readonly HTTP2_METHOD_MOVE: "MOVE";
2248
+ readonly HTTP2_METHOD_OPTIONS: "OPTIONS";
2249
+ readonly HTTP2_METHOD_ORDERPATCH: "ORDERPATCH";
2250
+ readonly HTTP2_METHOD_PATCH: "PATCH";
2251
+ readonly HTTP2_METHOD_POST: "POST";
2252
+ readonly HTTP2_METHOD_PRI: "PRI";
2253
+ readonly HTTP2_METHOD_PROPFIND: "PROPFIND";
2254
+ readonly HTTP2_METHOD_PROPPATCH: "PROPPATCH";
2255
+ readonly HTTP2_METHOD_PUT: "PUT";
2256
+ readonly HTTP2_METHOD_REBIND: "REBIND";
2257
+ readonly HTTP2_METHOD_REPORT: "REPORT";
2258
+ readonly HTTP2_METHOD_SEARCH: "SEARCH";
2259
+ readonly HTTP2_METHOD_TRACE: "TRACE";
2260
+ readonly HTTP2_METHOD_UNBIND: "UNBIND";
2261
+ readonly HTTP2_METHOD_UNCHECKOUT: "UNCHECKOUT";
2262
+ readonly HTTP2_METHOD_UNLINK: "UNLINK";
2263
+ readonly HTTP2_METHOD_UNLOCK: "UNLOCK";
2264
+ readonly HTTP2_METHOD_UPDATE: "UPDATE";
2265
+ readonly HTTP2_METHOD_UPDATEREDIRECTREF: "UPDATEREDIRECTREF";
2266
+ readonly HTTP2_METHOD_VERSION_CONTROL: "VERSION-CONTROL";
2267
+ readonly HTTP_STATUS_CONTINUE: 100;
2268
+ readonly HTTP_STATUS_SWITCHING_PROTOCOLS: 101;
2269
+ readonly HTTP_STATUS_PROCESSING: 102;
2270
+ readonly HTTP_STATUS_EARLY_HINTS: 103;
2271
+ readonly HTTP_STATUS_OK: 200;
2272
+ readonly HTTP_STATUS_CREATED: 201;
2273
+ readonly HTTP_STATUS_ACCEPTED: 202;
2274
+ readonly HTTP_STATUS_NON_AUTHORITATIVE_INFORMATION: 203;
2275
+ readonly HTTP_STATUS_NO_CONTENT: 204;
2276
+ readonly HTTP_STATUS_RESET_CONTENT: 205;
2277
+ readonly HTTP_STATUS_PARTIAL_CONTENT: 206;
2278
+ readonly HTTP_STATUS_MULTI_STATUS: 207;
2279
+ readonly HTTP_STATUS_ALREADY_REPORTED: 208;
2280
+ readonly HTTP_STATUS_IM_USED: 226;
2281
+ readonly HTTP_STATUS_MULTIPLE_CHOICES: 300;
2282
+ readonly HTTP_STATUS_MOVED_PERMANENTLY: 301;
2283
+ readonly HTTP_STATUS_FOUND: 302;
2284
+ readonly HTTP_STATUS_SEE_OTHER: 303;
2285
+ readonly HTTP_STATUS_NOT_MODIFIED: 304;
2286
+ readonly HTTP_STATUS_USE_PROXY: 305;
2287
+ readonly HTTP_STATUS_TEMPORARY_REDIRECT: 307;
2288
+ readonly HTTP_STATUS_PERMANENT_REDIRECT: 308;
2289
+ readonly HTTP_STATUS_BAD_REQUEST: 400;
2290
+ readonly HTTP_STATUS_UNAUTHORIZED: 401;
2291
+ readonly HTTP_STATUS_PAYMENT_REQUIRED: 402;
2292
+ readonly HTTP_STATUS_FORBIDDEN: 403;
2293
+ readonly HTTP_STATUS_NOT_FOUND: 404;
2294
+ readonly HTTP_STATUS_METHOD_NOT_ALLOWED: 405;
2295
+ readonly HTTP_STATUS_NOT_ACCEPTABLE: 406;
2296
+ readonly HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED: 407;
2297
+ readonly HTTP_STATUS_REQUEST_TIMEOUT: 408;
2298
+ readonly HTTP_STATUS_CONFLICT: 409;
2299
+ readonly HTTP_STATUS_GONE: 410;
2300
+ readonly HTTP_STATUS_LENGTH_REQUIRED: 411;
2301
+ readonly HTTP_STATUS_PRECONDITION_FAILED: 412;
2302
+ readonly HTTP_STATUS_PAYLOAD_TOO_LARGE: 413;
2303
+ readonly HTTP_STATUS_URI_TOO_LONG: 414;
2304
+ readonly HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE: 415;
2305
+ readonly HTTP_STATUS_RANGE_NOT_SATISFIABLE: 416;
2306
+ readonly HTTP_STATUS_EXPECTATION_FAILED: 417;
2307
+ readonly HTTP_STATUS_TEAPOT: 418;
2308
+ readonly HTTP_STATUS_MISDIRECTED_REQUEST: 421;
2309
+ readonly HTTP_STATUS_UNPROCESSABLE_ENTITY: 422;
2310
+ readonly HTTP_STATUS_LOCKED: 423;
2311
+ readonly HTTP_STATUS_FAILED_DEPENDENCY: 424;
2312
+ readonly HTTP_STATUS_TOO_EARLY: 425;
2313
+ readonly HTTP_STATUS_UPGRADE_REQUIRED: 426;
2314
+ readonly HTTP_STATUS_PRECONDITION_REQUIRED: 428;
2315
+ readonly HTTP_STATUS_TOO_MANY_REQUESTS: 429;
2316
+ readonly HTTP_STATUS_REQUEST_HEADER_FIELDS_TOO_LARGE: 431;
2317
+ readonly HTTP_STATUS_UNAVAILABLE_FOR_LEGAL_REASONS: 451;
2318
+ readonly HTTP_STATUS_INTERNAL_SERVER_ERROR: 500;
2319
+ readonly HTTP_STATUS_NOT_IMPLEMENTED: 501;
2320
+ readonly HTTP_STATUS_BAD_GATEWAY: 502;
2321
+ readonly HTTP_STATUS_SERVICE_UNAVAILABLE: 503;
2322
+ readonly HTTP_STATUS_GATEWAY_TIMEOUT: 504;
2323
+ readonly HTTP_STATUS_HTTP_VERSION_NOT_SUPPORTED: 505;
2324
+ readonly HTTP_STATUS_VARIANT_ALSO_NEGOTIATES: 506;
2325
+ readonly HTTP_STATUS_INSUFFICIENT_STORAGE: 507;
2326
+ readonly HTTP_STATUS_LOOP_DETECTED: 508;
2327
+ readonly HTTP_STATUS_BANDWIDTH_LIMIT_EXCEEDED: 509;
2328
+ readonly HTTP_STATUS_NOT_EXTENDED: 510;
2329
+ readonly HTTP_STATUS_NETWORK_AUTHENTICATION_REQUIRED: 511;
2330
+ }
2331
+ export const constants: Http2Constants;
2332
+ export function createSecureServer(options: SecureServerOptions): Http2SecureServer;
2333
+
2334
+ /* ── the REAL h2c surface (scr_http2.c: frame codec + HPACK over the
2335
+ * net loop) — createServer/connect and the session/stream handles the
2336
+ * Node suite's http2 family exercises. Headers cross as the canonical
2337
+ * header record (the IncomingHttpHeaders index-signature shape); the
2338
+ * response :status reads back as a number. Members declared here
2339
+ * without a lowering fence by name at their use sites. */
2340
+
2341
+ /** The http2 module's own header shapes: pure index-signature records
2342
+ * (the HEADER-FAMILY canonicalization — string[] arm included). */
2343
+ export interface IncomingHttpHeaders {
2344
+ [name: string]: number | string | string[] | undefined;
2345
+ }
2346
+ export interface OutgoingHttpHeaders {
2347
+ [name: string]: number | string | string[] | undefined;
2348
+ }
2349
+
2350
+ export interface Http2Session {
2351
+ close(callback?: () => void): void;
2352
+ destroy(): void;
2353
+ readonly closed: boolean;
2354
+ readonly destroyed: boolean;
2355
+ readonly encrypted: boolean;
2356
+ readonly type: number;
2357
+ readonly alpnProtocol: string;
2358
+ readonly socket: import("net").Socket;
2359
+ readonly pendingSettingsAck: boolean;
2360
+ ref(): void;
2361
+ unref(): void;
2362
+ setTimeout(msecs: number, callback?: () => void): void;
2363
+ ping(callback: (err: Error | null, duration: number, payload: Uint8Array) => void): boolean;
2364
+ /* The settings surface rides the checked-dynamic machinery (records
2365
+ * cross as DOM values — the suite's mustCall listeners are dyn). */
2366
+ settings(settings?: any, callback?: any): void;
2367
+ readonly localSettings: any;
2368
+ readonly remoteSettings: any;
2369
+ goaway(code?: number, lastStreamID?: number, opaqueData?: Uint8Array): void;
2370
+ on(event: "close" | "timeout", listener: () => void): void;
2371
+ on(event: "error", listener: (err: Error) => void): void;
2372
+ on(event: "connect", listener: (session: Http2Session, socket: import("net").Socket) => void): void;
2373
+ on(event: "stream", listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void): void;
2374
+ on(event: "goaway", listener: (errorCode: number, lastStreamID: number, opaqueData?: Uint8Array) => void): void;
2375
+ on(event: "localSettings" | "remoteSettings", listener: (settings: any) => void): void;
2376
+ on(event: "frameError", listener: (type: number, code: number, id: number) => void): void;
2377
+ on(event: "ping", listener: (payload: Uint8Array) => void): void;
2378
+ once(event: "close" | "timeout", listener: () => void): void;
2379
+ once(event: "error", listener: (err: Error) => void): void;
2380
+ once(event: "connect", listener: (session: Http2Session, socket: import("net").Socket) => void): void;
2381
+ once(event: "stream", listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void): void;
2382
+ once(event: "goaway", listener: (errorCode: number, lastStreamID: number, opaqueData?: Uint8Array) => void): void;
2383
+ once(event: "localSettings" | "remoteSettings", listener: (settings: any) => void): void;
2384
+ }
2385
+
2386
+ export interface ClientHttp2Session extends Http2Session {
2387
+ request(headers?: OutgoingHttpHeaders, options?: { endStream?: boolean; exclusive?: boolean; parent?: number; weight?: number; waitForTrailers?: boolean }): ClientHttp2Stream;
2388
+ }
2389
+
2390
+ export interface ServerHttp2Session extends Http2Session {
2391
+ altsvc(alt: string, originOrStream: number | string): void;
2392
+ origin(...origins: string[]): void;
2393
+ }
2394
+
2395
+ /** The shared Http2Stream core (both roles). 'data' chunks are Buffers
2396
+ * (strings once setEncoding('utf8') is in force — the IncomingMessage
2397
+ * chunk:any stance keeps both working). */
2398
+ interface Http2StreamCore {
2399
+ readonly id: number | undefined;
2400
+ readonly rstCode: number;
2401
+ readonly closed: boolean;
2402
+ readonly destroyed: boolean;
2403
+ readonly pending: boolean;
2404
+ readonly aborted: boolean;
2405
+ readonly session: Http2Session;
2406
+ readonly sentHeaders: OutgoingHttpHeaders;
2407
+ readonly state: Record<string, number>;
2408
+ write(chunk: string | Uint8Array, callback?: (err?: Error | null) => void): boolean;
2409
+ end(data?: string | Uint8Array, callback?: () => void): void;
2410
+ end(callback: () => void): void;
2411
+ close(code?: number, callback?: () => void): void;
2412
+ destroy(error?: Error): void;
2413
+ setEncoding(encoding: string): this;
2414
+ resume(): void;
2415
+ pause(): void;
2416
+ setTimeout(msecs: number, callback?: () => void): void;
2417
+ priority(options: Record<string, number | boolean>): void;
2418
+ sendTrailers(headers: OutgoingHttpHeaders): void;
2419
+ }
2420
+
2421
+ export interface ServerHttp2Stream extends Http2StreamCore {
2422
+ on(event: "data", listener: (chunk: any) => void): void;
2423
+ on(event: "end" | "close" | "aborted" | "ready" | "timeout" | "drain" | "finish" | "wantTrailers", listener: () => void): void;
2424
+ on(event: "error", listener: (err: Error) => void): void;
2425
+ on(event: "frameError", listener: (type: number, code: number, id: number) => void): void;
2426
+ on(event: "trailers", listener: (trailers: IncomingHttpHeaders, flags: number) => void): void;
2427
+ once(event: "data", listener: (chunk: any) => void): void;
2428
+ once(event: "end" | "close" | "aborted" | "ready" | "timeout" | "drain" | "finish" | "wantTrailers", listener: () => void): void;
2429
+ once(event: "error", listener: (err: Error) => void): void;
2430
+ once(event: "trailers", listener: (trailers: IncomingHttpHeaders, flags: number) => void): void;
2431
+ respond(headers?: OutgoingHttpHeaders, options?: { endStream?: boolean; waitForTrailers?: boolean }): void;
2432
+ respondWithFile(path: string, headers?: OutgoingHttpHeaders, options?: Record<string, unknown>): void;
2433
+ respondWithFD(fd: number, headers?: OutgoingHttpHeaders, options?: Record<string, unknown>): void;
2434
+ pushStream(headers: OutgoingHttpHeaders, callback: (err: Error | null, pushStream: ServerHttp2Stream, headers: OutgoingHttpHeaders) => void): void;
2435
+ readonly headersSent: boolean;
2436
+ readonly pushAllowed: boolean;
2437
+ additionalHeaders(headers: OutgoingHttpHeaders): void;
2438
+ }
2439
+
2440
+ export interface ClientHttp2Stream extends Http2StreamCore {
2441
+ on(event: "response", listener: (headers: IncomingHttpHeaders, flags: number) => void): void;
2442
+ on(event: "push", listener: (headers: IncomingHttpHeaders, flags: number) => void): void;
2443
+ on(event: "headers", listener: (headers: IncomingHttpHeaders, flags: number) => void): void;
2444
+ on(event: "data", listener: (chunk: any) => void): void;
2445
+ on(event: "end" | "close" | "aborted" | "ready" | "timeout" | "drain" | "finish" | "wantTrailers", listener: () => void): void;
2446
+ on(event: "error", listener: (err: Error) => void): void;
2447
+ on(event: "frameError", listener: (type: number, code: number, id: number) => void): void;
2448
+ on(event: "trailers", listener: (trailers: IncomingHttpHeaders, flags: number) => void): void;
2449
+ once(event: "response", listener: (headers: IncomingHttpHeaders, flags: number) => void): void;
2450
+ once(event: "push", listener: (headers: IncomingHttpHeaders, flags: number) => void): void;
2451
+ once(event: "data", listener: (chunk: any) => void): void;
2452
+ once(event: "end" | "close" | "aborted" | "ready" | "timeout" | "drain" | "finish" | "wantTrailers", listener: () => void): void;
2453
+ once(event: "error", listener: (err: Error) => void): void;
2454
+ }
2455
+
2456
+ export interface Http2Server {
2457
+ listen(port?: number, callback?: () => void): void;
2458
+ listen(port: number, host: string, callback?: () => void): void;
2459
+ close(callback?: () => void): void;
2460
+ address(): import("node:dgram").AddressInfo;
2461
+ setTimeout(msecs?: number, callback?: () => void): void;
2462
+ ref(): void;
2463
+ unref(): void;
2464
+ on(event: "stream", listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void): void;
2465
+ on(event: "session", listener: (session: ServerHttp2Session) => void): void;
2466
+ on(event: "request", listener: (req: Http2ServerRequest, res: Http2ServerResponse) => void): void;
2467
+ on(event: "error", listener: (err: Error) => void): void;
2468
+ on(event: "close" | "listening" | "timeout", listener: () => void): void;
2469
+ on(event: "connection", listener: (socket: import("net").Socket) => void): void;
2470
+ on(event: "sessionError", listener: (err: Error, session: ServerHttp2Session) => void): void;
2471
+ once(event: "stream", listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void): void;
2472
+ once(event: "session", listener: (session: ServerHttp2Session) => void): void;
2473
+ once(event: "request", listener: (req: Http2ServerRequest, res: Http2ServerResponse) => void): void;
2474
+ once(event: "error", listener: (err: Error) => void): void;
2475
+ once(event: "close" | "listening" | "timeout", listener: () => void): void;
2476
+ }
2477
+
2478
+ export interface ServerOptions {
2479
+ [option: string]: unknown;
2480
+ }
2481
+
2482
+ export function createServer(onRequestHandler?: (req: Http2ServerRequest, res: Http2ServerResponse) => void): Http2Server;
2483
+ export function createServer(options: ServerOptions, onRequestHandler?: (req: Http2ServerRequest, res: Http2ServerResponse) => void): Http2Server;
2484
+
2485
+ export function connect(authority: string, listener?: (session: ClientHttp2Session, socket: import("net").Socket) => void): ClientHttp2Session;
2486
+ export function connect(authority: string, options: Record<string, unknown>, listener?: (session: ClientHttp2Session, socket: import("net").Socket) => void): ClientHttp2Session;
2487
+
2488
+ export function getDefaultSettings(): any;
2489
+ export function getPackedSettings(settings: Record<string, number | boolean>): Uint8Array;
2490
+ export const sensitiveHeaders: unique symbol;
2491
+ }
2492
+ declare module "node:http2" {
2493
+ export * from "http2";
2494
+ }
2495
+
2496
+ /* node:dgram — UDP sockets over the event loop (scr_dgram.c, linked only
2497
+ * into using binaries). createSocket takes "udp4" or the
2498
+ * { type: "udp4", reuseAddr? } literal; bind/connect bind NOW and defer
2499
+ * 'listening'/'connect' to the next loop turn; send takes one string or
2500
+ * Buffer datagram with an explicit port + address (the connected-send
2501
+ * and callback forms have no lowering); address() returns the real
2502
+ * {address, family, port} record and THROWS "Not running" before bind,
2503
+ * like Node. 'error' with no listener exits 1 (the unhandled
2504
+ * EventEmitter 'error' behavior). Multicast has no lowering. */
2505
+ declare module "dgram" {
2506
+ export interface AddressInfo {
2507
+ address: string;
2508
+ family: string;
2509
+ port: number;
2510
+ }
2511
+ export interface RemoteInfo {
2512
+ address: string;
2513
+ family: string;
2514
+ port: number;
2515
+ size: number;
2516
+ }
2517
+ export interface Socket {
2518
+ bind(port: number, address?: string, callback?: () => void): void;
2519
+ connect(port: number, address?: string, callback?: () => void): void;
2520
+ send(msg: string | Uint8Array, port: number, address: string): void;
2521
+ address(): AddressInfo;
2522
+ close(callback?: () => void): void;
2523
+ unref(): void;
2524
+ ref(): void;
2525
+ on(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): void;
2526
+ on(event: "listening" | "close" | "connect", listener: () => void): void;
2527
+ on(event: "error", listener: (err: Error) => void): void;
2528
+ once(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): void;
2529
+ once(event: "listening" | "close" | "connect", listener: () => void): void;
2530
+ once(event: "error", listener: (err: Error) => void): void;
2531
+ }
2532
+ export function createSocket(type: "udp4"): Socket;
2533
+ export function createSocket(options: { type: "udp4"; reuseAddr?: boolean }): Socket;
2534
+ }
2535
+ declare module "node:dgram" {
2536
+ export * from "dgram";
2537
+ }
2538
+
2539
+ /* node:dns — the lookup slice (scr_dgram.c hosts it; getaddrinfo runs AT
2540
+ * CALL TIME and the callback defers to the next loop turn — SEMANTICS.md
2541
+ * documents the blocking divergence). Only the { family: 4 } options
2542
+ * form lowers; failures deliver Node's error shape ("getaddrinfo
2543
+ * ENOTFOUND <hostname>") as the callback's Error argument, with "" for
2544
+ * the address where Node passes undefined. */
2545
+ declare module "dns" {
2546
+ export function lookup(
2547
+ hostname: string,
2548
+ /* The options-record stance (see http.RequestOptions): family is the
2549
+ * lowered option ({ family: 4 }); hints/all/order/verbatim fence by
2550
+ * name; undocumented keys drop like Node. */
2551
+ options: { family: number; [option: string]: unknown },
2552
+ callback: (err: Error | null, address: string, family: number) => void,
2553
+ ): void;
2554
+ }
2555
+ declare module "node:dns" {
2556
+ export * from "dns";
2557
+ }
2558
+
2559
+ /* node:worker_threads — the MAIN-THREAD slice only. A compiled binary is
2560
+ * always the main thread (no JS-engine thread machinery exists), so
2561
+ * isMainThread lowers to `true` and threadId to 0 — Node's main-thread
2562
+ * answers exactly. Worker itself is declared surface without a lowering:
2563
+ * constructing one fences at the site; the CLASS as a value participates
2564
+ * in identity-only flows. */
2565
+ declare module "worker_threads" {
2566
+ export const isMainThread: boolean;
2567
+ export const threadId: number;
2568
+ export class Worker {
2569
+ constructor(filename: string | URL, options?: unknown);
2570
+ on(event: string, listener: (...args: unknown[]) => void): void;
2571
+ postMessage(value: unknown): void;
2572
+ terminate(): Promise<number>;
2573
+ }
2574
+ export const parentPort: unknown;
2575
+ export const workerData: unknown;
2576
+ }
2577
+ declare module "node:worker_threads" {
2578
+ export * from "worker_threads";
2579
+ }
2580
+
2581
+ /* node:buffer — the module spelling of the Buffer/atob/btoa globals.
2582
+ * Buffer re-exports the GLOBAL declaration, so an imported binding
2583
+ * resolves to the same symbol the lowerings already answer for (and
2584
+ * third-party .d.ts files that `import { Buffer } from "node:buffer"` —
2585
+ * file-entry-cache in prettier's source graph — typecheck). */
2586
+ declare module "buffer" {
2587
+ export function atob(data: string): string;
2588
+ export function btoa(data: string): string;
2589
+ export const kMaxLength: number;
2590
+ export const kStringMaxLength: number;
2591
+ export const Buffer: BufferConstructor;
2592
+ }
2593
+ declare module "node:buffer" {
2594
+ export * from "buffer";
2595
+ }
2596
+
2597
+ /* node:cluster — the primary-probe slice. A compiled binary never runs
2598
+ * as a cluster worker (cluster forks the node binary itself — the
2599
+ * mechanism is na for compiled programs), so isPrimary lowers to `true`
2600
+ * and isWorker to `false`; everything else is undeclared. */
2601
+ declare module "cluster" {
2602
+ const cluster: {
2603
+ readonly isPrimary: boolean;
2604
+ readonly isMaster: boolean;
2605
+ readonly isWorker: boolean;
2606
+ };
2607
+ export = cluster;
2608
+ }
2609
+ declare module "node:cluster" {
2610
+ import cluster = require("cluster");
2611
+ export = cluster;
2612
+ }
2613
+
2614
+ /* node:tty — the fd probe (the same isatty(3) behind process.*.isTTY). */
2615
+ declare module "tty" {
2616
+ export function isatty(fd: number): boolean;
2617
+ }
2618
+ declare module "node:tty" {
2619
+ export * from "tty";
2620
+ }
2621
+
2622
+ /* node:async_hooks — declared surface without lowering: async-hook
2623
+ * instrumentation is guarded behind env flags in harness code; a reached
2624
+ * use fences at its site. */
2625
+ declare module "async_hooks" {
2626
+ /* AsyncLocalStorage: fiber-carried context snapshots — run/getStore/
2627
+ * exit/enterWith/disable lower onto the runtime's active-slot machinery
2628
+ * (als.* libCalls); values cross as DOM values. */
2629
+ export class AsyncLocalStorage<T = any> {
2630
+ constructor();
2631
+ run<R>(store: T, callback: (...args: any[]) => R, ...args: any[]): R;
2632
+ exit<R>(callback: (...args: any[]) => R, ...args: any[]): R;
2633
+ getStore(): T | undefined;
2634
+ enterWith(store: T): void;
2635
+ disable(): void;
2636
+ }
2637
+ export interface AsyncHook {
2638
+ enable(): AsyncHook;
2639
+ disable(): AsyncHook;
2640
+ }
2641
+ export function createHook(callbacks: {
2642
+ init?: (asyncId: number, type: string, triggerAsyncId: number, resource: unknown) => void;
2643
+ before?: (asyncId: number) => void;
2644
+ after?: (asyncId: number) => void;
2645
+ destroy?: (asyncId: number) => void;
2646
+ }): AsyncHook;
2647
+ export function executionAsyncId(): number;
2648
+ export function triggerAsyncId(): number;
2649
+ }
2650
+ declare module "node:async_hooks" {
2651
+ export * from "async_hooks";
2652
+ }
2653
+ /* node:events — the EventEmitter class (the module object IS the class,
2654
+ * like Node's `module.exports = EventEmitter`). Listener/emit signatures
2655
+ * mirror @types/node's untyped `...args: any[]` surface; the compiler's
2656
+ * lowering unifies each event name's argument tuple program-wide and
2657
+ * checks annotated listener parameters against it (unannotated non-empty
2658
+ * parameter lists have no static types and fence at the registration). */
2659
+ declare module "events" {
2660
+ class EventEmitter {
2661
+ constructor();
2662
+ static defaultMaxListeners: number;
2663
+ on(eventName: string, listener: (...args: any[]) => void): this;
2664
+ addListener(eventName: string, listener: (...args: any[]) => void): this;
2665
+ once(eventName: string, listener: (...args: any[]) => void): this;
2666
+ prependListener(eventName: string, listener: (...args: any[]) => void): this;
2667
+ prependOnceListener(eventName: string, listener: (...args: any[]) => void): this;
2668
+ off(eventName: string, listener: (...args: any[]) => void): this;
2669
+ removeListener(eventName: string, listener: (...args: any[]) => void): this;
2670
+ removeAllListeners(eventName?: string): this;
2671
+ emit(eventName: string, ...args: any[]): boolean;
2672
+ listenerCount(eventName: string, listener?: (...args: any[]) => void): number;
2673
+ /* Declared as zero-parameter closures so the RESULT is statically
2674
+ * consumable (.length, indexing, identity): the lowering only admits
2675
+ * these calls for events whose argument tuple is empty — a listener
2676
+ * pulled from the array is then safely callable too. Events with
2677
+ * arguments fence (their element type would lie). */
2678
+ listeners(eventName: string): Array<() => void>;
2679
+ rawListeners(eventName: string): Array<() => void>;
2680
+ eventNames(): string[];
2681
+ setMaxListeners(n: number): this;
2682
+ getMaxListeners(): number;
2683
+ }
2684
+ import internal = require("node:events");
2685
+ namespace EventEmitter {
2686
+ // The class under its own name, so `import { EventEmitter }` resolves
2687
+ // (the @types/node namespace-alias pattern).
2688
+ export { internal as EventEmitter };
2689
+ export function once(emitter: EventEmitter, eventName: string): Promise<any[]>;
2690
+ }
2691
+ export = EventEmitter;
2692
+ }
2693
+ declare module "node:events" {
2694
+ import events = require("events");
2695
+ export = events;
2696
+ }
2697
+
2698
+ /* node:stream — the static stream classes (runtime-provided, the
2699
+ * EventEmitter-hierarchy precedent). Phase 1 is the OPTIONS-OBJECT
2700
+ * constructor surface: `new Readable({ read() {} })`, `new Writable({
2701
+ * write(chunk, enc, cb) {} })`, Duplex/Transform/PassThrough, push/read,
2702
+ * flowing vs paused, write/end backpressure + 'drain', pipe/unpipe, and
2703
+ * destroy — with Node's event orderings. Chunks are BYTES (Buffer), with
2704
+ * utf8 strings converted at push/write like Node; objectMode and
2705
+ * setEncoding are declared so uses fence at their sites with their own
2706
+ * words. `class My extends Readable` (the _read override form) is a
2707
+ * separate feature and fences at the class declaration. The runtime-fired
2708
+ * events carry per-class FORCED argument tuples ('data' is one Buffer,
2709
+ * 'error' one Error, 'pipe'/'unpipe' one Readable, the rest empty) — the
2710
+ * overloads below hand tsc the same contract so unannotated listener
2711
+ * parameters contextually type in .js sources. */
2712
+ declare module "stream" {
2713
+ import { EventEmitter } from "events";
2714
+
2715
+ interface ReadableOptions {
2716
+ highWaterMark?: number;
2717
+ encoding?: string;
2718
+ objectMode?: boolean;
2719
+ read?(this: Readable, size: number): void;
2720
+ destroy?(this: Readable, error: Error | null, callback: (error?: Error | null) => void): void;
2721
+ construct?(this: Readable, callback: (error?: Error | null) => void): void;
2722
+ autoDestroy?: boolean;
2723
+ emitClose?: boolean;
2724
+ captureRejections?: boolean;
2725
+ defaultEncoding?: string;
2726
+ signal?: unknown;
2727
+ }
2728
+ interface WritableOptions {
2729
+ highWaterMark?: number;
2730
+ decodeStrings?: boolean;
2731
+ defaultEncoding?: string;
2732
+ objectMode?: boolean;
2733
+ write?(this: Writable, chunk: Buffer, encoding: string, callback: (error?: Error | null) => void): void;
2734
+ writev?(this: Writable, chunks: unknown[], callback: (error?: Error | null) => void): void;
2735
+ final?(this: Writable, callback: (error?: Error | null) => void): void;
2736
+ destroy?(this: Writable, error: Error | null, callback: (error?: Error | null) => void): void;
2737
+ construct?(this: Writable, callback: (error?: Error | null) => void): void;
2738
+ autoDestroy?: boolean;
2739
+ emitClose?: boolean;
2740
+ captureRejections?: boolean;
2741
+ signal?: unknown;
2742
+ }
2743
+ interface DuplexOptions {
2744
+ highWaterMark?: number;
2745
+ readableHighWaterMark?: number;
2746
+ writableHighWaterMark?: number;
2747
+ encoding?: string;
2748
+ decodeStrings?: boolean;
2749
+ objectMode?: boolean;
2750
+ readableObjectMode?: boolean;
2751
+ writableObjectMode?: boolean;
2752
+ allowHalfOpen?: boolean;
2753
+ read?(this: Duplex, size: number): void;
2754
+ write?(this: Duplex, chunk: Buffer, encoding: string, callback: (error?: Error | null) => void): void;
2755
+ final?(this: Duplex, callback: (error?: Error | null) => void): void;
2756
+ destroy?(this: Duplex, error: Error | null, callback: (error?: Error | null) => void): void;
2757
+ construct?(this: Duplex, callback: (error?: Error | null) => void): void;
2758
+ autoDestroy?: boolean;
2759
+ emitClose?: boolean;
2760
+ captureRejections?: boolean;
2761
+ readable?: boolean;
2762
+ writable?: boolean;
2763
+ defaultEncoding?: string;
2764
+ writev?(this: Duplex, chunks: unknown[], callback: (error?: Error | null) => void): void;
2765
+ signal?: unknown;
2766
+ }
2767
+ interface TransformOptions {
2768
+ highWaterMark?: number;
2769
+ readableHighWaterMark?: number;
2770
+ writableHighWaterMark?: number;
2771
+ encoding?: string;
2772
+ decodeStrings?: boolean;
2773
+ objectMode?: boolean;
2774
+ readableObjectMode?: boolean;
2775
+ writableObjectMode?: boolean;
2776
+ allowHalfOpen?: boolean;
2777
+ transform?(this: Transform, chunk: Buffer, encoding: string, callback: (error?: Error | null, data?: Buffer | string) => void): void;
2778
+ flush?(this: Transform, callback: (error?: Error | null, data?: Buffer | string) => void): void;
2779
+ destroy?(this: Transform, error: Error | null, callback: (error?: Error | null) => void): void;
2780
+ construct?(this: Transform, callback: (error?: Error | null) => void): void;
2781
+ read?(this: Transform, size: number): void;
2782
+ write?(this: Transform, chunk: Buffer, encoding: string, callback: (error?: Error | null) => void): void;
2783
+ final?(this: Transform, callback: (error?: Error | null) => void): void;
2784
+ writev?(this: Transform, chunks: unknown[], callback: (error?: Error | null) => void): void;
2785
+ autoDestroy?: boolean;
2786
+ emitClose?: boolean;
2787
+ captureRejections?: boolean;
2788
+ readable?: boolean;
2789
+ writable?: boolean;
2790
+ defaultEncoding?: string;
2791
+ signal?: unknown;
2792
+ }
2793
+
2794
+ class Readable extends EventEmitter {
2795
+ constructor(opts?: ReadableOptions);
2796
+ /* The underscore-method surface (@types/node declares these on the
2797
+ * classes; assigning them post-construction shadows the prototype
2798
+ * method and the machinery calls through the assignment — lowered
2799
+ * onto the option-callback slots). */
2800
+ _read(size: number): void;
2801
+ _destroy(error: Error | null, callback: (error?: Error | null) => void): void;
2802
+ [Symbol.asyncIterator](): AsyncIterableIterator<any>;
2803
+ push(chunk: Buffer | string | null, encoding?: string): boolean;
2804
+ unshift(chunk: Buffer | string, encoding?: string): void;
2805
+ read(size?: number): Buffer | null;
2806
+ pause(): this;
2807
+ resume(): this;
2808
+ isPaused(): boolean;
2809
+ setEncoding(encoding: string): this;
2810
+ pipe<T extends Writable>(destination: T, options?: { end?: boolean }): T;
2811
+ unpipe(destination?: Writable): this;
2812
+ destroy(error?: Error): this;
2813
+ readonly readable: boolean;
2814
+ readonly readableEnded: boolean;
2815
+ readonly readableFlowing: boolean | null;
2816
+ readonly readableLength: number;
2817
+ readonly readableHighWaterMark: number;
2818
+ readonly readableObjectMode: boolean;
2819
+ readonly closed: boolean;
2820
+ readonly destroyed: boolean;
2821
+ readonly errored: Error | null;
2822
+ static from(iterable: unknown, options?: ReadableOptions): Readable;
2823
+ on(event: "data", listener: (chunk: any) => void): this;
2824
+ on(event: "end" | "close" | "readable" | "pause" | "resume", listener: () => void): this;
2825
+ on(event: "error", listener: (err: Error) => void): this;
2826
+ on(event: string, listener: (...args: any[]) => void): this;
2827
+ once(event: "data", listener: (chunk: any) => void): this;
2828
+ once(event: "end" | "close" | "readable" | "pause" | "resume", listener: () => void): this;
2829
+ once(event: "error", listener: (err: Error) => void): this;
2830
+ once(event: string, listener: (...args: any[]) => void): this;
2831
+ addListener(event: "data", listener: (chunk: any) => void): this;
2832
+ addListener(event: "end" | "close" | "readable" | "pause" | "resume", listener: () => void): this;
2833
+ addListener(event: "error", listener: (err: Error) => void): this;
2834
+ addListener(event: string, listener: (...args: any[]) => void): this;
2835
+ prependListener(event: "data", listener: (chunk: any) => void): this;
2836
+ prependListener(event: "end" | "close" | "readable" | "pause" | "resume", listener: () => void): this;
2837
+ prependListener(event: "error", listener: (err: Error) => void): this;
2838
+ prependListener(event: string, listener: (...args: any[]) => void): this;
2839
+ prependOnceListener(event: "data", listener: (chunk: any) => void): this;
2840
+ prependOnceListener(event: "end" | "close" | "readable" | "pause" | "resume", listener: () => void): this;
2841
+ prependOnceListener(event: "error", listener: (err: Error) => void): this;
2842
+ prependOnceListener(event: string, listener: (...args: any[]) => void): this;
2843
+ off(event: "data", listener: (chunk: any) => void): this;
2844
+ off(event: "end" | "close" | "readable" | "pause" | "resume", listener: () => void): this;
2845
+ off(event: "error", listener: (err: Error) => void): this;
2846
+ off(event: string, listener: (...args: any[]) => void): this;
2847
+ removeListener(event: "data", listener: (chunk: any) => void): this;
2848
+ removeListener(event: "end" | "close" | "readable" | "pause" | "resume", listener: () => void): this;
2849
+ removeListener(event: "error", listener: (err: Error) => void): this;
2850
+ removeListener(event: string, listener: (...args: any[]) => void): this;
2851
+ }
2852
+
2853
+ class Writable extends EventEmitter {
2854
+ constructor(opts?: WritableOptions);
2855
+ /* The underscore-method surface (see Readable). */
2856
+ _write(chunk: any, encoding: string, callback: (error?: Error | null) => void): void;
2857
+ _writev(chunks: Array<{ chunk: any; encoding: string }>, callback: (error?: Error | null) => void): void;
2858
+ _final(callback: (error?: Error | null) => void): void;
2859
+ _destroy(error: Error | null, callback: (error?: Error | null) => void): void;
2860
+ write(chunk: Buffer | string, callback?: (error?: Error | null) => void): boolean;
2861
+ write(chunk: Buffer | string, encoding: string, callback?: (error?: Error | null) => void): boolean;
2862
+ end(callback?: () => void): this;
2863
+ end(chunk: Buffer | string, callback?: () => void): this;
2864
+ end(chunk: Buffer | string, encoding: string, callback?: () => void): this;
2865
+ cork(): void;
2866
+ uncork(): void;
2867
+ setDefaultEncoding(encoding: string): this;
2868
+ destroy(error?: Error): this;
2869
+ readonly writable: boolean;
2870
+ readonly writableEnded: boolean;
2871
+ readonly writableFinished: boolean;
2872
+ readonly writableLength: number;
2873
+ readonly writableHighWaterMark: number;
2874
+ readonly writableObjectMode: boolean;
2875
+ readonly writableNeedDrain: boolean;
2876
+ readonly writableCorked: number;
2877
+ readonly closed: boolean;
2878
+ readonly destroyed: boolean;
2879
+ readonly errored: Error | null;
2880
+ on(event: "drain" | "finish" | "close", listener: () => void): this;
2881
+ on(event: "error", listener: (err: Error) => void): this;
2882
+ on(event: "pipe" | "unpipe", listener: (src: Readable) => void): this;
2883
+ on(event: string, listener: (...args: any[]) => void): this;
2884
+ once(event: "drain" | "finish" | "close", listener: () => void): this;
2885
+ once(event: "error", listener: (err: Error) => void): this;
2886
+ once(event: "pipe" | "unpipe", listener: (src: Readable) => void): this;
2887
+ once(event: string, listener: (...args: any[]) => void): this;
2888
+ addListener(event: "drain" | "finish" | "close", listener: () => void): this;
2889
+ addListener(event: "error", listener: (err: Error) => void): this;
2890
+ addListener(event: "pipe" | "unpipe", listener: (src: Readable) => void): this;
2891
+ addListener(event: string, listener: (...args: any[]) => void): this;
2892
+ prependListener(event: "drain" | "finish" | "close", listener: () => void): this;
2893
+ prependListener(event: "error", listener: (err: Error) => void): this;
2894
+ prependListener(event: "pipe" | "unpipe", listener: (src: Readable) => void): this;
2895
+ prependListener(event: string, listener: (...args: any[]) => void): this;
2896
+ prependOnceListener(event: "drain" | "finish" | "close", listener: () => void): this;
2897
+ prependOnceListener(event: "error", listener: (err: Error) => void): this;
2898
+ prependOnceListener(event: "pipe" | "unpipe", listener: (src: Readable) => void): this;
2899
+ prependOnceListener(event: string, listener: (...args: any[]) => void): this;
2900
+ off(event: "drain" | "finish" | "close", listener: () => void): this;
2901
+ off(event: "error", listener: (err: Error) => void): this;
2902
+ off(event: "pipe" | "unpipe", listener: (src: Readable) => void): this;
2903
+ off(event: string, listener: (...args: any[]) => void): this;
2904
+ removeListener(event: "drain" | "finish" | "close", listener: () => void): this;
2905
+ removeListener(event: "error", listener: (err: Error) => void): this;
2906
+ removeListener(event: "pipe" | "unpipe", listener: (src: Readable) => void): this;
2907
+ removeListener(event: string, listener: (...args: any[]) => void): this;
2908
+ }
2909
+
2910
+ /* Duplex is Readable + Writable in one object. TS single inheritance
2911
+ * mirrors @types/node: extends Readable, the writable half declared
2912
+ * again. The lowering treats both halves as first-class. */
2913
+ class Duplex extends Readable {
2914
+ constructor(opts?: DuplexOptions);
2915
+ /* The underscore-method surface (see Readable). */
2916
+ _write(chunk: any, encoding: string, callback: (error?: Error | null) => void): void;
2917
+ _writev(chunks: Array<{ chunk: any; encoding: string }>, callback: (error?: Error | null) => void): void;
2918
+ _final(callback: (error?: Error | null) => void): void;
2919
+ write(chunk: Buffer | string, callback?: (error?: Error | null) => void): boolean;
2920
+ write(chunk: Buffer | string, encoding: string, callback?: (error?: Error | null) => void): boolean;
2921
+ end(callback?: () => void): this;
2922
+ end(chunk: Buffer | string, callback?: () => void): this;
2923
+ end(chunk: Buffer | string, encoding: string, callback?: () => void): this;
2924
+ cork(): void;
2925
+ uncork(): void;
2926
+ setDefaultEncoding(encoding: string): this;
2927
+ readonly writable: boolean;
2928
+ readonly writableEnded: boolean;
2929
+ readonly writableFinished: boolean;
2930
+ readonly writableLength: number;
2931
+ readonly writableHighWaterMark: number;
2932
+ readonly writableObjectMode: boolean;
2933
+ readonly writableNeedDrain: boolean;
2934
+ readonly writableCorked: number;
2935
+ readonly allowHalfOpen: boolean;
2936
+ on(event: "data", listener: (chunk: any) => void): this;
2937
+ on(event: "end" | "close" | "readable" | "pause" | "resume" | "drain" | "finish", listener: () => void): this;
2938
+ on(event: "error", listener: (err: Error) => void): this;
2939
+ on(event: "pipe" | "unpipe", listener: (src: Readable) => void): this;
2940
+ on(event: string, listener: (...args: any[]) => void): this;
2941
+ once(event: "data", listener: (chunk: any) => void): this;
2942
+ once(event: "end" | "close" | "readable" | "pause" | "resume" | "drain" | "finish", listener: () => void): this;
2943
+ once(event: "error", listener: (err: Error) => void): this;
2944
+ once(event: "pipe" | "unpipe", listener: (src: Readable) => void): this;
2945
+ once(event: string, listener: (...args: any[]) => void): this;
2946
+ addListener(event: "data", listener: (chunk: any) => void): this;
2947
+ addListener(event: "end" | "close" | "readable" | "pause" | "resume" | "drain" | "finish", listener: () => void): this;
2948
+ addListener(event: "error", listener: (err: Error) => void): this;
2949
+ addListener(event: "pipe" | "unpipe", listener: (src: Readable) => void): this;
2950
+ addListener(event: string, listener: (...args: any[]) => void): this;
2951
+ prependListener(event: "data", listener: (chunk: any) => void): this;
2952
+ prependListener(event: "end" | "close" | "readable" | "pause" | "resume" | "drain" | "finish", listener: () => void): this;
2953
+ prependListener(event: "error", listener: (err: Error) => void): this;
2954
+ prependListener(event: "pipe" | "unpipe", listener: (src: Readable) => void): this;
2955
+ prependListener(event: string, listener: (...args: any[]) => void): this;
2956
+ prependOnceListener(event: "data", listener: (chunk: any) => void): this;
2957
+ prependOnceListener(event: "end" | "close" | "readable" | "pause" | "resume" | "drain" | "finish", listener: () => void): this;
2958
+ prependOnceListener(event: "error", listener: (err: Error) => void): this;
2959
+ prependOnceListener(event: "pipe" | "unpipe", listener: (src: Readable) => void): this;
2960
+ prependOnceListener(event: string, listener: (...args: any[]) => void): this;
2961
+ off(event: "data", listener: (chunk: any) => void): this;
2962
+ off(event: "end" | "close" | "readable" | "pause" | "resume" | "drain" | "finish", listener: () => void): this;
2963
+ off(event: "error", listener: (err: Error) => void): this;
2964
+ off(event: "pipe" | "unpipe", listener: (src: Readable) => void): this;
2965
+ off(event: string, listener: (...args: any[]) => void): this;
2966
+ removeListener(event: "data", listener: (chunk: any) => void): this;
2967
+ removeListener(event: "end" | "close" | "readable" | "pause" | "resume" | "drain" | "finish", listener: () => void): this;
2968
+ removeListener(event: "error", listener: (err: Error) => void): this;
2969
+ removeListener(event: "pipe" | "unpipe", listener: (src: Readable) => void): this;
2970
+ removeListener(event: string, listener: (...args: any[]) => void): this;
2971
+ }
2972
+
2973
+ class Transform extends Duplex {
2974
+ constructor(opts?: TransformOptions);
2975
+ /* The underscore-method surface (see Readable). */
2976
+ _transform(chunk: any, encoding: string, callback: (error?: Error | null, data?: Buffer | string) => void): void;
2977
+ _flush(callback: (error?: Error | null, data?: Buffer | string) => void): void;
2978
+ }
2979
+ class PassThrough extends Transform {
2980
+ constructor(opts?: TransformOptions);
2981
+ }
2982
+
2983
+ /* Declared so requires typecheck; each fences at its use site. */
2984
+ function pipeline(...streams: unknown[]): unknown;
2985
+ function finished(stream: unknown, callback: (err?: Error | null) => void): () => void;
2986
+ /* Folds to the TARGET platform's default at compile time (win32 16384,
2987
+ * else 65536 — Node's own state.js split); literal argument only. */
2988
+ function getDefaultHighWaterMark(objectMode: boolean): number;
2989
+ namespace promises {
2990
+ function pipeline(...streams: unknown[]): Promise<void>;
2991
+ function finished(stream: unknown): Promise<void>;
2992
+ }
2993
+ class Stream extends EventEmitter {}
2994
+
2995
+ export { Readable, Writable, Duplex, Transform, PassThrough, Stream, pipeline, finished, getDefaultHighWaterMark, promises };
2996
+ export type { ReadableOptions, WritableOptions, DuplexOptions, TransformOptions };
2997
+ }
2998
+ declare module "node:stream" {
2999
+ import stream = require("stream");
3000
+ export = stream;
3001
+ }