browser-debugger-cli 0.11.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 (222) hide show
  1. package/.claude/skills/bdg/SKILL.md +4 -4
  2. package/README.md +143 -79
  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/css.d.ts +13 -0
  8. package/dist/commands/css.js +53 -0
  9. package/dist/commands/dom/DomElementResolver.d.ts +3 -1
  10. package/dist/commands/dom/DomElementResolver.js +10 -3
  11. package/dist/commands/dom/a11y.js +3 -2
  12. package/dist/commands/dom/audit.d.ts +14 -0
  13. package/dist/commands/dom/audit.js +87 -0
  14. package/dist/commands/dom/eval.d.ts +3 -2
  15. package/dist/commands/dom/eval.js +11 -5
  16. package/dist/commands/dom/form.js +10 -9
  17. package/dist/commands/dom/formInteraction.js +42 -11
  18. package/dist/commands/dom/get.js +8 -8
  19. package/dist/commands/dom/helpers/index.d.ts +1 -1
  20. package/dist/commands/dom/helpers/index.js +1 -1
  21. package/dist/commands/dom/helpers/keyAttributes.d.ts +3 -2
  22. package/dist/commands/dom/helpers/keyAttributes.js +6 -4
  23. package/dist/commands/dom/helpers/query.d.ts +27 -3
  24. package/dist/commands/dom/helpers/query.js +152 -64
  25. package/dist/commands/dom/helpers/screenshot.d.ts +1 -0
  26. package/dist/commands/dom/helpers/screenshot.js +169 -49
  27. package/dist/commands/dom/index.js +7 -2
  28. package/dist/commands/dom/query.d.ts +19 -2
  29. package/dist/commands/dom/query.js +37 -6
  30. package/dist/commands/dom/screenshot.js +12 -7
  31. package/dist/commands/dom/semanticUtils.d.ts +3 -2
  32. package/dist/commands/dom/semanticUtils.js +40 -9
  33. package/dist/commands/dom/wait.js +5 -3
  34. package/dist/commands/helpJson.d.ts +82 -19
  35. package/dist/commands/helpJson.js +112 -41
  36. package/dist/commands/helpTopic.d.ts +16 -1
  37. package/dist/commands/helpTopic.js +59 -1
  38. package/dist/commands/installSkill.d.ts +15 -5
  39. package/dist/commands/installSkill.js +86 -16
  40. package/dist/commands/network/list.js +22 -12
  41. package/dist/commands/optionBehaviors.js +53 -16
  42. package/dist/commands/page.js +7 -4
  43. package/dist/commands/peek.d.ts +7 -0
  44. package/dist/commands/peek.js +65 -23
  45. package/dist/commands/shared/daemonErrorHandler.d.ts +5 -2
  46. package/dist/commands/shared/daemonErrorHandler.js +20 -9
  47. package/dist/commands/shared/dataFetcher.d.ts +12 -4
  48. package/dist/commands/shared/dataFetcher.js +12 -4
  49. package/dist/commands/shared/followMode.d.ts +9 -1
  50. package/dist/commands/shared/followMode.js +22 -4
  51. package/dist/commands/shared/optionTypes.d.ts +9 -2
  52. package/dist/commands/shared/outputFile.js +6 -1
  53. package/dist/commands/start.d.ts +20 -5
  54. package/dist/commands/start.js +84 -23
  55. package/dist/commands/stop.d.ts +11 -0
  56. package/dist/commands/stop.js +24 -1
  57. package/dist/commands/tail.d.ts +7 -1
  58. package/dist/commands/tail.js +13 -62
  59. package/dist/commands.js +2 -0
  60. package/dist/connection/cdp.d.ts +7 -0
  61. package/dist/connection/cdp.js +9 -0
  62. package/dist/connection/launcher.js +3 -2
  63. package/dist/daemon/SessionController.js +6 -1
  64. package/dist/daemon/launcher.d.ts +3 -2
  65. package/dist/daemon/launcher.js +47 -3
  66. package/dist/daemon/session/Session.d.ts +4 -1
  67. package/dist/daemon/session/Session.js +33 -2
  68. package/dist/daemon/session/TelemetryStore.d.ts +8 -1
  69. package/dist/daemon/session/TelemetryStore.js +13 -1
  70. package/dist/daemon/session/commandRegistry.js +36 -14
  71. package/dist/daemon/session/interactions.d.ts +2 -1
  72. package/dist/daemon/session/interactions.js +13 -1
  73. package/dist/daemon/session/plugins.js +19 -53
  74. package/dist/daemon/session/teardown.js +1 -1
  75. package/dist/daemon.js +9234 -7222
  76. package/dist/errors/messages.d.ts +88 -15
  77. package/dist/errors/messages.js +177 -27
  78. package/dist/index.js +19322 -13961
  79. package/dist/ipc/client.d.ts +22 -2
  80. package/dist/ipc/client.js +34 -5
  81. package/dist/ipc/protocol/auditTypes.d.ts +135 -0
  82. package/dist/ipc/protocol/auditTypes.js +6 -0
  83. package/dist/ipc/protocol/commands.d.ts +35 -0
  84. package/dist/ipc/protocol/commands.js +2 -0
  85. package/dist/ipc/protocol/domTypes.d.ts +16 -0
  86. package/dist/ipc/protocol/inspectTypes.d.ts +73 -8
  87. package/dist/ipc/session/types.d.ts +2 -0
  88. package/dist/runtime/css/search.d.ts +39 -0
  89. package/dist/runtime/css/search.js +122 -0
  90. package/dist/runtime/dom/actionEffects.d.ts +9 -2
  91. package/dist/runtime/dom/actionEffects.js +30 -14
  92. package/dist/runtime/dom/audit.d.ts +19 -0
  93. package/dist/runtime/dom/audit.js +37 -0
  94. package/dist/runtime/dom/auditModel.d.ts +45 -0
  95. package/dist/runtime/dom/auditModel.js +220 -0
  96. package/dist/runtime/dom/auditScripts.d.ts +113 -0
  97. package/dist/runtime/dom/auditScripts.js +148 -0
  98. package/dist/runtime/dom/elementGeometry.d.ts +16 -3
  99. package/dist/runtime/dom/elementGeometry.js +49 -10
  100. package/dist/runtime/dom/elementInfo.d.ts +74 -17
  101. package/dist/runtime/dom/elementInfo.js +187 -34
  102. package/dist/runtime/dom/evalHelpers.d.ts +12 -2
  103. package/dist/runtime/dom/evalHelpers.js +67 -7
  104. package/dist/runtime/dom/formDiscovery.d.ts +6 -2
  105. package/dist/runtime/dom/formDiscovery.js +20 -3
  106. package/dist/runtime/dom/formFillHelpers/fill.js +8 -12
  107. package/dist/runtime/dom/formFillHelpers/pressKey.js +2 -2
  108. package/dist/runtime/dom/formFillHelpers/shared.d.ts +16 -10
  109. package/dist/runtime/dom/formFillHelpers/shared.js +19 -52
  110. package/dist/runtime/dom/formSubmitHelpers.js +4 -3
  111. package/dist/runtime/dom/frameLayout.js +1 -0
  112. package/dist/runtime/dom/inspect.d.ts +7 -0
  113. package/dist/runtime/dom/inspect.js +92 -28
  114. package/dist/runtime/dom/inspectAllStyles.d.ts +16 -4
  115. package/dist/runtime/dom/inspectAllStyles.js +90 -7
  116. package/dist/runtime/dom/inspectCascade.d.ts +19 -2
  117. package/dist/runtime/dom/inspectCascade.js +214 -44
  118. package/dist/runtime/dom/inspectCascadeModel.d.ts +8 -0
  119. package/dist/runtime/dom/inspectCascadeModel.js +108 -34
  120. package/dist/runtime/dom/inspectHints.d.ts +26 -3
  121. package/dist/runtime/dom/inspectHints.js +125 -9
  122. package/dist/runtime/dom/inspectModel.d.ts +5 -1
  123. package/dist/runtime/dom/inspectModel.js +37 -10
  124. package/dist/runtime/dom/inspectPaintModel.d.ts +50 -22
  125. package/dist/runtime/dom/inspectPaintModel.js +182 -68
  126. package/dist/runtime/dom/inspectRules.d.ts +19 -0
  127. package/dist/runtime/dom/inspectRules.js +21 -5
  128. package/dist/runtime/dom/inspectScripts.d.ts +112 -12
  129. package/dist/runtime/dom/inspectScripts.js +357 -32
  130. package/dist/runtime/dom/inspectTree.js +10 -2
  131. package/dist/runtime/dom/inspectWhyModel.d.ts +2 -1
  132. package/dist/runtime/dom/inspectWhyModel.js +52 -10
  133. package/dist/runtime/dom/layout.js +40 -16
  134. package/dist/runtime/dom/reactEventHelpers.d.ts +21 -4
  135. package/dist/runtime/dom/reactEventHelpers.js +90 -36
  136. package/dist/runtime/dom/targetNode.d.ts +18 -5
  137. package/dist/runtime/dom/targetNode.js +268 -8
  138. package/dist/runtime/dom/wait.js +2 -1
  139. package/dist/runtime/page/bdgWorld.d.ts +57 -0
  140. package/dist/runtime/page/bdgWorld.js +180 -0
  141. package/dist/runtime/page/emulation.d.ts +13 -4
  142. package/dist/runtime/page/emulation.js +69 -4
  143. package/dist/runtime/page/replacedBuiltins.d.ts +28 -0
  144. package/dist/runtime/page/replacedBuiltins.js +136 -0
  145. package/dist/runtime/page/userAgent.d.ts +17 -0
  146. package/dist/runtime/page/userAgent.js +57 -0
  147. package/dist/session/QueryCacheManager.d.ts +4 -1
  148. package/dist/session/QueryCacheManager.js +5 -2
  149. package/dist/session/chrome.d.ts +4 -1
  150. package/dist/session/chrome.js +7 -1
  151. package/dist/session/cleanup/staleSession.d.ts +21 -4
  152. package/dist/session/cleanup/staleSession.js +79 -9
  153. package/dist/session/cleanup/userCommands.d.ts +4 -1
  154. package/dist/session/cleanup/userCommands.js +10 -5
  155. package/dist/session/daemonSocket.d.ts +10 -0
  156. package/dist/session/daemonSocket.js +22 -0
  157. package/dist/session/lastSession.d.ts +6 -3
  158. package/dist/session/lastSession.js +11 -5
  159. package/dist/session/paths.d.ts +3 -1
  160. package/dist/session/paths.js +5 -5
  161. package/dist/session/portClaims.js +4 -3
  162. package/dist/session/sessionList.d.ts +13 -5
  163. package/dist/session/sessionList.js +31 -7
  164. package/dist/telemetry/a11y.js +2 -2
  165. package/dist/telemetry/console.d.ts +2 -1
  166. package/dist/telemetry/console.js +30 -21
  167. package/dist/telemetry/pageCrash.d.ts +26 -0
  168. package/dist/telemetry/pageCrash.js +53 -0
  169. package/dist/types.d.ts +20 -0
  170. package/dist/ui/formatters/audit.d.ts +19 -0
  171. package/dist/ui/formatters/audit.js +115 -0
  172. package/dist/ui/formatters/cdp.d.ts +138 -0
  173. package/dist/ui/formatters/cdp.js +131 -0
  174. package/dist/ui/formatters/console/chronological.js +3 -1
  175. package/dist/ui/formatters/console/follow.d.ts +2 -1
  176. package/dist/ui/formatters/console/follow.js +2 -2
  177. package/dist/ui/formatters/console/json.d.ts +2 -2
  178. package/dist/ui/formatters/console/json.js +11 -5
  179. package/dist/ui/formatters/console/shared.d.ts +30 -0
  180. package/dist/ui/formatters/console/shared.js +16 -0
  181. package/dist/ui/formatters/console/summarize.d.ts +9 -2
  182. package/dist/ui/formatters/console/summarize.js +40 -9
  183. package/dist/ui/formatters/console.d.ts +2 -1
  184. package/dist/ui/formatters/console.js +7 -5
  185. package/dist/ui/formatters/details.js +3 -1
  186. package/dist/ui/formatters/dom.d.ts +2 -2
  187. package/dist/ui/formatters/dom.js +10 -8
  188. package/dist/ui/formatters/helpFormatters.js +1 -1
  189. package/dist/ui/formatters/inspect.js +50 -17
  190. package/dist/ui/formatters/installSkill.d.ts +9 -1
  191. package/dist/ui/formatters/installSkill.js +32 -6
  192. package/dist/ui/formatters/layout.js +2 -1
  193. package/dist/ui/formatters/networkList.d.ts +1 -1
  194. package/dist/ui/formatters/networkList.js +1 -2
  195. package/dist/ui/formatters/preview.d.ts +2 -0
  196. package/dist/ui/formatters/preview.js +17 -7
  197. package/dist/ui/formatters/sessions.d.ts +2 -2
  198. package/dist/ui/formatters/sessions.js +9 -2
  199. package/dist/ui/formatters/status.js +1 -1
  200. package/dist/ui/logging/logger.d.ts +1 -1
  201. package/dist/ui/messages/commands.d.ts +168 -11
  202. package/dist/ui/messages/commands.js +245 -18
  203. package/dist/ui/messages/consoleMessages.d.ts +24 -0
  204. package/dist/ui/messages/consoleMessages.js +32 -0
  205. package/dist/ui/messages/preview.d.ts +12 -0
  206. package/dist/ui/messages/preview.js +18 -2
  207. package/dist/ui/messages/session.d.ts +13 -2
  208. package/dist/ui/messages/session.js +22 -3
  209. package/dist/utils/cssValues.js +36 -4
  210. package/dist/utils/decisionTrees.js +0 -5
  211. package/dist/utils/directories.d.ts +34 -0
  212. package/dist/utils/directories.js +88 -0
  213. package/dist/utils/display.d.ts +16 -0
  214. package/dist/utils/display.js +42 -0
  215. package/dist/utils/exitCodes.d.ts +1 -0
  216. package/dist/utils/exitCodes.js +6 -0
  217. package/dist/utils/process.d.ts +12 -0
  218. package/dist/utils/process.js +25 -0
  219. package/dist/utils/suggestions.d.ts +4 -2
  220. package/dist/utils/suggestions.js +7 -5
  221. package/dist/utils/taskMappings.js +1 -1
  222. package/package.json +3 -2
