@magpie-community/opencode-qoder-auth 0.2.41 → 0.2.42
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 +26 -2
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -792,6 +792,28 @@ function callID(at, k, c) {
|
|
|
792
792
|
return "call_" + createHash("sha256").update(`${at}\0${k}\0${c.function?.name ?? ""}\0${said}`).digest("hex").slice(0, 32)
|
|
793
793
|
}
|
|
794
794
|
|
|
795
|
+
// reasoningOf is the thinking an assistant turn of the chat carries back:
|
|
796
|
+
// reasoning_content (DeepSeek's spelling, which magpie and most clients
|
|
797
|
+
// send), else reasoning (OpenRouter's), else reasoning_details' text, ""
|
|
798
|
+
// when it carries none.
|
|
799
|
+
function reasoningOf(m) {
|
|
800
|
+
let text = ""
|
|
801
|
+
for (const k of ["reasoning_content", "reasoning"]) if (!text && typeof m[k] === "string") text = m[k]
|
|
802
|
+
if (!text && Array.isArray(m.reasoning_details)) text = m.reasoning_details.map((d) => (typeof d?.text === "string" ? d.text : typeof d?.summary === "string" ? d.summary : "")).join("")
|
|
803
|
+
// A blank one (magpie's gateway sends " " for a tool turn with no
|
|
804
|
+
// thinking) is no thinking at all.
|
|
805
|
+
return text.trim() ? text : ""
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
// An assistant turn's thinking goes back in reasoning_content, as Qoder's
|
|
809
|
+
// own client sends it (qoder-agent-sdk, Qoder.app 0.x: its converter sets
|
|
810
|
+
// reasoning_content on every earlier assistant turn that had thinking).
|
|
811
|
+
// It was left out from the plugin's first version on, so a model behind
|
|
812
|
+
// Qoder never saw what it had thought on the turns before (uk.jent on
|
|
813
|
+
// Discord): on Qoder, DeepSeek-V4-Pro in a tool loop now recalls what its
|
|
814
|
+
// thinking before the call said, and said it had none without it. A turn
|
|
815
|
+
// with thinking and nothing else is still left out, as that client leaves
|
|
816
|
+
// it.
|
|
795
817
|
function qoderMessages(msgs) {
|
|
796
818
|
const out = []
|
|
797
819
|
const names = {}
|
|
@@ -850,7 +872,8 @@ function qoderMessages(msgs) {
|
|
|
850
872
|
const args = c.function?.arguments
|
|
851
873
|
return { id, type: "function", function: { name: c.function?.name, arguments: typeof args === "string" ? args : JSON.stringify(args ?? {}) } }
|
|
852
874
|
})
|
|
853
|
-
|
|
875
|
+
const think = reasoningOf(m)
|
|
876
|
+
out.push({ role: "assistant", content: textOf(m.content), ...(think ? { reasoning_content: think } : {}), tool_calls: calls })
|
|
854
877
|
const open = calls.map((c) => c.id)
|
|
855
878
|
const kept = new Set()
|
|
856
879
|
for (let j = i + 1; j < msgs.length && msgs[j].role === "tool"; j++) {
|
|
@@ -864,7 +887,8 @@ function qoderMessages(msgs) {
|
|
|
864
887
|
if (m.role === "assistant") blocks = blocks.filter((b) => b.type === "text")
|
|
865
888
|
if (!blocks.length) continue
|
|
866
889
|
if (m.role === "user" && seen.length) [blocks, seen] = [[...seen, ...blocks], []]
|
|
867
|
-
|
|
890
|
+
const think = m.role === "assistant" ? reasoningOf(m) : ""
|
|
891
|
+
out.push({ role: m.role, content: blocks, ...(think ? { reasoning_content: think } : {}) })
|
|
868
892
|
// a result after the assistant's own words answers no call before it
|
|
869
893
|
turn = null
|
|
870
894
|
}
|
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.42",
|
|
4
4
|
"description": "Qoder and QwenWork (千问办公) subscriptions in OpenCode and magpie: qoder.com, qoder.cn, gateway.qwenwork.cn and the enterprise flagship (VPC)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.mjs",
|