@magpie-community/opencode-qoder-auth 0.2.59 → 0.2.61
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/index.mjs +21 -3
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -1478,6 +1478,15 @@ function modelConfig(m, thinking) {
|
|
|
1478
1478
|
}
|
|
1479
1479
|
}
|
|
1480
1480
|
|
|
1481
|
+
// The business record also names the model: Qoder's CLI (qodercli 1.1.82,
|
|
1482
|
+
// qoder-worker-runtime v3 → snn + model_key) puts the chosen model's key
|
|
1483
|
+
// there when a prompt starts, and the server attributes the call's billing
|
|
1484
|
+
// from it. Without it Qoder and Qoder CN booked the call as Auto whatever
|
|
1485
|
+
// model_config named (plugins#692, chansee97; the same shape as #638, where
|
|
1486
|
+
// the model_config fix of 0.2.54 did not change the billing). Qoder.app
|
|
1487
|
+
// 0.4.3 and QwenWork 1.0.46 build their record without it, so a site that
|
|
1488
|
+
// ships such a client says businessModelKey: false.
|
|
1489
|
+
//
|
|
1481
1490
|
// qoderBody is the plaintext agent_chat_generation takes for a chat
|
|
1482
1491
|
// completion request, for model m, in the session the agent named (named,
|
|
1483
1492
|
// "" when none) and the task it is a call of (taskOf's, a new one when
|
|
@@ -1505,7 +1514,7 @@ function qoderBody(chat, m, named = "", task, site) {
|
|
|
1505
1514
|
chat_record_id: request,
|
|
1506
1515
|
session_id: session,
|
|
1507
1516
|
parameters: params,
|
|
1508
|
-
business: { product: site?.businessProduct ?? "app", version: site?.cosyVersion ?? COSY_VERSION, type: "agent", id: task.id, name: task.name ?? "", begin_at: task.begin, stage: task.answered ? "processing" : "start" },
|
|
1517
|
+
business: { product: site?.businessProduct ?? "app", version: site?.cosyVersion ?? COSY_VERSION, type: "agent", id: task.id, name: task.name ?? "", begin_at: task.begin, stage: task.answered ? "processing" : "start", ...(site?.businessModelKey === false ? {} : { model_key: m.key }) },
|
|
1509
1518
|
agent_id: "agent_common",
|
|
1510
1519
|
task_id: "common",
|
|
1511
1520
|
session_type: site?.sessionType ?? "app",
|
|
@@ -1600,7 +1609,16 @@ function failure(status, text) {
|
|
|
1600
1609
|
const said = msg && msg !== STATUS_CODES[status] ? ` (Qoder said ${status}: ${msg.slice(0, 300)})` : ""
|
|
1601
1610
|
return { status: 401, message: "the sign-in lapsed — sign in again" + said, lapsed: true }
|
|
1602
1611
|
}
|
|
1603
|
-
|
|
1612
|
+
// Qoder's words go with the status and code they came in, and the reply
|
|
1613
|
+
// itself when it says more than the message: a 429 that names no quota
|
|
1614
|
+
// ("All models failed", QwenWork) is not shown as an account's limit
|
|
1615
|
+
// with nothing to tell it apart (dsh, QwenWork flash)
|
|
1616
|
+
if (status === 429 || msg.toLowerCase().includes("quota")) {
|
|
1617
|
+
const raw = String(text ?? "").trim()
|
|
1618
|
+
const seen = `Qoder replied HTTP ${status}${code ? `, code ${code}` : ""}`
|
|
1619
|
+
const body = raw && raw !== msg ? `: ${raw.slice(0, 400)}` : ""
|
|
1620
|
+
return { status: 429, message: `usage limit reached: ${msg} (${seen}${body})` }
|
|
1621
|
+
}
|
|
1604
1622
|
return { status, message: msg }
|
|
1605
1623
|
}
|
|
1606
1624
|
|
|
@@ -2863,7 +2881,7 @@ const QWENWORK_COMMON = {
|
|
|
2863
2881
|
deviceRefreshTarget: "c",
|
|
2864
2882
|
clientHeaders: qwenworkClientHeaders,
|
|
2865
2883
|
modelScene: "qwork", listAllModels: true,
|
|
2866
|
-
clientType: "6", businessProduct: "qoder_work", sessionType: "qoder_work",
|
|
2884
|
+
clientType: "6", businessProduct: "qoder_work", sessionType: "qoder_work", businessModelKey: false,
|
|
2867
2885
|
userInfoPath: "/api/v1/adapter/user/account-context?include=user,plan,quota,page,data_sharing",
|
|
2868
2886
|
normalizeUser: v => (v?.data ?? v)?.user ?? (v?.data ?? v),
|
|
2869
2887
|
pat: false, // no /api/v1/jobToken/exchange on gateway.qwenwork.cn
|
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.61",
|
|
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",
|