@capyclaw/browser-workbench 0.0.0-stage → 0.1.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.
Files changed (52) hide show
  1. package/README.md +66 -2
  2. package/contract/browser-contract.json +890 -0
  3. package/cordis.patch.yml +25 -0
  4. package/demo/form.html +85 -0
  5. package/lib/host.mjs +68 -0
  6. package/package.json +61 -4
  7. package/server/constants.mjs +16 -0
  8. package/server/contract-snapshots.mjs +81 -0
  9. package/server/contract.mjs +24 -0
  10. package/server/engine.mjs +675 -0
  11. package/server/http-utils.mjs +2 -0
  12. package/server/infra/http.mjs +113 -0
  13. package/server/infra/tuning.mjs +82 -0
  14. package/server/mcp/handler.mjs +2 -0
  15. package/server/mcp/instructions.mjs +28 -0
  16. package/server/relay.mjs +226 -0
  17. package/server/routes/api.mjs +120 -0
  18. package/server/routes/assets.mjs +2 -0
  19. package/server/routes/mcp.mjs +17 -0
  20. package/server/routes/workbench.mjs +33 -0
  21. package/server/shared/SHARED_MANIFEST.json +47 -0
  22. package/server/shared/asset-service.mjs +217 -0
  23. package/server/shared/editor-host.mjs +125 -0
  24. package/server/shared/kit/editor/lease.mjs +139 -0
  25. package/server/shared/kit/service/api.mjs +45 -0
  26. package/server/shared/kit/service/http.mjs +113 -0
  27. package/server/shared/kit/service/mcp-http.mjs +142 -0
  28. package/server/shared/kit/tools/validate.mjs +115 -0
  29. package/server/shared/kit/tuning.mjs +82 -0
  30. package/server/shared/kit/util/fs-lock.mjs +132 -0
  31. package/server/shared/service-host.mjs +511 -0
  32. package/server/shared/state-service.mjs +249 -0
  33. package/server/shared/tool-host.mjs +341 -0
  34. package/server/shared/tuning.mjs +63 -0
  35. package/server/tools/capabilities/contract.mjs +35 -0
  36. package/server/tools/capabilities/evaluate.mjs +36 -0
  37. package/server/tools/capabilities/index.mjs +26 -0
  38. package/server/tools/capabilities/interaction.mjs +111 -0
  39. package/server/tools/capabilities/navigation.mjs +32 -0
  40. package/server/tools/capabilities/screenshot.mjs +33 -0
  41. package/server/tools/capabilities/session.mjs +75 -0
  42. package/server/tools/capabilities/snapshot.mjs +30 -0
  43. package/server/tools/capabilities/tabs.mjs +35 -0
  44. package/server/tools/index.mjs +12 -0
  45. package/server/tools/kernel/define.mjs +5 -0
  46. package/server/tools/kernel/output.mjs +22 -0
  47. package/server/tools/kernel/ports.mjs +54 -0
  48. package/server/tools/kernel/registry.mjs +17 -0
  49. package/server/tools.mjs +3 -0
  50. package/ui/app.js +157 -0
  51. package/ui/index.html +56 -0
  52. package/ui/style.css +76 -0
