aboutsummaryrefslogtreecommitdiff
path: root/src/domains/forms.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/forms.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/forms.ts')
-rw-r--r--src/domains/forms.ts4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/domains/forms.ts b/src/domains/forms.ts
index e38af9a..ed64a74 100644
--- a/src/domains/forms.ts
+++ b/src/domains/forms.ts
@@ -231,6 +231,7 @@ export const fillTool = defineBrowserTool({
"If a ref no longer resolves, re-run browser_snapshot to get fresh refs.",
],
parameters: FillArgs,
+ concurrency: "serialized",
async handler(args, { client }): Promise<Result<ToolOk, ToolErr>> {
const r = await resolveAndCall(client, args.ref, FILL_FN, [args.value]);
if (!r.success) return r;
@@ -278,6 +279,7 @@ export const fillFormTool = defineBrowserTool({
"Re-run browser_snapshot afterwards to verify the form state if needed.",
],
parameters: FillFormArgs,
+ concurrency: "serialized",
async handler(args, { client }): Promise<Result<ToolOk, ToolErr>> {
const results: Array<Readonly<Record<string, unknown>>> = [];
let okCount = 0;
@@ -323,6 +325,7 @@ export const selectOptionTool = defineBrowserTool({
"Use this for native <select> elements — clicking coordinates does not work for OS dropdowns.",
],
parameters: SelectOptionArgs,
+ concurrency: "serialized",
async handler(args, { client }): Promise<Result<ToolOk, ToolErr>> {
if (args.value === undefined && args.label === undefined) {
return err({ kind: "invalid_state", message: "Provide value or label to select an option." });
@@ -356,6 +359,7 @@ export const setCheckedTool = defineBrowserTool({
"For radios, set checked:true on the option you want; the group deselects the others.",
],
parameters: SetCheckedArgs,
+ concurrency: "serialized",
async handler(args, { client }): Promise<Result<ToolOk, ToolErr>> {
const r = await resolveAndCall(client, args.ref, CHECK_FN, [args.checked]);
if (!r.success) return r;