@magpie-community/opencode-workbuddy-auth 0.1.24 → 0.1.26

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.
Files changed (3) hide show
  1. package/README.md +35 -0
  2. package/index.mjs +17 -2
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -164,6 +164,39 @@ credits are read from the enterprise meter
164
164
  page reads: the cycle's credits used of its limit, and when the cycle
165
165
  resets (magpie #1904).
166
166
 
167
+ ## When free models work but a credit model does not
168
+
169
+ Check the failing account and model separately before concluding that the
170
+ wallet is empty:
171
+
172
+ - Use the exact API id from the account's model list. For example,
173
+ `glm-5.3-flash` is the id; `GLM-5.3-Flash` is its display name. A route
174
+ copied from another provider need not be a valid WorkBuddy model id.
175
+ - The WorkBuddy 5.6+ encrypted-desktop message means this sign-in cannot
176
+ be read, not that the account has zero credits. Use **Account (browser)**
177
+ for the same build/region. Keep the old entry until the new identity and
178
+ model list are confirmed. The desktop file is not decrypted or changed.
179
+ - An account restricted by WorkBuddy is a different failure. Code 11140
180
+ with its unusual-activity message calls for **Submit feedback** in
181
+ WorkBuddy; signing in repeatedly or changing the model does not lift it.
182
+ See [magpie#1849](https://github.com/yetone/magpie/issues/1849).
183
+ - Inspect each attempted provider/account in magpie's routing details.
184
+ A ZCode trial quota failure, another provider's insufficient credits, or
185
+ one account's restriction is not the balance of every WorkBuddy account.
186
+
187
+ A model response confirms that the selected account can answer. It does
188
+ not, without a matching vendor usage record, prove how many credits that
189
+ request deducted. A usage-read error means the balance is unknown.
190
+
191
+ The encrypted-desktop result can be reproduced without an account using
192
+ `packages/workbuddy/usage.test.mjs` in an isolated temporary HOME (and
193
+ USERPROFILE on Windows). It covers sign-in, usage and chat against a
194
+ synthetic sealed desktop file, and checks that the file stays unchanged.
195
+ A successful browser authorization alone is not a migration: compare the
196
+ returned identity with the intended desktop account before replacing its
197
+ entry. An already signed-in browser can simply renew another saved account.
198
+
199
+
167
200
  ## Not here
168
201
 
169
202
  magpie's built-in WorkBuddy does more than this package:
@@ -172,3 +205,5 @@ magpie's built-in WorkBuddy does more than this package:
172
205
  - several accounts under one provider.
173
206
 
174
207
  OpenCode's plugin API has no place for these.
208
+
209
+ Credit multipliers accept the international catalog's `x0.34 credits` text as well as `x0.34`. An empty credits value (for example Auto) stays unknown, never free.
package/index.mjs CHANGED
@@ -1403,7 +1403,7 @@ function modelOf(site, provider, m) {
1403
1403
  // rated. The same rule as magpie's built-in (wbCredits).
1404
1404
  function creditsOf(c) {
1405
1405
  if (c == null || c === "") return undefined
1406
- const s = String(c).trim().toLowerCase().replace(/^x/, "")
1406
+ const s = String(c).trim().toLowerCase().replace(/\s+credits?$/, "").replace(/^x/, "")
1407
1407
  const n = Number(s)
1408
1408
  return s !== "" && Number.isFinite(n) && n >= 0 ? n : undefined
1409
1409
  }
@@ -1461,6 +1461,21 @@ function priceOf(d, promotions, now = Date.now()) {
1461
1461
  return { free: base === 0, rate: base }
1462
1462
  }
1463
1463
 
1464
+ // effortsOf are the levels a config model takes. Most list them in
1465
+ // reasoning.supportedEfforts; some (fast-model, deepseek-v4.1-flash, kimi-k3,
1466
+ // gemini-3.5-flash … on both sites, plugins#255) say only supportsReasoning
1467
+ // and a default reasoning.effort. Those take low, high and max (each
1468
+ // reasoned under a real account, on four of them) and their own default.
1469
+ const EFFORT_ORDER = ["low", "medium", "high", "xhigh", "max"]
1470
+ function effortsOf(d) {
1471
+ const said = d.reasoning?.supportedEfforts
1472
+ if (Array.isArray(said) && said.length) return said
1473
+ if (d.supportsReasoning !== true) return []
1474
+ const own = d.reasoning?.effort
1475
+ const set = new Set(["low", "high", "max", ...(typeof own === "string" && EFFORT_ORDER.includes(own) ? [own] : [])])
1476
+ return EFFORT_ORDER.filter((e) => set.has(e))
1477
+ }
1478
+
1464
1479
  async function liveModels(site, a) {
1465
1480
  const headers = new Headers()
1466
1481
  sign(site, a, headers)
@@ -1483,7 +1498,7 @@ async function liveModels(site, a) {
1483
1498
  m.output = d.maxOutputTokens
1484
1499
  m.images = d.supportsImages === true && !textOnly(site, id)
1485
1500
  Object.assign(m, priceOf(d, cfg.modelPromotions))
1486
- const es = d.reasoning?.supportedEfforts ?? []
1501
+ const es = effortsOf(d)
1487
1502
  if (es.length) {
1488
1503
  const canOff = d.reasoning?.canDisableThinking
1489
1504
  m.efforts = [...(!d.onlyReasoning && (canOff == null || canOff) ? ["none"] : []), ...es]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magpie-community/opencode-workbuddy-auth",
3
- "version": "0.1.24",
3
+ "version": "0.1.26",
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",