@kynver-app/runtime 0.1.139 → 0.1.142

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/dist/config.d.ts CHANGED
@@ -14,6 +14,11 @@ export interface KynverUserConfig {
14
14
  deploymentSchedulerProvider?: "qstash" | "kynver-cron" | "openclaw-cron";
15
15
  /** Default harness run for `kynver daemon` / systemd user unit (set by `kynver cron install`). */
16
16
  defaultDaemonRunId?: string;
17
+ /**
18
+ * Kynver-owned daemon restart owner (`keeper` = in-process keeper; `systemd` = user unit).
19
+ * Set during `kynver setup` / `kynver start --install-systemd`.
20
+ */
21
+ daemonSupervisionOwner?: "keeper" | "systemd";
17
22
  /** Physical box pool for capacity snapshots (`forge` | `ghost`). Set via `kynver setup --box-kind`. */
18
23
  boxKind?: "ghost" | "forge";
19
24
  /**
@@ -33,6 +38,13 @@ export interface KynverUserConfig {
33
38
  /** @internal Advanced tuning — not required for setup. */
34
39
  memUtilization?: number;
35
40
  }
41
+ export interface AgentOsIdValidationResult {
42
+ ok: boolean;
43
+ value?: string;
44
+ reason?: string;
45
+ }
46
+ export declare function validateAgentOsId(raw: unknown): AgentOsIdValidationResult;
47
+ export declare function formatAgentOsIdValidationError(raw: unknown): string;
36
48
  export declare function loadUserConfig(): KynverUserConfig;
37
49
  export declare function saveUserConfig(config: KynverUserConfig): void;
38
50
  /** Persist path fields with `~` instead of absolute home directories. */
@@ -0,0 +1,4 @@
1
+ /** Supported consumer host kinds for daemon restart ownership. */
2
+ export type SupportedHostKind = "linux" | "wsl" | "darwin" | "win32";
3
+ export declare function detectSupportedHostKind(): SupportedHostKind;
4
+ export declare function hostSupportsSystemdUserUnit(host: SupportedHostKind): boolean;
@@ -0,0 +1,5 @@
1
+ export { detectSupportedHostKind, hostSupportsSystemdUserUnit, type SupportedHostKind } from "./host.js";
2
+ export { buildDaemonSupervisionPolicy, defaultSupervisionOwner, formatSupervisionGuidance, resolveSupervisionOwner, supervisionEnvUpdates, type DaemonSupervisionOwner, type DaemonSupervisionPolicy, } from "./policy.js";
3
+ export { applyDaemonSupervisionSetup, defaultSystemdUserUnitPath, isSystemdSupervisionInstalled, supervisionOwnerForDoctor, type DaemonSupervisionSetupResult, } from "./setup.js";
4
+ export { ensureDaemonSupervisionForStart, formatSystemdDelegationGuidance, shouldDelegateStartToSystemd, summarizeSupervisionForStart, type EnsureDaemonSupervisionInput, type EnsureDaemonSupervisionResult, } from "./start.js";
5
+ export { assessDaemonSupervisionChecks, type AssessDaemonSupervisionOptions, type DaemonSupervisionVerifyCheck, } from "./verify.js";
@@ -0,0 +1,16 @@
1
+ import type { KynverUserConfig } from "../config.js";
2
+ import { type SupportedHostKind } from "./host.js";
3
+ /** Who owns daemon process restarts on this box (Kynver-owned, not Hermes cron). */
4
+ export type DaemonSupervisionOwner = "keeper" | "systemd";
5
+ export interface DaemonSupervisionPolicy {
6
+ hostKind: SupportedHostKind;
7
+ owner: DaemonSupervisionOwner;
8
+ /** Env keys written during setup/start so the server knows a local daemon owns cron. */
9
+ envUpdates: Record<string, string>;
10
+ guidance: string[];
11
+ }
12
+ export declare function defaultSupervisionOwner(hostKind: SupportedHostKind): DaemonSupervisionOwner;
13
+ export declare function resolveSupervisionOwner(config: KynverUserConfig, hostKind: SupportedHostKind, args?: Record<string, string | boolean>): DaemonSupervisionOwner;
14
+ export declare function supervisionEnvUpdates(): Record<string, string>;
15
+ export declare function formatSupervisionGuidance(hostKind: SupportedHostKind, owner: DaemonSupervisionOwner): string[];
16
+ export declare function buildDaemonSupervisionPolicy(config: KynverUserConfig, args?: Record<string, string | boolean>, hostKind?: SupportedHostKind): DaemonSupervisionPolicy;
@@ -0,0 +1,14 @@
1
+ import { type KynverUserConfig } from "../config.js";
2
+ import { type DaemonSupervisionOwner, type DaemonSupervisionPolicy } from "./policy.js";
3
+ import type { SupportedHostKind } from "./host.js";
4
+ export interface DaemonSupervisionSetupResult {
5
+ policy: DaemonSupervisionPolicy;
6
+ configPath: string;
7
+ envFilePath: string;
8
+ envChanged: boolean;
9
+ configUpdated: boolean;
10
+ }
11
+ export declare function defaultSystemdUserUnitPath(): string;
12
+ export declare function isSystemdSupervisionInstalled(): boolean;
13
+ export declare function applyDaemonSupervisionSetup(config: KynverUserConfig, args?: Record<string, string | boolean>, hostKind?: SupportedHostKind): DaemonSupervisionSetupResult;
14
+ export declare function supervisionOwnerForDoctor(config: KynverUserConfig, hostKind: SupportedHostKind): DaemonSupervisionOwner;
@@ -0,0 +1,26 @@
1
+ import { installSystemdUserDaemon } from "../cron/cron-install-systemd.js";
2
+ import { type KynverUserConfig } from "../config.js";
3
+ export interface EnsureDaemonSupervisionInput {
4
+ config: KynverUserConfig;
5
+ agentOsId: string;
6
+ runId: string;
7
+ args: Record<string, string | boolean>;
8
+ }
9
+ export interface EnsureDaemonSupervisionResult {
10
+ action: "keeper" | "systemd_installed" | "systemd_guided" | "systemd_skipped";
11
+ owner: "keeper" | "systemd";
12
+ systemd?: ReturnType<typeof installSystemdUserDaemon>;
13
+ blockers?: string[];
14
+ }
15
+ /**
16
+ * Before `kynver start` hands off to the keeper, persist supervision env and
17
+ * optionally install the Linux systemd user unit (logout-surviving restarts).
18
+ */
19
+ export declare function ensureDaemonSupervisionForStart(input: EnsureDaemonSupervisionInput): Promise<EnsureDaemonSupervisionResult>;
20
+ /** When systemd install succeeds, `kynver start` must not spawn a foreground keeper. */
21
+ export declare function shouldDelegateStartToSystemd(result: EnsureDaemonSupervisionResult): boolean;
22
+ export declare function formatSystemdDelegationGuidance(unitName?: string): string[];
23
+ export declare function summarizeSupervisionForStart(config: KynverUserConfig, args: Record<string, string | boolean>): {
24
+ owner: "keeper" | "systemd";
25
+ guidance: string[];
26
+ };
@@ -0,0 +1,12 @@
1
+ import type { KynverUserConfig } from "../config.js";
2
+ export interface AssessDaemonSupervisionOptions {
3
+ /** Override for tests; defaults to ~/.kynver/.env */
4
+ envFilePath?: string;
5
+ }
6
+ export interface DaemonSupervisionVerifyCheck {
7
+ id: string;
8
+ ok: boolean;
9
+ summary: string;
10
+ remediation?: string;
11
+ }
12
+ export declare function assessDaemonSupervisionChecks(config: KynverUserConfig, options?: AssessDaemonSupervisionOptions): DaemonSupervisionVerifyCheck[];
@@ -0,0 +1,3 @@
1
+ import type { HarnessWorkerRecord } from "./status.js";
2
+ /** Stop a just-spawned worker when dispatch-start readback fails closed. */
3
+ export declare function abortDispatchedWorkerAfterReadbackFailure(runId: string, worker: HarnessWorkerRecord, reason: string): HarnessWorkerRecord;
@@ -0,0 +1,27 @@
1
+ import type { HarnessWorkerRecord } from "./status.js";
2
+ import type { TaskLeaseSnapshot } from "./monitor/monitor.types.js";
3
+ export declare const DISPATCH_START_READBACK_PREFIX = "dispatch_start_readback_failed:";
4
+ export interface DispatchStartReadbackInput {
5
+ agentOsId: string;
6
+ taskId: string;
7
+ leaseOwner: string;
8
+ expectedLeaseToken: string;
9
+ worker: HarnessWorkerRecord;
10
+ baseUrl: string;
11
+ secret: string;
12
+ }
13
+ export interface DispatchStartReadbackResult {
14
+ ok: boolean;
15
+ error?: string;
16
+ detail?: Record<string, unknown>;
17
+ snapshot?: TaskLeaseSnapshot;
18
+ }
19
+ export declare function formatDispatchStartReadbackFailure(reason: string): string;
20
+ export declare function assessDispatchStartReadback(input: {
21
+ snapshot: TaskLeaseSnapshot | null | undefined;
22
+ leaseOwner: string;
23
+ expectedLeaseToken: string;
24
+ worker: HarnessWorkerRecord;
25
+ }): DispatchStartReadbackResult;
26
+ /** Post-spawn AgentOS readback — board must show a live lease matching the claim token. */
27
+ export declare function verifyDispatchStartReadback(input: DispatchStartReadbackInput): Promise<DispatchStartReadbackResult>;
@@ -0,0 +1,3 @@
1
+ import type { DoctorSection } from "./doctor.types.js";
2
+ import type { RuntimeTakeoverProbes } from "./runtime-takeover.probes.js";
3
+ export declare function assessDaemonSupervision(probes: RuntimeTakeoverProbes): DoctorSection;