import { ArchiveContentOptions, ArchiveContentResponse, ArchiveDiffFormat, ArchiveOptions, ArchiveResponse, ArchivedContentDiff, ArchivedPage } from "./types.mjs"; /** Provider spellings, hints and bounds the tools declare. No imports, so tools.ts stays light. */ /** Provider names accepted in tool arguments; `auto` resolves to `all`. */ export declare const PROVIDERS: readonly ["auto", "all", "wayback", "arquivo", "webarchiv", "vefsafn", "oszk", "nlnz", "archiveIt", "conifer", "archiveToday", "memento", "commoncrawl", "webcite", "permacc"]; /** Kebab spellings accepted alongside the camelCase names. */ export 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. */ export declare const PROVIDER_INPUTS: readonly ["auto", "all", "wayback", "arquivo", "webarchiv", "vefsafn", "oszk", "nlnz", "archiveIt", "conifer", "archiveToday", "memento", "commoncrawl", "webcite", "permacc", ...("archive-it" | "archive-today")[]]; export type ProviderInput = (typeof PROVIDERS)[number]; export type ProviderName = Exclude; export declare const PROVIDER_HINT = "Provider to use. \"auto\" (or omit) uses \"all\", which queries Wayback, Arquivo.pt, Webarchiv Österreich, Vefsafn, OSZK Webarchívum, the New Zealand Web Archive, Archive.today, Common Crawl, and WebCite. Webarchiv Österreich and Vefsafn each search one exact URL through a public CDX 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."; export declare const CONTENT_PROVIDER_HINT = "Provider to read from. \"auto\" (or omit) uses \"all\", which tries Wayback, Arquivo.pt, Webarchiv Österreich, Vefsafn, OSZK Webarchívum, Archive.today, and Common Crawl. Memento reads the selected TimeMap URI directly and uses MemGator's proxy as fallback. Wayback, Arquivo.pt, Webarchiv Österreich, Vefsafn and OSZK Webarchívum 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 the New Zealand Web Archive keeps its replay behind a browser check; all four answer as unsupported."; /** Rendering of the archived body: readable text, or decoded text with markup intact. */ export declare const CONTENT_FORMATS: readonly ["text", "raw"]; export type ContentFormat = (typeof CONTENT_FORMATS)[number]; export 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."; /** Most targets one snapshot call looks up, the batch cap agntn/web uses too. */ export declare const MAX_SNAPSHOT_TARGETS = 10; export declare const SNAPSHOT_TARGET_HINT = "Domain or URL to search for archived snapshots, or a list of up to 10 of them looked up with the same options."; export 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."; /** Ends of a page's history a listing can start from. */ export declare const CAPTURE_ORDERS: readonly ["newest", "oldest"]; export declare const SNAPSHOT_ORDER_HINT = "Which end of the page's history the limit keeps, newest or oldest, listed in that order. Needs a page URL with its scheme (https://example.com/ for a home page): a bare domain lists page by page, not by time. Omitted, a single provider answers in its own order and provider=all newest first."; export 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."; export declare const DEFAULT_LIMIT = 10; export declare const MAX_LIMIT = 100; export declare const DEFAULT_MAX_CHARS = 20000; export declare const MAX_CONTENT_CHARS = 200000; export declare const DEFAULT_DIFF_CONTEXT = 3; export declare const MAX_DIFF_CONTEXT = 100; /** Variable naming the directory archives_content writes capture files into. */ export declare const CAPTURE_DIR_ENV = "ARCHIVES_CAPTURE_DIR"; export declare const MAX_PATH_LENGTH = 1024; export declare const CONTENT_PATH_HINT = "File to write the capture's bytes to, with transfer and content encodings undone, so the sha256 line is the file's hash. Relative to ARCHIVES_CAPTURE_DIR, or to the working directory when it is unset. The path must stay inside that directory and must not exist yet. A body longer than 2000000 bytes is not written."; /** Largest UTF-16 position accepted within the fixed fetched prefix. */ export declare const MAX_CONTENT_OFFSET = 2000000; /** Largest position in a derived patch, which can contain both complete bodies. */ export declare const MAX_DIFF_OFFSET: number; export declare const MAX_TIMESTAMP_LENGTH = 32; /** Timeout one content call asks for when the caller names none. */ export declare const DEFAULT_CONTENT_TIMEOUT = 30000; export declare const MAX_TARGET_LENGTH = 2048; export declare const MAX_PARAMETER_LENGTH = 256; export declare const MAX_TTL: number; export declare const MAX_RETRIES = 10; export declare const MAX_TIMEOUT: number; export declare const PERMACC_API_KEY_ENVS: readonly ["PERMA_CC_API_KEY", "PERMACC_API_KEY"]; declare namespace tool_operations_d_exports { export { CAPTURE_DIR_ENV, CAPTURE_ORDERS, CONTENT_FORMATS, CONTENT_FORMAT_HINT, CONTENT_PATH_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_PATH_LENGTH, MAX_RETRIES, MAX_SNAPSHOT_TARGETS, 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_ORDER_HINT, SNAPSHOT_TARGET_HINT, SNAPSHOT_TO_HINT, SnapshotBatchDetails, SnapshotBatchItem, SnapshotBatchParams, SnapshotDetails, SnapshotOptions, SnapshotParams, ToolResult, contentArchives, diffArchives, errorMessage, formatPage, formatProviderStatus, listArchiveProviders, normalizeFormat, normalizeProvider, redactOptions, responseFailureMessage, sanitizeField, sanitizeTerminalText, snapshotArchives, snapshotBatchArchives, truncateSingleLine, waybackSnapshots }; } /** One text block plus the details a harness renders next to it. */ export interface ToolResult { content: Array<{ type: "text"; text: string; }>; details: TDetails; /** Set when the operation ran but produced no usable answer. */ isError?: boolean; } /** Options passed to a provider factory, including the provider-specific extras. */ export 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. */ export type RedactedSnapshotOptions = Omit & { apiKey?: ""; }; /** Options passed to a provider factory for a content read. */ export type ContentOptions = ArchiveContentOptions & { apiKey?: string; collection?: string; user?: string; }; /** Content options as they reach a harness transcript: never carrying the key. */ export type RedactedContentOptions = Omit & { apiKey?: ""; }; /** Arguments of the snapshot tool, shared by every surface's schema. */ export interface SnapshotParams { target: string; provider?: string; limit?: number; order?: string; 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. */ export interface SnapshotDetails { mode: "snapshots"; target: string; provider: ProviderName; options: RedactedSnapshotOptions; count: number; response: ArchiveResponse; } /** Snapshot arguments as the tools take them: one target or a batch. */ export type SnapshotBatchParams = Omit & { target: string | readonly string[]; }; /** One target's answer in a batch. */ export interface SnapshotBatchItem { target: string; count: number; response: ArchiveResponse; } /** A batch lookup: shared provider and options, one item per target in input order. */ export interface SnapshotBatchDetails { mode: "snapshots-batch"; provider: ProviderName; options: RedactedSnapshotOptions; items: SnapshotBatchItem[]; } /** Arguments of the content tool, shared by every surface's schema. */ export 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; /** File to write the capture's bytes to, inside the capture directory. */ path?: string; } /** The capture that was read, plus how much of it the caller received. */ export interface ContentContinuation { target: string; provider: string; timestamp: string; format: ContentFormat; collection?: string; offset: number; } export 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; /** File the capture's bytes were written to. */ path?: string; response: ArchiveContentResponse; } /** Arguments of the capture diff tool, shared by every surface's schema. */ export 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. Ignored at offset 0. */ digest?: string; } /** One provider's reason for not producing a comparable capture pair. */ export interface DiffAttempt { provider: string; error: string; } /** Arguments pinned to the exact pair behind the following diff slice. */ export 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. */ export 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}. */ export 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. */ export 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. */ export declare function snapshotArchives(params: Readonly, signal?: Readonly): Promise>; /** * Looks up snapshots for one target or a batch of them, as the snapshot tool does. * * A single target answers exactly like {@link snapshotArchives}. A batch shares one * provider and one set of options, keeps provider requests within `concurrency`, and * answers with one block per target in input order, so a target no provider * answered costs its own block and not the call. The call is marked failed only * when no target got an answer. * * @param params - Tool arguments; `target` is a domain or URL, or a list of up to * {@link MAX_SNAPSHOT_TARGETS} of them * @param signal - Signal. * @returns {Promise>} Rendered blocks plus the raw responses * @throws {Error} When a target is empty, the batch is empty or too long, the provider is unknown, its prerequisites are missing, or the window is inverted */ export declare function snapshotBatchArchives(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. */ export 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. */ export 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. */ export 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. */ export 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. */ export 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. */ export 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. */ export 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. */ export declare function sanitizeTerminalText(text: string): string; /** * Reduces an error of unknown shape to one safe line. * * @param error - Error. * @returns {string} The resulting string. */ export declare function errorMessage(error: unknown): string; /** * Names why a response carries no usable pages. * * @param response - Response. * @returns {string} The resulting string. */ export declare function responseFailureMessage(response: ArchiveResponse): string; /** * Renders one archived page as the lines every surface shows. The original URL * gets its own line only when the snapshot address does not already end with it. * * 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. */ export 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. */ export declare function sanitizeField(value: string): string; /** * Renders one provider row of {@link listArchiveProviders}. * * @param status - Status. * @returns {string} The resulting string. */ export 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. */ export declare function truncateSingleLine(text: string, maxLength: number): string; export { tool_operations_d_exports };