@magpie-community/opencode-qoder-auth 0.2.53 → 0.2.55
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 +16 -1
- package/index.mjs +55 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -138,7 +138,10 @@ itself.
|
|
|
138
138
|
- The model's own configuration from Qoder's list goes with it.
|
|
139
139
|
- It picks the reasoning effort from the model's own levels:
|
|
140
140
|
- The nearest level to the one asked, the higher one on a tie.
|
|
141
|
-
- The model's default when none is asked
|
|
141
|
+
- The model's default when none is asked, unless the request's
|
|
142
|
+
`max_tokens` is 1024 or less: that is asked as "none" (since 0.2.55,
|
|
143
|
+
plugins#643), since thinking would spend so small a budget on
|
|
144
|
+
reasoning alone.
|
|
142
145
|
- The lowest level for "none", when the model can't turn thinking off.
|
|
143
146
|
- It picks the context window (`context_length`) from the model's own
|
|
144
147
|
windows (Qoder's Context setting: 200K, 400K, 1M): the default while the
|
|
@@ -209,6 +212,18 @@ name remain independently selectable. The name describes the catalog
|
|
|
209
212
|
entry used for the request, not an attestation of the backend that
|
|
210
213
|
executed it.
|
|
211
214
|
|
|
215
|
+
A request's `model_config` is built as Qoder's own client builds it
|
|
216
|
+
(Qoder CN's CLI 1.1.81, desktop 0.4.3), not sent as the listing entry
|
|
217
|
+
(since 0.2.54): `key`, `display_name`, an empty `model`, `format`,
|
|
218
|
+
`is_vl`, `is_reasoning` (off when thinking is turned off), empty
|
|
219
|
+
`api_key` and `url`, `source` and `max_input_tokens`. The entry's
|
|
220
|
+
`minimal_version`, `strategies`, prices and `thinking_config` are not
|
|
221
|
+
sent. While the whole entry was sent, Qoder CN billed DeepSeek-Flash
|
|
222
|
+
(`dfmodel`, whose entry has a `minimal_version`) as Auto at Auto's rate
|
|
223
|
+
(plugins#638); that the entry was the cause has not been confirmed on a
|
|
224
|
+
Qoder CN account. A model whose entry has no key of its own, or whose key is
|
|
225
|
+
`auto`, is refused with a 400 and nothing is sent, never served as Auto.
|
|
226
|
+
|
|
212
227
|
The `provider.models` hook reads the account's own list, as Qoder's client
|
|
213
228
|
asks for it (`/algo/api/v2/model/list`). It keeps the enabled models of the
|
|
214
229
|
listing's `app` scene, the list Qoder's app shows and the one a request
|
package/index.mjs
CHANGED
|
@@ -898,12 +898,24 @@ function fitEffort(want, levels) {
|
|
|
898
898
|
return best
|
|
899
899
|
}
|
|
900
900
|
|
|
901
|
+
// SMALL_BUDGET is the largest max_tokens a request can name and still be
|
|
902
|
+
// one no client meant to think in: Anthropic's API takes thinking only with
|
|
903
|
+
// a budget of at least 1024 tokens and a max_tokens above it, and a client's
|
|
904
|
+
// own short asks (a session title, a classification) name such budgets.
|
|
905
|
+
// Thinking by default spends them on reasoning: on WorkBuddy, a title asked
|
|
906
|
+
// at 64 tokens ended "length" with 64 reasoning tokens and no text
|
|
907
|
+
// (plugins#643, itspig).
|
|
908
|
+
const SMALL_BUDGET = 1024
|
|
909
|
+
|
|
901
910
|
// effortFor is whether to think and at which of the model's efforts ("" for
|
|
902
911
|
// none): asked for none, a model that always thinks thinks at its lowest;
|
|
903
|
-
// asked for nothing, or a level Qoder doesn't name, at its own default
|
|
904
|
-
|
|
912
|
+
// asked for nothing, or a level Qoder doesn't name, at its own default —
|
|
913
|
+
// unless the request's own budget (max_tokens, 0 when it named none) is
|
|
914
|
+
// SMALL_BUDGET or less, which is asked as none.
|
|
915
|
+
function effortFor(asked, m, budget = 0) {
|
|
905
916
|
let want = String(asked ?? "").toLowerCase()
|
|
906
917
|
if (!EFFORT_RANK.includes(want)) want = ""
|
|
918
|
+
if (want === "" && budget > 0 && budget <= SMALL_BUDGET) want = "none"
|
|
907
919
|
if (!m.thinks || (want === "none" && !m.alwaysThinks)) return [false, ""]
|
|
908
920
|
if (!m.efforts.length) return [true, ""]
|
|
909
921
|
if (want === "") return [true, m.defaultEffort]
|
|
@@ -1224,6 +1236,38 @@ function typedUnions(schema) {
|
|
|
1224
1236
|
return root
|
|
1225
1237
|
}
|
|
1226
1238
|
|
|
1239
|
+
// modelConfig is the model_config a request carries for model m, built as
|
|
1240
|
+
// Qoder's own client builds it (Qoder CN's CLI 1.1.81 and desktop 0.4.3,
|
|
1241
|
+
// the qoder-agent-sdk worker's model resolution): the listing entry's key,
|
|
1242
|
+
// name, format, image and reasoning flags, source and input size, with an
|
|
1243
|
+
// empty model, api_key and url, and is_reasoning off when thinking is.
|
|
1244
|
+
// Never the listing entry as it came: that also holds minimal_version,
|
|
1245
|
+
// strategies, prices and thinking_config, which no client sends. While it
|
|
1246
|
+
// was sent whole, Qoder CN billed DeepSeek-Flash (dfmodel, whose entry
|
|
1247
|
+
// carries a minimal_version) as Auto at Auto's rate, and Kimi-K3.1-Pro
|
|
1248
|
+
// (none) as itself (magpie-community/plugins#638, square-235); the entry
|
|
1249
|
+
// is the likely cause, not confirmed on a Qoder CN account.
|
|
1250
|
+
// A model with no key of its own is refused: Qoder's worker sends a
|
|
1251
|
+
// request with none as "auto", which is never what was asked for.
|
|
1252
|
+
function modelConfig(m, thinking) {
|
|
1253
|
+
const raw = m.config ?? {}
|
|
1254
|
+
const key = String(raw.key ?? m.key ?? "").trim()
|
|
1255
|
+
if (!key || ["auto", "default"].includes(key) || key !== m.key) throw new Error(`no Qoder model key for "${m.key ?? ""}"`)
|
|
1256
|
+
const max = Number.isInteger(raw.max_input_tokens) && raw.max_input_tokens > 0 ? raw.max_input_tokens : 200_000
|
|
1257
|
+
return {
|
|
1258
|
+
key,
|
|
1259
|
+
display_name: raw.display_name || key,
|
|
1260
|
+
...(raw.outer_provider ? { outer_provider: raw.outer_provider } : { model: "" }),
|
|
1261
|
+
format: raw.format ?? "openai",
|
|
1262
|
+
is_vl: !!raw.is_vl,
|
|
1263
|
+
is_reasoning: !!raw.is_reasoning && thinking,
|
|
1264
|
+
api_key: "",
|
|
1265
|
+
url: "",
|
|
1266
|
+
source: raw.source || "system",
|
|
1267
|
+
max_input_tokens: max,
|
|
1268
|
+
}
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1227
1271
|
// qoderBody is the plaintext agent_chat_generation takes for a chat
|
|
1228
1272
|
// completion request, for model m, in the session the agent named (named,
|
|
1229
1273
|
// "" when none) and the task it is a call of (taskOf's, a new one when
|
|
@@ -1236,7 +1280,8 @@ function qoderBody(chat, m, named = "", task, site) {
|
|
|
1236
1280
|
let sysText = system ? baseSystem + "\n\n" + system : baseSystem
|
|
1237
1281
|
if (chat.tool_choice === "required" && tools.length) sysText += "\nYou must call an available function in this response."
|
|
1238
1282
|
const sys = { type: "text", text: sysText }
|
|
1239
|
-
const
|
|
1283
|
+
const budget = chat.max_completion_tokens || chat.max_tokens || 0
|
|
1284
|
+
const [thinking, effort] = effortFor(chat.reasoning_effort, m, typeof budget === "number" ? budget : 0)
|
|
1240
1285
|
const params = { enable_thinking: thinking, max_tokens: chat.max_completion_tokens || chat.max_tokens || 32000 }
|
|
1241
1286
|
if (effort) params.reasoning_effort = effort
|
|
1242
1287
|
const window = windowFor(chat, m, params.max_tokens)
|
|
@@ -1254,7 +1299,7 @@ function qoderBody(chat, m, named = "", task, site) {
|
|
|
1254
1299
|
agent_id: "agent_common",
|
|
1255
1300
|
task_id: "common",
|
|
1256
1301
|
session_type: site?.sessionType ?? "app",
|
|
1257
|
-
model_config: m
|
|
1302
|
+
model_config: modelConfig(m, thinking),
|
|
1258
1303
|
system: [sys],
|
|
1259
1304
|
messages: [{ role: "system", content: [sys] }, ...cacheMarked(qoderMessages(chat.messages ?? []))],
|
|
1260
1305
|
}
|
|
@@ -3058,7 +3103,12 @@ const makePlugin = (site) => async ({ client }) => {
|
|
|
3058
3103
|
const api = siteOf(site, cred).api
|
|
3059
3104
|
const CHAT_URL = api + CHAT_PATH
|
|
3060
3105
|
const task = taskOf(sessionOf(chat, named), chat)
|
|
3061
|
-
|
|
3106
|
+
let body
|
|
3107
|
+
try {
|
|
3108
|
+
body = qoderBody(chat, m, named, task, siteOf(site, cred))
|
|
3109
|
+
} catch (e) {
|
|
3110
|
+
return errorResponse({ status: 400, message: e?.message ?? String(e) })
|
|
3111
|
+
}
|
|
3062
3112
|
// Qoder's queue is waited out (queueWait) and the request sent again
|
|
3063
3113
|
// under the request_set_id the queue knows, with a new request_id and
|
|
3064
3114
|
// chat_record_id, as Qoder's client sends it (its o4i before each
|
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.55",
|
|
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": "./index.mjs",
|