From 5cfa7ccc8f4082db111bc0186c5fa3d44b767ad3 Mon Sep 17 00:00:00 2001 From: amankumarsingh77 Date: Tue, 28 Jul 2026 00:01:32 +0530 Subject: refactor(tools): declare concurrency in the tool definition serialized: true was applied in registry.ts, away from the tools it describes. Now a required concurrency field on each definition, with a test pinning the serialized set so the classes cannot drift. The lock check defaults to taking the mutex for any class that is not explicitly "parallel", so a definition that bypasses defineBrowserTool at runtime fails safe rather than racing on shared CDP state. The test script gains --conditions=import: pi-coding-agent publishes no "require" condition, so importing any tool definition from a CJS-loaded test could not resolve it. Co-Authored-By: Claude Opus 5 (1M context) --- src/domains/history.ts | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/domains/history.ts') diff --git a/src/domains/history.ts b/src/domains/history.ts index 96036ba..fbab376 100644 --- a/src/domains/history.ts +++ b/src/domains/history.ts @@ -19,6 +19,7 @@ export const goBackTool = defineBrowserTool({ promptSnippet: "Go back one page", promptGuidelines: ["Use to return to the previous page after navigating."], parameters: Type.Object({}), + concurrency: "serialized", async handler(_a, { client }): Promise> { const h = await fetchHistory(client); if (!h.success) return h; @@ -38,6 +39,7 @@ export const goForwardTool = defineBrowserTool({ promptSnippet: "Go forward one page", promptGuidelines: ["Use to undo a browser_go_back."], parameters: Type.Object({}), + concurrency: "serialized", async handler(_a, { client }): Promise> { const h = await fetchHistory(client); if (!h.success) return h; @@ -57,6 +59,7 @@ export const reloadTool = defineBrowserTool({ promptSnippet: "Reload the page", promptGuidelines: ["Use to refresh the page, e.g. after server-side changes."], parameters: Type.Object({}), + concurrency: "serialized", async handler(_a, { client }): Promise> { const r = await client.session().call("Page.reload"); if (!r.success) return err({ kind: "cdp_error", message: r.error.message }); -- cgit v1.2.3