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
|
|
@ -161,6 +161,12 @@ in
|
|||
option changes what the harness believes about its own login state,
|
||||
the other actually supplies the credentials `claude` reads. Neither
|
||||
is useful alone.
|
||||
|
||||
An agent that stores an API key in the swarm secret store (the swarm UI's
|
||||
claude login section) needs neither: the harness also counts it as
|
||||
API-billed when its environment holds `ANTHROPIC_API_KEY` or
|
||||
`ANTHROPIC_AUTH_TOKEN`, so it tries instead of waiting for a login. This
|
||||
option stays the override for an agent whose key comes another way.
|
||||
'';
|
||||
};
|
||||
|
||||
|
|
@ -200,13 +206,13 @@ in
|
|||
before creating the file, or a fresh host rebuild before state is
|
||||
restored — makes systemd skip it rather than refuse to start the
|
||||
harness. See `services.hyperhive.agent.useApiKey`'s doc for the option this one is
|
||||
paired with. The subagent daemon loads the same file on an ACP agent
|
||||
and on an agent with `useApiKey` set, so its subagents authenticate
|
||||
the same way the harness does.
|
||||
paired with. The subagent daemon loads the same file, so its subagents
|
||||
authenticate the same way the harness does.
|
||||
|
||||
On an agent with a store (`services.hyperhive.agent.bao.addr`) that uses
|
||||
`useApiKey` or the `acp` runtime, `hive-agent-backend-env.service` also
|
||||
keeps this file's text at `swarm/agents/<agent>/backend-env`, field `env`.
|
||||
On an agent with a store (`services.hyperhive.agent.bao.addr`),
|
||||
`hive-agent-backend-env.service` also keeps this file's text at
|
||||
`swarm/agents/<agent>/backend-env`, field `env`, and appends the credentials
|
||||
an operator stores at `swarm/agents/<agent>/backend-secrets`, field `env`.
|
||||
A leaf nobody has written is created from this file once, with the same
|
||||
bytes, and this file is never rewritten or deleted. The harness and the
|
||||
subagent daemon load this file first and the store's copy after it, so
|
||||
|
|
|
|||
Loading…
Reference in a new issue