@kynver-app/runtime 0.1.39 → 0.1.47
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/README.md +15 -0
- package/dist/auto-complete.d.ts +60 -0
- package/dist/bounded-build/admission.d.ts +30 -0
- package/dist/bounded-build/constants.d.ts +10 -0
- package/dist/bounded-build/exec.d.ts +26 -0
- package/dist/bounded-build/index.d.ts +6 -0
- package/dist/bounded-build/meminfo.d.ts +5 -0
- package/dist/bounded-build/node-options.d.ts +9 -0
- package/dist/bounded-build/systemd-wrap.d.ts +17 -0
- package/dist/callback-headers.d.ts +2 -0
- package/dist/callbacks.d.ts +38 -0
- package/dist/cleanup-cli.d.ts +1 -0
- package/dist/cleanup-dir-size.d.ts +4 -0
- package/dist/cleanup-execute.d.ts +4 -0
- package/dist/cleanup-guards.d.ts +18 -0
- package/dist/cleanup-scan.d.ts +14 -0
- package/dist/cleanup-types.d.ts +56 -0
- package/dist/cleanup-worktree-index.d.ts +13 -0
- package/dist/cleanup.d.ts +5 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.js +1398 -199
- package/dist/cli.js.map +4 -4
- package/dist/command-center-contract-cli.d.ts +1 -0
- package/dist/completion-ack.d.ts +10 -0
- package/dist/completion-response.d.ts +15 -0
- package/dist/config.d.ts +61 -0
- package/dist/daemon.d.ts +5 -0
- package/dist/disk-gate.d.ts +9 -0
- package/dist/dispatch.d.ts +16 -0
- package/dist/doctor/doctor.types.d.ts +25 -0
- package/dist/doctor/index.d.ts +4 -0
- package/dist/doctor/runtime-takeover-cli.d.ts +1 -0
- package/dist/doctor/runtime-takeover.d.ts +3 -0
- package/dist/doctor/runtime-takeover.probes.d.ts +37 -0
- package/dist/exit-classify.d.ts +12 -0
- package/dist/exited-salvage.d.ts +22 -0
- package/dist/finalize.d.ts +16 -0
- package/dist/fortress-engagement-gate.d.ts +5 -0
- package/dist/git.d.ts +37 -0
- package/dist/github-repo.d.ts +5 -0
- package/dist/harness-verify-cli.d.ts +1 -0
- package/dist/harness-verify.d.ts +19 -0
- package/dist/heartbeat.d.ts +22 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +1733 -202
- package/dist/index.js.map +4 -4
- package/dist/installed-package-versions.d.ts +6 -0
- package/dist/landing-contract-gate.d.ts +24 -0
- package/dist/landing-gate.d.ts +24 -0
- package/dist/lease-renewal.d.ts +15 -0
- package/dist/model-routing-task-enrich.d.ts +8 -0
- package/dist/model-routing.d.ts +29 -0
- package/dist/monitor/index.d.ts +7 -0
- package/dist/monitor/monitor-cli.d.ts +9 -0
- package/dist/monitor/monitor-loop.d.ts +1 -0
- package/dist/monitor/monitor-spawn.d.ts +18 -0
- package/dist/monitor/monitor.classify.d.ts +15 -0
- package/dist/monitor/monitor.service.d.ts +17 -0
- package/dist/monitor/monitor.store.d.ts +6 -0
- package/dist/monitor/monitor.task-lease.d.ts +11 -0
- package/dist/monitor/monitor.terminal.d.ts +11 -0
- package/dist/monitor/monitor.types.d.ts +74 -0
- package/dist/package-version.d.ts +5 -0
- package/dist/path-values.d.ts +5 -0
- package/dist/paths.d.ts +7 -0
- package/dist/pipeline-dispatch.d.ts +7 -0
- package/dist/pipeline-tick.d.ts +45 -0
- package/dist/plan-persist/agentos-api.d.ts +28 -0
- package/dist/plan-persist/body-hash.d.ts +3 -0
- package/dist/plan-persist/drain.d.ts +7 -0
- package/dist/plan-persist/errors.d.ts +9 -0
- package/dist/plan-persist/handoff.d.ts +7 -0
- package/dist/plan-persist/idempotency.d.ts +2 -0
- package/dist/plan-persist/index.d.ts +8 -0
- package/dist/plan-persist/outbox-store.d.ts +18 -0
- package/dist/plan-persist/paths.d.ts +8 -0
- package/dist/plan-persist/persist.d.ts +10 -0
- package/dist/plan-persist/readback.d.ts +17 -0
- package/dist/plan-persist/types.d.ts +91 -0
- package/dist/plan-persist-cli.d.ts +3 -0
- package/dist/plan-progress-daemon-sync.d.ts +7 -0
- package/dist/plan-progress-sync.d.ts +21 -0
- package/dist/plan-progress.d.ts +10 -0
- package/dist/pr-handoff/index.d.ts +4 -0
- package/dist/pr-handoff/pr-handoff-assess.d.ts +26 -0
- package/dist/pr-handoff/pr-handoff-gh.d.ts +44 -0
- package/dist/pr-handoff/pr-handoff.d.ts +8 -0
- package/dist/pr-handoff/pr-handoff.types.d.ts +45 -0
- package/dist/prompt.d.ts +14 -0
- package/dist/providers/claude.d.ts +4 -0
- package/dist/providers/cursor-windows.d.ts +7 -0
- package/dist/providers/cursor.d.ts +11 -0
- package/dist/providers/model-preflight.d.ts +31 -0
- package/dist/providers/registry.d.ts +4 -0
- package/dist/providers/types.d.ts +32 -0
- package/dist/redact.d.ts +1 -0
- package/dist/resource-gate.d.ts +53 -0
- package/dist/retry-limits.d.ts +8 -0
- package/dist/run-store.d.ts +30 -0
- package/dist/shell-command-outcome.d.ts +32 -0
- package/dist/stale-reconcile.d.ts +25 -0
- package/dist/status.d.ts +161 -0
- package/dist/stream.d.ts +20 -0
- package/dist/supervisor.d.ts +25 -0
- package/dist/sweep.d.ts +1 -0
- package/dist/util.d.ts +22 -0
- package/dist/validate.d.ts +5 -0
- package/dist/vercel/index.d.ts +3 -0
- package/dist/vercel/vercel-evidence.d.ts +48 -0
- package/dist/vercel/vercel-github-status.d.ts +19 -0
- package/dist/vercel/vercel-url.d.ts +16 -0
- package/dist/worker-env.d.ts +15 -0
- package/dist/worker-lifecycle.d.ts +28 -0
- package/dist/worker-ops.d.ts +20 -0
- package/dist/workspace-runtime-config.d.ts +8 -0
- package/dist/worktree.d.ts +4 -0
- package/package.json +8 -4
package/README.md
CHANGED
|
@@ -50,6 +50,21 @@ Install Cursor CLI (Windows PowerShell): `irm 'https://cursor.com/install?win32=
|
|
|
50
50
|
|
|
51
51
|
Default Cursor model: `composer-2.5`. Override with `--model` on dispatch/worker start.
|
|
52
52
|
|
|
53
|
+
### Targeted dispatch (after creating a board task)
|
|
54
|
+
|
|
55
|
+
Broad `lane:any` dispatch still sweeps the ready queue (review lane first, then priority/age). To start **one specific task** you just created — without admitting an older ready row — pass the task id:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
kynver run dispatch --run <runId> --agent-os-id <id> --execute \
|
|
59
|
+
--target-task-id <taskId> --max-starts 1
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
The server `dispatch-next` body field is `targetTaskId` (same semantics). When set, no candidate pages are scanned; the response includes `targetTaskMiss: true` if the row is missing or belongs to another workspace.
|
|
63
|
+
|
|
64
|
+
### PR-ready handoff
|
|
65
|
+
|
|
66
|
+
`ensurePrReadyHandoff` resolves `owner/repo` from `git remote get-url origin` via URL parsing (repo names with dots, e.g. `Totalsolutionsync/Kynver`, are no longer truncated).
|
|
67
|
+
|
|
53
68
|
## Tests
|
|
54
69
|
|
|
55
70
|
```bash
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export interface AutoCompleteArgs {
|
|
2
|
+
run: string;
|
|
3
|
+
name: string;
|
|
4
|
+
agentOsId?: string;
|
|
5
|
+
pollMs?: number;
|
|
6
|
+
maxTotalMs?: number;
|
|
7
|
+
completeAttempts?: number;
|
|
8
|
+
completeBackoffMs?: number;
|
|
9
|
+
baseUrl?: string;
|
|
10
|
+
secret?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface AutoCompleteOutcome {
|
|
13
|
+
worker: string;
|
|
14
|
+
runId: string;
|
|
15
|
+
/** "completed" → finished + completion call returned ok. "blocked" → finished + completion replay refused (structural blocker set). "timed_out" → never finished within the cap. */
|
|
16
|
+
outcome: "completed" | "blocked" | "timed_out" | "missing_link";
|
|
17
|
+
httpStatus?: number;
|
|
18
|
+
attempts: number;
|
|
19
|
+
reason?: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Sidecar body: poll the worker until it finishes, then POST completion (with a
|
|
23
|
+
* small retry budget). Pure logic — the CLI just adapts `--`-args in/out.
|
|
24
|
+
*/
|
|
25
|
+
export declare function autoCompleteWorker(raw: Record<string, string | boolean>): Promise<AutoCompleteOutcome>;
|
|
26
|
+
/** CLI entry: write outcome JSON to stdout. Exit code 0 on completed/blocked (both record state); 1 on missing_link / timed_out. */
|
|
27
|
+
export declare function autoCompleteWorkerCli(raw: Record<string, string | boolean>): Promise<void>;
|
|
28
|
+
export interface SpawnSidecarOptions {
|
|
29
|
+
runId: string;
|
|
30
|
+
workerName: string;
|
|
31
|
+
workerDir: string;
|
|
32
|
+
/** Override the CLI script the sidecar invokes. Tests inject this. */
|
|
33
|
+
cliPath?: string;
|
|
34
|
+
/** Override the node executable. Tests inject this. */
|
|
35
|
+
nodeExecutable?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Carry the agentOsId on the command line so the sidecar still resolves
|
|
38
|
+
* its callback target even if `worker.json` is rewritten/relocated.
|
|
39
|
+
*/
|
|
40
|
+
agentOsId?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Pass-through for callers that want a non-default base URL/secret (e.g.
|
|
43
|
+
* tests or operator overrides). Production reads them from env.
|
|
44
|
+
*/
|
|
45
|
+
baseUrl?: string;
|
|
46
|
+
secret?: string;
|
|
47
|
+
}
|
|
48
|
+
export interface SpawnedSidecar {
|
|
49
|
+
pid?: number;
|
|
50
|
+
logPath: string;
|
|
51
|
+
cliPath: string;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Detach a per-worker completion sidecar that owns the worker's
|
|
55
|
+
* finalResult → AgentTask attribution. Returns the spawned pid (or undefined if
|
|
56
|
+
* `dryRun`). Failures here MUST NOT crash `worker start`: the worker is already
|
|
57
|
+
* running; missing the sidecar just means a daemon/watchdog has to replay
|
|
58
|
+
* completion later.
|
|
59
|
+
*/
|
|
60
|
+
export declare function spawnCompletionSidecar(opts: SpawnSidecarOptions): SpawnedSidecar | undefined;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export interface BuildAdmissionConfig {
|
|
2
|
+
perBuildBudgetBytes: number;
|
|
3
|
+
reserveBytes: number;
|
|
4
|
+
}
|
|
5
|
+
export interface BuildAdmissionVerdict {
|
|
6
|
+
admitted: boolean;
|
|
7
|
+
memAvailableBytes: number;
|
|
8
|
+
requiredBytes: number;
|
|
9
|
+
activeBuilds: number;
|
|
10
|
+
reason: string | null;
|
|
11
|
+
}
|
|
12
|
+
export declare function resolveBuildAdmissionConfig(config?: import("../config.js").KynverUserConfig): BuildAdmissionConfig;
|
|
13
|
+
export declare function getActiveBuildCount(): number;
|
|
14
|
+
/** Reset active build counter (tests). */
|
|
15
|
+
export declare function resetActiveBuildCountForTests(): void;
|
|
16
|
+
export declare function registerBuildStart(): void;
|
|
17
|
+
export declare function registerBuildEnd(): void;
|
|
18
|
+
/**
|
|
19
|
+
* RAM-aware admission: start another worktree build only when MemAvailable ≥
|
|
20
|
+
* per-build budget + reserve. Does not serialize — parallel builds proceed when
|
|
21
|
+
* the host has headroom.
|
|
22
|
+
*/
|
|
23
|
+
export declare function assessBuildAdmission(opts?: Partial<BuildAdmissionConfig> & {
|
|
24
|
+
memAvailableBytes?: number;
|
|
25
|
+
}): BuildAdmissionVerdict;
|
|
26
|
+
export declare function sleepMs(ms: number): void;
|
|
27
|
+
/** Poll admission until admitted or timeout (ms). Returns last verdict. */
|
|
28
|
+
export declare function waitForBuildAdmission(timeoutMs: number, pollMs?: number, opts?: Partial<BuildAdmissionConfig> & {
|
|
29
|
+
memAvailableBytes?: () => number;
|
|
30
|
+
}): BuildAdmissionVerdict;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Per-build RAM budget for admission (aligns with Hermes autopipeline worker sizing). */
|
|
2
|
+
export declare const DEFAULT_BUILD_MEM_BUDGET_BYTES: number;
|
|
3
|
+
/** Headroom reserved for OS / gateway before admitting another build. */
|
|
4
|
+
export declare const DEFAULT_BUILD_MEM_RESERVE_BYTES: number;
|
|
5
|
+
/** Node heap cap for npm/tsc build/check subprocesses unless overridden. */
|
|
6
|
+
export declare const DEFAULT_NODE_OLD_SPACE_SIZE_MB = 1024;
|
|
7
|
+
/** systemd scope MemoryMax for build/check subprocesses. */
|
|
8
|
+
export declare const DEFAULT_SYSTEMD_MEMORY_MAX = "1.5G";
|
|
9
|
+
/** systemd scope MemorySwapMax for build/check subprocesses. */
|
|
10
|
+
export declare const DEFAULT_SYSTEMD_MEMORY_SWAP_MAX = "2G";
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type BuildAdmissionVerdict } from "./admission.js";
|
|
2
|
+
export interface BoundedBuildExecResult {
|
|
3
|
+
ok: boolean;
|
|
4
|
+
exitCode: number;
|
|
5
|
+
stdout: string;
|
|
6
|
+
stderr: string;
|
|
7
|
+
admitted: boolean;
|
|
8
|
+
wrappedWithSystemd: boolean;
|
|
9
|
+
nodeOptionsFlag: string;
|
|
10
|
+
admission: BuildAdmissionVerdict;
|
|
11
|
+
command: string;
|
|
12
|
+
}
|
|
13
|
+
export interface RunBoundedBuildCheckInput {
|
|
14
|
+
cwd: string;
|
|
15
|
+
/** Shell command line (e.g. `npm run typecheck`). */
|
|
16
|
+
command: string;
|
|
17
|
+
env?: NodeJS.ProcessEnv;
|
|
18
|
+
/** Max ms to wait for RAM admission (0 = fail fast). Default 600_000. */
|
|
19
|
+
waitForAdmissionMs?: number;
|
|
20
|
+
timeoutMs?: number;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Run an expensive build/check command with NODE_OPTIONS heap cap, optional
|
|
24
|
+
* systemd-run memory scope, and RAM-aware admission (parallel-safe).
|
|
25
|
+
*/
|
|
26
|
+
export declare function runBoundedBuildCheck(input: RunBoundedBuildCheckInput): BoundedBuildExecResult;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { DEFAULT_BUILD_MEM_BUDGET_BYTES, DEFAULT_BUILD_MEM_RESERVE_BYTES, DEFAULT_NODE_OLD_SPACE_SIZE_MB, DEFAULT_SYSTEMD_MEMORY_MAX, DEFAULT_SYSTEMD_MEMORY_SWAP_MAX, } from "./constants.js";
|
|
2
|
+
export { readMemAvailableBytes } from "./meminfo.js";
|
|
3
|
+
export { formatNodeOptionsFlag, mergeNodeOptionsForBuildCheck, resolveNodeOldSpaceSizeMb, } from "./node-options.js";
|
|
4
|
+
export { buildSystemdRunArgv, isSystemdRunAvailable, type SystemdWrapOptions, } from "./systemd-wrap.js";
|
|
5
|
+
export { assessBuildAdmission, getActiveBuildCount, registerBuildEnd, registerBuildStart, resetActiveBuildCountForTests, resolveBuildAdmissionConfig, waitForBuildAdmission, type BuildAdmissionConfig, type BuildAdmissionVerdict, } from "./admission.js";
|
|
6
|
+
export { runBoundedBuildCheck, type BoundedBuildExecResult, type RunBoundedBuildCheckInput } from "./exec.js";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Resolved Node old-space cap in MiB (env override, else default 1024). */
|
|
2
|
+
export declare function resolveNodeOldSpaceSizeMb(): number;
|
|
3
|
+
/**
|
|
4
|
+
* Merge NODE_OPTIONS for build/check subprocesses: set --max-old-space-size unless
|
|
5
|
+
* the caller already set one in NODE_OPTIONS or KYNVER_NODE_OLD_SPACE_SIZE_MB=0
|
|
6
|
+
* disables injection.
|
|
7
|
+
*/
|
|
8
|
+
export declare function mergeNodeOptionsForBuildCheck(baseEnv?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
|
|
9
|
+
export declare function formatNodeOptionsFlag(mb?: number): string;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface SystemdWrapOptions {
|
|
2
|
+
memoryMax?: string;
|
|
3
|
+
memorySwapMax?: string;
|
|
4
|
+
cwd?: string;
|
|
5
|
+
/** argv after `--` (no shell). */
|
|
6
|
+
command: string[];
|
|
7
|
+
env?: NodeJS.ProcessEnv;
|
|
8
|
+
}
|
|
9
|
+
/** Clear cached systemd probe (tests). */
|
|
10
|
+
export declare function resetSystemdAvailabilityCacheForTests(): void;
|
|
11
|
+
/** True when `systemd-run --version` succeeds (Linux hosts with systemd). */
|
|
12
|
+
export declare function isSystemdRunAvailable(): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Build argv for `systemd-run --scope` with memory properties, then `-- command…`.
|
|
15
|
+
* Does not execute the command.
|
|
16
|
+
*/
|
|
17
|
+
export declare function buildSystemdRunArgv(opts: SystemdWrapOptions): string[];
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export interface DispatchNextDiskGateShape {
|
|
2
|
+
ok: boolean;
|
|
3
|
+
path: string;
|
|
4
|
+
freeBytes: number;
|
|
5
|
+
totalBytes: number;
|
|
6
|
+
usedPercent: number;
|
|
7
|
+
warnBelowBytes: number;
|
|
8
|
+
criticalBelowBytes: number;
|
|
9
|
+
maxUsedPercent: number;
|
|
10
|
+
hardMaxUsedPercent: number;
|
|
11
|
+
reason: string | null;
|
|
12
|
+
}
|
|
13
|
+
export interface DispatchNextResourceGateShape {
|
|
14
|
+
ok: boolean;
|
|
15
|
+
totalMemBytes: number;
|
|
16
|
+
freeMemBytes: number;
|
|
17
|
+
memReserveBytes: number;
|
|
18
|
+
perWorkerMemBytes: number;
|
|
19
|
+
configuredMaxWorkers: number | null;
|
|
20
|
+
capacityWorkers: number;
|
|
21
|
+
maxConcurrentWorkers: number;
|
|
22
|
+
activeWorkers: number;
|
|
23
|
+
slotsAvailable: number;
|
|
24
|
+
reason: string | null;
|
|
25
|
+
}
|
|
26
|
+
export interface PostJsonResult {
|
|
27
|
+
ok: boolean;
|
|
28
|
+
status: number;
|
|
29
|
+
response: unknown;
|
|
30
|
+
refreshedAuth?: boolean;
|
|
31
|
+
authRefreshFailure?: string;
|
|
32
|
+
}
|
|
33
|
+
export declare function postJson(url: string, secret: string, body: unknown): Promise<PostJsonResult>;
|
|
34
|
+
export declare function postJsonWithCredentialRefresh(url: string, secret: string, body: unknown, opts: {
|
|
35
|
+
agentOsId: string;
|
|
36
|
+
baseUrl?: string;
|
|
37
|
+
}): Promise<PostJsonResult>;
|
|
38
|
+
export declare function getJson(url: string, secret: string): Promise<PostJsonResult>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function runCleanupCli(args: Record<string, string | boolean>): void;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { CleanupAction, CleanupCandidate, CleanupSkipReason } from "./cleanup-types.js";
|
|
2
|
+
export declare function removeNodeModules(candidate: CleanupCandidate, execute: boolean): CleanupAction;
|
|
3
|
+
export declare function removeWorktree(candidate: CleanupCandidate, execute: boolean): CleanupAction;
|
|
4
|
+
export declare function isHarnessNodeModulesPath(targetPath: string, harnessRoot: string, worktreesDir: string): CleanupSkipReason | null;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { CleanupSkipReason } from "./cleanup-types.js";
|
|
2
|
+
import type { IndexedWorktree } from "./cleanup-worktree-index.js";
|
|
3
|
+
import type { RawHarnessWorkerStatus } from "./status.js";
|
|
4
|
+
export declare function isPrOrUnmergedWork(status: RawHarnessWorkerStatus): boolean;
|
|
5
|
+
export interface WorktreeGuardInput {
|
|
6
|
+
indexed: IndexedWorktree | null;
|
|
7
|
+
includeOrphans: boolean;
|
|
8
|
+
worktreesAgeMs: number;
|
|
9
|
+
ageMs: number;
|
|
10
|
+
}
|
|
11
|
+
export declare function skipWorktreeRemoval(input: WorktreeGuardInput): CleanupSkipReason | null;
|
|
12
|
+
export interface NodeModulesGuardInput {
|
|
13
|
+
indexed: IndexedWorktree | null;
|
|
14
|
+
includeOrphans: boolean;
|
|
15
|
+
nodeModulesAgeMs: number;
|
|
16
|
+
ageMs: number;
|
|
17
|
+
}
|
|
18
|
+
export declare function skipNodeModulesRemoval(input: NodeModulesGuardInput): CleanupSkipReason | null;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CleanupCandidate } from "./cleanup-types.js";
|
|
2
|
+
import { type IndexedWorktree } from "./cleanup-worktree-index.js";
|
|
3
|
+
export interface ScanHarnessOptions {
|
|
4
|
+
harnessRoot: string;
|
|
5
|
+
worktreesDir: string;
|
|
6
|
+
nodeModulesAgeMs: number;
|
|
7
|
+
worktreesAgeMs: number;
|
|
8
|
+
includeOrphans: boolean;
|
|
9
|
+
runIdFilter?: string;
|
|
10
|
+
index: Map<string, IndexedWorktree>;
|
|
11
|
+
now: number;
|
|
12
|
+
}
|
|
13
|
+
export declare function scanNodeModulesCandidates(opts: ScanHarnessOptions): CleanupCandidate[];
|
|
14
|
+
export declare function scanWorktreeCandidates(opts: ScanHarnessOptions): CleanupCandidate[];
|
|
@@ -0,0 +1,56 @@
|
|
|
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";
|
|
3
|
+
export interface CleanupCandidate {
|
|
4
|
+
kind: CleanupActionKind;
|
|
5
|
+
path: string;
|
|
6
|
+
bytes: number | null;
|
|
7
|
+
runId?: string;
|
|
8
|
+
worker?: string;
|
|
9
|
+
repo?: string;
|
|
10
|
+
ageMs: number;
|
|
11
|
+
}
|
|
12
|
+
export interface CleanupAction extends CleanupCandidate {
|
|
13
|
+
executed: boolean;
|
|
14
|
+
skipped: boolean;
|
|
15
|
+
skipReason?: CleanupSkipReason;
|
|
16
|
+
error?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface HarnessCleanupSummary {
|
|
19
|
+
harnessRoot: string;
|
|
20
|
+
dryRun: boolean;
|
|
21
|
+
execute: boolean;
|
|
22
|
+
nodeModulesAgeMs: number;
|
|
23
|
+
worktreesAgeMs: number;
|
|
24
|
+
includeOrphans: boolean;
|
|
25
|
+
scannedAt: string;
|
|
26
|
+
actions: CleanupAction[];
|
|
27
|
+
skips: Array<{
|
|
28
|
+
path: string;
|
|
29
|
+
reason: CleanupSkipReason;
|
|
30
|
+
detail?: string;
|
|
31
|
+
}>;
|
|
32
|
+
totals: {
|
|
33
|
+
candidateBytes: number;
|
|
34
|
+
removedBytes: number;
|
|
35
|
+
removedPaths: number;
|
|
36
|
+
skippedPaths: number;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export interface HarnessCleanupOptions {
|
|
40
|
+
harnessRoot?: string;
|
|
41
|
+
/** When false (default), only report candidates. */
|
|
42
|
+
execute?: boolean;
|
|
43
|
+
/** Minimum age before removing generated `node_modules` (default 6h). */
|
|
44
|
+
nodeModulesAgeMs?: number;
|
|
45
|
+
/** When 0 or unset, worktree removal is disabled. */
|
|
46
|
+
worktreesAgeMs?: number;
|
|
47
|
+
/** Allow cleaning `node_modules` under worktrees with no worker index entry. */
|
|
48
|
+
includeOrphans?: boolean;
|
|
49
|
+
/** When set, only consider workers for this harness run (pipeline tick scope). */
|
|
50
|
+
runIdFilter?: string;
|
|
51
|
+
now?: number;
|
|
52
|
+
}
|
|
53
|
+
/** Conservative default aligned with 2026-05-27 manual harness cleanup (6h). */
|
|
54
|
+
export declare const DEFAULT_NODE_MODULES_AGE_MS: number;
|
|
55
|
+
/** Seven days — only used when worktree cleanup is explicitly enabled. */
|
|
56
|
+
export declare const DEFAULT_WORKTREES_AGE_MS: number;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type HarnessRunRecord } from "./run-store.js";
|
|
2
|
+
import { type HarnessWorkerRecord, type RawHarnessWorkerStatus } from "./status.js";
|
|
3
|
+
export interface IndexedWorktree {
|
|
4
|
+
worktreePath: string;
|
|
5
|
+
runId: string;
|
|
6
|
+
workerName: string;
|
|
7
|
+
run: HarnessRunRecord;
|
|
8
|
+
worker: HarnessWorkerRecord;
|
|
9
|
+
status: RawHarnessWorkerStatus;
|
|
10
|
+
}
|
|
11
|
+
export declare function buildWorktreeIndex(): Map<string, IndexedWorktree>;
|
|
12
|
+
/** Load worker when index miss but path is known from disk layout. */
|
|
13
|
+
export declare function loadIndexedWorker(runId: string, workerName: string): HarnessWorkerRecord | null;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type HarnessCleanupOptions, type HarnessCleanupSummary } from "./cleanup-types.js";
|
|
2
|
+
export declare function runHarnessCleanup(options?: HarnessCleanupOptions): HarnessCleanupSummary;
|
|
3
|
+
/** Pipeline-safe defaults: node_modules only, dry-run unless execute env is set. */
|
|
4
|
+
export declare function runPipelineHarnessCleanup(runId?: string): HarnessCleanupSummary;
|
|
5
|
+
export declare function isPipelineCleanupEnabled(): boolean;
|
package/dist/cli.d.ts
ADDED