@magpie-community/opencode-cursor-auth 0.1.10 → 0.1.11
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 -1
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -954,6 +954,26 @@ function statusOf(status, code, msg) {
|
|
|
954
954
|
const textOf = (c) =>
|
|
955
955
|
typeof c === "string" ? c : Array.isArray(c) ? c.filter((p) => p?.type === "text").map((p) => p.text ?? "").join("") : ""
|
|
956
956
|
|
|
957
|
+
// joinSplitCalls joins an assistant message onto the assistant message
|
|
958
|
+
// before it when that one made tool calls: Anthropic takes consecutive
|
|
959
|
+
// assistant messages as one turn, and an agent can send a turn's parallel
|
|
960
|
+
// calls split over two of them, answered together after (yetone/magpie#1275).
|
|
961
|
+
// Answered at the second message, the first calls would be marked
|
|
962
|
+
// interrupted and their real results dropped. msgs is left as it is.
|
|
963
|
+
function joinSplitCalls(msgs) {
|
|
964
|
+
const out = []
|
|
965
|
+
for (const m of msgs) {
|
|
966
|
+
const prev = out.at(-1)
|
|
967
|
+
if (m?.role === "assistant" && prev?.role === "assistant" && prev.tool_calls?.length) {
|
|
968
|
+
const content = [textOf(prev.content), textOf(m.content)].filter(Boolean).join("\n\n")
|
|
969
|
+
out[out.length - 1] = { ...prev, content, tool_calls: [...prev.tool_calls, ...(m.tool_calls ?? [])] }
|
|
970
|
+
continue
|
|
971
|
+
}
|
|
972
|
+
out.push(m)
|
|
973
|
+
}
|
|
974
|
+
return out
|
|
975
|
+
}
|
|
976
|
+
|
|
957
977
|
function parseArgs(s) {
|
|
958
978
|
if (s && typeof s === "object") return s
|
|
959
979
|
try {
|
|
@@ -1035,7 +1055,7 @@ function conversation(chat, tools) {
|
|
|
1035
1055
|
if (results.length) add({ role: "tool", content: results })
|
|
1036
1056
|
results = []
|
|
1037
1057
|
}
|
|
1038
|
-
for (const m of chat.messages ?? []) {
|
|
1058
|
+
for (const m of joinSplitCalls(chat.messages ?? [])) {
|
|
1039
1059
|
if (m.role === "system" || m.role === "developer") continue
|
|
1040
1060
|
if (m.role === "tool") {
|
|
1041
1061
|
const id = m.tool_call_id ?? ""
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magpie-community/opencode-cursor-auth",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.11",
|
|
4
4
|
"description": "Cursor subscriptions (Pro, Pro+, Ultra, Teams) in OpenCode and magpie, through the API cursor-agent talks to",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.mjs",
|