Files
lobehub__lobehub/packages/builtin-tool-message/package.json
Arvin Xu 4bf7040515 ✨ feat: inject recent same-channel history & trim unsupported IM message APIs (#16608)
* ✨ feat: inject recent same-channel history & trim unsupported IM message APIs

On IM platforms without a history-read API (e.g. WeChat), the agent had no
way to answer "what did we just talk about": the system prompt told it to call
`readMessages`, which WeChat rejects with PlatformUnsupportedError, so the model
apologized instead of answering.

- Dynamic manifest: add `resolveMessageManifest` (mirrors `resolveLobeAgentManifest`)
  so the `lobe-message` tool drops APIs the current IM platform can't fulfil, in
  both the tool list and systemRole. Platforms declare `unsupportedMessageApis`
  on their PlatformDefinition; WeChat lists the ops its service throws on.
- Pre-inject recent same-channel history: for platforms that can't read history,
  surface recent topic titles + the last few user messages from the same channel
  (matched via `metadata.bot.platformThreadId`, current topic excluded) into the
  bot platform context, and stop instructing the model to call `readMessages`.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* 🐛 fix: cover all no-history IM platforms & include absent optional message APIs

Address review: Telegram/QQ also lack a readMessages API and every platform
except Discord lacks sendDirectMessage, but only WeChat was annotated — so those
bots still got the "call readMessages" guidance, skipped history pre-injection,
and were handed dead tools.

- Centralize per-platform unsupported message APIs into `PLATFORM_UNSUPPORTED_MESSAGE_APIS`
  (single source of truth), derived from each service's throws AND its absent
  optional methods (e.g. sendDirectMessage). Wire it into every limited platform
  definition: telegram, qq, slack, feishu, lark, imessage, wechat.
- WeChat now also trims sendDirectMessage; Telegram/QQ now report
  canReadHistory=false and get recent-channel-history injection.
- Add a drift-guard test that derives the real support from the service sources
  and asserts the map matches, so a service change that isn't mirrored fails CI.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* ✅ test: snapshot the full botPlatformContext prompt output

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* ♻️ refactor: inject recent channel history as structured <recent_topics> with lh topic view escape hatch

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* ♻️ refactor: inject recent topics only when opening a new topic, cap at 3

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-08-10 05:50:39 +08:00

29 lines
677 B
JSON

{
"name": "@lobechat/builtin-tool-message",
"version": "1.0.0",
"private": true,
"type": "module",
"exports": {
".": "./src/index.ts",
"./client": "./src/client/index.ts",
"./executor": "./src/executor/index.ts",
"./executionRuntime": "./src/ExecutionRuntime/index.ts"
},
"main": "./src/index.ts",
"scripts": {
"test": "vitest",
"test:coverage": "vitest --coverage --silent='passed-only'",
"test:update": "vitest -u"
},
"devDependencies": {
"@lobechat/types": "workspace:*"
},
"peerDependencies": {
"@lobehub/ui": "^5",
"antd-style": "*",
"lucide-react": "*",
"react": "*",
"react-i18next": "*"
}
}