@@ -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.
@@ -691,7 +714,16 @@ export declare function elementNotVisibleError(): ErrorWithSuggestion;
691
714
  */
692
715
  export declare function elementZeroDimensionsError(): ErrorWithSuggestion;
693
716
  /**
694
- * Missing required argument.
717
+ * `bdg dom hover --off` was given an element too.
718
+ *
719
+ * @returns Message and suggestion
720
+ */
721
+ export declare function hoverOffWithTargetError(): ErrorWithSuggestion;
722
+ /**
723
+ * A command was given neither its argument nor a flag that replaces it.
724
+ *
725
+ * @param usage - How to call it
726
+ * @returns Message and suggestion
695
727
  */
696
728
  export declare function missingArgumentError(usage: string): ErrorWithSuggestion;
697
729
  /**
@@ -776,14 +808,32 @@ export declare const FILL_REFUSALS: {
776
808
  readonly suggestion: "Only input, textarea, select, and contenteditable elements can be filled";
777
809
  };
778
810
  };
779
- /**
780
- * Clickable element not found.
781
- */
782
- export declare function clickableElementNotFoundError(selector: string): ErrorWithSuggestion;
783
811
  /**
784
812
  * Click target disappeared between locating and clicking it.
785
813
  */
786
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;
787
837
  /**
788
838
  * A pointer action refused under `--strict` because a real mouse could not
789
839
  * reach the element (covered, hidden, zero-size, pointer-events: none).
@@ -927,10 +977,16 @@ export declare function unexpectedResponseFormatError(context: string): ErrorWit
927
977
  */
