mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-26 14:01:14 -07:00
feat(browser): dynamically discover read-only tools (#23805)
This commit is contained in:
@@ -379,9 +379,19 @@ describe('browserAgentFactory', () => {
|
||||
|
||||
it('should register ALLOW rules for read-only tools', async () => {
|
||||
mockBrowserManager.getDiscoveredTools.mockResolvedValue([
|
||||
{ name: 'take_snapshot', description: 'Take snapshot' },
|
||||
{ name: 'take_screenshot', description: 'Take screenshot' },
|
||||
{ name: 'list_pages', description: 'list all pages' },
|
||||
{
|
||||
name: 'take_snapshot',
|
||||
description: 'Take snapshot',
|
||||
},
|
||||
{
|
||||
name: 'take_screenshot',
|
||||
description: 'Take screenshot',
|
||||
},
|
||||
{
|
||||
name: 'list_pages',
|
||||
description: 'list all pages',
|
||||
annotations: { readOnlyHint: true },
|
||||
},
|
||||
]);
|
||||
|
||||
await createBrowserAgentDefinition(mockConfig, mockMessageBus);
|
||||
|
||||
@@ -120,13 +120,12 @@ export async function createBrowserAgentDefinition(
|
||||
}
|
||||
|
||||
// Reduce noise for read-only tools in default mode
|
||||
const readOnlyTools = [
|
||||
'take_snapshot',
|
||||
'take_screenshot',
|
||||
'list_pages',
|
||||
'list_network_requests',
|
||||
];
|
||||
for (const toolName of readOnlyTools) {
|
||||
const readOnlyTools = (await browserManager.getDiscoveredTools())
|
||||
.filter((t) => !!t.annotations?.readOnlyHint)
|
||||
.map((t) => t.name);
|
||||
const allowlistedReadonlyTools = ['take_snapshot', 'take_screenshot'];
|
||||
|
||||
for (const toolName of [...readOnlyTools, ...allowlistedReadonlyTools]) {
|
||||
if (availableToolNames.includes(toolName)) {
|
||||
const rule = generateAllowRules(toolName);
|
||||
if (!existingRules.some((r) => isRuleEqual(r, rule))) {
|
||||
|
||||
Reference in New Issue
Block a user