/** * What a page's OWN conversation — or a conversation whose page switch is off — * never receives (common-docs context-delivery RULES.md §0). * * Arman, 2026-10-01: the agent in a battle "cannot and should not know its own * conversation id, route and things that identify itself. User, Client and * Organization are ok." A window or panel chat over the page is NOT the page's * own conversation and keeps receiving the page. * * Clients send the case as the request field `page_context` * (`{ mode, withheld? }`); aidream's context gate enforces it at the PAGE layer * (`decided_by.include === "page"`). The lists and every case are the parity * corpus's `page_context_defaults` / `page_context_cases` — aidream * `page_context.py` runs the same file. */ type PageContextMode = "own" | "off"; /** The request field `page_context`. Omitted = a conversation that follows the page. */ interface PageContextDirective { mode: PageContextMode; /** The page's declared list; omitted = the default for the mode. */ withheld?: string[]; } /** A switched-off page: everything that IS the page — its surroundings and its route. */ declare const PAGE_OFF_WITHHELD: readonly string[]; /** A page's own conversation: the page, plus what identifies the conversation itself. */ declare const OWN_CONVERSATION_WITHHELD: readonly string[]; /** Values about the PERSON, never the page — never withheld, whatever a page declares. */ declare const PERSON_CONTEXT_VALUES: ReadonlySet; /** * The conversation's OWN documents — the person attached them to THIS * conversation, so they are never the page's, whatever a page declares. The * chat page declares a lean ref named `working_document`; the page rule * claimed the chat's real working document as a page value and withheld it * from every main-chat turn (live 2026-10-07). The context KEYS, not the document surfaces' * `SurfaceValue` list (`@ai-matrx/chat` `CONVERSATION_DOCUMENT_VALUES`); aidream names this set * `CONVERSATION_DOCUMENT_VALUES` in `page_context.py`. */ declare const CONVERSATION_DOCUMENT_CONTEXT_KEYS: ReadonlySet; /** Each attached (non-active) scratchpad publishes `user_scratchpad_`. */ declare const CONVERSATION_SCRATCHPAD_PREFIX = "user_scratchpad_"; /** True for a value no page rule ever withholds: the person's and the conversation's own documents. */ declare function neverThePage(key: string): boolean; /** What the gate knows about one value when deciding (mirrors aidream `ValueFacts`). */ interface PageContextValueFacts { /** `"surroundings"` for a value from the screens around the page. */ origin?: string; /** The page itself declared this value. */ surfaceDeclared?: boolean; /** The surface that emitted it (`"_default"` when none). */ surfaceKey?: string; } declare function pageContextWithheldKeys(page: PageContextDirective): ReadonlySet; /** * True when the page rule keeps `key` from this conversation: a listed key, a * value from the screens around the page, or a value the page itself declared — * never a person value. */ declare function pageContextWithholds(page: PageContextDirective | null | undefined, key: string, facts?: PageContextValueFacts): boolean; /** * @ai-matrx/agents/context — the context value rules, headless. * * Contract: common-docs/systems/scopes-context/context-delivery/RULES.md. * Parity corpus: ./rules-corpus.json (run here by rules.test.ts and by aidream's * pytest against the Python twin `resolve_context_rule`). Every function here * is pure, zero-React, and safe to import on a server. * * The one flow a client runs per turn: * rows = values.map(v => resolveContextRow(v, savedRows, cap)) // what the table shows * context = buildContextWire(rows) // what the request sends * …on `context_receipt`: compareReceipt(rows, receipt) // screen vs server */ /** `users.user_surface_state.feature` for the person's saved rules. */ declare const CONTEXT_RULES_FEATURE = "context_rules"; /** Surface key for values no surface emitted (attachments, server-added values). */ declare const DEFAULT_SURFACE_KEY = "_default"; /** The server's default inline threshold when no layer sets one. */ declare const DEFAULT_INLINE_MAX_CHARS = 200; /** The default ceiling every resolved limit is clamped to (a server knob). */ declare const DEFAULT_INLINE_CAP = 50000; /** A lazy document's server default (RULES.md §2: "a small lazy document 6000"). */ declare const LAZY_SOURCE_DEFAULT_MAX = 6000; /** Which layer decided a field — lowest to highest. */ type ContextLayer = "default" | "page" | "agent" | "you"; type ContextDelivery = "inline" | "on_request" | "off"; /** * A client row's delivery: the server's three, plus `"server"` — an included * value the server resolves itself (`isServerResolved`), whose delivery the * client does not claim. Never on the wire or in a receipt. */ type ContextRowDelivery = ContextDelivery | "server"; /** One saved per-person rule (one key on one surface). Both fields optional. */ interface SavedContextRule { include?: boolean; max_inline_chars?: number; } /** `{ [surface_key]: { [context key]: SavedContextRule } }` — the person's rows. */ type SavedContextRuleRows = Record>; /** The agent layer for one key (RULES.md §2). */ interface ContextAgentLayer { /** The agent's Context Policy declares this key (or the value is the agent's own seed). */ declared?: boolean; /** The policy's ceiling; only read when `declared`. */ max_inline_chars?: number | null; /** `auto_context_disabled` — closes every undeclared key. */ kill_switch?: boolean; } /** The page layer for one key: the surface that emitted the value. */ interface ContextSurfaceLayer { /** The surface declares this value (a `ui_surface_value` row / manifest entry). */ declared?: boolean; /** `false` drops the value unless the agent declares it. */ auto_context?: boolean | null; /** `inlineUpTo` / envelope `max_inline_chars` / DB column. */ max_inline_chars?: number | null; /** * The value is withheld because this conversation IS the page (`page_context` mode `own`): * nothing re-opens it — not the agent's Context Policy, not the person's rule. A page's own * chat never receives itself (Arman, 2026-10-01 / 2026-10-21). */ own?: boolean; } /** The non-person layers for one value — what the table's layer breakdown shows. */ interface ContextRuleLayers { /** The server's per-key default limit; `null`/absent = 200. */ default_max?: number | null; agent?: ContextAgentLayer | null; surface?: ContextSurfaceLayer | null; } /** * Input to `resolveContextRule`. Snake case on purpose: it is the corpus shape * and the Python twin's shape. `user` is typed loosely because invalid saved * values (non-boolean include, non-integer or negative limit) must be ignored, * not trusted. */ interface ContextRuleInput extends ContextRuleLayers { /** Size in code points; `null` = an unresolved lazy source. */ chars: number | null; user?: { include?: unknown; max_inline_chars?: unknown; } | null; /** Ceiling; default `DEFAULT_INLINE_CAP`. */ cap?: number; /** * A server-authoritative value (`SERVER_AUTHORITATIVE_KEYS`, RULES.md §5a): * identity is not page or ambient context, so neither the page's switch nor * the agent's or mandate's kill switch closes it — only the person's own rule. */ identity?: boolean; } interface ContextRuleResult { include: boolean; /** Effective limit, after the clamp. */ max_inline_chars: number; delivery: ContextDelivery; decided_by: { include: ContextLayer; max_inline_chars: ContextLayer; }; clamped: boolean; } /** One receipt row — RULES.md §5, wire fields exactly. */ interface ContextReceiptRow { key: string; label: string; surface_key: string; origin: "client" | "server" | "surroundings" | "rule"; chars: number | null; include: boolean; max_inline_chars: number; delivery: ContextDelivery; decided_by: { include: ContextLayer; max_inline_chars: ContextLayer; }; user_rule: { include?: boolean; max_inline_chars?: number; } | null; clamped: boolean; /** The CLIENT itself sent a value the person turned off. */ client_sent_excluded: boolean; /** * `"model"`: nothing reached a model that reads no context. `"self_check"`: * the server's post-render safety check stripped it (RULES.md §4/§5) — * the row stays, `delivery: "off"`. */ blocked_by: ContextBlockedBy | null; /** * Set when the server did not keep the value under its own key — still a * row, never missing (RULES.md §5): `"expanded"` (a surroundings envelope * became one row per part), `"directive"` (a reserved directive the server * acted on), `"renamed"` (an earlier key spelling, held under the stable * key), `"unaccounted"` (a server path removed it with no reason — filed as * a defect). Absent from an older server. */ consumed_as?: ContextConsumedAs | null; /** The keys (each with its own row) that now carry what this value held. */ consumed_into?: string[]; /** * What the model READ for this value, verbatim from the rendered context * block (its own element: the whole value inline, or its on-request entry; * for a server-authoritative value, the server's own statement of it). * Absent/null when it reached no block (off, consumed) or from an older server. */ delivered?: ContextDeliveredRef | null; /** On-request values the server holds as text: what the `context` tool returns (size + hash). */ on_request?: ContextDeliveredRef | null; } /** * What the model read for one value or block, by SIZE and HASH only — never * the text (RULES.md §5b: a server-shaped value is fetched on demand, never * pushed). The text comes from the viewer (`ContextViewLoader`). */ interface ContextDeliveredRef { /** Code-point length of the whole text the model read. */ chars: number; /** SHA-256 hex of that text (UTF-8). */ sha256: string; } /** * What to view: a value's `delivered` element, its `on_request` text, a * `block`, or what the agent can `fetchable` for a value through a tool (the * Organization: its selected scopes' values via `scope_system` — rendered when * opened, never on the receipt; `source: "fetched_now"`). */ type ContextViewKind = "delivered" | "on_request" | "block" | "fetchable"; interface ContextViewTarget { kind: ContextViewKind; /** The value's key, or the block's id. */ key: string; } /** * The exact text the model received (a sent turn: `GET /ai/context/delivered`) * or will receive (the next turn: `POST /ai/context/preview` with `view`). */ interface ContextViewedText { kind: ContextViewKind; key: string; text: string; chars: number; sha256: string; /** * `fetched_now`: read at request time — a `fetchable` text (what the agent * gets if it asks now) or a lazy `on_request` value the agent never read. * `tool_result`: exactly what the `context` tool returned to the agent. */ source: "preview" | "wire" | "conversation_prompt" | "turn_record" | "fetched_now" | "tool_result"; /** * `fetchable` only: `false` when the turn's agent cannot call the tool that * returns it (tools off, excluded, a structured-output turn). `text` is then * `""`; the screen says so with state, never shows content as fetchable. */ available?: boolean; /** * A lazy `on_request` value of a SENT turn only (a document, a file family, * a scope — the turn never reads one): `true` — the agent called `context` * for it and `text` is what the tool returned; `false` — the agent never * read it and `text` is what it returns now (the screen says so). */ fetched?: boolean | null; } /** The host's door to the viewer API — called only when a person opens a value. */ type ContextViewLoader = (target: ContextViewTarget) => Promise; /** * The blocks a value's detail shows beneath its own text, because the model * received them as part of that value: the Organization is its live statement * AND the organization catalog (owner ruling 2026-10-01). Such a block is * counted in the value's chars and is not listed again under "Also sent". */ declare const CONTEXT_ROW_BLOCKS: Readonly>; /** * Values whose content the agent READS THROUGH A TOOL rather than receiving it, * keyed to that tool: the Organization's selected scopes' values are returned * by `scope_system` (by design, never inline). Their detail shows "Agent can * fetch" — the viewer's `fetchable` text, loaded when opened (RULES.md §5b). */ declare const CONTEXT_FETCHABLE_ROWS: Readonly>; /** The receipt blocks shown under `key`'s detail (`CONTEXT_ROW_BLOCKS`). */ declare function blocksForRow(key: string, blocks: readonly ContextReceiptBlock[] | null | undefined): ContextReceiptBlock[]; /** The receipt blocks not shown under any value present in `rowKeys`. */ declare function unclaimedBlocks(blocks: readonly ContextReceiptBlock[] | null | undefined, rowKeys: Iterable): ContextReceiptBlock[]; /** How the server consumed a value it did not keep under its own key (receipt `consumed_as`). */ type ContextConsumedAs = "expanded" | "directive" | "renamed" | "unaccounted"; /** * The reserved keys the server never keeps under their own name, and what it * does with each — the receipt rows say so (`consumed_as`). The same table is * the parity corpus's `consumed_key_cases` (aidream `RESERVED_CONSUMED_KEYS`). */ declare const RESERVED_CONSUMED_KEYS: Readonly>; /** * Where the server states each SERVER-AUTHORITATIVE value (RULES.md §5a, owner * ruling 2026-10-01: identity is the server's truth, never the page's claim). * The server drops the client's copy of these keys and the model reads the * server's own value, every turn: `"active_context"` — its `` * block (the conversation's organization, the scopes it admitted); * `"manifest"` — a server-built value (the authenticated person, the server's * clock). A screen never shows the client's copy of one as what will be sent. * The same table is the parity corpus's `server_authoritative_keys` (aidream * `SERVER_AUTHORITATIVE_KEYS`). */ declare const SERVER_AUTHORITATIVE_KEYS: Readonly>; /** True for a key whose value the server states itself (`SERVER_AUTHORITATIVE_KEYS`). */ declare function isServerAuthoritativeKey(key: string): boolean; /** * One block of server text the model received this turn that is not a single * value — the turn's ``, earlier-turn context, the sandbox * briefing, skills, memory, the organization catalog… (receipt `blocks`, * RULES.md §5). `delivered` is its exact text, cut at the receipt's cap. */ interface ContextReceiptBlock { /** Stable id: the per-turn slot it rode in, or the system-prompt addition's name. */ id: string; /** The id in words (`humanizeIdentifier`, `@ai-matrx/kit/text-case`). */ label: string; /** Size and hash; the text comes from the viewer (`kind: "block"`). */ delivered: ContextDeliveredRef; } /** The per-turn receipt the server streams as `context_receipt` — RULES.md §5. */ interface ContextReceipt { version: 1; surface: string | null; cap: number; /** False: this turn's model cannot read context at all (every row `blocked_by: "model"`). */ model_reads_context: boolean; /** The person's saved rules could not be read; the turn ran without them. */ rules_error: string | null; rows: ContextReceiptRow[]; /** Every other block of server text the model received, in render order (absent: older server). */ blocks?: ContextReceiptBlock[]; } type ContextRowOrigin = "page" | "attached" | "system"; /** Why the server kept a value from the model on this turn (receipt `blocked_by`). */ type ContextBlockedBy = "model" | "self_check"; /** A client's resolved row: what its table renders and what `buildContextWire` sends. */ interface ResolvedContextRow extends Omit { delivery: ContextRowDelivery; /** * The server resolves this value (a resource reference, a `*_id` UUID): size * and delivery are unknown (`chars: null`, `delivery: "server"` when * included), and its default limit is not predicted. Include and the * person's own rule still resolve normally. */ serverResolved?: boolean; /** Display-only: chars / limit / delivery were filled from a receipt (`applyReceiptToRows`). */ fromReceipt?: boolean; /** From a receipt: why the server kept this value from the model this turn. */ blockedBy?: ContextBlockedBy; /** * Display-only, from a receipt: what the model read for this value. When set, * a detail view shows THIS — never `value`, the client's pre-send copy. */ delivered?: ContextDeliveredRef; /** Display-only, from a receipt: what the `context` tool returns for it (size + hash). */ onRequest?: ContextDeliveredRef; /** Display-only, from a receipt: blocks the model received as part of this value. */ deliveredBlocks?: ContextReceiptBlock[]; key: string; label: string; surfaceKey: string; origin: ContextRowOrigin; /** The raw value, or an already-rich envelope (`{ content, type, … }`). */ value: unknown; chars: number | null; /** The saved rule that was applied (merged `_default` + surface row), or null. */ userRule: SavedContextRule | null; description?: string; /** Context object type for the wire envelope (`text`, `json`, …). */ type?: string; /** The non-person layers the rule was resolved from. Absent = default only. */ layers?: ContextRuleLayers; } /** What a client knows about one value before resolution. */ interface ContextRowSource { key: string; label: string; surfaceKey?: string; origin: ContextRowOrigin; value: unknown; /** Override the measured size (e.g. `null` for an unresolved lazy source). */ chars?: number | null; description?: string; type?: string; layers?: ContextRuleLayers; } declare function resolveContextRule(input: ContextRuleInput): ContextRuleResult; /** * Size of a value in code points, exactly as the server's `content_as_str()`: * a string is itself; anything else is `JSON.stringify(value, null, 2)` * (Python `json.dumps(value, ensure_ascii=False, indent=2)`). `undefined` → 0. */ declare function contextValueChars(value: unknown): number; /** * The person's rule for one key on one surface: `_default[key]` merged per * field under `rows[surfaceKey][key]`, invalid fields stripped. `null` when * nothing valid is saved. */ declare function lookupSavedRule(rows: SavedContextRuleRows | null | undefined, surfaceKey: string, key: string): SavedContextRule | null; /** * The person's rule for one key, drift-proof (identical to aidream's * `lookup_user_rule_for`). While a primary surface P is in play, every key * filed under `_default` OR under P resolves to the same per-field merge * `{ ..._default[key], ...rows[P][key] }` (P wins) — whichever surface the * client's or the server's manifest says "declares" the key. A code manifest * and the DB manifest can disagree (sync drift); this makes the person's rule * land the same on both sides anyway. A surroundings key (any other surface) * keeps its own surface: `{ ..._default[key], ...rows[surfaceKey][key] }`. * With no primary surface this is exactly `lookupSavedRule`. * * Saving is unchanged: page values save to P, everything else to `_default`. */ declare function lookupSavedRuleFor(rows: SavedContextRuleRows | null | undefined, primarySurface: string | null | undefined, surfaceKey: string, key: string): SavedContextRule | null; /** * The keys that make a dict the rich envelope form — exactly aidream * `context_objects._RICH_FORM_KEYS`. A dict with ANY other key is raw content * on the server, `content` key or not. */ declare const RICH_ENVELOPE_KEYS: ReadonlySet; /** * A rich envelope exactly as the server reads one (aidream * `_split_rich_context_value`): a plain object with its own `content` whose * every key is in `RICH_ENVELOPE_KEYS`. A record that merely HAS `content` * (a note `{ id, title, content }`) is raw content, not an envelope. */ declare function isRichEnvelope(value: unknown): value is Record; /** * True for a value with NOTHING to send: absent, `null`, a blank string, an empty list or an * empty object — or a rich envelope whose `content` is one of those and that names no `source` * for the server to read. Such a value is not a row (live walk 2026-10-23: Side Chat listed five * included 0-character rows — Current selection, Text before/after selection, Primary content, * Custom fields — and counted them). A directive the server acts on by shape is never "nothing". */ declare function hasNothingToSend(value: unknown): boolean; /** * Split one wire value into `{ content, overrides }` exactly as aidream * `_split_rich_context_value`: a rich envelope or lazy pointer → its `content` * (null when absent) and every other key; anything else → the whole value as * content, no overrides. */ declare function splitContextValue(value: unknown): { content: unknown; overrides: Record; }; /** * The server's default inline limit for one wire value — the `default` layer * the server will use, before page/agent/you. Mirrors aidream * `context_rules._server_default_max` over the object `ContextManifest.build` * makes from the value (after `normalize_resource_context`): * * - a rich envelope (every key in the rich-form set, and `content` present or a * lazy `source` with a string `kind`) carrying a whole-number, non-negative * `default_max_inline_chars` → that; * - a top-level resource reference (`envelope: "resource_ref"` with a type and a * UUID id), or a lazy source whose `extra.resource_type` is set → 0 * (descriptor-first); * - a lazy source (a `source` and null/absent `content`) → 6000; * - anything else → null (the server's 200). * * A resource reference nested as an envelope's `content` is NOT promoted by the * server (it reads top-level values only), so it is plain JSON content → null. */ declare function serverDefaultMax(value: unknown): number | null; /** Resolve one value into the row the table renders and the wire sends. */ declare function resolveContextRow(source: ContextRowSource, savedRows: SavedContextRuleRows | null | undefined, cap?: number, /** The page in play; makes the rule lookup drift-proof (`lookupSavedRuleFor`). */ primarySurface?: string | null): ResolvedContextRow; /** * Values the server acts on by their top-level shape in `request.context` * (aidream `normalize_resource_context` → `parse_resource_reference`, which * reads ONLY top-level values): * * - a resource reference — any object whose `envelope` is `"resource_ref"` * (its own promote/exclude/overlay policy rides inside it); * - a bare UUID string under a conventional `*_id` key (`file_id`, * `attached_file_id`, `current_note_id`, …), which the server promotes when * the noun is a registered resource type. The registry lives on the server, * so every `*_id` key with a UUID passes through; for an unregistered noun * the server reads the bare string exactly as it would read it wrapped; * - a reserved key the server consumes by shape (`RESERVED_CONSUMED_KEYS`: * `surface_chain`, `window_forms`, `__table_access`, `__google_files`) — * wrapped, the server reads `{content, label}` instead of its list or grant * and drops it. * * These ship exactly as-is: no label, type, description or limit added. */ declare function isWireDirective(key: string, value: unknown): boolean; /** * A value whose size, default limit and delivery the SERVER decides by * resolving it — so the client must not predict them: * * - a top-level resource reference (`envelope: "resource_ref"`), bare or as a * rich envelope's `content`; * - a UUID string under a `*_id` key, bare or as a rich envelope's `content`. * * The server only promotes an id when its noun is in the resource registry * (aidream `_resource_type_for_key`), which the client cannot see, so every * `*_id` UUID counts. This is a deliberate superset: on a value the server * does not promote, the client only stops predicting — it never makes a wrong * promise. */ declare function isServerResolved(key: string, value: unknown): boolean; /** * Build the request's `context` object from the resolved rows. This is the * ONLY function that may produce it, so what the table shows and what the * request carries cannot drift apart. * * - A row whose `include` is false is omitted entirely — it never reaches the * wire (RULES.md §1: off means off everywhere). * - An included row becomes `{ content, type?, label, description?, * max_inline_chars? }`. An already-rich envelope (`isRichEnvelope`, e.g. a * working document carrying `source`/`mutable`/`persist`, or a lazy pointer) * keeps every non-rule field it already has; `label`/`description`/`type` * are only filled when missing. * - `max_inline_chars` on the envelope is the PAGE layer's value only * (`layers.surface.max_inline_chars`, else the envelope's own page value). * The server reads the person's saved rules itself every turn (RULES.md §3) * and the agent layer from its own policy, so the wire must never carry the * person's number or the resolved effective limit dressed up as a page rule * — that would make a stale client value outrank the server's fresh read. */ declare function buildContextWire(rows: readonly ResolvedContextRow[]): Record; interface ContextReceiptMismatch { key: string; field: "include" | "max_inline_chars" | "delivery" | "user_rule" | "missing"; expected: unknown; actual: unknown; /** * `"self_check"`: a real difference from what was shown — the server's * safety check stripped the value before the model call. Say "removed by * the server's safety check", not "the screen was wrong". */ reason?: "self_check"; } /** * Compare the rows the client resolved (and rendered, and sent) with the * receipt the server emitted for the same turn. * * For each expected row, the receipt row is matched by key + surface key, then * by key alone. Compared: `include`, `max_inline_chars`, `delivery` (only when * both sides know the size) and `user_rule`. An expected row absent from the * receipt is a `missing` mismatch — except a row the client correctly withheld * for a reason other than the person's own rule (page `auto_context` off, the * agent's kill switch): the client never sent it and the server lists only * the person's saved `include: false` rules as `origin: "rule"` rows, so its * absence is the truth, not a lie. Receipt rows nobody expected are returned * as `systemRows` — shown, never hidden. A row the server consumed * (`consumed_as`: expanded / directive / renamed) is compared on `include` * and `user_rule` only — its parts carry their own rows; an `"unaccounted"` * row, or an included envelope `"expanded"` into no parts, is a `missing` * mismatch. */ declare function compareReceipt(expected: readonly ResolvedContextRow[], receipt: ContextReceipt): { mismatches: ContextReceiptMismatch[]; systemRows: ContextReceiptRow[]; modelReadsContext: boolean; }; /** * For DISPLAY only: fill each server-resolved row's `chars`, * `max_inline_chars` and `delivery` from the latest receipt row for the same * key (key + surface key, then key), marking it `fromReceipt`. Other rows are * returned unchanged. Never compare these rows — `compareReceipt` takes the * rows the client resolved before sending. */ declare function applyReceiptToRows(rows: readonly ResolvedContextRow[], receipt: ContextReceipt | null | undefined): ResolvedContextRow[]; /** * Turn one receipt row into the row a read-only table renders (a sent * message's context, read back from `chat.message.model_context`). The value * itself is not in the receipt, so `value` is undefined. */ declare function receiptRowToResolved(row: ContextReceiptRow, blocks?: readonly ContextReceiptBlock[] | null): ResolvedContextRow; /** A receipt row's `delivered` / `on_request` as display fields (absent when not sent). */ declare function deliveredFields(row: Pick): Pick; /** * Rebuild the non-person layers from what the server applied, so a read-only * table shows the applied limit as the inherited value and marks the layer * that decided it. The limit goes on the layer named by * `decided_by.max_inline_chars` (`you` is carried by `userRule`); include is * rebuilt the same way for a page `auto_context` off or the agent's kill switch. */ /** * Keys the client has a value for but is NOT sending this turn (excluded by * the page, the agent or the person's rule). Clients send this list as the * request's `context_withheld`, so the receipt's `origin: "rule"` rows are * limited to keys actually withheld on this page. Deduplicated, in row order. */ declare function withheldKeys(rows: readonly ResolvedContextRow[]): string[]; /** * Receipt rows the client never sent (`compareReceipt(...).systemRows`: * server-seeded attachments, scope seeds, saved off-rules…) as table rows, so * a person can see and govern them — the normal Include switch and Inline max * apply. Documents (`attached_document_*`, `attached_file_*`, * `resource_file_*`) group as "attached", everything else as "system". The * server resolved them (`serverResolved`), values come from the receipt * (`fromReceipt`), and `surfaceKey` is the row's own `surface_key` — so a rule * saved for one writes to `_default` unless the server filed it under a page. * `value` is undefined: `buildContextWire` never sends these rows. */ declare function systemRowsToResolved(systemRows: readonly ContextReceiptRow[]): ResolvedContextRow[]; /** * The context key the server files a conversation attachment under, derivable * by every client from `GET /conversations/{id}/attachments` (aidream * `conversation_attachments/briefing.py`; corpus `attachment_key_cases`): * * `attached_resource_` + encode(`${provider}:${resourceRef}`) * * where encode keeps ASCII letters, digits and `-`, and writes every other * UTF-8 byte as `_` + two lowercase hex digits (`_` itself is `_5f`). Unique * across providers, case-preserving (Drive ids), stable. */ declare function attachmentContextKey(provider: string, resourceRef: string): string; /** Compact size for a tabular column: `950`, `18.4k`, `184k`, `1.2M`, `—` for unknown. */ declare function formatChars(n: number | null | undefined): string; export { CONTEXT_FETCHABLE_ROWS, CONTEXT_ROW_BLOCKS, CONTEXT_RULES_FEATURE, CONVERSATION_DOCUMENT_CONTEXT_KEYS, CONVERSATION_SCRATCHPAD_PREFIX, DEFAULT_INLINE_CAP, DEFAULT_INLINE_MAX_CHARS, DEFAULT_SURFACE_KEY, LAZY_SOURCE_DEFAULT_MAX, OWN_CONVERSATION_WITHHELD, PAGE_OFF_WITHHELD, PERSON_CONTEXT_VALUES, RESERVED_CONSUMED_KEYS, RICH_ENVELOPE_KEYS, SERVER_AUTHORITATIVE_KEYS, applyReceiptToRows, attachmentContextKey, blocksForRow, buildContextWire, compareReceipt, contextValueChars, deliveredFields, formatChars, hasNothingToSend, isRichEnvelope, isServerAuthoritativeKey, isServerResolved, isWireDirective, lookupSavedRule, lookupSavedRuleFor, neverThePage, pageContextWithheldKeys, pageContextWithholds, receiptRowToResolved, resolveContextRow, resolveContextRule, serverDefaultMax, splitContextValue, systemRowsToResolved, unclaimedBlocks, withheldKeys }; export type { ContextAgentLayer, ContextBlockedBy, ContextConsumedAs, ContextDeliveredRef, ContextDelivery, ContextLayer, ContextReceipt, ContextReceiptBlock, ContextReceiptMismatch, ContextReceiptRow, ContextRowDelivery, ContextRowOrigin, ContextRowSource, ContextRuleInput, ContextRuleLayers, ContextRuleResult, ContextSurfaceLayer, ContextViewKind, ContextViewLoader, ContextViewTarget, ContextViewedText, PageContextDirective, PageContextMode, PageContextValueFacts, ResolvedContextRow, SavedContextRule, SavedContextRuleRows };