928
978
  export declare function operationFailedError(operation: string, errorMessage: string): ErrorWithSuggestion;
929
979
  /**
930
- * `dom inspect --props` named a property the element has no value for.
980
+ * `--why all`: `all` resets every property, so there is no one cascade to show.
981
+ *
982
+ * @returns Message and suggestion
983
+ */
984
+ export declare function whyAllPropertyError(): ErrorWithSuggestion;
985
+ /**
986
+ * Names given to --props or --why that are not CSS properties.
931
987
  *
932
- * @param names - Unknown property names
933
- * @param suggestions - Similar computed property names
988
+ * @param names - Unknown names
989
+ * @param suggestions - Closest known names
934
990
  * @returns Message and suggestion
935
991
  */
936
992
  export declare function unknownCssPropertyError(names: string[], suggestions: string[]): ErrorWithSuggestion;
@@ -984,10 +1040,27 @@ export declare function skillSourceMissingError(source: string): ErrorWithSugges
984
1040
  /**
985
1041
  * The skill could not be written to an agent's skill directory.
986
1042
  *
987
- * @param path - Destination SKILL.md
1043
+ * @param path - File that could not be written
988
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
1047
+ * @returns Message and suggestion
1048
+ */
1049
+ export declare function skillWriteFailedError(path: string, reason: string, pathIsFile: boolean, otherTargetFlag?: string): ErrorWithSuggestion;
1050
+ /**
1051
+ * `bdg peek --interval` without `--follow`.
1052
+ *
989
1053
  * @returns Message and suggestion
990
1054
  */