@@ -0,0 +1,890 @@
1
+ {
2
+ "contractVersion": "1.0.0",
3
+ "packageVersion": "0.1.0",
4
+ "toolCount": 15,
5
+ "tools": [
6
+ {
7
+ "name": "browser_capabilities",
8
+ "kind": "read",
9
+ "since": "1.0.0",
10
+ "capability": "contract",
11
+ "description": "返回工作台契约版本、工具清单、能力清单与引擎状态。skill 加载后先调用一次;工具缺失或 major 版本不一致时停止并提示升级。",
12
+ "inputSchema": {
13
+ "type": "object",
14
+ "properties": {},
15
+ "additionalProperties": false
16
+ }
17
+ },
18
+ {
19
+ "name": "browser_navigate",
20
+ "kind": "write",
21
+ "since": "1.0.0",
22
+ "capability": "navigation",
23
+ "description": "打开网址(仅 http/https;URL 内嵌用户名密码会被拒绝)。首次调用会自动拉起浏览器(默认有头可见,登录态持久化)。返回新页面的元素快照,后续动作直接引用其中的 ref。",
24
+ "inputSchema": {
25
+ "type": "object",
26
+ "properties": {
27
+ "url": {
28
+ "type": "string",
29
+ "maxLength": 2048,
30
+ "description": "目标网址,如 https://example.com/"
31
+ },
32
+ "tab": {
33
+ "type": "string",
34
+ "maxLength": 16,
35
+ "description": "在指定标签页打开(缺省=当前活动标签页;浏览器未启动时自动新建)"
36
+ }
37
+ },
38
+ "required": [
39
+ "url"
40
+ ],
41
+ "additionalProperties": false
42
+ }
43
+ },
44
+ {
45
+ "name": "browser_snapshot",
46
+ "kind": "read",
47
+ "since": "1.0.0",
48
+ "capability": "snapshot",
49
+ "description": "观察当前页面:返回可交互元素(链接/按钮/输入框/下拉…)与结构节点(标题/图片)的缩进文本树,每个元素带 ref=eN。click/fill/select 等动作只用 ref 定位;页面变化后 ref 会过期(报 STALE_SNAPSHOT),重新快照即可。",
50
+ "inputSchema": {
51
+ "type": "object",
52
+ "properties": {
53
+ "tab": {
54
+ "type": "string",
55
+ "maxLength": 16,
56
+ "description": "目标标签页 id(缺省=当前活动标签页)"
57
+ }
58
+ },
59
+ "additionalProperties": false
60
+ }
61
+ },
62
+ {
63
+ "name": "browser_click",
64
+ "kind": "write",
65
+ "since": "1.0.0",
66
+ "capability": "interaction",
67
+ "description": "点击元素。ref 来自最近一次 browser_navigate/browser_snapshot 的快照;元素已变化时报 STALE_SNAPSHOT,重新快照后用新 ref。动作成功后返回新快照。",
68
+ "inputSchema": {
69
+ "type": "object",
70
+ "properties": {
71
+ "ref": {
72
+ "type": "string",
73
+ "maxLength": 16,
74
+ "description": "快照里的元素引用,如 e5"
75
+ },
76
+ "tab": {
77
+ "type": "string",
78
+ "maxLength": 16,
79
+ "description": "目标标签页 id(缺省=当前活动标签页)"
80
+ }
81
+ },
82
+ "required": [
83
+ "ref"
84
+ ],
85
+ "additionalProperties": false
86
+ }
87
+ },
88
+ {
89
+ "name": "browser_fill",
90
+ "kind": "write",
91
+ "since": "1.0.0",
92
+ "capability": "interaction",
93
+ "description": "在输入框/文本域填写文字(整体替换,兼容 React/Vue 受控输入)。submit=true 时填写后按回车提交。密码框会被快照掩码显示,但填写不受影响。",
94
+ "inputSchema": {
95
+ "type": "object",
96
+ "properties": {
97
+ "ref": {
98
+ "type": "string",
99
+ "maxLength": 16,
100
+ "description": "目标输入框的 ref"
101
+ },
102
+ "text": {
103
+ "type": "string",
104
+ "maxLength": 10000,
105
+ "description": "要填入的文字(空字符串=清空)"
106
+ },
107
+ "submit": {
108
+ "type": "boolean",
109
+ "description": "填写后按 Enter 提交(默认 false)"
110
+ },
111
+ "tab": {
112
+ "type": "string",
113
+ "maxLength": 16,
114
+ "description": "目标标签页 id(缺省=当前活动标签页)"
115
+ }
116
+ },
117
+ "required": [
118
+ "ref",
119
+ "text"
120
+ ],
121
+ "additionalProperties": false
122
+ }
123
+ },
124
+ {
125
+ "name": "browser_press",
126
+ "kind": "write",
127
+ "since": "1.0.0",
128
+ "capability": "interaction",
129
+ "description": "按键。给 ref 时在指定元素上按(如输入框内 Enter),不给 ref 时对当前页面按(如 Tab / Escape / Control+a)。",
130
+ "inputSchema": {
131
+ "type": "object",
132
+ "properties": {
133
+ "key": {
134
+ "type": "string",
135
+ "maxLength": 40,
136
+ "description": "键名:Enter / Tab / Escape / ArrowDown / Control+a 等(Playwright 键名)"
137
+ },
138
+ "ref": {
139
+ "type": "string",
140
+ "maxLength": 16,
141
+ "description": "目标元素 ref(缺省=页面级按键)"
142
+ },
143
+ "tab": {
144
+ "type": "string",
145
+ "maxLength": 16,
146
+ "description": "目标标签页 id(缺省=当前活动标签页)"
147
+ }
148
+ },
149
+ "required": [
150
+ "key"
151
+ ],
152
+ "additionalProperties": false
153
+ }
154
+ },
155
+ {
156
+ "name": "browser_select",
157
+ "kind": "write",
158
+ "since": "1.0.0",
159
+ "capability": "interaction",
160
+ "description": "选择下拉框(select)的选项。value 先按 <option value> 匹配,失败自动按选项文本匹配。",
161
+ "inputSchema": {
162
+ "type": "object",
163
+ "properties": {
164
+ "ref": {
165
+ "type": "string",
166
+ "maxLength": 16,
167
+ "description": "目标下拉框的 ref"
168
+ },
169
+ "value": {
170
+ "type": "string",
171
+ "maxLength": 300,
172
+ "description": "选项的 value 或可见文本"
173
+ },
174
+ "tab": {
175
+ "type": "string",
176
+ "maxLength": 16,
177
+ "description": "目标标签页 id(缺省=当前活动标签页)"
178
+ }
179
+ },
180
+ "required": [
181
+ "ref",
182
+ "value"
183
+ ],
184
+ "additionalProperties": false
185
+ }
186
+ },
187
+ {
188
+ "name": "browser_scroll",
189
+ "kind": "write",
190
+ "since": "1.0.0",
191
+ "capability": "interaction",
192
+ "description": "滚动当前页面(默认向下 600px)。懒加载页面翻内容用它。",
193
+ "inputSchema": {
194
+ "type": "object",
195
+ "properties": {
196
+ "direction": {
197
+ "type": "string",
198
+ "enum": [
199
+ "up",
200
+ "down"
201
+ ],
202
+ "description": "方向(默认 down)"
203
+ },
204
+ "amount": {
205
+ "type": "number",
206
+ "description": "像素数(默认 600)"
207
+ },
208
+ "tab": {
209
+ "type": "string",
210
+ "maxLength": 16,
211
+ "description": "目标标签页 id(缺省=当前活动标签页)"
212
+ }
213
+ },
214
+ "additionalProperties": false
215
+ }
216
+ },
217
+ {
218
+ "name": "browser_tabs",
219
+ "kind": "control",
220
+ "since": "1.0.0",
221
+ "capability": "tabs",
222
+ "description": "标签页四合一:action=list 列出(含稳定 id 与当前地址);new 打开新标签页(可带 url);select 切换活动标签页;close 关闭。后续动作默认作用于活动标签页,也可用 tab 参数显式指定。",
223
+ "inputSchema": {
224
+ "type": "object",
225
+ "properties": {
226
+ "action": {
227
+ "type": "string",
228
+ "enum": [
229
+ "list",
230
+ "new",
231
+ "select",
232
+ "close"
233
+ ],
234
+ "description": "动作(默认 list)"
235
+ },
236
+ "url": {
237
+ "type": "string",
238
+ "maxLength": 2048,
239
+ "description": "new 动作要打开的网址"
240
+ },
241
+ "tab": {
242
+ "type": "string",
243
+ "maxLength": 16,
244
+ "description": "select/close 的目标标签页 id"
245
+ }
246
+ },
247
+ "additionalProperties": false
248
+ }
249
+ },
250
+ {
251
+ "name": "browser_screenshot",
252
+ "kind": "read",
253
+ "since": "1.0.0",
254
+ "capability": "screenshot",
255
+ "description": "当前页面截图(PNG 保存到本机,返回绝对路径)。默认视口截图;fullPage=true 截整页。工作台地址可实时观察页面。",
256
+ "inputSchema": {
257
+ "type": "object",
258
+ "properties": {
259
+ "fullPage": {
260
+ "type": "boolean",
261
+ "description": "是否截取整页(默认 false)"
262
+ },
263
+ "tab": {
264
+ "type": "string",
265
+ "maxLength": 16,
266
+ "description": "目标标签页 id(缺省=当前活动标签页)"
267
+ }
268
+ },
269
+ "additionalProperties": false
270
+ }
271
+ },
272
+ {
273
+ "name": "browser_status",
274
+ "kind": "read",
275
+ "since": "1.0.0",
276
+ "capability": "session",
277
+ "description": "引擎状态:是否运行、有头/无头、标签页清单(id+地址)、累计动作数、最近动作日志。不确定浏览器是否还活着时先看它。",
278
+ "inputSchema": {
279
+ "type": "object",
280
+ "properties": {},
281
+ "additionalProperties": false
282
+ }
283
+ },
284
+ {
285
+ "name": "browser_wait",
286
+ "kind": "control",
287
+ "since": "1.0.0",
288
+ "capability": "session",
289
+ "description": "等待:ms=毫秒;selector=等元素出现(如 .result);都不给=等页面 load 完成。动作后页面还在加载/渲染时用它。",
290
+ "inputSchema": {
291
+ "type": "object",
292
+ "properties": {
293
+ "ms": {
294
+ "type": "number",
295
+ "description": "等待毫秒数(上限 30000)"
296
+ },
297
+ "selector": {
298
+ "type": "string",
299
+ "maxLength": 300,
300
+ "description": "等待出现的 CSS 选择器"
301
+ },
302
+ "tab": {
303
+ "type": "string",
304
+ "maxLength": 16,
305
+ "description": "目标标签页 id(缺省=当前活动标签页)"
306
+ }
307
+ },
308
+ "additionalProperties": false
309
+ }
310
+ },
311
+ {
312
+ "name": "browser_history",
313
+ "kind": "control",
314
+ "since": "1.0.0",
315
+ "capability": "session",
316
+ "description": "浏览历史:back 后退 / forward 前进 / reload 重载。返回操作后的新快照。",
317
+ "inputSchema": {
318
+ "type": "object",
319
+ "properties": {
320
+ "action": {
321
+ "type": "string",
322
+ "enum": [
323
+ "back",
324
+ "forward",
325
+ "reload"
326
+ ],
327
+ "description": "动作(默认 back)"
328
+ },
329
+ "tab": {
330
+ "type": "string",
331
+ "maxLength": 16,
332
+ "description": "目标标签页 id(缺省=当前活动标签页)"
333
+ }
334
+ },
335
+ "additionalProperties": false
336
+ }
337
+ },
338
+ {
339
+ "name": "browser_close",
340
+ "kind": "control",
341
+ "since": "1.0.0",
342
+ "capability": "session",
343
+ "description": "关闭浏览器(所有标签页)。登录态与 profile 持久化,下次 navigate 自动重启浏览器并保留登录。任务结束或页面卡死时用它重置。",
344
+ "inputSchema": {
345
+ "type": "object",
346
+ "properties": {},
347
+ "additionalProperties": false
348
+ }
349
+ },
350
+ {
351
+ "name": "browser_evaluate",
352
+ "kind": "write",
353
+ "since": "1.0.0",
354
+ "capability": "evaluate",
355
+ "description": "在页面里执行 JS 表达式并返回结果。默认关闭(安全默认);关闭时返回 NOT_IMPLEMENTED 与开启方法。优先用快照+ref 完成任务,本工具留给快照覆盖不了的场景。",
356
+ "inputSchema": {
357
+ "type": "object",
358
+ "properties": {
359
+ "script": {
360
+ "type": "string",
361
+ "maxLength": 20000,
362
+ "description": "JS 表达式(如 document.title)"
363
+ },
364
+ "tab": {
365
+ "type": "string",
366
+ "maxLength": 16,
367
+ "description": "目标标签页 id(缺省=当前活动标签页)"
368
+ }
369
+ },
370
+ "required": [
371
+ "script"
372
+ ],
373
+ "additionalProperties": false
374
+ }
375
+ }
376
+ ],
377
+ "features": [
378
+ "browser.contract",
379
+ "browser.navigation",
380
+ "browser.snapshot",
381
+ "browser.interaction",
382
+ "browser.tabs",
383
+ "browser.screenshot",
384
+ "browser.session",
385
+ "browser.evaluate"
386
+ ],
387
+ "capabilities": [
388
+ {
389
+ "id": "contract",
390
+ "title": "契约探测",
391
+ "description": "",
392
+ "tags": [
393
+ "meta"
394
+ ],
395
+ "requires": [
396
+ "engine",
397
+ "server"
398
+ ],
399
+ "dependsOn": [],
400
+ "provides": {},
401
+ "features": [
402
+ "browser.contract"
403
+ ],
404
+ "tools": [
405
+ {
406
+ "name": "browser_capabilities",
407
+ "description": "返回工作台契约版本、工具清单、能力清单与引擎状态。skill 加载后先调用一次;工具缺失或 major 版本不一致时停止并提示升级。",
408
+ "inputSchema": {
409
+ "type": "object",
410
+ "properties": {},
411
+ "additionalProperties": false
412
+ },
413
+ "kind": "read",
414
+ "since": "1.0.0"
415
+ }
416
+ ]
417
+ },
418
+ {
419
+ "id": "navigation",
420
+ "title": "导航",
421
+ "description": "",
422
+ "tags": [
423
+ "core"
424
+ ],
425
+ "requires": [
426
+ "engine"
427
+ ],
428
+ "dependsOn": [],
429
+ "provides": {},
430
+ "features": [
431
+ "browser.navigation"
432
+ ],
433
+ "tools": [
434
+ {
435
+ "name": "browser_navigate",
436
+ "description": "打开网址(仅 http/https;URL 内嵌用户名密码会被拒绝)。首次调用会自动拉起浏览器(默认有头可见,登录态持久化)。返回新页面的元素快照,后续动作直接引用其中的 ref。",
437
+ "inputSchema": {
438
+ "type": "object",
439
+ "properties": {
440
+ "url": {
441
+ "type": "string",
442
+ "maxLength": 2048,
443
+ "description": "目标网址,如 https://example.com/"
444
+ },
445
+ "tab": {
446
+ "type": "string",
447
+ "maxLength": 16,
448
+ "description": "在指定标签页打开(缺省=当前活动标签页;浏览器未启动时自动新建)"
449
+ }
450
+ },
451
+ "required": [
452
+ "url"
453
+ ],
454
+ "additionalProperties": false
455
+ },
456
+ "kind": "write",
457
+ "since": "1.0.0"
458
+ }
459
+ ]
460
+ },
461
+ {
462
+ "id": "snapshot",
463
+ "title": "页面快照",
464
+ "description": "",
465
+ "tags": [
466
+ "core"
467
+ ],
468
+ "requires": [
469
+ "engine"
470
+ ],
471
+ "dependsOn": [],
472
+ "provides": {},
473
+ "features": [
474
+ "browser.snapshot"
475
+ ],
476
+ "tools": [
477
+ {
478
+ "name": "browser_snapshot",
479
+ "description": "观察当前页面:返回可交互元素(链接/按钮/输入框/下拉…)与结构节点(标题/图片)的缩进文本树,每个元素带 ref=eN。click/fill/select 等动作只用 ref 定位;页面变化后 ref 会过期(报 STALE_SNAPSHOT),重新快照即可。",
480
+ "inputSchema": {
481
+ "type": "object",
482
+ "properties": {
483
+ "tab": {
484
+ "type": "string",
485
+ "maxLength": 16,
486
+ "description": "目标标签页 id(缺省=当前活动标签页)"
487
+ }
488
+ },
489
+ "additionalProperties": false
490
+ },
491
+ "kind": "read",
492
+ "since": "1.0.0"
493
+ }
494
+ ]
495
+ },
496
+ {
497
+ "id": "interaction",
498
+ "title": "页面交互",
499
+ "description": "",
500
+ "tags": [
501
+ "core"
502
+ ],
503
+ "requires": [
504
+ "engine"
505
+ ],
506
+ "dependsOn": [],
507
+ "provides": {},
508
+ "features": [
509
+ "browser.interaction"
510
+ ],
511
+ "tools": [
512
+ {
513
+ "name": "browser_click",
514
+ "description": "点击元素。ref 来自最近一次 browser_navigate/browser_snapshot 的快照;元素已变化时报 STALE_SNAPSHOT,重新快照后用新 ref。动作成功后返回新快照。",
515
+ "inputSchema": {
516
+ "type": "object",
517
+ "properties": {
518
+ "ref": {
519
+ "type": "string",
520
+ "maxLength": 16,
521
+ "description": "快照里的元素引用,如 e5"
522
+ },
523
+ "tab": {
524
+ "type": "string",
525
+ "maxLength": 16,
526
+ "description": "目标标签页 id(缺省=当前活动标签页)"
527
+ }
528
+ },
529
+ "required": [
530
+ "ref"
531
+ ],
532
+ "additionalProperties": false
533
+ },
534
+ "kind": "write",
535
+ "since": "1.0.0"
536
+ },
537
+ {
538
+ "name": "browser_fill",
539
+ "description": "在输入框/文本域填写文字(整体替换,兼容 React/Vue 受控输入)。submit=true 时填写后按回车提交。密码框会被快照掩码显示,但填写不受影响。",
540
+ "inputSchema": {
541
+ "type": "object",
542
+ "properties": {
543
+ "ref": {
544
+ "type": "string",
545
+ "maxLength": 16,
546
+ "description": "目标输入框的 ref"
547
+ },
548
+ "text": {
549
+ "type": "string",
550
+ "maxLength": 10000,
551
+ "description": "要填入的文字(空字符串=清空)"
552
+ },
553
+ "submit": {
554
+ "type": "boolean",
555
+ "description": "填写后按 Enter 提交(默认 false)"
556
+ },
557
+ "tab": {
558
+ "type": "string",
559
+ "maxLength": 16,
560
+ "description": "目标标签页 id(缺省=当前活动标签页)"
561
+ }
562
+ },
563
+ "required": [
564
+ "ref",
565
+ "text"
566
+ ],
567
+ "additionalProperties": false
568
+ },
569
+ "kind": "write",
570
+ "since": "1.0.0"
571
+ },
572
+ {
573
+ "name": "browser_press",
574
+ "description": "按键。给 ref 时在指定元素上按(如输入框内 Enter),不给 ref 时对当前页面按(如 Tab / Escape / Control+a)。",
575
+ "inputSchema": {
576
+ "type": "object",
577
+ "properties": {
578
+ "key": {
579
+ "type": "string",
580
+ "maxLength": 40,
581
+ "description": "键名:Enter / Tab / Escape / ArrowDown / Control+a 等(Playwright 键名)"
582
+ },
583
+ "ref": {
584
+ "type": "string",
585
+ "maxLength": 16,
586
+ "description": "目标元素 ref(缺省=页面级按键)"
587
+ },
588
+ "tab": {
589
+ "type": "string",
590
+ "maxLength": 16,
591
+ "description": "目标标签页 id(缺省=当前活动标签页)"
592
+ }
593
+ },
594
+ "required": [
595
+ "key"
596
+ ],
597
+ "additionalProperties": false
598
+ },
599
+ "kind": "write",
600
+ "since": "1.0.0"
601
+ },
602
+ {
603
+ "name": "browser_select",
604
+ "description": "选择下拉框(select)的选项。value 先按 <option value> 匹配,失败自动按选项文本匹配。",
605
+ "inputSchema": {
606
+ "type": "object",
607
+ "properties": {
608
+ "ref": {
609
+ "type": "string",
610
+ "maxLength": 16,
611
+ "description": "目标下拉框的 ref"
612
+ },
613
+ "value": {
614
+ "type": "string",
615
+ "maxLength": 300,
616
+ "description": "选项的 value 或可见文本"
617
+ },
618
+ "tab": {
619
+ "type": "string",
620
+ "maxLength": 16,
621
+ "description": "目标标签页 id(缺省=当前活动标签页)"
622
+ }
623
+ },
624
+ "required": [
625
+ "ref",
626
+ "value"
627
+ ],
628
+ "additionalProperties": false
629
+ },
630
+ "kind": "write",
631
+ "since": "1.0.0"
632
+ },
633
+ {
634
+ "name": "browser_scroll",
635
+ "description": "滚动当前页面(默认向下 600px)。懒加载页面翻内容用它。",
636
+ "inputSchema": {
637
+ "type": "object",
638
+ "properties": {
639
+ "direction": {
640
+ "type": "string",
641
+ "enum": [
642
+ "up",
643
+ "down"
644
+ ],
645
+ "description": "方向(默认 down)"
646
+ },
647
+ "amount": {
648
+ "type": "number",
649
+ "description": "像素数(默认 600)"
650
+ },
651
+ "tab": {
652
+ "type": "string",
653
+ "maxLength": 16,
654
+ "description": "目标标签页 id(缺省=当前活动标签页)"
655
+ }
656
+ },
657
+ "additionalProperties": false
658
+ },
659
+ "kind": "write",
660
+ "since": "1.0.0"
661
+ }
662
+ ]
663
+ },
664
+ {
665
+ "id": "tabs",
666
+ "title": "标签页管理",
667
+ "description": "",
668
+ "tags": [
669
+ "core"
670
+ ],
671
+ "requires": [
672
+ "engine"
673
+ ],
674
+ "dependsOn": [],
675
+ "provides": {},
676
+ "features": [
677
+ "browser.tabs"
678
+ ],
679
+ "tools": [
680
+ {
681
+ "name": "browser_tabs",
682
+ "description": "标签页四合一:action=list 列出(含稳定 id 与当前地址);new 打开新标签页(可带 url);select 切换活动标签页;close 关闭。后续动作默认作用于活动标签页,也可用 tab 参数显式指定。",
683
+ "inputSchema": {
684
+ "type": "object",
685
+ "properties": {
686
+ "action": {
687
+ "type": "string",
688
+ "enum": [
689
+ "list",
690
+ "new",
691
+ "select",
692
+ "close"
693
+ ],
694
+ "description": "动作(默认 list)"
695
+ },
696
+ "url": {
697
+ "type": "string",
698
+ "maxLength": 2048,
699
+ "description": "new 动作要打开的网址"
700
+ },
701
+ "tab": {
702
+ "type": "string",
703
+ "maxLength": 16,
704
+ "description": "select/close 的目标标签页 id"
705
+ }
706
+ },
707
+ "additionalProperties": false
708
+ },
709
+ "kind": "control",
710
+ "since": "1.0.0"
711
+ }
712
+ ]
713
+ },
714
+ {
715
+ "id": "screenshot",
716
+ "title": "页面截图",
717
+ "description": "",
718
+ "tags": [
719
+ "verify"
720
+ ],
721
+ "requires": [
722
+ "engine",
723
+ "server"
724
+ ],
725
+ "dependsOn": [],
726
+ "provides": {},
727
+ "features": [
728
+ "browser.screenshot"
729
+ ],
730
+ "tools": [
731
+ {
732
+ "name": "browser_screenshot",
733
+ "description": "当前页面截图(PNG 保存到本机,返回绝对路径)。默认视口截图;fullPage=true 截整页。工作台地址可实时观察页面。",
734
+ "inputSchema": {
735
+ "type": "object",
736
+ "properties": {
737
+ "fullPage": {
738
+ "type": "boolean",
739
+ "description": "是否截取整页(默认 false)"
740
+ },
741
+ "tab": {
742
+ "type": "string",
743
+ "maxLength": 16,
744
+ "description": "目标标签页 id(缺省=当前活动标签页)"
745
+ }
746
+ },
747
+ "additionalProperties": false
748
+ },
749
+ "kind": "read",
750
+ "since": "1.0.0"
751
+ }
752
+ ]
753
+ },
754
+ {
755
+ "id": "session",
756
+ "title": "会话管理",
757
+ "description": "",
758
+ "tags": [
759
+ "core"
760
+ ],
761
+ "requires": [
762
+ "engine"
763
+ ],
764
+ "dependsOn": [],
765
+ "provides": {},
766
+ "features": [
767
+ "browser.session"
768
+ ],
769
+ "tools": [
770
+ {
771
+ "name": "browser_status",
772
+ "description": "引擎状态:是否运行、有头/无头、标签页清单(id+地址)、累计动作数、最近动作日志。不确定浏览器是否还活着时先看它。",
773
+ "inputSchema": {
774
+ "type": "object",
775
+ "properties": {},
776
+ "additionalProperties": false
777
+ },
778
+ "kind": "read",
779
+ "since": "1.0.0"
780
+ },
781
+ {
782
+ "name": "browser_wait",
783
+ "description": "等待:ms=毫秒;selector=等元素出现(如 .result);都不给=等页面 load 完成。动作后页面还在加载/渲染时用它。",
784
+ "inputSchema": {
785
+ "type": "object",
786
+ "properties": {
787
+ "ms": {
788
+ "type": "number",
789
+ "description": "等待毫秒数(上限 30000)"
790
+ },
791
+ "selector": {
792
+ "type": "string",
793
+ "maxLength": 300,
794
+ "description": "等待出现的 CSS 选择器"
795
+ },
796
+ "tab": {
797
+ "type": "string",
798
+ "maxLength": 16,
799
+ "description": "目标标签页 id(缺省=当前活动标签页)"
800
+ }
801
+ },
802
+ "additionalProperties": false
803
+ },
804
+ "kind": "control",
805
+ "since": "1.0.0"
806
+ },
807
+ {
808
+ "name": "browser_history",
809
+ "description": "浏览历史:back 后退 / forward 前进 / reload 重载。返回操作后的新快照。",
810
+ "inputSchema": {
811
+ "type": "object",
812
+ "properties": {
813
+ "action": {
814
+ "type": "string",
815
+ "enum": [
816
+ "back",
817
+ "forward",
818
+ "reload"
819
+ ],
820
+ "description": "动作(默认 back)"
821
+ },
822
+ "tab": {
823
+ "type": "string",
824
+ "maxLength": 16,
825
+ "description": "目标标签页 id(缺省=当前活动标签页)"
826
+ }
827
+ },
828
+ "additionalProperties": false
829
+ },
830
+ "kind": "control",
831
+ "since": "1.0.0"
832
+ },
833
+ {
834
+ "name": "browser_close",
835
+ "description": "关闭浏览器(所有标签页)。登录态与 profile 持久化,下次 navigate 自动重启浏览器并保留登录。任务结束或页面卡死时用它重置。",
836
+ "inputSchema": {
837
+ "type": "object",
838
+ "properties": {},
839
+ "additionalProperties": false
840
+ },
841
+ "kind": "control",
842
+ "since": "1.0.0"
843
+ }
844
+ ]
845
+ },
846
+ {
847
+ "id": "evaluate",
848
+ "title": "页面脚本",
849
+ "description": "",
850
+ "tags": [
851
+ "advanced"
852
+ ],
853
+ "requires": [
854
+ "engine"
855
+ ],
856
+ "dependsOn": [],
857
+ "provides": {},
858
+ "features": [
859
+ "browser.evaluate"
860
+ ],
861
+ "tools": [
862
+ {
863
+ "name": "browser_evaluate",
864
+ "description": "在页面里执行 JS 表达式并返回结果。默认关闭(安全默认);关闭时返回 NOT_IMPLEMENTED 与开启方法。优先用快照+ref 完成任务,本工具留给快照覆盖不了的场景。",
865
+ "inputSchema": {
866
+ "type": "object",
867
+ "properties": {
868
+ "script": {
869
+ "type": "string",
870
+ "maxLength": 20000,
871
+ "description": "JS 表达式(如 document.title)"
872
+ },
873
+ "tab": {
874
+ "type": "string",
875
+ "maxLength": 16,
876
+ "description": "目标标签页 id(缺省=当前活动标签页)"
877
+ }
878
+ },
879
+ "required": [
880
+ "script"
881
+ ],
882
+ "additionalProperties": false
883
+ },
884
+ "kind": "write",
885
+ "since": "1.0.0"
886
+ }
887
+ ]
888
+ }
889
+ ]
890
+ }