看截图
+Agent 通过视觉模型识别菜单、按钮、输入框,再一步步点击。
+-
+
- 优点:不需要改造页面 +
- 风险:慢、贵、UI 变化敏感 +
- 适合:临时探索和低风险页面 +
diff --git a/pages/demo/adoption-plan.md b/pages/demo/adoption-plan.md index 16e03f5..ca074fa 100644 --- a/pages/demo/adoption-plan.md +++ b/pages/demo/adoption-plan.md @@ -1,33 +1,37 @@ -# 模拟展示 4:团队落地清单 +# Demo 4:本地兜底,不抢官方主线
Core Message
++ 视觉识别和 DOM 识别让 Agent 尝试理解页面表象;WebMCP 的方向是让页面主动提供结构化能力, + 让 Agent 调用工具、传入参数、拿到结果。 +
+Agent 通过视觉模型识别菜单、按钮、输入框,再一步步点击。
+Agent 读取 DOM 或可访问性树,通过结构化信息定位交互元素。
+页面暴露工具名、描述、参数 schema 和执行逻辑,Agent 直接调用业务能力。
+| 维度 | +视觉识别 | +DOM / A11y | +WebMCP | +
|---|---|---|---|
| 交互方式 | +观察截图后猜测点击位置 | +读取结构后定位元素 | +调用页面声明的语义工具 | +
| 稳定性 | +受视觉布局影响明显 | +受 DOM 结构和组件状态影响 | +受工具设计、权限和业务逻辑影响 | +
| 现场讲法 | +“像让 AI 蒙着眼睛找按钮” | +“给了地图,但地图可能不完整” | +“给了工具入口和参数说明” | +
+ 打开 /demo/webmcp/index.html,展示声明式表单工具、 + 指令式 JS 工具、工具 schema 面板和复合任务调用日志。 +
++ 先让人提交表单,再让工具面板执行同一类任务。观众会看到 Agent 不需要猜 UI, + 它看到的是工具名、描述、参数 schema 和执行结果。 +
+使用 document.modelContext.registerTool 暴露工具,官方示例包含 pizza layer 和 order status。
+给 AI 编程工具补充现代 Web 知识、兼容性和最佳实践。
+让 coding agent 访问真实浏览器、console、network、performance trace 和 Lighthouse。
+浏览器内置语言模型能力,适合作为渐进增强展示。
+把真实 DOM 放入 Canvas / WebGL / WebGPU 场景,同时保留浏览器能力。
+官方交互 demo,用于快闪展示 Web 体验能力升级。
++ 继续使用本页的卡片和对比表讲主线:AI 不擅长猜复杂 UI,WebMCP 的价值是结构化暴露工具。 + 官方链接可作为会后资料。 +
++ 只回答原则:渐进增强、权限继承、高危确认、审计日志、工具按需暴露。 + 不在本场扩展到厂商 SDK 选型和企业架构。 +
+${tool.description}
+ ${tool.source} +${escapeHtml(JSON.stringify(tool.inputSchema, null, 2))}
+ `;
+ toolListEl.append(card);
+ });
+}
+
+function sampleInputFor(name) {
+ const samples = {
+ create_support_ticket: {
+ email: "dev@example.com",
+ category: "refund",
+ description: "订单 CHR-2026-0614 到货后发现配件缺失。",
+ },
+ lookup_order_status: { orderId: "CHR-2026-0614" },
+ approve_refund_review: { orderId: "CHR-2026-0614", reason: "missing_accessory" },
+ draft_customer_reply: {
+ email: "dev@example.com",
+ category: "refund",
+ orderId: "CHR-2026-0614",
+ },
+ };
+ return samples[name] ?? {};
+}
+
+function log(title, payload) {
+ const entry = document.createElement("div");
+ entry.className = "entry";
+ entry.innerHTML = `${title}${escapeHtml(JSON.stringify(payload, null, 2))}`;
+ logEl.prepend(entry);
+}
+
+function escapeHtml(value) {
+ return String(value)
+ .replaceAll("&", "&")
+ .replaceAll("<", "<")
+ .replaceAll(">", ">")
+ .replaceAll('"', """);
+}
diff --git a/public/demo/webmcp/index.html b/public/demo/webmcp/index.html
new file mode 100644
index 0000000..118e4f0
--- /dev/null
+++ b/public/demo/webmcp/index.html
@@ -0,0 +1,148 @@
+
+
+
+
+
+ Runnable demo
++ 这个页面模拟一个售后后台:左侧是人能操作的业务 UI,右侧是页面暴露给 Agent 的工具契约。 + 如果当前 Chrome 没有开启 WebMCP,本页面会使用本地 mock,让现场仍然能看清楚“工具注册”和“工具调用”的流程。 +
+Declarative API
+<form
+ toolname="create_support_ticket"
+ tooldescription="Create a support ticket from user supplied issue details.">
+ <input name="email" type="email" required />
+ <select name="category" required>...</select>
+ <textarea name="description" required></textarea>
+</form>
+ Imperative API
+navigator.modelContext.registerTool({
+ name: "lookup_order_status",
+ description: "Look up order status by order id.",
+ inputSchema: {
+ type: "object",
+ properties: { orderId: { type: "string" } },
+ required: ["orderId"]
+ },
+ execute: async ({ orderId }) => lookupOrder(orderId)
+});
+