991
- export declare function skillWriteFailedError(path: string, reason: string): ErrorWithSuggestion;
1055
+ export declare function intervalWithoutFollowError(): ErrorWithSuggestion;
1056
+ /**
1057
+ * An unknown `dom audit` check.
1058
+ *
1059
+ * @param value - Name given
1060
+ * @param similar - Closest names
1061
+ * @param checks - Every check
1062
+ * @returns Message
1063
+ */
1064
+ export declare function unknownAuditCheckMessage(value: string, similar: string[], checks: readonly string[]): string;
992
1065
  export {};
993
1066
  //# sourceMappingURL=messages.d.ts.map
@@ -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
  /**
@@ -1025,9 +1076,25 @@ export function noNodesFoundError(selector, context = {}) {
1025
1076
  const note = unreachableElementsNote(selector, context.unsearched);
1026
1077
  return {
1027
1078
  message: `No nodes found matching "${selector}"`,
1028
- suggestion: withLoadingHint(joinLines(context.similar, context.shadowHost && shadowBoundaryLine(context.shadowHost), `${hidden}Verify the CSS selector is correct.`, note ? note : undefined), context.readyState, selector),
1079
+ suggestion: withLoadingHint(joinLines(context.similar, context.shadowHost && shadowBoundaryLine(context.shadowHost), shadowPseudoLine(selector), `${hidden}Verify the CSS selector is correct.`, note ? note : undefined), context.readyState, selector),
1029
1080
  };
1030
1081
  }
1082
+ /**
1083
+ * Advice for a selector with `::part()` or `::slotted()`, which name
1084
+ * pseudo-elements a page's stylesheet uses and never match an element.
1085
+ *
1086
+ * @param selector - Selector as given
1087
+ * @returns Line, or undefined for other selectors
1088
+ */
1089
+ function shadowPseudoLine(selector) {
1090
+ const part = /::part\(\s*([^)\s]+)\s*\)/.exec(selector)?.[1];
1091
+ if (part) {
1092
+ return `::part() styles a shadow part and selects nothing; bdg searches open shadow roots, so select the part itself: [part~="${part}"]`;
1093
+ }
1094
+ return /::slotted\(/.test(selector)
1095
+ ? '::slotted() selects nothing; select the slotted element itself (it is in the light DOM)'
1096
+ : undefined;
1097
+ }
1031
1098
  /**
1032
1099
  * Quote a value for a POSIX shell command line.
1033
1100
  *
@@ -1176,7 +1243,21 @@ export function elementZeroDimensionsError() {
1176
1243
  };
1177
1244
  }
1178
1245
  /**
1179
- * Missing required argument.
1246
+ * `bdg dom hover --off` was given an element too.
1247
+ *
1248
+ * @returns Message and suggestion
1249
+ */
1250
+ export function hoverOffWithTargetError() {
1251
+ return {
1252
+ message: '--off moves the mouse off the page; it takes no element',
1253
+ suggestion: 'Use bdg dom hover --off alone, or bdg dom hover <selector> to hover an element',
1254
+ };
1255
+ }
1256
+ /**
1257
+ * A command was given neither its argument nor a flag that replaces it.
1258
+ *
1259
+ * @param usage - How to call it
1260
+ * @returns Message and suggestion
1180
1261
  */
