@magpie-community/opencode-cursor-auth 0.2.0 → 0.2.1
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
|
@@ -592,7 +592,7 @@ function pick(entry, effort, fast, seed) {
|
|
|
592
592
|
const have = valuesOf(v)
|
|
593
593
|
return Object.keys({ ...have, ...want }).every((k) => have[k] === undefined || want[k] === undefined || have[k] === want[k])
|
|
594
594
|
}
|
|
595
|
-
const v = entry.variants.find(same) ?? (entry.partial ? nearest(entry.variants, want) : undefined)
|
|
595
|
+
const v = entry.variants.find(same) ?? (seed ? branch(entry, want) : undefined) ?? (entry.partial ? nearest(entry.variants, want) : undefined)
|
|
596
596
|
const params = Object.entries(v ? { ...want, ...valuesOf(v) } : want).map(([id, value]) => ({ id, value }))
|
|
597
597
|
// no variant: Max Mode when the size is more than Cursor allows outside it
|
|
598
598
|
const maxMode = v ? needsMax(entry.model, v) : needsMax(entry.model, def) || tokensOf(entry.size) > (entry.model.contextTokenLimit || Infinity)
|
|
@@ -603,6 +603,26 @@ function pick(entry, effort, fast, seed) {
|
|
|
603
603
|
return { id, params, maxMode }
|
|
604
604
|
}
|
|
605
605
|
|
|
606
|
+
// branch is, for an id of Cursor's own asked at an effort no variant has
|
|
607
|
+
// with the rest of its parameters (claude-opus-5-low at xhigh: Opus 5
|
|
608
|
+
// without thinking stops at high), the variant with those parameters at the
|
|
609
|
+
// nearest effort it has, not the default's id with parameters that
|
|
610
|
+
// contradict it (claude-opus-5-thinking-high with thinking=false). Where
|
|
611
|
+
// the default differs from what is asked in the effort alone, the effort
|
|
612
|
+
// goes as asked, as for a listed model.
|
|
613
|
+
function branch(entry, want) {
|
|
614
|
+
if (!entry.pid || entry.pid === "thinking") return undefined
|
|
615
|
+
const def = valuesOf(entry.def)
|
|
616
|
+
if (Object.keys(want).every((k) => k === entry.pid || k === "context" || def[k] === undefined || def[k] === want[k])) return undefined
|
|
617
|
+
const vs = entry.variants.filter((v) => {
|
|
618
|
+
const have = valuesOf(v)
|
|
619
|
+
return entry.pid in have && Object.keys(want).every((k) => k === entry.pid || have[k] === undefined || have[k] === want[k])
|
|
620
|
+
})
|
|
621
|
+
const level = (x) => (x === "extra-high" ? "xhigh" : x)
|
|
622
|
+
const at = fitEffort(level(want[entry.pid]), vs.map((v) => level(valuesOf(v)[entry.pid])))
|
|
623
|
+
return at ? vs.find((v) => level(valuesOf(v)[entry.pid]) === at) : undefined
|
|
624
|
+
}
|
|
625
|
+
|
|
606
626
|
// fitEffort is the nearest effort a model has to the one asked for; max
|
|
607
627
|
// for ultra, and none only when asked.
|
|
608
628
|
function fitEffort(want, levels) {
|
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.1",
|
|
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",
|