

























@@ -41,6 +41,7 @@ describe("subagent target policy", () => {
4141targetAgentId: "task-manager",
4242requestedAgentId: "task-manager",
4343allowAgents: ["planner", "checker"],
44+configuredAgentIds: ["task-manager", "planner", "checker"],
4445});
4546expect(result.ok).toBe(false);
4647if (result.ok) {
@@ -65,6 +66,35 @@ describe("subagent target policy", () => {
6566});
6667});
676869+it("filters explicit allowlists to configured target ids", () => {
70+expect(
71+resolveSubagentAllowedTargetIds({
72+requesterAgentId: "main",
73+allowAgents: ["planner", "stale"],
74+configuredAgentIds: ["main", "planner"],
75+}),
76+).toEqual({
77+allowAny: false,
78+allowedIds: ["planner"],
79+});
80+81+const result = resolveSubagentTargetPolicy({
82+requesterAgentId: "main",
83+targetAgentId: "stale",
84+requestedAgentId: "stale",
85+allowAgents: ["planner", "stale"],
86+configuredAgentIds: ["main", "planner"],
87+});
88+expect(result.ok).toBe(false);
89+if (result.ok) {
90+throw new Error("Expected target policy to reject stale explicit target");
91+}
92+expect(result.allowedText).toBe("planner");
93+expect(result.error).toBe(
94+'agentId "stale" is not in the configured agent registry (allowed: planner)',
95+);
96+});
97+6898it("limits wildcard allowlists to configured agents plus the requester", () => {
6999expect(
70100resolveSubagentAllowedTargetIds({
@@ -97,7 +127,7 @@ describe("subagent target policy", () => {
97127);
98128});
99129100-it("preserves explicit targets when wildcard allowlists are mixed", () => {
130+it("filters explicit targets when wildcard allowlists are mixed", () => {
101131expect(
102132resolveSubagentAllowedTargetIds({
103133requesterAgentId: "main",
@@ -106,17 +136,22 @@ describe("subagent target policy", () => {
106136}),
107137).toEqual({
108138allowAny: true,
109-allowedIds: ["beta", "main", "planner"],
139+allowedIds: ["main", "planner"],
110140});
111141112-expect(
113-resolveSubagentTargetPolicy({
114-requesterAgentId: "main",
115-targetAgentId: "beta",
116-requestedAgentId: "beta",
117-allowAgents: ["*", "beta"],
118-configuredAgentIds: ["main", "planner"],
119-}),
120-).toEqual({ ok: true });
142+const result = resolveSubagentTargetPolicy({
143+requesterAgentId: "main",
144+targetAgentId: "beta",
145+requestedAgentId: "beta",
146+allowAgents: ["*", "beta"],
147+configuredAgentIds: ["main", "planner"],
148+});
149+expect(result.ok).toBe(false);
150+if (result.ok) {
151+throw new Error("Expected target policy to reject stale mixed explicit target");
152+}
153+expect(result.error).toBe(
154+'agentId "beta" is not in the configured agent registry (allowed: main, planner)',
155+);
121156});
122157});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。