import { tool } from "../tool.js"; import { answerUiInputSchema } from "../../src/chat/answer-ui.js"; import catalog from "../../src/chat/answer-ui-catalog.json" with { type: "json" }; export default tool({ description: "把回答的一段内容发布为本地交互界面。spec 是 root + elements 的扁平树,每个元素包括 type、props、children。只组织真实查询资料或用户事实;无脚本、URL 或任意代码。不执行地图或业务动作,不等待浏览器,不代表业务完成。相同 block_id 更新本轮同一内容块。组件参数的 JSON Schema:" + JSON.stringify(catalog.props), args: { block_id: tool.schema.string().regex(/^[a-zA-Z0-9_-]{1,80}$/), fallback_text: tool.schema.string().min(1).max(4000), spec: tool.schema.object({ root: tool.schema.string(), elements: tool.schema.record(tool.schema.string(), tool.schema.object({ type: tool.schema.string(), props: tool.schema.record(tool.schema.string(), tool.schema.unknown()), children: tool.schema.array(tool.schema.string()).max(48), }).strict()) }).strict(), }, async execute(args) { const value = answerUiInputSchema.parse(args); return JSON.stringify({ version: "answer-ui@1", ...value, recorded: true }); }, });