dsh-browser-view 0.4.1 → 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 +7776 -5392
- 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 -873
- package/lib/types/browser/types.d.ts +70 -7
- package/lib/types/browser/walker.d.ts +3 -12
- 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
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import type { BrowserContext, Page } from "playwright-core";
|
|
2
|
-
import type { BrowserConfig, ProfileState, DownloadEntry, FormField, NavEntry
|
|
2
|
+
import type { BrowserConfig, ProfileState, DownloadEntry, FormField, NavEntry } from "./types.js";
|
|
3
|
+
export * from "./session/cache.js";
|
|
4
|
+
export * from "./session/collaboration.js";
|
|
5
|
+
export * from "./session/recorder.js";
|
|
6
|
+
export * from "./session/screenshot.js";
|
|
7
|
+
export * from "./session/target.js";
|
|
8
|
+
export * from "./session/semantic.js";
|
|
3
9
|
/** 当前活动 profile 名(默认 "default")。 */
|
|
4
10
|
export declare let currentProfile: string;
|
|
5
11
|
/** 多配置文件浏览器会话:name → 会话状态。 */
|
|
@@ -8,129 +14,6 @@ export declare const profileStates: Map<string, ProfileState>;
|
|
|
8
14
|
export declare const savedForms: Map<string, FormField[]>;
|
|
9
15
|
/** 最近一次 browser_form 填充的字段(供 browser_form_save 无参保存)。 */
|
|
10
16
|
export declare let lastFormFields: FormField[];
|
|
11
|
-
/** 记录一次 aria 快照分配的 ref(整表替换)。 */
|
|
12
|
-
export declare function setPageRefs(page: Page, refs: Map<string, RefEntry>): void;
|
|
13
|
-
/** 查询某个 ref 的定位信息;未注册返回 undefined。 */
|
|
14
|
-
export declare function pageRef(page: Page, ref: string): RefEntry | undefined;
|
|
15
|
-
/** 清空页面的 ref 表(导航/新快照时调用)。 */
|
|
16
|
-
export declare function clearPageRefs(page: Page): void;
|
|
17
|
-
/** 取页面当前完整 ref 表(browser_find 增量续号合并用;无则空 Map)。 */
|
|
18
|
-
export declare function pageRefsOf(page: Page): Map<string, RefEntry>;
|
|
19
|
-
/** 一个历史版本的快照内容(text/aria 两种模式共用同一条版本序列)。 */
|
|
20
|
-
export interface SnapshotEntry {
|
|
21
|
-
version: number;
|
|
22
|
-
text: string;
|
|
23
|
-
aria: string;
|
|
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
|
-
}
|
|
36
|
-
export declare function snapshotCacheOf(page: Page): SnapshotCache | undefined;
|
|
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;
|
|
50
|
-
/** 已保存的录制脚本:name → 步骤数组。 */
|
|
51
|
-
export declare const savedRecordings: Map<string, {
|
|
52
|
-
steps: ReplayStep[];
|
|
53
|
-
savedAt: number;
|
|
54
|
-
}>;
|
|
55
|
-
/** 一次工具调用的记录(操作轨迹 / 录制 / 回放共用)。 */
|
|
56
|
-
export interface TestCall {
|
|
57
|
-
tool: string;
|
|
58
|
-
args: Record<string, any>;
|
|
59
|
-
ok: boolean;
|
|
60
|
-
ms: number;
|
|
61
|
-
ts: number;
|
|
62
|
-
error?: string;
|
|
63
|
-
/** 录制时采集的选择器指纹(回放自愈用;register 包装层异步补齐)。 */
|
|
64
|
-
meta?: {
|
|
65
|
-
hint?: SelectorHint;
|
|
66
|
-
source?: "human";
|
|
67
|
-
};
|
|
68
|
-
/** source: "human" 表示这条来自用户在浏览器中的手动操作(混合录制)。 */
|
|
69
|
-
source?: "human";
|
|
70
|
-
}
|
|
71
|
-
export declare function isRecording(): boolean;
|
|
72
|
-
export declare function startRecording(): void;
|
|
73
|
-
export declare function stopRecording(): TestCall[];
|
|
74
|
-
/** 最近一次完整录制(start→stop)的 buffer;从未录制过返回 null。 */
|
|
75
|
-
export declare function lastRecordingOf(): TestCall[] | null;
|
|
76
|
-
/** 操作轨迹追加(同时写入录制 buffer,排除 record/replay 自身)。返回存入的调用对象(供调用方补 meta)。 */
|
|
77
|
-
export declare function recordCall(call: TestCall): TestCall;
|
|
78
|
-
/** 操作轨迹(按时间倒序,最新在前)。 */
|
|
79
|
-
export declare function testLogOf(): TestCall[];
|
|
80
|
-
export declare function setPauseInstruction(instruction: string): void;
|
|
81
|
-
export declare function clearPauseInstruction(): void;
|
|
82
|
-
export declare function currentPause(): {
|
|
83
|
-
instruction: string;
|
|
84
|
-
startedAt: number;
|
|
85
|
-
} | null;
|
|
86
|
-
/** 一次待审批的敏感操作(browser_confirm 等待期间供面板展示与提交决策)。 */
|
|
87
|
-
export interface PendingConfirm {
|
|
88
|
-
id: string;
|
|
89
|
-
reason: string;
|
|
90
|
-
tool?: string;
|
|
91
|
-
args?: Record<string, any>;
|
|
92
|
-
startedAt: number;
|
|
93
|
-
decision?: "allowed" | "denied";
|
|
94
|
-
}
|
|
95
|
-
export declare function setPendingConfirm(entry: PendingConfirm): void;
|
|
96
|
-
export declare function getPendingConfirm(): PendingConfirm | null;
|
|
97
|
-
export declare function clearPendingConfirm(): void;
|
|
98
|
-
/** 面板提交审批决策;id 不匹配(已被新审批取代/超时清理)时返回 false。 */
|
|
99
|
-
export declare function resolveConfirm(id: string, decision: "allowed" | "denied"): boolean;
|
|
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;
|
|
107
|
-
/** window 上的回传 binding 名(须为合法 JS 标识符)。 */
|
|
108
|
-
export declare const HUMAN_BINDING = "__dshBrowserHumanEvent";
|
|
109
|
-
/** agent 即将/刚刚执行了 DOM 操作(register 包装层调用);1.5s 内的页内事件视为工具回声。 */
|
|
110
|
-
export declare function noteAgentAction(): void;
|
|
111
|
-
/** 导出供测试:距上次 agent 操作是否在去重窗口内。 */
|
|
112
|
-
export declare function agentActionRecent(now?: number, windowMs?: number): boolean;
|
|
113
|
-
/**
|
|
114
|
-
* 页内人工操作事件 → 录制步骤(纯函数,导出供测试)。
|
|
115
|
-
* payload 由 installHumanRecorder 生成:{ kind, selector, value?, testid?, role?, name?, id?, text?, tag? }。
|
|
116
|
-
* 无法映射(缺 selector / 未知 kind / 空输入)返回 null。
|
|
117
|
-
*/
|
|
118
|
-
export declare function humanEventToStep(payload: unknown): {
|
|
119
|
-
tool: string;
|
|
120
|
-
args: Record<string, any>;
|
|
121
|
-
meta: {
|
|
122
|
-
hint: SelectorHint;
|
|
123
|
-
source: "human";
|
|
124
|
-
};
|
|
125
|
-
} | null;
|
|
126
|
-
/**
|
|
127
|
-
* 页内注入的人工操作监听(addInitScript 序列化;每次导航自动重装)。
|
|
128
|
-
* 监听常驻但 node 侧只在录制中生效,关闭录制等价于"移除"。
|
|
129
|
-
* 只上报可交互元素上的 click 与表单控件的 change,避免逐键噪音。
|
|
130
|
-
* F5 收敛:cssPath 等元素描述来自 walker.ts 单一来源(构建期拼装注入),
|
|
131
|
-
* 不再持有内联副本;payload 字段语义与 v0.3 完全一致。
|
|
132
|
-
*/
|
|
133
|
-
export declare const installHumanRecorder: (payload: unknown) => void;
|
|
134
17
|
/** 网络请求/响应记录。 */
|
|
135
18
|
export interface NetworkEntry {
|
|
136
19
|
url: string;
|
|
@@ -190,20 +73,4 @@ export declare function pageIdentity(page: Page): Promise<{
|
|
|
190
73
|
export declare function setLastFormFields(fields: FormField[]): void;
|
|
191
74
|
/** 切换当前 profile。 */
|
|
192
75
|
export declare function setCurrentProfile(name: string): void;
|
|
193
|
-
/** 记录最近一次截图目录(截图工具调用时写入)。 */
|
|
194
|
-
export declare function noteScreenshotDir(dir: string): void;
|
|
195
|
-
/** 定时清扫入口:若已知截图目录则按当前配置清理。 */
|
|
196
|
-
export declare function sweepScreenshotDir(opts: {
|
|
197
|
-
maxAgeDays?: number;
|
|
198
|
-
maxCount?: number;
|
|
199
|
-
}): number;
|
|
200
|
-
/**
|
|
201
|
-
* 清理截图目录里的 .png 文件:按修改时间保留最新的 maxCount 个,
|
|
202
|
-
* 并删除超过 maxAgeDays 天的旧文件。只处理目录直属文件,不递归;
|
|
203
|
-
* 单个文件删除失败(被占用等)静默跳过。返回删除数量。
|
|
204
|
-
*/
|
|
205
|
-
export declare function cleanupScreenshots(dir: string, opts: {
|
|
206
|
-
maxAgeDays?: number;
|
|
207
|
-
maxCount?: number;
|
|
208
|
-
}): number;
|
|
209
76
|
//# sourceMappingURL=session.d.ts.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Page } from "playwright-core";
|
|
2
|
+
export interface TypeOptions {
|
|
3
|
+
speed?: "slow" | "normal" | "fast";
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* 基于 Box-Muller 变换的高斯分布随机数生成器
|
|
7
|
+
*/
|
|
8
|
+
export declare function gaussianRandom(mean?: number, stdev?: number, min?: number, max?: number): number;
|
|
9
|
+
/**
|
|
10
|
+
* 拟人化敲击键盘输入文本
|
|
11
|
+
*/
|
|
12
|
+
export declare function humanType(page: Page, text: string, options?: TypeOptions): Promise<void>;
|
|
13
|
+
//# sourceMappingURL=keyboard.d.ts.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Locator, Page } from "playwright-core";
|
|
2
|
+
export interface Point {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
}
|
|
6
|
+
export interface MouseOptions {
|
|
7
|
+
speed?: "slow" | "normal" | "fast";
|
|
8
|
+
steps?: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* 获取当前页面记录的鼠标坐标,若未记录则默认返回初始点 (100, 100)
|
|
12
|
+
*/
|
|
13
|
+
export declare function getMousePosition(page: Page): Point;
|
|
14
|
+
export declare function setMousePosition(page: Page, pos: Point): void;
|
|
15
|
+
/**
|
|
16
|
+
* 生成起点到终点的三次贝塞尔平滑轨迹点序列
|
|
17
|
+
* B(t) = (1-t)^3 * P0 + 3(1-t)^2 * t * P1 + 3(1-t) * t^2 * P2 + t^3 * P3
|
|
18
|
+
*/
|
|
19
|
+
export declare function generateBezierPath(start: Point, end: Point, stepCount?: number): Point[];
|
|
20
|
+
/**
|
|
21
|
+
* 拟人化平滑移动鼠标至指定像素坐标
|
|
22
|
+
*/
|
|
23
|
+
export declare function humanMove(page: Page, target: Point, options?: MouseOptions): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* 拟人化微偏随机点击元素
|
|
26
|
+
*/
|
|
27
|
+
export declare function humanClick(page: Page, locator: Locator, options?: MouseOptions): Promise<boolean>;
|
|
28
|
+
//# sourceMappingURL=mouse.d.ts.map
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { Page } from "playwright-core";
|
|
2
|
+
import type { BrowserConfig } from "../types.js";
|
|
3
|
+
/**
|
|
4
|
+
* 操作预告高亮:agent 即将 click/type/select/press 的元素在页面上琥珀色描边
|
|
5
|
+
* ~1.5 秒。异步不阻塞(fire-and-forget,任何失败静默),不影响操作时序。
|
|
6
|
+
*/
|
|
7
|
+
export declare function previewHighlight(page: Page | null, selector: string, label: string): void;
|
|
8
|
+
/**
|
|
9
|
+
* 等待人工登录完成(配合 headless:false 使用):agent 打开登录页后调用本工具,
|
|
10
|
+
* 提示用户在浏览器窗口中完成登录(输入/扫码/双因素)。基于通用条件引擎:
|
|
11
|
+
* successSelector / successUrl 指定完成条件,两者都不给则以 URL 跳转视为完成。
|
|
12
|
+
* 超时返回 loggedIn:false(不抛错)。
|
|
13
|
+
*/
|
|
14
|
+
export declare function waitForLoginTool(config: BrowserConfig, args: Record<string, any>): Promise<{
|
|
15
|
+
url: string;
|
|
16
|
+
title: string;
|
|
17
|
+
loggedIn: boolean;
|
|
18
|
+
}>;
|
|
19
|
+
/**
|
|
20
|
+
* 人工接管等待(通用版 wait_for_login):agent 把控制权交还给用户(验证码 /
|
|
21
|
+
* 二次确认 / 人工复核等)。instruction 会显示在实时画面面板;完成条件三选一:
|
|
22
|
+
* successSelector(元素出现)/ successUrl(URL 正则)/ 两者都不给则以
|
|
23
|
+
* URL 变化或页面内容签名变化视为完成。轮询间隔 2 秒,超时返回 completed:false
|
|
24
|
+
* (不抛错)。导出 runPauseOnPage 供测试注入 fake page。
|
|
25
|
+
*/
|
|
26
|
+
export declare function runPauseOnPage(page: Page, args: Record<string, any>): Promise<{
|
|
27
|
+
completed: boolean;
|
|
28
|
+
waitedMs: number;
|
|
29
|
+
detail: string;
|
|
30
|
+
}>;
|
|
31
|
+
/** 人工接管等待工具入口(缺 instruction 在启动浏览器前即校验,失败更快)。 */
|
|
32
|
+
export declare function pauseForHumanTool(config: BrowserConfig, args: Record<string, any>): Promise<{
|
|
33
|
+
url: string;
|
|
34
|
+
title: string;
|
|
35
|
+
completed: boolean;
|
|
36
|
+
status: "completed" | "timedOut";
|
|
37
|
+
instruction: string;
|
|
38
|
+
detail: string;
|
|
39
|
+
waitedMs: number;
|
|
40
|
+
}>;
|
|
41
|
+
/**
|
|
42
|
+
* 敏感操作审批:agent 在执行提交/删除/支付类动作前调用,把审批请求推到实时
|
|
43
|
+
* 画面面板,挂起等待用户点「允许/拒绝」。超时视为拒绝(fail-closed)。
|
|
44
|
+
* 用户允许时返回 { decision: "allowed", ... };拒绝/超时**抛错**(消息含原因),
|
|
45
|
+
* 使 live 调用与 replay/batch 步骤统一按失败处理,agent 不应继续敏感动作。
|
|
46
|
+
* 决策通过 session.resolveConfirm(面板 POST)写入。
|
|
47
|
+
*/
|
|
48
|
+
export declare function confirmTool(config: BrowserConfig, args: Record<string, any>): Promise<{
|
|
49
|
+
decision: "allowed";
|
|
50
|
+
id: string;
|
|
51
|
+
reason: string;
|
|
52
|
+
waitedMs: number;
|
|
53
|
+
detail: string;
|
|
54
|
+
}>;
|
|
55
|
+
/**
|
|
56
|
+
* 面板点选教学工具:等待用户在实时画面大图上点选目标元素,返回其统一描述、
|
|
57
|
+
* 稳定 selector、选择器指纹(与录制自愈 healCandidates 兼容)与可直接使用
|
|
58
|
+
* 的 ref。坐标换算:cssX = imgPx * viewportWidth / imgW / pageScaleFactor(elementFromPoint 收
|
|
59
|
+
* 视口相对坐标,无需 scroll 换算)。
|
|
60
|
+
* 导出 pickToolOnPage 供测试注入 fake page。
|
|
61
|
+
*/
|
|
62
|
+
export declare function pickToolOnPage(page: Page, config: BrowserConfig, args: Record<string, any>): Promise<Record<string, any>>;
|
|
63
|
+
/** 面板点选教学工具入口。 */
|
|
64
|
+
export declare function pickTool(config: BrowserConfig, args: Record<string, any>): Promise<Record<string, any>>;
|
|
65
|
+
import { sensitiveHits, DEFAULT_SENSITIVE_PATTERNS, DEFAULT_SENSITIVE_TOOLS, type SensitiveDesc } from "../policy/engine.js";
|
|
66
|
+
export { sensitiveHits, DEFAULT_SENSITIVE_PATTERNS, DEFAULT_SENSITIVE_TOOLS, type SensitiveDesc };
|
|
67
|
+
/**
|
|
68
|
+
* 策略引擎审批闸: 命中 auto 级别策略时经 confirmTool 弹审批等待用户决策,
|
|
69
|
+
* 拒绝/超时抛错(调用方该步失败), 允许则返回继续执行原工具。
|
|
70
|
+
* page 参数仅供测试注入; 缺省取当前活动页。
|
|
71
|
+
*/
|
|
72
|
+
export declare function confirmGate(config: BrowserConfig, tool: string, args: Record<string, any>, page?: Page | null): Promise<void>;
|
|
73
|
+
//# sourceMappingURL=collaboration.d.ts.map
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/** 组件库下拉框的可见选项选择器并集 (基于通用 WAI-ARIA 与主流组件库规范)。 */
|
|
2
|
+
export declare const DROPDOWN_OPTION_SELECTOR: string;
|
|
3
|
+
/** 读取 PNG 文件头(IHDR)中的宽高,不解码像素(导出供测试)。 */
|
|
4
|
+
export declare function pngSize(buf: Buffer): {
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
};
|
|
8
|
+
/** 按缩放比例换算 mask 矩形(导出供测试;与页内比对共用同一套坐标语义)。 */
|
|
9
|
+
export declare function scaleRects(rects: {
|
|
10
|
+
x: number;
|
|
11
|
+
y: number;
|
|
12
|
+
width: number;
|
|
13
|
+
height: number;
|
|
14
|
+
}[], scale: number): {
|
|
15
|
+
x: number;
|
|
16
|
+
y: number;
|
|
17
|
+
width: number;
|
|
18
|
+
height: number;
|
|
19
|
+
}[];
|
|
20
|
+
/**
|
|
21
|
+
* 快照文本压缩(导出供测试):
|
|
22
|
+
* - 去掉首尾空白行;
|
|
23
|
+
* - 连续空白行折叠为 1 行;
|
|
24
|
+
* - 连续重复的非空行(表格空单元格/占位行产生的噪音)折叠为「首行 + …(重复 N 行)」。
|
|
25
|
+
* 只折叠完全相同的相邻行,不重排、不删改非重复内容。
|
|
26
|
+
*/
|
|
27
|
+
export declare function compressText(text: string): string;
|
|
28
|
+
/** 最长公共子串长度(小写比较;零依赖,导出供测试)。 */
|
|
29
|
+
export declare function lcsScore(a: string, b: string): number;
|
|
30
|
+
/** 零命中时按相似度挑 top5 候选(导出供测试)。 */
|
|
31
|
+
export declare function topSuggestions(query: string, candidates: {
|
|
32
|
+
role: string;
|
|
33
|
+
name: string;
|
|
34
|
+
}[], count?: number): {
|
|
35
|
+
role: string;
|
|
36
|
+
name: string;
|
|
37
|
+
score: number;
|
|
38
|
+
}[];
|
|
39
|
+
/**
|
|
40
|
+
* 行级 diff:掐掉公共前缀/后缀,返回变化区。导出供测试。
|
|
41
|
+
* 全等返回 { unchanged: true };否则 changedFrom 为新文本中变化区首行(1 起)。
|
|
42
|
+
*/
|
|
43
|
+
export declare function diffLines(oldText: string, newText: string): {
|
|
44
|
+
unchanged: boolean;
|
|
45
|
+
changedFrom?: number;
|
|
46
|
+
lines?: string[];
|
|
47
|
+
removed?: number;
|
|
48
|
+
};
|
|
49
|
+
/** 给本身无超时的 Playwright 调用(evaluate/allTextContents)加有界保护,防页面主线程忙时无限挂起。 */
|
|
50
|
+
export declare function withTimeout<T>(p: Promise<T>, ms: number, what: string): Promise<T>;
|
|
51
|
+
/**
|
|
52
|
+
* 防御性解码 eval 脚本:模型/人工偶发把脚本 JSON.stringify 一次再传
|
|
53
|
+
* (脚本以 \" 开头、换行变字面 \\n),回放/录制链路不纠错会导致语法错误。
|
|
54
|
+
* 识别条件:字符串以引号包裹且含反斜杠转义,且 JSON.parse 结果仍是字符串。
|
|
55
|
+
* 无法解析或语义不变场景原样返回(裸字符串字面量如 "hello" 不含转义,不受影响)。
|
|
56
|
+
*/
|
|
57
|
+
export declare function unwrapDoubleEncodedScript(script: string): {
|
|
58
|
+
script: string;
|
|
59
|
+
unwrapped: boolean;
|
|
60
|
+
};
|
|
61
|
+
/** 工作区内落盘路径解析(拒绝穿越到工作区之外)。 */
|
|
62
|
+
export declare function workspaceFilePath(cwd: string, file: string): string;
|
|
63
|
+
/**
|
|
64
|
+
* 规则化抽取:fields 定义抽取结构,next 选择器驱动翻页(maxPages 上限),
|
|
65
|
+
* 行数超 maxRows 截断;format/file 控制序列化与落盘(json/csv/jsonl/markdown)。
|
|
66
|
+
*/
|
|
67
|
+
//# sourceMappingURL=common.d.ts.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ToolRunContext } from "../../lib/types.js";
|
|
2
|
+
import type { BrowserConfig } from "../types.js";
|
|
3
|
+
/** 一项诊断结果(ok=false 时附 advice 修复建议)。导出供测试。 */
|
|
4
|
+
export interface DoctorCheck {
|
|
5
|
+
name: string;
|
|
6
|
+
ok: boolean;
|
|
7
|
+
detail: string;
|
|
8
|
+
advice?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function setDoctorProbe(fn: ((basePath: string) => Promise<{
|
|
11
|
+
ok: boolean;
|
|
12
|
+
detail: string;
|
|
13
|
+
advice?: string;
|
|
14
|
+
}>) | null): void;
|
|
15
|
+
/** 目录可写性检查(mkdir + 写探针文件 + 删除)。导出供测试。 */
|
|
16
|
+
export declare function checkWritableDir(dir: string): {
|
|
17
|
+
ok: boolean;
|
|
18
|
+
detail: string;
|
|
19
|
+
};
|
|
20
|
+
/** 可执行文件存在性检查(executablePath 显式配置用)。导出供测试。 */
|
|
21
|
+
export declare function checkExecutable(path: string): DoctorCheck;
|
|
22
|
+
/** 一次性健康诊断:不启动浏览器,只做静态/本地检查。 */
|
|
23
|
+
export declare function doctorTool(config: BrowserConfig, _args: Record<string, any>, exec?: ToolRunContext): Promise<{
|
|
24
|
+
checks: DoctorCheck[];
|
|
25
|
+
summary: {
|
|
26
|
+
ok: boolean;
|
|
27
|
+
passed: number;
|
|
28
|
+
failed: number;
|
|
29
|
+
};
|
|
30
|
+
}>;
|
|
31
|
+
//# sourceMappingURL=doctor.d.ts.map
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import type { ToolRunContext } from "../../lib/types.js";
|
|
2
|
+
import type { BrowserConfig } from "../types.js";
|
|
3
|
+
export interface ExtractField {
|
|
4
|
+
name: string;
|
|
5
|
+
selector: string;
|
|
6
|
+
attr?: string;
|
|
7
|
+
multiple?: boolean;
|
|
8
|
+
fields?: ExtractField[];
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* 把单页抽取结果规整为行数组:恰好一个顶层 multiple 字段时,其数组即行
|
|
12
|
+
* (行内嵌套对象为行,标量包装成 { [name]: value });否则整页算一行。
|
|
13
|
+
*/
|
|
14
|
+
export declare function rowsOfExtract(result: Record<string, any>, fields: ExtractField[]): Record<string, any>[];
|
|
15
|
+
/** suggest 采集的表格单元格信息(页内采集,纯函数消费)。 */
|
|
16
|
+
export interface SuggestCell {
|
|
17
|
+
text: string;
|
|
18
|
+
href?: string;
|
|
19
|
+
src?: string;
|
|
20
|
+
}
|
|
21
|
+
/** suggest 页内分析结果(自包含 injectWalker 注入采集)。 */
|
|
22
|
+
export interface SuggestAnalysis {
|
|
23
|
+
ok: boolean;
|
|
24
|
+
/** table: 表格行模式;list: 重复卡片/列表项模式。 */
|
|
25
|
+
kind?: "table" | "list";
|
|
26
|
+
/** 行/卡片选择器(抽取 fields 顶层的 multiple selector)。 */
|
|
27
|
+
rowSelector?: string;
|
|
28
|
+
headerTexts?: string[];
|
|
29
|
+
cells?: SuggestCell[];
|
|
30
|
+
item?: SuggestCell;
|
|
31
|
+
reason?: string;
|
|
32
|
+
overview?: {
|
|
33
|
+
links: number;
|
|
34
|
+
images: number;
|
|
35
|
+
buttons: number;
|
|
36
|
+
headings: number;
|
|
37
|
+
rows: number;
|
|
38
|
+
textChars: number;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/** 字段名净化:空白→下划线,限长 30,空回落 col_N。导出供测试。 */
|
|
42
|
+
export declare function suggestFieldName(header: string | undefined, index: number): string;
|
|
43
|
+
/**
|
|
44
|
+
* 纯逻辑:由表头与首行单元格特征推断表格 fields(单元格文本/链接 href/图片 src)。
|
|
45
|
+
* 返回可直接放进 rows.fields 的嵌套字段数组。导出供测试。
|
|
46
|
+
*/
|
|
47
|
+
export declare function fieldsFromCells(headerTexts: string[], cells: SuggestCell[]): ExtractField[];
|
|
48
|
+
/**
|
|
49
|
+
* 纯逻辑:由首条卡片信息推断列表 fields(项文本/链接/图片)。
|
|
50
|
+
* 文本取第一个子元素(项自身无法用 querySelector 自选)。导出供测试。
|
|
51
|
+
*/
|
|
52
|
+
export declare function fieldsFromCard(item: SuggestCell): ExtractField[];
|
|
53
|
+
/** 纯逻辑:由 fields 与单元格样本拼出首行样例(与抽取输出同构;按 td 序号对位)。导出供测试。 */
|
|
54
|
+
export declare function sampleOfFields(fields: ExtractField[], cells: SuggestCell[]): Record<string, unknown>;
|
|
55
|
+
/**
|
|
56
|
+
* suggest 汇总(纯逻辑):由页内分析结果组装「可直接交给抽取模式」的顶层 fields
|
|
57
|
+
* (单个 multiple rows 字段 + 行内嵌套字段)与样本。推断失败原样返回。导出供测试。
|
|
58
|
+
*/
|
|
59
|
+
export declare function suggestWrap(analysis: SuggestAnalysis): {
|
|
60
|
+
suggested: boolean;
|
|
61
|
+
kind?: "table" | "list";
|
|
62
|
+
rowSelector?: string;
|
|
63
|
+
headerTexts?: string[];
|
|
64
|
+
fields?: ExtractField[];
|
|
65
|
+
sample?: Record<string, unknown>;
|
|
66
|
+
reason?: string;
|
|
67
|
+
overview?: SuggestAnalysis["overview"];
|
|
68
|
+
};
|
|
69
|
+
export declare function extractTool(config: BrowserConfig, args: Record<string, any>, exec?: ToolRunContext): Promise<{
|
|
70
|
+
url: string;
|
|
71
|
+
title: string;
|
|
72
|
+
suggested: boolean;
|
|
73
|
+
kind?: "table" | "list";
|
|
74
|
+
rowSelector?: string;
|
|
75
|
+
headerTexts?: string[];
|
|
76
|
+
fields?: ExtractField[];
|
|
77
|
+
sample?: Record<string, unknown>;
|
|
78
|
+
reason?: string;
|
|
79
|
+
overview?: SuggestAnalysis["overview"];
|
|
80
|
+
action: string;
|
|
81
|
+
} | {
|
|
82
|
+
url: string;
|
|
83
|
+
title: string;
|
|
84
|
+
file?: string | undefined;
|
|
85
|
+
bytes?: number | undefined;
|
|
86
|
+
truncated: boolean;
|
|
87
|
+
rows: Record<string, any>[];
|
|
88
|
+
count: number;
|
|
89
|
+
pages: number;
|
|
90
|
+
format: string;
|
|
91
|
+
}>;
|
|
92
|
+
//# sourceMappingURL=extract.d.ts.map
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { ToolRunContext } from "../../lib/types.js";
|
|
2
|
+
import type { BrowserConfig } from "../types.js";
|
|
3
|
+
import { assignRefs as assignRefsImpl } from "../session/cache.js";
|
|
4
|
+
export declare const assignRefs: typeof assignRefsImpl;
|
|
5
|
+
/**
|
|
6
|
+
* 页内语义扫描已收敛到 session/semantic.ts 的 scanInteractive(walker 单一
|
|
7
|
+
* 来源 + 打分排序),browser_find 与 what 语义定位共用同一匹配语义。
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* 语义元素定位:按名称(或 id/data-testid)在可交互元素中查找,只返回命中的
|
|
11
|
+
* ref + 区域上下文,不输出全量 aria 树 —— 大页面定位单个目标时 token 开销
|
|
12
|
+
* 远小于 browser_snapshot { mode: "aria" }。返回的 ref 可直接用于
|
|
13
|
+
* click/type/select/press。零命中不抛错,附最相近候选供二次定位。
|
|
14
|
+
*/
|
|
15
|
+
export declare function findTool(config: BrowserConfig, args: Record<string, any>): Promise<{
|
|
16
|
+
scanned: number;
|
|
17
|
+
url: string;
|
|
18
|
+
title: string;
|
|
19
|
+
truncated?: true | undefined;
|
|
20
|
+
suggestions?: {
|
|
21
|
+
role: string;
|
|
22
|
+
name: string;
|
|
23
|
+
score: number;
|
|
24
|
+
}[] | undefined;
|
|
25
|
+
found: number;
|
|
26
|
+
matches: {
|
|
27
|
+
ref: string;
|
|
28
|
+
role: string;
|
|
29
|
+
name: string;
|
|
30
|
+
ancestors: string[] | undefined;
|
|
31
|
+
}[];
|
|
32
|
+
}>;
|
|
33
|
+
export declare function snapshotTool(config: BrowserConfig, args: Record<string, any>): Promise<{
|
|
34
|
+
url: string;
|
|
35
|
+
title: string;
|
|
36
|
+
scope?: string | undefined;
|
|
37
|
+
unchanged: boolean;
|
|
38
|
+
contentVersion: number;
|
|
39
|
+
} | {
|
|
40
|
+
url: string;
|
|
41
|
+
title: string;
|
|
42
|
+
truncated: boolean;
|
|
43
|
+
scope?: string | undefined;
|
|
44
|
+
diff: boolean;
|
|
45
|
+
contentVersion: number;
|
|
46
|
+
changedFrom: number | undefined;
|
|
47
|
+
removed: number | undefined;
|
|
48
|
+
} | {
|
|
49
|
+
url: string;
|
|
50
|
+
title: string;
|
|
51
|
+
truncated: boolean;
|
|
52
|
+
scope?: string | undefined;
|
|
53
|
+
stale?: boolean | undefined;
|
|
54
|
+
contentVersion: number;
|
|
55
|
+
}>;
|
|
56
|
+
export declare function screenshotTool(config: BrowserConfig, args: Record<string, any>, exec?: ToolRunContext): Promise<{
|
|
57
|
+
path: string;
|
|
58
|
+
bytes: number;
|
|
59
|
+
width: number;
|
|
60
|
+
height: number;
|
|
61
|
+
baseline: string;
|
|
62
|
+
} | {
|
|
63
|
+
som?: boolean | undefined;
|
|
64
|
+
somMarks?: {
|
|
65
|
+
id: number;
|
|
66
|
+
role: string;
|
|
67
|
+
name: string;
|
|
68
|
+
}[] | undefined;
|
|
69
|
+
path: string;
|
|
70
|
+
bytes: number;
|
|
71
|
+
width: number;
|
|
72
|
+
height: number;
|
|
73
|
+
baseline?: undefined;
|
|
74
|
+
}>;
|
|
75
|
+
/**
|
|
76
|
+
* 语义定位零命中时的 SoM 兜底截图(clickTool 失败路径调用,somFallback 配置
|
|
77
|
+
* 控制):截一张带标徽的视口图,供多模态模型看图后 browser_click { mark: N }
|
|
78
|
+
* 一次往返完成定位。无活动页面或截图失败返回 null(不放大错误)。
|
|
79
|
+
*/
|
|
80
|
+
export declare function somFallbackShot(config: BrowserConfig, exec?: ToolRunContext): Promise<{
|
|
81
|
+
screenshot: string;
|
|
82
|
+
marks: Array<{
|
|
83
|
+
id: number;
|
|
84
|
+
role: string;
|
|
85
|
+
name: string;
|
|
86
|
+
}>;
|
|
87
|
+
} | null>;
|
|
88
|
+
export declare function elementsTool(config: BrowserConfig, args: Record<string, any>): Promise<{
|
|
89
|
+
count: number;
|
|
90
|
+
elements: Record<string, unknown>[];
|
|
91
|
+
dropdownOptions: string[];
|
|
92
|
+
}>;
|
|
93
|
+
//# sourceMappingURL=inspection.d.ts.map
|