@kynver-app/runtime 0.2.19 → 0.2.24

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 (48) hide show
  1. package/README.md +52 -18
  2. package/dist/bootstrap.d.ts +48 -0
  3. package/dist/cli.d.ts +11 -0
  4. package/dist/cli.js +73 -66
  5. package/dist/config.d.ts +1 -1
  6. package/dist/cron/cron-install-plan.d.ts +3 -1
  7. package/dist/daemon-keeper.d.ts +32 -0
  8. package/dist/doctor/runner-install.d.ts +86 -2
  9. package/dist/doctor/runtime-takeover-deploy-evidence.d.ts +7 -3
  10. package/dist/doctor/runtime-takeover.probes.d.ts +1 -1
  11. package/dist/index.d.ts +5 -2
  12. package/dist/index.js +95 -88
  13. package/dist/landing/land-pr-check-classify.d.ts +6 -0
  14. package/dist/orchestration-providers/inventory.d.ts +27 -4
  15. package/dist/provider-evidence/index.d.ts +0 -1
  16. package/dist/providers/model-preflight.d.ts +8 -0
  17. package/dist/providers/openai-compatible-response.d.ts +23 -0
  18. package/dist/providers/openai-compatible-runner.d.ts +1 -0
  19. package/dist/providers/openai-compatible.d.ts +46 -0
  20. package/dist/scheduler-cutover.d.ts +1 -1
  21. package/dist/server/adapter-contract.d.ts +1 -0
  22. package/dist/server/adapter-contract.js +1 -0
  23. package/dist/server/cleanup.js +14 -14
  24. package/dist/server/context-budget-receipt.d.ts +2 -0
  25. package/dist/server/context-budget-receipt.js +6 -0
  26. package/dist/server/db-credentials.d.ts +1 -0
  27. package/dist/server/db-credentials.js +2 -0
  28. package/dist/server/default-repo.js +1 -1
  29. package/dist/server/heavy-verification.js +1 -1
  30. package/dist/server/memory-cost-enforce.js +2 -2
  31. package/dist/server/memory-cost.js +2 -2
  32. package/dist/server/model-routing.d.ts +3 -0
  33. package/dist/server/model-routing.js +5 -0
  34. package/dist/server/monitor.js +7 -7
  35. package/dist/server/node-runtime-policy.d.ts +1 -0
  36. package/dist/server/node-runtime-policy.js +1 -0
  37. package/dist/server/orchestration.d.ts +1 -1
  38. package/dist/server/orchestration.js +1 -1
  39. package/dist/server/prompt.d.ts +1 -0
  40. package/dist/server/prompt.js +19 -0
  41. package/dist/server/worker-policy.d.ts +1 -1
  42. package/dist/server/worker-policy.js +2 -2
  43. package/dist/status.d.ts +3 -1
  44. package/dist/stream.d.ts +13 -0
  45. package/dist/worker-provider-policy.d.ts +21 -4
  46. package/dist/worker-usage.d.ts +20 -0
  47. package/dist/worktree.d.ts +33 -0
  48. package/package.json +34 -3
