@mearl/client 2.17.0 → 2.18.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/dist/commands.js CHANGED
@@ -310,7 +310,11 @@ export const COMMANDS = [
310
310
  aliases: ['tab_new', 'new_tab', 'tab_create', 'create_tab'],
311
311
  params: [
312
312
  { name: 'url', type: 'string', required: true, description: '要打开的 URL' },
313
- { name: 'active', type: 'boolean', description: '是否激活新 Tab,默认 false' },
313
+ {
314
+ name: 'active',
315
+ type: 'boolean',
316
+ description: '是否激活目标 Tab 并恢复最小化窗口,默认 false;响应返回 activation 验证结果',
317
+ },
314
318
  {
315
319
  name: 'openerTabId',
316
320
  type: 'number',
@@ -440,14 +444,14 @@ export const COMMANDS = [
440
444
  { name: 'tabId', type: 'number', required: true, description: '目标标签页 ID' },
441
445
  ],
442
446
  examples: [
443
- `page_click --payload '{"text":"提交"}'`,
444
- `page_click --payload '{"text":"退款明细","role":"button"}'`,
445
- `page_click --payload '{"text":"确定","scope":"@e12"}'`,
446
- `page_click --payload '{"selector":"@e3"}'`,
447
- `page_click --payload '{"selector":".submit-btn"}'`,
448
- `page_click --payload '{"selector":".gesture-btn","clickMode":"touch"}'`,
449
- `page_click --payload '{"point":{"x":336,"y":117}}'`,
450
- `page_click --payload '{"point":{"x":196,"y":240},"coordinateSpace":"active-frame"}'`,
447
+ `page_click --payload '{"tabId":12345,"text":"提交"}'`,
448
+ `page_click --payload '{"tabId":12345,"text":"退款明细","role":"button"}'`,
449
+ `page_click --payload '{"tabId":12345,"text":"确定","scope":"@e12"}'`,
450
+ `page_click --payload '{"tabId":12345,"selector":"@e3"}'`,
451
+ `page_click --payload '{"tabId":12345,"selector":".submit-btn"}'`,
452
+ `page_click --payload '{"tabId":12345,"selector":".gesture-btn","clickMode":"touch"}'`,
453
+ `page_click --payload '{"tabId":12345,"point":{"x":336,"y":117}}'`,
454
+ `page_click --payload '{"tabId":12345,"point":{"x":196,"y":240},"coordinateSpace":"active-frame"}'`,
451
455
  ],
452
456
  },
453
457
  {
@@ -481,8 +485,8 @@ export const COMMANDS = [
481
485
  { name: 'tabId', type: 'number', required: true, description: '目标标签页 ID' },
482
486
  ],
483
487
  examples: [
484
- `page_drag --payload '{"from":{"x":350,"y":80},"to":{"x":80,"y":80}}'`,
485
- `page_drag --payload '{"from":"@e3","to":"#drop-zone","dragMode":"mouse"}'`,
488
+ `page_drag --payload '{"tabId":12345,"from":{"x":350,"y":80},"to":{"x":80,"y":80}}'`,
489
+ `page_drag --payload '{"tabId":12345,"from":"@e3","to":"#drop-zone","dragMode":"mouse"}'`,
486
490
  ],
487
491
  },
488
492
  {
@@ -501,7 +505,7 @@ export const COMMANDS = [
501
505
  PAGE_DIAGNOSTICS_PARAM,
502
506
  { name: 'tabId', type: 'number', required: true, description: '目标标签页 ID' },
503
507
  ],
504
- examples: [`page_type --payload '{"selector":"@e6","text":"搜索关键词"}'`],
508
+ examples: [`page_type --payload '{"tabId":12345,"selector":"@e6","text":"搜索关键词"}'`],
505
509
  },
506
510
  {
507
511
  name: 'page_hover',
@@ -517,11 +521,11 @@ export const COMMANDS = [
517
521
  PAGE_DIAGNOSTICS_PARAM,
518
522
  { name: 'tabId', type: 'number', required: true, description: '目标标签页 ID' },
519
523
  ],
520
- examples: [`page_hover --payload '{"selector":".nav-menu"}'`],
524
+ examples: [`page_hover --payload '{"tabId":12345,"selector":".nav-menu"}'`],
521
525
  },
522
526
  {
523
527
  name: 'page_scroll',
524
- description: '滚动页面或指定容器',
528
+ description: '滚动页面或指定容器;页面根不可滚动时自动发现活动滚动区',
525
529
  params: [
526
530
  {
527
531
  name: 'direction',
@@ -545,10 +549,10 @@ export const COMMANDS = [
545
549
  { name: 'tabId', type: 'number', required: true, description: '目标标签页 ID' },
546
550
  ],
547
551
  examples: [
548
- `page_scroll --payload '{"direction":"down"}'`,
549
- `page_scroll --payload '{"direction":"bottom"}'`,
550
- `page_scroll --payload '{"selector":".virtual-list","direction":"down","distance":800}'`,
551
- `page_scroll --payload '{"selector":"@e8","containerPolicy":"nearest","direction":"bottom"}'`,
552
+ `page_scroll --payload '{"tabId":12345,"direction":"down"}'`,
553
+ `page_scroll --payload '{"tabId":12345,"direction":"bottom"}'`,
554
+ `page_scroll --payload '{"tabId":12345,"selector":".virtual-list","direction":"down","distance":800}'`,
555
+ `page_scroll --payload '{"tabId":12345,"selector":"@e8","containerPolicy":"nearest","direction":"bottom"}'`,
552
556
  ],
553
557
  },
554
558
  {
@@ -569,7 +573,46 @@ export const COMMANDS = [
569
573
  PAGE_DIAGNOSTICS_PARAM,
570
574
  { name: 'tabId', type: 'number', required: true, description: '目标标签页 ID' },
571
575
  ],
572
- examples: [`page_eval --payload '{"expression":"document.title"}'`],
576
+ examples: [`page_eval --payload '{"tabId":12345,"expression":"document.title"}'`],
577
+ },
578
+ {
579
+ name: 'page_inspect',
580
+ description: '查询 DOM 元素的数量、边框盒、计算样式、遮挡、溢出和最近滚动容器',
581
+ params: [
582
+ {
583
+ name: 'selector',
584
+ type: 'string',
585
+ description: '原生 CSS、page_snapshot 返回的 @eN ref,或 DevTools Elements 当前选区 $0;做全页溢出诊断时可省略',
586
+ },
587
+ {
588
+ name: 'filter',
589
+ type: '"all" | "overflowing" | "horizontal-overflow" | "vertical-overflow" | "scrollable"',
590
+ description: '结果过滤;省略 selector 时必须指定非 all 的过滤条件',
591
+ },
592
+ {
593
+ name: 'styles',
594
+ type: 'string[]',
595
+ description: '要返回的计算样式属性,默认 display/position/box-sizing/overflow-x/overflow-y',
596
+ },
597
+ {
598
+ name: 'maxResults',
599
+ type: 'number',
600
+ description: '最多返回的明细数,默认 20,最大 100;未触发 scanTruncated 时 count 为完整命中数',
601
+ },
602
+ {
603
+ name: 'includeOuterHTML',
604
+ type: 'boolean',
605
+ description: '是否返回 outerHTML(最多 3000 字符);$0 默认 true,其他目标默认 false',
606
+ },
607
+ { name: 'tabId', type: 'number', required: true, description: '目标标签页 ID' },
608
+ ],
609
+ examples: [
610
+ `page_inspect --payload '{"tabId":12345,"selector":".form-field","styles":["display","width"]}'`,
611
+ `page_inspect --payload '{"tabId":12345,"selector":"@e8"}'`,
612
+ `page_inspect --payload '{"tabId":12345,"selector":"$0"}'`,
613
+ `page_inspect --payload '{"tabId":12345,"filter":"horizontal-overflow"}'`,
614
+ `page_inspect --payload '{"tabId":12345,"filter":"scrollable"}'`,
615
+ ],
573
616
  },
574
617
  {
575
618
  name: 'page_press',
@@ -582,22 +625,38 @@ export const COMMANDS = [
582
625
  description: '按键名称:Enter/Tab/Escape/Backspace 等',
583
626
  },
584
627
  { name: 'modifiers', type: 'string[]', description: '修饰键数组:ctrl/alt/shift/meta/cmd' },
628
+ {
629
+ name: 'pressMode',
630
+ type: '"auto" | "dom" | "keyboard"',
631
+ description: '派发模式;auto 默认在隐藏页降级为 DOM 键盘事件',
632
+ },
585
633
  PAGE_OBSERVE_PARAM,
586
634
  PAGE_DIAGNOSTICS_PARAM,
587
635
  { name: 'tabId', type: 'number', required: true, description: '目标标签页 ID' },
588
636
  ],
589
- examples: [`page_press --payload '{"key":"Enter"}'`],
637
+ examples: [`page_press --payload '{"tabId":12345,"key":"Enter"}'`],
590
638
  },
591
639
  {
592
640
  name: 'page_wait',
593
- description: '等待指定时间、元素出现或页面条件成立',
641
+ description: '等待指定时间、元素状态、可见文本或页面条件成立',
594
642
  params: [
595
- { name: 'time', type: 'number', description: '等待毫秒数(与 selector 二选一)' },
643
+ {
644
+ name: 'time',
645
+ type: 'number',
646
+ description: '等待毫秒数(与 selector/text/condition 四选一)',
647
+ },
596
648
  {
597
649
  name: 'selector',
598
650
  type: 'string',
599
- description: '等待元素出现的 CSS 选择器(与 time/condition 三选一)',
651
+ description: '目标 CSS 选择器(与 time/text/condition 四选一)',
652
+ },
653
+ {
654
+ name: 'state',
655
+ type: '"attached" | "detached" | "visible" | "hidden"',
656
+ description: 'selector 的目标状态,默认 attached',
600
657
  },
658
+ { name: 'text', type: 'string', description: '等待页面出现的可见文本' },
659
+ { name: 'exact', type: 'boolean', description: 'text 是否精确匹配,默认 false' },
601
660
  {
602
661
  name: 'condition',
603
662
  type: 'string',
@@ -608,9 +667,11 @@ export const COMMANDS = [
608
667
  { name: 'tabId', type: 'number', required: true, description: '目标标签页 ID' },
609
668
  ],
610
669
  examples: [
611
- `page_wait --payload '{"time":1000}'`,
612
- `page_wait --payload '{"selector":".loaded"}'`,
613
- `page_wait --payload '{"condition":"window.appReady === true","timeout":30000}'`,
670
+ `page_wait --payload '{"tabId":12345,"time":1000}'`,
671
+ `page_wait --payload '{"tabId":12345,"selector":".dialog","state":"visible"}'`,
672
+ `page_wait --payload '{"tabId":12345,"selector":".loading","state":"hidden"}'`,
673
+ `page_wait --payload '{"tabId":12345,"text":"提交成功"}'`,
674
+ `page_wait --payload '{"tabId":12345,"condition":"window.appReady === true","timeout":30000}'`,
614
675
  ],
615
676
  },
616
677
  {
@@ -656,29 +717,29 @@ export const COMMANDS = [
656
717
  { name: 'tabId', type: 'number', required: true, description: '目标标签页 ID' },
657
718
  ],
658
719
  examples: [
659
- `page_upload --payload '{"selector":"#file-input","filePaths":["/Users/me/photo.jpg"]}'`,
720
+ `page_upload --payload '{"tabId":12345,"selector":"#file-input","filePaths":["/Users/me/photo.jpg"]}'`,
660
721
  ],
661
722
  },
662
723
  // ── 页面感知 ──────────────────────────────────────────────────────────────
663
724
  {
664
725
  name: 'page_snapshot',
665
- description: '获取页面无障碍树快照,支持完整、交互元素或当前视口范围(含 @ref)',
726
+ description: '获取带 @ref 的页面结构快照,默认使用无障碍树,也可显式读取渲染 DOM',
666
727
  params: [
667
728
  { name: 'depth', type: 'number', description: '树深度,默认 15,复杂页面可调大' },
668
729
  {
669
730
  name: 'mode',
670
- type: '"full" | "interactive" | "viewport"',
671
- description: '输出范围,默认 full;interactive 只保留当前视口内的语义控件;长列表优先使用 viewport',
731
+ type: '"full" | "interactive" | "viewport" | "dom"',
732
+ description: '默认 full;interactive/viewport 裁剪 AX 树;AX 信息缺失时可显式使用 dom 读取渲染 DOM',
672
733
  },
673
734
  {
674
735
  name: 'rootSelector',
675
736
  type: 'string',
676
- description: '只获取指定 CSS 元素的 AX 子树,可与 mode 组合;与 rootRef 互斥',
737
+ description: '只获取指定 CSS 元素的局部子树,可与 mode 组合;与 rootRef 互斥',
677
738
  },
678
739
  {
679
740
  name: 'rootRef',
680
741
  type: 'string',
681
- description: '以已有 @eN ref 为根获取局部 AX 子树;与 rootSelector 互斥',
742
+ description: '以已有 @eN ref 为根获取局部子树;与 rootSelector 互斥',
682
743
  },
683
744
  {
684
745
  name: 'ancestorDepth',
@@ -688,7 +749,7 @@ export const COMMANDS = [
688
749
  {
689
750
  name: 'query',
690
751
  type: '{ text?: string; role?: string; exact?: boolean }',
691
- description: '服务端过滤 AX 树,只保留按 accessibility name / role 命中的节点及祖先路径',
752
+ description: '服务端按 name / role 过滤当前模式的树,只保留命中节点及祖先路径',
692
753
  },
693
754
  { name: 'maxNodes', type: 'number', description: '最多输出节点数,0 表示不限制' },
694
755
  {
@@ -699,8 +760,9 @@ export const COMMANDS = [
699
760
  { name: 'tabId', type: 'number', required: true, description: '目标标签页 ID' },
700
761
  ],
701
762
  examples: [
702
- 'page_snapshot',
763
+ `page_snapshot --payload '{"tabId":12345}'`,
703
764
  `page_snapshot --payload '{"tabId":1,"mode":"viewport"}'`,
765
+ `page_snapshot --payload '{"tabId":1,"mode":"dom"}'`,
704
766
  `page_snapshot --payload '{"tabId":1,"rootSelector":"[role=dialog]"}'`,
705
767
  `page_snapshot --payload '{"tabId":1,"rootRef":"@e8","ancestorDepth":1}'`,
706
768
  `page_snapshot --payload '{"tabId":1,"query":{"text":"保存","role":"button"}}'`,
@@ -717,28 +779,9 @@ export const COMMANDS = [
717
779
  { name: 'tabId', type: 'number', required: true, description: '目标标签页 ID' },
718
780
  ],
719
781
  examples: [
720
- 'page_screenshot --output ./screenshot.png',
721
- `page_screenshot --payload '{"selector":".product-card"}' --output ./card.png`,
722
- ],
723
- },
724
- {
725
- name: 'page_selected_element',
726
- description: '获取 DevTools Elements 面板当前选中元素的详细信息',
727
- outputFlag: true,
728
- params: [
729
- {
730
- name: 'includeOuterHTML',
731
- type: 'boolean',
732
- description: '是否返回 outerHTML(最多 3000 字符),默认 true',
733
- },
734
- {
735
- name: 'includeScreenshot',
736
- type: 'boolean',
737
- description: '是否附带元素截图,默认 false;指定 --output 时自动开启',
738
- },
739
- { name: 'tabId', type: 'number', required: true, description: '目标标签页 ID' },
782
+ `page_screenshot --payload '{"tabId":12345}' --output ./screenshot.png`,
783
+ `page_screenshot --payload '{"tabId":12345,"selector":".product-card"}' --output ./card.png`,
740
784
  ],
741
- examples: ['page_selected_element', 'page_selected_element --output ./element.png'],
742
785
  },
743
786
  // ── 移动端模拟 ────────────────────────────────────────────────────────────
744
787
  {
@@ -786,10 +829,10 @@ export const COMMANDS = [
786
829
  { name: 'tabId', type: 'number', required: true, description: '目标标签页 ID' },
787
830
  ],
788
831
  examples: [
789
- `set_device_emulation --payload '{"enabled":true,"preset":"iphone-17-pro"}'`,
790
- `set_device_emulation --payload '{"enabled":true,"preset":"pixel-11","orientation":"landscape"}'`,
791
- `set_device_emulation --payload '{"enabled":true,"preset":"ipad-mini-a17-pro","orientation":"landscape","deviceShell":true,"splitScreen":true}'`,
792
- `set_device_emulation --payload '{"enabled":false}'`,
832
+ `set_device_emulation --payload '{"tabId":12345,"enabled":true,"preset":"iphone-17-pro"}'`,
833
+ `set_device_emulation --payload '{"tabId":12345,"enabled":true,"preset":"pixel-11","orientation":"landscape"}'`,
834
+ `set_device_emulation --payload '{"tabId":12345,"enabled":true,"preset":"ipad-mini-a17-pro","orientation":"landscape","deviceShell":true,"splitScreen":true}'`,
835
+ `set_device_emulation --payload '{"tabId":12345,"enabled":false}'`,
793
836
  ],
794
837
  },
795
838
  {
@@ -829,14 +872,14 @@ export const COMMANDS = [
829
872
  { name: 'tabId', type: 'number', required: true, description: '目标标签页 ID' },
830
873
  ],
831
874
  examples: [
832
- `set_app_profile --payload '{"enabled":true,"profile":"fliggy"}'`,
833
- `set_app_profile --payload '{"enabled":true,"profile":"fliggy","mtopEnv":"pre"}'`,
834
- `set_app_profile --payload '{"enabled":false,"mtopEnv":"prod"}'`,
835
- `set_app_profile --payload '{"enabled":true,"profile":"fliggy","emulation":{}}'`,
836
- `set_app_profile --payload '{"enabled":true,"profile":"alipay","emulation":{"preset":"pixel-11","deviceShell":true}}'`,
837
- `set_app_profile --payload '{"enabled":true,"profile":"fliggy","emulation":{"preset":"ipad-mini-a17-pro","orientation":"landscape","deviceShell":true,"splitScreen":true}}'`,
838
- `set_app_profile --payload '{"enabled":false}'`,
839
- `set_app_profile --payload '{"enabled":false,"emulation":{}}'`,
875
+ `set_app_profile --payload '{"tabId":12345,"enabled":true,"profile":"fliggy"}'`,
876
+ `set_app_profile --payload '{"tabId":12345,"enabled":true,"profile":"fliggy","mtopEnv":"pre"}'`,
877
+ `set_app_profile --payload '{"tabId":12345,"enabled":false,"mtopEnv":"prod"}'`,
878
+ `set_app_profile --payload '{"tabId":12345,"enabled":true,"profile":"fliggy","emulation":{}}'`,
879
+ `set_app_profile --payload '{"tabId":12345,"enabled":true,"profile":"alipay","emulation":{"preset":"pixel-11","deviceShell":true}}'`,
880
+ `set_app_profile --payload '{"tabId":12345,"enabled":true,"profile":"fliggy","emulation":{"preset":"ipad-mini-a17-pro","orientation":"landscape","deviceShell":true,"splitScreen":true}}'`,
881
+ `set_app_profile --payload '{"tabId":12345,"enabled":false}'`,
882
+ `set_app_profile --payload '{"tabId":12345,"enabled":false,"emulation":{}}'`,
840
883
  ],
841
884
  },
842
885
  {
@@ -343,16 +343,11 @@ export interface RulesResult {
343
343
  rules: Array<Record<string, unknown>>;
344
344
  }
345
345
  export interface PageScreenshotParams {
346
- tabId?: number;
346
+ tabId: number;
347
347
  selector?: string;
348
348
  format?: 'png' | 'jpeg';
349
349
  quality?: number;
350
350
  }
351
- export interface PageSelectedElementParams {
352
- tabId?: number;
353
- includeOuterHTML?: boolean;
354
- includeScreenshot?: boolean;
355
- }
356
351
  export declare const BROWSER_DEVICE_PRESET_NAMES: readonly ["iphone-17-pro", "iphone-17e", "pixel-11", "ipad-mini-a17-pro", "galaxy-s26", "pura-x-max", "iphone-15-pro", "iphone-se", "pixel-8", "ipad-mini", "galaxy-s23"];
357
352
  export type BrowserDevicePresetName = (typeof BROWSER_DEVICE_PRESET_NAMES)[number];
358
353
  export interface BrowserEmulationOptions {
@@ -370,7 +365,7 @@ export interface BrowserEmulationOptions {
370
365
  /** App 容器横屏时将根页面与业务页面分置左右 WebView;仅与 deviceShell、App 档案同时生效。 */
371
366
  splitScreen?: boolean;
372
367
  }
373
- export type AppBridgeConfigBehavior = 'navigate' | 'closeAll' | 'closeBackData' | 'postMessage' | 'notifySubscribe' | 'notifyUnsubscribe' | 'notifyPost' | 'sharedFileRead' | 'sharedFileWrite' | 'sharedDataGet' | 'sharedDataSet' | 'legacyBroadcastCreate' | 'legacyBroadcastPost' | 'legacyBroadcastClose' | 'memoryGet' | 'memorySet' | 'memoryDelete' | 'availabilityMap' | 'userInfo' | 'networkInfo' | 'geolocation' | 'permission' | 'prefetch' | 'fptTrack' | 'mtopStream' | 'previewFile' | 'toast' | 'unsupportedNativeInput' | 'payment' | 'userTrack' | 'calendar' | 'networkQualityMonitor' | 'beaconRequest' | 'voiceRecognition';
368
+ export type AppBridgeConfigBehavior = 'navigate' | 'closeAll' | 'closeBackData' | 'postMessage' | 'notifySubscribe' | 'notifyUnsubscribe' | 'notifyPost' | 'sharedFileRead' | 'sharedFileWrite' | 'sharedDataGet' | 'sharedDataSet' | 'legacyBroadcastCreate' | 'legacyBroadcastPost' | 'legacyBroadcastClose' | 'memoryGet' | 'memorySet' | 'memoryDelete' | 'availabilityMap' | 'userInfo' | 'networkInfo' | 'geolocation' | 'permission' | 'imagePicker' | 'prefetch' | 'fptTrack' | 'mtopStream' | 'previewFile' | 'toast' | 'unsupportedNativeInput' | 'payment' | 'userTrack' | 'calendar' | 'networkQualityMonitor' | 'beaconRequest' | 'voiceRecognition';
374
369
  /** 单个桥方法的声明式覆盖;行为、固定回包、成功空实现三选一。 */
375
370
  export interface AppBridgeMethodConfig {
376
371
  behavior?: AppBridgeConfigBehavior;
@@ -419,7 +414,7 @@ export interface TabOpenParams {
419
414
  export declare const APP_PROFILE_NAMES: readonly ["fliggy", "taobao", "wechat", "tmall", "alipay", "koubei", "taobao-tj", "taobao-live", "xianyu", "etao", "eleme", "damai", "btrip", "amap", "qianwen", "lingyou", "didi", "easybike"];
420
415
  export type AppProfileName = (typeof APP_PROFILE_NAMES)[number];
421
416
  export interface SetAppProfileParams {
422
- tabId?: number;
417
+ tabId: number;
423
418
  /** false 时清除该 tab 的容器模拟并刷新 */
424
419
  enabled: boolean;
425
420
  /** 容器档案名(enabled=true 时必填) */
@@ -461,7 +456,7 @@ export interface PageDiagnosticsOptions {
461
456
  }
462
457
  export type PageDiagnosticsSetting = PageDiagnosticsOptions | boolean;
463
458
  export interface PageClickParams {
464
- tabId?: number;
459
+ tabId: number;
465
460
  selector?: string;
466
461
  text?: string;
467
462
  point?: {
@@ -485,7 +480,7 @@ export interface PageDragPoint {
485
480
  }
486
481
  export type PageDragEndpoint = string | PageDragPoint;
487
482
  export interface PageDragParams {
488
- tabId?: number;
483
+ tabId: number;
489
484
  from: PageDragEndpoint;
490
485
  to: PageDragEndpoint;
491
486
  dragMode?: 'auto' | 'dom' | 'mouse' | 'touch';
@@ -494,7 +489,7 @@ export interface PageDragParams {
494
489
  diagnostics?: PageDiagnosticsSetting;
495
490
  }
496
491
  export interface PageTypeParams {
497
- tabId?: number;
492
+ tabId: number;
498
493
  selector: string;
499
494
  text: string;
500
495
  clearFirst?: boolean;
@@ -502,7 +497,7 @@ export interface PageTypeParams {
502
497
  diagnostics?: PageDiagnosticsSetting;
503
498
  }
504
499
  export interface PageScrollParams {
505
- tabId?: number;
500
+ tabId: number;
506
501
  direction: 'up' | 'down' | 'top' | 'bottom';
507
502
  distance?: number;
508
503
  selector?: string;
@@ -511,13 +506,13 @@ export interface PageScrollParams {
511
506
  diagnostics?: PageDiagnosticsSetting;
512
507
  }
513
508
  export interface PageHoverParams {
514
- tabId?: number;
509
+ tabId: number;
515
510
  selector: string;
516
511
  observe?: PageObservationWaitOptions | false;
517
512
  diagnostics?: PageDiagnosticsSetting;
518
513
  }
519
514
  export interface PageEvalParams {
520
- tabId?: number;
515
+ tabId: number;
521
516
  expression: string;
522
517
  frameId?: string;
523
518
  awaitPromise?: boolean;
@@ -530,7 +525,7 @@ export interface PageSnapshotQuery {
530
525
  exact?: boolean;
531
526
  }
532
527
  export interface PageSnapshotParams {
533
- tabId?: number;
528
+ tabId: number;
534
529
  depth?: number;
535
530
  maxChars?: number;
536
531
  maxNodes?: number;
@@ -538,46 +533,65 @@ export interface PageSnapshotParams {
538
533
  rootRef?: string;
539
534
  ancestorDepth?: number;
540
535
  query?: PageSnapshotQuery;
541
- mode?: 'full' | 'interactive' | 'viewport';
536
+ mode?: 'full' | 'interactive' | 'viewport' | 'dom';
537
+ }
538
+ export type PageInspectFilter = 'all' | 'overflowing' | 'horizontal-overflow' | 'vertical-overflow' | 'scrollable';
539
+ export interface PageInspectParams {
540
+ tabId: number;
541
+ /** Native CSS selector, a page_snapshot @ref, or DevTools' current selection ($0). */
542
+ selector?: string;
543
+ /** Limit results after filtering. Defaults to 20, maximum 100. */
544
+ maxResults?: number;
545
+ /** Computed-style properties to return. Defaults to common layout properties. */
546
+ styles?: string[];
547
+ /** Page-wide or selector-scoped layout filter. Defaults to all. */
548
+ filter?: PageInspectFilter;
549
+ /** Include a trimmed outerHTML string for returned matches. Defaults to true for $0. */
550
+ includeOuterHTML?: boolean;
542
551
  }
543
552
  export interface PagePressParams {
544
- tabId?: number;
553
+ tabId: number;
545
554
  key: string;
546
555
  modifiers?: string[];
556
+ /** Dispatch strategy. Auto uses DOM events when the page is hidden. */
557
+ pressMode?: 'auto' | 'dom' | 'keyboard';
547
558
  observe?: PageObservationWaitOptions | false;
548
559
  diagnostics?: PageDiagnosticsSetting;
549
560
  }
550
561
  export interface PageWaitParams {
551
- tabId?: number;
562
+ tabId: number;
552
563
  time?: number;
553
564
  selector?: string;
565
+ state?: 'attached' | 'detached' | 'visible' | 'hidden';
566
+ text?: string;
567
+ exact?: boolean;
554
568
  condition?: string;
555
569
  timeout?: number;
556
570
  interval?: number;
557
571
  }
558
572
  export interface PageNavigateParams {
559
- tabId?: number;
573
+ tabId: number;
560
574
  url?: string;
561
575
  refresh?: boolean;
562
576
  history?: 'back' | 'forward';
563
577
  }
564
578
  export interface PageUploadParams {
565
- tabId?: number;
579
+ tabId: number;
566
580
  selector: string;
567
581
  filePaths: string[];
568
582
  observe?: PageObservationWaitOptions | false;
569
583
  diagnostics?: PageDiagnosticsSetting;
570
584
  }
571
585
  export interface PageFramesParams {
572
- tabId?: number;
586
+ tabId: number;
573
587
  }
574
588
  export interface SetDeviceEmulationParams extends BrowserEmulationOptions {
575
- tabId?: number;
589
+ tabId: number;
576
590
  enabled: boolean;
577
591
  reload?: boolean;
578
592
  }
579
593
  export interface SetTimezoneParams {
580
- tabId?: number;
594
+ tabId: number;
581
595
  timezone: string;
582
596
  }
583
597
  export interface SetTimezoneResult {
@@ -585,7 +599,7 @@ export interface SetTimezoneResult {
585
599
  timezone: string | null;
586
600
  }
587
601
  export interface GetCookieParams {
588
- tabId?: number;
602
+ tabId: number;
589
603
  name: string;
590
604
  /** Cookie lookup URL; defaults to the current tab URL. */
591
605
  url?: string;
@@ -602,7 +616,7 @@ export interface GetCookieResult {
602
616
  path?: string;
603
617
  }
604
618
  export interface SetCookieParams {
605
- tabId?: number;
619
+ tabId: number;
606
620
  name: string;
607
621
  value: string;
608
622
  domain?: string;
@@ -699,10 +713,6 @@ export interface BrowserActionMap {
699
713
  request: PageScreenshotParams;
700
714
  response: unknown;
701
715
  };
702
- page_selected_element: {
703
- request: PageSelectedElementParams;
704
- response: unknown;
705
- };
706
716
  tab_open: {
707
717
  request: TabOpenParams;
708
718
  response: unknown;
@@ -739,6 +749,10 @@ export interface BrowserActionMap {
739
749
  request: PageEvalParams;
740
750
  response: unknown;
741
751
  };
752
+ page_inspect: {
753
+ request: PageInspectParams;
754
+ response: unknown;
755
+ };
742
756
  page_snapshot: {
743
757
  request: PageSnapshotParams;
744
758
  response: unknown;
@@ -797,6 +811,10 @@ export type BrowserActionRequest<A extends BrowserAction> = BrowserActionMap[A][
797
811
  export type BrowserActionResponse<A extends BrowserAction> = BrowserActionMap[A]['response'];
798
812
  export type BrowserCommandAction = Exclude<BrowserAction, 'browser_select_browser'>;
799
813
  export type ExtensionBrowserAction = Exclude<BrowserCommandAction, 'browser_list' | 'browser_launch' | 'browser_close'>;
814
+ export declare const TAB_ID_REQUIRED_ACTIONS: readonly ["page_screenshot", "tab_close", "page_click", "page_drag", "page_type", "page_scroll", "page_hover", "page_eval", "page_inspect", "page_snapshot", "page_press", "page_wait", "page_navigate", "page_upload", "page_frames", "set_device_emulation", "set_app_profile", "set_timezone", "get_cookie", "set_cookie", "run_actions"];
815
+ export type TabIdRequiredAction = (typeof TAB_ID_REQUIRED_ACTIONS)[number];
816
+ export declare function actionRequiresTabId(action: unknown): action is TabIdRequiredAction;
817
+ export declare function validateRequiredActionTabId(action: string, data: unknown): void;
800
818
  export declare const PAGE_ACT_ACTIONS: readonly ["page_click", "page_drag", "page_type", "page_hover", "page_scroll", "page_press", "page_upload", "page_eval"];
801
819
  export type PageActAction = (typeof PAGE_ACT_ACTIONS)[number];
802
820
  export declare const BROWSER_ACTIONS: {
@@ -817,7 +835,6 @@ export declare const BROWSER_ACTIONS: {
817
835
  readonly browser_launch: true;
818
836
  readonly browser_close: true;
819
837
  readonly page_screenshot: true;
820
- readonly page_selected_element: true;
821
838
  readonly tab_open: true;
822
839
  readonly tab_close: true;
823
840
  readonly tab_list: true;
@@ -827,6 +844,7 @@ export declare const BROWSER_ACTIONS: {
827
844
  readonly page_scroll: true;
828
845
  readonly page_hover: true;
829
846
  readonly page_eval: true;
847
+ readonly page_inspect: true;
830
848
  readonly page_snapshot: true;
831
849
  readonly page_press: true;
832
850
  readonly page_wait: true;
@@ -858,7 +876,6 @@ export declare const BROWSER_COMMAND_ACTIONS: {
858
876
  readonly browser_launch: true;
859
877
  readonly browser_close: true;
860
878
  readonly page_screenshot: true;
861
- readonly page_selected_element: true;
862
879
  readonly tab_open: true;
863
880
  readonly tab_close: true;
864
881
  readonly tab_list: true;
@@ -868,6 +885,7 @@ export declare const BROWSER_COMMAND_ACTIONS: {
868
885
  readonly page_scroll: true;
869
886
  readonly page_hover: true;
870
887
  readonly page_eval: true;
888
+ readonly page_inspect: true;
871
889
  readonly page_snapshot: true;
872
890
  readonly page_press: true;
873
891
  readonly page_wait: true;
@@ -896,7 +914,6 @@ export declare const EXTENSION_BROWSER_ACTIONS: {
896
914
  readonly send_mtop_request: true;
897
915
  readonly browser_release: true;
898
916
  readonly page_screenshot: true;
899
- readonly page_selected_element: true;
900
917
  readonly tab_open: true;
901
918
  readonly tab_close: true;
902
919
  readonly tab_list: true;
@@ -906,6 +923,7 @@ export declare const EXTENSION_BROWSER_ACTIONS: {
906
923
  readonly page_scroll: true;
907
924
  readonly page_hover: true;
908
925
  readonly page_eval: true;
926
+ readonly page_inspect: true;
909
927
  readonly page_snapshot: true;
910
928
  readonly page_press: true;
911
929
  readonly page_wait: true;