dsh-browser-view 0.4.0 → 0.7.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/README.md +14 -10
- package/lib/client.js +1 -1
- package/lib/index.js +7787 -5190
- package/lib/types/browser/adapters/antd.d.ts +14 -0
- package/lib/types/browser/adapters/archetypes.d.ts +93 -0
- package/lib/types/browser/adapters/dom.d.ts +6 -0
- package/lib/types/browser/adapters/element.d.ts +5 -0
- package/lib/types/browser/adapters/engine.d.ts +51 -0
- package/lib/types/browser/adapters/generic.d.ts +5 -0
- package/lib/types/browser/adapters/index.d.ts +10 -0
- package/lib/types/browser/adapters/modules/drag.d.ts +3 -0
- package/lib/types/browser/adapters/modules/editor.d.ts +3 -0
- package/lib/types/browser/adapters/modules/hierarchy.d.ts +3 -0
- package/lib/types/browser/adapters/modules/temporal.d.ts +3 -0
- package/lib/types/browser/adapters/modules/transfer.d.ts +3 -0
- package/lib/types/browser/adapters/modules/virtual.d.ts +4 -0
- package/lib/types/browser/adapters/quiescence.d.ts +3 -0
- package/lib/types/browser/adapters/registry.d.ts +64 -0
- package/lib/types/browser/adapters/select.d.ts +15 -0
- package/lib/types/browser/adapters/types.d.ts +134 -0
- package/lib/types/browser/codegen/playwright.d.ts +10 -0
- package/lib/types/browser/definitions/collaboration.d.ts +4 -0
- package/lib/types/browser/definitions/doctor.d.ts +4 -0
- package/lib/types/browser/definitions/extract.d.ts +4 -0
- package/lib/types/browser/definitions/inspection.d.ts +4 -0
- package/lib/types/browser/definitions/interaction.d.ts +4 -0
- package/lib/types/browser/definitions/navigation.d.ts +4 -0
- package/lib/types/browser/definitions/recorder.d.ts +4 -0
- package/lib/types/browser/definitions/testing.d.ts +4 -0
- package/lib/types/browser/policy/engine.d.ts +26 -0
- package/lib/types/browser/policy/types.d.ts +36 -0
- package/lib/types/browser/primitives/dialog.d.ts +12 -0
- package/lib/types/browser/primitives/dom.d.ts +43 -0
- package/lib/types/browser/primitives/drag.d.ts +3 -0
- package/lib/types/browser/primitives/editor.d.ts +3 -0
- package/lib/types/browser/primitives/form.d.ts +7 -0
- package/lib/types/browser/primitives/hierarchy.d.ts +3 -0
- package/lib/types/browser/primitives/index.d.ts +12 -0
- package/lib/types/browser/primitives/select.d.ts +7 -0
- package/lib/types/browser/primitives/temporal.d.ts +3 -0
- package/lib/types/browser/primitives/transfer.d.ts +3 -0
- package/lib/types/browser/primitives/types.d.ts +48 -0
- package/lib/types/browser/primitives/virtual.d.ts +4 -0
- package/lib/types/browser/reports.d.ts +0 -2
- package/lib/types/browser/session/cache.d.ts +103 -0
- package/lib/types/browser/session/collaboration.d.ts +53 -0
- package/lib/types/browser/session/recorder.d.ts +62 -0
- package/lib/types/browser/session/screencast.d.ts +37 -0
- package/lib/types/browser/session/screenshot.d.ts +17 -0
- package/lib/types/browser/session/semantic.d.ts +94 -0
- package/lib/types/browser/session/target.d.ts +16 -0
- package/lib/types/browser/session/tracer.d.ts +56 -0
- package/lib/types/browser/session.d.ts +7 -140
- package/lib/types/browser/stealth/keyboard.d.ts +13 -0
- package/lib/types/browser/stealth/mouse.d.ts +28 -0
- package/lib/types/browser/tools/collaboration.d.ts +73 -0
- package/lib/types/browser/tools/common.d.ts +67 -0
- package/lib/types/browser/tools/doctor.d.ts +31 -0
- package/lib/types/browser/tools/extract.d.ts +92 -0
- package/lib/types/browser/tools/inspection.d.ts +93 -0
- package/lib/types/browser/tools/interaction.d.ts +148 -0
- package/lib/types/browser/tools/navigation.d.ts +126 -0
- package/lib/types/browser/tools/recorder.d.ts +236 -0
- package/lib/types/browser/tools/testing.d.ts +94 -0
- package/lib/types/browser/tools.d.ts +9 -861
- package/lib/types/browser/types.d.ts +70 -1
- package/lib/types/browser/walker.d.ts +3 -0
- package/lib/types/client/api.d.ts +24 -0
- package/lib/types/client/components/ConfirmCard.d.ts +20 -0
- package/lib/types/client/components/FloatingOverlay.d.ts +10 -0
- package/lib/types/client/components/FloatingPanel.d.ts +40 -0
- package/lib/types/client/components/InspectionModal.d.ts +51 -0
- package/lib/types/client/components/SettingsSection.d.ts +5 -0
- package/lib/types/client/components/styles.d.ts +18 -0
- package/lib/types/client/hooks/useBrowserStatus.d.ts +11 -0
- package/lib/types/client/hooks/useConfirmPolling.d.ts +6 -0
- package/lib/types/client/hooks/usePickPolling.d.ts +5 -0
- package/lib/types/client/hooks/useRecordings.d.ts +9 -0
- package/lib/types/client/index.d.ts +7 -10
- package/lib/types/client/theme.d.ts +7 -0
- package/lib/types/client/types.d.ts +74 -0
- package/lib/types/lib/config.d.ts +0 -2
- package/lib/types/lib/http.d.ts +0 -2
- package/lib/types/lib/types.d.ts +1 -0
- package/package.json +13 -3
- package/lib/types/embed.d.ts +0 -7
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import type { ToolRunContext } from "../../lib/types.js";
|
|
2
|
+
import type { BrowserConfig } from "../types.js";
|
|
3
|
+
import { targetLocator, resolveTargetLocator } from "../session.js";
|
|
4
|
+
import { type FormFillResult } from "../primitives/index.js";
|
|
5
|
+
export { targetLocator, resolveTargetLocator };
|
|
6
|
+
export declare function isBotSensitiveUrl(url: string): boolean;
|
|
7
|
+
export declare function clickTool(config: BrowserConfig, args: Record<string, any>, exec?: ToolRunContext): Promise<{
|
|
8
|
+
url: string;
|
|
9
|
+
title: string;
|
|
10
|
+
effectHint?: string | undefined;
|
|
11
|
+
clicked: string;
|
|
12
|
+
effect: {
|
|
13
|
+
switchedCandidate?: boolean | undefined;
|
|
14
|
+
newRequests?: {
|
|
15
|
+
status?: number | undefined;
|
|
16
|
+
url: string;
|
|
17
|
+
method: string;
|
|
18
|
+
}[] | undefined;
|
|
19
|
+
urlChanged: boolean;
|
|
20
|
+
mutations?: string[] | undefined;
|
|
21
|
+
domChanged: boolean;
|
|
22
|
+
};
|
|
23
|
+
} | {
|
|
24
|
+
url: string;
|
|
25
|
+
title: string;
|
|
26
|
+
clicked: string;
|
|
27
|
+
}>;
|
|
28
|
+
export declare function typeTool(config: BrowserConfig, args: Record<string, any>): Promise<{
|
|
29
|
+
url: string;
|
|
30
|
+
title: string;
|
|
31
|
+
typed: boolean;
|
|
32
|
+
editor: boolean;
|
|
33
|
+
selector: string;
|
|
34
|
+
} | {
|
|
35
|
+
url: string;
|
|
36
|
+
title: string;
|
|
37
|
+
typed: boolean;
|
|
38
|
+
selector: string;
|
|
39
|
+
submit: boolean;
|
|
40
|
+
}>;
|
|
41
|
+
export declare function pressTool(config: BrowserConfig, args: Record<string, any>): Promise<{
|
|
42
|
+
url: string;
|
|
43
|
+
title: string;
|
|
44
|
+
warning?: string | undefined;
|
|
45
|
+
pressed: string;
|
|
46
|
+
}>;
|
|
47
|
+
/**
|
|
48
|
+
* 下拉选择原语:委托给 UI 组件库下拉适配器(Native / AntDesign / ElementPlus / GenericARIA)。
|
|
49
|
+
* 各组件库特异性的展开机制、虚拟列表穿透与 0 宽度读屏傀儡节点过滤完全隔离在适配器中。
|
|
50
|
+
*/
|
|
51
|
+
export declare function selectTool(config: BrowserConfig, args: Record<string, any>): Promise<{
|
|
52
|
+
url: string;
|
|
53
|
+
title: string;
|
|
54
|
+
selected: string;
|
|
55
|
+
selector: string;
|
|
56
|
+
}>;
|
|
57
|
+
export declare function evalTool(config: BrowserConfig, args: Record<string, any>): Promise<{
|
|
58
|
+
scriptUnwrapped?: boolean | undefined;
|
|
59
|
+
result: unknown;
|
|
60
|
+
}>;
|
|
61
|
+
export declare function downloadTool(config: BrowserConfig, args: Record<string, any>, exec?: ToolRunContext): Promise<{
|
|
62
|
+
path: string;
|
|
63
|
+
filename: string;
|
|
64
|
+
url: string;
|
|
65
|
+
bytes: number;
|
|
66
|
+
}>;
|
|
67
|
+
export declare function uploadTool(config: BrowserConfig, args: Record<string, any>, exec?: ToolRunContext): Promise<{
|
|
68
|
+
url: string;
|
|
69
|
+
title: string;
|
|
70
|
+
uploaded: string;
|
|
71
|
+
bytes: number;
|
|
72
|
+
}>;
|
|
73
|
+
export declare function cookiesTool(config: BrowserConfig, args: Record<string, any>): Promise<{
|
|
74
|
+
cookies: {
|
|
75
|
+
name: string;
|
|
76
|
+
value: string;
|
|
77
|
+
domain: string;
|
|
78
|
+
path: string;
|
|
79
|
+
httpOnly: boolean;
|
|
80
|
+
secure: boolean;
|
|
81
|
+
sameSite: "Strict" | "Lax" | "None";
|
|
82
|
+
expires: number;
|
|
83
|
+
}[];
|
|
84
|
+
set?: undefined;
|
|
85
|
+
name?: undefined;
|
|
86
|
+
url?: undefined;
|
|
87
|
+
cleared?: undefined;
|
|
88
|
+
} | {
|
|
89
|
+
set: boolean;
|
|
90
|
+
name: string;
|
|
91
|
+
url: any;
|
|
92
|
+
cookies?: undefined;
|
|
93
|
+
cleared?: undefined;
|
|
94
|
+
} | {
|
|
95
|
+
cleared: boolean;
|
|
96
|
+
cookies?: undefined;
|
|
97
|
+
set?: undefined;
|
|
98
|
+
name?: undefined;
|
|
99
|
+
url?: undefined;
|
|
100
|
+
}>;
|
|
101
|
+
export declare function formTool(config: BrowserConfig, args: Record<string, any>): Promise<{
|
|
102
|
+
url: string;
|
|
103
|
+
title: string;
|
|
104
|
+
filled: ({
|
|
105
|
+
selector: any;
|
|
106
|
+
label?: undefined;
|
|
107
|
+
} | {
|
|
108
|
+
label: any;
|
|
109
|
+
selector?: undefined;
|
|
110
|
+
})[];
|
|
111
|
+
submit: boolean;
|
|
112
|
+
}>;
|
|
113
|
+
export declare function formSaveTool(args: Record<string, any>): Promise<{
|
|
114
|
+
saved: string;
|
|
115
|
+
fields: number;
|
|
116
|
+
}>;
|
|
117
|
+
export declare function formsTool(args: Record<string, any>): Promise<{
|
|
118
|
+
forms: {
|
|
119
|
+
name: string;
|
|
120
|
+
fields: number;
|
|
121
|
+
preview: string;
|
|
122
|
+
}[];
|
|
123
|
+
deleted?: undefined;
|
|
124
|
+
name?: undefined;
|
|
125
|
+
} | {
|
|
126
|
+
deleted: boolean;
|
|
127
|
+
name: string;
|
|
128
|
+
forms?: undefined;
|
|
129
|
+
}>;
|
|
130
|
+
/**
|
|
131
|
+
* 智能批量表单填写: 一次调用自动识别并填充多个表单控件, 结合 UI 适配器自动处理输入/选择与弹层
|
|
132
|
+
*/
|
|
133
|
+
export declare function formFillTool(config: BrowserConfig, args: Record<string, any>): Promise<FormFillResult>;
|
|
134
|
+
export declare function transferTool(config: BrowserConfig, args: Record<string, any>): Promise<{
|
|
135
|
+
url: string;
|
|
136
|
+
title: string;
|
|
137
|
+
transferred: boolean;
|
|
138
|
+
direction: string;
|
|
139
|
+
items: string[];
|
|
140
|
+
}>;
|
|
141
|
+
export declare function dragTool(config: BrowserConfig, args: Record<string, any>): Promise<{
|
|
142
|
+
url: string;
|
|
143
|
+
title: string;
|
|
144
|
+
dragged: boolean;
|
|
145
|
+
source: string;
|
|
146
|
+
target: string;
|
|
147
|
+
}>;
|
|
148
|
+
//# sourceMappingURL=interaction.d.ts.map
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import type { BrowserConfig } from "../types.js";
|
|
2
|
+
export declare function openTool(configOrArgs: BrowserConfig | Record<string, any>, maybeArgs?: Record<string, any>): Promise<{
|
|
3
|
+
url: string;
|
|
4
|
+
title: string;
|
|
5
|
+
status: string;
|
|
6
|
+
}>;
|
|
7
|
+
export declare function backTool(config: BrowserConfig): Promise<{
|
|
8
|
+
url: string;
|
|
9
|
+
title: string;
|
|
10
|
+
}>;
|
|
11
|
+
export declare function reloadTool(config: BrowserConfig): Promise<{
|
|
12
|
+
url: string;
|
|
13
|
+
title: string;
|
|
14
|
+
}>;
|
|
15
|
+
/**
|
|
16
|
+
* 命名隔离上下文:同一浏览器进程内独立 cookies/storage 的"标签组"。
|
|
17
|
+
* 页注册进 profile 标签表(所有既有工具直接可用),context 只做归属记录:
|
|
18
|
+
* list / new(name?, url?) / switch(激活该组的一页,没有则新开) / close(整组关闭)。
|
|
19
|
+
* 持久模式(userDataDir)浏览器只有单一 context,不支持本工具(用 profiles 替代)。
|
|
20
|
+
*/
|
|
21
|
+
export declare function contextTool(config: BrowserConfig, args: Record<string, any>): Promise<{
|
|
22
|
+
contexts: {
|
|
23
|
+
name: string;
|
|
24
|
+
pages: number;
|
|
25
|
+
active: boolean;
|
|
26
|
+
createdAt: number;
|
|
27
|
+
}[];
|
|
28
|
+
profile: string;
|
|
29
|
+
closed?: undefined;
|
|
30
|
+
remainingTabs?: undefined;
|
|
31
|
+
} | {
|
|
32
|
+
url: string;
|
|
33
|
+
title: string;
|
|
34
|
+
navigated?: string | undefined;
|
|
35
|
+
created: string;
|
|
36
|
+
contexts?: undefined;
|
|
37
|
+
profile?: undefined;
|
|
38
|
+
closed?: undefined;
|
|
39
|
+
remainingTabs?: undefined;
|
|
40
|
+
} | {
|
|
41
|
+
url: string;
|
|
42
|
+
title: string;
|
|
43
|
+
switched: string;
|
|
44
|
+
contexts?: undefined;
|
|
45
|
+
profile?: undefined;
|
|
46
|
+
closed?: undefined;
|
|
47
|
+
remainingTabs?: undefined;
|
|
48
|
+
} | {
|
|
49
|
+
url: string;
|
|
50
|
+
title: string;
|
|
51
|
+
switched: string;
|
|
52
|
+
pages: number;
|
|
53
|
+
contexts?: undefined;
|
|
54
|
+
profile?: undefined;
|
|
55
|
+
closed?: undefined;
|
|
56
|
+
remainingTabs?: undefined;
|
|
57
|
+
} | {
|
|
58
|
+
closed: string;
|
|
59
|
+
remainingTabs: number;
|
|
60
|
+
contexts?: undefined;
|
|
61
|
+
profile?: undefined;
|
|
62
|
+
}>;
|
|
63
|
+
export declare function statusTool(): Promise<{
|
|
64
|
+
open: boolean;
|
|
65
|
+
profile: string;
|
|
66
|
+
channel: string;
|
|
67
|
+
tabs: number;
|
|
68
|
+
profiles: {
|
|
69
|
+
name: string;
|
|
70
|
+
open: boolean;
|
|
71
|
+
tabs: number;
|
|
72
|
+
channel: string;
|
|
73
|
+
persistent: boolean;
|
|
74
|
+
}[];
|
|
75
|
+
} | {
|
|
76
|
+
url: string;
|
|
77
|
+
title: string;
|
|
78
|
+
open: boolean;
|
|
79
|
+
profile: string;
|
|
80
|
+
channel: string;
|
|
81
|
+
tabs: number;
|
|
82
|
+
profiles: {
|
|
83
|
+
name: string;
|
|
84
|
+
open: boolean;
|
|
85
|
+
tabs: number;
|
|
86
|
+
channel: string;
|
|
87
|
+
persistent: boolean;
|
|
88
|
+
}[];
|
|
89
|
+
}>;
|
|
90
|
+
export declare function tabsTool(config: BrowserConfig, args: Record<string, any>): Promise<{
|
|
91
|
+
action: any;
|
|
92
|
+
tabs: {
|
|
93
|
+
id: number;
|
|
94
|
+
url: string;
|
|
95
|
+
title: string;
|
|
96
|
+
}[];
|
|
97
|
+
activeId: number;
|
|
98
|
+
tab?: undefined;
|
|
99
|
+
} | {
|
|
100
|
+
action: any;
|
|
101
|
+
tab: {
|
|
102
|
+
id: number;
|
|
103
|
+
url: string;
|
|
104
|
+
title: string;
|
|
105
|
+
};
|
|
106
|
+
tabs: {
|
|
107
|
+
id: number;
|
|
108
|
+
url: string;
|
|
109
|
+
title: string;
|
|
110
|
+
}[];
|
|
111
|
+
activeId: number;
|
|
112
|
+
}>;
|
|
113
|
+
export declare function profileTool(config: BrowserConfig, args: Record<string, any>): Promise<{
|
|
114
|
+
current: string;
|
|
115
|
+
profiles: {
|
|
116
|
+
name: string;
|
|
117
|
+
open: boolean;
|
|
118
|
+
tabs: number;
|
|
119
|
+
persistent: boolean;
|
|
120
|
+
userDataDir: string;
|
|
121
|
+
}[];
|
|
122
|
+
}>;
|
|
123
|
+
export declare function closeTool(): Promise<{
|
|
124
|
+
closed: boolean;
|
|
125
|
+
}>;
|
|
126
|
+
//# sourceMappingURL=navigation.d.ts.map
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import type { Page } from "playwright-core";
|
|
2
|
+
import type { ToolRunContext } from "../../lib/types.js";
|
|
3
|
+
import type { BrowserConfig, ReplayStep, SelectorHint } from "../types.js";
|
|
4
|
+
import { type RunRecord } from "../reports.js";
|
|
5
|
+
/** 使用 args.selector 定位的工具集合(自愈与录制指纹的作用范围)。 */
|
|
6
|
+
export declare const SELECTOR_STEP_TOOLS: Set<string>;
|
|
7
|
+
/**
|
|
8
|
+
* 采集选择器指向元素的指纹(页内 evaluate;找不到元素返回 null)。
|
|
9
|
+
* 指纹是回放自愈的降级候选来源:testid / role+name / text / id / tag+text。
|
|
10
|
+
* F5 收敛:元素描述(role/name/text)改用 walker 单一来源
|
|
11
|
+
* (describeElement),与 aria 快照/find/录制回声共用同一套语义;相比旧
|
|
12
|
+
* 内联副本,role 推断更完整(slider/spinbutton/searchbox/heading 等),
|
|
13
|
+
* name 补齐 labelledby/label[for]/title 兜底 —— 指纹只作自愈降级候选,
|
|
14
|
+
* 语义增强只会让自愈命中率更高,不改变任何主链路行为。
|
|
15
|
+
*/
|
|
16
|
+
export declare function captureSelectorHint(page: Page, selector: string): Promise<SelectorHint | null>;
|
|
17
|
+
/** 由指纹生成自愈降级候选(按优先级排序;导出供测试)。 */
|
|
18
|
+
export declare function healCandidates(hint: SelectorHint): {
|
|
19
|
+
via: string;
|
|
20
|
+
selector: string;
|
|
21
|
+
}[];
|
|
22
|
+
/** 录制管理:start / stop / save / list / delete。 */
|
|
23
|
+
export declare function recordTool(args: Record<string, any>, config?: BrowserConfig, exec?: ToolRunContext): Promise<{
|
|
24
|
+
recording: boolean;
|
|
25
|
+
hint: string;
|
|
26
|
+
steps?: undefined;
|
|
27
|
+
recordings?: undefined;
|
|
28
|
+
deleted?: undefined;
|
|
29
|
+
name?: undefined;
|
|
30
|
+
exported?: undefined;
|
|
31
|
+
format?: undefined;
|
|
32
|
+
path?: undefined;
|
|
33
|
+
code?: undefined;
|
|
34
|
+
} | {
|
|
35
|
+
recording: boolean;
|
|
36
|
+
steps: number;
|
|
37
|
+
hint?: undefined;
|
|
38
|
+
recordings?: undefined;
|
|
39
|
+
deleted?: undefined;
|
|
40
|
+
name?: undefined;
|
|
41
|
+
exported?: undefined;
|
|
42
|
+
format?: undefined;
|
|
43
|
+
path?: undefined;
|
|
44
|
+
code?: undefined;
|
|
45
|
+
} | {
|
|
46
|
+
hint: string;
|
|
47
|
+
warnings?: string[] | undefined;
|
|
48
|
+
varsApplied?: number | undefined;
|
|
49
|
+
skippedFailed?: number | undefined;
|
|
50
|
+
stripped?: number | undefined;
|
|
51
|
+
saved: string;
|
|
52
|
+
steps: number;
|
|
53
|
+
source: string;
|
|
54
|
+
file: string;
|
|
55
|
+
recording?: undefined;
|
|
56
|
+
recordings?: undefined;
|
|
57
|
+
deleted?: undefined;
|
|
58
|
+
name?: undefined;
|
|
59
|
+
exported?: undefined;
|
|
60
|
+
format?: undefined;
|
|
61
|
+
path?: undefined;
|
|
62
|
+
code?: undefined;
|
|
63
|
+
} | {
|
|
64
|
+
recordings: {
|
|
65
|
+
name: string;
|
|
66
|
+
steps: number;
|
|
67
|
+
savedAt: number;
|
|
68
|
+
preview: string;
|
|
69
|
+
}[];
|
|
70
|
+
recording?: undefined;
|
|
71
|
+
hint?: undefined;
|
|
72
|
+
steps?: undefined;
|
|
73
|
+
deleted?: undefined;
|
|
74
|
+
name?: undefined;
|
|
75
|
+
exported?: undefined;
|
|
76
|
+
format?: undefined;
|
|
77
|
+
path?: undefined;
|
|
78
|
+
code?: undefined;
|
|
79
|
+
} | {
|
|
80
|
+
deleted: boolean;
|
|
81
|
+
name: string;
|
|
82
|
+
recording?: undefined;
|
|
83
|
+
hint?: undefined;
|
|
84
|
+
steps?: undefined;
|
|
85
|
+
recordings?: undefined;
|
|
86
|
+
exported?: undefined;
|
|
87
|
+
format?: undefined;
|
|
88
|
+
path?: undefined;
|
|
89
|
+
code?: undefined;
|
|
90
|
+
} | {
|
|
91
|
+
exported: boolean;
|
|
92
|
+
format: string;
|
|
93
|
+
path: string;
|
|
94
|
+
code: string;
|
|
95
|
+
recording?: undefined;
|
|
96
|
+
hint?: undefined;
|
|
97
|
+
steps?: undefined;
|
|
98
|
+
recordings?: undefined;
|
|
99
|
+
deleted?: undefined;
|
|
100
|
+
name?: undefined;
|
|
101
|
+
} | {
|
|
102
|
+
exported: boolean;
|
|
103
|
+
format: string;
|
|
104
|
+
code: string;
|
|
105
|
+
recording?: undefined;
|
|
106
|
+
hint?: undefined;
|
|
107
|
+
steps?: undefined;
|
|
108
|
+
recordings?: undefined;
|
|
109
|
+
deleted?: undefined;
|
|
110
|
+
name?: undefined;
|
|
111
|
+
path?: undefined;
|
|
112
|
+
}>;
|
|
113
|
+
/** 回放选项(自愈开关与单次尝试超时,来自 config;retryFailed 为自动重试次数)。 */
|
|
114
|
+
export interface ReplayOptions {
|
|
115
|
+
healing?: boolean;
|
|
116
|
+
healTimeoutMs?: number;
|
|
117
|
+
/** F2:步骤失败(含自愈链耗尽)后自动重试的次数,步骤间 500ms×n 线性退避。 */
|
|
118
|
+
retryFailed?: number;
|
|
119
|
+
}
|
|
120
|
+
/** 回放执行器(步骤 → 工具调用),由 register.ts 注入实现 map。支持选择器自愈。 */
|
|
121
|
+
export declare function runReplay(steps: ReplayStep[], impls: Record<string, (args: any) => Promise<unknown>>, failFast: boolean, opts?: ReplayOptions): Promise<{
|
|
122
|
+
total: number;
|
|
123
|
+
passed: number;
|
|
124
|
+
failed: number;
|
|
125
|
+
healedCount: number;
|
|
126
|
+
retries?: {
|
|
127
|
+
attempted: number;
|
|
128
|
+
recovered: number;
|
|
129
|
+
};
|
|
130
|
+
stoppedAt?: number;
|
|
131
|
+
results: any[];
|
|
132
|
+
}>;
|
|
133
|
+
/**
|
|
134
|
+
* 回归报告:list 列出最近运行,show 看单条详情,
|
|
135
|
+
* export 聚合生成 Markdown/HTML 报告落盘工作区。
|
|
136
|
+
*/
|
|
137
|
+
export declare function reportTool(config: BrowserConfig, args: Record<string, any>, exec?: ToolRunContext): Promise<{
|
|
138
|
+
runs: {
|
|
139
|
+
row?: number | undefined;
|
|
140
|
+
runId: string;
|
|
141
|
+
ts: number;
|
|
142
|
+
kind: "replay" | "batch";
|
|
143
|
+
source: string;
|
|
144
|
+
total: number;
|
|
145
|
+
passed: number;
|
|
146
|
+
failed: number;
|
|
147
|
+
healedCount: number;
|
|
148
|
+
durationMs: number;
|
|
149
|
+
}[];
|
|
150
|
+
run?: undefined;
|
|
151
|
+
file?: undefined;
|
|
152
|
+
bytes?: undefined;
|
|
153
|
+
format?: undefined;
|
|
154
|
+
} | {
|
|
155
|
+
run: RunRecord;
|
|
156
|
+
runs?: undefined;
|
|
157
|
+
file?: undefined;
|
|
158
|
+
bytes?: undefined;
|
|
159
|
+
format?: undefined;
|
|
160
|
+
} | {
|
|
161
|
+
file: string;
|
|
162
|
+
bytes: number;
|
|
163
|
+
runs: number;
|
|
164
|
+
format: string;
|
|
165
|
+
run?: undefined;
|
|
166
|
+
}>;
|
|
167
|
+
/**
|
|
168
|
+
* 动作批处理:一次调用顺序执行多个浏览器步骤(内核复用 runReplay),
|
|
169
|
+
* 减少「点击→等待→输入」类固定小序列的工具往返。步骤内禁止嵌套
|
|
170
|
+
* batch/replay/record;批整体在操作轨迹里记为一条 browser_batch。
|
|
171
|
+
*/
|
|
172
|
+
export declare function batchTool(args: Record<string, any>, impls: Record<string, (args: any) => Promise<unknown>>, config?: BrowserConfig): Promise<{
|
|
173
|
+
summary: string;
|
|
174
|
+
total: number;
|
|
175
|
+
passed: number;
|
|
176
|
+
failed: number;
|
|
177
|
+
healedCount: number;
|
|
178
|
+
retries?: {
|
|
179
|
+
attempted: number;
|
|
180
|
+
recovered: number;
|
|
181
|
+
};
|
|
182
|
+
stoppedAt?: number;
|
|
183
|
+
results: any[];
|
|
184
|
+
}>;
|
|
185
|
+
/** 收集步骤中所有 {{var}} 占位符名(导出供测试)。 */
|
|
186
|
+
export declare function findPlaceholders(steps: ReplayStep[]): string[];
|
|
187
|
+
/**
|
|
188
|
+
* 深拷贝步骤并替换字符串叶子里的 {{var}} 占位符(导出供测试)。
|
|
189
|
+
* vars 缺失的占位符保留原样(由调用方先 findPlaceholders 校验)。
|
|
190
|
+
*/
|
|
191
|
+
export declare function substituteVars(steps: ReplayStep[], vars: Record<string, unknown>): ReplayStep[];
|
|
192
|
+
/**
|
|
193
|
+
* 回放入口:name(已保存录制)或 steps(数组)二选一。
|
|
194
|
+
* vars 注入 {{占位符}};data/dataFile 数据集模式逐行运行并聚合。
|
|
195
|
+
*/
|
|
196
|
+
export declare function replayTool(args: Record<string, any>, impls: Record<string, (args: any) => Promise<unknown>>, config?: BrowserConfig, exec?: ToolRunContext): Promise<{
|
|
197
|
+
source: string;
|
|
198
|
+
rows: number;
|
|
199
|
+
passedRows: number;
|
|
200
|
+
failedRows: number;
|
|
201
|
+
runs: any[];
|
|
202
|
+
summary: string;
|
|
203
|
+
} | {
|
|
204
|
+
summary: string;
|
|
205
|
+
total: number;
|
|
206
|
+
passed: number;
|
|
207
|
+
failed: number;
|
|
208
|
+
healedCount: number;
|
|
209
|
+
retries?: {
|
|
210
|
+
attempted: number;
|
|
211
|
+
recovered: number;
|
|
212
|
+
};
|
|
213
|
+
stoppedAt?: number;
|
|
214
|
+
results: any[];
|
|
215
|
+
source: string;
|
|
216
|
+
rows?: undefined;
|
|
217
|
+
passedRows?: undefined;
|
|
218
|
+
failedRows?: undefined;
|
|
219
|
+
runs?: undefined;
|
|
220
|
+
}>;
|
|
221
|
+
/** 重跑请求:source 为已保存录制名,retryOf 为被重跑的原 runId(记录用)。 */
|
|
222
|
+
export interface RerunRequest {
|
|
223
|
+
source: string;
|
|
224
|
+
retryOf?: string;
|
|
225
|
+
}
|
|
226
|
+
type RerunHandler = (req: RerunRequest) => Promise<unknown>;
|
|
227
|
+
/** registerTools 注册重跑入口(stepImpls 同路径);web-only 进程保持 null。 */
|
|
228
|
+
export declare function setRerunHandler(fn: RerunHandler): void;
|
|
229
|
+
/** 当前可用的重跑入口(null = 本进程没有 tools 服务,无法重跑)。 */
|
|
230
|
+
export declare function getRerunHandler(): RerunHandler | null;
|
|
231
|
+
/** 重跑是否正在执行(端点互斥;导出供测试)。 */
|
|
232
|
+
export declare function rerunBusy(): boolean;
|
|
233
|
+
/** 执行一次面板重跑(busy 检查 + 互斥标记;返回 replayTool 结果)。 */
|
|
234
|
+
export declare function runPanelRerun(req: RerunRequest): Promise<unknown>;
|
|
235
|
+
export {};
|
|
236
|
+
//# sourceMappingURL=recorder.d.ts.map
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type { Page } from "playwright-core";
|
|
2
|
+
import type { ToolRunContext } from "../../lib/types.js";
|
|
3
|
+
import type { BrowserConfig } from "../types.js";
|
|
4
|
+
export declare function waitTool(config: BrowserConfig, args: Record<string, any>): Promise<{
|
|
5
|
+
url: string;
|
|
6
|
+
title: string;
|
|
7
|
+
waitedMs: number;
|
|
8
|
+
}>;
|
|
9
|
+
/**
|
|
10
|
+
* 条件检查引擎(测试原语共用)。
|
|
11
|
+
*
|
|
12
|
+
* cond 支持四类(每类内部互斥,取第一个存在的字段):
|
|
13
|
+
* { selector: "#btn", state: "visible|hidden|attached|detached" } 元素状态(默认 visible)
|
|
14
|
+
* { url: "正则字符串" } 当前 URL 匹配
|
|
15
|
+
* { text: "子串" } body 可见文本包含
|
|
16
|
+
* { count: { selector, op: "eq|gt|gte|lt|lte", value: n } } 元素数量比较
|
|
17
|
+
* { eval: "JS 表达式" } 表达式求值 truthy
|
|
18
|
+
*/
|
|
19
|
+
export type TestCondition = Record<string, any>;
|
|
20
|
+
/** 单次检查:返回 { ok, detail }。不抛错,失败时 detail 给出原因。 */
|
|
21
|
+
export declare function checkOnce(page: Page, cond: TestCondition): Promise<{
|
|
22
|
+
ok: boolean;
|
|
23
|
+
detail?: string;
|
|
24
|
+
}>;
|
|
25
|
+
/** 轮询等待条件成立(intervalMs 步进),返回最后一次检查结果。 */
|
|
26
|
+
export declare function pollCondition(page: Page, cond: TestCondition, timeoutMs: number, intervalMs?: number): Promise<{
|
|
27
|
+
ok: boolean;
|
|
28
|
+
detail?: string;
|
|
29
|
+
}>;
|
|
30
|
+
/** 通用显式等待:等待条件成立,超时抛错。 */
|
|
31
|
+
export declare function waitForTool(config: BrowserConfig, args: Record<string, any>): Promise<{
|
|
32
|
+
url: string;
|
|
33
|
+
title: string;
|
|
34
|
+
met: boolean;
|
|
35
|
+
}>;
|
|
36
|
+
/** 断言:条件在 timeoutMs 内成立则通过,否则失败并自动截图存证据。visual 断言走像素比对。 */
|
|
37
|
+
export declare function assertTool(config: BrowserConfig, args: Record<string, any>, exec?: ToolRunContext): Promise<{
|
|
38
|
+
url: string;
|
|
39
|
+
title: string;
|
|
40
|
+
passed: boolean;
|
|
41
|
+
visual: {
|
|
42
|
+
baseline: string;
|
|
43
|
+
diffRatio: number;
|
|
44
|
+
diffPixels: number;
|
|
45
|
+
};
|
|
46
|
+
} | {
|
|
47
|
+
url: string;
|
|
48
|
+
title: string;
|
|
49
|
+
passed: boolean;
|
|
50
|
+
}>;
|
|
51
|
+
/** 网络记录查询:list / failed / wait / clear。兼容 (args) 与 (config, args) 两种调用签名。 */
|
|
52
|
+
export declare function networkTool(configOrArgs?: Record<string, any>, maybeArgs?: Record<string, any>): Promise<{
|
|
53
|
+
cleared: boolean;
|
|
54
|
+
entries: never[];
|
|
55
|
+
matched?: undefined;
|
|
56
|
+
waitMs?: undefined;
|
|
57
|
+
stats?: undefined;
|
|
58
|
+
failed?: undefined;
|
|
59
|
+
} | {
|
|
60
|
+
matched: import("../session.js").NetworkEntry;
|
|
61
|
+
waitMs: number;
|
|
62
|
+
cleared?: undefined;
|
|
63
|
+
entries?: undefined;
|
|
64
|
+
stats?: undefined;
|
|
65
|
+
failed?: undefined;
|
|
66
|
+
} | {
|
|
67
|
+
stats: {
|
|
68
|
+
host: string;
|
|
69
|
+
total: number;
|
|
70
|
+
failed: number;
|
|
71
|
+
avgMs: number | null;
|
|
72
|
+
byStatus: Record<string, number>;
|
|
73
|
+
}[];
|
|
74
|
+
cleared?: undefined;
|
|
75
|
+
entries?: undefined;
|
|
76
|
+
matched?: undefined;
|
|
77
|
+
waitMs?: undefined;
|
|
78
|
+
failed?: undefined;
|
|
79
|
+
} | {
|
|
80
|
+
failed: import("../session.js").NetworkEntry[];
|
|
81
|
+
cleared?: undefined;
|
|
82
|
+
entries?: undefined;
|
|
83
|
+
matched?: undefined;
|
|
84
|
+
waitMs?: undefined;
|
|
85
|
+
stats?: undefined;
|
|
86
|
+
} | {
|
|
87
|
+
entries: import("../session.js").NetworkEntry[];
|
|
88
|
+
cleared?: undefined;
|
|
89
|
+
matched?: undefined;
|
|
90
|
+
waitMs?: undefined;
|
|
91
|
+
stats?: undefined;
|
|
92
|
+
failed?: undefined;
|
|
93
|
+
}>;
|
|
94
|
+
//# sourceMappingURL=testing.d.ts.map
|