From 71da8e0719c50d9b11c918b032b9ed4d77aabf5b Mon Sep 17 00:00:00 2001 From: amankumarsingh77 Date: Mon, 4 May 2026 22:44:55 +0530 Subject: feat: parallel tool execution with automatic mutation serialization - Add lightweight async mutex (src/util/mutex.ts) for FIFO serialization - Add serialized?: boolean to BrowserToolDefinition - Wire mutex acquisition into registerBrowserTool execute wrapper - Expose mutationMutex() on BrowserClient - Mark all mutation tools (click, type, scroll, navigate, switch_tab, etc.) as serialized - Leave observation tools (screenshot, page_info, execute_js, http_get, etc.) unguarded - Update prompt and skill docs to reflect parallel-safe behavior - Fix scroll tool: add Page.bringToFront, explicit button:none/buttons:0/pointerType:mouse - Update .gitignore to ignore scripts/ and data/ folders --- src/registry.ts | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) (limited to 'src/registry.ts') diff --git a/src/registry.ts b/src/registry.ts index 5f9d7da..d9b7cea 100644 --- a/src/registry.ts +++ b/src/registry.ts @@ -16,31 +16,34 @@ import { dragAndDropTool } from "./domains/drag"; import { httpGetTool, getNetworkLogTool } from "./domains/network"; import { executeJsTool, runScriptTool } from "./domains/js"; +// Mutation tools that modify page / browser state are marked `serialized: true` +// so they run through a shared async mutex. Observation / read-only tools are +// left unmarked and can execute in parallel. const TOOLS: ReadonlyArray = [ - clickTool, - typeTool, - pressKeyTool, - dispatchKeyTool, - scrollTool, + { ...clickTool, serialized: true }, + { ...typeTool, serialized: true }, + { ...pressKeyTool, serialized: true }, + { ...dispatchKeyTool, serialized: true }, + { ...scrollTool, serialized: true }, pageInfoTool, waitTool, - waitForLoadTool, - handleDialogTool, + { ...waitForLoadTool, serialized: true }, + { ...handleDialogTool, serialized: true }, screenshotTool, - navigateTool, - openUrlsTool, - goBackTool, - goForwardTool, - reloadTool, + { ...navigateTool, serialized: true }, + { ...openUrlsTool, serialized: true }, + { ...goBackTool, serialized: true }, + { ...goForwardTool, serialized: true }, + { ...reloadTool, serialized: true }, listTabsTool, currentTabTool, - switchTabTool, - newTabTool, - uploadFileTool, - downloadTool, - printToPdfTool, - viewportResizeTool, - dragAndDropTool, + { ...switchTabTool, serialized: true }, + { ...newTabTool, serialized: true }, + { ...uploadFileTool, serialized: true }, + { ...downloadTool, serialized: true }, + { ...printToPdfTool, serialized: true }, + { ...viewportResizeTool, serialized: true }, + { ...dragAndDropTool, serialized: true }, httpGetTool, getNetworkLogTool, executeJsTool, -- cgit v1.2.3