Feat/browser privacy consent (#21119)

This commit is contained in:
Aditya Bijalwan
2026-03-19 01:03:24 +05:30
committed by GitHub
parent 0082e1ec97
commit b6d5374fb7
4 changed files with 271 additions and 0 deletions

View File

@@ -23,6 +23,7 @@ import type { Tool as McpTool } from '@modelcontextprotocol/sdk/types.js';
import { debugLogger } from '../../utils/debugLogger.js';
import type { Config } from '../../config/config.js';
import { Storage } from '../../config/storage.js';
import { getBrowserConsentIfNeeded } from '../../utils/browserConsent.js';
import { injectInputBlocker } from './inputBlocker.js';
import * as path from 'node:path';
import * as fs from 'node:fs';
@@ -260,6 +261,16 @@ export class BrowserManager {
if (this.rawMcpClient) {
return;
}
// Request browser consent if needed (first-run privacy notice)
const consentGranted = await getBrowserConsentIfNeeded();
if (!consentGranted) {
throw new Error(
'Browser agent requires user consent to proceed. ' +
'Please re-run and accept the privacy notice.',
);
}
await this.connectMcp();
}
@@ -352,6 +363,11 @@ export class BrowserManager {
mcpArgs.push('--userDataDir', defaultProfilePath);
}
// Respect the user's privacy.usageStatisticsEnabled setting
if (!this.config.getUsageStatisticsEnabled()) {
mcpArgs.push('--no-usage-statistics', '--no-performance-crux');
}
if (
browserConfig.customConfig.allowedDomains &&
browserConfig.customConfig.allowedDomains.length > 0