Skip to content

feat(settings): keep secrets once and assign them in a Secrets tab - #479

Merged
edenreich merged 1 commit into
mainfrom
feat/secrets-tab
Nov 8, 2026
Merged

edenreich merged 1 commit into
mainfrom
feat/secrets-tab

Conversation

@edenreich

@edenreich edenreich commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Resolves #475

Summary

Settings gets a Secrets tab. A secret is kept once and given to the computers that need it: this computer, and any Kubernetes workspace. The agent editor can save an inbox-scoped AgentMail key as a secret, so an agent's computer mails as its own inbox and the owner key never reaches a worker.

A secret has a unique label, the variable it becomes, and a masked value. This differs from #475 as filed, where the name was the variable. Several secrets may share a variable as long as no computer gets two of them. With 12 agents on 12 computers, each computer gets its own AGENTMAIL_API_KEY and one mcp.yaml header ${AGENTMAIL_API_KEY} works on all of them.

Changes

  • backend/src/secrets.rs (new):
    • Values live in ~/.infer/auth.yaml (0600) under secret/<label>. That is no environment variable name, so neither the CLI nor auth_env ever reads one as a provider key.
    • ~/.infer/secrets.yaml keeps the label, the variable and whether this computer gets it. It holds no values.
    • A Kubernetes workspace's assignment is its secrets list in daemon.yaml, which names the Kubernetes Secret infer-secret-<label>. The tab reads assignments from there, so they move with a workspace rename.
    • Saving writes the Kubernetes Secret into every assigned workspace's namespace first, through kubectl apply --server-side with the manifest on stdin. Only then is it listed in daemon.yaml, because the CLI refuses an Orchestrator whose listed Secret is missing.
    • Unassigning unlists it, then deletes the Kubernetes Secret unless a workspace in the same namespace still lists it.
    • A cluster that cannot be reached is reported and the rest of the save still applies. A workspace that listed the secret before keeps it, since its namespace still holds the previous value.
    • Refused: an invalid label (DNS label, it names the Kubernetes Secret) or variable, a taken label, an API key's variable, a non-Kubernetes workspace, and a second secret with the same variable on this computer or on one workspace.
    • Each secret shows the mcp.yaml servers whose headers expand its variable as ${NAME} or $NAME.
    • One mutex serializes saves and deletes, each a read-modify-write of auth.yaml, secrets.yaml and daemon.yaml.
  • backend/src/env.rs: infer_env adds the secrets assigned to this computer, so every infer process the app starts gets them, the local daemon's workers too. The gateway keeps getting the API keys alone.
  • backend/src/config.rs:
    • auth_env leaves secrets out, so a secret assigned nowhere reaches no process.
    • Fix: saving the API Keys tab rewrote auth.yaml with the provider keys alone and dropped every agent's AgentMail owner key. It now saves the keys it shows and keeps every other entry.
  • backend/src/agent_mail.rs: save_inbox_secret mints a key scoped to the agent's inbox with the owner key and saves it as the secret <agent>-inbox for AGENTMAIL_API_KEY. A new one is assigned to the agent's Kubernetes workspace when it has one. An existing one keeps its assignments and gets the new key. The checks run before minting, so a refused save never mints a key.
  • backend/src/workspace_settings.rs: WorkspaceConfig reads secrets without the Workspaces tab ever writing it, list_secret edits the lists, and kubectl_with_input pipes a manifest on stdin.
  • backend/src/local_cluster.rs: the local cluster's kubectl runs as docker exec -i, so it can read a manifest on stdin.
  • frontend/components/SecretsTab.tsx (new): the list, the form and the restart notice. A change to a secret that goes anywhere asks for a CLI restart and says that running sessions keep the old values until they get a new machine.
  • frontend/components/AgentEditor.tsx: Save inbox key as secret in the Email section, for an agent saved with its address.
  • AGENTS.md: the DOM contract gains the secret form ids, New secret, Save secret, Save inbox key as secret, Edit secret <label> and Delete secret <label>.
  • e2e/tests/secrets-settings.yaml: a secret saved under Secrets lands in secrets.yaml by variable and in auth.yaml by value.

Acceptance criteria of #475

  • A Secrets tab to add, edit and delete secrets with masked values, kept in auth.yaml with mode 0600, never in an export: done. A value is never sent back to the frontend. On edit a blank value keeps the saved one. The export never reads auth.yaml or secrets.yaml.
  • A valid variable name, a taken name refused: done for the label and variable model above.
  • Each secret shows where it goes: done, covering this computer, its Kubernetes workspaces and the MCP servers whose headers use its variable.
  • This computer gets it, a secret assigned nowhere reaches no process: done.
  • A Kubernetes workspace gets it from a Kubernetes Secret in its namespace, the value on stdin, unassigning removes it: done.
  • A change says the CLI needs a restart and that running sessions keep their old values: done.
  • The agent editor saves an inbox-scoped key minted with the owner key: done.

Verification

  • cargo fmt --check, cargo clippy --all-targets -- -D warnings and cargo test pass in backend/. That is 255 tests, through the pre-commit hook. New tests cover the label and variable rules, every refusal, MCP header matching, which workspaces get listed when a cluster is down, namespace cleanup and the manifest. They also cover that only secrets assigned to this computer reach its processes, and that saving the API Keys keeps agent keys and secrets.
  • bun run build passes and bun test passes 224 tests. cargo test -p desktop-e2e validates the e2e YAML.
  • On the local infer-k3s cluster, in a throwaway namespace since deleted, I checked that re-applying the Secret without a key drops that key, that it gets no last-applied annotation, and that a second delete with --ignore-not-found succeeds.
  • I did not run the macOS e2e suite, because it drives the real UI. The new test covers a secret assigned nowhere only: the driver clicks buttons alone and keypress clicks the first text area, so it cannot tick the checkboxes.

Known gaps

  • Deleting a workspace leaves its infer-secret-* in the namespace when no other workspace lists it.
  • Saving an inbox key again leaves the previous one alive in AgentMail until it is revoked there.
  • A pod also needs the AgentMail MCP server itself before its agent can mail, which waits on the MCPs tab ([FEATURE] MCPs tab, and agents pick the MCP servers they use #476) and its CLI and operator counterparts.

Cross-repo impact

A secret has a label, the variable it becomes and a masked value kept in
auth.yaml under secret/<label>. Several secrets may share a variable as long
as no computer gets two of them, so each agent's computer can mail as its own
inbox through AGENTMAIL_API_KEY.

Assigned to this computer, a secret reaches every infer process the app
starts. Assigned to a Kubernetes workspace, it is written into the Secret
infer-secret-<label> in the workspace's namespace through kubectl on stdin and
listed under the workspace's secrets in daemon.yaml. A secret assigned nowhere
reaches no process.

The agent editor mints a key scoped to the agent's inbox with the owner key
and keeps it as a secret, so the owner key never reaches a worker.

Saving the API Keys no longer rewrites auth.yaml with the provider keys alone,
which dropped every agent's AgentMail owner key.
@edenreich
edenreich marked this pull request as ready for review November 8, 2026 17:58
@edenreich
edenreich merged commit f90cdeb into main Nov 8, 2026
1 check passed
@edenreich
edenreich deleted the feat/secrets-tab branch November 8, 2026 17:58
@inference-gateway-maintainer

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.60.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@inference-gateway-maintainer inference-gateway-maintainer Bot added the released Shipped in a release label Nov 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Shipped in a release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Secrets tab: keep secrets once and assign them to computers and MCP servers

1 participant