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]>
125 lines
3.8 KiB
TypeScript
125 lines
3.8 KiB
TypeScript
import { HarnessProviderKinds } from "./harness-provider-dict";
|
|
|
|
/**
|
|
* Where an env applies. A user's personal one (for one bot, set from the
|
|
* chat) beats the bot's own, which beats the computer it runs on, which
|
|
* beats the workspace it works in, which beats a general one.
|
|
*/
|
|
export const EnvParadigms = [
|
|
{
|
|
title: "General",
|
|
value: "general",
|
|
},
|
|
{
|
|
title: "Workspace",
|
|
value: "workspace",
|
|
},
|
|
{
|
|
title: "Computer",
|
|
value: "computer",
|
|
},
|
|
{
|
|
title: "Bot",
|
|
value: "bot",
|
|
},
|
|
{
|
|
title: "Personal",
|
|
value: "user",
|
|
},
|
|
] as const;
|
|
|
|
export type EnvParadigm = (typeof EnvParadigms)[number]["value"];
|
|
|
|
export type KnownEnv = {
|
|
key: string;
|
|
description: string;
|
|
required: boolean;
|
|
/**
|
|
* Hidden once saved; only replaced, never shown.
|
|
*/
|
|
secret: boolean;
|
|
};
|
|
|
|
/**
|
|
* Envs the app itself reads (`grabEnv`), set in Settings, under
|
|
* Environment. They are general only and never go to computers. Users add
|
|
* their own keys beside these for bots and computers to use.
|
|
*
|
|
* Not here, and never in the `envs` table: `ENCRYPTION_KEY` and
|
|
* `ENCRYPTION_SALT` (they encrypt the table), and `PORT`, `DATA_DIR`,
|
|
* `BACKUP_ARCHIVE_DIR` and `MAIN_SERVER` (the container's own start-up
|
|
* settings). Those stay in the process environment.
|
|
*/
|
|
export const EnvDict: readonly KnownEnv[] = [
|
|
{
|
|
key: "VAPID_PUBLIC_KEY",
|
|
description:
|
|
"Web Push public key, shared with browsers that subscribe. Generated on first start when missing.",
|
|
required: false,
|
|
secret: false,
|
|
},
|
|
{
|
|
key: "VAPID_PRIVATE_KEY",
|
|
description:
|
|
"Web Push private key, used to sign notifications. Generated on first start when missing; never share it.",
|
|
required: false,
|
|
secret: true,
|
|
},
|
|
{
|
|
key: "MAIN_COMPUTER_URL",
|
|
description: `The main computer's address, for a server running outside docker (e.g. http://localhost:8170). Empty uses the docker network.`,
|
|
required: false,
|
|
secret: false,
|
|
},
|
|
{
|
|
key: "COMPUTER_APP_URL",
|
|
description: `Where computers reach this app, for hooks they call (browser notifications), e.g. http://172.17.0.1:7000 for a server running outside docker. Empty uses the app's container on the docker network.`,
|
|
required: false,
|
|
secret: false,
|
|
},
|
|
{
|
|
key: "MAIN_COMPUTER_DATA_DIR",
|
|
description: `Where the main computer's workspace (/home/gem/workspace, the only folder bots work in) is on this server's disk, for a computer the app didn't create itself (see MAIN_COMPUTER_URL), e.g. the bind mount your sandbox's compose file uses. Empty reads DATA_DIR/computers/<id>.`,
|
|
required: false,
|
|
secret: false,
|
|
},
|
|
...HarnessProviderKinds.flatMap((provider) =>
|
|
provider.key_env
|
|
? [
|
|
{
|
|
key: provider.key_env,
|
|
description: `${provider.title} key, used when the provider has no key of its own.`,
|
|
required: false,
|
|
secret: true,
|
|
},
|
|
]
|
|
: [],
|
|
),
|
|
];
|
|
|
|
/**
|
|
* Keys that must stay in the process environment.
|
|
*/
|
|
export const ProcessOnlyEnvKeys = [
|
|
"ENCRYPTION_KEY",
|
|
"ENCRYPTION_SALT",
|
|
"PORT",
|
|
"DATA_DIR",
|
|
"DB_DIR",
|
|
"BACKUP_ARCHIVE_DIR",
|
|
"MAIN_SERVER",
|
|
] as const;
|
|
|
|
/**
|
|
* What an env key may look like: a shell variable name.
|
|
*/
|
|
export const EnvKeyRegex = /^[A-Za-z_][A-Za-z0-9_]{0,127}$/;
|
|
|
|
/**
|
|
* Where a secret a bot asked a user for stands (`secret_requests.status`):
|
|
* `pending` until the user saves a value (`saved`) or declines it.
|
|
*/
|
|
export const SecretRequestStatuses = ["pending", "saved", "declined"] as const;
|
|
|
|
export type SecretRequestStatus = (typeof SecretRequestStatuses)[number];
|