@kynver-app/runtime 0.1.91 → 0.1.92

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.
@@ -0,0 +1,19 @@
1
+ import type { KynverUserConfig } from "./config.js";
2
+ export type WorkerPoolBoxKind = "ghost" | "forge";
3
+ export type BoxKindSource = "config" | "env" | "default";
4
+ export interface ResolvedBoxIdentity {
5
+ boxKind: WorkerPoolBoxKind;
6
+ source: BoxKindSource;
7
+ /** True when identity would have been inferred from KYNVER_AGENT_OS_SLUG without an explicit box kind. */
8
+ slugInferenceBlocked: boolean;
9
+ warnings: string[];
10
+ }
11
+ /** Normalize host/box labels to ghost | forge for worker-pool attribution. */
12
+ export declare function normalizeWorkerPoolBoxKind(raw: string | null | undefined): WorkerPoolBoxKind;
13
+ /**
14
+ * Resolve physical box identity for capacity snapshots and daemon policy.
15
+ * Never maps AgentOS workspace slug alone to box kind — Forge installs must set
16
+ * `boxKind` in ~/.kynver/config.json or `KYNVER_BOX_KIND`.
17
+ */
18
+ export declare function resolveBoxIdentity(env?: NodeJS.ProcessEnv, config?: Pick<KynverUserConfig, "boxKind">): ResolvedBoxIdentity;
19
+ export declare function resolveBoxKindFromConfig(config?: Pick<KynverUserConfig, "boxKind">, env?: NodeJS.ProcessEnv): WorkerPoolBoxKind;
@@ -1,3 +1,4 @@
1
- export declare function normalizeWorkerPoolBoxKind(raw: string | null | undefined): "ghost" | "forge";
1
+ export { normalizeWorkerPoolBoxKind, resolveBoxIdentity } from "./box-identity.js";
2
+ /** @deprecated Prefer resolveBoxIdentity — kept for callers that only need the kind string. */
2
3
  export declare function resolveBoxKindFromEnv(env?: NodeJS.ProcessEnv): string;
3
4
  export declare function defaultBoxId(boxKind: string, hostLabel?: string | null): string;
@@ -1,9 +1,7 @@
1
- import type { CleanupAction, CleanupCandidate, CleanupSkipReason } from "./cleanup-types.js";
1
+ import type { CleanupAction, CleanupCandidate } from "./cleanup-types.js";
2
+ export { isHarnessBuildCachePath, isHarnessNextCachePath, isHarnessNodeModulesPath } from "./cleanup-harness-path-validate.js";
2
3
  export declare function removeNodeModules(candidate: CleanupCandidate, execute: boolean): CleanupAction;
3
4
  export declare function removeNextCache(candidate: CleanupCandidate, execute: boolean): CleanupAction;
4
5
  export declare function removeBuildCache(candidate: CleanupCandidate, execute: boolean): CleanupAction;
5
6
  export declare function removeRunDirectory(candidate: CleanupCandidate, execute: boolean): CleanupAction;
6
7
  export declare function removeWorktree(candidate: CleanupCandidate, execute: boolean): CleanupAction;
