@doubao-dev/plugin-app-dev 0.0.0-stage → 0.0.40-canary-dea0ddc73-20261026073950

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 (107) hide show
  1. package/README.md +10 -2
  2. package/dist/147.js +9 -0
  3. package/dist/assets.d.ts +5 -0
  4. package/dist/assets.js +4 -0
  5. package/dist/index.d.ts +43 -0
  6. package/dist/index.js +1378 -0
  7. package/dist/plugin.d.ts +102 -0
  8. package/dist/plugin.js +4995 -0
  9. package/dist/preview.js +16 -0
  10. package/dist/rslib-runtime.js +33 -0
  11. package/dist/skills/doubao-plugin-app/SKILL.md +21 -0
  12. package/dist/skills/doubao-plugin-app/references/app-development.md +85 -0
  13. package/dist/skills/doubao-plugin-app/references/frontend/components/container-overlay.md +131 -0
  14. package/dist/skills/doubao-plugin-app/references/frontend/components/form-controls.md +146 -0
  15. package/dist/skills/doubao-plugin-app/references/frontend/components/interactive-controls.md +120 -0
  16. package/dist/skills/doubao-plugin-app/references/frontend/components/map-canvas.md +107 -0
  17. package/dist/skills/doubao-plugin-app/references/frontend/components/overview.md +43 -0
  18. package/dist/skills/doubao-plugin-app/references/frontend/components/scroll-list.md +149 -0
  19. package/dist/skills/doubao-plugin-app/references/frontend/components/text-media.md +209 -0
  20. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/01-/345/237/272/347/241/200.md +1389 -0
  21. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/02-/347/263/273/347/273/237.md +1376 -0
  22. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/03-/350/207/252/345/256/232/344/271/211/351/200/232/344/277/241.md +127 -0
  23. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/04-/345/256/232/344/275/215.md +784 -0
  24. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/05-/345/255/230/345/202/250.md +1176 -0
  25. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/06-/350/267/257/347/224/261.md +839 -0
  26. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/07-/347/225/214/351/235/242.md +376 -0
  27. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/08-/344/272/244/344/272/222.md +1319 -0
  28. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/09-/350/276/223/345/205/245.md +192 -0
  29. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/10-/347/275/221/347/273/234.md +900 -0
  30. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/11-/345/252/222/344/275/223.md +1496 -0
  31. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/12-/344/270/232/345/212/241/350/203/275/345/212/233.md +1281 -0
  32. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/13-/347/231/273/345/275/225.md +511 -0
  33. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/14-/346/224/257/344/273/230.md +943 -0
  34. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/15-/346/225/260/346/215/256/345/210/206/346/236/220.md +124 -0
  35. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/16-/350/223/235/347/211/231.md +3364 -0
  36. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/17-wi-fi.md +1028 -0
  37. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/18-/345/212/240/351/200/237/345/272/246/350/256/241.md +354 -0
  38. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/19-ibeacon.md +508 -0
  39. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/20-/347/275/227/347/233/230.md +320 -0
  40. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/21-/350/256/276/345/244/207/346/226/271/345/220/221.md +351 -0
  41. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/22-/351/231/200/350/236/272/344/273/252.md +354 -0
  42. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/23-/345/252/222/344/275/223-/350/256/276/345/244/207-/347/275/221/347/273/234.md +264 -0
  43. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/24-/347/237/255/344/277/241.md +155 -0
  44. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/25-/346/227/240/351/232/234/347/242/215.md +144 -0
  45. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/26-/345/237/272/347/241/200/344/277/241/346/201/257.md +238 -0
  46. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/27-/347/224/265/346/261/240.md +235 -0
  47. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/28-/345/211/252/350/264/264/346/235/277.md +303 -0
  48. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/29-/345/212/240/345/257/206.md +126 -0
  49. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/30-/346/227/245/345/216/206.md +417 -0
  50. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/31-/347/224/265/350/257/235.md +144 -0
  51. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/32-/346/211/253/347/240/201.md +236 -0
  52. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/33-/345/261/217/345/271/225.md +747 -0
  53. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/34-/351/234/207/345/212/250.md +277 -0
  54. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/35-/346/226/207/344/273/266/347/263/273/347/273/237.md +431 -0
  55. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/common-errors.md +69 -0
  56. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/groups.md +43 -0
  57. package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/quick-reference.md +436 -0
  58. package/dist/skills/doubao-plugin-app/references/frontend/examples/common-patterns.md +590 -0
  59. package/dist/skills/doubao-plugin-app/references/frontend/examples/doubao-agentic-service-api-recipes.md +209 -0
  60. package/dist/skills/doubao-plugin-app/references/frontend/examples/page-widget-basics.md +368 -0
  61. package/dist/skills/doubao-plugin-app/references/frontend/examples/page-widget-recipes.md +65 -0
  62. package/dist/skills/doubao-plugin-app/references/frontend/framework/core.md +283 -0
  63. package/dist/skills/doubao-plugin-app/references/frontend/guides/auth.md +277 -0
  64. package/dist/skills/doubao-plugin-app/references/frontend/guides/best-practices.md +574 -0
  65. package/dist/skills/doubao-plugin-app/references/frontend/guides/client-tools-and-events.md +209 -0
  66. package/dist/skills/doubao-plugin-app/references/frontend/guides/component-development.md +832 -0
  67. package/dist/skills/doubao-plugin-app/references/frontend/guides/debugger-mcp.md +537 -0
  68. package/dist/skills/doubao-plugin-app/references/frontend/guides/expired-widget.md +101 -0
  69. package/dist/skills/doubao-plugin-app/references/frontend/guides/performance-optimization.md +417 -0
  70. package/dist/skills/doubao-plugin-app/references/frontend/guides/troubleshooting.md +278 -0
  71. package/dist/skills/doubao-plugin-app/references/frontend/lynx/best-practices.md +720 -0
  72. package/dist/skills/doubao-plugin-app/references/frontend/lynx/css/pseudo-classes.md +149 -0
  73. package/dist/skills/doubao-plugin-app/references/frontend/lynx/css/selectors.md +224 -0
  74. package/dist/skills/doubao-plugin-app/references/frontend/lynx/css/supported-properties.md +269 -0
  75. package/dist/skills/doubao-plugin-app/references/frontend/lynx/css/values-and-units.md +314 -0
  76. package/dist/skills/doubao-plugin-app/references/frontend/lynx/layout/flex-layout.md +334 -0
  77. package/dist/skills/doubao-plugin-app/references/frontend/lynx/layout/grid-layout.md +408 -0
  78. package/dist/skills/doubao-plugin-app/references/frontend/lynx/layout/linear-layout.md +355 -0
  79. package/dist/skills/doubao-plugin-app/references/frontend/lynx/layout/relative-layout.md +189 -0
  80. package/dist/skills/doubao-plugin-app/references/frontend/lynx/lynx-vs-web/css-differences.md +737 -0
  81. package/dist/skills/doubao-plugin-app/references/frontend/lynx/lynx-vs-web/migration-guide.md +669 -0
  82. package/dist/skills/doubao-plugin-app/references/frontend/lynx/lynx-vs-web/unsupported-features.md +290 -0
  83. package/dist/skills/doubao-plugin-app/references/frontend/lynx/overview.md +60 -0
  84. package/dist/skills/doubao-plugin-app/references/frontend/lynx/patterns/animation.md +243 -0
  85. package/dist/skills/doubao-plugin-app/references/frontend/lynx/patterns/responsive.md +194 -0
  86. package/dist/skills/doubao-plugin-app/references/frontend/lynx/patterns/theming.md +143 -0
  87. package/dist/skills/doubao-plugin-app/references/frontend/lynx/quick-reference.md +229 -0
  88. package/dist/skills/doubao-plugin-app/references/frontend/rules/dos-and-donts.md +479 -0
  89. package/dist/skills/doubao-plugin-app/references/frontend/widget-templates/design-boundary.md +46 -0
  90. package/dist/skills/doubao-plugin-app/references/frontend/widget-templates/overview.md +118 -0
  91. package/dist/skills/doubao-plugin-app/references/frontend/widget-templates/props.md +301 -0
  92. package/dist/skills/doubao-plugin-app/references/mcp-and-cards.md +38 -0
  93. package/dist/templates/README.md.template +11 -0
  94. package/dist/templates/com.doubao/app/manifest.yaml +41 -0
  95. package/dist/templates/com.doubao/app/package.json.template +13 -0
  96. package/dist/templates/com.doubao/app/src/app.config.ts.template +5 -0
  97. package/dist/templates/com.doubao/app/src/app.ts.template +3 -0
  98. package/dist/templates/com.doubao/app/src/pages/home/index.css +14 -0
  99. package/dist/templates/com.doubao/app/src/pages/home/index.tsx.template +14 -0
  100. package/dist/templates/com.doubao/app/src/widgets/example/index.tsx.template +29 -0
  101. package/dist/templates/com.doubao/app/tsconfig.json +19 -0
  102. package/dist/templates/mcp.json +9 -0
  103. package/dist/templates/plugin.json.template +29 -0
  104. package/dist/templates/skills/example/SKILL.md.template +14 -0
  105. package/dist/upload.d.ts +44 -0
  106. package/dist/upload.js +38 -0
  107. package/package.json +60 -3
