Commit Graph

3 Commits

Author SHA1 Message Date
GitHub Actions
1c7b86e2c0 feat: bridge Lingma tool events to OpenAI/Anthropic responses
Add structured tool event propagation from Lingma stream/finish metadata and map it to OpenAI tool_calls and Anthropic tool_use/tool_result in both streaming and non-streaming responses. Add focused bridge tests and update docs/design notes to match current behavior.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-18 22:34:43 +08:00
GitHub Actions
0b08dc6573 feat: Anthropic Messages API compat (/v1/messages)
Add a wire-compatible Anthropic endpoint alongside the existing OpenAI one
so Claude Code / anthropic-sdk / Cursor Agent can hit Lingma directly.

- app/anthropic_schema.py (new): request model + content-block flattener
  + internal-messages adapter + affinity key helper. Handles text / image /
  tool_use / tool_result blocks; unknown types degrade gracefully.
- app/auth.py: add require_anthropic_key (x-api-key, Bearer fallback)
  and AnthropicAuthError so auth failures render in Anthropic's error
  envelope instead of FastAPI's {detail:...} wrapper.
- app/main.py: POST /v1/messages. Shares LingmaPool / SessionCache /
  InFlightGuard / StatsCollector with the OpenAI path — same api_key +
  same conversation prefix hits the same upstream sessionId across both
  protocols (KV cache carries over). Streaming emits the named Anthropic
  event sequence (message_start / content_block_start / content_block_delta
  / content_block_stop / message_delta / message_stop). No claude-*
  model mapping table: resolve_model's default fallback handles it.
- README.md / DESIGN.md: document the new endpoint, add decision 5.12,
  iteration history M5, and a 4.3b streaming flow diagram.
- Bump FastAPI app version to 0.4.0.

Made-with: Cursor
2026-04-18 15:40:43 +08:00
GitHub Actions
d9dffbb8ba docs: restructure README + add DESIGN.md (二开白盒手册)
README 重写为分层结构:架构速览 + 快速开始 + 按主题分组的配置表 +
API 参考 + 常用场景 + 升级注意 + 故障排查 + 二开入口。相比旧版:
更好导航,破坏性改动显式标注升级路径,故障排查能覆盖生产常见坑。

DESIGN.md 是全新的工程手册,覆盖:项目目标/非目标、组件数据流、
模块职责表、6 个核心流程的 ASCII 图解(启动、非流式/流式 chat、
子进程 + LSP、bundle、自动登录、关闭)、11 条关键设计决策
(每条带问题/方案/权衡/未选其他方案原因)、扩展指引(常见需求 → 改哪些文件)、
已知问题 / TODO、完整迭代历程(M1~M4 + M3 性能 bug 根因)、
Lingma LSP 协议速查。

目标:新成员或几个月后的自己能在一天内理清全项目。

Made-with: Cursor
2026-04-18 10:36:17 +08:00