1181
1262
  export function missingArgumentError(usage) {
1182
1263
  return {
@@ -1319,21 +1400,50 @@ export const FILL_REFUSALS = {
1319
1400
  },
1320
1401
  };
1321
1402
  /**
1322
- * Clickable element not found.
1403
+ * Click target disappeared between locating and clicking it.
1323
1404
  */
1324
- export function clickableElementNotFoundError(selector) {
1405
+ export function clickTargetDetachedError(selector) {
1325
1406
  return {
1326
- message: `Element not found: ${selector}`,
1327
- 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',
1328
1409
  };
1329
1410
  }
1330
1411
  /**
1331
- * 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
1332
1419
  */
1333
- export function clickTargetDetachedError(selector) {
1420
+ export function actionScriptFailedError(action, exception, selector) {
1421
+ const damage = detectSelectorQuoteDamage(selector);
1334
1422
  return {
1335
- message: `Element was removed before it could be clicked: ${selector}`,
1336
- 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 '…'")}`,
1337
1447
  };
1338
1448
  }
1339
1449
  /**
@@ -1644,10 +1754,21 @@ export function operationFailedError(operation, errorMessage) {
1644
1754
  };
1645
1755
  }
1646
1756
  /**
1647
- * `dom inspect --props` named a property the element has no value for.
1757
+ * `--why all`: `all` resets every property, so there is no one cascade to show.
1758
+ *
1759
+ * @returns Message and suggestion
1760
+ */
1761
+ export function whyAllPropertyError() {
1762
+ return {
1763
+ message: '--why takes one property; "all" resets every property',
1764
+ suggestion: 'Name the property you are after (e.g. --why color), or use --all to list the set ones',
1765
+ };
1766
+ }
1767
+ /**
1768
+ * Names given to --props or --why that are not CSS properties.
1648
1769
  *
1649
- * @param names - Unknown property names
1650
- * @param suggestions - Similar computed property names
1770
+ * @param names - Unknown names
1771
+ * @param suggestions - Closest known names
1651
1772
  * @returns Message and suggestion
1652
1773
  */
1653
1774
  export function unknownCssPropertyError(names, suggestions) {
@@ -1767,14 +1888,43 @@ export function skillSourceMissingError(source) {
1767
1888
  /**
1768
1889
  * The skill could not be written to an agent's skill directory.
1769
1890
  *
1770
- * @param path - Destination SKILL.md
1891
+ * @param path - File that could not be written
1771
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
1772
1895
  * @returns Message and suggestion
1773
1896
  */
1774
- 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';
1775
1901
  return {
1776
1902
  message: `Could not write ${path}: ${reason}`,
1777
- 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,
1906
+ };
1907
+ }
1908
+ /**
1909
+ * `bdg peek --interval` without `--follow`.
1910
+ *
1911
+ * @returns Message and suggestion
1912
+ */
1913
+ export function intervalWithoutFollowError() {
1914
+ return {
1915
+ message: '--interval sets how often --follow refreshes',
1916
+ suggestion: 'Add --follow, e.g. bdg peek --follow --interval 500',
1778
1917
  };
1779
1918
  }
1919
+ /**
1920
+ * An unknown `dom audit` check.
1921
+ *
1922
+ * @param value - Name given
1923
+ * @param similar - Closest names
1924
+ * @param checks - Every check
1925
+ * @returns Message
1926
+ */
1927
+ export function unknownAuditCheckMessage(value, similar, checks) {
1928
+ return `Unknown check "${value}"${similar.length > 0 ? `; did you mean ${similar[0]}?` : ''} (checks: ${checks.join(', ')})`;
1929
+ }
1780
1930
  //# sourceMappingURL=messages.js.map