Files
SupplierSystem/docs/mcp/order-parse-tools.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

83 lines
3.3 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.
# 录单解析 MCP 工具草稿
**状态:** 合同草稿。仓库内**没有** MCP server;本文对齐现有 HTTP,供以后挂 Cursor / 内部 MCP。
分层见 [../design/20260903-order-parse-layers.md](../design/20260903-order-parse-layers.md)。
权限:functions 类需登录且满足 `order_entry`(超管除外),见 `server/src/routes/functions.ts`。
不要做成独立工具:`parse-image-order`、`parse-voice-order`(同一编排的瘦包装)。不要暴露内部 SQL。
## transcribe_audio
听写,不做 SKU 匹配。
| 项 | 值 |
|---|---|
| HTTP | `POST /api/functions/transcribe-audio` |
| 实现 | `transcribeVoiceAudio` → `transcribeAudioBase64` |
| 入参 | `audioBase64`(必填);`audioFormat`(缺省按实现视为 `ogg`) |
| 出参 | `{ text, durationMs? }` |
| 副作用 | 无落库 |
| Web | 停录写入文字框,不自动拆条 |
| 小程序 | 产品路径通常把音频交给 `parse_order`,不单独调本工具 |
## parse_order
采集 + 拆条 + 匹配一次走完。产品主命令。
| 项 | 值 |
|---|---|
| HTTP(Web) | `POST /api/functions/parse-order-three-layer` |
| HTTP(小程序) | `POST /api/mobile/customer-order/parse` |
| 实现 | `parseOrderThreeLayer` |
| 入参 | `customerCode`(必填);`text` / `imageBase64` / `audioBase64` 至少一种;`audioFormat`;`includeParseCategory`(Web 传 `true`) |
| 优先级 | 图片 > 音频 > 文字 |
| 拆条 | 图 → `order.parse.image`;文与语音转写 → `order.parse.text` |
| 匹配 | `fourLayerParse` + `spoken-ratio` |
| 出参 | `ParseResult`:`items`、`unmatched`、`demoMode?`、`message?`、`extractedStats?` |
| 副作用 | 图片未命中缓存且有结果时异步写图片向量缓存。小程序图路径另写 `parse_sessions` |
| 缓存 | 同客户图片 SHA 命中则跳过 LLM 与匹配 |
小程序额外:解析后 `enrichParsedCustomerOrderItems` + 报价;默认 `audio_format=mp3`。
## learn_alias
确认后写入客户别名,**不在拆条内调用**。
| 项 | 值 |
|---|---|
| HTTP | `POST /api/functions/learn-alias` |
| 实现 | `learnAlias` |
| 入参 | `customerCode`;`items[]`(`originalName`、`skuCode`、`skuName`) |
| 出参 | `{ learned }` |
| 副作用 | `INSERT customer_sku_aliases … ON CONFLICT DO NOTHING` |
| 生产 | `customerOrderSubmitService` 提交时调用(失败非阻塞) |
## sync_customer_mappings
确认后同步客户商品映射(及可选目录)。
| 项 | 值 |
|---|---|
| HTTP | `POST /api/functions/sync-customer-mappings` |
| 实现 | `syncCustomerMappings` |
| 生产 | 提交服务 + 小程序确认后 |
## resolve_candidate_alias
消歧:录单员从候选 SKU 中选定一条,写入别名。
| 项 | 值 |
|---|---|
| HTTP | `POST /api/mobile/customer-order/resolve-candidate` |
| 实现 | `resolveCandidateAlias` |
| 入参 | `customer_code`、`original_name`、`sku_code`、`sku_name` |
## 兼容 HTTP(非 MCP 工具)
| HTTP | 说明 |
|---|---|
| `POST /api/functions/parse-image-order` | `parseImageOrder`:映射字段 + 平均 confidence;缺客户默认 `self` |
| `POST /api/functions/parse-voice-order` | `parseVoiceOrder`:有音频则忽略 text |
脚本 `server/scripts/test-functionality.js` 仍调用上述两条。产品 Web 只用 `transcribe-audio` + `parse-order-three-layer`。