@doubao-dev/plugin-app-dev 1.0.0-rc.2 → 1.0.0-rc.21
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 +1 -1
- package/dist/plugin.d.ts +2 -4
- package/dist/plugin.js +6 -6
- package/dist/rslib-runtime.js +1 -1
- package/dist/skills/doubao-plugin-app/SKILL.md +7 -9
- package/dist/skills/doubao-plugin-app/references/app/app-development.md +88 -0
- package/dist/skills/doubao-plugin-app/references/app/tools-and-cards.md +79 -0
- package/dist/skills/doubao-plugin-app/references/app/ui-design.md +32 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/02-/347/263/273/347/273/237.md +458 -33
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/07-/347/225/214/351/235/242.md +1 -1
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/11-/345/252/222/344/275/223.md +299 -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 +11 -6
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/36-/347/224/273/345/270/203.md +177 -0
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/groups.md +4 -3
- package/dist/skills/doubao-plugin-app/references/frontend/doubao-agentic-service-api/quick-reference.md +16 -2
- package/dist/skills/doubao-plugin-app/references/frontend/widget-templates/props.md +12 -8
- package/dist/templates/README.md.template +1 -1
- package/package.json +6 -11
- package/dist/skills/doubao-plugin-app/references/app-development.md +0 -90
- package/dist/skills/doubao-plugin-app/references/tools-and-cards.md +0 -47
|
@@ -38,16 +38,16 @@
|
|
|
38
38
|
|
|
39
39
|
## Tag — 标签展示组件
|
|
40
40
|
|
|
41
|
-
`import { Tag, type TagProps, type TagTone, type TagValue } from '@doubao-dev/template/primitives'`
|
|
41
|
+
`import { Tag, type TagItem, type TagProps, type TagTone, type TagValue } from '@doubao-dev/template/primitives'`
|
|
42
42
|
|
|
43
43
|
`Tag` 用于卡片内容中的营销或常规辅助标签,不是独立卡片模板。
|
|
44
44
|
|
|
45
45
|
| Prop | 类型 | 说明 |
|
|
46
46
|
|------|------|------|
|
|
47
|
-
| `text` | `string \| number` |
|
|
47
|
+
| `text` | `string \| number \| readonly TagItem[]` | 标签内容或标签数组;数组项为 `{ text, tone? }` |
|
|
48
48
|
| `tone` | `'marketing' \| 'neutral'` | 营销橙色或常规灰色,默认 `neutral`;旧值 `authority` 已废弃,仅保留兼容,按 `neutral` 显示 |
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
数组由 Tag 自行横向排列,间距 4px,高度 26px(上下各 3px),只显示第一行;空字符串项跳过,空数组不渲染。单值保持 20px 高度。每项 tone 不传时继承外层 tone;数组中的标签也适配深浅色模式。避免传入比整个容器还宽的单枚标签。
|
|
51
51
|
|
|
52
52
|
---
|
|
53
53
|
|
|
@@ -91,13 +91,14 @@
|
|
|
91
91
|
|
|
92
92
|
## Price — 价格展示组件
|
|
93
93
|
|
|
94
|
-
`import { Price, type PricePrefixTone, type PriceProps, type PriceTone, type PriceValue } from '@doubao-dev/template/primitives'`
|
|
94
|
+
`import { Price, type PricePrefixTone, type PriceProps, type PriceSize, type PriceTone, type PriceValue } from '@doubao-dev/template/primitives'`
|
|
95
95
|
|
|
96
96
|
`Price` 用于卡片内容中的价格排版,不是独立卡片模板。
|
|
97
97
|
|
|
98
98
|
| Prop | 类型 | 说明 |
|
|
99
99
|
|------|------|------|
|
|
100
100
|
| `value` | `string \| number` | 价格值;字符串保留前导零和末尾小数位 |
|
|
101
|
+
| `size` | `'md' \| 'sm'` | 默认 md 保持原样;sm 高 20px,现价和原价均为系统字体 13px、19.5px 行高;现价字重 500,原价字重 400、灰色删除线 |
|
|
101
102
|
| `currency` | `string` | 币种符号,默认 `¥`;空字符串隐藏 |
|
|
102
103
|
| `prefix` / `suffix` | `string` | 价格前缀 / 后缀 |
|
|
103
104
|
| `prefixTone` | `'default' \| 'highlight' \| 'muted'` | 前缀主文字色 / 豆包蓝 / `--neutral-70` 次级灰色;不传时跟随价格色调 |
|
|
@@ -128,7 +129,7 @@
|
|
|
128
129
|
|
|
129
130
|
## CompositeCard — 组合卡
|
|
130
131
|
|
|
131
|
-
`import { CompositeCard, type CompositeCardContentSection, type CompositeCardCustomSection, type CompositeCardHeaderProps, type CompositeCardOptionGroupSection, type CompositeCardProps, type CompositeCardSection, type CompositeCardTransitSection } from '@doubao-dev/template'`
|
|
132
|
+
`import { CompositeCard, type CompositeCardContentSection, type CompositeCardCustomSection, type CompositeCardHeaderProps, type CompositeCardOptionGroupSection, type CompositeCardProductItem, type CompositeCardProductProps, type CompositeCardProductSection, type CompositeCardProps, type CompositeCardSection, type CompositeCardTransitSection } from '@doubao-dev/template'`
|
|
132
133
|
|
|
133
134
|
| Prop | 类型 | 说明 |
|
|
134
135
|
|------|------|------|
|
|
@@ -140,13 +141,15 @@
|
|
|
140
141
|
当前白名单:
|
|
141
142
|
|
|
142
143
|
- `CompositeCardTransitSection`:`{ type: 'transit', props: { items?: TransitCardItem[] } }`。
|
|
143
|
-
- `CompositeCardContentSection`:`{ type: 'content', props: { items?: ContentCardItem[] } }`;只复用 ContentCard
|
|
144
|
+
- `CompositeCardContentSection`:`{ type: 'content', props: { items?: ContentCardItem[], topBar?: ContentCardTopBarProps } }`;只复用 ContentCard 的内容区域及列表上方的信息栏,不渲染其卡片外壳、header 或 footer。
|
|
144
145
|
- `CompositeCardOptionGroupSection`:`{ type: 'option-group', props: OptionGroupProps }`。
|
|
146
|
+
- `CompositeCardProductSection`:`{ type: 'product', props: { items: CompositeCardProductItem[] } }`;仅展示前三项,始终三等分列宽,不足三个时保留空列。左右、下方 12px,列间距 8px;图片为随列宽缩放的正方形,标题单行省略,价格使用 Price size="sm"。
|
|
147
|
+
- `CompositeCardProductItem`:`key?`、`title: TemplateText`、`imageSrc?: string`、`price?: Pick<PriceProps, 'value' | 'currency' | 'originalPrice' | 'tone'>`、`onClick?: (event: TouchEvent) => void`;有回调时整项点击上报并阻止冒泡,没有回调时保留根节点点击。
|
|
145
148
|
- `CompositeCardCustomSection`:`{ type: 'custom', content: ReactElement }`;传入业务内容组件,外壳、header 和 footer 仍由模板管理。
|
|
146
149
|
|
|
147
150
|
`props` 透传给对应模块,因此模块原有的回调和具名内容字段仍然有效;只有 `custom.content` 支持业务组件及其内容区样式。其他 section 不开放 `children`、任意 JSX、布局参数或 wrapper 样式,也不提供独立标题字段。标题、说明等普通信息通过 `content` section 表达。业务样式不能覆盖模板外壳、header、footer 或模板类名。卡片统一管理标准 header/footer,复用模块保留原有内容留白、内部布局与窄屏策略;`OptionGroup` 由组合卡内的专用容器补充左右 12px、下方 16px,上方不额外留白。
|
|
148
151
|
|
|
149
|
-
`items` 为空的 section
|
|
152
|
+
`items` 为空的 section 会连同间距一起收起;`content` section 配置了 `topBar` 时仍展示该信息栏。运行时未知 `type` 不展示。`sections` 不支持运行中插入、删除或重排,不要求配置 section key。
|
|
150
153
|
|
|
151
154
|
---
|
|
152
155
|
|
|
@@ -173,11 +176,12 @@ MapCard 的 `ref` 直接绑定到内部 Map,可通过 `MapRef` 调用地图实
|
|
|
173
176
|
|
|
174
177
|
## ContentCard — 列表卡
|
|
175
178
|
|
|
176
|
-
`import { ContentCard, type ContentCardItem, type ContentCardProps, type TemplateExtraAction, type TemplateCardHeaderProps, type TemplateCardFooterProps } from '@doubao-dev/template'`
|
|
179
|
+
`import { ContentCard, type ContentCardItem, type ContentCardProps, type ContentCardTopBarProps, type TemplateExtraAction, type TemplateCardHeaderProps, type TemplateCardFooterProps } from '@doubao-dev/template'`
|
|
177
180
|
|
|
178
181
|
| Prop | 类型 | 说明 |
|
|
179
182
|
|------|------|------|
|
|
180
183
|
| `header` | `TemplateCardHeaderProps` | 标题栏配置 |
|
|
184
|
+
| `topBar` | `ContentCardTopBarProps` | 内容列表上方的业务信息栏:`tagText?: TemplateText` 标题前灰色标签,`title: TemplateText` 左侧文字,`extra?: TemplateText` 右侧补充文字;只接受字符串或数字,单行超出省略,不传时不占空间;标签与标题间隔 6px,标签支持深色模式 |
|
|
181
185
|
| `items` | `ContentCardItem[]` | 列表数据,全量展示 |
|
|
182
186
|
| `footer` | `TemplateCardFooterProps` | 底部操作区配置 |
|
|
183
187
|
|
|
@@ -10,4 +10,4 @@ dbx dev --app
|
|
|
10
10
|
|
|
11
11
|
端工具定义位于 `com.doubao/app/tools.json`,实现位于 `com.doubao/app/src/tools/`,并在 `com.doubao/app/src/app.config.ts` 注册。Kit 根据工具定义生成 Manifest 中的工具和实体配置。
|
|
12
12
|
|
|
13
|
-
项目配置与上传见 [
|
|
13
|
+
项目配置与上传见 [插件与工作台开发](.agents/skills/doubao-plugin-creator/SKILL.md),页面和卡片开发见 [App 开发 Skill](.agents/skills/doubao-plugin-app/SKILL.md)。链接缺失时运行 `dbx skills`。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@doubao-dev/plugin-app-dev",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.21",
|
|
4
4
|
"description": "App development tools for Doubao Plugin CLI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -20,23 +20,18 @@
|
|
|
20
20
|
"!dist/**/*.map"
|
|
21
21
|
],
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"
|
|
23
|
+
"@lynx-js/debug-router-connector": "0.0.21",
|
|
24
24
|
"open": "10.1.0",
|
|
25
|
-
"qrcode": "1.5.4",
|
|
26
|
-
"debug": "^4.4.3",
|
|
27
|
-
"zod": "4.2.0",
|
|
28
|
-
"@lynx-js/debug-router-connector": "0.0.13",
|
|
29
|
-
"@lynx-js/remote-debug-driver": "0.0.3",
|
|
30
|
-
"tslib": "^2.8.1",
|
|
31
25
|
"ws": "^8.21.0",
|
|
32
|
-
"moleculer": "^0.15.0"
|
|
26
|
+
"moleculer": "^0.15.0",
|
|
27
|
+
"zod": "4.2.0"
|
|
33
28
|
},
|
|
34
29
|
"devDependencies": {
|
|
30
|
+
"@byted-doubao-apps/plugin-app-dev": "1.0.0-rc.21",
|
|
35
31
|
"@rslib/core": "1.0.0-beta.1",
|
|
36
32
|
"@types/node": "22.20.4",
|
|
37
33
|
"rimraf": "3.0.2",
|
|
38
|
-
"typescript": "6.0.3"
|
|
39
|
-
"@byted-doubao-apps/plugin-app-dev": "1.0.0-rc.2"
|
|
34
|
+
"typescript": "6.0.3"
|
|
40
35
|
},
|
|
41
36
|
"engines": {
|
|
42
37
|
"node": ">=22.13.0"
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
# 应用开发指南
|
|
2
|
-
|
|
3
|
-
## 项目与配置
|
|
4
|
-
|
|
5
|
-
`plugin.json` 所在目录是插件根目录,前端位于 `com.doubao/app/`;下文的 `src/` 相对此目录。`dbx` 可以在根目录或前端目录运行。每包最多一个 App,不同时包含 `com.doubao/app/` 与 `com.dola/app/`,并提供配套业务 Skill。
|
|
6
|
-
|
|
7
|
-
- 存在 `manifest.yaml` 才启用 App;CLI 优先按 `plugin.json.id`,其次按 name 查询 AppID,失败使用本地调试 ID。上传返回的插件 ID 自动保存,源清单和前端配置无需填写 AppID,发布时由服务端补齐。
|
|
8
|
-
- `dbx init <name> --app` 准备独立的开发包、Kit 和前端依赖。跳过安装或安装失败时,在前端目录运行 `pnpm install`;工具包不需要加入前端依赖。
|
|
9
|
-
- `package.json` 声明前端依赖,随包提供所用包管理工具的锁文件。新项目安装 `@doubao-dev/framework` 和 `@doubao-dev/template` 的 latest 版本;已有项目沿用自身包体系和版本。Hooks 从 framework 导入,端能力从 framework/api 导入。
|
|
10
|
-
|
|
11
|
-
`com.doubao/app/src/app.config.ts` 示例:
|
|
12
|
-
|
|
13
|
-
```ts
|
|
14
|
-
export default {
|
|
15
|
-
name: '我的应用插件',
|
|
16
|
-
pages: ['pages/home/index'],
|
|
17
|
-
widgets: ['widgets/example/index'],
|
|
18
|
-
tools: [{ entry: 'tools/search-products/index', name: 'search_products' }]
|
|
19
|
-
};
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
前端配置默认导出普通对象,必须声明非空的 `widgets`,至少注册一个卡片入口;`pages`、`tools` 按需声明。应用元信息通过 `name`(应用名称)、`description`(应用描述)两个顶层字段按需填写。端工具定义放在 `com.doubao/app/tools.json`,与 `manifest.yaml` 同级。
|
|
23
|
-
|
|
24
|
-
## 实现与验证
|
|
25
|
-
|
|
26
|
-
1. 工具调用或出卡变化先按 [端工具与出卡配置](tools-and-cards.md) 对齐业务 Skill、tools.json、handler 和生成的 Manifest。
|
|
27
|
-
2. 在 `src/widgets/<name>/index.tsx` 实现卡片,在 `src/pages/<name>/index.tsx` 实现全屏页面,在 `src/app.config.ts` 注册入口,保留已有配置。
|
|
28
|
-
3. 使用 Lynx 的 `view`、`text`、`image` 和独立样式文件;布局按 Lynx 文档实现。Widget 优先使用 SDK 卡片模板,核对 props 后映射实体数据。
|
|
29
|
-
4. `useViewData<T>()` 的类型与返回实体一致,并处理数据未到达的空态。字符串入口 `widgets/example/index` 的 Widget ID 为 `example`,显式对象入口使用其 `id`,均须与 Manifest 绑定一致。
|
|
30
|
-
5. 用 `dbx dev --app` 验证真实出卡、交互和导航。
|
|
31
|
-
|
|
32
|
-
页面、卡片和配置的完整示例以当前项目模板为准,SDK 用法按下表读取。
|
|
33
|
-
|
|
34
|
-
上传前按项目根目录 `.agents/skills/doubao-plugin-cli/references/upload.md` 检查图标、尺寸和路径;Web 调试成功不代表平台物料校验已通过。
|
|
35
|
-
|
|
36
|
-
## 本地调试
|
|
37
|
-
|
|
38
|
-
运行 `dbx dev --app`。启动方式、平台同步、非 TTY 进程管理与停止卸载见项目内 `.agents/skills/doubao-plugin-cli/references/development.md`。
|
|
39
|
-
|
|
40
|
-
Kit 缓存缺失时自动安装,版本由 CLI 锁定;需要指定版本时用 `DBX_KIT_VERSION=<准确版本>`。
|
|
41
|
-
|
|
42
|
-
- 源清单未填写 AppID 时,模拟器对话使用 Sandbox 会话创建返回的真实 `sandbox_appid`,会话重建后重新读取,不将占位 ID 写入请求清单。
|
|
43
|
-
- 交互终端用 `web` 打开模拟器、`status` 查看详情和 URL;非交互环境从日志获取地址。设备命令在 dev 交互界面内输入,不是独立的 `dbx` 子命令。
|
|
44
|
-
- 前端由 Kit 热更新;MCP 地址或 headers 变化会重启 App 运行时,更改应用身份或 App 配置后重启 dev。
|
|
45
|
-
- Web 模拟器只读取业务 `skills/<name>/SKILL.md` 正文,不加载其附件。
|
|
46
|
-
|
|
47
|
-
## 真机与桌面调试
|
|
48
|
-
|
|
49
|
-
前提:CLI 能从平台查询到有效 AppID,手机能访问电脑的局域网资源地址。没有平台 AppID 时先使用 Web 模拟器;不能用 Web Sandbox 的兜底 ID 申请真机授权。
|
|
50
|
-
|
|
51
|
-
1. 运行 `dbx dev --app`,等待应用编译就绪,输入 `device` 进入真机菜单。
|
|
52
|
-
2. 用 `version` 选择已上传版本以调试对话和工具调用;没有版本时选择“本地调试,不绑定云端版本”。
|
|
53
|
-
3. 使用手机豆包扫描终端二维码,或输入 `open-web` 打开浏览器扫码,等待调试包安装和连接就绪。已有可复用连接时不必重新扫码。
|
|
54
|
-
4. 用 `page` 或 `widget` 打开页面或卡片,再验证对话中的工具调用和实体数据。
|
|
55
|
-
|
|
56
|
-
| 命令 | 用途 |
|
|
57
|
-
| --- | --- |
|
|
58
|
-
| `qr` | 沿用当前调试版本,重新生成连接二维码 |
|
|
59
|
-
| `open-web` | 扫码期间在浏览器打开当前二维码,不重新申请票据 |
|
|
60
|
-
| `change-size` | 扫码期间切换紧凑/大图,不重新申请票据或断开连接 |
|
|
61
|
-
| `version` | 选择云端版本或不绑定版本的本地调试;切换后会重新连接 |
|
|
62
|
-
| `page` / `widget` | 连接后选择页面或卡片 |
|
|
63
|
-
| `desktop` | 按需安装并打开桌面开发工具,与 CLI 共用设备连接,查看日志、截图和页面结构 |
|
|
64
|
-
| `cancel` | 连接过程中取消,已连接时断开;空闲时不显示 |
|
|
65
|
-
| `back` | 返回上级菜单;已连接时保留连接,未连接完成时取消连接 |
|
|
66
|
-
|
|
67
|
-
扫码期间只显示 `change-size`、`open-web` 和 `back`;`back` 取消本次连接等待并返回真机菜单,连接成功后自动恢复真机菜单。
|
|
68
|
-
|
|
69
|
-
`status` 在主菜单查看调试详情;Ctrl+C 退出并清理连接。
|
|
70
|
-
|
|
71
|
-
连接短暂中断会等待 30 秒恢复,先等待,不要立即重新扫码;超时后按提示执行 `qr`。无法连接时检查 AppID、登录账号、手机到电脑的网络可达性,再查看 `status` 和桌面日志。
|
|
72
|
-
|
|
73
|
-
这里的二维码用于连接本地开发服务,需要保持 dev 运行。`dbx upload` 输出的是云构建成功后的预览二维码;它与本地连接二维码用途不同,上传成功也不代表云构建或预览已成功。
|
|
74
|
-
|
|
75
|
-
## 按需读取 SDK 参考资料
|
|
76
|
-
|
|
77
|
-
| 场景 | 参考资料 |
|
|
78
|
-
| --- | --- |
|
|
79
|
-
| Page / Widget、生命周期、viewData | [组件开发](frontend/guides/component-development.md) |
|
|
80
|
-
| 选择卡片模板和核对 props | [模板索引](frontend/widget-templates/overview.md) |
|
|
81
|
-
| 内置组件的 props 和事件 | [组件索引](frontend/components/overview.md) |
|
|
82
|
-
| 网络、导航、位置等端能力 | [API 速查](frontend/doubao-agentic-service-api/quick-reference.md) |
|
|
83
|
-
| Hooks 与框架核心能力 | [Framework](frontend/framework/core.md) |
|
|
84
|
-
| 布局、CSS、Lynx 与 Web 差异 | [Lynx 索引](frontend/lynx/overview.md) |
|
|
85
|
-
| 登录和隐私授权入口 | [前端授权](frontend/guides/auth.md) |
|
|
86
|
-
| 端工具、事件、页面模型上下文 | [端工具与事件](frontend/guides/client-tools-and-events.md) |
|
|
87
|
-
| 模拟器日志、Trace、工具调用现场 | [Debugger MCP](frontend/guides/debugger-mcp.md) |
|
|
88
|
-
| 编译和运行问题 | [排障指南](frontend/guides/troubleshooting.md) |
|
|
89
|
-
|
|
90
|
-
前端项目配置由本 Skill 单独维护,API、组件和样式资料与 SDK 共用。登录、跳转等 API 的 AppID 参数按对应接口说明填写,与项目配置中的 AppID 注入分别处理。
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
# 端工具、业务 Skill 与卡片
|
|
2
|
-
|
|
3
|
-
## 配置职责
|
|
4
|
-
|
|
5
|
-
插件根目录的 `plugin.json` 展示信息和业务 Skill 格式,见项目内 `.agents/skills/doubao-plugin-cli/references/project-config.md`。
|
|
6
|
-
|
|
7
|
-
App 模板使用本地端工具。工具定义必须放在 `com.doubao/app/tools.json`,与 `manifest.yaml` 和 `package.json` 同级,不放在插件根目录。下文的 `src/` 均相对此 App 目录;SDK 参考资料中的“项目根目录”在此指 `com.doubao/app/`。
|
|
8
|
-
|
|
9
|
-
| 文件 | 职责 |
|
|
10
|
-
| --- | --- |
|
|
11
|
-
| `com.doubao/app/tools.json` | 工具名称、说明、入参、输出 schema 和卡片绑定 |
|
|
12
|
-
| `com.doubao/app/src/app.config.ts` | `tools` 注册工具名称和入口,`widgets` 注册卡片 |
|
|
13
|
-
| `com.doubao/app/src/tools/<name>/index.ts` | 默认导出 handler,接收解析后的参数对象,返回结果对象或 Promise |
|
|
14
|
-
| `com.doubao/app/manifest.yaml` | 保留基础配置;Kit 从 tools.json 生成工具和实体配置 |
|
|
15
|
-
| `skills/<name>/SKILL.md` | 业务触发条件、参数规则、结果与失败处理 |
|
|
16
|
-
|
|
17
|
-
## 端工具定义与实现
|
|
18
|
-
|
|
19
|
-
`tools.json` 的 `tools` 为非空数组。每项声明唯一 `name`、`description`、`inputSchema`、`outputSchema` 和 `tool_type: "client"`。名称须与 `app.config.ts.tools` 的 `name` 一致,`entry` 相对 `src/`。
|
|
20
|
-
|
|
21
|
-
参数使用 JSON Schema 的 `integer` / `number` 类型;不声明 `enum`、`minimum`、`maximum` 等不受支持的约束。将取值范围写入 `description`,在 handler 中校验。完整格式与 JSB 限制见 [端工具与事件](frontend/guides/client-tools-and-events.md)。
|
|
22
|
-
|
|
23
|
-
handler 必须返回文本 `content` 数组;成功结果用 `structuredContent` 返回符合 `outputSchema` 的对象或实体数组。业务失败返回 `isError: true` 和解释原因的文本,不生成成功实体。
|
|
24
|
-
|
|
25
|
-
模板的 `search_products` 从本地目录匹配商品,并校验非空 `query` 与 1~10 的整数 `limit`。业务 Skill、schema、handler 和卡片使用相同的字段,示例价格不代表实时售价。
|
|
26
|
-
|
|
27
|
-
## Manifest 与出卡契约
|
|
28
|
-
|
|
29
|
-
`manifest.yaml` 保留 `manifest_version: 2`、`permissions` 等基础配置,顶层为单个 YAML 对象,不允许重复键。`app_key` 可省略,由平台补齐。
|
|
30
|
-
|
|
31
|
-
Kit 根据 `tools.json` 生成端工具、入参、实体 schema 与卡片绑定;不要在源 Manifest 中重复声明同名工具或实体,否则构建会报错。构建不回写源 Manifest。
|
|
32
|
-
|
|
33
|
-
使用实体驱动 Widget 出卡时,逐项核对:
|
|
34
|
-
|
|
35
|
-
1. `tools.json` 中 `_meta.ui.widgetId` 与 `app.config.ts` 注册的 Widget ID 一致。
|
|
36
|
-
2. `outputSchema` 使用对象数组,实体顶层恰有一个字段标记 `x-db-is-entity-id: true`,返回值稳定标识实体。
|
|
37
|
-
3. handler 返回 `structuredContent` 实体数组,运行时补充 `entity_type`;不要在 schema 中声明该字段。
|
|
38
|
-
4. 使用 `same_conversation` 过期策略时,实体 ID 字段同时是唯一的 `x-db-is-refresh-key`。
|
|
39
|
-
5. Widget 用 `useViewData<T>()` 读取单个实体,字段与工具返回数据一致;一个列表实体可渲染含多项商品的卡片。
|
|
40
|
-
|
|
41
|
-
## 验证与排查
|
|
42
|
-
|
|
43
|
-
先在工具页用固定参数调用,确认搜索命中、无结果和非法输入,再验证对话出卡与页面导航。
|
|
44
|
-
|
|
45
|
-
按 tools.json → 入口注册 → handler 原始结果 → Kit 生成的 Manifest → Widget 字段排查,再查看 [模拟器日志与 Trace](frontend/guides/debugger-mcp.md)。
|
|
46
|
-
|
|
47
|
-
已有项目需要远端 MCP 时,在插件根目录维护 `mcp.json` 和对应展示信息,按实际服务契约维护 Manifest;当前 Web 模拟器接入单个 `streamable-http` 服务。端工具无需配置 MCP Server。
|