Move secrets between users and computers without the model seeing them

A new personal env scope (paradigm user: one user's secret for one bot)
beats every other scope, reaches only that user's runs of that bot, and
is redacted like any secret. Bots take secrets in with request_secret,
which puts a [secret-request:ID] card in the chat: the user types the
value into a masked input there, never into a message, and the bot is
told only the key. Bots show secrets with capture_secret (a task's
computer tool that saves a file or a command's output straight to a
personal env, then redacts it from the rest of the run) and show_secret
(an env by key): both give a [secret:ID] chip whose Reveal and Copy fetch
the value on click, for its own user (personal) or a super admin
(anything else), logged by key. Values never go into messages, page
props, history, Copy chat or logs. Users manage their own secrets on
Settings > Secrets; the Environment page lists everyone's, remove only.
Deleting a bot or user removes its personal secrets, and SecretsNote
tells bots never to ask for or print secrets in chat.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-10-25 16:51:32 +01:00
co-authored by Claude Opus 5.5
parent 83ff79b9c3
commit 69988e08fc
78 changed files with 2472 additions and 52 deletions
@@ -41,6 +41,7 @@ const Descriptions: Record<EnvScope["paradigm"], string> = {
computer:
"For this computer only. Beats a workspace, loses to the bot's own.",
bot: "For this bot only, everywhere it works. Beats the workspace, the computer and general.",
user: "For one user's runs of one bot, set from the chat. Beats everything else.",
};
/**
@@ -0,0 +1,110 @@
import { useState } from "react";
import Input from "@moduletrace/twui/form/Input";
import Button from "@moduletrace/twui/layout/Button";
import Row from "@moduletrace/twui/layout/Row";
import Span from "@moduletrace/twui/layout/Span";
import Stack from "@moduletrace/twui/layout/Stack";
import { Pencil, Trash2 } from "lucide-react";
import { twMerge } from "tailwind-merge";
import RowIconButton from "@/src/components/general/row-icon-button";
import type { PersonalSecret } from "@/src/types";
type Props = {
secret: PersonalSecret;
/**
* Whose it is, for the super admin's list of everyone's.
*/
show_user?: boolean;
busy?: boolean;
/**
* Saves a new value; without it the row can only be removed.
*/
onReplace?: (params: { secret: PersonalSecret; value: string }) => Promise<boolean>;
onRemove: (params: { secret: PersonalSecret }) => void;
};
/**
* One personal secret: its key, what it's for, which bot (and whose), and
* never its value. Replace opens a masked input in place.
*/
export default function PersonalSecretRow({ secret, show_user, busy, onReplace, onRemove }: Props) {
const [editing, setEditing] = useState(false);
const [value, setValue] = useState("");
const save = async () => {
if (!value || !onReplace) return;
if (await onReplace({ secret, value })) {
setValue("");
setEditing(false);
}
};
return (
<Stack
className={twMerge(
"w-full gap-3! items-stretch py-3 px-4",
"border-0 border-b border-solid border-hairline last:border-b-0",
)}
>
<Row className="w-full gap-3! flex-nowrap items-start justify-between">
<Stack className="gap-0.5! min-w-0">
<Span className="text-sm font-bold leading-5 text-ink truncate">{secret.key}</Span>
{secret.description ? (
<Span className="text-[13px] leading-[18px] text-ink-secondary break-words">{secret.description}</Span>
) : null}
<Span className="text-[13px] leading-[18px] text-ink-secondary">
{`${show_user ? `${secret.user_name}, for ` : "For "}${secret.bot_name}`}
</Span>
</Stack>
<Row className="gap-1! flex-nowrap shrink-0">
{onReplace ? (
<RowIconButton
icon={Pencil}
title={`Replace ${secret.key}`}
disabled={busy}
onClick={() => setEditing(!editing)}
/>
) : null}
<RowIconButton
icon={Trash2}
title={`Remove ${secret.key}`}
loading={busy}
disabled={busy}
onClick={() => onRemove({ secret })}
/>
</Row>
</Row>
{editing ? (
<Row className="w-full gap-2! flex-nowrap items-end">
<Input
id={`personal-secret-${secret.id}`}
title={`New value for ${secret.key}`}
label="New value"
showLabel
type="password"
autoComplete="off"
value={value}
onChange={(e) => setValue(e.target.value)}
/>
<Button
type="button"
variant="outlined"
color="gray"
size="small"
title="Cancel"
onClick={() => {
setValue("");
setEditing(false);
}}
>
Cancel
</Button>
<Button type="button" size="small" title={`Save ${secret.key}`} loading={busy} disabled={busy || !value} onClick={save}>
Save
</Button>
</Row>
) : null}
</Stack>
);
}
@@ -0,0 +1,49 @@
import type { PersonalSecret } from "@/src/types";
import SettingsGroup from "../settings-group";
import SettingsList from "../settings-list";
import SettingsStatus from "../settings-status";
import PersonalSecretRow from "./personal-secret-row";
type Props = {
title: string;
description: string;
secrets: PersonalSecret[];
show_user?: boolean;
busy_id?: number;
status?: { error?: boolean; success?: boolean; msg?: string };
onReplace?: (params: { secret: PersonalSecret; value: string }) => Promise<boolean>;
onRemove: (params: { secret: PersonalSecret }) => void;
};
/**
* A list of personal secrets (set from the chat), values never shown: the
* user's own on the Secrets page, everyone's on the Environment page.
*/
export default function PersonalSecretsGroup({
title,
description,
secrets,
show_user,
busy_id,
status,
onReplace,
onRemove,
}: Props) {
return (
<SettingsGroup title={title} description={description}>
<SettingsList is_empty={!secrets.length} empty="No secrets saved yet.">
{secrets.map((secret) => (
<PersonalSecretRow
key={secret.id}
secret={secret}
show_user={show_user}
busy={busy_id == secret.id}
onReplace={onReplace}
onRemove={onRemove}
/>
))}
</SettingsList>
<SettingsStatus status={status} />
</SettingsGroup>
);
}