@kynver-app/runtime 0.1.42 → 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.
Files changed (117) hide show
  1. package/README.md +15 -0
  2. package/dist/auto-complete.d.ts +60 -0
  3. package/dist/bounded-build/admission.d.ts +30 -0
  4. package/dist/bounded-build/constants.d.ts +10 -0
  5. package/dist/bounded-build/exec.d.ts +26 -0
  6. package/dist/bounded-build/index.d.ts +6 -0
  7. package/dist/bounded-build/meminfo.d.ts +5 -0
  8. package/dist/bounded-build/node-options.d.ts +9 -0
  9. package/dist/bounded-build/systemd-wrap.d.ts +17 -0
  10. package/dist/callback-headers.d.ts +2 -0
  11. package/dist/callbacks.d.ts +38 -0
  12. package/dist/cleanup-cli.d.ts +1 -0
  13. package/dist/cleanup-dir-size.d.ts +4 -0
  14. package/dist/cleanup-execute.d.ts +4 -0
  15. package/dist/cleanup-guards.d.ts +18 -0
  16. package/dist/cleanup-scan.d.ts +14 -0
  17. package/dist/cleanup-types.d.ts +56 -0
  18. package/dist/cleanup-worktree-index.d.ts +13 -0
  19. package/dist/cleanup.d.ts +5 -0
  20. package/dist/cli.d.ts +3 -0
  21. package/dist/cli.js +789 -74
  22. package/dist/cli.js.map +4 -4
  23. package/dist/command-center-contract-cli.d.ts +1 -0
  24. package/dist/completion-ack.d.ts +10 -0
  25. package/dist/completion-response.d.ts +15 -0
  26. package/dist/config.d.ts +61 -0
  27. package/dist/daemon.d.ts +5 -0
  28. package/dist/disk-gate.d.ts +9 -0
  29. package/dist/dispatch.d.ts +16 -0
  30. package/dist/doctor/doctor.types.d.ts +25 -0
  31. package/dist/doctor/index.d.ts +4 -0
  32. package/dist/doctor/runtime-takeover-cli.d.ts +1 -0
  33. package/dist/doctor/runtime-takeover.d.ts +3 -0
  34. package/dist/doctor/runtime-takeover.probes.d.ts +37 -0
  35. package/dist/exit-classify.d.ts +12 -0
  36. package/dist/exited-salvage.d.ts +22 -0
  37. package/dist/finalize.d.ts +16 -0
  38. package/dist/fortress-engagement-gate.d.ts +5 -0
  39. package/dist/git.d.ts +37 -0
  40. package/dist/github-repo.d.ts +5 -0
  41. package/dist/harness-verify-cli.d.ts +1 -0
  42. package/dist/harness-verify.d.ts +19 -0
  43. package/dist/heartbeat.d.ts +22 -0
  44. package/dist/index.d.ts +33 -0
  45. package/dist/index.js +829 -78
  46. package/dist/index.js.map +4 -4
  47. package/dist/installed-package-versions.d.ts +6 -0
  48. package/dist/landing-contract-gate.d.ts +24 -0
  49. package/dist/landing-gate.d.ts +24 -0
  50. package/dist/lease-renewal.d.ts +15 -0
  51. package/dist/model-routing-task-enrich.d.ts +8 -0
  52. package/dist/model-routing.d.ts +29 -0
  53. package/dist/monitor/index.d.ts +7 -0
  54. package/dist/monitor/monitor-cli.d.ts +9 -0
  55. package/dist/monitor/monitor-loop.d.ts +1 -0
  56. package/dist/monitor/monitor-spawn.d.ts +18 -0
  57. package/dist/monitor/monitor.classify.d.ts +15 -0
  58. package/dist/monitor/monitor.service.d.ts +17 -0
  59. package/dist/monitor/monitor.store.d.ts +6 -0
  60. package/dist/monitor/monitor.task-lease.d.ts +11 -0
  61. package/dist/monitor/monitor.terminal.d.ts +11 -0
  62. package/dist/monitor/monitor.types.d.ts +74 -0
  63. package/dist/package-version.d.ts +5 -0
  64. package/dist/path-values.d.ts +5 -0
  65. package/dist/paths.d.ts +7 -0
  66. package/dist/pipeline-dispatch.d.ts +7 -0
  67. package/dist/pipeline-tick.d.ts +45 -0
  68. package/dist/plan-persist/agentos-api.d.ts +28 -0
  69. package/dist/plan-persist/body-hash.d.ts +3 -0
  70. package/dist/plan-persist/drain.d.ts +7 -0
  71. package/dist/plan-persist/errors.d.ts +9 -0
  72. package/dist/plan-persist/handoff.d.ts +7 -0
  73. package/dist/plan-persist/idempotency.d.ts +2 -0
  74. package/dist/plan-persist/index.d.ts +8 -0
  75. package/dist/plan-persist/outbox-store.d.ts +18 -0
  76. package/dist/plan-persist/paths.d.ts +8 -0
  77. package/dist/plan-persist/persist.d.ts +10 -0
  78. package/dist/plan-persist/readback.d.ts +17 -0
  79. package/dist/plan-persist/types.d.ts +91 -0
  80. package/dist/plan-persist-cli.d.ts +3 -0
  81. package/dist/plan-progress-daemon-sync.d.ts +7 -0
  82. package/dist/plan-progress-sync.d.ts +21 -0
  83. package/dist/plan-progress.d.ts +10 -0
  84. package/dist/pr-handoff/index.d.ts +4 -0
  85. package/dist/pr-handoff/pr-handoff-assess.d.ts +26 -0
  86. package/dist/pr-handoff/pr-handoff-gh.d.ts +44 -0
  87. package/dist/pr-handoff/pr-handoff.d.ts +8 -0
  88. package/dist/pr-handoff/pr-handoff.types.d.ts +45 -0
  89. package/dist/prompt.d.ts +14 -0
  90. package/dist/providers/claude.d.ts +4 -0
  91. package/dist/providers/cursor-windows.d.ts +7 -0
  92. package/dist/providers/cursor.d.ts +11 -0
  93. package/dist/providers/model-preflight.d.ts +31 -0
  94. package/dist/providers/registry.d.ts +4 -0
  95. package/dist/providers/types.d.ts +32 -0
  96. package/dist/redact.d.ts +1 -0
  97. package/dist/resource-gate.d.ts +53 -0
  98. package/dist/retry-limits.d.ts +8 -0
  99. package/dist/run-store.d.ts +30 -0
  100. package/dist/shell-command-outcome.d.ts +32 -0
  101. package/dist/stale-reconcile.d.ts +25 -0
  102. package/dist/status.d.ts +161 -0
  103. package/dist/stream.d.ts +20 -0
  104. package/dist/supervisor.d.ts +25 -0
  105. package/dist/sweep.d.ts +1 -0
  106. package/dist/util.d.ts +22 -0
  107. package/dist/validate.d.ts +5 -0
  108. package/dist/vercel/index.d.ts +3 -0
  109. package/dist/vercel/vercel-evidence.d.ts +48 -0
  110. package/dist/vercel/vercel-github-status.d.ts +19 -0
  111. package/dist/vercel/vercel-url.d.ts +16 -0
  112. package/dist/worker-env.d.ts +15 -0
  113. package/dist/worker-lifecycle.d.ts +28 -0
  114. package/dist/worker-ops.d.ts +20 -0
  115. package/dist/workspace-runtime-config.d.ts +8 -0
  116. package/dist/worktree.d.ts +4 -0
  117. package/package.json +4 -2
