browser-pilot 0.0.12 → 0.0.13

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.
package/README.md CHANGED
@@ -167,10 +167,10 @@ console.log(snapshot.interactiveElements);
167
167
 
168
168
  // Text representation for LLMs
169
169
  console.log(snapshot.text);
170
- // - main [ref=e1]
171
- // - heading "Welcome" [ref=e2]
172
- // - button "Get Started" [ref=e3]
173
- // - textbox [ref=e4] placeholder="Email"
170
+ // - main ref:e1
171
+ // - heading "Welcome" ref:e2
172
+ // - button "Get Started" ref:e3
173
+ // - textbox ref:e4 placeholder="Email"
174
174
  ```
175
175
 
176
176
  ### Ref-Based Selectors
@@ -179,7 +179,7 @@ After taking a snapshot, use element refs directly as selectors:
179
179
 
180
180
  ```typescript
181
181
  const snapshot = await page.snapshot();
182
- // Output shows: button "Submit" [ref=e4]
182
+ // Output shows: button "Submit" ref:e4
183
183
 
184
184
  // Click using the ref - no fragile CSS needed
185
185
  await page.click('ref:e4');
@@ -383,13 +383,19 @@ bp exec -s my-session '[
383
383
 
384
384
  # Get page state (note the refs in output)
385
385
  bp snapshot -s my-session --format text
386
- # Output: button "Submit" [ref=e4], textbox "Email" [ref=e5], ...
386
+ # Output: button "Submit" ref:e4, textbox "Email" ref:e5, ...
387
387
 
388
388
  # Use refs from snapshot for reliable targeting
389
389
  # Refs are cached per session+URL after snapshot
390
390
  bp exec -s my-session '{"action":"click","selector":"ref:e4"}'
391
391
  bp exec -s my-session '{"action":"fill","selector":"ref:e5","value":"test@example.com"}'
392
392
 
393
+ # Quick discovery commands
394
+ bp page -s my-session # URL, title, headings, forms, interactive controls
395
+ bp forms -s my-session # Structured form metadata only
396
+ bp targets -s my-session # Browser tabs with targetIds
397
+ bp connect --new-tab --url https://example.com --name fresh
398
+
393
399
  # Handle native dialogs (alert/confirm/prompt)
394
400
  bp exec --dialog accept '{"action":"click","selector":"#delete-btn"}'
395
401
 
@@ -423,7 +429,7 @@ The CLI is designed for AI agent tool calls. The recommended workflow:
423
429
  ```bash
424
430
  # Step 1: Get page state with refs
425
431
  bp snapshot --format text
426
- # Output shows: button "Add to Cart" [ref=e12], textbox "Search" [ref=e5]
432
+ # Output shows: button "Add to Cart" ref:e12, textbox "Search" ref:e5
427
433
 
428
434
  # Step 2: Use refs to interact (stable, no CSS guessing)
429
435
  bp exec '[
package/dist/actions.cjs CHANGED
@@ -638,6 +638,9 @@ var BatchExecutor = class {
638
638
  const snapshot = await this.page.snapshot();
639
639
  return { value: snapshot };
640
640
  }
641
+ case "forms": {
642
+ return { value: await this.page.forms() };
643
+ }
641
644
  case "screenshot": {
642
645
  const data = await this.page.screenshot({
643
646
  format: step.format,
@@ -657,6 +660,21 @@ var BatchExecutor = class {
657
660
  const text = await this.page.text(selector);
658
661
  return { text, selectorUsed: selector };
659
662
  }
663
+ case "newTab": {
664
+ const { targetId } = await this.page.cdpClient.send(
665
+ "Target.createTarget",
666
+ {
667
+ url: step.url ?? "about:blank"
668
+ },
669
+ null
670
+ );
671
+ return { value: { targetId } };
672
+ }
673
+ case "closeTab": {
674
+ const targetId = step.targetId ?? this.page.targetId;
675
+ await this.page.cdpClient.send("Target.closeTarget", { targetId }, null);
676
+ return { value: { targetId, closedCurrent: targetId === this.page.targetId } };
677
+ }
660
678
  case "switchFrame": {
661
679
  if (!step.selector) throw new Error("switchFrame requires selector");
662
680
  await this.page.switchToFrame(step.selector, { timeout, optional });
@@ -771,10 +789,15 @@ var BatchExecutor = class {
771
789
  snap: "snapshot",
772
790
  accessibility: "snapshot",
773
791
  a11y: "snapshot",
792
+ formslist: "forms",
774
793
  image: "screenshot",
775
794
  pic: "screenshot",
776
795
  frame: "switchFrame",
777
796
  iframe: "switchFrame",
797
+ newtab: "newTab",
798
+ opentab: "newTab",
799
+ createtab: "newTab",
800
+ closetab: "closeTab",
778
801
  assert_visible: "assertVisible",
779
802
  assert_exists: "assertExists",
780
803
  assert_text: "assertText",
@@ -788,7 +811,7 @@ var BatchExecutor = class {
788
811
  };
789
812
  const suggestion = aliases[action.toLowerCase()];
790
813
  const hint = suggestion ? ` Did you mean "${suggestion}"?` : "";
791
- const valid = "goto, click, fill, type, select, check, uncheck, submit, press, shortcut, focus, hover, scroll, wait, snapshot, screenshot, evaluate, text, switchFrame, switchToMain, assertVisible, assertExists, assertText, assertUrl, assertValue";
814
+ const valid = "goto, click, fill, type, select, check, uncheck, submit, press, shortcut, focus, hover, scroll, wait, snapshot, forms, screenshot, evaluate, text, newTab, closeTab, switchFrame, switchToMain, assertVisible, assertExists, assertText, assertUrl, assertValue";
792
815
  throw new Error(`Unknown action "${action}".${hint}
