browser-debugger-cli 0.12.0 → 0.13.0

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.
Files changed (180) hide show
  1. package/.claude/skills/bdg/SKILL.md +4 -4
  2. package/README.md +1 -0
  3. package/dist/commands/cdp.d.ts +22 -1
  4. package/dist/commands/cdp.js +100 -43
  5. package/dist/commands/console.d.ts +12 -0
  6. package/dist/commands/console.js +62 -12
  7. package/dist/commands/dom/DomElementResolver.d.ts +3 -1
  8. package/dist/commands/dom/DomElementResolver.js +10 -3
  9. package/dist/commands/dom/a11y.js +3 -2
  10. package/dist/commands/dom/eval.d.ts +3 -2
  11. package/dist/commands/dom/eval.js +11 -5
  12. package/dist/commands/dom/form.js +10 -9
  13. package/dist/commands/dom/formInteraction.js +8 -7
  14. package/dist/commands/dom/get.js +8 -8
  15. package/dist/commands/dom/helpers/index.d.ts +1 -1
  16. package/dist/commands/dom/helpers/index.js +1 -1
  17. package/dist/commands/dom/helpers/query.d.ts +27 -3
  18. package/dist/commands/dom/helpers/query.js +152 -64
  19. package/dist/commands/dom/helpers/screenshot.js +13 -13
  20. package/dist/commands/dom/index.js +4 -2
  21. package/dist/commands/dom/query.d.ts +19 -2
  22. package/dist/commands/dom/query.js +37 -6
  23. package/dist/commands/dom/screenshot.js +2 -1
  24. package/dist/commands/dom/semanticUtils.d.ts +3 -2
  25. package/dist/commands/dom/semanticUtils.js +40 -9
  26. package/dist/commands/helpJson.d.ts +82 -19
  27. package/dist/commands/helpJson.js +111 -40
  28. package/dist/commands/helpTopic.d.ts +16 -1
  29. package/dist/commands/helpTopic.js +59 -1
  30. package/dist/commands/installSkill.d.ts +15 -5
  31. package/dist/commands/installSkill.js +86 -16
  32. package/dist/commands/network/list.js +22 -12
  33. package/dist/commands/optionBehaviors.js +33 -11
  34. package/dist/commands/shared/daemonErrorHandler.d.ts +5 -2
  35. package/dist/commands/shared/daemonErrorHandler.js +20 -9
  36. package/dist/commands/shared/dataFetcher.d.ts +12 -4
  37. package/dist/commands/shared/dataFetcher.js +12 -4
  38. package/dist/commands/shared/followMode.d.ts +9 -1
  39. package/dist/commands/shared/followMode.js +22 -4
  40. package/dist/commands/shared/optionTypes.d.ts +4 -1
  41. package/dist/commands/shared/outputFile.js +6 -1
  42. package/dist/commands/start.d.ts +7 -5
  43. package/dist/commands/start.js +65 -21
  44. package/dist/commands/stop.d.ts +11 -0
  45. package/dist/commands/stop.js +24 -1
  46. package/dist/commands.js +1 -1
  47. package/dist/connection/cdp.d.ts +7 -0
  48. package/dist/connection/cdp.js +9 -0
  49. package/dist/connection/launcher.js +3 -2
  50. package/dist/daemon/SessionController.js +6 -1
  51. package/dist/daemon/launcher.d.ts +3 -2
  52. package/dist/daemon/launcher.js +47 -3
  53. package/dist/daemon/session/Session.d.ts +4 -1
  54. package/dist/daemon/session/Session.js +33 -2
  55. package/dist/daemon/session/TelemetryStore.d.ts +8 -1
  56. package/dist/daemon/session/TelemetryStore.js +13 -1
  57. package/dist/daemon/session/commandRegistry.js +29 -13
  58. package/dist/daemon/session/interactions.d.ts +2 -1
  59. package/dist/daemon/session/interactions.js +13 -1
  60. package/dist/daemon/session/plugins.js +16 -2
  61. package/dist/daemon/session/teardown.js +1 -1
  62. package/dist/daemon.js +1622 -748
  63. package/dist/errors/messages.d.ts +54 -11
  64. package/dist/errors/messages.js +109 -22
  65. package/dist/index.js +13733 -8796
  66. package/dist/ipc/client.d.ts +18 -2
  67. package/dist/ipc/client.js +26 -5
  68. package/dist/ipc/protocol/auditTypes.d.ts +8 -2
  69. package/dist/ipc/protocol/commands.d.ts +12 -0
  70. package/dist/ipc/protocol/domTypes.d.ts +12 -0
  71. package/dist/ipc/protocol/inspectTypes.d.ts +2 -0
  72. package/dist/ipc/session/types.d.ts +2 -0
  73. package/dist/runtime/dom/actionEffects.d.ts +5 -1
  74. package/dist/runtime/dom/actionEffects.js +26 -14
  75. package/dist/runtime/dom/audit.js +3 -2
  76. package/dist/runtime/dom/auditModel.js +6 -1
  77. package/dist/runtime/dom/auditScripts.d.ts +9 -3
  78. package/dist/runtime/dom/auditScripts.js +41 -5
  79. package/dist/runtime/dom/elementGeometry.d.ts +10 -3
  80. package/dist/runtime/dom/elementGeometry.js +27 -4
  81. package/dist/runtime/dom/elementInfo.d.ts +74 -18
  82. package/dist/runtime/dom/elementInfo.js +187 -40
  83. package/dist/runtime/dom/evalHelpers.d.ts +12 -2
  84. package/dist/runtime/dom/evalHelpers.js +67 -7
  85. package/dist/runtime/dom/formDiscovery.d.ts +6 -2
  86. package/dist/runtime/dom/formDiscovery.js +20 -3
  87. package/dist/runtime/dom/formFillHelpers/fill.js +7 -11
  88. package/dist/runtime/dom/formFillHelpers/pressKey.js +2 -2
  89. package/dist/runtime/dom/formFillHelpers/shared.d.ts +16 -10
  90. package/dist/runtime/dom/formFillHelpers/shared.js +19 -52
  91. package/dist/runtime/dom/formSubmitHelpers.js +4 -3
  92. package/dist/runtime/dom/frameLayout.js +1 -0
  93. package/dist/runtime/dom/inspect.js +5 -6
  94. package/dist/runtime/dom/inspectAllStyles.js +1 -0
  95. package/dist/runtime/dom/inspectHints.d.ts +1 -1
  96. package/dist/runtime/dom/inspectModel.d.ts +2 -1
  97. package/dist/runtime/dom/inspectModel.js +7 -3
  98. package/dist/runtime/dom/inspectPaintModel.d.ts +2 -0
  99. package/dist/runtime/dom/inspectPaintModel.js +3 -1
  100. package/dist/runtime/dom/inspectScripts.d.ts +29 -2
  101. package/dist/runtime/dom/inspectScripts.js +49 -10
  102. package/dist/runtime/dom/layout.js +9 -7
  103. package/dist/runtime/dom/reactEventHelpers.d.ts +14 -4
  104. package/dist/runtime/dom/reactEventHelpers.js +63 -27
  105. package/dist/runtime/dom/targetNode.d.ts +18 -5
  106. package/dist/runtime/dom/targetNode.js +268 -8
  107. package/dist/runtime/dom/wait.js +2 -1
  108. package/dist/runtime/page/bdgWorld.d.ts +57 -0
  109. package/dist/runtime/page/bdgWorld.js +180 -0
  110. package/dist/runtime/page/replacedBuiltins.d.ts +28 -0
  111. package/dist/runtime/page/replacedBuiltins.js +136 -0
  112. package/dist/session/QueryCacheManager.d.ts +4 -1
  113. package/dist/session/QueryCacheManager.js +5 -2
  114. package/dist/session/chrome.d.ts +4 -1
  115. package/dist/session/chrome.js +7 -1
  116. package/dist/session/cleanup/staleSession.d.ts +21 -4
  117. package/dist/session/cleanup/staleSession.js +79 -9
  118. package/dist/session/cleanup/userCommands.d.ts +4 -1
  119. package/dist/session/cleanup/userCommands.js +10 -5
  120. package/dist/session/daemonSocket.d.ts +10 -0
  121. package/dist/session/daemonSocket.js +22 -0
  122. package/dist/session/lastSession.d.ts +6 -3
  123. package/dist/session/lastSession.js +11 -5
  124. package/dist/session/paths.d.ts +3 -1
  125. package/dist/session/paths.js +5 -5
  126. package/dist/session/portClaims.js +4 -3
  127. package/dist/session/sessionList.d.ts +13 -5
  128. package/dist/session/sessionList.js +31 -7
  129. package/dist/telemetry/a11y.js +2 -2
  130. package/dist/telemetry/console.d.ts +2 -1
  131. package/dist/telemetry/console.js +30 -21
  132. package/dist/telemetry/pageCrash.d.ts +26 -0
  133. package/dist/telemetry/pageCrash.js +53 -0
  134. package/dist/types.d.ts +16 -0
  135. package/dist/ui/formatters/audit.js +14 -5
  136. package/dist/ui/formatters/cdp.d.ts +138 -0
  137. package/dist/ui/formatters/cdp.js +131 -0
  138. package/dist/ui/formatters/console/chronological.js +3 -1
  139. package/dist/ui/formatters/console/follow.d.ts +2 -1
  140. package/dist/ui/formatters/console/follow.js +2 -2
  141. package/dist/ui/formatters/console/json.d.ts +2 -2
  142. package/dist/ui/formatters/console/json.js +11 -5
  143. package/dist/ui/formatters/console/shared.d.ts +30 -0
  144. package/dist/ui/formatters/console/shared.js +16 -0
  145. package/dist/ui/formatters/console/summarize.d.ts +9 -2
  146. package/dist/ui/formatters/console/summarize.js +40 -9
  147. package/dist/ui/formatters/console.d.ts +2 -1
  148. package/dist/ui/formatters/console.js +7 -5
  149. package/dist/ui/formatters/details.js +3 -1
  150. package/dist/ui/formatters/dom.d.ts +1 -1
  151. package/dist/ui/formatters/dom.js +5 -6
  152. package/dist/ui/formatters/helpFormatters.js +1 -1
  153. package/dist/ui/formatters/inspect.js +9 -3
  154. package/dist/ui/formatters/installSkill.d.ts +9 -1
  155. package/dist/ui/formatters/installSkill.js +32 -6
  156. package/dist/ui/formatters/layout.js +2 -1
  157. package/dist/ui/formatters/networkList.d.ts +1 -1
  158. package/dist/ui/formatters/networkList.js +1 -2
  159. package/dist/ui/formatters/preview.d.ts +2 -0
  160. package/dist/ui/formatters/preview.js +17 -7
  161. package/dist/ui/formatters/sessions.d.ts +2 -2
  162. package/dist/ui/formatters/sessions.js +9 -2
  163. package/dist/ui/logging/logger.d.ts +1 -1
  164. package/dist/ui/messages/commands.d.ts +124 -4
  165. package/dist/ui/messages/commands.js +162 -7
  166. package/dist/ui/messages/consoleMessages.d.ts +24 -0
  167. package/dist/ui/messages/consoleMessages.js +32 -0
  168. package/dist/ui/messages/preview.d.ts +6 -0
  169. package/dist/ui/messages/preview.js +9 -1
  170. package/dist/ui/messages/session.d.ts +13 -2
  171. package/dist/ui/messages/session.js +22 -3
  172. package/dist/utils/directories.d.ts +34 -0
  173. package/dist/utils/directories.js +88 -0
  174. package/dist/utils/display.d.ts +16 -0
  175. package/dist/utils/display.js +42 -0
  176. package/dist/utils/exitCodes.d.ts +1 -0
  177. package/dist/utils/exitCodes.js +6 -0
  178. package/dist/utils/process.d.ts +12 -0
  179. package/dist/utils/process.js +25 -0
  180. package/package.json +1 -1
