/** * UpdateCheck service — manages cached version checks and notifications. * * Reads/writes a platform-cache `update-check.json` file, determines whether * the check should be skipped, and produces notification messages. * * @experimental This API is unstable and may change without notice. * @packageDocumentation */ import * as DateTime from "effect/DateTime"; import * as Effect from "effect/Effect"; import * as FileSystem from "effect/FileSystem"; import * as Layer from "effect/Layer"; import * as Option from "effect/Option"; import * as Path from "effect/Path"; import * as Schema from "effect/Schema"; import * as ServiceMap from "effect/Context"; /** Schema for the on-disk update check cache file. */ export declare const UpdateCheckCacheSchema: Schema.Struct<{ readonly latestVersion: Schema.String; readonly checkedAt: Schema.decodeTo; }>; /** Decoded cache shape. */ export type UpdateCheckCache = typeof UpdateCheckCacheSchema.Type; /** * Context used to determine whether the update check should be skipped. * Accepts parameters rather than reading globals directly for testability. */ export interface SkipCheckContext { readonly isJsonOutput: boolean; readonly noUpdateCheckEnv: boolean; readonly isUpgradeCommand: boolean; readonly isNonInteractive: boolean; readonly isStderrTTY: boolean; readonly isAgentSession: boolean; } export type NotificationAudience = "human" | "agent"; export interface UpdateCheckService { /** Read the cached update check, returning None if missing, invalid, or stale. */ readonly readCache: () => Effect.Effect>; /** Write the cache with the given version and current timestamp. */ readonly writeCache: (latestVersion: string) => Effect.Effect; /** Check if an update is available based on cached data. */ readonly isUpdateAvailable: (localVersion: string) => Effect.Effect>; /** Determine if the update check should be skipped entirely. */ readonly shouldSkip: (context: SkipCheckContext) => boolean; /** Build a notification message. */ readonly notificationMessage: (current: string, latest: string, audience?: NotificationAudience) => string; } declare const UpdateCheck_base: ServiceMap.ServiceClass; /** * Effect service tag for update check management. * * @experimental This API is unstable and may change without notice. */ export declare class UpdateCheck extends UpdateCheck_base { } /** * Determine if the update check should be skipped. */ export declare const shouldSkip: (context: SkipCheckContext) => boolean; /** * Build a notification message. */ export declare const notificationMessage: (current: string, latest: string, audience?: NotificationAudience) => string; /** * Check whether the cache is stale (older than 60 minutes). */ export declare const isCacheStale: (checkedAt: DateTime.Utc) => Effect.Effect; /** * Read and parse the cache file, returning None if missing, invalid, or stale. */ export declare const readCacheFromPath: (cachePath: string) => Effect.Effect, never, FileSystem.FileSystem>; /** * Write the cache file with the given version and current timestamp. */ export declare const writeCacheToPath: (cachePath: string, latestVersion: string) => Effect.Effect; /** * Check if an update is available by reading the cache and comparing versions. */ export declare const isUpdateAvailableFromPath: (cachePath: string, localVersion: string) => Effect.Effect | Option.Some<{ readonly current: string; readonly latest: string; }>, never, FileSystem.FileSystem>; export declare const UpdateCheckLive: Layer.Layer; /** * Create an UpdateCheck layer for testing with a configurable cache path. */ export declare const UpdateCheckTest: (cachePath: string) => Layer.Layer; export {}; //# sourceMappingURL=update-check.d.ts.map