+9
-96
@@ -229,22 +229,6 @@ async function host(
|
||||
};
|
||||
}
|
||||
|
||||
test("Agents is independently loadable with no quota, storage, MCP, or custom tools", async () => {
|
||||
expect(plugin.id).toBe("stanp-opencode.agents");
|
||||
const h = await host();
|
||||
expect(h.agents.has("coordinate")).toBe(true);
|
||||
expect(h.agents.has("multi-work")).toBe(false);
|
||||
expect(h.agents.get("build")?.mode).toBe("primary");
|
||||
expect(h.skills.get("anti-overengineering")?.content).toContain("correctness");
|
||||
});
|
||||
|
||||
test("preserves an existing user anti-overengineering skill", async () => {
|
||||
const first = await host();
|
||||
const original = { ...first.skills.get("anti-overengineering")!, content: "user definition" };
|
||||
const h = await host(models, { agents }, original);
|
||||
expect(h.skills.get("anti-overengineering")).toEqual(original);
|
||||
});
|
||||
|
||||
test("worker availability, deep fallback, and model refresh remain provider aware", async () => {
|
||||
const h = await host();
|
||||
expect(String(h.agents.get("coordinate")?.model?.id)).toBe("gpt-6-astra");
|
||||
@@ -267,19 +251,7 @@ test("without agents options or with the empty skeleton nothing is registered",
|
||||
}
|
||||
});
|
||||
|
||||
test("empty deep pair disables deep; partially filled required assignments fail", async () => {
|
||||
const h = await host(models, { agents: { ...agents, "deep-lo": "", "deep-hi": "" } });
|
||||
expect(String(h.agents.get("coordinate")?.model?.id)).toBe("gpt-6.1-sol");
|
||||
expect(h.agents.has("deep-lo")).toBe(false);
|
||||
await expect(host(models, { agents: { ...agents, "good-hi": "" } })).rejects.toThrow(
|
||||
"agents good-hi is required",
|
||||
);
|
||||
await expect(host(models, { agents: { "deep-lo": agents["deep-lo"] } })).rejects.toThrow(
|
||||
"agents fast-lo is required",
|
||||
);
|
||||
});
|
||||
|
||||
test("assignments are provider-qualified with optional deep pair and variant", async () => {
|
||||
test("assignments are provider-qualified with optional deep pair and variant; partial ones fail", async () => {
|
||||
const shallow = Object.fromEntries(
|
||||
Object.entries(agents).filter(([name]) => !name.startsWith("deep-")),
|
||||
);
|
||||
@@ -296,47 +268,15 @@ test("assignments are provider-qualified with optional deep pair and variant", a
|
||||
await expect(
|
||||
host(models, { agents: { ...agents, "fast-lo": "unqualified#low" } }),
|
||||
).rejects.toThrow("agents fast-lo must be provider/model[#variant]");
|
||||
});
|
||||
|
||||
test("live final build permissions reach workers, coordinate and the native Agents RPC", async () => {
|
||||
const h = await host();
|
||||
const rules = [
|
||||
{ action: "*", resource: "*", effect: "allow" as const },
|
||||
{ action: "read", resource: "secret", effect: "deny" as const },
|
||||
];
|
||||
await h.configure(rules);
|
||||
expect(await h.permissions()).toEqual(rules);
|
||||
expect(h.agents.get("fast-lo")?.permissions).toEqual([
|
||||
...rules,
|
||||
{ action: "subagent", resource: "*", effect: "deny" },
|
||||
]);
|
||||
expect(h.agents.get("coordinate")?.permissions).toContainEqual(rules[1]);
|
||||
expect(h.agents.get("coordinate")?.permissions.some((rule) => rule.action === "shell")).toBe(
|
||||
false,
|
||||
const empty = await host(models, { agents: { ...agents, "deep-lo": "", "deep-hi": "" } });
|
||||
expect(String(empty.agents.get("coordinate")?.model?.id)).toBe("gpt-6.1-sol");
|
||||
expect(empty.agents.has("deep-lo")).toBe(false);
|
||||
await expect(host(models, { agents: { ...agents, "good-hi": "" } })).rejects.toThrow(
|
||||
"agents good-hi is required",
|
||||
);
|
||||
await expect(host(models, { agents: { "deep-lo": agents["deep-lo"] } })).rejects.toThrow(
|
||||
"agents fast-lo is required",
|
||||
);
|
||||
});
|
||||
|
||||
test("available Codegraph tools inherit permission rules without changing MCP configuration", async () => {
|
||||
const h = await host();
|
||||
await h.availableTools(["codegraph_query", "docs_search"]);
|
||||
await h.configure([
|
||||
{ action: "*", resource: "*", effect: "allow" },
|
||||
{ action: "code*", resource: "*", effect: "ask" },
|
||||
]);
|
||||
expect(h.agents.get("coordinate")?.permissions).toContainEqual({
|
||||
action: "codegraph_query",
|
||||
resource: "*",
|
||||
effect: "ask",
|
||||
});
|
||||
expect(
|
||||
h.agents.get("coordinate")?.permissions.some((rule) => rule.action === "docs_search"),
|
||||
).toBe(false);
|
||||
await h.availableTools([]);
|
||||
expect(
|
||||
h.agents
|
||||
.get("coordinate")
|
||||
?.permissions.some((rule) => rule.action.startsWith("codegraph_")),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
test("native tool and command paths retain core delegation restrictions", async () => {
|
||||
@@ -357,30 +297,3 @@ test("native tool and command paths retain core delegation restrictions", async
|
||||
.parse((await h.request("coordinate")).subagent?.input.properties).agent,
|
||||
).toEqual({ type: "string", enum: ["fast-lo", "fast-hi", "good-lo", "good-hi"] });
|
||||
});
|
||||
|
||||
test("foreign-location model events do not refresh this plugin instance", async () => {
|
||||
const h = await host();
|
||||
await h.models([], { directory: "/elsewhere" });
|
||||
expect(h.agents.has("coordinate")).toBe(true);
|
||||
});
|
||||
|
||||
test("reasoning uses advertised variants and falls back to request settings", async () => {
|
||||
const h = await host();
|
||||
expect(String(h.agents.get("fast-lo")?.model?.variant)).toBe("low");
|
||||
expect(h.agents.get("fast-lo")?.request?.settings).toEqual({});
|
||||
const noVariants = models.map((model) => ({ ...model, variants: [] }));
|
||||
const fallback = await host(noVariants);
|
||||
expect(fallback.agents.get("fast-lo")?.model?.variant).toBeUndefined();
|
||||
expect(fallback.agents.get("fast-lo")?.request?.settings).toEqual({ reasoningEffort: "low" });
|
||||
expect(fallback.agents.get("coordinate")?.request?.settings).toEqual({
|
||||
reasoningEffort: "low",
|
||||
});
|
||||
});
|
||||
|
||||
test("disabled catalog entries do not authorize worker availability", async () => {
|
||||
const h = await host(
|
||||
models.map((model) => ({ ...model, enabled: model.id !== "gpt-6-astra" })),
|
||||
);
|
||||
expect(String(h.agents.get("coordinate")?.model?.id)).toBe("gpt-6.1-sol");
|
||||
expect(h.agents.has("deep-lo")).toBe(false);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user