aboutsummaryrefslogtreecommitdiff
path: root/src/domains/files.ts
diff options
context:
space:
mode:
authoramankumarsingh77 <amankumarsingh7702@gmail.com>2026-07-28 00:01:32 +0530
committerAman Kumar <145339995+amankumarsingh77@users.noreply.github.com>2026-08-02 19:12:46 +0530
commit5cfa7ccc8f4082db111bc0186c5fa3d44b767ad3 (patch)
tree05720833665398725d960aad67496ff6159540eb /src/domains/files.ts
parent753c2ad615fa9827e168be256e1a7c7384605855 (diff)
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) <noreply@anthropic.com>
Diffstat (limited to 'src/domains/files.ts')
-rw-r--r--src/domains/files.ts3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/domains/files.ts b/src/domains/files.ts
index cf9393e..4e0195d 100644
--- a/src/domains/files.ts
+++ b/src/domains/files.ts
@@ -109,6 +109,7 @@ export const uploadFileTool = defineBrowserTool({
"File path must be absolute and readable.",
],
parameters: UploadArgs,
+ concurrency: "serialized",
async handler(args, { client }): Promise<Result<ToolOk, ToolErr>> {
const readable = await verifyReadable(args.filePath);
if (!readable.success) return readable;
@@ -160,6 +161,7 @@ export const downloadTool = defineBrowserTool({
"Affects all subsequent downloads on this browser.",
],
parameters: DownloadArgs,
+ concurrency: "serialized",
async handler(args, { client }): Promise<Result<ToolOk, ToolErr>> {
try {
await mkdir(args.downloadPath, { recursive: true });
@@ -205,6 +207,7 @@ export const printToPdfTool = defineBrowserTool({
promptSnippet: "Print the current page to PDF",
promptGuidelines: ["Default output path is in tmpdir; pass outputPath to control."],
parameters: PrintPdfArgs,
+ concurrency: "serialized",
async handler(args, { client }): Promise<Result<ToolOk, ToolErr>> {
const r = await client.session().call("Page.printToPDF", {
printBackground: true,