@@ -258,6 +258,21 @@ export declare function invalidSelectorFilterError(selector: string, filter: str
258
258
  * @param closest - Most similar existing command path, if any
259
259
  */
260
260
  export declare function unknownHelpTopicError(topic: string, closest?: string): ErrorWithSuggestion;
261
+ /**
262
+ * Suggestion for a command-line usage error (missing argument, invalid value,
263
+ * unknown option without a close match).
264
+ *
265
+ * @param path - Command path, e.g. "bdg dom query"
266
+ */
267
+ export declare function usageHelpSuggestion(path: string): string;
268
+ /**
269
+ * A command group was run without one of its subcommands.
270
+ */
271
+ export declare function missingSubcommandMessage(): string;
272
+ /**
273
+ * `bdg cdp --search` with an empty or blank query (which would match every method).
274
+ */
275
+ export declare function emptyCdpSearchError(): ErrorWithSuggestion;
261
276
  /**
262
277
  * Chrome rejected a CDP method or its parameters.
263
278
  *
@@ -442,15 +457,22 @@ export declare function conflictingTargetError(option: string, positional: strin
442
457
  *
443
458
  * @param first - First option
444
459
  * @param second - Option it conflicts with
445
- * @returns Message
460
+ * @returns Message and suggestion
446
461
  */
447
- export declare function conflictingOptionsMessage(first: string, second: string): string;
462
+ export declare function conflictingOptionsError(first: string, second: string): ErrorWithSuggestion;
448
463
  /**
449
464
  * A Chrome flag bdg cannot pass on.
450
465
  *
451
466
  * @param flag - The flag
452
467
  */
453
468
  export declare function invalidChromeFlagError(flag: string): ErrorWithSuggestion;
469
+ /**
470
+ * A page command on a page whose renderer crashed.
471
+ *
472
+ * @param crashedAt - When it crashed (epoch ms)
473
+ * @returns Message and the way back
474
+ */
475
+ export declare function pageCrashedError(crashedAt: number): ErrorWithSuggestion;
454
476
  /**
455
477
  * The session (its browser or daemon) went away while a command was running.
456
478
  */
@@ -460,9 +482,9 @@ export declare function sessionEndedDuringCommandError(): ErrorWithSuggestion;
460
482
  *
461
483
  * @param option - Option given
462
484
  * @param required - Option it needs
463
- * @returns Message
485
+ * @returns Message and suggestion
464
486
  */
465
- export declare function optionRequiresMessage(option: string, required: string): string;
487
+ export declare function optionRequiresError(option: string, required: string): ErrorWithSuggestion;
466
488
  /**
467
489
  * `bdg page navigate javascript:…`: scripts run with dom eval.
468
490
  */
@@ -556,9 +578,10 @@ export declare function staleNodeError(index?: number, source?: IndexSource): Er
556
578
  *
557
579
  * @param source - The index and the list it refers to
558
580
  * @param count - Number of cached results
581
+ * @param total - Matches the query found, when more than it cached (`dom query` caches the first 1000)
559
582
  * @returns Message and suggestion
560
583
  */
561
- export declare function cachedIndexOutOfRangeError(source: IndexSource, count: number): ErrorWithSuggestion;
584
+ export declare function cachedIndexOutOfRangeError(source: IndexSource, count: number, total?: number): ErrorWithSuggestion;
562
585
  /**
563
586
  * Note for a form command (fill, submit) whose index refers to results of
564
587
  * another command and hit an element it cannot act on.
@@ -785,14 +808,32 @@ export declare const FILL_REFUSALS: {
785
808
  readonly suggestion: "Only input, textarea, select, and contenteditable elements can be filled";
786
809
  };
787
810
  };
788
- /**
789
- * Clickable element not found.
790
- */
791
- export declare function clickableElementNotFoundError(selector: string): ErrorWithSuggestion;
792
811
  /**
793
812
  * Click target disappeared between locating and clicking it.
794
813
  */
795
814
  export declare function clickTargetDetachedError(selector: string): ErrorWithSuggestion;
815
+ /**
816
+ * An action's page script threw (on a page whose built-ins all look like the
817
+ * browser's).
818
+ *
819
+ * @param action - The action, e.g. `fill`
820
+ * @param exception - What the script threw, e.g. `TypeError: x is not a function`
821
+ * @param selector - Selector the action was for
822
+ * @returns Error naming the exception
823
+ */
824
+ export declare function actionScriptFailedError(action: string, exception: string, selector: string): ErrorWithSuggestion;
825
+ /**
826
+ * An action's page script threw on a page that replaced built-ins it uses
827
+ * (anti-bot scripts make `getBoundingClientRect`, `focus` or
828
+ * `dispatchEvent` throw; old libraries such as MooTools 1.2 replace
829
+ * `Event`). All replaced built-ins are named.
830
+ *
831
+ * @param action - The action, e.g. `fill`
832
+ * @param exception - What the script threw, e.g. `Error: anti-bot: focus`
833
+ * @param replaced - Dotted names of the replaced built-ins
834
+ * @returns Error naming the replaced built-ins and the exception
835
+ */
836
+ export declare function actionBrokenByPageError(action: string, exception: string, replaced: readonly string[]): ErrorWithSuggestion;
796
837
  /**
797
838
  * A pointer action refused under `--strict` because a real mouse could not
798
839
  * reach the element (covered, hidden, zero-size, pointer-events: none).
@@ -999,11 +1040,13 @@ export declare function skillSourceMissingError(source: string): ErrorWithSugges
999
1040
  /**
1000
1041
  * The skill could not be written to an agent's skill directory.
1001
1042
  *
1002
- * @param path - Destination SKILL.md
1043
+ * @param path - File that could not be written
1003
1044
  * @param reason - The file system error
1045
+ * @param pathIsFile - Whether a part of the path is a file (ENOTDIR, EEXIST)
1046
+ * @param otherTargetFlag - Flag installing for the other agent only, when both were picked
1004
1047
  * @returns Message and suggestion
1005
1048
  */
1006
- export declare function skillWriteFailedError(path: string, reason: string): ErrorWithSuggestion;
1049
+ export declare function skillWriteFailedError(path: string, reason: string, pathIsFile: boolean, otherTargetFlag?: string): ErrorWithSuggestion;
1007
1050
  /**
1008
1051
  * `bdg peek --interval` without `--follow`.
1009
1052
  *
@@ -370,6 +370,30 @@ export function unknownHelpTopicError(topic, closest) {
370
370
  : `Run "bdg ${parent ? `${parent} ` : ''}--help" for commands`,
371
371
  };
372
372
  }
373
+ /**
374
+ * Suggestion for a command-line usage error (missing argument, invalid value,
375
+ * unknown option without a close match).
376
+ *
377
+ * @param path - Command path, e.g. "bdg dom query"
378
+ */
379
+ export function usageHelpSuggestion(path) {
380
+ return `Run "${path} --help" for usage`;
381
+ }
382
+ /**
383
+ * A command group was run without one of its subcommands.
384
+ */
385
+ export function missingSubcommandMessage() {
386
+ return 'Missing subcommand';
387
+ }
388
+ /**
389
+ * `bdg cdp --search` with an empty or blank query (which would match every method).
390
+ */
391
+ export function emptyCdpSearchError() {
392
+ return {
393
+ message: 'Empty search query',
394
+ suggestion: 'Search for a keyword, e.g. bdg cdp --search cookie; list domains: bdg cdp --list',
395
+ };
396
+ }
373
397
  /**
374
398
  * Chrome rejected a CDP method or its parameters.
375
399
  *
@@ -687,10 +711,13 @@ export function conflictingTargetError(option, positional) {
687
711
  *
688
712
  * @param first - First option
689
713
  * @param second - Option it conflicts with
690
- * @returns Message
714
+ * @returns Message and suggestion
691
715
  */
692
- export function conflictingOptionsMessage(first, second) {
693
- return `${first} cannot be combined with ${second}; use one of them`;
716
+ export function conflictingOptionsError(first, second) {
717
+ return {
718
+ message: `${first} cannot be combined with ${second}`,
719
+ suggestion: `Use one of them: drop ${first} or ${second}`,
720
+ };
694
721
  }
695
722
  /**
696
723
  * A Chrome flag bdg cannot pass on.
@@ -708,6 +735,18 @@ export function invalidChromeFlagError(flag) {
708
735
  suggestion: 'Give Chrome flags as one quoted value: --chrome-flags="--lang=pl --disable-gpu"',
709
736
  };
710
737
  }
738
+ /**
739
+ * A page command on a page whose renderer crashed.
740
+ *
741
+ * @param crashedAt - When it crashed (epoch ms)
742
+ * @returns Message and the way back
743
+ */
744
+ export function pageCrashedError(crashedAt) {
745
+ return {
746
+ message: `The page crashed at ${new Date(crashedAt).toLocaleTimeString()} (its renderer is gone), so page commands cannot run`,
747
+ suggestion: `Load it again with: ${sessionCommand('bdg page reload')} (or start a new session: ${sessionCommand('bdg <url>')})`,
748
+ };
749
+ }
711
750
  /**
712
751
  * The session (its browser or daemon) went away while a command was running.
713
752
  */
@@ -722,10 +761,13 @@ export function sessionEndedDuringCommandError() {
722
761
  *
723
762
  * @param option - Option given
724
763
  * @param required - Option it needs
725
- * @returns Message
764
+ * @returns Message and suggestion
726
765
  */
727
- export function optionRequiresMessage(option, required) {
728
- return `${option} only works with ${required}; add ${required} or drop ${option}`;
766
+ export function optionRequiresError(option, required) {
767
+ return {
768
+ message: `${option} only works with ${required}`,
769
+ suggestion: `Add ${required}, or drop ${option}`,
770
+ };
729
771
  }
730
772
  /**
731
773
  * `bdg page navigate javascript:…`: scripts run with dom eval.
@@ -935,15 +977,24 @@ export function staleNodeError(index, source) {
935
977
  *
936
978
  * @param source - The index and the list it refers to
937
979
  * @param count - Number of cached results
980
+ * @param total - Matches the query found, when more than it cached (`dom query` caches the first 1000)
938
981
  * @returns Message and suggestion
939
982
  */
940
- export function cachedIndexOutOfRangeError(source, count) {
941
- const results = count === 1 ? '1 result' : `${count} results`;
983
+ export function cachedIndexOutOfRangeError(source, count, total) {
984
+ if (total !== undefined && total > count && source.index < total) {
985
+ return {
986
+ message: `Index ${source.index} is past the ${count} matches of ${cachedListText(source)} that can be used by index (${total} in all)`,
987
+ suggestion: `Re-run it with --limit ${source.index + 1} (or --limit 0) to index that many`,
988
+ };
989
+ }
990
+ const all = total !== undefined && total > count ? total : count;
991
+ const results = all === 1 ? '1 result' : `${all} results`;
992
+ const range = all > count
993
+ ? `between 0 and ${count - 1}, or up to ${all - 1} after re-running it with --limit 0`
994
+ : `between 0 and ${count - 1}, or re-run "${refreshCommand(source)}"`;
942
995
  return {
943
996
  message: `Index ${source.index} is out of range for ${cachedListText(source)} (${results})`,
944
- suggestion: count > 0
945
- ? `Use an index between 0 and ${count - 1}, or re-run "${refreshCommand(source)}"`
946
- : `Re-run "${refreshCommand(source)}"`,
997
+ suggestion: count > 0 ? `Use an index ${range}` : `Re-run "${refreshCommand(source)}"`,
947
998
  };
948
999
  }
949
1000
  /**
@@ -1349,21 +1400,50 @@ export const FILL_REFUSALS = {
1349
1400
  },
1350
1401
  };
1351
1402
  /**
1352
- * Clickable element not found.
1403
+ * Click target disappeared between locating and clicking it.
1353
1404
  */
1354
- export function clickableElementNotFoundError(selector) {
1405
+ export function clickTargetDetachedError(selector) {
1355
1406
  return {
1356
- message: `Element not found: ${selector}`,
1357
- suggestion: 'Verify the selector matches a clickable element',
1407
+ message: `Element was removed before it could be clicked: ${selector}`,
1408
+ suggestion: 'The page changed during the click; wait for it to settle and retry',
1358
1409
  };
1359
1410
  }
1360
1411
  /**
1361
- * Click target disappeared between locating and clicking it.
1412
+ * An action's page script threw (on a page whose built-ins all look like the
1413
+ * browser's).
1414
+ *
1415
+ * @param action - The action, e.g. `fill`
1416
+ * @param exception - What the script threw, e.g. `TypeError: x is not a function`
1417
+ * @param selector - Selector the action was for
1418
+ * @returns Error naming the exception
1362
1419
  */
1363
- export function clickTargetDetachedError(selector) {
1420
+ export function actionScriptFailedError(action, exception, selector) {
1421
+ const damage = detectSelectorQuoteDamage(selector);
1364
1422
  return {
1365
- message: `Element was removed before it could be clicked: ${selector}`,
1366
- suggestion: 'The page changed during the click; wait for it to settle and retry',
1423
+ message: `The ${action} script failed in the page: ${exception}`,
1424
+ suggestion: damage.damaged
1425
+ ? `The selector looks damaged by shell quoting${damage.details ? ` (${damage.details})` : ''}; query it first with ${sessionCommand(`bdg dom query ${JSON.stringify(selector)}`)}, then act on the index`
1426
+ : `Check the element with ${sessionCommand(`bdg dom get ${JSON.stringify(selector)}`)}, or act on it with ${sessionCommand("bdg dom eval '…'")}`,
1427
+ };
1428
+ }
1429
+ /**
1430
+ * An action's page script threw on a page that replaced built-ins it uses
1431
+ * (anti-bot scripts make `getBoundingClientRect`, `focus` or
1432
+ * `dispatchEvent` throw; old libraries such as MooTools 1.2 replace
1433
+ * `Event`). All replaced built-ins are named.
1434
+ *
1435
+ * @param action - The action, e.g. `fill`
1436
+ * @param exception - What the script threw, e.g. `Error: anti-bot: focus`
1437
+ * @param replaced - Dotted names of the replaced built-ins
1438
+ * @returns Error naming the replaced built-ins and the exception
1439
+ */
1440
+ export function actionBrokenByPageError(action, exception, replaced) {
1441
+ const fill = action === 'fill'
1442
+ ? ' The field may already hold the value without the page having seen input or change events.'
1443
+ : '';
1444
+ return {
1445
+ message: `The page replaced built-ins bdg's ${action} script uses (${replaced.join(', ')}), and the script failed: ${exception}`,
1446
+ suggestion: `The page blocks or changes these APIs (an anti-bot script or an old library).${fill} If the page still lets scripts act, use ${sessionCommand("bdg dom eval '…'")}`,
1367
1447
  };
1368
1448
  }
1369
1449
  /**
@@ -1808,14 +1888,21 @@ export function skillSourceMissingError(source) {
1808
1888
  /**
1809
1889
  * The skill could not be written to an agent's skill directory.
1810
1890
  *
1811
- * @param path - Destination SKILL.md
1891
+ * @param path - File that could not be written
1812
1892
  * @param reason - The file system error
1893
+ * @param pathIsFile - Whether a part of the path is a file (ENOTDIR, EEXIST)
1894
+ * @param otherTargetFlag - Flag installing for the other agent only, when both were picked
1813
1895
  * @returns Message and suggestion
1814
1896
  */
1815
- export function skillWriteFailedError(path, reason) {
1897
+ export function skillWriteFailedError(path, reason, pathIsFile, otherTargetFlag) {
1898
+ const fix = pathIsFile
1899
+ ? 'A part of that path is a file, not a directory: move it away'
1900
+ : 'Check the permissions of that directory';
1816
1901
  return {
1817
1902
  message: `Could not write ${path}: ${reason}`,
1818
- suggestion: 'Check the permissions of that directory, or install for the other agent only (--claude or --agents)',
1903
+ suggestion: otherTargetFlag
1904
+ ? `${fix}, or install for the other agent only (${otherTargetFlag})`
1905
+ : fix,
1819
1906
  };
1820
1907
  }
1821
1908
  /**