@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.
- package/README.md +10 -2
- package/dist/147.js +9 -0
- package/dist/assets.d.ts +5 -0
- package/dist/assets.js +4 -0
- package/dist/index.d.ts +43 -0
- package/dist/index.js +1378 -0
- package/dist/plugin.d.ts +102 -0
- package/dist/plugin.js +4995 -0
- package/dist/preview.js +16 -0
- package/dist/rslib-runtime.js +33 -0
- package/dist/skills/doubao-plugin-app/SKILL.md +21 -0
- package/dist/skills/doubao-plugin-app/references/app-development.md +85 -0
- package/dist/skills/doubao-plugin-app/references/frontend/components/container-overlay.md +131 -0
- package/dist/skills/doubao-plugin-app/references/frontend/components/form-controls.md +146 -0
- package/dist/skills/doubao-plugin-app/references/frontend/components/interactive-controls.md +120 -0
- package/dist/skills/doubao-plugin-app/references/frontend/components/map-canvas.md +107 -0
- package/dist/skills/doubao-plugin-app/references/frontend/components/overview.md +43 -0
- package/dist/skills/doubao-plugin-app/references/frontend/components/scroll-list.md +149 -0
- package/dist/skills/doubao-plugin-app/references/frontend/components/text-media.md +209 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/01-/345/237/272/347/241/200.md +1389 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/02-/347/263/273/347/273/237.md +1376 -0
- 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
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/04-/345/256/232/344/275/215.md +784 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/05-/345/255/230/345/202/250.md +1176 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/06-/350/267/257/347/224/261.md +839 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/07-/347/225/214/351/235/242.md +376 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/08-/344/272/244/344/272/222.md +1319 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/09-/350/276/223/345/205/245.md +192 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/10-/347/275/221/347/273/234.md +900 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/11-/345/252/222/344/275/223.md +1496 -0
- 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
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/13-/347/231/273/345/275/225.md +511 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/14-/346/224/257/344/273/230.md +943 -0
- 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
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/16-/350/223/235/347/211/231.md +3364 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/17-wi-fi.md +1028 -0
- 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
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/19-ibeacon.md +508 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/20-/347/275/227/347/233/230.md +320 -0
- 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
- 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
- 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
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/24-/347/237/255/344/277/241.md +155 -0
- 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
- 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
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/27-/347/224/265/346/261/240.md +235 -0
- 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
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/29-/345/212/240/345/257/206.md +126 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/30-/346/227/245/345/216/206.md +417 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/31-/347/224/265/350/257/235.md +144 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/32-/346/211/253/347/240/201.md +236 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/33-/345/261/217/345/271/225.md +747 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/34-/351/234/207/345/212/250.md +277 -0
- 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
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/common-errors.md +69 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/groups.md +43 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/quick-reference.md +436 -0
- package/dist/skills/doubao-plugin-app/references/frontend/examples/common-patterns.md +590 -0
- package/dist/skills/doubao-plugin-app/references/frontend/examples/doubao-agentic-service-api-recipes.md +209 -0
- package/dist/skills/doubao-plugin-app/references/frontend/examples/page-widget-basics.md +368 -0
- package/dist/skills/doubao-plugin-app/references/frontend/examples/page-widget-recipes.md +65 -0
- package/dist/skills/doubao-plugin-app/references/frontend/framework/core.md +283 -0
- package/dist/skills/doubao-plugin-app/references/frontend/guides/auth.md +277 -0
- package/dist/skills/doubao-plugin-app/references/frontend/guides/best-practices.md +574 -0
- package/dist/skills/doubao-plugin-app/references/frontend/guides/client-tools-and-events.md +209 -0
- package/dist/skills/doubao-plugin-app/references/frontend/guides/component-development.md +832 -0
- package/dist/skills/doubao-plugin-app/references/frontend/guides/debugger-mcp.md +537 -0
- package/dist/skills/doubao-plugin-app/references/frontend/guides/expired-widget.md +101 -0
- package/dist/skills/doubao-plugin-app/references/frontend/guides/performance-optimization.md +417 -0
- package/dist/skills/doubao-plugin-app/references/frontend/guides/troubleshooting.md +278 -0
- package/dist/skills/doubao-plugin-app/references/frontend/lynx/best-practices.md +720 -0
- package/dist/skills/doubao-plugin-app/references/frontend/lynx/css/pseudo-classes.md +149 -0
- package/dist/skills/doubao-plugin-app/references/frontend/lynx/css/selectors.md +224 -0
- package/dist/skills/doubao-plugin-app/references/frontend/lynx/css/supported-properties.md +269 -0
- package/dist/skills/doubao-plugin-app/references/frontend/lynx/css/values-and-units.md +314 -0
- package/dist/skills/doubao-plugin-app/references/frontend/lynx/layout/flex-layout.md +334 -0
- package/dist/skills/doubao-plugin-app/references/frontend/lynx/layout/grid-layout.md +408 -0
- package/dist/skills/doubao-plugin-app/references/frontend/lynx/layout/linear-layout.md +355 -0
- package/dist/skills/doubao-plugin-app/references/frontend/lynx/layout/relative-layout.md +189 -0
- package/dist/skills/doubao-plugin-app/references/frontend/lynx/lynx-vs-web/css-differences.md +737 -0
- package/dist/skills/doubao-plugin-app/references/frontend/lynx/lynx-vs-web/migration-guide.md +669 -0
- package/dist/skills/doubao-plugin-app/references/frontend/lynx/lynx-vs-web/unsupported-features.md +290 -0
- package/dist/skills/doubao-plugin-app/references/frontend/lynx/overview.md +60 -0
- package/dist/skills/doubao-plugin-app/references/frontend/lynx/patterns/animation.md +243 -0
- package/dist/skills/doubao-plugin-app/references/frontend/lynx/patterns/responsive.md +194 -0
- package/dist/skills/doubao-plugin-app/references/frontend/lynx/patterns/theming.md +143 -0
- package/dist/skills/doubao-plugin-app/references/frontend/lynx/quick-reference.md +229 -0
- package/dist/skills/doubao-plugin-app/references/frontend/rules/dos-and-donts.md +479 -0
- package/dist/skills/doubao-plugin-app/references/frontend/widget-templates/design-boundary.md +46 -0
- package/dist/skills/doubao-plugin-app/references/frontend/widget-templates/overview.md +118 -0
- package/dist/skills/doubao-plugin-app/references/frontend/widget-templates/props.md +301 -0
- package/dist/skills/doubao-plugin-app/references/mcp-and-cards.md +38 -0
- package/dist/templates/README.md.template +11 -0
- package/dist/templates/com.doubao/app/manifest.yaml +41 -0
- package/dist/templates/com.doubao/app/package.json.template +13 -0
- package/dist/templates/com.doubao/app/src/app.config.ts.template +5 -0
- package/dist/templates/com.doubao/app/src/app.ts.template +3 -0
- package/dist/templates/com.doubao/app/src/pages/home/index.css +14 -0
- package/dist/templates/com.doubao/app/src/pages/home/index.tsx.template +14 -0
- package/dist/templates/com.doubao/app/src/widgets/example/index.tsx.template +29 -0
- package/dist/templates/com.doubao/app/tsconfig.json +19 -0
- package/dist/templates/mcp.json +9 -0
- package/dist/templates/plugin.json.template +29 -0
- package/dist/templates/skills/example/SKILL.md.template +14 -0
- package/dist/upload.d.ts +44 -0
- package/dist/upload.js +38 -0
- package/package.json +60 -3
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
# 端工具、事件与页面上下文
|
|
2
|
+
|
|
3
|
+
## 选择数据方向
|
|
4
|
+
|
|
5
|
+
| 能力 | 接入点 | 职责 |
|
|
6
|
+
| --- | --- | --- |
|
|
7
|
+
| Client Tool | `tools.json`、`app.config.ts.tools`、默认函数 handler | 执行端侧能力并返回工具结果 |
|
|
8
|
+
| Agent Event | `events.json`、业务 `SKILL.md` 事件占位符、`useAgentEvent` | 更新已打开页面 |
|
|
9
|
+
| Page Model Context | `useModelContext().setPageContext` | 提交当前页面完整状态,供后续模型轮次使用 |
|
|
10
|
+
|
|
11
|
+
端工具不能直接读取其他 Page 的 React state;事件不会自动打开页面;提交模型上下文不会发起新一轮对话。
|
|
12
|
+
|
|
13
|
+
## JSB 调用限制
|
|
14
|
+
|
|
15
|
+
端工具在独立的 ToolRuntime 中执行,可调用的 JSB 受白名单限制。当前 Android 和 iOS 允许以下业务 JSB;表中名称是宿主方法名,业务仍通过 `@doubao-dev/framework/api` 中对应的公开 API 调用。
|
|
16
|
+
|
|
17
|
+
| 类别 | 允许的 JSB |
|
|
18
|
+
| --- | --- |
|
|
19
|
+
| 账号与登录 | `doubao.getAccountInfo`、`doubao.login` |
|
|
20
|
+
| 设置与授权状态 | `doubao.getSetting`、`doubao.getAppAuthorizeSetting`、`doubao.getSystemSetting` |
|
|
21
|
+
| 系统与设备 | `doubao.getSystemInfo`、`doubao.getDeviceInfo` |
|
|
22
|
+
| 网络与定位 | `doubao.request`、`doubao.getLocation` |
|
|
23
|
+
| 埋点 | `doubao.reportEvent` |
|
|
24
|
+
| 存储 | `doubao.setStorage`、`doubao.getStorage`、`doubao.removeStorage`、`doubao.clearStorage`、`doubao.getStorageInfo` |
|
|
25
|
+
|
|
26
|
+
工具结果回传由 Framework 处理,业务只需返回符合协议的结果对象。
|
|
27
|
+
|
|
28
|
+
不在白名单中的 JSB 会被拒绝,包括 `navigateTo`、`redirectTo`、`reLaunch`、`navigateBack`、`openPage` 等路由能力。SDK 导出了某个 API,或该 API 能在 Page / Widget 中使用,不代表它能在端工具中调用;需要页面跳转时,应在支持该路由能力的 Page / Widget 交互中完成。
|
|
29
|
+
|
|
30
|
+
白名单放行也不代表调用必然成功:仍需满足接口权限、用户授权、宿主支持和限流等条件。在 `tools.json` 中声明 `permissions` 不能扩大端工具的 JSB 白名单;业务需要处理实际调用失败。
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
## Schema 限制
|
|
35
|
+
|
|
36
|
+
这里使用的是平台支持的 JSON Schema 子集,不支持 `enum`、数值上下界(`minimum` / `maximum`,即 min/max)等校验能力。不要在 schema 中添加这些约束;将可选值和取值范围写入字段 `description`,并在业务代码中校验。此限制同时适用于 `tools.json` 的 `inputSchema`、`outputSchema` 和 `events.json` 的 `payloadSchema`。
|
|
37
|
+
|
|
38
|
+
优先使用基础结构字段 `type`、`properties`、`required`、`items` 和 `description`。描述中的约束不会自动执行:端工具在 handler 中检查输入,Page 在事件回调中检查 payload,输出也应符合声明的结果结构。
|
|
39
|
+
|
|
40
|
+
## tools.json 与端工具注册
|
|
41
|
+
|
|
42
|
+
在项目根目录声明 `tools.json`。`tools` 是非空数组;每项需要唯一 `name`、`description`、对象形式的 `inputSchema` 和 `outputSchema`。端工具显式设置 `tool_type: "client"`;省略时按远程工具处理。
|
|
43
|
+
|
|
44
|
+
```json
|
|
45
|
+
{
|
|
46
|
+
"tools": [
|
|
47
|
+
{
|
|
48
|
+
"name": "calculate_total",
|
|
49
|
+
"description": "Calculate an amount in integer cents when the user explicitly provides unit price and quantity. Does not create orders or charge money.",
|
|
50
|
+
"tool_type": "client",
|
|
51
|
+
"inputSchema": {
|
|
52
|
+
"type": "object",
|
|
53
|
+
"properties": {
|
|
54
|
+
"unit_price_cents": { "type": "integer", "description": "Non-negative unit price in cents" },
|
|
55
|
+
"quantity": { "type": "integer", "description": "Positive item count" }
|
|
56
|
+
},
|
|
57
|
+
"required": ["unit_price_cents", "quantity"]
|
|
58
|
+
},
|
|
59
|
+
"outputSchema": {
|
|
60
|
+
"type": "object",
|
|
61
|
+
"properties": {
|
|
62
|
+
"total_cents": { "type": "integer" }
|
|
63
|
+
},
|
|
64
|
+
"required": ["total_cents"]
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
]
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
将以下配置合入 `src/app.config.ts`,保留现有页面与卡片配置。`entry` 相对于 `src/`,注册名称与 `tools.json.name` 必须一致。
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
import { defineAppConfig } from '@doubao-dev/framework/config';
|
|
75
|
+
|
|
76
|
+
export default defineAppConfig({
|
|
77
|
+
appId: 'your-app-id',
|
|
78
|
+
name: 'Amount Calculator',
|
|
79
|
+
tools: [{ entry: 'tools/calculate-total/index', name: 'calculate_total' }]
|
|
80
|
+
});
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
在 `src/tools/calculate-total/index.ts` 默认导出 handler,接收解析后的对象,返回结果对象或 Promise。以下示例只计算整数分金额,不下单、不扣款:
|
|
84
|
+
|
|
85
|
+
```ts
|
|
86
|
+
export default function calculateTotal(input: Record<string, unknown>) {
|
|
87
|
+
const { unit_price_cents: unitPrice, quantity } = input;
|
|
88
|
+
if (
|
|
89
|
+
typeof unitPrice !== 'number' ||
|
|
90
|
+
!Number.isSafeInteger(unitPrice) ||
|
|
91
|
+
unitPrice < 0 ||
|
|
92
|
+
typeof quantity !== 'number' ||
|
|
93
|
+
!Number.isSafeInteger(quantity) ||
|
|
94
|
+
quantity <= 0
|
|
95
|
+
) {
|
|
96
|
+
return {
|
|
97
|
+
isError: true,
|
|
98
|
+
content: [
|
|
99
|
+
{ type: 'text', text: 'Provide a non-negative integer price and a positive integer quantity.' }
|
|
100
|
+
]
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Integer cents avoid fractional currency rounding; reject unsafe totals before returning a result.
|
|
105
|
+
const total = unitPrice * quantity;
|
|
106
|
+
if (!Number.isSafeInteger(total)) {
|
|
107
|
+
return { isError: true, content: [{ type: 'text', text: 'The total exceeds the supported range.' }] };
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return {
|
|
111
|
+
content: [{ type: 'text', text: `Total: ${total} cents. No order was placed.` }],
|
|
112
|
+
structuredContent: { total_cents: total }
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
结果必须包含文本块 `content` 数组;`structuredContent` 可为对象或对象数组,业务失败返回 `isError: true`。运行时的外形检查不替代业务校验。
|
|
118
|
+
|
|
119
|
+
需要卡片时:声明 `_meta.ui.widgetId` 并匹配注册的 Widget ID;`outputSchema` 使用对象数组,实体顶层恰有一个字段标记 `x-db-is-entity-id: true`;handler 返回对应实体数组。`entity_type` 由运行时补充,不在 schema 中声明。使用 `same_conversation` 过期策略时,同一个实体 ID 字段还必须是唯一的 `x-db-is-refresh-key`。
|
|
120
|
+
|
|
121
|
+
## events.json 与页面订阅
|
|
122
|
+
|
|
123
|
+
在项目根目录声明 `events.json`。根对象的 `events` 数组中,每项包含 `name`、`description` 和对象形式的 `payloadSchema`:
|
|
124
|
+
|
|
125
|
+
```json
|
|
126
|
+
{
|
|
127
|
+
"events": [
|
|
128
|
+
{
|
|
129
|
+
"name": "demo.pageDataUpdated",
|
|
130
|
+
"description": "Update the displayed title for the current page task when explicitly requested by the user.",
|
|
131
|
+
"payloadSchema": {
|
|
132
|
+
"type": "object",
|
|
133
|
+
"properties": {
|
|
134
|
+
"task_id": { "type": "string", "description": "The target page task ID" },
|
|
135
|
+
"title": { "type": "string", "description": "The title explicitly requested by the user" }
|
|
136
|
+
},
|
|
137
|
+
"required": ["task_id", "title"]
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
]
|
|
141
|
+
}
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
在开发者的业务 `SKILL.md` 中加入事件占位符;业务 Skill 的存放位置按项目组织,不由本开发 Skill 指定。事件名必须与声明和订阅一致:
|
|
145
|
+
|
|
146
|
+
```text
|
|
147
|
+
仅当用户明确要求修改已打开页面的标题时,发送 demo.pageDataUpdated 事件。
|
|
148
|
+
目标任务 ID 使用当前页面上下文或用户明确提供的值,标题使用用户要求的内容。
|
|
149
|
+
缺少必要信息时先追问。普通问答不发送此事件,也不声称该事件会保存服务端数据。
|
|
150
|
+
|
|
151
|
+
{{event:demo.pageDataUpdated}}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
将页面注册到 `app.config.ts.pages`,打开时传入 `taskId`。`task_id` 是业务目标标识,Framework 不会自动用它筛选页面:
|
|
155
|
+
|
|
156
|
+
```tsx
|
|
157
|
+
import { useAgentEvent, useState, useViewData } from '@doubao-dev/framework';
|
|
158
|
+
|
|
159
|
+
export default function EventDemoPage() {
|
|
160
|
+
const { taskId } = useViewData<{ taskId?: string }>();
|
|
161
|
+
const [title, setTitle] = useState('Original title');
|
|
162
|
+
|
|
163
|
+
useAgentEvent('demo.pageDataUpdated', payload => {
|
|
164
|
+
// Event schemas do not enforce page ownership; validate the target before changing local state.
|
|
165
|
+
if (typeof taskId !== 'string' || !taskId || payload.task_id !== taskId) return;
|
|
166
|
+
if (typeof payload.title !== 'string' || !payload.title.trim()) {
|
|
167
|
+
console.error('Invalid demo.pageDataUpdated title');
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
setTitle(payload.title);
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
if (!taskId) return <text>Missing taskId</text>;
|
|
174
|
+
return <text>{title}</text>;
|
|
175
|
+
}
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
Framework 自动调用可选的 App `onAgentEvent` 后分发给订阅者,不要手动重复转发。Hook 随挂载订阅、卸载取消,不按页面可见性或栈顶筛选,也不重放历史事件。业务应校验目标、保证重复事件处理幂等,异步任务自行捕获错误。
|
|
179
|
+
|
|
180
|
+
## 页面模型上下文
|
|
181
|
+
|
|
182
|
+
在上面的页面中导入 `useEffect`、`useModelContext`,在条件返回前加入:
|
|
183
|
+
|
|
184
|
+
```tsx
|
|
185
|
+
const modelContext = useModelContext();
|
|
186
|
+
|
|
187
|
+
useEffect(() => {
|
|
188
|
+
if (typeof taskId !== 'string' || !taskId) return;
|
|
189
|
+
void modelContext.setPageContext({
|
|
190
|
+
taskId,
|
|
191
|
+
pageInfo: {
|
|
192
|
+
context_schema: 'demo.page.v1',
|
|
193
|
+
task_id: taskId,
|
|
194
|
+
title
|
|
195
|
+
}
|
|
196
|
+
}).catch(error => {
|
|
197
|
+
console.error('Failed to update page context', error);
|
|
198
|
+
});
|
|
199
|
+
}, [modelContext, taskId, title]);
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
每次提交完整 `pageInfo`,不依赖局部字段合并。控制器稳定,但不会自动同步 React state;通过依赖最新 state 的 Effect 提交。处理调用失败,在下一轮对话确认模型使用最新页面值。此 Hook 的 `{ taskId, pageInfo }` 与 `/api` 的 `updateModelContext({ taskId?, entityId?, content })` 参数不同。
|
|
203
|
+
|
|
204
|
+
## 调试检查
|
|
205
|
+
|
|
206
|
+
- 端工具:先固定参数直接运行,再检查真实调用结果;非法输入应返回业务错误。
|
|
207
|
+
- 页面事件:先打开页面,再手动触发;错误目标和非法 payload 不更新状态;随后验证 Agent 事件链路。
|
|
208
|
+
- 页面上下文:修改状态并提交后,在下一轮对话核对最新值。
|
|
209
|
+
- Web 模拟器通过不代表目标宿主已验证;需要读取运行现场时参考[Debugger MCP](debugger-mcp.md)。
|