7
- export declare function isHarnessNodeModulesPath(targetPath: string, harnessRoot: string, worktreesDir: string): CleanupSkipReason | null;
8
- export declare function isHarnessNextCachePath(targetPath: string, harnessRoot: string, worktreesDir: string): CleanupSkipReason | null;
9
- export declare function isHarnessBuildCachePath(targetPath: string, harnessRoot: string, worktreesDir: string): CleanupSkipReason | null;
@@ -0,0 +1,5 @@
1
+ import type { CleanupSkipReason } from "./cleanup-types.js";
2
+ export declare function isHarnessNodeModulesPath(targetPath: string, harnessRoot: string, worktreesDir: string): CleanupSkipReason | null;
3
+ export declare function isHarnessNextCachePath(targetPath: string, harnessRoot: string, worktreesDir: string): CleanupSkipReason | null;
4
+ export declare function isHarnessBuildCachePath(targetPath: string, harnessRoot: string, worktreesDir: string): CleanupSkipReason | null;
5
+ export declare function isHarnessGeneratedCachePath(targetPath: string, harnessRoot: string, worktreesDir: string): boolean;
@@ -0,0 +1,9 @@
1
+ export interface PathOwnershipInfo {
2
+ uid: number;
3
+ gid: number;
4
+ /** True when the entry is not owned by the current process user/group. */
5
+ foreign: boolean;
6
+ }
7
+ export declare function readPathOwnership(targetPath: string): PathOwnershipInfo | null;
8
+ /** Shallow scan for foreign-owned entries (dependency caches are usually uniform). */
9
+ export declare function pathHasForeignOwnedEntry(targetPath: string, maxEntries?: number): boolean;
@@ -0,0 +1,13 @@
1
+ export type PrivilegedCleanupMode = "off" | "auto" | "force";
2
+ export declare function resolvePrivilegedCleanupMode(): PrivilegedCleanupMode;
3
+ export interface PrivilegedReclaimResult {
4
+ ok: boolean;
5
+ method?: "chown_then_rm" | "sudo_rm";
6
+ error?: string;
7
+ }
8
+ /**
9
+ * Reclaim a harness generated cache directory that is not owned by the daemon user.
10
+ * Only operates on validated `worktrees/<run>/<worker>/{node_modules,.next,...}` paths.
11
+ */
12
+ export declare function tryPrivilegedReclaimHarnessCache(targetPath: string, harnessRoot: string, worktreesDir: string): PrivilegedReclaimResult;
13
+ export declare const HARNESS_ROOT_OWNED_CACHE_RUNBOOK = "Root-owned harness caches require operator reclaim: configure passwordless sudo for chown/rm under ~/.kynver/harness/worktrees, or run `node scripts/reclaim-harness-root-owned-cache.mjs --execute` as the harness owner with sudo available. See docs/runbooks/harness-root-owned-cache-reclaim.md.";
@@ -0,0 +1,17 @@
1
+ import { rmSync } from "node:fs";
2
+ import type { CleanupCandidate, CleanupSkipReason } from "./cleanup-types.js";
3
+ import { pathHasForeignOwnedEntry } from "./cleanup-path-ownership.js";
4
+ export interface RemoveHarnessPathOutcome {
5
+ executed: boolean;
6
+ skipped: boolean;
7
+ skipReason?: CleanupSkipReason;
8
+ error?: string;
9
+ bytes?: number;
10
+ privilegedReclaim?: boolean;
11
+ }
12
+ interface RemoveHarnessGeneratedPathDeps {
13
+ removePath?: typeof rmSync;
14
+ hasForeignOwnedEntry?: typeof pathHasForeignOwnedEntry;
15
+ }
16
+ export declare function removeHarnessGeneratedPath(candidate: CleanupCandidate, execute: boolean, deps?: RemoveHarnessGeneratedPathDeps): RemoveHarnessPathOutcome;
17
+ export {};
@@ -1,5 +1,7 @@
1
1
  export type CleanupActionKind = "remove_node_modules" | "remove_next_cache" | "remove_build_cache" | "remove_worktree" | "remove_run_directory";
2
2
  export type CleanupSkipReason = "dry_run" | "below_age_threshold" | "active_worker" | "dirty_worktree" | "landing_blocked" | "pr_or_unmerged_commits" | "completion_blocked" | "run_still_active" | "path_outside_harness" | "worktrees_disabled" | "orphan_without_flag" | "missing_worktree" | "remove_failed"
3
+ /** Generated cache owned by another user (often root); daemon cannot unlink without privileged reclaim. */
4
+ | "foreign_owner"
3
5
  /** Harness `runs/` metadata must never be removed by worktree GC. */
4
6
  | "run_metadata_protected"
5
7
  /** AgentOS / operator lifecycle overlay blocked removal (see `detail`). */