import { type RedactionMark, type RedactionReport, type SummarizableFinding } from "@sema-agent/primitives";
export type { RedactionFinding, RedactionReport, RedactionConfidence, RedactionSource, SummarizableFinding } from "@sema-agent/primitives";
/** Render findings as ONE human-readable line, e.g. `"3 redactions: prefixed-token (high) x1, url (medium) x1, fs-path (low)
 *  x1"`, so an upper layer can declare to its consumer how much was removed and how confidently.
 *
 *  PURE, and deliberately only that: it reads the array, returns a string, and injects nothing anywhere. Attaching this
 *  line to an output is the caller's decision — a redaction pipeline that silently appended prose to the very text it was
 *  asked to bound would break both the size contract (`boundedString`) and the byte-invariance the whole channel is built
 *  on.
 *
 *  Grouping is by kind AND confidence together: collapsing on kind alone would report whichever confidence happened to
 *  arrive first for the rest of that group, a silent mis-statement of how sure the removals were. */
export declare function summarizeRedactions(findings: readonly SummarizableFinding[]): string;
/**
 * Every exit that redacts — into a model's context, a host's event or error lane, a log line, a person's screen — does it
 * with ONE pass, its tier's, and nothing else redacts: a text through {@link egressText}, a thrown value's text through
 * {@link egressThrownText}, a value with members (a thrown error, a marks bag) through {@link egressValue}, which runs the
 * same pass over every string member. What comes out is an {@link Egress}: a string the type checker knows came out of
 * that tier. What a tool RETURNS is its content, read by the model that asked for it, and is not redacted (CC redacts
 * nothing there either); what is redacted is what the engine itself words or carries: errors, summaries, run rows.
 *
 * Two tiers, because the faces have two audiences:
 *  - **`same-principal`** — the model, the script and the host that launched the work (tool results, workflow agent
 *    outputs / results / errors, run rows behind the scope-gated observe API, host error lanes): the credential
 *    vocabulary only. Paths and URLs in a worker's answer are the caller's OWN machine's paths — redacting them killed the
 *    cross-agent assertion pattern ("return the file you wrote" → `«redacted:path»`) while protecting no one;
 *    cross-tenant isolation on these faces is ACCESS CONTROL (scope gates), not string surgery. CC redacts nothing here;
 *    sema keeps the credential pass as a declared superset.
 *  - **`human`** — text shown to a person or exported beyond the launching principal: the credential vocabulary plus
 *    every URL and absolute path — host internals, and exfil-lure links in untrusted text.
 * {@link untrustedEgressForHuman} additionally FENCES its text (design/97 CORE-2), so untrusted content cannot pose as
 * instructions to its reader.
 */
export type EgressTier = "same-principal" | "human";
declare const EGRESS_TIER: unique symbol;
/** A string that came out of tier `T`'s pass. Only this module mints one. */
export type Egress<T extends EgressTier> = string & {
    readonly [EGRESS_TIER]: T;
};
/** Tier `tier`'s one pass over a text. A report's `preexistingMarkers` counts the marks ({@link REDACTION_MARKS}) already in
 *  the text. */
export declare function egressText<T extends EgressTier>(tier: T, text: string, report?: RedactionReport): Egress<T>;
/** The egress pass's credential vocabulary over `text` (the `same-principal` tier's pass): what it renders, and the spans of `text` it
 *  withholds, as [start, end) in `text`'s coordinates with the member each hit wrote — the renderer's own account of what it took
 *  (every hit of every pass, read as written and with its format characters removed, a later pass's over the words an earlier one's
 *  mark left, each mapped back to the text), each less the head and tail its own rendering keeps around the mark (`x-api-key: `
 *  stays, the value is what goes; a hit its rendering keeps nothing of is taken whole); a stretch the pass could not read, as the
 *  `oversized` member, whole. */
export declare function egressCredentialReading(text: string): {
    readonly rendered: string;
    readonly spans: Array<readonly [number, number, RedactionMark]>;
};
/** The parts of `text` the egress pass's credential vocabulary reads as credentials, as [start, end) in `text`: every hit its
 *  scanner reads, as written and with its format characters removed (a hit another one holds included — `Basic <x>` inside
 *  `Basic <x>-<y>`, so `<x>` standing alone elsewhere is a credential too), with the renderer's own account
 *  ({@link egressCredentialReading}: a later pass's hit over the words an earlier mark set apart); a stretch either could not read
 *  among them. A reader that carries the text in another spelling (folded to one line) takes these out of that spelling, where they
 *  stand and wherever else their values do. */
