@magpie-community/opencode-workbuddy-auth 0.2.5 → 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.
Files changed (3) hide show
  1. package/README.md +14 -1
  2. package/index.mjs +40 -6
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -251,7 +251,9 @@ same words ending `stop`, or the filter cutting off a reply after other
251
251
  words, go through as they came.
252
252
  copilot.tencent.com sends the line with a newline on each side
253
253
  (`"\nSorry, I can't respond to this question.\n"`); since 0.2.5 white
254
- space around it no longer lets it through.
254
+ space around it no longer lets it through. It also puts `"tool_calls": []` on
255
+ every delta; since 0.2.6 only a list with a call in it lets the reply
256
+ through as it came.
255
257
 
256
258
  ## Models
257
259
 
@@ -284,6 +286,17 @@ client sends it: WorkBuddy doesn't think when a chat names none, so
284
286
  OpenCode's default variant got answers without thinking. An effort the
285
287
  client names, `none` too, goes as it came.
286
288
 
289
+ Two values differ from the config, each measured with real requests:
290
+
291
+ - DeepSeek-V4.1-Flash (and its paid `-sg` id) lists `none`, though the
292
+ config says it only reasons: WorkBuddy answers `reasoning_effort: "none"`
293
+ on it with no thinking at all (since 0.2.7, #563).
294
+ - On `workbuddy` (copilot.tencent.com), DeepSeek-V4.1-Flash's context is
295
+ 100000, not the config's 1000000: a longer prompt is refused with
296
+ "prompt is too long: … > 100000 maximum", while GLM-5.3-Flash on the same
297
+ endpoint takes the million. `workbuddy-ai` takes the million on it
298
+ (since 0.2.7, #561).
299
+
287
300
  A chat goes gzipped (`Content-Encoding: gzip`), as WorkBuddy's own client
288
301
  sends its model requests (`RequestBodyGzip` in both builds' product.json).
289
302
  Claude's Messages route goes as it came, and so does anything that isn't a
package/index.mjs CHANGED
@@ -28,7 +28,7 @@ const CN_MODELS = [
28
28
  ["hy4-preview-f", "Hy4 preview", 1000000, ["high"]],
29
29
  ["hy3", "Hy3", 192000, ["low", "high"]],
30
30
  ["hy3-x", "Hy3-X", 192000, ["low", "high"]],
31
- ["deepseek-v4.1-flash", "Deepseek-V4.1-Flash", 1000000],
31
+ ["deepseek-v4.1-flash", "Deepseek-V4.1-Flash", 1000000, ["none", "low", "high", "max"]],
32
32
  ["glm-5.3", "GLM-5.3", 1000000, ["low", "high", "max"]],
33
33
  ["glm-5.3-flash", "GLM-5.3-Flash", 1000000, ["low", "high", "max"]],
34
34
  ["glm-5.2", "GLM-5.2", 1000000, ["high", "xhigh"]],
@@ -81,6 +81,9 @@ const SITES = {
81
81
  // where this build's API keys are made (see keyAccount)
82
82
  keys: "https://www.workbuddy.cn/profile/keys",
83
83
  models: CN_MODELS,
84
+ // the prompt a model takes here, where it is less than the config's
85
+ // maxInputTokens (see contextOf)
86
+ contextCap: { "deepseek-v4.1-flash": 100000 },
84
87
  // it serves the Claude models on Anthropic's Messages API too (see
85
88
  // nativeOf)
86
89
  messages: true,
@@ -109,6 +112,33 @@ const SITES = {
109
112
  },
110
113
  }
111
114
 
115
+ // contextOf is the prompt site takes for model: the config's
116
+ // maxInputTokens, or less where the site turns a longer prompt away.
117
+ // copilot.tencent.com's /v3/config gives deepseek-v4.1-flash 1000000, but
118
+ // its chat answers a prompt over 100000 tokens with 400 "prompt is too long:
119
+ // 100001 tokens > 100000 maximum" (plugins#561: 11 times on two accounts;
120
+ // the largest prompt it took was 76,065), while glm-5.3-flash on the same
121
+ // endpoint took 954,019. A client planning against 1M grows its thread
122
+ // past 100k and then can't compact it either, as the compaction resends it
123
+ // whole. WorkBuddy AI is not capped so: www.workbuddy.ai's
124
+ // deepseek-v4.1-flash took a 181,887-token prompt (measured 2026-10-31),
125
+ // so only the China build has the cap.
126
+ function contextOf(site, model, said) {
127
+ const cap = site.contextCap?.[model]
128
+ if (!cap) return said
129
+ return typeof said === "number" && said > 0 ? Math.min(said, cap) : cap
130
+ }
131
+
132
+ // OFF_TAKEN are models that turn thinking off for reasoning_effort "none"
133
+ // though the config says onlyReasoning (so WorkBuddy's own client offers no
134
+ // off switch): deepseek-v4.1-flash, and the same model under its paid id.
135
+ // Measured 2026-10-31 on www.workbuddy.ai: "none" answered 200 with 0
136
+ // reasoning tokens on both, where "low" thought 1221 and 1127; and on the
137
+ // China build by the reporter of plugins#563 (0 reasoning tokens, a 30-item
138
+ // prompt in 14s instead of 50s). Without the level magpie sends "low" for
139
+ // a client's "none".
140
+ const OFF_TAKEN = new Set(["deepseek-v4.1-flash", "deepseek-v4.1-flash-sg"])
141
+
112
142
  // textOnly says whether site drops the images sent to model, whatever its
113
143
  // config says. On 2026-10-13, with a real WorkBuddy AI account (Yirasumi on
114
144
  // Discord), www.workbuddy.ai's /v3/config marked every model
@@ -1660,7 +1690,10 @@ function unsaid(res) {
1660
1690
  const c = chunkOf(ev)?.choices?.[0]
1661
1691
  const text = typeof c?.delta?.content === "string" ? c.delta.content : ""
1662
1692
  const finish = c?.finish_reason
1663
- if (c?.delta?.tool_calls || (text && !filterSaid(said + text))) {
1693
+ // copilot.tencent.com sends "tool_calls": [] on every delta, text
1694
+ // too: only a list with a call in it is one
1695
+ const calls = c?.delta?.tool_calls
1696
+ if ((Array.isArray(calls) ? calls.length > 0 : calls) || (text && !filterSaid(said + text))) {
1664
1697
  open = false
1665
1698
  const out = [...held, ev]
1666
1699
  held = []
@@ -2927,7 +2960,7 @@ function variants(efforts) {
2927
2960
  function configModels(site) {
2928
2961
  return Object.fromEntries(site.models.map(([id, name, context, efforts]) => [id, {
2929
2962
  name,
2930
- limit: { context, output: 0 },
2963
+ limit: { context: contextOf(site, id, context), output: 0 },
2931
2964
  tool_call: true,
2932
2965
  // OpenCode (and magpie's host) read a config model's package and URL
2933
2966
  // from provider: { npm, api }, not api
@@ -3122,14 +3155,15 @@ async function liveModels(site, a) {
3122
3155
  const d = (cfg.models ?? []).find((x) => x.id === id)
3123
3156
  const m = { id, name: d?.name || id }
3124
3157
  if (d) {
3125
- m.context = d.maxInputTokens
3158
+ m.context = contextOf(site, id, d.maxInputTokens)
3126
3159
  m.output = d.maxOutputTokens
3127
3160
  m.images = d.supportsImages === true && !textOnly(site, id)
3128
3161
  Object.assign(m, priceOf(d, cfg.modelPromotions))
3129
3162
  const es = effortsOf(d, site, id)
3130
3163
  if (es.length) {
3131
3164
  const canOff = d.reasoning?.canDisableThinking
3132
- m.efforts = [...(!d.onlyReasoning && (canOff == null || canOff) ? ["none"] : []), ...es]
3165
+ const off = (!d.onlyReasoning && (canOff == null || canOff)) || OFF_TAKEN.has(id)
3166
+ m.efforts = [...(off ? ["none"] : []), ...es]
3133
3167
  const def = defaultEffortOf(d, es)
3134
3168
  if (def) m.effort = def
3135
3169
  }
@@ -3756,4 +3790,4 @@ export const WorkBuddyAuthPlugin = makePlugin(SITES.workbuddy)
3756
3790
  export const WorkBuddyAIAuthPlugin = makePlugin(SITES["workbuddy-ai"])
3757
3791
 
3758
3792
  // for tests
3759
- export const _internal = { idFor, replyAfterToolsOn, withDefaultEffort, defaultEffortOf, gzipped, FREE_ONLY, PRICE_TTL, keyAccount, remoteConfig, cycleOf, typeUnions, systemAsUser, systemKey, DEFAULT_SYSTEM, EDGE_READS, fitShape, replyAfterTools, AFTER_TOOLS_REFUSED, enterpriseUsageOf, accountName, notDesktop, textOnly, runsOutOf, packagesOf, endOf, enterpriseHeaders, enterpriseOf, liveModels, browserSignIn, withSystem, asReasoning, normalizeToolChoice, fitTools, fitted, renamed, unsaid, FILTER_SAYS, unflagged, usageOf, desktopHeld, explained, REFUSED_HINT, RESTRICTED_HINT, EXHAUSTED_HINT, REFUSED_DOC, commaPaused, commaPausedOn, opened, freeCredits, creditsOf, priceOf, fresh, SITES, renewing, renewed, SESSION, attend, scopeOf, turnKey, conversationKey, signatureOf, isMessages, withoutUnsigned, withoutSignedThinking, prepared, answeredBefore, nativeOf, modelOf, configModels, freeWindowOf, tokensShort, freeWindowRows, freeWindowLedger, readLedgerTail, pinned, rowTime, rowAccount, ofAccount, windowOffset, windowReset, FREE_WINDOW_MODELS, FREE_WINDOW_SPAN, FREE_WINDOW_GAP, FREE_WINDOW_LEAD, checkinOf, API_MESSAGES: NPM_MESSAGES, API_CHAT: NPM }
3793
+ export const _internal = { idFor, contextOf, OFF_TAKEN, replyAfterToolsOn, withDefaultEffort, defaultEffortOf, gzipped, FREE_ONLY, PRICE_TTL, keyAccount, remoteConfig, cycleOf, typeUnions, systemAsUser, systemKey, DEFAULT_SYSTEM, EDGE_READS, fitShape, replyAfterTools, AFTER_TOOLS_REFUSED, enterpriseUsageOf, accountName, notDesktop, textOnly, runsOutOf, packagesOf, endOf, enterpriseHeaders, enterpriseOf, liveModels, browserSignIn, withSystem, asReasoning, normalizeToolChoice, fitTools, fitted, renamed, unsaid, FILTER_SAYS, unflagged, usageOf, desktopHeld, explained, REFUSED_HINT, RESTRICTED_HINT, EXHAUSTED_HINT, REFUSED_DOC, commaPaused, commaPausedOn, opened, freeCredits, creditsOf, priceOf, fresh, SITES, renewing, renewed, SESSION, attend, scopeOf, turnKey, conversationKey, signatureOf, isMessages, withoutUnsigned, withoutSignedThinking, prepared, answeredBefore, nativeOf, modelOf, configModels, freeWindowOf, tokensShort, freeWindowRows, freeWindowLedger, readLedgerTail, pinned, rowTime, rowAccount, ofAccount, windowOffset, windowReset, FREE_WINDOW_MODELS, FREE_WINDOW_SPAN, FREE_WINDOW_GAP, FREE_WINDOW_LEAD, checkinOf, API_MESSAGES: NPM_MESSAGES, API_CHAT: NPM }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magpie-community/opencode-workbuddy-auth",
3
- "version": "0.2.5",
3
+ "version": "0.2.7",
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",