export { MANAGED_BACKGROUND_WORKER_ENV } from "./background-environment.js"; import type { ProcessIncarnation, SameProcessIncarnation } from "./process-incarnation.js"; export type ManagedRuntimeVerificationMode = "fast-reuse" | "full-reuse" | "installed" | "repaired"; export interface ManagedBackgroundRuntime { readonly cliPath: string; readonly nodePath: string; readonly installRoot: string; readonly packageVersion: string; readonly cliSha256: string; readonly nodeAbi: string; /** How the durable runtime was established for this invocation. */ readonly verificationMode: ManagedRuntimeVerificationMode; /** Opaque, path-free proof consumed only by the managed LaunchAgent worker. */ readonly launchProof: string; } export interface ManagedRuntimeLaunchVerification { /** Exact verified closure root; safe to add as an app-owned read-only SRT root. */ readonly installRoot: string; /** Operator-facing provenance derived from the same verified marker. */ readonly provenanceDetail: string; readonly packageVersion: string; readonly cliSha256: string; } export interface ManagedRuntimeSourceIdentity { readonly packageVersion: string; readonly cliSha256: string; } export interface ManagedRuntimeLaunchVerificationInput { readonly currentCliPath: string; readonly launchProof: string; readonly homeDir?: string; readonly now?: () => number; readonly sleep?: (ms: number) => Promise; } export interface ManagedRuntimeProvenanceVerificationInput { readonly packageRoot: string; readonly packageVersion: string; readonly cliSha256: string; readonly sourceClosureSha256: string; readonly closureManifestSha256: string; readonly executionProofSha256: string; readonly nodeAbi: string; readonly platform: NodeJS.Platform; readonly arch: string; readonly installedAt: string; } export interface ManagedRuntimeProvenanceVerificationDeps { /** Deterministic race-test seam; production never supplies this hook. */ readonly afterInitialClosureCapture?: () => Promise; /** In-capture race seam after root files were read but before the final proof pass. */ readonly afterFinalRootCapture?: () => Promise; /** Full-manifest race seam after traversal but before its global identity pass. */ readonly beforeFinalManifestProof?: () => Promise; } /** One config-selected package that is loaded dynamically rather than declared by agent-app. */ export interface ManagedRuntimeAdditionalPackage { readonly packageName: string; /** Resolved package root containing package.json (not a node_modules symlink). */ readonly packageSource: string; } export interface ManagedBackgroundRuntimeInput { /** The CLI currently executing. Its exact bytes are the trust anchor. */ readonly currentCliPath: string; readonly nodePath: string; readonly homeDir?: string; readonly packageVersion?: string; readonly nodeAbi?: string; readonly platform?: NodeJS.Platform; readonly arch?: string; /** Test/packaging seam; defaults to the package root containing currentCliPath. */ readonly packageSource?: string; /** Config-selected channel/memory plugin packages that must survive outside the caller's install tree. */ readonly additionalPackages?: readonly ManagedRuntimeAdditionalPackage[]; } /** Inputs for the read-only fleet attestation of an already materialized runtime. */ export interface ManagedBackgroundRuntimeAttestationInput { /** CLI from the trusted deploy checkout whose execution closure is expected. */ readonly currentCliPath: string; /** CLI path persisted in the managed LaunchAgent. */ readonly runtimeCliPath: string; readonly homeDir?: string; readonly packageVersion?: string; readonly nodeAbi?: string; readonly platform?: NodeJS.Platform; readonly arch?: string; readonly packageSource?: string; readonly additionalPackages?: readonly ManagedRuntimeAdditionalPackage[]; } export interface ManagedBackgroundRuntimeAttestation { readonly schema: "mono-agent.managed-runtime-attestation.v1"; /** Opaque, path-free identity used only to compare an initial and final probe. */ readonly fingerprint: string; /** Safe lifecycle boundary: a managed worker must start after this install. */ readonly installedAt: string; } interface ManagedBackgroundRuntimeAttestationDeps { /** Deterministic race-test seam; production never supplies this hook. */ readonly afterInitialCaptures?: () => Promise; } export interface ManagedRuntimeInstallInput { readonly stagingDir: string; readonly packageVersion: string; readonly packageSource: string; readonly nodePath: string; readonly additionalPackages: readonly ManagedRuntimeAdditionalPackage[]; readonly expectedSourceClosureSha256: string; } export interface ManagedBackgroundRuntimeDeps { readonly now: () => number; readonly sleep: (ms: number) => Promise; readonly randomId: () => string; readonly installPackage: (input: ManagedRuntimeInstallInput) => Promise; /** Test/embed seams for persistent install-lock ownership. */ readonly currentProcessIncarnation?: () => Promise; readonly isSameProcessIncarnation?: SameProcessIncarnation; } export declare function defaultManagedBackgroundRuntimeDeps(): ManagedBackgroundRuntimeDeps; /** * launchd can retain a user's historical environment independently of the * plist. Strip it before dotenv loading so the worker observes only the * reviewed operational allowlist plus the selected dotenv file. */ export declare function sanitizeManagedBackgroundWorkerEnvironment(env: Record): void; /** * Materialize the currently executing published CLI into a private, immutable * runtime outside npm/npx's disposable cache. A runtime is accepted only when * the exact installed CLI bytes match the caller, not merely when its package * version matches. */ export declare function ensureManagedBackgroundRuntime(input: ManagedBackgroundRuntimeInput, deps?: ManagedBackgroundRuntimeDeps): Promise; /** * Inspect the controller CLI as inert installation input. The recovery helper * uses this to decide whether launchd owns an older closure without ever * executing mutable checkout bytes. */ export declare function inspectManagedRuntimeSourceIdentity(currentCliPathInput: string): Promise; /** * Validate the opaque proof carried by a managed LaunchAgent against the exact * CLI that is about to start. This is intentionally lighter than controller * attestation: it rechecks the private layout, marker, CLI, and stored closure * manifest fingerprints without traversing the entire installed dependency * tree on every KeepAlive restart. */ export declare function verifyManagedRuntimeLaunch(input: ManagedRuntimeLaunchVerificationInput): Promise; /** * Canonically verify the installed package, freshly recomputed execution * closure/filesystem proof, and coherent current manifest behind a provenance * marker. This intentionally does not install, repair, or compare against a * deploy checkout; it only validates the managed snapshot executing the caller. */ export declare function verifyManagedRuntimeClosureForProvenance(input: ManagedRuntimeProvenanceVerificationInput, deps?: ManagedRuntimeProvenanceVerificationDeps): Promise; /** * Prove, without installing or repairing anything, that a persisted managed * runtime is the canonical private copy of the exact deploy-source execution * closure (including config-selected plugin roots). */ export declare function attestManagedBackgroundRuntime(input: ManagedBackgroundRuntimeAttestationInput, deps?: ManagedBackgroundRuntimeAttestationDeps): Promise; //# sourceMappingURL=background-runtime.d.ts.map