dsh-browser-view 0.7.0 → 0.7.4
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/lib/index.js +703 -95
- package/lib/types/browser/session/semantic.d.ts +2 -0
- package/lib/types/browser/session/target.d.ts +3 -1
- package/lib/types/browser/session.d.ts +5 -2
- package/lib/types/browser/tools/collaboration.d.ts +25 -3
- package/lib/types/browser/tools/interaction.d.ts +2 -0
- package/lib/types/browser/tools/navigation.d.ts +4 -1
- package/lib/types/browser/tools/testing.d.ts +23 -1
- package/lib/types/browser/types.d.ts +6 -0
- package/lib/types/browser/walker.d.ts +1 -0
- package/package.json +2 -1
|
@@ -35,6 +35,7 @@ export declare const scanInteractive: (payload: {
|
|
|
35
35
|
scope: string;
|
|
36
36
|
limit: number;
|
|
37
37
|
dialogSelector?: string;
|
|
38
|
+
preferredRoles?: string[];
|
|
38
39
|
}) => {
|
|
39
40
|
matches: SemanticMatch[];
|
|
40
41
|
candidates: {
|
|
@@ -65,6 +66,7 @@ export declare function resolveSemanticTarget(page: Page, what: string, opts?: {
|
|
|
65
66
|
scope?: string;
|
|
66
67
|
limit?: number;
|
|
67
68
|
maxRefs?: number;
|
|
69
|
+
preferredRoles?: string[];
|
|
68
70
|
}): Promise<TargetResolution | SemanticMiss>;
|
|
69
71
|
/**
|
|
70
72
|
* 全量可交互元素扫描(SPA ref 重锚定的数据源):返回页面(或 scope 内)全部
|
|
@@ -10,7 +10,9 @@ export declare function buildFlexibleTextPattern(text: string): RegExp;
|
|
|
10
10
|
* 自动识别 selector 或 ref;若 ref 标记位于子 Frame,自动绑定到对应子 Frame 上下文。
|
|
11
11
|
* 具备路径防漂移校验与 getByRole 自愈降级能力。
|
|
12
12
|
*/
|
|
13
|
-
export declare function resolveTargetLocator(page: Page, args: Record<string, any
|
|
13
|
+
export declare function resolveTargetLocator(page: Page, args: Record<string, any>, opts?: {
|
|
14
|
+
preferredRoles?: string[];
|
|
15
|
+
}): Promise<TargetResolution>;
|
|
14
16
|
/** 兼容旧版签名的目标定位快捷方式 */
|
|
15
17
|
export declare function targetLocator(page: Page, args: Record<string, any>): Promise<Locator>;
|
|
16
18
|
//# sourceMappingURL=target.d.ts.map
|
|
@@ -49,7 +49,9 @@ export interface NamedContext {
|
|
|
49
49
|
createdAt: number;
|
|
50
50
|
}
|
|
51
51
|
export declare function namedContextsOf(): Map<string, NamedContext>;
|
|
52
|
-
/** 把一个已 attach 的页面注册进 profile 标签表并激活,返回分配的 tab id。
|
|
52
|
+
/** 把一个已 attach 的页面注册进 profile 标签表并激活,返回分配的 tab id。
|
|
53
|
+
* 唯一注册路径:同时挂 close 监听幂等摘除外部关闭的页(否则僵尸句柄会永久占用
|
|
54
|
+
* activeId,所有工具连报 "Target page...closed" 而 tabs list 仍显示存活)。 */
|
|
53
55
|
export declare function registerTabPage(state: ProfileState, page: Page): number;
|
|
54
56
|
/** 新建一个页面(当前 profile 会话未启动时先启动)。 */
|
|
55
57
|
export declare function newPage(config: BrowserConfig): Promise<Page>;
|
|
@@ -57,8 +59,9 @@ export declare function newPage(config: BrowserConfig): Promise<Page>;
|
|
|
57
59
|
export declare function getPage(config: BrowserConfig): Promise<Page>;
|
|
58
60
|
/** 活动页面(可能为 null,不触发启动)。 */
|
|
59
61
|
export declare function activePage(): Page | null;
|
|
60
|
-
/** 投影当前 profile
|
|
62
|
+
/** 投影当前 profile 的标签列表(先摘除僵尸页,附注册时间)。 */
|
|
61
63
|
export declare function tabList(): Promise<{
|
|
64
|
+
createdAt?: number | undefined;
|
|
62
65
|
id: number;
|
|
63
66
|
url: string;
|
|
64
67
|
title: string;
|
|
@@ -5,16 +5,38 @@ import type { BrowserConfig } from "../types.js";
|
|
|
5
5
|
* ~1.5 秒。异步不阻塞(fire-and-forget,任何失败静默),不影响操作时序。
|
|
6
6
|
*/
|
|
7
7
|
export declare function previewHighlight(page: Page | null, selector: string, label: string): void;
|
|
8
|
+
/**
|
|
9
|
+
* 常见认证/登录相关的 URL 特征正则,用于防止跳板页提前误判。
|
|
10
|
+
*/
|
|
11
|
+
export declare const AUTH_URL_PATTERN: RegExp;
|
|
12
|
+
export interface WaitForLoginResult {
|
|
13
|
+
loggedIn: boolean;
|
|
14
|
+
waitedMs: number;
|
|
15
|
+
detail: string;
|
|
16
|
+
targetPage: Page;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* 等待人工登录底层执行(独立导出供测试注入 fake page)。
|
|
20
|
+
* 协同机制:
|
|
21
|
+
* 1. 挂起等待期间置入 instruction 至实时画面面板(setPauseInstruction),结束后统一清理;
|
|
22
|
+
* 2. 存活标签感知:感知 context 内所有存活页面,原标签关闭时自动迁移至存活页,新标签出现时通知外层注册;
|
|
23
|
+
* 3. 稳态判定:
|
|
24
|
+
* - 显式 successSelector / successUrl 优先;
|
|
25
|
+
* - 缺省时,检测 URL 离开登录页(非 AUTH_URL_PATTERN)、登录密码框消除、或 SPA 内容签名稳态变化,防范跳板页误判与 SPA 弹窗漏判。
|
|
26
|
+
*/
|
|
27
|
+
export declare function runWaitForLoginOnPage(initialPage: Page, args: Record<string, any>, onNewPageDetected?: (page: Page) => void): Promise<WaitForLoginResult>;
|
|
8
28
|
/**
|
|
9
29
|
* 等待人工登录完成(配合 headless:false 使用):agent 打开登录页后调用本工具,
|
|
10
|
-
* 提示用户在浏览器窗口中完成登录(输入/扫码/双因素)
|
|
11
|
-
*
|
|
12
|
-
* 超时返回 loggedIn:false(
|
|
30
|
+
* 提示用户在浏览器窗口中完成登录(输入/扫码/双因素)。支持 instruction 提示语
|
|
31
|
+
* 与右下角实时画面面板联动显示横幅,支持多标签感知与 SPA 签名自适应判定。
|
|
32
|
+
* 超时返回 loggedIn:false(附 waitedMs 与 detail,不抛错)。
|
|
13
33
|
*/
|
|
14
34
|
export declare function waitForLoginTool(config: BrowserConfig, args: Record<string, any>): Promise<{
|
|
15
35
|
url: string;
|
|
16
36
|
title: string;
|
|
17
37
|
loggedIn: boolean;
|
|
38
|
+
waitedMs: number;
|
|
39
|
+
detail: string;
|
|
18
40
|
}>;
|
|
19
41
|
/**
|
|
20
42
|
* 人工接管等待(通用版 wait_for_login):agent 把控制权交还给用户(验证码 /
|
|
@@ -7,6 +7,7 @@ export declare function isBotSensitiveUrl(url: string): boolean;
|
|
|
7
7
|
export declare function clickTool(config: BrowserConfig, args: Record<string, any>, exec?: ToolRunContext): Promise<{
|
|
8
8
|
url: string;
|
|
9
9
|
title: string;
|
|
10
|
+
viaBridge?: boolean | undefined;
|
|
10
11
|
effectHint?: string | undefined;
|
|
11
12
|
clicked: string;
|
|
12
13
|
effect: {
|
|
@@ -23,6 +24,7 @@ export declare function clickTool(config: BrowserConfig, args: Record<string, an
|
|
|
23
24
|
} | {
|
|
24
25
|
url: string;
|
|
25
26
|
title: string;
|
|
27
|
+
viaBridge?: boolean | undefined;
|
|
26
28
|
clicked: string;
|
|
27
29
|
}>;
|
|
28
30
|
export declare function typeTool(config: BrowserConfig, args: Record<string, any>): Promise<{
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { BrowserConfig } from "../types.js";
|
|
2
2
|
export declare function openTool(configOrArgs: BrowserConfig | Record<string, any>, maybeArgs?: Record<string, any>): Promise<{
|
|
3
|
+
recovered?: string | undefined;
|
|
3
4
|
url: string;
|
|
4
5
|
title: string;
|
|
5
6
|
status: string;
|
|
@@ -90,6 +91,7 @@ export declare function statusTool(): Promise<{
|
|
|
90
91
|
export declare function tabsTool(config: BrowserConfig, args: Record<string, any>): Promise<{
|
|
91
92
|
action: any;
|
|
92
93
|
tabs: {
|
|
94
|
+
createdAt?: number | undefined;
|
|
93
95
|
id: number;
|
|
94
96
|
url: string;
|
|
95
97
|
title: string;
|
|
@@ -104,11 +106,12 @@ export declare function tabsTool(config: BrowserConfig, args: Record<string, any
|
|
|
104
106
|
title: string;
|
|
105
107
|
};
|
|
106
108
|
tabs: {
|
|
109
|
+
createdAt?: number | undefined;
|
|
107
110
|
id: number;
|
|
108
111
|
url: string;
|
|
109
112
|
title: string;
|
|
110
113
|
}[];
|
|
111
|
-
activeId: number;
|
|
114
|
+
activeId: number | null;
|
|
112
115
|
}>;
|
|
113
116
|
export declare function profileTool(config: BrowserConfig, args: Record<string, any>): Promise<{
|
|
114
117
|
current: string;
|
|
@@ -9,12 +9,13 @@ export declare function waitTool(config: BrowserConfig, args: Record<string, any
|
|
|
9
9
|
/**
|
|
10
10
|
* 条件检查引擎(测试原语共用)。
|
|
11
11
|
*
|
|
12
|
-
* cond
|
|
12
|
+
* cond 支持六类(每类内部互斥,取第一个存在的字段):
|
|
13
13
|
* { selector: "#btn", state: "visible|hidden|attached|detached" } 元素状态(默认 visible)
|
|
14
14
|
* { url: "正则字符串" } 当前 URL 匹配
|
|
15
15
|
* { text: "子串" } body 可见文本包含
|
|
16
16
|
* { count: { selector, op: "eq|gt|gte|lt|lte", value: n } } 元素数量比较
|
|
17
17
|
* { eval: "JS 表达式" } 表达式求值 truthy
|
|
18
|
+
* { bridge: { method, args?, expect?/expectContains? } } 页内调用 __DSH_BRIDGE__ 方法并断言返回
|
|
18
19
|
*/
|
|
19
20
|
export type TestCondition = Record<string, any>;
|
|
20
21
|
/** 单次检查:返回 { ok, detail }。不抛错,失败时 detail 给出原因。 */
|
|
@@ -56,6 +57,7 @@ export declare function networkTool(configOrArgs?: Record<string, any>, maybeArg
|
|
|
56
57
|
waitMs?: undefined;
|
|
57
58
|
stats?: undefined;
|
|
58
59
|
failed?: undefined;
|
|
60
|
+
suggestions?: undefined;
|
|
59
61
|
} | {
|
|
60
62
|
matched: import("../session.js").NetworkEntry;
|
|
61
63
|
waitMs: number;
|
|
@@ -63,6 +65,7 @@ export declare function networkTool(configOrArgs?: Record<string, any>, maybeArg
|
|
|
63
65
|
entries?: undefined;
|
|
64
66
|
stats?: undefined;
|
|
65
67
|
failed?: undefined;
|
|
68
|
+
suggestions?: undefined;
|
|
66
69
|
} | {
|
|
67
70
|
stats: {
|
|
68
71
|
host: string;
|
|
@@ -76,13 +79,31 @@ export declare function networkTool(configOrArgs?: Record<string, any>, maybeArg
|
|
|
76
79
|
matched?: undefined;
|
|
77
80
|
waitMs?: undefined;
|
|
78
81
|
failed?: undefined;
|
|
82
|
+
suggestions?: undefined;
|
|
79
83
|
} | {
|
|
80
84
|
failed: import("../session.js").NetworkEntry[];
|
|
85
|
+
suggestions: string[];
|
|
81
86
|
cleared?: undefined;
|
|
82
87
|
entries?: undefined;
|
|
83
88
|
matched?: undefined;
|
|
84
89
|
waitMs?: undefined;
|
|
85
90
|
stats?: undefined;
|
|
91
|
+
} | {
|
|
92
|
+
failed: import("../session.js").NetworkEntry[];
|
|
93
|
+
cleared?: undefined;
|
|
94
|
+
entries?: undefined;
|
|
95
|
+
matched?: undefined;
|
|
96
|
+
waitMs?: undefined;
|
|
97
|
+
stats?: undefined;
|
|
98
|
+
suggestions?: undefined;
|
|
99
|
+
} | {
|
|
100
|
+
entries: import("../session.js").NetworkEntry[];
|
|
101
|
+
suggestions: string[];
|
|
102
|
+
cleared?: undefined;
|
|
103
|
+
matched?: undefined;
|
|
104
|
+
waitMs?: undefined;
|
|
105
|
+
stats?: undefined;
|
|
106
|
+
failed?: undefined;
|
|
86
107
|
} | {
|
|
87
108
|
entries: import("../session.js").NetworkEntry[];
|
|
88
109
|
cleared?: undefined;
|
|
@@ -90,5 +111,6 @@ export declare function networkTool(configOrArgs?: Record<string, any>, maybeArg
|
|
|
90
111
|
waitMs?: undefined;
|
|
91
112
|
stats?: undefined;
|
|
92
113
|
failed?: undefined;
|
|
114
|
+
suggestions?: undefined;
|
|
93
115
|
}>;
|
|
94
116
|
//# sourceMappingURL=testing.d.ts.map
|
|
@@ -92,6 +92,10 @@ export interface ProfileState {
|
|
|
92
92
|
activeId: number | null;
|
|
93
93
|
counter: number;
|
|
94
94
|
channel?: string;
|
|
95
|
+
/** 标签元数据(id → createdAt);随 pages 同步增删,僵尸标签治理用。 */
|
|
96
|
+
tabMeta?: Map<number, {
|
|
97
|
+
createdAt: number;
|
|
98
|
+
}>;
|
|
95
99
|
}
|
|
96
100
|
/** 一次页面下载的记录。 */
|
|
97
101
|
export interface DownloadEntry {
|
|
@@ -173,6 +177,8 @@ export interface TargetResolution {
|
|
|
173
177
|
visibleCount?: number;
|
|
174
178
|
/** 语义定位的备选目标(按打分次序,最多 2 个);点击效果验证无变化时自动换选。 */
|
|
175
179
|
alternates?: Locator[];
|
|
180
|
+
/** 经 window.__DSH_BRIDGE__.resolveActionTarget 兜底命中(vite-plugin-dsh-bridge 反哺)。 */
|
|
181
|
+
viaBridge?: boolean;
|
|
176
182
|
}
|
|
177
183
|
/** 录制时采集的选择器指纹(回放自愈的降级候选来源)。 */
|
|
178
184
|
export interface SelectorHint {
|
|
@@ -20,6 +20,7 @@ declare function __walkerCore(): {
|
|
|
20
20
|
};
|
|
21
21
|
composedParent: (el: Element) => Element | null;
|
|
22
22
|
deepChildren: (el: Element) => Element[];
|
|
23
|
+
isProbablyClickable: (el: Element) => boolean;
|
|
23
24
|
};
|
|
24
25
|
/** walker 核心注入后暴露给 entry 的 API(类型层)。 */
|
|
25
26
|
export type WalkerApi = ReturnType<typeof __walkerCore>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-browser-view",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.4",
|
|
4
4
|
"description": "DSH 插件:共享 Playwright 浏览器自动化(38 个 browser_* 工具,含 what 意图语义定位(一次调用替代快照→查找→点击)、SoM 标徽看图点击与零命中截图兜底、SPA ref 软失效重锚定、open Shadow DOM 组合树穿透、跨 Frame/IFrame 定位、视口感知动态快照、批量表单智能填充、点击效果验证与定位失败遥测、Playwright 规范代码导出、批处理、视觉回归、选择器自愈、增量快照)+ 人机协作(面板点选教学 browser_pick_element、人工接管等待、敏感操作审批硬拦截、人机混合录制、面板一键重跑)+ CDP 流式推流、拟人化轨迹与高斯击键、全景时光机、企业富控件矩阵。仅依赖 playwright-core。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
"test:enterprise": "tsx scripts/test-dev-server-enterprise.ts",
|
|
35
35
|
"test:energy": "tsx scripts/test-dev-server-energy.ts",
|
|
36
36
|
"test:shadow": "tsx scripts/test-dev-server-shadow.ts",
|
|
37
|
+
"test:span": "tsx scripts/test-dev-server-clickable-span.ts",
|
|
37
38
|
"test:pick": "tsx scripts/test-panel-pick.ts",
|
|
38
39
|
"dev:server": "tsx scripts/dev-server.ts",
|
|
39
40
|
"verify": "npm run typecheck && npm run lint && npm run test && npm run build",
|