@glittering0717/ai-browser 2.5.5 → 2.5.7
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/examples/AGENT_INSTRUCTIONS.md +3 -3
- package/package.json +1 -1
- package/scripts/skill.cjs +168 -10
- package/skills/ai-browser/SKILL.md +20 -15
- package/skills/ai-browser/references/network.md +34 -12
- package/skills/ai-browser/references/tasks.md +3 -3
- package/skills/content-publish/SKILL.md +10 -3
- package/skills/read-webpage/SKILL.md +10 -3
- package/src/main/mcp_instructions.js +37 -0
- package/src/main/mcp_server.js +32 -3
- package/src/main/mcp_tools.js +13 -12
- package/src/shared/version.js +1 -1
- package/skills/web-network-monitor/SKILL.md +0 -52
|
@@ -11,12 +11,12 @@ npx -y @glittering0717/ai-browser skill install
|
|
|
11
11
|
|
|
12
12
|
| 技能 | 干什么 |
|
|
13
13
|
|---|---|
|
|
14
|
-
| `ai-browser` |
|
|
14
|
+
| `ai-browser` | 最小循环、卡住时的第一反应、难搞页面的处理(抓请求/看接口在它的 `references/network.md`) |
|
|
15
15
|
| `content-publish` | 把文章发布到 CSDN / 知乎 / 掘金 |
|
|
16
16
|
| `read-webpage` | 读一篇文章正文并总结 |
|
|
17
|
-
| `web-network-monitor` | 长时间盯某个页面的请求 |
|
|
18
17
|
|
|
19
|
-
不装技能也能用——
|
|
18
|
+
不装技能也能用——17 个工具的 schema 之外,MCP 初始化时还会给客户端一段 `instructions`
|
|
19
|
+
(我是谁、什么时候用我、最小循环)。技能只是把"怎么组合"讲得更细。
|
|
20
20
|
|
|
21
21
|
---
|
|
22
22
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@glittering0717/ai-browser",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.7",
|
|
4
4
|
"description": "AI-native browser — renders pixels for humans, structured semantic-tree API for agents. No screenshots, no OCR, no coordinate guessing.",
|
|
5
5
|
"main": "src/main/index.js",
|
|
6
6
|
"bin": {
|
package/scripts/skill.cjs
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
const fs = require('node:fs');
|
|
15
15
|
const os = require('node:os');
|
|
16
16
|
const path = require('node:path');
|
|
17
|
+
const crypto = require('node:crypto');
|
|
17
18
|
const pkg = require('../package.json');
|
|
18
19
|
|
|
19
20
|
const SKILLS_ROOT = path.join(__dirname, '..', 'skills');
|
|
@@ -42,19 +43,133 @@ function detectTargets() {
|
|
|
42
43
|
}));
|
|
43
44
|
}
|
|
44
45
|
|
|
46
|
+
// 标记文件里记的是"装它的那个包版本"。返回值语义必须分清:
|
|
47
|
+
// null = 这个目录没有标记(不是本工具装的,绝不碰)
|
|
48
|
+
// '' = 有标记但读不出/格式旧(当作需要重装,不要当成"已是最新")
|
|
49
|
+
function readMarker(dest) {
|
|
50
|
+
const marker = path.join(dest, MARKER);
|
|
51
|
+
if (!fs.existsSync(marker)) return null;
|
|
52
|
+
try {
|
|
53
|
+
const m = fs.readFileSync(marker, 'utf8').match(/ai-browser\s+(\S+)/);
|
|
54
|
+
return m ? m[1] : '';
|
|
55
|
+
} catch {
|
|
56
|
+
return '';
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// 内容指纹。为什么需要它(2026-11-25 当晚就踩到):
|
|
61
|
+
// 只比版本号时,"同一版本里改了技能文案"这类改动永远装不上去 —— install 判定
|
|
62
|
+
// up-to-date 直接跳过,用户看到的是"改了描述但 agent 行为没变",而且没有任何
|
|
63
|
+
// 报错。所以标记里再存一份内容 hash,版本相同但内容变了也要重装。
|
|
64
|
+
function skillSignature(dir) {
|
|
65
|
+
if (!fs.existsSync(dir)) return '';
|
|
66
|
+
const h = crypto.createHash('sha256');
|
|
67
|
+
const walk = (cur) => {
|
|
68
|
+
const entries = fs.readdirSync(cur, { withFileTypes: true })
|
|
69
|
+
.sort((a, b) => (a.name < b.name ? -1 : 1));
|
|
70
|
+
for (const e of entries) {
|
|
71
|
+
if (e.name === MARKER) continue;
|
|
72
|
+
const p = path.join(cur, e.name);
|
|
73
|
+
if (e.isDirectory()) walk(p);
|
|
74
|
+
else {
|
|
75
|
+
h.update(path.relative(dir, p));
|
|
76
|
+
h.update(fs.readFileSync(p));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
walk(dir);
|
|
81
|
+
return h.digest('hex').slice(0, 8);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function readSignature(dest) {
|
|
85
|
+
const marker = path.join(dest, MARKER);
|
|
86
|
+
if (!fs.existsSync(marker)) return null;
|
|
87
|
+
try {
|
|
88
|
+
const m = fs.readFileSync(marker, 'utf8').match(/ai-browser\s+\S+\s+([0-9a-f]{4,})/);
|
|
89
|
+
return m ? m[1] : '';
|
|
90
|
+
} catch {
|
|
91
|
+
return '';
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function markerText(sig) {
|
|
96
|
+
return `ai-browser ${pkg.version} ${sig}\n`;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// 包里已经删掉的技能,在用户目录里不会自己消失 —— 它会继续被客户端发现、
|
|
100
|
+
// 继续按旧描述触发。2026-11-25 合并 web-network-monitor 时踩到的就是这个:
|
|
101
|
+
// 新版明明不带了,老用户那边还在跑。所以 install 必须负责收尸。
|
|
102
|
+
// 只删带 marker 的目录(= 本工具装的),用户自己写的同名技能永远不碰。
|
|
103
|
+
function removeOrphans(targetDir) {
|
|
104
|
+
if (!fs.existsSync(targetDir)) return [];
|
|
105
|
+
const current = new Set(listSkills());
|
|
106
|
+
const removed = [];
|
|
107
|
+
for (const e of fs.readdirSync(targetDir, { withFileTypes: true })) {
|
|
108
|
+
if (!e.isDirectory() || current.has(e.name)) continue;
|
|
109
|
+
const dir = path.join(targetDir, e.name);
|
|
110
|
+
if (!fs.existsSync(path.join(dir, MARKER))) continue;
|
|
111
|
+
fs.rmSync(dir, { recursive: true, force: true });
|
|
112
|
+
removed.push(e.name);
|
|
113
|
+
}
|
|
114
|
+
return removed;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// 已装副本与当前包的版本差。为什么需要它(2026-11-25):
|
|
118
|
+
// install 只在有人手动跑的时候写盘,`npm i -g` / `npx` 升级都不会碰用户目录,
|
|
119
|
+
// 于是"包装到了 2.4.1、技能还停在 2.1.1"是**静默**发生的 —— 用户看到的现象是
|
|
120
|
+
// "模型还是照着旧说明乱来",而没有任何地方提示这件事。实测就有一台机器停在
|
|
121
|
+
// 2.1.1,缺 references/tabs.md 整节。
|
|
122
|
+
function drift() {
|
|
123
|
+
const out = [];
|
|
124
|
+
for (const t of detectTargets()) {
|
|
125
|
+
if (!t.exists) continue;
|
|
126
|
+
for (const s of t.installed) {
|
|
127
|
+
const dest = path.join(t.dir, s);
|
|
128
|
+
const v = readMarker(dest);
|
|
129
|
+
const sig = readSignature(dest);
|
|
130
|
+
const want = skillSignature(path.join(SKILLS_ROOT, s));
|
|
131
|
+
if (v !== pkg.version || sig !== want) {
|
|
132
|
+
out.push({
|
|
133
|
+
target: t.label,
|
|
134
|
+
dir: t.dir,
|
|
135
|
+
skill: s,
|
|
136
|
+
from: v || '?',
|
|
137
|
+
contentOnly: v === pkg.version,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return out;
|
|
143
|
+
}
|
|
144
|
+
|
|
45
145
|
function installOne(skill, targetDir) {
|
|
46
146
|
const src = path.join(SKILLS_ROOT, skill);
|
|
47
147
|
const dest = path.join(targetDir, skill);
|
|
48
|
-
const marker = path.join(dest, MARKER);
|
|
49
148
|
|
|
50
|
-
|
|
149
|
+
const installedVersion = fs.existsSync(dest) ? readMarker(dest) : null;
|
|
150
|
+
|
|
151
|
+
// 没有标记 = 用户自己写的同名技能,跳过(这条永远优先)
|
|
152
|
+
if (fs.existsSync(dest) && installedVersion === null) {
|
|
51
153
|
return { skill, status: 'skipped-user-owned' };
|
|
52
154
|
}
|
|
53
155
|
|
|
156
|
+
const srcSig = skillSignature(src);
|
|
157
|
+
// 版本 + 内容都一致才算最新:只比版本会把"同版本改了文案"判成 up-to-date,
|
|
158
|
+
// 改动永远装不上去,而且不报错。
|
|
159
|
+
if (installedVersion === pkg.version && readSignature(dest) === srcSig) {
|
|
160
|
+
return { skill, status: 'up-to-date' };
|
|
161
|
+
}
|
|
162
|
+
|
|
54
163
|
fs.mkdirSync(targetDir, { recursive: true });
|
|
164
|
+
// 必须先删干净再拷:cpSync 只会覆盖同名文件,包里**已经删掉**的文件会一直
|
|
165
|
+
// 留在用户目录里。那样"升级成功"和"还是旧版"在文件系统上无法区分,
|
|
166
|
+
// 而且 agent 会继续读到已经作废的 reference。
|
|
167
|
+
if (fs.existsSync(dest)) fs.rmSync(dest, { recursive: true, force: true });
|
|
55
168
|
fs.cpSync(src, dest, { recursive: true });
|
|
56
|
-
fs.writeFileSync(
|
|
57
|
-
|
|
169
|
+
fs.writeFileSync(path.join(dest, MARKER), markerText(srcSig), 'utf8');
|
|
170
|
+
|
|
171
|
+
const status = installedVersion ? 'upgraded' : 'installed';
|
|
172
|
+
return { skill, status, from: installedVersion || null };
|
|
58
173
|
}
|
|
59
174
|
|
|
60
175
|
function install({ dir, all }) {
|
|
@@ -77,18 +192,39 @@ function install({ dir, all }) {
|
|
|
77
192
|
}
|
|
78
193
|
|
|
79
194
|
let failed = 0;
|
|
195
|
+
let changed = 0;
|
|
80
196
|
for (const t of dirs) {
|
|
81
197
|
console.log(`\n→ ${t.label} (${t.dir})`);
|
|
82
198
|
for (const s of skills) {
|
|
83
199
|
const r = installOne(s, t.dir);
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
200
|
+
let note;
|
|
201
|
+
if (r.status === 'installed') {
|
|
202
|
+
note = `✓ ${s}`;
|
|
203
|
+
changed++;
|
|
204
|
+
} else if (r.status === 'upgraded') {
|
|
205
|
+
note =
|
|
206
|
+
r.from === pkg.version
|
|
207
|
+
? `↻ ${s} 内容变了(版本仍是 ${pkg.version})`
|
|
208
|
+
: `↑ ${s} ${r.from} → ${pkg.version}`;
|
|
209
|
+
changed++;
|
|
210
|
+
} else if (r.status === 'up-to-date') {
|
|
211
|
+
note = `· ${s} 已是最新(${pkg.version})`;
|
|
212
|
+
} else {
|
|
213
|
+
note = `! ${s} —— 这个目录已有同名技能且不是本工具装的,跳过(要覆盖请先手动删掉)`;
|
|
214
|
+
}
|
|
88
215
|
console.log(' ' + note);
|
|
89
216
|
}
|
|
217
|
+
const removed = removeOrphans(t.dir);
|
|
218
|
+
if (removed.length) {
|
|
219
|
+
console.log(` − 已移除 ${removed.join('、')}(包里不再带这个技能了)`);
|
|
220
|
+
changed++;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
if (changed) {
|
|
224
|
+
console.log(`\n更新了 ${changed} 个技能(共 ${skills.length} 个 × ${dirs.length} 个位置)。新开会话时客户端会自动发现它们。`);
|
|
225
|
+
} else {
|
|
226
|
+
console.log('\n全部已是最新,没有写盘。');
|
|
90
227
|
}
|
|
91
|
-
console.log(`\n装了 ${skills.length} 个技能。新开会话时客户端会自动发现它们,不需要再贴说明书。`);
|
|
92
228
|
return failed;
|
|
93
229
|
}
|
|
94
230
|
|
|
@@ -113,6 +249,16 @@ function run(argv) {
|
|
|
113
249
|
const state = !t.exists ? '目录不存在' : t.installed.length ? `已装 ${t.installed.length} 个` : '未装';
|
|
114
250
|
console.log(` ${t.label.padEnd(12)} ${state.padEnd(12)} ${t.dir}`);
|
|
115
251
|
}
|
|
252
|
+
// 版本漂移必须在人主动查看时就能看见,而不是等 agent 用旧技能出错。
|
|
253
|
+
const stale = drift();
|
|
254
|
+
if (stale.length) {
|
|
255
|
+
console.log(`\n! ${stale.length} 个副本需要刷新:`);
|
|
256
|
+
for (const d of stale) {
|
|
257
|
+
const why = d.contentOnly ? `内容变了(版本仍是 ${pkg.version})` : `${d.from} → ${pkg.version}`;
|
|
258
|
+
console.log(` ${d.target}/${d.skill} ${why}`);
|
|
259
|
+
}
|
|
260
|
+
console.log(' 运行 `ai-browser skill install` 刷新。');
|
|
261
|
+
}
|
|
116
262
|
console.log('\n装上:ai-browser skill install 只装到已存在的客户端目录');
|
|
117
263
|
console.log(' ai-browser skill install --all 三个位置都装');
|
|
118
264
|
console.log(' ai-browser skill print 打印入口 SKILL.md(手动粘贴用)');
|
|
@@ -130,4 +276,16 @@ function run(argv) {
|
|
|
130
276
|
return 2;
|
|
131
277
|
}
|
|
132
278
|
|
|
133
|
-
module.exports = {
|
|
279
|
+
module.exports = {
|
|
280
|
+
run,
|
|
281
|
+
listSkills,
|
|
282
|
+
detectTargets,
|
|
283
|
+
drift,
|
|
284
|
+
readMarker,
|
|
285
|
+
readSignature,
|
|
286
|
+
skillSignature,
|
|
287
|
+
installOne,
|
|
288
|
+
removeOrphans,
|
|
289
|
+
SKILLS_ROOT,
|
|
290
|
+
MARKER,
|
|
291
|
+
};
|
|
@@ -1,29 +1,34 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: ai-browser
|
|
3
3
|
description: >-
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
ai-browser —— 真实、可见、带登录态、跑 JS、人可随时接管的浏览器。
|
|
5
|
+
触发词:要打开网址、要操作网站。反过来——不打开网址(本地文件、命令、代码、纯写作、跑测试)就别用我。
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
# ai-browser
|
|
9
9
|
|
|
10
|
+
> 任务根本不碰网页?直接回用户「这个不需要浏览器」,别硬用。
|
|
11
|
+
|
|
12
|
+
## 兄弟技能(并列,不在本文件里)
|
|
13
|
+
|
|
14
|
+
- 发文章(CSDN / 知乎 / 掘金 / 公众号)→ `content-publish` 技能
|
|
15
|
+
- 提取文章正文 → `read-webpage` 技能
|
|
16
|
+
- 抓请求 / 看登录后的接口 → `references/network.md`
|
|
17
|
+
|
|
10
18
|
## 两条路
|
|
11
19
|
|
|
12
|
-
工具在就 `browse_navigate {"url":"https://example.com"}
|
|
20
|
+
工具在就 `browse_navigate {"url":"https://example.com"}`;不在走 CLI(没这命令就加 `npx -y @glittering0717/ai-browser`):
|
|
13
21
|
|
|
14
22
|
```
|
|
15
|
-
ai-browser call ui.get_tree '{"subset":"interactive"}' #
|
|
23
|
+
ai-browser call ui.get_tree '{"subset":"interactive"}' # 读页面
|
|
16
24
|
ai-browser call ui.act '{"action":"click","target":"e:a-3"}' # 点它
|
|
17
25
|
```
|
|
18
26
|
|
|
19
|
-
没这个命令就加 `npx -y @glittering0717/ai-browser`,浏览器没开会自动拉起。
|
|
20
27
|
方法名 = 工具名把 `browse_` 换成 `ui.`(tabs 等例外)。
|
|
21
28
|
|
|
22
29
|
## 你的标签组
|
|
23
30
|
|
|
24
|
-
|
|
25
|
-
省略 `tab` 就打它;用户的页不会被碰也不会被顶掉。组有上限,满了先关再开。
|
|
26
|
-
看用户的页 / 人登录扫码 / 全程后台:`references/tabs.md`。
|
|
31
|
+
第一次动手给你一页**空白工作页**,归你的标签组;省略 `tab` 就打它,用户的页不会被碰。
|
|
27
32
|
|
|
28
33
|
## 点东西只认 id
|
|
29
34
|
|
|
@@ -46,13 +51,13 @@ ai-browser call ui.act '{"action":"click","target":"e:a-3"}' # 点它
|
|
|
46
51
|
|
|
47
52
|
## 需要人帮忙
|
|
48
53
|
|
|
49
|
-
|
|
54
|
+
登录扫码滑块支付:请人操作,好了再读树;没有 chat 工具,勿编密码。
|
|
50
55
|
|
|
51
56
|
## 按需深挖
|
|
52
57
|
|
|
53
|
-
- `references/tabs.md` —
|
|
54
|
-
- `references/cli.md` — CLI
|
|
55
|
-
- `references/troubleshooting.md` —
|
|
56
|
-
- `references/hard-pages.md` —
|
|
57
|
-
- `references/network.md` —
|
|
58
|
-
- `references/tasks.md` —
|
|
58
|
+
- `references/tabs.md` — 标签组 / 人接管
|
|
59
|
+
- `references/cli.md` — CLI 全量
|
|
60
|
+
- `references/troubleshooting.md` — 排查
|
|
61
|
+
- `references/hard-pages.md` — 难搞页面
|
|
62
|
+
- `references/network.md` — 抓请求 / 接口
|
|
63
|
+
- `references/tasks.md` — 发文章 / 读正文
|
|
@@ -1,21 +1,43 @@
|
|
|
1
|
-
#
|
|
1
|
+
# 网络与接口(抓请求 / 取数据)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
抓包**从 tab 打开那一刻就开始**,不需要订阅、不需要写脚本,POST 请求体也在。
|
|
4
|
+
**登录后才看得到的接口正是它的用武之地** —— 浏览器的登录态就是请求的登录态。
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
## 什么时候该看网络,而不是看树
|
|
7
|
+
|
|
8
|
+
- 点了提交没反应,想知道到底发了什么、返回了什么
|
|
9
|
+
- 想知道某个列表页背后的 API(比解析 DOM 稳一个数量级)
|
|
10
|
+
- 排查 4xx / 5xx、怀疑"页面没数据"是接口没回
|
|
11
|
+
- 需要结构化数据,而 DOM 只是渲染后的残缺版本
|
|
12
|
+
|
|
13
|
+
## 标准四步
|
|
6
14
|
|
|
7
15
|
```
|
|
8
|
-
browse_network { operation:"
|
|
9
|
-
|
|
10
|
-
browse_network { operation:"
|
|
16
|
+
browse_network { operation:"clear" } # 1 先清,别混进旧请求
|
|
17
|
+
browse_act { action:"click", target:"e:button-7" } # 2 触发请求
|
|
18
|
+
browse_network { operation:"list", filters:{ method:["POST"] } } # 3 找到 id
|
|
19
|
+
browse_network { operation:"get", network_id:"<id>",
|
|
20
|
+
include:{ response_body:true, request_body:true } } # 4 取 headers 与 body
|
|
11
21
|
```
|
|
12
22
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
23
|
+
## 参数形态(按 op 分组,不是拍平的)
|
|
24
|
+
|
|
25
|
+
| op | 参数 |
|
|
26
|
+
|---|---|
|
|
27
|
+
| `list` | `filters:{ method[], url_contains, status_min, status_max, resource_type[], state[], started_after, started_before, limit(默认 50 / 最多 200), before_seq }` |
|
|
28
|
+
| `get` | `network_id` + `include:{ request_headers, response_headers, request_body, response_body, sensitive_headers, body_limit }` + `body_offset:{ request, response }` |
|
|
29
|
+
| `clear` | 无需参数(只清当前 tab) |
|
|
30
|
+
| `configure` | `configure:{ enabled, capture_bodies:"none"|"api"|"all" }` |
|
|
31
|
+
|
|
32
|
+
## 关键事实(不按这个来会白等)
|
|
16
33
|
|
|
17
|
-
|
|
18
|
-
|
|
34
|
+
- 记录**只从现在起累积**;`clear` 只清当前 tab,tab 一关记录就没了,跨 tab 各自独立
|
|
35
|
+
- `response_body` 要请求**已完成**才有;`state:"pending"` 时先 `browse_wait` 或稍等再 `get`
|
|
36
|
+
- 敏感头(`cookie` / `authorization`)默认打码;要看真值需启动时 `AI_BROWSER_NETWORK_SENSITIVE=1`
|
|
37
|
+
- body 很大:先用 `filters` 收窄,再用 `include.body_limit` + `body_offset` 分页取
|
|
38
|
+
- 省内存可关抓包:`browse_network { operation:"configure", configure:{ enabled:false } }`
|
|
39
|
+
- `browse_evaluate` 替代不了它:evaluate 只看页面 JS 上下文,看不到网络层
|
|
40
|
+
- 页面自身 JS 报错(不是接口)看 `browse_errors`
|
|
19
41
|
|
|
20
42
|
## 从页面取结构化数据
|
|
21
43
|
|
|
@@ -24,7 +46,7 @@ browse_network { operation:"get", network_id:"<id>", include_response_body:true
|
|
|
24
46
|
1. **页面自己的数据模型**。很多 SPA 把数据挂在全局对象上:
|
|
25
47
|
`browse_evaluate { js: "JSON.stringify(window.__NUXT__?.data ?? null)" }`
|
|
26
48
|
拿到的是原始结构,比从 DOM 反推可靠一个数量级。
|
|
27
|
-
2. **背后的 API**。用 `browse_network`
|
|
49
|
+
2. **背后的 API**。用 `browse_network` 抓到接口,再在 `browse_evaluate` 里 `fetch` 同一接口
|
|
28
50
|
(注意带凭据:`credentials:'include'`)。
|
|
29
51
|
3. **语义树**。`browse_get_tree {subset:"interactive"}` 逐节点取 `label`/`value`。
|
|
30
52
|
适合表格、列表这类结构规整的页面。
|
|
@@ -39,6 +39,6 @@ browse_diff { operation:"diff", snapshot:"<基线>" } // verdict: changed |
|
|
|
39
39
|
|
|
40
40
|
这三类别在这里硬做,用对应的技能(它们带更细的校验步骤):
|
|
41
41
|
|
|
42
|
-
- 把文章发布到 CSDN / 知乎 / 掘金 → `content-publish`
|
|
43
|
-
- 读一篇文章的正文并总结 → `read-webpage`
|
|
44
|
-
-
|
|
42
|
+
- 把文章发布到 CSDN / 知乎 / 掘金 → `content-publish` 技能
|
|
43
|
+
- 读一篇文章的正文并总结 → `read-webpage` 技能
|
|
44
|
+
- 盯某个页面的请求 / 看登录后的接口 → `references/network.md`(本技能内,不用另找)
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: content-publish
|
|
3
3
|
description: >-
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
content-publish —— 只在「要把内容提交到某个平台」时用我:CSDN / 知乎 / 掘金 / 公众号 / 其它博客社区。
|
|
5
|
+
触发词:发布到、发到、发博客、发帖、发一篇、投稿、发出去、上传到平台、帮我发。
|
|
6
|
+
不适用:只编辑不提交 → ai-browser 的 browse_act;只读文章 → read-webpage 技能。
|
|
6
7
|
---
|
|
7
8
|
|
|
8
9
|
# 内容发布 / 提交流程(content-publish)
|
|
@@ -54,7 +55,13 @@ description: >-
|
|
|
54
55
|
| 审核 / 待审核 | 进入人工/系统审核 |
|
|
55
56
|
| 报错 toast / message_appeared 事件体 | 失败,需读取提示原文 |
|
|
56
57
|
|
|
57
|
-
##
|
|
58
|
+
## 不适用(交给谁)
|
|
59
|
+
- 只是编辑已有页面、不提交 → `browse_navigate` / `browse_act`,不需要发布校验
|
|
60
|
+
- 只是读一篇文章 → `read-webpage` 技能
|
|
61
|
+
- 还不知道正文从哪来(要先抓文章内容)→ 先用 `ai-browser` 取,再回来发布
|
|
62
|
+
- 目标是某个接口而不是页面 → `ai-browser` 的 `references/network.md`
|
|
63
|
+
|
|
64
|
+
## 操作边界
|
|
58
65
|
- skill 不保存账号/密码,登录与验证码需用户配合。
|
|
59
66
|
- 若某平台按钮文案不同,用 `browse_get_tree` 的 label 动态定位,不要硬编码选择器。
|
|
60
67
|
- 发布属于不可逆操作:点击前可用 `browse_get_tree` 确认拿到的确实是发布按钮(label 含"发布/提交"),避免误点。
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: read-webpage
|
|
3
3
|
description: >-
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
read-webpage —— 只在「要把一整篇文章的正文取出来」时用我:标题 + 段落,新闻/博客/公众号/掘金这类页面。
|
|
5
|
+
触发词:读这篇文章、看看这篇、帮我读一下、这页讲了啥、这篇写的是什么、提取正文、翻译这页、总结这篇。
|
|
6
|
+
不适用:读控件 / 按钮 / 少量文本 → browse_get_tree;要交互(登录 / 表单 / 评论 / 发布)→ ai-browser 主循环。
|
|
6
7
|
---
|
|
7
8
|
|
|
8
9
|
# 网页正文提取(read-webpage)
|
|
@@ -46,7 +47,13 @@ description: >-
|
|
|
46
47
|
- 输出为标题 + 段落数组(同一套提取脚本主体),可直接交给用户阅读或总结。
|
|
47
48
|
- 空结果时明确提示,不强行拼接垃圾文本。
|
|
48
49
|
|
|
49
|
-
##
|
|
50
|
+
## 不适用(交给谁)
|
|
51
|
+
- 只要读控件 / 标签 / 按钮 / 少量文本 → `browse_get_tree`,不要提正文
|
|
52
|
+
- 目的是交互(登录、填表、评论、发布)→ 回 `ai-browser` 的主循环
|
|
53
|
+
- 要的是接口返回的 JSON,而不是页面上的字 → `ai-browser` 的 `references/network.md`
|
|
54
|
+
- 页面根本还没打开、不知道在哪 → 先用 `browse_navigate` 过去(`ai-browser` 主循环)
|
|
55
|
+
|
|
56
|
+
## 技术边界
|
|
50
57
|
- 只用于"正文文章"。登录框、评论、表格、导航等非文章内容走 `browse_get_tree` / `browse_act`。
|
|
51
58
|
- 不分页/不处理懒加载(动态新增段落不会出现);长文分段处理或提示用户。
|
|
52
59
|
- 静默失败判据:若取回的 title 与 paras 均为空,判为"非文章页"。
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// main/mcp_instructions.js — MCP 初始化时交给客户端的那段自我介绍。
|
|
2
|
+
//
|
|
3
|
+
// 为什么单独成文件(2026-11-25):
|
|
4
|
+
//
|
|
5
|
+
// MCP 的 InitializeResult 有一个 `instructions` 字段,客户端会把它拼进 system
|
|
6
|
+
// prompt —— 这是**协议里唯一**能让服务端主动说"我是什么、什么时候该用我"的地方。
|
|
7
|
+
// 此前它是空的,于是 agent 对这个 server 的全部认知只剩一份 17 个
|
|
8
|
+
// `browse_*` 工具清单:名字像通用动词,描述是写给人看的机制说明
|
|
9
|
+
// (data-ai-id、subset、milestone)。实测后果很直接 —— 用户说"用 ai-browser",
|
|
10
|
+
// 新会话里的 agent 不知道那是什么,得被点名 GitHub 仓库才肯去查。
|
|
11
|
+
//
|
|
12
|
+
// 判据不是"描述够不够详细",而是"只拿到工具清单的模型能不能判断该不该用"。
|
|
13
|
+
// 所以这段文字只回答四件事,不重复 schema 里的参数细节:
|
|
14
|
+
// 1. 它是什么(真窗口,不是无头/截图驱动)
|
|
15
|
+
// 2. 什么意图下必须用它,以及为什么要用它而不是别的浏览器工具
|
|
16
|
+
// 3. 最小循环,且把 success 只代表"发出去了"这条硬规矩放在这里
|
|
17
|
+
// 4. 需要人时的正确姿势
|
|
18
|
+
//
|
|
19
|
+
// 成本:这段文字每个会话注入一次(不是每轮),但仍要克制。预算见
|
|
20
|
+
// tests/test_mcp_instructions.js 的 MAX_CHARS,超了 CI 红。
|
|
21
|
+
//
|
|
22
|
+
// 为什么没有做成 MCP prompt / resource:tests/test_invariants.js 把
|
|
23
|
+
// "prompts/resources 三个 list 必须应答空集合"钉成了不变量(目录扫描器会把
|
|
24
|
+
// Method not found 记为健康检查失败),那是刻意保留的,不在这轮改动范围内。
|
|
25
|
+
|
|
26
|
+
export const MCP_INSTRUCTIONS = [
|
|
27
|
+
'AI Browser is a real, visible browser that you drive on the user\'s behalf.',
|
|
28
|
+
'Use it whenever a task involves a website: open a page, read what it says, click, fill a form, log in, publish, upload or download, or pull data that sits behind a login.',
|
|
29
|
+
'',
|
|
30
|
+
'Prefer it over headless or screenshot-driven browser tools when the page needs JS to render, when a session is already logged in, or when the user should be able to watch and take over. The window is a normal app window: the user can click and type in it at any time.',
|
|
31
|
+
'',
|
|
32
|
+
'Loop: browse_navigate {url} -> browse_get_tree {subset:"interactive"} -> browse_act {action, target:<id from the tree>}. Repeat. success:true means the action was dispatched, not that anything changed - use browse_diff when the outcome matters.',
|
|
33
|
+
'',
|
|
34
|
+
'Never invent a target id or a password. For login, QR scan, captcha or payment, ask the user to do it in the window and continue once they confirm.',
|
|
35
|
+
'',
|
|
36
|
+
'If these tools are not registered in this client, the same engine is reachable from a shell: `ai-browser call ui.get_tree \'{"subset":"interactive"}\'`.',
|
|
37
|
+
].join('\n');
|
package/src/main/mcp_server.js
CHANGED
|
@@ -14,7 +14,9 @@ import { fileURLToPath } from 'node:url';
|
|
|
14
14
|
// 启动逻辑与 CLI 共用一份(scripts/ensure_running.cjs)。曾经这里有一份私有实现,
|
|
15
15
|
// 结果 MCP 能自动拉起浏览器、CLI 不能 —— 同一件事两个行为。
|
|
16
16
|
import ensureMod from '../../scripts/ensure_running.cjs';
|
|
17
|
+
import skillMod from '../../scripts/skill.cjs';
|
|
17
18
|
import { MCP_TOOLS } from './mcp_tools.js';
|
|
19
|
+
import { MCP_INSTRUCTIONS } from './mcp_instructions.js';
|
|
18
20
|
import { actParams, networkParams } from './mcp_args.js';
|
|
19
21
|
import { evaluateGuardError } from '../shared/guards.js';
|
|
20
22
|
import { timeoutForTool } from '../shared/tool_timeout.js';
|
|
@@ -78,12 +80,17 @@ const server = new Server(
|
|
|
78
80
|
// resources/prompts 声明为空能力:协议要求即使一个都没有也要正常应答这两个
|
|
79
81
|
// list 请求(部分目录扫描器,如 Smithery,会把 "Method not found" 记为健康
|
|
80
82
|
// 检查失败)。能力清单保留声明,客户端据此知道服务端支持该方法族。
|
|
81
|
-
|
|
83
|
+
//
|
|
84
|
+
// instructions:客户端会把它拼进 system prompt,是协议里唯一能让服务端主动
|
|
85
|
+
// 说"我是什么、什么时候用我"的地方。此前这一位是空的,agent 只看到一份
|
|
86
|
+
// 名字像通用动词的工具清单 —— 用户说"用 ai-browser",新会话根本不知道那是
|
|
87
|
+
// 什么。内容与成本见 ./mcp_instructions.js。
|
|
88
|
+
{ capabilities: { tools: {}, resources: {}, prompts: {} }, instructions: MCP_INSTRUCTIONS }
|
|
82
89
|
);
|
|
83
90
|
|
|
84
91
|
// Tool definitions — curated minimal MCP_TOOLS (see mcp_tools.js). Kept small
|
|
85
92
|
// to reduce per-message token cost; low-frequency/flow capabilities live in
|
|
86
|
-
// skills/ (read-webpage
|
|
93
|
+
// skills/ (ai-browser + read-webpage / content-publish) and its references/.
|
|
87
94
|
server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
88
95
|
tools: MCP_TOOLS
|
|
89
96
|
}));
|
|
@@ -307,8 +314,11 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
307
314
|
return { content: [{ type: 'text', text: JSON.stringify(result) }] };
|
|
308
315
|
}
|
|
309
316
|
if (op === 'configure') {
|
|
317
|
+
// reload 必须转发:hook 对"安装之前已经画完"的内容无能为力,重载是拿到
|
|
318
|
+
// 完整绘制历史的唯一办法(hard-pages.md 就是按这个教 agent 的)。
|
|
319
|
+
// 曾被漏在这里 —— schema 也没声明,于是文档教的"现装现读"静默无效。
|
|
310
320
|
const result = await wsClient.call('ui.canvas_configure', {
|
|
311
|
-
tab: args.tab, mode: args.mode, clear: args.clear,
|
|
321
|
+
tab: args.tab, mode: args.mode, clear: args.clear, reload: args.reload,
|
|
312
322
|
});
|
|
313
323
|
return { content: [{ type: 'text', text: JSON.stringify(result) }] };
|
|
314
324
|
}
|
|
@@ -400,6 +410,25 @@ async function main() {
|
|
|
400
410
|
// up on first use, inside wsClient's connection-retry loop (via ensureRunning).
|
|
401
411
|
const listening = await checkPort(ELECTRON_PORT);
|
|
402
412
|
if (!listening) console.error('[mcp] ai-browser not running — will auto-start on first browse_* call');
|
|
413
|
+
|
|
414
|
+
// 技能漂移提示:package upgrade 不会刷新用户目录里的技能副本,agent 会继续
|
|
415
|
+
// 照着旧说明操作(实测有机器停在 2.1.1 而包已 2.4.1,缺 tabs.md 整节)。
|
|
416
|
+
// 只提示、不自动写盘 —— 启动过程不该有副作用,也可能根本没有写权限。
|
|
417
|
+
try {
|
|
418
|
+
const stale = skillMod.drift();
|
|
419
|
+
if (stale.length) {
|
|
420
|
+
const s = stale[0];
|
|
421
|
+
const why = s.contentOnly ? `changed (still ${VERSION})` : `${s.from} -> ${VERSION}`;
|
|
422
|
+
console.error(
|
|
423
|
+
`[mcp] skills out of date (${s.target}/${s.skill} ${why})` +
|
|
424
|
+
(stale.length > 1 ? ` and ${stale.length - 1} more` : '') +
|
|
425
|
+
' — run `ai-browser skill install` to refresh'
|
|
426
|
+
);
|
|
427
|
+
}
|
|
428
|
+
} catch {
|
|
429
|
+
// 技能目录存在与否绝不能影响 MCP 启动
|
|
430
|
+
}
|
|
431
|
+
|
|
403
432
|
const transport = new StdioServerTransport();
|
|
404
433
|
await server.connect(transport);
|
|
405
434
|
// stderr is for logging only; stdout is the MCP protocol
|
package/src/main/mcp_tools.js
CHANGED
|
@@ -11,7 +11,7 @@ export const MCP_TOOLS = [
|
|
|
11
11
|
{
|
|
12
12
|
name: 'browse_navigate',
|
|
13
13
|
title: 'Navigate tab',
|
|
14
|
-
description: '
|
|
14
|
+
description: 'Use when the user wants to open a page or reach a URL in your tab, before reading or acting. Returns at the milestone (default: DOM ready), not load, which SPAs never fire.',
|
|
15
15
|
annotations: { readOnlyHint: false, destructiveHint: false, openWorldHint: true },
|
|
16
16
|
inputSchema: {
|
|
17
17
|
type: 'object',
|
|
@@ -26,7 +26,7 @@ export const MCP_TOOLS = [
|
|
|
26
26
|
{
|
|
27
27
|
name: 'browse_get_tree',
|
|
28
28
|
title: 'Read semantic tree',
|
|
29
|
-
description: '
|
|
29
|
+
description: 'Use to read the page: every element as a node with role, label, id and its actions. This is how you see the screen and find click targets. subset:"interactive" saves tokens.',
|
|
30
30
|
annotations: { readOnlyHint: true, destructiveHint: false, openWorldHint: true },
|
|
31
31
|
inputSchema: {
|
|
32
32
|
type: 'object',
|
|
@@ -42,7 +42,7 @@ export const MCP_TOOLS = [
|
|
|
42
42
|
{
|
|
43
43
|
name: 'browse_act',
|
|
44
44
|
title: 'Act on element',
|
|
45
|
-
description: '
|
|
45
|
+
description: 'Use to click, type, fill, select, upload or press keys — the act that does the work. target = an id from browse_get_tree, never visible text. type appends at caret; setContent replaces all.',
|
|
46
46
|
annotations: { readOnlyHint: false, destructiveHint: false, openWorldHint: true },
|
|
47
47
|
inputSchema: {
|
|
48
48
|
type: 'object',
|
|
@@ -172,7 +172,7 @@ export const MCP_TOOLS = [
|
|
|
172
172
|
{
|
|
173
173
|
name: 'browse_auth_state',
|
|
174
174
|
title: 'Check login / auth-wall state',
|
|
175
|
-
description: 'Is this tab still logged in, or bounced to a
|
|
175
|
+
description: 'Is this tab still logged in, or bounced to a wall? auth_wall.detected=true means stop debugging and re-authenticate first. logged_in is heuristic; auth_wall is the signal.',
|
|
176
176
|
annotations: { readOnlyHint: true, destructiveHint: false, openWorldHint: true },
|
|
177
177
|
inputSchema: {
|
|
178
178
|
type: 'object',
|
|
@@ -184,7 +184,7 @@ export const MCP_TOOLS = [
|
|
|
184
184
|
{
|
|
185
185
|
name: 'browse_screenshot',
|
|
186
186
|
title: 'Screenshot the viewport',
|
|
187
|
-
description: 'Screenshot the viewport (base64). Use FIRST when an action misbehaves
|
|
187
|
+
description: 'Screenshot the viewport (base64). Use FIRST when an action misbehaves — the tree cannot show overlays, occlusion or glitches. Warns about password inputs.',
|
|
188
188
|
annotations: { readOnlyHint: true, destructiveHint: false, openWorldHint: true },
|
|
189
189
|
inputSchema: {
|
|
190
190
|
type: 'object',
|
|
@@ -235,7 +235,7 @@ export const MCP_TOOLS = [
|
|
|
235
235
|
{
|
|
236
236
|
name: 'browse_network',
|
|
237
237
|
title: 'Inspect network',
|
|
238
|
-
description: 'Query captured HTTP requests: list/get/clear/configure.
|
|
238
|
+
description: 'Query captured HTTP requests: list/get/clear/configure. Headers and POST bodies captured; sensitive headers redacted. Each op reads its own group.',
|
|
239
239
|
annotations: { readOnlyHint: false, destructiveHint: false, openWorldHint: true },
|
|
240
240
|
inputSchema: {
|
|
241
241
|
type: 'object',
|
|
@@ -294,7 +294,7 @@ export const MCP_TOOLS = [
|
|
|
294
294
|
{
|
|
295
295
|
name: 'browse_canvas',
|
|
296
296
|
title: 'Read canvas',
|
|
297
|
-
description: 'Read <canvas>
|
|
297
|
+
description: 'Read <canvas> from captured draw calls, not pixels: list/read/configure/capture. 2D text comes from fillText, so no OCR; WebGL is opaque.',
|
|
298
298
|
annotations: { readOnlyHint: false, destructiveHint: false, openWorldHint: true },
|
|
299
299
|
inputSchema: {
|
|
300
300
|
type: 'object',
|
|
@@ -306,7 +306,8 @@ export const MCP_TOOLS = [
|
|
|
306
306
|
since_seq: { type: 'integer', description: 'read: cursor from pagination.next_seq.' },
|
|
307
307
|
limit: { type: 'integer', description: 'read: page size (default 200, max 1000).' },
|
|
308
308
|
mode: { type: 'string', enum: ['off', 'semantic', 'trace'], description: 'configure: recording mode.' },
|
|
309
|
-
clear: { type: 'boolean', description: 'configure: drop retained calls.' }
|
|
309
|
+
clear: { type: 'boolean', description: 'configure: drop retained calls.' },
|
|
310
|
+
reload: { type: 'boolean', description: 'configure: reload to record earlier draws.' }
|
|
310
311
|
},
|
|
311
312
|
required: ['operation']
|
|
312
313
|
}
|
|
@@ -333,7 +334,7 @@ export const MCP_TOOLS = [
|
|
|
333
334
|
{
|
|
334
335
|
name: 'browse_capabilities',
|
|
335
336
|
title: 'Probe capabilities',
|
|
336
|
-
description: 'Probe how to operate a page: DOM vs canvas, iframes,
|
|
337
|
+
description: 'Probe how to operate a page: DOM vs canvas, iframes, window objects, JSON endpoints, plus a plan. deep=true also probes closure-hidden models.',
|
|
337
338
|
annotations: { readOnlyHint: true, destructiveHint: false, openWorldHint: true },
|
|
338
339
|
inputSchema: {
|
|
339
340
|
type: 'object',
|
|
@@ -348,7 +349,7 @@ export const MCP_TOOLS = [
|
|
|
348
349
|
{
|
|
349
350
|
name: 'browse_repaint',
|
|
350
351
|
title: 'Force repaint',
|
|
351
|
-
description: "Force the compositor to redraw a tab's BrowserView when the window shows a stale page; returns repaint_count
|
|
352
|
+
description: "Force the compositor to redraw a tab's BrowserView when the window shows a stale page; returns repaint_count.",
|
|
352
353
|
annotations: { readOnlyHint: false, destructiveHint: false, openWorldHint: false },
|
|
353
354
|
inputSchema: {
|
|
354
355
|
type: 'object',
|
|
@@ -360,7 +361,7 @@ export const MCP_TOOLS = [
|
|
|
360
361
|
{
|
|
361
362
|
name: 'browse_downloads',
|
|
362
363
|
title: 'List downloads',
|
|
363
|
-
description: 'List a tab\'s downloads with on-disk paths. Downloads are async: poll this after clicking export
|
|
364
|
+
description: 'List a tab\'s downloads with on-disk paths. Downloads are async: poll this after clicking export, not in the click response.',
|
|
364
365
|
annotations: { readOnlyHint: true, destructiveHint: false, openWorldHint: false },
|
|
365
366
|
inputSchema: {
|
|
366
367
|
type: 'object',
|
|
@@ -372,7 +373,7 @@ export const MCP_TOOLS = [
|
|
|
372
373
|
{
|
|
373
374
|
name: 'browse_errors',
|
|
374
375
|
title: 'Read error log',
|
|
375
|
-
description: 'Read the main-process error log: uncaught exceptions, crashes, failed navigations, RPC errors.
|
|
376
|
+
description: 'Read the main-process error log: uncaught exceptions, crashes, failed navigations, RPC errors. Returns the on-disk JSONL path.',
|
|
376
377
|
annotations: { readOnlyHint: true, destructiveHint: false, openWorldHint: false },
|
|
377
378
|
inputSchema: {
|
|
378
379
|
type: 'object',
|
package/src/shared/version.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
// Kept in JS (not imported from package.json) to avoid Node import-attribute
|
|
3
3
|
// (JSON module) compatibility issues inside Electron. package.json "version"
|
|
4
4
|
// is manually synced to this value; tests assert they match.
|
|
5
|
-
export const VERSION = '2.5.
|
|
5
|
+
export const VERSION = '2.5.7';
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: web-network-monitor
|
|
3
|
-
description: >-
|
|
4
|
-
适用于监控页面发出的网络请求、抓取指定 API 的响应体、验证请求参数/返回值、或查看页面 JS 错误的排查任务。触发词:抓包、网络请求、接口响应、接口返回了什么、response body、看下这个接口、js error、请求参数。
|
|
5
|
-
仅当任务需要"网络层信息"时使用;普通点击/读写页面请直接用 browse_act / browse_get_tree。
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
# 网络 / 接口监控(web-network-monitor)
|
|
9
|
-
|
|
10
|
-
用**两个**工具就够,不需要订阅、不需要写脚本:
|
|
11
|
-
|
|
12
|
-
| 想做什么 | 调用 |
|
|
13
|
-
|---|---|
|
|
14
|
-
| 看页面发了哪些请求 | `browse_network {operation:"list"}` |
|
|
15
|
-
| 按 URL 找某个请求 | `browse_network {operation:"list", filters:{url_contains:"/api/user"}}` |
|
|
16
|
-
| 看某条请求的详情 + 响应体 | `browse_network {operation:"get", network_id:"<从 list 拿>", include:{response_body:true}}` |
|
|
17
|
-
| 清空已记录请求 | `browse_network {operation:"clear"}` |
|
|
18
|
-
| 看页面 JS 报错 | `browse_errors` |
|
|
19
|
-
|
|
20
|
-
## 标准四步
|
|
21
|
-
|
|
22
|
-
1. `browse_network {operation:"clear"}` —— 先清,避免混进旧请求。
|
|
23
|
-
2. 触发请求:`browse_act {action:"click", target:"<按钮 data-ai-id>"}`。
|
|
24
|
-
3. `browse_network {operation:"list", filters:{url_contains:"<关键字>"}}`
|
|
25
|
-
→ 每条带 `id`、`method`、`url`、`status`、`state`。
|
|
26
|
-
4. `browse_network {operation:"get", network_id:"<id>", include:{response_body:true, request_body:true}}`
|
|
27
|
-
→ 拿 headers 与 body。大 body 用 `body_offset` 翻页。
|
|
28
|
-
|
|
29
|
-
## 关键事实(不按这个来会白等)
|
|
30
|
-
|
|
31
|
-
- **网络记录是按"从现在起"累积的**,`clear` 只清当前 tab 的记录。
|
|
32
|
-
- `list` 默认返回 50 条(最多 200);更多用 `filters.before_seq` 翻页。
|
|
33
|
-
- `response_body` 只在请求**已完成**后才有;`state:"pending"` 时先 `browse_wait {condition:"text_contains"}` 或稍等再 `get`。
|
|
34
|
-
- 敏感 header(Cookie/Authorization)默认打码,需要时由人设置 `AI_BROWSER_NETWORK_SENSITIVE=1` 并重启。
|
|
35
|
-
- 请求体/响应体可能很大:先用 `filters` 收窄,再 `include.body_limit` 控制。
|
|
36
|
-
|
|
37
|
-
## 示例
|
|
38
|
-
|
|
39
|
-
用户:"我点提交之后到底调了哪个接口、返回了什么?"
|
|
40
|
-
|
|
41
|
-
```
|
|
42
|
-
browse_network {operation:"clear"}
|
|
43
|
-
browse_act {action:"click", target:"e:button-7"}
|
|
44
|
-
browse_network {operation:"list", filters:{method:["POST"]}}
|
|
45
|
-
browse_network {operation:"get", network_id:"<上一步的 id>", include:{response_body:true}}
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
## 边界
|
|
49
|
-
|
|
50
|
-
- 页面关闭后该 tab 的记录一起没了;跨 tab 各自独立。
|
|
51
|
-
- `browse_evaluate` 不能替代:它只看得到页面 JS 上下文,看不到网络层。
|
|
52
|
-
- 拿不到 body 时先确认 `state` 是否为 `finished`,再确认请求是否真的发生过(`list` 里有没有它)。
|