swarm-ui: edit an agent's permissions on its detail panel
The detail panel had editors for inference, instructions, resource caps and
accounts, but nothing for the permissions the swarm grants, which could only
be set at create time or with swarmctl. A permissions row shows the grant
(the default set, none, or the list) and an edit dialog ticks the catalogue
from GET /api/permissions and saves with PUT /api/agents/{agent}/permissions.
Ticking exactly the default set sends the DELETE, as the create form sends no
list for it.
This commit is contained in:
parent
eaf26aaadd
commit
78c48272ee
5 changed files with 339 additions and 3 deletions
35
frontend/packages/swarm-ui/test/agent-permissions.test.mjs
Normal file
35
frontend/packages/swarm-ui/test/agent-permissions.test.mjs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
// The detail panel's permissions editor: its starting selection and the
|
||||
// summary line. Run by `npm test` with Node's type stripping.
|
||||
import assert from "node:assert/strict";
|
||||
import { test } from "node:test";
|
||||
import {
|
||||
editorSelection,
|
||||
grantSummary,
|
||||
} from "../src/agent/detail/permissions.ts";
|
||||
|
||||
const all = ["messaging", "meta", "inbox", "execution", "manage_root_agent"];
|
||||
const defaults = ["messaging", "meta", "inbox", "execution"];
|
||||
|
||||
test("an agent the swarm sets nothing for starts on the default set", () => {
|
||||
assert.deepEqual(editorSelection(undefined, all, defaults), defaults);
|
||||
});
|
||||
|
||||
test("a stored list is the starting selection, empty included", () => {
|
||||
assert.deepEqual(
|
||||
editorSelection(["meta", "manage_root_agent"], all, defaults),
|
||||
["meta", "manage_root_agent"],
|
||||
);
|
||||
assert.deepEqual(editorSelection([], all, defaults), []);
|
||||
});
|
||||
|
||||
test("a stored name the catalogue does not list is not offered", () => {
|
||||
assert.deepEqual(editorSelection(["meta", "retired"], all, defaults), [
|
||||
"meta",
|
||||
]);
|
||||
});
|
||||
|
||||
test("the summary tells unset, empty and a list apart", () => {
|
||||
assert.equal(grantSummary(undefined), "the default set");
|
||||
assert.equal(grantSummary([]), "none");
|
||||
assert.equal(grantSummary(["meta", "inbox"]), "2 granted");
|
||||
});
|
||||
Loading…
Reference in a new issue