package/dist/config.d.ts CHANGED
@@ -9,7 +9,7 @@ export interface KynverUserConfig {
9
9
  harnessRoot?: string;
10
10
  /**
11
11
  * Operator attestation that the hosted Kynver deployment uses this scheduler provider
12
- * (set on user runners after Vercel env cutover — scheduling is deployment-owned).
12
+ * (set on user runners after the hosted env cutover — scheduling is deployment-owned).
13
13
  */
14
14
  deploymentSchedulerProvider?: "qstash" | "kynver-cron" | "openclaw-cron";
15
15
  /** Default harness run for `kynver daemon` / systemd user unit (set by `kynver cron install`). */
@@ -1,7 +1,9 @@
1
1
  import type { KynverUserConfig } from "../config.js";
2
2
  export declare const WATCHDOG_DEDUPE_KEY = "watchdog:board-sweep";
3
3
  export declare const DEFAULT_WATCHDOG_CRON = "*/5 * * * *";
4
- export declare const VERCEL_KYNVER_CRON_CUTOVER_STEPS: readonly ["Set KYNVER_SCHEDULER_PROVIDER=kynver-cron on the hosted Kynver deployment (Vercel).", "Set KYNVER_CRON_SECRET to the same value written to ~/.kynver/.env by this installer.", "Unset KYNVER_CRON_STORE_PATH on Vercel — the connected box owns the local store.", "Keep QSTASH_TOKEN only if other non-watchdog schedules still use QStash (analyst/market jobs)."];
4
+ export declare const HOSTED_KYNVER_CRON_CUTOVER_STEPS: readonly ["Set KYNVER_SCHEDULER_PROVIDER=kynver-cron on the hosted Kynver deployment (the Railway production service).", "Set KYNVER_CRON_SECRET to the same value written to ~/.kynver/.env by this installer.", "Unset KYNVER_CRON_STORE_PATH on the Railway service — the connected box owns the local store.", "Keep QSTASH_TOKEN only if other non-watchdog schedules still use QStash (analyst/market jobs)."];
5
+ /** @deprecated Renamed after the 2026-08 Railway cutover — use HOSTED_KYNVER_CRON_CUTOVER_STEPS. */
6
+ export declare const VERCEL_KYNVER_CRON_CUTOVER_STEPS: readonly ["Set KYNVER_SCHEDULER_PROVIDER=kynver-cron on the hosted Kynver deployment (the Railway production service).", "Set KYNVER_CRON_SECRET to the same value written to ~/.kynver/.env by this installer.", "Unset KYNVER_CRON_STORE_PATH on the Railway service — the connected box owns the local store.", "Keep QSTASH_TOKEN only if other non-watchdog schedules still use QStash (analyst/market jobs)."];
5
7
  export interface CronInstallPlanInput {
6
8
  config: KynverUserConfig;
7
9
  apiBaseUrl: string;
@@ -1,3 +1,35 @@
1
+ /**
2
+ * A child that dies nonzero this fast with a config-shaped error message will
3
+ * die identically on every respawn — a bad `~/.kynver/config.json` must not
4
+ * become an infinite keeper crash loop (respawn → same error → backoff → …).
5
+ */
6
+ export declare const KEEPER_PERMANENT_FAILURE_WINDOW_MS = 10000;
7
+ export interface KeeperChildFailureVerdict {
8
+ permanent: boolean;
9
+ /** First stderr line that matched a permanent pattern (for the operator). */
10
+ matchedLine?: string;
11
+ }
12
+ /**
13
+ * Decide whether a child exit is a permanent configuration failure (stop
14
+ * respawning) or transient (keep exponential backoff). Permanent requires ALL
15
+ * of: a nonzero exit code (signals are transient — OOM killer etc.), death
16
+ * inside the startup grace window, and stderr matching a known config-error
17
+ * class. Anything else keeps the resilient default: respawn with backoff.
18
+ */
19
+ export declare function classifyKeeperChildFailure(input: {
20
+ exitCode: number | null;
21
+ exitSignal: NodeJS.Signals | null;
22
+ uptimeMs: number;
23
+ stderrTail: string;
24
+ }): KeeperChildFailureVerdict;
25
+ /**
26
+ * Remediation-formatted error for a missing daemon/keeper argument (modeled
27
+ * on `formatAgentOsIdValidationError`): what is missing, where it normally
28
+ * comes from (`~/.kynver/config.json`), and the command that sets it up. The
29
+ * leading `missing --…` token is load-bearing — the keeper's permanent
30
+ * config-error classifier and legacy log greps both key on it.
31
+ */
32
+ export declare function formatMissingDaemonArgError(flag: "--run" | "--agent-os-id"): string;
1
33
  export declare function resolveKeeperStallMs(flag: string | boolean | undefined, env?: NodeJS.ProcessEnv): number;
2
34
  /**
3
35
  * Supervision is the DEFAULT for `kynver daemon`. Opt out only when an
@@ -1,2 +1,86 @@
1
- import type { RunnerInstallDoctorReport } from "./doctor.types.js";
2
- export declare function assessRunnerInstallReadiness(): RunnerInstallDoctorReport;
1
+ import { type KynverUserConfig } from "../config.js";
2
+ import type { DoctorCheck, DoctorSection, RunnerInstallDoctorReport } from "./doctor.types.js";
3
+ /** Repo base-ref probe result: can a new run be cut from this checkout? */
4
+ export interface RepoBaseRefProbe {
5
+ originMainOk: boolean;
6
+ /** Remote default branch (e.g. `origin/master`) when origin/main is absent. */
7
+ remoteHead: string | null;
8
+ remoteHeadOk: boolean;
9
+ }
10
+ /** Probe `origin/main` (what runs are cut from) with the remote-HEAD fallback. */
11
+ export declare function probeRepoBaseRef(repo: string): RepoBaseRefProbe;
12
+ /** Pure builder so tests can pin all three verdicts without a git fixture. */
13
+ export declare function buildRepoBaseRefCheck(repo: string, probe: RepoBaseRefProbe): DoctorCheck;
14
+ /** What the configured worker provider needs on PATH, plus probe results. */
15
+ export interface ProviderCliProbe {
16
+ provider: string;
17
+ /** Acceptable binaries (any one satisfies), in preference order. */
18
+ binaries: string[];
19
+ foundBinary: string | null;
20
+ /** Best-effort `<bin> --version` health probe (warn-only). */
21
+ versionProbe: {
22
+ ok: boolean;
23
+ detail: string;
24
+ } | null;
25
+ knownProvider: boolean;
26
+ }
27
+ /** Probe the configured worker provider's CLI on PATH (+ cheap health check). */
28
+ export declare function probeProviderCli(config?: KynverUserConfig): ProviderCliProbe;
29
+ /** Pure builder so tests can pin verdicts without spawning real provider CLIs. */
30
+ export declare function buildProviderCliSection(probe: ProviderCliProbe): DoctorSection;
31
+ export interface ApiLivenessProbe {
32
+ baseUrl: string | null;
33
+ version: {
34
+ kind: "ok";
35
+ status: number;
36
+ } | {
37
+ kind: "http_error";
38
+ status: number;
39
+ } | {
40
+ kind: "network";
41
+ detail: string;
42
+ } | {
43
+ kind: "skipped";
44
+ reason: string;
45
+ };
46
+ credential: {
47
+ kind: "ok";
48
+ } | {
49
+ kind: "unauthorized";
50
+ } | {
51
+ kind: "forbidden";
52
+ } | {
53
+ kind: "http_error";
54
+ status: number;
55
+ } | {
56
+ kind: "network";
57
+ detail: string;
58
+ } | {
59
+ kind: "skipped";
60
+ reason: string;
61
+ };
62
+ }
63
+ export declare const API_LIVENESS_TIMEOUT_MS = 5000;
64
+ /**
65
+ * Live probes: `GET /api/version` (is the URL a reachable Kynver at all?) and
66
+ * a credentialed `GET …/runner-credentials` (does this account/key still have
67
+ * access?). 401 vs 403 get distinct verdicts — revoked key vs gated access.
68
+ */
69
+ export declare function probeApiLiveness(opts: {
70
+ baseUrl?: string;
71
+ agentOsId?: string;
72
+ apiKey?: string;
73
+ fetchImpl?: typeof fetch;
74
+ timeoutMs?: number;
75
+ }): Promise<ApiLivenessProbe>;
76
+ /** Pure builder so tests can pin the 401/403/network verdicts without a server. */
77
+ export declare function buildApiLivenessSection(probe: ApiLivenessProbe): DoctorSection;
78
+ export declare function assessRunnerInstallReadiness(extraSections?: DoctorSection[]): RunnerInstallDoctorReport;
79
+ /**
80
+ * Full readiness report including the live API probes (`/api/version` + the
81
+ * credentialed runner-credential route). This is what `kynver doctor
82
+ * runner-install` runs; the sync `assessRunnerInstallReadiness` remains for
83
+ * offline/embedded callers.
84
+ */
85
+ export declare function assessRunnerInstallReadinessAsync(): Promise<RunnerInstallDoctorReport>;
86
+ export declare function runRunnerInstallDoctorCliAsync(): Promise<void>;
@@ -2,8 +2,12 @@ import type { DoctorSection } from "./doctor.types.js";
2
2
  import { type GitHubReadinessProbe } from "./github-readiness.js";
3
3
  import type { RuntimeTakeoverProbes } from "./runtime-takeover.probes.js";
4
4
  /**
5
- * Optional deploy-evidence checks for merge-gate / PR handoff workflows.
6
- * Core runtime takeover does not require Vercel CLI or VERCEL_TOKEN when GitHub
7
- * commit-status evidence is viable.
5
+ * Optional deploy-evidence checks for merge-gate / PR handoff workflows
6
+ * (Railway era). Post-cutover (2026-08) production deploy evidence is the
7
+ * production /api/version probe plus GitHub ancestry/commit-status lookups —
8
+ * Vercel is decommissioned, so the old Vercel StatusContext and VERCEL_TOKEN
9
+ * REST fallback no longer exist. This section verifies GitHub auth for those
10
+ * lookups and flags Vercel leftovers (global CLI, stale VERCEL_TOKEN) as
11
+ * hygiene warnings.
8
12
  */
9
13
  export declare function assessDeployEvidence(probes: RuntimeTakeoverProbes, githubProbe: GitHubReadinessProbe): DoctorSection;
@@ -37,7 +37,7 @@ export interface RuntimeTakeoverProbes {
37
37
  pathExists(target: string): boolean;
38
38
  pathWritable(target: string): boolean;
39
39
  ghAuthToken(): CommandProbeResult;
40
- /** When false, GitHub/Vercel deploy-evidence checks are advisory-only skips. */
40
+ /** When false, GitHub deploy-evidence checks are advisory-only skips. */
41
41
  deployEvidenceNeedsGithub?(): boolean;
42
42
  /** Injectable systemd active probe for supervision checks. */
43
43
  systemdDaemonActive?(): boolean;
package/dist/index.d.ts CHANGED
@@ -25,14 +25,17 @@ export { MEMORY_LANE_PREVIEW_CHARS, buildChatMemoryShadowPreview, buildLegacyCha
25
25
  export { canonicalJsonStringify, computeInstructionBundleVersion, deriveInstructionBundleKeyId, parseRawEd25519Key, isSignedInstructionBundleShape, PINNED_INSTRUCTION_BUNDLE_PUBLIC_KEYS, resolveInstructionBundlePublicKey, verifyInstructionBundleSignatureWithKey, verifySignedInstructionBundle, EMBEDDED_INSTRUCTION_BUNDLE, EMBEDDED_INSTRUCTION_BUNDLE_VERSION, getActiveInstructionBundle, getActiveInstructionBundleSource, getActiveInstructionBundleVersion, setActiveInstructionBundle, resolveInstructionText, resolvePolicyThreshold, resolveBundlePersona, ensureInstructionBundle, instructionBundleCachePath, loadInstructionBundleCache, saveInstructionBundleCache, INSTRUCTION_BUNDLE_REFRESH_TTL_MS, type InstructionBundle, type InstructionBundleContent, type InstructionBundlePersona, type SignedInstructionBundle, type InstructionBundleSource, type InstructionBundleVerifyResult, type EnsureInstructionBundleOptions, type EnsureInstructionBundleResult, } from "./instruction-bundle/index.js";
26
26
  export { WORKER_PERSONA_CATALOG, getWorkerPersonaCatalogEntry, getPersonaDispatchLane, getPersonaDefaultRoleLane, isKnownWorkerPersonaSlug, workerPersonaReviewSlugs, workerPersonaLandingSlugs, type WorkerPersonaCatalogEntry, type WorkerPersonaCatalogSlug, type WorkerPersonaDispatchLane, type WorkerPersonaDefaultRoleLane, } from "./worker-persona-catalog.js";
27
27
  export { assessPrHandoffRequirement, ensurePrReadyHandoff, extractPrUrlFromText, } from "./pr-handoff/index.js";
28
- export { normalizeCursorModelAlias, preflightClaudeModel, preflightCodexModel, preflightCursorModel, } from "./providers/model-preflight.js";
28
+ export { normalizeCursorModelAlias, preflightClaudeModel, preflightCodexModel, preflightCursorModel, preflightOpenAiCompatibleModel, } from "./providers/model-preflight.js";
29
29
  export { CODEX_DEFAULT_MODEL, codexProvider, buildCodexExecArgv } from "./providers/codex.js";
30
+ export { OPENAI_COMPATIBLE_PROVIDER, OPENAI_COMPATIBLE_SYSTEM_PROMPT, OpenAiCompatibleConfigError, buildOpenAiCompatibleChatRequest, buildOpenAiCompatibleRunnerConfig, openAiCompatibleProvider, resolveOpenAiCompatibleDefaultModel, resolveOpenAiCompatibleEndpoint, type OpenAiCompatibleChatRequest, type OpenAiCompatibleEndpoint, type OpenAiCompatibleRunnerConfig, } from "./providers/openai-compatible.js";
31
+ export { extractOpenAiCompatibleCompletion, type OpenAiCompatibleCompletion, type OpenAiCompatibleUsage, } from "./providers/openai-compatible-response.js";
32
+ export { resolveWorkerUsagePayload, type ResolveWorkerUsageInput, type WorkerUsagePayload, } from "./worker-usage.js";
30
33
  export { HERMES_OPENAI_CODEX_DEFAULT_MODEL, hermesCodexProvider, buildHermesOpenAiCodexChatArgv, } from "./providers/hermes-codex.js";
31
34
  export { classifyOpenAiCodexError, formatCronJobDeliveryFailure, formatOpenAiCodexFailureNotice, redactProviderErrorText, resolveOpenAiCodexRetryBudget, TRANSIENT_OPENAI_CODEX_ERROR_CLASSES, OPENAI_CODEX_PROVIDER, type ClassifiedOpenAiCodexError, type CodexFailureNoticeInput, type OpenAiCodexErrorClass, } from "./providers/openai-codex-resilience.js";
32
35
  export * from "./cron/hermes-provider-notice.js";
33
36
  export { buildOrchestrationProviderInventory, classifyOrchestrationRisk, compareProviderCandidates, getOrchestrationProviderCapability, listOrchestrationProviderCapabilities, probeClaudeOAuthBinding, probeCodexOAuthBinding, probeCursorOAuthBinding, probeHermesCliAdapter, probeHermesOpenAiCodexBinding, probeOrchestrationProviderBinding, providerCapableForRisk, resolveCodexOrchestrationAdapter, resolveOrchestrationRouting, selectCheapestCapableProvider, sanitizeOrchestrationAudit, orchestrationAuditForWorkerJson, getAdapterContextContract, listAdapterContextContracts, type AdapterContextCapability, type AdapterContextContract, type AdapterContextContractId, type CodexOrchestrationAdapterStatus, type CodexOrchestrationPath, type HermesCliAdapterStatus, type HermesOpenAiCodexBindingStatus, type OrchestrationAuthSource, type OrchestrationCloudApiCredits, type OrchestrationCostTier, type OrchestrationProviderBindingStatus, type OrchestrationProviderCapability, type OrchestrationProviderId, type OrchestrationProviderInventory, type OrchestrationRiskClass, type OrchestrationRoutingAudit, type OrchestrationRoutingDecision, } from "./orchestration-providers/index.js";
34
37
  export { ORCHESTRATION_POLICY_MODES, ORCHESTRATION_ACTION_KINDS, ORCHESTRATION_POLICY_DECISIONS, resolveOrchestrationPolicyMode, isOrchestrationEnforceTasksEnabled, buildForegroundHarnessIdempotencyKey, evaluateOrchestrationPolicy, type OrchestrationPolicyMode, type OrchestrationActionKind, type OrchestrationPolicyDecision, type OrchestrationPolicyEvaluateInput, type OrchestrationPolicyEvaluateResult, } from "./orchestration-enforcement/index.js";
35
- export { DEFAULT_WORKER_PROVIDER, enforceCursorWorkerProvider, isClaudeFamilyProvider, preferCursorExecutor, resolveConfiguredWorkerProvider, taskAllowsClaudeWorker, type EnforceCursorWorkerProviderInput, } from "./worker-provider-policy.js";
38
+ export { DEFAULT_WORKER_PROVIDER, enforceCursorWorkerProvider, isClaudeFamilyProvider, normalizeWorkerProviderName, preferCursorExecutor, resolveConfiguredWorkerProvider, taskAllowsClaudeWorker, taskExpressesWorkerProviderPreference, type EnforceCursorWorkerProviderInput, } from "./worker-provider-policy.js";
36
39
  export { parseExecutorRefRoutingIntent, executorRefRequestsNonCursorWorker, type ExecutorRefRoutingIntent, } from "./executor-ref-routing.js";
37
40
  export { assessDispatchModelGuard, type DispatchModelGuardInput, type DispatchModelGuardResult, } from "./dispatch-model-guard.js";
38
41
  export { GLOBAL_DEFAULT_MODEL, CURSOR_DEFAULT_MODEL, inferModelRoutingFromTask, resolveGlobalDefaultModel, resolveModelFallback, resolveWorkerLaunch, type ModelRoutingDecision, } from "./model-routing.js";