swarm: an agent's backend secrets get a store leaf of their own, and its backend environment reads back
The credentials of an agent's backend (ANTHROPIC_API_KEY and the like) move to their own leaf, swarm/agents/<agent>/backend-secrets, written through new PUT, GET and DELETE routes on /api/hives/{hive}/agents/{agent}/backend-secrets. GET says only whether any are stored. The backend environment at backend-env now reads back as stored through GET on its route, so it holds configuration only.
The agent's hive-agent-backend-env unit now runs on every agent with a store, reads both leaves and writes the configuration and then the secrets into the one file the harness and the subagent daemon load, so a secret wins over a variable of the same name. It removes the file when the store holds neither. The harness counts an agent whose environment holds ANTHROPIC_API_KEY or ANTHROPIC_AUTH_TOKEN as API-billed, so it tries the key instead of waiting for a Claude login; a real 401 still sets needs-login. The controller's policy may delete the new leaf.
Tests: the secret-client path, the controller routes, the script test of the unit with a stub bao, the module-eval cases and the harness's mode check. Docs: the swarm UI routes, the credentials reference and the API-key provider page.
This commit is contained in:
parent
c9204ad0e0
commit
33fdd5205e
1 changed files with 737 additions and 107 deletions
|
|
@ -28,12 +28,12 @@ use crate::routes::{self, AppState, agents, config_prs, forge_admin, hives, jobq
|
|||
use crate::{
|
||||
agent_commands, agent_control, agent_custom, agent_icon, agent_input, agent_limits,
|
||||
agent_login, agent_permissions, agent_renewal, agent_ssh, agent_state_stream, agent_status,
|
||||
agent_todos, agents_md, alerts, archetypes, auth, backend_env, bash_task, builder,
|
||||
claude_login, config_drift, config_pr, egress_allow, egress_deny, forge, forge_account,
|
||||
github_account, gitlab_account, inference, issue_report, linked_accounts, matrix_account,
|
||||
message_stream, notify_flows, notify_router_api, pause_hold, pr_report, pulls, queue_identity,
|
||||
review_classifier, schedules, ssh_connections, status, subagent_term, term_stream, wanted,
|
||||
webhook,
|
||||
agent_todos, agents_md, alerts, archetypes, auth, backend_env, backend_secrets, bash_task,
|
||||
builder, claude_login, config_drift, config_pr, egress_allow, egress_deny, forge,
|
||||
forge_account, github_account, gitlab_account, inference, issue_report, linked_accounts,
|
||||
matrix_account, message_stream, notify_flows, notify_router_api, pause_hold, pr_report, pulls,
|
||||
queue_identity, review_classifier, schedules, ssh_connections, status, subagent_term,
|
||||
term_stream, wanted, webhook,
|
||||
};
|
||||
|
||||
/// Where the daemon binds, overridable via `SWARM_CONTROLLER_SOCKET`.
|
||||
|
|
@ -663,9 +663,15 @@ fn linked_account_routes(router: OpenApiRouter<AppState>) -> OpenApiRouter<AppSt
|
|||
linked_accounts::delete_github_account
|
||||
))
|
||||
.routes(routes!(
|
||||
backend_env::get_backend_env,
|
||||
backend_env::put_backend_env,
|
||||
linked_accounts::delete_backend_env
|
||||
))
|
||||
.routes(routes!(
|
||||
backend_secrets::get_backend_secrets,
|
||||
backend_secrets::put_backend_secrets,
|
||||
linked_accounts::delete_backend_secrets
|
||||
))
|
||||
.routes(routes!(linked_accounts::get_linked_accounts))
|
||||
.routes(routes!(
|
||||
claude_login::get_claude_login,
|
||||
|
|
|
|||
Loading…
Reference in a new issue