@magpie-community/opencode-workbuddy-auth 0.1.5 → 0.1.6
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 +20 -5
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -465,18 +465,29 @@ function modelOf(site, provider, m) {
|
|
|
465
465
|
variants: variants(m.efforts),
|
|
466
466
|
// magpie's own: served at no cost to the plan's credits
|
|
467
467
|
free: !!m.free,
|
|
468
|
+
// magpie's own: the credits a request costs, as a multiple (0: none)
|
|
469
|
+
rate: m.rate ?? 0,
|
|
468
470
|
}
|
|
469
471
|
}
|
|
470
472
|
|
|
471
473
|
// liveModels asks WorkBuddy's product config for the plan's models: the
|
|
472
474
|
// "cli" agent's list, each with its details. The CLI User-Agent picks
|
|
473
475
|
// WorkBuddy's config (a bare WorkBuddy/<v> gets CodeBuddy IDE's, no cli).
|
|
476
|
+
// creditsOf reads a model's credits, the multiple WorkBuddy's picker shows
|
|
477
|
+
// by it: "x0.03", "0" or 0; "x0.00" is free. A rate it can't read (or
|
|
478
|
+
// none, or an infinite one) is undefined: the model is neither free nor
|
|
479
|
+
// rated. The same rule as magpie's built-in (wbCredits).
|
|
480
|
+
function creditsOf(c) {
|
|
481
|
+
if (c == null || c === "") return undefined
|
|
482
|
+
const s = String(c).trim().toLowerCase().replace(/^x/, "")
|
|
483
|
+
const n = Number(s)
|
|
484
|
+
return s !== "" && Number.isFinite(n) && n >= 0 ? n : undefined
|
|
485
|
+
}
|
|
486
|
+
|
|
474
487
|
// freeCredits says whether a model's credits are none: "x0.00", "0" or 0.
|
|
475
488
|
// A rate it can't read is not free.
|
|
476
489
|
function freeCredits(c) {
|
|
477
|
-
|
|
478
|
-
const s = String(c).trim().toLowerCase().replace(/^x/, "")
|
|
479
|
-
return s !== "" && Number.isFinite(Number(s)) && Number(s) === 0
|
|
490
|
+
return creditsOf(c) === 0
|
|
480
491
|
}
|
|
481
492
|
|
|
482
493
|
async function liveModels(site, a) {
|
|
@@ -500,7 +511,11 @@ async function liveModels(site, a) {
|
|
|
500
511
|
m.context = d.maxInputTokens
|
|
501
512
|
m.output = d.maxOutputTokens
|
|
502
513
|
m.images = d.supportsImages === true
|
|
503
|
-
|
|
514
|
+
const r = creditsOf(d.credits)
|
|
515
|
+
if (r !== undefined) {
|
|
516
|
+
m.free = r === 0
|
|
517
|
+
m.rate = r
|
|
518
|
+
}
|
|
504
519
|
const es = d.reasoning?.supportedEfforts ?? []
|
|
505
520
|
if (es.length) {
|
|
506
521
|
const canOff = d.reasoning?.canDisableThinking
|
|
@@ -661,4 +676,4 @@ export const WorkBuddyAuthPlugin = makePlugin(SITES.workbuddy)
|
|
|
661
676
|
export const WorkBuddyAIAuthPlugin = makePlugin(SITES["workbuddy-ai"])
|
|
662
677
|
|
|
663
678
|
// for tests
|
|
664
|
-
export const _internal = { withSystem, usageOf, desktopHeld, explained, REFUSED_HINT, freeCredits, fresh, SITES }
|
|
679
|
+
export const _internal = { withSystem, usageOf, desktopHeld, explained, REFUSED_HINT, freeCredits, creditsOf, fresh, SITES }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magpie-community/opencode-workbuddy-auth",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "OpenCode provider plugins for WorkBuddy's plans: WorkBuddy (CodeBuddy, copilot.tencent.com) and WorkBuddy AI (www.workbuddy.ai)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.mjs",
|