export declare function egressCredentialFinds(text: string): Array<readonly [number, number]>;
/**
 * THE one cut of foreign words that arrive a line at a time and are judged as they arrive (an MCP server's stderr, `mcp-stderr-lines.ts`):
 * how much of what is not yet shown may be shown now, and what it reads as. `text` is what is not yet shown, after the last characters
 * already judged (`text[0, from)`: read for what begins there, never shown again); it ends at a line's end, or anywhere when `final` (no
 * words follow).
 *
 * The finds are read over the whole of `text`: the credential reading's ({@link egressCredentialFinds}) and what the one-line spelling
 * alone finds ({@link oneLineFinds}). Whether a find runs across lines is the vocabulary's business, never the reader's. The cut is the
 * furthest line start at or after `from` (the end counting as one) that no find runs across and before which no find begins that reaches
 * into `text`'s last line — such a find may go on in the words that come next (a key block's banner holds every line after it until its
 * footer), so it is held from where it begins, from `from` when it began in the judged words, until a later line ends it. With `final`
 * the cut is the end. `shown` is `text[from, cut)` with every find's part inside it withheld where it stands — one that began in the
 * judged words, and a value whose label stands there, included — then the tier's pass. `open` is where the earliest find that runs to
 * `text`'s very end begins (none: `undefined`): the words that follow may still be part of it — the reader that must let go of what it
 * holds keeps the line it begins on, so what follows is still read as that find's (`from` at `text`'s end reads `open` alone, showing
 * nothing).
 */
export declare function egressSafeCut(text: string, from: number, final: boolean): {
    readonly cut: number;
    readonly shown: Egress<"same-principal">;
    readonly open: number | undefined;
};
/**
 * THE reading of a foreign text's words in their one-line spelling ({@link foldToOneLine}) for a reader that carries them as
 * written: what the egress scanner reads in the one-line spelling that it does not read in the written words, as [start, end)
 * spans of `text` — each at the written code units whose places fall inside it. The fold puts a token beside the scheme word a line
 * break kept it from (`Authorization: Negotiate` LF `<token>`: the written words read the scheme word as the header's whole value
 * and stop at the break), and an exit that folds the carried words later finds nothing to join (the mark the written pass left
 * hides the token). None where the fold changes nothing or finds nothing more. The scanner's spans on both sides, not the
 * renderer's account ({@link egressCredentialFinds}, a rendering per hit), and the written words are scanned only when a one-line
 * find is one the fold changed (its words, or the character before them: `Authorization:` LF `<token>`): a dense body whose finds
 * the fold leaves as they are costs one scan more. Its readers: `remoteWords` (a remote endpoint's words, with its request's declared values), {@link egressThrownText} and {@link egressSafeCut}.
 */
export declare function oneLineFinds(text: string): Array<readonly [number, number]>;
/** The text a thrown value reads as (`thrownText`), through {@link egressForeignText}: the one form a thrown value's words take
 *  on their way out of the engine. */
export declare function egressThrownText<T extends EgressTier>(tier: T, err: unknown): Egress<T>;
/** A foreign text through tier `tier`'s pass, its lines kept — the multi-line form of a foreign party's words in this layer: what its
 *  one-line spelling alone finds ({@link oneLineFinds}) is withheld where it stands first, in one rendering with the vocabulary's own
 *  finds (one region, one mark). {@link egressThrownText} and {@link redactThenCut} read it. */
export declare function egressForeignText<T extends EgressTier>(tier: T, text: string): Egress<T>;
/** The `same-principal` tier's pass, under the name hosts call it by (the engine calls {@link egressText}). */
export declare function redactSecrets(s: string, report?: RedactionReport): Egress<"same-principal">;
/** Hard-bound a line to `max` UTF-16 units — a pure prefix, no marker appended. When the cut would split a
 *  redaction marker, it moves back to the marker's start (the bound holds, and the output never shows a
 *  marker fragment); when it would split a surrogate pair, it moves back one unit (never a lone surrogate). */
export declare function cutAt(line: string, max: number): string;
/**
 * Redact, THEN bound — the one cut of a foreign text that keeps its lines (a thrown value's text, a step's outcome, a steering
 * preview): the `same-principal` pass, as written and with what its one-line spelling alone finds ({@link egressForeignText}), on
 * the words a bounded form reads ({@link boundedForeignReading}), then {@link cutAt}, so a cut never leaves part of a credential
 * the pass would have read whole. A cut is a pure prefix, as {@link cutAt} writes it; words that went on past what was read end in
 * the cut mark, within `max` (the reader is told the words were cut where a word was left out). Keeps
 * newlines: a multi-line body is the caller's shape; only the bound and the redaction are this function's. Words that go onto one
 * line take `foreignLine` (protocol-http-auth.ts).
 */
