Files
plugins/packages/joycode/CHANGELOG.md
T
liangmouse f653369a77 joycode 0.2.0: route models by adapterType to Chat, Responses and Messages (#464)
joycode 0.2.0 (liangmouse). Each JoyCode model is routed by the `extJson.adapterType` in its catalogue entry:
- missing/other → Chat Completions (`@ai-sdk/openai-compatible`, `chat_completions`)
- `openai-response` → Responses (`@ai-sdk/openai`, `responses_completions`)
- `anthropic` → Anthropic Messages (`@ai-sdk/anthropic`, `anthropic_completions`)

The routing matches JoyCoder.joycoder-fe 3.8.71's `buildApiHandler`. Other changes:
- Anthropic `/messages/count_tokens` gets a local 404 and nothing goes upstream, so magpie's `unsupportedCount` uses its local estimate.
- All three protocols send `language: UNKNOWN`, as JoyCode's own handlers do.
- Non-streaming JSON for Anthropic and Responses counts as success.
- `flatten` applies to chat only.
- JoyCode's extra SSE layer (`data: event:` / `data: data:`) is removed line by line as the stream arrives. Standard SSE passes through unchanged.

Reviewed and run at f1ccb2ab59b0570295264317f270b266c7a585da (on mote, macOS, Bun 1.4.2, HOME a temp dir):
- `bun test packages/joycode`: 42 pass. `node --test packages/joycode/*.test.mjs`: 42 pass. `bun scripts/check.mjs joycode`: ok.
- Broken by hand, one at a time, each went red:
  - count_tokens guard off → the count_tokens test;
  - Anthropic normalizer off → the Anthropic double-wrapped test;
  - Responses normalizer off → the Responses double-wrapped test;
  - `language` dropped → 2 tests.
- Official SDKs (`@anthropic-ai/sdk` 1.3.0, `openai` 7.45.1) read JoyCode-framed streams through the plugin's fetch, served locally and cut into 7-byte chunks:
  - `messages.stream` got the full event sequence, text "OK", `end_turn`;
  - `responses.create({stream})` got 9 events ending in `response.completed`, text "OK".
  - The same bytes without the plugin: "request ended without sending any chunks" from Anthropic and "malformed server-sent event JSON" from OpenAI.
- Upstream functionIds seen were `anthropic_completions` and `responses_completions`.

Real account: the author's run is in the PR thread and the CHANGELOG (`provider test` GPT-6 Astra 200 in 3.0s, Claude-Opus-5-hq 200 in 7.3s). Not tried here: no JoyCode account.
2026-10-29 01:12:42 +08:00

2.4 KiB
Raw Blame History

更新记录

0.2.0

  • 按 JoyCode 模型目录中的 extJson.adapterType 自动选择 Chat Completions、Responses 或 Anthropic Messages,使 /models 返回的 GPT、Claude 及其他模型都能使用正确的 SDK 和网关。
  • 请求转发支持 Request 输入,并正确清理宿主生成的鉴权头及长度/主机头。
  • Anthropic /messages/count_tokens 在插件本地返回 404,避免被转发为一次付费生成;三种协议统一携带 language。
  • 修复 Anthropic Messages 与 Responses 的正常非流式 JSON 被误判为无效响应的问题;flatten 仅用于 Chat Completions。
  • 增量还原 JoyCode 多包一层的 Anthropic 和 Responses SSE,使官方 Anthropic SDK、OpenAI SDK 及 Claude Code 能消费流式事件,同时保持标准 SSE 和跨 chunk 边界不变。

验证:42 项回归测试通过;真实 JoyCode 账号的 joycode_modelList 返回 15 个模型,覆盖 10 个 chat、4 个 openai-response 和 1 个 anthropic。最终 provider test 中,GPT-6 Astra 的 Responses 请求返回 200(3.0 秒),Claude-Opus-5-hq 的 Anthropic Messages 请求返回 200(7.3 秒)。另经 magpie 网关用官方 OpenAI SDK 和官方 Anthropic SDK 各发一条真实流式短请求,均收到完整事件和文本 OK(分别为 2.9 秒、7.6 秒)。更早一次 Claude 冷启动曾耗时 34.7 秒;分段计时显示延迟发生在上游响应头,不是插件等待完整回复后才返回。

0.1.1

  • 支持浏览器登录京东账号,自动接收并验证 JoyCode 票据,保存租户和登录类型。
  • 接入 IDE 同款额度接口,展示套餐、已用/剩余积分及有效期文字。
  • 按账号动态同步模型列表和积分消耗倍率,正确识别 0× 免费模型。
  • 补齐聊天请求所需的真实账号元数据,修复已登录却无法回复的问题。
  • 将 HTTP 200 流式响应中的裸 JSON 错误转换为明确错误,避免客户端空白等待;权限错误不再误判为登录过期。
  • 保留多轮消息与工具调用,加入 JoyCode 图标并缩短本地插件目录名。

验证:25 项回归测试通过;JoyAI-Code-1.6 的真实流式回复、工具调用往返和 magpie provider test 通过;用户确认 Claude 桌面端可使用。

0.1.0

  • 本地供应商插件原型:手动 ptKey 登录、静态模型列表、签名网关转发及可选纯文本压平模式。