|
1 | 1 | import { describe, expect, it } from "vitest"; |
2 | 2 | import { |
| 3 | + resolveConfiguredSubagentAllowAgents, |
3 | 4 | resolveSubagentAllowedTargetIds, |
4 | 5 | resolveSubagentTargetPolicy, |
5 | 6 | } from "./subagent-target-policy.js"; |
@@ -64,4 +65,33 @@ describe("subagent target policy", () => { |
64 | 65 | allowedIds: ["planner"], |
65 | 66 | }); |
66 | 67 | }); |
| 68 | + |
| 69 | + it("uses SPAWN_ALLOWLIST as a fallback allowlist when config omits one", () => { |
| 70 | + expect( |
| 71 | + resolveConfiguredSubagentAllowAgents({ |
| 72 | + env: { SPAWN_ALLOWLIST: " planner, checker " }, |
| 73 | + }), |
| 74 | + ).toEqual(["planner", "checker"]); |
| 75 | + expect( |
| 76 | + resolveConfiguredSubagentAllowAgents({ |
| 77 | + env: { OPENCLAW_SPAWN_ALLOWLIST: '["research", "*"]', SPAWN_ALLOWLIST: "ignored" }, |
| 78 | + }), |
| 79 | + ).toEqual(["research", "*"]); |
| 80 | + }); |
| 81 | + |
| 82 | + it("keeps explicit config ahead of SPAWN_ALLOWLIST", () => { |
| 83 | + expect( |
| 84 | + resolveConfiguredSubagentAllowAgents({ |
| 85 | + agentAllowAgents: ["agent-specific"], |
| 86 | + defaultAllowAgents: ["default"], |
| 87 | + env: { SPAWN_ALLOWLIST: "*" }, |
| 88 | + }), |
| 89 | + ).toEqual(["agent-specific"]); |
| 90 | + expect( |
| 91 | + resolveConfiguredSubagentAllowAgents({ |
| 92 | + defaultAllowAgents: ["default"], |
| 93 | + env: { SPAWN_ALLOWLIST: "*" }, |
| 94 | + }), |
| 95 | + ).toEqual(["default"]); |
| 96 | + }); |
67 | 97 | }); |
0 commit comments