@linxiraos/pi-utils 1.0.0

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 (244) hide show
  1. package/CHANGELOG.md +449 -0
  2. package/README.md +36 -0
  3. package/dist/types/abortable.d.ts +32 -0
  4. package/dist/types/acp/connection.d.ts +118 -0
  5. package/dist/types/acp/protocol.d.ts +526 -0
  6. package/dist/types/acp/schema.d.ts +41 -0
  7. package/dist/types/acp/stream.d.ts +8 -0
  8. package/dist/types/acp/transport.d.ts +81 -0
  9. package/dist/types/acp.d.ts +6 -0
  10. package/dist/types/async.d.ts +20 -0
  11. package/dist/types/binary.d.ts +17 -0
  12. package/dist/types/browsers.d.ts +68 -0
  13. package/dist/types/chalk.d.ts +125 -0
  14. package/dist/types/cli.d.ts +134 -0
  15. package/dist/types/color.d.ts +102 -0
  16. package/dist/types/dates.d.ts +7 -0
  17. package/dist/types/dirs.d.ts +282 -0
  18. package/dist/types/docx/converter.d.ts +46 -0
  19. package/dist/types/docx/xml.d.ts +26 -0
  20. package/dist/types/docx/zip.d.ts +6 -0
  21. package/dist/types/docx.d.ts +11 -0
  22. package/dist/types/dom/core.d.ts +431 -0
  23. package/dist/types/dom/parser.d.ts +7 -0
  24. package/dist/types/dom/selector.d.ts +5 -0
  25. package/dist/types/dom.d.ts +5 -0
  26. package/dist/types/env.d.ts +124 -0
  27. package/dist/types/fetch-retry.d.ts +96 -0
  28. package/dist/types/file-lock.d.ts +23 -0
  29. package/dist/types/format.d.ts +37 -0
  30. package/dist/types/frontmatter.d.ts +46 -0
  31. package/dist/types/fs-error.d.ts +31 -0
  32. package/dist/types/glob.d.ts +28 -0
  33. package/dist/types/headers.d.ts +34 -0
  34. package/dist/types/index.d.ts +39 -0
  35. package/dist/types/json-parse.d.ts +74 -0
  36. package/dist/types/json.d.ts +14 -0
  37. package/dist/types/logger/rotating-file.d.ts +18 -0
  38. package/dist/types/logger.d.ts +96 -0
  39. package/dist/types/loop-phase.d.ts +10 -0
  40. package/dist/types/lru.d.ts +46 -0
  41. package/dist/types/marked/core.d.ts +445 -0
  42. package/dist/types/marked.d.ts +2 -0
  43. package/dist/types/mermaid-ascii.d.ts +11 -0
  44. package/dist/types/mime.d.ts +29 -0
  45. package/dist/types/module-timer.d.ts +1 -0
  46. package/dist/types/path-tree.d.ts +76 -0
  47. package/dist/types/path.d.ts +2 -0
  48. package/dist/types/peek-file.d.ts +29 -0
  49. package/dist/types/postmortem.d.ts +104 -0
  50. package/dist/types/process-name.d.ts +7 -0
  51. package/dist/types/procmgr.d.ts +74 -0
  52. package/dist/types/prompt.d.ts +18 -0
  53. package/dist/types/ptree.d.ts +110 -0
  54. package/dist/types/readability/readability.d.ts +9 -0
  55. package/dist/types/readability/readerable.d.ts +10 -0
  56. package/dist/types/readability/types.d.ts +70 -0
  57. package/dist/types/readability.d.ts +4 -0
  58. package/dist/types/ring.d.ts +93 -0
  59. package/dist/types/runtime-install.d.ts +78 -0
  60. package/dist/types/sanitize-text.d.ts +29 -0
  61. package/dist/types/snowflake.d.ts +25 -0
  62. package/dist/types/stderr-guard.d.ts +22 -0
  63. package/dist/types/stream.d.ts +67 -0
  64. package/dist/types/tab-spacing.d.ts +24 -0
  65. package/dist/types/temp.d.ts +17 -0
  66. package/dist/types/template.d.ts +62 -0
  67. package/dist/types/timing-buffer.d.ts +22 -0
  68. package/dist/types/tls-fetch.d.ts +37 -0
  69. package/dist/types/turndown/gfm.d.ts +11 -0
  70. package/dist/types/turndown/html.d.ts +5 -0
  71. package/dist/types/turndown/service.d.ts +21 -0
  72. package/dist/types/turndown/types.d.ts +70 -0
  73. package/dist/types/turndown.d.ts +4 -0
  74. package/dist/types/type-guards.d.ts +5 -0
  75. package/dist/types/vendor/mermaid-ascii/ascii/ansi.d.ts +41 -0
  76. package/dist/types/vendor/mermaid-ascii/ascii/canvas.d.ts +89 -0
  77. package/dist/types/vendor/mermaid-ascii/ascii/class-diagram.d.ts +7 -0
  78. package/dist/types/vendor/mermaid-ascii/ascii/converter.d.ts +12 -0
  79. package/dist/types/vendor/mermaid-ascii/ascii/draw.d.ts +66 -0
  80. package/dist/types/vendor/mermaid-ascii/ascii/edge-bundling.d.ts +48 -0
  81. package/dist/types/vendor/mermaid-ascii/ascii/edge-routing.d.ts +43 -0
  82. package/dist/types/vendor/mermaid-ascii/ascii/er-diagram.d.ts +7 -0
  83. package/dist/types/vendor/mermaid-ascii/ascii/grid.d.ts +56 -0
  84. package/dist/types/vendor/mermaid-ascii/ascii/index.d.ts +65 -0
  85. package/dist/types/vendor/mermaid-ascii/ascii/multiline-utils.d.ts +27 -0
  86. package/dist/types/vendor/mermaid-ascii/ascii/pathfinder.d.ts +17 -0
  87. package/dist/types/vendor/mermaid-ascii/ascii/sequence.d.ts +7 -0
  88. package/dist/types/vendor/mermaid-ascii/ascii/shapes/circle.d.ts +11 -0
  89. package/dist/types/vendor/mermaid-ascii/ascii/shapes/corners.d.ts +34 -0
  90. package/dist/types/vendor/mermaid-ascii/ascii/shapes/diamond.d.ts +11 -0
  91. package/dist/types/vendor/mermaid-ascii/ascii/shapes/hexagon.d.ts +11 -0
  92. package/dist/types/vendor/mermaid-ascii/ascii/shapes/index.d.ts +26 -0
  93. package/dist/types/vendor/mermaid-ascii/ascii/shapes/rectangle.d.ts +31 -0
  94. package/dist/types/vendor/mermaid-ascii/ascii/shapes/rounded.d.ts +11 -0
  95. package/dist/types/vendor/mermaid-ascii/ascii/shapes/special.d.ts +59 -0
  96. package/dist/types/vendor/mermaid-ascii/ascii/shapes/stadium.d.ts +17 -0
  97. package/dist/types/vendor/mermaid-ascii/ascii/shapes/state.d.ts +30 -0
  98. package/dist/types/vendor/mermaid-ascii/ascii/shapes/types.d.ts +55 -0
  99. package/dist/types/vendor/mermaid-ascii/ascii/types.d.ts +206 -0
  100. package/dist/types/vendor/mermaid-ascii/ascii/validate.d.ts +51 -0
  101. package/dist/types/vendor/mermaid-ascii/ascii/xychart.d.ts +2 -0
  102. package/dist/types/vendor/mermaid-ascii/class/parser.d.ts +6 -0
  103. package/dist/types/vendor/mermaid-ascii/class/types.d.ts +102 -0
  104. package/dist/types/vendor/mermaid-ascii/er/parser.d.ts +6 -0
  105. package/dist/types/vendor/mermaid-ascii/er/types.d.ts +76 -0
  106. package/dist/types/vendor/mermaid-ascii/index.d.ts +1 -0
  107. package/dist/types/vendor/mermaid-ascii/multiline-utils.d.ts +9 -0
  108. package/dist/types/vendor/mermaid-ascii/parser.d.ts +7 -0
  109. package/dist/types/vendor/mermaid-ascii/sequence/parser.d.ts +6 -0
  110. package/dist/types/vendor/mermaid-ascii/sequence/types.d.ts +130 -0
  111. package/dist/types/vendor/mermaid-ascii/text-metrics.d.ts +21 -0
  112. package/dist/types/vendor/mermaid-ascii/types.d.ts +114 -0
  113. package/dist/types/vendor/mermaid-ascii/xychart/colors.d.ts +25 -0
  114. package/dist/types/vendor/mermaid-ascii/xychart/parser.d.ts +6 -0
  115. package/dist/types/vendor/mermaid-ascii/xychart/types.d.ts +145 -0
  116. package/dist/types/version.d.ts +18 -0
  117. package/dist/types/vterm/buffer.d.ts +99 -0
  118. package/dist/types/vterm/terminal.d.ts +44 -0
  119. package/dist/types/vterm.d.ts +8 -0
  120. package/dist/types/which.d.ts +37 -0
  121. package/dist/types/worker-host.d.ts +51 -0
  122. package/dist/types/xml.d.ts +31 -0
  123. package/package.json +59 -0
  124. package/src/abortable.ts +109 -0
  125. package/src/acp/connection.ts +344 -0
  126. package/src/acp/protocol.ts +466 -0
  127. package/src/acp/schema.ts +160 -0
  128. package/src/acp/stream.ts +82 -0
  129. package/src/acp/transport.ts +213 -0
  130. package/src/acp.ts +6 -0
  131. package/src/async.ts +91 -0
  132. package/src/binary.ts +50 -0
  133. package/src/browsers.ts +501 -0
  134. package/src/chalk.ts +312 -0
  135. package/src/cli.ts +529 -0
  136. package/src/color.ts +302 -0
  137. package/src/dates.ts +194 -0
  138. package/src/dirs.ts +1026 -0
  139. package/src/docx/converter.ts +681 -0
  140. package/src/docx/xml.ts +166 -0
  141. package/src/docx/zip.ts +87 -0
  142. package/src/docx.ts +20 -0
  143. package/src/dom/core.ts +1254 -0
  144. package/src/dom/parser.ts +370 -0
  145. package/src/dom/selector.ts +290 -0
  146. package/src/dom.ts +33 -0
  147. package/src/env.ts +400 -0
  148. package/src/fetch-retry.ts +379 -0
  149. package/src/file-lock.ts +69 -0
  150. package/src/format.ts +113 -0
  151. package/src/frontmatter.ts +205 -0
  152. package/src/fs-error.ts +56 -0
  153. package/src/glob.ts +189 -0
  154. package/src/headers.ts +167 -0
  155. package/src/index.ts +59 -0
  156. package/src/json-parse.ts +821 -0
  157. package/src/json.ts +23 -0
  158. package/src/logger/rotating-file.ts +149 -0
  159. package/src/logger.ts +798 -0
  160. package/src/loop-phase.ts +49 -0
  161. package/src/lru.ts +185 -0
  162. package/src/marked/core.ts +1576 -0
  163. package/src/marked.ts +2 -0
  164. package/src/mermaid-ascii.ts +31 -0
  165. package/src/mime.ts +159 -0
  166. package/src/module-timer.ts +148 -0
  167. package/src/path-tree.ts +147 -0
  168. package/src/path.ts +28 -0
  169. package/src/peek-file.ts +188 -0
  170. package/src/postmortem.ts +433 -0
  171. package/src/process-name.ts +57 -0
  172. package/src/procmgr.ts +247 -0
  173. package/src/prompt.ts +545 -0
  174. package/src/ptree.ts +412 -0
  175. package/src/readability/readability.ts +533 -0
  176. package/src/readability/readerable.ts +51 -0
  177. package/src/readability/types.ts +72 -0
  178. package/src/readability.ts +11 -0
  179. package/src/ring.ts +169 -0
  180. package/src/runtime-install.ts +393 -0
  181. package/src/sanitize-text.ts +96 -0
  182. package/src/snowflake.ts +121 -0
  183. package/src/stderr-guard.ts +155 -0
  184. package/src/stream.ts +454 -0
  185. package/src/tab-spacing.ts +336 -0
  186. package/src/temp.ts +134 -0
  187. package/src/template.ts +586 -0
  188. package/src/timing-buffer.ts +47 -0
  189. package/src/tls-fetch.ts +178 -0
  190. package/src/turndown/gfm.ts +106 -0
  191. package/src/turndown/html.ts +257 -0
  192. package/src/turndown/service.ts +334 -0
  193. package/src/turndown/types.ts +81 -0
  194. package/src/turndown.ts +5 -0
  195. package/src/type-guards.ts +17 -0
  196. package/src/vendor/mermaid-ascii/NOTICE +33 -0
  197. package/src/vendor/mermaid-ascii/ascii/ansi.ts +409 -0
  198. package/src/vendor/mermaid-ascii/ascii/canvas.ts +476 -0
  199. package/src/vendor/mermaid-ascii/ascii/class-diagram.ts +699 -0
  200. package/src/vendor/mermaid-ascii/ascii/converter.ts +271 -0
  201. package/src/vendor/mermaid-ascii/ascii/draw.ts +1382 -0
  202. package/src/vendor/mermaid-ascii/ascii/edge-bundling.ts +328 -0
  203. package/src/vendor/mermaid-ascii/ascii/edge-routing.ts +297 -0
  204. package/src/vendor/mermaid-ascii/ascii/er-diagram.ts +441 -0
  205. package/src/vendor/mermaid-ascii/ascii/grid.ts +578 -0
  206. package/src/vendor/mermaid-ascii/ascii/index.ts +187 -0
  207. package/src/vendor/mermaid-ascii/ascii/multiline-utils.ts +78 -0
  208. package/src/vendor/mermaid-ascii/ascii/pathfinder.ts +277 -0
  209. package/src/vendor/mermaid-ascii/ascii/sequence.ts +460 -0
  210. package/src/vendor/mermaid-ascii/ascii/shapes/circle.ts +27 -0
  211. package/src/vendor/mermaid-ascii/ascii/shapes/corners.ts +127 -0
  212. package/src/vendor/mermaid-ascii/ascii/shapes/diamond.ts +27 -0
  213. package/src/vendor/mermaid-ascii/ascii/shapes/hexagon.ts +27 -0
  214. package/src/vendor/mermaid-ascii/ascii/shapes/index.ts +101 -0
  215. package/src/vendor/mermaid-ascii/ascii/shapes/rectangle.ts +175 -0
  216. package/src/vendor/mermaid-ascii/ascii/shapes/rounded.ts +27 -0
  217. package/src/vendor/mermaid-ascii/ascii/shapes/special.ts +296 -0
  218. package/src/vendor/mermaid-ascii/ascii/shapes/stadium.ts +114 -0
  219. package/src/vendor/mermaid-ascii/ascii/shapes/state.ts +192 -0
  220. package/src/vendor/mermaid-ascii/ascii/shapes/types.ts +73 -0
  221. package/src/vendor/mermaid-ascii/ascii/types.ts +273 -0
  222. package/src/vendor/mermaid-ascii/ascii/validate.ts +120 -0
  223. package/src/vendor/mermaid-ascii/ascii/xychart.ts +875 -0
  224. package/src/vendor/mermaid-ascii/class/parser.ts +290 -0
  225. package/src/vendor/mermaid-ascii/class/types.ts +121 -0
  226. package/src/vendor/mermaid-ascii/er/parser.ts +181 -0
  227. package/src/vendor/mermaid-ascii/er/types.ts +91 -0
  228. package/src/vendor/mermaid-ascii/index.ts +14 -0
  229. package/src/vendor/mermaid-ascii/multiline-utils.ts +30 -0
  230. package/src/vendor/mermaid-ascii/parser.ts +645 -0
  231. package/src/vendor/mermaid-ascii/sequence/parser.ts +207 -0
  232. package/src/vendor/mermaid-ascii/sequence/types.ts +146 -0
  233. package/src/vendor/mermaid-ascii/text-metrics.ts +71 -0
  234. package/src/vendor/mermaid-ascii/types.ts +164 -0
  235. package/src/vendor/mermaid-ascii/xychart/colors.ts +140 -0
  236. package/src/vendor/mermaid-ascii/xychart/parser.ts +115 -0
  237. package/src/vendor/mermaid-ascii/xychart/types.ts +150 -0
  238. package/src/version.ts +99 -0
  239. package/src/vterm/buffer.ts +218 -0
  240. package/src/vterm/terminal.ts +773 -0
  241. package/src/vterm.ts +8 -0
  242. package/src/which.ts +234 -0
  243. package/src/worker-host.ts +100 -0
  244. package/src/xml.ts +313 -0
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Cleanup and postmortem handler utilities.
3
+ *
4
+ * This module provides a system for registering and running cleanup callbacks
5
+ * in response to process exit, signals, or fatal exceptions. It is intended to
6
+ * allow reliably releasing resources or shutting down subprocesses, files, sockets, etc.
7
+ */
8
+ export declare enum Reason {
9
+ PRE_EXIT = "pre_exit",// Pre-exit phase (not used by default)
10
+ EXIT = "exit",// Normal process exit
11
+ SIGINT = "sigint",// Ctrl-C or SIGINT
12
+ SIGTERM = "sigterm",// SIGTERM
13
+ SIGHUP = "sighup",// SIGHUP
14
+ UNCAUGHT_EXCEPTION = "uncaught_exception",// Fatal exception
15
+ UNHANDLED_REJECTION = "unhandled_rejection",// Unhandled promise rejection
16
+ MANUAL = "manual"
17
+ }
18
+ /**
19
+ * Symbol stamped by the extension-load guard onto the throwing replacement it
20
+ * installs over `process.exit` / `process.reallyExit`, carrying the native
21
+ * primitive that replacement shadows.
22
+ *
23
+ * Host-owned shutdown ({@link exitProcess}) reads through it so a signal that
24
+ * lands while the guard is active still terminates the process (#6488), while
25
+ * a signal that lands after the guard has restored the native exit also
26
+ * terminates cleanly (#7393). `Symbol.for` so it survives duplicate module
27
+ * instances across bundles/realms.
28
+ */
29
+ export declare const NATIVE_PROCESS_EXIT: unique symbol;
30
+ /** User-facing command printed before fatal cleanup so interrupted work can be resumed. */
31
+ export interface FatalRecoveryHint {
32
+ /** Stable label identifying the recoverable session or process. */
33
+ label: string;
34
+ /** Complete shell command the user can execute to resume the interrupted work. */
35
+ command: string;
36
+ }
37
+ type FatalRecoveryHintProvider = () => FatalRecoveryHint | undefined;
38
+ /** Origin of an EPIPE raised by a process communication channel. */
39
+ export type BrokenPipeSource = "ipc-send" | "stdio-write";
40
+ /**
41
+ * Classify EPIPE errors from worker IPC and stdio without treating unrelated
42
+ * broken pipes as globally recoverable.
43
+ */
44
+ export declare function classifyBrokenPipe(err: Error): BrokenPipeSource | undefined;
45
+ /** Whether an EPIPE came from an IPC `send()` to an optional worker. */
46
+ export declare function isIpcSendEpipe(err: Error): boolean;
47
+ /**
48
+ * Treat unhandled stdout EPIPE rejections as a graceful peer disconnect.
49
+ *
50
+ * Stdio protocol servers call this for their process lifetime so a closed
51
+ * client pipe runs registered cleanup callbacks instead of the fatal path.
52
+ * The returned callback removes the registration.
53
+ */
54
+ export declare function registerStdioDisconnectHandling(): () => void;
55
+ /**
56
+ * Mark an error as expected cleanup fallout so the global fatal handlers
57
+ * downgrade it to a log line instead of tearing down the process. Use for
58
+ * abort reasons fired by routine resource teardown (browser run end, tab
59
+ * close) whose rejections may surface on fire-and-forget promises with no
60
+ * consumer. Returns the same error for inline use at the `abort()` callsite.
61
+ */
62
+ export declare function markExpectedCleanupError<T extends object>(reason: T): T;
63
+ /**
64
+ * Whether `reason` (or any error in its `cause` chain) was marked via
65
+ * {@link markExpectedCleanupError}. Walks the chain because the unhandled
66
+ * reason is often a wrapper (`AbortError`) with the marked abort reason as
67
+ * its `cause`.
68
+ */
69
+ export declare function isExpectedCleanupError(reason: unknown): boolean;
70
+ /**
71
+ * Register an interceptor consulted before an unhandled rejection tears the
72
+ * process down. A consuming interceptor owns reporting and keeps the process alive.
73
+ */
74
+ export declare function interceptUnhandledRejections(interceptor: (reason: unknown) => boolean): () => void;
75
+ /**
76
+ * Register a synchronous recovery command to print when the process exits
77
+ * through an uncaught exception or unhandled rejection.
78
+ */
79
+ export declare function registerFatalRecoveryHint(provider: FatalRecoveryHintProvider): () => void;
80
+ /**
81
+ * Register a process cleanup callback, to be run on shutdown, signal, or fatal error.
82
+ *
83
+ * Returns a Callback instance that can be used to cancel (unregister) or manually clean up.
84
+ * If register is called after cleanup already began, invokes callback on a microtask.
85
+ */
86
+ export declare function register(id: string, callback: (reason: Reason) => void | Promise<void>): () => void;
87
+ /**
88
+ * Runs all cleanup callbacks without exiting.
89
+ * Use this in workers or when you need to clean up but continue execution.
90
+ */
91
+ export declare function cleanup(): Promise<void>;
92
+ /** Controls how manual process shutdown handles terminal output. */
93
+ export interface QuitOptions {
94
+ /** Wait for buffered stdout before exiting; disable after the terminal has disconnected. */
95
+ drainStdout?: boolean;
96
+ }
97
+ /**
98
+ * Runs all cleanup callbacks and exits through the current `process.exit`.
99
+ *
100
+ * In main thread: waits for stdout drain unless disabled, then calls `process.exit()`.
101
+ * In workers: runs cleanup only (process.exit would kill entire process).
102
+ */
103
+ export declare function quit(code?: number, options?: QuitOptions): Promise<void>;
104
+ export {};
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Set both the JS `process.title` and — on Linux — the kernel `comm` name.
3
+ *
4
+ * Never throws: `bun:ffi` unavailability or a failed syscall degrades silently
5
+ * to the `process.title`-only behavior, so it is safe to call at startup.
6
+ */
7
+ export declare function setProcessName(name: string): void;
@@ -0,0 +1,74 @@
1
+ import type { Subprocess } from "bun";
2
+ export interface ShellConfig {
3
+ shell: string;
4
+ args: string[];
5
+ env: Record<string, string>;
6
+ prefix: string | undefined;
7
+ }
8
+ /** Identifies the settings source users should edit when shell resolution fails. */
9
+ export interface ShellConfigOptions {
10
+ /** File path or runtime layer that supplied the active shell setting. */
11
+ configSource?: string;
12
+ }
13
+ /**
14
+ * Check if a shell binary is executable.
15
+ */
16
+ export declare function isExecutable(path: string): boolean;
17
+ /**
18
+ * Get shell args for the resolved shell.
19
+ * cmd.exe takes `/c`; PowerShell (powershell.exe / pwsh) takes
20
+ * `-NoLogo -Command`, with `-NoProfile` when PI_BASH_NO_LOGIN /
21
+ * CLAUDE_BASH_NO_LOGIN is set (profile scripts are PowerShell's login-shell
22
+ * analog); POSIX shells take `-c`, with `-l` unless the same env is set.
23
+ *
24
+ * Exported for tests; `env` overrides the process env gate.
25
+ */
26
+ export declare function getShellArgs(shell: string, env?: Record<string, string | undefined>): string[];
27
+ /** Whether the shell is Windows cmd.exe (spawn paths must use `/c`, not `-c`). */
28
+ export declare function isCmdShell(shell: string): boolean;
29
+ /**
30
+ * Whether the shell is Windows PowerShell or PowerShell Core (pwsh). Spawn
31
+ * paths must use `-Command`: passing the POSIX `-l -c` pair makes PowerShell
32
+ * parse `-l` as the command and fail with `The term '-l' is not recognized`.
33
+ */
34
+ export declare function isPowerShell(shell: string): boolean;
35
+ /**
36
+ * Resolve a basic shell (bash or sh) as fallback.
37
+ */
38
+ export declare function resolveBasicShell(): string | undefined;
39
+ /**
40
+ * Resolve the external shell to advertise on Windows.
41
+ *
42
+ * A host bash is OPTIONAL: bash tool commands always execute in the embedded
43
+ * brush-core shell. The resolved binary only serves the spawn-a-shell paths
44
+ * (interactive PTY sessions, ACP client terminals, SHELL env), so this
45
+ * prefers a real Git Bash when one exists and otherwise falls back to
46
+ * cmd.exe — it never fails.
47
+ *
48
+ * Search order:
49
+ * 1. Git for Windows install roots (machine + per-user installers)
50
+ * 2. scoop installs — scoop's git manifest sets GIT_INSTALL_ROOT and shims
51
+ * sh.exe/git.exe but never bash.exe, so PATH lookup alone misses it
52
+ * 3. bash.exe on PATH (Cygwin, MSYS2, ...)
53
+ * 4. sh.exe on PATH (Git for Windows' sh.exe is bash; prefer a sibling
54
+ * bash.exe when present)
55
+ * 5. cmd.exe from ComSpec
56
+ *
57
+ * Exported for tests; `env` overrides Bun.env-based discovery.
58
+ */
59
+ export declare function resolveWindowsShell(env?: Record<string, string | undefined>): string;
60
+ /**
61
+ * Get shell configuration based on platform.
62
+ * Resolution order:
63
+ * 1. User-specified shellPath from the active settings source
64
+ * 2. On Windows: Git Bash / bash / sh discovery, then cmd.exe (see
65
+ * {@link resolveWindowsShell}) — never fails
66
+ * 3. On Unix: $SHELL if bash/zsh, then fallback paths
67
+ * 4. Fallback: sh
68
+ */
69
+ export declare function getShellConfig(customShellPath?: string, options?: ShellConfigOptions): ShellConfig;
70
+ /**
71
+ * Check if a process is running.
72
+ */
73
+ export declare function isPidRunning(pid: number | Subprocess): boolean;
74
+ export declare function onProcessExit(proc: Subprocess | number, abortSignal?: AbortSignal): Promise<boolean>;
@@ -0,0 +1,18 @@
1
+ import type { HelperDelegate, Template } from "./template.js";
2
+ export type { HelperDelegate, HelperOptions, Template, TemplateDelegate } from "./template.js";
3
+ export type PromptRenderPhase = "pre-render" | "post-render";
4
+ export interface PromptFormatOptions {
5
+ renderPhase?: PromptRenderPhase;
6
+ replaceAsciiSymbols?: boolean;
7
+ normalizeRfc2119?: boolean;
8
+ }
9
+ export declare function format(content: string, options?: PromptFormatOptions): string;
10
+ export interface TemplateContext extends Record<string, unknown> {
11
+ args?: string[];
12
+ ARGUMENTS?: string;
13
+ arguments?: string;
14
+ }
15
+ export declare function registerHelper(name: string, fn: HelperDelegate): void;
16
+ export declare function registerPartial(name: string, fn: Template): void;
17
+ export declare function compile(template: string): (context: TemplateContext) => string;
18
+ export declare function render(template: string, context?: TemplateContext): string;
@@ -0,0 +1,110 @@
1
+ /**
2
+ * Process tree management utilities for Bun subprocesses.
3
+ *
4
+ * - Track managed child processes for cleanup on shutdown (postmortem).
5
+ * - Drain stdout/stderr to avoid subprocess pipe deadlocks.
6
+ * - Cross-platform tree kill for process groups (Windows taskkill, Unix -pid).
7
+ * - Convenience helpers: captureText / execText, AbortSignal, timeouts.
8
+ */
9
+ import type { Spawn, Subprocess } from "bun";
10
+ type InMask = "pipe" | "ignore" | Buffer | Uint8Array | null;
11
+ /** A Bun subprocess with stdout/stderr always piped (stdin may vary). */
12
+ type PipedSubprocess<In extends InMask = InMask> = Subprocess<In, "pipe", "pipe">;
13
+ /**
14
+ * Base for all exceptions representing child process nonzero exit, killed, or
15
+ * cancellation.
16
+ */
17
+ export declare abstract class Exception extends Error {
18
+ readonly exitCode: number;
19
+ readonly stderr: string;
20
+ constructor(message: string, exitCode: number, stderr: string);
21
+ abstract readonly aborted: boolean;
22
+ }
23
+ /** Exception for nonzero exit codes (not cancellation). */
24
+ export declare class NonZeroExitError extends Exception {
25
+ static readonly MAX_TRACE: number;
26
+ constructor(exitCode: number, stderr: string);
27
+ get aborted(): boolean;
28
+ }
29
+ /** Exception for explicit process abortion (via signal). */
30
+ export declare class AbortError extends Exception {
31
+ readonly reason: unknown;
32
+ constructor(reason: unknown, stderr: string);
33
+ get aborted(): boolean;
34
+ }
35
+ /** Exception for process timeout. */
36
+ export declare class TimeoutError extends AbortError {
37
+ constructor(timeout: number, stderr: string);
38
+ }
39
+ /** Options for waiting for process exit and capturing output. */
40
+ export interface WaitOptions {
41
+ allowNonZero?: boolean;
42
+ allowAbort?: boolean;
43
+ /** `full` requires upfront capture; `exec` enables it, while direct `spawn` callers pass `stderr: "full"`. */
44
+ stderr?: "full" | "buffer";
45
+ }
46
+ /** Result from wait and exec. */
47
+ export interface ExecResult {
48
+ stdout: string;
49
+ stderr: string;
50
+ exitCode: number | null;
51
+ ok: boolean;
52
+ exitError?: Exception;
53
+ }
54
+ /**
55
+ * ChildProcess wraps a managed subprocess, capturing stderr tail, providing
56
+ * cross-platform kill/detach logic plus AbortSignal integration.
57
+ *
58
+ * Stdout is exposed directly from the underlying Bun subprocess; consumers
59
+ * must read it (via text(), wait(), etc.) to prevent pipe deadlock.
60
+ * Stderr is eagerly drained into an internal buffer.
61
+ */
62
+ export declare class ChildProcess<In extends InMask = InMask> {
63
+ #private;
64
+ readonly proc: PipedSubprocess<In>;
65
+ readonly exposeStderr: boolean;
66
+ constructor(proc: PipedSubprocess<In>, exposeStderr: boolean, retainFullStderr?: boolean);
67
+ get pid(): number;
68
+ get exited(): Promise<number>;
69
+ get exitCode(): number | null;
70
+ get exitReason(): Exception | undefined;
71
+ get killed(): boolean;
72
+ get stdin(): Bun.SpawnOptions.WritableToIO<In>;
73
+ /** Raw stdout stream. Must be consumed to prevent pipe deadlock. */
74
+ get stdout(): ReadableStream<Uint8Array<ArrayBuffer>>;
75
+ /** Optional stderr stream (only when requested in spawn options). */
76
+ get stderr(): ReadableStream<Uint8Array<ArrayBufferLike>> | undefined;
77
+ get exitedCleanly(): Promise<number>;
78
+ /** Returns the truncated stderr tail (last 32KB). */
79
+ peekStderr(): string;
80
+ nothrow(): this;
81
+ kill(reason?: Exception): void;
82
+ text(): Promise<string>;
83
+ blob(): Promise<Blob>;
84
+ json(): Promise<unknown>;
85
+ arrayBuffer(): Promise<ArrayBuffer>;
86
+ bytes(): Promise<Uint8Array>;
87
+ wait(opts?: WaitOptions): Promise<ExecResult>;
88
+ attachSignal(signal: AbortSignal): void;
89
+ attachTimeout(ms: number): void;
90
+ [Symbol.dispose](): void;
91
+ }
92
+ /** Options for child spawn. Always pipes stdout/stderr. */
93
+ type ChildSpawnOptions<In extends InMask = InMask> = Omit<Spawn.SpawnOptions<In, "pipe", "pipe">, "stdout" | "stderr" | "detached"> & {
94
+ signal?: AbortSignal;
95
+ detached?: boolean;
96
+ /** Expose and retain complete stderr for a later `wait({ stderr: "full" })`. */
97
+ stderr?: "full" | null;
98
+ };
99
+ /** Spawn a child process with piped stdout/stderr. */
100
+ export declare function spawn<In extends InMask = InMask>(cmd: string[], opts?: ChildSpawnOptions<In>): ChildProcess<In>;
101
+ /** Options for exec. */
102
+ export interface ExecOptions extends Omit<ChildSpawnOptions, "stderr" | "stdin">, WaitOptions {
103
+ input?: string | Buffer | Uint8Array;
104
+ }
105
+ /** Spawn, wait, and return captured output. */
106
+ export declare function exec(cmd: string[], opts?: ExecOptions): Promise<ExecResult>;
107
+ type SignalValue = AbortSignal | number | null | undefined;
108
+ /** Combine AbortSignals and timeout values into a single signal. */
109
+ export declare function combineSignals(...signals: SignalValue[]): AbortSignal | undefined;
110
+ export {};
@@ -0,0 +1,9 @@
1
+ /** Behavior-compatible reimplementation of @mozilla/readability's used surface. */
2
+ import type { ReadabilityArticle, ReadabilityDocument, ReadabilityOptions } from "./types.js";
3
+ /** Extracts the article body and metadata from a standards-shaped document. */
4
+ export declare class Readability<T = string> {
5
+ #private;
6
+ constructor(document: ReadabilityDocument, options?: ReadabilityOptions<T>);
7
+ /** Runs extraction once; the supplied document is consumed and should not be reused. */
8
+ parse(): ReadabilityArticle<T> | null;
9
+ }
@@ -0,0 +1,10 @@
1
+ /** Behavior-compatible reimplementation of @mozilla/readability's used surface. */
2
+ import type { ReadabilityDocument, ReadabilityNode } from "./types.js";
3
+ /** Options for the inexpensive readerability estimate. */
4
+ export interface ReaderableOptions {
5
+ minContentLength?: number;
6
+ minScore?: number;
7
+ visibilityChecker?: (node: ReadabilityNode) => boolean;
8
+ }
9
+ /** Estimates whether a document contains enough prose for article extraction. */
10
+ export declare function isProbablyReaderable(document: ReadabilityDocument, options?: ReaderableOptions | ((node: ReadabilityNode) => boolean)): boolean;
@@ -0,0 +1,70 @@
1
+ /** Behavior-compatible reimplementation of @mozilla/readability's used surface. */
2
+ /** Minimal standards-shaped DOM node accepted by the readability extractor. */
3
+ export interface ReadabilityNode {
4
+ readonly nodeType: number;
5
+ readonly nodeName: string;
6
+ readonly tagName?: string;
7
+ readonly ownerDocument?: ReadabilityDocument | null;
8
+ parentNode: ReadabilityNode | null;
9
+ readonly children?: ArrayLike<ReadabilityElement>;
10
+ readonly childNodes: ArrayLike<ReadabilityNode>;
11
+ readonly firstChild: ReadabilityNode | null;
12
+ readonly textContent: string | null;
13
+ appendChild(node: ReadabilityNode): ReadabilityNode;
14
+ cloneNode(deep?: boolean): ReadabilityNode;
15
+ remove(): void;
16
+ }
17
+ /** Minimal standards-shaped DOM element accepted by the readability extractor. */
18
+ export interface ReadabilityElement extends ReadabilityNode {
19
+ readonly children: ArrayLike<ReadabilityElement>;
20
+ readonly tagName: string;
21
+ id: string;
22
+ className: string;
23
+ innerHTML: string;
24
+ readonly attributes: ArrayLike<{
25
+ readonly name: string;
26
+ readonly value: string;
27
+ }>;
28
+ getAttribute(name: string): string | null;
29
+ hasAttribute(name: string): boolean;
30
+ setAttribute(name: string, value: string): void;
31
+ removeAttribute(name: string): void;
32
+ getElementsByTagName(name: string): ArrayLike<ReadabilityElement>;
33
+ querySelector(selector: string): ReadabilityElement | null;
34
+ querySelectorAll(selector: string): ArrayLike<ReadabilityElement>;
35
+ }
36
+ /** Minimal standards-shaped document accepted by the readability extractor. */
37
+ export interface ReadabilityDocument extends ReadabilityNode {
38
+ title: string;
39
+ readonly body: ReadabilityElement | null;
40
+ readonly documentElement: ReadabilityElement | null;
41
+ createElement(name: string): ReadabilityElement;
42
+ getElementsByTagName(name: string): ArrayLike<ReadabilityElement>;
43
+ querySelector(selector: string): ReadabilityElement | null;
44
+ querySelectorAll(selector: string): ArrayLike<ReadabilityElement>;
45
+ }
46
+ /** Configuration for article extraction. */
47
+ export interface ReadabilityOptions<T = string> {
48
+ debug?: boolean;
49
+ maxElemsToParse?: number;
50
+ nbTopCandidates?: number;
51
+ charThreshold?: number;
52
+ classesToPreserve?: string[];
53
+ keepClasses?: boolean;
54
+ serializer?: (node: ReadabilityNode) => T;
55
+ disableJSONLD?: boolean;
56
+ allowedVideoRegex?: RegExp;
57
+ }
58
+ /** Extracted article and metadata. */
59
+ export interface ReadabilityArticle<T = string> {
60
+ title: string | null | undefined;
61
+ content: T | null | undefined;
62
+ textContent: string | null | undefined;
63
+ length: number | null | undefined;
64
+ excerpt: string | null | undefined;
65
+ byline: string | null | undefined;
66
+ dir: string | null | undefined;
67
+ siteName: string | null | undefined;
68
+ lang: string | null | undefined;
69
+ publishedTime: string | null | undefined;
70
+ }
@@ -0,0 +1,4 @@
1
+ /** Behavior-compatible reimplementation of @mozilla/readability's used surface. */
2
+ export { Readability } from "./readability/readability.js";
3
+ export { isProbablyReaderable, type ReaderableOptions } from "./readability/readerable.js";
4
+ export type { ReadabilityArticle, ReadabilityDocument, ReadabilityElement, ReadabilityNode, ReadabilityOptions, } from "./readability/types.js";
@@ -0,0 +1,93 @@
1
+ /**
2
+ * A fixed-capacity circular buffer that supports efficient push/pop/shift/unshift operations.
3
+ * When the buffer is full, adding new items overwrites the oldest items (FIFO behavior).
4
+ *
5
+ * @template T The type of elements stored in the buffer.
6
+ */
7
+ export declare class RingBuffer<T> {
8
+ #private;
9
+ readonly capacity: number;
10
+ /**
11
+ * Creates a new ring buffer with the specified capacity.
12
+ *
13
+ * @param capacity - The maximum number of elements the buffer can hold. Must be positive.
14
+ */
15
+ constructor(capacity: number);
16
+ /**
17
+ * The number of elements currently in the buffer.
18
+ */
19
+ get length(): number;
20
+ /**
21
+ * Whether the buffer is at full capacity.
22
+ */
23
+ get isFull(): boolean;
24
+ /**
25
+ * Whether the buffer is empty (contains no elements).
26
+ */
27
+ get isEmpty(): boolean;
28
+ /**
29
+ * Adds an item to the end of the buffer.
30
+ * If the buffer is full, the oldest item is overwritten and returned.
31
+ *
32
+ * @param item - The item to add.
33
+ * @returns The overwritten item if the buffer was full, otherwise `undefined`.
34
+ */
35
+ push(item: T): T | undefined;
36
+ /**
37
+ * Removes and returns the first (oldest) item from the buffer.
38
+ *
39
+ * @returns The removed item, or `undefined` if the buffer is empty.
40
+ */
41
+ shift(): T | undefined;
42
+ /**
43
+ * Removes and returns the last (newest) item from the buffer.
44
+ *
45
+ * @returns The removed item, or `undefined` if the buffer is empty.
46
+ */
47
+ pop(): T | undefined;
48
+ /**
49
+ * Adds an item to the beginning of the buffer.
50
+ * If the buffer is full, the newest item is overwritten and returned.
51
+ *
52
+ * @param item - The item to add.
53
+ * @returns The overwritten item if the buffer was full, otherwise `undefined`.
54
+ */
55
+ unshift(item: T): T | undefined;
56
+ /**
57
+ * Returns the element at the specified index without removing it.
58
+ * Supports negative indices (e.g., `-1` for the last element).
59
+ *
60
+ * @param index - The zero-based index, or negative index from the end.
61
+ * @returns The element at the index, or `undefined` if the index is out of bounds.
62
+ */
63
+ at(index: number): T | undefined;
64
+ /**
65
+ * Returns the first (oldest) element without removing it.
66
+ *
67
+ * @returns The first element, or `undefined` if the buffer is empty.
68
+ */
69
+ peek(): T | undefined;
70
+ /**
71
+ * Returns the last (newest) element without removing it.
72
+ *
73
+ * @returns The last element, or `undefined` if the buffer is empty.
74
+ */
75
+ peekBack(): T | undefined;
76
+ /**
77
+ * Removes all elements from the buffer, resetting it to an empty state.
78
+ */
79
+ clear(): void;
80
+ /**
81
+ * Returns an iterator that yields elements in logical order (oldest to newest).
82
+ * Allows the buffer to be used with `for...of` loops and spread syntax.
83
+ *
84
+ * @yields Elements in FIFO order.
85
+ */
86
+ [Symbol.iterator](): Iterator<T>;
87
+ /**
88
+ * Creates a new array containing all elements in logical order (oldest to newest).
89
+ *
90
+ * @returns A new array with all buffer elements.
91
+ */
92
+ toArray(): T[];
93
+ }
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Walk a conditional `exports` target (string, array of fallbacks, or a
3
+ * condition object) and return the first relative path that matches a runtime
4
+ * condition in declaration order. Returns `null` when nothing applies (e.g.
5
+ * an `import`-only entry).
6
+ */
7
+ export declare function selectConditionalTarget(target: unknown): string | null;
8
+ /**
9
+ * Split a bare specifier into its package name and optional subpath, handling
10
+ * scoped packages (`@scope/name/sub` → `@scope/name` + `sub`).
11
+ */
12
+ export declare function splitBareSpecifier(specifier: string): {
13
+ packageName: string;
14
+ subpath: string | undefined;
15
+ };
16
+ /**
17
+ * Resolve a bare specifier against an installed `node_modules` directory,
18
+ * honoring `exports` (CommonJS conditions), then `main`, then `index.js`.
19
+ * Returns an absolute file path, or `null` when the package/entry is absent.
20
+ */
21
+ export declare function resolveRuntimeModule(runtimeNodeModules: string, specifier: string): string | null;
22
+ export interface RuntimeResolverOptions {
23
+ /** Absolute path to the runtime cache's `node_modules`. */
24
+ runtimeNodeModules: string;
25
+ /** Bare specifier → absolute file path overrides (e.g. `sharp` → no-op stub). */
26
+ stubs?: Record<string, string>;
27
+ }
28
+ /**
29
+ * Patch `node:module`'s resolver (idempotently) so bare specifiers that the
30
+ * stock compiled-binary resolver cannot find fall back to the registered
31
+ * runtime caches. Stock resolution is tried first and kept for anything
32
+ * outside the registered roots (bundled imports, node builtins, host or
33
+ * extension trees). Multiple runtime roots may register; they are consulted
34
+ * in registration order. Returns an uninstaller that drops the registration
35
+ * and restores the stock resolver once no registrations remain.
36
+ *
37
+ * One stock "success" is distrusted: the compiled-binary resolver ignores
38
+ * `main`/`exports` for real-FS packages (Bun #1763), so a package shipping
39
+ * its TS source next to `dist/` (e.g. `@huggingface/hub`'s root `index.ts`)
40
+ * resolves to the wrong file. When the stock hit lands inside a registered
41
+ * runtime root, the manifest-aware resolution wins.
42
+ *
43
+ * KNOWN LIMITATION (Bun 1.3.14): while any JS override of
44
+ * `Module._resolveFilename` is installed, Bun routes `createRequire(...)`
45
+ * resolution through it with `parent === undefined` — the requester context is
46
+ * never passed, so relative requires from a `createRequire` require fail with
47
+ * "Cannot find module './x' from ''". The override cannot recover what it is
48
+ * never given. Keep this patch scoped to dedicated worker/runtime processes
49
+ * (tiny-inference, fastembed); never install it in the main agent process,
50
+ * where legacy-pi extensions rely on `createRequire` relative requires.
51
+ */
52
+ export declare function installRuntimeModuleResolver({ runtimeNodeModules, stubs }: RuntimeResolverOptions): () => void;
53
+ /** Pinned dependency set materialized into a runtime cache directory. */
54
+ export interface RuntimeInstallSpec {
55
+ dependencies: Record<string, string>;
56
+ /** Version pins forced across the whole runtime tree (bun `overrides`), e.g. dislodging a transitive dep. */
57
+ overrides?: Record<string, string>;
58
+ /** Packages whose lifecycle scripts bun may run during the install. */
59
+ trustedDependencies?: string[];
60
+ }
61
+ export type RuntimeInstallPhase = "initiate" | "download" | "done";
62
+ export interface EnsureRuntimeInstalledOptions {
63
+ /** Directory owning the runtime `package.json` + `node_modules`. */
64
+ runtimeDir: string;
65
+ install: RuntimeInstallSpec;
66
+ /** Package whose installed manifest marks the runtime complete; defaults to the first dependency. */
67
+ probePackage?: string;
68
+ /** Phase notifications (progress UI); not emitted when already installed. */
69
+ onPhase?: (phase: RuntimeInstallPhase) => void;
70
+ lockAttempts?: number;
71
+ lockSleepMs?: number;
72
+ }
73
+ export declare function writeRuntimeManifest(runtimeDir: string, install: RuntimeInstallSpec): Promise<void>;
74
+ /**
75
+ * Materialize a pinned dependency set into `runtimeDir` (idempotent,
76
+ * cross-process safe via a lock directory). Returns `runtimeDir`.
77
+ */
78
+ export declare function ensureRuntimeInstalled(options: EnsureRuntimeInstalledOptions): Promise<string>;
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Strip ANSI escape sequences, remove control characters / lone surrogates,
3
+ * and normalize line endings.
4
+ *
5
+ * Bun-native implementation of the former native `sanitizeText` (see
6
+ * `crates/pi-natives/src/text.rs::sanitize_text`). JavaScript strings are
7
+ * already UTF-16 code-unit arrays. `toWellFormed()` handles the uncommon
8
+ * malformed path; when it changes the input, replacement characters are
9
+ * dropped and the normalized result goes through the well-formed sanitizer.
10
+ *
11
+ * Fast path: well-formed input with no controls or ANSI returns the original
12
+ * string after the control probe.
13
+ */
14
+ export declare function sanitizeText(text: string): string;
15
+ /**
16
+ * Escape the three XML-significant characters (`&`, `<`, `>`) in text destined
17
+ * for an XML/markup element body. Allocation-conscious: returns the input
18
+ * unchanged (same reference) when nothing needs escaping. Quotes are left as-is
19
+ * — use it for element text, not attribute values.
20
+ */
21
+ export declare function escapeXmlText(input: string): string;
22
+ /**
23
+ * Escape XML-significant characters for an attribute VALUE: the three body
24
+ * characters (`&`, `<`, `>`) plus the double quote (`"` → `&quot;`) that would
25
+ * otherwise close the attribute. Allocation-conscious: returns the input
26
+ * unchanged (same reference) when nothing needs escaping. Use it for attribute
27
+ * values; {@link escapeXmlText} is for element bodies and leaves `"` intact.
28
+ */
29
+ export declare function escapeXmlAttribute(input: string): string;
@@ -0,0 +1,25 @@
1
+ type Snowflake = string & {
2
+ readonly __brand: unique symbol;
3
+ };
4
+ declare namespace Snowflake {
5
+ const PATTERN: RegExp;
6
+ const EPOCH_TIMESTAMP = 1420070400000;
7
+ const MAX_SEQUENCE = 4194303;
8
+ function formatParts(dt: number, seq: number): Snowflake;
9
+ class Source {
10
+ #private;
11
+ constructor(sequence?: number);
12
+ get sequence(): number;
13
+ set sequence(v: number);
14
+ reset(): void;
15
+ generate(timestamp: number): Snowflake;
16
+ }
17
+ function next(timestamp?: number): Snowflake;
18
+ function valid(value: string): value is Snowflake;
19
+ function lowerbound(timelike: Date | number | Snowflake): Snowflake;
20
+ function upperbound(timelike: Date | number | Snowflake): Snowflake;
21
+ function getSequence(value: Snowflake): number;
22
+ function getTimestamp(value: Snowflake): number;
23
+ function getDate(value: Snowflake): Date;
24
+ }
25
+ export { Snowflake };
@@ -0,0 +1,22 @@
1
+ export interface SuppressTerminalStderrOptions {
2
+ /** Redirect target path; defaults to today's omp log file, then /dev/null. */
3
+ redirectPath?: string;
4
+ /** Bypass the macOS + same-terminal gate. Tests only. */
5
+ force?: boolean;
6
+ }
7
+ /**
8
+ * Redirect fd 2 away from the terminal while the TUI owns the viewport.
9
+ * Returns true when suppression is (already) active. No-op — returning
10
+ * false — off macOS, when stderr does not target the stdout terminal, or
11
+ * when the libc fd ops are unavailable.
12
+ */
13
+ export declare function suppressTerminalStderr(options?: SuppressTerminalStderrOptions): boolean;
14
+ /**
15
+ * Re-point fd 2 at the saved terminal stderr. Safe to call unconditionally:
16
+ * no-op when suppression is not active. Called at every terminal-ownership
17
+ * release and by the postmortem fatal handlers before they print, so crash
18
+ * reports reach the real terminal.
19
+ */
20
+ export declare function restoreTerminalStderr(): void;
21
+ /** Whether fd 2 is currently redirected away from the terminal. */
22
+ export declare function isTerminalStderrSuppressed(): boolean;