export declare function redactThenCut(s: string, max: number): string;
/** The longest credential a bounded form of foreign words must read whole: 32 KiB. The longest a vocabulary row reads only whole
 *  is a private key block — an RSA 8192 key's PEM is 6 392 characters (PKCS#8, generated and measured), an RSA 16384 key's about
 *  12 600 by its DER size — so 32 KiB is about two and a half of the largest. Twice it (64 KiB, the read cap of a model provider's
 *  error body, `ERROR_BODY_BYTE_CAP`) plus the shown length is what a bounded form reads at most; any text up to that reads whole. */
export declare const FOREIGN_WINDOW_MARGIN = 32768;
/** The most code units of foreign words an exit that reads them whole reads (the provider's sentence, an MCP server's failure
 *  record): 256 KiB. An ordinary long text within it (a 100 KiB stack trace) is read and shown as 7.68.3 showed it; the worst shape
 *  at it (dense credentials) costs about 2.5 times 7.68.3's worst at that length, 2.2–4.2 times shape by shape (three trees, measured). */
export declare const FOREIGN_WHOLE_MAX = 262144;
/** What an exit that reads foreign words whole writes in their place when they are longer than {@link FOREIGN_WHOLE_MAX}
 *  ({@link unreadWords}); `undefined` for words within the bound. */
export declare function pastWholeReading(text: string): string | undefined;
/**
 * THE one reading of foreign words an exit shows only the head of (`foreignLine`, {@link redactThenCut}, a disclosed rule text):
 * `read` — the credential pass of that exit's spelling — runs on a window of the words, so its cost follows what is shown, not
 * what arrived. Words no longer than `shown` + 2 × {@link FOREIGN_WINDOW_MARGIN} are read whole. Longer words are read twice —
 * their first `shown` + 2 × margin code units and their first `shown` + margin — and what is shown is the part both readings say
 * alike (never half a mark, never half a surrogate pair), which the caller then cuts to `shown`.
 *
 * Why two readings: a credential the window's end cuts is at most a margin long, so it starts after the shorter reading's end and
 * none of it is in the part both say alike; a credential the shorter reading's end cuts is read whole by the longer one, so the
 * two readings part at its start, and what is shown stops before it — however far the redaction of a long value before it pulled
 * the later words forward.
 *
 * And a bounded reading does not show a word it did not read to its end: where the part both say alike stops, if the longer reading
 * goes on with a character that is not white space, the run of such characters the part ends in is not part of the window's head
 * — whether the part is the whole shorter reading or the two parted inside that run. A word longer than the margin that the
 * vocabulary knows only whole (a URL's userinfo is read only with the `@host` after it) is cut by both readings, and both write it
 * as it stands, or part somewhere inside it. Ordinary words are not touched: the shorter reading ends a margin past the shown head,
 * so only a run the readings did not both finish, reaching back into the head, is left out. `dropped` says the words went on past
 * the window; the caller ends such words in its cut mark.
 *
 * The window's reach is all a bounded form reads: what it shows of longer words is the window's head, however short (a sentence
 * before a long run with no white space is shown and ends in the cut mark). Where that head holds no word at all — a run not read to
 * its end from the first character on (a JSON or base64 body with no white space, that URL) — the words are not read: the oversized
 * mark and their length stand for them ({@link unreadWords}), as past {@link FOREIGN_WHOLE_MAX} on the exits below.
 *
 * An exit whose pass withholds a value it finds anywhere in the words wherever else it stands reads them whole always — the
 * provider's sentence (`foreignLine`'s `whole`) and an MCP server's failure record: a window there would show a value written bare
 * in the head and labeled only past the window, which those exits withheld before 7.69.0. Up to {@link FOREIGN_WHOLE_MAX} their
 * cost follows what arrived; past it the words are not read ({@link pastWholeReading}).
 */
export declare function boundedForeignReading(text: string, shown: number, read: (words: string) => string): {
    readonly words: string;
    readonly dropped: boolean;
};
/** THE whole reading of foreign words (the exits that read whole): `read` on all of them up to {@link FOREIGN_WHOLE_MAX}, past it
 *  the words are not read and {@link pastWholeReading}'s mark stands for them. */
