@magpie-community/opencode-qoder-auth 0.2.81 → 0.2.82
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/index.mjs +29 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -215,7 +215,8 @@ itself.
|
|
|
215
215
|
| A quota (codes 110, 112–119, 122) | 429 |
|
|
216
216
|
| A model the account's listing has off while its usage says no credits are left (since 0.2.64, #880) | 429 usage limit reached, with the credits used and the model; a model off with credits left, or whose usage can't be read, stays 400 `unknown or disabled model`, and an id Qoder never served is that 400 at once |
|
|
217
217
|
| Busy or queued for the model (code 10605) | Since 0.2.28 the request waits in Qoder's queue as Qoder's client does (below), then is sent again; since 0.2.62 a streamed request is answered 200 at once and kept alive with SSE comments for up to an hour (since 0.2.71, 5 minutes when the queue hasn't moved with nothing ahead), its outcome in the stream; past the wait, 503 with `Retry-After` from Qoder's `retryAfterSeconds` (30s when it gives none). Since 0.2.40, when magpie has another candidate after this request (`x-magpie-fallback: 1`), the 503 comes at once, saying the queue and how many are ahead, and magpie asks the next. The sign-in is untouched |
|
|
218
|
-
|
|
|
218
|
+
| Qoder's content safety check refusing the conversation (an HTTP 406 such as "Session blocked, Please clear context try again", or code 406) | Since 0.2.82, 400 with error type `content_filter` and code 406, Qoder's words first: magpie reads it as a refusal of the content, asks the next candidate as its refusal setting allows, and rests no account. The plugin asks Qoder once, and the sign-in is untouched |
|
|
219
|
+
| A refusal of the request itself (codes 416, 430, 80411, 80412, 100400–100403) | 400, with Qoder's words |
|
|
219
220
|
| "Error in upstream response", the model's own vendor behind Qoder failing, which Qoder sends as a 400 (since 0.2.24) | 502, so magpie asks again or another account; the sign-in is untouched |
|
|
220
221
|
| "Range of max_tokens should be [1, N]" behind "Error in upstream response" (since 0.2.63) | Asked again once with max_tokens N, which later requests for that model are sent from the start; refused again, 400 with Qoder's words, the sign-in untouched. QoDuck (`lmodel`) is never sent more than 131072, and a model whose listing entry names `max_output_tokens` never more than that; a smaller max_tokens goes as asked |
|
|
221
222
|
| A failure before the answer starts | Qoder's status |
|
package/index.mjs
CHANGED
|
@@ -1708,6 +1708,18 @@ const QUOTA_CODES = new Set(["110", "112", "113", "114", "115", "116", "117", "1
|
|
|
1708
1708
|
// refusals of this request, not of the account: sensitive content, not
|
|
1709
1709
|
// supported, input too long, too many media, a custom model's service
|
|
1710
1710
|
const REQUEST_CODES = new Set(["406", "416", "430", "80411", "80412", "100400", "100401", "100403"])
|
|
1711
|
+
// SENSITIVE is Qoder's content safety check refusing the conversation: its
|
|
1712
|
+
// code 406, or an HTTP 406 whose body names no other code of Qoder's
|
|
1713
|
+
// ("Session blocked, Please clear context try again"). Qwen Code, Qoder's
|
|
1714
|
+
// own CLI on the same backend, reads an HTTP 406 as content filtered
|
|
1715
|
+
// (errorPresentation.ts, CONTENT_FILTERED_MESSAGE), and its maintainers
|
|
1716
|
+
// confirm it is a content-safety rejection that asking again in the same
|
|
1717
|
+
// conversation doesn't clear (QwenLM/qwen-code#16915). It goes to magpie
|
|
1718
|
+
// as its content_filter convention (plugins#1264): a 400 whose error type
|
|
1719
|
+
// is content_filter, Qoder's 406 kept as the code, so magpie's routing
|
|
1720
|
+
// decides whether another candidate is asked (its RefusalRetries) and
|
|
1721
|
+
// rests no account; as a plain 400 or 406 the group ended at it.
|
|
1722
|
+
const SENSITIVE = "406"
|
|
1711
1723
|
const BUSY_WAIT = 30
|
|
1712
1724
|
// UPSTREAM_FAILED is Qoder saying the model's own vendor behind it failed:
|
|
1713
1725
|
// "Error in upstream response", which Qoder sends as a 400 (SlouchyQuill507
|
|
@@ -1762,6 +1774,14 @@ function failure(status, text) {
|
|
|
1762
1774
|
return { status: 503, message: `Qoder ${what}${model}${tier}; try again in ${wait}s`, retryAfter: wait, signIn: "", queue: queue ?? {} }
|
|
1763
1775
|
}
|
|
1764
1776
|
if (QUOTA_CODES.has(code)) return { status: 429, message: "usage limit reached: " + msg, signIn: "" }
|
|
1777
|
+
if (code === SENSITIVE || (status === 406 && !/^\d+$/.test(code)))
|
|
1778
|
+
return {
|
|
1779
|
+
status: 400,
|
|
1780
|
+
message: `${msg} — Qoder's content safety check refused this conversation (406); sent again with the same history it is refused again, so start a new conversation`,
|
|
1781
|
+
signIn: "",
|
|
1782
|
+
type: "content_filter",
|
|
1783
|
+
code: 406,
|
|
1784
|
+
}
|
|
1765
1785
|
if (REQUEST_CODES.has(code)) return { status: 400, message: `Qoder refused the request (${code}): ${msg}`, signIn: "" }
|
|
1766
1786
|
// a max_tokens above the model's ceiling, said behind "Error in upstream
|
|
1767
1787
|
// response": the request's fault on every account, so a 400 that rests
|
|
@@ -1795,9 +1815,11 @@ function failure(status, text) {
|
|
|
1795
1815
|
// errorResponse is a failure as OpenAI's API gives it. signIn is what it
|
|
1796
1816
|
// means for the account (magpie's X-Magpie-Sign-In): a 401 keeps it unless
|
|
1797
1817
|
// told expired, since the built-in marked only a refused refresh. retryAfter
|
|
1798
|
-
// (seconds) is sent as Retry-After.
|
|
1799
|
-
|
|
1800
|
-
|
|
1818
|
+
// (seconds) is sent as Retry-After. type and code, when failure names them
|
|
1819
|
+
// (a content refusal's content_filter and 406), go in place of qoder_error
|
|
1820
|
+
// and the status.
|
|
1821
|
+
const errorResponse = ({ status, message, signIn = status === 401 ? "kept" : undefined, retryAfter, type = "qoder_error", code = status }) =>
|
|
1822
|
+
new Response(JSON.stringify({ error: { message, type, code } }), {
|
|
1801
1823
|
status,
|
|
1802
1824
|
headers: {
|
|
1803
1825
|
"Content-Type": "application/json",
|
|
@@ -2800,7 +2822,10 @@ async function answer({ it, first }, chat, servedName = chat.model) {
|
|
|
2800
2822
|
else if (e.args) ctl.enqueue(chunk({ tool_calls: [{ index: e.args.index, function: { arguments: e.args.text } }] }))
|
|
2801
2823
|
else if (e.stop) ctl.enqueue(chunk({}, e.stop, e.usage ? { usage: e.usage } : {}))
|
|
2802
2824
|
else if (e.error) {
|
|
2803
|
-
|
|
2825
|
+
// a content refusal says its type here too; magpie replays nothing
|
|
2826
|
+
// once the answer has begun
|
|
2827
|
+
const { message, status, type, code = status } = e.error
|
|
2828
|
+
ctl.enqueue(enc.encode(`data: ${JSON.stringify({ error: { message, ...(type ? { type } : {}), code } })}\n\n`))
|
|
2804
2829
|
ctl.close()
|
|
2805
2830
|
}
|
|
2806
2831
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magpie-community/opencode-qoder-auth",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.82",
|
|
4
4
|
"description": "Qoder and QwenWork (千问办公) subscriptions in OpenCode and magpie: qoder.com, qoder.cn, gateway.qwenwork.cn and the enterprise flagship, VPC and dedicated domains",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./opencode.mjs",
|