/** * `agentworkforce --version` update check. * * Printing a bare version number tells you what you have but not whether it is * current, so `--version` also asks the npm registry for the published * `latest` and — when the installed build is behind it — prints the upgrade * command to stderr. stderr keeps `$(agentworkforce --version)` parsable in * scripts while the notice still reaches a human at a terminal. * * The check is strictly best-effort: an offline machine, a private registry * that does not carry the package, a slow proxy, or a malformed response all * resolve to "no notice". Nothing in this module may throw or delay `--version` * beyond the timeout, so every failure path is swallowed. * * This module is imported from the `agentworkforce` wrapper bin as well as from * `cli-impl`, so it must stay free of non-builtin imports. */ import path from 'node:path'; /** The package users install, and therefore the one whose `latest` we report. */ export declare const UPDATE_CHECK_PACKAGE = "agentworkforce"; /** Registry used when neither agentworkforce nor npm config names one. */ export declare const DEFAULT_REGISTRY = "https://registry.npmjs.org"; /** * Registry budget for the whole check. `--version` does not exit until the * check settles, so this doubles as the worst case it can add to a run against * a black-holed registry; the response itself is a few dozen bytes. */ export declare const DEFAULT_UPDATE_CHECK_TIMEOUT_MS = 1000; /** Where the running CLI was resolved from; decides whether to suggest `-g`. */ export type InstallScope = 'global' | 'project'; type ParsedVersion = { numbers: [bigint, bigint, bigint]; prerelease: string; }; export type UpdateNoticeOptions = { /** Install location of the CLI being run. Inferred from `moduleUrl` if omitted. */ scope?: InstallScope; /** Module whose location decides the scope. Defaults to this module. */ moduleUrl?: string; /** Working directory a project-local install would be resolved against. */ cwd?: string; env?: NodeJS.ProcessEnv; /** Injected for tests; defaults to the global `fetch`. */ fetchImpl?: typeof fetch; }; /** * Strict semver parse. Returns `undefined` instead of throwing: an unparsable * version (a git build, a registry typo) means "cannot compare", not "fail". */ export declare function parseVersion(version: unknown): ParsedVersion | undefined; /** * Semver ordering, `undefined` when either side is unparsable. Mirrors the * comparator the wrapper bin uses to pick between installs, including * "a prerelease sorts below its own release". */ export declare function compareVersions(left: unknown, right: unknown): number | undefined; /** * Opt-out. `AGENTWORKFORCE_NO_UPDATE_CHECK=1` is ours; `NO_UPDATE_NOTIFIER=1` * is the ecosystem-wide convention and images that set it mean it for us too. */ export declare function isUpdateCheckDisabled(env?: NodeJS.ProcessEnv): boolean; /** * Registry to query: our override first, then whatever npm was configured with * (`npm_config_registry` is exported into `npm run`/`npx` environments), then * the public registry. A non-http(s) value is ignored rather than fetched. */ export declare function resolveRegistryBase(env?: NodeJS.ProcessEnv): string; /** Timeout budget, overridable for slow private registries. */ export declare function resolveTimeoutMs(env?: NodeJS.ProcessEnv): number; /** * Read the `latest` dist-tag. The dist-tags endpoint is a few dozen bytes, * unlike the full packument, which is megabytes for a package with our release * cadence. */ export declare function fetchLatestVersion(options?: { registry?: string; timeoutMs?: number; fetchImpl?: typeof fetch; }): Promise; /** * The scope decision as pure path arithmetic, split out from `resolveInstallScope` * so both POSIX and Windows semantics can be exercised on either platform by * passing `path.posix` / `path.win32`. */ export declare function classifyInstallPath(modulePath: string, cwd: string, pathImpl?: path.PlatformPath): InstallScope; /** * A CLI installed as a project dependency must not be told to run `-g`: that * would update a different copy than the one that just ran. * * The directory owning the *outermost* `node_modules` on the module's path is * the install root — `` for both `/node_modules/@agentworkforce/cli` * and the nested `/node_modules/agentworkforce/node_modules/…` layout. * The install is project-local when the command was run from inside that root, * which includes subdirectories: node resolves a dependency from an ancestor's * `node_modules` just as readily as from the working directory's own. */ export declare function resolveInstallScope(moduleUrl?: string, cwd?: string): InstallScope; /** The command that replaces the running install with the published latest. */ export declare function resolveUpdateCommand(scope: InstallScope): string; /** The two-line notice; kept short so it does not bury the version itself. */ export declare function formatUpdateNotice(current: string, latest: string, scope?: InstallScope): string; /** * The notice for this install, or `undefined` when the check is disabled, the * registry is unreachable, or the running build is already current (or ahead of * `latest`, as an unreleased local build is). */ export declare function resolveUpdateNotice(currentVersion: string, options?: UpdateNoticeOptions): Promise; /** * Emit the notice on stderr, if there is one. Callers can `await` this without * a try/catch: it resolves quietly on every failure. */ export declare function writeUpdateNotice(currentVersion: string, options?: UpdateNoticeOptions & { write?: (text: string) => void; }): Promise; export {}; //# sourceMappingURL=update-check.d.ts.map