export declare function wholeForeignReading(text: string, read: (words: string) => string): string;
/** The `human` tier's pass, under the name hosts call it by (the engine calls {@link egressText}). */
export declare function redactHostLeaks(s: string, report?: RedactionReport): Egress<"human">;
/**
 * Tier `tier`'s pass over every string member of `value`, returned as a DATA SNAPSHOT — never the value itself, so nothing
 * that leaves can run the value's code again (a getter, a serializer, a proxy trap): a host's serializer, a log's inspector
 * and the loop's own readers (`thrownText`, `thrownMarksOf`) reach what was read, once, and passed. The rules, one each:
 *  - a string goes through {@link egressText}, and so does every member NAME; a function is code, not data, and is not
 *    carried at any depth (the value handed in included: it comes back `undefined`); any other primitive is itself;
 *  - an error (any realm, any class) is re-minted as a plain `Error` — never on the thrown value's prototype, whose
 *    serializers and accessors would run again — carrying EVERY own member (`message`, `stack`, `cause`, `errors`,
 *    `details`, `code` …) and its `name`, `message`, `code` and `stack` read once through its chain, all as own data;
 *  - any other object is what JSON reads: its `toJSON(name)` when it has one (a `URL` is its `href`, a `Date` its ISO
 *    text; one that answers itself is read for its members), otherwise its own enumerable members; an array is its slots
 *    up to its `length`, a hole among them;
 *  - a member whose name is a credential name (the vocabulary's record-key view: `password`, `Authorization`,
 *    `x-api-key`) and whose reading is a string is the marker whole;
 *  - every read the walk makes of the value counts against one bound — a listed member, an array slot (a hole included),
 *    an array's `length`, an error's chain member — and the first one past it stands as {@link PAST_THE_BOUND} under its
 *    own name (an array's slot for a slot), an enumerable member whatever the unread one was, nothing after it in its
 *    container read; the members are listed once (`Reflect.ownKeys`) and each is asked for only within the bound;
 *  - a value nested past the depth bound, one whose members cannot be listed and one whose `toJSON` throws stand as their
 *    {@link notRecordedMark};
 *  - shared members stay shared on the snapshot; a member that points back at an object the reading is still inside — a cycle, which no
 *    serializer can write — stands as the cycle {@link notRecordedMark} where it points back.
 */
export declare function egressValue<T extends EgressTier, V>(tier: T, value: V): V;
/**
 * Tier `tier`'s pass over an engine ACCOUNT value — a notice's detail, a trace frame: data the engine shaped, carrying words that may have
 * come from a host, a store or a remote. Returned as a new value, never the one handed in. The rules, one each:
 *  - a string, at any depth, goes through {@link egressText};
 *  - a member NAME of plain data is the engine's own closed word and is kept as written (a detail's `key` or `tokenCount` is not a
 *    credential name, and reading it as one would blank the engine's own facts);
 *  - plain data is an array or an object whose prototype is `Object.prototype` or `null`, and is not a proxy (whose traps answer what
 *    they choose, a fresh value at every read included); its own enumerable members are read once, a function member is code and is
 *    not carried; an array keeps its `length`, a trailing hole included, up to {@link holeCut}'s bound on its holes (past it the slots end
 *    where the bound does, and the mark names the length);
 *  - any other object (an error, a class instance, a `Map`, a `Date`, a proxy) came from elsewhere and leaves as
 *    {@link egressValue} reads it — there, and only there, a credential-named member's string is the marker whole, and there, and
 *    only there, a member bound applies (one per such value);
 *  - no member bound applies to plain data: the account is the engine's own, and its size is the engine's to answer for;
 *  - one walk, the engine's data first: every value from elsewhere it meets (a getter's answer included) is read after the plain
 *    data is, so an object the data reaches is the data's reading, carried whole, whatever reached it first; an object reached twice
 *    is read once and answers one snapshot (shared members stay shared; a member that points back at an object the reading is still inside is the cycle mark); past {@link VALUE_DEPTH_MAX} the depth's
 *    {@link notRecordedMark} stands in.
 * Every pass it runs is a fixed point, so an account value minted twice reads the same.
 */
export declare function egressAccount<T extends EgressTier, V>(tier: T, value: V): V;
/** The `same-principal` tier's pass + size-bound (NO injection fence): workflow outputs/results/errors riding back to
 *  the launching model/script, run rows behind scope-gated observe. Paths/URLs survive (the assertion pattern depends on
 *  them); secrets never do. */
export declare function boundedRedactedSummary(value: unknown, max: number): Egress<"same-principal">;
/**
 * The FULL untrusted-egress transform (design/97 CORE-2): the `human` tier's pass + size-bound + FENCE. Use
 * for any worker prompt/output (#5 transcript) or steer content (#6) shown to a HUMAN or exported beyond the
 * launching principal, so untrusted text can neither leak host internals nor pose as instructions.
 */
export declare function untrustedEgressForHuman(value: unknown, opts: {
    label: string;
    max: number;
}): Egress<"human">;
