export declare const DEFAULT_LICENSE_API_BASE: string; export declare const PRODUCT_SLUG = "z2w-starter-kit"; export declare const DEFAULT_CONFIG_DIR: string; export declare const LICENSE_FILE_NAME = "license"; /** 24h local cache: skip /license/check if last attempt is within this window. */ export declare const CACHE_TTL_MS: number; /** Past this many days of consecutive check failures, the CLI declines paid features. */ export declare const N_DAY_CEILING = 14; /** Past this many days of consecutive check failures, the CLI warns (but still allows). */ export declare const N_DAY_WARN_THRESHOLD: number; export type ServerStatus = "active" | "expired" | "suspended" | "revoked"; export interface LicenseState { version: 1; key: string; productSlug: string; machineId: string; lastSuccessfulCheck: string | null; lastCheckAttempt: string | null; cachedStatus: ServerStatus | null; cachedExpiresAt: string | null; retryAfter: string | null; } export type LicenseEvaluationReason = "active" | "expired-snapshot-only" | "suspended-snapshot-only" | "revoked-blocked" | "check-failing-within-grace" | "check-failing-past-warn" | "check-failing-past-ceiling" | "never-checked" | "no-license"; export interface LicenseEvaluation { allowPaidFeatures: boolean; allowTemplatesUpdates: boolean; reason: LicenseEvaluationReason; warning: string | null; daysSinceLastCheck: number | null; } export interface RuntimeOptions { /** Override the config directory (tests). Default {@link DEFAULT_CONFIG_DIR}. */ configDir?: string; /** Override the API base URL (tests). Default {@link DEFAULT_LICENSE_API_BASE}. */ licenseApiBase?: string; /** Override the fetch implementation (tests). Default global `fetch`. */ fetchImpl?: typeof fetch; /** Override the clock (tests). Default `() => Date.now()`. */ now?: () => number; /** Override UUID generation (tests). Default `() => crypto.randomUUID()`. */ uuid?: () => string; } export declare class LicenseError extends Error { constructor(message: string); } /** * Maps stored license state + current time to a paid-feature decision. Pure * function — no I/O, no side effects. The runtime check writes new state to * disk first and THEN calls this; the unit tests pin every row in the * directive §8 failure matrix against this function alone. */ export declare function evaluateLicense(state: LicenseState | null, now?: number): LicenseEvaluation; export declare function loadLicenseState(opts?: RuntimeOptions): Promise; export declare function saveLicenseState(state: LicenseState, opts?: RuntimeOptions): Promise; export declare function clearLicenseState(opts?: RuntimeOptions): Promise; export declare function isValidLicenseKey(key: string): boolean; /** Masks a license key for diagnostic display: "Z2W-ABCD-...-WXYZ". */ export declare function maskKey(key: string): string; /** * Activates a license on this machine. On 2xx, persists state including a * fresh `lastSuccessfulCheck`. On error, throws LicenseError without writing. */ export declare function activateLicense(key: string, opts?: RuntimeOptions): Promise<{ state: LicenseState; status: ServerStatus; }>; export interface CheckResult { state: LicenseState; status: ServerStatus | null; networkOk: boolean; message: string | null; } /** * Calls /license/check and updates state accordingly. Never throws on network * failure / 5xx / 429 — bumps `lastCheckAttempt`, persists `retryAfter` if * the server sent one, and returns `networkOk: false`. Throws only when no * license is configured (callers should handle that ahead of time). * * Honors a previously-persisted Retry-After by short-circuiting the network * call until the persisted deadline passes. */ export declare function checkLicense(opts?: RuntimeOptions): Promise; /** * Deactivates the local license. Attempts to notify the server (so the * activation slot frees up) but clears local state even if the server call * fails — the user has decided to deactivate, and a stuck server-side * activation isn't a reason to block them. */ export declare function deactivateLicense(opts?: RuntimeOptions): Promise; /** * The orchestrator paid-feature gates call. Reads stored state; if cache is * stale (>24h since last attempt), phones home; runs the pure evaluator * against whatever state ends up persisted. Never throws — returns a * well-formed evaluation in every case so call sites can switch on * `allowPaidFeatures` cleanly. */ export declare function runtimeLicenseCheck(opts?: RuntimeOptions): Promise;