browser-debugger-cli 0.9.0 → 0.11.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.
- package/.claude/skills/bdg/SKILL.md +268 -0
- package/README.md +15 -1
- package/dist/commands/dom/a11y.js +2 -1
- package/dist/commands/dom/formInteraction.js +56 -25
- package/dist/commands/dom/helpers/keyAttributes.d.ts +20 -0
- package/dist/commands/dom/helpers/keyAttributes.js +54 -0
- package/dist/commands/dom/helpers/query.d.ts +1 -1
- package/dist/commands/dom/helpers/query.js +66 -19
- package/dist/commands/dom/helpers/runElementCommand.js +4 -3
- package/dist/commands/dom/helpers/screenshot.js +85 -12
- package/dist/commands/dom/index.d.ts +1 -0
- package/dist/commands/dom/index.js +8 -3
- package/dist/commands/dom/inspect.d.ts +15 -0
- package/dist/commands/dom/inspect.js +82 -0
- package/dist/commands/dom/layout.js +2 -2
- package/dist/commands/dom/listeners.js +2 -2
- package/dist/commands/dom/semanticUtils.d.ts +14 -1
- package/dist/commands/dom/semanticUtils.js +44 -3
- package/dist/commands/installSkill.d.ts +20 -0
- package/dist/commands/installSkill.js +87 -0
- package/dist/commands/network/list.js +13 -2
- package/dist/commands/optionBehaviors.js +48 -6
- package/dist/commands/page.d.ts +1 -1
- package/dist/commands/page.js +62 -3
- package/dist/commands/shared/commonOptions.d.ts +4 -0
- package/dist/commands/shared/commonOptions.js +9 -0
- package/dist/commands/shared/optionTypes.d.ts +21 -0
- package/dist/commands/shared/startHelpers.d.ts +66 -0
- package/dist/commands/shared/startHelpers.js +91 -10
- package/dist/commands/shared/validation.d.ts +11 -0
- package/dist/commands/shared/validation.js +16 -0
- package/dist/commands.js +3 -0
- package/dist/daemon/launcher.d.ts +8 -1
- package/dist/daemon/launcher.js +3 -1
- package/dist/daemon/session/Session.d.ts +7 -0
- package/dist/daemon/session/Session.js +23 -1
- package/dist/daemon/session/commandRegistry.d.ts +14 -1
- package/dist/daemon/session/commandRegistry.js +65 -9
- package/dist/daemon/session/interactions.d.ts +18 -5
- package/dist/daemon/session/interactions.js +22 -12
- package/dist/daemon.js +3565 -329
- package/dist/errors/messages.d.ts +85 -0
- package/dist/errors/messages.js +128 -1
- package/dist/index.js +2151 -960
- package/dist/ipc/client.d.ts +9 -0
- package/dist/ipc/client.js +13 -0
- package/dist/ipc/protocol/commands.d.ts +56 -1
- package/dist/ipc/protocol/commands.js +2 -0
- package/dist/ipc/protocol/domTypes.d.ts +35 -2
- package/dist/ipc/protocol/inspectTypes.d.ts +388 -0
- package/dist/ipc/protocol/inspectTypes.js +10 -0
- package/dist/runtime/dom/actionEffects.d.ts +94 -15
- package/dist/runtime/dom/actionEffects.js +173 -27
- package/dist/runtime/dom/actionEffectsScripts.d.ts +52 -14
- package/dist/runtime/dom/actionEffectsScripts.js +224 -32
- package/dist/runtime/dom/elementInfo.d.ts +26 -0
- package/dist/runtime/dom/elementInfo.js +65 -0
- package/dist/runtime/dom/eventListeners.js +14 -4
- package/dist/runtime/dom/formFillHelpers/fill.d.ts +3 -4
- package/dist/runtime/dom/formFillHelpers/fill.js +77 -28
- package/dist/runtime/dom/frameSelection.d.ts +11 -0
- package/dist/runtime/dom/frameSelection.js +20 -1
- package/dist/runtime/dom/frames.d.ts +38 -5
- package/dist/runtime/dom/frames.js +136 -21
- package/dist/runtime/dom/inspect.d.ts +28 -0
- package/dist/runtime/dom/inspect.js +557 -0
- package/dist/runtime/dom/inspectAllStyles.d.ts +62 -0
- package/dist/runtime/dom/inspectAllStyles.js +385 -0
- package/dist/runtime/dom/inspectCascade.d.ts +94 -0
- package/dist/runtime/dom/inspectCascade.js +371 -0
- package/dist/runtime/dom/inspectCascadeModel.d.ts +39 -0
- package/dist/runtime/dom/inspectCascadeModel.js +232 -0
- package/dist/runtime/dom/inspectHints.d.ts +62 -0
- package/dist/runtime/dom/inspectHints.js +305 -0
- package/dist/runtime/dom/inspectLayoutModel.d.ts +87 -0
- package/dist/runtime/dom/inspectLayoutModel.js +346 -0
- package/dist/runtime/dom/inspectModel.d.ts +74 -0
- package/dist/runtime/dom/inspectModel.js +184 -0
- package/dist/runtime/dom/inspectPaintModel.d.ts +157 -0
- package/dist/runtime/dom/inspectPaintModel.js +461 -0
- package/dist/runtime/dom/inspectRules.d.ts +37 -0
- package/dist/runtime/dom/inspectRules.js +101 -0
- package/dist/runtime/dom/inspectScripts.d.ts +132 -0
- package/dist/runtime/dom/inspectScripts.js +263 -0
- package/dist/runtime/dom/inspectTree.d.ts +40 -0
- package/dist/runtime/dom/inspectTree.js +134 -0
- package/dist/runtime/dom/inspectVariables.d.ts +33 -0
- package/dist/runtime/dom/inspectVariables.js +94 -0
- package/dist/runtime/dom/inspectWhyModel.d.ts +20 -0
- package/dist/runtime/dom/inspectWhyModel.js +134 -0
- package/dist/runtime/dom/layout.d.ts +5 -1
- package/dist/runtime/dom/layout.js +10 -3
- package/dist/runtime/dom/listenerPageScripts.d.ts +11 -5
- package/dist/runtime/dom/listenerPageScripts.js +95 -9
- package/dist/runtime/dom/listenerSummary.d.ts +4 -0
- package/dist/runtime/dom/listenerSummary.js +26 -9
- package/dist/runtime/dom/reactEventHelpers.d.ts +5 -0
- package/dist/runtime/dom/reactEventHelpers.js +12 -4
- package/dist/runtime/page/emulation.d.ts +20 -0
- package/dist/runtime/page/emulation.js +37 -0
- package/dist/telemetry/a11y.d.ts +10 -0
- package/dist/telemetry/a11y.js +78 -1
- package/dist/telemetry/console.d.ts +1 -0
- package/dist/telemetry/console.js +100 -5
- package/dist/telemetry/network.js +3 -1
- package/dist/types.d.ts +40 -0
- package/dist/ui/formatters/details.d.ts +8 -0
- package/dist/ui/formatters/details.js +59 -3
- package/dist/ui/formatters/dom.d.ts +2 -1
- package/dist/ui/formatters/dom.js +25 -9
- package/dist/ui/formatters/inspect.d.ts +39 -0
- package/dist/ui/formatters/inspect.js +596 -0
- package/dist/ui/formatters/installSkill.d.ts +11 -0
- package/dist/ui/formatters/installSkill.js +31 -0
- package/dist/ui/formatters/keyAttributes.d.ts +19 -0
- package/dist/ui/formatters/keyAttributes.js +84 -0
- package/dist/ui/formatters/layout.js +2 -2
- package/dist/ui/formatters/networkHeaders.d.ts +13 -0
- package/dist/ui/formatters/networkHeaders.js +23 -3
- package/dist/ui/formatters/networkList.d.ts +29 -1
- package/dist/ui/formatters/networkList.js +86 -20
- package/dist/ui/formatters/status.js +1 -1
- package/dist/ui/formatting.d.ts +9 -0
- package/dist/ui/formatting.js +6 -3
- package/dist/ui/messages/commands.d.ts +123 -7
- package/dist/ui/messages/commands.js +181 -10
- package/dist/ui/messages/networkMessages.d.ts +14 -0
- package/dist/ui/messages/networkMessages.js +18 -0
- package/dist/ui/messages/session.d.ts +14 -0
- package/dist/ui/messages/session.js +20 -0
- package/dist/utils/async.d.ts +9 -0
- package/dist/utils/async.js +17 -0
- package/dist/utils/color.d.ts +84 -0
- package/dist/utils/color.js +376 -0
- package/dist/utils/cssValues.d.ts +109 -0
- package/dist/utils/cssValues.js +236 -0
- package/dist/utils/selectorFilters.d.ts +12 -0
- package/dist/utils/selectorFilters.js +29 -0
- package/package.json +2 -1
|
@@ -595,6 +595,17 @@ export declare function unreachableElementsNote(selector: string, unsearched?: U
|
|
|
595
595
|
* @returns e.g. `Did you mean #remove-backpack? (similar id on the page)`; empty without names
|
|
596
596
|
*/
|
|
597
597
|
export declare function similarSelectorsLine(kind: 'id' | 'class', names: string[]): string;
|
|
598
|
+
/**
|
|
599
|
+
* A selector that would have to cross into a shadow root: selectors cannot,
|
|
600
|
+
* but bdg searches open shadow roots on its own.
|
|
601
|
+
*
|
|
602
|
+
* @param host - The compound matching the host, and the selector after it
|
|
603
|
+
* @returns e.g. `mdn-search-modal hosts a shadow root, which a selector cannot cross into; bdg searches open shadow roots itself: use "form"`
|
|
604
|
+
*/
|
|
605
|
+
export declare function shadowBoundaryLine(host: {
|
|
606
|
+
compound: string;
|
|
607
|
+
rest: string;
|
|
608
|
+
}): string;
|
|
598
609
|
/** What the page says about a selector that matched nothing */
|
|
599
610
|
export interface NoMatchContext {
|
|
600
611
|
/** Elements only its `:visible` filters excluded */
|
|
@@ -605,6 +616,11 @@ export interface NoMatchContext {
|
|
|
605
616
|
unsearched?: UnsearchedContent;
|
|
606
617
|
/** "Did you mean" line for a single id or class ({@link similarSelectorsLine}) */
|
|
607
618
|
similar?: string;
|
|
619
|
+
/** A leading compound that matches a shadow host, and the selector after it */
|
|
620
|
+
shadowHost?: {
|
|
621
|
+
compound: string;
|
|
622
|
+
rest: string;
|
|
623
|
+
};
|
|
608
624
|
}
|
|
609
625
|
/**
|
|
610
626
|
* No nodes found for selector.
|
|
@@ -768,6 +784,33 @@ export declare function clickableElementNotFoundError(selector: string): ErrorWi
|
|
|
768
784
|
* Click target disappeared between locating and clicking it.
|
|
769
785
|
*/
|
|
770
786
|
export declare function clickTargetDetachedError(selector: string): ErrorWithSuggestion;
|
|
787
|
+
/**
|
|
788
|
+
* A pointer action refused under `--strict` because a real mouse could not
|
|
789
|
+
* reach the element (covered, hidden, zero-size, pointer-events: none).
|
|
790
|
+
*
|
|
791
|
+
* @param target - Selector and element description, as the click located it
|
|
792
|
+
* @param reason - Why the mouse could not reach it, e.g. "covered by another element (div#shield)"
|
|
793
|
+
* @param verb - What was refused, e.g. "click", "hover"
|
|
794
|
+
* @returns Message naming the obstruction, and how to inspect it
|
|
795
|
+
*/
|
|
796
|
+
export declare function unreachableElementError(target: {
|
|
797
|
+
selector: string;
|
|
798
|
+
element?: string | undefined;
|
|
799
|
+
}, reason: string | null | undefined, verb: string): ErrorWithSuggestion;
|
|
800
|
+
/**
|
|
801
|
+
* A mouse press refused under `--strict` because it did not reach the
|
|
802
|
+
* element: it was sent, but landed on another element, or the page never
|
|
803
|
+
* saw it (a browser dialog or bubble captured the input).
|
|
804
|
+
*
|
|
805
|
+
* @param target - Selector and element description, as the click located it
|
|
806
|
+
* @param verb - What was refused, e.g. "click"
|
|
807
|
+
* @param landedOn - The element the press landed on, when the page saw it
|
|
808
|
+
* @returns Message, and how to inspect the page
|
|
809
|
+
*/
|
|
810
|
+
export declare function pressNotReceivedError(target: {
|
|
811
|
+
selector: string;
|
|
812
|
+
element?: string | undefined;
|
|
813
|
+
}, verb: string, landedOn?: string): ErrorWithSuggestion;
|
|
771
814
|
/**
|
|
772
815
|
* Key press failed.
|
|
773
816
|
*/
|
|
@@ -815,6 +858,13 @@ export declare function emptyFrameError(): ErrorWithSuggestion;
|
|
|
815
858
|
* @param frames - Frames of the page
|
|
816
859
|
*/
|
|
817
860
|
export declare function frameNotFoundError(query: string, frames: DomFrame[]): ErrorWithSuggestion;
|
|
861
|
+
/**
|
|
862
|
+
* A `dom eval --frame` index that names another frame (or none) than when
|
|
863
|
+
* `bdg dom frames` listed it.
|
|
864
|
+
*
|
|
865
|
+
* @param index - Requested index
|
|
866
|
+
*/
|
|
867
|
+
export declare function staleFrameIndexError(index: number): ErrorWithSuggestion;
|
|
818
868
|
/**
|
|
819
869
|
* `dom eval --frame` matching more than one iframe.
|
|
820
870
|
*
|
|
@@ -876,6 +926,14 @@ export declare function unexpectedResponseFormatError(context: string): ErrorWit
|
|
|
876
926
|
* Generic operation failure with dynamic error message.
|
|
877
927
|
*/
|
|
878
928
|
export declare function operationFailedError(operation: string, errorMessage: string): ErrorWithSuggestion;
|
|
929
|
+
/**
|
|
930
|
+
* `dom inspect --props` named a property the element has no value for.
|
|
931
|
+
*
|
|
932
|
+
* @param names - Unknown property names
|
|
933
|
+
* @param suggestions - Similar computed property names
|
|
934
|
+
* @returns Message and suggestion
|
|
935
|
+
*/
|
|
936
|
+
export declare function unknownCssPropertyError(names: string[], suggestions: string[]): ErrorWithSuggestion;
|
|
879
937
|
/**
|
|
880
938
|
* The browser does not offer `DOMDebugger.getEventListeners` (non-Chrome
|
|
881
939
|
* targets, or browsers that disable the DOMDebugger domain).
|
|
@@ -904,5 +962,32 @@ export declare function formDiscoveryFailedError(detail: string, readyState?: st
|
|
|
904
962
|
* Form in iframe (cross-origin or same-origin).
|
|
905
963
|
*/
|
|
906
964
|
export declare function formInIframeError(iframeUrl: string, crossOrigin: boolean): ErrorWithSuggestion;
|
|
965
|
+
/**
|
|
966
|
+
* `bdg cdp` when Chrome rejected the call: a missing node, target or
|
|
967
|
+
* frame, or wrong parameters.
|
|
968
|
+
*
|
|
969
|
+
* @param method - CDP method
|
|
970
|
+
* @param message - Chrome's error
|
|
971
|
+
* @returns Message, suggestion, and whether something named was not found
|
|
972
|
+
*/
|
|
973
|
+
export declare function cdpCallError(method: string, message: string): ErrorWithSuggestion & {
|
|
974
|
+
notFound: boolean;
|
|
975
|
+
};
|
|
976
|
+
/**
|
|
977
|
+
* The skill file is not where the package should have it (a broken or
|
|
978
|
+
* partial install).
|
|
979
|
+
*
|
|
980
|
+
* @param source - Expected SKILL.md path
|
|
981
|
+
* @returns Message and suggestion
|
|
982
|
+
*/
|
|
983
|
+
export declare function skillSourceMissingError(source: string): ErrorWithSuggestion;
|
|
984
|
+
/**
|
|
985
|
+
* The skill could not be written to an agent's skill directory.
|
|
986
|
+
*
|
|
987
|
+
* @param path - Destination SKILL.md
|
|
988
|
+
* @param reason - The file system error
|
|
989
|
+
* @returns Message and suggestion
|
|
990
|
+
*/
|
|
991
|
+
export declare function skillWriteFailedError(path: string, reason: string): ErrorWithSuggestion;
|
|
907
992
|
export {};
|
|
908
993
|
//# sourceMappingURL=messages.d.ts.map
|
package/dist/errors/messages.js
CHANGED
|
@@ -999,6 +999,16 @@ export function similarSelectorsLine(kind, names) {
|
|
|
999
999
|
const plural = names.length === 1 ? what : kind === 'id' ? 'ids' : 'classes';
|
|
1000
1000
|
return `Did you mean ${names.map((name) => sigil + name).join(', ')}? (similar ${plural} on the page)`;
|
|
1001
1001
|
}
|
|
1002
|
+
/**
|
|
1003
|
+
* A selector that would have to cross into a shadow root: selectors cannot,
|
|
1004
|
+
* but bdg searches open shadow roots on its own.
|
|
1005
|
+
*
|
|
1006
|
+
* @param host - The compound matching the host, and the selector after it
|
|
1007
|
+
* @returns e.g. `mdn-search-modal hosts a shadow root, which a selector cannot cross into; bdg searches open shadow roots itself: use "form"`
|
|
1008
|
+
*/
|
|
1009
|
+
export function shadowBoundaryLine(host) {
|
|
1010
|
+
return `${host.compound} hosts a shadow root, which a selector cannot cross into; bdg searches open shadow roots itself: use "${host.rest}"`;
|
|
1011
|
+
}
|
|
1002
1012
|
/**
|
|
1003
1013
|
* No nodes found for selector.
|
|
1004
1014
|
*
|
|
@@ -1015,7 +1025,7 @@ export function noNodesFoundError(selector, context = {}) {
|
|
|
1015
1025
|
const note = unreachableElementsNote(selector, context.unsearched);
|
|
1016
1026
|
return {
|
|
1017
1027
|
message: `No nodes found matching "${selector}"`,
|
|
1018
|
-
suggestion: withLoadingHint(joinLines(context.similar, `${hidden}Verify the CSS selector is correct.`, note ? note : undefined), context.readyState, 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),
|
|
1019
1029
|
};
|
|
1020
1030
|
}
|
|
1021
1031
|
/**
|
|
@@ -1326,6 +1336,42 @@ export function clickTargetDetachedError(selector) {
|
|
|
1326
1336
|
suggestion: 'The page changed during the click; wait for it to settle and retry',
|
|
1327
1337
|
};
|
|
1328
1338
|
}
|
|
1339
|
+
/**
|
|
1340
|
+
* A pointer action refused under `--strict` because a real mouse could not
|
|
1341
|
+
* reach the element (covered, hidden, zero-size, pointer-events: none).
|
|
1342
|
+
*
|
|
1343
|
+
* @param target - Selector and element description, as the click located it
|
|
1344
|
+
* @param reason - Why the mouse could not reach it, e.g. "covered by another element (div#shield)"
|
|
1345
|
+
* @param verb - What was refused, e.g. "click", "hover"
|
|
1346
|
+
* @returns Message naming the obstruction, and how to inspect it
|
|
1347
|
+
*/
|
|
1348
|
+
export function unreachableElementError(target, reason, verb) {
|
|
1349
|
+
const element = target.element ?? target.selector;
|
|
1350
|
+
return {
|
|
1351
|
+
message: `Did not ${verb} ${element}: it is ${reason ?? 'not reachable by the mouse'}, so a user could not ${verb} it (--strict)`,
|
|
1352
|
+
suggestion: `See what is in the way with ${sessionCommand(`bdg dom layout ${shellQuote(target.selector)}`)}, then close the overlay or scroll; without --strict bdg uses DOM events instead`,
|
|
1353
|
+
};
|
|
1354
|
+
}
|
|
1355
|
+
/**
|
|
1356
|
+
* A mouse press refused under `--strict` because it did not reach the
|
|
1357
|
+
* element: it was sent, but landed on another element, or the page never
|
|
1358
|
+
* saw it (a browser dialog or bubble captured the input).
|
|
1359
|
+
*
|
|
1360
|
+
* @param target - Selector and element description, as the click located it
|
|
1361
|
+
* @param verb - What was refused, e.g. "click"
|
|
1362
|
+
* @param landedOn - The element the press landed on, when the page saw it
|
|
1363
|
+
* @returns Message, and how to inspect the page
|
|
1364
|
+
*/
|
|
1365
|
+
export function pressNotReceivedError(target, verb, landedOn) {
|
|
1366
|
+
const element = target.element ?? target.selector;
|
|
1367
|
+
const where = landedOn === undefined
|
|
1368
|
+
? 'the page saw no press: the browser may be showing a dialog or bubble that captures input'
|
|
1369
|
+
: `landed on ${landedOn}`;
|
|
1370
|
+
return {
|
|
1371
|
+
message: `Did not ${verb} ${element}: the press did not reach the element (it was sent, but ${where}) (--strict)`,
|
|
1372
|
+
suggestion: `Check the page with ${sessionCommand('bdg dom screenshot page.png')} and ${sessionCommand(`bdg dom layout ${shellQuote(target.selector)}`)}`,
|
|
1373
|
+
};
|
|
1374
|
+
}
|
|
1329
1375
|
/**
|
|
1330
1376
|
* Key press failed.
|
|
1331
1377
|
*/
|
|
@@ -1425,6 +1471,18 @@ export function frameNotFoundError(query, frames) {
|
|
|
1425
1471
|
suggestion: joinLines('Available frames:', ...frames.map((frame) => ` ${frameLabel(frame)}`)),
|
|
1426
1472
|
};
|
|
1427
1473
|
}
|
|
1474
|
+
/**
|
|
1475
|
+
* A `dom eval --frame` index that names another frame (or none) than when
|
|
1476
|
+
* `bdg dom frames` listed it.
|
|
1477
|
+
*
|
|
1478
|
+
* @param index - Requested index
|
|
1479
|
+
*/
|
|
1480
|
+
export function staleFrameIndexError(index) {
|
|
1481
|
+
return {
|
|
1482
|
+
message: `Frame index ${index} is stale: the page's iframes changed since bdg dom frames listed them`,
|
|
1483
|
+
suggestion: 'Re-run bdg dom frames to refresh the indices, or pick the frame by name, id or URL (--frame <name>)',
|
|
1484
|
+
};
|
|
1485
|
+
}
|
|
1428
1486
|
/**
|
|
1429
1487
|
* `dom eval --frame` matching more than one iframe.
|
|
1430
1488
|
*
|
|
@@ -1585,6 +1643,22 @@ export function operationFailedError(operation, errorMessage) {
|
|
|
1585
1643
|
suggestion: errorMessage,
|
|
1586
1644
|
};
|
|
1587
1645
|
}
|
|
1646
|
+
/**
|
|
1647
|
+
* `dom inspect --props` named a property the element has no value for.
|
|
1648
|
+
*
|
|
1649
|
+
* @param names - Unknown property names
|
|
1650
|
+
* @param suggestions - Similar computed property names
|
|
1651
|
+
* @returns Message and suggestion
|
|
1652
|
+
*/
|
|
1653
|
+
export function unknownCssPropertyError(names, suggestions) {
|
|
1654
|
+
const plural = names.length > 1;
|
|
1655
|
+
return {
|
|
1656
|
+
message: `Unknown CSS ${plural ? 'properties' : 'property'}: ${names.join(', ')}`,
|
|
1657
|
+
suggestion: suggestions.length > 0
|
|
1658
|
+
? `Did you mean: ${suggestions.join(', ')}?`
|
|
1659
|
+
: 'Use CSS property names as in a stylesheet (e.g. --props padding-top,color,--brand); bdg dom inspect <selector> --all lists the set ones',
|
|
1660
|
+
};
|
|
1661
|
+
}
|
|
1588
1662
|
/**
|
|
1589
1663
|
* The browser does not offer `DOMDebugger.getEventListeners` (non-Chrome
|
|
1590
1664
|
* targets, or browsers that disable the DOMDebugger domain).
|
|
@@ -1650,4 +1724,57 @@ export function formInIframeError(iframeUrl, crossOrigin) {
|
|
|
1650
1724
|
: 'dom form lists forms of the main document only; its fields are reachable directly: bdg dom query "input, select, textarea", then bdg dom fill <index> <value>',
|
|
1651
1725
|
};
|
|
1652
1726
|
}
|
|
1727
|
+
/** CDP error messages that name something that does not exist (a node, target, frame…) */
|
|
1728
|
+
const CDP_NOT_FOUND_PATTERN = /could not find|cannot find|not found|no \w+ (with|for) (the )?given|does not exist|no such/i;
|
|
1729
|
+
/**
|
|
1730
|
+
* `bdg cdp` when Chrome rejected the call: a missing node, target or
|
|
1731
|
+
* frame, or wrong parameters.
|
|
1732
|
+
*
|
|
1733
|
+
* @param method - CDP method
|
|
1734
|
+
* @param message - Chrome's error
|
|
1735
|
+
* @returns Message, suggestion, and whether something named was not found
|
|
1736
|
+
*/
|
|
1737
|
+
export function cdpCallError(method, message) {
|
|
1738
|
+
if (CDP_NOT_FOUND_PATTERN.test(message)) {
|
|
1739
|
+
const ids = /node/i.test(message)
|
|
1740
|
+
? 'Node ids come from DOM.getDocument (the root) or DOM.querySelector, and a new DOM.getDocument or a navigation replaces them; '
|
|
1741
|
+
: '';
|
|
1742
|
+
return {
|
|
1743
|
+
message: `${method}: ${message}`,
|
|
1744
|
+
suggestion: `${ids}check the ids with ${sessionCommand(`bdg cdp ${method} --describe`)}`,
|
|
1745
|
+
notFound: true,
|
|
1746
|
+
};
|
|
1747
|
+
}
|
|
1748
|
+
return {
|
|
1749
|
+
message: `${method}: ${message}`,
|
|
1750
|
+
suggestion: `See the parameters with ${sessionCommand(`bdg cdp ${method} --describe`)}`,
|
|
1751
|
+
notFound: false,
|
|
1752
|
+
};
|
|
1753
|
+
}
|
|
1754
|
+
/**
|
|
1755
|
+
* The skill file is not where the package should have it (a broken or
|
|
1756
|
+
* partial install).
|
|
1757
|
+
*
|
|
1758
|
+
* @param source - Expected SKILL.md path
|
|
1759
|
+
* @returns Message and suggestion
|
|
1760
|
+
*/
|
|
1761
|
+
export function skillSourceMissingError(source) {
|
|
1762
|
+
return {
|
|
1763
|
+
message: `The bdg skill is missing from the installed package (${source})`,
|
|
1764
|
+
suggestion: 'Reinstall bdg: npm install -g browser-debugger-cli',
|
|
1765
|
+
};
|
|
1766
|
+
}
|
|
1767
|
+
/**
|
|
1768
|
+
* The skill could not be written to an agent's skill directory.
|
|
1769
|
+
*
|
|
1770
|
+
* @param path - Destination SKILL.md
|
|
1771
|
+
* @param reason - The file system error
|
|
1772
|
+
* @returns Message and suggestion
|
|
1773
|
+
*/
|
|
1774
|
+
export function skillWriteFailedError(path, reason) {
|
|
1775
|
+
return {
|
|
1776
|
+
message: `Could not write ${path}: ${reason}`,
|
|
1777
|
+
suggestion: 'Check the permissions of that directory, or install for the other agent only (--claude or --agents)',
|
|
1778
|
+
};
|
|
1779
|
+
}
|
|
1653
1780
|
//# sourceMappingURL=messages.js.map
|