dsh-browser-view 0.3.4 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -6
- package/lib/client.js +1 -1
- package/lib/index.js +1081 -516
- package/lib/types/browser/reports.d.ts +7 -0
- package/lib/types/browser/session.d.ts +35 -3
- package/lib/types/browser/tools.d.ts +143 -2
- package/lib/types/browser/types.d.ts +30 -2
- package/lib/types/browser/walker.d.ts +42 -0
- package/package.json +2 -2
|
@@ -21,6 +21,13 @@ export interface RunRecord {
|
|
|
21
21
|
durationMs: number;
|
|
22
22
|
/** data 数据集模式时的行号(单次运行为 undefined)。 */
|
|
23
23
|
row?: number;
|
|
24
|
+
/** retryFailed 自动重试统计(F2:attempted 总尝试次数,recovered 经重试挽回的步骤数)。 */
|
|
25
|
+
retries?: {
|
|
26
|
+
attempted: number;
|
|
27
|
+
recovered: number;
|
|
28
|
+
};
|
|
29
|
+
/** 面板一键重跑产生的运行所引用的原 runId(F2)。 */
|
|
30
|
+
retryOf?: string;
|
|
24
31
|
results: RunStepResult[];
|
|
25
32
|
}
|
|
26
33
|
/** 报告存储目录($DSH_HOME/.dsh-browser/reports)。 */
|
|
@@ -16,13 +16,37 @@ export declare function pageRef(page: Page, ref: string): RefEntry | undefined;
|
|
|
16
16
|
export declare function clearPageRefs(page: Page): void;
|
|
17
17
|
/** 取页面当前完整 ref 表(browser_find 增量续号合并用;无则空 Map)。 */
|
|
18
18
|
export declare function pageRefsOf(page: Page): Map<string, RefEntry>;
|
|
19
|
-
|
|
19
|
+
/** 一个历史版本的快照内容(text/aria 两种模式共用同一条版本序列)。 */
|
|
20
|
+
export interface SnapshotEntry {
|
|
20
21
|
version: number;
|
|
21
22
|
text: string;
|
|
22
23
|
aria: string;
|
|
23
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* F3 增量快照历史:per-page 环形数组保存最近 K 个版本(K = snapshotHistory,
|
|
27
|
+
* 默认 5,上限 20;text 模式 ≤20KB/版本 → 内存上界 ≈100KB/page)。
|
|
28
|
+
* 任意 since ∈ [latest-K+1, latest] 都能 diff;更旧版本回落全量标 stale。
|
|
29
|
+
*/
|
|
30
|
+
export interface SnapshotCache {
|
|
31
|
+
/** 最新版本号(单调递增,不因环形淘汰回退)。 */
|
|
32
|
+
version: number;
|
|
33
|
+
/** 最近 K 个版本,按 version 升序;长度 ≤ K。 */
|
|
34
|
+
history: SnapshotEntry[];
|
|
35
|
+
}
|
|
24
36
|
export declare function snapshotCacheOf(page: Page): SnapshotCache | undefined;
|
|
25
37
|
export declare function setSnapshotCache(page: Page, cache: SnapshotCache): void;
|
|
38
|
+
/** 环形容量钳制(1..20,非法值回落默认 5)。导出供测试。 */
|
|
39
|
+
export declare function snapshotCapacity(k: unknown): number;
|
|
40
|
+
/**
|
|
41
|
+
* 追加一个新版本并淘汰超限的最旧版本(纯逻辑,导出供测试)。
|
|
42
|
+
* cache 为 undefined 时从 version 1 开始;返回新缓存(不修改入参)。
|
|
43
|
+
*/
|
|
44
|
+
export declare function pushSnapshotVersion(cache: SnapshotCache | undefined, content: {
|
|
45
|
+
text: string;
|
|
46
|
+
aria: string;
|
|
47
|
+
}, capacity: unknown): SnapshotCache;
|
|
48
|
+
/** 按版本号取历史条目;不在环形窗口内(更旧/未知)返回 undefined。 */
|
|
49
|
+
export declare function snapshotVersionEntry(cache: SnapshotCache | undefined, version: number): SnapshotEntry | undefined;
|
|
26
50
|
/** 已保存的录制脚本:name → 步骤数组。 */
|
|
27
51
|
export declare const savedRecordings: Map<string, {
|
|
28
52
|
steps: ReplayStep[];
|
|
@@ -74,6 +98,12 @@ export declare function clearPendingConfirm(): void;
|
|
|
74
98
|
/** 面板提交审批决策;id 不匹配(已被新审批取代/超时清理)时返回 false。 */
|
|
75
99
|
export declare function resolveConfirm(id: string, decision: "allowed" | "denied"): boolean;
|
|
76
100
|
export declare function clearTestLog(): void;
|
|
101
|
+
/** live 工具调用开始(register 包装层调用)。 */
|
|
102
|
+
export declare function noteToolStart(): void;
|
|
103
|
+
/** live 工具调用结束(成功/失败都算结束)。 */
|
|
104
|
+
export declare function noteToolEnd(): void;
|
|
105
|
+
/** 当前在途的 live 工具调用数(0 = agent 空闲)。 */
|
|
106
|
+
export declare function activeToolCalls(): number;
|
|
77
107
|
/** window 上的回传 binding 名(须为合法 JS 标识符)。 */
|
|
78
108
|
export declare const HUMAN_BINDING = "__dshBrowserHumanEvent";
|
|
79
109
|
/** agent 即将/刚刚执行了 DOM 操作(register 包装层调用);1.5s 内的页内事件视为工具回声。 */
|
|
@@ -97,8 +127,10 @@ export declare function humanEventToStep(payload: unknown): {
|
|
|
97
127
|
* 页内注入的人工操作监听(addInitScript 序列化;每次导航自动重装)。
|
|
98
128
|
* 监听常驻但 node 侧只在录制中生效,关闭录制等价于"移除"。
|
|
99
129
|
* 只上报可交互元素上的 click 与表单控件的 change,避免逐键噪音。
|
|
130
|
+
* F5 收敛:cssPath 等元素描述来自 walker.ts 单一来源(构建期拼装注入),
|
|
131
|
+
* 不再持有内联副本;payload 字段语义与 v0.3 完全一致。
|
|
100
132
|
*/
|
|
101
|
-
export declare
|
|
133
|
+
export declare const installHumanRecorder: (payload: unknown) => void;
|
|
102
134
|
/** 网络请求/响应记录。 */
|
|
103
135
|
export interface NetworkEntry {
|
|
104
136
|
url: string;
|
|
@@ -149,7 +181,7 @@ export declare function tabList(): Promise<{
|
|
|
149
181
|
title: string;
|
|
150
182
|
}[]>;
|
|
151
183
|
export declare function closeBrowser(): Promise<void>;
|
|
152
|
-
/** Best-effort current page identity, safe when nothing is open. */
|
|
184
|
+
/** Best-effort current page identity, safe when nothing is open.title 有界防页面忙时挂起。 */
|
|
153
185
|
export declare function pageIdentity(page: Page): Promise<{
|
|
154
186
|
url: string;
|
|
155
187
|
title: string;
|
|
@@ -53,6 +53,10 @@ export declare function assignRefs(existing: Map<string, RefEntry>, matches: {
|
|
|
53
53
|
name: string;
|
|
54
54
|
selector: string;
|
|
55
55
|
ancestors: string[];
|
|
56
|
+
library?: string;
|
|
57
|
+
component?: string;
|
|
58
|
+
sourceFile?: string;
|
|
59
|
+
formLabel?: string;
|
|
56
60
|
}[], maxRefs: number): {
|
|
57
61
|
withRefs: {
|
|
58
62
|
ref: string;
|
|
@@ -60,12 +64,16 @@ export declare function assignRefs(existing: Map<string, RefEntry>, matches: {
|
|
|
60
64
|
name: string;
|
|
61
65
|
selector: string;
|
|
62
66
|
ancestors: string[];
|
|
67
|
+
library?: string;
|
|
68
|
+
component?: string;
|
|
69
|
+
sourceFile?: string;
|
|
70
|
+
formLabel?: string;
|
|
63
71
|
}[];
|
|
64
72
|
merged: Map<string, RefEntry>;
|
|
65
73
|
truncated: boolean;
|
|
66
74
|
};
|
|
67
75
|
/**
|
|
68
|
-
* 语义元素定位:按名称(或 id/data-testid)在可交互元素中查找,只返回命中的
|
|
76
|
+
* 语义元素定位:按名称(或 id/data-testid/组件名/源码文件)在可交互元素中查找,只返回命中的
|
|
69
77
|
* ref + 区域上下文,不输出全量 aria 树 —— 大页面定位单个目标时 token 开销
|
|
70
78
|
* 远小于 browser_snapshot { mode: "aria" }。返回的 ref 可直接用于
|
|
71
79
|
* click/type/select/press。零命中不抛错,附最相近候选供二次定位。
|
|
@@ -82,6 +90,10 @@ export declare function findTool(config: BrowserConfig, args: Record<string, any
|
|
|
82
90
|
}[] | undefined;
|
|
83
91
|
found: number;
|
|
84
92
|
matches: {
|
|
93
|
+
formLabel?: string | undefined;
|
|
94
|
+
sourceFile?: string | undefined;
|
|
95
|
+
component?: string | undefined;
|
|
96
|
+
library?: string | undefined;
|
|
85
97
|
ref: string;
|
|
86
98
|
role: string;
|
|
87
99
|
name: string;
|
|
@@ -144,6 +156,8 @@ export declare function pressTool(config: BrowserConfig, args: Record<string, an
|
|
|
144
156
|
title: string;
|
|
145
157
|
pressed: string;
|
|
146
158
|
}>;
|
|
159
|
+
/** 给本身无超时的 Playwright 调用(evaluate/allTextContents)加有界保护,防页面主线程忙时无限挂起。 */
|
|
160
|
+
export declare function withTimeout<T>(p: Promise<T>, ms: number, what: string): Promise<T>;
|
|
147
161
|
/**
|
|
148
162
|
* 下拉选择原语:原生 <select> 走 selectOption;组件库下拉(antd/element/listbox)
|
|
149
163
|
* 走「点击触发框 → 等待可见选项 → 按文本点击」。找不到选项时抛出错误并附当前可见
|
|
@@ -488,6 +502,33 @@ export declare function confirmTool(config: BrowserConfig, args: Record<string,
|
|
|
488
502
|
waitedMs: number;
|
|
489
503
|
detail: string;
|
|
490
504
|
}>;
|
|
505
|
+
/** auto 模式默认敏感文本模式(提交/删除/支付类)。 */
|
|
506
|
+
export declare const DEFAULT_SENSITIVE_PATTERNS: string[];
|
|
507
|
+
/** auto 模式默认参与判定的工具(已决:只拦 browser_click,type 误报率高)。 */
|
|
508
|
+
export declare const DEFAULT_SENSITIVE_TOOLS: string[];
|
|
509
|
+
/** 敏感判定的元素描述(与 walker describeElement 字段子集对应)。 */
|
|
510
|
+
export interface SensitiveDesc {
|
|
511
|
+
role: string;
|
|
512
|
+
name: string;
|
|
513
|
+
text: string;
|
|
514
|
+
id: string;
|
|
515
|
+
testid: string;
|
|
516
|
+
tag: string;
|
|
517
|
+
}
|
|
518
|
+
/**
|
|
519
|
+
* 纯逻辑:元素描述命中了哪些敏感模式(role/name/text/id/testid/tag 拼接后
|
|
520
|
+
* 子串匹配,大小写不敏感;空白模式忽略)。返回命中的模式列表(空 = 放行)。
|
|
521
|
+
* 导出供测试。
|
|
522
|
+
*/
|
|
523
|
+
export declare function sensitiveHits(desc: SensitiveDesc | null, patterns: string[]): string[];
|
|
524
|
+
/**
|
|
525
|
+
* auto 模式审批闸:命中敏感模式时经 confirmTool 弹审批等待用户决策,
|
|
526
|
+
* 拒绝/超时抛错(调用方该步失败),允许则返回继续执行原工具。
|
|
527
|
+
* 不满足前置条件(非 auto / 工具不在 sensitiveTools / 无模式 / 无活动页 /
|
|
528
|
+
* 无目标 selector / 页内取描述失败)一律直接放行,由原工具自行处理错误。
|
|
529
|
+
* page 参数仅供测试注入;缺省取当前活动页。
|
|
530
|
+
*/
|
|
531
|
+
export declare function confirmGate(config: BrowserConfig, tool: string, args: Record<string, any>, page?: Page | null): Promise<void>;
|
|
491
532
|
/** 断言:条件在 timeoutMs 内成立则通过,否则失败并自动截图存证据。visual 断言走像素比对。 */
|
|
492
533
|
export declare function assertTool(config: BrowserConfig, args: Record<string, any>, exec?: ToolRunContext): Promise<{
|
|
493
534
|
url: string;
|
|
@@ -551,6 +592,11 @@ export declare const SELECTOR_STEP_TOOLS: Set<string>;
|
|
|
551
592
|
/**
|
|
552
593
|
* 采集选择器指向元素的指纹(页内 evaluate;找不到元素返回 null)。
|
|
553
594
|
* 指纹是回放自愈的降级候选来源:testid / role+name / text / id / tag+text。
|
|
595
|
+
* F5 收敛:元素描述(role/name/text)改用 walker 单一来源
|
|
596
|
+
* (describeElement),与 aria 快照/find/录制回声共用同一套语义;相比旧
|
|
597
|
+
* 内联副本,role 推断更完整(slider/spinbutton/searchbox/heading 等),
|
|
598
|
+
* name 补齐 labelledby/label[for]/title 兜底 —— 指纹只作自愈降级候选,
|
|
599
|
+
* 语义增强只会让自愈命中率更高,不改变任何主链路行为。
|
|
554
600
|
*/
|
|
555
601
|
export declare function captureSelectorHint(page: Page, selector: string): Promise<SelectorHint | null>;
|
|
556
602
|
/** 由指纹生成自愈降级候选(按优先级排序;导出供测试)。 */
|
|
@@ -607,10 +653,12 @@ export declare function recordTool(args: Record<string, any>): Promise<{
|
|
|
607
653
|
steps?: undefined;
|
|
608
654
|
recordings?: undefined;
|
|
609
655
|
}>;
|
|
610
|
-
/** 回放选项(自愈开关与单次尝试超时,来自 config)。 */
|
|
656
|
+
/** 回放选项(自愈开关与单次尝试超时,来自 config;retryFailed 为自动重试次数)。 */
|
|
611
657
|
export interface ReplayOptions {
|
|
612
658
|
healing?: boolean;
|
|
613
659
|
healTimeoutMs?: number;
|
|
660
|
+
/** F2:步骤失败(含自愈链耗尽)后自动重试的次数,步骤间 500ms×n 线性退避。 */
|
|
661
|
+
retryFailed?: number;
|
|
614
662
|
}
|
|
615
663
|
/** 回放执行器(步骤 → 工具调用),由 register.ts 注入实现 map。支持选择器自愈。 */
|
|
616
664
|
export declare function runReplay(steps: ReplayStep[], impls: Record<string, (args: any) => Promise<unknown>>, failFast: boolean, opts?: ReplayOptions): Promise<{
|
|
@@ -618,6 +666,10 @@ export declare function runReplay(steps: ReplayStep[], impls: Record<string, (ar
|
|
|
618
666
|
passed: number;
|
|
619
667
|
failed: number;
|
|
620
668
|
healedCount: number;
|
|
669
|
+
retries?: {
|
|
670
|
+
attempted: number;
|
|
671
|
+
recovered: number;
|
|
672
|
+
};
|
|
621
673
|
stoppedAt?: number;
|
|
622
674
|
results: any[];
|
|
623
675
|
}>;
|
|
@@ -639,7 +691,73 @@ export declare function workspaceFilePath(cwd: string, file: string): string;
|
|
|
639
691
|
* 规则化抽取:fields 定义抽取结构,next 选择器驱动翻页(maxPages 上限),
|
|
640
692
|
* 行数超 maxRows 截断;format/file 控制序列化与落盘(json/csv/jsonl/markdown)。
|
|
641
693
|
*/
|
|
694
|
+
/** suggest 采集的表格单元格信息(页内采集,纯函数消费)。 */
|
|
695
|
+
export interface SuggestCell {
|
|
696
|
+
text: string;
|
|
697
|
+
href?: string;
|
|
698
|
+
src?: string;
|
|
699
|
+
}
|
|
700
|
+
/** suggest 页内分析结果(自包含 injectWalker 注入采集)。 */
|
|
701
|
+
export interface SuggestAnalysis {
|
|
702
|
+
ok: boolean;
|
|
703
|
+
/** table: 表格行模式;list: 重复卡片/列表项模式。 */
|
|
704
|
+
kind?: "table" | "list";
|
|
705
|
+
/** 行/卡片选择器(抽取 fields 顶层的 multiple selector)。 */
|
|
706
|
+
rowSelector?: string;
|
|
707
|
+
headerTexts?: string[];
|
|
708
|
+
cells?: SuggestCell[];
|
|
709
|
+
item?: SuggestCell;
|
|
710
|
+
reason?: string;
|
|
711
|
+
overview?: {
|
|
712
|
+
links: number;
|
|
713
|
+
images: number;
|
|
714
|
+
buttons: number;
|
|
715
|
+
headings: number;
|
|
716
|
+
rows: number;
|
|
717
|
+
textChars: number;
|
|
718
|
+
};
|
|
719
|
+
}
|
|
720
|
+
/** 字段名净化:空白→下划线,限长 30,空回落 col_N。导出供测试。 */
|
|
721
|
+
export declare function suggestFieldName(header: string | undefined, index: number): string;
|
|
722
|
+
/**
|
|
723
|
+
* 纯逻辑:由表头与首行单元格特征推断表格 fields(单元格文本/链接 href/图片 src)。
|
|
724
|
+
* 返回可直接放进 rows.fields 的嵌套字段数组。导出供测试。
|
|
725
|
+
*/
|
|
726
|
+
export declare function fieldsFromCells(headerTexts: string[], cells: SuggestCell[]): ExtractField[];
|
|
727
|
+
/**
|
|
728
|
+
* 纯逻辑:由首条卡片信息推断列表 fields(项文本/链接/图片)。
|
|
729
|
+
* 文本取第一个子元素(项自身无法用 querySelector 自选)。导出供测试。
|
|
730
|
+
*/
|
|
731
|
+
export declare function fieldsFromCard(item: SuggestCell): ExtractField[];
|
|
732
|
+
/** 纯逻辑:由 fields 与单元格样本拼出首行样例(与抽取输出同构;按 td 序号对位)。导出供测试。 */
|
|
733
|
+
export declare function sampleOfFields(fields: ExtractField[], cells: SuggestCell[]): Record<string, unknown>;
|
|
734
|
+
/**
|
|
735
|
+
* suggest 汇总(纯逻辑):由页内分析结果组装「可直接交给抽取模式」的顶层 fields
|
|
736
|
+
* (单个 multiple rows 字段 + 行内嵌套字段)与样本。推断失败原样返回。导出供测试。
|
|
737
|
+
*/
|
|
738
|
+
export declare function suggestWrap(analysis: SuggestAnalysis): {
|
|
739
|
+
suggested: boolean;
|
|
740
|
+
kind?: "table" | "list";
|
|
741
|
+
rowSelector?: string;
|
|
742
|
+
headerTexts?: string[];
|
|
743
|
+
fields?: ExtractField[];
|
|
744
|
+
sample?: Record<string, unknown>;
|
|
745
|
+
reason?: string;
|
|
746
|
+
overview?: SuggestAnalysis["overview"];
|
|
747
|
+
};
|
|
642
748
|
export declare function extractTool(config: BrowserConfig, args: Record<string, any>, exec?: ToolRunContext): Promise<{
|
|
749
|
+
url: string;
|
|
750
|
+
title: string;
|
|
751
|
+
suggested: boolean;
|
|
752
|
+
kind?: "table" | "list";
|
|
753
|
+
rowSelector?: string;
|
|
754
|
+
headerTexts?: string[];
|
|
755
|
+
fields?: ExtractField[];
|
|
756
|
+
sample?: Record<string, unknown>;
|
|
757
|
+
reason?: string;
|
|
758
|
+
overview?: SuggestAnalysis["overview"];
|
|
759
|
+
action: string;
|
|
760
|
+
} | {
|
|
643
761
|
url: string;
|
|
644
762
|
title: string;
|
|
645
763
|
file?: string | undefined;
|
|
@@ -695,6 +813,10 @@ export declare function batchTool(args: Record<string, any>, impls: Record<strin
|
|
|
695
813
|
passed: number;
|
|
696
814
|
failed: number;
|
|
697
815
|
healedCount: number;
|
|
816
|
+
retries?: {
|
|
817
|
+
attempted: number;
|
|
818
|
+
recovered: number;
|
|
819
|
+
};
|
|
698
820
|
stoppedAt?: number;
|
|
699
821
|
results: any[];
|
|
700
822
|
}>;
|
|
@@ -722,6 +844,10 @@ export declare function replayTool(args: Record<string, any>, impls: Record<stri
|
|
|
722
844
|
passed: number;
|
|
723
845
|
failed: number;
|
|
724
846
|
healedCount: number;
|
|
847
|
+
retries?: {
|
|
848
|
+
attempted: number;
|
|
849
|
+
recovered: number;
|
|
850
|
+
};
|
|
725
851
|
stoppedAt?: number;
|
|
726
852
|
results: any[];
|
|
727
853
|
source: string;
|
|
@@ -730,4 +856,19 @@ export declare function replayTool(args: Record<string, any>, impls: Record<stri
|
|
|
730
856
|
failedRows?: undefined;
|
|
731
857
|
runs?: undefined;
|
|
732
858
|
}>;
|
|
859
|
+
/** 重跑请求:source 为已保存录制名,retryOf 为被重跑的原 runId(记录用)。 */
|
|
860
|
+
export interface RerunRequest {
|
|
861
|
+
source: string;
|
|
862
|
+
retryOf?: string;
|
|
863
|
+
}
|
|
864
|
+
type RerunHandler = (req: RerunRequest) => Promise<unknown>;
|
|
865
|
+
/** registerTools 注册重跑入口(stepImpls 同路径);web-only 进程保持 null。 */
|
|
866
|
+
export declare function setRerunHandler(fn: RerunHandler): void;
|
|
867
|
+
/** 当前可用的重跑入口(null = 本进程没有 tools 服务,无法重跑)。 */
|
|
868
|
+
export declare function getRerunHandler(): RerunHandler | null;
|
|
869
|
+
/** 重跑是否正在执行(端点互斥;导出供测试)。 */
|
|
870
|
+
export declare function rerunBusy(): boolean;
|
|
871
|
+
/** 执行一次面板重跑(busy 检查 + 互斥标记;返回 replayTool 结果)。 */
|
|
872
|
+
export declare function runPanelRerun(req: RerunRequest): Promise<unknown>;
|
|
873
|
+
export {};
|
|
733
874
|
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -31,13 +31,35 @@ export interface BrowserConfig {
|
|
|
31
31
|
maxRefs?: number;
|
|
32
32
|
/** browser_extract 单次最多聚合的行数(默认 1000)。 */
|
|
33
33
|
maxRows?: number;
|
|
34
|
+
/**
|
|
35
|
+
* 增量快照保留的历史版本数 K(默认 5,上限 20;内存上界 ≈100KB/page)。
|
|
36
|
+
* since ∈ [latest-K+1, latest] 都能 diff,更旧版本回落全量标 stale。
|
|
37
|
+
*/
|
|
38
|
+
snapshotHistory?: number;
|
|
34
39
|
/**
|
|
35
40
|
* 敏感操作审批模式:off(默认,行为与 v0.2 一致,工具仍可手动调用)|
|
|
36
|
-
* manual(systemPrompt 指示 agent 在提交/删除/支付类动作前调用 browser_confirm)
|
|
41
|
+
* manual(systemPrompt 指示 agent 在提交/删除/支付类动作前调用 browser_confirm)|
|
|
42
|
+
* auto(硬约束:宿主层在 sensitiveTools 工具执行前强制解析目标元素并与
|
|
43
|
+
* sensitivePatterns 匹配,命中即弹审批卡,拒绝/超时该步失败,agent 无法绕过)。
|
|
37
44
|
*/
|
|
38
|
-
confirmMode?: "off" | "manual";
|
|
45
|
+
confirmMode?: "off" | "manual" | "auto";
|
|
39
46
|
/** browser_confirm 等待人工决策的默认超时毫秒(默认 60000)。 */
|
|
40
47
|
confirmTimeoutMs?: number;
|
|
48
|
+
/**
|
|
49
|
+
* auto 模式敏感文本模式:对目标元素的 role/name/text/id/testid/tag 做
|
|
50
|
+
* 子串匹配(大小写不敏感),命中任一即拦。默认 提交/删除/支付。
|
|
51
|
+
*/
|
|
52
|
+
sensitivePatterns?: string[];
|
|
53
|
+
/**
|
|
54
|
+
* auto 模式参与判定的工具(默认只拦 browser_click —— type 误报率高,
|
|
55
|
+
* 需要拦输入类动作时显式加入)。
|
|
56
|
+
*/
|
|
57
|
+
sensitiveTools?: string[];
|
|
58
|
+
/**
|
|
59
|
+
* replay/batch 是否同样走 auto 审批闸(默认 true)。设为 false 表示回放
|
|
60
|
+
* 不再弹审批 —— 数据驱动/定时回归的逃生口,风险自担(见 README)。
|
|
61
|
+
*/
|
|
62
|
+
confirmInReplay?: boolean;
|
|
41
63
|
/**
|
|
42
64
|
* 工具集:all(默认,全部工具)| core(只注册高频核心集,低频的
|
|
43
65
|
* 录制/回放/报告/抽取/profile 等不注册,降 systemPrompt 常驻 token)。
|
|
@@ -82,6 +104,12 @@ export interface RefEntry {
|
|
|
82
104
|
name: string;
|
|
83
105
|
/** 生成快照时计算的稳定 CSS 路径(优先 #id / [data-testid] / nth-of-type 链)。 */
|
|
84
106
|
selector: string;
|
|
107
|
+
/** 组件库标识(如 ant-design-vue, element-plus) */
|
|
108
|
+
library?: string;
|
|
109
|
+
/** 组件名(如 ASelect, ElSelect) */
|
|
110
|
+
component?: string;
|
|
111
|
+
/** 源码位置坐标(@xiaou66/vite-plugin-vue-mcp-next 或 inspector 注入,如 src/views/Login.vue:24:5) */
|
|
112
|
+
sourceFile?: string;
|
|
85
113
|
}
|
|
86
114
|
/** 录制时采集的选择器指纹(回放自愈的降级候选来源)。 */
|
|
87
115
|
export interface SelectorHint {
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/** 页内 walker 核心(自包含;勿引用模块级变量、勿导入任何模块)。 */
|
|
2
|
+
declare function __walkerCore(): {
|
|
3
|
+
INTERACTIVE: Set<string>;
|
|
4
|
+
STRUCTURAL: Set<string>;
|
|
5
|
+
SKIP_TAGS: Set<string>;
|
|
6
|
+
roleOf: (el: Element) => string;
|
|
7
|
+
nameOf: (el: Element, role: string) => string;
|
|
8
|
+
cssPath: (el: Element) => string;
|
|
9
|
+
isVisible: (el: Element) => boolean;
|
|
10
|
+
describeElement: (el: Element) => {
|
|
11
|
+
role: string;
|
|
12
|
+
name: string;
|
|
13
|
+
selector: string;
|
|
14
|
+
testid: string;
|
|
15
|
+
id: string;
|
|
16
|
+
tag: string;
|
|
17
|
+
text: string;
|
|
18
|
+
visible: boolean;
|
|
19
|
+
library?: string;
|
|
20
|
+
component?: string;
|
|
21
|
+
sourceFile?: string;
|
|
22
|
+
formLabel?: string;
|
|
23
|
+
};
|
|
24
|
+
resolveComponentSemantics: (el: Element) => {
|
|
25
|
+
library: string;
|
|
26
|
+
component: string;
|
|
27
|
+
sourceFile: string;
|
|
28
|
+
role: string;
|
|
29
|
+
formLabel: string;
|
|
30
|
+
placeholder: string;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
/** walker 核心注入后暴露给 entry 的 API(类型层)。 */
|
|
34
|
+
export type WalkerApi = ReturnType<typeof __walkerCore>;
|
|
35
|
+
/**
|
|
36
|
+
* 把消费方 entry(自包含函数,签名 (payload, w: WalkerApi) => R)拼装成
|
|
37
|
+
* 可被 page.evaluate 序列化的独立函数 (payload: P) => R。
|
|
38
|
+
* 拼装发生在模块加载期(new Function 一次性),调用期零开销。
|
|
39
|
+
*/
|
|
40
|
+
export declare function injectWalker<P, R>(entry: (payload: P, w: WalkerApi) => R): (payload: P) => R;
|
|
41
|
+
export {};
|
|
42
|
+
//# sourceMappingURL=walker.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-browser-view",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "DSH 插件:共享 Playwright 浏览器自动化(36 个 browser_*
|
|
3
|
+
"version": "0.4.1",
|
|
4
|
+
"description": "DSH 插件:共享 Playwright 浏览器自动化(36 个 browser_* 工具,含语义元素查找、批处理、视觉回归、选择器自愈、参数化/数据驱动回放、失败自动重试、结构化抽取与字段建议、增量快照历史版本、回归报告与隔离 context)+ 人机协作(人工接管等待、敏感操作审批(confirmMode:auto 宿主层硬拦截)、人机混合录制、面板一键重跑、面板双向化:操作预告高亮/内嵌报告)+ 实时画面面板与录制管理。仅依赖 playwright-core,不依赖任何 @deepseek-ai 运行时包。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
|
7
7
|
"types": "./lib/types/index.d.ts",
|