import { ArchiveContentOptions, ArchiveContentResponse, ArchiveDiffFormat, ArchiveOptions, ArchiveResponse, ArchivedContentDiff, ArchivedPage } from "./_chunks/types.mjs"; /** One text block plus the details a harness renders next to it. */ interface ToolResult { content: Array<{ type: "text"; text: string; }>; details: TDetails; /** Set when the operation ran but produced no usable answer. */ isError?: boolean; } /** Provider names accepted in tool arguments; `auto` resolves to `all`. */ declare const PROVIDERS: readonly ["auto", "all", "wayback", "arquivo", "webarchiv", "archiveIt", "conifer", "archiveToday", "memento", "commoncrawl", "webcite", "permacc"]; /** Kebab spellings accepted alongside the camelCase names. */ declare const PROVIDER_ALIASES: { readonly "archive-today": "archiveToday"; readonly "archive-it": "archiveIt"; }; /** Every spelling a caller may pass, for surfaces that enumerate them in a schema. */ declare const PROVIDER_INPUTS: readonly ["auto", "all", "wayback", "arquivo", "webarchiv", "archiveIt", "conifer", "archiveToday", "memento", "commoncrawl", "webcite", "permacc", ...("archive-it" | "archive-today")[]]; type ProviderInput = (typeof PROVIDERS)[number]; type ProviderName = Exclude; declare const PROVIDER_HINT = "Provider to use. \"auto\" (or omit) uses \"all\", which queries Wayback, Arquivo.pt, Webarchiv Österreich, Archive.today, Common Crawl, and WebCite. Webarchiv Österreich searches one exact URL through a public CDXJ endpoint. Memento uses the public MemGator service to query several archives and stays outside \"all\" to avoid duplicate requests. Archive-It requires a numeric collection id. Conifer requires user and collection slugs. Perma.cc requires an API key from an environment variable and searches exact URLs accessible to that account."; declare const CONTENT_PROVIDER_HINT = "Provider to read from. \"auto\" (or omit) uses \"all\", which tries Wayback, Arquivo.pt, Webarchiv Österreich, Archive.today, and Common Crawl. Memento reads the selected TimeMap URI directly and uses MemGator's proxy as fallback. Wayback, Arquivo.pt and Webarchiv Österreich use raw replay endpoints; Archive.today serves its rendered wrapper page rather than the original bytes. Archive-It reads bodies too, with a numeric collection id. Conifer, WebCite and Perma.cc serve no readable capture bodies and answer as unsupported."; /** Rendering of the archived body: readable text, or decoded text with markup intact. */ declare const CONTENT_FORMATS: readonly ["text", "raw"]; type ContentFormat = (typeof CONTENT_FORMATS)[number]; declare const CONTENT_FORMAT_HINT = "How to return the body. \"text\" (default) strips markup from an HTML capture and returns what a reader would see; \"raw\" returns the decoded capture body without stripping markup."; declare const SNAPSHOT_FROM_HINT = "Earliest capture to list, as archive digits (YYYY through YYYYMMDDhhmmss) or an ISO 8601 date. Inclusive; a partial stamp starts the window at the beginning of the period it names."; declare const SNAPSHOT_TO_HINT = "Latest capture to list, in the same formats as \"from\". Inclusive; a partial stamp stretches the window to the end of the period it names, so from=2019 with to=2019 covers the whole year."; declare const DEFAULT_LIMIT = 10; declare const MAX_LIMIT = 100; declare const DEFAULT_MAX_CHARS = 20000; declare const MAX_CONTENT_CHARS = 200000; declare const DEFAULT_DIFF_CONTEXT = 3; declare const MAX_DIFF_CONTEXT = 100; /** Largest UTF-16 position accepted within the fixed fetched prefix. */ declare const MAX_CONTENT_OFFSET = 2000000; /** Largest position in a derived patch, which can contain both complete bodies. */ declare const MAX_DIFF_OFFSET: number; declare const MAX_TIMESTAMP_LENGTH = 32; /** Timeout one content call asks for when the caller names none. */ declare const DEFAULT_CONTENT_TIMEOUT = 30000; declare const MAX_TARGET_LENGTH = 2048; declare const MAX_PARAMETER_LENGTH = 256; declare const MAX_TTL: number; declare const MAX_RETRIES = 10; declare const MAX_TIMEOUT: number; declare const PERMACC_API_KEY_ENVS: readonly ["PERMA_CC_API_KEY", "PERMACC_API_KEY"]; /** Options passed to a provider factory, including the provider-specific extras. */ type SnapshotOptions = ArchiveOptions & { apiKey?: string; collection?: string; user?: string; collapse?: string; filter?: string; }; /** Snapshot options as they reach a harness transcript: never carrying the key. */ type RedactedSnapshotOptions = Omit & { apiKey?: ""; }; /** Options passed to a provider factory for a content read. */ type ContentOptions = ArchiveContentOptions & { apiKey?: string; collection?: string; user?: string; }; /** Content options as they reach a harness transcript: never carrying the key. */ type RedactedContentOptions = Omit & { apiKey?: ""; }; /** Arguments of the snapshot tool, shared by every surface's schema. */ interface SnapshotParams { target: string; provider?: string; limit?: number; cache?: boolean; ttl?: number; concurrency?: number; batchSize?: number; timeout?: number; retries?: number; collection?: string; user?: string; collapse?: string; filter?: string; from?: string; to?: string; } /** The queried window plus the response it came from. */ interface SnapshotDetails { mode: "snapshots"; target: string; provider: ProviderName; options: RedactedSnapshotOptions; count: number; response: ArchiveResponse; } /** Arguments of the content tool, shared by every surface's schema. */ interface ContentParams { target: string; provider?: string; timestamp?: string; format?: string; maxChars?: number; offset?: number; cache?: boolean; ttl?: number; timeout?: number; retries?: number; collection?: string; user?: string; } /** The capture that was read, plus how much of it the caller received. */ interface ContentContinuation { target: string; provider: string; timestamp: string; format: ContentFormat; collection?: string; offset: number; } interface ContentDetails { mode: "content"; target: string; provider: ProviderName; format: ContentFormat; options: RedactedContentOptions; /** Characters of body text handed back, after formatting and clipping. */ characters: number; /** UTF-16 position where this slice starts. */ offset: number; /** UTF-16 position immediately after this slice. */ endOffset: number; /** Another slice can be requested. */ hasMore: boolean; /** Position to pass as `offset` for the next slice. */ nextOffset?: number; /** Arguments pinned to the capture for the next slice. */ continuation?: Readonly; /** Body text was clipped to `maxChars` while rendering. */ clipped: boolean; response: ArchiveContentResponse; } /** Arguments of the capture diff tool, shared by every surface's schema. */ interface DiffParams { target: string; before: string; after: string; provider?: string; format?: string; context?: number; maxChars?: number; offset?: number; cache?: boolean; ttl?: number; timeout?: number; retries?: number; collection?: string; user?: string; /** SHA-256 from a prior continuation, used to reject a changed recomputation. */ digest?: string; } /** One provider's reason for not producing a comparable capture pair. */ interface DiffAttempt { provider: string; error: string; } /** Arguments pinned to the exact pair behind the following diff slice. */ interface DiffContinuation { target: string; provider: string; before: string; after: string; format: ArchiveDiffFormat; context: number; collection?: string; digest: string; offset: number; } /** Structured evidence retained beside the rendered diff. */ interface DiffDetails { mode: "diff"; target: string; provider: ProviderName; format: ArchiveDiffFormat; context: number; options: Omit & { before: string; after: string; }; success: boolean; attempts: DiffAttempt[]; result?: Omit; /** SHA-256 of the complete generated patch. */ digest?: string; characters: number; offset: number; endOffset: number; hasMore: boolean; nextOffset?: number; continuation?: Readonly; clipped: boolean; } /** One provider row, as listed by {@link listArchiveProviders}. */ interface ProviderStatus { name: ProviderName; factory: string; includedInAll: boolean; requiresApiKey: boolean; configured: boolean; note: string; } /** Every built-in provider and whether it is usable on this machine. */ interface ProvidersDetails { providers: ProviderStatus[]; } /** * Queries one provider (or every provider in `all`) for archived snapshots. * * @param params - Tool arguments; `target` is a domain or URL * @returns {Promise>} Rendered snapshot list plus the raw response * @throws {Error} When the target is empty, the provider is unknown, or its prerequisites are missing * * @param signal - Signal. */ declare function snapshotArchives(params: Readonly, signal?: Readonly): Promise>; /** * Reads the body of one archived capture. * * The listing tools say which captures exist; this one answers what the page * said, which is the step a caller otherwise has to take outside the archive. * A plain fetch of a playback URL returns the archive's own framing rather than * the capture. * * @param params - Tool arguments; `target` is a URL, archived or original * @returns {Promise>} The rendered body plus the capture it came from * @throws {Error} When the target is empty, an argument is out of range, the provider is * unknown, or its prerequisites are missing * * @param signal - Signal. */ declare function contentArchives(params: Readonly, signal?: Readonly): Promise>; /** * Reads and compares two chronological captures from one archive provider. * * Provider fan-out is sequential: a patch is emitted only when one provider * produced both bodies. Mixing one archive's earlier capture with another's * later capture would make rewriting specific to an archive look like a site change. * * @param params - Tool arguments naming the target and two capture instants. * @param signal - Cancels in-flight archive requests. * @returns {Promise>} A bounded unified diff plus exact capture provenance. * @throws {Error} When an argument is invalid or outside its accepted range. */ declare function diffArchives(params: Readonly, signal?: Readonly): Promise>; /** * Lists the built-in providers, their `provider=all` membership, and Perma.cc key state. * * @returns {ToolResult} The operation result. */ declare function listArchiveProviders(): ToolResult; /** * Wayback-only lookup backing the interactive `/archive` command. * * @param target - Target. * @param limit - Limit. * @returns {Promise} A promise resolving to the operation result. */ declare function waybackSnapshots(target: string, limit?: number): Promise; /** * Resolves a user-supplied provider name, accepting the kebab-case spellings. * * @param provider - Provider. * @returns {ProviderName} The operation result. */ declare function normalizeProvider(provider: string | undefined): ProviderName; /** * Resolves the requested rendering, rejecting a spelling no surface offers. * * @param format - Format. * @returns {ContentFormat} The operation result. */ declare function normalizeFormat(format: string | undefined): ContentFormat; /** * Strips private runtime state before options reach a transcript or a tool result. * * @param options - Options. * @returns {Omit & { apiKey?: "" }} The operation result. */ declare function redactOptions(options: TOptions): Omit & { apiKey?: ""; }; /** * Removes terminal control bytes that provider-supplied text could smuggle into a TUI. * * @param text - Text. * @returns {string} The resulting string. */ declare function sanitizeTerminalText(text: string): string; /** * Reduces an error of unknown shape to one safe line. * * @param error - Error. * @returns {string} The resulting string. */ declare function errorMessage(error: unknown): string; /** * Names why a response carries no usable pages. * * @param response - Response. * @returns {string} The resulting string. */ declare function responseFailureMessage(response: ArchiveResponse): string; /** * Renders one archived page as the three lines every surface shows. * * Every interpolated field is provider-supplied and goes through * {@link sanitizeField}: a newline inside a URL would otherwise close the record * and forge a second entry that reads exactly like a real snapshot. * * @param page - Page. * @param index - Index. * @returns {string} The resulting string. */ declare function formatPage(page: ArchivedPage, index?: number): string; /** * Reduces one untrusted field to a single line with no terminal control bytes. * * @param value - Value. * @returns {string} The resulting string. */ declare function sanitizeField(value: string): string; /** * Renders one provider row of {@link listArchiveProviders}. * * @param status - Status. * @returns {string} The resulting string. */ declare function formatProviderStatus(status: Readonly): string; /** * Collapses whitespace and clips text to `maxLength`, for one-line call previews. * * @param text - Text. * @param maxLength - Max Length. * @returns {string} The resulting string. */ declare function truncateSingleLine(text: string, maxLength: number): string; export { CONTENT_FORMATS, CONTENT_FORMAT_HINT, CONTENT_PROVIDER_HINT, ContentContinuation, ContentDetails, ContentFormat, ContentOptions, ContentParams, DEFAULT_CONTENT_TIMEOUT, DEFAULT_DIFF_CONTEXT, DEFAULT_LIMIT, DEFAULT_MAX_CHARS, DiffAttempt, DiffContinuation, DiffDetails, DiffParams, MAX_CONTENT_CHARS, MAX_CONTENT_OFFSET, MAX_DIFF_CONTEXT, MAX_DIFF_OFFSET, MAX_LIMIT, MAX_PARAMETER_LENGTH, MAX_RETRIES, MAX_TARGET_LENGTH, MAX_TIMEOUT, MAX_TIMESTAMP_LENGTH, MAX_TTL, PERMACC_API_KEY_ENVS, PROVIDERS, PROVIDER_ALIASES, PROVIDER_HINT, PROVIDER_INPUTS, ProviderInput, ProviderName, ProviderStatus, ProvidersDetails, RedactedContentOptions, RedactedSnapshotOptions, SNAPSHOT_FROM_HINT, SNAPSHOT_TO_HINT, SnapshotDetails, SnapshotOptions, SnapshotParams, ToolResult, contentArchives, diffArchives, errorMessage, formatPage, formatProviderStatus, listArchiveProviders, normalizeFormat, normalizeProvider, redactOptions, responseFailureMessage, sanitizeField, sanitizeTerminalText, snapshotArchives, truncateSingleLine, waybackSnapshots };