/** * The capture envelope (RCL-07) — provenance as a first-class record. * * Every capture, wherever it came from, lands in one directory: * * page.mhtml byte-fidelity archive (CDP Page.captureSnapshot) * page.pdf optional print fidelity * readable.md Readability-cleaned Markdown — what gets chunked * screenshot.png full-page, for the document card * meta.json provenance (this module) * * EVERYTHING HERE IS DEFENSIVE. `meta.json` is written by a browser extension * on a machine we do not control; it can be absent, truncated mid-write, * half-populated by an adapter that bailed, or carry a `tags` that is a string * instead of an array. None of that may fail an ingest: a document with no * provenance is worth indexing, a failed ingest is worth nothing. Every reader * below returns a value or null and never throws. * * @module v1/cli/knowledge/capture-envelope */ export declare const ENVELOPE_META_FILE = "meta.json"; export declare const ENVELOPE_READABLE_FILE = "readable.md"; /** Envelope members, best representation first. */ export declare const ENVELOPE_DOCUMENTS: readonly ['readable.md', 'page.html', 'page.htm', 'page.xhtml', 'page.mhtml', 'page.mht', 'page.pdf']; export interface CaptureProvenance { url?: string; canonicalUrl?: string; title?: string; byline?: string; publishedAt?: string; capturedAt?: string; httpStatus?: number; /** Hash of the captured RAW bytes, as written by the capturer. Document * identity keys on the EXTRACTED text hash instead — see document-pipeline * — because two byte-different archives of one unchanged article are the * same document. */ contentHash?: string; favicon?: string; note?: string; selection?: string; tags?: string[]; collection?: string; /** `extension` | `monobrowse` | `crawl`, per the capture contract. */ source?: string; /** The mono-agent profile this capture was filed into, when it named one. * It decides which store ingests the capture (knowledge/profile-store), * so an id that could not be a directory name is dropped here rather * than carried into the index. */ profile?: string; } /** Keep only keys we understand, coerced to the declared type. An unknown or * wrong-typed field is dropped rather than carried into the index. */ export declare function normalizeProvenance(raw: unknown): CaptureProvenance | null; /** Read and normalize the `meta.json` sitting next to `filePath`. Returns null * when there is none, it is unreadable, oversized, or not valid JSON. */ export declare function readCaptureProvenance(filePath: string): CaptureProvenance | null; /** True when `dir` looks like a capture envelope rather than an ordinary * folder that happens to contain HTML. */ export declare function isCaptureEnvelope(dir: string): boolean; /** * The `readable.md` that supersedes `filePath`, or null. * * WHY IT WINS — `readable.md` was produced by Readability against the LIVE * DOM, with lazy images resolved, the consent modal dismissed and the site's * own JS having finished. Re-deriving text from the archived markup can only * be worse. The archive is kept for fidelity; the readable pass is kept for * meaning, and meaning is what gets chunked. * * Guarded so a plain directory of HTML files that happens to hold one * `readable.md` does not collapse to a single document: either the directory * is a real envelope (it has `meta.json`) or the file is the envelope's * `page.*`. */ export declare function readableSiblingFor(filePath: string): string | null; /** The envelope member that should represent `dir` as a document, or null when * `dir` is not an envelope. */ export declare function envelopePrimaryDocument(dir: string): string | null; /** * The identity URL for dedupe: `canonicalUrl` when the capturer resolved one, * otherwise `url`. The fragment is dropped — `#section-3` is a scroll * position, not a different document — and nothing else is rewritten, because * query strings and trailing slashes DO distinguish pages on real sites. */ export declare function captureIdentityUrl(meta: CaptureProvenance | null | undefined): string | undefined; //# sourceMappingURL=capture-envelope.d.ts.map