@kynver-app/runtime 0.1.157 → 0.1.168
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/bounded-build/exec.d.ts +3 -0
- package/dist/bounded-build/index.d.ts +1 -1
- package/dist/byoc/context-hydration.d.ts +54 -0
- package/dist/byoc/execution-proof.d.ts +46 -0
- package/dist/byoc/index.d.ts +5 -0
- package/dist/byoc/job-envelope.d.ts +39 -0
- package/dist/byoc/m6-golden-path.d.ts +86 -0
- package/dist/byoc/mcp-tool-proof.d.ts +42 -0
- package/dist/cli.js +58 -55
- package/dist/config.d.ts +8 -0
- package/dist/doctor/doctor.types.d.ts +23 -0
- package/dist/doctor/runner-install-cli.d.ts +1 -0
- package/dist/doctor/runner-install.d.ts +2 -0
- package/dist/harness-verify.d.ts +2 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +75 -71
- package/dist/model-routing.d.ts +15 -0
- package/dist/orchestration-providers/adapter-contract.d.ts +50 -0
- package/dist/orchestration-providers/index.d.ts +1 -0
- package/dist/orchestration-providers/oauth-binding-utils.d.ts +1 -0
- package/dist/provider-quota-preflight.d.ts +38 -0
- package/dist/providers/claude.d.ts +2 -0
- package/dist/server/cleanup.js +13 -13
- package/dist/server/default-repo.js +1 -1
- package/dist/server/heavy-verification.js +1 -1
- package/dist/server/monitor.js +7 -7
- package/dist/server/orchestration.js +1 -1
- package/dist/server/worker-policy.js +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type HeavyVerificationGateVerdict, type WorkerCommandGateOutcome } from "../heavy-verification/index.js";
|
|
2
2
|
import { type BuildAdmissionVerdict } from "./admission.js";
|
|
3
|
+
export declare function isSystemdScopeError(stderr: string): boolean;
|
|
3
4
|
export interface BoundedBuildExecResult {
|
|
4
5
|
ok: boolean;
|
|
5
6
|
exitCode: number;
|
|
@@ -7,6 +8,8 @@ export interface BoundedBuildExecResult {
|
|
|
7
8
|
stderr: string;
|
|
8
9
|
admitted: boolean;
|
|
9
10
|
wrappedWithSystemd: boolean;
|
|
11
|
+
/** True when systemd scope creation failed and the command was retried via plain shell. */
|
|
12
|
+
systemdScopeFallback?: boolean;
|
|
10
13
|
nodeOptionsFlag: string;
|
|
11
14
|
admission: BuildAdmissionVerdict;
|
|
12
15
|
/** Cross-process heavy-verification lease (typecheck/build throttle). */
|
|
@@ -3,4 +3,4 @@ export { readMemAvailableBytes } from "./meminfo.js";
|
|
|
3
3
|
export { formatNodeOptionsFlag, mergeNodeOptionsForBuildCheck, resolveNodeOldSpaceSizeMb, } from "./node-options.js";
|
|
4
4
|
export { buildSystemdRunArgv, isSystemdRunAvailable, type SystemdWrapOptions, } from "./systemd-wrap.js";
|
|
5
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";
|
|
6
|
+
export { runBoundedBuildCheck, isSystemdScopeError, type BoundedBuildExecResult, type RunBoundedBuildCheckInput } from "./exec.js";
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BYOC M0.6 — context hydration.
|
|
3
|
+
*
|
|
4
|
+
* Takes a validated job envelope (jobId + agentOsId + taskId) and resolves
|
|
5
|
+
* the local config needed to run the job: repo path, worktree base, API URL.
|
|
6
|
+
*
|
|
7
|
+
* Pure: reads env/config but makes no network calls and writes nothing.
|
|
8
|
+
* Fail-closed: any missing required field returns a typed error code.
|
|
9
|
+
* No secrets in the returned object.
|
|
10
|
+
*/
|
|
11
|
+
import type { LocalCodexJobEnvelope } from "./job-envelope.js";
|
|
12
|
+
export interface HydratedJobContext {
|
|
13
|
+
/** From the job envelope — unchanged. */
|
|
14
|
+
jobId: string;
|
|
15
|
+
agentOsId: string;
|
|
16
|
+
taskId: string;
|
|
17
|
+
/** Absolute path to the default repo on this host. null when not configured. */
|
|
18
|
+
repoPath: string | null;
|
|
19
|
+
/** Absolute path where worktrees for this job will be created. null = unresolved. */
|
|
20
|
+
worktreeBase: string | null;
|
|
21
|
+
/** Kynver API base URL (no trailing slash). */
|
|
22
|
+
apiBaseUrl: string;
|
|
23
|
+
/** ISO timestamp when hydration ran. */
|
|
24
|
+
hydratedAt: string;
|
|
25
|
+
}
|
|
26
|
+
export type ContextHydrationErrorCode =
|
|
27
|
+
/** No API base URL in env or config. */
|
|
28
|
+
"missing_api_base_url"
|
|
29
|
+
/** Workspace ID in envelope does not match locally configured agentOsId. */
|
|
30
|
+
| "workspace_mismatch";
|
|
31
|
+
export type ContextHydrationResult = {
|
|
32
|
+
ok: true;
|
|
33
|
+
context: HydratedJobContext;
|
|
34
|
+
} | {
|
|
35
|
+
ok: false;
|
|
36
|
+
code: ContextHydrationErrorCode;
|
|
37
|
+
detail: string;
|
|
38
|
+
};
|
|
39
|
+
export interface ContextHydrationOptions {
|
|
40
|
+
env?: NodeJS.ProcessEnv;
|
|
41
|
+
nowMs?: number;
|
|
42
|
+
/** Override config values for tests. */
|
|
43
|
+
config?: {
|
|
44
|
+
agentOsId?: string;
|
|
45
|
+
defaultRepo?: string;
|
|
46
|
+
harnessRoot?: string;
|
|
47
|
+
apiBaseUrl?: string;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Hydrate a validated job envelope with local runner config.
|
|
52
|
+
* Call after `validateJobEnvelope` and `verifyLocalCodexGoldenPath` pass.
|
|
53
|
+
*/
|
|
54
|
+
export declare function hydrateJobContext(envelope: LocalCodexJobEnvelope, options?: ContextHydrationOptions): ContextHydrationResult;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BYOC M0.6 — execution readiness proof.
|
|
3
|
+
*
|
|
4
|
+
* Verifies that the local Codex execution plane and target repo are accessible
|
|
5
|
+
* enough to run a task. Does NOT spawn a Codex process — it probes fs
|
|
6
|
+
* accessibility and binary location only.
|
|
7
|
+
*
|
|
8
|
+
* Fail-closed on unexpected errors; returns a typed result, never throws.
|
|
9
|
+
* No secrets in the returned object.
|
|
10
|
+
*/
|
|
11
|
+
import type { HydratedJobContext } from "./context-hydration.js";
|
|
12
|
+
import type { CodexOrchestrationPath } from "../orchestration-providers/codex-orchestration-adapter.js";
|
|
13
|
+
import { resolveCodexOrchestrationAdapter } from "../orchestration-providers/codex-orchestration-adapter.js";
|
|
14
|
+
export interface ExecutionProofResult {
|
|
15
|
+
/** Whether a Codex binary or Hermes OpenAI-Codex path was resolved on this host. */
|
|
16
|
+
codexReachable: boolean;
|
|
17
|
+
/** Which orchestration path was resolved (codex_cli | hermes_openai_codex | none). */
|
|
18
|
+
codexPath: CodexOrchestrationPath;
|
|
19
|
+
/** Absolute path to the codex binary, or null when using Hermes or unavailable. */
|
|
20
|
+
codexBinaryPath: string | null;
|
|
21
|
+
/** Whether the configured repo path exists on disk. */
|
|
22
|
+
repoAccessible: boolean;
|
|
23
|
+
/** Absolute repo path that was probed, or null when not configured. */
|
|
24
|
+
repoPath: string | null;
|
|
25
|
+
/** Whether a worktree base directory exists and is accessible. */
|
|
26
|
+
worktreeBaseAccessible: boolean;
|
|
27
|
+
/** Absolute worktree base path that was probed, or null when not configured. */
|
|
28
|
+
worktreeBase: string | null;
|
|
29
|
+
/** ISO timestamp when the proof ran. */
|
|
30
|
+
probedAt: string;
|
|
31
|
+
/** Wall-clock probe duration. */
|
|
32
|
+
durationMs: number;
|
|
33
|
+
/** First error encountered, or null on full pass. */
|
|
34
|
+
error: string | null;
|
|
35
|
+
}
|
|
36
|
+
export interface ExecutionProofOptions {
|
|
37
|
+
env?: NodeJS.ProcessEnv;
|
|
38
|
+
nowMs?: number;
|
|
39
|
+
/** Injectable codex adapter for tests. */
|
|
40
|
+
codexAdapter?: ReturnType<typeof resolveCodexOrchestrationAdapter>;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Probe execution readiness for the given hydrated job context.
|
|
44
|
+
* All checks are local — no network calls.
|
|
45
|
+
*/
|
|
46
|
+
export declare function probeExecutionReadiness(context: HydratedJobContext, options?: ExecutionProofOptions): ExecutionProofResult;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Local Codex job envelope — the typed payload Kynver cloud sends to the
|
|
3
|
+
* user's local runner for BYO-compute execution. Contains no secrets.
|
|
4
|
+
*
|
|
5
|
+
* The envelope is opaque to the cloud after dispatch; the local runner
|
|
6
|
+
* validates it against local state (workspace, runner identity, expiry,
|
|
7
|
+
* tool policy) before spawning a Codex worker.
|
|
8
|
+
*/
|
|
9
|
+
export interface LocalCodexJobToolPolicy {
|
|
10
|
+
/** Toolsets the local Codex agent may activate (e.g. ["hermes-cli"]). */
|
|
11
|
+
allowedToolsets: string[];
|
|
12
|
+
/** Whether privileged platform actions (DB writes, deploy, secrets) are permitted. */
|
|
13
|
+
allowPrivilegedPlatformActions: boolean;
|
|
14
|
+
}
|
|
15
|
+
/** Envelope from the Kynver control plane. Never contains secrets or tokens. */
|
|
16
|
+
export interface LocalCodexJobEnvelope {
|
|
17
|
+
jobId: string;
|
|
18
|
+
agentOsId: string;
|
|
19
|
+
taskId: string;
|
|
20
|
+
issuedAt: string;
|
|
21
|
+
expiresAt: string;
|
|
22
|
+
toolPolicy: LocalCodexJobToolPolicy;
|
|
23
|
+
/** Optional runner identity hint — reject if present and mismatched. */
|
|
24
|
+
runnerIdHint?: string | null;
|
|
25
|
+
}
|
|
26
|
+
export type JobEnvelopeValidationError = "missing_job_id" | "missing_agent_os_id" | "missing_task_id" | "missing_issued_at" | "missing_expires_at" | "missing_tool_policy" | "malformed_dates" | "job_expired";
|
|
27
|
+
export type JobEnvelopeValidationResult = {
|
|
28
|
+
ok: true;
|
|
29
|
+
envelope: LocalCodexJobEnvelope;
|
|
30
|
+
} | {
|
|
31
|
+
ok: false;
|
|
32
|
+
code: JobEnvelopeValidationError;
|
|
33
|
+
detail: string;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Validate an envelope from the cloud. Fail closed on any structural or
|
|
37
|
+
* temporal problem — never return partially-valid state.
|
|
38
|
+
*/
|
|
39
|
+
export declare function validateJobEnvelope(input: unknown, nowMs?: number): JobEnvelopeValidationResult;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* M6 first-run local Codex golden path verifier.
|
|
3
|
+
*
|
|
4
|
+
* Validates a signed Kynver cloud job envelope against local runner state:
|
|
5
|
+
* workspace binding, runner presence, Codex/Hermes auth, BYO entitlement,
|
|
6
|
+
* and tool policy. Fails closed — any missing or mismatched prerequisite
|
|
7
|
+
* returns a typed failure code rather than proceeding to execution.
|
|
8
|
+
*
|
|
9
|
+
* Secrets and tokens are never returned. Session fingerprints are sha256
|
|
10
|
+
* prefixes of non-secret binding metadata (see oauth-binding-utils).
|
|
11
|
+
*/
|
|
12
|
+
import { resolveCodexOrchestrationAdapter, type CodexOrchestrationPath } from "../orchestration-providers/codex-orchestration-adapter.js";
|
|
13
|
+
import type { LocalCodexJobEnvelope } from "./job-envelope.js";
|
|
14
|
+
/**
|
|
15
|
+
* Failure codes for the M6 golden path. Each maps to an operator-visible
|
|
16
|
+
* remediation action — never expose secret material in messages.
|
|
17
|
+
*/
|
|
18
|
+
export type GoldenPathCheckCode =
|
|
19
|
+
/** Runner not configured or identity cannot be resolved. */
|
|
20
|
+
"missing_runner"
|
|
21
|
+
/** Codex CLI and Hermes openai-codex are both unavailable on this host. */
|
|
22
|
+
| "missing_codex_auth"
|
|
23
|
+
/** Job's agentOsId does not match the runner's configured workspace. */
|
|
24
|
+
| "wrong_workspace"
|
|
25
|
+
/**
|
|
26
|
+
* Job envelope is structurally invalid (missing/blank required field or
|
|
27
|
+
* malformed dates). Indicates a control-plane/serialization problem, not a
|
|
28
|
+
* runner-config problem — distinct from `wrong_workspace`.
|
|
29
|
+
*/
|
|
30
|
+
| "malformed_envelope"
|
|
31
|
+
/** Job envelope has expired (expiresAt in the past). */
|
|
32
|
+
| "job_expired"
|
|
33
|
+
/**
|
|
34
|
+
* BYO compute entitlement is not active for this runner.
|
|
35
|
+
* Set KYNVER_BYOC_ENTITLED=1 or complete the workspace entitlement flow.
|
|
36
|
+
*/
|
|
37
|
+
| "missing_entitlement"
|
|
38
|
+
/**
|
|
39
|
+
* Job requests a tool or toolset not permitted on local BYO runners, or
|
|
40
|
+
* requests privileged platform actions (DB writes, deploy, secrets).
|
|
41
|
+
*/
|
|
42
|
+
| "unauthorized_tool_policy";
|
|
43
|
+
/** Non-secret audit evidence written back to the control plane. */
|
|
44
|
+
export interface GoldenPathAuditEvidence {
|
|
45
|
+
jobId: string;
|
|
46
|
+
agentOsId: string;
|
|
47
|
+
taskId: string;
|
|
48
|
+
runnerId: string;
|
|
49
|
+
runnerIdHint: string | null;
|
|
50
|
+
codexPath: CodexOrchestrationPath;
|
|
51
|
+
codexReady: boolean;
|
|
52
|
+
sessionFingerprint: string | undefined;
|
|
53
|
+
toolsetsRequested: string[];
|
|
54
|
+
privilegedRequested: boolean;
|
|
55
|
+
checkedAt: string;
|
|
56
|
+
}
|
|
57
|
+
export type GoldenPathResult = {
|
|
58
|
+
passed: true;
|
|
59
|
+
envelope: LocalCodexJobEnvelope;
|
|
60
|
+
evidence: GoldenPathAuditEvidence;
|
|
61
|
+
} | {
|
|
62
|
+
passed: false;
|
|
63
|
+
code: GoldenPathCheckCode;
|
|
64
|
+
detail: string;
|
|
65
|
+
evidence: GoldenPathAuditEvidence;
|
|
66
|
+
};
|
|
67
|
+
export interface GoldenPathOptions {
|
|
68
|
+
/** Override current time (ms) for testing. */
|
|
69
|
+
nowMs?: number;
|
|
70
|
+
/** Override process.env for testing. */
|
|
71
|
+
env?: NodeJS.ProcessEnv;
|
|
72
|
+
/** Injectable for tests — skips live Codex probe. */
|
|
73
|
+
codexAdapter?: ReturnType<typeof resolveCodexOrchestrationAdapter>;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Run the M6 golden path checks in order. The first failure short-circuits
|
|
77
|
+
* and returns the error code — callers must not proceed to execution.
|
|
78
|
+
*/
|
|
79
|
+
export declare function verifyLocalCodexGoldenPath(rawEnvelope: unknown, options?: GoldenPathOptions): GoldenPathResult;
|
|
80
|
+
/**
|
|
81
|
+
* Format a human-readable remediation notice for a golden path failure.
|
|
82
|
+
* Safe to log — contains no secrets or tokens.
|
|
83
|
+
*/
|
|
84
|
+
export declare function formatGoldenPathFailureNotice(result: Extract<GoldenPathResult, {
|
|
85
|
+
passed: false;
|
|
86
|
+
}>): string;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BYOC M0.6 — MCP tool reachability proof.
|
|
3
|
+
*
|
|
4
|
+
* Proves the runner-credential auth pathway to the Kynver server works by making
|
|
5
|
+
* a lightweight HTTP probe (GET /api/agent-os/runner-token/verify) using the
|
|
6
|
+
* scoped runner token. Does not invoke any destructive MCP tools.
|
|
7
|
+
*
|
|
8
|
+
* Fail-closed on network errors — returns a typed result, never throws.
|
|
9
|
+
* No secrets in the returned object.
|
|
10
|
+
*/
|
|
11
|
+
import type { HydratedJobContext } from "./context-hydration.js";
|
|
12
|
+
export type McpAuthSource = "runner_token" | "api_key" | "none";
|
|
13
|
+
export interface McpToolProofResult {
|
|
14
|
+
/** Whether the MCP endpoint replied with a non-error HTTP status. */
|
|
15
|
+
reachable: boolean;
|
|
16
|
+
/** Which credential was used to probe. */
|
|
17
|
+
authSource: McpAuthSource;
|
|
18
|
+
/** The probe endpoint URL (no path secrets). */
|
|
19
|
+
endpoint: string | null;
|
|
20
|
+
/** HTTP status code returned, or null on network error. */
|
|
21
|
+
httpStatus: number | null;
|
|
22
|
+
/** Round-trip duration in ms, or null on failure. */
|
|
23
|
+
responseMs: number | null;
|
|
24
|
+
/** ISO timestamp when the probe ran. */
|
|
25
|
+
probedAt: string;
|
|
26
|
+
/** Error message if the probe failed, or null on success. */
|
|
27
|
+
error: string | null;
|
|
28
|
+
}
|
|
29
|
+
export interface McpToolProofOptions {
|
|
30
|
+
env?: NodeJS.ProcessEnv;
|
|
31
|
+
nowMs?: number;
|
|
32
|
+
/** Timeout for the HTTP probe. Default 8 000 ms. */
|
|
33
|
+
timeoutMs?: number;
|
|
34
|
+
/** Injectable fetch for tests — defaults to global fetch. */
|
|
35
|
+
fetcher?: typeof fetch;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Probe MCP/API reachability using the runner credential.
|
|
39
|
+
* Uses `GET /api/agent-os/runner-token/verify` — a read-only identity endpoint
|
|
40
|
+
* added in M0.4 that requires only the runner token and returns the workspace ID.
|
|
41
|
+
*/
|
|
42
|
+
export declare function probeMcpToolReachability(context: HydratedJobContext, options?: McpToolProofOptions): Promise<McpToolProofResult>;
|