793
816
 
794
817
  Valid actions: ${valid}`);
@@ -859,6 +882,11 @@ var ACTION_ALIASES = {
859
882
  pic: "screenshot",
860
883
  frame: "switchFrame",
861
884
  iframe: "switchFrame",
885
+ formslist: "forms",
886
+ newtab: "newTab",
887
+ opentab: "newTab",
888
+ createtab: "newTab",
889
+ closetab: "closeTab",
862
890
  assert_visible: "assertVisible",
863
891
  assert_exists: "assertExists",
864
892
  assert_text: "assertText",
@@ -895,7 +923,8 @@ var PROPERTY_ALIASES = {
895
923
  button: "key",
896
924
  address: "url",
897
925
  page: "url",
898
- path: "url"
926
+ path: "url",
927
+ tabId: "targetId"
899
928
  };
900
929
  var ACTION_RULES = {
901
930
  goto: {
@@ -996,6 +1025,10 @@ var ACTION_RULES = {
996
1025
  fullPage: { type: "boolean" }
997
1026
  }
998
1027
  },
1028
+ forms: {
1029
+ required: {},
1030
+ optional: {}
1031
+ },
999
1032
  evaluate: {
1000
1033
  required: { value: { type: "string" } },
1001
1034
  optional: {}
@@ -1010,6 +1043,18 @@ var ACTION_RULES = {
1010
1043
  required: { selector: { type: "string|string[]" } },
1011
1044
  optional: {}
1012
1045
  },
1046
+ newTab: {
1047
+ required: {},
1048
+ optional: {
1049
+ url: { type: "string" }
1050
+ }
1051
+ },
1052
+ closeTab: {
1053
+ required: {},
1054
+ optional: {
1055
+ targetId: { type: "string" }
1056
+ }
1057
+ },
1013
1058
  switchToMain: {
1014
1059
  required: {},
1015
1060
  optional: {}
@@ -1052,6 +1097,7 @@ var KNOWN_STEP_FIELDS = /* @__PURE__ */ new Set([
1052
1097
  "selector",
1053
1098
  "url",
1054
1099
  "value",
1100
+ "targetId",
1055
1101
  "key",
1056
1102
  "combo",
1057
1103
  "modifiers",
@@ -1206,15 +1252,22 @@ function validateSteps(steps) {
1206
1252
  const rule = ACTION_RULES[action];
1207
1253
  for (const key of Object.keys(obj)) {
1208
1254
  if (key === "action") continue;
1209
- if (!KNOWN_STEP_FIELDS.has(key)) {
1210
- const suggestion = suggestProperty(key);
1211
- errors.push({
1212
- stepIndex: i,
1213
- field: key,
1214
- message: suggestion ? `unknown property "${key}". Did you mean "${suggestion}"?` : `unknown property "${key}".`,
1215
- suggestion: suggestion ? `Did you mean "${suggestion}"?` : void 0
1216
- });
1255
+ if (KNOWN_STEP_FIELDS.has(key)) continue;
1256
+ const canonical = PROPERTY_ALIASES[key];
1257
+ if (canonical) {
1258
+ if (!(canonical in obj)) {
1259
+ obj[canonical] = obj[key];
1260
+ }
1261
+ delete obj[key];
1262
+ continue;
1217
1263
  }
1264
+ const suggestion = suggestProperty(key);
1265
+ errors.push({
1266
+ stepIndex: i,
1267
+ field: key,
1268
+ message: suggestion ? `unknown property "${key}". Did you mean "${suggestion}"?` : `unknown property "${key}".`,
1269
+ suggestion: suggestion ? `Did you mean "${suggestion}"?` : void 0
1270
+ });
1218
1271
  }
1219
1272
  for (const [field, fieldRule] of Object.entries(rule.required)) {
1220
1273
  if (!(field in obj) || obj[field] === void 0) {
@@ -1,6 +1,6 @@
1
- import { y as Page, S as Step, B as BatchOptions, b as BatchResult } from './types-BOPu0OQZ.cjs';
2
- export { A as ActionType, af as FailureReason, c as StepResult } from './types-BOPu0OQZ.cjs';
3
- import './client-7Nqka5MV.cjs';
1
+ import { H as Page, S as Step, B as BatchOptions, b as BatchResult } from './types-BXMGFtnB.cjs';
2
+ export { A as ActionType, ai as FailureReason, c as StepResult } from './types-BXMGFtnB.cjs';
3
+ import './client-DRqxBdHv.cjs';
4
4
 
5
5
  /**
6
6
  * Batch action executor
package/dist/actions.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { y as Page, S as Step, B as BatchOptions, b as BatchResult } from './types-j23Iqo2L.js';
2
- export { A as ActionType, af as FailureReason, c as StepResult } from './types-j23Iqo2L.js';
3
- import './client-7Nqka5MV.js';
1
+ import { H as Page, S as Step, B as BatchOptions, b as BatchResult } from './types-CzgQjai9.js';
2
+ export { A as ActionType, ai as FailureReason, c as StepResult } from './types-CzgQjai9.js';
3
+ import './client-DRqxBdHv.js';
4
4
 
5
5
  /**
6
6
  * Batch action executor
package/dist/actions.mjs CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  BatchExecutor,
3
3
  addBatchToPage,
4
4
  validateSteps
5
- } from "./chunk-NLIARNEE.mjs";
5
+ } from "./chunk-A2ZRAEO3.mjs";
6
6
  import "./chunk-JXAUPHZM.mjs";
7
7
  export {
8
8
  BatchExecutor,