@linxiraos/pi-utils 1.1.9 → 1.1.11

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 (167) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/THIRD-PARTY-NOTICES.txt +22909 -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 +88 -0
  9. package/dist/types/acp.d.ts +6 -0
  10. package/dist/types/ar/arj.d.ts +5 -0
  11. package/dist/types/ar/asar.d.ts +7 -0
  12. package/dist/types/ar/bytes.d.ts +20 -0
  13. package/dist/types/ar/cab.d.ts +5 -0
  14. package/dist/types/ar/checksums.d.ts +10 -0
  15. package/dist/types/ar/codecs/bzip2.d.ts +4 -0
  16. package/dist/types/ar/codecs/gzip.d.ts +6 -0
  17. package/dist/types/ar/codecs/lzma.d.ts +6 -0
  18. package/dist/types/ar/codecs/lzw.d.ts +4 -0
  19. package/dist/types/ar/codecs/lzx.d.ts +7 -0
  20. package/dist/types/ar/codecs/xz.d.ts +4 -0
  21. package/dist/types/ar/codecs/zstd.d.ts +6 -0
  22. package/dist/types/ar/cpio.d.ts +7 -0
  23. package/dist/types/ar/deb.d.ts +5 -0
  24. package/dist/types/ar/entries.d.ts +22 -0
  25. package/dist/types/ar/error.d.ts +8 -0
  26. package/dist/types/ar/index.d.ts +11 -0
  27. package/dist/types/ar/iso.d.ts +5 -0
  28. package/dist/types/ar/limits.d.ts +33 -0
  29. package/dist/types/ar/lzh.d.ts +7 -0
  30. package/dist/types/ar/open.d.ts +45 -0
  31. package/dist/types/ar/paths.d.ts +18 -0
  32. package/dist/types/ar/rar/rar4-decoder.d.ts +6 -0
  33. package/dist/types/ar/rar/rar5-decoder.d.ts +6 -0
  34. package/dist/types/ar/rar.d.ts +5 -0
  35. package/dist/types/ar/reader.d.ts +28 -0
  36. package/dist/types/ar/registry.d.ts +17 -0
  37. package/dist/types/ar/rpm.d.ts +5 -0
  38. package/dist/types/ar/sevenzip/decode.d.ts +33 -0
  39. package/dist/types/ar/sevenzip.d.ts +5 -0
  40. package/dist/types/ar/source.d.ts +54 -0
  41. package/dist/types/ar/tar.d.ts +9 -0
  42. package/dist/types/ar/types.d.ts +99 -0
  43. package/dist/types/ar/unix-ar.d.ts +7 -0
  44. package/dist/types/ar/write.d.ts +10 -0
  45. package/dist/types/ar/zip.d.ts +10 -0
  46. package/dist/types/async.d.ts +32 -0
  47. package/dist/types/binary.d.ts +23 -0
  48. package/dist/types/browsers.d.ts +68 -0
  49. package/dist/types/chalk.d.ts +125 -0
  50. package/dist/types/cli.d.ts +134 -0
  51. package/dist/types/color.d.ts +136 -0
  52. package/dist/types/dates.d.ts +7 -0
  53. package/dist/types/dirs.d.ts +323 -0
  54. package/dist/types/docx/converter.d.ts +46 -0
  55. package/dist/types/docx/xml.d.ts +26 -0
  56. package/dist/types/docx.d.ts +11 -0
  57. package/dist/types/dom/core.d.ts +431 -0
  58. package/dist/types/dom/parser.d.ts +7 -0
  59. package/dist/types/dom/selector.d.ts +5 -0
  60. package/dist/types/dom.d.ts +5 -0
  61. package/dist/types/env.d.ts +132 -0
  62. package/dist/types/fetch-retry.d.ts +98 -0
  63. package/dist/types/file-lock.d.ts +23 -0
  64. package/dist/types/format.d.ts +37 -0
  65. package/dist/types/frontmatter.d.ts +46 -0
  66. package/dist/types/fs-error.d.ts +31 -0
  67. package/dist/types/glob.d.ts +28 -0
  68. package/dist/types/headers.d.ts +34 -0
  69. package/dist/types/incoming-json.d.ts +232 -0
  70. package/dist/types/index.d.ts +43 -0
  71. package/dist/types/json-lexer.d.ts +116 -0
  72. package/dist/types/json-parse.d.ts +83 -0
  73. package/dist/types/json.d.ts +20 -0
  74. package/dist/types/logger/rotating-file.d.ts +18 -0
  75. package/dist/types/logger.d.ts +96 -0
  76. package/dist/types/loop-phase.d.ts +10 -0
  77. package/dist/types/lru.d.ts +46 -0
  78. package/dist/types/marked/core.d.ts +445 -0
  79. package/dist/types/marked.d.ts +2 -0
  80. package/dist/types/materialize-string.d.ts +7 -0
  81. package/dist/types/math-delimiters.d.ts +45 -0
  82. package/dist/types/mermaid-ascii.d.ts +11 -0
  83. package/dist/types/mime.d.ts +29 -0
  84. package/dist/types/module-timer.d.ts +1 -0
  85. package/dist/types/path-tree.d.ts +76 -0
  86. package/dist/types/path.d.ts +4 -0
  87. package/dist/types/peek-file.d.ts +29 -0
  88. package/dist/types/postmortem.d.ts +178 -0
  89. package/dist/types/process-name.d.ts +7 -0
  90. package/dist/types/procmgr.d.ts +76 -0
  91. package/dist/types/prompt.d.ts +18 -0
  92. package/dist/types/ptree.d.ts +124 -0
  93. package/dist/types/readability/readability.d.ts +9 -0
  94. package/dist/types/readability/readerable.d.ts +10 -0
  95. package/dist/types/readability/types.d.ts +70 -0
  96. package/dist/types/readability.d.ts +4 -0
  97. package/dist/types/ring.d.ts +93 -0
  98. package/dist/types/runtime-install.d.ts +85 -0
  99. package/dist/types/sanitize-text.d.ts +29 -0
  100. package/dist/types/snowflake.d.ts +25 -0
  101. package/dist/types/sqlite.d.ts +26 -0
  102. package/dist/types/stderr-guard.d.ts +22 -0
  103. package/dist/types/stream.d.ts +75 -0
  104. package/dist/types/tab-spacing.d.ts +24 -0
  105. package/dist/types/temp.d.ts +24 -0
  106. package/dist/types/template.d.ts +62 -0
  107. package/dist/types/timing-buffer.d.ts +22 -0
  108. package/dist/types/tls-fetch.d.ts +50 -0
  109. package/dist/types/turndown/gfm.d.ts +11 -0
  110. package/dist/types/turndown/html.d.ts +5 -0
  111. package/dist/types/turndown/service.d.ts +21 -0
  112. package/dist/types/turndown/types.d.ts +70 -0
  113. package/dist/types/turndown.d.ts +4 -0
  114. package/dist/types/type-guards.d.ts +5 -0
  115. package/dist/types/vendor/mermaid-ascii/ascii/ansi.d.ts +41 -0
  116. package/dist/types/vendor/mermaid-ascii/ascii/canvas.d.ts +89 -0
  117. package/dist/types/vendor/mermaid-ascii/ascii/class-diagram.d.ts +7 -0
  118. package/dist/types/vendor/mermaid-ascii/ascii/converter.d.ts +12 -0
  119. package/dist/types/vendor/mermaid-ascii/ascii/draw.d.ts +66 -0
  120. package/dist/types/vendor/mermaid-ascii/ascii/edge-bundling.d.ts +48 -0
  121. package/dist/types/vendor/mermaid-ascii/ascii/edge-routing.d.ts +43 -0
  122. package/dist/types/vendor/mermaid-ascii/ascii/er-diagram.d.ts +7 -0
  123. package/dist/types/vendor/mermaid-ascii/ascii/grid.d.ts +56 -0
  124. package/dist/types/vendor/mermaid-ascii/ascii/index.d.ts +65 -0
  125. package/dist/types/vendor/mermaid-ascii/ascii/multiline-utils.d.ts +27 -0
  126. package/dist/types/vendor/mermaid-ascii/ascii/pathfinder.d.ts +17 -0
  127. package/dist/types/vendor/mermaid-ascii/ascii/sequence.d.ts +7 -0
  128. package/dist/types/vendor/mermaid-ascii/ascii/shapes/circle.d.ts +11 -0
  129. package/dist/types/vendor/mermaid-ascii/ascii/shapes/corners.d.ts +34 -0
  130. package/dist/types/vendor/mermaid-ascii/ascii/shapes/diamond.d.ts +11 -0
  131. package/dist/types/vendor/mermaid-ascii/ascii/shapes/hexagon.d.ts +11 -0
  132. package/dist/types/vendor/mermaid-ascii/ascii/shapes/index.d.ts +26 -0
  133. package/dist/types/vendor/mermaid-ascii/ascii/shapes/rectangle.d.ts +31 -0
  134. package/dist/types/vendor/mermaid-ascii/ascii/shapes/rounded.d.ts +11 -0
  135. package/dist/types/vendor/mermaid-ascii/ascii/shapes/special.d.ts +59 -0
  136. package/dist/types/vendor/mermaid-ascii/ascii/shapes/stadium.d.ts +17 -0
  137. package/dist/types/vendor/mermaid-ascii/ascii/shapes/state.d.ts +30 -0
  138. package/dist/types/vendor/mermaid-ascii/ascii/shapes/types.d.ts +55 -0
  139. package/dist/types/vendor/mermaid-ascii/ascii/types.d.ts +206 -0
  140. package/dist/types/vendor/mermaid-ascii/ascii/validate.d.ts +51 -0
  141. package/dist/types/vendor/mermaid-ascii/ascii/xychart.d.ts +2 -0
  142. package/dist/types/vendor/mermaid-ascii/class/parser.d.ts +6 -0
  143. package/dist/types/vendor/mermaid-ascii/class/types.d.ts +102 -0
  144. package/dist/types/vendor/mermaid-ascii/er/parser.d.ts +6 -0
  145. package/dist/types/vendor/mermaid-ascii/er/types.d.ts +76 -0
  146. package/dist/types/vendor/mermaid-ascii/index.d.ts +1 -0
  147. package/dist/types/vendor/mermaid-ascii/multiline-utils.d.ts +9 -0
  148. package/dist/types/vendor/mermaid-ascii/parser.d.ts +7 -0
  149. package/dist/types/vendor/mermaid-ascii/sequence/parser.d.ts +6 -0
  150. package/dist/types/vendor/mermaid-ascii/sequence/types.d.ts +130 -0
  151. package/dist/types/vendor/mermaid-ascii/text-metrics.d.ts +23 -0
  152. package/dist/types/vendor/mermaid-ascii/types.d.ts +114 -0
  153. package/dist/types/vendor/mermaid-ascii/xychart/colors.d.ts +25 -0
  154. package/dist/types/vendor/mermaid-ascii/xychart/parser.d.ts +6 -0
  155. package/dist/types/vendor/mermaid-ascii/xychart/types.d.ts +145 -0
  156. package/dist/types/version.d.ts +18 -0
  157. package/dist/types/vterm/buffer.d.ts +99 -0
  158. package/dist/types/vterm/query-responder.d.ts +24 -0
  159. package/dist/types/vterm/terminal.d.ts +44 -0
  160. package/dist/types/vterm.d.ts +9 -0
  161. package/dist/types/which.d.ts +37 -0
  162. package/dist/types/worker-host.d.ts +51 -0
  163. package/dist/types/xml.d.ts +31 -0
  164. package/package.json +60 -57
  165. package/src/dirs.ts +40 -60
  166. package/src/env.ts +7 -14
  167. package/src/procmgr.ts +7 -0
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Lightweight string-level repair of the escape/control-char hazards that make
3
+ * otherwise-valid JSON fail `JSON.parse`: raw control characters inside strings
4
+ * are escaped, and invalid `\x` escapes have their backslash escaped. Returns the
5
+ * input unchanged when no repair is needed. Pure string→string; does not parse.
6
+ */
7
+ export declare function repairJson(json: string): string;
8
+ /**
9
+ * Final-parse a JSON value, repairing the common LLM malformations
10
+ * ({@link RelaxedJson}). Tries strict `JSON.parse` first (fast path, exact JSON
11
+ * semantics), then the relaxed parser. Throws when the input is unrepairable,
12
+ * truncated, or carries trailing garbage — so callers can skip a bad tool call
13
+ * rather than execute a half-formed one.
14
+ */
15
+ export declare function parseJsonWithRepair<T>(json: string): T;
16
+ /**
17
+ * Parse possibly-incomplete JSON during streaming. Always returns a value, never
18
+ * throws: `{}` for empty/whitespace/unrecoverable buffers, and an auto-closed
19
+ * best-effort object for truncated ones.
20
+ */
21
+ export declare function parseStreamingJson<T = Record<string, unknown>>(partialJson: string | undefined): T;
22
+ /**
23
+ * Default minimum byte growth before `parseStreamingJsonThrottled` will
24
+ * re-parse a streaming tool-call argument buffer. Acts as the floor of the
25
+ * geometric gate — see {@link parseStreamingJsonThrottled}.
26
+ */
27
+ export declare const STREAMING_JSON_PARSE_MIN_GROWTH = 256;
28
+ /**
29
+ * Throttled variant of {@link parseStreamingJson} for the per-delta hot path.
30
+ *
31
+ * Tool calls arrive as a long sequence of small deltas — calling
32
+ * `parseStreamingJson(buffer)` on every delta re-parses the entire buffer
33
+ * each time, giving O(N²) work in the total buffer length. A fixed re-parse
34
+ * floor alone does NOT fix this: with `minGrowthBytes` constant, a buffer of
35
+ * length N is parsed N/minGrowthBytes times at an average cost of N/2, which
36
+ * is still O(N²) (the constant just shrinks). Long `write` payloads — where
37
+ * the buffer is the whole file — made this the dominant main-thread stall
38
+ * during streaming.
39
+ *
40
+ * Instead the gate scales geometrically: once the buffer is large, a re-parse
41
+ * requires growth proportional to the current length (`len / 32`, floored at
42
+ * `minGrowthBytes`). Parse points then form a geometric progression, so a
43
+ * buffer of length N is parsed O(log N) times for O(N log N) total work,
44
+ * while small buffers keep the snappy fixed-cadence updates.
45
+ *
46
+ * Each provider tracks the last parsed length on its tool-call block, so the
47
+ * final `toolcall_end` parse (which providers already perform unconditionally)
48
+ * is the authoritative full parse — the throttle only delays mid-stream UI
49
+ * updates, by at most ~3% of the accumulated content for large buffers.
50
+ *
51
+ * @returns the parsed object plus the new `parsedLen` to persist; or `null`
52
+ * when the buffer has not grown enough to warrant a re-parse.
53
+ */
54
+ export declare function parseStreamingJsonThrottled<T = Record<string, unknown>>(partialJson: string | undefined, lastParsedLen: number, minGrowthBytes?: number): {
55
+ value: T;
56
+ parsedLen: number;
57
+ } | null;
58
+ /**
59
+ * Classification of a streaming buffer against strict JSON (RFC 8259):
60
+ * - `"complete"`: exactly one whole JSON value (plus surrounding whitespace).
61
+ * - `"prefix"`: a proper prefix of some valid JSON value — more bytes can
62
+ * still complete it.
63
+ * - `"invalid"`: no suffix can ever make it valid strict JSON (e.g. a raw
64
+ * control character inside a string, or a second top-level value).
65
+ */
66
+ export type JsonPrefixState = "complete" | "prefix" | "invalid";
67
+ /**
68
+ * Classify `text` as a strict-JSON value, prefix, or dead end.
69
+ *
70
+ * Providers use this to disambiguate identifierless streaming tool-call
71
+ * deltas: a chunk starting with `{` is a *new* sibling call only if the
72
+ * current call's argument buffer cannot absorb it — the buffer is already a
73
+ * complete value, already unsalvageable (lossy hosts abandon buffers
74
+ * mid-string, leaving raw control characters strict JSON forbids), or the
75
+ * concatenation would break it. Unlike {@link parseStreamingJson} this is
76
+ * deliberately strict: forgiving repair would mask exactly the corruption
77
+ * signals the caller needs.
78
+ *
79
+ * A top-level number at end-of-input classifies as `"complete"` even though
80
+ * more digits could extend it; tool-argument buffers are always objects, so
81
+ * the ambiguity is immaterial here.
82
+ */
83
+ export declare function classifyJsonPrefix(text: string): JsonPrefixState;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Try to parse JSON, returning null on failure.
3
+ */
4
+ export declare function tryParseJson<T = unknown>(content: string): T | null;
5
+ /**
6
+ * Serialize JSON while preserving bigint precision as decimal strings.
7
+ *
8
+ * Tool arguments normally arrive from JSON providers, but extension hooks and
9
+ * host integrations can supply JavaScript bigint values. Native
10
+ * `JSON.stringify` throws for those values, which makes otherwise valid agent
11
+ * history impossible to persist, replay, or compact. A decimal string is the
12
+ * only lossless JSON representation.
13
+ */
14
+ export declare function stringifyJson(value: unknown, space?: string | number): string | undefined;
15
+ /**
16
+ * Deterministically serialize JSON-shaped data by sorting object keys at every
17
+ * depth while preserving array order. Throws for values JSON cannot represent
18
+ * as a top-level value instead of returning an easy-to-misuse undefined.
19
+ */
20
+ export declare function stableStringifyJson(value: unknown): string;
@@ -0,0 +1,18 @@
1
+ /** Configuration for a process-local rotating file sink. */
2
+ export interface RotatingFileOptions {
3
+ readonly directory: string;
4
+ readonly filenamePrefix: string;
5
+ readonly filenameSuffix: string;
6
+ readonly auditFile: string;
7
+ readonly maxBytes: number;
8
+ readonly maxFiles: number;
9
+ }
10
+ /** Synchronous append sink with local-day and size rotation plus bounded retention. */
11
+ export declare class RotatingFileSink {
12
+ #private;
13
+ constructor(options: RotatingFileOptions);
14
+ /** Append one already-formatted log record. */
15
+ write(line: string): void;
16
+ /** Stop accepting records. Synchronous writes require no drain phase. */
17
+ close(): void;
18
+ }
@@ -0,0 +1,96 @@
1
+ /** Severity names accepted by the centralized logger. */
2
+ export type LogLevel = "error" | "warn" | "info" | "debug";
3
+ /** Structured log event forwarded to out-of-band sinks such as OpenTelemetry. */
4
+ export interface LogEvent {
5
+ readonly level: LogLevel;
6
+ readonly message: string;
7
+ readonly context: Record<string, unknown> | undefined;
8
+ readonly timestamp: Date;
9
+ }
10
+ /** Receives each structured log event after the local transport path runs. */
11
+ export type LogSink = (event: LogEvent) => void;
12
+ /** Register an out-of-band log sink and return a disposer. */
13
+ export declare function registerLogSink(sink: LogSink): () => void;
14
+ /**
15
+ * Replace the active log transports. Pass `console: true, file: false` for
16
+ * long-running services (the auth broker, etc.) that want their structured
17
+ * logs piped into a process supervisor instead of the rotating file.
18
+ */
19
+ export declare function setTransports(opts: {
20
+ console?: boolean;
21
+ file?: boolean | string;
22
+ }): void;
23
+ /**
24
+ * Log an error message.
25
+ * @param message - The message to log.
26
+ * @param context - The context to log.
27
+ */
28
+ export declare function error(message: string, context?: Record<string, unknown>): void;
29
+ /**
30
+ * Log a warning message.
31
+ * @param message - The message to log.
32
+ * @param context - The context to log.
33
+ */
34
+ export declare function warn(message: string, context?: Record<string, unknown>): void;
35
+ /**
36
+ * Log an informational message.
37
+ * @param message - The message to log.
38
+ * @param context - The context to log.
39
+ */
40
+ export declare function info(message: string, context?: Record<string, unknown>): void;
41
+ /**
42
+ * Log a debug message.
43
+ * @param message - The message to log.
44
+ * @param context - The context to log.
45
+ */
46
+ export declare function debug(message: string, context?: Record<string, unknown>): void;
47
+ /**
48
+ * Streaming startup markers, enabled by `PI_DEBUG_STARTUP`. Unlike the
49
+ * PI_TIMING tree (printed only after startup completes), these write one
50
+ * synchronous stderr line as each phase begins/ends, so a hard hang still
51
+ * shows the last phase that started. `fs.writeSync(2)` is used deliberately:
52
+ * it cannot be reordered or buffered past a synchronous block of the event
53
+ * loop (dlopen, sync fs on a dead mount, spawnSync).
54
+ */
55
+ export declare function startupMarker(text: string): void;
56
+ export declare function timingModeIncludes(option: "full" | "x"): boolean;
57
+ export declare function shouldExitAfterTimings(): boolean;
58
+ /**
59
+ * Print collected timings as an indented tree.
60
+ * Each span shows wall duration; parents with children also show "(self)" for unattributed time.
61
+ * Sibling spans are sorted by start time. Spans whose intervals overlap with siblings ran in parallel.
62
+ */
63
+ export declare function printTimings(): void;
64
+ /**
65
+ * Begin recording startup timings under a new root span.
66
+ * Idempotent: a second call while already recording is a no-op, so an explicit
67
+ * starter (main.ts) and any future early starter can coexist.
68
+ */
69
+ export declare function startTiming(): void;
70
+ /**
71
+ * Record an externally-measured span as a leaf child of the active span (or root
72
+ * when no span is active). Used by {@link spliceModuleLoadBuffer} to fold
73
+ * preload-captured module windows into the tree.
74
+ */
75
+ export declare function recordModuleLoadSpan(path: string, start: number, durationMs: number, bodyMs?: number, imports?: string[]): void;
76
+ /**
77
+ * End timing window and clear buffers.
78
+ */
79
+ export declare function endTiming(): void;
80
+ /**
81
+ * Ops of the currently-open span chain (root → deepest), following the most
82
+ * recently started unfinished child at each level. Lets a startup watchdog
83
+ * name the phase a stalled startup is stuck in.
84
+ */
85
+ export declare function openSpanPath(): string[];
86
+ /**
87
+ * Time a span. Three forms:
88
+ * time(op) — point event (zero-duration breadcrumb)
89
+ * time(op, fn, ...args) — wrap fn in a span; returns fn's return value (sync or Promise)
90
+ *
91
+ * Spans nest hierarchically via AsyncLocalStorage: a child started inside another span's fn
92
+ * (even across awaits) becomes that span's child. Parallel children are recorded as siblings
93
+ * with overlapping intervals.
94
+ */
95
+ export declare function time(op: string): void;
96
+ export declare function time<T, A extends unknown[]>(op: string, fn: (...args: A) => T, ...args: A): T;
@@ -0,0 +1,10 @@
1
+ export declare function pushLoopPhase(label: string): void;
2
+ export declare function popLoopPhase(): void;
3
+ export declare function currentLoopPhase(): string | undefined;
4
+ /**
5
+ * Phase to blame for a just-detected loop block: the live top phase if one is
6
+ * still held, else the most recent phase pushed since the last call. Clears the
7
+ * recent slot so a block in a later, phase-less interval is not misattributed
8
+ * to a phase that already finished.
9
+ */
10
+ export declare function takeRecentLoopPhase(): string | undefined;
@@ -0,0 +1,46 @@
1
+ /** Behavior-compatible reimplementation of lru-cache's used surface. */
2
+ /** Why an entry left the cache. */
3
+ export type DisposeReason = "evict" | "set" | "delete" | "expire";
4
+ /** Options supported by {@link LRUCache}. */
5
+ export interface LRUCacheOptions<K, V> {
6
+ /** Maximum number of retained entries. */
7
+ max?: number;
8
+ /** Maximum aggregate calculated size. */
9
+ maxSize?: number;
10
+ /** Maximum calculated size of one entry. */
11
+ maxEntrySize?: number;
12
+ /** Calculates an entry's size. */
13
+ sizeCalculation?: (value: V, key: K) => number;
14
+ /** Entry lifetime in milliseconds; zero disables expiry. */
15
+ ttl?: number;
16
+ /** Refreshes an entry's lifetime when it is read. */
17
+ updateAgeOnGet?: boolean;
18
+ /** Called synchronously before an entry is removed. */
19
+ dispose?: (value: V, key: K, reason: DisposeReason) => void;
20
+ }
21
+ /** A bounded least-recently-used cache with optional size and lifetime limits. */
22
+ export declare class LRUCache<K, V> {
23
+ #private;
24
+ /** Creates an empty cache. */
25
+ constructor(options: LRUCacheOptions<K, V>);
26
+ /** Number of entries, including stale entries not yet removed by `get`. */
27
+ get size(): number;
28
+ /** Aggregate calculated size of retained entries. */
29
+ get calculatedSize(): number;
30
+ /** Stores a value and makes it most recently used. */
31
+ set(key: K, value: V | undefined): this;
32
+ /** Returns a value and makes a fresh entry most recently used. */
33
+ get(key: K): V | undefined;
34
+ /** Reports whether a fresh value is present without changing recency. */
35
+ has(key: K): boolean;
36
+ /** Returns a fresh value without changing recency or removing stale data. */
37
+ peek(key: K): V | undefined;
38
+ /** Removes a value, returning whether one was present. */
39
+ delete(key: K): boolean;
40
+ /** Removes every value from least to most recently used. */
41
+ clear(): void;
42
+ /** Iterates fresh keys from most to least recently used. */
43
+ keys(): Generator<K, void, unknown>;
44
+ /** Iterates fresh values from most to least recently used. */
45
+ values(): Generator<V, void, unknown>;
46
+ }