jeopi-utils 16.2.13 → 16.2.14
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 +3 -1
- package/README.md +2 -2
- package/package.json +6 -6
- package/src/dirs.ts +123 -75
- package/src/logger.ts +1 -1
- package/src/procmgr.ts +2 -2
- package/dist/types/abortable.d.ts +0 -32
- package/dist/types/async.d.ts +0 -6
- package/dist/types/binary.d.ts +0 -17
- package/dist/types/cli.d.ts +0 -117
- package/dist/types/color.d.ts +0 -102
- package/dist/types/dirs.d.ts +0 -260
- package/dist/types/env.d.ts +0 -74
- package/dist/types/fetch-retry.d.ts +0 -94
- package/dist/types/format.d.ts +0 -37
- package/dist/types/frontmatter.d.ts +0 -25
- package/dist/types/fs-error.d.ts +0 -31
- package/dist/types/glob.d.ts +0 -28
- package/dist/types/index.d.ts +0 -35
- package/dist/types/json-parse.d.ts +0 -48
- package/dist/types/json.d.ts +0 -4
- package/dist/types/logger.d.ts +0 -83
- package/dist/types/loop-phase.d.ts +0 -10
- package/dist/types/mermaid-ascii.d.ts +0 -11
- package/dist/types/mime.d.ts +0 -29
- package/dist/types/module-timer.d.ts +0 -1
- package/dist/types/path-tree.d.ts +0 -76
- package/dist/types/path.d.ts +0 -2
- package/dist/types/peek-file.d.ts +0 -29
- package/dist/types/postmortem.d.ts +0 -37
- package/dist/types/procmgr.d.ts +0 -29
- package/dist/types/prompt.d.ts +0 -18
- package/dist/types/ptree.d.ts +0 -108
- package/dist/types/ring.d.ts +0 -93
- package/dist/types/runtime-install.d.ts +0 -68
- package/dist/types/sanitize-text.d.ts +0 -29
- package/dist/types/snowflake.d.ts +0 -25
- package/dist/types/stream.d.ts +0 -68
- package/dist/types/tab-spacing.d.ts +0 -24
- package/dist/types/temp.d.ts +0 -17
- package/dist/types/timing-buffer.d.ts +0 -22
- package/dist/types/tls-fetch.d.ts +0 -37
- package/dist/types/type-guards.d.ts +0 -3
- package/dist/types/vendor/mermaid-ascii/ascii/ansi.d.ts +0 -41
- package/dist/types/vendor/mermaid-ascii/ascii/canvas.d.ts +0 -89
- package/dist/types/vendor/mermaid-ascii/ascii/class-diagram.d.ts +0 -7
- package/dist/types/vendor/mermaid-ascii/ascii/converter.d.ts +0 -12
- package/dist/types/vendor/mermaid-ascii/ascii/draw.d.ts +0 -66
- package/dist/types/vendor/mermaid-ascii/ascii/edge-bundling.d.ts +0 -48
- package/dist/types/vendor/mermaid-ascii/ascii/edge-routing.d.ts +0 -43
- package/dist/types/vendor/mermaid-ascii/ascii/er-diagram.d.ts +0 -7
- package/dist/types/vendor/mermaid-ascii/ascii/grid.d.ts +0 -56
- package/dist/types/vendor/mermaid-ascii/ascii/index.d.ts +0 -65
- package/dist/types/vendor/mermaid-ascii/ascii/multiline-utils.d.ts +0 -27
- package/dist/types/vendor/mermaid-ascii/ascii/pathfinder.d.ts +0 -17
- package/dist/types/vendor/mermaid-ascii/ascii/sequence.d.ts +0 -7
- package/dist/types/vendor/mermaid-ascii/ascii/shapes/circle.d.ts +0 -11
- package/dist/types/vendor/mermaid-ascii/ascii/shapes/corners.d.ts +0 -34
- package/dist/types/vendor/mermaid-ascii/ascii/shapes/diamond.d.ts +0 -11
- package/dist/types/vendor/mermaid-ascii/ascii/shapes/hexagon.d.ts +0 -11
- package/dist/types/vendor/mermaid-ascii/ascii/shapes/index.d.ts +0 -26
- package/dist/types/vendor/mermaid-ascii/ascii/shapes/rectangle.d.ts +0 -31
- package/dist/types/vendor/mermaid-ascii/ascii/shapes/rounded.d.ts +0 -11
- package/dist/types/vendor/mermaid-ascii/ascii/shapes/special.d.ts +0 -59
- package/dist/types/vendor/mermaid-ascii/ascii/shapes/stadium.d.ts +0 -17
- package/dist/types/vendor/mermaid-ascii/ascii/shapes/state.d.ts +0 -30
- package/dist/types/vendor/mermaid-ascii/ascii/shapes/types.d.ts +0 -55
- package/dist/types/vendor/mermaid-ascii/ascii/types.d.ts +0 -206
- package/dist/types/vendor/mermaid-ascii/ascii/validate.d.ts +0 -51
- package/dist/types/vendor/mermaid-ascii/ascii/xychart.d.ts +0 -2
- package/dist/types/vendor/mermaid-ascii/class/parser.d.ts +0 -6
- package/dist/types/vendor/mermaid-ascii/class/types.d.ts +0 -102
- package/dist/types/vendor/mermaid-ascii/er/parser.d.ts +0 -6
- package/dist/types/vendor/mermaid-ascii/er/types.d.ts +0 -76
- package/dist/types/vendor/mermaid-ascii/index.d.ts +0 -1
- package/dist/types/vendor/mermaid-ascii/multiline-utils.d.ts +0 -9
- package/dist/types/vendor/mermaid-ascii/parser.d.ts +0 -7
- package/dist/types/vendor/mermaid-ascii/sequence/parser.d.ts +0 -6
- package/dist/types/vendor/mermaid-ascii/sequence/types.d.ts +0 -130
- package/dist/types/vendor/mermaid-ascii/text-metrics.d.ts +0 -21
- package/dist/types/vendor/mermaid-ascii/types.d.ts +0 -114
- package/dist/types/vendor/mermaid-ascii/xychart/colors.d.ts +0 -25
- package/dist/types/vendor/mermaid-ascii/xychart/parser.d.ts +0 -6
- package/dist/types/vendor/mermaid-ascii/xychart/types.d.ts +0 -145
- package/dist/types/which.d.ts +0 -37
- package/dist/types/worker-host.d.ts +0 -47
package/CHANGELOG.md
CHANGED
|
@@ -2,13 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [16.2.14] - 2026-07-02
|
|
6
|
+
|
|
5
7
|
### Added
|
|
6
8
|
|
|
7
9
|
- Added `wrapFetchForExtraCa` and `withExtraCaFetch` utility functions to apply `NODE_EXTRA_CA_CERTS` to Bun's `RequestInit.tls.ca` configuration.
|
|
8
10
|
|
|
9
11
|
### Changed
|
|
10
12
|
|
|
11
|
-
- Renamed `APP_NAME` from `omp` to `jeopi`. `CONFIG_DIR_NAME`
|
|
13
|
+
- Renamed `APP_NAME` from `omp` to `jeopi`. `CONFIG_DIR_NAME` is now `.jeopi` (was `.omp`); XDG app directories and log-file prefixes now use `jeopi`. Added `LEGACY_CONFIG_DIR_NAME` (`.omp`), `hasUnmigratedLegacyConfigDir()`, and `migrateLegacyConfigDir()` to detect and move an existing `~/.omp` to `~/.jeopi` (exposed as `jeopi config migrate-legacy` in coding-agent) — never run automatically, so a live process never renames a directory another process might have open.
|
|
12
14
|
- The rotating log transport and crash-log path now derive their filename from `APP_NAME` (`jeopi.<DATE>.log`, `jeopi-crash.log`) instead of hardcoding `omp.*`, matching `getLogPath()`/`getDebugLogPath()` so path helpers and the writer agree.
|
|
13
15
|
|
|
14
16
|
## [16.2.9] - 2026-06-30
|
package/README.md
CHANGED
|
@@ -6,9 +6,9 @@ Shared utilities for [oh-my-pi](https://github.com/can1357/oh-my-pi) packages. Z
|
|
|
6
6
|
|
|
7
7
|
| Module | Purpose |
|
|
8
8
|
| --- | --- |
|
|
9
|
-
| `logger` | Centralized logger writing to `~/.
|
|
9
|
+
| `logger` | Centralized logger writing to `~/.jeopi/logs/` with rotation (TUI-safe — never stdout) |
|
|
10
10
|
| `prompt` | Handlebars-based prompt templating and formatting helpers |
|
|
11
|
-
| `dirs` | Path helpers for omp config directories (`~/.
|
|
11
|
+
| `dirs` | Path helpers for omp config directories (`~/.jeopi`, XDG-aware on Linux) |
|
|
12
12
|
| `stream` | `readStream` / `readLines` helpers over `ReadableStream` |
|
|
13
13
|
| `ptree` / `procmgr` | Process trees, `ChildProcess` wrapper, process lifecycle management |
|
|
14
14
|
| `postmortem` | Cleanup callbacks on exit, signals, and fatal exceptions |
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "jeopi-utils",
|
|
4
|
-
"version": "16.2.
|
|
4
|
+
"version": "16.2.14",
|
|
5
5
|
"description": "Shared utilities for pi packages",
|
|
6
6
|
"homepage": "https://github.com/akillness/jeopi",
|
|
7
7
|
"author": "Can Boluk",
|
|
@@ -31,13 +31,13 @@
|
|
|
31
31
|
"fmt": "biome format --write ."
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"jeopi-natives": "
|
|
35
|
-
"handlebars": "
|
|
36
|
-
"winston": "
|
|
37
|
-
"winston-daily-rotate-file": "
|
|
34
|
+
"jeopi-natives": "catalog:",
|
|
35
|
+
"handlebars": "catalog:",
|
|
36
|
+
"winston": "catalog:",
|
|
37
|
+
"winston-daily-rotate-file": "catalog:"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@types/bun": "
|
|
40
|
+
"@types/bun": "catalog:"
|
|
41
41
|
},
|
|
42
42
|
"engines": {
|
|
43
43
|
"bun": ">=1.3.14"
|
package/src/dirs.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Centralized path helpers for
|
|
2
|
+
* Centralized path helpers for jeopi config directories.
|
|
3
3
|
*
|
|
4
|
-
* Uses PI_CONFIG_DIR (default ".
|
|
4
|
+
* Uses PI_CONFIG_DIR (default ".jeopi") for the config root and
|
|
5
5
|
* PI_CODING_AGENT_DIR to override the agent directory.
|
|
6
6
|
*
|
|
7
7
|
* On Linux, if XDG_DATA_HOME / XDG_STATE_HOME / XDG_CACHE_HOME environment
|
|
8
8
|
* variables are set, paths are redirected to XDG-compliant locations under
|
|
9
|
-
* $XDG_*_HOME/
|
|
9
|
+
* $XDG_*_HOME/jeopi/. This requires running `jeopi config init-xdg` first to
|
|
10
10
|
* move data to the new locations. No filesystem existence checks are performed
|
|
11
|
-
* — if the env var is set,
|
|
11
|
+
* — if the env var is set, jeopi trusts that the migration has been done.
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
import * as fs from "node:fs";
|
|
@@ -19,8 +19,11 @@ import { engines, version } from "../package.json" with { type: "json" };
|
|
|
19
19
|
/** App name (e.g. "jeopi") */
|
|
20
20
|
export const APP_NAME: string = "jeopi";
|
|
21
21
|
|
|
22
|
-
/** Config directory name (e.g. ".
|
|
23
|
-
export const CONFIG_DIR_NAME: string = ".
|
|
22
|
+
/** Config directory name (e.g. ".jeopi") */
|
|
23
|
+
export const CONFIG_DIR_NAME: string = ".jeopi";
|
|
24
|
+
|
|
25
|
+
/** Pre-rebrand config directory name, kept only to detect and migrate unmigrated installs. */
|
|
26
|
+
export const LEGACY_CONFIG_DIR_NAME: string = ".omp";
|
|
24
27
|
|
|
25
28
|
/** Version (e.g. "1.0.0") */
|
|
26
29
|
export const VERSION: string = version;
|
|
@@ -199,12 +202,12 @@ export async function directoryExists(dir: string): Promise<boolean> {
|
|
|
199
202
|
}
|
|
200
203
|
}
|
|
201
204
|
|
|
202
|
-
/** Get the config directory name relative to home (e.g. ".
|
|
205
|
+
/** Get the config directory name relative to home (e.g. ".jeopi" or PI_CONFIG_DIR override). */
|
|
203
206
|
export function getConfigDirName(): string {
|
|
204
207
|
return process.env.PI_CONFIG_DIR || CONFIG_DIR_NAME;
|
|
205
208
|
}
|
|
206
209
|
|
|
207
|
-
/** Get the config agent directory name relative to home (e.g. ".
|
|
210
|
+
/** Get the config agent directory name relative to home (e.g. ".jeopi/agent" or PI_CONFIG_DIR + "/agent"). */
|
|
208
211
|
export function getConfigAgentDirName(): string {
|
|
209
212
|
const profile = getActiveProfile();
|
|
210
213
|
return profile ? path.join(getConfigDirName(), "profiles", profile, "agent") : `${getConfigDirName()}/agent`;
|
|
@@ -217,8 +220,8 @@ export function getConfigAgentDirName(): string {
|
|
|
217
220
|
type XdgCategory = "data" | "state" | "cache";
|
|
218
221
|
|
|
219
222
|
/**
|
|
220
|
-
* Resolves and caches all
|
|
221
|
-
* variables are set, paths are redirected under $XDG_*_HOME/
|
|
223
|
+
* Resolves and caches all jeopi directory paths. On Linux, when XDG environment
|
|
224
|
+
* variables are set, paths are redirected under $XDG_*_HOME/jeopi/. A new
|
|
222
225
|
* instance is created whenever the agent directory changes, which naturally
|
|
223
226
|
* invalidates all cached paths.
|
|
224
227
|
*/
|
|
@@ -227,7 +230,7 @@ class DirResolver {
|
|
|
227
230
|
readonly agentDir: string;
|
|
228
231
|
|
|
229
232
|
// Per-category base dirs. Without XDG, all three equal configRoot / agentDir.
|
|
230
|
-
// With XDG on Linux, they point to $XDG_*_HOME/
|
|
233
|
+
// With XDG on Linux, they point to $XDG_*_HOME/jeopi/.
|
|
231
234
|
readonly #rootDirs: Record<XdgCategory, string>;
|
|
232
235
|
readonly #agentDirs: Record<XdgCategory, string>;
|
|
233
236
|
|
|
@@ -244,14 +247,14 @@ class DirResolver {
|
|
|
244
247
|
const isDefault = this.agentDir === defaultAgent;
|
|
245
248
|
|
|
246
249
|
// XDG is a Linux convention. On supported platforms, default profile state
|
|
247
|
-
// resolves under $XDG_*_HOME/
|
|
250
|
+
// resolves under $XDG_*_HOME/jeopi once `jeopi config init-xdg` has migrated
|
|
248
251
|
// the user's data. Named profiles follow a stricter rule: the XDG choice
|
|
249
252
|
// is keyed on the profile-specific XDG path, never the base app root.
|
|
250
253
|
//
|
|
251
254
|
// Why: if we consulted the base app root for named profiles too, the same
|
|
252
|
-
// profile could resolve to `~/.
|
|
253
|
-
// (when no $XDG_*_HOME/
|
|
254
|
-
// `$XDG_*_HOME/
|
|
255
|
+
// profile could resolve to `~/.jeopi/profiles/<name>` on first activation
|
|
256
|
+
// (when no $XDG_*_HOME/jeopi exists yet) and then silently move to
|
|
257
|
+
// `$XDG_*_HOME/jeopi/profiles/<name>` the moment the base appeared, orphaning
|
|
255
258
|
// the earlier state. Pinning on the profile path means a profile's location
|
|
256
259
|
// is decided at first activation and stays put until the user explicitly
|
|
257
260
|
// migrates it (e.g. by mkdir'ing the XDG profile dir).
|
|
@@ -287,7 +290,7 @@ class DirResolver {
|
|
|
287
290
|
state: xdgState ?? this.configRoot,
|
|
288
291
|
cache: xdgCache ?? this.configRoot,
|
|
289
292
|
};
|
|
290
|
-
// XDG flattens the agent/ prefix: ~/.
|
|
293
|
+
// XDG flattens the agent/ prefix: ~/.jeopi/agent/sessions → $XDG_DATA_HOME/jeopi/sessions
|
|
291
294
|
this.#agentDirs = {
|
|
292
295
|
data: xdgData ?? this.agentDir,
|
|
293
296
|
state: xdgState ?? this.agentDir,
|
|
@@ -327,7 +330,7 @@ class DirResolver {
|
|
|
327
330
|
* agent dir. The profile source can be the active profile or a lower-priority
|
|
328
331
|
* `PI_PROFILE` that was bypassed because `OMP_PROFILE` explicitly selected the
|
|
329
332
|
* default profile. Returns `undefined` in those cases so reset falls back to the
|
|
330
|
-
* standard `~/.
|
|
333
|
+
* standard `~/.jeopi/agent`.
|
|
331
334
|
*/
|
|
332
335
|
function resolvePreProfileAgentDir(
|
|
333
336
|
profile: string | undefined,
|
|
@@ -362,7 +365,7 @@ let dirs = new DirResolver({
|
|
|
362
365
|
* unconditionally deleting the env var. Without the snapshot, a process started
|
|
363
366
|
* with `PI_CODING_AGENT_DIR=/custom` then `setProfile("work")` then
|
|
364
367
|
* `setProfile(undefined)` would silently lose `/custom` and fall back to
|
|
365
|
-
* `~/.
|
|
368
|
+
* `~/.jeopi/agent`. Captured at module load — ignoring a profile-derived value
|
|
366
369
|
* inherited from a parent's `setProfile` (see {@link resolvePreProfileAgentDir})
|
|
367
370
|
* — and refreshed on `setAgentDir`, since that call is the user explicitly
|
|
368
371
|
* redefining the baseline.
|
|
@@ -399,11 +402,56 @@ export function refreshDirsFromEnv(): void {
|
|
|
399
402
|
// Root directories
|
|
400
403
|
// =============================================================================
|
|
401
404
|
|
|
402
|
-
/** Get the config root directory (~/.
|
|
405
|
+
/** Get the config root directory (~/.jeopi). */
|
|
403
406
|
export function getConfigRootDir(): string {
|
|
404
407
|
return dirs.configRoot;
|
|
405
408
|
}
|
|
406
409
|
|
|
410
|
+
/**
|
|
411
|
+
* Whether an unmigrated pre-rebrand config directory exists at `~/.omp` while
|
|
412
|
+
* the new `~/.jeopi` root does not. Read-only — never renames anything. Used
|
|
413
|
+
* by CLI startup to print a one-time migration hint and by `{APP_NAME} config
|
|
414
|
+
* migrate-legacy` to decide whether there is anything to do.
|
|
415
|
+
*
|
|
416
|
+
* Always `false` when `PI_CONFIG_DIR` is set: an explicit override means the
|
|
417
|
+
* user already manages their own directory name and the legacy default is
|
|
418
|
+
* irrelevant.
|
|
419
|
+
*/
|
|
420
|
+
export function hasUnmigratedLegacyConfigDir(): boolean {
|
|
421
|
+
if (process.env.PI_CONFIG_DIR) return false;
|
|
422
|
+
const legacy = path.join(os.homedir(), LEGACY_CONFIG_DIR_NAME);
|
|
423
|
+
const current = path.join(os.homedir(), CONFIG_DIR_NAME);
|
|
424
|
+
return fs.existsSync(legacy) && !fs.existsSync(current);
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* Rename `~/.omp` to `~/.jeopi` in place, carrying over auth, sessions,
|
|
429
|
+
* settings, and every profile in one atomic move. Explicit and opt-in
|
|
430
|
+
* (`{APP_NAME} config migrate-legacy`) — never invoked automatically at
|
|
431
|
+
* module load or from {@link DirResolver}, so a running process never renames
|
|
432
|
+
* a directory another concurrent process might have open.
|
|
433
|
+
*
|
|
434
|
+
* Throws if `PI_CONFIG_DIR` is set, if `~/.omp` does not exist, or if
|
|
435
|
+
* `~/.jeopi` already exists (refuses to clobber). Callers own reporting;
|
|
436
|
+
* this performs the single `fs.renameSync` and nothing else — no cache
|
|
437
|
+
* invalidation, since the resolver reads `os.homedir()` fresh on next use.
|
|
438
|
+
*/
|
|
439
|
+
export function migrateLegacyConfigDir(): { from: string; to: string } {
|
|
440
|
+
if (process.env.PI_CONFIG_DIR) {
|
|
441
|
+
throw new Error("PI_CONFIG_DIR is set; migrate-legacy only handles the default config directory.");
|
|
442
|
+
}
|
|
443
|
+
const from = path.join(os.homedir(), LEGACY_CONFIG_DIR_NAME);
|
|
444
|
+
const to = path.join(os.homedir(), CONFIG_DIR_NAME);
|
|
445
|
+
if (!fs.existsSync(from)) {
|
|
446
|
+
throw new Error(`No legacy config directory found at ${from}.`);
|
|
447
|
+
}
|
|
448
|
+
if (fs.existsSync(to)) {
|
|
449
|
+
throw new Error(`Refusing to overwrite existing ${to}.`);
|
|
450
|
+
}
|
|
451
|
+
fs.renameSync(from, to);
|
|
452
|
+
return { from, to };
|
|
453
|
+
}
|
|
454
|
+
|
|
407
455
|
/** Set the coding agent directory. Creates a fresh resolver, invalidating all cached paths. */
|
|
408
456
|
export function setAgentDir(dir: string): void {
|
|
409
457
|
activeProfile = undefined;
|
|
@@ -486,37 +534,37 @@ export function getActiveProfile(): string | undefined {
|
|
|
486
534
|
export function getProfileRootDir(profile: string | undefined): string {
|
|
487
535
|
return getProfileConfigRoot(normalizeProfileName(profile));
|
|
488
536
|
}
|
|
489
|
-
/** Get the agent config directory (~/.
|
|
537
|
+
/** Get the agent config directory (~/.jeopi/agent). */
|
|
490
538
|
export function getAgentDir(): string {
|
|
491
539
|
return dirs.agentDir;
|
|
492
540
|
}
|
|
493
541
|
|
|
494
|
-
/** Get the project-local config directory (.
|
|
542
|
+
/** Get the project-local config directory (.jeopi). */
|
|
495
543
|
export function getProjectAgentDir(cwd: string = getProjectDir()): string {
|
|
496
544
|
return path.join(cwd, CONFIG_DIR_NAME);
|
|
497
545
|
}
|
|
498
546
|
|
|
499
547
|
// =============================================================================
|
|
500
|
-
// Config-root subdirectories (~/.
|
|
548
|
+
// Config-root subdirectories (~/.jeopi/*)
|
|
501
549
|
// =============================================================================
|
|
502
550
|
|
|
503
|
-
/** Get the reports directory (~/.
|
|
551
|
+
/** Get the reports directory (~/.jeopi/reports). */
|
|
504
552
|
export function getReportsDir(): string {
|
|
505
553
|
return dirs.rootSubdir("reports", "state");
|
|
506
554
|
}
|
|
507
555
|
|
|
508
|
-
/** Get the logs directory (~/.
|
|
556
|
+
/** Get the logs directory (~/.jeopi/logs). */
|
|
509
557
|
export function getLogsDir(): string {
|
|
510
558
|
return dirs.rootSubdir("logs", "state");
|
|
511
559
|
}
|
|
512
560
|
|
|
513
|
-
/** Get the path to a dated log file (~/.
|
|
561
|
+
/** Get the path to a dated log file (~/.jeopi/logs/jeopi.YYYY-MM-DD.log). */
|
|
514
562
|
export function getLogPath(date = new Date()): string {
|
|
515
563
|
return path.join(getLogsDir(), `${APP_NAME}.${date.toISOString().slice(0, 10)}.log`);
|
|
516
564
|
}
|
|
517
565
|
|
|
518
566
|
/**
|
|
519
|
-
* Get the plugins directory (~/.
|
|
567
|
+
* Get the plugins directory (~/.jeopi/plugins or its XDG equivalent).
|
|
520
568
|
*
|
|
521
569
|
* No-arg form (production callers) goes through the XDG-aware DirResolver so
|
|
522
570
|
* reads and writes always agree. The optional `home` parameter is for test
|
|
@@ -532,22 +580,22 @@ export function getPluginsDir(home?: string): string {
|
|
|
532
580
|
return dirs.rootSubdir("plugins", "data");
|
|
533
581
|
}
|
|
534
582
|
|
|
535
|
-
/** Where npm installs packages (~/.
|
|
583
|
+
/** Where npm installs packages (~/.jeopi/plugins/node_modules). */
|
|
536
584
|
export function getPluginsNodeModules(home?: string): string {
|
|
537
585
|
return path.join(getPluginsDir(home), "node_modules");
|
|
538
586
|
}
|
|
539
587
|
|
|
540
|
-
/** Plugin manifest (~/.
|
|
588
|
+
/** Plugin manifest (~/.jeopi/plugins/package.json). */
|
|
541
589
|
export function getPluginsPackageJson(home?: string): string {
|
|
542
590
|
return path.join(getPluginsDir(home), "package.json");
|
|
543
591
|
}
|
|
544
592
|
|
|
545
|
-
/** Plugin lock file (~/.
|
|
593
|
+
/** Plugin lock file (~/.jeopi/plugins/omp-plugins.lock.json). */
|
|
546
594
|
export function getPluginsLockfile(home?: string): string {
|
|
547
595
|
return path.join(getPluginsDir(home), "omp-plugins.lock.json");
|
|
548
596
|
}
|
|
549
597
|
|
|
550
|
-
/** Get the remote mount directory (~/.
|
|
598
|
+
/** Get the remote mount directory (~/.jeopi/remote). */
|
|
551
599
|
export function getRemoteDir(): string {
|
|
552
600
|
return dirs.rootSubdir("remote", "data");
|
|
553
601
|
}
|
|
@@ -557,8 +605,8 @@ export function getRemoteDir(): string {
|
|
|
557
605
|
* empty/whitespace input or a path that is still relative after expansion.
|
|
558
606
|
*
|
|
559
607
|
* A worktree base is process-global and consumed by both creation
|
|
560
|
-
* (PR checkout, task isolation) and cleanup (`
|
|
561
|
-
* would resolve against whatever cwd happened to launch `
|
|
608
|
+
* (PR checkout, task isolation) and cleanup (`jeopi worktree`). A relative value
|
|
609
|
+
* would resolve against whatever cwd happened to launch `jeopi`, so checkout and
|
|
562
610
|
* cleanup could disagree — we refuse it rather than silently bind it to cwd.
|
|
563
611
|
*/
|
|
564
612
|
function resolveWorktreeBase(value: string | undefined): string | undefined {
|
|
@@ -574,9 +622,9 @@ let worktreesDirOverride: string | undefined;
|
|
|
574
622
|
|
|
575
623
|
/**
|
|
576
624
|
* Relocate the base directory for agent-managed worktrees (PR checkouts, task
|
|
577
|
-
* isolation, and `
|
|
625
|
+
* isolation, and `jeopi worktree` cleanup all read the same base). Driven by the
|
|
578
626
|
* `worktree.base` setting in coding-agent; pass `undefined`/empty to clear and
|
|
579
|
-
* fall back to `OMP_WORKTREE_DIR` or the `~/.
|
|
627
|
+
* fall back to `OMP_WORKTREE_DIR` or the `~/.jeopi/wt` default.
|
|
580
628
|
*
|
|
581
629
|
* `~` is expanded and a relative path is rejected (see {@link resolveWorktreeBase}).
|
|
582
630
|
* Returns the absolute path that took effect, or `undefined` if the input was
|
|
@@ -591,7 +639,7 @@ export function setWorktreesDir(dir: string | undefined): string | undefined {
|
|
|
591
639
|
/**
|
|
592
640
|
* Get the agent-managed worktrees directory. Resolution order: the
|
|
593
641
|
* `OMP_WORKTREE_DIR` env var, then the {@link setWorktreesDir} override (the
|
|
594
|
-
* `worktree.base` setting), then the `~/.
|
|
642
|
+
* `worktree.base` setting), then the `~/.jeopi/wt` default. The env var and the
|
|
595
643
|
* override are both `~`-expanded and must be absolute; a relative value is
|
|
596
644
|
* ignored and resolution falls through.
|
|
597
645
|
*/
|
|
@@ -599,27 +647,27 @@ export function getWorktreesDir(): string {
|
|
|
599
647
|
return resolveWorktreeBase(process.env.OMP_WORKTREE_DIR) ?? worktreesDirOverride ?? dirs.rootSubdir("wt", "data");
|
|
600
648
|
}
|
|
601
649
|
|
|
602
|
-
/** Get the SSH control socket directory (~/.
|
|
650
|
+
/** Get the SSH control socket directory (~/.jeopi/ssh-control). */
|
|
603
651
|
export function getSshControlDir(): string {
|
|
604
652
|
return dirs.rootSubdir("ssh-control", "state");
|
|
605
653
|
}
|
|
606
654
|
|
|
607
|
-
/** Get the remote host info directory (~/.
|
|
655
|
+
/** Get the remote host info directory (~/.jeopi/remote-host). */
|
|
608
656
|
export function getRemoteHostDir(): string {
|
|
609
657
|
return dirs.rootSubdir("remote-host", "data");
|
|
610
658
|
}
|
|
611
659
|
|
|
612
|
-
/** Get the managed Python venv directory (~/.
|
|
660
|
+
/** Get the managed Python venv directory (~/.jeopi/python-env). */
|
|
613
661
|
export function getPythonEnvDir(): string {
|
|
614
662
|
return dirs.rootSubdir("python-env", "data");
|
|
615
663
|
}
|
|
616
664
|
|
|
617
|
-
/** Get the shared Python gateway state directory (~/.
|
|
665
|
+
/** Get the shared Python gateway state directory (~/.jeopi/agent/python-gateway; XDG default: $XDG_STATE_HOME/jeopi/python-gateway). */
|
|
618
666
|
export function getPythonGatewayDir(): string {
|
|
619
667
|
return dirs.agentSubdir(undefined, "python-gateway", "state");
|
|
620
668
|
}
|
|
621
669
|
|
|
622
|
-
/** Get the puppeteer sandbox directory (~/.
|
|
670
|
+
/** Get the puppeteer sandbox directory (~/.jeopi/puppeteer). */
|
|
623
671
|
export function getPuppeteerDir(): string {
|
|
624
672
|
return dirs.rootSubdir("puppeteer", "cache");
|
|
625
673
|
}
|
|
@@ -637,7 +685,7 @@ export function getAutoQaDbDir(): string {
|
|
|
637
685
|
* Stable 7-character hex digest of an absolute filesystem path.
|
|
638
686
|
*
|
|
639
687
|
* Used to pack the project identity into a single short fs-safe segment
|
|
640
|
-
* (e.g. PR-checkout and task-isolation worktree dirs under `~/.
|
|
688
|
+
* (e.g. PR-checkout and task-isolation worktree dirs under `~/.jeopi/wt/`).
|
|
641
689
|
* Bun.hash is non-cryptographic — collision space is ~2^28, which is fine
|
|
642
690
|
* for naming a handful of repos on a single machine. Same input on the
|
|
643
691
|
* same Bun runtime yields the same output.
|
|
@@ -646,18 +694,18 @@ export function hashPath(absPath: string): string {
|
|
|
646
694
|
return Bun.hash(path.resolve(absPath)).toString(16).padStart(16, "0").slice(-7);
|
|
647
695
|
}
|
|
648
696
|
|
|
649
|
-
/** Get the path to a single worktree directory (~/.
|
|
697
|
+
/** Get the path to a single worktree directory (~/.jeopi/wt/<segment>). */
|
|
650
698
|
export function getWorktreeDir(segment: string): string {
|
|
651
699
|
return path.join(getWorktreesDir(), segment);
|
|
652
700
|
}
|
|
653
701
|
|
|
654
|
-
/** Get the GPU cache path (~/.
|
|
702
|
+
/** Get the GPU cache path (~/.jeopi/gpu_cache.json). */
|
|
655
703
|
export function getGpuCachePath(): string {
|
|
656
704
|
return dirs.rootSubdir("gpu_cache.json", "cache");
|
|
657
705
|
}
|
|
658
706
|
|
|
659
707
|
/**
|
|
660
|
-
* Get the GitHub view cache database path (~/.
|
|
708
|
+
* Get the GitHub view cache database path (~/.jeopi/cache/github-cache.db).
|
|
661
709
|
* Honors the `OMP_GITHUB_CACHE_DB` env var when set so tests can isolate the
|
|
662
710
|
* cache file without touching the rest of the config root.
|
|
663
711
|
*/
|
|
@@ -668,7 +716,7 @@ export function getGithubCacheDbPath(): string {
|
|
|
668
716
|
}
|
|
669
717
|
|
|
670
718
|
/**
|
|
671
|
-
* Get the encrypted auth-broker snapshot cache path (~/.
|
|
719
|
+
* Get the encrypted auth-broker snapshot cache path (~/.jeopi/cache/auth-broker-snapshot.enc).
|
|
672
720
|
* Honors the `OMP_AUTH_BROKER_SNAPSHOT_CACHE` env var when set so tests and
|
|
673
721
|
* operators can isolate or relocate the cache file.
|
|
674
722
|
*/
|
|
@@ -678,48 +726,48 @@ export function getAuthBrokerSnapshotCachePath(): string {
|
|
|
678
726
|
return dirs.rootSubdir(path.join("cache", "auth-broker-snapshot.enc"), "cache");
|
|
679
727
|
}
|
|
680
728
|
|
|
681
|
-
/** Get the local FastEmbed model cache directory (~/.
|
|
729
|
+
/** Get the local FastEmbed model cache directory (~/.jeopi/cache/fastembed). */
|
|
682
730
|
export function getFastembedCacheDir(): string {
|
|
683
731
|
return dirs.rootSubdir(path.join("cache", "fastembed"), "cache");
|
|
684
732
|
}
|
|
685
733
|
|
|
686
|
-
/** Get the on-demand fastembed runtime install root (~/.
|
|
734
|
+
/** Get the on-demand fastembed runtime install root (~/.jeopi/cache/fastembed-runtime). */
|
|
687
735
|
export function getFastembedRuntimeDir(): string {
|
|
688
736
|
return dirs.rootSubdir(path.join("cache", "fastembed-runtime"), "cache");
|
|
689
737
|
}
|
|
690
738
|
|
|
691
|
-
/** Get the natives directory (~/.
|
|
739
|
+
/** Get the natives directory (~/.jeopi/natives). */
|
|
692
740
|
export function getNativesDir(): string {
|
|
693
741
|
return dirs.rootSubdir("natives", "cache");
|
|
694
742
|
}
|
|
695
743
|
|
|
696
|
-
/** Get the stats database path (~/.
|
|
744
|
+
/** Get the stats database path (~/.jeopi/stats.db). */
|
|
697
745
|
export function getStatsDbPath(): string {
|
|
698
746
|
return dirs.rootSubdir("stats.db", "data");
|
|
699
747
|
}
|
|
700
748
|
|
|
701
|
-
/** Get the autoresearch state directory (~/.
|
|
749
|
+
/** Get the autoresearch state directory (~/.jeopi/autoresearch). */
|
|
702
750
|
export function getAutoresearchDir(): string {
|
|
703
751
|
return dirs.rootSubdir("autoresearch", "state");
|
|
704
752
|
}
|
|
705
753
|
|
|
706
|
-
/** Get the per-project autoresearch state directory (~/.
|
|
754
|
+
/** Get the per-project autoresearch state directory (~/.jeopi/autoresearch/<encoded-project>). */
|
|
707
755
|
export function getAutoresearchProjectDir(encodedProject: string): string {
|
|
708
756
|
return path.join(getAutoresearchDir(), encodedProject);
|
|
709
757
|
}
|
|
710
758
|
|
|
711
|
-
/** Get the per-project autoresearch SQLite database path (~/.
|
|
759
|
+
/** Get the per-project autoresearch SQLite database path (~/.jeopi/autoresearch/<encoded-project>.db). */
|
|
712
760
|
export function getAutoresearchDbPath(encodedProject: string): string {
|
|
713
761
|
return path.join(getAutoresearchDir(), `${encodedProject}.db`);
|
|
714
762
|
}
|
|
715
763
|
|
|
716
|
-
/** Get the per-run artifact directory (~/.
|
|
764
|
+
/** Get the per-run artifact directory (~/.jeopi/autoresearch/<encoded-project>/runs/<runId>). */
|
|
717
765
|
export function getAutoresearchRunDir(encodedProject: string, runId: number): string {
|
|
718
766
|
return path.join(getAutoresearchProjectDir(encodedProject), "runs", String(runId).padStart(4, "0"));
|
|
719
767
|
}
|
|
720
768
|
|
|
721
769
|
// =============================================================================
|
|
722
|
-
// Agent subdirectories (~/.
|
|
770
|
+
// Agent subdirectories (~/.jeopi/agent/*)
|
|
723
771
|
// =============================================================================
|
|
724
772
|
|
|
725
773
|
/** Get the path to agent.db (SQLite database for settings and auth storage). */
|
|
@@ -727,7 +775,7 @@ export function getAgentDbPath(agentDir?: string): string {
|
|
|
727
775
|
return dirs.agentSubdir(agentDir, "agent.db", "data");
|
|
728
776
|
}
|
|
729
777
|
|
|
730
|
-
/** Get the last-seen-changelog-version marker file (~/.
|
|
778
|
+
/** Get the last-seen-changelog-version marker file (~/.jeopi/agent/last-changelog-version). */
|
|
731
779
|
export function getLastChangelogVersionPath(agentDir?: string): string {
|
|
732
780
|
return dirs.agentSubdir(agentDir, "last-changelog-version", "state");
|
|
733
781
|
}
|
|
@@ -742,86 +790,86 @@ export function getModelDbPath(agentDir?: string): string {
|
|
|
742
790
|
return dirs.agentSubdir(agentDir, "models.db", "data");
|
|
743
791
|
}
|
|
744
792
|
|
|
745
|
-
/** Get the tiny title model cache directory (~/.
|
|
793
|
+
/** Get the tiny title model cache directory (~/.jeopi/agent/cache/tiny-models). */
|
|
746
794
|
export function getTinyModelsCacheDir(agentDir?: string): string {
|
|
747
795
|
return dirs.agentSubdir(agentDir, path.join("cache", "tiny-models"), "cache");
|
|
748
796
|
}
|
|
749
797
|
|
|
750
|
-
/** Get the document conversion cache directory (~/.
|
|
798
|
+
/** Get the document conversion cache directory (~/.jeopi/agent/cache/document-conversions; XDG default: $XDG_CACHE_HOME/jeopi/cache/document-conversions). */
|
|
751
799
|
export function getDocumentConversionCacheDir(agentDir?: string): string {
|
|
752
800
|
return dirs.agentSubdir(agentDir, path.join("cache", "document-conversions"), "cache");
|
|
753
801
|
}
|
|
754
802
|
|
|
755
|
-
/** Get the sessions directory (~/.
|
|
803
|
+
/** Get the sessions directory (~/.jeopi/agent/sessions). */
|
|
756
804
|
export function getSessionsDir(agentDir?: string): string {
|
|
757
805
|
return dirs.agentSubdir(agentDir, "sessions", "data");
|
|
758
806
|
}
|
|
759
807
|
|
|
760
|
-
/** Get the content-addressed blob store directory (~/.
|
|
808
|
+
/** Get the content-addressed blob store directory (~/.jeopi/agent/blobs). */
|
|
761
809
|
export function getBlobsDir(agentDir?: string): string {
|
|
762
810
|
return dirs.agentSubdir(agentDir, "blobs", "data");
|
|
763
811
|
}
|
|
764
812
|
|
|
765
|
-
/** Get the custom themes directory (~/.
|
|
813
|
+
/** Get the custom themes directory (~/.jeopi/agent/themes). */
|
|
766
814
|
export function getCustomThemesDir(agentDir?: string): string {
|
|
767
815
|
return dirs.agentSubdir(agentDir, "themes");
|
|
768
816
|
}
|
|
769
817
|
|
|
770
|
-
/** Get the tools directory (~/.
|
|
818
|
+
/** Get the tools directory (~/.jeopi/agent/tools). */
|
|
771
819
|
export function getToolsDir(agentDir?: string): string {
|
|
772
820
|
return dirs.agentSubdir(agentDir, "tools");
|
|
773
821
|
}
|
|
774
822
|
|
|
775
|
-
/** Get the slash commands directory (~/.
|
|
823
|
+
/** Get the slash commands directory (~/.jeopi/agent/commands). */
|
|
776
824
|
export function getCommandsDir(agentDir?: string): string {
|
|
777
825
|
return dirs.agentSubdir(agentDir, "commands");
|
|
778
826
|
}
|
|
779
827
|
|
|
780
|
-
/** Get the prompts directory (~/.
|
|
828
|
+
/** Get the prompts directory (~/.jeopi/agent/prompts). */
|
|
781
829
|
export function getPromptsDir(agentDir?: string): string {
|
|
782
830
|
return dirs.agentSubdir(agentDir, "prompts");
|
|
783
831
|
}
|
|
784
832
|
|
|
785
|
-
/** Get the user-level Python modules directory (~/.
|
|
833
|
+
/** Get the user-level Python modules directory (~/.jeopi/agent/modules). */
|
|
786
834
|
export function getAgentModulesDir(agentDir?: string): string {
|
|
787
835
|
return dirs.agentSubdir(agentDir, "modules");
|
|
788
836
|
}
|
|
789
837
|
|
|
790
|
-
/** Get the memories directory (~/.
|
|
838
|
+
/** Get the memories directory (~/.jeopi/agent/memories). */
|
|
791
839
|
export function getMemoriesDir(agentDir?: string): string {
|
|
792
840
|
return dirs.agentSubdir(agentDir, "memories", "state");
|
|
793
841
|
}
|
|
794
842
|
|
|
795
|
-
/** Get the terminal sessions directory (~/.
|
|
843
|
+
/** Get the terminal sessions directory (~/.jeopi/agent/terminal-sessions). */
|
|
796
844
|
export function getTerminalSessionsDir(agentDir?: string): string {
|
|
797
845
|
return dirs.agentSubdir(agentDir, "terminal-sessions", "state");
|
|
798
846
|
}
|
|
799
847
|
|
|
800
|
-
/** Get the crash log path (~/.
|
|
848
|
+
/** Get the crash log path (~/.jeopi/agent/jeopi-crash.log). */
|
|
801
849
|
export function getCrashLogPath(agentDir?: string): string {
|
|
802
850
|
return dirs.agentSubdir(agentDir, `${APP_NAME}-crash.log`, "state");
|
|
803
851
|
}
|
|
804
852
|
|
|
805
|
-
/** Get the debug log path (~/.
|
|
853
|
+
/** Get the debug log path (~/.jeopi/agent/jeopi-debug.log). */
|
|
806
854
|
export function getDebugLogPath(agentDir?: string): string {
|
|
807
855
|
return dirs.agentSubdir(agentDir, `${APP_NAME}-debug.log`, "state");
|
|
808
856
|
}
|
|
809
857
|
|
|
810
858
|
// =============================================================================
|
|
811
|
-
// Project subdirectories (.
|
|
859
|
+
// Project subdirectories (.jeopi/*)
|
|
812
860
|
// =============================================================================
|
|
813
861
|
|
|
814
|
-
/** Get the project-level Python modules directory (.
|
|
862
|
+
/** Get the project-level Python modules directory (.jeopi/modules). */
|
|
815
863
|
export function getProjectModulesDir(cwd: string = getProjectDir()): string {
|
|
816
864
|
return path.join(getProjectAgentDir(cwd), "modules");
|
|
817
865
|
}
|
|
818
866
|
|
|
819
|
-
/** Get the project-level prompts directory (.
|
|
867
|
+
/** Get the project-level prompts directory (.jeopi/prompts). */
|
|
820
868
|
export function getProjectPromptsDir(cwd: string = getProjectDir()): string {
|
|
821
869
|
return path.join(getProjectAgentDir(cwd), "prompts");
|
|
822
870
|
}
|
|
823
871
|
|
|
824
|
-
/** Get the project-level plugin overrides path (.
|
|
872
|
+
/** Get the project-level plugin overrides path (.jeopi/plugin-overrides.json). */
|
|
825
873
|
export function getProjectPluginOverridesPath(cwd: string = getProjectDir()): string {
|
|
826
874
|
return path.join(getProjectAgentDir(cwd), "plugin-overrides.json");
|
|
827
875
|
}
|
|
@@ -856,15 +904,15 @@ const INSTALL_ID_FILE = "install-id";
|
|
|
856
904
|
const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
857
905
|
|
|
858
906
|
/**
|
|
859
|
-
* Persistent per-install UUID stored at `~/.
|
|
907
|
+
* Persistent per-install UUID stored at `~/.jeopi/install-id`.
|
|
860
908
|
*
|
|
861
909
|
* Generated lazily on first call and persisted with `O_CREAT|O_EXCL` so
|
|
862
910
|
* concurrent first-call races don't clobber each other (loser re-reads the
|
|
863
911
|
* winner's id). Survives independently of agent state: deleting
|
|
864
|
-
* `~/.
|
|
912
|
+
* `~/.jeopi/agent/` does not regenerate it. Server-side dedup for grievance
|
|
865
913
|
* pushes (and similar telemetry) keys on this id.
|
|
866
914
|
*
|
|
867
|
-
* Anchored to the base config root (`~/.
|
|
915
|
+
* Anchored to the base config root (`~/.jeopi/install-id`) regardless of the
|
|
868
916
|
* active profile: install identity is per-install, not per-profile, so every
|
|
869
917
|
* profile shares one id and the global cache stays correct no matter the
|
|
870
918
|
* profile / `getInstallId` call order.
|
package/src/logger.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Centralized logger for jeopi.
|
|
3
3
|
*
|
|
4
|
-
* Default: rotating `~/.
|
|
4
|
+
* Default: rotating `~/.jeopi/logs/jeopi.<DATE>.log`, no console output (writing
|
|
5
5
|
* to stdout/stderr would corrupt the TUI). Long-running headless services
|
|
6
6
|
* (the auth broker, etc.) call {@link setTransports} to swap in a console
|
|
7
7
|
* transport so a process supervisor (pm2, journald, k8s) captures the logs.
|
package/src/procmgr.ts
CHANGED
|
@@ -113,7 +113,7 @@ export function getShellConfig(customShellPath?: string): ShellConfig {
|
|
|
113
113
|
return cachedShellConfig;
|
|
114
114
|
}
|
|
115
115
|
throw new Error(
|
|
116
|
-
`Custom shell path not found: ${customShellPath}\nPlease update shellPath in ~/.
|
|
116
|
+
`Custom shell path not found: ${customShellPath}\nPlease update shellPath in ~/.jeopi/agent/settings.json`,
|
|
117
117
|
);
|
|
118
118
|
}
|
|
119
119
|
|
|
@@ -147,7 +147,7 @@ export function getShellConfig(customShellPath?: string): ShellConfig {
|
|
|
147
147
|
`No bash shell found. Options:\n` +
|
|
148
148
|
` 1. Install Git for Windows: https://git-scm.com/download/win\n` +
|
|
149
149
|
` 2. Add your bash to PATH (Cygwin, MSYS2, etc.)\n` +
|
|
150
|
-
` 3. Set shellPath in ~/.
|
|
150
|
+
` 3. Set shellPath in ~/.jeopi/agent/settings.json\n\n` +
|
|
151
151
|
`Searched Git Bash in:\n${paths.map(p => ` ${p}`).join("\n")}`,
|
|
152
152
|
);
|
|
153
153
|
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
export declare class AbortError extends Error {
|
|
2
|
-
constructor(signal: AbortSignal);
|
|
3
|
-
}
|
|
4
|
-
/**
|
|
5
|
-
* Abortable async iteration over a {@link ReadableStream}. Reads the source
|
|
6
|
-
* reader directly and yields each chunk, so the consumer's `for await` drives a
|
|
7
|
-
* single read loop with no intermediate stream or per-chunk enqueue.
|
|
8
|
-
*
|
|
9
|
-
* Unlike `stream.pipeThrough(..., { signal })`, this explicitly cancels the
|
|
10
|
-
* source reader on abort or early `break`, propagating HTTP-client disconnects
|
|
11
|
-
* and watchdog timeouts to the backend request instead of only stopping the
|
|
12
|
-
* local consumer. On abort it throws {@link AbortError}; the lock is released
|
|
13
|
-
* on completion, abort, throw, or early exit. The source is cancelled only on
|
|
14
|
-
* abort or early exit — never on natural EOF.
|
|
15
|
-
*/
|
|
16
|
-
export declare function abortableSource<T>(stream: ReadableStream<T>, signal?: AbortSignal): AsyncGenerator<T>;
|
|
17
|
-
/**
|
|
18
|
-
* Runs a promise-returning function (`pr`). If the given AbortSignal is aborted before or during
|
|
19
|
-
* execution, the promise is rejected with a standard error.
|
|
20
|
-
*
|
|
21
|
-
* @param signal - Optional AbortSignal to cancel the operation
|
|
22
|
-
* @param pr - Function returning a promise to run
|
|
23
|
-
* @returns Promise resolving as `pr` would, or rejecting on abort
|
|
24
|
-
*/
|
|
25
|
-
export declare function untilAborted<T>(signal: AbortSignal | undefined | null, pr: Promise<T> | (() => Promise<T>)): Promise<T>;
|
|
26
|
-
/**
|
|
27
|
-
* Memoizes a function with no arguments, calling it once and caching the result.
|
|
28
|
-
*
|
|
29
|
-
* @param fn - Function to be called once
|
|
30
|
-
* @returns A function that returns the cached result of `fn`
|
|
31
|
-
*/
|
|
32
|
-
export declare function once<T>(fn: () => T): () => T;
|