@magpie-community/opencode-workbuddy-auth 0.1.44 → 0.1.45

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 +3 -1
  2. package/index.mjs +23 -5
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -244,7 +244,9 @@ client names, `none` too, goes as it came.
244
244
 
245
245
  A chat goes gzipped (`Content-Encoding: gzip`), as WorkBuddy's own client
246
246
  sends its model requests (`RequestBodyGzip` in both builds' product.json).
247
- Claude's Messages route goes as it came.
247
+ Claude's Messages route goes as it came, and so does anything that isn't a
248
+ chat completion: magpie's drawings (`/v2/images/generations`,
249
+ `/v2/images/edits`) go as plain JSON, which is all the images API reads.
248
250
 
249
251
  A model's price is its `credits` ("x0.29") and the config's
250
252
  `modelPromotions`. A discount for whole days (Step-5-Preview's 独家限免) is
package/index.mjs CHANGED
@@ -1336,9 +1336,13 @@ function fitted(body) {
1336
1336
  // copilot.tencent.com against 258 MB down. Measured 2026-10-28 on
1337
1337
  // www.workbuddy.ai: a gzipped chat answers as the plain one does. A
1338
1338
  // Messages request (Claude on the China build) goes as it came: that route
1339
- // wasn't tried gzipped. null when the body isn't sent gzipped.
1340
- function gzipped(native, b) {
1341
- if (native) return null
1339
+ // wasn't tried gzipped. Only a chat completion goes gzipped (isCompletion):
1340
+ // WorkBuddy's images API reads its body as plain JSON, and magpie's drawing
1341
+ // (/v2/images/generations, /v2/images/edits) is sent through this same
1342
+ // fetch; gzipped it answered 400 11101 "invalid character '\x1f'" (iwinux on
1343
+ // Discord, 0.1.43). null when the body isn't sent gzipped.
1344
+ function gzipped(completion, b) {
1345
+ if (!completion) return null
1342
1346
  if (typeof b === "string") return gzipSync(Buffer.from(b))
1343
1347
  if (b instanceof ArrayBuffer || ArrayBuffer.isView(b)) return gzipSync(b)
1344
1348
  return null
@@ -2174,6 +2178,19 @@ function effortsOf(d, site, id) {
2174
2178
  return EFFORT_ORDER.filter((e) => set.has(e))
2175
2179
  }
2176
2180
 
2181
+ // isCompletion is whether a request is a chat completion: one to
2182
+ // .../chat/completions, or, with no URL to read, a body holding a chat's
2183
+ // messages. Nothing else the loader's fetch sends (magpie's drawings to
2184
+ // /v2/images/*) is a chat: it goes neither gzipped nor given an effort.
2185
+ function isCompletion(url, chat) {
2186
+ let path = ""
2187
+ try {
2188
+ path = new URL(String(url ?? "")).pathname
2189
+ } catch {}
2190
+ if (path) return /\/chat\/completions$/.test(path)
2191
+ return Array.isArray(chat?.messages)
2192
+ }
2193
+
2177
2194
  // defaultEffortOf is the level WorkBuddy's own client asks a model for when
2178
2195
  // the user picked none: its CLI's configureThinkingSettings (WorkBuddy
2179
2196
  // 5.9.3, CLI 2.165.0) takes the session's effort, else the settings', else
@@ -2486,13 +2503,14 @@ function makePlugin(site) {
2486
2503
  // a chat that names no effort is asked at the model's default,
2487
2504
  // as WorkBuddy's client asks it (withDefaultEffort); with no
2488
2505
  // list to read (effortList) the chat goes as it came
2489
- if (!native && chat && !namesEffort(chat) && withDefaultEffort(chat, await effortList(a))) changed = true
2506
+ const completion = !native && isCompletion(req ? req.url : input, chat)
2507
+ if (completion && chat && !namesEffort(chat) && withDefaultEffort(chat, await effortList(a))) changed = true
2490
2508
  chatHeaders(site, headers)
2491
2509
  attendChat(headers, chat, session)
2492
2510
  const post = (b) => {
2493
2511
  // a chat goes gzipped, as WorkBuddy's client sends it
2494
2512
  // (gzipped); its size on the wire is what unanswered weighs
2495
- const z = gzipped(native, b)
2513
+ const z = gzipped(completion, b)
2496
2514
  if (z) headers.set("Content-Encoding", "gzip")
2497
2515
  else headers.delete("Content-Encoding")
2498
2516
  return fetch(req ? req.url : input, { ...init, method: init?.method ?? req?.method, headers, body: z ?? b }).catch((e) => unanswered(site, a, z ?? b, e, init?.signal))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magpie-community/opencode-workbuddy-auth",
3
- "version": "0.1.44",
3
+ "version": "0.1.45",
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",