Out of credits, 妙手's gateway answers the turn HTTP 200 with the sentence "当前余额不足以完成本次操作。[去购买更多](https://credit.catpaw.meituan.com/#/plan), 即可继续使用全部功能。" as the assistant's text, in frames with no error field and no model / modelDisplayName. The plugin only read `error`, so the agent got the sentence as the model's answer (and with tools, the forced-tool retry spent a second turn on it). Now a frame that names no model and whose text, before anything was streamed, starts with "当前余额不足以完成本次操作" is the credit gate: the request fails 402 with {type: insufficient_quota, code: insufficient_credits, help_url, upstream_message}, the message with the markdown link spelled out as "去购买更多 (https://…)". magpie's gateway reads a 402 as failCredit: the account rests for credit and the next one is tried, not counted as broken. A head that could still grow into the sentence ("当前", "当前余额") is held until it does or doesn't; a model's answer quoting the sentence names its model and passes as text. "余额不足" in a round's msg, an SSE error frame or a non-200 body is a 402 too. Streaming requests now wait for the conversation's first event (up to 10s) before answering, so the 402, and a round or turn's bare 429 / 401, go out as their own status instead of an error chunk inside a 200. A slower turn streams as before. The bare 429 now says it is 妙手's rate limit with Retry-After: 45 (the reporter saw a ~41s cool-down), the bare 401 that the sign-in has expired; both keep the step and status. The fixture (testdata/issue-933.json) is the reporter's frames as the issue quotes them; the elided finishing frame is filled in, and the model fields of a normal answer are made up (the issue doesn't quote their values). Run in WSL (magpie-desktop) via wsl-run at this tree: - bun test packages/catpaw: 73 pass, 0 fail - bun scripts/check.mjs: exit 0, catpaw ✓ Broken by hand, each red, then restored: - no gate throw: 4 of the new tests red (both 402 paths, tools, split) - gate without the no-model condition: the quoting test red - plain stream not primed: 402-before-streaming, split and 429 red - tool stream not primed: the tools 402 and the 401 test red - held head never flushed: the held-head test red - 429 not mapped: the 429 test red Not tried: no real CatPaw account, so neither the gate nor the bare 429/401 was met against the real gateway; the 409/400 mapping the issue suggests for "会话未在执行中" is not done. Reported-by: LIEGU0317
29 lines
769 B
JSON
29 lines
769 B
JSON
{
|
|
"name": "@magpie-community/opencode-catpaw-auth",
|
|
"version": "0.2.2",
|
|
"description": "OpenCode & Magpie provider plugin for Meituan's 妙手 CatPaw (ai.catpaw.meituan.com): web sign-in or the desktop client's saved credentials, chat through the round/event/turn protocol, models and credit balance",
|
|
"type": "module",
|
|
"main": "./opencode.mjs",
|
|
"exports": { ".": "./opencode2.mjs" },
|
|
"files": [
|
|
"index.mjs",
|
|
"opencode.mjs",
|
|
"opencode2.mjs",
|
|
"README.md"
|
|
],
|
|
"keywords": [
|
|
"opencode",
|
|
"opencode-plugin",
|
|
"magpie",
|
|
"catpaw",
|
|
"meituan",
|
|
"妙手"
|
|
],
|
|
"license": "MIT",
|
|
"repository": {
|
|
"type": "git",
|
|
"url": "git+https://github.com/magpie-community/plugins.git",
|
|
"directory": "packages/catpaw"
|
|
}
|
|
}
|