Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.
gui: Insights › Masking shows each request as sent, what was masked and how
yetonee698a688fd5c
diff --git a/internal/gui/assets/app.css b/internal/gui/assets/app.cssindex 2c18ed5e1..5d610135f 100644--- a/internal/gui/assets/app.css+++ b/internal/gui/assets/app.css@@ -3253,123 +3253,14 @@ body:not(.side-nav) #view-settings .set-head.stuck::before { box-shadow: 0 1px 0#privacyModelRow.pm-wait .name { color: var(--muted); }#privacyModelRow .badge.new { margin-left: 7px; background: var(--accent-soft); color: var(--accent); }-/* Privacy › what masking kept from vendors (renderMaskObs): a quiet card- over the switches, in the other cards' own colour. Flat only: no- gradients, no shadows; hairlines, one thin number, and the accent kept- for what left this computer as placeholders */-.mask-obs { position: relative; container-type: inline-size; margin-bottom: 6px; padding: 26px 30px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); }-.mask-obs:empty { display: none; }-.mo-head { display: flex; align-items: flex-start; gap: 12px; }-.mo-head .grow, .mo-lh .grow { flex: 1; }-.mo-title { min-width: 0; }-.mo-name { font-size: 12px; letter-spacing: .14em; color: var(--fg-2); }-.mo-sub { margin-top: 7px; font-size: 12.5px; line-height: 1.45; color: var(--muted); }-.mo-empty { margin-top: 14px; font-size: 12px; line-height: 1.5; color: var(--muted); }-.mo-hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 236px); gap: 56px; align-items: end; margin-top: 38px; }-.mo-count { min-width: 0; }-.mo-num { font-family: "SF Pro Display", -apple-system, BlinkMacSystemFont, system-ui, sans-serif; font-size: clamp(64px, 16cqi, 140px); font-weight: 100; line-height: .82; letter-spacing: -.055em; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--fg); }-.mo-unit { margin-top: 20px; font-size: 14px; letter-spacing: .02em; color: var(--fg-2); }-.mo-unit span { margin-left: 8px; color: var(--faint); }-.mo-stats { min-width: 0; border-top: 1px solid var(--line); }-.mo-stat { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 12.5px; color: var(--muted); }-.mo-stat b { font-size: 20px; font-weight: 300; letter-spacing: -.02em; font-variant-numeric: tabular-nums; color: var(--fg); }-.mo-days { position: relative; min-width: 0; height: 54px; margin-top: 14px; display: flex; flex-direction: column; }-.mo-bars { flex: 1; min-height: 0; display: flex; align-items: stretch; justify-content: space-between; gap: 5px; }-.mo-bars.many { gap: 2px; }-.mo-day { flex: 1 1 0; min-width: 3px; display: flex; align-items: flex-end; justify-content: center; }-.mo-day i { display: block; width: 100%; border-radius: 1.5px; background: color-mix(in srgb, var(--fg) 24%, transparent); transform-origin: bottom; transition: background-color .15s; }-.mo-day:hover i { background: color-mix(in srgb, var(--fg) 42%, transparent); }-.mo-day.now i, .mo-day.now:hover i { background: var(--accent); }-.mo-day.zero i { height: 2px; background: var(--line); }-.mo-axis { display: flex; justify-content: space-between; padding-top: 6px; font-size: 10.5px; line-height: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }-.mo-axis span:last-child { color: var(--accent); }-.mo-ctip { position: absolute; top: -4px; transform: translate(-50%, -100%); padding: 4px 8px; border-radius: 7px; border: 1px solid var(--line-2); background: var(--card); font-size: 11px; white-space: nowrap; color: var(--fg); font-variant-numeric: tabular-nums; pointer-events: none; }-.mo-ctip[hidden] { display: none; }-.mo-sk-num { width: 180px; height: 96px; border-radius: 10px; }-.mo-sk-chart { height: 96px; border-radius: 10px; }-.mo-sec > .label, .mo-lh { display: flex; align-items: baseline; gap: 10px; margin-bottom: 6px; }-.mo-hint { font-size: 11.5px; color: var(--faint); }+/* masking's shared marks: a kind's dot, a placeholder in its kind's colour,+ and a label row (Settings › Privacy's Try it, Insights › Masking) */+.mo-lh { display: flex; align-items: baseline; gap: 10px; margin-bottom: 6px; }+.mo-lh .grow { flex: 1; }.mo-dotc { flex: none; width: 7px; height: 7px; border-radius: 50%; }--/* agents → this computer → providers: hairlines on a faint grid */-.mo-fl { margin: 64px 0 0; }-.mo-flow { position: relative; display: grid; grid-template-columns: minmax(0, 150px) minmax(80px, 1fr) minmax(0, 150px); gap: 14px; }-.mo-col { display: flex; flex-direction: column; justify-content: center; min-width: 0; }-.mo-node { display: flex; flex-direction: column; align-items: flex-end; justify-content: center; gap: 2px; height: 48px; min-width: 0; padding: 0 10px; border: 0; border-radius: 9px; background: none; color: var(--fg); font: inherit; cursor: default; }-.mo-col.provider .mo-node { align-items: flex-start; }-.mo-node:not(:disabled):hover { background: var(--pill); }-.mo-node:disabled { color: var(--muted); }-.mo-node .nm { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }-.mo-node .ct { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }-.mo-col.provider .ct { color: var(--accent); }-.mo-mid { position: relative; min-width: 0; }-.mo-mid svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }-/* the dot grid behind the hairlines, a dot every 14px */-.mo-mid::before { content: ""; position: absolute; inset: 0; background: var(--fg); opacity: .07; pointer-events: none;- -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14'%3E%3Ccircle cx='1' cy='1' r='.6'/%3E%3C/svg%3E") 0 0 / 14px 14px;- mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14'%3E%3Ccircle cx='1' cy='1' r='.6'/%3E%3C/svg%3E") 0 0 / 14px 14px; }-.mo-th { fill: none; stroke: var(--fg); stroke-width: .6; stroke-dasharray: 1 1; }-.mo-th.out { stroke: var(--accent); }-.mo-th.one { stroke-width: .9; }-.mo-mem { stroke: var(--accent); stroke-opacity: .55; stroke-width: 1; }-.mo-tick { stroke: var(--accent); stroke-opacity: .35; stroke-width: .6; }-.mo-scan { fill: var(--accent); opacity: 0; animation: mo-scan 5.5s cubic-bezier(.45, 0, .55, 1) infinite; }-@keyframes mo-scan { 0% { transform: translateY(0); opacity: 0; } 15%, 85% { opacity: 1; } 100% { transform: translateY(var(--h)); opacity: 0; } }-.mo-dot { fill: var(--fg); opacity: 0; }-.mo-dot.out { fill: var(--accent); }-.mo-hub { position: absolute; left: 50%; top: -30px; width: 20px; height: 20px; margin-left: -10px; display: flex; align-items: center; justify-content: center; color: var(--accent); }-.mo-cap { margin-top: 16px; text-align: center; font-size: 11px; letter-spacing: .12em; color: var(--muted); }--/* the newest request as the vendor got it, or as it is here */-.mo-saw { margin-top: 30px; border-radius: 12px; background: var(--card-2); box-shadow: inset 0 0 0 1px var(--line); }-.mo-saw .mo-lh { align-items: center; flex-wrap: wrap; row-gap: 6px; margin: 0; padding: 10px 12px 10px 18px; border-bottom: 1px solid var(--line); }-.mo-saw .label { margin: 0; }-.mo-lines { padding: 12px 18px 14px; }-.mo-snip { font-family: var(--code); font-size: 12px; line-height: 2; color: var(--fg-2); overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }-.mo-snip + .mo-snip { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line); }.mo-ph { padding: 1px 5px; border-radius: 4px; font: inherit; color: color-mix(in srgb, var(--k) 78%, var(--fg)); background: color-mix(in srgb, var(--k) 13%, transparent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--k) 22%, transparent); outline: none; cursor: default; }.mo-ph:hover { background: color-mix(in srgb, var(--k) 22%, transparent); }.mo-ph:focus-visible { background: color-mix(in srgb, var(--k) 22%, transparent); }-.mo-saw .mo-ph { padding: 1px 6px; margin: 0 1px; border-radius: 5px; color: var(--accent); background: color-mix(in srgb, var(--accent) 13%, transparent); box-shadow: inset 0 0 0 .5px color-mix(in srgb, var(--accent) 40%, transparent); animation: mo-breathe 4.8s ease-in-out infinite; }-.mo-saw .mo-ph:hover, .mo-saw .mo-ph:focus-visible { background: color-mix(in srgb, var(--accent) 20%, transparent); }-@keyframes mo-breathe { 50% { box-shadow: inset 0 0 0 .5px color-mix(in srgb, var(--accent) 75%, transparent), 0 0 0 3px color-mix(in srgb, var(--accent) 7%, transparent); } }-.mo-orig { color: var(--fg); border-bottom: 1px dotted var(--muted); }-.mo-orig.gone { color: var(--faint); }--/* what was kept and how it was found; the values masked most */-.mo-low { display: grid; grid-template-columns: minmax(0, 240px) minmax(0, 1fr); gap: 52px; margin-top: 34px; }-.mo-ledger { min-width: 0; }-.mo-ledg + .mo-ledg { margin-top: 24px; }-.mo-ledg > .label { margin-bottom: 2px; }-.mo-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; width: 100%; padding: 10px 0; border: 0; border-bottom: 1px solid var(--line); background: none; color: var(--fg); font: inherit; font-size: 12.5px; text-align: left; cursor: default; }-.mo-row:last-child { border-bottom: 0; }-.mo-row .nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--fg-2); transition: color .15s; }-.mo-row:not(:disabled):hover .nm { color: var(--fg); }-.mo-row b { font-size: 16px; font-weight: 300; font-variant-numeric: tabular-nums; }-.mo-row.model b { color: var(--accent); }-.mo-top { min-width: 0; }-.mo-values { display: flex; flex-direction: column; }-.mo-val { display: flex; align-items: center; gap: 14px; height: 38px; padding: 0 10px; margin: 0 -10px; border: 0; border-radius: 9px; background: none; color: var(--fg); font: inherit; font-size: 12.5px; text-align: left; cursor: default; outline: none; }-.mo-val:hover, .mo-val:focus-visible { background: var(--pill); }-.mo-val .i { flex: none; width: 16px; font-size: 10.5px; color: var(--faint); font-variant-numeric: tabular-nums; }-.mo-val .sh { flex: 0 1 150px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--code); font-size: 12px; letter-spacing: .03em; }-.mo-val .by { flex: none; width: 72px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11.5px; color: var(--muted); }-.mo-val .bar { flex: 1; min-width: 12px; display: flex; }-.mo-val .bar i { height: 1px; background: color-mix(in srgb, var(--fg) 24%, transparent); transition: background-color .15s; }-.mo-val:hover .bar i, .mo-val:focus-visible .bar i { background: var(--accent); }-.mo-val .x { flex: none; min-width: 36px; text-align: right; font-variant-numeric: tabular-nums; }-.mo-foot { display: flex; align-items: center; gap: 10px; margin-top: 22px; padding-top: 12px; border-top: 1px solid var(--line); }-.mo-note { flex: 1; min-width: 0; font-size: 11.5px; line-height: 1.4; color: var(--muted); }-.mo-open { flex: none; display: inline-flex; align-items: center; gap: 2px; }-@container (max-width: 620px) {- .mo-hero, .mo-low { grid-template-columns: minmax(0, 1fr); gap: 26px; }- .mo-hero { margin-top: 28px; }- .mo-fl { margin-top: 52px; }- .mo-flow { grid-template-columns: minmax(0, 1fr) minmax(48px, 1fr) minmax(0, 1fr); gap: 4px; }- .mo-val .by { display: none; }-}-@media (max-width: 560px) { .mask-obs { padding: 20px 18px 12px; } }-@media (prefers-reduced-motion: reduce) { .mo-scan, .mo-saw .mo-ph { animation: none; } }/* what a masked value was, beside it while it is pointed at */.mask-tip { position: fixed; z-index: 1000; max-width: min(360px, calc(100vw - 16px)); padding: 8px 11px 9px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--card); box-shadow: 0 12px 32px rgba(0, 0, 0, .18); font-size: 12px; color: var(--fg); pointer-events: none; animation: mask-tip .16s var(--ease); }@@ -3380,34 +3271,7 @@ body:not(.side-nav) #view-settings .set-head.stuck::before { box-shadow: 0 1px 0@keyframes mask-tip { from { opacity: 0; transform: translateY(3px); } }@media (prefers-reduced-motion: reduce) { .mask-tip { animation: none; } }-/* the records, in the Privacy page's place while they are open */-#view-settings:not(.set-searching) #setPage-privacy.recs > :not(.mask-recs) { display: none; }-.set-searching .mask-obs, .set-searching .mask-recs { display: none; }-.mask-recs[hidden] { display: none; }-.mr-head { display: flex; align-items: center; gap: 10px; min-height: 28px; }-.mr-back { display: inline-flex; align-items: center; gap: 1px; margin-left: -4px; }-.mr-title { font-size: 13px; font-weight: 600; color: var(--fg); }-.mr-filters { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 2px; }-.mr-filters:empty { display: none; }-.mask-recs .row-head { margin-top: 8px; }-.mr-group { overflow: hidden; }-.mr-item + .mr-item { border-top: 1px solid var(--line); }-.mr-row { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 42px; padding: 6px 12px 6px 10px; border: 0; background: transparent; color: var(--fg); font: inherit; font-size: 12.5px; text-align: left; cursor: default; }-.mr-row:hover { background: var(--pill); }-.mr-row:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--accent-soft); }-.mr-chev { flex: none; display: inline-flex; color: var(--faint); transition: transform .2s var(--ease); }-.mr-item.open .mr-chev { transform: rotate(90deg); }-.mr-time { flex: none; color: var(--muted); font-variant-numeric: tabular-nums; }-.mr-route { flex: 1 1 auto; display: flex; align-items: center; gap: 5px; min-width: 0; overflow: hidden; white-space: nowrap; }-.mr-route .who { flex: none; max-width: 40%; overflow: hidden; text-overflow: ellipsis; }-.mr-route .arrow { flex: none; color: var(--faint); }-.mr-route .model { min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }-.mr-route .what { flex: none; height: 18px; padding: 0 6px; border-radius: 5px; display: inline-flex; align-items: center; font-size: 10.5px; color: var(--muted); background: var(--pill); }-.mr-kinds { flex: none; display: flex; gap: 4px; }-.mr-kind { display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 7px; border-radius: 99px; border: 1px solid var(--line); background: var(--card-2); font-size: 11px; color: var(--fg-2); white-space: nowrap; }-.mr-kind b { font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }-.mr-n { flex: none; min-width: 20px; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }-.mr-body { padding: 0 14px 12px 34px; }+/* a masked value in a row: its kind, shape, finder and what is done with it */.mr-val { display: flex; align-items: center; gap: 8px; min-height: 26px; font-size: 12px; }.mr-k { color: var(--fg-2); }.mr-shape { font-family: var(--code); font-size: 11.5px; color: var(--fg); border-radius: 4px; padding: 1px 3px; outline: none; }@@ -3419,7 +3283,6 @@ body:not(.side-nav) #view-settings .set-head.stuck::before { box-shadow: 0 1px 0.mr-act { display: inline-flex; align-items: center; height: 18px; padding: 0 6px; border-radius: 5px; font-size: 10.5px; color: var(--muted); background: var(--pill); }.mr-act.warn { color: var(--amber); background: var(--amber-soft); }.mr-act.block { color: var(--red); background: var(--red-soft); }-.mr-route .what.held { color: var(--red); }/* what is done with a kind of value: mask, warn or block (#1977) */.mask-act .name { display: flex; align-items: center; gap: 8px; }#maskActList .mask-act .who .sub.act-warn { color: var(--amber); }@@ -3435,19 +3298,6 @@ body:not(.side-nav) #view-settings .set-head.stuck::before { box-shadow: 0 1px 0.mask-try-hits { display: flex; flex-direction: column; }.mask-try-note { font-size: 11.5px; color: var(--muted); }.mask-try-note.block { color: var(--red); font-weight: 500; }-.mr-x { color: var(--muted); font-variant-numeric: tabular-nums; }-.mr-snip { margin-top: 8px; padding: 9px 11px; border-radius: 8px; border: 1px solid var(--line); background: var(--card-2); font-family: var(--code); font-size: 11.5px; line-height: 1.65; color: var(--fg-2); white-space: pre-wrap; overflow-wrap: anywhere; }-.mr-ph { --k: var(--accent); padding: 1px 4px; border-radius: 4px; color: var(--fg); background: color-mix(in srgb, var(--k) 16%, transparent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--k) 30%, transparent); outline: none; cursor: default; }-.mr-ph:hover { background: color-mix(in srgb, var(--k) 26%, transparent); }-.mr-ph:focus-visible { background: color-mix(in srgb, var(--k) 26%, transparent); }-.mr-note { margin-top: 8px; font-size: 11.5px; color: var(--muted); }-.mr-none { padding: 26px 12px; text-align: center; font-size: 12.5px; color: var(--muted); }-.mr-none.err { color: var(--red); }-.mr-more { display: block; margin: 10px auto 0; }-@media (max-width: 560px) {- .mr-kind:not(:first-child) { display: none; }- .mr-route .model { display: none; }-}/* a request's masked values, on Recent calls and the Routing page */.mask-badge { flex: none; display: inline-flex; align-items: center; gap: 3px; height: 18px; padding: 0 6px 0 5px; border: 0; border-radius: 99px; background: var(--accent-soft); color: var(--accent); font: inherit; font-size: 11px; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; cursor: default; }diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.jsindex f3063b456..8b15b68b3 100644--- a/internal/gui/assets/app.js+++ b/internal/gui/assets/app.js@@ -4042,6 +4042,8 @@ async function load(again) {// does: drawn again only on a change, with no skeleton between; on the// Overview, where the allowances are, that is opening them (#1588)if (view === "usage") await magpie.call("usage", "refresh", again);+ // the Masking page names agents and providers from what came back+ if (view === "masking") await magpie.call("masking", "refresh", again);// so is an open sync form (WebDAV, export, import): its passwords are// never sent back, so a rebuild would empty itif (view === "settings" && !syncOpen) await loadSettings();@@ -21857,7 +21859,7 @@ async function discoveryOffWarning() {// renderRedact: what the gateway masks before a request goes to a vendor —// secrets, personal data, the user's own words — and puts back in what the// vendor answers. The page says it in three parts under what masking did-// (renderMaskObs): how it is found (the local model first, then the+// (Insights › Masking): how it is found (the local model first, then the// rules), what to mask, what is shared.function renderRedact(s, keep) {const box = $("#redactList"), find = $("#findList"), share = $("#shareList");@@ -21929,7 +21931,13 @@ function renderRedact(s, keep) {// rides on that event: nothing goes without itif (!s.noStats) rowIn(share, t("Share the agents, providers and models I use"), t("Sent with that event, by magpie's own ids, with how many of each, and how often each partner was shown, opened and added; a provider you added yourself is only “custom”. No names, addresses, accounts, keys or usage"),onOff(!s.noUsageStats, (on) => savePrefs({ ...keep, noUsageStats: !on })));- renderMaskObs(s);+ // what masking did is a page of its own, Insights › Masking+ if (!featureHides($('#nav button[data-view="masking"]'))) {+ const open = el("button", "", t("Open"));+ open.type = "button";+ open.onclick = () => openMaskRecord(0);+ box.prepend(rowIn(box, t("What was masked"), t("Each request masking changed, what the vendor saw, and how, on Insights › Masking"), open));+ }}// privacyModelRow: the local masking model (internal/pii), downloaded when@@ -22016,13 +22024,7 @@ const MASK_BY = { rule: "Rules", yours: "Your rules", word: "Your words", model:const MASK_WHAT = { search: "Web search", image: "Image", video: "Video", decide: "System One", embeddings: "Embeddings", audio: "Audio" };const SHIELD = "M8 1.8 13 3.6v4.1c0 3-2.1 5.4-5 6.5-2.9-1.1-5-3.5-5-6.5V3.6Z";const PLACEHOLDER = /\{\{[^{}\s]{1,64}\}\}/g;-let maskS = null; // the settings the card was drawn with-let maskSum = null, maskSumDays = 0, maskAt = 0, maskBusy = null, maskBusyDays = 0;-let maskDays = 7; // the card's span, kept per machine-try { if (localStorage.getItem("magpie.maskDays") === "30") maskDays = 30; } catch {}-let maskDrawn = ""; // what the card says, so a redraw that changes nothing is skipped-let maskView = null; // the records, while they are open-let maskSaw = null, maskSawAt = 0, maskSawBusy = false; // the newest records, for the lines the vendor saw+let maskSum = null; // the summary Insights › Masking read last: its kinds' coloursconst maskValues = new Map(); // placeholder → what it stood for, as this magpie told itconst maskKindName = (k) => MASK_KINDS[k] ? t(MASK_KINDS[k]) : k;const maskByName = (b) => MASK_BY[b] ? t(MASK_BY[b]) : b;@@ -22110,215 +22112,6 @@ function maskTipOn(anchor, v) {anchor.onmouseleave = anchor.onblur = maskTipOff;}-// maskLoad reads the summary for the days shown, when what is kept is-// older than 10s or for other days; forced, it reads again whatever is kept-function maskLoad(force) {- const days = maskDays;- if (maskBusy && maskBusyDays === days) return maskBusy;- if (!force && maskSum && maskSumDays === days && Date.now() - maskAt < 10000) return null;- maskBusyDays = days;- const p = maskBusy = api("masking/summary?days=" + days).then((sum) => {- if (days !== maskDays) return;- maskSum = { days: [], kinds: [], agents: [], providers: [], values: [], by: {}, n: 0, distinct: 0, requests: 0, ...(sum || {}) };- maskSumDays = days;- maskAt = Date.now();- }).catch(() => {}).finally(() => { if (maskBusy === p) maskBusy = null; });- return p;-}--// renderMaskObs draws the card with the summary kept, and again when a-// fresh one is in-function renderMaskObs(s) {- maskS = s;- if (!providers && !maskProvAsked) {- maskProvAsked = true;- api("providers").then((r) => { maskProv = r; drawMaskObs(); if (maskView) drawMaskRecs(); }).catch(() => { maskProvAsked = false; });- }- if (maskView && maskView.lang !== document.documentElement.lang) drawMaskRecs();- drawMaskObs();- maskLoad()?.then(drawMaskObs);-}-// while Privacy is on screen the card keeps up with requests as they go-setInterval(() => {- if (view !== "settings" || setShown !== "privacy" || document.hidden || !maskS) return;- maskLoad(true)?.then(drawMaskObs);- if (maskView && !maskView.busy) maskRefreshRecs();-}, 15000);--function drawMaskObs() {- const box = $("#maskObs");- if (!box || !maskS) return;- const s = maskS;- const sum = maskSumDays === maskDays ? maskSum : null;- const on = !!(s.redact || s.redactPersonal);- if (sum?.requests) maskSawLoad();- const saw = maskSawLines();- const key = JSON.stringify([document.documentElement.lang, maskDays, on, sum, saw?.texts, state.agents?.length, (providers || maskProv)?.providers?.length]);- if (key === maskDrawn && box.firstChild) return;- maskDrawn = key;- // it moves when it first has numbers to say, and for other days: not- // on every poll- const move = !!sum && box.dataset.drawn !== String(maskDays) && !stillMotion();- if (sum) box.dataset.drawn = String(maskDays);- maskTipOff();- box.replaceChildren();- box.classList.toggle("off", !on);-- const head = el("div", "mo-head");- const words = el("div", "mo-title");- words.append(el("div", "mo-name", t("Kept from vendors")),- el("div", "mo-sub", on ? t("Masked on this computer before each request left it, and put back in each answer") : t("Masking is off: requests go to vendors as they are")));- head.append(words, el("span", "grow"));- if (sum?.requests || maskDays === 30) head.append(segs([["7", t("7 days")], ["30", t("30 days")]], String(maskDays), (v) => {- maskDays = +v;- try { localStorage.setItem("magpie.maskDays", v); } catch {}- maskLoad(true)?.then(drawMaskObs);- }));- box.append(head);- if (!sum) {- const sk = el("div", "mo-hero");- sk.append(el("span", "skeleton mo-sk-num"), el("span", "skeleton mo-sk-chart"));- box.append(sk);- return;- }- if (!sum.requests && !on) {- box.append(el("div", "mo-empty", t("Turn on Mask secrets or Mask personal data below, and what is kept from vendors shows here, request by request")));- return;- }-- // the number in full; beside it what makes it up, and the days- const hero = el("div", "mo-hero"), count = el("div", "mo-count");- const num = el("div", "mo-num", sum.n.toLocaleString(intlLang()));- const unit = el("div", "mo-unit", t(sum.n === 1 ? "value masked" : "values masked"));- unit.append(el("span", "", t(maskDays === 30 ? "30 days" : "7 days")));- count.append(num, unit);- const stats = el("div", "mo-stats");- const stat = (label, n) => { const r = el("div", "mo-stat"); r.append(el("span", "", label), el("b", "", fmtN(n))); stats.append(r); };- if (sum.requests) {- stat(t("Different values"), sum.distinct);- stat(t("Requests"), sum.requests);- if (sum.blocked) stat(t("Held back"), sum.blocked);- if (sum.warned) stat(t("Sent as written"), sum.warned);- } else stats.append(el("div", "mo-stat", t("Nothing yet in these days")));- const chart = el("div", "mo-days");- stats.append(chart);- hero.append(count, stats);- box.append(hero);- maskStrip(chart, sum.days, move);- if (move && sum.n) maskCountUp(num, sum.n);- if (!sum.requests) {- box.append(el("div", "mo-empty", t("A request that carries a key, a password or personal data shows here as it goes")));- return;- }-- // agents, this computer, providers; then the newest request- if (sum.agents.length && sum.providers.length) box.append(maskFlow(sum, move));- if (saw) box.append(maskSawPane(saw, move));-- // what was kept and what found it; beside them the values masked most- const low = el("div", "mo-low"), ledger = el("div", "mo-ledger");- if (sum.kinds.length) {- const top = sum.kinds.slice(0, 6), rest = sum.kinds.slice(6);- const rows = top.map((k) => ({ n: k.n, label: maskKindName(k.name), open: { kind: k.name }, tip: t("Show the requests with {kind}", { kind: maskKindName(k.name) }) }));- if (rest.length) rows.push({ n: rest.reduce((a, k) => a + k.n, 0), label: t("Other") });- ledger.append(maskLedger(t("What was kept"), "kind", rows));- }- const by = Object.keys(MASK_BY).filter((b) => sum.by?.[b]).map((b) => ({ n: sum.by[b], label: maskByName(b), open: { by: b }, model: b === "model",- tip: b === "model" ? t(sum.by.model === 1 ? "1 value found by the local model, which no rule recognises" : "{n} values found by the local model, which no rule recognises", { n: fmtN(sum.by.model) }) : "" }));- if (by.length) ledger.append(maskLedger(t("Found by"), "by", by));- low.append(ledger);- if (sum.values.length) {- const sec = el("div", "mo-top"), lh = el("div", "mo-lh");- lh.append(el("span", "label", t("Masked most")), el("span", "grow"), el("span", "mo-hint", t("Point at one to see what it was")));- const wrap = el("div", "mo-values"), max = sum.values[0].n || 1;- for (const [i, v] of sum.values.slice(0, 8).entries()) {- const c = el("button", "mo-val"), sh = maskShape(v.head, v.len), bar = el("span", "bar"), f = el("i");- c.type = "button";- c.setAttribute("aria-label", maskKindName(v.kind) + " " + sh);- f.style.width = Math.max(3, (100 * v.n) / max) + "%";- bar.append(f);- c.append(el("span", "i", String(i + 1).padStart(2, "0")), el("span", "sh", sh), el("span", "by", maskByName(v.by)), bar, el("span", "x", fmtN(v.n)));- maskTipOn(c, { p: v.p, kind: v.kind, by: v.by, meta: t(v.requests === 1 ? "In 1 request, {when}" : "In {n} requests, most recently {when}", { n: fmtN(v.requests), when: ago(v.last) }) });- c.onclick = () => maskOpenRecords({ kind: v.kind });- wrap.append(c);- }- sec.append(lh, wrap);- low.append(sec);- }- box.append(low);-- const foot = el("div", "mo-foot");- foot.append(el("span", "mo-note", t("Kept on this computer for 30 days, without the values themselves")));- const open = el("button", "text mo-open");- open.append(el("span", "", t("View records")), svg(CHEV_R, 11, 1.7));- open.onclick = () => maskOpenRecords({});- foot.append(open);- box.append(foot);- // each part rises out of a blur- if (move) for (const [i, n] of [...box.children].slice(1).entries()) n.animate([{ opacity: 0, transform: "translateY(8px)", filter: "blur(6px)" }, {}], { duration: 1100, delay: i * 120, easing: "cubic-bezier(.2, .7, .1, 1)", fill: "backwards" });-}--function maskCountUp(node, n) {- const start = performance.now(), ms = 1100;- const step = (now) => {- if (!node.isConnected) return;- const p = Math.min(1, (now - start) / ms);- const e = p === 1 ? 1 : 1 - Math.pow(2, -10 * p);- node.textContent = Math.round(n * e).toLocaleString(intlLang());- if (p < 1) requestAnimationFrame(step);- };- requestAnimationFrame(step);-}--// maskStrip: the values masked each day, a bar a day on a hairline, today-// in the accent; the day pointed at said over it-function maskStrip(box, days, move) {- const total = days.reduce((a, d) => a + d.n, 0);- box.setAttribute("role", "img");- box.setAttribute("aria-label", t("{n} values masked over {days} days", { n: fmtN(total), days: days.length }));- if (!days.length) return;- const max = Math.max(1, ...days.map((d) => d.n));- const bars = el("div", "mo-bars" + (days.length > 14 ? " many" : ""));- const tip = el("div", "mo-ctip");- tip.hidden = true;- const fmt = (d) => d === days.at(-1).day ? t("Today") : new Date(d + "T00:00").toLocaleDateString(intlLang(), { month: "short", day: "numeric" });- days.forEach((d, i) => {- const b = el("span", "mo-day" + (i === days.length - 1 ? " now" : "") + (d.n ? "" : " zero"));- const f = el("i");- if (d.n) f.style.height = Math.max(5, (100 * d.n) / max) + "%";- b.append(f);- b.onpointerenter = () => {- tip.hidden = false;- tip.textContent = `${fmt(d.day)} · ${t(d.n === 1 ? "1 value masked" : "{n} values masked", { n: fmtN(d.n) })} · ${t(d.requests === 1 ? "1 request" : "{n} requests", { n: fmtN(d.requests) })}`;- const w = tip.offsetWidth, W = box.clientWidth, x = b.offsetLeft + b.offsetWidth / 2;- tip.style.left = Math.max(w / 2, Math.min(x, W - w / 2)) + "px";- };- b.onpointerleave = () => { tip.hidden = true; };- if (move && d.n) f.animate([{ transform: "scaleY(0)" }, { transform: "none" }], { duration: 760, delay: 160 + (i * 520) / days.length, easing: "cubic-bezier(.32, .72, 0, 1)", fill: "backwards" });- bars.append(b);- });- const axis = el("div", "mo-axis");- axis.append(el("span", "", fmt(days[0].day)), el("span", "", fmt(days.at(-1).day)));- box.append(bars, axis, tip);-}--// maskLedger: a column of the breakdown; a row opens its records-function maskLedger(title, kind, rows) {- const col = el("div", "mo-ledg " + kind);- col.append(el("div", "label", title));- for (const r of rows) {- const b = el("button", "mo-row" + (r.model ? " model" : ""));- b.type = "button";- b.append(el("span", "nm", r.label), el("b", "", fmtN(r.n)));- if (r.open) {- if (r.tip) b.title = r.tip;- b.onclick = () => maskOpenRecords(r.open);- } else b.disabled = true;- col.append(b);- }- return col;-}-// maskSnipTexts: a record's lines around its values, each piece of text// once where values side by side share itfunction maskSnipTexts(r) {@@ -22326,20 +22119,6 @@ function maskSnipTexts(r) {const all = [...new Set(Object.values(r.snips || {}))];return all.filter((x, i) => !all.some((y, j) => j != i && (y.length > x.length || y.length == x.length && j < i) && y.includes(core(x))));}-// the newest records, read again with the summary; their lines live in-// memory only, so there are none after a restart-function maskSawLoad() {- if (maskSawBusy || Date.now() - maskSawAt < 14000) return;- maskSawBusy = true;- api("masking/records?limit=12").then((r) => { maskSaw = r?.records || []; })- .catch(() => {})- .finally(() => { maskSawBusy = false; maskSawAt = Date.now(); drawMaskObs(); });-}-// the newest record with lines, up to three of them-function maskSawLines() {- const r = (maskSaw || []).find((r) => maskSnipTexts(r).length);- return r && { r, texts: maskSnipTexts(r).slice(0, 3).map((x) => x.replace(/\s+/g, " ")), info: new Map((r.values || []).map((x) => [x.p, x])) };-}// maskPlace: a placeholder as the text carried it, in its kind's colour,// what it stood for shown while pointed atfunction maskPlace(cls, p, x) {@@ -22350,342 +22129,6 @@ function maskPlace(cls, p, x) {maskTipOn(mark, { p, kind, by: x?.b || "known" });return mark;}-// maskSawPane: the newest request's lines as the vendor got them, or as-// written here, each value read from this magpie's memory when asked-function maskSawPane(saw, move) {- const pane = el("div", "mo-saw"), r = saw.r;- const h = el("div", "mo-lh");- h.append(el("span", "label", t("Latest request")), el("span", "mo-hint", [maskWho(r.agent, "agent").name + " → " + maskWho(r.provider, "provider").name, ago(r.t), t(r.n === 1 ? "1 value masked" : "{n} values masked", { n: fmtN(r.n) })].join(" · ")), el("span", "grow"));- const body = el("div", "mo-lines");- const fill = (here) => {- maskTipOff();- body.replaceChildren();- let k = 0;- for (const text of saw.texts) {- const s = el("div", "mo-snip");- let at = 0;- for (const m of text.matchAll(PLACEHOLDER)) {- s.append(document.createTextNode(text.slice(at, m.index)));- let mark;- if (here) {- mark = el("span", "mo-orig", m[0]);- maskValue(m[0]).then((v) => { if (v === null) mark.classList.add("gone"); else mark.textContent = v; });- } else {- mark = maskPlace("mo-ph", m[0], saw.info.get(m[0]));- // a marker drawn over the value, then lifted- const ink = { backgroundColor: "var(--accent)", color: "transparent" };- if (move) mark.animate([{ clipPath: "inset(0 100% 0 0)", ...ink }, { clipPath: "inset(0)", ...ink, offset: .55 }, { clipPath: "inset(0)" }],- { duration: 900, delay: 900 + k++ * 180, easing: "cubic-bezier(.65, 0, .35, 1)", fill: "backwards" });- }- s.append(mark);- at = m.index + m[0].length;- }- s.append(document.createTextNode(text.slice(at)));- body.append(s);- }- move = false;- };- h.append(segs([["v", t("What the vendor saw")], ["h", t("As written here")]], "v", (v) => fill(v === "h")));- fill(false);- pane.append(h, body);- return pane;-}--// maskFlow: hairlines from the agents into this computer, uneven as-// written, and out of it to the providers, even as placeholders-function maskFlow(sum, move) {- const sec = el("div", "mo-sec mo-fl"), flow = el("div", "mo-flow");- const side = (list, kind) => {- const shown = list.slice(0, 4), rest = list.slice(4);- const rows = shown.map((x) => ({ id: x.name, n: x.n, ...maskWho(x.name, kind) }));- if (rest.length) rows.push({ id: "", n: rest.reduce((a, x) => a + x.n, 0), name: t("{n} more", { n: rest.length }) });- const col = el("div", "mo-col " + kind);- for (const r of rows) {- const b = el("button", "mo-node");- b.type = "button";- b.append(el("span", "nm", r.name), el("span", "ct", fmtN(r.n)));- if (r.id) {- b.title = t("Show what {name} sent masked", { name: r.name });- b.onclick = () => maskOpenRecords({ [kind]: r.id });- } else b.disabled = true;- col.append(b);- }- return [col, rows];- };- const [from, fromRows] = side(sum.agents, "agent");- const [to, toRows] = side(sum.providers, "provider");- const mid = el("div", "mo-mid");- const rowH = 48, H = Math.max(fromRows.length, toRows.length, 2) * rowH;- const max = Math.max(...fromRows.map((r) => r.n), ...toRows.map((r) => r.n), 1);- const hub = el("span", "mo-hub");- hub.append(svg(SHIELD, 16, 1.3));- // drawn in the middle's own pixels on each resize: a stretched viewBox- // would bend the hairlines- const s = sv("svg", { "aria-hidden": "true" });- let drawnW = 0;- const draw = () => {- const W = Math.round(mid.clientWidth);- if (!W || W === drawnW) return;- drawnW = W;- s.setAttribute("viewBox", `0 0 ${W} ${H}`);- s.replaceChildren();- const m = W / 2, still = stillMotion(), lines = [];- const add = (tag, a, to = s) => { const n = sv(tag, a); to.append(n); return n; };- const curve = (x0, y0, x1, y1) => `M${x0},${y0}C${(x0 + x1) / 2},${y0} ${(x0 + x1) / 2},${y1} ${x1},${y1}`;- const bundle = (rows, out) => {- const ks = rows.map((r) => Math.max(1, Math.round(24 * r.n / max))), all = ks.reduce((a, k) => a + k, 0);- let j = 0, rnd = out ? 11 : 7;- rows.forEach((r, i) => {- const y = (H - rows.length * rowH) / 2 + (i + .5) * rowH;- for (let q = 0; q < ks[i]; q++, j++) {- const at = all > 1 ? H * (.2 + .6 * j / (all - 1)) : H / 2;- rnd = (rnd * 16807) % 2147483647;- const end = y + (q - (ks[i] - 1) / 2) * 1.6 + (out ? 0 : (rnd % 30 - 15) / 10);- const d = out ? curve(m, at, W, end) : curve(0, end, m, at);- lines.push(add("path", { d, pathLength: 1, class: "mo-th" + (out ? " out" : "") + (ks[i] === 1 ? " one" : ""), "stroke-opacity": ks[i] === 1 ? (out ? .8 : .4) : out ? .42 : .07 + (rnd % 20) / 100 }));- // a value goes in round, a placeholder out square- if (q === ks[i] >> 1 && !still) for (let k = 0, dots = 1 + Math.round(2 * r.n / max); k < dots; k++) {- const dur = 1.7 + i * .5, begin = (out ? dur : 0) + k * 2 * dur / dots + "s";- const z = out ? 1.8 : 1.7, dot = add("rect", { x: -z, y: -z, width: 2 * z, height: 2 * z, rx: out ? .6 : z, class: "mo-dot" + (out ? " out" : "") });- const a = { dur: dur + "s", begin, repeatCount: "indefinite" };- add("animateMotion", { path: d, ...a }, dot);- add("animate", { attributeName: "opacity", values: "0;1;1;0", keyTimes: "0;.1;.85;1", ...a }, dot);- }- }- });- };- bundle(fromRows, false);- bundle(toRows, true);- // this computer: a ticked line, and a mark going down it- add("line", { x1: m, y1: 0, x2: m, y2: H, class: "mo-mem" });- for (let y = 0; y <= H; y += 19) add("line", { x1: m - 3, y1: y, x2: m + 3, y2: y, class: "mo-tick" });- if (!still) add("rect", { x: m - 1, y: 0, width: 2, height: 22, rx: 1, class: "mo-scan" }).style.setProperty("--h", H - 22 + "px");- // drawn in once, the way in first- if (move) lines.forEach((p) => {- p.animate([{ strokeDashoffset: 1 }, {}], { duration: 2400, delay: p.classList.contains("out") ? 700 : 300, easing: "cubic-bezier(.3, .6, .1, 1)", fill: "backwards" });- });- move = false;- };- mid.append(s, hub);- flow.style.height = H + "px";- flow.append(from, mid, to);- new ResizeObserver(draw).observe(mid);- sec.append(flow, el("div", "mo-cap", t("Masked here, on this computer")));- return sec;-}--// ---- the records: each request masking changed, newest first -----function maskOpenRecords(filter, focus) {- maskTipOff();- maskView = { filter: { kind: "", by: "", agent: "", provider: "", ...filter }, records: [], more: false, busy: true, open: new Set(), focus: focus || 0, one: null, lang: "" };- $("#setPage-privacy").classList.add("recs");- drawMaskRecs();- maskFetchRecs();- if (focus) api("masking/record?key=" + focus)- .then((r) => { if (maskView?.focus === focus) { maskView.one = r; maskView.open.add(focus); drawMaskRecs(); } })- .catch(() => { if (maskView?.focus === focus) { maskView.one = false; drawMaskRecs(); } });-}-function maskCloseRecords() {- maskTipOff();- maskView = null;- $("#setPage-privacy").classList.remove("recs");- const box = $("#maskRecs");- box.hidden = true;- box.replaceChildren();-}-function maskQuery(before) {- const q = new URLSearchParams({ limit: "40" });- if (before) q.set("before", before);- for (const [k, v] of Object.entries(maskView.filter)) if (v) q.set(k, v);- return "masking/records?" + q;-}-function maskFetchRecs(more) {- const v = maskView;- v.busy = true;- v.error = "";- if (more) drawMaskRecs();- api(maskQuery(more ? v.records.at(-1)?.key : 0))- .then((r) => {- if (maskView !== v) return;- const got = r?.records || [];- v.records = more ? [...v.records, ...got] : got;- v.more = !!r?.more;- })- .catch((e) => { if (maskView === v) v.error = e.message; })- .finally(() => { if (maskView === v) { v.busy = false; drawMaskRecs(); } });-}-// new records come in over the ones shown, which keep their place-function maskRefreshRecs() {- const v = maskView;- if (!v.records.length) return maskFetchRecs();- api(maskQuery(0)).then((r) => {- if (maskView !== v || !v.records.length) return;- const fresh = (r?.records || []).filter((x) => x.key > v.records[0].key);- if (fresh.length) { v.records = [...fresh, ...v.records]; drawMaskRecs(); }- }).catch(() => {});-}--function drawMaskRecs() {- const v = maskView, box = $("#maskRecs");- if (!v || !box) return;- v.lang = document.documentElement.lang;- maskTipOff();- box.hidden = false;- box.replaceChildren();- const head = el("div", "mr-head");- const back = el("button", "text mr-back");- back.type = "button";- back.append(svg("m9.5 4.5-3 3.5 3 3.5", 12, 1.7), el("span", "", t("Privacy")));- back.onclick = maskCloseRecords;- head.append(back, el("span", "mr-title", t("What was masked")));- box.append(head);-- const sum = maskSum || {};- const bar = el("div", "mr-filters");- const pick = (key, all, title, opts) => {- const b = el("button", "sess-pick");- b.type = "button";- if (v.filter[key] && !opts.some((o) => o.v === v.filter[key])) opts.unshift({ v: v.filter[key], name: v.filter[key] });- sessPick(b, all, v.filter[key], opts, title, (val) => {- v.filter[key] = val || "";- v.focus = 0;- v.one = null;- maskFetchRecs();- });- if (v.filter[key]) b.firstChild.textContent = opts.find((o) => o.v === v.filter[key])?.name || v.filter[key];- bar.append(b);- };- pick("kind", "Every kind", "Kind", (sum.kinds || []).map((k) => ({ v: k.name, name: maskKindName(k.name) })));- pick("by", "Found by anything", "Found by", Object.keys(sum.by || {}).filter((b) => sum.by[b]).map((b) => ({ v: b, name: maskByName(b) })));- pick("agent", "Every agent", "Agent", (sum.agents || []).map((a) => ({ v: a.name, name: maskWho(a.name, "agent").name })));- pick("provider", "Every provider", "Provider", (sum.providers || []).map((p) => ({ v: p.name, name: maskWho(p.name, "provider").name })));- box.append(bar);-- // the request a badge was clicked on, first and open- if (v.focus) {- const h = el("div", "row-head");- h.append(el("span", "label", t("This request")));- const list = el("div", "list mr-group");- if (v.one) list.append(maskRecordRow(v.one, v));- else list.append(el("div", "mr-none", v.one === false ? t("This request's record is gone: records are kept for 30 days") : t("Loading…")));- box.append(h, list);- }- if (v.error) box.append(el("div", "mr-none err", t(v.error)));- else if (!v.records.length) {- if (!v.busy) box.append(el("div", "mr-none", Object.values(v.filter).some(Boolean) ? t("Nothing masked matches these filters") : t("Nothing masked yet")));- else if (!v.focus) box.append(el("div", "mr-none", t("Loading…")));- }- let day = "", list = null;- for (const r of v.records) {- if (r.key === v.focus && v.one) continue;- const d = new Date(r.t).toDateString();- if (d !== day) {- day = d;- const h = el("div", "row-head");- h.append(el("span", "label", maskDayName(r.t)));- list = el("div", "list mr-group");- box.append(h, list);- }- list.append(maskRecordRow(r, v));- }- if (v.more) {- const more = el("button", "text mr-more", v.busy ? t("Loading…") : t("Load more"));- more.disabled = v.busy;- more.onclick = () => maskFetchRecs(true);- box.append(more);- }-}--function maskRecordRow(r, v) {- const item = el("div", "mr-item");- const row = el("button", "mr-row");- row.type = "button";- const chev = el("span", "mr-chev");- chev.append(svg(CHEV_R, 11, 1.6));- const when = el("span", "mr-time", new Date(r.t).toLocaleTimeString(intlLang(), { hour: "2-digit", minute: "2-digit" }));- const route = el("span", "mr-route");- const a = maskWho(r.agent, "agent"), p = maskWho(r.provider, "provider");- if (r.agent) {- if (a.icon) route.append(icon(a.icon));- route.append(el("span", "who", a.name), el("span", "arrow", "→"));- }- if (p.icon && r.provider) route.append(icon(p.icon));- route.append(el("span", "who", r.provider ? p.name : t("A vendor")));- if (r.model) route.append(el("span", "model", "· " + r.model));- if (r.blocked) route.append(el("span", "what held", t("Held back")));- else if (r.what && r.what !== "chat") route.append(el("span", "what", MASK_WHAT[r.what] ? t(MASK_WHAT[r.what]) : r.what));- const kinds = el("span", "mr-kinds");- const by = {};- for (const x of r.values || []) by[x.k] = (by[x.k] || 0) + (x.n || 1);- const ranked = Object.entries(by).sort((x, y) => y[1] - x[1]);- for (const [k, n] of ranked.slice(0, 3)) {- const c = el("span", "mr-kind");- c.append(maskDot(k), el("span", "", maskKindName(k)), el("b", "", "×" + fmtN(n)));- kinds.append(c);- }- if (ranked.length > 3) kinds.append(el("span", "mr-kind more", "+" + (ranked.length - 3)));- const n = el("span", "mr-n", fmtN(r.n));- n.title = t(r.n === 1 ? "1 value masked" : "{n} values masked", { n: fmtN(r.n) });- row.append(chev, when, route, kinds, n);- item.append(row);- const set = (open) => {- item.classList.toggle("open", open);- row.setAttribute("aria-expanded", String(open));- };- set(v.open.has(r.key));- if (v.open.has(r.key)) item.append(maskRecordBody(r));- row.onclick = () => {- const open = !v.open.has(r.key);- if (open) v.open.add(r.key); else v.open.delete(r.key);- set(open);- maskTipOff();- const had = item.querySelector(".mr-body");- if (!open) { if (had) sheet(had, false, () => had.remove()); return; }- had?.remove();- const body = maskRecordBody(r);- item.append(body);- sheet(body, true);- };- return item;-}--// maskRecordBody: each value the request had masked, and the text around-// it as the vendor saw it, each placeholder showing what it was while it is-// pointed at-function maskRecordBody(r) {- const body = el("div", "mr-body");- const vals = el("div", "mr-vals");- for (const x of r.values || []) {- const line = el("div", "mr-val");- const shape = el("span", "mr-shape" + (x.known ? " known" : ""), maskShape(x.h, x.l));- if (x.known) {- shape.tabIndex = 0;- maskTipOn(shape, { p: x.p, kind: x.k, by: x.b });- }- line.append(maskDot(x.k), el("span", "mr-k", maskKindName(x.k)), shape, el("span", "mr-by" + (x.b === "model" ? " model" : ""), maskByName(x.b)));- if (x.n > 1) line.append(el("span", "mr-x", "×" + fmtN(x.n)));- if (x.a === "warn") line.append(el("span", "mr-act warn", t("Sent as written")));- else if (x.a === "block") line.append(el("span", "mr-act block", t("Held back")));- vals.append(line);- }- body.append(vals);- const snips = maskSnipTexts(r).map((x) => [, x]);- if (!snips.length) body.append(el("div", "mr-note", t("The text around them was kept in memory only, and magpie has restarted since")));- const info = new Map((r.values || []).map((x) => [x.p, x]));- for (const [, text] of snips) {- const s = el("div", "mr-snip");- let at = 0;- for (const m of text.matchAll(PLACEHOLDER)) {- s.append(document.createTextNode(text.slice(at, m.index)));- s.append(maskPlace("mr-ph", m[0], info.get(m[0])));- at = m.index + m[0].length;- }- s.append(document.createTextNode(text.slice(at)));- body.append(s);- }- return body;-}-// maskedBadge: what masking swapped in one request (gateway's Masked), for// Recent calls and the Routing page; it opens that request's recordfunction maskedBadge(m) {@@ -22703,11 +22146,11 @@ function maskedBadge(m) {b.onkeydown = (e) => e.stopPropagation(); // Enter on it isn't the row'sreturn b;}+// openMaskRecord: Insights › Masking, on request key when there is one; the+// tray panel opens the window on itfunction openMaskRecord(key) {- openSettings();- if (mode !== "window") return;- setSetTab("privacy", true);- maskOpenRecords({}, key);+ if (mode !== "window") return void api("window/main?view=masking" + (key ? "&key=" + key : ""), {}).catch(() => {});+ show("masking").then((went) => { if (went !== false && key && view === "masking") magpie.call("masking", "focus", key); });}function renderOTel(s, keep) {diff --git a/internal/gui/assets/i18n.js b/internal/gui/assets/i18n.jsindex acb500127..826a8d59a 100644--- a/internal/gui/assets/i18n.js+++ b/internal/gui/assets/i18n.js@@ -3904,6 +3904,21 @@ const I18N = {"System One": "System One","Embeddings": "向量嵌入","Audio": "音频",+ // Insights › Masking (plugins/redact), words said elsewhere too+ "Masking": "脱敏",+ "Each request masking changed, what the vendor saw, and how, on Insights › Masking": "每条被脱敏的请求、厂商看到的样子和遮法,都在 观测 › 脱敏",+ "Settings › Privacy": "设置 › 隐私",+ "By request": "按请求",+ "Received": "收到",+ "Nothing was sent": "什么也没发出",+ "a value": "一个值",+ "The agent": "Agent",+ "Original": "原文",+ "1 value": "1 个值",+ "{n} values": "{n} 个值",+ "1 place": "1 处",+ "as written": "原样",+ "Where": "位置",},"zh-TW": {"None": "無",@@ -7791,6 +7806,21 @@ const I18N = {"System One": "System One","Embeddings": "向量嵌入","Audio": "音訊",+ // Insights › Masking (plugins/redact), words said elsewhere too+ "Masking": "脫敏",+ "Each request masking changed, what the vendor saw, and how, on Insights › Masking": "每則被脫敏的請求、廠商看到的樣子和遮法,都在 觀測 › 脫敏",+ "Settings › Privacy": "設定 › 隱私",+ "By request": "按請求",+ "Received": "收到",+ "Nothing was sent": "什麼也沒發出",+ "a value": "一個值",+ "The agent": "Agent",+ "Original": "原文",+ "1 value": "1 個值",+ "{n} values": "{n} 個值",+ "1 place": "1 處",+ "as written": "原樣",+ "Where": "位置",},ja: {"None": "なし",@@ -11680,6 +11710,21 @@ const I18N = {"System One": "System One","Embeddings": "埋め込み","Audio": "音声",+ // Insights › Masking (plugins/redact), words said elsewhere too+ "Masking": "マスク",+ "Each request masking changed, what the vendor saw, and how, on Insights › Masking": "マスクしたリクエストごとに、ベンダーに届いた姿とマスクの仕方を 観測 › マスク で見られます",+ "Settings › Privacy": "設定 › プライバシー",+ "By request": "リクエスト別",+ "Received": "受信",+ "Nothing was sent": "何も送っていません",+ "a value": "ある値",+ "The agent": "エージェント",+ "Original": "原文",+ "1 value": "1 個の値",+ "{n} values": "{n} 個の値",+ "1 place": "1 か所",+ "as written": "そのまま",+ "Where": "場所",},de: {"None": "Keine",@@ -15569,6 +15614,21 @@ const I18N = {"System One": "System One","Embeddings": "Embeddings","Audio": "Audio",+ // Insights › Masking (plugins/redact), words said elsewhere too+ "Masking": "Maskierung",+ "Each request masking changed, what the vendor saw, and how, on Insights › Masking": "Jede maskierte Anfrage, was der Anbieter sah und wie, unter Einblick › Maskierung",+ "Settings › Privacy": "Einstellungen › Datenschutz",+ "By request": "Nach Anfrage",+ "Received": "Empfangen",+ "Nothing was sent": "Nichts wurde gesendet",+ "a value": "einen Wert",+ "The agent": "Der Agent",+ "Original": "Original",+ "1 value": "1 Wert",+ "{n} values": "{n} Werte",+ "1 place": "1 Stelle",+ "as written": "unverändert",+ "Where": "Wo",},};diff --git a/internal/gui/assets/index.html b/internal/gui/assets/index.htmlindex d3346e378..74791fe1c 100644--- a/internal/gui/assets/index.html+++ b/internal/gui/assets/index.html@@ -13,6 +13,7 @@<link rel="stylesheet" href="plugins/library/library.css"><link rel="stylesheet" href="plugins.css"><link rel="stylesheet" href="plugins/sessions/sessions.css">+<link rel="stylesheet" href="plugins/redact/redact.css"><link rel="stylesheet" href="context.css"><link rel="stylesheet" href="omarchy.css"></head>@@ -55,6 +56,7 @@<button data-view="gateway" data-feature="gateway"><svg class="nav-ic" viewBox="0 0 20 20" width="16" height="16" aria-hidden="true"><g fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="4" width="14" height="5" rx="1.5"/><rect x="3" y="11" width="14" height="5" rx="1.5"/><path d="M6 6.5h.01M6 13.5h.01"/></g></svg><span data-t>Gateway</span></button><span class="nav-gl" data-t>Insights</span><button data-view="usage" data-feature="usage"><svg class="nav-ic" viewBox="0 0 20 20" width="16" height="16" aria-hidden="true"><g fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M4 16V9M8 16V5M12 16v-5M16 16V7"/></g></svg><span data-t>Usage</span></button>+ <button data-view="masking" data-feature="redact"><svg class="nav-ic" viewBox="0 0 16 16" width="16" height="16" aria-hidden="true"><path d="M8 1.8 13 3.6v4.1c0 3-2.1 5.4-5 6.5-2.9-1.1-5-3.5-5-6.5V3.6Z" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linejoin="round"/></svg><span data-t>Masking</span></button><span class="nav-gl" data-t>Extend</span><button data-view="plugins"><svg class="nav-ic" viewBox="0 0 20 20" width="16" height="16" aria-hidden="true"><g fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M8 3.5h4v2.5a1.5 1.5 0 0 0 3 0V3.5h1.5v13H4v-4h2.5a1.5 1.5 0 0 0 0-3H4v-6z"/></g></svg><span data-t>Plugins</span></button></nav>@@ -374,8 +376,6 @@<div class="list prefs" id="disabledModelsList"></div></section><section class="set-page" id="setPage-privacy" role="tabpanel" aria-labelledby="setTab-privacy">- <div class="mask-obs" id="maskObs"></div>- <div class="mask-recs" id="maskRecs" hidden></div><div class="row-head"><span class="label" data-t>How it's found</span></div><div class="list prefs" id="findList"></div><div class="row-head"><span class="label" data-t>What to mask</span></div>@@ -481,12 +481,15 @@<script src="plugins/routing/client.js"></script><script src="plugins/usage/i18n.js"></script><script src="plugins/usage/client.js"></script>+<script src="plugins/redact/i18n.js"></script>+<script src="plugins/redact/client.js"></script><script src="purposes.js"></script><script src="app.js"></script><script src="plugins.js"></script><script src="pluginpages.js"></script><script src="context.js"></script><script src="plugins/usage/page.js"></script>+<script src="plugins/redact/page.js"></script><script src="start.js"></script></body></html>diff --git a/internal/gui/assets/plugins/redact/client.js b/internal/gui/assets/plugins/redact/client.jsnew file mode 100644index 000000000..e09319ea4--- /dev/null+++ b/internal/gui/assets/plugins/redact/client.js@@ -0,0 +1,27 @@+// Insights › Masking: what masking kept from vendors, request by request.+//+// A page the redact plugin adds to the window (kernel.js), its words in+// i18n.js beside this file. This file registers the page and its markup,+// before app.js; page.js, after app.js, is the page's code. The card on+// top says how much was masked over 7 or 30 days and where it went, the+// list under it each request (or each value) masking changed, and a+// request opened says what it carried, what the vendor got instead, and+// how each value was found and put back. The hooks are what the shell+// asks of it: open, refresh (the window came back), reload (Refresh in+// the sidebar), leave, and focus (a masked call's badge opens its request).+magpie.plugin("redact", (ctx) => {+ ctx.slots.add("page", {+ key: "masking",+ title: "Masking",+ html: `+ <section class="msk-card" id="maskCard"></section>+ <section class="msk-list" id="maskList"></section>+ <section class="msk-one" id="maskOne" hidden></section>+`,+ open() { return maskPageOpen(); },+ refresh(again) { return maskPageLoad(again); },+ reload() { return maskPageLoad(true); },+ leave() { maskTipOff(); },+ focus(key) { maskOneOpen(+key); },+ });+});diff --git a/internal/gui/assets/plugins/redact/i18n.js b/internal/gui/assets/plugins/redact/i18n.jsnew file mode 100644index 000000000..5f7361d38--- /dev/null+++ b/internal/gui/assets/plugins/redact/i18n.js@@ -0,0 +1,184 @@+// Insights › Masking's words in each language, the English the key: the+// kernel adds them to i18n.js's (magpie.strings).+magpie.strings({+ zh: {+ "Turn on masking": "打开脱敏",+ "You can also change it in": "也可以在这里调整:",+ "Requests go to vendors as they are": "请求按原样发给厂商",+ "Turned on, keys, passwords, computer names and emails become placeholders before they leave this computer, and are put back in each answer. What each request had masked shows here.": "打开脱敏后,密钥、密码、计算机名、邮箱这些值在离开这台电脑前会换成占位符,回复里再换回来。每条请求遮了什么,都会显示在这里。",+ "magpie masked these on this computer": "magpie 在这台电脑上脱敏",+ "By value": "按值",+ "Read again every 15 seconds while this page is open": "页面打开时每 15 秒刷新一次",+ "Newer request": "较新的请求",+ "Older request": "较早的请求",+ "What happened": "经过",+ "From {agent}": "来自 {agent}",+ "Found 1 value": "发现 1 个值",+ "Found {n} values": "发现 {n} 个值",+ "Replaced 1 place": "替换 1 处",+ "Replaced {n} places": "替换 {n} 处",+ "With placeholders": "换成占位符",+ "Not sent to {provider}": "没有发给 {provider}",+ "Put back 1": "换回 1 处",+ "Put back {n}": "换回 {n} 处",+ "In the answer, before {agent} got it": "在回复交给 {agent} 之前",+ "Nothing to put back": "没有要换回的",+ "The answer named no placeholder": "回复里没有出现占位符",+ "Not known after a restart": "重启后无从得知",+ "This request was not sent": "这条请求没有发出",+ "It carried {kinds}, which you set to hold back, so magpie didn't send it to {provider}. {agent} got an error saying why.": "它带着{kinds},你把这类设成了拦下,所以 magpie 没把它发给 {provider}。{agent} 收到的是一条说明原因的错误。",+ "Mask it instead": "改成只遮住",+ "From now on {kinds} go to vendors as placeholders, like the other values": "今后{kinds}会像其他值一样,以占位符发给厂商",+ "Masked from now on": "今后只遮住",+ "See the rules in Settings": "在设置里看规则",+ "Request content": "请求内容",+ "Only the parts masking changed": "只显示有改动的部分",+ "Side by side": "对照",+ "This request's whole text is no longer in memory: magpie keeps it for the newest requests only. The lines around each value are still here.": "这条请求的全文已不在内存里:magpie 只保留最近的请求。每个值前后的那一小段还在。",+ "What was written is kept in memory only, and magpie has restarted since. Still here: each value's kind, length and first characters, and the line around each placeholder as the vendor got it.": "原文和原值只存在内存里,magpie 重启后就没有了。这里还看得到每个值的种类、长度、开头几个字,以及占位符前后厂商看到的那一小段。",+ "Show only the changes": "只看改动",+ "Show all of it": "显示全部",+ "1 part unchanged": "1 段没有改动",+ "{n} parts unchanged": "{n} 段没有改动",+ "{n} places": "{n} 处",+ "How it was masked": "怎么遮的",+ "In the answer": "回复里",+ "Not named": "没有出现",+ "A value itself is in this computer's memory only: shown while it is pointed at or picked, and gone once magpie restarts. The record on disk keeps its kind, length and first characters.": "原值只存在这台电脑的内存里:指向或选中时才显示,magpie 重启后就没有了。磁盘上的记录只留下种类、长度和开头几个字。",+ },+ "zh-TW": {+ "Turn on masking": "開啟脫敏",+ "You can also change it in": "也可以在這裡調整:",+ "Requests go to vendors as they are": "請求照原樣發給廠商",+ "Turned on, keys, passwords, computer names and emails become placeholders before they leave this computer, and are put back in each answer. What each request had masked shows here.": "開啟脫敏後,金鑰、密碼、電腦名稱、電子郵件這些值在離開這台電腦前會換成佔位符,回覆裡再換回來。每則請求遮了什麼,都會顯示在這裡。",+ "magpie masked these on this computer": "magpie 在這台電腦上脫敏",+ "By value": "按值",+ "Read again every 15 seconds while this page is open": "頁面開啟時每 15 秒重新整理一次",+ "Newer request": "較新的請求",+ "Older request": "較早的請求",+ "What happened": "經過",+ "From {agent}": "來自 {agent}",+ "Found 1 value": "發現 1 個值",+ "Found {n} values": "發現 {n} 個值",+ "Replaced 1 place": "替換 1 處",+ "Replaced {n} places": "替換 {n} 處",+ "With placeholders": "換成佔位符",+ "Not sent to {provider}": "沒有發給 {provider}",+ "Put back 1": "換回 1 處",+ "Put back {n}": "換回 {n} 處",+ "In the answer, before {agent} got it": "在回覆交給 {agent} 之前",+ "Nothing to put back": "沒有要換回的",+ "The answer named no placeholder": "回覆裡沒有出現佔位符",+ "Not known after a restart": "重新啟動後無從得知",+ "This request was not sent": "這則請求沒有發出",+ "It carried {kinds}, which you set to hold back, so magpie didn't send it to {provider}. {agent} got an error saying why.": "它帶著{kinds},你把這類設成了攔下,所以 magpie 沒把它發給 {provider}。{agent} 收到的是一則說明原因的錯誤。",+ "Mask it instead": "改成只遮住",+ "From now on {kinds} go to vendors as placeholders, like the other values": "今後{kinds}會像其他值一樣,以佔位符發給廠商",+ "Masked from now on": "今後只遮住",+ "See the rules in Settings": "在設定裡看規則",+ "Request content": "請求內容",+ "Only the parts masking changed": "只顯示有改動的部分",+ "Side by side": "對照",+ "This request's whole text is no longer in memory: magpie keeps it for the newest requests only. The lines around each value are still here.": "這則請求的全文已不在記憶體裡:magpie 只保留最近的請求。每個值前後的那一小段還在。",+ "What was written is kept in memory only, and magpie has restarted since. Still here: each value's kind, length and first characters, and the line around each placeholder as the vendor got it.": "原文和原值只存在記憶體裡,magpie 重新啟動後就沒有了。這裡還看得到每個值的種類、長度、開頭幾個字,以及佔位符前後廠商看到的那一小段。",+ "Show only the changes": "只看改動",+ "Show all of it": "顯示全部",+ "1 part unchanged": "1 段沒有改動",+ "{n} parts unchanged": "{n} 段沒有改動",+ "{n} places": "{n} 處",+ "How it was masked": "怎麼遮的",+ "In the answer": "回覆裡",+ "Not named": "沒有出現",+ "A value itself is in this computer's memory only: shown while it is pointed at or picked, and gone once magpie restarts. The record on disk keeps its kind, length and first characters.": "原值只存在這台電腦的記憶體裡:指向或選取時才顯示,magpie 重新啟動後就沒有了。磁碟上的記錄只留下種類、長度和開頭幾個字。",+ },+ ja: {+ "Turn on masking": "マスクをオンにする",+ "You can also change it in": "こちらでも変更できます:",+ "Requests go to vendors as they are": "リクエストはそのままベンダーに送られます",+ "Turned on, keys, passwords, computer names and emails become placeholders before they leave this computer, and are put back in each answer. What each request had masked shows here.": "オンにすると、キー・パスワード・コンピュータ名・メールアドレスはこのコンピュータを出る前にプレースホルダーに置き換わり、返答の中で元に戻されます。各リクエストで何をマスクしたかがここに表示されます。",+ "magpie masked these on this computer": "magpie がこのコンピュータでマスク",+ "By value": "値別",+ "Read again every 15 seconds while this page is open": "このページを開いている間、15 秒ごとに読み直します",+ "Newer request": "新しいリクエスト",+ "Older request": "古いリクエスト",+ "What happened": "経過",+ "From {agent}": "{agent} から",+ "Found 1 value": "1 個の値を検出",+ "Found {n} values": "{n} 個の値を検出",+ "Replaced 1 place": "1 か所を置換",+ "Replaced {n} places": "{n} か所を置換",+ "With placeholders": "プレースホルダーに",+ "Not sent to {provider}": "{provider} には送っていません",+ "Put back 1": "1 か所を戻した",+ "Put back {n}": "{n} か所を戻した",+ "In the answer, before {agent} got it": "返答が {agent} に届く前に",+ "Nothing to put back": "戻すものなし",+ "The answer named no placeholder": "返答にプレースホルダーは出てきませんでした",+ "Not known after a restart": "再起動後はわかりません",+ "This request was not sent": "このリクエストは送信されませんでした",+ "It carried {kinds}, which you set to hold back, so magpie didn't send it to {provider}. {agent} got an error saying why.": "{kinds}が含まれていて、それをブロックに設定しているため、magpie は {provider} に送りませんでした。{agent} には理由を説明するエラーが返っています。",+ "Mask it instead": "マスクに変更",+ "From now on {kinds} go to vendors as placeholders, like the other values": "今後、{kinds}もほかの値と同じくプレースホルダーとしてベンダーに送られます",+ "Masked from now on": "今後はマスク",+ "See the rules in Settings": "設定でルールを見る",+ "Request content": "リクエストの内容",+ "Only the parts masking changed": "マスクで変わった部分だけ",+ "Side by side": "並べて比較",+ "This request's whole text is no longer in memory: magpie keeps it for the newest requests only. The lines around each value are still here.": "このリクエストの全文はもうメモリにありません:magpie は最近のリクエストの分だけ保持します。各値の前後の行はまだ残っています。",+ "What was written is kept in memory only, and magpie has restarted since. Still here: each value's kind, length and first characters, and the line around each placeholder as the vendor got it.": "原文と元の値はメモリにだけあり、magpie はその後再起動しています。残っているのは各値の種類・長さ・先頭の数文字と、ベンダーに届いたプレースホルダー前後の行です。",+ "Show only the changes": "変更だけ表示",+ "Show all of it": "すべて表示",+ "1 part unchanged": "変更なし 1 件",+ "{n} parts unchanged": "変更なし {n} 件",+ "{n} places": "{n} か所",+ "How it was masked": "マスクの仕方",+ "In the answer": "返答で",+ "Not named": "出てこなかった",+ "A value itself is in this computer's memory only: shown while it is pointed at or picked, and gone once magpie restarts. The record on disk keeps its kind, length and first characters.": "値そのものはこのコンピュータのメモリにだけあります:ポイントするか選んだときだけ表示され、magpie を再起動すると消えます。ディスク上の記録に残るのは種類・長さ・先頭の数文字です。",+ },+ de: {+ "Turn on masking": "Maskierung einschalten",+ "You can also change it in": "Auch zu ändern unter",+ "Requests go to vendors as they are": "Anfragen gehen unverändert an die Anbieter",+ "Turned on, keys, passwords, computer names and emails become placeholders before they leave this computer, and are put back in each answer. What each request had masked shows here.": "Eingeschaltet werden Schlüssel, Passwörter, Computernamen und E-Mails zu Platzhaltern, bevor sie diesen Computer verlassen, und in jeder Antwort zurückgesetzt. Was jede Anfrage maskiert hatte, steht dann hier.",+ "magpie masked these on this computer": "magpie hat sie auf diesem Computer maskiert",+ "By value": "Nach Wert",+ "Read again every 15 seconds while this page is open": "Wird alle 15 Sekunden neu gelesen, solange diese Seite offen ist",+ "Newer request": "Neuere Anfrage",+ "Older request": "Ältere Anfrage",+ "What happened": "Was geschah",+ "From {agent}": "Von {agent}",+ "Found 1 value": "1 Wert gefunden",+ "Found {n} values": "{n} Werte gefunden",+ "Replaced 1 place": "1 Stelle ersetzt",+ "Replaced {n} places": "{n} Stellen ersetzt",+ "With placeholders": "Durch Platzhalter",+ "Not sent to {provider}": "Nicht an {provider} gesendet",+ "Put back 1": "1 zurückgesetzt",+ "Put back {n}": "{n} zurückgesetzt",+ "In the answer, before {agent} got it": "In der Antwort, bevor {agent} sie bekam",+ "Nothing to put back": "Nichts zurückzusetzen",+ "The answer named no placeholder": "Die Antwort nannte keinen Platzhalter",+ "Not known after a restart": "Nach einem Neustart unbekannt",+ "This request was not sent": "Diese Anfrage wurde nicht gesendet",+ "It carried {kinds}, which you set to hold back, so magpie didn't send it to {provider}. {agent} got an error saying why.": "Sie enthielt {kinds}, die du zurückhalten lässt, also hat magpie sie nicht an {provider} gesendet. {agent} bekam einen Fehler mit dem Grund.",+ "Mask it instead": "Stattdessen maskieren",+ "From now on {kinds} go to vendors as placeholders, like the other values": "Ab jetzt gehen {kinds} wie die anderen Werte als Platzhalter an die Anbieter",+ "Masked from now on": "Ab jetzt maskiert",+ "See the rules in Settings": "Regeln in den Einstellungen ansehen",+ "Request content": "Inhalt der Anfrage",+ "Only the parts masking changed": "Nur die Teile, die die Maskierung änderte",+ "Side by side": "Nebeneinander",+ "This request's whole text is no longer in memory: magpie keeps it for the newest requests only. The lines around each value are still here.": "Der ganze Text dieser Anfrage ist nicht mehr im Speicher: magpie behält ihn nur für die neuesten Anfragen. Die Zeilen um jeden Wert sind noch da.",+ "What was written is kept in memory only, and magpie has restarted since. Still here: each value's kind, length and first characters, and the line around each placeholder as the vendor got it.": "Was geschrieben war, liegt nur im Speicher, und magpie wurde seitdem neu gestartet. Noch da: Art, Länge und erste Zeichen jedes Werts und die Zeile um jeden Platzhalter, wie der Anbieter sie bekam.",+ "Show only the changes": "Nur die Änderungen zeigen",+ "Show all of it": "Alles zeigen",+ "1 part unchanged": "1 Teil unverändert",+ "{n} parts unchanged": "{n} Teile unverändert",+ "{n} places": "{n} Stellen",+ "How it was masked": "Wie maskiert wurde",+ "In the answer": "In der Antwort",+ "Not named": "Nicht genannt",+ "A value itself is in this computer's memory only: shown while it is pointed at or picked, and gone once magpie restarts. The record on disk keeps its kind, length and first characters.": "Ein Wert selbst liegt nur im Speicher dieses Computers: gezeigt, solange er angezeigt oder gewählt ist, und weg, sobald magpie neu startet. Der Eintrag auf der Festplatte behält Art, Länge und erste Zeichen.",+ },+});diff --git a/internal/gui/assets/plugins/redact/page.js b/internal/gui/assets/plugins/redact/page.jsnew file mode 100644index 000000000..3631e3244--- /dev/null+++ b/internal/gui/assets/plugins/redact/page.js@@ -0,0 +1,843 @@+// Insights › Masking's code (client.js has its markup and hooks): run after+// app.js, whose masking helpers it shares (maskWho, maskTip, maskColor,+// maskShape, maskValue: Settings' Try it and the masked calls' badges use+// them too). What a placeholder stood for is in this magpie's memory alone,+// never on disk, so after a restart it is gone; so is the text a request+// went out with (/api/masking/sent), kept for the newest requests only.++// ---- the summary: over 7 or 30 days, kept per machine ----+let maskSumDays = 0, maskAt = 0, maskBusy = null, maskBusyDays = 0;+let maskDays = 7;+try { if (localStorage.getItem("magpie.maskDays") === "30") maskDays = 30; } catch {}+let maskDrawn = ""; // what the card says, so a redraw that changes nothing is skipped+let maskKeyRead = false; // the address's key=, a masked call opened from the tray panel+// the list: by request or by value, and what it is narrowed to+const maskL = { mode: "req", facet: "", kind: "", agent: "", provider: "", records: [], more: false, busy: false, error: "", read: false };+let maskO = null; // the request open, while it is++// maskLoad reads the summary for the days shown, when what is kept is+// older than 10s or for other days; forced, it reads again whatever is kept+function maskLoad(force) {+ const days = maskDays;+ if (maskBusy && maskBusyDays === days) return maskBusy;+ if (!force && maskSum && maskSumDays === days && Date.now() - maskAt < 10000) return null;+ maskBusyDays = days;+ const p = maskBusy = api("masking/summary?days=" + days).then((sum) => {+ if (days !== maskDays) return;+ maskSum = { days: [], kinds: [], agents: [], providers: [], values: [], by: {}, n: 0, distinct: 0, requests: 0, ...(sum || {}) };+ maskSumDays = days;+ maskAt = Date.now();+ }).catch(() => {}).finally(() => { if (maskBusy === p) maskBusy = null; });+ return p;+}+const maskSettings = () => prefs || state?.settings || {};+const maskOn = () => { const s = maskSettings(); return !!(s.redact || s.redactPersonal); };++function maskPageOpen() {+ if (!providers && !maskProvAsked) {+ maskProvAsked = true;+ api("providers").then((r) => { maskProv = r; maskDrawn = ""; maskDrawAll(); }).catch(() => { maskProvAsked = false; });+ }+ // a masked call in the tray panel opens the window on its request+ if (!maskKeyRead) {+ maskKeyRead = true;+ const k = +params.get("key");+ if (k) {+ const q = new URLSearchParams(location.search);+ q.delete("key");+ history.replaceState(null, "", "?" + q);+ maskOneOpen(k);+ }+ }+ return maskPageLoad();+}+function maskPageLoad(force) {+ maskDrawAll();+ const sum = maskLoad(force)?.then(() => { drawMaskCard(); drawMaskList(); });+ const recs = maskL.read && force ? maskRefresh() : maskL.read ? null : maskFetch();+ return Promise.all([sum, recs]);+}+function maskDrawAll() {+ drawMaskCard();+ drawMaskList();+ if (maskO) drawMaskOne();+}+// while the page is on screen it keeps up with requests as they go+setInterval(() => {+ if (view !== "masking" || document.hidden) return;+ maskLoad(true)?.then(() => { drawMaskCard(); if (maskL.mode === "val" || !maskO) drawMaskList(); });+ if (!maskL.busy) maskRefresh();+}, 15000);++// ---- the card: how much was kept, and where it went ----+function drawMaskCard() {+ const box = $("#maskCard");+ if (!box) return;+ // until the window's state is read, agents would show as their ids+ const on = maskOn(), sum = maskSumDays === maskDays && load.done ? maskSum : null;+ const key = JSON.stringify([document.documentElement.lang, maskDays, on, sum, state?.agents?.length, (providers || maskProv)?.providers?.length]);+ if (key === maskDrawn && box.firstChild) return;+ maskDrawn = key;+ // it moves when it first has numbers to say, and for other days: not+ // on every poll+ const move = !!sum && box.dataset.drawn !== String(maskDays) && !stillMotion();+ if (sum) box.dataset.drawn = String(maskDays);+ maskTipOff();+ box.replaceChildren();+ box.classList.remove("off");+ if (sum && !sum.requests && !on) return maskOffCard(box);++ const head = el("div", "msk-head"), words = el("div", "msk-title");+ words.append(el("h2", "", t("Kept from vendors")),+ el("span", "msk-sub", on ? t("Masked on this computer before each request left it, and put back in each answer") : t("Masking is off: requests go to vendors as they are")));+ head.append(words, el("span", "grow"));+ if (!on) {+ const b = el("button", "text", t("Turn on masking"));+ b.type = "button";+ b.onclick = maskTurnOn;+ head.append(b);+ }+ if (sum?.requests || maskDays === 30) head.append(segs([["7", t("7 days")], ["30", t("30 days")]], String(maskDays), (v) => {+ maskDays = +v;+ try { localStorage.setItem("magpie.maskDays", v); } catch {}+ maskLoad(true)?.then(() => { drawMaskCard(); drawMaskList(); });+ }));+ box.append(head);+ const band = el("div", "msk-band");+ box.append(band);+ if (!sum) {+ band.append(el("span", "skeleton msk-sk-num"), el("span", "skeleton msk-sk-flow"));+ return;+ }++ // the number, what makes it up, and the days+ const nums = el("div", "msk-nums");+ const num = el("div", "msk-num", sum.n.toLocaleString(intlLang()));+ nums.append(num, el("div", "msk-unit", t(sum.n === 1 ? "value masked" : "values masked")));+ const stats = el("div", "msk-stats");+ const stat = (label, n, cls) => { const s = el("span", cls || ""); s.append(el("b", "", fmtN(n)), document.createTextNode(label)); stats.append(s); };+ stat(t("Different values"), sum.distinct);+ stat(t("Requests"), sum.requests);+ if (sum.blocked) stat(t("Held back"), sum.blocked, "held");+ nums.append(stats);+ const days = el("div", "msk-days");+ nums.append(days);+ band.append(nums);+ maskStrip(days, sum.days, move);+ if (move && sum.n) maskCountUp(num, sum.n);+ if (sum.agents.length && sum.providers.length) band.append(maskFlow(sum, move));+ else band.append(el("div", "msk-flow-none", t("A request that carries a key, a password or personal data shows here as it goes")));+ if (move) for (const [i, n] of [...band.children].entries()) n.animate([{ opacity: 0, transform: "translateY(6px)", filter: "blur(6px)" }, {}], { duration: 900, delay: i * 120, easing: "cubic-bezier(.2, .7, .1, 1)", fill: "backwards" });+}++// masking off and nothing ever masked: what it would do, and the switch+function maskOffCard(box) {+ box.classList.add("off");+ const s = svg(SHIELD, 40, .9);+ s.classList.add("msk-off-ic");+ const b = el("button", "text primary", t("Turn on masking"));+ b.type = "button";+ b.onclick = maskTurnOn;+ const also = el("span", "msk-also");+ const link = el("button", "text", t("Settings › Privacy"));+ link.type = "button";+ link.onclick = (e) => openSettingsAt(e, "privacy");+ also.append(el("span", "", t("You can also change it in")), link);+ box.append(s, el("h2", "", t("Requests go to vendors as they are")),+ el("p", "", t("Turned on, keys, passwords, computer names and emails become placeholders before they leave this computer, and are put back in each answer. What each request had masked shows here.")),+ b, also);+}+function maskTurnOn(e) {+ const b = e.currentTarget;+ b.disabled = true;+ (prefs ? Promise.resolve() : loadSettings())+ .then(() => savePrefs({ ...prefsKeep(prefs), redact: true }))+ .then(() => { maskDrawn = ""; drawMaskCard(); })+ .finally(() => { b.disabled = false; });+}++function maskCountUp(node, n) {+ const start = performance.now(), ms = 1100;+ const step = (now) => {+ if (!node.isConnected) return;+ const p = Math.min(1, (now - start) / ms);+ const e = p === 1 ? 1 : 1 - Math.pow(2, -10 * p);+ node.textContent = Math.round(n * e).toLocaleString(intlLang());+ if (p < 1) requestAnimationFrame(step);+ };+ requestAnimationFrame(step);+}++// maskStrip: the values masked each day, a bar a day on a hairline, today+// in the accent; the day pointed at said over it+function maskStrip(box, days, move) {+ const total = days.reduce((a, d) => a + d.n, 0);+ box.setAttribute("role", "img");+ box.setAttribute("aria-label", t("{n} values masked over {days} days", { n: fmtN(total), days: days.length }));+ if (!days.length) return;+ const max = Math.max(1, ...days.map((d) => d.n));+ const bars = el("div", "msk-bars" + (days.length > 14 ? " many" : ""));+ const tip = el("div", "msk-ctip");+ tip.hidden = true;+ const fmt = (d) => d === days.at(-1).day ? t("Today") : new Date(d + "T00:00").toLocaleDateString(intlLang(), { month: "short", day: "numeric" });+ days.forEach((d, i) => {+ const b = el("span", "msk-day" + (i === days.length - 1 ? " now" : "") + (d.n ? "" : " zero"));+ const f = el("i");+ if (d.n) f.style.height = Math.max(8, (100 * d.n) / max) + "%";+ b.append(f);+ b.onpointerenter = () => {+ tip.hidden = false;+ tip.textContent = `${fmt(d.day)} · ${t(d.n === 1 ? "1 value masked" : "{n} values masked", { n: fmtN(d.n) })} · ${t(d.requests === 1 ? "1 request" : "{n} requests", { n: fmtN(d.requests) })}`;+ const w = tip.offsetWidth, W = box.clientWidth, x = b.offsetLeft + b.offsetWidth / 2;+ tip.style.left = Math.max(w / 2, Math.min(x, W - w / 2)) + "px";+ };+ b.onpointerleave = () => { tip.hidden = true; };+ if (move && d.n) f.animate([{ transform: "scaleY(0)" }, { transform: "none" }], { duration: 760, delay: 160 + (i * 520) / days.length, easing: "cubic-bezier(.32, .72, 0, 1)", fill: "backwards" });+ bars.append(b);+ });+ const axis = el("div", "msk-axis");+ axis.append(el("span", "", fmt(days[0].day)), el("span", "", fmt(days.at(-1).day)));+ box.append(bars, axis, tip);+}++// maskFlow: hairlines from the agents into this computer, uneven as+// written, and out of it to the providers, even as placeholders; magpie's+// bird on the line between, so a screenshot says who masked them+function maskFlow(sum, move) {+ const sec = el("div", "msk-fl"), flow = el("div", "mo-flow");+ const side = (list, kind) => {+ const shown = list.slice(0, 3), rest = list.slice(3);+ const rows = shown.map((x) => ({ id: x.name, n: x.n, ...maskWho(x.name, kind) }));+ if (rest.length) rows.push({ id: "", n: rest.reduce((a, x) => a + x.n, 0), name: t("{n} more", { n: rest.length }) });+ const col = el("div", "mo-col " + kind);+ for (const r of rows) {+ const b = el("button", "mo-node" + (r.id && maskL[kind] === r.id ? " on" : ""));+ b.type = "button";+ b.append(el("span", "nm", r.name), el("span", "ct", fmtN(r.n)));+ if (r.id) {+ b.title = t("Show what {name} sent masked", { name: r.name });+ b.onclick = () => maskNarrow({ [kind]: maskL[kind] === r.id ? "" : r.id });+ } else b.disabled = true;+ col.append(b);+ }+ return [col, rows];+ };+ const [from, fromRows] = side(sum.agents, "agent");+ const [to, toRows] = side(sum.providers, "provider");+ const mid = el("div", "mo-mid");+ const rowH = 34, H = Math.max(fromRows.length, toRows.length, 3) * rowH;+ const max = Math.max(...fromRows.map((r) => r.n), ...toRows.map((r) => r.n), 1);+ const hub = el("span", "msk-hub");+ hub.title = "magpie";+ hub.innerHTML = '<svg viewBox="0 0 44 44" aria-hidden="true"><use href="#bird"/></svg>';+ // drawn in the middle's own pixels on each resize: a stretched viewBox+ // would bend the hairlines+ const s = sv("svg", { "aria-hidden": "true" });+ let drawnW = 0;+ const draw = () => {+ const W = Math.round(mid.clientWidth);+ if (!W || W === drawnW) return;+ drawnW = W;+ s.setAttribute("viewBox", `0 0 ${W} ${H}`);+ s.replaceChildren();+ const m = W / 2, still = stillMotion(), lines = [];+ const add = (tag, a, to = s) => { const n = sv(tag, a); to.append(n); return n; };+ const curve = (x0, y0, x1, y1) => `M${x0},${y0}C${(x0 + x1) / 2},${y0} ${(x0 + x1) / 2},${y1} ${x1},${y1}`;+ const bundle = (rows, out) => {+ const ks = rows.map((r) => Math.max(1, Math.round(18 * r.n / max))), all = ks.reduce((a, k) => a + k, 0);+ let j = 0, rnd = out ? 11 : 7;+ rows.forEach((r, i) => {+ const y = (H - rows.length * rowH) / 2 + (i + .5) * rowH;+ for (let q = 0; q < ks[i]; q++, j++) {+ const at = all > 1 ? H * (.22 + .56 * j / (all - 1)) : H / 2;+ rnd = (rnd * 16807) % 2147483647;+ const end = y + (q - (ks[i] - 1) / 2) * 1.4 + (out ? 0 : (rnd % 30 - 15) / 10);+ const d = out ? curve(m, at, W, end) : curve(0, end, m, at);+ lines.push(add("path", { d, pathLength: 1, class: "mo-th" + (out ? " out" : "") + (ks[i] === 1 ? " one" : ""), "stroke-opacity": ks[i] === 1 ? (out ? .8 : .4) : out ? .42 : .07 + (rnd % 20) / 100 }));+ // a value goes in round, a placeholder out square+ if (q === ks[i] >> 1 && !still) for (let k = 0, dots = 1 + Math.round(2 * r.n / max); k < dots; k++) {+ const dur = 1.7 + i * .5, begin = (out ? dur : 0) + k * 2 * dur / dots + "s";+ const z = out ? 1.8 : 1.7, dot = add("rect", { x: -z, y: -z, width: 2 * z, height: 2 * z, rx: out ? .6 : z, class: "mo-dot" + (out ? " out" : "") });+ const a = { dur: dur + "s", begin, repeatCount: "indefinite" };+ add("animateMotion", { path: d, ...a }, dot);+ add("animate", { attributeName: "opacity", values: "0;1;1;0", keyTimes: "0;.1;.85;1", ...a }, dot);+ }+ }+ });+ };+ bundle(fromRows, false);+ bundle(toRows, true);+ // this computer: a ticked line, and a mark going down it+ add("line", { x1: m, y1: 0, x2: m, y2: H, class: "mo-mem" });+ for (let y = 0; y <= H; y += 17) add("line", { x1: m - 3, y1: y, x2: m + 3, y2: y, class: "mo-tick" });+ if (!still) add("rect", { x: m - 1, y: 0, width: 2, height: 18, rx: 1, class: "mo-scan" }).style.setProperty("--h", H - 18 + "px");+ // drawn in once, the way in first+ if (move) lines.forEach((p) => {+ p.animate([{ strokeDashoffset: 1 }, {}], { duration: 2400, delay: p.classList.contains("out") ? 700 : 300, easing: "cubic-bezier(.3, .6, .1, 1)", fill: "backwards" });+ });+ move = false;+ };+ mid.append(s, hub);+ flow.style.height = H + "px";+ flow.append(from, mid, to);+ new ResizeObserver(draw).observe(mid);+ sec.append(flow, el("div", "mo-cap", t("magpie masked these on this computer")));+ return sec;+}++// ---- the list: each request masking changed, or each value ----+const MASK_FACETS = [+ ["", "All", (s) => s.n],+ ["secret", "Secrets", (s) => (s.kinds || []).filter((k) => MASK_SECRET_KINDS.includes(k.name)).reduce((a, k) => a + k.n, 0)],+ ["rule", "Rules", (s) => s.by?.rule || 0],+ ["model", "Local model", (s) => s.by?.model || 0],+ ["blocked", "Held back", (s) => s.blocked || 0],+];+function maskQuery(before) {+ const q = new URLSearchParams({ limit: "40" });+ if (before) q.set("before", before);+ const f = maskL.facet;+ if (maskL.kind) q.set("kind", maskL.kind);+ else if (f === "secret") q.set("kind", MASK_SECRET_KINDS.join(","));+ if (f === "rule" || f === "model") q.set("by", f);+ if (f === "blocked") q.set("blocked", "1");+ if (maskL.agent) q.set("agent", maskL.agent);+ if (maskL.provider) q.set("provider", maskL.provider);+ return "masking/records?" + q;+}+// maskNarrow: the list for other filters, read again from the start+function maskNarrow(change) {+ Object.assign(maskL, change);+ maskDrawn = "";+ drawMaskCard();+ return maskFetch();+}+let maskSeq = 0;+function maskFetch(more) {+ const seq = ++maskSeq;+ maskL.busy = true;+ maskL.error = "";+ drawMaskList();+ return api(maskQuery(more ? maskL.records.at(-1)?.key : 0))+ .then((r) => {+ if (seq !== maskSeq) return;+ const got = r?.records || [];+ maskL.records = more ? [...maskL.records, ...got] : got;+ maskL.more = !!r?.more;+ })+ .catch((e) => { if (seq === maskSeq) maskL.error = e.message; })+ .finally(() => {+ if (seq !== maskSeq) return;+ maskL.busy = false;+ maskL.read = true;+ drawMaskList();+ if (maskO) drawMaskOne(); // its previous and next+ });+}+// new records come in over the ones shown, which keep their place+function maskRefresh() {+ if (!maskL.records.length) return maskFetch();+ const seq = maskSeq;+ return api(maskQuery(0)).then((r) => {+ if (seq !== maskSeq || !maskL.records.length) return;+ const fresh = (r?.records || []).filter((x) => x.key > maskL.records[0].key);+ if (!fresh.length) return;+ maskL.records = [...fresh, ...maskL.records];+ if (!maskO) drawMaskList();+ else drawMaskOne();+ }).catch(() => {});+}++function drawMaskList() {+ const box = $("#maskList");+ if (!box) return;+ const sum = (maskSumDays === maskDays && maskSum) || null;+ maskTipOff();+ box.replaceChildren();+ const bar = el("div", "msk-bar");+ bar.append(segs([["req", t("By request")], ["val", t("By value")]], maskL.mode, (v) => { maskL.mode = v; drawMaskList(); }));+ const live = el("span", "msk-live");+ live.title = t("Read again every 15 seconds while this page is open");+ live.append(el("i"), el("span", "", t("Live")));+ bar.append(live, el("span", "grow"));+ if (maskL.mode === "req") {+ const pick = (key, all, head, opts) => {+ const b = el("button", "sess-pick");+ b.type = "button";+ if (maskL[key] && !opts.some((o) => o.v === maskL[key])) opts.unshift({ v: maskL[key], name: maskWho(maskL[key], key).name });+ sessPick(b, all, maskL[key], opts, head, (v) => maskNarrow({ [key]: v || "" }));+ bar.append(b);+ };+ pick("agent", "Every agent", "Agent", (sum?.agents || []).map((a) => ({ v: a.name, name: maskWho(a.name, "agent").name })));+ pick("provider", "Every provider", "Provider", (sum?.providers || []).map((p) => ({ v: p.name, name: maskWho(p.name, "provider").name })));+ }+ box.append(bar);++ // what was masked and how: counts that narrow the list+ const facets = el("div", "msk-facets");+ facets.setAttribute("role", "group");+ facets.setAttribute("aria-label", t("Show"));+ for (const [id, name, count] of MASK_FACETS) {+ const n = sum ? count(sum) : 0;+ if (id && !n && maskL.facet !== id) continue;+ const b = el("button", "msk-facet" + (id ? " " + id : ""));+ b.type = "button";+ b.setAttribute("aria-pressed", String(maskL.facet === id && !maskL.kind));+ if (id) b.append(el("span", "msk-fdot"));+ b.append(el("span", "", t(name)));+ if (sum) b.append(el("b", "", fmtN(n)));+ b.onclick = () => maskNarrow({ facet: id, kind: "" });+ facets.append(b);+ }+ if (maskL.kind) {+ const b = el("button", "msk-facet kind");+ b.type = "button";+ b.setAttribute("aria-pressed", "true");+ b.title = t("Clear filter");+ b.append(maskDot(maskL.kind), el("span", "", maskKindName(maskL.kind)), el("span", "x", "×"));+ b.onclick = () => maskNarrow({ kind: "" });+ facets.append(b);+ }+ box.append(facets);+ if (maskL.mode === "val") maskValueList(box, sum);+ else maskRequestList(box);+ const foot = el("div", "msk-foot");+ foot.append(el("span", "", t("Kept on this computer for 30 days, without the values themselves")));+ if (maskL.mode === "req" && maskL.more) {+ const more = el("button", "text", maskL.busy ? t("Loading…") : t("Load more"));+ more.type = "button";+ more.disabled = maskL.busy;+ more.onclick = () => maskFetch(true);+ foot.append(more);+ }+ box.append(foot);+}++function maskRequestList(box) {+ const filtered = maskL.facet || maskL.kind || maskL.agent || maskL.provider;+ if (maskL.error) return void box.append(el("div", "msk-none err", t(maskL.error)));+ if (!maskL.records.length) return void box.append(el("div", "msk-none", maskL.busy || !maskL.read ? t("Loading…") : filtered ? t("Nothing masked matches these filters") : t("Nothing masked yet")));+ let day = "", list = null;+ for (const r of maskL.records) {+ const d = new Date(r.t).toDateString();+ if (d !== day) {+ day = d;+ const g = el("div", "msk-group");+ g.append(el("div", "msk-gday", maskDayName(r.t)));+ list = el("div", "list");+ g.append(list);+ box.append(g);+ }+ list.append(maskRecordRow(r));+ }+}+// who to whom, an icon where there is one+function maskRoute(into, r) {+ const a = maskWho(r.agent, "agent"), p = maskWho(r.provider, "provider");+ if (r.agent) {+ if (a.icon) into.append(icon(a.icon));+ into.append(el("span", "who", a.name), el("span", "arrow", "→"));+ }+ if (p.icon && r.provider) into.append(icon(p.icon));+ into.append(el("span", "who", r.provider ? p.name : t("A vendor")));+}+function maskKindsOf(r) {+ const by = {};+ for (const x of r.values || []) by[x.k] = (by[x.k] || 0) + (x.n || 1);+ return Object.entries(by).sort((x, y) => y[1] - x[1]);+}+function maskRecordRow(r) {+ const row = el("button", "msk-row" + (r.blocked ? " held" : ""));+ row.type = "button";+ row.dataset.key = r.key;+ const route = el("span", "msk-route");+ maskRoute(route, r);+ const model = el("span", "msk-model", r.model || "");+ const kinds = el("span", "msk-kinds");+ if (r.blocked) kinds.append(el("span", "msk-held", t("Held back")));+ else if (r.what && r.what !== "chat") kinds.append(el("span", "msk-what", MASK_WHAT[r.what] ? t(MASK_WHAT[r.what]) : r.what));+ const ranked = maskKindsOf(r);+ for (const [k, n] of ranked.slice(0, 3)) {+ const c = el("span", "msk-kind");+ c.append(maskDot(k), el("span", "", maskKindName(k)), el("b", "", "×" + fmtN(n)));+ kinds.append(c);+ }+ if (ranked.length > 3) kinds.append(el("span", "msk-kind more", "+" + (ranked.length - 3)));+ const n = el("span", "msk-n", fmtN(r.n));+ n.title = t(r.n === 1 ? "1 value masked" : "{n} values masked", { n: fmtN(r.n) });+ const chev = el("span", "msk-chev");+ chev.append(svg(CHEV_R, 11, 1.6));+ row.append(el("span", "msk-time", new Date(r.t).toLocaleTimeString(intlLang(), { hour: "2-digit", minute: "2-digit" })), route, model, kinds, n, chev);+ row.onclick = () => maskOneOpen(r.key, r);+ return row;+}++// the values masked most, as the summary ranks them: what a facet can+// narrow them by; one opens the requests with its kind+function maskValueList(box, sum) {+ const f = maskL.facet;+ const vs = (sum?.values || []).filter((v) => (!maskL.kind || v.kind === maskL.kind) && (f !== "secret" || MASK_SECRET_KINDS.includes(v.kind)) && (f !== "rule" && f !== "model" || v.by === f) && f !== "blocked");+ if (!sum) return void box.append(el("div", "msk-none", t("Loading…")));+ if (!vs.length) return void box.append(el("div", "msk-none", sum.values?.length ? t("Nothing masked matches these filters") : t("Nothing masked yet")));+ const head = el("div", "msk-vhead");+ head.append(el("span", "", t("Masked most")), el("span", "grow"), el("span", "", t("Point at one to see what it was")));+ const list = el("div", "list msk-vals"), max = vs[0].n || 1;+ for (const [i, v] of vs.entries()) {+ const c = el("button", "msk-vrow"), sh = maskShape(v.head, v.len), bar = el("span", "bar"), fill = el("i");+ c.type = "button";+ c.setAttribute("aria-label", maskKindName(v.kind) + " " + sh);+ fill.style.width = Math.max(3, (100 * v.n) / max) + "%";+ bar.append(fill);+ const kind = el("span", "k");+ kind.append(maskDot(v.kind), el("span", "", maskKindName(v.kind)));+ c.append(el("span", "i", String(i + 1).padStart(2, "0")), el("span", "sh", sh), kind, el("span", "by", maskByName(v.by)), bar, el("span", "x", fmtN(v.n)));+ maskTipOn(c, { p: v.p, kind: v.kind, by: v.by, meta: t(v.requests === 1 ? "In 1 request, {when}" : "In {n} requests, most recently {when}", { n: fmtN(v.requests), when: ago(v.last) }) });+ c.onclick = () => { maskL.mode = "req"; maskNarrow({ kind: v.kind, facet: "" }); };+ list.append(c);+ }+ box.append(head, list);+}++// ---- one request: what it carried, what the vendor got, how ----+function maskOneOpen(key, r) {+ if (!key) return;+ maskTipOff();+ const o = maskO = { key, r: r || maskL.records.find((x) => x.key === key) || null, sent: undefined, leaves: null, vals: new Map(), view: "both", pick: "", open: new Set(), whole: new Set() };+ $("#maskCard").hidden = $("#maskList").hidden = true;+ $("#maskOne").hidden = false;+ drawMaskOne();+ (o.r ? Promise.resolve(o.r) : api("masking/record?key=" + key))+ .then((rec) => {+ if (maskO !== o) return;+ o.r = rec;+ drawMaskOne();+ const ps = (rec.values || []).map((x) => x.p);+ const vals = ps.length ? api("masking/values", { ps }).then((x) => {+ for (const [p, v] of Object.entries(x?.values || {})) { o.vals.set(p, v); maskValues.set(p, v); }+ }).catch(() => {}) : null;+ const sent = api("masking/sent?key=" + key).then((x) => (typeof x?.body === "string" ? x.body : null), () => null);+ return Promise.all([sent, vals]).then(([body]) => {+ if (maskO !== o) return;+ o.sent = body;+ o.leaves = body === null ? null : maskLeaves(body);+ if (body === null && !o.vals.size) o.view = "vendor";+ drawMaskOne();+ });+ })+ .catch(() => { if (maskO === o) { o.r = false; drawMaskOne(); } });+}+function maskOneClose() {+ maskTipOff();+ maskO = null;+ $("#maskOne").hidden = true;+ $("#maskOne").replaceChildren();+ $("#maskCard").hidden = $("#maskList").hidden = false;+ drawMaskList();+}++// maskLeaves: each piece of text in the body a request went out with,+// where it sits and whose it is (the message's role, else its type)+function maskLeaves(body) {+ let root;+ try { root = JSON.parse(body); } catch { return [{ path: "", role: "", text: body }]; }+ const out = [];+ const walk = (v, path, role) => {+ if (typeof v === "string") return void out.push({ path, role, text: v });+ if (!v || typeof v !== "object") return;+ if (Array.isArray(v)) return void v.forEach((x, i) => walk(x, path + "[" + i + "]", role));+ const r = typeof v.role === "string" ? v.role : role || (typeof v.type === "string" ? v.type : "");+ for (const [k, x] of Object.entries(v)) walk(x, path ? path + "." + k : k, r);+ };+ walk(root, "", "");+ return out;+}+const maskTook = (us) => us >= 1e6 ? (us / 1e6).toFixed(1) + " s" : us >= 1000 ? (us / 1000).toFixed(us >= 1e4 ? 0 : 1) + " ms" : Math.max(1, Math.round(us)) + " µs";++function drawMaskOne() {+ const box = $("#maskOne"), o = maskO;+ if (!box || !o) return;+ maskTipOff();+ box.replaceChildren();+ const r = o.r;+ // back, when, and the requests beside it in the list+ const bar = el("div", "msk-onebar");+ const back = el("button", "text msk-back");+ back.type = "button";+ back.append(svg("m9.5 3.5-4.5 4.5 4.5 4.5", 12, 1.7), el("span", "", t("Masking")));+ back.onclick = maskOneClose;+ bar.append(back);+ if (r) bar.append(el("span", "msk-crumb", "/"), el("span", "msk-when", maskDayName(r.t) + " " + new Date(r.t).toLocaleTimeString(intlLang(), { hour: "2-digit", minute: "2-digit", second: "2-digit" })));+ bar.append(el("span", "grow"));+ const at = maskL.records.findIndex((x) => x.key === o.key);+ const step = (d, label, path) => {+ const b = el("button", "icon msk-step");+ b.type = "button";+ b.setAttribute("aria-label", t(label));+ b.dataset.tt = "";+ b.append(svg(path, 12, 1.7));+ const to = at < 0 ? null : maskL.records[at + d];+ b.disabled = !to;+ if (to) b.onclick = () => maskOneOpen(to.key, to);+ bar.append(b);+ };+ step(-1, "Newer request", "M3.5 9.5 8 5l4.5 4.5");+ step(1, "Older request", "M3.5 6.5 8 11l4.5-4.5");+ box.append(bar);+ if (r === false) return void box.append(el("div", "msk-none", t("This request's record is gone: records are kept for 30 days")));+ if (!r) return void box.append(el("div", "msk-none", t("Loading…")));++ const info = new Map((r.values || []).map((x) => [x.p, x]));+ // the request: who to whom, and what happened to it in order+ const card = el("section", "msk-req");+ const who = el("div", "msk-who");+ maskRoute(who, r);+ if (r.model) who.append(el("span", "msk-chip", r.model));+ if (r.what && r.what !== "chat") who.append(el("span", "msk-chip", MASK_WHAT[r.what] ? t(MASK_WHAT[r.what]) : r.what));+ card.append(who, maskSteps(r, o));+ box.append(card);+ if (r.blocked) box.append(maskBlocked(r));++ const grid = el("div", "msk-onegrid");+ grid.append(maskContent(r, o, info), maskHow(r, o, info));+ box.append(grid);+ maskPick(box, o.pick);+}++// maskSteps: received, found, replaced, sent (or held back), put back+function maskSteps(r, o) {+ const ol = el("ol", "msk-steps");+ ol.setAttribute("aria-label", t("What happened"));+ const memory = o.sent || o.vals.size || Object.keys(r.snips || {}).length;+ const back = Object.values(r.back || {}).reduce((a, n) => a + n, 0);+ const by = [...new Set((r.values || []).map((x) => maskByName(x.b)))].join(", ");+ const a = maskWho(r.agent, "agent").name, p = r.provider ? maskWho(r.provider, "provider").name : t("A vendor");+ const steps = [+ ["", t("Received"), r.agent ? t("From {agent}", { agent: a }) + (o.sent ? " · " + fmtBytes(new Blob([o.sent]).size) : "") : o.sent ? fmtBytes(new Blob([o.sent]).size) : ""],+ ["", t((r.values || []).length === 1 ? "Found 1 value" : "Found {n} values", { n: fmtN((r.values || []).length) }), by + (r.took ? " · " + maskTook(r.took) : "")],+ ["", t(r.n === 1 ? "Replaced 1 place" : "Replaced {n} places", { n: fmtN(r.n) }), t("With placeholders")],+ r.blocked ? ["held", t("Held back"), t("Not sent to {provider}", { provider: p })] : ["", t("Sent"), p + (r.model ? " · " + r.model : "")],+ r.blocked ? ["none", t("Put back"), t("Nothing was sent")]+ : back ? ["", t(back === 1 ? "Put back 1" : "Put back {n}", { n: fmtN(back) }), t("In the answer, before {agent} got it", { agent: a })]+ : memory ? ["none", t("Nothing to put back"), t("The answer named no placeholder")]+ : ["none", t("Put back"), t("Not known after a restart")],+ ];+ steps.forEach(([cls, title, sub], i) => {+ const li = el("li", cls);+ const mk = el("div", "msk-sdot");+ mk.append(el("span", "", String(i + 1)));+ li.append(mk, el("div", "msk-st", title), el("div", "msk-ss", sub));+ ol.append(li);+ });+ return ol;+}++// a request held back: why, and the way to send it masked instead+function maskBlocked(r) {+ const box = el("section", "msk-blocked");+ const head = el("div", "msk-bhead"), ic = svg(SHIELD, 20, 1.3);+ ic.append(sv("path", { d: "m6 6 4 4M10 6l-4 4" }));+ head.append(ic, el("h2", "", t("This request was not sent")));+ const kinds = [...new Set((r.values || []).filter((x) => x.a === "block").map((x) => x.k))];+ const a = maskWho(r.agent, "agent").name, p = r.provider ? maskWho(r.provider, "provider").name : t("A vendor");+ box.append(head, el("p", "", t("It carried {kinds}, which you set to hold back, so magpie didn't send it to {provider}. {agent} got an error saying why.", { kinds: kinds.map(maskKindName).join(", ") || t("a value"), provider: p, agent: r.agent ? a : t("The agent") })));+ const tools = el("div", "msk-btools");+ if (kinds.length) {+ const b = el("button", "text primary", t("Mask it instead"));+ b.type = "button";+ b.title = t("From now on {kinds} go to vendors as placeholders, like the other values", { kinds: kinds.map(maskKindName).join(", ") });+ b.onclick = () => {+ b.disabled = true;+ (prefs ? Promise.resolve() : loadSettings())+ .then(() => writingPrefs(api("settings/redact-actions", { actions: { ...(prefs.redactActions || {}), ...Object.fromEntries(kinds.map((k) => [k, "mask"])) } })))+ .then((ns) => { prefs = ns; if (state) state.settings = ns; b.textContent = t("Masked from now on"); status(t("Saved"), "ok", 1500); })+ .catch((e) => { b.disabled = false; status(t(e.message), "err"); });+ };+ tools.append(b);+ }+ const rules = el("button", "text", t("See the rules in Settings"));+ rules.type = "button";+ rules.onclick = (e) => openSettingsAt(e, "privacy", $("#maskActList"));+ tools.append(rules);+ box.append(tools);+ return box;+}++// maskInk: text with this request's placeholders marked, as the vendor+// got them or, here, as they were written+function maskInk(into, text, here, o, info) {+ let at = 0;+ for (const m of text.matchAll(PLACEHOLDER)) {+ const x = info.get(m[0]);+ if (!x) continue;+ into.append(document.createTextNode(text.slice(at, m.index)));+ let mark;+ if (here) {+ const v = o.vals.get(m[0]);+ mark = el("mark", "msk-orig" + (typeof v === "string" ? "" : " gone"), typeof v === "string" ? v : maskShape(x.h, x.l));+ mark.style.setProperty("--k", maskColor(x.k));+ mark.tabIndex = 0;+ maskTipOn(mark, { p: m[0], kind: x.k, by: x.b });+ } else mark = maskPlace("msk-ph", m[0], x);+ mark.dataset.p = m[0];+ into.append(mark);+ at = m.index + m[0].length;+ }+ into.append(document.createTextNode(text.slice(at)));+}+// the parts of a long text around its placeholders, 120 characters each+// side, the rest left out+function maskWindows(text, info) {+ const rs = [];+ for (const m of text.matchAll(PLACEHOLDER)) if (info.has(m[0])) rs.push([Math.max(0, m.index - 120), Math.min(text.length, m.index + m[0].length + 120)]);+ const out = [];+ for (const r of rs) {+ const last = out.at(-1);+ if (last && r[0] <= last[1] + 20) last[1] = Math.max(last[1], r[1]);+ else out.push([...r]);+ }+ return out;+}++// maskContent: the request's text, only the pieces masking changed, the+// rest folded; as written, as the vendor got it, or side by side+function maskContent(r, o, info) {+ const sec = el("section", "msk-content");+ const head = el("div", "msk-chead");+ head.append(el("h2", "", t("Request content")), el("span", "msk-hint", t("Only the parts masking changed")), el("span", "grow"));+ const known = o.sent || o.vals.size;+ const views = [["here", t("Original")], ["vendor", t("What the vendor saw")], ["both", t("Side by side")]];+ const sg = segs(views, o.view, (v) => { o.view = v; drawMaskOne(); });+ if (!known && o.sent !== undefined) for (const b of sg.querySelectorAll("button")) if (!b.getAttribute("aria-pressed") || b.getAttribute("aria-pressed") === "false") b.disabled = true;+ head.append(sg);+ sec.append(head);+ const view = known || o.sent === undefined ? o.view : "vendor";+ if (o.sent === undefined) return sec.append(el("div", "msk-none", t("Loading…"))), sec;++ let items;+ if (o.leaves) {+ items = [];+ let fold = null;+ for (const l of o.leaves) {+ const changed = [...l.text.matchAll(PLACEHOLDER)].some((m) => info.has(m[0]));+ if (changed) { fold = null; items.push({ leaf: l }); continue; }+ if (!fold) items.push(fold = { fold: [] });+ fold.fold.push(l);+ }+ } else {+ // only the lines around each value are left: the request's whole text+ // was in memory, and is no longer+ if (!r.blocked) sec.append(el("p", "msk-gone", o.vals.size+ ? t("This request's whole text is no longer in memory: magpie keeps it for the newest requests only. The lines around each value are still here.")+ : t("What was written is kept in memory only, and magpie has restarted since. Still here: each value's kind, length and first characters, and the line around each placeholder as the vendor got it.")));+ items = maskSnipTexts(r).map((text) => ({ leaf: { path: "", role: "", text } }));+ if (!items.length) sec.append(el("div", "msk-none", t("The text around them was kept in memory only, and magpie has restarted since")));+ }+ const list = el("div", "msk-msgs" + (view === "both" ? " both" : ""));+ if (view === "both") {+ const cols = el("div", "msk-cols");+ cols.append(el("span", "", t("As written here")), el("span", "", t("What the vendor saw")));+ list.append(cols);+ }+ items.forEach((it, i) => {+ if (it.fold) {+ const size = it.fold.reduce((a, l) => a + l.text.length, 0);+ const f = el("div", "msk-fold" + (o.open.has(i) ? " open" : ""));+ const b = el("button", "msk-foldb");+ b.type = "button";+ b.setAttribute("aria-expanded", String(o.open.has(i)));+ b.append(svg(CHEV_R, 10, 1.8), el("span", "", t(it.fold.length === 1 ? "1 part unchanged" : "{n} parts unchanged", { n: fmtN(it.fold.length) })), el("span", "msk-size", fmtBytes(size)));+ b.onclick = () => { if (o.open.has(i)) o.open.delete(i); else o.open.add(i); drawMaskOne(); };+ f.append(b);+ if (o.open.has(i)) {+ const rest = el("div", "msk-same");+ for (const l of it.fold.slice(0, 40)) {+ const p = el("div", "msk-sameline");+ p.append(el("span", "msk-path", l.path), el("span", "", l.text.length > 400 ? l.text.slice(0, 400) + "…" : l.text));+ rest.append(p);+ }+ if (it.fold.length > 40) rest.append(el("div", "msk-path", t("{n} more", { n: fmtN(it.fold.length - 40) })));+ f.append(rest);+ }+ return list.append(f);+ }+ const l = it.leaf, m = el("div", "msk-msg");+ const n = [...l.text.matchAll(PLACEHOLDER)].filter((x) => info.has(x[0])).length;+ const mh = el("div", "msk-mhead");+ if (l.role) mh.append(el("span", "msk-role", l.role));+ if (l.path) mh.append(el("span", "msk-path", l.path));+ mh.append(el("span", "grow"), el("span", "msk-count", t(n === 1 ? "1 value" : "{n} values", { n: fmtN(n) })));+ m.append(mh);+ const whole = o.whole.has(i), wins = whole || l.text.length <= 600 ? [[0, l.text.length]] : maskWindows(l.text, info);+ const col = (here) => {+ const c = el("div", "msk-text");+ wins.forEach(([a, b], j) => {+ if (j || a) c.append(el("span", "msk-gap", "…"));+ maskInk(c, l.text.slice(a, b), here, o, info);+ });+ if (wins.at(-1)[1] < l.text.length) c.append(el("span", "msk-gap", "…"));+ return c;+ };+ const body = el("div", "msk-mbody");+ if (view === "both") body.append(col(true), col(false));+ else body.append(col(view === "here"));+ m.append(body);+ if (l.text.length > 600) {+ const b = el("button", "text msk-whole", whole ? t("Show only the changes") : t("Show all of it"));+ b.type = "button";+ b.onclick = () => { if (whole) o.whole.delete(i); else o.whole.add(i); drawMaskOne(); };+ m.append(b);+ }+ list.append(m);+ });+ sec.append(list);+ return sec;+}++// maskHow: each value, what it became, who found it, where it was, and+// how often the answer had it put back; picked, its places light up+function maskHow(r, o, info) {+ const aside = el("aside", "msk-how");+ const vs = r.values || [];+ const head = el("div", "msk-chead");+ head.append(el("h2", "", t("How it was masked")), el("span", "msk-hint", t(vs.length === 1 ? "1 value" : "{n} values", { n: fmtN(vs.length) }) + " · " + t(r.n === 1 ? "1 place" : "{n} places", { n: fmtN(r.n) })));+ aside.append(head);+ const where = new Map();+ for (const l of o.leaves || []) for (const m of l.text.matchAll(PLACEHOLDER)) if (info.has(m[0]) && l.path) {+ const w = where.get(m[0]) || new Set();+ w.add(l.path);+ where.set(m[0], w);+ }+ const memory = o.sent || o.vals.size;+ for (const x of vs) {+ const b = el("button", "msk-val");+ b.type = "button";+ b.dataset.p = x.p;+ b.style.setProperty("--k", maskColor(x.k));+ b.setAttribute("aria-pressed", String(o.pick === x.p));+ const top = el("div", "msk-vtop");+ top.append(maskDot(x.k), el("span", "msk-vk", maskKindName(x.k)), el("span", "grow"));+ if (x.a === "warn") top.append(el("span", "mr-act warn", t("Sent as written")));+ else if (x.a === "block") top.append(el("span", "mr-act block", t("Held back")));+ top.append(el("span", "msk-vx", "×" + fmtN(x.n || 1)));+ const v = o.vals.get(x.p), shown = o.pick === x.p && typeof v === "string" ? v : maskShape(x.h, x.l);+ const mid = el("div", "msk-vmid");+ mid.append(el("span", "msk-vshown", shown), svg("M1 8h11M9 5l3 3-3 3", 12, 1.3), el("span", "msk-vph", x.a === "warn" ? t("as written") : x.p));+ const meta = el("dl", "msk-vmeta");+ const add = (k, val) => meta.append(el("dt", "", k), el("dd", "", val));+ add(t("Found by"), maskByName(x.b));+ const w = [...(where.get(x.p) || [])];+ if (w.length) add(t("Where"), w[0] + (w.length > 1 ? " +" + (w.length - 1) : ""));+ const n = r.back?.[x.p] || 0;+ add(t("In the answer"), n ? t(n === 1 ? "Put back 1" : "Put back {n}", { n: fmtN(n) }) : r.blocked ? "—" : memory || r.back ? t("Not named") : t("Not known after a restart"));+ b.append(top, mid, meta);+ b.onclick = () => { o.pick = o.pick === x.p ? "" : x.p; drawMaskOne(); };+ aside.append(b);+ }+ aside.append(el("p", "msk-note", t("A value itself is in this computer's memory only: shown while it is pointed at or picked, and gone once magpie restarts. The record on disk keeps its kind, length and first characters.")));+ return aside;+}+// a value picked lights its places; the rest fade+function maskPick(box, p) {+ box.classList.toggle("picking", !!p);+ for (const m of box.querySelectorAll("mark[data-p]")) m.classList.toggle("lit", m.dataset.p === p);+}diff --git a/internal/gui/assets/plugins/redact/redact.css b/internal/gui/assets/plugins/redact/redact.cssnew file mode 100644index 000000000..59328db3a--- /dev/null+++ b/internal/gui/assets/plugins/redact/redact.css@@ -0,0 +1,233 @@+/* Insights › Masking (page.js): what masking kept from vendors, in a+ short band over the requests it changed, and one request opened. Flat+ only: hairlines, one thin number, the accent kept for what left this+ computer as placeholders */+#view-masking { container-type: inline-size; }+#view-masking .grow { flex: 1; }+.msk-card { position: relative; padding: 16px 20px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); }+.msk-card[hidden], .msk-list[hidden], .msk-one[hidden] { display: none; }+.msk-head { display: flex; align-items: flex-start; gap: 12px; }+.msk-title { min-width: 0; }+.msk-title h2 { margin: 0; font-size: 13px; font-weight: 600; color: var(--fg); }+.msk-sub { display: block; margin-top: 3px; font-size: 12px; line-height: 1.4; color: var(--muted); }+.msk-band { display: grid; grid-template-columns: minmax(0, 240px) minmax(0, 1fr); gap: 36px; align-items: center; margin-top: 12px; }+.msk-sk-num { height: 92px; border-radius: 10px; }+.msk-sk-flow { height: 102px; border-radius: 10px; }+.msk-num { font-family: "SF Pro Display", -apple-system, BlinkMacSystemFont, system-ui, sans-serif; font-size: 52px; font-weight: 100; line-height: .9; letter-spacing: -.045em; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--fg); }+.msk-unit { margin-top: 6px; font-size: 12.5px; color: var(--fg-2); }+.msk-stats { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 8px; font-size: 11.5px; color: var(--muted); }+.msk-stats b { margin-right: 4px; font-weight: 600; color: var(--fg); font-variant-numeric: tabular-nums; }+.msk-stats .held b { color: var(--red); }+.msk-days { position: relative; height: 40px; margin-top: 10px; display: flex; flex-direction: column; }+.msk-bars { flex: 1; min-height: 0; display: flex; align-items: stretch; gap: 4px; }+.msk-bars.many { gap: 2px; }+.msk-day { flex: 1 1 0; min-width: 3px; display: flex; align-items: flex-end; }+.msk-day i { display: block; width: 100%; border-radius: 1.5px; background: color-mix(in srgb, var(--fg) 24%, transparent); transform-origin: bottom; transition: background-color .15s; }+.msk-day:hover i { background: color-mix(in srgb, var(--fg) 42%, transparent); }+.msk-day.now i, .msk-day.now:hover i { background: var(--accent); }+.msk-day.zero i { height: 2px; background: var(--line); }+.msk-axis { display: flex; justify-content: space-between; padding-top: 4px; font-size: 10.5px; line-height: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }+.msk-axis span:last-child { color: var(--accent); }+.msk-ctip { position: absolute; top: -4px; transform: translate(-50%, -100%); padding: 4px 8px; border-radius: 7px; border: 1px solid var(--line-2); background: var(--card); font-size: 11px; white-space: nowrap; color: var(--fg); font-variant-numeric: tabular-nums; pointer-events: none; z-index: 2; }+.msk-ctip[hidden] { display: none; }+.msk-flow-none { font-size: 12px; line-height: 1.5; color: var(--muted); text-align: center; }++/* agents → this computer → providers: hairlines on a faint grid, magpie's+ bird where they cross the line */+.msk-fl { min-width: 0; }+.mo-flow { position: relative; display: grid; grid-template-columns: minmax(0, 140px) minmax(80px, 1fr) minmax(0, 140px); gap: 14px; }+.mo-col { display: flex; flex-direction: column; justify-content: center; min-width: 0; }+.mo-node { display: flex; flex-direction: column; align-items: flex-end; justify-content: center; gap: 0; height: 34px; min-width: 0; padding: 0 10px; border: 0; border-radius: 9px; background: none; color: var(--fg); font: inherit; cursor: default; }+.mo-col.provider .mo-node { align-items: flex-start; }+.mo-node:not(:disabled):hover { background: var(--pill); }+.mo-node:disabled { color: var(--muted); }+.mo-node .nm { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; }+.mo-node .ct { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }+.mo-col.provider .ct { color: var(--accent); }+.mo-mid { position: relative; min-width: 0; }+.mo-mid svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }+.mo-mid::before { content: ""; position: absolute; inset: 0; background: var(--fg); opacity: .07; pointer-events: none;+ -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14'%3E%3Ccircle cx='1' cy='1' r='.6'/%3E%3C/svg%3E") 0 0 / 14px 14px;+ mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14'%3E%3Ccircle cx='1' cy='1' r='.6'/%3E%3C/svg%3E") 0 0 / 14px 14px; }+.mo-th { fill: none; stroke: var(--fg); stroke-width: .6; stroke-dasharray: 1 1; }+.mo-th.out { stroke: var(--accent); }+.mo-th.one { stroke-width: .9; }+.mo-mem { stroke: var(--accent); stroke-opacity: .55; stroke-width: 1; }+.mo-tick { stroke: var(--accent); stroke-opacity: .35; stroke-width: .6; }+.mo-scan { fill: var(--accent); opacity: 0; animation: mo-scan 5.5s cubic-bezier(.45, 0, .55, 1) infinite; }+@keyframes mo-scan { 0% { transform: translateY(0); opacity: 0; } 15%, 85% { opacity: 1; } 100% { transform: translateY(var(--h)); opacity: 0; } }+.mo-dot { fill: var(--fg); opacity: 0; }+.mo-dot.out { fill: var(--accent); }+.mo-cap { margin-top: 8px; text-align: center; font-size: 11px; letter-spacing: .12em; color: var(--muted); }+.mo-node.on { background: var(--accent-soft); }+.mo-node .nm { line-height: 16px; }+.mo-node .ct { line-height: 13px; }+.msk-hub { position: absolute; left: 50%; top: 50%; width: 30px; height: 30px; margin: -15px 0 0 -15px; display: flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--card); box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 55%, transparent), 0 0 0 5px var(--card); color: var(--accent); }+.msk-hub svg { width: 20px; height: 20px; }++/* the masking off, nothing ever masked: what it would do */+.msk-card.off { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 26px 24px; text-align: center; }+.msk-card.off h2 { margin: 0; font-size: 16px; font-weight: 600; }+.msk-card.off p { margin: 0; max-width: 420px; font-size: 12.5px; line-height: 1.6; color: var(--muted); }+.msk-off-ic { width: 44px; height: 44px; color: var(--accent); }+.msk-off-ic path { fill: color-mix(in srgb, var(--accent) 12%, transparent); }+.msk-also { display: inline-flex; align-items: center; gap: 2px; font-size: 11.5px; color: var(--muted); }++/* the list: a bar, facets that narrow it, a day at a time */+.msk-list { margin-top: 14px; }+.msk-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }+.msk-live { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--muted); }+.msk-live i { width: 6px; height: 6px; border-radius: 50%; background: var(--green, var(--accent)); animation: msk-live 2.4s ease-in-out infinite; }+@keyframes msk-live { 50% { opacity: .35; } }+.msk-facets { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 4px; }+.msk-facet { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border: 1px solid var(--line); border-radius: 99px; background: var(--card); color: var(--fg-2); font: inherit; font-size: 12px; cursor: default; white-space: nowrap; }+.msk-facet:hover { background: var(--pill); }+.msk-facet[aria-pressed="true"] { border-color: transparent; background: var(--accent-soft); color: var(--accent); }+.msk-facet b { font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }+.msk-facet[aria-pressed="true"] b { color: inherit; }+.msk-facet .x { color: var(--muted); }+.msk-fdot { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }+.msk-facet.secret .msk-fdot { background: var(--c1); }+.msk-facet.rule .msk-fdot { background: var(--fg-2); }+.msk-facet.model .msk-fdot { background: var(--c6); }+.msk-facet.blocked .msk-fdot { background: var(--red); }+.msk-group { margin-top: 10px; }+.msk-gday { margin: 0 2px 5px; font-size: 11.5px; font-weight: 600; color: var(--muted); }+.msk-group .list { overflow: hidden; }+.msk-row { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 6px 10px 6px 12px; border: 0; background: transparent; color: var(--fg); font: inherit; font-size: 12.5px; text-align: left; cursor: default; }+.msk-row + .msk-row { border-top: 1px solid var(--line); }+.msk-row:hover { background: var(--pill); }+.msk-row:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--accent-soft); }+.msk-time { flex: none; width: 40px; color: var(--muted); font-variant-numeric: tabular-nums; }+.msk-route { flex: 0 1 auto; display: flex; align-items: center; gap: 5px; min-width: 0; overflow: hidden; white-space: nowrap; }+.msk-route .ic, .msk-who .ic { flex: none; width: 14px; height: 14px; }+.msk-route .who { min-width: 0; overflow: hidden; text-overflow: ellipsis; }+.msk-route .arrow, .msk-who .arrow { flex: none; color: var(--faint); }+.msk-model { flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }+.msk-kinds { flex: none; display: flex; gap: 4px; }+.msk-kind { display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 7px; border-radius: 99px; border: 1px solid var(--line); background: var(--card-2); font-size: 11px; color: var(--fg-2); white-space: nowrap; }+.msk-kind b { font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }+.msk-kind.more { color: var(--muted); }+.msk-held, .msk-what { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 99px; font-size: 11px; white-space: nowrap; }+.msk-held { color: var(--red); background: var(--red-soft); }+.msk-what { color: var(--muted); background: var(--pill); }+.msk-n { flex: none; min-width: 22px; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }+.msk-chev { flex: none; display: inline-flex; color: var(--faint); }+.msk-none { padding: 26px 12px; text-align: center; font-size: 12.5px; color: var(--muted); }+.msk-none.err { color: var(--red); }+.msk-foot { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 12px; padding: 0 2px; font-size: 11.5px; color: var(--muted); }+.msk-foot > span { flex: 1; min-width: 0; }+.msk-vhead { display: flex; align-items: baseline; gap: 10px; margin: 12px 2px 5px; font-size: 11.5px; color: var(--muted); }+.msk-vhead span:first-child { font-weight: 600; }+.msk-vals { overflow: hidden; }+.msk-vrow { display: flex; align-items: center; gap: 12px; width: 100%; height: 38px; padding: 0 12px; border: 0; background: none; color: var(--fg); font: inherit; font-size: 12.5px; text-align: left; cursor: default; outline: none; }+.msk-vrow + .msk-vrow { border-top: 1px solid var(--line); }+.msk-vrow:hover, .msk-vrow:focus-visible { background: var(--pill); }+.msk-vrow .i { flex: none; width: 16px; font-size: 10.5px; color: var(--faint); font-variant-numeric: tabular-nums; }+.msk-vrow .sh { flex: 0 1 150px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--code); font-size: 12px; }+.msk-vrow .k { flex: 0 1 130px; min-width: 0; display: flex; align-items: center; gap: 6px; overflow: hidden; white-space: nowrap; color: var(--fg-2); }+.msk-vrow .by { flex: none; width: 76px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11.5px; color: var(--muted); }+.msk-vrow .bar { flex: 1; min-width: 12px; display: flex; }+.msk-vrow .bar i { height: 1px; background: color-mix(in srgb, var(--fg) 24%, transparent); }+.msk-vrow:hover .bar i { background: var(--accent); }+.msk-vrow .x { flex: none; min-width: 36px; text-align: right; font-variant-numeric: tabular-nums; }++/* one request: back, its route and steps, its text, how each value went */+/* back, when, newer and older stay at the top while a long request+ scrolls under them, on the frosted strip Settings' head has */+.msk-onebar { position: sticky; top: 0; z-index: 3; display: flex; align-items: center; gap: 8px; min-height: 28px; }+.msk-onebar::before {+ content: ""; position: absolute; z-index: -1; pointer-events: none; inset: -6px -12px;+ background: color-mix(in srgb, var(--bg) 92%, transparent);+ -webkit-backdrop-filter: saturate(1.6) blur(16px); backdrop-filter: saturate(1.6) blur(16px);+}+body.window .msk-onebar { top: -2px; }+body.window .msk-onebar::before { inset: -6px -16px; }+.msk-back { display: inline-flex; align-items: center; gap: 2px; margin-left: -4px; }+.msk-crumb { color: var(--faint); }+.msk-when { font-size: 12.5px; color: var(--fg-2); font-variant-numeric: tabular-nums; }+.msk-req { margin-top: 8px; padding: 14px 18px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); }+.msk-who { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 14px; font-weight: 600; }+.msk-chip { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 6px; background: var(--pill); font-size: 11.5px; font-weight: 400; color: var(--fg-2); }+.msk-steps { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin: 14px 0 0; padding: 0; list-style: none; counter-reset: none; }+.msk-steps li { position: relative; min-width: 0; }+.msk-steps li + li::before { content: ""; position: absolute; left: -10px; top: 10px; width: 10px; height: 1px; background: var(--line-2); }+.msk-sdot { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; }+.msk-steps li.held .msk-sdot { background: var(--red-soft); color: var(--red); }+.msk-steps li.none .msk-sdot { background: var(--pill); color: var(--muted); }+.msk-st { margin-top: 6px; font-size: 12.5px; font-weight: 600; color: var(--fg); }+.msk-steps li.held .msk-st { color: var(--red); }+.msk-ss { margin-top: 2px; font-size: 11.5px; line-height: 1.4; color: var(--muted); overflow-wrap: anywhere; }+.msk-blocked { margin-top: 10px; padding: 14px 18px; border-radius: 14px; background: var(--card); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--red) 40%, transparent); }+.msk-bhead { display: flex; align-items: center; gap: 8px; color: var(--red); }+.msk-bhead svg path:first-child { fill: var(--red-soft); }+.msk-bhead h2 { margin: 0; font-size: 14px; font-weight: 600; color: var(--fg); }+.msk-blocked p { margin: 8px 0 0; font-size: 12.5px; line-height: 1.6; color: var(--fg-2); }+.msk-btools { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }+.msk-onegrid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 280px); gap: 14px; align-items: start; margin-top: 12px; }+.msk-content, .msk-how { min-width: 0; padding: 14px 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); }+.msk-chead { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; margin-bottom: 10px; }+.msk-chead h2 { margin: 0; font-size: 13px; font-weight: 600; }+.msk-hint { font-size: 11.5px; color: var(--faint); }+.msk-gone { margin: 0 0 10px; font-size: 12px; line-height: 1.55; color: var(--muted); }+.msk-msgs { display: flex; flex-direction: column; gap: 8px; }+.msk-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; font-size: 11px; color: var(--muted); }+.msk-msg { border-radius: 10px; background: var(--card-2); box-shadow: inset 0 0 0 1px var(--line); }+.msk-mhead { display: flex; align-items: center; gap: 8px; padding: 7px 12px; border-bottom: 1px solid var(--line); font-size: 11.5px; }+.msk-role { font-weight: 600; color: var(--fg-2); }+.msk-path { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--code); font-size: 11px; color: var(--faint); }+.msk-count { flex: none; color: var(--muted); }+.msk-mbody { display: grid; grid-template-columns: minmax(0, 1fr); }+.msk-msgs.both .msk-mbody { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }+.msk-msgs.both .msk-text + .msk-text { border-left: 1px solid var(--line); }+.msk-text { padding: 9px 12px; font-family: var(--code); font-size: 12px; line-height: 1.75; color: var(--fg-2); white-space: pre-wrap; overflow-wrap: anywhere; }+.msk-gap { color: var(--faint); }+.msk-ph, .msk-orig { --k: var(--accent); padding: 1px 4px; border-radius: 4px; font: inherit; color: var(--fg); background: color-mix(in srgb, var(--k) 16%, transparent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--k) 30%, transparent); outline: none; cursor: default; transition: opacity .15s, box-shadow .15s; }+.msk-ph:hover, .msk-ph:focus-visible, .msk-orig:hover, .msk-orig:focus-visible { background: color-mix(in srgb, var(--k) 26%, transparent); }+.msk-orig { background: transparent; box-shadow: inset 0 -1.5px 0 var(--k); border-radius: 2px; }+.msk-orig.gone { color: var(--faint); }+.msk-one.picking mark[data-p]:not(.lit) { opacity: .4; }+.msk-one mark.lit { box-shadow: inset 0 0 0 1.5px var(--k); }+.msk-whole { margin: 0 8px 6px; }+.msk-fold { border-radius: 10px; border: 1px dashed var(--line); }+.msk-foldb { display: flex; align-items: center; gap: 6px; width: 100%; padding: 7px 12px; border: 0; background: none; color: var(--muted); font: inherit; font-size: 11.5px; text-align: left; cursor: default; }+.msk-foldb svg { transition: transform .2s var(--ease); }+.msk-fold.open .msk-foldb svg { transform: rotate(90deg); }+.msk-foldb:hover { color: var(--fg-2); }+.msk-size { margin-left: auto; color: var(--faint); font-variant-numeric: tabular-nums; }+.msk-same { padding: 0 12px 8px; display: flex; flex-direction: column; gap: 4px; }+.msk-sameline { display: flex; gap: 8px; font-family: var(--code); font-size: 11px; line-height: 1.5; color: var(--muted); }+.msk-sameline > span:last-child { min-width: 0; overflow-wrap: anywhere; white-space: pre-wrap; }+.msk-sameline .msk-path { flex: none; max-width: 40%; }+.msk-how { display: flex; flex-direction: column; gap: 8px; }+.msk-how .msk-chead { margin-bottom: 2px; }+.msk-val { display: block; width: 100%; padding: 10px 12px; border: 0; border-radius: 10px; background: var(--card-2); box-shadow: inset 0 0 0 1px var(--line); color: var(--fg); font: inherit; text-align: left; cursor: default; }+.msk-val:hover { background: var(--pill); }+.msk-val[aria-pressed="true"] { box-shadow: inset 0 0 0 1.5px var(--k); }+.msk-vtop { display: flex; align-items: center; gap: 6px; font-size: 12px; }+.msk-vk { font-weight: 600; }+.msk-vx { color: var(--muted); font-variant-numeric: tabular-nums; }+.msk-vmid { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-family: var(--code); font-size: 11.5px; min-width: 0; }+.msk-vmid svg { flex: none; color: var(--faint); }+.msk-vshown, .msk-vph { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }+.msk-vph { color: var(--accent); }+.msk-vmeta { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 10px; margin: 8px 0 0; font-size: 11px; }+.msk-vmeta dt { color: var(--faint); }+.msk-vmeta dd { margin: 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--fg-2); }+.msk-note { margin: 2px 0 0; font-size: 11px; line-height: 1.5; color: var(--faint); }++@container (max-width: 760px) {+ .msk-onegrid { grid-template-columns: minmax(0, 1fr); }+ .msk-steps { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); row-gap: 12px; }+ .msk-steps li + li::before { display: none; }+}+@container (max-width: 640px) {+ .msk-band { grid-template-columns: minmax(0, 1fr); gap: 16px; }+ .mo-flow { grid-template-columns: minmax(0, 1fr) minmax(48px, 1fr) minmax(0, 1fr); gap: 4px; }+ .msk-model, .msk-kind:not(:first-child), .msk-kind.more { display: none; }+ .msk-msgs.both .msk-mbody, .msk-cols { grid-template-columns: minmax(0, 1fr); }+ .msk-cols span:last-child { display: none; }+ .msk-msgs.both .msk-text + .msk-text { border-left: 0; border-top: 1px solid var(--line); }+ .msk-vrow .by, .msk-vrow .bar { display: none; }+}+@media (prefers-reduced-motion: reduce) { .mo-scan, .msk-live i { animation: none; } }diff --git a/internal/gui/assets/plugins/routing/i18n.js b/internal/gui/assets/plugins/routing/i18n.jsindex 47086a669..97549e9ca 100644--- a/internal/gui/assets/plugins/routing/i18n.js+++ b/internal/gui/assets/plugins/routing/i18n.js@@ -14,7 +14,6 @@ magpie.strings({"{failed}, the searcher magpie picked, didn't search for {whom}: {why}. So magpie had {searcher}, the next searcher it can use, search in its place. Not a turn of the conversation.": "{failed} 是 magpie 自动选的代搜模型,但它没能为 {whom} 搜索:{why}。所以 magpie 改让下一个可用的代搜模型 {searcher} 来搜。不属于对话轮次。","This routing group will no longer be available to agents.": "此路由组将不再供 Agent 使用。","These routing groups will no longer be available to agents.": "这些路由组将不再供 Agent 使用。",- "By request": "按请求","By session": "按会话","No session ID": "未提供会话标识","{n} in progress": "{n} 个进行中",@@ -577,7 +576,6 @@ magpie.strings({"It can pick the model too: add a rule with an intent": "它也能挑模型:新增一條帶意圖的規則","This routing group will no longer be available to agents.": "此路由組將不再供 Agent 使用。","These routing groups will no longer be available to agents.": "這些路由組將不再供 Agent 使用。",- "By request": "按請求","By session": "按會話","No session ID": "未提供會話標識","{n} in progress": "{n} 個進行中",@@ -1118,7 +1116,6 @@ magpie.strings({"a model that can't search the web by itself": "自分ではウェブ検索できないモデル","{failed}, the searcher picked in Settings › Models › Web search, didn't search for {whom}: {why}. So magpie had {searcher}, the next searcher it can use, search in its place. Not a turn of the conversation.": "設定 › モデル › ウェブ検索 で選んだ検索モデル {failed} は {whom} の代わりに検索できませんでした:{why}。そのため magpie は次に使える検索モデル {searcher} に代わりに検索させました。会話のターンではありません。","{failed}, the searcher magpie picked, didn't search for {whom}: {why}. So magpie had {searcher}, the next searcher it can use, search in its place. Not a turn of the conversation.": "magpie が自動で選んだ検索モデル {failed} は {whom} の代わりに検索できませんでした:{why}。そのため magpie は次に使える検索モデル {searcher} に代わりに検索させました。会話のターンではありません。",- "By request": "リクエスト別","By session": "セッション別","No session ID": "セッション ID なし","{n} in progress": "{n} 件進行中",@@ -1671,7 +1668,6 @@ magpie.strings({"a model that can't search the web by itself": "ein Modell, das nicht selbst im Web suchen kann","{failed}, the searcher picked in Settings › Models › Web search, didn't search for {whom}: {why}. So magpie had {searcher}, the next searcher it can use, search in its place. Not a turn of the conversation.": "{failed}, der unter Einstellungen › Modelle › Websuche gewählte Sucher, hat nicht für {whom} gesucht: {why}. Daher ließ magpie {searcher}, den nächsten nutzbaren Sucher, an seiner Stelle suchen. Keine Runde des Gesprächs.","{failed}, the searcher magpie picked, didn't search for {whom}: {why}. So magpie had {searcher}, the next searcher it can use, search in its place. Not a turn of the conversation.": "{failed}, der von magpie gewählte Sucher, hat nicht für {whom} gesucht: {why}. Daher ließ magpie {searcher}, den nächsten nutzbaren Sucher, an seiner Stelle suchen. Keine Runde des Gesprächs.",- "By request": "Nach Anfrage","By session": "Nach Sitzung","No session ID": "Keine Sitzungs-ID","{n} in progress": "{n} laufend",diff --git a/internal/gui/core_budget_test.go b/internal/gui/core_budget_test.goindex 184a3d3fd..d28e3317c 100644--- a/internal/gui/core_budget_test.go+++ b/internal/gui/core_budget_test.go@@ -15,8 +15,8 @@ import (// so a page can't quietly grow back into the core; a change that needs more// raises them and says why in its commit.const (- appScriptBudget = 1_343_465 // app.js: 1,198,239 after Usage left (P2); 1,218,098 with the 10-15 fixes to pages still in the core; 1,232,466 with the provider editor's Advanced fold and every dialog holding its place, the core's own (10-16); 1,250,533 with the quota refresh kept through redraws, the core's own since the tray panel draws it too, plus 1.5% (#2397); 1,269,083 with Free first's option in the provider editor's ROUTINGS, which the Routing page reads too, plus 1.5%; 1,272,726 with the Providers page drawing its last list at once (#1519), the core's page, and the Routing trace's account names read without Object.entries (#1481), plus 1.5%; a dialog growing out of the row that opened it and folding back into it, the core's own since every page's dialogs open through it (10-20); Codex's and Claude Code's own settings moved from Settings into the agent's row on the Agents page, the core's own since the tray panel and the window both draw them (10-20); 1,314,432 with Settings › Privacy's record of what was masked (its summary, the records view and the local model's controls), which belongs to Settings, the core's own, plus 1.5%; 1,336,481 with a provider's Names & levels saying Provider in model names is Settings' and opening it there (joe), and Settings' Image recognition saying where a custom provider's model is marked (nexnull), both in the core's own pages, with no room added (10-23); 1,337,633 with Settings › Models › Replies' Intent classifier timeout (#2934, reyoung), Settings' own row, drawn by waitRow, which the Image generation timeout's row now shares, with no room added; 1,337,735 with the provider editor's link naming a partner's page by its own host (siteHost) instead of usemagpie.ai's /go link, the core's own editor, with no room added (10-23); 1,338,084 with Check in now saying what the press came to (claimed +credits, already today, not available yet) where it said "refreshed" (#3326), the check-in row the tray panel draws too, the core's own, with no room added (10-23); 1,338,929 with a new partner's tile keeping a small dot until it is opened, in the add sheet, the core's own, with no room added (10-23); 1,343,324 with the sidebar's open-page row marked by one shape that moves on a spring (navTopGo), the window's own shell, which every page sits beside, with no room added (10-23); 1,343,465 with a dialog kept centred while its content comes in, until it is pressed (holdModal, every page's dialogs), the core's own, with no room added (10-24)- coreScriptBudget = 1_550_768 // every core script: 1,358,034 after Usage left; 1,380,003 with them; 1,405,937 with the fold; 1,426,102 with 10-16's core work (the GitHub list loading, the move to plugins, Settings › Long conversations), plus 1.5% (#2612); 1,447,368 with loadBack, the window's one state read per return, which every page needs and so is the core's own (1,446,845 before it, 155 bytes under), plus 1.5%; OpenCode Zen's card saying OpenCode tells no key its balance adds ~390 bytes inside it; 1,472,589 with the dialog that grows out of its row and the agents' own settings in their rows, on main's 10-20 core work (the Providers page's last list, the Routing trace's names), plus 1.5% (10-20); 1,506,192 with Settings › Privacy's record of what was masked, plus 1.5%; 1,529,393 with the Intent classifier timeout row (#2934), with no room added; 1,529,495 with the editor's partner link host, with no room added; 1,529,844 with Check in now's press summary (#3326), with no room added; 1,530,689 with the new partner tile's dot, with no room added; 1,535,084 with the sidebar's spring, with no room added; 1,549,478 with the context window card's map (tiles by tokens, the default look, the block grid a switch away) and its text view showing an inline image, in context.js, which the Routing page draws as well as Usage, so the core's own, with no room added (10-24); 1,550,768 with a usage card's refresh opening after its text (#840's card, which the tray panel draws too), the Add key spinner, and a dialog kept centred while its content comes in, with no room added (10-24)+ appScriptBudget = 1_317_486 // app.js: 1,198,239 after Usage left (P2); 1,218,098 with the 10-15 fixes to pages still in the core; 1,232,466 with the provider editor's Advanced fold and every dialog holding its place, the core's own (10-16); 1,250,533 with the quota refresh kept through redraws, the core's own since the tray panel draws it too, plus 1.5% (#2397); 1,269,083 with Free first's option in the provider editor's ROUTINGS, which the Routing page reads too, plus 1.5%; 1,272,726 with the Providers page drawing its last list at once (#1519), the core's page, and the Routing trace's account names read without Object.entries (#1481), plus 1.5%; a dialog growing out of the row that opened it and folding back into it, the core's own since every page's dialogs open through it (10-20); Codex's and Claude Code's own settings moved from Settings into the agent's row on the Agents page, the core's own since the tray panel and the window both draw them (10-20); 1,314,432 with Settings › Privacy's record of what was masked (its summary, the records view and the local model's controls), which belongs to Settings, the core's own, plus 1.5%; 1,336,481 with a provider's Names & levels saying Provider in model names is Settings' and opening it there (joe), and Settings' Image recognition saying where a custom provider's model is marked (nexnull), both in the core's own pages, with no room added (10-23); 1,337,633 with Settings › Models › Replies' Intent classifier timeout (#2934, reyoung), Settings' own row, drawn by waitRow, which the Image generation timeout's row now shares, with no room added; 1,337,735 with the provider editor's link naming a partner's page by its own host (siteHost) instead of usemagpie.ai's /go link, the core's own editor, with no room added (10-23); 1,338,084 with Check in now saying what the press came to (claimed +credits, already today, not available yet) where it said "refreshed" (#3326), the check-in row the tray panel draws too, the core's own, with no room added (10-23); 1,338,929 with a new partner's tile keeping a small dot until it is opened, in the add sheet, the core's own, with no room added (10-23); 1,343,324 with the sidebar's open-page row marked by one shape that moves on a spring (navTopGo), the window's own shell, which every page sits beside, with no room added (10-23); 1,343,465 with a dialog kept centred while its content comes in, until it is pressed (holdModal, every page's dialogs), the core's own, with no room added (10-24); 1,317,486 with what masking did moved out to Insights › Masking (plugins/redact), the budget lowered to it (10-24)+ coreScriptBudget = 1_524_789 // every core script: 1,358,034 after Usage left; 1,380,003 with them; 1,405,937 with the fold; 1,426,102 with 10-16's core work (the GitHub list loading, the move to plugins, Settings › Long conversations), plus 1.5% (#2612); 1,447,368 with loadBack, the window's one state read per return, which every page needs and so is the core's own (1,446,845 before it, 155 bytes under), plus 1.5%; OpenCode Zen's card saying OpenCode tells no key its balance adds ~390 bytes inside it; 1,472,589 with the dialog that grows out of its row and the agents' own settings in their rows, on main's 10-20 core work (the Providers page's last list, the Routing trace's names), plus 1.5% (10-20); 1,506,192 with Settings › Privacy's record of what was masked, plus 1.5%; 1,529,393 with the Intent classifier timeout row (#2934), with no room added; 1,529,495 with the editor's partner link host, with no room added; 1,529,844 with Check in now's press summary (#3326), with no room added; 1,530,689 with the new partner tile's dot, with no room added; 1,535,084 with the sidebar's spring, with no room added; 1,549,478 with the context window card's map (tiles by tokens, the default look, the block grid a switch away) and its text view showing an inline image, in context.js, which the Routing page draws as well as Usage, so the core's own, with no room added (10-24); 1,550,768 with a usage card's refresh opening after its text (#840's card, which the tray panel draws too), the Add key spinner, and a dialog kept centred while its content comes in, with no room added (10-24); 1,524,789 with what masking did moved out to Insights › Masking, lowered to it)func TestCoreScriptBudget(t *testing.T) {diff --git a/internal/gui/tests/masking-records.test.cjs b/internal/gui/tests/masking-records.test.cjsindex 39ffcd919..9a6bd9900 100644--- a/internal/gui/tests/masking-records.test.cjs+++ b/internal/gui/tests/masking-records.test.cjs@@ -1,25 +1,26 @@// Run with Node's test runner and Playwright on the module path; see README.md.-// Settings › Privacy opens on what masking kept from vendors: the number,-// the days, the kinds, agents to providers and the values masked most, a-// value shown only while pointed at (and said gone when this magpie no-// longer knows it), and the newest request as the vendor got it or, asked-// for, as it is here. Its records open from the card, filtered by what was-// clicked, each one opening on the text the vendor saw. A masked call on-// the Gateway page opens its own record. Nothing in the card or the-// records is left in English, nothing is wider than the window, and a-// click scrolls nothing.-// Every language, Chromium and WebKit, 1100 and 640px, tall enough that-// pointing at a row needs no scroll; the API is faked.+// Insights › Masking: a short card of what masking kept from vendors (the+// number, the days, agents to providers through magpie's bird) over the+// requests it changed, by day, narrowed by facets, agents and providers,+// or the values masked most. A request opens on its steps, its text as+// written here, as the vendor got it or side by side (only the parts+// masking changed, the rest folded) and how each value was masked; picking+// a value lights its places. A request held back says why and offers to+// mask instead; one whose text is gone (a restart, or older than the+// newest kept) shows the lines that are left. Masking off and nothing+// masked, the card offers to turn it on. A masked call on the Gateway page+// and a key= in the address open its request. Nothing is left in English,+// nothing is wider than the window, and a click scrolls nothing.+// Every language, Chromium and WebKit, 1100 and 640px; the API is faked.const assert = require("node:assert/strict");const fs = require("node:fs/promises");const path = require("node:path");const { test } = require("node:test");const { chromium, webkit } = require("playwright");-const { watchSettingsReads, settingsDrawn } = require("./reader.cjs");const assets = path.resolve(__dirname, "../assets");-const KEY = "{{API_KEY_aaaa1111}}", NAME = "{{PERSON_bbbb2222}}", MAIL = "{{EMAIL_cccc3333}}";-const SECRET = "sk-proj-abcdEFGH1234ijkl";+const KEY = "{{API_KEY_aaaa1111}}", NAME = "{{PERSON_bbbb2222}}", MAIL = "{{EMAIL_cccc3333}}", PK = "{{PRIVATE_KEY_dddd4444}}";+const SECRET = "sk-proj-abcdEFGH1234ijkl", ADDR = "[email protected]";function day(back) {const d = new Date();@@ -32,7 +33,7 @@ function summary(days) {const per = [0, 3, 0, 7, 5, 12, 15];return {days: Array.from({ length: days }, (_, i) => { const n = per[(i + 7 - days % 7) % 7]; return { day: day(days - 1 - i), requests: n ? 2 : 0, n, distinct: n ? 1 : 0 }; }),- requests: 9, n: 42, distinct: 11, hours: [],+ requests: 9, n: 42, distinct: 11, blocked: 1, hours: [],kinds: [{ name: "API_KEY", n: 20, distinct: 3 }, { name: "EMAIL", n: 12, distinct: 4 }, { name: "PERSON", n: 10, distinct: 4 }],by: { rule: 7, model: 4 },agents: [{ name: "claude", n: 30, distinct: 8 }, { name: "codex", n: 12, distinct: 3 }],@@ -44,24 +45,42 @@ function summary(days) {since: ago(7 * 86400e3),};}+const filler = "x".repeat(900);+// the body 1002 went out with: a long system prompt nothing was masked in,+// and a user message with two values+const SENT = JSON.stringify({ model: "claude-opus-4-1", system: "You are Claude Code. " + filler, messages: [+ { role: "user", content: [{ type: "text", text: "earlier, unchanged" }] },+ { role: "user", content: [{ type: "text", text: `export OPENAI_API_KEY=${KEY} # mail ${MAIL}, again ${KEY}` }] },+] });const records = [- { key: 1002, t: ago(120e3), route: "messages", what: "chat", agent: "claude", provider: "anthropic", model: "claude-opus-4-1", n: 3,- values: [{ p: KEY, k: "API_KEY", b: "rule", h: "sk-p", l: 24, n: 2, known: true }, { p: MAIL, k: "EMAIL", b: "rule", h: "a", l: 17, n: 1 }],- // two values in one line: their text is shown once+ { key: 1003, t: ago(60e3), route: "messages", what: "chat", agent: "claude", provider: "anthropic", model: "claude-opus-4-1", n: 1, blocked: true,+ values: [{ p: PK, k: "PRIVATE_KEY", b: "rule", h: "b3Bl", l: 400, n: 1, a: "block" }],+ snips: { [PK]: `-----BEGIN OPENSSH PRIVATE KEY----- ${PK}` } },+ { key: 1002, t: ago(120e3), route: "messages", what: "chat", agent: "claude", provider: "anthropic", model: "claude-opus-4-1", n: 3, took: 1800, back: { [KEY]: 1 },+ values: [{ p: KEY, k: "API_KEY", b: "rule", h: "sk-p", l: 24, n: 2, known: true }, { p: MAIL, k: "EMAIL", b: "rule", h: "a", l: 15, n: 1, known: true }],snips: { [KEY]: `export OPENAI_API_KEY=${KEY} # mail ${MAIL}`, [MAIL]: `…_KEY=${KEY} # mail ${MAIL}` } },+ // from before a restart: no body, no values in memory{ key: 1001, t: ago(300e3), route: "search", what: "search", agent: "codex", provider: "openai", model: "gpt-5", n: 1,- values: [{ p: NAME, k: "PERSON", b: "model", h: "", l: 3, n: 1 }] },+ values: [{ p: NAME, k: "PERSON", b: "model", h: "", l: 3, n: 1 }], snips: { [NAME]: `ask ${NAME} about it` } },];-function serve(lang, sum, asked) {- const settings = { theme: "light", lang, tray: "panel", currency: "usd", redact: true, redactPersonal: true };+function serve(lang, sum, asked, opts = {}) {+ const settings = { theme: "light", lang, tray: "panel", currency: "usd", redact: !opts.off, redactPersonal: !opts.off, redactActions: { PRIVATE_KEY: "block" } };return async (route) => {const req = route.request(), url = new URL(req.url());const json = (data) => route.fulfill({ json: data });if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:"${lang}",theme:"light",web:true};` });if (url.pathname === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });- if (url.pathname === "/api/state") return json({ agents: [{ id: "claude", name: "Claude Code", icon: "claude" }, { id: "codex", name: "Codex", icon: "codex" }], profiles: [], settings });- if (url.pathname === "/api/settings") return json(settings);+ if (url.pathname === "/api/state") return json({ agents: [{ id: "claude", name: "Claude Code", icon: "claude", fields: [] }, { id: "codex", name: "Codex", icon: "codex", fields: [] }], profiles: [], settings });+ if (url.pathname === "/api/settings") {+ if (req.method() === "POST") { asked.push("settings " + req.postData()); Object.assign(settings, JSON.parse(req.postData())); }+ return json(settings);+ }+ if (url.pathname === "/api/settings/redact-actions") {+ asked.push("actions " + req.postData());+ settings.redactActions = JSON.parse(req.postData()).actions;+ return json(settings);+ }if (url.pathname === "/api/providers") return json({ providers: [{ id: "anthropic", name: "Anthropic", icon: "anthropic", agents: [], models: [] }, { id: "openai", name: "OpenAI", icon: "openai", agents: [], models: [] }], presets: [], excluded: [],gateway: { running: true, window: true, mine: true, url: "http://127.0.0.1:3999", models: 0, groups: [],calls: [{ id: 7, time: ago(120e3), agent: "claude", model: "claude-opus-4-1", from: "anthropic", to: "anthropic", status: 200, ms: 900, masked: { n: 3, distinct: 2, kinds: { API_KEY: 2, EMAIL: 1 }, by: { rule: 2 }, key: 1002 } },@@ -72,14 +91,25 @@ function serve(lang, sum, asked) {if (url.pathname === "/api/masking/summary") return json(sum(+url.searchParams.get("days")));if (url.pathname === "/api/masking/records") {asked.push(url.search);- const q = url.searchParams;- const rs = records.filter((r) => (!q.get("kind") || r.values.some((v) => v.k === q.get("kind"))) && (!q.get("by") || r.values.some((v) => v.b === q.get("by"))));+ const q = url.searchParams, kinds = q.get("kind")?.split(",");+ const rs = (opts.none ? [] : records).filter((r) => (!kinds || r.values.some((v) => kinds.includes(v.k))) && (!q.get("by") || r.values.some((v) => v.b === q.get("by")))+ && (!q.get("agent") || r.agent === q.get("agent")) && (!q.get("provider") || r.provider === q.get("provider")) && (!q.get("blocked") || r.blocked));return json({ records: rs, more: false });}if (url.pathname === "/api/masking/record") {const r = records.find((r) => r.key === +url.searchParams.get("key"));return r ? json(r) : route.fulfill({ status: 404, body: "404 page not found" });}+ if (url.pathname === "/api/masking/sent") {+ asked.push("sent " + url.searchParams.get("key"));+ return url.searchParams.get("key") === "1002" ? json({ body: SENT }) : route.fulfill({ status: 404, body: "404 page not found" });+ }+ if (url.pathname === "/api/masking/values") {+ const known = { [KEY]: SECRET, [MAIL]: ADDR };+ const ps = JSON.parse(req.postData()).ps;+ asked.push("values " + ps.join(","));+ return json({ values: Object.fromEntries(ps.filter((p) => known[p]).map((p) => [p, known[p]])) });+ }if (url.pathname === "/api/masking/value") {asked.push("value " + url.searchParams.get("p"));return url.searchParams.get("p") === KEY ? json({ value: SECRET }) : route.fulfill({ status: 404, body: "404 page not found" });@@ -91,135 +121,183 @@ function serve(lang, sum, asked) {};}-async function open(engine, lang, width, sum, where) {+async function open(engine, lang, width, sum, where, opts) {const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));- const page = await (await browser.newContext({ viewport: { width, height: 1800 }, reducedMotion: "reduce" })).newPage();+ const page = await (await browser.newContext({ viewport: { width, height: 1000 }, reducedMotion: "reduce" })).newPage();page.setDefaultTimeout(8000);const errors = [], asked = [];page.on("pageerror", (e) => errors.push(e.message));- await page.route("**/*", serve(lang, sum, asked));- await watchSettingsReads(page);- await page.goto("http://magpie.test/" + (where || "?view=settings&tab=privacy"));- if (!where) await settingsDrawn(page);+ await page.route("**/*", serve(lang, sum, asked, opts));+ await page.goto("http://magpie.test/" + (where || "?view=masking"));return { browser, page, errors, asked };}+// what the fake API was asked is on this side, not the page's+async function until(ok, ms = 8000) {+ for (const end = Date.now() + ms; !ok();) {+ if (Date.now() > end) throw new Error("never happened: " + ok);+ await new Promise((r) => setTimeout(r, 25));+ }+}+const shot = (page, name) => process.env.MASK_SHOTS && page.screenshot({ path: path.join(process.env.MASK_SHOTS, name + ".png"), fullPage: true });// English that a translated page must not show-const english = ["Kept from vendors", "What the vendor saw", "As written here", "Latest request", "Different values", "values masked", "What was kept", "Masked most", "View records", "What was masked", "Every kind", "Found by", "Local model", "Not in memory", "This request"];+const english = ["Kept from vendors", "By request", "By value", "masked these on this computer", "Different values", "values masked", "Held back",+ "Request content", "How it was masked", "What happened", "Side by side", "Only the parts masking changed", "parts unchanged", "Found by", "In the answer",+ "This request was not sent", "Mask it instead", "See the rules", "Nothing to put back", "no longer in memory", "Masked most", "Local model"];+const untranslated = async (page, lang) => {+ if (lang === "en") return;+ const said = await page.locator("#view-masking").innerText();+ for (const w of english) assert(!said.includes(w), `${w} left in English: ${said}`);+};const wide = (page) => page.evaluate(() => {- const over = [...document.querySelectorAll("#maskObs *, #maskRecs *")].filter((n) => n.getClientRects().length && n.getBoundingClientRect().right > innerWidth + 1).map((n) => n.className?.baseVal ?? n.className);+ const over = [...document.querySelectorAll("#view-masking *")].filter((n) => n.getClientRects().length && n.getBoundingClientRect().right > innerWidth + 1 && !n.closest(".msk-text, .msk-same")).map((n) => n.className?.baseVal ?? n.className);return { page: document.documentElement.scrollWidth > document.documentElement.clientWidth, over };});-const scrolled = (page) => page.evaluate(() => [scrollX, scrollY, document.querySelector("#view-settings").scrollTop]);+const scrolled = (page) => page.evaluate(() => [scrollX, scrollY, document.querySelector("#view-masking").scrollTop, document.querySelector("main, .main, #main")?.scrollTop ?? 0]);+// a click that moves nothing: Playwright brings the target into view+// first, so the page is read after that and again after the click+async function stillClick(page, loc) {+ await loc.scrollIntoViewIfNeeded();+ const before = await scrolled(page);+ await loc.click();+ await page.waitForTimeout(100);+ assert.deepEqual(await scrolled(page), before, "no click moved the page");+}for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {for (const lang of ["en", "zh", "zh-TW", "ja", "de"]) {for (const width of [1100, 640]) {- test(`${engine} ${lang} ${width}px: the card says what was kept, and its records open on what the vendor saw`, async (t) => {+ test(`${engine} ${lang} ${width}px: the card says what was kept, and each request opens on what changed`, async (t) => {const { browser, page, errors, asked } = await open(engine, lang, width, summary);t.after(() => browser.close());- const card = page.locator("#maskObs");- await card.locator(".mo-num").waitFor();- assert.equal(await card.locator(".mo-num").textContent(), "42");- assert.equal(await card.locator(".mo-days .mo-day").count(), 7, "a bar a day");- assert.equal(await card.locator(".mo-days .mo-day.zero").count(), 2, "a day with nothing, a dot");- assert.equal(await card.locator(".mo-ledg.kind .mo-row:enabled").count(), 3);- assert.equal(await card.locator(".mo-ledg.by .mo-row:enabled").count(), 2, "rules, then the model");- assert.equal(await card.locator(".mo-row.model").count(), 1, "what only the model found");- // the newest lines, as the vendor got them: one line shown once- await card.locator(".mo-saw .mo-snip").first().waitFor();- assert.equal(await card.locator(".mo-saw .mo-snip").count(), 1);- assert.deepEqual(await card.locator(".mo-saw mark.mo-ph").allTextContents(), [KEY, MAIL]);- assert.equal(await page.evaluate(() => [document.querySelector("#maskObs"), ...document.querySelectorAll("#maskObs *")].some((n) => /gradient/.test(getComputedStyle(n).backgroundImage + getComputedStyle(n, "::before").backgroundImage))), false, "flat: no gradient");+ const card = page.locator("#maskCard"), list = page.locator("#maskList");+ await card.locator(".msk-num").waitFor();+ assert.equal(await card.locator(".msk-num").textContent(), "42");+ assert.equal(await card.locator(".msk-days .msk-day").count(), 7, "a bar a day");+ assert.equal(await card.locator(".msk-days .msk-day.zero").count(), 2, "a day with nothing, a dot");assert.deepEqual(await card.locator(".mo-col.agent .nm").allTextContents(), ["Claude Code", "Codex"]);assert.deepEqual(await card.locator(".mo-col.provider .nm").allTextContents(), ["Anthropic", "OpenAI"]);- // hairlines into this computer and out of it, drawn once it is laid out- await card.locator(".mo-flow path.mo-th:not(.out)").first().waitFor({ state: "attached" });await card.locator(".mo-flow path.mo-th.out").first().waitFor({ state: "attached" });- assert.equal(await page.evaluate(() => getComputedStyle(document.querySelector("#maskObs")).boxShadow), "none", "no shadow");- assert.deepEqual(await card.locator(".mo-val .sh").allTextContents(), ["sk-p••••••••", "•••"]);- assert.equal((await card.textContent()).includes(SECRET), false, "no value until pointed at");- assert.equal(asked.filter((a) => a.startsWith("value")).length, 0, "nothing asked until pointed at");- if (lang !== "en") {- const said = await page.locator("#maskObs").innerText();- for (const w of english) assert(!said.includes(w), `${w} left in English: ${said}`);- }- assert.deepEqual(await wide(page), { page: false, over: [] });+ // magpie's bird on the line through this computer, and the words+ // that say magpie masked them, for a screenshot shared elsewhere+ assert.equal(await card.locator(".msk-hub use").getAttribute("href"), "#bird");+ const hub = await card.locator(".msk-hub").boundingBox(), mid = await card.locator(".mo-mid").boundingBox();+ assert(Math.abs(hub.x + hub.width / 2 - (mid.x + mid.width / 2)) < 1.5, "the bird sits on the centre line");+ assert.match(await card.locator(".mo-cap").textContent(), /magpie/);+ assert.equal(await page.evaluate(() => [...document.querySelectorAll("#maskCard, #maskCard *")].some((n) => /gradient/.test(getComputedStyle(n).backgroundImage))), false, "flat: no gradient");+ // short: the list starts in the first screen+ assert((await list.locator(".msk-row").first().boundingBox()).y < 760, "the requests show without a scroll");- // pointed at, a value says what it was; one this magpie no longer- // knows says so+ // the requests, by day, the held one red+ await list.locator(".msk-row").first().waitFor();+ assert.equal(await list.locator(".msk-row").count(), 3);+ assert.equal(await list.locator(".msk-row.held .msk-held").count(), 1);+ assert.equal(await list.locator(".msk-gday").count(), 1);+ // facets with their counts, a zero left out+ assert.deepEqual(await list.locator(".msk-facet b").allTextContents(), ["42", "20", "7", "4", "1"]);+ await untranslated(page, lang);+ assert.deepEqual(await wide(page), { page: false, over: [] });+ await shot(page, `${engine}-${lang}-${width}-main`);const before = await scrolled(page);- await card.locator(".mo-val").first().hover();- await page.waitForFunction((s) => document.querySelector(".mask-tip .v")?.textContent === s, SECRET);- await card.locator(".mo-val").nth(1).hover();- await page.waitForFunction(() => document.querySelector(".mask-tip .v.gone"));- await page.mouse.move(1, 1);- await page.locator(".mask-tip").waitFor({ state: "detached" });- // a line's placeholder says what it stood for- await card.locator(".mo-saw mark.mo-ph").first().hover();+ // a facet narrows the list, and All brings it back+ await list.locator(".msk-facet.model").click();+ await page.waitForFunction(() => document.querySelectorAll("#maskList .msk-row").length === 1);+ assert.match(asked.filter((a) => a.startsWith("?")).at(-1), /by=model/);+ await list.locator(".msk-facet").first().click();+ await page.waitForFunction(() => document.querySelectorAll("#maskList .msk-row").length === 3);+ // an agent in the flow narrows it to that agent+ await card.locator(".mo-col.agent .mo-node", { hasText: "Codex" }).click();+ await page.waitForFunction(() => document.querySelectorAll("#maskList .msk-row").length === 1);+ assert.match(asked.filter((a) => a.startsWith("?")).at(-1), /agent=codex/);+ await card.locator(".mo-col.agent .mo-node.on").click();+ await page.waitForFunction(() => document.querySelectorAll("#maskList .msk-row").length === 3);++ // by value: the values masked most, each said only while pointed at+ await list.locator(".msk-bar .segs .opt").nth(1).click();+ await list.locator(".msk-vrow").first().waitFor();+ assert.deepEqual(await list.locator(".msk-vrow .sh").allTextContents(), ["sk-p••••••••", "•••"]);+ assert.equal((await list.textContent()).includes(SECRET), false, "no value until pointed at");+ await list.locator(".msk-vrow").first().hover();await page.waitForFunction((s) => document.querySelector(".mask-tip .v")?.textContent === s, SECRET);await page.mouse.move(1, 1);- await page.locator(".mask-tip").waitFor({ state: "detached" });+ await untranslated(page, lang);+ await list.locator(".msk-bar .segs .opt").first().click();- // asked for, the newest request as it is here: each value read then,- // one this magpie no longer knows said so; and back- await card.locator(".mo-saw .segs .opt").nth(1).click();- await page.waitForFunction((s) => document.querySelector("#maskObs .mo-orig:not(.gone)")?.textContent === s, SECRET);- await card.locator(".mo-saw .mo-orig.gone").waitFor();- assert.equal(await card.locator(".mo-saw mark.mo-ph").count(), 0);- await card.locator(".mo-saw .segs .opt").first().click();- assert.deepEqual(await card.locator(".mo-saw mark.mo-ph").allTextContents(), [KEY, MAIL]);+ // a request: its steps, only the text masking changed, side by side+ await list.locator(".msk-row:not(.held)").first().click();+ const one = page.locator("#maskOne");+ await one.locator(".msk-msg").first().waitFor();+ assert.equal(await card.isHidden(), true);+ assert.equal(await one.locator(".msk-steps li").count(), 5);+ assert.equal(await one.locator(".msk-msg").count(), 1, "one piece of text had values");+ assert.equal(await one.locator(".msk-fold").count(), 1, "the system prompt and the earlier message, folded as one");+ assert.deepEqual(await one.locator(".msk-msg .msk-text").last().locator("mark").allTextContents(), [KEY, MAIL, KEY], "as the vendor got it");+ // as written here; an address stays hidden while Hide accounts is on+ // (it is, while Privacy masks personal data), for a screenshot+ const here = one.locator(".msk-msg .msk-text").first().locator("mark");+ assert.deepEqual(await here.evaluateAll((ms) => ms.map((m) => m.querySelector(".pii")?.dataset.raw ?? m.textContent)), [SECRET, ADDR, SECRET], "as written here");+ assert.equal(await here.nth(1).locator(".pii").count(), 1, "the address hidden");+ assert.equal(await one.locator(".msk-val").count(), 2);+ assert.match(await one.locator(".msk-steps").innerText(), /1[.,]8 ms/);+ await untranslated(page, lang);+ assert.deepEqual(await wide(page), { page: false, over: [] });+ await shot(page, `${engine}-${lang}-${width}-request`);+ // picked, a value lights its places and says what it was+ await stillClick(page, one.locator(".msk-val").first());+ assert.equal(await one.locator("mark.lit").count(), 4);+ assert.equal(await one.locator(".msk-val[aria-pressed=true] .msk-vshown").textContent(), SECRET);+ // a fold opens on what it holds+ await stillClick(page, one.locator(".msk-foldb").first());+ await one.locator(".msk-sameline").first().waitFor();- // a kind's row opens its records, filtered by it- await card.locator(".mo-ledg.kind .mo-row").nth(1).click();- const recs = page.locator("#maskRecs");- await recs.locator(".mr-item").first().waitFor();- assert.match(asked.filter((a) => a.startsWith("?")).at(-1), /kind=EMAIL/);- assert.equal(await page.locator("#redactList").isVisible(), false, "the records stand in for the page");- assert.equal(await recs.locator(".mr-item").count(), 1);- if (lang !== "en") {- const said = await recs.innerText();- for (const w of english) assert(!said.includes(w), `${w} left in English: ${said}`);- }- // opened: each value, and the text the vendor saw with its- // placeholders marked- await recs.locator(".mr-row").first().click();- await recs.locator(".mr-body .mr-snip").first().waitFor();- assert.equal(await recs.locator(".mr-val").count(), 2);- assert.equal(await recs.locator(".mr-body .mr-snip").count(), 1, "a shared line once");- assert.deepEqual(await recs.locator(".mr-snip mark.mr-ph").allTextContents(), [KEY, MAIL]);- assert.equal(await recs.locator(".mr-shape.known").count(), 1, "only a value it still knows offers to show");- await recs.locator(".mr-snip mark.mr-ph").first().hover();- await page.waitForFunction((s) => document.querySelector(".mask-tip .v")?.textContent === s, SECRET);+ // the older one is from before a restart: the lines that are left,+ // as the vendor got them+ await one.locator(".msk-step").nth(1).click();+ await one.locator(".msk-gone").waitFor();+ assert.equal(await one.locator(".msk-chead .segs .opt:disabled").count(), 2, "only what the vendor saw");+ assert.deepEqual(await one.locator(".msk-msg mark").allTextContents(), [NAME]);+ await untranslated(page, lang);+ // and the newest was held back: why, and how to send it masked+ await one.locator(".msk-step").first().click();+ await one.locator(".msk-step").first().click();+ await one.locator(".msk-blocked").waitFor();+ await untranslated(page, lang);assert.deepEqual(await wide(page), { page: false, over: [] });- assert.deepEqual(await scrolled(page), before, "no click moved the page");+ await shot(page, `${engine}-${lang}-${width}-blocked`);+ await one.locator(".msk-btools button").first().click();+ await until(() => asked.some((x) => x.startsWith("actions")));+ assert.deepEqual(JSON.parse(asked.find((x) => x.startsWith("actions")).slice(8)), { actions: { PRIVATE_KEY: "mask" } });- // back to Privacy, as it was- await recs.locator(".mr-back").click();- await page.locator("#redactList").waitFor();- assert.equal(await recs.isHidden(), true);+ // back to the list, as it was+ await one.locator(".msk-back").click();+ await list.locator(".msk-row").first().waitFor();+ assert.equal(await one.isHidden(), true);+ assert.deepEqual(await scrolled(page), before, "no click moved the page");assert.deepEqual(errors, []);});}+ test(`${engine} ${lang}: masking off and nothing masked, the card offers to turn it on`, async (t) => {+ const empty = (d) => ({ ...summary(d), requests: 0, n: 0, distinct: 0, blocked: 0, kinds: [], agents: [], providers: [], values: [], by: {} });+ const { browser, page, errors, asked } = await open(engine, lang, 640, empty, null, { off: true, none: true });+ t.after(() => browser.close());+ await page.locator("#maskCard.off").waitFor();+ await page.locator("#maskList .msk-none").waitFor();+ if (lang !== "en") {+ const said = await page.locator("#view-masking").innerText();+ for (const w of ["Requests go to vendors", "Turn on masking", "You can also", "Nothing masked yet"]) assert(!said.includes(w), `${w} left in English: ${said}`);+ }+ assert.deepEqual(await wide(page), { page: false, over: [] });+ await shot(page, `${engine}-${lang}-off`);+ await page.locator("#maskCard .primary").click();+ await until(() => asked.some((x) => x.startsWith("settings")));+ assert.equal(JSON.parse(asked.find((x) => x.startsWith("settings")).slice(9)).redact, true);+ await page.locator("#maskCard:not(.off) .msk-head").waitFor();+ assert.deepEqual(errors, []);+ });}- test(`${engine}: a summary of nothing, an empty one and records filtered to nothing each say so`, async (t) => {- let shape = {};- const { browser, page, errors } = await open(engine, "en", 1100, () => shape);- t.after(() => browser.close());- // an old magpie's {}: the card waits on requests, without failing- await page.locator("#maskObs .mo-empty").waitFor();- assert.match(await page.locator("#maskObs").innerText(), /A request that carries a key/);- await page.locator("#maskObs .mo-open").count().then((n) => assert.equal(n, 0));- shape = { ...summary(7), requests: 0, n: 0, distinct: 0, kinds: [], agents: [], providers: [], values: [], by: {} };- // the records with a filter matching nothing- await page.evaluate(() => maskOpenRecords({ by: "yours" }));- await page.locator("#maskRecs .mr-none", { hasText: "Nothing masked matches these filters" }).waitFor();- assert.deepEqual(errors, []);- });-- test(`${engine}: a masked call on the Gateway page opens its record`, async (t) => {+ test(`${engine}: a masked call on the Gateway page, and a key in the address, open its request`, async (t) => {const { browser, page, errors } = await open(engine, "en", 1100, summary, "?view=gateway");t.after(() => browser.close());const badge = page.locator("#activity .call .mask-badge:not(.warn)");@@ -231,11 +309,17 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",assert.equal(await badge.textContent(), "3");assert.match(await badge.getAttribute("title"), /^3 values masked before it went to the vendor: API keys 2, Emails 1$/);await badge.click();- const recs = page.locator("#maskRecs");- await recs.locator(".row-head .label", { hasText: "This request" }).waitFor();- // first, and open on what the vendor saw- await recs.locator(".mr-item.open .mr-snip").first().waitFor();+ await page.locator("#view-masking #maskOne .msk-msg").first().waitFor();assert.equal(await page.locator("#activity .call-item.open").count(), 0, "the click wasn't the row's");+ assert.match(await page.locator("#maskOne .msk-when").textContent(), /\d/);+ // the tray panel's badge opens the window on key=+ await page.goto("http://magpie.test/?view=masking&key=1001");+ await page.locator("#maskOne .msk-gone").waitFor();+ assert.equal(new URL(page.url()).searchParams.get("key"), null, "read once");+ // and Settings › Privacy links to the page+ await page.goto("http://magpie.test/?view=settings&tab=privacy");+ await page.locator("#redactList .row", { hasText: "What was masked" }).locator("button").click();+ await page.locator("#maskCard .msk-num").waitFor();assert.deepEqual(errors, []);});}diff --git a/internal/gui/trace.go b/internal/gui/trace.goindex 22aaef905..f38f445dd 100644--- a/internal/gui/trace.go+++ b/internal/gui/trace.go@@ -173,7 +173,8 @@ func publicRoute(r gateway.Route, pub func(string) string) gateway.Route {// mainView is the tab the window is asked to open on, as the page's view// parameter: the Routing page on one request (req, its id) when the tray-// panel's Routing tab asks for it, or the Usage page's Requests on one+// panel's Routing tab asks for it, Masking on one request's record (key)+// when a masked call's badge there does, or the Usage page's Requests on one// provider or agent when its Usage tab does, its Overview (the allowances)// when a menu-bar cell's click does. Anything but an id, or a name of the// kind a provider or an agent has, is dropped.@@ -184,6 +185,10 @@ func mainView(q url.Values) string {if id, err := strconv.ParseInt(q.Get("req"), 10, 64); err == nil && id > 0 {view += "&req=" + strconv.FormatInt(id, 10)}+ case "masking":+ if key, err := strconv.ParseInt(q.Get("key"), 10, 64); err == nil && key > 0 {+ view += "&key=" + strconv.FormatInt(key, 10)+ }case "usage":if tab := q.Get("tab"); tab == "requests" || tab == "usage" {view += "&tab=" + tabdiff --git a/internal/gui/trace_test.go b/internal/gui/trace_test.goindex 083f8abc2..88c612ca6 100644--- a/internal/gui/trace_test.go+++ b/internal/gui/trace_test.go@@ -26,6 +26,9 @@ func TestMainView(t *testing.T) {{url.Values{"view": {"settings"}, "req": {"42"}}, "settings"},{url.Values{"view": {"routing"}, "req": {"42&view=x"}}, "routing"},{url.Values{"view": {"routing"}, "req": {"-1"}}, "routing"},+ {url.Values{"view": {"masking"}, "key": {"1730000000123"}}, "masking&key=1730000000123"},+ {url.Values{"view": {"masking"}, "key": {"7&view=settings"}}, "masking"},+ {url.Values{"view": {"settings"}, "key": {"7"}}, "settings"},{url.Values{"view": {"usage"}}, "usage"},{url.Values{"view": {"usage"}, "tab": {"requests"}, "provider": {"codex"}}, "usage&tab=requests&provider=codex"},{url.Values{"view": {"usage"}, "tab": {"requests"}, "agent": {"claude-desktop"}, "provider": {"relay team"}}, "usage&tab=requests&provider=relay+team&agent=claude-desktop"},diff --git a/plugins/redact/redact.go b/plugins/redact/redact.goindex f78b81d66..739de5ea9 100644--- a/plugins/redact/redact.go+++ b/plugins/redact/redact.go@@ -22,6 +22,9 @@ func init() {Name: "Privacy masking", Sub: "Secrets, personal data and your own words go to vendors as placeholders, and come back as they were",One: "Masking is on", Many: "Masking is on",InUse: InUse,+ // Insights › Masking: what masking did, request by request+ Parts: []pluginrt.Part{{Slot: "nav.page", Key: "masking"}},+ Client: []string{"i18n.js", "redact.css", "client.js", "page.js"},Apply: func(c *pluginrt.Ctx) error {c.OnDispose(gwmw.Mask(masking.Masker{}))return nil