Files
SupplierSystem/docs/design/20260903-assistant-framework-freeze.md
T
Ubuntu deb3e72750
CI / server typecheck + tests (push) Canceled after 0s
CI / web typecheck + tests + miniprogram syntax (push) Canceled after 0s
CI / eslint (观察项,C7 骨架) (push) Canceled after 0s
CI / npm audit (critical 硬拦) (push) Canceled after 0s
chore: 以 AI 生鲜配送系统 当前版本作为 SupplierSystem 起点
来源仓库:jxc/ai-fresh-delivery
来源提交:f0b1a180e2deb7e4673b9d1c8542619f7bc0f73d
快照树:  09f679334ff38f0ff25e907961c94a8223bcaedd(与来源 HEAD 工作树逐字节一致,3801 个文件)

按约定本仓库不带任何历史提交:来源仓库的历史中含真实凭据
(生产 SSH 私钥 deploy/id_rsa_tencent、server/.env、.env.tencent/.env.production/.env.gitea、
deploy/小程序AppSecret.txt,其中 MP_APPSECRET / S3 AccessKey 经哈希比对与线上同值),
整包推送会把这些凭据永久带入本仓库,故只取「当前版本」的单提交快照。
供应商系统后续开发自本提交开始。
2026-10-08 17:35:43 +08:00

89 lines
3.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 助手框架冻结(权限 × 端 × 服务端模块路由)
日期:2026-09-03
承接 [能力目录](./20260903-capability-registry.md)。本文把契约冻死,避免加配送/小程序时推翻。
## 目标 / 非目标
### 目标
- 任意已登录账号可开助手壳(含供应商门户);能力仍按权限与端过滤。
- 服务端路由选出 1~2 个助手模块,专员 Host 只带这些模块的工具。
- 写操作确认只能来自用户动作,不进模型可见 schema。
- UI 意图端无关;本期小程序只认协议、不交对话页。
### 非目标
- 不把 Web `BUSINESS_MODULES.id` 当助手模块主键。
- 不做成 `load_modules` 工具。
- 不登记财务/配送 handler(可有空摘要占位)。
- 不改销售价/成本口径、订单状态机、`/api/data` 任意 SQL。
## 方案要点
```
登录用户 → 权限×端过滤可见模块 → routeModules(text, visible, hint) → 专员 Host(仅这些工具)
```
### 助手模块
稳定 id:`navigate`、`order-entry`。可选 `webMenuKeys` / `mpPage` 对齐两端。
可见规则:本端该模块里至少有一条该用户有权限的能力。
### 开壳
`GET/POST /api/mcp/order-entry/*` 只要求 JWT。去掉录单权限门槛。
### 确认闸
`toToolSchema` 不暴露 `confirm`。写操作等请求体 `confirmed_action_id` 与能力名一致时由服务端注入后再进 handler。模型传入的 `confirm` 一律丢弃。
Web / 小程序专员工具不含 `submit_order`;Web 下单仍走录单页确认 + `POST /orders/submit`。
### 表面
`web` | `miniprogram` | `api`。`web_fab` 仅作兼容别名,映射为 `web`。
### UI 意图
`{ type, web?: { path }, miniprogram?: { page }, payload, ... }`。壳各自执行。
控当前页用通用契约(`describe_page` / `set_page_fields` / `run_page_action`),见 [20260903-copilot-page-contract.md](./20260903-copilot-page-contract.md)。不要一面一套 `patch_*` 工具。
### 路由
`routeModules(text, visibleModules, hintModule) → ids`:本期关键词 + 粘滞。禁止模型选工具集。
## 改动面
- 本文、`docs/design/README.md`、`docs/API.md`
- `server/src/capabilities/*`
- `server/src/mcp/orderEntryAgentHost.ts`、`orderEntryTools.ts`、`routes/orderEntryAgent.ts`
- Web 助手壳
## 验收标准
- [x] 已登录即可 chat;无 `order_entry` 不能 parse
- [x] 「给某客户录土豆」路由到 `order-entry`
- [x] 模型 schema 无 `confirm`;仅 `confirmed_action_id` 可放行写操作
- [x] `web` / `miniprogram` 无 `submit_order`
- [x] 供应商账号能开壳但 parse 仍 forbidden
## 验证
- [x] `need_confirm` 忽略模型传入的 `confirm: true`
- [x] `modules: []` 时 Host 工具为空;`navigate` 专员无 parse
- [x] 无 `order-entry` 可见时关键词不路由到录单
- [x] 粘滞 hint 跟进「改成20斤」
- [x] FAB 已登录即可见
- [ ] 浏览器对话缺客户时会追问(需登录与模型)
偏差:无。
## 风险与回滚
路由关键词漏选模块:用户换说法或回传 `hint_module`。回滚 Host 可临时挂全量已授权工具(仍禁止 confirm 进 schema)。