mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-06-21 16:57:08 -07:00
rename 'browser_agent' to 'browser'
This commit is contained in:
@@ -24,7 +24,7 @@ import {
|
||||
} from '../../config/models.js';
|
||||
|
||||
/** Canonical agent name — used for routing and configuration lookup. */
|
||||
export const BROWSER_AGENT_NAME = 'browser_agent';
|
||||
export const BROWSER_AGENT_NAME = 'browser';
|
||||
|
||||
/**
|
||||
* Output schema for browser agent results.
|
||||
|
||||
@@ -96,7 +96,7 @@ describe('browserAgentFactory', () => {
|
||||
mockConfig = makeFakeConfig({
|
||||
agents: {
|
||||
overrides: {
|
||||
browser_agent: {
|
||||
browser: {
|
||||
enabled: true,
|
||||
},
|
||||
},
|
||||
@@ -133,7 +133,7 @@ describe('browserAgentFactory', () => {
|
||||
const headlessConfig = makeFakeConfig({
|
||||
agents: {
|
||||
overrides: {
|
||||
browser_agent: {
|
||||
browser: {
|
||||
enabled: true,
|
||||
},
|
||||
},
|
||||
@@ -205,7 +205,7 @@ describe('browserAgentFactory', () => {
|
||||
const configWithVision = makeFakeConfig({
|
||||
agents: {
|
||||
overrides: {
|
||||
browser_agent: {
|
||||
browser: {
|
||||
enabled: true,
|
||||
},
|
||||
},
|
||||
@@ -230,7 +230,7 @@ describe('browserAgentFactory', () => {
|
||||
const configWithVision = makeFakeConfig({
|
||||
agents: {
|
||||
overrides: {
|
||||
browser_agent: {
|
||||
browser: {
|
||||
enabled: true,
|
||||
},
|
||||
},
|
||||
@@ -369,7 +369,7 @@ describe('browserAgentFactory', () => {
|
||||
|
||||
expect(mockPolicyEngine.addRule).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
toolName: 'mcp_browser_agent_fill',
|
||||
toolName: 'mcp_browser_fill',
|
||||
decision: PolicyDecision.ASK_USER,
|
||||
priority: 999,
|
||||
}),
|
||||
@@ -377,7 +377,7 @@ describe('browserAgentFactory', () => {
|
||||
|
||||
expect(mockPolicyEngine.addRule).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
toolName: 'mcp_browser_agent_upload_file',
|
||||
toolName: 'mcp_browser_upload_file',
|
||||
decision: PolicyDecision.ASK_USER,
|
||||
priority: 999,
|
||||
}),
|
||||
@@ -385,7 +385,7 @@ describe('browserAgentFactory', () => {
|
||||
|
||||
expect(mockPolicyEngine.addRule).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
toolName: 'mcp_browser_agent_evaluate_script',
|
||||
toolName: 'mcp_browser_evaluate_script',
|
||||
decision: PolicyDecision.ASK_USER,
|
||||
priority: 999,
|
||||
}),
|
||||
@@ -397,13 +397,13 @@ describe('browserAgentFactory', () => {
|
||||
|
||||
expect(mockPolicyEngine.addRule).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
toolName: 'mcp_browser_agent_fill',
|
||||
toolName: 'mcp_browser_fill',
|
||||
}),
|
||||
);
|
||||
|
||||
expect(mockPolicyEngine.addRule).not.toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
toolName: 'mcp_browser_agent_upload_file',
|
||||
toolName: 'mcp_browser_upload_file',
|
||||
}),
|
||||
);
|
||||
});
|
||||
@@ -429,7 +429,7 @@ describe('browserAgentFactory', () => {
|
||||
|
||||
expect(mockPolicyEngine.addRule).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
toolName: 'mcp_browser_agent_take_snapshot',
|
||||
toolName: 'mcp_browser_take_snapshot',
|
||||
decision: PolicyDecision.ALLOW,
|
||||
priority: PRIORITY_SUBAGENT_TOOL,
|
||||
}),
|
||||
@@ -437,7 +437,7 @@ describe('browserAgentFactory', () => {
|
||||
|
||||
expect(mockPolicyEngine.addRule).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
toolName: 'mcp_browser_agent_take_screenshot',
|
||||
toolName: 'mcp_browser_take_screenshot',
|
||||
decision: PolicyDecision.ALLOW,
|
||||
priority: PRIORITY_SUBAGENT_TOOL,
|
||||
}),
|
||||
@@ -445,7 +445,7 @@ describe('browserAgentFactory', () => {
|
||||
|
||||
expect(mockPolicyEngine.addRule).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
toolName: 'mcp_browser_agent_list_pages',
|
||||
toolName: 'mcp_browser_list_pages',
|
||||
decision: PolicyDecision.ALLOW,
|
||||
priority: PRIORITY_SUBAGENT_TOOL,
|
||||
}),
|
||||
|
||||
@@ -59,7 +59,7 @@ describe('BrowserAgentInvocation', () => {
|
||||
mockConfig = makeFakeConfig({
|
||||
agents: {
|
||||
overrides: {
|
||||
browser_agent: {
|
||||
browser: {
|
||||
enabled: true,
|
||||
},
|
||||
},
|
||||
@@ -96,14 +96,14 @@ describe('BrowserAgentInvocation', () => {
|
||||
expect(invocation.params).toEqual(mockParams);
|
||||
});
|
||||
|
||||
it('should use browser_agent as default tool name', () => {
|
||||
it('should use browser as default tool name', () => {
|
||||
const invocation = new BrowserAgentInvocation(
|
||||
mockConfig,
|
||||
mockParams,
|
||||
mockMessageBus,
|
||||
);
|
||||
|
||||
expect(invocation['_toolName']).toBe('browser_agent');
|
||||
expect(invocation['_toolName']).toBe('browser');
|
||||
});
|
||||
|
||||
it('should use custom tool name if provided', () => {
|
||||
@@ -172,7 +172,7 @@ describe('BrowserAgentInvocation', () => {
|
||||
beforeEach(() => {
|
||||
vi.mocked(createBrowserAgentDefinition).mockResolvedValue({
|
||||
definition: {
|
||||
name: 'browser_agent',
|
||||
name: 'browser',
|
||||
description: 'mock definition',
|
||||
kind: 'local',
|
||||
inputConfig: {} as never,
|
||||
@@ -331,7 +331,7 @@ describe('BrowserAgentInvocation', () => {
|
||||
|
||||
fireActivity({
|
||||
isSubagentActivityEvent: true,
|
||||
agentName: 'browser_agent',
|
||||
agentName: 'browser',
|
||||
type: 'THOUGHT_CHUNK',
|
||||
data: { text: 'Navigating to the page...' },
|
||||
});
|
||||
@@ -374,13 +374,13 @@ describe('BrowserAgentInvocation', () => {
|
||||
|
||||
fireActivity({
|
||||
isSubagentActivityEvent: true,
|
||||
agentName: 'browser_agent',
|
||||
agentName: 'browser',
|
||||
type: 'THOUGHT_CHUNK',
|
||||
data: { text: 'I am thinking.' },
|
||||
});
|
||||
fireActivity({
|
||||
isSubagentActivityEvent: true,
|
||||
agentName: 'browser_agent',
|
||||
agentName: 'browser',
|
||||
type: 'THOUGHT_CHUNK',
|
||||
data: { text: 'Now I will act.' },
|
||||
});
|
||||
@@ -420,7 +420,7 @@ describe('BrowserAgentInvocation', () => {
|
||||
|
||||
fireActivity({
|
||||
isSubagentActivityEvent: true,
|
||||
agentName: 'browser_agent',
|
||||
agentName: 'browser',
|
||||
type: 'TOOL_CALL_START',
|
||||
data: {
|
||||
name: 'navigate_browser',
|
||||
@@ -431,7 +431,7 @@ describe('BrowserAgentInvocation', () => {
|
||||
|
||||
fireActivity({
|
||||
isSubagentActivityEvent: true,
|
||||
agentName: 'browser_agent',
|
||||
agentName: 'browser',
|
||||
type: 'TOOL_CALL_END',
|
||||
data: { name: 'navigate_browser', id: 'call-1' },
|
||||
});
|
||||
@@ -471,7 +471,7 @@ describe('BrowserAgentInvocation', () => {
|
||||
|
||||
fireActivity({
|
||||
isSubagentActivityEvent: true,
|
||||
agentName: 'browser_agent',
|
||||
agentName: 'browser',
|
||||
type: 'TOOL_CALL_START',
|
||||
data: {
|
||||
name: 'fill_form',
|
||||
@@ -515,14 +515,14 @@ describe('BrowserAgentInvocation', () => {
|
||||
|
||||
fireActivity({
|
||||
isSubagentActivityEvent: true,
|
||||
agentName: 'browser_agent',
|
||||
agentName: 'browser',
|
||||
type: 'TOOL_CALL_START',
|
||||
data: { name: 'click_element', callId: 'call-3', args: {} },
|
||||
});
|
||||
|
||||
fireActivity({
|
||||
isSubagentActivityEvent: true,
|
||||
agentName: 'browser_agent',
|
||||
agentName: 'browser',
|
||||
type: 'ERROR',
|
||||
data: { error: 'Element not found', callId: 'call-3' },
|
||||
});
|
||||
@@ -560,7 +560,7 @@ describe('BrowserAgentInvocation', () => {
|
||||
|
||||
fireActivity({
|
||||
isSubagentActivityEvent: true,
|
||||
agentName: 'browser_agent',
|
||||
agentName: 'browser',
|
||||
type: 'ERROR',
|
||||
data: { error: 'Auth failed: api_key=sk-secret-abc1234567890' },
|
||||
});
|
||||
@@ -600,7 +600,7 @@ describe('BrowserAgentInvocation', () => {
|
||||
|
||||
fireActivity({
|
||||
isSubagentActivityEvent: true,
|
||||
agentName: 'browser_agent',
|
||||
agentName: 'browser',
|
||||
type: 'ERROR',
|
||||
data: {
|
||||
error:
|
||||
@@ -643,14 +643,14 @@ describe('BrowserAgentInvocation', () => {
|
||||
|
||||
fireActivity({
|
||||
isSubagentActivityEvent: true,
|
||||
agentName: 'browser_agent',
|
||||
agentName: 'browser',
|
||||
type: 'TOOL_CALL_START',
|
||||
data: { name: 'tool_a', callId: 'c1', args: {} },
|
||||
});
|
||||
|
||||
fireActivity({
|
||||
isSubagentActivityEvent: true,
|
||||
agentName: 'browser_agent',
|
||||
agentName: 'browser',
|
||||
type: 'TOOL_CALL_START',
|
||||
data: { name: 'tool_b', callId: 'c2', args: {} },
|
||||
});
|
||||
@@ -658,7 +658,7 @@ describe('BrowserAgentInvocation', () => {
|
||||
// ERROR with no callId should mark ALL running tools as error
|
||||
fireActivity({
|
||||
isSubagentActivityEvent: true,
|
||||
agentName: 'browser_agent',
|
||||
agentName: 'browser',
|
||||
type: 'ERROR',
|
||||
data: { error: 'Agent crashed' },
|
||||
});
|
||||
@@ -699,7 +699,7 @@ describe('BrowserAgentInvocation', () => {
|
||||
|
||||
vi.mocked(createBrowserAgentDefinition).mockResolvedValue({
|
||||
definition: {
|
||||
name: 'browser_agent',
|
||||
name: 'browser',
|
||||
description: 'mock definition',
|
||||
kind: 'local',
|
||||
inputConfig: {} as never,
|
||||
|
||||
@@ -66,7 +66,7 @@ export class BrowserAgentInvocation extends BaseToolInvocation<
|
||||
_toolName?: string,
|
||||
_toolDisplayName?: string,
|
||||
) {
|
||||
const resolvedName = _toolName ?? 'browser_agent';
|
||||
const resolvedName = _toolName ?? 'browser';
|
||||
// Note: BrowserAgentDefinition is a factory function, so we use hardcoded names
|
||||
super(
|
||||
params,
|
||||
|
||||
@@ -97,7 +97,7 @@ describe('BrowserManager', () => {
|
||||
mockConfig = makeFakeConfig({
|
||||
agents: {
|
||||
overrides: {
|
||||
browser_agent: {
|
||||
browser: {
|
||||
enabled: true,
|
||||
},
|
||||
},
|
||||
@@ -419,7 +419,7 @@ describe('BrowserManager', () => {
|
||||
const headlessConfig = makeFakeConfig({
|
||||
agents: {
|
||||
overrides: {
|
||||
browser_agent: {
|
||||
browser: {
|
||||
enabled: true,
|
||||
},
|
||||
},
|
||||
@@ -444,7 +444,7 @@ describe('BrowserManager', () => {
|
||||
const profileConfig = makeFakeConfig({
|
||||
agents: {
|
||||
overrides: {
|
||||
browser_agent: {
|
||||
browser: {
|
||||
enabled: true,
|
||||
},
|
||||
},
|
||||
@@ -469,7 +469,7 @@ describe('BrowserManager', () => {
|
||||
const isolatedConfig = makeFakeConfig({
|
||||
agents: {
|
||||
overrides: {
|
||||
browser_agent: {
|
||||
browser: {
|
||||
enabled: true,
|
||||
},
|
||||
},
|
||||
@@ -492,7 +492,7 @@ describe('BrowserManager', () => {
|
||||
const existingConfig = makeFakeConfig({
|
||||
agents: {
|
||||
overrides: {
|
||||
browser_agent: {
|
||||
browser: {
|
||||
enabled: true,
|
||||
},
|
||||
},
|
||||
@@ -531,7 +531,7 @@ describe('BrowserManager', () => {
|
||||
const existingConfig = makeFakeConfig({
|
||||
agents: {
|
||||
overrides: {
|
||||
browser_agent: {
|
||||
browser: {
|
||||
enabled: true,
|
||||
},
|
||||
},
|
||||
@@ -628,7 +628,7 @@ describe('BrowserManager', () => {
|
||||
const privacyDisabledConfig = makeFakeConfig({
|
||||
agents: {
|
||||
overrides: {
|
||||
browser_agent: {
|
||||
browser: {
|
||||
enabled: true,
|
||||
},
|
||||
},
|
||||
@@ -730,7 +730,7 @@ describe('BrowserManager', () => {
|
||||
it('should return different instances for different session modes', () => {
|
||||
const isolatedConfig = makeFakeConfig({
|
||||
agents: {
|
||||
overrides: { browser_agent: { enabled: true } },
|
||||
overrides: { browser: { enabled: true } },
|
||||
browser: { sessionMode: 'isolated' },
|
||||
},
|
||||
});
|
||||
@@ -744,13 +744,13 @@ describe('BrowserManager', () => {
|
||||
it('should return different instances for different profile paths', () => {
|
||||
const config1 = makeFakeConfig({
|
||||
agents: {
|
||||
overrides: { browser_agent: { enabled: true } },
|
||||
overrides: { browser: { enabled: true } },
|
||||
browser: { profilePath: '/path/a' },
|
||||
},
|
||||
});
|
||||
const config2 = makeFakeConfig({
|
||||
agents: {
|
||||
overrides: { browser_agent: { enabled: true } },
|
||||
overrides: { browser: { enabled: true } },
|
||||
browser: { profilePath: '/path/b' },
|
||||
},
|
||||
});
|
||||
@@ -769,7 +769,7 @@ describe('BrowserManager', () => {
|
||||
|
||||
const isolatedConfig = makeFakeConfig({
|
||||
agents: {
|
||||
overrides: { browser_agent: { enabled: true } },
|
||||
overrides: { browser: { enabled: true } },
|
||||
browser: { sessionMode: 'isolated' },
|
||||
},
|
||||
});
|
||||
@@ -879,7 +879,7 @@ describe('BrowserManager', () => {
|
||||
mockConfig = makeFakeConfig({
|
||||
agents: {
|
||||
overrides: {
|
||||
browser_agent: {
|
||||
browser: {
|
||||
enabled: true,
|
||||
},
|
||||
},
|
||||
@@ -901,7 +901,7 @@ describe('BrowserManager', () => {
|
||||
mockConfig = makeFakeConfig({
|
||||
agents: {
|
||||
overrides: {
|
||||
browser_agent: {
|
||||
browser: {
|
||||
enabled: true,
|
||||
},
|
||||
},
|
||||
@@ -923,7 +923,7 @@ describe('BrowserManager', () => {
|
||||
mockConfig = makeFakeConfig({
|
||||
agents: {
|
||||
overrides: {
|
||||
browser_agent: {
|
||||
browser: {
|
||||
enabled: true,
|
||||
},
|
||||
},
|
||||
@@ -969,7 +969,7 @@ describe('BrowserManager', () => {
|
||||
it('should NOT re-inject overlay when headless is true', async () => {
|
||||
const headlessConfig = makeFakeConfig({
|
||||
agents: {
|
||||
overrides: { browser_agent: { enabled: true } },
|
||||
overrides: { browser: { enabled: true } },
|
||||
browser: { headless: true },
|
||||
},
|
||||
});
|
||||
@@ -1001,7 +1001,7 @@ describe('BrowserManager', () => {
|
||||
mockConfig = makeFakeConfig({
|
||||
agents: {
|
||||
overrides: {
|
||||
browser_agent: {
|
||||
browser: {
|
||||
enabled: true,
|
||||
},
|
||||
},
|
||||
@@ -1098,7 +1098,7 @@ describe('BrowserManager', () => {
|
||||
vi.stubEnv('SANDBOX', 'sandbox-exec');
|
||||
const existingConfig = makeFakeConfig({
|
||||
agents: {
|
||||
overrides: { browser_agent: { enabled: true } },
|
||||
overrides: { browser: { enabled: true } },
|
||||
browser: { sessionMode: 'existing' },
|
||||
},
|
||||
});
|
||||
@@ -1127,7 +1127,7 @@ describe('BrowserManager', () => {
|
||||
.mockImplementation(() => {});
|
||||
const existingConfig = makeFakeConfig({
|
||||
agents: {
|
||||
overrides: { browser_agent: { enabled: true } },
|
||||
overrides: { browser: { enabled: true } },
|
||||
browser: { sessionMode: 'existing' },
|
||||
},
|
||||
});
|
||||
|
||||
@@ -61,7 +61,7 @@ describe('mcpToolWrapper Confirmation', () => {
|
||||
expect(details).toEqual(
|
||||
expect.objectContaining({
|
||||
type: 'mcp',
|
||||
serverName: 'browser_agent',
|
||||
serverName: 'browser',
|
||||
toolName: 'test_tool',
|
||||
}),
|
||||
);
|
||||
@@ -76,7 +76,7 @@ describe('mcpToolWrapper Confirmation', () => {
|
||||
expect(mockMessageBus.publish).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
type: MessageBusType.UPDATE_POLICY,
|
||||
mcpName: 'browser_agent',
|
||||
mcpName: 'browser',
|
||||
persist: false,
|
||||
}),
|
||||
);
|
||||
@@ -94,7 +94,7 @@ describe('mcpToolWrapper Confirmation', () => {
|
||||
);
|
||||
|
||||
expect(options).toEqual({
|
||||
mcpName: 'browser_agent',
|
||||
mcpName: 'browser',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1549,7 +1549,7 @@ describe('AgentRegistry', () => {
|
||||
const config = makeMockedConfig({
|
||||
agents: {
|
||||
overrides: {
|
||||
browser_agent: { enabled: true },
|
||||
browser: { enabled: true },
|
||||
},
|
||||
browser: {
|
||||
sessionMode: 'persistent',
|
||||
@@ -1559,7 +1559,7 @@ describe('AgentRegistry', () => {
|
||||
const registry = new TestableAgentRegistry(config);
|
||||
await registry.initialize();
|
||||
|
||||
expect(registry.getDefinition('browser_agent')).toBeUndefined();
|
||||
expect(registry.getDefinition('browser')).toBeUndefined();
|
||||
expect(feedbackSpy).toHaveBeenCalledWith(
|
||||
'info',
|
||||
expect.stringContaining('Browser agent disabled in container sandbox'),
|
||||
@@ -1572,7 +1572,7 @@ describe('AgentRegistry', () => {
|
||||
const config = makeMockedConfig({
|
||||
agents: {
|
||||
overrides: {
|
||||
browser_agent: { enabled: true },
|
||||
browser: { enabled: true },
|
||||
},
|
||||
browser: {
|
||||
sessionMode: 'existing',
|
||||
@@ -1582,7 +1582,7 @@ describe('AgentRegistry', () => {
|
||||
const registry = new TestableAgentRegistry(config);
|
||||
await registry.initialize();
|
||||
|
||||
expect(registry.getDefinition('browser_agent')).toBeDefined();
|
||||
expect(registry.getDefinition('browser')).toBeDefined();
|
||||
});
|
||||
|
||||
it('should register browser agent normally in seatbelt sandbox', async () => {
|
||||
@@ -1591,14 +1591,14 @@ describe('AgentRegistry', () => {
|
||||
const config = makeMockedConfig({
|
||||
agents: {
|
||||
overrides: {
|
||||
browser_agent: { enabled: true },
|
||||
browser: { enabled: true },
|
||||
},
|
||||
},
|
||||
});
|
||||
const registry = new TestableAgentRegistry(config);
|
||||
await registry.initialize();
|
||||
|
||||
expect(registry.getDefinition('browser_agent')).toBeDefined();
|
||||
expect(registry.getDefinition('browser')).toBeDefined();
|
||||
});
|
||||
|
||||
it('should register browser agent normally when not in sandbox', async () => {
|
||||
@@ -1607,14 +1607,14 @@ describe('AgentRegistry', () => {
|
||||
const config = makeMockedConfig({
|
||||
agents: {
|
||||
overrides: {
|
||||
browser_agent: { enabled: true },
|
||||
browser: { enabled: true },
|
||||
},
|
||||
},
|
||||
});
|
||||
const registry = new TestableAgentRegistry(config);
|
||||
await registry.initialize();
|
||||
|
||||
expect(registry.getDefinition('browser_agent')).toBeDefined();
|
||||
expect(registry.getDefinition('browser')).toBeDefined();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1505,7 +1505,7 @@ describe('Server Config (config.ts)', () => {
|
||||
...baseParams,
|
||||
agents: {
|
||||
overrides: {
|
||||
browser_agent: {
|
||||
browser: {
|
||||
enabled: true,
|
||||
modelConfig: { model: 'custom-model' },
|
||||
},
|
||||
@@ -1552,7 +1552,7 @@ describe('Server Config (config.ts)', () => {
|
||||
...baseParams,
|
||||
agents: {
|
||||
overrides: {
|
||||
browser_agent: {
|
||||
browser: {
|
||||
enabled: true,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -3385,7 +3385,7 @@ export class Config implements McpContext, AgentLoopContext {
|
||||
model?: string;
|
||||
customConfig: BrowserAgentCustomConfig;
|
||||
} {
|
||||
const override = this.getAgentOverride('browser_agent');
|
||||
const override = this.getAgentOverride('browser');
|
||||
const customConfig = this.getAgentsSettings()?.browser ?? {};
|
||||
return {
|
||||
enabled: override?.enabled ?? false,
|
||||
@@ -3591,9 +3591,15 @@ export class Config implements McpContext, AgentLoopContext {
|
||||
!this.isAgentsEnabled() ||
|
||||
agentsOverrides[definition.name]?.enabled === false
|
||||
) {
|
||||
process.stderr.write(
|
||||
`[Config] Skipping disabled subagent tool: ${definition.name}\n`,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
process.stderr.write(
|
||||
`[Config] Registering subagent tool: ${definition.name}\n`,
|
||||
);
|
||||
const tool = new SubagentTool(definition, this, this.messageBus);
|
||||
registry.registerTool(tool);
|
||||
} catch (e: unknown) {
|
||||
|
||||
Reference in New Issue
Block a user