import { type ResolvedAutoUpdateConfig } from '../config.js'; /** Normalize repo to "owner/name" (strip URL prefix or .git suffix). */ export declare function normalizeRepo(repo: string): string; export declare function parseTagName(ref: string): string | null; export declare function isValidRef(ref: string): boolean; export declare function isValidRepoSpec(repo: string): boolean; export declare function repoToFetchUrl(repo: string): string; export declare function githubRepoForApi(repo: string): string | null; export declare function resolveRemoteCommitSha(repoSpec: string, ref: string, log: (msg: string) => void, gitEnv: NodeJS.ProcessEnv): Promise; export type PendingUpdateState = { target: "a" | "b"; commit: string; version?: string; ref: string; createdAt: string; }; export type CommitCheckStatus = { status: "available" | "up-to-date" | "error"; commit?: string; }; export declare function readPendingUpdateState(): Promise; export declare function clearPendingUpdateState(): Promise; export declare function writePendingUpdateState(state: PendingUpdateState): Promise; /** * Query the NPM registry for the latest published version of the CLI package. * Uses `dist-tags.latest` by default; when `allowPrerelease` is true, also * checks `beta` / `next` tags and picks the highest semver. */ export type NpmVersionResult = { version: string; error?: false; } | { version: null; error: true; } | { version: null; error: false; }; export declare function resolveLatestNpmVersion(log: (msg: string) => void, allowPrerelease?: boolean): Promise; export declare function compareSemver(a: string, b: string): number; export declare function getCurrentCliVersion(): string; export type NpmVersionStatus = { status: "available" | "up-to-date" | "error"; version?: string; }; export declare function checkForNpmVersionUpdate(log: (msg: string) => void, allowPrerelease?: boolean): Promise; /** * Check GitHub for a new commit on the configured branch. * Returns the latest commit SHA if an update is available, null otherwise. */ export declare function checkForNewCommit(au: ResolvedAutoUpdateConfig, log: (msg: string) => void, refOverride?: string): Promise; export declare function checkForNewCommitWithStatus(au: ResolvedAutoUpdateConfig, log: (msg: string) => void, refOverride?: string): Promise; export type UpdateStatus = "updated" | "up-to-date" | "failed"; export declare function acquireUpdateLock(log: (msg: string) => void): Promise; export declare function releaseUpdateLock(): Promise; /** Default per-step build timeouts (milliseconds). Override via config. */ export declare const DEFAULT_BUILD_TIMEOUTS: { readonly install: 180000; readonly build: 180000; readonly contracts: 300000; readonly markitdown: 900000; }; export declare function resolveBuildTimeouts(au: Pick): { install: number; build: number; contracts: number; markitdown: number; }; /** * Run a build command with a timeout, then best-effort sweep orphan build * subprocesses on failure. Node's `exec` SIGTERMs the direct child on timeout * but pnpm's grandchildren (notably `solcjs-runner`) survive and pin a CPU, * which has caused subsequent update attempts on the same host to time out * even faster ("doom loop" observed on dkg-v9-relay-02/04). The sweep targets * narrow process-name patterns so we never kill unrelated workloads. */ export declare function runBuildStep(execAsync: (cmd: string, opts: any) => Promise, cmd: string, opts: { cwd: string; timeoutMs: number; label: string; log: (m: string) => void; env?: NodeJS.ProcessEnv; }): Promise<{ stdout: string; stderr: string; }>; /** * Core blue-green update logic. Builds the new version in the inactive slot, * then atomically swaps the `releases/current` symlink. * Returns true if an update was applied (caller should SIGTERM to restart). */ export interface PerformUpdateOptions { refOverride?: string; allowPrerelease?: boolean; verifyTagSignature?: boolean; /** * If true, run `git clean -fdx` in the inactive slot before building. * Default false: preserve `node_modules/` and the Hardhat compile cache so * the build is incremental. Cold rebuilds on ARM64 historically exceeded * the 5-minute build-step timeout. Operators who want a known-clean state * should set this explicitly. */ forceClean?: boolean; } export declare function performUpdate(au: ResolvedAutoUpdateConfig, log: (msg: string) => void, opts?: PerformUpdateOptions): Promise; export declare function performUpdateWithStatus(au: ResolvedAutoUpdateConfig, log: (msg: string) => void, opts?: PerformUpdateOptions): Promise; export declare function performNpmUpdate(targetVersion: string, log: (msg: string) => void): Promise; /** * Edge npm-only update path (OT-RFC-41 §4.1 + §4.8, Bundle B1b). * * Unlike {@link performNpmUpdate} (Core), Edge nodes do not use * blue-green slots. The update is a direct `npm install -g` against * the user's npm-global install, after recording the current * version to `~/.dkg/previous-version` so `dkg rollback` (Edge * branch) has a target to reinstall. * * Tradeoffs accepted (per RFC §7.2): * - Non-atomic: a mid-install crash leaves the global state * half-updated. Recovery is `npm install -g` re-run. * - Network-dependent rollback: requires the npm registry to * have the previous version available. * * The function returns `'updated'` after the npm install completes; * the caller is responsible for stopping the running daemon so the * supervisor respawns from the new entry point (mirrors how the * Core path's swap-slot+restart sequence works). * * Returns `'failed'` on any npm install failure; the previous-version * write is best-effort and a write failure does NOT block the install * (the operator can still rollback manually via * `npm install -g @origintrail-official/dkg@`). */ export declare function performNpmUpdateEdge(targetVersion: string, currentVersion: string | null, log: (msg: string) => void): Promise; export declare function checkForUpdate(au: ResolvedAutoUpdateConfig, log: (msg: string) => void): Promise; //# sourceMappingURL=auto-update.d.ts.map