@magpie-community/opencode-cursor-auth 0.1.7 → 0.1.8
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 +14 -6
- package/package.json +3 -2
package/index.mjs
CHANGED
|
@@ -981,11 +981,14 @@ function toolsOf(chat) {
|
|
|
981
981
|
// catalog lists the caller's tools for the model. It sees MCP tools only
|
|
982
982
|
// through Cursor's GetDynamicTools and CallDynamicTool, and Cursor names
|
|
983
983
|
// them in a prompt of its own, which this conversation goes without:
|
|
984
|
-
// without the list the model says it has no such tool.
|
|
984
|
+
// without the list the model says it has no such tool. Each entry is
|
|
985
|
+
// written as the CallDynamicTool call itself: listed as <tool name=...>,
|
|
986
|
+
// some models (GLM-5.3) called the names bare, as tools of their own, and
|
|
987
|
+
// those calls went nowhere (#11).
|
|
985
988
|
function catalog(tools) {
|
|
986
989
|
if (!tools.length) return ""
|
|
987
|
-
let s = `\n\n<dynamic_tool_catalog>\nThe
|
|
988
|
-
for (const t of tools) s += `<
|
|
990
|
+
let s = `\n\n<dynamic_tool_catalog>\nThe MCP namespace "magpie" has the tools below. They are reached only through \`${CALL}\`, never as tools of their own. Each entry is the exact call to make; its arguments must match the schema given. The schemas are complete, so there is no need to call \`GetDynamicTools\` first.\n`
|
|
991
|
+
for (const t of tools) s += `<call>${CALL}({"namespace":"magpie","toolName":"${t.name}","arguments":{...}})\n${t.description}\narguments schema: ${t.schemaText}\n</call>\n`
|
|
989
992
|
return s + "</dynamic_tool_catalog>"
|
|
990
993
|
}
|
|
991
994
|
|
|
@@ -1345,6 +1348,8 @@ async function* decode(stream, { send, blobs, tools, estimate }) {
|
|
|
1345
1348
|
let calls = 0
|
|
1346
1349
|
let listed = 0
|
|
1347
1350
|
let said = 0
|
|
1351
|
+
// wrote: the reply's text alone; a turn of thinking only says nothing
|
|
1352
|
+
let wrote = 0
|
|
1348
1353
|
let usage = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, reasoning: 0 }
|
|
1349
1354
|
const finish = () => {
|
|
1350
1355
|
if (!usage.output) usage.output = Math.floor((said + 3) / 4)
|
|
@@ -1369,7 +1374,7 @@ async function* decode(stream, { send, blobs, tools, estimate }) {
|
|
|
1369
1374
|
if (f.end) {
|
|
1370
1375
|
const e = failure(200, f.data)
|
|
1371
1376
|
if (e.status < 200 || e.status > 299) yield { error: e }
|
|
1372
|
-
else if (
|
|
1377
|
+
else if (wrote === 0 && calls === 0) yield { error: { status: 502, message: "an empty reply" } }
|
|
1373
1378
|
else yield finish()
|
|
1374
1379
|
return
|
|
1375
1380
|
}
|
|
@@ -1384,6 +1389,7 @@ async function* decode(stream, { send, blobs, tools, estimate }) {
|
|
|
1384
1389
|
const t = pbStr(uf, 1)
|
|
1385
1390
|
if (t) {
|
|
1386
1391
|
said += t.length
|
|
1392
|
+
wrote += t.length
|
|
1387
1393
|
yield { text: t }
|
|
1388
1394
|
}
|
|
1389
1395
|
break
|
|
@@ -1400,7 +1406,9 @@ async function* decode(stream, { send, blobs, tools, estimate }) {
|
|
|
1400
1406
|
case 14: // turn ended, with what it used
|
|
1401
1407
|
usage = usageOf(uf)
|
|
1402
1408
|
if (calls === 0) {
|
|
1403
|
-
|
|
1409
|
+
// nothing written and nothing called: an empty reply,
|
|
1410
|
+
// which the client asks again, not a finished turn
|
|
1411
|
+
yield wrote === 0 ? { error: { status: 502, message: "an empty reply" } } : finish()
|
|
1404
1412
|
return
|
|
1405
1413
|
}
|
|
1406
1414
|
break
|
|
@@ -1725,4 +1733,4 @@ export async function CursorAuthPlugin() {
|
|
|
1725
1733
|
}
|
|
1726
1734
|
|
|
1727
1735
|
// for tests
|
|
1728
|
-
export const _internal = { usable, maxRequired, conversationID, usageOf, sessionOf, SESSION, errorResponse, kept, poolBase, splitID, families, byEffort, offered, modelID, conversation, buildRun, decode, exec, fields, pb, pbValue, pbAny, frame, frames, failure, toolsOf, expiry }
|
|
1736
|
+
export const _internal = { catalog, usable, maxRequired, conversationID, usageOf, sessionOf, SESSION, errorResponse, kept, poolBase, splitID, families, byEffort, offered, modelID, conversation, buildRun, decode, exec, fields, pb, pbValue, pbAny, frame, frames, failure, toolsOf, expiry }
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magpie-community/opencode-cursor-auth",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
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",
|
|
7
7
|
"exports": "./index.mjs",
|
|
8
8
|
"files": ["index.mjs", "README.md"],
|
|
9
9
|
"keywords": ["opencode", "opencode-plugin", "magpie", "cursor"],
|
|
10
|
-
"license": "MIT"
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"repository": { "type": "git", "url": "git+https://github.com/magpie-community/plugins.git", "directory": "packages/cursor" }
|
|
11
12
|
}
|