@@ -0,0 +1,6 @@
1
+ export type InstalledPackageVersionMap = Record<string, {
2
+ version: string;
3
+ observedAt: string;
4
+ path: string;
5
+ }>;
6
+ export declare function collectInstalledPackageVersions(observedAt?: string): Promise<InstalledPackageVersionMap>;
@@ -0,0 +1,24 @@
1
+ import type { WorkerLandingSnapshot } from "./landing-gate.js";
2
+ export type TargetPrOutcome = "merged" | "skipped" | "blocked";
3
+ export interface TargetPrReconciliation {
4
+ prUrl: string;
5
+ outcome: TargetPrOutcome;
6
+ mergeCommit?: string | null;
7
+ reason?: string | null;
8
+ }
9
+ export interface WorkerLandingContract {
10
+ landingOnly: boolean;
11
+ targetPrUrls: string[];
12
+ }
13
+ export type WorkerLandingContractBlockReason = "unrelated_implementation_pr" | "missing_target_pr_reconciliation" | "incomplete_target_pr_landing";
14
+ export interface WorkerLandingContractVerdict {
15
+ blocked: boolean;
16
+ reason?: WorkerLandingContractBlockReason;
17
+ detail?: string;
18
+ }
19
+ export declare function assessWorkerLandingContract(input: {
20
+ contract: WorkerLandingContract;
21
+ snapshot: WorkerLandingSnapshot;
22
+ finalResult?: unknown;
23
+ }): WorkerLandingContractVerdict;
24
+ export declare function landingContractAttentionReason(verdict: WorkerLandingContractVerdict): string | undefined;
@@ -0,0 +1,24 @@
1
+ import type { GitAncestry } from "./git.js";
2
+ export type WorkerLandingBlockReason = "dirty_worktree_no_pr";
3
+ export interface WorkerLandingSnapshot {
4
+ finalResult: unknown;
5
+ changedFiles: string[];
6
+ headCommit?: string | null;
7
+ prUrl?: string | null;
8
+ artifactBundlePath?: string | null;
9
+ patchPath?: string | null;
10
+ gitAncestry?: GitAncestry | null;
11
+ }
12
+ export interface WorkerLandingVerdict {
13
+ /** When true, do not treat the worker as cleanly landed/done. */
14
+ blocked: boolean;
15
+ reason?: WorkerLandingBlockReason;
16
+ /** Human-readable attention reason for boards and completion payloads. */
17
+ detail?: string;
18
+ }
19
+ /**
20
+ * Hard landing gate: a recorded final result is not sufficient when the worker
21
+ * left uncommitted code and has no commit/PR/patch/bundle landing path.
22
+ */
23
+ export declare function assessWorkerLanding(snapshot: WorkerLandingSnapshot): WorkerLandingVerdict;
24
+ export declare function landingAttentionReason(verdict: WorkerLandingVerdict): string | undefined;
@@ -0,0 +1,15 @@
1
+ export interface RenewActiveLeasesResult {
2
+ renewed: string[];
3
+ failed: Array<{
4
+ worker: string;
5
+ reason: string;
6
+ }>;
7
+ skipped: string[];
8
+ }
9
+ /**
10
+ * Renew leases for board-linked workers whose process is still alive.
11
+ * Prevents dispatch/reaper from reclaiming a task while a local worker runs.
12
+ */
13
+ export declare function renewActiveTaskLeases(runId: string, args: Record<string, string | boolean>): Promise<RenewActiveLeasesResult>;
14
+ /** True when this run already has a live worker bound to the same board task. */
15
+ export declare function hasLiveWorkerForTask(runId: string, taskId: string): boolean;
@@ -0,0 +1,8 @@
1
+ /** Enrich dispatch task metadata with `roleLane` when the board row omits it. */
2
+ /**
3
+ * Best-effort plan role lane from persona, title, and executorRef.
4
+ * Returns undefined when nothing confident matches.
5
+ */
6
+ export declare function inferRoleLaneFromTask(task: Record<string, unknown>): string | undefined;
7
+ /** Attach inferred `roleLane` so `inferModelRoutingFromTask` can use plan-lane rules. */
8
+ export declare function enrichTaskForModelRouting(task: Record<string, unknown>): Record<string, unknown>;
@@ -0,0 +1,29 @@
1
+ import { type KynverUserConfig } from "./config.js";
2
+ /** Conservative default — Sonnet for ordinary harness work (not Opus). */
3
+ export declare const GLOBAL_DEFAULT_MODEL = "claude-sonnet-4-6";
4
+ export declare const CURSOR_DEFAULT_MODEL = "composer-2.5";
5
+ export interface ModelRoutingDecision {
6
+ /** Model id passed to the provider CLI (undefined → provider default). */
7
+ model?: string;
8
+ /** Worker provider key (`claude` | `cursor`). */
9
+ provider: string;
10
+ /** Audit trail for Command Center / worker.json. */
11
+ rule: string;
12
+ /** Original task/board model request when inferred from metadata. */
13
+ requestedModel?: string;
14
+ }
15
+ /** Resolve global default: config → env → Sonnet. */
16
+ export declare function resolveGlobalDefaultModel(config?: KynverUserConfig): string;
17
+ /**
18
+ * Infer model + provider from AgentOS task metadata when the dispatcher did not
19
+ * pass an explicit `--model`. Explicit CLI/model args always win.
20
+ */
21
+ export declare function inferModelRoutingFromTask(task: Record<string, unknown>): ModelRoutingDecision;
22
+ /** Resolve launch parameters: explicit CLI wins, then task inference, then global default. */
23
+ export declare function resolveWorkerLaunch(input: {
24
+ explicitModel?: string;
25
+ explicitProvider?: string;
26
+ task?: Record<string, unknown>;
27
+ }): ModelRoutingDecision;
28
+ /** Fallback chain tail after provider start — never hard-code Opus here. */
29
+ export declare function resolveModelFallback(startedModel: string | undefined, launchModel: string | undefined, providerDefault: string | undefined): string;
@@ -0,0 +1,7 @@
1
+ export type { AutoCompleteAssessment, MonitorListEntry, MonitorSessionRecord, MonitorTickResult, TaskLeaseSnapshot, WorkerHealthClass, WorkerMonitorView, } from "./monitor.types.js";
2
+ export { classifyWorkerHealth, type WorkerHealthClassification } from "./monitor.classify.js";
3
+ export { assessAutoCompleteEligibility } from "./monitor.terminal.js";
4
+ export { getMonitorStatus, listMonitors, monitorAutoCompleteCli, runMonitorTick, stopMonitor, } from "./monitor.service.js";
5
+ export { spawnMonitorSidecar, type SpawnedMonitor, type SpawnMonitorOptions } from "./monitor-spawn.js";
6
+ export { runMonitorLoop } from "./monitor-loop.js";
7
+ export { deleteMonitorSession, loadMonitorSession, monitorIdFor, saveMonitorSession, } from "./monitor.store.js";
@@ -0,0 +1,9 @@
1
+ import { getMonitorStatus, listMonitors, monitorAutoCompleteCli, runMonitorTick, stopMonitor } from "./monitor.service.js";
2
+ import type { StartMonitorResult } from "./monitor.service.js";
3
+ export declare function startMonitorCli(args: Record<string, string | boolean>): Promise<StartMonitorResult>;
4
+ export declare function monitorStatusCli(args: Record<string, string | boolean>): Promise<void>;
5
+ export declare function monitorStopCli(args: Record<string, string | boolean>): void;
6
+ export declare function monitorListCli(): void;
7
+ export declare function monitorRunLoopCli(args: Record<string, string | boolean>): Promise<void>;
8
+ export declare function monitorTickCli(args: Record<string, string | boolean>): Promise<void>;
9
+ export { monitorAutoCompleteCli, startMonitorCli as startMonitor, getMonitorStatus, listMonitors, runMonitorTick, stopMonitor, };
@@ -0,0 +1 @@
1
+ export declare function runMonitorLoop(args: Record<string, string | boolean>): Promise<void>;
@@ -0,0 +1,18 @@
1
+ import type { MonitorSessionRecord } from "./monitor.types.js";
2
+ export interface SpawnMonitorOptions {
3
+ runId: string;
4
+ workerName?: string;
5
+ agentOsId?: string;
6
+ pollMs?: number;
7
+ cliPath?: string;
8
+ nodeExecutable?: string;
9
+ baseUrl?: string;
10
+ secret?: string;
11
+ }
12
+ export interface SpawnedMonitor {
13
+ monitorId: string;
14
+ pid?: number;
15
+ logPath: string;
16
+ session: MonitorSessionRecord;
17
+ }
18
+ export declare function spawnMonitorSidecar(opts: SpawnMonitorOptions): SpawnedMonitor | undefined;
@@ -0,0 +1,15 @@
1
+ import { type HarnessWorkerRecord, type RawHarnessWorkerStatus } from "../status.js";
2
+ import type { TaskLeaseSnapshot, WorkerHealthClass } from "./monitor.types.js";
3
+ export interface WorkerHealthClassification {
4
+ health: WorkerHealthClass;
5
+ reason: string;
6
+ }
7
+ /**
8
+ * Classify harness worker disk state vs optional board lease snapshot.
9
+ * `running` on AgentTask means live executor lease — not plan-row `in_progress`.
10
+ */
11
+ export declare function classifyWorkerHealth(input: {
12
+ worker: HarnessWorkerRecord;
13
+ status: RawHarnessWorkerStatus;
14
+ taskLease?: TaskLeaseSnapshot | null;
15
+ }): WorkerHealthClassification;
@@ -0,0 +1,17 @@
1
+ import type { MonitorListEntry, MonitorSessionRecord, MonitorTickResult } from "./monitor.types.js";
2
+ /** One monitor poll: classify workers, renew leases, auto-complete when verified terminal. */
3
+ export declare function runMonitorTick(args: Record<string, string | boolean>): Promise<MonitorTickResult>;
4
+ export declare function getMonitorStatus(args: Record<string, string | boolean>): MonitorTickResult;
5
+ export declare function listMonitors(): MonitorListEntry[];
6
+ export interface StartMonitorResult {
7
+ monitorId: string;
8
+ session: MonitorSessionRecord;
9
+ spawned: boolean;
10
+ pid?: number;
11
+ }
12
+ export declare function stopMonitor(args: Record<string, string | boolean>): {
13
+ monitorId: string;
14
+ stopped: boolean;
15
+ pid?: number;
16
+ };
17
+ export declare function monitorAutoCompleteCli(args: Record<string, string | boolean>): Promise<void>;
@@ -0,0 +1,6 @@
1
+ import type { MonitorListEntry, MonitorSessionRecord } from "./monitor.types.js";
2
+ export declare function monitorIdFor(runId: string, workerName?: string): string;
3
+ export declare function loadMonitorSession(monitorId: string): MonitorSessionRecord | undefined;
4
+ export declare function saveMonitorSession(session: MonitorSessionRecord): void;
5
+ export declare function deleteMonitorSession(monitorId: string): boolean;
6
+ export declare function listMonitorSessions(): MonitorListEntry[];
@@ -0,0 +1,11 @@
1
+ import type { TaskLeaseSnapshot } from "./monitor.types.js";
2
+ /**
3
+ * Best-effort board lease snapshot for monitor classification. Failures return
4
+ * an empty map — local disk classification still runs without server data.
5
+ */
6
+ export declare function fetchTaskLeasesForWorkers(input: {
7
+ agentOsId?: string;
8
+ taskIds: string[];
9
+ baseUrl?: string;
10
+ secret?: string;
11
+ }): Promise<Map<string, TaskLeaseSnapshot>>;
@@ -0,0 +1,11 @@
1
+ import { type HarnessWorkerRecord, type RawHarnessWorkerStatus } from "../status.js";
2
+ import type { AutoCompleteAssessment } from "./monitor.types.js";
3
+ /**
4
+ * Auto-complete may only run when the worker has reached a verified terminal
5
+ * condition and no structural blocker is present. Never paper over heartbeat
6
+ * blockers, landing gates, or completion replay failures.
7
+ */
8
+ export declare function assessAutoCompleteEligibility(input: {
9
+ worker: HarnessWorkerRecord;
10
+ status: RawHarnessWorkerStatus;
11
+ }): AutoCompleteAssessment;
@@ -0,0 +1,74 @@
1
+ import type { RawHarnessWorkerStatus } from "../status.js";
2
+ /** Local worker health — distinct from AgentTask `running` (live executor lease). */
3
+ export type WorkerHealthClass = "healthy" | "stale" | "orphaned";
4
+ export interface TaskLeaseSnapshot {
5
+ taskId: string;
6
+ /** AgentTask.status — `running` means a live executor lease on the board. */
7
+ status: string;
8
+ leaseOwner: string | null;
9
+ leaseExpiresAt: string | null;
10
+ heartbeatAt: string | null;
11
+ blocker: string | null;
12
+ }
13
+ export interface MonitorSessionRecord {
14
+ monitorId: string;
15
+ runId: string;
16
+ workerName?: string;
17
+ agentOsId?: string;
18
+ pid?: number;
19
+ startedAt: string;
20
+ stoppedAt?: string;
21
+ pollMs: number;
22
+ logPath: string;
23
+ }
24
+ export interface WorkerMonitorView {
25
+ runId: string;
26
+ worker: string;
27
+ health: WorkerHealthClass;
28
+ healthReason: string;
29
+ workerStatus: string;
30
+ attentionState: string;
31
+ attentionReason: string;
32
+ alive: boolean;
33
+ taskId?: string;
34
+ leaseOwner?: string;
35
+ taskStatus?: string;
36
+ autoComplete: AutoCompleteAssessment;
37
+ status: RawHarnessWorkerStatus;
38
+ }
39
+ export interface AutoCompleteAssessment {
40
+ eligible: boolean;
41
+ terminalVerified: boolean;
42
+ terminalReason?: string;
43
+ blockers: string[];
44
+ }
45
+ export interface MonitorTickResult {
46
+ runId: string;
47
+ agentOsId?: string;
48
+ workers: WorkerMonitorView[];
49
+ leaseRenewal?: {
50
+ renewed: string[];
51
+ failed: Array<{
52
+ worker: string;
53
+ reason: string;
54
+ }>;
55
+ skipped: string[];
56
+ };
57
+ autoCompleted: Array<{
58
+ worker: string;
59
+ outcome: string;
60
+ ok: boolean;
61
+ reason?: string;
62
+ }>;
63
+ }
64
+ export interface MonitorListEntry {
65
+ monitorId: string;
66
+ runId: string;
67
+ workerName?: string;
68
+ agentOsId?: string;
69
+ pid?: number;
70
+ alive: boolean;
71
+ startedAt: string;
72
+ pollMs: number;
73
+ logPath: string;
74
+ }
@@ -0,0 +1,5 @@
1
+ export declare function readOwnPackageVersion(moduleUrl?: string): string;
2
+ export declare const PACKAGE_VERSION: string;
3
+ export declare function wantsCliVersion(argv: string[]): boolean;
4
+ export declare function printCliVersionAndExit(version: string, binName?: string): never;
5
+ export declare function handleCliVersionFlag(argv: string[], moduleUrl?: string, binName?: string): boolean;
@@ -0,0 +1,5 @@
1
+ export declare function expandHomePath(value: string): string;
2
+ export declare function resolveUserPath(value: string): string;
3
+ export declare function redactHomePath(value: string): string;
4
+ /** User-facing path strings (doctor JSON, setup output). */
5
+ export declare function displayUserPath(value: string): string;
@@ -0,0 +1,7 @@
1
+ export declare function resolveHarnessRoot(): string;
2
+ export declare function getHarnessPaths(): {
3
+ harnessRoot: string;
4
+ runsDir: string;
5
+ worktreesDir: string;
6
+ };
7
+ export declare function runDir(runsDir: string, id: string): string;
@@ -0,0 +1,7 @@
1
+ /** Drop CLI max-starts so pipeline ticks always use the resource-gate slot budget. */
2
+ export declare function stripCliMaxStarts(args: Record<string, string | boolean>): Record<string, string | boolean>;
3
+ /**
4
+ * Two-pass daemon dispatch: reserve one start for the review lane, then fill
5
+ * remaining slots from the mixed queue (review-first ordering on the server).
6
+ */
7
+ export declare function runPipelineDispatch(args: Record<string, string | boolean>, slots: number): Promise<Record<string, unknown>>;
@@ -0,0 +1,45 @@
1
+ import type { ReconcileStaleWorkersResult } from "./stale-reconcile.js";
2
+ import { type RunnerResourceGateShape } from "./resource-gate.js";
3
+ import { renewActiveTaskLeases } from "./lease-renewal.js";
4
+ import type { HarnessCleanupSummary } from "./cleanup-types.js";
5
+ export interface PipelineTickResult {
6
+ runId: string;
7
+ agentOsId: string;
8
+ execute: boolean;
9
+ resourceGate: RunnerResourceGateShape;
10
+ leaseRenewal?: Awaited<ReturnType<typeof renewActiveTaskLeases>>;
11
+ completedWorkers: Array<{
12
+ worker: string;
13
+ ok: boolean;
14
+ taskId?: string | null;
15
+ skipped?: boolean;
16
+ }>;
17
+ staleReconcile: ReconcileStaleWorkersResult;
18
+ planProgressSync: Array<{
19
+ worker: string;
20
+ phase: string;
21
+ ok: boolean;
22
+ skipped?: boolean;
23
+ }>;
24
+ completionAckSync: Array<{
25
+ worker: string;
26
+ taskId: string;
27
+ taskStatus: string;
28
+ }>;
29
+ harnessCleanup?: HarnessCleanupSummary;
30
+ operatorTick: unknown;
31
+ sweep: unknown;
32
+ dispatch: unknown;
33
+ idle: boolean;
34
+ }
35
+ export declare function completeFinishedWorkers(runId: string, args: Record<string, string | boolean>): Promise<Array<{
36
+ worker: string;
37
+ ok: boolean;
38
+ taskId?: string | null;
39
+ skipped?: boolean;
40
+ }>>;
41
+ /**
42
+ * One operator/dispatcher cycle (M10 / D7 pull-first):
43
+ * refresh status → complete finished workers → ingest operator tick → sweep leases → dispatch up to slot cap.
44
+ */
45
+ export declare function runPipelineTick(args: Record<string, string | boolean>): Promise<PipelineTickResult>;
@@ -0,0 +1,28 @@
1
+ import type { PersistPlanInput } from "./types.js";
2
+ export interface AgentOsPlanGetPayload {
3
+ plan: {
4
+ id: string;
5
+ title: string;
6
+ summary: string | null;
7
+ currentVersionId: string | null;
8
+ };
9
+ currentVersion: {
10
+ id: string;
11
+ versionNumber: number;
12
+ title: string;
13
+ body: string;
14
+ summary: string | null;
15
+ } | null;
16
+ }
17
+ export interface AgentOsWriteResult {
18
+ planId: string;
19
+ versionId: string | null;
20
+ versionNumber: number | null;
21
+ }
22
+ export interface AgentOsApiDeps {
23
+ baseUrl?: string;
24
+ apiKey?: string;
25
+ fetchFn?: typeof fetch;
26
+ }
27
+ export declare function agentOsGetPlan(slug: string, planId: string, deps?: AgentOsApiDeps): Promise<AgentOsPlanGetPayload>;
28
+ export declare function agentOsWritePlan(input: PersistPlanInput, deps?: AgentOsApiDeps): Promise<AgentOsWriteResult>;
@@ -0,0 +1,3 @@
1
+ /** Stable hash for readback verification (normalized trailing whitespace). */
2
+ export declare function hashPlanBody(body: string): string;
3
+ export declare function hashSummary(summary: string | null | undefined): string | null;
@@ -0,0 +1,7 @@
1
+ import { type PersistPlanDeps } from "./persist.js";
2
+ import type { DrainOutboxResult, PlanOutboxItem } from "./types.js";
3
+ export declare function drainPlanOutbox(opts?: {
4
+ max?: number;
5
+ outboxId?: string;
6
+ }, deps?: PersistPlanDeps): Promise<DrainOutboxResult>;
7
+ export declare function loadOutboxById(outboxId: string): PlanOutboxItem | null;
@@ -0,0 +1,9 @@
1
+ import type { PlanPersistFailureKind } from "./types.js";
2
+ export declare class PlanPersistError extends Error {
3
+ readonly kind: PlanPersistFailureKind;
4
+ readonly httpStatus?: number;
5
+ constructor(kind: PlanPersistFailureKind, message: string, httpStatus?: number);
6
+ }
7
+ export declare function classifyHttpFailure(status: number, message: string): PlanPersistError;
8
+ export declare function classifyFetchFailure(err: unknown): PlanPersistError;
9
+ export declare function isRetryableFailure(kind: PlanPersistFailureKind): boolean;
@@ -0,0 +1,7 @@
1
+ import type { PlanOutboxItem } from "./types.js";
2
+ export declare function formatPlanOutboxHandoffBlock(item: PlanOutboxItem): string;
3
+ export declare function extractPlanOutboxFromTask(task: Record<string, unknown>): {
4
+ outboxId?: string;
5
+ jsonPath?: string;
6
+ bodyPath?: string;
7
+ } | null;
@@ -0,0 +1,2 @@
1
+ import type { PersistPlanInput } from "./types.js";
2
+ export declare function buildPlanPersistIdempotencyKey(input: PersistPlanInput): string;
@@ -0,0 +1,8 @@
1
+ export type { PlanPersistUserStatus, PlanPersistOperation, PlanOutboxItem, PersistPlanInput, PersistPlanResult, DrainOutboxResult, } from "./types.js";
2
+ export { hashPlanBody, hashSummary } from "./body-hash.js";
3
+ export { persistPlan } from "./persist.js";
4
+ export { drainPlanOutbox, loadOutboxById } from "./drain.js";
5
+ export { listOutboxItems, findOutboxByIdempotencyKey } from "./outbox-store.js";
6
+ export { formatPlanOutboxHandoffBlock, extractPlanOutboxFromTask, } from "./handoff.js";
7
+ export { isTmpOnlyPath, planOutboxDir } from "./paths.js";
8
+ export { PlanPersistError } from "./errors.js";
@@ -0,0 +1,18 @@
1
+ import type { PlanOutboxItem, PersistPlanInput } from "./types.js";
2
+ export declare function listOutboxItems(): PlanOutboxItem[];
3
+ export declare function findOutboxByIdempotencyKey(key: string): PlanOutboxItem | null;
4
+ export declare function readOutboxItem(jsonPath: string): PlanOutboxItem | null;
5
+ export declare function readOutboxBody(item: PlanOutboxItem): string;
6
+ export declare function writeOutboxItem(input: PersistPlanInput, opts: {
7
+ lastError: string;
8
+ lastFailureKind: PlanOutboxItem["lastFailureKind"];
9
+ existing?: PlanOutboxItem;
10
+ }): PlanOutboxItem;
11
+ export declare function saveOutboxItem(item: PlanOutboxItem): void;
12
+ export declare function archiveOutboxItem(item: PlanOutboxItem): void;
13
+ export declare function outboxItemPaths(item: PlanOutboxItem): {
14
+ jsonPath: string;
15
+ bodyPath: string;
16
+ };
17
+ export declare function removeOutboxItem(item: PlanOutboxItem): void;
18
+ export declare function outboxInputFromItem(item: PlanOutboxItem, body: string): PersistPlanInput;
@@ -0,0 +1,8 @@
1
+ export declare function resolveKynverStateRoot(): string;
2
+ export declare function planOutboxDir(): string;
3
+ export declare function planOutboxArchiveDir(): string;
4
+ export declare function ensurePlanOutboxDirs(): {
5
+ outboxDir: string;
6
+ archiveDir: string;
7
+ };
8
+ export declare function isTmpOnlyPath(filePath: string): boolean;
@@ -0,0 +1,10 @@
1
+ import type { AgentOsApiDeps } from "./agentos-api.js";
2
+ import { agentOsWritePlan } from "./agentos-api.js";
3
+ import { verifyPlanReadback } from "./readback.js";
4
+ import type { PersistPlanInput, PersistPlanResult } from "./types.js";
5
+ export interface PersistPlanDeps extends AgentOsApiDeps {
6
+ /** When set, skip live HTTP (tests). */
7
+ writePlan?: typeof agentOsWritePlan;
8
+ verifyReadback?: typeof verifyPlanReadback;
9
+ }
10
+ export declare function persistPlan(input: PersistPlanInput, deps?: PersistPlanDeps): Promise<PersistPlanResult>;
@@ -0,0 +1,17 @@
1
+ import { type AgentOsApiDeps } from "./agentos-api.js";
2
+ import type { PlanPersistReadbackEvidence, PersistPlanInput } from "./types.js";
3
+ export interface ReadbackExpectation {
4
+ planId: string;
5
+ title: string;
6
+ summary: string | null;
7
+ body: string;
8
+ bodyHash: string;
9
+ versionId?: string | null;
10
+ versionNumber?: number | null;
11
+ }
12
+ export declare function verifyPlanReadback(slug: string, expectation: ReadbackExpectation, deps?: AgentOsApiDeps): Promise<PlanPersistReadbackEvidence>;
13
+ export declare function buildReadbackExpectation(input: PersistPlanInput, write: {
14
+ planId: string;
15
+ versionId: string | null;
16
+ versionNumber: number | null;
17
+ }): ReadbackExpectation;
@@ -0,0 +1,91 @@
1
+ /** User-facing persistence outcome — never imply AgentOS success from local files alone. */
2
+ export type PlanPersistUserStatus = "persisted and read back" | "queued for retry" | "failed and needs action";
3
+ export type PlanPersistOperation = "create" | "add_version" | "update_metadata";
4
+ export type PlanOutboxQueueStatus = "queued" | "draining" | "archived" | "failed";
5
+ export type PlanPersistFailureKind = "approval_guard" | "auth" | "network" | "server" | "tool_interruption" | "verification_failed" | "permanent";
6
+ export interface PlanPersistSourceRefs {
7
+ model?: string;
8
+ source?: string;
9
+ [key: string]: unknown;
10
+ }
11
+ export interface PlanPersistReadbackEvidence {
12
+ planId: string;
13
+ currentVersionId: string | null;
14
+ versionNumber: number | null;
15
+ title: string;
16
+ summary: string | null;
17
+ bodyHash: string;
18
+ readAt: string;
19
+ }
20
+ export interface PlanOutboxItem {
21
+ id: string;
22
+ idempotencyKey: string;
23
+ operation: PlanPersistOperation;
24
+ agentOsSlug: string;
25
+ planId: string | null;
26
+ planSlug: string | null;
27
+ title: string;
28
+ summary: string | null;
29
+ /** Relative to outbox dir when body is large; inline when small. */
30
+ bodyPath: string;
31
+ bodyHash: string;
32
+ author: string | null;
33
+ model: string | null;
34
+ sourceRefs: PlanPersistSourceRefs | null;
35
+ changeSummary: string | null;
36
+ markCurrent: boolean | null;
37
+ createdAt: string;
38
+ updatedAt: string;
39
+ retryCount: number;
40
+ maxRetries: number;
41
+ lastError: string | null;
42
+ lastFailureKind: PlanPersistFailureKind | null;
43
+ queueStatus: PlanOutboxQueueStatus;
44
+ userStatus: PlanPersistUserStatus;
45
+ /** Set after a successful drain for audit. */
46
+ readbackEvidence: PlanPersistReadbackEvidence | null;
47
+ }
48
+ export interface PersistPlanInput {
49
+ operation: PlanPersistOperation;
50
+ agentOsSlug: string;
51
+ title: string;
52
+ body: string;
53
+ summary?: string | null;
54
+ planId?: string | null;
55
+ planSlug?: string | null;
56
+ changeSummary?: string | null;
57
+ author?: string | null;
58
+ model?: string | null;
59
+ sourceRefs?: PlanPersistSourceRefs | null;
60
+ markCurrent?: boolean;
61
+ maxRetries?: number;
62
+ /** When the immediate AgentOS/MCP write failed before reaching the server. */
63
+ immediateFailure?: {
64
+ kind: PlanPersistFailureKind;
65
+ message: string;
66
+ };
67
+ /** Optional path hint — `/tmp`-only paths must not count as durable persistence. */
68
+ bodyPathHint?: string;
69
+ }
70
+ export interface PersistPlanResult {
71
+ userStatus: PlanPersistUserStatus;
72
+ outboxId?: string;
73
+ outboxPath?: string;
74
+ bodyPath?: string;
75
+ planId?: string;
76
+ versionId?: string;
77
+ readbackEvidence?: PlanPersistReadbackEvidence;
78
+ lastError?: string;
79
+ idempotencyKey?: string;
80
+ }
81
+ export interface DrainOutboxResult {
82
+ processed: number;
83
+ succeeded: number;
84
+ stillQueued: number;
85
+ failed: number;
86
+ results: Array<{
87
+ outboxId: string;
88
+ userStatus: PlanPersistUserStatus;
89
+ lastError?: string;
90
+ }>;
91
+ }
@@ -0,0 +1,3 @@
1
+ export declare function runPlanPersist(args: Record<string, string | boolean>): Promise<void>;
2
+ export declare function runPlanOutboxList(): Promise<void>;
3
+ export declare function runPlanOutboxDrain(args: Record<string, string | boolean>): Promise<void>;
@@ -0,0 +1,7 @@
1
+ /** Push heartbeat blockers to the server orchestrator (deduped per worker). */
2
+ export declare function syncActiveWorkerPlanProgress(runId: string, args: Record<string, string | boolean>): Promise<Array<{
3
+ worker: string;
4
+ phase: string;
5
+ ok: boolean;
6
+ skipped?: boolean;
7
+ }>>;
@@ -0,0 +1,21 @@
1
+ export type PlanProgressSyncPhase = "worker_dispatched" | "worker_completed" | "heartbeat_blocker";
2
+ export interface PlanProgressSyncArtifact {
3
+ branch?: string;
4
+ worktreePath?: string;
5
+ prUrl?: string;
6
+ headCommit?: string;
7
+ changedFiles?: string[];
8
+ }
9
+ export declare function syncPlanProgress(args: {
10
+ agentOsId: string;
11
+ taskId: string;
12
+ phase: PlanProgressSyncPhase;
13
+ blocker?: string;
14
+ artifact?: PlanProgressSyncArtifact;
15
+ baseUrl?: string;
16
+ secret?: string;
17
+ }): Promise<{
18
+ ok: boolean;
19
+ status: number;
20
+ response: unknown;
21
+ }>;