@linxiraos/pi-utils 1.1.15 → 1.1.17
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.
- package/CHANGELOG.md +2 -2
- package/THIRD-PARTY-NOTICES.txt +54 -25
- package/dist/types/async.d.ts +18 -0
- package/dist/types/browsers.d.ts +2 -30
- package/dist/types/color.d.ts +2 -0
- package/dist/types/dirs.d.ts +18 -1
- package/dist/types/env.d.ts +12 -2
- package/dist/types/executable.d.ts +4 -0
- package/dist/types/fetch-retry.d.ts +8 -2
- package/dist/types/file-lock.d.ts +6 -0
- package/dist/types/format.d.ts +7 -0
- package/dist/types/index.d.ts +2 -1
- package/dist/types/mime.d.ts +1 -0
- package/dist/types/path.d.ts +6 -0
- package/dist/types/peek-file.d.ts +2 -3
- package/dist/types/postmortem.d.ts +26 -5
- package/dist/types/procmgr.d.ts +2 -4
- package/dist/types/snowflake.d.ts +1 -0
- package/dist/types/sqlite.d.ts +27 -7
- package/dist/types/stream.d.ts +76 -1
- package/dist/types/which.d.ts +8 -2
- package/dist/types/yaml-config.d.ts +2 -0
- package/package.json +2 -2
- package/src/acp/transport.ts +37 -3
- package/src/async.ts +31 -0
- package/src/browsers.ts +10 -169
- package/src/color.ts +1 -1
- package/src/dirs.ts +28 -6
- package/src/env.ts +81 -34
- package/src/executable.ts +17 -0
- package/src/fetch-retry.ts +72 -13
- package/src/file-lock.ts +28 -0
- package/src/format.ts +16 -0
- package/src/index.ts +2 -1
- package/src/json.ts +12 -1
- package/src/logger/rotating-file.ts +40 -3
- package/src/logger.ts +16 -4
- package/src/mime.ts +3 -7
- package/src/path.ts +14 -0
- package/src/peek-file.ts +17 -67
- package/src/postmortem.ts +95 -47
- package/src/procmgr.ts +2 -12
- package/src/ptree.ts +36 -5
- package/src/snowflake.ts +12 -1
- package/src/sqlite.ts +242 -7
- package/src/stream.ts +167 -35
- package/src/which.ts +38 -14
- package/src/xml.ts +16 -0
- package/src/yaml-config.ts +8 -0
- package/dist/types/glob.d.ts +0 -28
- package/src/glob.ts +0 -189
package/CHANGELOG.md
CHANGED
package/THIRD-PARTY-NOTICES.txt
CHANGED
|
@@ -10843,7 +10843,7 @@ RUST RUNTIME DEPENDENCY LICENSES
|
|
|
10843
10843
|
|
|
10844
10844
|
Generated from Cargo.lock by cargo-about 0.8.2 in locked, offline, workspace, all-feature, all-target mode, then restricted using cargo metadata to normal and build edges reachable from the workspace (development-only edges are excluded). cargo-deny independently evaluates the complete all-target graph.
|
|
10845
10845
|
|
|
10846
|
-
Native Opus (
|
|
10846
|
+
Native Opus (opus/opusic-sys) and PCRE2 (pcre2/pcre2-sys) are covered by the exact crate license payloads below. inferno 0.12.8 is package-scoped as CDDL-1.0: its CDDL-covered source remains available in the locked crates.io source archive at https://crates.io/crates/inferno/0.12.8 and https://github.com/jonhoo/inferno. The full locked license text follows below.
|
|
10847
10847
|
|
|
10848
10848
|
-------------------------------------------------------------------------------
|
|
10849
10849
|
License: Apache License 2.0 (Apache-2.0)
|
|
@@ -12509,6 +12509,58 @@ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
|
12509
12509
|
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
12510
12510
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
12511
12511
|
|
|
12512
|
+
-------------------------------------------------------------------------------
|
|
12513
|
+
License: BSD 3-Clause "New" or "Revised" License (BSD-3-Clause)
|
|
12514
|
+
Used by:
|
|
12515
|
+
- opusic-sys 0.7.5 (https://github.com/DoumanAsh/opusic-sys)
|
|
12516
|
+
|
|
12517
|
+
Full license text:
|
|
12518
|
+
|
|
12519
|
+
Copyright 2001-2023 Xiph.Org, Skype Limited, Octasic,
|
|
12520
|
+
Jean-Marc Valin, Timothy B. Terriberry,
|
|
12521
|
+
CSIRO, Gregory Maxwell, Mark Borgerding,
|
|
12522
|
+
Erik de Castro Lopo, Mozilla, Amazon
|
|
12523
|
+
|
|
12524
|
+
Redistribution and use in source and binary forms, with or without
|
|
12525
|
+
modification, are permitted provided that the following conditions
|
|
12526
|
+
are met:
|
|
12527
|
+
|
|
12528
|
+
- Redistributions of source code must retain the above copyright
|
|
12529
|
+
notice, this list of conditions and the following disclaimer.
|
|
12530
|
+
|
|
12531
|
+
- Redistributions in binary form must reproduce the above copyright
|
|
12532
|
+
notice, this list of conditions and the following disclaimer in the
|
|
12533
|
+
documentation and/or other materials provided with the distribution.
|
|
12534
|
+
|
|
12535
|
+
- Neither the name of Internet Society, IETF or IETF Trust, nor the
|
|
12536
|
+
names of specific contributors, may be used to endorse or promote
|
|
12537
|
+
products derived from this software without specific prior written
|
|
12538
|
+
permission.
|
|
12539
|
+
|
|
12540
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
12541
|
+
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
12542
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
12543
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
|
12544
|
+
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
12545
|
+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
12546
|
+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
12547
|
+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
12548
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
12549
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
12550
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
12551
|
+
|
|
12552
|
+
Opus is subject to the royalty-free patent licenses which are
|
|
12553
|
+
specified at:
|
|
12554
|
+
|
|
12555
|
+
Xiph.Org Foundation:
|
|
12556
|
+
https://datatracker.ietf.org/ipr/1524/
|
|
12557
|
+
|
|
12558
|
+
Microsoft Corporation:
|
|
12559
|
+
https://datatracker.ietf.org/ipr/1914/
|
|
12560
|
+
|
|
12561
|
+
Broadcom Corporation:
|
|
12562
|
+
https://datatracker.ietf.org/ipr/1526/
|
|
12563
|
+
|
|
12512
12564
|
-------------------------------------------------------------------------------
|
|
12513
12565
|
License: BSD 3-Clause "New" or "Revised" License (BSD-3-Clause)
|
|
12514
12566
|
Used by:
|
|
@@ -13290,29 +13342,6 @@ jurisdiction of the Federal Courts of the Northern District of
|
|
|
13290
13342
|
California and the state courts of the State of California, with
|
|
13291
13343
|
venue lying in Santa Clara County, California.
|
|
13292
13344
|
|
|
13293
|
-
-------------------------------------------------------------------------------
|
|
13294
|
-
License: ISC License (ISC)
|
|
13295
|
-
Used by:
|
|
13296
|
-
- audiopus_sys 0.2.2 (https://github.com/lakelezz/audiopus_sys.git)
|
|
13297
|
-
|
|
13298
|
-
Full license text:
|
|
13299
|
-
|
|
13300
|
-
ISC License
|
|
13301
|
-
|
|
13302
|
-
Copyright (c) 2019, Lakelezz
|
|
13303
|
-
|
|
13304
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
13305
|
-
purpose with or without fee is hereby granted, provided that the above
|
|
13306
|
-
copyright notice and this permission notice appear in all copies.
|
|
13307
|
-
|
|
13308
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
13309
|
-
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
13310
|
-
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
13311
|
-
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
13312
|
-
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
13313
|
-
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
13314
|
-
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
13315
|
-
|
|
13316
13345
|
-------------------------------------------------------------------------------
|
|
13317
13346
|
License: ISC License (ISC)
|
|
13318
13347
|
Used by:
|
|
@@ -18734,7 +18763,7 @@ DEALINGS IN THE SOFTWARE.
|
|
|
18734
18763
|
-------------------------------------------------------------------------------
|
|
18735
18764
|
License: MIT License (MIT)
|
|
18736
18765
|
Used by:
|
|
18737
|
-
- opus 0.
|
|
18766
|
+
- opus 0.4.0 (https://github.com/SpaceManiac/opus-rs)
|
|
18738
18767
|
|
|
18739
18768
|
Full license text:
|
|
18740
18769
|
|
package/dist/types/async.d.ts
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Largest delay `setTimeout` (and `timers/promises` `scheduler.wait`)
|
|
3
|
+
* accepts without 32-bit signed overflow: larger values wrap and fire
|
|
4
|
+
* almost immediately instead of sleeping. Chunk day-scale provider waits
|
|
5
|
+
* (e.g. a monthly quota reset parsed from an error hint) so the full
|
|
6
|
+
* duration elapses instead of overflowing the timer.
|
|
7
|
+
*/
|
|
8
|
+
export declare const MAX_TIMER_DELAY_MS = 2147483647;
|
|
9
|
+
/**
|
|
10
|
+
* Abortable sleep for arbitrarily long delays. Waits longer than
|
|
11
|
+
* {@link MAX_TIMER_DELAY_MS} chunk the sleep into back-to-back timer waits
|
|
12
|
+
* so no single timer overflows; an abort during any chunk rejects like
|
|
13
|
+
* `scheduler.wait`.
|
|
14
|
+
*
|
|
15
|
+
* Uses a monotonic deadline so a timer that wakes prematurely is re-armed for
|
|
16
|
+
* the unelapsed duration instead of shortening the requested sleep.
|
|
17
|
+
*/
|
|
18
|
+
export declare function sleepLong(delayMs: number, signal?: AbortSignal): Promise<void>;
|
|
1
19
|
/**
|
|
2
20
|
* Wrap a promise with a timeout and optional abort signal.
|
|
3
21
|
* Rejects with the given error or a new error containing the given message if
|
package/dist/types/browsers.d.ts
CHANGED
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
/** Behavior-compatible reimplementation of @puppeteer/browsers' used surface. */
|
|
2
|
-
/** Supported browser products. */
|
|
3
|
-
export declare enum Browser {
|
|
4
|
-
CHROME = "chrome",
|
|
5
|
-
CHROMEHEADLESSSHELL = "chrome-headless-shell",
|
|
6
|
-
CHROMIUM = "chromium",
|
|
7
|
-
FIREFOX = "firefox",
|
|
8
|
-
CHROMEDRIVER = "chromedriver"
|
|
9
|
-
}
|
|
10
1
|
/** Browser download platform identifiers. */
|
|
11
2
|
export declare enum BrowserPlatform {
|
|
12
3
|
LINUX = "linux",
|
|
@@ -16,17 +7,6 @@ export declare enum BrowserPlatform {
|
|
|
16
7
|
WIN32 = "win32",
|
|
17
8
|
WIN64 = "win64"
|
|
18
9
|
}
|
|
19
|
-
/** Chrome-for-Testing release channel tags accepted by {@link resolveBuildId}. */
|
|
20
|
-
export declare enum BrowserTag {
|
|
21
|
-
CANARY = "canary",
|
|
22
|
-
NIGHTLY = "nightly",
|
|
23
|
-
BETA = "beta",
|
|
24
|
-
DEV = "dev",
|
|
25
|
-
DEVEDITION = "devedition",
|
|
26
|
-
STABLE = "stable",
|
|
27
|
-
ESR = "esr",
|
|
28
|
-
LATEST = "latest"
|
|
29
|
-
}
|
|
30
10
|
/** Download progress reported while a browser archive is streamed to disk. */
|
|
31
11
|
export interface BrowserDownloadProgress {
|
|
32
12
|
downloadedBytes: number;
|
|
@@ -34,7 +14,6 @@ export interface BrowserDownloadProgress {
|
|
|
34
14
|
}
|
|
35
15
|
/** Inputs used to locate an installed browser executable. */
|
|
36
16
|
export interface ComputeExecutablePathOptions {
|
|
37
|
-
browser: Browser;
|
|
38
17
|
buildId: string;
|
|
39
18
|
cacheDir: string;
|
|
40
19
|
platform?: BrowserPlatform;
|
|
@@ -44,9 +23,8 @@ export interface InstallOptions extends ComputeExecutablePathOptions {
|
|
|
44
23
|
baseUrl?: string;
|
|
45
24
|
downloadProgressCallback?: (progress: BrowserDownloadProgress) => void;
|
|
46
25
|
}
|
|
47
|
-
/** Metadata for
|
|
26
|
+
/** Metadata for a managed Chrome installation in Puppeteer's cache layout. */
|
|
48
27
|
export interface InstalledBrowser {
|
|
49
|
-
browser: Browser;
|
|
50
28
|
buildId: string;
|
|
51
29
|
platform: BrowserPlatform;
|
|
52
30
|
path: string;
|
|
@@ -54,15 +32,9 @@ export interface InstalledBrowser {
|
|
|
54
32
|
}
|
|
55
33
|
/** Detect the current host's Puppeteer browser platform. */
|
|
56
34
|
export declare function detectBrowserPlatform(): BrowserPlatform | undefined;
|
|
57
|
-
/** Resolve a Chrome-for-Testing channel, milestone, or build prefix to a full build ID. */
|
|
58
|
-
export declare function resolveBuildId(browser: Browser, _platform: BrowserPlatform, tag: string | BrowserTag): Promise<string>;
|
|
59
35
|
/** Return the Chrome-for-Testing archive URL for a browser build. */
|
|
60
|
-
export declare function getDownloadUrl(
|
|
36
|
+
export declare function getDownloadUrl(platform: BrowserPlatform, buildId: string, baseUrl?: string): URL;
|
|
61
37
|
/** Compute the executable path in Puppeteer's cache layout. */
|
|
62
38
|
export declare function computeExecutablePath(options: ComputeExecutablePathOptions): string;
|
|
63
|
-
/** Scan a Puppeteer cache for browser installation directories. */
|
|
64
|
-
export declare function getInstalledBrowsers(options: {
|
|
65
|
-
cacheDir: string;
|
|
66
|
-
}): Promise<InstalledBrowser[]>;
|
|
67
39
|
/** Download and unpack Chrome into Puppeteer's existing cache layout. */
|
|
68
40
|
export declare function install(options: InstallOptions): Promise<InstalledBrowser>;
|
package/dist/types/color.d.ts
CHANGED
|
@@ -82,6 +82,8 @@ export declare function adjustHsv(hex: string, adj: HSVAdjustment): string;
|
|
|
82
82
|
* Convert HSL (h: 0-360, s: 0-1, l: 0-1) to a CSS hex string.
|
|
83
83
|
*/
|
|
84
84
|
export declare function hslToHex(h: number, s: number, l: number): string;
|
|
85
|
+
/** Parse a 256-color palette index (0–255) to RGB (0..255). */
|
|
86
|
+
export declare function paletteToRgb(index: number): RGB | undefined;
|
|
85
87
|
export interface OKLCH {
|
|
86
88
|
/** Perceptual lightness (0-1) */
|
|
87
89
|
l: number;
|
package/dist/types/dirs.d.ts
CHANGED
|
@@ -37,10 +37,20 @@ export declare function normalizeProfileName(profile: string | undefined): strin
|
|
|
37
37
|
* syntactically invalid value).
|
|
38
38
|
*/
|
|
39
39
|
export declare function resolveProfileEnv(profile: string | undefined): string | undefined;
|
|
40
|
-
/** Profile-independent config root (~/.zeta), shared by every
|
|
40
|
+
/** Profile-independent config root (~/.zeta), shared by every zeta profile. */
|
|
41
41
|
export declare function getBaseConfigRoot(): string;
|
|
42
42
|
export declare function resolveEquivalentPath(inputPath: string): string;
|
|
43
43
|
export declare function normalizePathForComparison(inputPath: string): string;
|
|
44
|
+
/**
|
|
45
|
+
* Compare paths already normalized by {@link normalizePathForComparison}.
|
|
46
|
+
*
|
|
47
|
+
* Returns the relative path (an empty string when the paths are equal), or
|
|
48
|
+
* `null` when the candidate is outside the root. Callers classifying one
|
|
49
|
+
* candidate against several static roots can normalize each side once and
|
|
50
|
+
* reuse the public helpers' containment semantics without repeating realpath
|
|
51
|
+
* work.
|
|
52
|
+
*/
|
|
53
|
+
export declare function relativePathWithinNormalizedRoot(normalizedRoot: string, normalizedCandidate: string): string | null;
|
|
44
54
|
export declare function pathIsWithin(root: string, candidate: string): boolean;
|
|
45
55
|
export declare function relativePathWithinRoot(root: string, candidate: string): string | null;
|
|
46
56
|
/** Get the project directory. */
|
|
@@ -267,6 +277,13 @@ export declare function getAgentModulesDir(agentDir?: string): string;
|
|
|
267
277
|
export declare function getMemoriesDir(agentDir?: string): string;
|
|
268
278
|
/** Get the terminal sessions directory (~/.zeta/agent/terminal-sessions). */
|
|
269
279
|
export declare function getTerminalSessionsDir(agentDir?: string): string;
|
|
280
|
+
/**
|
|
281
|
+
* Get the persistent registry of custom session files
|
|
282
|
+
* (~/.zeta/agent/custom-session-files). Each `--session-dir`/`--session`
|
|
283
|
+
* transcript is recorded here as one marker file so storage GC can scan its
|
|
284
|
+
* exact path after its terminal breadcrumb is overwritten by a later session.
|
|
285
|
+
*/
|
|
286
|
+
export declare function getCustomSessionFilesDir(agentDir?: string): string;
|
|
270
287
|
/** Get the crash log path (~/.zeta/agent/zeta-crash.log). */
|
|
271
288
|
export declare function getCrashLogPath(agentDir?: string): string;
|
|
272
289
|
/** Get the debug log path (~/.zeta/agent/zeta-debug.log). */
|
package/dist/types/env.d.ts
CHANGED
|
@@ -26,11 +26,21 @@ export declare function isMacosMallocStackLoggingEnvName(name: string): boolean;
|
|
|
26
26
|
*/
|
|
27
27
|
export declare function isWsl(platform?: NodeJS.Platform, env?: NodeJS.ProcessEnv): boolean;
|
|
28
28
|
export declare function filterProcessEnv(env: Record<string, string | undefined>): Record<string, string>;
|
|
29
|
+
/**
|
|
30
|
+
* Removes {@link GIT_REPO_LOCATION_ENV_NAMES} from a copied child env in place.
|
|
31
|
+
*
|
|
32
|
+
* Windows environment lookups are case-insensitive, so a block that spells a
|
|
33
|
+
* variable `git_dir` is just as binding there; match case-insensitively on
|
|
34
|
+
* win32 and exactly elsewhere (POSIX env names are case-sensitive).
|
|
35
|
+
*/
|
|
36
|
+
export declare function stripGitRepoLocationEnv(env: Record<string, string>, platform?: NodeJS.Platform): void;
|
|
29
37
|
/** Filters process env for child shells without launch-cwd dotenv values. */
|
|
30
38
|
export declare function filterChildShellEnv(env: Record<string, string | undefined>, cwd?: string): Record<string, string>;
|
|
39
|
+
/** Return every value defined by `cwd`'s dotenv files, plus environment values that came from them. */
|
|
40
|
+
export declare function getDotenvEnvValues(cwd?: string, env?: Record<string, string | undefined>): string[];
|
|
31
41
|
/**
|
|
32
|
-
* Parses a .env file
|
|
33
|
-
*
|
|
42
|
+
* Parses a complete .env file with the runtime's dotenv grammar, then retains
|
|
43
|
+
* only shell-identifier names and spawn-safe values.
|
|
34
44
|
*/
|
|
35
45
|
export declare function parseEnvFile(filePath: string): Record<string, string>;
|
|
36
46
|
/**
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
/** Provider-specific interpretation for timezone-naive retry timestamps. */
|
|
2
|
+
export interface RetryHintOptions {
|
|
3
|
+
/** UTC offset appended to an absolute reset stamp that omits its timezone. */
|
|
4
|
+
naiveResetTimezoneOffset?: string;
|
|
5
|
+
}
|
|
1
6
|
/**
|
|
2
7
|
* Server-suggested retry delay extraction. Merges the patterns historically used
|
|
3
|
-
* by the OpenAI Codex and Google Gemini retry helpers.
|
|
4
8
|
*
|
|
5
9
|
* Header sources (checked in order):
|
|
6
10
|
* - `retry-after-ms` (milliseconds)
|
|
@@ -16,12 +20,14 @@
|
|
|
16
20
|
* - `try again in 250ms` / `try again in 12s` / `try again in 5 min` / `try again in ~158 min`
|
|
17
21
|
* - `retry-after-ms=98497000` / `retry-after-ms: 7200000` / `retry-after-ms = 7200000`
|
|
18
22
|
* - `Your limit will reset at 2026-09-01 09:44:51` / `将在 2026-09-01 09:44:51 重置`
|
|
23
|
+
* (a provider offset makes a naive wall clock authoritative; otherwise it
|
|
24
|
+
* resolves only when no relative signal is present)
|
|
19
25
|
*
|
|
20
26
|
* Returns `undefined` if no signal is found, or `0` when the provider
|
|
21
27
|
* explicitly asks for an immediate retry (`retry-after…=0`, or an absolute
|
|
22
28
|
* reset timestamp that has already elapsed).
|
|
23
29
|
*/
|
|
24
|
-
export declare function extractRetryHint(source: Response | Headers | null | undefined, body?: string): number | undefined;
|
|
30
|
+
export declare function extractRetryHint(source: Response | Headers | null | undefined, body?: string, options?: RetryHintOptions): number | undefined;
|
|
25
31
|
export interface FetchWithRetryOptions extends RequestInit {
|
|
26
32
|
/** Total fetch attempts (initial + retries). Default `5`. */
|
|
27
33
|
maxAttempts?: number;
|
|
@@ -12,12 +12,18 @@ export interface FileLockOptions {
|
|
|
12
12
|
export interface FileLockHandle {
|
|
13
13
|
release(): void;
|
|
14
14
|
}
|
|
15
|
+
/** An exclusive OS-backed lease. Releasing an already released handle is safe. */
|
|
16
|
+
export interface FileLockHandle {
|
|
17
|
+
release(): void;
|
|
18
|
+
}
|
|
15
19
|
declare function getLockPath(filePath: string): string;
|
|
16
20
|
declare function tryAcquireLock(lockPath: string): NativeFileLock | null;
|
|
17
21
|
/** Acquire an exclusive lease; callers must release it when their operation ends. */
|
|
18
22
|
export declare function acquireFileLock(filePath: string, options?: FileLockOptions): Promise<FileLockHandle>;
|
|
19
23
|
/** Run `fn` while holding an OS-backed exclusive lock for `filePath`. */
|
|
20
24
|
export declare function withFileLock<T>(filePath: string, fn: () => Promise<T>, options?: FileLockOptions): Promise<T>;
|
|
25
|
+
/** Run synchronous `fn` while holding an OS-backed exclusive lock for `filePath`. */
|
|
26
|
+
export declare function withFileLockSync<T>(filePath: string, fn: () => T, options?: FileLockOptions): T;
|
|
21
27
|
/**
|
|
22
28
|
* Test-only acquisition handle for forcing ownership handoffs. This is not
|
|
23
29
|
* part of the supported package API.
|
package/dist/types/format.d.ts
CHANGED
|
@@ -14,6 +14,13 @@ export declare function formatNumber(n: number): string;
|
|
|
14
14
|
* Examples: "512B", "1.5KB", "2.3MB", "1.2GB"
|
|
15
15
|
*/
|
|
16
16
|
export declare function formatBytes(bytes: number): string;
|
|
17
|
+
/**
|
|
18
|
+
* Count `\n` code units via native `indexOf` — no split array, roughly an
|
|
19
|
+
* order of magnitude cheaper than a per-code-unit loop on multi-MiB text.
|
|
20
|
+
* Line-count semantics are the caller's (empty text is 0 or 1 lines
|
|
21
|
+
* depending on the contract).
|
|
22
|
+
*/
|
|
23
|
+
export declare function countNewlines(text: string): number;
|
|
17
24
|
/**
|
|
18
25
|
* Truncate a string to maxLen characters, appending an ellipsis if truncated.
|
|
19
26
|
* For display-width-aware truncation (terminals), use truncateToWidth from @linxiraos/pi-tui.
|
package/dist/types/index.d.ts
CHANGED
|
@@ -4,12 +4,12 @@ export * from "./binary.js";
|
|
|
4
4
|
export * from "./color.js";
|
|
5
5
|
export * from "./dirs.js";
|
|
6
6
|
export * from "./env.js";
|
|
7
|
+
export * from "./executable.js";
|
|
7
8
|
export * from "./fetch-retry.js";
|
|
8
9
|
export * from "./file-lock.js";
|
|
9
10
|
export * from "./format.js";
|
|
10
11
|
export * from "./frontmatter.js";
|
|
11
12
|
export * from "./fs-error.js";
|
|
12
|
-
export * from "./glob.js";
|
|
13
13
|
export * from "./incoming-json.js";
|
|
14
14
|
export * from "./json.js";
|
|
15
15
|
export * from "./json-parse.js";
|
|
@@ -40,4 +40,5 @@ export * from "./tls-fetch.js";
|
|
|
40
40
|
export * from "./type-guards.js";
|
|
41
41
|
export * from "./version.js";
|
|
42
42
|
export * from "./which.js";
|
|
43
|
+
export * from "./yaml-config.js";
|
|
43
44
|
export declare function structuredCloneJSON<T>(value: T): T;
|
package/dist/types/mime.d.ts
CHANGED
package/dist/types/path.d.ts
CHANGED
|
@@ -2,3 +2,9 @@
|
|
|
2
2
|
export declare function windowsPathToWslMount(filePath: string): string | undefined;
|
|
3
3
|
/** Removes Win32 extended-length prefixes before passing paths to Bun APIs. */
|
|
4
4
|
export declare function stripWindowsExtendedLengthPathPrefix(filePath: string, platform?: NodeJS.Platform): string;
|
|
5
|
+
/**
|
|
6
|
+
* Test whether a path is fully qualified and drive-independent.
|
|
7
|
+
* On Windows, requires a drive letter with separator (e.g. `C:\`) or UNC (`\\server\share` or `//server/share`).
|
|
8
|
+
* On POSIX, requires an absolute path.
|
|
9
|
+
*/
|
|
10
|
+
export declare function isFullyQualifiedPath(filePath: string, platform?: NodeJS.Platform): boolean;
|
|
@@ -10,9 +10,8 @@ export declare function peekFile<T>(filePath: string, maxBytes: number, op: (hea
|
|
|
10
10
|
/**
|
|
11
11
|
* Read up to the last `maxBytes` of `filePath` and pass that slice to `op`.
|
|
12
12
|
*
|
|
13
|
-
* The tail mirror of {@link peekFile}:
|
|
14
|
-
*
|
|
15
|
-
* window ends at EOF. When the file is shorter than `maxBytes`, the whole file is
|
|
13
|
+
* The tail mirror of {@link peekFile}: the read is positioned at `size - len` so
|
|
14
|
+
* the window ends at EOF. When the file is shorter than `maxBytes`, the whole file is
|
|
16
15
|
* returned. A multi-byte codepoint straddling the leading cut decodes to a
|
|
17
16
|
* replacement char — callers that parse line-oriented tails drop the partial
|
|
18
17
|
* leading line anyway.
|
|
@@ -27,6 +27,27 @@ export declare enum Reason {
|
|
|
27
27
|
* instances across bundles/realms.
|
|
28
28
|
*/
|
|
29
29
|
export declare const NATIVE_PROCESS_EXIT: unique symbol;
|
|
30
|
+
/**
|
|
31
|
+
* Hard-exit the process through the native primitive, resolved on every call.
|
|
32
|
+
*
|
|
33
|
+
* The native exit is deliberately re-resolved here rather than bound at module
|
|
34
|
+
* load: the extension/hook loader's `withHostGuard` transiently swaps
|
|
35
|
+
* `process.reallyExit`/`process.exit` for a stub that throws
|
|
36
|
+
* `ExtensionExitError`, and the shipped bundle defers this module's evaluation
|
|
37
|
+
* until first access — which can land inside that guard window, so binding at
|
|
38
|
+
* init could freeze the throwing stub forever and turn every later shutdown
|
|
39
|
+
* (SIGHUP/SIGINT/fatal) into an unhandled-rejection loop (#7393). When the
|
|
40
|
+
* guard is active the stub carries the native exit under
|
|
41
|
+
* {@link NATIVE_PROCESS_EXIT} (#6488).
|
|
42
|
+
*
|
|
43
|
+
* Both globals are reinstalled to their natives before exiting: Bun's
|
|
44
|
+
* `process.exit` re-reads `process.reallyExit` at call time, so exiting through
|
|
45
|
+
* one primitive while its sibling still holds the throwing stub re-enters the
|
|
46
|
+
* guard and loops the rejection storm (#11789). After restoring, `reallyExit`
|
|
47
|
+
* (the low-level primitive) is preferred; `process.exit` and finally `SIGKILL`
|
|
48
|
+
* are fallbacks so a poisoned or absent chain can never leave the process alive.
|
|
49
|
+
*/
|
|
50
|
+
export declare function exitProcess(code: number): never;
|
|
30
51
|
/** User-facing command printed before fatal cleanup so interrupted work can be resumed. */
|
|
31
52
|
export interface FatalRecoveryHint {
|
|
32
53
|
/** Stable label identifying the recoverable session or process. */
|
|
@@ -91,11 +112,11 @@ export declare function isWorkerIpcDeserializeError(err: unknown): boolean;
|
|
|
91
112
|
*/
|
|
92
113
|
export declare function registerWorkerIpcFaultHandler(handler: (err: Error) => void): () => void;
|
|
93
114
|
/**
|
|
94
|
-
* Treat
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
115
|
+
* Treat a closed stdout consumer as a graceful peer disconnect for the caller's
|
|
116
|
+
* active lifetime. Attaches one shared `process.stdout` `error` listener,
|
|
117
|
+
* ref-counted across registrants (the ACP protocol server, the one-shot CLI
|
|
118
|
+
* entry). The returned callback removes the registration; the listener detaches
|
|
119
|
+
* when the last registrant unregisters.
|
|
99
120
|
*/
|
|
100
121
|
export declare function registerStdioDisconnectHandling(): () => void;
|
|
101
122
|
/**
|
package/dist/types/procmgr.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { Subprocess } from "bun";
|
|
2
|
+
import { isExecutable } from "./executable.js";
|
|
3
|
+
export { isExecutable };
|
|
2
4
|
export interface ShellConfig {
|
|
3
5
|
shell: string;
|
|
4
6
|
args: string[];
|
|
@@ -10,10 +12,6 @@ export interface ShellConfigOptions {
|
|
|
10
12
|
/** File path or runtime layer that supplied the active shell setting. */
|
|
11
13
|
configSource?: string;
|
|
12
14
|
}
|
|
13
|
-
/**
|
|
14
|
-
* Check if a shell binary is executable.
|
|
15
|
-
*/
|
|
16
|
-
export declare function isExecutable(path: string): boolean;
|
|
17
15
|
/**
|
|
18
16
|
* Get shell args for the resolved shell.
|
|
19
17
|
* cmd.exe takes `/c`; PowerShell (powershell.exe / pwsh) takes
|
package/dist/types/sqlite.d.ts
CHANGED
|
@@ -1,13 +1,33 @@
|
|
|
1
|
+
/** Shared SQLite opening, error attribution, and result-code classification for persistent stores. */
|
|
2
|
+
import { Database } from "bun:sqlite";
|
|
3
|
+
/** Controls opt-in replacement of an unrecoverably corrupt SQLite store. */
|
|
4
|
+
export interface SqliteOpenOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Preserve a corrupt store and its sidecars, recreate it, and run the
|
|
7
|
+
* initializer once more. Disabled by default.
|
|
8
|
+
*/
|
|
9
|
+
recoverCorruption?: boolean;
|
|
10
|
+
/** Runs after preservation and before the replacement is initialized. */
|
|
11
|
+
onCorruptionPreserved?: (backupPath: string, error: unknown) => void;
|
|
12
|
+
}
|
|
1
13
|
/**
|
|
2
|
-
*
|
|
14
|
+
* Opens and initializes a store, retrying BUSY failures up to four total attempts.
|
|
15
|
+
* Installs the busy handler before initialization and closes failed connections.
|
|
16
|
+
* The initializer may run again on a fresh connection; on success it owns the handle.
|
|
3
17
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* credential store and the model cache.
|
|
18
|
+
* With corruption recovery enabled, recovery is serialized across processes.
|
|
19
|
+
* The identity observed by the failed handle is checked under that lock, so a
|
|
20
|
+
* waiter adopts a replacement made by a peer instead of quarantining it.
|
|
21
|
+
* Final failures retain their SQLite codes and include the database path.
|
|
9
22
|
*/
|
|
10
|
-
|
|
23
|
+
export declare function openSqliteDatabase<T>(dbPath: string, initialize: (db: Database) => T | Promise<T>, options?: SqliteOpenOptions): Promise<T>;
|
|
24
|
+
/**
|
|
25
|
+
* Synchronous counterpart to {@link openSqliteDatabase}. It performs no BUSY
|
|
26
|
+
* retry loop; corruption recovery, when enabled, is bounded to one replacement.
|
|
27
|
+
*/
|
|
28
|
+
export declare function openSqliteDatabaseSync<T>(dbPath: string, initialize: (db: Database) => T, options?: SqliteOpenOptions): T;
|
|
29
|
+
/** Adds the failing store's path to an error without losing SQLite result codes or its original stack. */
|
|
30
|
+
export declare function annotateSqliteError(error: unknown, dbPath: string): Error;
|
|
11
31
|
/** Checkpoints committed WAL frames without waiting for concurrent readers. */
|
|
12
32
|
export declare function checkpointWal(db: Database): void;
|
|
13
33
|
/**
|
package/dist/types/stream.d.ts
CHANGED
|
@@ -1,5 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Split a byte stream on LF boundaries.
|
|
3
|
+
*
|
|
4
|
+
* Every yielded line owns its bytes and remains unchanged after the generator
|
|
5
|
+
* advances or drains. Line terminators are excluded.
|
|
6
|
+
*/
|
|
1
7
|
export declare function readLines(stream: ReadableStream<Uint8Array>, signal?: AbortSignal): AsyncGenerator<Uint8Array>;
|
|
2
8
|
export declare function readJsonl<T>(stream: ReadableStream<Uint8Array>, signal?: AbortSignal): AsyncGenerator<T>;
|
|
9
|
+
/**
|
|
10
|
+
* Amortized byte accumulator for chunked stream readers.
|
|
11
|
+
*
|
|
12
|
+
* Holds the unconsumed tail of a stream in a single growing `Buffer` so that
|
|
13
|
+
* appending N chunks costs O(total bytes) instead of re-copying the whole
|
|
14
|
+
* prefix per chunk. Backs {@link readLines}, {@link readJsonl} and
|
|
15
|
+
* {@link readSseEvents}; also usable directly when a reader needs its own
|
|
16
|
+
* framing loop (see `consume` and `flush`).
|
|
17
|
+
*/
|
|
18
|
+
export declare class ConcatSink {
|
|
19
|
+
#private;
|
|
20
|
+
append(chunk: Uint8Array): void;
|
|
21
|
+
reset(chunk: Uint8Array): void;
|
|
22
|
+
get isEmpty(): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* The buffered bytes as a live view — invalidated by the next `append`,
|
|
25
|
+
* `reset` or `consume`.
|
|
26
|
+
*/
|
|
27
|
+
flush(): Uint8Array | undefined;
|
|
28
|
+
/** Drop the first `count` buffered bytes, keeping the remainder. */
|
|
29
|
+
consume(count: number): void;
|
|
30
|
+
clear(): void;
|
|
31
|
+
/**
|
|
32
|
+
* Append a chunk and yield each complete LF-delimited line.
|
|
33
|
+
*
|
|
34
|
+
* Yielded lines are owned snapshots. Unlike {@link flush}, they remain
|
|
35
|
+
* valid after this sink or the input chunk is mutated.
|
|
36
|
+
*/
|
|
37
|
+
appendAndFlushLines(chunk: Uint8Array): Generator<Uint8Array>;
|
|
38
|
+
appendAndFlushText(chunk: Uint8Array, decoder: TextDecoder): string | undefined;
|
|
39
|
+
pullJSONL<T>(chunk: Uint8Array, beg: number, end: number): Generator<T, void, unknown>;
|
|
40
|
+
}
|
|
3
41
|
/**
|
|
4
42
|
* Stream parsed JSON objects from SSE `data:` lines.
|
|
5
43
|
*
|
|
@@ -18,6 +56,25 @@ export declare function readJsonl<T>(stream: ReadableStream<Uint8Array>, signal?
|
|
|
18
56
|
*/
|
|
19
57
|
export type SseEventObserver = (event: ServerSentEvent) => void;
|
|
20
58
|
export declare function readSseJson<T>(stream: ReadableStream<Uint8Array>, signal?: AbortSignal, onEvent?: SseEventObserver): AsyncGenerator<T>;
|
|
59
|
+
/**
|
|
60
|
+
* Like {@link readSseJson}, but a `data:` frame that is not valid JSON is yielded
|
|
61
|
+
* as its raw text instead of raising a `SyntaxError`. Cut-off container-shaped
|
|
62
|
+
* stream tails stay recoverable, exactly as they are in {@link readSseJson}.
|
|
63
|
+
*
|
|
64
|
+
* Consumers that only understand objects must treat a `string` yield as a
|
|
65
|
+
* transport-level failure (for example a `429 Too Many Requests` or an HTML
|
|
66
|
+
* throttle page from a reverse proxy that already committed to the stream). This
|
|
67
|
+
* exists because `readSseJson`'s baseline consumers span unrelated transports
|
|
68
|
+
* whose error handling a text yield would subtly change; new call sites opt in.
|
|
69
|
+
*
|
|
70
|
+
* Note that the text lane is only the frames `JSON.parse` *rejected*: a frame
|
|
71
|
+
* carrying a JSON-encoded string (`data: "429 Too Many Requests"`) parses, so it
|
|
72
|
+
* is yielded as that string and is indistinguishable from a rejected frame by
|
|
73
|
+
* type alone. Consumers branching on `typeof === "string"` therefore see both,
|
|
74
|
+
* which is the safe direction — each is classified as text rather than trusted as
|
|
75
|
+
* an event object.
|
|
76
|
+
*/
|
|
77
|
+
export declare function readSseJsonOrText<T>(stream: ReadableStream<Uint8Array>, signal?: AbortSignal, onEvent?: SseEventObserver): AsyncGenerator<T | string>;
|
|
21
78
|
/**
|
|
22
79
|
* A single Server-Sent Event dispatched on a blank-line boundary.
|
|
23
80
|
*
|
|
@@ -34,6 +91,15 @@ export declare function readSseJson<T>(stream: ReadableStream<Uint8Array>, signa
|
|
|
34
91
|
export interface ServerSentEvent {
|
|
35
92
|
event: string | null;
|
|
36
93
|
data: string;
|
|
94
|
+
/**
|
|
95
|
+
* Decoded wire lines for this event (`event:`/`data:`/etc.), for the
|
|
96
|
+
* diagnostic pipeline. Populated only when the reader opts in via
|
|
97
|
+
* {@link ReadSseEventsOptions.captureRaw} (or attaches an `onSseEvent`
|
|
98
|
+
* observer to the JSON readers, which opt in automatically); otherwise
|
|
99
|
+
* `[]`. Direct `readSseEvents` callers that need wire text must pass
|
|
100
|
+
* `{ captureRaw: true }` — the field is allocation-free by default so
|
|
101
|
+
* the token path pays no per-frame array/slice cost.
|
|
102
|
+
*/
|
|
37
103
|
raw: string[];
|
|
38
104
|
id?: string;
|
|
39
105
|
retry?: number;
|
|
@@ -57,7 +123,16 @@ export interface ServerSentEvent {
|
|
|
57
123
|
* }
|
|
58
124
|
* ```
|
|
59
125
|
*/
|
|
60
|
-
export
|
|
126
|
+
export interface ReadSseEventsOptions {
|
|
127
|
+
/**
|
|
128
|
+
* Capture per-line wire text into `event.raw` for the diagnostic
|
|
129
|
+
* pipeline (`onSseEvent` observers, raw-SSE viewer). Off by default:
|
|
130
|
+
* every frame otherwise pays an array allocation plus one string slice
|
|
131
|
+
* per line on the token path.
|
|
132
|
+
*/
|
|
133
|
+
captureRaw?: boolean;
|
|
134
|
+
}
|
|
135
|
+
export declare function readSseEvents(stream: ReadableStream<Uint8Array>, signal?: AbortSignal, options?: ReadSseEventsOptions): AsyncGenerator<ServerSentEvent>;
|
|
61
136
|
/**
|
|
62
137
|
* Parse a complete JSONL string, skipping malformed lines instead of throwing.
|
|
63
138
|
*
|
package/dist/types/which.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Cache policy for which lookups.
|
|
3
3
|
*/
|
|
4
|
-
export declare
|
|
4
|
+
export declare enum WhichCachePolicy {
|
|
5
5
|
/**
|
|
6
6
|
* Use cached result if available.
|
|
7
7
|
*/
|
|
@@ -22,9 +22,15 @@ export declare const enum WhichCachePolicy {
|
|
|
22
22
|
export interface WhichOptions extends Bun.WhichOptions {
|
|
23
23
|
/**
|
|
24
24
|
* Cache policy for the lookup.
|
|
25
|
-
* Defaults to `WhichCachePolicy.
|
|
25
|
+
* Defaults to `WhichCachePolicy.Cached`.
|
|
26
26
|
*/
|
|
27
27
|
cache?: WhichCachePolicy;
|
|
28
|
+
/**
|
|
29
|
+
* Only search absolute directory entries in PATH, ignoring relative entries
|
|
30
|
+
* (e.g. `.` or `./bin`) and empty components to prevent resolving against
|
|
31
|
+
* an untrusted working directory.
|
|
32
|
+
*/
|
|
33
|
+
requireAbsolutePaths?: boolean;
|
|
28
34
|
}
|
|
29
35
|
declare function darwinWhich(command: string, options?: Bun.WhichOptions): string | null;
|
|
30
36
|
export declare const whichFresh: typeof darwinWhich;
|