@proagentstore/cli 0.3.7 → 0.3.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -63,6 +63,11 @@ async function typeRobustly(loc, text) {
63
63
  */
64
64
  export async function performBrowserAction(page, action, clickRobustly, resumeFile) {
65
65
  const locate = () => {
66
+ // Prefer the stable snapshot ref (aria-ref) — points at the exact element, so two
67
+ // fields sharing a label (e.g. a phone "Country" code and an address "Country")
68
+ // are never confused. Fall back to role+name for older snapshots.
69
+ if (action.ref)
70
+ return page.locator(`aria-ref=${action.ref}`);
66
71
  const role = action.role;
67
72
  let loc = role
68
73
  ? page.getByRole(role, action.name ? { name: action.name } : undefined)
@@ -267,12 +272,17 @@ export async function performBrowserAction(page, action, clickRobustly, resumeFi
267
272
  export async function inspectField(page, action) {
268
273
  if (action.action !== "type" && action.action !== "select" && action.action !== "check")
269
274
  return "";
270
- if (!action.name)
275
+ if (!action.name && !action.ref)
271
276
  return "";
272
277
  try {
273
278
  const role = action.role;
274
- let loc = role ? page.getByRole(role, { name: action.name }) : page.getByText(action.name, { exact: false });
275
- loc = typeof action.nth === "number" ? loc.nth(action.nth) : loc.first();
279
+ let loc = action.ref
280
+ ? page.locator(`aria-ref=${action.ref}`)
281
+ : role
282
+ ? page.getByRole(role, action.name ? { name: action.name } : undefined)
283
+ : page.getByText(action.name ?? "", { exact: false });
284
+ if (!action.ref)
285
+ loc = typeof action.nth === "number" ? loc.nth(action.nth) : loc.first();
276
286
  const el = await loc.elementHandle({ timeout: 1_500 }).catch(() => null);
277
287
  if (!el)
278
288
  return "";
@@ -620,7 +620,15 @@ export class LocalRunner {
620
620
  }
621
621
  const page = await this.getActivePage();
622
622
  await page.waitForLoadState("domcontentloaded", { timeout: 5_000 }).catch(() => undefined);
623
- const full = await page.locator("body").ariaSnapshot().catch(() => "");
623
+ // Match what a direct Claude + Playwright-MCP agent sees: `ariaSnapshot({mode:"ai"})`
624
+ // carries element STATE (disabled/checked/expanded/selected/value) and a stable
625
+ // [ref=eNN] on each interactive element, so the brain targets them unambiguously via
626
+ // the aria-ref selector (instead of role+name, which collides when two fields share a
627
+ // label). This is exactly the call Playwright's own MCP uses. Falls back to the plain
628
+ // aria snapshot if the option is ever unavailable.
629
+ const aria = page;
630
+ const full = (await aria.ariaSnapshot({ mode: "ai" }).catch(() => "")) ||
631
+ (await page.locator("body").ariaSnapshot().catch(() => ""));
624
632
  const MAX = 16_000;
625
633
  const snapshot = full.length > MAX ? `${full.slice(0, MAX)}\n… [snapshot truncated]` : full;
626
634
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proagentstore/cli",
3
- "version": "0.3.7",
3
+ "version": "0.3.8",
4
4
  "description": "CLI for creating, publishing, and running ProAgentStore agents",
5
5
  "license": "MIT",
6
6
  "type": "module",