@@ -0,0 +1,537 @@
1
+ # Debugger MCP 协议
2
+
3
+ Web SDK Debugger MCP 是本地调试服务暴露给调试 Agent 的接口,用来发起模拟器对话,以及发现、渲染和读取当前
4
+ Page / Widget 运行现场。它不替代用户业务 MCP server,只描述 debugger 自身的调试能力。
5
+
6
+ ## 目录
7
+
8
+ - [Endpoint](#endpoint)
9
+ - [Transport](#transport)
10
+ - [Snapshot](#snapshot)
11
+ - [Tools](#tools)
12
+ - [`list_console_messages`](#list_console_messages)
13
+ - [`get_console_message`](#get_console_message)
14
+ - [`get_log_snapshot`](#get_log_snapshot)
15
+ - [`list_render_targets`](#list_render_targets)
16
+ - [`render_page`](#render_page)
17
+ - [`render_widget`](#render_widget)
18
+ - [`submit_chat_query`](#submit_chat_query)
19
+ - [`set_viewport`](#set_viewport)
20
+ - [`take_snapshot`](#take_snapshot)
21
+ - [`get_computed_style`](#get_computed_style)
22
+ - [`get_element_rect`](#get_element_rect)
23
+ - [`scroll_to`](#scroll_to)
24
+ - [`take_screenshot`](#take_screenshot)
25
+ - [`list_agent_trace_events`](#list_agent_trace_events)
26
+ - [`list_agent_tool_calls`](#list_agent_tool_calls)
27
+ - [安全边界](#安全边界)
28
+
29
+ ## Endpoint
30
+
31
+ 本协议只约定 MCP endpoint path:
32
+
33
+ ```text
34
+ /__wsd_mcp
35
+ ```
36
+
37
+ 完整 URL 的发现方式由启动器或宿主集成文档说明,不属于 Debugger MCP 协议本身。
38
+
39
+ ## Transport
40
+
41
+ - 协议:MCP Streamable HTTP。
42
+ - 协议版本:支持 `2026-07-28` modern era,也接受 2025-era legacy 请求;modern client 通过
43
+ `server/discover` 协商版本。
44
+ - 方法:`POST /__wsd_mcp`。
45
+ - 会话:当前实现不生成 session id,每次请求创建一次 MCP server / transport。
46
+ - CORS 预检:`OPTIONS /__wsd_mcp` 返回 204。
47
+ - 数据来源:调试台 UI 通过 `/__wsd_connection` WebSocket 同步运行期快照、接收控制命令和 Sandbox 事件,查询 tools 从 debugger server 内存中的最新快照读取数据。`GET /__agent_trace` 保留为只读的 HTTP 快照访问接口。
48
+ - 浏览器控制:调试台通过共享 WebSocket 通道接收控制命令;渲染命令会在目标完成渲染且生成匹配命令的新 DOM 快照后回执。
49
+
50
+ Web SDK Debugger 连接用户业务 MCP endpoint 时使用自动版本协商:优先选择 `2026-07-28`,对只支持 2025-era
51
+ 的 server 回退到 legacy handshake。每次 `tools/list` 或 `tools/call` 都建立独立 client,因此会重新执行协商,不缓存
52
+ endpoint 的 era 判定。
53
+
54
+ 当 debugger server 尚未收到快照,或当前没有 Page / Widget 运行现场时,tools 返回:
55
+
56
+ ```json
57
+ {
58
+ "stored": false
59
+ }
60
+ ```
61
+
62
+ 如果 debugger server 已经记录过更新时间,返回体可能同时包含 `updatedAtMs`。
63
+
64
+ ## Snapshot
65
+
66
+ MCP tools 读取 debugger server 内存中的最新 snapshot。
67
+
68
+ 所有 tools 都返回 MCP tool result:
69
+
70
+ - `structuredContent`:任意 JSON value;当前 debugger 内置 tools 返回对象。
71
+ - `content[0].text`:默认是同一 JSON 的格式化字符串;`take_snapshot` 直接返回 uid 文本树,方便 Agent 阅读。
72
+
73
+ 分页类 tools 的通用字段:
74
+
75
+ | 字段 | 说明 |
76
+ |------|------|
77
+ | `stored` | 是否已有可读快照 |
78
+ | `storedAt` | 快照写入时间 |
79
+ | `updatedAtMs` | 快照更新时间戳 |
80
+ | `total` | 当前过滤条件下的总数 |
81
+ | `pageIdx` | 当前页序号,从 0 开始 |
82
+ | `pageSize` | 每页条数,最大 200 |
83
+ | `hasMore` | 是否还有下一页 |
84
+
85
+ ## Tools
86
+
87
+ | Tool | 用途 | 关键参数 |
88
+ |------|------|----------|
89
+ | `list_console_messages` | 分页列出 runtime console | `target`、`levels`、`query`、`pageIdx`、`pageSize` |
90
+ | `get_console_message` | 按 `msgid` 获取完整 console entry | `msgid` |
91
+ | `get_log_snapshot` | 返回最近一次调试现场快照 | 无 |
92
+ | `list_render_targets` | 列出 manifest 中可调试的 Page / Widget 及当前目标 | `type` |
93
+ | `render_page` | 切换到全页视图并强制渲染指定路由 | `url` |
94
+ | `render_widget` | 切换到卡片视图并渲染指定 Widget | `widgetId`、`structuredContent` |
95
+ | `submit_chat_query` | 通过调试台对话框提交 query,并等待本轮生成结束 | `query` |
96
+ | `set_viewport` | 设置当前 Page / Widget 的模拟视口尺寸 | `width`、`height` |
97
+ | `take_snapshot` | 返回当前 Page / Widget 的 uid 文本树和可访问性信息 | `target`、`verbose` |
98
+ | `get_computed_style` | 按快照 uid 查询元素的 computed style | `uid`、`properties` |
99
+ | `get_element_rect` | 按快照 uid 查询元素的 x、y、width、height | `uid` |
100
+ | `scroll_to` | 将当前 Page / Widget 的滚动容器移动到绝对坐标 | `uid`、`x`、`y` |
101
+ | `take_screenshot` | 截取当前 Page / Widget 或指定 uid 元素 | `uid`、`format`、`quality` |
102
+ | `list_agent_trace_events` | 分页列出 simulator / MCP / runtime trace events | `category`、`event`、`requestId`、`pageIdx`、`pageSize` |
103
+ | `list_agent_tool_calls` | 分页列出 simulator tool calls | `toolName`、`status`、`requestId`、`query`、`pageIdx`、`pageSize` |
104
+
105
+ 除 `render_page`、`render_widget`、`submit_chat_query`、`set_viewport` 和 `scroll_to` 外,以上 tools 都是只读
106
+ 操作。渲染 tools 会改变本地调试台的当前视图和运行目标;`submit_chat_query` 会新增一轮对话并可能调用网络与 MCP
107
+ tools;`set_viewport` 会改变当前模拟设备尺寸;`scroll_to` 会改变运行目标内滚动容器的当前位置。
108
+
109
+ ## `list_console_messages`
110
+
111
+ `target` 可选值:
112
+
113
+ - `current`:根据当前运行模式选择 Page / Widget / App。
114
+ - `page`:只读 Page runtime console。
115
+ - `widget`:只读 Widget runtime console。
116
+ - `app`:只读 App runtime console。
117
+ - `all`:读取全部 runtime console。
118
+
119
+ `levels` 支持 `log`、`info`、`warn`、`error`、`debug`、`eval`。
120
+
121
+ 返回 `structuredContent`:
122
+
123
+ ```ts
124
+ {
125
+ stored: true;
126
+ storedAt?: string;
127
+ updatedAtMs?: number;
128
+ total: number;
129
+ pageIdx: number;
130
+ pageSize: number;
131
+ hasMore: boolean;
132
+ messages: Array<{
133
+ msgid: string;
134
+ target: 'page' | 'widget' | 'app';
135
+ level: string;
136
+ source: string;
137
+ timestamp: number;
138
+ text: string;
139
+ url?: string;
140
+ lineNumber?: number;
141
+ columnNumber?: number;
142
+ updatedAtMs?: number;
143
+ }>;
144
+ }
145
+ ```
146
+
147
+ 列表项里的 `msgid` 可用于继续调用 `get_console_message` 读取完整参数和 stack。
148
+
149
+ ## `get_console_message`
150
+
151
+ 输入 `msgid`,返回:
152
+
153
+ - `found`:是否命中。
154
+ - `message`:完整 console entry,包括原始 `args`、位置和 stack 信息。
155
+
156
+ 返回 `structuredContent`:
157
+
158
+ ```ts
159
+ {
160
+ stored: true;
161
+ storedAt?: string;
162
+ updatedAtMs?: number;
163
+ found: true;
164
+ message: {
165
+ msgid: string;
166
+ target: 'page' | 'widget' | 'app';
167
+ level: string;
168
+ source: string;
169
+ timestamp: number;
170
+ text: string;
171
+ url?: string;
172
+ lineNumber?: number;
173
+ columnNumber?: number;
174
+ updatedAtMs?: number;
175
+ entry: Record<string, unknown>;
176
+ };
177
+ }
178
+ ```
179
+
180
+ 未命中时返回:
181
+
182
+ ```ts
183
+ {
184
+ stored: true;
185
+ storedAt?: string;
186
+ updatedAtMs?: number;
187
+ found: false;
188
+ msgid: string;
189
+ }
190
+ ```
191
+
192
+ ## `get_log_snapshot`
193
+
194
+ 返回当前调试现场快照,包含 runtime console、trace events、tool calls 和调试上下文,适合 Agent 一次性读取当前现场。
195
+
196
+ 返回 `structuredContent`:
197
+
198
+ ```ts
199
+ {
200
+ stored: true;
201
+ storedAt?: string;
202
+ updatedAtMs?: number;
203
+ snapshot: Record<string, unknown>;
204
+ }
205
+ ```
206
+
207
+ ## `list_render_targets`
208
+
209
+ 从最近一次调试快照列出 manifest 中可渲染的目标。`type` 可选值为 `all`、`page`、`widget`,默认 `all`。
210
+
211
+ 返回 `structuredContent`:
212
+
213
+ ```ts
214
+ {
215
+ stored: true;
216
+ storedAt?: string;
217
+ updatedAtMs?: number;
218
+ pages: Array<{
219
+ pageId: string;
220
+ path: string;
221
+ name: string;
222
+ isHome: boolean;
223
+ }>;
224
+ widgets: Array<{
225
+ widgetId: string;
226
+ name: string;
227
+ }>;
228
+ currentTarget?: RuntimeTargetInfo;
229
+ }
230
+ ```
231
+
232
+ 首期只包含 manifest Page 和 Widget 模板,不包含对话区已经渲染的卡片实例。
233
+
234
+ ## `render_page`
235
+
236
+ 输入现有页面路由格式的 `url`,可携带 query。例如:
237
+
238
+ ```json
239
+ {
240
+ "url": "/pages/weather/index?city=beijing"
241
+ }
242
+ ```
243
+
244
+ 调用会切换到全页视图。即使当前已经是同一路由,也会强制重渲染。只有 Page controller 完成渲染,并生成携带同一
245
+ command id 的新 DOM 快照后,tool 才返回成功:
246
+
247
+ ```ts
248
+ {
249
+ rendered: true;
250
+ target: RuntimeTargetInfo;
251
+ }
252
+ ```
253
+
254
+ 如需读取新页面结构,渲染成功后继续调用 `take_snapshot`。
255
+
256
+ ## `render_widget`
257
+
258
+ 输入 Widget id 和可选的 `structuredContent`:
259
+
260
+ ```json
261
+ {
262
+ "widgetId": "weather-card",
263
+ "structuredContent": {
264
+ "city": "北京"
265
+ }
266
+ }
267
+ ```
268
+
269
+ `structuredContent` 默认 `{}`,不会复用调试台输入框的历史数据。调用会切换到卡片视图、同步输入框并强制渲染
270
+ 指定 Widget。成功返回与 `render_page` 相同的 `{ rendered, target }` 结构;随后调用 `take_snapshot` 读取新卡片
271
+ 结构。
272
+
273
+ ## `submit_chat_query`
274
+
275
+ 输入非空的 `query`:
276
+
277
+ ```json
278
+ {
279
+ "query": "生成一张北京天气卡片"
280
+ }
281
+ ```
282
+
283
+ 调用会切换到对话视图,并复用调试台输入框的正常提交流程;debugger server 不会绕过调试台直接请求 Simulator
284
+ Gateway。tool 会等待本轮流式响应结束,成功时返回:
285
+
286
+ ```ts
287
+ {
288
+ submitted: true;
289
+ completed: true;
290
+ query: string;
291
+ requestId: string;
292
+ }
293
+ ```
294
+
295
+ 可用返回的 `requestId` 继续查询 `list_agent_trace_events` 和 `list_agent_tool_calls`,并通过 `get_log_snapshot`
296
+ 读取本轮 simulator message 和卡片数据。该 tool 只接收 `query`,不接收 token、header 或 session 参数;认证和
297
+ Simulator 上下文均沿用当前调试台。
298
+
299
+ ## `set_viewport`
300
+
301
+ 输入模拟视口的 `width` 和 `height`,两者都必须是 1~9999 的整数:
302
+
303
+ ```json
304
+ {
305
+ "width": 450,
306
+ "height": 844
307
+ }
308
+ ```
309
+
310
+ 调用等价于在调试台选择自定义尺寸,只修改当前 Page / Widget 的模拟设备尺寸,不切换视图或运行目标。尺寸应用后返回:
311
+
312
+ ```ts
313
+ {
314
+ updated: true;
315
+ viewport: {
316
+ width: number;
317
+ height: number;
318
+ };
319
+ }
320
+ ```
321
+
322
+ 当前目标可能因设备尺寸变化而重新渲染;如需读取更新后的结构或图片,继续调用 `take_snapshot` 或 `take_screenshot`。
323
+
324
+ ## `take_snapshot`
325
+
326
+ 返回当前运行目标的 uid 文本树、可访问性信息、目标标识和视口信息。`target` 可选值为 `current`、`page`、
327
+ `widget`,默认 `current`;指定类型与当前目标不一致时返回 `TARGET_MISMATCH`。`verbose: true` 会包含全部已采集
328
+ 属性和 `focusable=false` 等详细字段。
329
+
330
+ 返回 `structuredContent`:
331
+
332
+ ```ts
333
+ {
334
+ stored: true;
335
+ available: true;
336
+ target: RuntimeTargetInfo;
337
+ nodeCount: number;
338
+ selectedUid?: string;
339
+ truncated: boolean;
340
+ snapshotUpdatedAtMs?: number;
341
+ snapshot: string;
342
+ }
343
+ ```
344
+
345
+ 文本树示例:
346
+
347
+ ```text
348
+ uid=root page
349
+ uid=title-1 text role="heading" name="天气" class="title" [selected]
350
+ uid=text-1 text "北京 26°C"
351
+ ```
352
+
353
+ 结构快照最多保留 5000 个节点,单个属性值最多保留 500 个字符;达到限制时 `truncated` 为 `true`。
354
+
355
+ ## `get_computed_style`
356
+
357
+ 输入 `take_snapshot` 返回的元素 `uid`,按需读取浏览器 `getComputedStyle` 结果。`properties` 可选;不传时返回全部
358
+ computed style,传入时只返回指定 CSS 属性:
359
+
360
+ ```json
361
+ {
362
+ "uid": "node-12",
363
+ "properties": ["display", "color", "font-size"]
364
+ }
365
+ ```
366
+
367
+ 返回:
368
+
369
+ ```ts
370
+ {
371
+ uid: string;
372
+ computedStyle: Array<{
373
+ name: string;
374
+ value: string;
375
+ }>;
376
+ }
377
+ ```
378
+
379
+ uid 不存在或对应节点不是元素时返回 `ELEMENT_NOT_FOUND`。
380
+
381
+ ## `get_element_rect`
382
+
383
+ 输入 `take_snapshot` 返回的元素 `uid`,返回相对于模拟设备视口的元素矩形;坐标和尺寸已经消除调试台显示缩放:
384
+
385
+ ```ts
386
+ {
387
+ uid: string;
388
+ x: number;
389
+ y: number;
390
+ width: number;
391
+ height: number;
392
+ }
393
+ ```
394
+
395
+ ## `scroll_to`
396
+
397
+ 按绝对坐标滚动当前 Page / Widget 中的容器。`uid` 来自 `take_snapshot`;传入时精确操作对应元素,不传时从当前
398
+ inspector tree 中选择在运行目标视口内可见面积最大、且在请求坐标轴上有滚动范围的容器:
399
+
400
+ ```json
401
+ {
402
+ "uid": "node-12",
403
+ "y": 480
404
+ }
405
+ ```
406
+
407
+ `x`、`y` 必须是大于等于 0 的有限数字。未传的坐标轴保持当前位置;两者都不传时只查询当前滚动信息。坐标超过
408
+ 范围时自动 clamp。滚动设置后等待两个 animation frame,再读取最终位置并返回:
409
+
410
+ ```ts
411
+ {
412
+ scrolled: true;
413
+ uid: string;
414
+ x: number;
415
+ y: number;
416
+ maxX: number;
417
+ maxY: number;
418
+ viewportWidth: number;
419
+ viewportHeight: number;
420
+ }
421
+ ```
422
+
423
+ 指定 uid 不存在时返回 `ELEMENT_NOT_FOUND`;当前没有运行目标时返回 `TARGET_NOT_FOUND`;找不到可滚动容器或请求
424
+ 坐标轴没有滚动范围时返回 `SCROLL_FAILED`。
425
+
426
+ 连续逐屏截图可由 Agent 编排 `scroll_to` 和 `take_screenshot`:
427
+
428
+ 1. 调用 `scroll_to({ y: 0 })`,保存返回的 `uid` 并截取当前目标。
429
+ 2. 若 `y !== maxY`,调用
430
+ `scroll_to({ uid, y: Math.min(y + viewportHeight, maxY) })`,再调用 `take_screenshot`。
431
+ 3. 重复上一步,直到返回 `y === maxY`。
432
+
433
+ 本期只负责逐屏滚动和截图,不生成或拼接完整长图。
434
+
435
+ ## `take_screenshot`
436
+
437
+ 不传 `uid` 时截取当前 Page / Widget 运行目标;传入 `uid` 时只截取对应元素。支持 `png`、`jpeg`、`webp`,默认
438
+ `png`;`quality` 范围为 0~100,仅对 JPEG 和 WebP 生效:
439
+
440
+ ```json
441
+ {
442
+ "uid": "node-12",
443
+ "format": "webp",
444
+ "quality": 80
445
+ }
446
+ ```
447
+
448
+ 图片通过 MCP image content 返回,`structuredContent` 只包含元数据,不重复携带 base64:
449
+
450
+ ```ts
451
+ {
452
+ captured: true;
453
+ format: 'png' | 'jpeg' | 'webp';
454
+ mimeType: string;
455
+ width: number;
456
+ height: number;
457
+ uid?: string;
458
+ }
459
+ ```
460
+
461
+ 截图支持运行目标中的 open Shadow DOM。单张图片的 base64 负载限制为 8 MiB;跨域图片或字体无法被浏览器读取时可能返回
462
+ `SCREENSHOT_FAILED`。
463
+
464
+ ## `list_agent_trace_events`
465
+
466
+ 按 `category`、`event`、`requestId` 过滤 trace events。常见 category 包括 `simulator`、`mcp`、`runtime`。
467
+
468
+ 返回 `structuredContent`:
469
+
470
+ ```ts
471
+ {
472
+ stored: true;
473
+ storedAt?: string;
474
+ updatedAtMs?: number;
475
+ total: number;
476
+ pageIdx: number;
477
+ pageSize: number;
478
+ hasMore: boolean;
479
+ events: Array<{
480
+ source: 'simulator' | 'widget_runtime' | 'page_runtime';
481
+ id: string;
482
+ timestamp: number;
483
+ category: string;
484
+ event: string;
485
+ requestId: string;
486
+ payload: unknown;
487
+ }>;
488
+ }
489
+ ```
490
+
491
+ ## `list_agent_tool_calls`
492
+
493
+ 按 `toolName`、`status`、`requestId` 或 `query` 过滤 simulator tool calls。
494
+
495
+ 返回 `structuredContent`:
496
+
497
+ ```ts
498
+ {
499
+ stored: true;
500
+ storedAt?: string;
501
+ updatedAtMs?: number;
502
+ total: number;
503
+ pageIdx: number;
504
+ pageSize: number;
505
+ hasMore: boolean;
506
+ toolCalls: Array<{
507
+ id: string;
508
+ requestId: string;
509
+ toolCallId: string;
510
+ toolName: string;
511
+ serverId: string;
512
+ appKey: string;
513
+ status: string;
514
+ createdAtMs: number;
515
+ updatedAtMs: number;
516
+ requiresUserApproval: boolean;
517
+ isMiniApp: boolean;
518
+ message: string;
519
+ }>;
520
+ }
521
+ ```
522
+
523
+ ## 安全边界
524
+
525
+ - 查询 tools 标记为 read-only,不修改调试现场。
526
+ - `render_page`、`render_widget`、`submit_chat_query`、`set_viewport`、`scroll_to` 标记为非只读、非破坏性;
527
+ `set_viewport` 和 `scroll_to` 还标记为幂等、无外部网络访问。渲染、对话或调整尺寸可能触发生命周期、网络请求
528
+ 和其他本地运行时副作用。
529
+ - 同一调试台的控制命令串行执行;普通控制命令超时时间为 15 秒,`submit_chat_query` 为 120 秒;SSE 断线会
530
+ 立即终止正在执行和排队的命令。
531
+ - 控制命令失败返回 MCP error,并在 `structuredContent.error.code` 中使用
532
+ `DEBUGGER_NOT_CONNECTED`、`DEBUGGER_DISCONNECTED`、`TARGET_NOT_FOUND`、`ELEMENT_NOT_FOUND`、
533
+ `RENDER_FAILED`、`RENDER_TIMEOUT`、`VIEWPORT_FAILED`、`INSPECTION_FAILED`、`SCROLL_FAILED`、
534
+ `SCREENSHOT_FAILED`、`CHAT_NOT_READY`、`CHAT_BUSY`、`CHAT_SUBMIT_FAILED`、`CHAT_TIMEOUT` 或
535
+ `COMMAND_TIMEOUT`。
536
+ 失败时不会把旧目标快照当作成功结果返回。
537
+ - 不提供通用点击、输入或样式修改;`submit_chat_query` 只开放对话 query 提交。
@@ -0,0 +1,101 @@
1
+ # 失效卡片
2
+
3
+ `expiredWidget()` 用于把已经过期的业务 Widget 实例更新成框架内置失效卡,通常在业务 Widget 内容失效后调用。
4
+
5
+ `__doubao_apps__expired-widget` 是框架内置虚拟 Widget,不需要在 `src/widgets` 中创建同名目录,也不要手动注册到
6
+ `src/app.config.ts`。
7
+
8
+ `expiredWidget()` 的 `url` 是用户点击失效卡后跳转的目标 Page 路径或 schema。
9
+
10
+ ---
11
+
12
+ ## 当前 Widget 标记为失效
13
+
14
+ 在 Widget 内部可以通过 `getWidgetInstanceId()` 获取当前实例 ID,再调用 `expiredWidget()`。`getWidgetInstanceId()`
15
+ 只在 Widget 环境有值,在 Page 中通常返回 `undefined`。
16
+
17
+ ```ts
18
+ import { getWidgetInstanceId } from '@doubao-dev/framework';
19
+ import { expiredWidget } from '@doubao-dev/framework/api';
20
+
21
+ async function markCurrentWidgetExpired() {
22
+ const widgetInstanceId = getWidgetInstanceId();
23
+ if (!widgetInstanceId) {
24
+ return;
25
+ }
26
+
27
+ await expiredWidget({
28
+ widgetInstanceId,
29
+ url: '/pages/detail/index?from=expired',
30
+ title: '内容已失效',
31
+ detailText: '点击查看最新内容'
32
+ });
33
+ }
34
+ ```
35
+
36
+ ---
37
+
38
+ ## 从 Widget 打开 Page 并传递 widgetInstanceId
39
+
40
+ 如果需要在 Page 中处理过期逻辑,先在 Widget 中拿到 `widgetInstanceId`,通过页面跳转参数传给目标 Page。
41
+
42
+ ```tsx
43
+ import { getWidgetInstanceId } from '@doubao-dev/framework';
44
+ import { navigateTo } from '@doubao-dev/framework/api';
45
+
46
+ export default function OrderWidget() {
47
+ const handleOpenDetail = async () => {
48
+ const widgetInstanceId = getWidgetInstanceId();
49
+ const query = widgetInstanceId ? `?widgetInstanceId=${encodeURIComponent(widgetInstanceId)}` : '';
50
+
51
+ await navigateTo({
52
+ url: `/pages/order-detail/index${query}`
53
+ });
54
+ };
55
+
56
+ return (
57
+ <view className="order-widget">
58
+ <button text="查看详情" onClick={handleOpenDetail} />
59
+ </view>
60
+ );
61
+ }
62
+ ```
63
+
64
+ ---
65
+
66
+ ## Page 中读取 widgetInstanceId 并标记失效
67
+
68
+ Page 不直接拥有 Widget 实例 ID。需要从 `useViewData<T>()` 读取上一步传入的 `widgetInstanceId`,或通过业务数据、通信等方式拿到目标实例 ID。
69
+
70
+ ```tsx
71
+ import { useViewData } from '@doubao-dev/framework';
72
+ import { expiredWidget } from '@doubao-dev/framework/api';
73
+ import './index.scss';
74
+
75
+ interface OrderDetailPageData {
76
+ widgetInstanceId?: string;
77
+ }
78
+
79
+ export default function OrderDetailPage() {
80
+ const viewData = useViewData<OrderDetailPageData>();
81
+
82
+ const handleMarkExpired = async () => {
83
+ if (!viewData.widgetInstanceId) {
84
+ return;
85
+ }
86
+
87
+ await expiredWidget({
88
+ widgetInstanceId: viewData.widgetInstanceId,
89
+ url: '/pages/order-detail/index?from=expired',
90
+ title: '订单状态已更新',
91
+ detailText: '点击查看最新订单状态'
92
+ });
93
+ };
94
+
95
+ return (
96
+ <view className="order-detail-page">
97
+ <button text="标记原卡片失效" disabled={!viewData.widgetInstanceId} onClick={handleMarkExpired} />
98
+ </view>
99
+ );
100
+ }
101
+ ```