|
| 1 | +/** |
| 2 | + * Copyright 2026 GoodRx, Inc. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +import AgentPolicyService from '../PolicyService'; |
| 18 | + |
| 19 | +describe('AgentPolicyService', () => { |
| 20 | + it('keeps read-only sandbox tools in the read capability', () => { |
| 21 | + expect( |
| 22 | + AgentPolicyService.capabilityForSessionWorkspaceTool('workspace.read_file', { |
| 23 | + readOnlyHint: true, |
| 24 | + }) |
| 25 | + ).toBe('read'); |
| 26 | + }); |
| 27 | + |
| 28 | + it('keeps session git helpers in the git write capability', () => { |
| 29 | + expect(AgentPolicyService.capabilityForSessionWorkspaceTool('git.branch')).toBe('git_write'); |
| 30 | + }); |
| 31 | + |
| 32 | + it('maps read-only external MCP tools to external_mcp_read', () => { |
| 33 | + expect( |
| 34 | + AgentPolicyService.capabilityForExternalMcpTool('getJiraIssue', { |
| 35 | + readOnlyHint: true, |
| 36 | + }) |
| 37 | + ).toBe('external_mcp_read'); |
| 38 | + }); |
| 39 | + |
| 40 | + it('maps mutating external MCP tools to external_mcp_write without workspace heuristics', () => { |
| 41 | + expect(AgentPolicyService.capabilityForExternalMcpTool('editJiraIssue')).toBe('external_mcp_write'); |
| 42 | + }); |
| 43 | +}); |
0 commit comments