/** * Dispatch: classify a block, then hand it to the engine that fits. * * NO INSTANCE STATE, AND THAT IS THE WHOLE DESIGN. HeadRoom's open issue #3486 * is "Concurrent requests cross-contaminate compression options -- one shared * `ContentRouter` stores per-request state on `self`". A proxy is concurrent by * definition: two agents, or one agent with parallel tool calls, are two * requests in flight through the same router at the same time. Per-request * state on a shared object means request A's options silently decide how * request B's content is compressed. * * The fix is not care, it is shape. Everything here is a pure function of * (text, context). There is no object to hold state on, so the bug is not * something we avoid -- it is something that cannot be written. * * THE BUILT-INS REGISTER LIKE ANYBODY ELSE'S. They are ordinary registry * entries, so there is one dispatch path to test and a custom engine can claim * content ahead of them. What used to be the order of a `switch` is now * priority, which makes the reasoning explicit: * * diff 70 its hunks ARE the content; nothing may elide them * json 60 before prose, since a pretty-printed payload of English * strings reads as wordy lines * search 50 grep output carries source lines AND timestamps, so both * code and log would claim it and then find nothing * log 40 * code 30 * prose 10 the most permissive claim of the content engines * records 5 a SHAPE, not a kind, so it goes last of all: it may only * see text every engine above deliberately declined */ import type { CompressionResult, ContentKind, EngineContext } from './types.js'; /** Built-in names, so a caller can tell ours from a third party's. */ export declare const BUILT_IN_ENGINES: readonly string[]; /** * What kind of content this is. * * Answers with the winning engine's name, so a custom engine appears in a * report rather than being invisible. */ export declare function classify(text: string, ctx?: EngineContext): ContentKind; /** The engine that would handle this block, built-in or not. */ export declare function engineNameFor(text: string, ctx?: EngineContext): string | null; /** * Compresses one block. * * Two things happen here that `routed` deliberately does not do: a numbered * read is stripped, compressed and renumbered, and whatever survives is * offered to the long-repeat fold. * * THE FOLD RUNS LAST AND ONLY AT THE TOP. Last, because it should see what * the engine left rather than what it was given -- an engine that already * removed the second copy leaves nothing here to find, and one that could not * reach inside a line leaves the whole of it. Only at the top, because a * string inside a JSON document is routed back through here with a depth, and * a marker folded into a nested value would be re-escaped by the document * around it and read back through a different grammar than the one that wrote * it. `movable` draws the same line for the same reason. * * The fold is offered the ORIGINAL text as well, so a block no engine claimed * is still eligible: an unclaimed block is the one most likely to be a large * opaque payload sent twice. */ export declare function compressBlock(text: string, ctx?: EngineContext): CompressionResult; //# sourceMappingURL=router.d.ts.map