@kynver-app/runtime 0.1.56 → 0.1.60

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.
@@ -1,3 +1,17 @@
1
+ /** WSL host disk snapshot — present only when the runner is under WSL.
2
+ * The field is optional/nullable so older runners (no probe) and non-WSL
3
+ * runners both serialize as `wslHost: null` for the dispatch-next server. */
4
+ export interface DispatchNextWslHostShape {
5
+ ok: boolean;
6
+ path: string;
7
+ freeBytes: number;
8
+ totalBytes: number;
9
+ usedPercent: number;
10
+ warnBelowBytes: number;
11
+ criticalBelowBytes: number;
12
+ reason: string | null;
13
+ probeError: string | null;
14
+ }
1
15
  export interface DispatchNextDiskGateShape {
2
16
  ok: boolean;
3
17
  path: string;
@@ -9,6 +23,9 @@ export interface DispatchNextDiskGateShape {
9
23
  maxUsedPercent: number;
10
24
  hardMaxUsedPercent: number;
11
25
  reason: string | null;
26
+ /** Windows host disk under WSL (`/mnt/c` by default). `null` on non-WSL
27
+ * hosts and when the probe was opted out via `skipWslHostCheck`. */
28
+ wslHost?: DispatchNextWslHostShape | null;
12
29
  }
13
30
  export interface DispatchNextResourceGateShape {
14
31
  ok: boolean;
@@ -0,0 +1,2 @@
1
+ /** Strip generated install trees from porcelain — they are what cleanup removes. */
2
+ export declare function materialWorktreeChanges(changedFiles: string[]): string[];
@@ -1,17 +1,28 @@
1
- import type { CleanupSkipReason } from "./cleanup-types.js";
1
+ import type { CleanupSkipReason, WorktreeRemovalGuardHook } from "./cleanup-types.js";
2
2
  import type { IndexedWorktree } from "./cleanup-worktree-index.js";
3
3
  import type { RawHarnessWorkerStatus } from "./status.js";
4
+ export { materialWorktreeChanges } from "./cleanup-guards-helpers.js";
4
5
  /** Blocks whole-worktree removal when commits are not landed or tree is dirty. */
5
6
  export declare function isPrOrUnmergedWork(status: RawHarnessWorkerStatus): boolean;
6
- /** Strip generated install trees from porcelain — they are what cleanup removes. */
7
- export declare function materialWorktreeChanges(changedFiles: string[]): string[];
8
7
  export interface WorktreeGuardInput {
9
8
  indexed: IndexedWorktree | null;
9
+ /** Resolved worktree directory (required for overlay guards on orphans). */
10
+ worktreePath: string;
10
11
  includeOrphans: boolean;
11
12
  worktreesAgeMs: number;
12
13
  ageMs: number;
14
+ /**
15
+ * Filesystem-derived skip reason for orphan candidates (computed by
16
+ * `assessOrphanWorktreeSafety`). Used only when `indexed` is null.
17
+ */
18
+ orphanSafety?: CleanupSkipReason | null;
19
+ worktreeRemovalGuard?: WorktreeRemovalGuardHook;
13
20
  }
14
- export declare function skipWorktreeRemoval(input: WorktreeGuardInput): CleanupSkipReason | null;
21
+ export type WorktreeGuardSkip = CleanupSkipReason | {
22
+ reason: CleanupSkipReason;
23
+ detail?: string;
24
+ };
25
+ export declare function skipWorktreeRemoval(input: WorktreeGuardInput): WorktreeGuardSkip | null;
15
26
  export interface NodeModulesGuardInput {
16
27
  indexed: IndexedWorktree | null;
17
28
  includeOrphans: boolean;
@@ -0,0 +1,17 @@
1
+ import type { CleanupSkipReason } from "./cleanup-types.js";
2
+ export interface OrphanSafetyInput {
3
+ worktreePath: string;
4
+ harnessRoot: string;
5
+ runId?: string;
6
+ workerName?: string;
7
+ heartbeatFreshMs?: number;
8
+ now?: number;
9
+ }
10
+ /**
11
+ * Inspect filesystem signals for an orphan worktree (no run/worker.json index entry).
12
+ *
13
+ * Returns a `CleanupSkipReason` when removal is unsafe, or `null` when the orphan
14
+ * appears safe to delete. Conservative on errors — any unreadable git state or
15
+ * unexpected layout returns `pr_or_unmerged_commits` so genuine work is preserved.
16
+ */
17
+ export declare function assessOrphanWorktreeSafety(input: OrphanSafetyInput): CleanupSkipReason | null;
@@ -1,5 +1,7 @@
1
1
  export type CleanupActionKind = "remove_node_modules" | "remove_worktree";
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";
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
+ /** AgentOS / operator lifecycle overlay blocked removal (see `detail`). */
4
+ | "board_lifecycle_blocked";
3
5
  export interface CleanupCandidate {
4
6
  kind: CleanupActionKind;
5
7
  path: string;
@@ -20,6 +22,15 @@ export interface RunFinalizeSummary {
20
22
  from: string;
21
23
  to: string;
22
24
  }
25
+ export interface HarnessStorageSnapshotShape {
26
+ harnessRoot: string;
27
+ worktreesDir: string;
28
+ worktreesBytes: number | null;
29
+ runCount: number;
30
+ workerCount: number;
31
+ oldestRunAt: string | null;
32
+ scannedAt: string;
33
+ }
23
34
  export interface HarnessCleanupSummary {
24
35
  harnessRoot: string;
25
36
  dryRun: boolean;
@@ -43,7 +54,21 @@ export interface HarnessCleanupSummary {
43
54
  skippedPaths: number;
44
55
  skipReasons: Partial<Record<CleanupSkipReason, number>>;
45
56
  };
57
+ /** Disk-pressure evidence — present when bytes accounting is enabled. */
58
+ storage?: HarnessStorageSnapshotShape;
59
+ }
60
+ export interface WorktreeRemovalGuardInput {
61
+ worktreePath: string;
62
+ /** True when `buildWorktreeIndex()` has a worker.json entry for this path. */
63
+ indexed: boolean;
64
+ runId?: string;
65
+ worker?: string;
46
66
  }
67
+ /** Optional overlay (e.g. AgentOS board + lease checks) evaluated after runtime salvage gates. */
68
+ export type WorktreeRemovalGuardHook = (input: WorktreeRemovalGuardInput) => {
69
+ reason: CleanupSkipReason;
70
+ detail?: string;
71
+ } | null;
47
72
  export interface HarnessCleanupOptions {
48
73
  harnessRoot?: string;
49
74
  /** When false (default), only report candidates. */
@@ -61,6 +86,8 @@ export interface HarnessCleanupOptions {
61
86
  /** When set, only consider workers for this harness run (pipeline tick scope). */
62
87
  runIdFilter?: string;
63
88
  now?: number;
89
+ /** When set, invoked for each worktree candidate after built-in salvage guards. */
90
+ worktreeRemovalGuard?: WorktreeRemovalGuardHook;
64
91
  }
65
92
  /** Conservative default aligned with 2026-05-27 manual harness cleanup (6h). */
66
93
  export declare const DEFAULT_NODE_MODULES_AGE_MS: number;