mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-12 12:54:07 -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 () => {
|
it('should register ALLOW rules for read-only tools', async () => {
|
||||||
mockBrowserManager.getDiscoveredTools.mockResolvedValue([
|
mockBrowserManager.getDiscoveredTools.mockResolvedValue([
|
||||||
{ name: 'take_snapshot', description: 'Take snapshot' },
|
{
|
||||||
{ name: 'take_screenshot', description: 'Take screenshot' },
|
name: 'take_snapshot',
|
||||||
{ name: 'list_pages', description: 'list all pages' },
|
description: 'Take snapshot',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'take_screenshot',
|
||||||
|
description: 'Take screenshot',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'list_pages',
|
||||||
|
description: 'list all pages',
|
||||||
|
annotations: { readOnlyHint: true },
|
||||||
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
await createBrowserAgentDefinition(mockConfig, mockMessageBus);
|
await createBrowserAgentDefinition(mockConfig, mockMessageBus);
|
||||||
|
|||||||
@@ -120,13 +120,12 @@ export async function createBrowserAgentDefinition(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Reduce noise for read-only tools in default mode
|
// Reduce noise for read-only tools in default mode
|
||||||
const readOnlyTools = [
|
const readOnlyTools = (await browserManager.getDiscoveredTools())
|
||||||
'take_snapshot',
|
.filter((t) => !!t.annotations?.readOnlyHint)
|
||||||
'take_screenshot',
|
.map((t) => t.name);
|
||||||
'list_pages',
|
const allowlistedReadonlyTools = ['take_snapshot', 'take_screenshot'];
|
||||||
'list_network_requests',
|
|
||||||
];
|
for (const toolName of [...readOnlyTools, ...allowlistedReadonlyTools]) {
|
||||||
for (const toolName of readOnlyTools) {
|
|
||||||
if (availableToolNames.includes(toolName)) {
|
if (availableToolNames.includes(toolName)) {
|
||||||
const rule = generateAllowRules(toolName);
|
const rule = generateAllowRules(toolName);
|
||||||
if (!existingRules.some((r) => isRuleEqual(r, rule))) {
|
if (!existingRules.some((r) => isRuleEqual(r, rule))) {
|
||||||
|
|||||||
Reference in New Issue
Block a user