Add Brave CDP automation, replace Oracle browser mode

Connects to user's running Brave via Chrome DevTools Protocol
to automate ChatGPT interaction. Uses puppeteer-core to open a
tab, send the prompt, wait for response, and extract the result.

No cookies, no separate profiles, no copy/paste. Just connects
to the browser where the user is already logged in.

One-time setup: relaunch Brave with --remote-debugging-port=9222

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Taylor Eernisse
2026-02-07 16:16:41 -05:00
parent d776a266a8
commit e7882b917b
4163 changed files with 782828 additions and 148 deletions

View File

@@ -0,0 +1,24 @@
/**
* Copyright 2025 Google LLC.
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import type { LoggerFn } from '../../../utils/log.js';
import type { CdpTarget } from '../cdp/CdpTarget.js';
import type { EventManager } from '../session/EventManager.js';
export declare class SpeculationProcessor {
#private;
constructor(eventManager: EventManager, logger: LoggerFn | undefined);
onCdpTargetCreated(cdpTarget: CdpTarget): void;
}

View File

@@ -0,0 +1,58 @@
/**
* Copyright 2025 Google LLC.
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { LogType } from '../../../utils/log.js';
export class SpeculationProcessor {
#eventManager;
#logger;
constructor(eventManager, logger) {
this.#eventManager = eventManager;
this.#logger = logger;
}
onCdpTargetCreated(cdpTarget) {
cdpTarget.cdpClient.on('Preload.prefetchStatusUpdated', (event) => {
let prefetchStatus;
switch (event.status) {
case 'Running':
prefetchStatus = "pending" /* Speculation.PreloadingStatus.Pending */;
break;
case 'Ready':
prefetchStatus = "ready" /* Speculation.PreloadingStatus.Ready */;
break;
case 'Success':
prefetchStatus = "success" /* Speculation.PreloadingStatus.Success */;
break;
case 'Failure':
prefetchStatus = "failure" /* Speculation.PreloadingStatus.Failure */;
break;
default:
// If status is not recognized, skip the event
this.#logger?.(LogType.debugWarn, `Unknown prefetch status: ${event.status}`);
return;
}
this.#eventManager.registerEvent({
type: 'event',
method: 'speculation.prefetchStatusUpdated',
params: {
context: event.initiatingFrameId,
url: event.prefetchUrl,
status: prefetchStatus,
},
}, cdpTarget.id);
});
}
}
//# sourceMappingURL=SpeculationProcessor.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"SpeculationProcessor.js","sourceRoot":"","sources":["../../../../../src/bidiMapper/modules/speculation/SpeculationProcessor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,EAAC,OAAO,EAAC,MAAM,uBAAuB,CAAC;AAI9C,MAAM,OAAO,oBAAoB;IAC/B,aAAa,CAAe;IACnB,OAAO,CAAuB;IAEvC,YAAY,YAA0B,EAAE,MAA4B;QAClE,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;QAClC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAED,kBAAkB,CAAC,SAAoB;QACrC,SAAS,CAAC,SAAS,CAAC,EAAE,CAAC,+BAA+B,EAAE,CAAC,KAAK,EAAE,EAAE;YAChE,IAAI,cAA4C,CAAC;YACjD,QAAQ,KAAK,CAAC,MAAM,EAAE,CAAC;gBACrB,KAAK,SAAS;oBACZ,cAAc,uDAAuC,CAAC;oBACtD,MAAM;gBACR,KAAK,OAAO;oBACV,cAAc,mDAAqC,CAAC;oBACpD,MAAM;gBACR,KAAK,SAAS;oBACZ,cAAc,uDAAuC,CAAC;oBACtD,MAAM;gBACR,KAAK,SAAS;oBACZ,cAAc,uDAAuC,CAAC;oBACtD,MAAM;gBACR;oBACE,8CAA8C;oBAC9C,IAAI,CAAC,OAAO,EAAE,CACZ,OAAO,CAAC,SAAS,EACjB,4BAA4B,KAAK,CAAC,MAAM,EAAE,CAC3C,CAAC;oBACF,OAAO;YACX,CAAC;YACD,IAAI,CAAC,aAAa,CAAC,aAAa,CAC9B;gBACE,IAAI,EAAE,OAAO;gBACb,MAAM,EAAE,mCAAmC;gBAC3C,MAAM,EAAE;oBACN,OAAO,EAAE,KAAK,CAAC,iBAAiB;oBAChC,GAAG,EAAE,KAAK,CAAC,WAAW;oBACtB,MAAM,EAAE,cAAc;iBACvB;aACF,EACD,SAAS,CAAC,EAAE,CACb,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}