@linxiraos/pi-utils 1.1.8 → 1.1.10

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/src/async.ts CHANGED
@@ -108,3 +108,19 @@ export class AsyncDrain<T> {
108
108
  return this.#promise;
109
109
  }
110
110
  }
111
+
112
+ /**
113
+ * Runs async operations one at a time in call order. Each `run` starts after
114
+ * the previous operation settles (success or failure) and returns that
115
+ * operation's own promise, so a rejected step never poisons the queue. Used by
116
+ * stateful cursors whose concurrent pulls must not interleave.
117
+ */
118
+ export class Serial {
119
+ #tail: Promise<unknown> = Promise.resolve();
120
+
121
+ run<T>(op: () => Promise<T>): Promise<T> {
122
+ const result = this.#tail.then(op, op);
123
+ this.#tail = result.catch(() => {});
124
+ return result;
125
+ }
126
+ }
package/src/dirs.ts CHANGED
@@ -8,7 +8,7 @@
8
8
  * variables are set, paths are redirected to XDG-compliant locations under
9
9
  * $XDG_*_HOME/zeta/. This requires running `zeta config migrate` first to
10
10
  * move data to the new locations. No filesystem existence checks are performed
11
- * — if the env var is set, omp trusts that the migration has been done.
11
+ * — if the env var is set, zeta trusts that the migration has been done.
12
12
  */
13
13
 
14
14
  import * as fs from "node:fs";
@@ -17,7 +17,7 @@ import * as path from "node:path";
17
17
  import { engines, version } from "../package.json" with { type: "json" };
18
18
  import { isEnoent, isEnotdir } from "./fs-error";
19
19
 
20
- /** App name (e.g. "omp") */
20
+ /** App name (e.g. "zeta") */
21
21
  export const APP_NAME: string = "zeta";
22
22
 
23
23
  /** Config directory name (e.g. ".zeta") */
@@ -67,7 +67,7 @@ export function normalizeProfileName(profile: string | undefined): string | unde
67
67
  WINDOWS_RESERVED_BASENAME_RE.test(normalized)
68
68
  ) {
69
69
  throw new Error(
70
- `Invalid OMP profile "${profile}". Profile names must match ${PROFILE_NAME_RE.source}, ` +
70
+ `Invalid Zeta profile "${profile}". Profile names must match ${PROFILE_NAME_RE.source}, ` +
71
71
  `cannot be "." or "..", cannot end with ".", and cannot be a Windows reserved device name ` +
72
72
  `(CON, PRN, AUX, NUL, COM0-9, LPT0-9, or any of those with an extension).`,
73
73
  );
@@ -97,7 +97,7 @@ function getProfileFromEnv(): string | undefined {
97
97
  * crash a bare `import` of this module with an uncaught stack trace before the
98
98
  * CLI's error handling is in scope. The default profile is used instead; the
99
99
  * CLI re-validates the env (see `runCli` in coding-agent/src/cli.ts) so the
100
- * user still gets a clean "Invalid OMP profile" message.
100
+ * user still gets a clean "Invalid Zeta profile" message.
101
101
  */
102
102
  function readProfileFromEnvSafe(): string | undefined {
103
103
  try {
@@ -295,7 +295,7 @@ export function getConfigAgentDirName(): string {
295
295
  type XdgCategory = "data" | "state" | "cache";
296
296
 
297
297
  /**
298
- * Resolves and caches all omp directory paths. On Linux, when XDG environment
298
+ * Resolves and caches all zeta directory paths. On Linux, when XDG environment
299
299
  * variables are set, paths are redirected under $XDG_*_HOME/zeta/. A new
300
300
  * instance is created whenever the agent directory changes, which naturally
301
301
  * invalidates all cached paths.
@@ -949,6 +949,11 @@ export function getSecretPlaceholderKeyPath(): string {
949
949
  return keyPath;
950
950
  }
951
951
 
952
+ /** Directory holding the per-model tiny-worker sockets and logs (~/.zeta/run/tiny; XDG default: $XDG_STATE_HOME/zeta/run/tiny). */
953
+ export function getTinyWorkerRuntimeDir(): string {
954
+ return dirs.rootSubdir(path.join("run", "tiny"), "state");
955
+ }
956
+
952
957
  /** Root directory containing every per-project daemon runtime scope (~/.zeta/run/daemons; XDG default: $XDG_STATE_HOME/zeta/run/daemons). */
953
958
  export function getDaemonRuntimeRoot(): string {
954
959
  return dirs.rootSubdir(path.join("run", "daemons"), "state");
@@ -1108,11 +1113,6 @@ export function getInstallId(): string {
1108
1113
  return next;
1109
1114
  }
1110
1115
 
1111
- /** Test-only: clear cached install id. Never call from production code. */
1112
- export function __resetInstallIdCacheForTests(): void {
1113
- cachedInstallId = null;
1114
- }
1115
-
1116
1116
  /** Get the project-level tracking directory (<project>/.zeta/tracking). */
1117
1117
  export function getProjectTrackingDir(cwd: string = getProjectDir()): string {
1118
1118
  return path.join(getProjectAgentDir(cwd), "tracking");
@@ -1122,3 +1122,8 @@ export function getProjectTrackingDir(cwd: string = getProjectDir()): string {
1122
1122
  export function getTrackingIndexPath(agentDir?: string): string {
1123
1123
  return path.join(agentDir ?? getAgentDir(), "tracking-index.json");
1124
1124
  }
1125
+
1126
+ /** Test-only: clear cached install id. Never call from production code. */
1127
+ export function __resetInstallIdCacheForTests(): void {
1128
+ cachedInstallId = null;
1129
+ }