Skip to content
GitHub (opens in a new tab)

RedactionPreview

Shows exactly what is about to leave the product for a model or outside tool, with sensitive values masked by type and a mask rule per type, before it is sent. Send, then one line.

stableOrganismcontracts/redactionpreview.json

Preview

RedactionPreview

What leaves for a model or tool, masked by type, before it goes. Not ContextWindow. Not ApprovalCard.

Master

Flip a rule, reveal a chip, then Send. onSend gets the masked text.

Sending to Claude (Anthropic API)

EU region
  • Name1
  • Email2
  • Card number1
  • Phone1
  • API key1

What will be sent

Summarise this ticket and draft a reply.

From:  <>
Order 48213 was charged twice to card .
Please call me on  or reply to .
Our integration still uses key  — is that why?
Mask before sending
  • Locked on

Secrets always stay masked. They are never sent to a model or outside tool.

6 values masked

Usage

RedactionPreview sits between an agent and the model or tool it calls. Pass the exact payload and the sensitive spans your detector found; the person sees what leaves and can loosen rules, but never for secrets.

Do's

  • an agent is about to send customer or company data to a model, API or outside tool
  • a person should see and control which sensitive values leave masked
  • secrets must never leave, whatever the person chooses

Don'ts

  • how much of the model's context is used — ContextWindow
  • approving one command or edit — ApprovalCard
  • granting standing access to a resource — PermissionRequest
<RedactionPreview
  destination="Claude (Anthropic API)"
  region="EU"
  payload={ticket}
  spans={[{ start: 47, end: 76, type: "email" }, { start: 120, end: 139, type: "card" }]}
  rules={rules}
  onRulesChange={setRules}
  onSend={(maskedPayload) => send(maskedPayload)}
  onCancel={cancel}
/>

When to use

  • an agent is about to send customer or company data to a model, API or outside tool
  • a person should see and control which sensitive values leave masked
  • secrets must never leave, whatever the person chooses

When not to use

  • how much of the model's context is used — ContextWindow
  • approving one command or edit — ApprovalCard
  • granting standing access to a resource — PermissionRequest

What an agent reads

import { RedactionPreview } from "agentic-ds-kit";
must
  • the Card is aria-labelledby "Sending to <destination>"
  • masked spans are buttons named "masked <type>"; a Tooltip gives the type and aria-pressed tracks Reveal, which shows the value to the viewer only
  • unmasked spans carry hidden "unmasked <type>:" text, never colour alone
  • each mask rule is a labelled Switch; locked Switches are disabled and described by the reason
  • anything going out unmasked raises a warning Alert
  • the resolved row is named with what was sent and how many values were masked
  • motion is opacity and transform only, off under prefers-reduced-motion
  • status error is a danger Alert (role=alert) and focus moves to Try again
  • split: Before and After are labelled regions; locked types stay masked in both
defaults
  • lockedTypes ["apiKey","password","secret"]
  • lockedReason Secrets always stay masked. They are never sent to a model or outside tool.
  • status pending
  • layout inline
stops if
  • Do not invent a local PiiViewer, MaskedText or DataLeakPanel
  • Do not bend CodeSnippet to mark spans up
  • Do not let a person unlock secrets (lockedTypes)
  • Send is the one solid primary; Cancel is outline
  • Do not use raw hex

From contracts/redactionpreview.json: must is the a11y requirements, defaults the prop defaults, stops if the doNot rules where the agent asks instead of inventing a cousin.

Props

NameTypeRequiredDefaultNotes
destinationstringYes—Where the data goes. Title reads "Sending to <destination>".
regionstringNo—Data region of the destination, a Badge ("EU region").
payloadstringYes—Exactly what will be sent, as plain text. Shown read-only in mono.
spansarrayYes—{ start, end, type }[] character ranges of sensitive values, e.g. type "email", "card", "apiKey". Overlaps are dropped.
rulesobjectNo—{ [type]: boolean } mask on or off. Types not listed are masked.
lockedTypesarrayNo["apiKey","password","secret"]Always masked; their Switch is locked on with lockedReason as the hint.
lockedReasonstringNoSecrets always stay masked. They are never sent to a model or outside tool.—
typeLabelsobjectNo—{ [type]: label }. Common types (email, phone, card, apiKey…) have defaults.
onRulesChangefunctionNo—(rules) => void when a mask Switch flips.
onSendfunctionNo—(maskedPayload) => void. Send, the one solid primary. Masked values are replaced by "[type]", or "[Label •••• tail]" with keepLast.
onCancelfunctionNo—Cancel, outline.
statuspending | sent | cancelled | errorNopendingsent folds to one line ("Sent to … with 10 values masked"); cancelled to "Not sent"; error keeps the card with a danger Alert ("Couldn't send. Nothing left the product.") and Send becomes Try again.
errorTextstringNo—status error: why it failed, the Alert body.
onRetryfunctionNo—status error: Try again, outline neutral. Falls back to onSend.
layoutinline | splitNoinlinesplit: Before (only you see it; secrets stay masked) and After (exactly what is sent) side by side; on a narrow card After shows first and Before sits behind "Show before".
keepLastobjectNo—{ [type]: number } characters kept at the end of a masked value, e.g. { card: 4 } sends "[Card number •••• 4242]". Never applies to lockedTypes.
  • Component
    →

    ContextWindow

    How full the prompt context is and what uses the space, by segment, with a warning near the limit, Trim oldest and compaction with Undo.

  • Component
    →

    ApprovalCard

    The agent asks before it acts: risk, what will happen in words, an exact preview of the command or diff, and Approve (⌘/Ctrl+Enter) / Deny (Escape) with an optional auto-deny countdown.

  • Component
    →

    PermissionRequest

    An agent asks for standing access to a capability (files, email, repo, billing), scope by scope, with why and expiry.

  • Component
    →

    Card

    Framed tile with optional header, body, and footer actions.