


















@@ -64,4 +64,59 @@ describe("subagent target policy", () => {
6464allowedIds: ["planner"],
6565});
6666});
67+68+it("limits wildcard allowlists to configured agents plus the requester", () => {
69+expect(
70+resolveSubagentAllowedTargetIds({
71+requesterAgentId: "main",
72+allowAgents: ["*"],
73+configuredAgentIds: ["planner", "checker"],
74+}),
75+).toEqual({
76+allowAny: true,
77+allowedIds: ["checker", "main", "planner"],
78+});
79+});
80+81+it("rejects wildcard targets outside the configured registry", () => {
82+const result = resolveSubagentTargetPolicy({
83+requesterAgentId: "main",
84+targetAgentId: "bogus",
85+requestedAgentId: "bogus",
86+allowAgents: ["*"],
87+configuredAgentIds: ["main", "planner"],
88+});
89+90+expect(result.ok).toBe(false);
91+if (result.ok) {
92+throw new Error("Expected target policy to reject unconfigured wildcard target");
93+}
94+expect(result.allowedText).toBe("main, planner");
95+expect(result.error).toBe(
96+'agentId "bogus" is not in the configured agent registry (allowed: main, planner)',
97+);
98+});
99+100+it("preserves explicit targets when wildcard allowlists are mixed", () => {
101+expect(
102+resolveSubagentAllowedTargetIds({
103+requesterAgentId: "main",
104+allowAgents: ["*", "beta"],
105+configuredAgentIds: ["main", "planner"],
106+}),
107+).toEqual({
108+allowAny: true,
109+allowedIds: ["beta", "main", "planner"],
110+});
111+112+expect(
113+resolveSubagentTargetPolicy({
114+requesterAgentId: "main",
115+targetAgentId: "beta",
116+requestedAgentId: "beta",
117+allowAgents: ["*", "beta"],
118+configuredAgentIds: ["main", "planner"],
119+}),
120+).toEqual({ ok: true });
121+});
67122});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。