(params: {
agentId: string;
agentAiDefaults?: ProjectsConfig["agentAiDefaults"];
})
| 31 | } |
| 32 | |
| 33 | async function resolvePolicyForAgent(params: { |
| 34 | agentId: string; |
| 35 | agentAiDefaults?: ProjectsConfig["agentAiDefaults"]; |
| 36 | }) { |
| 37 | using tempDir = new DisposableTempDir("agent-resolution-advisor-defaults"); |
| 38 | const projectPath = path.join(tempDir.path, "project"); |
| 39 | await fs.mkdir(projectPath, { recursive: true }); |
| 40 | |
| 41 | const metadata = createSubagentMetadata({ |
| 42 | projectPath, |
| 43 | agentId: params.agentId, |
| 44 | }); |
| 45 | const cfg: ProjectsConfig = { |
| 46 | projects: new Map([ |
| 47 | [ |
| 48 | projectPath, |
| 49 | { |
| 50 | trusted: true, |
| 51 | workspaces: [ |
| 52 | { id: PARENT_WORKSPACE_ID, name: PARENT_WORKSPACE_ID, path: projectPath }, |
| 53 | { |
| 54 | id: CHILD_WORKSPACE_ID, |
| 55 | name: CHILD_WORKSPACE_ID, |
| 56 | path: projectPath, |
| 57 | parentWorkspaceId: PARENT_WORKSPACE_ID, |
| 58 | agentId: params.agentId, |
| 59 | agentType: params.agentId, |
| 60 | }, |
| 61 | ], |
| 62 | }, |
| 63 | ], |
| 64 | ]), |
| 65 | ...(params.agentAiDefaults ? { agentAiDefaults: params.agentAiDefaults } : {}), |
| 66 | }; |
| 67 | |
| 68 | const result = await resolveAgentForStream({ |
| 69 | workspaceId: CHILD_WORKSPACE_ID, |
| 70 | metadata, |
| 71 | runtime: new LocalRuntime(projectPath), |
| 72 | workspacePath: projectPath, |
| 73 | requestedAgentId: params.agentId, |
| 74 | disableWorkspaceAgents: false, |
| 75 | callerToolPolicy: undefined, |
| 76 | cfg, |
| 77 | emitError: () => undefined, |
| 78 | isAdvisorExperimentEnabled: true, |
| 79 | }); |
| 80 | |
| 81 | if (!result.success) { |
| 82 | throw new Error("Expected agent resolution to succeed"); |
| 83 | } |
| 84 | return result.data.effectiveToolPolicy ?? []; |
| 85 | } |
| 86 | |
| 87 | describe("getLegacyModeForAgentMetadata", () => { |
| 88 | test("omits legacy mode metadata for custom or derived agents", () => { |
no test coverage detected