UNPKG

@juspay/neurolink

Version:

The pipe layer of an AI nervous system: one interface connecting provider neurons to your application, across three inference types — generate, stream and decide. `decide` returns typed, calibrated judgements from a non-generative model (~400ms, ~$0.00002

72 lines (71 loc) • 3.68 kB
/** * Update State Persistence * Manages persistent state for the proxy auto-update feature. * Tracks check timestamps, suppressed versions, and update history. * * State file location: ~/.neurolink/update-state.json * Suppressed versions expire after 24 hours. */ import type { UpdateState } from "../types/index.js"; /** * Return an empty/initial UpdateState. */ export declare function getDefaultUpdateState(): UpdateState; /** * Load the update state from disk. * Returns null if the file does not exist. * Returns the default state if the file contains corrupt JSON. * * @param stateFilePath - Override path for testing (default: ~/.neurolink/update-state.json) */ export declare function loadUpdateState(stateFilePath?: string): UpdateState | null; /** * Save the update state to disk. * * @param state - The UpdateState to persist * @param stateFilePath - Override path for testing (default: ~/.neurolink/update-state.json) */ export declare function saveUpdateState(state: UpdateState, stateFilePath?: string): void; /** * Check whether a version is currently suppressed (i.e., suppressed AND within the 24-hour window). * * @param version - Semver version string to check * @param stateFilePath - Override path for testing */ export declare function isVersionSuppressed(version: string, stateFilePath?: string): boolean; /** * Add a version to the suppressed list and persist. * * @param version - Semver version string to suppress * @param reason - Human-readable reason for suppression * @param stateFilePath - Override path for testing */ export declare function suppressVersion(version: string, reason: string, stateFilePath?: string): void; /** * Record a successful update: set lastUpdateAt and lastUpdateVersion, then persist. * * @param version - The version that was successfully installed * @param stateFilePath - Override path for testing */ export declare function recordSuccessfulUpdate(version: string, stateFilePath?: string): void; /** Record that the package was validated but live activation is still pending. */ export declare function recordUpdateInstalled(version: string, stateFilePath?: string): void; /** Abandon a matching installed version so the next cycle may reinstall it. */ export declare function abandonPendingUpdate(version: string, stateFilePath?: string): boolean; /** Persist a stage-specific updater failure so status remains actionable. */ export declare function recordUpdateFailure(version: string, stage: NonNullable<UpdateState["lastFailure"]>["stage"], message: string, stateFilePath?: string): void; /** Persist why a discovered update is waiting without treating it as a failure. */ export declare function recordUpdateDeferred(version: string, reason: NonNullable<UpdateState["deferredUpdate"]>["reason"], activeRequests: number | null, stateFilePath?: string): void; /** Clear matching updater deferral metadata once work can proceed. */ export declare function clearUpdateDeferral(version?: string, stateFilePath?: string): boolean; /** Complete an updater-managed install after a manual or automatic restart. */ export declare function reconcileRunningUpdate(runningVersion: string, stateFilePath?: string): boolean; /** * Record an update check: set lastCheckAt and lastCheckVersion, then persist. * * @param latestVersion - The latest version found during the check * @param stateFilePath - Override path for testing */ export declare function recordCheck(latestVersion: string, stateFilePath?: string): void; /** Preserve the last successful registry version when discovery fails. */ export declare function recordCheckFailure(message: string, stateFilePath?: string): void;