Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"shellcheck": "shellcheck *.sh"
},
"dependencies": {
"@agentworkforce/layered-agent": "0.1.26",
"@agentworkforce/layered-agent": "0.1.29",
"@alchemy.run/aws": "2.0.0-beta.84",
"@effect/platform-node": "4.0.7",
"@effect/platform-node-shared": "4.0.7",
Expand Down
29 changes: 23 additions & 6 deletions agent/test/agent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import { fileURLToPath } from "node:url";
import { gunzipSync } from "node:zlib";
import { AGENT_CARD_FILE, EC2_USER_DATA_ENCODED_LIMIT, ISSUE_WATCH_FILE, ISSUE_WATCH_KIT_FILES, RELAY_SESSIONS_KIT_FILES, renderIssueWatch, WORKER_KIT_FILES, fileReader, hostRolePolicy, hostTemplate, renderAgentCard, userDataBase64 } from "@agentworkforce/layered-agent";
import { AGENT_CARD_FILE, DELEGATION_KIT_FILES, EC2_USER_DATA_ENCODED_LIMIT, ISSUE_WATCH_FILE, ISSUE_WATCH_KIT_FILES, RELAY_SESSIONS_KIT_FILES, STEWARDSHIP_FILE, STEWARDSHIP_KIT_FILES, renderIssueWatch, renderStewardship, stewardship, WORKER_KIT_FILES, fileReader, hostRolePolicy, hostTemplate, renderAgentCard, userDataBase64 } from "@agentworkforce/layered-agent";
import agent from "../agent.config.ts";

const read = fileReader(fileURLToPath(new URL("..", import.meta.url)));
Expand All @@ -18,10 +18,11 @@ test("user data: under EC2's limit, every kit and lane file, no secret values",
const encoded = userDataBase64(agent, read);
assert.ok(encoded.length < EC2_USER_DATA_ENCODED_LIMIT - 500, `user data is ${encoded.length} bytes encoded`);
const script = gunzipSync(Buffer.from(encoded, "base64")).toString("utf8");
const optional: readonly string[] = ["headless.py", "delegation.md", "orchestration.md", ...WORKER_KIT_FILES, ...RELAY_SESSIONS_KIT_FILES, ...ISSUE_WATCH_KIT_FILES];
// The kit's own list of files that ride the hot update (it does not export it): ledger.py since 0.1.28.
const optional: readonly string[] = ["headless.py", "ledger.py", "delegation.md", "orchestration.md", ...DELEGATION_KIT_FILES, ...WORKER_KIT_FILES, ...RELAY_SESSIONS_KIT_FILES, ...ISSUE_WATCH_KIT_FILES, ...STEWARDSHIP_KIT_FILES];
for (const f of agent.files) {
const shipped = script.includes(`cat > /opt/agent-host/${f.name} <<'`);
// The generated card and issue-watch files travel by hot update, never in user data.
// The generated card, issue-watch and stewardship files travel by hot update, never in user data.
assert.equal(shipped, !(f.source === "generated" || (f.source === "kit" && optional.includes(f.name))), f.name);
}
assert.doesNotMatch(script, /sk-ant-|ghp_|ghs_|gho_|BEGIN [A-Z ]*PRIVATE KEY|"private_key"/);
Expand Down Expand Up @@ -137,15 +138,31 @@ test("the A2A card: renders within the relay's limits, one skill per kind of wor
assert.equal(card.documentation_url, "https://github.com/AgentWorkforce/infra");
assert.match(card.version, /^[0-9a-f]{12}$/);
assert.equal(agent.generated[AGENT_CARD_FILE], rendered);
assert.deepEqual(agent.files.filter((f) => f.source === "generated"), [{ name: AGENT_CARD_FILE, source: "generated" }, { name: ISSUE_WATCH_FILE, source: "generated" }]);
assert.deepEqual(agent.files.filter((f) => f.source === "generated"), [{ name: AGENT_CARD_FILE, source: "generated" }, { name: ISSUE_WATCH_FILE, source: "generated" }, { name: STEWARDSHIP_FILE, source: "generated" }]);
const script = gunzipSync(Buffer.from(userDataBase64(agent, read), "base64")).toString("utf8");
assert.ok(!script.includes(`cat > /opt/agent-host/${AGENT_CARD_FILE}`), "the card never rides in user data");
});

test("new-issue watch: this repo, to khaliq-gant, generated and kept out of user data", () => {
test("new-issue and new-PR watch: this repo, to khaliq-gant, generated and kept out of user data", () => {
assert.deepEqual(agent.input.issueWatch, { repos: ["AgentWorkforce/infra"], notify: "khaliq-gant" });
assert.equal(agent.generated[ISSUE_WATCH_FILE], renderIssueWatch(agent.input.issueWatch!));
assert.deepEqual(JSON.parse(agent.generated[ISSUE_WATCH_FILE]!).globs, ["/github/repos/AgentWorkforce/infra/issues/**"]);
// Since kit 0.1.29 a watch covers pull requests too unless it sets pullRequests: false.
const watch = JSON.parse(agent.generated[ISSUE_WATCH_FILE]!) as { notify: string[]; pullRequests: boolean; globs: string[] };
assert.deepEqual(watch.notify, ["khaliq-gant"]);
assert.equal(watch.pullRequests, true);
assert.deepEqual(watch.globs, ["/github/repos/AgentWorkforce/infra/issues/**", "/github/repos/AgentWorkforce/infra/pulls/**"]);
const script = gunzipSync(Buffer.from(userDataBase64(agent, read), "base64")).toString("utf8");
assert.ok(!script.includes(`cat > /opt/agent-host/${ISSUE_WATCH_FILE}`), "the watch never rides in user data");
});

test("repo stewardship: the kit's default for this repo, generated and kept out of user data", () => {
assert.equal(agent.input.stewardship, undefined, "the default: on, this repo, the kit's stale thresholds");
const steward = stewardship(agent.input)!;
assert.deepEqual(steward.repos, ["AgentWorkforce/infra"]);
// The explicit issueWatch above replaces stewardship's own watch, so khaliq-gant stays the one notified.
assert.deepEqual(steward.owners, []);
assert.equal(agent.generated[STEWARDSHIP_FILE], renderStewardship(steward));
for (const name of STEWARDSHIP_KIT_FILES) assert.ok(agent.files.some((f) => f.name === name && f.source === "kit"), name);
const script = gunzipSync(Buffer.from(userDataBase64(agent, read), "base64")).toString("utf8");
assert.ok(!script.includes(`cat > /opt/agent-host/${STEWARDSHIP_FILE}`), "stewardship never rides in user data");
});
Loading