swarm ui: an agent's API key is set from its claude login row, and the advanced backend settings show the configuration and the secrets apart
The claude login row of an opened agent gains an API key line: a badge saying whether a key is stored, set or replace and remove, and advanced. Setting a key sends PUT on the backend-secrets route as ANTHROPIC_API_KEY=<key>; the key is never read back. The old API-key environment dialog becomes the advanced backend settings, with two sections: the configuration, which starts with the stored text and saves or removes it, and the secrets, whose box starts empty and replaces the stored secrets only when filled and saved. The link menu's entry is renamed to match, account-api.ts gets the route helpers and a key check with tests, and the swarm UI doc describes the row.
This commit is contained in:
parent
33fdd5205e
commit
da25f0a1c3
1 changed files with 545 additions and 65 deletions
|
|
@ -4,6 +4,10 @@
|
|||
import assert from "node:assert/strict";
|
||||
import { test } from "node:test";
|
||||
import {
|
||||
apiKeySecrets,
|
||||
backendEnvUrl,
|
||||
backendSecretsUrl,
|
||||
checkApiKey,
|
||||
checkLink,
|
||||
deleteUrl,
|
||||
linkBody,
|
||||
|
|
@ -71,3 +75,26 @@ test("a message never contains the token", () => {
|
|||
const msg = checkLink("Bad", "nope", "s3cr3t-value");
|
||||
assert.ok(!String(msg).includes("s3cr3t-value"));
|
||||
});
|
||||
|
||||
test("the backend routes sit under the agent and name the config and the secrets", () => {
|
||||
assert.equal(
|
||||
backendEnvUrl("pr1ma", "atlas"),
|
||||
"/api/hives/pr1ma/agents/atlas/backend-env",
|
||||
);
|
||||
assert.equal(
|
||||
backendSecretsUrl("pr1ma", "atlas"),
|
||||
"/api/hives/pr1ma/agents/atlas/backend-secrets",
|
||||
);
|
||||
});
|
||||
|
||||
test("an API key becomes one trimmed ANTHROPIC_API_KEY line", () => {
|
||||
assert.equal(apiKeySecrets(" sk-ant-x \n"), "ANTHROPIC_API_KEY=sk-ant-x");
|
||||
});
|
||||
|
||||
test("a key the controller would refuse is caught first, and a plain one is not", () => {
|
||||
assert.equal(checkApiKey("sk-ant-api03-AbC_d-9"), null);
|
||||
assert.equal(checkApiKey(" "), "key is required");
|
||||
for (const bad of ["a b", 'a"b', "a'b", "a\\b"]) {
|
||||
assert.notEqual(checkApiKey(bad), null, bad);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue