mirror of
https://github.com/justlovemaki/AIClient-2-API.git
synced 2026-04-26 09:55:54 +03:00
[PR #226] [MERGED] refactor(orchids): 重构 Orchids API 事件处理逻辑,添加原生工具调用支持 #307
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/AIClient-2-API-justlovemaki#307
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/justlovemaki/AIClient-2-API/pull/226
Author: @leonaii
Created: 1/13/2026
Status: ✅ Merged
Merged: 1/13/2026
Merged by: @justlovemaki
Base:
main← Head:main📝 Commits (1)
e2b7ae1refactor(orchids): 重构 Orchids API 事件处理逻辑,添加工具适配📊 Changes
1 file changed (+631 additions, -55 deletions)
View changed files
📝
src/providers/claude/claude-orchids.js(+631 -55)📄 Description
概述
重构
claude-orchids.js的事件处理逻辑,基于 Orchids 官方 API 事件流格式,实现原生工具调用支持。主要变更
1. 新增 fs_operation_response 响应机制
fs_operation_response的问题model.tool-call或coding_agent.Edit.edit.completed事件后自动发送响应2. 重构 _convertToAnthropicSSE 方法
3. 新增 model 事件处理
model.reasoning-start/delta/end- 推理事件model.tool-input-start/delta/end- 工具输入事件model.tool-call- 工具调用完成事件model.text-start/delta/end- 文本事件model.finish- 完成事件4. 新增 coding_agent 工具调用事件支持
coding_agent.Edit.edit.*- 编辑操作事件coding_agent.todo_write.*- TODO 写入事件5. 修复叠字问题
coding_agent.reasoning.*事件coding_agent.response.chunk事件output_text_delta事件6. 扩展状态跟踪
7. 优化 response_done 处理
function_call输出解析技术细节
Orchids API 事件流格式
Orchids API 使用 WebSocket 事件流,包含两类事件:
model. 事件*(低级别,用于处理)
reasoning-start/delta/end- 推理内容text-start/delta/end- 文本内容tool-input-start/delta/end- 工具输入tool-call- 工具调用完成finish- 流结束coding_agent. 事件*(高级别,大部分忽略以避免重复)
Edit.edit.*- 编辑操作(需要处理)todo_write.*- TODO 写入(需要处理)reasoning.*- 推理(忽略,与 model.reasoning 重复)response.chunk- 响应块(忽略,与 model.text 重复)事件转换映射
model.reasoning-startcontent_block_start(type: thinking)model.reasoning-deltacontent_block_delta(type: thinking_delta)model.reasoning-endcontent_block_stopmodel.text-startcontent_block_start(type: text)model.text-deltacontent_block_delta(type: text_delta)model.text-endcontent_block_stopmodel.tool-input-startcontent_block_start(type: tool_use)model.tool-input-deltacontent_block_delta(type: input_json_delta)model.tool-callcontent_block_stopmodel.finishmessage_delta+message_stop测试
node --check)相关 Issue
解决 Orchids 服务无法正确处理工具调用的问题。
变更文件
src/providers/claude/claude-orchids.js(+631, -55)🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.