@kynver-app/runtime 0.1.123 → 0.1.129
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/chat/chat-claim-loop.d.ts +11 -0
- package/dist/chat/command-allowlist.d.ts +8 -0
- package/dist/chat/command-executor.d.ts +13 -0
- package/dist/cli.js +62 -17782
- package/dist/config.d.ts +2 -0
- package/dist/cron/cron-cli-bin.d.ts +7 -0
- package/dist/cron/cron-readiness.d.ts +35 -0
- package/dist/daemon-heartbeat.d.ts +3 -0
- package/dist/disk-gate.d.ts +7 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +79 -19281
- package/dist/instruction-bundle/cache.d.ts +6 -0
- package/dist/instruction-bundle/client.d.ts +25 -0
- package/dist/instruction-bundle/contract.d.ts +4 -0
- package/dist/instruction-bundle/contract.js +5 -0
- package/dist/instruction-bundle/embedded-bundle.d.ts +3 -0
- package/dist/instruction-bundle/index.d.ts +7 -0
- package/dist/instruction-bundle/keys.d.ts +14 -0
- package/dist/instruction-bundle/state.d.ts +24 -0
- package/dist/instruction-bundle/types.d.ts +42 -0
- package/dist/instruction-bundle/verify.d.ts +15 -0
- package/dist/mesh-liveness/mesh-cron-lease-store.d.ts +9 -0
- package/dist/retry-limits.d.ts +4 -0
- package/dist/server/cleanup.js +16 -4054
- package/dist/server/default-repo.js +1 -458
- package/dist/server/harness-notice.js +15 -287
- package/dist/server/heavy-verification.js +1 -223
- package/dist/server/landing.js +1 -44
- package/dist/server/memory-cost-enforce.js +2 -480
- package/dist/server/memory-cost.js +2 -184
- package/dist/server/monitor.js +8 -1805
- package/dist/server/orchestration.js +1 -444
- package/dist/server/pr-evidence.js +1 -163
- package/dist/server/repo-search.js +1 -224
- package/dist/server/worker-policy.js +1 -432
- package/dist/worker-persona-catalog.d.ts +5 -0
- package/dist/worker-persona-catalog.js +5 -138
- package/package.json +8 -2
- package/dist/cli.js.map +0 -7
- package/dist/index.js.map +0 -7
- package/dist/server/cleanup.js.map +0 -7
- package/dist/server/default-repo.js.map +0 -7
- package/dist/server/harness-notice.js.map +0 -7
- package/dist/server/heavy-verification.js.map +0 -7
- package/dist/server/landing.js.map +0 -7
- package/dist/server/memory-cost-enforce.js.map +0 -7
- package/dist/server/memory-cost.js.map +0 -7
- package/dist/server/monitor.js.map +0 -7
- package/dist/server/orchestration.js.map +0 -7
- package/dist/server/pr-evidence.js.map +0 -7
- package/dist/server/repo-search.js.map +0 -7
- package/dist/server/worker-policy.js.map +0 -7
- package/dist/worker-persona-catalog.js.map +0 -7
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type SignedInstructionBundle } from "./types.js";
|
|
2
|
+
export declare function instructionBundleCachePath(agentOsId: string): string;
|
|
3
|
+
/** Best-effort atomic write (temp + rename). Never throws. */
|
|
4
|
+
export declare function saveInstructionBundleCache(agentOsId: string, signed: SignedInstructionBundle): void;
|
|
5
|
+
/** Load the cached signed payload. Caller MUST verify the signature before use. */
|
|
6
|
+
export declare function loadInstructionBundleCache(agentOsId: string): SignedInstructionBundle | null;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare const INSTRUCTION_BUNDLE_REFRESH_TTL_MS: number;
|
|
2
|
+
export declare function __resetInstructionBundleClientForTest(): void;
|
|
3
|
+
export interface EnsureInstructionBundleOptions {
|
|
4
|
+
agentOsId: string;
|
|
5
|
+
/** Kynver API base URL (e.g. from `resolveBaseUrl`). No fetch when absent. */
|
|
6
|
+
baseUrl?: string | null;
|
|
7
|
+
/** Runner credential / callback secret for the by-id route. */
|
|
8
|
+
secret?: string | null;
|
|
9
|
+
/** Bypass the TTL gate (startup / tests). */
|
|
10
|
+
force?: boolean;
|
|
11
|
+
fetchImpl?: typeof fetch;
|
|
12
|
+
nowMs?: number;
|
|
13
|
+
}
|
|
14
|
+
export interface EnsureInstructionBundleResult {
|
|
15
|
+
source: "server" | "disk" | "embedded" | "primed";
|
|
16
|
+
version: string;
|
|
17
|
+
/** True when this call changed the active bundle. */
|
|
18
|
+
updated: boolean;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Ensure the active instruction bundle is fresh. TTL-gated (15 min) so the
|
|
22
|
+
* daemon can call it every tick; the first call performs the startup fetch.
|
|
23
|
+
* Never throws.
|
|
24
|
+
*/
|
|
25
|
+
export declare function ensureInstructionBundle(opts: EnsureInstructionBundleOptions): Promise<EnsureInstructionBundleResult>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export * from "./types.js";
|
|
2
|
+
export { PINNED_INSTRUCTION_BUNDLE_PUBLIC_KEYS, resolveInstructionBundlePublicKey, } from "./keys.js";
|
|
3
|
+
export { verifyInstructionBundleSignatureWithKey, verifySignedInstructionBundle, type InstructionBundleVerifyResult, } from "./verify.js";
|
|
4
|
+
export { EMBEDDED_INSTRUCTION_BUNDLE, EMBEDDED_INSTRUCTION_BUNDLE_VERSION, } from "./embedded-bundle.js";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{createHash as u}from"node:crypto";function o(e){return JSON.stringify(i(e))}function i(e){if(Array.isArray(e))return e.map(i);if(e&&typeof e=="object"){let t={};for(let n of Object.keys(e).sort())t[n]=i(e[n]);return t}return e}function L(e){return`ib1-${u("sha256").update(o(e),"utf8").digest("hex").slice(0,16)}`}function N(e){return`ib-${u("sha256").update(Buffer.from(e)).digest("hex").slice(0,12)}`}function a(e){if(!e)return null;let t=e.trim();if(!t)return null;if(/^[0-9a-fA-F]{64}$/.test(t))return new Uint8Array(t.match(/.{2}/g).map(n=>parseInt(n,16)));try{let n=Buffer.from(t,"base64");if(n.length===32)return new Uint8Array(n)}catch{}return null}function s(e){if(!e||typeof e!="object")return!1;let t=e;if(typeof t.signature!="string"||!t.signature||typeof t.publicKeyId!="string"||!t.publicKeyId)return!1;let n=t.bundle;return!(!n||typeof n!="object"||typeof n.version!="string"||!n.version||typeof n.generatedAt!="string"||!Array.isArray(n.personas)||!n.instructions||typeof n.instructions!="object"||!n.policyThresholds||typeof n.policyThresholds!="object")}var p={"ib-3bab6314f0ba":"53a2040646cd479e1f5f1aea9abf7848ce8b62e32001efb8044dfd90e8ab87ed"};function l(e,t=process.env){let n=a(t.KYNVER_INSTRUCTION_BUNDLE_PUBLIC_KEY);if(n)return n;let r=p[e];return r?a(r):null}import{createPublicKey as f,verify as m}from"node:crypto";var g=Buffer.from("302a300506032b6570032100","hex");function y(e){return f({key:Buffer.concat([g,Buffer.from(e)]),format:"der",type:"spki"})}function d(e,t){if(!s(e))return{ok:!1,reason:"malformed signed bundle payload"};let n;try{n=Buffer.from(e.signature,"base64url")}catch{return{ok:!1,reason:"signature is not base64url"}}if(n.length!==64)return{ok:!1,reason:"signature is not a 64-byte Ed25519 signature"};try{let r=Buffer.from(o(e.bundle),"utf8");return m(null,r,y(t),n)?{ok:!0,bundle:e.bundle}:{ok:!1,reason:"Ed25519 signature mismatch"}}catch(r){return{ok:!1,reason:`signature verification failed: ${r.message}`}}}function h(e,t=process.env){if(!s(e))return{ok:!1,reason:"malformed signed bundle payload"};let n=l(e.publicKeyId,t);return n?d(e,n):{ok:!1,reason:`no verification key for publicKeyId "${e.publicKeyId}" (not pinned; set KYNVER_INSTRUCTION_BUNDLE_PUBLIC_KEY)`}}var c="embedded-1",I=[{slug:"ghost",displayName:"Ghost",description:"Orchestration persona.",dispatchLane:null,defaultRoleLane:"system"},{slug:"astra",displayName:"Astra",description:"Planning persona.",dispatchLane:"implementation",defaultRoleLane:"plan_author"},{slug:"rhea",displayName:"Rhea",description:"Implementation persona.",dispatchLane:"implementation",defaultRoleLane:"implementer"},{slug:"mnemo",displayName:"Mnemo",description:"Implementation persona.",dispatchLane:"implementation",defaultRoleLane:"implementer"},{slug:"sentinel",displayName:"Sentinel",description:"Review persona.",dispatchLane:"review",defaultRoleLane:"deep_reviewer"},{slug:"pixel",displayName:"Pixel",description:"Implementation persona.",dispatchLane:"implementation",defaultRoleLane:"implementer"},{slug:"schema",displayName:"Schema",description:"Implementation persona.",dispatchLane:"implementation",defaultRoleLane:"implementer"},{slug:"atlas",displayName:"Atlas",description:"Implementation persona.",dispatchLane:"implementation",defaultRoleLane:"runtime_verifier"},{slug:"bridge",displayName:"Bridge",description:"Implementation persona.",dispatchLane:"implementation",defaultRoleLane:"implementer"},{slug:"catalyst",displayName:"Catalyst",description:"Implementation persona.",dispatchLane:"implementation",defaultRoleLane:"implementer"},{slug:"lorentz",displayName:"Lorentz",description:"Review persona.",dispatchLane:"review",defaultRoleLane:"report_reviewer"},{slug:"dalton",displayName:"Dalton",description:"Landing persona.",dispatchLane:"landing",defaultRoleLane:"implementer"}],b={"worker.prompt.core_rules":["Structured final result (recommended): record completion as JSON with summary, files, PR URLs, verification, risks, and blockers.","Completion handoff (required): before you stop, summarize the outcome in your last message and append a heartbeat line with phase `complete`. Commit your work cleanly and open a GitHub PR (draft OK) for substantial changes \u2014 never leave uncommitted changes behind without reporting them.","Review-only workers must not open new implementation PRs \u2014 review the existing PR and record a verdict in the final result.","Keep verification targeted to touched paths; avoid full-monorepo verification unless explicitly requested.","Do not run `npm publish`.","If verification fails, append a heartbeat line immediately with the failing command, reason, and next action."].join(`
|
|
2
|
+
`),"worker.prompt.progress.compact":"Plan progress: when planId is set, report progress with `kynver plan progress --plan <planId> --row <rowKey> --role implementer --status in_progress|running|partial|blocked`. Do not mark rows done from the worker CLI.","worker.prompt.progress.full":["Structured plan progress (required when planId is set):","- Report checkpoints with `kynver plan progress --plan <planId> --row <rowKey> --role implementer --status in_progress|running|partial|blocked`.","- When a slice is finished, emit `partial` with evidence (`--evidence pr:<url>`, `--evidence path:<file>`, or `--evidence command:<cmd>`).","- Do not propose or confirm row `done` from the worker CLI."].join(`
|
|
3
|
+
`),"worker.prompt.merge_gate.compact":"Verification cost control: prefer local verification before requesting CI runs; do not push empty commits to re-trigger CI; record verification evidence on the PR.","worker.prompt.merge_gate.full":["Verification cost control:","- Prefer local verification of touched paths before requesting any CI run.","- Do not push empty commits to re-trigger CI.","- Record verification evidence on the PR before requesting review."].join(`
|
|
4
|
+
`),"worker.prompt.plan_artifacts.compact":"Plan artifacts: when authoring or revising plan documents, open a GitHub PR early and iterate from that PR branch; do not leave the canonical plan only in a local worktree.","worker.prompt.plan_artifacts.full":["Plan artifacts (when authoring or revising plan documents):","- Create a feature branch and open a GitHub PR (draft OK) before substantial drafting; commit and push the plan file.","- Iterate on that PR branch and link the PR URL on the related task and progress evidence."].join(`
|
|
5
|
+
`)},R={"harness.maxTaskAttempts":4,"harness.dispatchCooldownMs":5e3,"daemon.idleIntervalMs":5*6e4,"daemon.maxIdleStreak":10},B={version:c,generatedAt:"1970-01-01T00:00:00.000Z",personas:I,instructions:b,policyThresholds:R};export{B as EMBEDDED_INSTRUCTION_BUNDLE,c as EMBEDDED_INSTRUCTION_BUNDLE_VERSION,p as PINNED_INSTRUCTION_BUNDLE_PUBLIC_KEYS,o as canonicalJsonStringify,L as computeInstructionBundleVersion,N as deriveInstructionBundleKeyId,s as isSignedInstructionBundleShape,a as parseRawEd25519Key,l as resolveInstructionBundlePublicKey,d as verifyInstructionBundleSignatureWithKey,h as verifySignedInstructionBundle};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* keyId → raw Ed25519 public key (hex). `ib-3bab6314f0ba` is the committed
|
|
3
|
+
* DEV fallback pair the server uses when `KYNVER_INSTRUCTION_BUNDLE_KEY` is
|
|
4
|
+
* unset — fine for dev/first-boot, NOT a production trust root (its private
|
|
5
|
+
* half is committed server-side). Production deployments set a real private
|
|
6
|
+
* key on the server and `KYNVER_INSTRUCTION_BUNDLE_PUBLIC_KEY` on daemon
|
|
7
|
+
* hosts until the prod public key is pinned here in a republish.
|
|
8
|
+
*/
|
|
9
|
+
export declare const PINNED_INSTRUCTION_BUNDLE_PUBLIC_KEYS: Readonly<Record<string, string>>;
|
|
10
|
+
/**
|
|
11
|
+
* Resolve the raw public key for a `publicKeyId`. The env override wins (key
|
|
12
|
+
* rotation without a package republish); otherwise the pinned set by id.
|
|
13
|
+
*/
|
|
14
|
+
export declare function resolveInstructionBundlePublicKey(publicKeyId: string, env?: Record<string, string | undefined>): Uint8Array | null;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { InstructionBundle, InstructionBundlePersona } from "./types.js";
|
|
2
|
+
export type InstructionBundleSource = "embedded" | "disk" | "server" | "primed";
|
|
3
|
+
export declare function getActiveInstructionBundle(): InstructionBundle;
|
|
4
|
+
export declare function getActiveInstructionBundleVersion(): string;
|
|
5
|
+
export declare function getActiveInstructionBundleSource(): InstructionBundleSource;
|
|
6
|
+
/**
|
|
7
|
+
* Install a bundle as the active one. The fetch client calls this ONLY after
|
|
8
|
+
* signature verification; `primed` is for in-process callers that already
|
|
9
|
+
* hold canonical content (e.g. the Kynver server seeding its own runtime
|
|
10
|
+
* imports) and for tests.
|
|
11
|
+
*/
|
|
12
|
+
export declare function setActiveInstructionBundle(bundle: InstructionBundle, source: InstructionBundleSource): void;
|
|
13
|
+
/** Reset to the embedded fallback (tests). */
|
|
14
|
+
export declare function __resetActiveInstructionBundleForTest(): void;
|
|
15
|
+
/**
|
|
16
|
+
* Resolve a keyed instruction literal: active bundle first, then the embedded
|
|
17
|
+
* fallback for that key, then empty string (never throws — a missing key must
|
|
18
|
+
* never take a worker down).
|
|
19
|
+
*/
|
|
20
|
+
export declare function resolveInstructionText(key: string): string;
|
|
21
|
+
/** Resolve a numeric policy threshold: active bundle → embedded → fallback. */
|
|
22
|
+
export declare function resolvePolicyThreshold(key: string, fallback: number): number;
|
|
23
|
+
/** Persona entry from the active bundle (null when the slug is not present). */
|
|
24
|
+
export declare function resolveBundlePersona(slug: string | null | undefined): InstructionBundlePersona | null;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export type InstructionBundleDispatchLane = "implementation" | "review" | "landing";
|
|
2
|
+
export type InstructionBundleRoleLane = "plan_author" | "implementer" | "report_reviewer" | "deep_reviewer" | "runtime_verifier" | "system";
|
|
3
|
+
export interface InstructionBundlePersona {
|
|
4
|
+
slug: string;
|
|
5
|
+
displayName: string;
|
|
6
|
+
description: string;
|
|
7
|
+
dispatchLane: InstructionBundleDispatchLane | null;
|
|
8
|
+
defaultRoleLane: InstructionBundleRoleLane;
|
|
9
|
+
}
|
|
10
|
+
/** Content payload — everything the version hash covers. */
|
|
11
|
+
export interface InstructionBundleContent {
|
|
12
|
+
personas: InstructionBundlePersona[];
|
|
13
|
+
/** Keyed instruction literals (e.g. `worker.prompt.core_rules`). */
|
|
14
|
+
instructions: Record<string, string>;
|
|
15
|
+
/** Keyed numeric policy thresholds (e.g. `harness.maxTaskAttempts`). */
|
|
16
|
+
policyThresholds: Record<string, number>;
|
|
17
|
+
}
|
|
18
|
+
export interface InstructionBundle extends InstructionBundleContent {
|
|
19
|
+
/** Content hash (`ib1-<sha256 prefix>`) — stable per content, used as ETag. */
|
|
20
|
+
version: string;
|
|
21
|
+
generatedAt: string;
|
|
22
|
+
}
|
|
23
|
+
export interface SignedInstructionBundle {
|
|
24
|
+
bundle: InstructionBundle;
|
|
25
|
+
/** base64url Ed25519 signature over `canonicalJsonStringify(bundle)`. */
|
|
26
|
+
signature: string;
|
|
27
|
+
/** Identifies the signing key (`ib-<sha256(publicKey) prefix>`). */
|
|
28
|
+
publicKeyId: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Deterministic JSON: recursively sorted object keys so signer and verifier
|
|
32
|
+
* agree on the signed bytes regardless of construction/parse order.
|
|
33
|
+
*/
|
|
34
|
+
export declare function canonicalJsonStringify(value: unknown): string;
|
|
35
|
+
/** Stable content-hash version: `ib1-` + first 16 hex of sha256(canonical content). */
|
|
36
|
+
export declare function computeInstructionBundleVersion(content: InstructionBundleContent): string;
|
|
37
|
+
/** Derive the key id used as `publicKeyId` from a raw 32-byte Ed25519 public key. */
|
|
38
|
+
export declare function deriveInstructionBundleKeyId(rawPublicKey: Uint8Array): string;
|
|
39
|
+
/** Parse a raw 32-byte key from hex (64 chars) or base64. Returns null when malformed. */
|
|
40
|
+
export declare function parseRawEd25519Key(raw: string | null | undefined): Uint8Array | null;
|
|
41
|
+
/** Structural validation of a parsed wire payload. */
|
|
42
|
+
export declare function isSignedInstructionBundleShape(value: unknown): value is SignedInstructionBundle;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type InstructionBundle } from "./types.js";
|
|
2
|
+
export type InstructionBundleVerifyResult = {
|
|
3
|
+
ok: true;
|
|
4
|
+
bundle: InstructionBundle;
|
|
5
|
+
} | {
|
|
6
|
+
ok: false;
|
|
7
|
+
reason: string;
|
|
8
|
+
};
|
|
9
|
+
/** Verify a signed bundle against an explicit raw 32-byte public key. */
|
|
10
|
+
export declare function verifyInstructionBundleSignatureWithKey(signed: unknown, rawPublicKey: Uint8Array): InstructionBundleVerifyResult;
|
|
11
|
+
/**
|
|
12
|
+
* Verify a signed bundle resolving the key from the env override / pinned set.
|
|
13
|
+
* This is the daemon's trust gate — a bundle that fails here is never used.
|
|
14
|
+
*/
|
|
15
|
+
export declare function verifySignedInstructionBundle(signed: unknown, env?: Record<string, string | undefined>): InstructionBundleVerifyResult;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface PersistedMeshCronLease {
|
|
2
|
+
leaseToken: string | null;
|
|
3
|
+
holderBoxId: string | null;
|
|
4
|
+
authorized: boolean;
|
|
5
|
+
updatedAt: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function loadPersistedMeshCronLease(runId: string): PersistedMeshCronLease | null;
|
|
8
|
+
export declare function persistMeshCronLease(runId: string, input: Pick<PersistedMeshCronLease, "leaseToken" | "holderBoxId" | "authorized">): void;
|
|
9
|
+
export declare function extractMeshLivenessFromOperatorTickResponse(operatorTick: unknown): PersistedMeshCronLease | null;
|
package/dist/retry-limits.d.ts
CHANGED
|
@@ -5,4 +5,8 @@ export interface HarnessRetryLimits {
|
|
|
5
5
|
/** Minimum ms between dispatch starts for the same run (default 5s). */
|
|
6
6
|
dispatchCooldownMs: number;
|
|
7
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
* Precedence: env override → server-delivered instruction bundle threshold →
|
|
10
|
+
* embedded default (M6 — policy values iterate via bundle push, no republish).
|
|
11
|
+
*/
|
|
8
12
|
export declare function readHarnessRetryLimits(): HarnessRetryLimits;
|