@magpie-community/opencode-qoder-auth 0.2.68 → 0.2.69
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 +15 -4
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -1200,7 +1200,18 @@ function reasoningOf(m) {
|
|
|
1200
1200
|
// thinking before the call said, and said it had none without it. A turn
|
|
1201
1201
|
// with thinking and nothing else is still left out, as that client leaves
|
|
1202
1202
|
// it.
|
|
1203
|
-
|
|
1203
|
+
// Kimi on QwenWork (kimi-k3.1-pro) answers 400 "Error in upstream response"
|
|
1204
|
+
// to an assistant turn with tool_calls and an empty content, which is how
|
|
1205
|
+
// every OpenAI client records a call-only turn (nanfei892, #1213: 9-token
|
|
1206
|
+
// bodies, DeepSeek, GLM and Qwen on the same account fine, " " served).
|
|
1207
|
+
// QwenWork's own client always writes text beside a call. A Kimi model's
|
|
1208
|
+
// call-only turn carries one space; other models get the turn as written.
|
|
1209
|
+
function kimiModel(m) {
|
|
1210
|
+
const key = String(m?.key ?? "")
|
|
1211
|
+
return /^kmodel/i.test(key) || /kimi/i.test(key + " " + (m?.config?.display_name ?? "") + " " + (m?.name ?? ""))
|
|
1212
|
+
}
|
|
1213
|
+
|
|
1214
|
+
function qoderMessages(msgs, opts = {}) {
|
|
1204
1215
|
const out = []
|
|
1205
1216
|
const names = {}
|
|
1206
1217
|
let seen = []
|
|
@@ -1259,7 +1270,7 @@ function qoderMessages(msgs) {
|
|
|
1259
1270
|
return { id, type: "function", function: { name: c.function?.name, arguments: typeof args === "string" ? args : JSON.stringify(args ?? {}) } }
|
|
1260
1271
|
})
|
|
1261
1272
|
const think = reasoningOf(m)
|
|
1262
|
-
out.push({ role: "assistant", content: textOf(m.content), ...(think ? { reasoning_content: think } : {}), tool_calls: calls })
|
|
1273
|
+
out.push({ role: "assistant", content: textOf(m.content) || (opts.callText ?? ""), ...(think ? { reasoning_content: think } : {}), tool_calls: calls })
|
|
1263
1274
|
const open = calls.map((c) => c.id)
|
|
1264
1275
|
const kept = new Set()
|
|
1265
1276
|
for (let j = i + 1; j < msgs.length && msgs[j].role === "tool"; j++) {
|
|
@@ -1522,7 +1533,7 @@ function qoderBody(chat, m, named = "", task, site) {
|
|
|
1522
1533
|
session_type: site?.sessionType ?? "app",
|
|
1523
1534
|
model_config: modelConfig(m, thinking),
|
|
1524
1535
|
system: [sys],
|
|
1525
|
-
messages: [{ role: "system", content: [sys] }, ...cacheMarked(qoderMessages(chat.messages ?? []))],
|
|
1536
|
+
messages: [{ role: "system", content: [sys] }, ...cacheMarked(qoderMessages(chat.messages ?? [], { callText: kimiModel(m) ? " " : "" }))],
|
|
1526
1537
|
}
|
|
1527
1538
|
if (tools.length)
|
|
1528
1539
|
body.tools = tools.map((t) => ({
|
|
@@ -4216,4 +4227,4 @@ export async function QwenWorkEnterpriseAuthPlugin({ client }) {
|
|
|
4216
4227
|
export const protocol = { makePlugin, deviceSignIn, openapi, siteOf }
|
|
4217
4228
|
|
|
4218
4229
|
// for tests
|
|
4219
|
-
export const _internal = { spentOf, OUTPUT_CAPS, LEARNED_CAPS, outputCap, fetchListing, accountIdentity, deviceRefreshBody, qwenworkClientHeaders, freeView, maskPhone, phoneLabelOf, realEmailOf, chatHeaders, machineOS, machineHostname, cosyHeaders, typedUnions, Splitter, campaignRuntime, RUNTIMES, campaignPage, campaignTarget, vpcInstance, vpcSite, dedicatedOrigin, dedicatedHost, dedicatedSite, lingmaRoots, lingmaDecode, lingmaSite, lingmaHeaders, LINGMA_MODELS, parseUsage, gfmt, when, failure, modelInfo, qoderBody, qoderMessages, cacheMarked, sessionOf, namedSession, taskOf, TASKS, TASK_MAX, TASK_IDLE, SESSION, SITES, decodeBody, events, QUEUE, queueState }
|
|
4230
|
+
export const _internal = { spentOf, OUTPUT_CAPS, LEARNED_CAPS, outputCap, fetchListing, accountIdentity, deviceRefreshBody, qwenworkClientHeaders, freeView, maskPhone, phoneLabelOf, realEmailOf, chatHeaders, machineOS, machineHostname, cosyHeaders, typedUnions, Splitter, campaignRuntime, RUNTIMES, campaignPage, campaignTarget, vpcInstance, vpcSite, dedicatedOrigin, dedicatedHost, dedicatedSite, lingmaRoots, lingmaDecode, lingmaSite, lingmaHeaders, LINGMA_MODELS, parseUsage, gfmt, when, failure, modelInfo, qoderBody, qoderMessages, kimiModel, cacheMarked, sessionOf, namedSession, taskOf, TASKS, TASK_MAX, TASK_IDLE, SESSION, SITES, decodeBody, events, QUEUE, queueState }
|
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.69",
|
|
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",
|