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

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 +6 -4
  2. package/index.mjs +32 -10
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -126,8 +126,8 @@ Each chat carries WorkBuddy's headers:
126
126
  - `Authorization`, `X-User-Id`, `X-Domain`, `X-Product: SaaS`, `X-IDE-Type: WorkBuddy`;
127
127
  - the desktop CLI's `User-Agent`, `WorkBuddy/<app> <appName>/<app> CLI/<cli>`:
128
128
  `WorkBuddy/5.9.3 WorkBuddy/5.9.3 CLI/2.165.0` on the China build and
129
- `WorkBuddy/5.8.4 workbuddy-ai/5.8.4 CLI/2.161.0` on WorkBuddy AI, each
130
- build's current app on 2026-10-28; `X-IDE-Version` is the app's version.
129
+ `WorkBuddy/5.9.3 workbuddy-ai/5.9.3 CLI/2.165.0` on WorkBuddy AI, each
130
+ build's current app on 2026-10-29; `X-IDE-Version` is the app's version.
131
131
  A User-Agent not starting `WorkBuddy/<version>` is answered error 10085;
132
132
  - the client's, which WorkBuddy's usage list shows as the client that asked
133
133
  (使用端): `X-Agent-Purpose: conversation`, `X-IDE-Name: WorkBuddy`,
@@ -144,7 +144,7 @@ Each chat carries WorkBuddy's headers:
144
144
  one, a made-up conversation of the request's own being what splits one
145
145
  conversation into many in the usage detail;
146
146
  - what the CLI adds to a model request alone: `X-Agent-Type: main` on both
147
- builds, `X-Agent-Runtime: local-agent` on the China build (new in 5.9),
147
+ builds, `X-Agent-Runtime: local-agent` (new in 5.9),
148
148
  `Accept: application/json`, and the `X-Stainless-*` headers of the OpenAI
149
149
  SDK it sends through (openai 6.25.0 on Electron 37's Node v22.21.1, a
150
150
  1200s timeout, no retries).
@@ -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
@@ -92,11 +92,15 @@ const SITES = {
92
92
  authID: "workbuddy-desktop-ai",
93
93
  platform: "workbuddy-ai",
94
94
  ai: true,
95
- // WorkBuddy AI 5.8.4.41366630, its update feed's current build on
96
- // 2026-10-28 (see the China build's)
97
- app: "5.8.4",
98
- cli: "2.161.0",
95
+ // WorkBuddy AI 5.9.3.42398134, its update feed's current build on
96
+ // 2026-10-29 (see the China build's): the same CLI as the China
97
+ // build's 5.9.3, byte for byte but for product.json, and the same
98
+ // Electron (37.10.3); its desktop puts agentRuntime local-agent in the
99
+ // prompt meta as the China build's does
100
+ app: "5.9.3",
101
+ cli: "2.165.0",
99
102
  appName: "workbuddy-ai",
103
+ runtime: "local-agent",
100
104
  keys: "https://www.workbuddy.ai/profile/keys",
101
105
  models: AI_MODELS,
102
106
  // models whose images WorkBuddy AI drops though its config says they
@@ -1328,7 +1332,7 @@ function fitted(body) {
1328
1332
 
1329
1333
  // gzipped is a chat's body compressed, as WorkBuddy's own client sends its
1330
1334
  // model requests: its CLI's GzipRequestProcessor (WorkBuddy 5.9.3, CLI
1331
- // 2.165.0; WorkBuddy AI 5.8.4 the same) gzips each POST's body and sets
1335
+ // 2.165.0, on both builds) gzips each POST's body and sets
1332
1336
  // Content-Encoding: gzip when the product's RequestBodyGzip feature is on,
1333
1337
  // which both builds' product.json turn on and /v3/config (merged over it)
1334
1338
  // doesn't turn off. Sent as plain JSON, a long agent conversation went up
@@ -1336,9 +1340,13 @@ function fitted(body) {
1336
1340
  // copilot.tencent.com against 258 MB down. Measured 2026-10-28 on
1337
1341
  // www.workbuddy.ai: a gzipped chat answers as the plain one does. A
1338
1342
  // 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
1343
+ // wasn't tried gzipped. Only a chat completion goes gzipped (isCompletion):
1344
+ // WorkBuddy's images API reads its body as plain JSON, and magpie's drawing
1345
+ // (/v2/images/generations, /v2/images/edits) is sent through this same
1346
+ // fetch; gzipped it answered 400 11101 "invalid character '\x1f'" (iwinux on
1347
+ // Discord, 0.1.43). null when the body isn't sent gzipped.
1348
+ function gzipped(completion, b) {
1349
+ if (!completion) return null
1342
1350
  if (typeof b === "string") return gzipSync(Buffer.from(b))
1343
1351
  if (b instanceof ArrayBuffer || ArrayBuffer.isView(b)) return gzipSync(b)
1344
1352
  return null
@@ -2174,6 +2182,19 @@ function effortsOf(d, site, id) {
2174
2182
  return EFFORT_ORDER.filter((e) => set.has(e))
2175
2183
  }
2176
2184
 
2185
+ // isCompletion is whether a request is a chat completion: one to
2186
+ // .../chat/completions, or, with no URL to read, a body holding a chat's
2187
+ // messages. Nothing else the loader's fetch sends (magpie's drawings to
2188
+ // /v2/images/*) is a chat: it goes neither gzipped nor given an effort.
2189
+ function isCompletion(url, chat) {
2190
+ let path = ""
2191
+ try {
2192
+ path = new URL(String(url ?? "")).pathname
2193
+ } catch {}
2194
+ if (path) return /\/chat\/completions$/.test(path)
2195
+ return Array.isArray(chat?.messages)
2196
+ }
2197
+
2177
2198
  // defaultEffortOf is the level WorkBuddy's own client asks a model for when
2178
2199
  // the user picked none: its CLI's configureThinkingSettings (WorkBuddy
2179
2200
  // 5.9.3, CLI 2.165.0) takes the session's effort, else the settings', else
@@ -2486,13 +2507,14 @@ function makePlugin(site) {
2486
2507
  // a chat that names no effort is asked at the model's default,
2487
2508
  // as WorkBuddy's client asks it (withDefaultEffort); with no
2488
2509
  // list to read (effortList) the chat goes as it came
2489
- if (!native && chat && !namesEffort(chat) && withDefaultEffort(chat, await effortList(a))) changed = true
2510
+ const completion = !native && isCompletion(req ? req.url : input, chat)
2511
+ if (completion && chat && !namesEffort(chat) && withDefaultEffort(chat, await effortList(a))) changed = true
2490
2512
  chatHeaders(site, headers)
2491
2513
  attendChat(headers, chat, session)
2492
2514
  const post = (b) => {
2493
2515
  // a chat goes gzipped, as WorkBuddy's client sends it
2494
2516
  // (gzipped); its size on the wire is what unanswered weighs
2495
- const z = gzipped(native, b)
2517
+ const z = gzipped(completion, b)
2496
2518
  if (z) headers.set("Content-Encoding", "gzip")
2497
2519
  else headers.delete("Content-Encoding")
2498
2520
  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.46",
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",