/** * archive command — Internet Archive Wayback Machine integration (ADR-0006). * * Implements temporal archival intelligence: * * - `archive cdx [--from TS] [--to TS] [--status 200] [--limit N]`: * Queries the CDX Server API to enumerate historical captures. * - `archive get [--at ] [--raw]`: * Replays a capture using Wayback's `id_` verbatim mode (toolbar stripped), * auto-resolving the best snapshot via the Availability API when omitted. * - `archive diff --since `: * One-shot snapshot-vs-live comparison: replays the capture at or * before `--since` (CDX-selected, never nearest-after) and diffs its * sections against the live page (watch-temporal-diff lane B, T3). * * Credential-free (public, keyless API) dispatched before config load. */ import type { CommandResult } from "../command-invocation.js"; import type { OutputMode } from "../lib/output.js"; import type { HandlerDependencies } from "../index.js"; export declare const ARCHIVE_HELP: string; export declare const WAYBACK_CDX_ENDPOINT = "https://web.archive.org/cdx/search/cdx"; export declare const WAYBACK_AVAILABILITY_ENDPOINT = "https://archive.org/wayback/available"; export declare const DEFAULT_ARCHIVE_TIMEOUT_MS = 30000; export interface ArchiveCapture { readonly timestamp: string; readonly statusCode: number; readonly length: number; readonly digest: string; readonly originalUrl: string; } export interface ArchiveCdxReport { readonly schemaVersion: 1; readonly url: string; readonly total: number; readonly captures: readonly ArchiveCapture[]; } export interface ArchiveGetReport { readonly schemaVersion: 1; readonly url: string; readonly snapshotTimestamp: string; readonly archiveUrl: string; readonly statusCode: number; readonly bytes: number; readonly contentType?: string; readonly content?: string; } export interface ArchiveDiffOptions { readonly since?: string; readonly timeout?: number; } export interface ArchiveDiffReport { readonly schemaVersion: 1; readonly url: string; readonly asOf: string; readonly snapshotTimestamp: string; readonly finalUrl: string; readonly added: readonly string[]; readonly removed: readonly string[]; readonly changed: readonly string[]; readonly hashOnly: boolean; readonly moved: boolean; } export interface ArchiveCdxOptions { readonly from?: string; readonly to?: string; readonly status?: string; readonly limit?: number; readonly timeout?: number; } export interface ArchiveGetOptions { readonly at?: string; readonly raw?: boolean; readonly timeout?: number; } /** * Fetch with exponential backoff on HTTP 429/503 (rate limiting). */ export declare function fetchWithArchiveBackoff(url: string, options?: { timeout?: number; headers?: Record; sleep?: (ms: number) => Promise; }, consumer?: (res: Response) => Promise): Promise; /** * Enumerate captures via CDX server. */ export declare function executeArchiveCdx(urlOrPattern: string, options?: ArchiveCdxOptions, dependencies?: { sleep?: (ms: number) => Promise; cdxEndpoint?: string; }): Promise; /** * Resolve snapshot timestamp via Wayback Availability API. */ export declare function resolveAvailableSnapshot(url: string, timestampHint?: string, dependencies?: { sleep?: (ms: number) => Promise; timeout?: number; availabilityEndpoint?: string; }): Promise<{ timestamp: string; archiveUrl: string; }>; /** * Fetch raw capture content via Wayback's `id_` verbatim mode. */ export declare function executeArchiveGet(url: string, options?: ArchiveGetOptions, dependencies?: { sleep?: (ms: number) => Promise; availabilityEndpoint?: string; replayBaseUrl?: string; }): Promise; /** * Invocation-seam wrapper for archive cdx. */ export declare function archiveCdxCommand(urlOrPattern: string, options?: ArchiveCdxOptions): Promise>; /** * Invocation-seam wrapper for archive get. */ export declare function archiveGetCommand(url: string, options?: ArchiveGetOptions): Promise>; export declare function resolveSinceInstant(since: string, now?: () => number): { atMs: number; asOf: string; }; /** Pull the charset parameter out of a Content-Type header, if present. */ export declare function charsetFromContentType(contentType: string | undefined): string | undefined; /** * Fetch the LIVE side: manual redirect loop (≤10 hops, 303/301/302 * downgrade semantics per fetch), 50MB bounded read (never * `arrayBuffer()`), browser UA, AbortController timeout. Returns the * final body plus `moved` — true only when the chain contains a * permanent (301/308) hop AND the final URL differs from the request. */ export declare function fetchLiveDocument(url: string, timeoutMs: number): Promise<{ raw: Buffer; finalUrl: string; moved: boolean; contentType?: string; statusCode: number; }>; /** * One-shot snapshot-vs-live section diff (watch-temporal-diff lane B, T3). * * Archive side = snapshot RAW bytes via `id_` replay; live side = real * HTTP fetch. Sections extracted from each side's bytes under its own * charset hint; non-HTML degrades to hash-only per the engine contract. */ export declare function executeArchiveDiff(url: string, options?: ArchiveDiffOptions, dependencies?: { sleep?: (ms: number) => Promise; cdxEndpoint?: string; replayBaseUrl?: string; now?: () => number; }): Promise; /** * Same-document URL comparison: normalizes before comparing so a * 301 to a trailing-slash variant of the same path is NOT a move, * matching watch run's cross-surface rule. Case-insensitive host, * trailing-slash-insensitive for non-root paths, query strings stay * significant. Unparseable inputs fall back to exact string equality * (degrades to the pre-normalization behavior, never worse). * Exported for watch.ts to adopt the same comparison. */ export declare function isSameDocumentUrl(a: string, b: string): boolean; /** * Invocation-seam wrapper for archive diff. */ export declare function archiveDiffCommand(url: string, options?: ArchiveDiffOptions): Promise>; /** * Parse CLI args for archive command. */ export declare function parseArchiveArgs(args: readonly string[]): { readonly subcommand?: string; readonly positional: readonly string[]; readonly flags: Record; readonly showHelp: boolean; }; /** * Dispatcher handler for `archive` in `src/index.ts`. */ export declare function handleArchive(args: string[], outputMode: OutputMode, deps: HandlerDependencies, forceRaw?: boolean): Promise; //# sourceMappingURL=archive.d.ts.map