@magpie-community/opencode-cursor-auth 0.2.6 → 0.2.7
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 +5 -1
- package/index.mjs +9 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -63,7 +63,11 @@ plugin's `fetch` answers them on Cursor's agent API:
|
|
|
63
63
|
so subagents under one session are conversations of their own. With
|
|
64
64
|
nothing naming the session, each Run has a new one.
|
|
65
65
|
- Text, thinking (`reasoning_content`) and token usage come back streamed
|
|
66
|
-
or not.
|
|
66
|
+
or not. Replayed assistant `reasoning_content` (or `reasoning`) is kept as
|
|
67
|
+
AI SDK reasoning parts in the next Run's transcript, including when a
|
|
68
|
+
caller splits parallel tool calls across assistant messages. It stays
|
|
69
|
+
separate from reply text; no thinking signature is invented.
|
|
70
|
+
Cursor's `input_tokens` counts the cached prompt too: the cache
|
|
67
71
|
read and written is taken out of it, and given as `cached_tokens` and
|
|
68
72
|
`cache_write_tokens`, so it is counted once; its reasoning tokens are
|
|
69
73
|
`reasoning_tokens`. A step that calls tools gets no usage in its Run
|
package/index.mjs
CHANGED
|
@@ -1081,6 +1081,10 @@ function statusOf(status, code, msg) {
|
|
|
1081
1081
|
const textOf = (c) =>
|
|
1082
1082
|
typeof c === "string" ? c : Array.isArray(c) ? c.filter((p) => p?.type === "text").map((p) => p.text ?? "").join("") : ""
|
|
1083
1083
|
|
|
1084
|
+
// Chat clients replay thinking beside content. Cursor's transcript blobs
|
|
1085
|
+
// use AI SDK reasoning parts; putting it in text would change its role.
|
|
1086
|
+
const reasoningOf = (m) => [m.reasoning_content, m.reasoning].find((s) => typeof s === "string" && s.trim()) ?? ""
|
|
1087
|
+
|
|
1084
1088
|
// joinSplitCalls joins an assistant message onto the assistant message
|
|
1085
1089
|
// before it when that one made tool calls: Anthropic takes consecutive
|
|
1086
1090
|
// assistant messages as one turn, and an agent can send a turn's parallel
|
|
@@ -1093,7 +1097,8 @@ function joinSplitCalls(msgs) {
|
|
|
1093
1097
|
const prev = out.at(-1)
|
|
1094
1098
|
if (m?.role === "assistant" && prev?.role === "assistant" && prev.tool_calls?.length) {
|
|
1095
1099
|
const content = [textOf(prev.content), textOf(m.content)].filter(Boolean).join("\n\n")
|
|
1096
|
-
|
|
1100
|
+
const reasoning_content = [reasoningOf(prev), reasoningOf(m)].filter(Boolean).join("\n\n")
|
|
1101
|
+
out[out.length - 1] = { ...prev, content, reasoning_content, tool_calls: [...prev.tool_calls, ...(m.tool_calls ?? [])] }
|
|
1097
1102
|
continue
|
|
1098
1103
|
}
|
|
1099
1104
|
out.push(m)
|
|
@@ -1198,9 +1203,11 @@ function conversation(chat, tools) {
|
|
|
1198
1203
|
if (m.role === "assistant") {
|
|
1199
1204
|
answer()
|
|
1200
1205
|
const content = []
|
|
1206
|
+
const reasoning = reasoningOf(m)
|
|
1207
|
+
if (reasoning) content.push({ type: "reasoning", text: reasoning })
|
|
1201
1208
|
const text = textOf(m.content)
|
|
1202
1209
|
if (text) content.push({ type: "text", text })
|
|
1203
|
-
size += text.length
|
|
1210
|
+
size += reasoning.length + text.length
|
|
1204
1211
|
for (const c of m.tool_calls ?? []) {
|
|
1205
1212
|
if (c?.type && c.type !== "function") continue
|
|
1206
1213
|
const args = parseArgs(c.function?.arguments)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magpie-community/opencode-cursor-auth",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.7",
|
|
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",
|