Watch
0
0
Fork
You've already forked hyperhive
0

make squid's allowed domains editable at runtime in the swarm ui

This commit is contained in:
atlas 2026-10-28 20:39:22 +01:00 • committed by mara
commit c9abc2a42b

View file

@ -0,0 +1,54 @@
// The detail panel's allowed-domains editor: which entries one agent sees and
// the bodies it sends. Run by `npm test` with Node's type stripping.
import assert from "node:assert/strict";
import { test } from "node:test";
import {
allowedSummary,
entriesFor,
entryBody,
} from "../src/agent/detail/allowed-domains.ts";
const all = [
{ domain: "crates.io", agent: "atlas" },
{ domain: "docs.rs", agent: "argus" },
{ domain: "github.com" },
{ domain: "pypi.org", agent: "atlas" },
];
test("an agent sees the swarm-wide entries first, then its own, and not another agent's", () => {
assert.deepEqual(entriesFor(all, "atlas"), [
{ domain: "github.com" },
{ domain: "crates.io", agent: "atlas" },
{ domain: "pypi.org", agent: "atlas" },
]);
// Control: the other agent's entry is there to be found.
assert.deepEqual(entriesFor(all, "argus"), [
{ domain: "github.com" },
{ domain: "docs.rs", agent: "argus" },
]);
assert.deepEqual(entriesFor(all, "iris"), [{ domain: "github.com" }]);
assert.deepEqual(entriesFor([], "atlas"), []);
});
test("the summary counts each scope", () => {
assert.equal(allowedSummary([]), "none added");
assert.equal(
allowedSummary(entriesFor(all, "atlas")),
"1 swarm-wide, 2 for this agent",
);
assert.equal(allowedSummary(entriesFor(all, "iris")), "1 swarm-wide");
assert.equal(
allowedSummary([{ domain: "a.io", agent: "atlas" }]),
"1 for this agent",
);
});
test("the body is swarm-wide or for the agent, with the name trimmed", () => {
assert.deepEqual(entryBody(" github.com ", true, "atlas"), {
domain: "github.com",
});
assert.deepEqual(entryBody("github.com", false, "atlas"), {
domain: "github.com",
agent: "atlas",
});
});