Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

test(e2e): serve a scan-blocked SKILL.md from the mock registry (#7082)

oxoxDevcf2b297a43cb
diff --git a/scripts/mock-api/routes/__tests__/skill-registry.test.mjs b/scripts/mock-api/routes/__tests__/skill-registry.test.mjs
index ade36df7dc..7b82267e24 100644
--- a/scripts/mock-api/routes/__tests__/skill-registry.test.mjs
+++ b/scripts/mock-api/routes/__tests__/skill-registry.test.mjs
@@ -30,7 +30,13 @@ function createRes() {
}
function get(path) {
- const ctx = { method: "GET", url: path, body: "", parsedBody: null, res: createRes() };
+ const ctx = {
+ method: "GET",
+ url: path,
+ body: "",
+ parsedBody: null,
+ res: createRes(),
+ };
const handled = handleIntegrations(ctx);
return { handled, res: ctx.res };
}
@@ -45,8 +51,8 @@ test("the catalog spans more than one 25-entry page", () => {
assert.equal(res.statusCode, 200);
const entries = JSON.parse(res.body);
assert.ok(entries.length > 25, `only ${entries.length} entries`);
- assert.ok(entries.some(entry => entry.name === "git-workflow"));
- assert.ok(entries.some(entry => entry.name === "docker-management"));
+ assert.ok(entries.some((entry) => entry.name === "git-workflow"));
+ assert.ok(entries.some((entry) => entry.name === "docker-management"));
});
test("the catalog answers 503 while the registry is marked unavailable", () => {
@@ -64,3 +70,13 @@ test("each catalog entry has a SKILL.md and unknown names 404", () => {
const missing = get("/skills/nope/SKILL.md");
assert.equal(missing.res.statusCode, 404);
});
+
+test("the skill named by skillRegistryScanBlocked carries an invisible code point", () => {
+ setMockBehavior("skillRegistryScanBlocked", "git-workflow");
+ const blocked = get("/skills/git-workflow/SKILL.md");
+ assert.equal(blocked.res.statusCode, 200);
+ assert.ok(blocked.res.body.includes("\u200b"));
+
+ const clean = get("/skills/docker-management/SKILL.md");
+ assert.ok(!clean.res.body.includes("\u200b"));
+});
diff --git a/scripts/mock-api/routes/integrations.mjs b/scripts/mock-api/routes/integrations.mjs
index 209e376885..d7c485c571 100644
--- a/scripts/mock-api/routes/integrations.mjs
+++ b/scripts/mock-api/routes/integrations.mjs
@@ -43,8 +43,11 @@ const SKILL_REGISTRY_CATALOG = [
...SKILL_REGISTRY_FILLER,
];
-function skillRegistryDocument(name) {
- return `---\nname: ${name}\ndescription: Mock registry skill ${name}.\n---\n\n# ${name}\n`;
+// The skill named by `skillRegistryScanBlocked` carries a zero-width space,
+// which the supply-chain scan blocks.
+function skillRegistryDocument(name, scanBlocked) {
+ const body = scanBlocked ? "Run the steps\u200b in order.\n" : "";
+ return `---\nname: ${name}\ndescription: Mock registry skill ${name}.\n---\n\n# ${name}\n${body}`;
}
export function handleIntegrations(ctx) {
@@ -60,15 +63,22 @@ export function handleIntegrations(ctx) {
return true;
}
- const skillDocument = method === "GET" && url.match(/^\/skills\/([a-z0-9-]+)\/SKILL\.md(?:\?.*)?$/);
+ const skillDocument =
+ method === "GET" &&
+ url.match(/^\/skills\/([a-z0-9-]+)\/SKILL\.md(?:\?.*)?$/);
if (skillDocument) {
const name = skillDocument[1];
- if (!SKILL_REGISTRY_CATALOG.some(entry => entry.name === name)) {
+ if (!SKILL_REGISTRY_CATALOG.some((entry) => entry.name === name)) {
json(res, 404, { success: false, error: "no such skill" });
return true;
}
res.writeHead(200, { "Content-Type": "text/markdown; charset=utf-8" });
- res.end(skillRegistryDocument(name));
+ res.end(
+ skillRegistryDocument(
+ name,
+ mockBehavior.skillRegistryScanBlocked === name,
+ ),
+ );
return true;
}
@@ -707,7 +717,11 @@ export function handleIntegrations(ctx) {
requestId: "exa-answer",
answer: `Mock Exa answer for ${query}`,
citations: [
- { id: "c0", url: "https://exa.example.com/answer", title: "Exa source" },
+ {
+ id: "c0",
+ url: "https://exa.example.com/answer",
+ title: "Exa source",
+ },
],
costDollars: { total: 0.005 },
},
@@ -720,7 +734,11 @@ export function handleIntegrations(ctx) {
data: {
requestId: "exa-similar",
results: [
- { id: "s0", url: "https://exa.example.com/similar", title: "Similar page" },
+ {
+ id: "s0",
+ url: "https://exa.example.com/similar",
+ title: "Similar page",
+ },
],
costDollars: { total: 0.005 },
},