dsh-connect-workbuddy 5.17.0 → 5.18.2

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/README.en.md CHANGED
@@ -32,17 +32,21 @@ It depends on the WorkBuddy client's own endpoints (not a public API), so the pl
32
32
  - **Dual parallel providers (CN + international)** — the CN side registers as the `workbuddy` provider (`GLM-5.3`, `DeepSeek-V4-Pro`, `Kimi-K3`, `MiniMax-M3`, `Hy3`, etc.), the international side as `workbuddy-global` (`GPT-5.6`, `Gemini-3.5-Flash`, `GLM-5.3`, `Kimi-K3`, etc.). **A region's models appear in the DSH model picker when that region has an account**: with accounts on both sides, both rosters are selectable at once, and different sessions can each pick a side without interfering. **A region with no local sign-in lists no models** — it cannot serve a single request, so listing them would offer nothing but failures. Sign in once for that region and its models come back on "detect accounts again" or after a restart; the provider itself stays registered either way, because its settings card is how you sign in (re-detection lives in the pool block). Model names carry the upstream credit multiplier (e.g. `GLM-5.3 · x0.79`), matching WorkBuddy's own model menu.
33
33
  - **Tabbed settings card** — the card's top carries a "Domestic / Global" tab bar; each tab holds its own account pool and model management. Account, directory, selection, and unsaved drafts are fully isolated per tab — switching accounts or refreshing models on one tab never touches the other side's runtime catalog or sessions.
34
34
  - **Switch either provider off on its own** — each tab carries an on/off checkbox (both checked by default). Unchecking one **withdraws that provider from DSH's model picker entirely** (it is not merely a hidden tab): its adapter route and its "Settings → Models" directory entry are both pulled, and startup no longer sends pointless requests for it. Account, credits, directory, and selection are all kept, and re-checking restores everything. The typical use is "I have no use for the international side" — switch it off and keep the picker clean. Note: a session that had already selected a model from the switched-off provider will report `NO_ADAPTER` on its next call; the card states this plainly on the switched-off tab instead of failing silently.
35
- - **Model management** — refresh the full catalog from upstream and enable or disable each model individually; refresh is a draft operation that only takes effect on save. Upstream also reports credit multiplier, context/output limits, and reasoning efforts; **every model row carries a "default reasoning" picker** (issue #179): which tier that model uses when a request names none — new conversations, compaction summaries and session titles are all such requests. The options are exactly the tiers that model declares (across one roster `deepseek`/`glm-5.3` say `low/high/max`, `glm-5.2` says `high/xhigh`, `space-bunny` has five), so this can only be chosen per model and not once for the route, and the first option reads "Default (high)", naming the tier upstream itself declares for that model. **This picker also replaces the old read-only "Reasoning: …" line** — it already lists every tier, so saying it twice adds nothing. **"Turn thinking off" is not here**: that stays the job of the `off` checkbox below. **image input is decided by a verified table**: a refresh pre-checks only models the table records as natively multimodal, leaves documented text-only models unchecked, and treats any id without a source as unverified and unchecked rather than guessing. The table carries two evidence tiers — vendor documentation (13 entries) and **the upstream catalog's own description** (2 entries: `space-bunny` and `minimax-m3.1-flash`, whose descriptions say “native multimodal”) — while a NEW id still needs a vendor source; see the “Image input” section of [docs/DESIGN.md](docs/DESIGN.md). Upstream's `supportsImages` is a *platform* declaration, not the model's capability, so it does not drive that decision at all. You can still tick any box by hand, and your selection is kept locally. **Every model row also carries a “Can disable” (`off`) checkbox**: it decides whether that model gets the “turn thinking off entirely” level. The default comes from a reviewed built-in table (the 9 models that claim the capability but answer HTTP 400 for it start unticked), and you can change it per model — **untick** for a model you do not need the level on. **The 9 tabled models cannot be ticked at all** (their row is marked "refuses off" with an explanatory tooltip): the level is not merely an extra option — pi-ai uses it as the DEFAULT for every request that names no tier, and a compaction summary is exactly such a request, so one tick made every `/compact` for that model fail with HTTP 400 / code 11133 (issue #83). Models outside the table are still decided entirely by your selection and their own declaration; your ticks are saved on first save and recomputed no further.
35
+ - **Model management** — refresh the full catalog from upstream and enable or disable each model individually; **your ticks are a draft that only takes effect on save, but the directory and its prices are not** (issue #214). A refresh records what it just read and applies it immediately, because a price is not an edit — the upstream changes those rates whenever it likes, and hiding a new one in a draft is what made the card show a stale figure while `/models/refresh` reported the fresh one (the reporter measured `glm-5.3` arriving as 0.69 from the refresh while the card still drew 0.79). **Your selection, context budgets, image ticks and default reasoning tiers** are still committed only by Save; a refresh never writes unsaved edits of those for you. Upstream also reports credit multiplier, context/output limits, and reasoning efforts; **every model row carries a "default reasoning" picker** (issue #179): which tier that model uses when a request names none — new conversations, compaction summaries and session titles are all such requests. The options are exactly the tiers that model declares (across one roster `deepseek`/`glm-5.3` say `low/high/max`, `glm-5.2` says `high/xhigh`, `space-bunny` has five), so this can only be chosen per model and not once for the route, and the first option names the tier that will actually be used — the level WorkBuddy declares for that model, or (when it declares none) that model’s own middle tier, never its weakest one, so an unset choice cannot quietly turn thinking down. **This picker also replaces the old read-only "Reasoning: …" line** — it already lists every tier, so saying it twice adds nothing. **"Turn thinking off" is not here**: that stays the job of the `off` checkbox below. **image input is decided by a verified table**: a refresh pre-checks only models the table records as natively multimodal, leaves documented text-only models unchecked, and treats any id without a source as unverified and unchecked rather than guessing. The table carries two evidence tiers — vendor documentation (13 entries) and **the upstream catalog's own description** (2 entries: `space-bunny` and `minimax-m3.1-flash`, whose descriptions say “native multimodal”) — while a NEW id still needs a vendor source; see the “Image input” section of [docs/DESIGN.md](docs/DESIGN.md). Upstream's `supportsImages` is a *platform* declaration, not the model's capability, so it does not drive that decision at all. You can still tick any box by hand, and your selection is kept locally. **Every model row also carries a “Can disable” (`off`) checkbox**: it decides whether that model gets the “turn thinking off entirely” level. The default comes from a reviewed built-in table (the 9 models that claim the capability but answer HTTP 400 for it start unticked), and you can change it per model — **untick** for a model you do not need the level on. **The 9 tabled models cannot be ticked at all** (their row is marked "refuses off" with an explanatory tooltip): the level is not merely an extra option — pi-ai uses it as the DEFAULT for every request that names no tier, and a compaction summary is exactly such a request, so one tick made every `/compact` for that model fail with HTTP 400 / code 11133 (issue #83). Models outside the table are still decided entirely by your selection and their own declaration; your ticks are saved on first save and recomputed no further.
36
36
 
37
37
  <img src="docs/assets/dsh-connect-workbuddy-model-picker.png" width="420" alt="DSH model picker: the same campaign badge (night discount / Free now) drawn after the model name, per region (no account data)" />
38
38
  - **Campaign badges on model rows** — the upstream model catalog carries campaign information (free trials, night discounts, limited-time free use, subscription-only tiers, and the like). The plugin adds **no extra request** (it reuses the catalog configuration it already fetches when refreshing models) and draws a pill badge right on the model row: the upstream supplies both the colour and the wording, and hovering shows the upstream's campaign text, its start/end dates, and its daily window (e.g. “night 23:00–7:50”). **A badge is a function of the current moment**: it shows only inside the window the upstream declares and disappears on its own when that window closes; a window that crosses midnight is judged in the timezone the upstream declared; when several campaigns hit the same model, only the highest-priority one is drawn. A benefit marker without an end date (such as “subscription only”) stays until upstream withdraws it. **The multiplier shown is the price you actually pay**: while a “night discount” is running, the card and the picker both show the discounted `x0.06` instead of the catalog figure, and both go back on their own when the window closes — no restart needed (issue #120). **A badge is a hint, not behaviour** — it reports the campaign and discount upstream currently advertises, and makes no choice for you. **The same badge now appears in the DSH model picker**: every menu row draws the identical pill after the model name and before the load icon — menu rows use the upstream's short wording ("night", "free"), the composer trigger beside the input uses the full one ("night discount", "exclusive free"); judged from the same data at the same clock, because the screen where the model is chosen is exactly where "is it free right now" matters most. (Both regions' catalogs ship the campaign fields: read as the app, the CN `/v3/config` carries 8 promotions + 1 tier badge and the global one carries 5 + 1; the evidence and the decision rules are written up in [docs/PROMO_BADGE.md](docs/PROMO_BADGE.md).)
39
39
  - **Model load on model rows (CN only)** — the upstream answers "how busy is this model right now" from a separate read-only probe (`POST /v2/chat/busy`, up to 50 ids per call, free, no account state touched). The plugin asks it once per catalog refresh and draws the level as a small figure beside the model name: **the number of people = how many are queueing** (healthy `normal` = one yellow figure, `busy` = two orange ones, `congested` = three red ones), while **idle is a green rocket** (nobody is queueing = full speed ahead) — idle is deliberately *not* drawn as "one green person", because at 12px "nobody is waiting" and "one person is waiting" have to be distinguishable at a glance; **unavailable** is a crossed-out figure. The probe's own `unknown` **draws nothing**: **"we were told nothing" is never reported as "all good"**. Colours follow the theme and the `title` tooltip ("极度拥堵") is still there. **The level is not persisted**: the catalog is a fact that survives a restart, a load level is a fact about that minute, so it is stamped onto the runtime catalog only and dies with the process; a failed probe logs one warning and never blocks the refresh. Measured on the CN gateway: the probe answers byte-identically under the CLI and the app identity, the 50-id ceiling is real (62 ids → HTTP 400), and 19 models come back in 186 ms. **The international region shows no load badge, because the international gateway simply does not have this endpoint** — measured, `www.workbuddy.ai` answers **404** for `/v2/chat/busy` (and for the neighbouring `/v3/chat/busy`, `/v2/models/busy` and friends), while the very same credential reads its `/v3/config` fine (28 models) and that document carries **no load or queue field at all**. This is not something the plugin left unimplemented, and it is not a configuration or permission problem: **upstream has never published this data for the international region**. So the international region shows the model name and campaign badges only; the failed probe degrades quietly to "no badge", never blocking the model list, and the plugin never guesses a load level from latency or credits.
40
40
  - **Queueing tells you your position** — upstream expresses a queue with three business codes (`6020` waiting, `6021` queue full, `6022` this user already at the maximum). Instead of passing along a raw upstream error, the plugin says "模型排队中:你排在第 8777 位,队列共 9021 个请求;约 7 秒后自动重试". **A queue does not trigger failover**: the line is shared platform-wide and bound to the model, so another account is handed the same position — no account-pool rotation, no extra requests burned. (The upstream's `/v2/chat/queue/status` returns an i18n KEY rather than a sentence, so the plugin never relays its `message` and always uses its own wording.) **The "resend once it is your turn" half is not implemented** — that needs the queue answer's real envelope on the OpenAI-compatible channel, and writing it unmeasured would mean code that never runs.
41
41
  - **Tabbed settings card (accounts / models / capabilities / diagnostics)** — the card used to be a single 3,500-pixel column that mixed two things with completely different commit semantics: **operating accounts** (who is serving, how much is left, switch order, check-in log) and **editing the catalog** (ticking models, context budgets, reasoning tiers, turning thinking off). An account change takes effect on the click; a catalog change is a draft that needs Save — so the Save button often sat three screens away from the thing it saves. Now each tab does one thing, and **switching tabs neither refetches nor drops an unsaved draft** (inactive panels stay mounted and are merely `hidden`, so they also leave the accessibility tree). The third tab, Capabilities, holds the **grants**: let the plugin drive the local CodeBuddy CLI, let the model buy an image on its own, where the credit readout is drawn. Each takes effect on the click and never passes through Save, and each is expected to grow sub-options of its own (a working directory for the CLI route, a size or price cap for the image tool) — which is why they no longer share one thin strip above the account table. The fourth tab, Diagnostics, is a read-only fact table: current region, upstream host, the account actually serving (by NAME, never by id), sign-in validity, how many models the catalog holds, how many are enabled, the pool switch, and the **raw text** of the upstream's most recent error (quoted, never translated or summarised) — its only reason to exist is to be pasted into a bug report, so it contains no control that changes a setting.
42
+ - **Optional: a sidebar entry (`sidebarPanel`, OFF by default)** — adds a WorkBuddy row to the DSH sidebar that opens **this card as a full page** (with a "back to conversation" link in the top left). Squeezed into four tabs inside the settings page, the account table, model catalog and diagnostics text each get half a screen; the full page gives them the whole column. **Off by default**: that row occupies a **global sidebar slot shared by every installed plugin**, and the Plugins page already opens the same card — an upgrade should not take that seat on the user's behalf. The switch lives on the Capabilities tab and **takes effect on the click — no Save** — like every other grant there.
43
+ - **Turning it off unregisters, it does not render an empty component.** A sidebar nav row is assembled from the slot entry's **metadata** (`label` plus icon), so a component that returns `null` yields a **blank but still clickable** button. The decision therefore belongs in `apply` (`src/client/panel-switch.ts` is the seam between card and entry), and switching off means `dispose`.
44
+ - **The first-screen state asks the host, not the browser's settings mirror.** That mirror is stale on some 0.1.7 builds and `whileServed` fires on the namespace **edge** only, never on a **value change** — a stale `false` would hide the row for the whole session with no event ever correcting it. So the seed reads the host's own answer (the `sidebarPanelEnabled` field of the usage document).
45
+ - **Switching it off while the page is open returns you to the conversation by itself** (`ui-layout` drops an `activePanelId` whose key no longer exists), so the plugin never navigates. The macOS run is recorded in [docs/MAC-VERIFY-PR188-REPORT.md](docs/MAC-VERIFY-PR188-REPORT.md); the checklist is [docs/MAC-VERIFY-PR188.md](docs/MAC-VERIFY-PR188.md).
42
46
  - **Model availability testing, including cooldown recovery times** — working out when a limited model frees up used to mean guessing through repeated failures. Now every model row has a **Test** button that gives you a direct answer for whether the model works right now and, if not, when it comes back. **It sends a real-volume request (about 25k input tokens)**, rather than "ping it and see if it answers" — because the upstream throttles on request **SIZE** (measured: about 20k tokens pass, about 30k are refused), so a small request looks fine while every request in a long conversation may be refused. That is exactly where "the test passes but I am limited" came from. **Where the recovery time comes from**: the upstream's 429 carries **no** `Retry-After` header (and no `X-RateLimit-*`), but it writes the reset time into the response **body** — `{"code":6004,"msg":"…将在 2026-09-30 02:30:30 UTC+8 重置…"}`. The plugin parses that time and converts it using the UTC offset the message states, so the result does not depend on your machine's timezone; the card then shows “✗ Rate limited · usable again after 2026/9/30 02:30:30”. When none of the sources states a time, the plugin **never invents a countdown** and says plainly that no time was given. A rate limit deliberately does **not** borrow the monthly refresh time, which would tell you to wait weeks for a limit that clears in seconds. **A success never has a cooldown**: this gateway also attaches `Retry-After` to a 200, and its value is the account's monthly quota reset (measured: `2026-11-01 00:00 +08:00`) — not a wait. So a successful row shows “✓ Usable” and never appends “usable again after”, and records written by older builds with that stray time are healed on read. Probes run in the Host, so **the credential never reaches the page**, and results are not written to settings — your saved selection is untouched.
43
47
  - **Image generation tool `workbuddy_draw_image` (CN and international, OFF by default, granted per region)** — hands WorkBuddy's text-to-image capability to the agent: say "draw me a cat sunning itself on a windowsill" in the conversation and the model calls the tool itself, then posts the image back. **It is off by default**, because it is the one capability here where the MODEL decides to spend: about 5.71 credits an image on the CN gateway and about 0.03 on the international one, and the host offers no per-call confirmation. Tick 「Let the model draw images」 on that region's Capabilities tab to enable it; while it is off the tool is **not registered at all**, so the model never sees it and cannot attempt a call that would fail. **Both gateways work, but through two different models**: CN `hunyuan-image-alpha` and international `hy-image-3.5` (the latter measured on 2026-10-25). The two credit pools are independent, so **5.71 and 0.03 are not a cross-region price difference for the same image** — they are two different models on two different gateways, and neither number converts into the other. The grant is **per region**: ticking the box on one tab authorises only that gateway's accounts, and with both ticked the CN gateway wins (the only order that keeps the old behaviour). **Endpoint and request body are copied from the official CLI's ImageService** (`POST /v2/images/generations`), and the product is a 24-hour COS signed URL the plugin tells you to download in time. **The same tool edits images**: pass `image` (a local path, `file://`, `http(s)`, a data URL, or bare base64, up to 8 MB) and it switches to `POST /v2/images/edits` with the model carrying the `image-to-image` tag (CN `hunyuan-image-alpha-edit`, international `hy-image-3.5`); omit it and you get text-to-image — **the mode is decided solely by whether there is an input image, there is no `mode` parameter**. Input images are only normalised into the data URL the gateway accepts: **no rescaling, cropping or format conversion**. An unreadable, malformed or oversized image fails before any request is sent, so it is not a paid failure. **Sizes are not limited to squares, and the ceiling is about 4.19 megapixels** (measured tier by tier on 2026-10-25: `1024x1536`, `2048x2048`, `2048x1536`, `2560x1440` and `2560x1600` all succeed and come back at exactly the requested width and height, not silently downscaled; `2560x2560` and anything larger is refused outright). So the usual answers are `2560x1440` for a 16:9 desktop, `2048x2048` for a large square and `2048x1536` for a wide one; for portrait, put the long edge in the same range — beyond that you need super-resolution, the parameter itself is maxed out. **It really costs money**: about **5.71 credits per image** on CN and **0.03** on the international gateway (both measured), so the tool description gives both magnitudes and says to trust the `credit` each response returns, a failure carries a 30-second cooldown (while a bad parameter, a missing sign-in or an unknown model costs nothing and does not cool down), and there is no "draw four at once" parameter that could spend uncontrollably. The definition is hand-written raw JSON Schema, **adding no dependency**. See [docs/IMAGE_GEN.md](docs/IMAGE_GEN.md) for the evidence, protocol and live run.
44
48
 
45
- **Two things to know.** ① **It really does spend credits** — one measured probe reported `credit` 0.02 (a refused one 429s and costs almost nothing). So testing is **manual and per-model only**: there is deliberately no “Test selected” batch button, because sweeping the whole list from one click is an uncontrolled spend — and the Host enforces the same rule, **accepting a single model only** and refusing multi-model requests. ② The upstream advertises a 1M context yet throttles far below it, and the plugin advertises each model's **native** window to DSH (no longer clamped to 200K as of 3.5.0), so DSH compacts very late — hitting the throttle in a long session follows directly from that. To make DSH compact sooner, set a “DSH context budget” cap on the model's row (200K / 500K / the model's native window).
49
+ **Two things to know.** ① **It really does spend credits** — one measured probe reported `credit` 0.02 (a refused one 429s and costs almost nothing). So testing is **manual and per-model only**: there is deliberately no “Test selected” batch button, because sweeping the whole list from one click is an uncontrolled spend — and the Host enforces the same rule, **accepting a single model only** and refusing multi-model requests. ② The upstream advertises a 1M context yet throttles far below it, and the plugin advertises each model's **native** window to DSH (no longer clamped to 200K as of 3.5.0), so DSH compacts very late — hitting the throttle in a long session follows directly from that. To make DSH compact sooner, set a “DSH context budget” cap on the model's row (200K / 500K / the model's native window). **Which of the three reads as current is decided by the window the backend actually derives** (issue #215): with no cap set, the selected tier is the model's native window, because that is what DSH is told. The native tier means **no cap** — choosing it deletes the model's budget entry rather than storing a number that happens to equal the window, so it keeps following the model if the upstream ever raises it.
46
50
  - **Local account switching** — discovers the multiple sign-in credentials WorkBuddy's desktop app leaves behind and lets you switch per region. Tokens are never written to DSH settings.
47
51
  - **Credit readout in the composer toolbar (follows the selected model, per region)** — a clickable readout sits at the left of the composer toolbar (e.g. `WB CN · 1,072`) and **switches region automatically with the model this session is using**: pick a WB CN model and it shows the domestic balance, pick a WB AI model and it shows the international one; with any other provider's model it does not appear at all. It refreshes every 5 minutes and can also be refreshed by hand. Clicking it opens a panel: a **table of balances per account**, where clicking a row switches to that account (the same setting the card's account picker writes), and an account that cannot serve right now is **labelled in its row** (e.g. rate-limited, out of credits) using the same wording as the account-pool table. The per-account figures are fetched only while the panel is open, so the 5-minute background refresh never multiplies by the account count. To turn a side off, untick “Show credits in the composer toolbar” under that region's tab on the card; while a region's provider is switched off, the readout disappears and its switch is disabled. The same block carries a “Position” line: by default the readout sits in the composer toolbar (the row with the model picker); choosing “below the input box” moves it to the turn/step/token stats row instead — useful when another plugin has taken the toolbar seat.
48
52
 
@@ -333,15 +337,22 @@ tar xzf codebuddy-cred.tgz -C "${XDG_CONFIG_HOME:-$HOME/.config}"
333
337
  dsh plugin --profile web exec dsh-connect-workbuddy status
334
338
  ```
335
339
 
336
- > ⚠️ **On Linux there is no `~/.local/share` path.** The candidate directories come from `defaultDesktopAuthDirs()` in `src/auth.ts`, and **Linux reads only `$XDG_CONFIG_HOME` (defaulting to `~/.config`)**:
340
+ > **On Linux both XDG locations are read, in order** (issue #190 corrected what this note used to say). The candidate directories come from `defaultDesktopAuthDirs()` in `src/auth.ts`:
337
341
  >
338
- > | Platform | The credential directory the plugin actually reads |
342
+ > | Platform | The credential directory the plugin actually reads (in probe order) |
339
343
  > | --- | --- |
340
344
  > | macOS | `~/Library/Application Support/CodeBuddyExtension/Data/Public/auth` |
341
- > | Linux | `${XDG_CONFIG_HOME:-~/.config}/CodeBuddyExtension/Data/Public/auth` |
345
+ > | Linux | ① `${XDG_CONFIG_HOME:-~/.config}/CodeBuddyExtension/Data/Public/auth` ② `${XDG_DATA_HOME:-~/.local/share}/CodeBuddyExtension/Data/Public/auth` |
342
346
  > | Windows | `CodeBuddyExtension\Data\Public\auth` under `%LOCALAPPDATA%` and `%APPDATA%` |
347
+ > | HarmonyOS | `${WORKBUDDY_USER_HOME:-/storage/Users/currentUser}/.local/share/CodeBuddyExtension/Data/Public/auth` |
343
348
  >
344
- > So **unpacking into `~/.local/share` alone will not be seen** — either unpack into the directories listed above, or point `WORKBUDDY_AUTH_FILE` straight at the auth file (when set explicitly, sibling backup files in that directory are still scanned, so account switching keeps working).
349
+ > This note previously said "on Linux there is no `~/.local/share` path" — that was **the implementation at the time**, not a platform fact. `Data/Public/auth` is data, so by XDG convention it belongs under `$XDG_DATA_HOME`, and the machine in issue #190 did keep it there.
350
+ >
351
+ > ⚠️ **`~/.config` still comes FIRST.** The order decides which copy is used when `WORKBUDDY_AUTH_FILE` is unset, and `~/.config` has been the behaviour since day one; the Linux candidates have never been verified item by item on real hardware, so promoting the new directory would change what existing users resolve without evidence to back it. This change only adds a candidate.
352
+ >
353
+ > On HarmonyOS, `os.homedir()` returns an **app sandbox** (`/data/storage/el2/base/haps/entry/files`), not the user's home, so the path comes from the fixed system mount point instead — override it with `WORKBUDDY_USER_HOME` when your layout differs.
354
+ >
355
+ > You can always bypass all of these defaults: point `WORKBUDDY_AUTH_FILE` straight at the auth file (when set explicitly, sibling backup files in that directory are still scanned, so account switching keeps working). Unpacking into `~/.local/share/...` now works too — it is the second Linux candidate — but `~/.config/...` is still checked first, so unpack there if you want the copy you just placed to be the one that wins.
345
356
 
346
357
  > 🔐 **Encrypted credentials (WorkBuddy 5.6.0 and later) cannot be carried over this way.** Recent desktop builds encrypt the token fields inside the auth file, and the key is fetched at runtime from the app's native binding and never written to disk. On a server without the app, copying the encrypted auth file over **will not be readable** (the plugin reports not-signed-in honestly rather than degrading into reading a truncated token). What works: carry the credential from a machine still running a pre-5.6.0 version or an unencrypted credential, or install the app on that server to obtain the key.
347
358
  >
@@ -476,6 +487,7 @@ The outbound identity profile (`wireProfile`) and the device-header tier (`devic
476
487
  | `WORKBUDDY_TURING_PRODUCT_NAME` | `WorkBuddy` | Product name the SDK initialises with |
477
488
  | `WORKBUDDY_TURING_PRODUCT_VERSION` | plugin version | Product version the SDK initialises with |
478
489
  | `WORKBUDDY_TURING_KEYCHAIN_STORAGE` | unset (= off) | Set to `1` to let the SDK enable its own device-cache storage; off by default — the plugin does not write device state into the user's keychain |
490
+ | `WORKBUDDY_DEVICE_SDK_ENABLED` | unset (= off) | Bypass for the SDK master switch, for `doctor` and other standalone processes that cannot read the plugin config: `1` / `true` = on. The card's switch of the same name (`deviceSdkEnabled`, **off by default**) is the normal entry point; both mean the same thing and the plugin always passes a value explicitly. Off means no discovery, no child process, no prewarming. To check whether the SDK works at all, run `WORKBUDDY_DEVICE_SDK_ENABLED=1 node lib/bin.js doctor` |
479
491
 
480
492
  > **Why these three commands work on a machine with nothing installed (issue #47)**
481
493
  >
package/README.md CHANGED
@@ -40,7 +40,11 @@
40
40
  - **插件卡片 tab 切换** —— 设置卡片顶部为「国内版 / 国际版」两个 tab,各含独立的账号池与模型管理;每个 tab 的账号、目录、勾选与未保存草稿完全隔离——在一个 tab 里切账号或刷新模型,不会触碰另一边的运行时目录与会话。
41
41
  - **可单独关闭任一版本供应商** —— 每个 tab 右侧有一个勾选框(默认都勾选)。**取消勾选即把该供应商从 DSH 模型选择器里彻底撤掉**(不是只藏起 tab):它的路由与「设置 → 模型」页的目录条目一并摘除,启动时也不再为它发无用请求。账号、积分、目录与勾选**全部保留**,重新勾选即完整恢复。典型用法是「我根本用不到国际版」——关掉它,让选择器干净。注意:若某会话此前选中的正是被关闭供应商的模型,该会话再调用会报 `NO_ADAPTER`,卡片会在关闭态的 tab 上明确提示这一点,不会静默失败。
42
42
  - **设置卡片分四栏:账号 / 模型 / 能力 / 诊断** —— 原来这张卡片是一列 3000 多像素的长页,把两类互不相干的事情混排在一起:**运维账号**(谁在服务、还剩多少、切换顺序、签到日志)与**编辑目录**(勾模型、上下文预算、推理档、关闭思考)。它们连提交语义都不同——账号改动点一下即生效,目录改动是草稿、必须点保存——所以「保存」按钮常常离它要保存的东西隔着三屏。现在分栏,一栏只做一件事;**切栏既不会重新拉取,也不会丢掉未保存的目录草稿**(非活动栏留在页面里,只是通过 `hidden` 不可见,因此也不进入无障碍树)。第三栏「能力」放的是**授权类开关**——允许调用本机 CodeBuddy CLI、允许模型自主生图、积分读数显示在哪——它们点一下即生效、从不经过保存,而且每一个都留着长自己子选项的位置(CLI 的工作目录、生图的尺寸或价格上限),所以不挤在账号表格上方那一小条里。第四栏「诊断」是只读的事实表:当前区域、上游域名、真正在服务的账号名、登录有效期、目录里共几个模型、启用了几个、账号池开关,以及上游最近一次错误的**原文**(原样引用,不翻译、不概括)——这一栏存在的唯一理由就是能被整段贴进问题反馈,所以里面没有任何会改设置的控件。
43
- - **模型管理** —— 从上游刷新完整模型目录,逐项勾选启用或禁用;刷新是草稿操作,点保存才生效。上游同时给出积分倍率、上下文/输出上限与推理档位;**每个模型行上有一个「默认推理强度」选择器**(issue #179):请求未指定档位时该模型用哪一档——新对话、压缩摘要、会话标题都属于这类请求。选项就是该模型自己声明的那些档位(名册里 `deepseek`/`glm-5.3` 是 `low/high/max`,`glm-5.2` 是 `high/xhigh`,`space-bunny` 有五个,所以只能逐模型选、不能全局一个值),第一项是「默认(high)」——括号里写明上游为这个模型声明的档位。**这一行同时也是原来那行只读「推理强度:…」的替代**——选择器已经列全了档位,不必再多说一遍。**「关闭思考」不在这里**,它仍是下面那个 `off` 勾选框的职责。**图片输入按核验表判定**:刷新时只有核验表收录为原生多模态的模型才自动勾选,写明纯文本的不勾,**没有资料的 id 一律按「未核实」不猜**(上游的 `supportsImages` 是平台侧声明,不等于模型能看图,不参与判定)。核验表分两档证据——厂商文档(13 条)与**上游目录自述**(2 条:`space-bunny`、`minimax-m3.1-flash`,各自的描述里写着「原生多模态」)——但新增 id 仍要求厂商来源,详见 [docs/DESIGN.md](docs/DESIGN.md) 的「图片输入」一节。用户仍可随时手动勾选,勾选状态保存在本地。**每个模型行还有「可关闭思考」(`off`)勾选框**:决定要不要为该模型提供「完全关闭思考」这一档位。默认由内置复核名单给出(上游声称可关闭、实测却对它返回 HTTP 400 的 9 个模型默认不勾),你可以按模型改勾/取消——**取消**用于当前不需要该档位的模型;**名单内那 9 个模型不可勾选**(行上标「拒绝 off」,悬停有说明):该档位被勾上后不只是多一个选项,pi-ai 会把它当作**所有未指定档位请求的默认值**,压缩摘要请求正属于这一类,勾一次等于让该模型的每一次 `/compact` 都 400 / 11133(issue #83)。名单外的模型仍完全由你的勾选与自身声明决定;首次保存即写入你的勾选,之后不再重算。
43
+ - **可选:侧边栏入口(`sidebarPanel`,默认关闭)** —— 在 DSH 侧边栏加一行 WorkBuddy,点开就是**这张卡片的整页版**(左上有「返回会话」)。卡片以四栏挤在设置页里时,账号表格、模型目录与诊断原文都只有半屏宽;整页版把同一批东西摊到整栏。**默认关闭**:这一行占的是**所有已安装插件共用的全局侧边栏座位**,而「插件」页本来就能点开同一张卡片,一次升级不该替用户占这个位置。开关在「能力」栏,**勾上即出现、取消即消失,不走保存**——与这一栏其它授权类开关一致。
44
+ - **关掉时是把注册注销,不是渲染空组件**:侧边栏导航行是用槽位**条目元数据**(`label` + 图标)拼的,组件返回 `null` 只会得到一颗**空白但仍可点**的按钮。所以决策点在 `apply`(`src/client/panel-switch.ts` 是卡片与入口之间的接缝),关掉即 `dispose`。
45
+ - **首屏状态问宿主,不问浏览器里的设置镜像**:那份镜像在部分 0.1.7 上是陈的,且只在命名空间**边缘**触发、不在**值变化**时触发——一份陈的 `false` 会让这一行整个会话都不出现,且没有任何事件来纠正它。所以种子读宿主自己的答案(usage 文档的 `sidebarPanelEnabled`)。
46
+ - **开着面板时关掉,中间栏自己回对话**(`ui-layout` 丢掉已不存在的 `activePanelId`),不需要插件去导航。macOS 实测记录见 [docs/MAC-VERIFY-PR188-REPORT.md](docs/MAC-VERIFY-PR188-REPORT.md),验证清单见 [docs/MAC-VERIFY-PR188.md](docs/MAC-VERIFY-PR188.md)。
47
+ - **模型管理** —— 从上游刷新完整模型目录,逐项勾选启用或禁用;**勾选是草稿,点保存才生效**(issue #214)。目录与价格不等人:刷新会把这次读到的目录**直接记下来并立刻生效**,因为价格不属于草稿——上游倍率随时会变,把新价锁在草稿里意味着卡片继续显示旧价、`/usage` 与刷新按钮各说一套(报告者实测:刷新得 `glm-5.3` 0.69,卡片却仍显示 0.79)。所以**目录与倍率**随刷新即刻落盘、即刻生效,**你的勾选、上下文预算、图片勾选与默认推理档**仍然只在点保存时提交;刷新不会替你把没保存的改动一起写下去。上游同时给出积分倍率、上下文/输出上限与推理档位;**每个模型行上有一个「默认推理强度」选择器**(issue #179):请求未指定档位时该模型用哪一档——新对话、压缩摘要、会话标题都属于这类请求。选项就是该模型自己声明的那些档位(名册里 `deepseek`/`glm-5.3` 是 `low/high/max`,`glm-5.2` 是 `high/xhigh`,`space-bunny` 有五个,所以只能逐模型选、不能全局一个值),第一项会写明真正会用的那一档——括号里先是上游为这个模型声明的档位,上游没声明时则是该模型自己的**中档**(不是最弱的那一档,免得默认把思考调低)。**这一行同时也是原来那行只读「推理强度:…」的替代**——选择器已经列全了档位,不必再多说一遍。**「关闭思考」不在这里**,它仍是下面那个 `off` 勾选框的职责。**图片输入按核验表判定**:刷新时只有核验表收录为原生多模态的模型才自动勾选,写明纯文本的不勾,**没有资料的 id 一律按「未核实」不猜**(上游的 `supportsImages` 是平台侧声明,不等于模型能看图,不参与判定)。核验表分两档证据——厂商文档(13 条)与**上游目录自述**(2 条:`space-bunny`、`minimax-m3.1-flash`,各自的描述里写着「原生多模态」)——但新增 id 仍要求厂商来源,详见 [docs/DESIGN.md](docs/DESIGN.md) 的「图片输入」一节。用户仍可随时手动勾选,勾选状态保存在本地。**每个模型行还有「可关闭思考」(`off`)勾选框**:决定要不要为该模型提供「完全关闭思考」这一档位。默认由内置复核名单给出(上游声称可关闭、实测却对它返回 HTTP 400 的 9 个模型默认不勾),你可以按模型改勾/取消——**取消**用于当前不需要该档位的模型;**名单内那 9 个模型不可勾选**(行上标「拒绝 off」,悬停有说明):该档位被勾上后不只是多一个选项,pi-ai 会把它当作**所有未指定档位请求的默认值**,压缩摘要请求正属于这一类,勾一次等于让该模型的每一次 `/compact` 都 400 / 11133(issue #83)。名单外的模型仍完全由你的勾选与自身声明决定;首次保存即写入你的勾选,之后不再重算。
44
48
 
45
49
  <img src="docs/assets/dsh-connect-workbuddy-model-picker.png" width="420" alt="DSH 模型选择器:同一枚活动徽标(夜间折扣 / Free now)画在模型名之后(无账号信息)" />
46
50
  - **模型行上的活动徽标** —— 上游的模型目录里带着活动信息(免费试用、夜间折扣、限时免费、订阅优先等),插件**不新增任何请求**(复用刷新模型时本来就会拉的那份目录配置),直接在模型行上画一枚胶囊徽标:颜色与文案都由上游给出,悬停能看到上游的活动说明、活动的起止日期与每日生效时段(例如「夜间 23:00–7:50」)。**徽标是「此刻」的函数**:活动只在它自己声明的时间窗内显示,窗口一关徽标就自己消失;跨零点的时段按上游声明的时区判断;同一个模型命中多条活动时只画优先级最高的那条。上游没给结束时间的权益标记(如「订阅优先」)则常驻,直到上游把它下架。**徽标只是提示,不改变模型行为**——它标注的是上游此刻给出的活动与折扣,不替你做选择。**同一枚徽标也出现在 DSH 的模型选择器里**:菜单每一行都在模型名之后、队列图标之前画同样的胶囊 —— 菜单行用上游的短词(「夜间」「限免」),输入框旁那个触发器用完整词(「夜间折扣」「独家限免」);判定用的是同一份数据、同一个时钟,因为选模型的那一屏正好是最该看到「现在免费吗」的地方。(两个区域的上游目录都下发活动字段:国内版按 App 身份读 `/v3/config` 时带 8 条促销 + 1 条等级标记,国际版带 5 条 + 1 条;取证与判定规则见 [docs/PROMO_BADGE.md](docs/PROMO_BADGE.md)。)
@@ -48,9 +52,9 @@
48
52
  - **排队时说清楚你排在第几位** —— 上游用三个业务码表达排队(`6020` 等待、`6021` 队列满、`6022` 已达上限)。撞上它们时,插件不再给一句上游报错,而是「模型排队中:你排在第 8777 位,队列共 9021 个请求。请稍后重新发送这条消息,或换一个模型」。**排队不会触发换号**:队列跟随的是模型与平台级的队伍,换个账号拿到的还是同一个位次,所以这里既不走账号池也不额外烧请求(上游 `/v2/chat/queue/status` 回的 `message` 是 i18n key 而不是人话,插件因此从不转述它,只用自己的措辞)。**排队不会自动重发,也不会被自动重试**——插件没有排队轮询循环(它需要排队答案在 OpenAI 兼容通道上的真实信封,没测到就不写),并且明确告诉宿主不要重试(`x-should-retry: false`):一次排队在几千位之后,重试十几次也轮不到,只会把真实请求白白花掉。位次报出来,由你决定是重发还是换模型。
49
53
  - **模型可用性测试(含冷却恢复时间)** —— 限量模型的冷却时间过去只能靠反复试错去猜。现在每个模型行有一个「测试」按钮,直接告诉你它此刻能否使用、不能用时何时恢复。**它发的是一条真实体积的请求(约 25k 输入 token)**,而不是「发个 ping 看通不通」——因为上游的限流**按请求体积触发**(实测约 20k 能过、约 30k 被拒),小请求看着正常、长对话里却可能每次都被拒,那正是「测试通过、实际被限」的来源。**恢复时间的来源**:上游的 429 **不带** `Retry-After` 响应头(也没有 `X-RateLimit-*`),但它把重置时间写在**响应体**里——`{"code":6004,"msg":"…将在 2026-09-30 02:30:30 UTC+8 重置…"}`。插件从响应体解析该时间(并按其声明的 UTC 偏移换算,不受你本机时区影响),因此卡片能直接显示「✗ 被限流 · 2026/9/30 02:30:30 之后可再用」。三处来源都没说时,插件**不编造倒计时**,如实显示「上游未给出何时恢复」。限流**不会**去借月周期包的刷新时间(那会让人为几秒的限流去等几周)。**成功即无冷却**:这个网关在 200 响应上也会带 `Retry-After`,值是账号月度积分包的刷新时刻(实测 `2026-11-01 00:00 +08:00`),它不是「你在此之前不能用」——所以成功的行只显示「✓ 可用」,绝不附「之后可再用」;旧版本已经写进文件的那类记录会在读取时自动治愈。探测在后台发起,**凭据不会传到页面**;结果不写入设置,也不改变你已保存的勾选。
50
54
 
51
- **两点需要知道**:① **它真的花钱**——实测一次报 `credit` 0.02(被限流时直接 429,几乎不花)。因此**只能按单个模型手工点**,没有「测试已勾选」这类批量按钮:一次覆盖整个列表就是一次不可控支出(服务端也据此**只接受单个模型**,多模型请求会被拒)。② 上游虽宣称 1M 上下文,但节流线远低于此;插件按模型的**原生窗口**向 DSH 宣称(3.5.0 起不再默认压到 200K),所以 DSH 很晚才压缩对话——长会话撞限流是这条机制的直接结果。想让 DSH 更早压缩,就在模型行上手动设一个「DSH 上下文预算」上限(可选 200K / 500K / 模型原生窗口)。
52
- - **生图工具 `workbuddy_draw_image`(国内版 / 国际版,默认关闭,逐区授权)** —— 把 WorkBuddy 的文生图能力交给 agent:你在对话里说「帮我画一只在窗台上晒太阳的猫」,模型自己就会调用这个工具,画完把图贴回来。**默认不开启**,因为这是本插件里唯一一项「由模型自己决定花钱」的能力:国内区约 5.71 积分一张、国际区约 0.03 积分一张,而宿主没有「调用前先确认」的机制。想用就去卡片「能力」栏那个区勾上「允许模型自主生图」;不勾的时候这个工具**根本不会注册**,模型看不到它,也就不会发起注定失败的调用。**两个区都能用,但用的是两个不同的模型**:国内区 `hunyuan-image-alpha`(5.71 积分/张),国际区 `hy-image-3.5`(0.03 积分/张,2026-10-25 实测)。两者的积分池彼此独立,**5.71 与 0.03 不是同一张图的跨区差价**,只是一个读数,别拿它做汇率换算。勾选是**逐区**的:在一个 tab 里勾上只授权那一区的账号;两区都勾着时优先国内区(与升级前的行为一致)。**端点与请求体照抄官方 CLI 的 ImageService**(`POST /v2/images/generations`),产物是 24 小时有效的 COS 签名 URL,插件会提醒你及时下载。**同一个工具也能改图**:给 `image` 参数(本地路径 / `file://` / `http(s)` / data URL / 裸 base64,上限 8 MB)就自动切到 `POST /v2/images/edits` 并用带 `image-to-image` 标签的模型(国内 `hunyuan-image-alpha-edit`、国际 `hy-image-3.5`),不给就是文生图——**模式由「有没有图」唯一决定,没有 `mode` 参数**。输入图只归一成上游要的 data URL,**不缩放、不裁剪、不转格式**;读不到图、格式错、超限都在发请求之前报错,不算一次花钱的失败。**尺寸不限于方图,上限约 419 万像素**(2026-10-25 逐档实测:`1024x1536` / `2048x2048` / `2048x1536` / `2560x1440` / `2560x1600` 都成功且输出宽高与请求一致;`2560x2560` 起被直接拒绝,不会悄悄降级),常见回答是「桌面 16:9 用 2560x1440、方形大图 2048x2048、横图 2048x1536,竖版把长边放到同一档」;再大只能走超分,单纯调参数已经到顶。**它真的花钱**:单价随区域与模型不同,所以工具描述里同时写了两个区的量级,并要求以返回的 `credit` 为准;失败后有 30 秒冷却(但参数写错、没登录、模型不存在这三类一分钱没花,不进冷却),也不提供「一次画四张」这类不可控支出的参数。工具定义是手写的 raw JSON Schema,**没有引入任何新依赖**。取证、协议与联调记录见 [docs/IMAGE_GEN.md](docs/IMAGE_GEN.md)。
53
- - **视频生成工具 `workbuddy_draw_video`(国内版 / 国际版,默认关闭,逐区授权)** —— 把 WorkBuddy 的视频能力交给 agent:「帮我把这段描述做成 5 秒视频」,模型自己调用工具,跑完把 **mp4 的本地路径**贴回来(视频是二进制,只回 `file://` 路径并渲染成链接,不塞进对话体)。**它和生图不是一个形状**:视频是**异步任务**,`POST /v2/videos/generations` 只回一个 `taskId`,插件再轮询 `POST /v2/videos/tasks` 直到 `completed`(5 秒一次、上限 10 分钟),最后把产物下载到 `os.tmpdir()/workbuddy-video-gen/`。**同一个工具也做图生视频**:给 `image` 参数(与生图同一套输入形态)就切到 `image-to-video` 标签组并按输入图决定比例,不给就是文生视频——**模式由「有没有图」唯一决定**。其余参数:`seconds`(默认 5,须在该模型 `[min,max]` 内)、`resolution`(不在模型 `resolutions` 内会回落默认值并给出告警)、`aspect_ratio`(仅文生视频,`16:9`/`9:16`/`1:1`)、`negative_prompt`、`enable_audio`。**默认不开启**、逐区勾选「允许模型自主生视频」,不勾时工具**根本不注册**;失败后 60 秒冷却,但参数错、没登录、读不到输入图、以及**上游在建任务之前就退回的 4xx**(它明说没扣积分)这类**一分钱没花**的失败不进冷却——改完参数可以立刻重试,不用白等一分钟;上游若在拒绝文案里报了时长区间(`supported range: 4-15 seconds`),插件会记住它,下次同样的越界值直接在本地拦下。**模型可按模式钉住**:卡片「能力」栏在视频开关下方按文生 / 图生各给一行选择框,写进 `preferredVideoModels`(按区、按标签存);它是**软约束**——显式 `model` 写错照旧报错,钉住的模型若已从目录里消失则静默回落到组内第一个。两个区的模型目录不同(国内区 `kling-video-v3` / `minimax-video-h3`,国际区 `kling-video-v3`),id 不跨区。**实测单价(国内区)**:图生视频 4 秒 57.14(`minimax-video-h3`)/ 68.57(`kling-video-v3`),文生视频 5 秒 71.43 / 128.57 积分;**产物实测**是 H.264 + AAC、24fps 的 `1280x720` 或 `1344x768`(没有 1080p,`resolution: "1080p"` 会被拒并回落默认),视频码率 3.7–11.5 Mbps,秒数以 24fps 帧数为准(请求 5 秒得 5.09–5.17 秒)。取证、协议与联调记录见 [docs/VIDEO_GEN.md](docs/VIDEO_GEN.md)。
55
+ **两点需要知道**:① **它真的花钱**——实测一次报 `credit` 0.02(被限流时直接 429,几乎不花)。因此**只能按单个模型手工点**,没有「测试已勾选」这类批量按钮:一次覆盖整个列表就是一次不可控支出(服务端也据此**只接受单个模型**,多模型请求会被拒)。② 上游虽宣称 1M 上下文,但节流线远低于此;插件按模型的**原生窗口**向 DSH 宣称(3.5.0 起不再默认压到 200K),所以 DSH 很晚才压缩对话——长会话撞限流是这条机制的直接结果。想让 DSH 更早压缩,就在模型行上手动设一个「DSH 上下文预算」上限(可选 200K / 500K / 模型原生窗口)。**这三档里哪一个是「当前」由后端算出的实际窗口决定**(issue #215):没设过预算时选中的就是模型原生窗口,因为 DSH 拿到的正是它;「模型原生窗口」这一档对应的是**没有上限**,选中它会把这个模型的预算条目删掉,而不是写一个恰好等于窗口的数字——这样上游日后调大该模型的窗口时,这一档会跟着变大。
56
+ - **生图工具 `workbuddy_draw_image`(国内版 / 国际版,默认关闭,逐区授权)** —— 把 WorkBuddy 的文生图能力交给 agent:你在对话里说「帮我画一只在窗台上晒太阳的猫」,模型自己就会调用这个工具,画完把图贴回来。**默认不开启**,因为这是本插件里唯一一项「由模型自己决定花钱」的能力:国内区约 5.71 积分一张、国际区约 0.03 积分一张,而宿主没有「调用前先确认」的机制。想用就去卡片「能力」栏那个区勾上「允许模型自主生图」;不勾的时候这个工具**根本不会注册**,模型看不到它,也就不会发起注定失败的调用。**两个区都能用,但用的是两个不同的模型**:国内区 `hunyuan-image-alpha`(5.71 积分/张),国际区 `hy-image-3.5`(0.03 积分/张,2026-10-25 实测)。两者的积分池彼此独立,**5.71 与 0.03 不是同一张图的跨区差价**,只是一个读数,别拿它做汇率换算。勾选是**逐区**的:在一个 tab 里勾上只授权那一区的账号;两区都勾着时优先国内区(与升级前的行为一致)。**端点与请求体照抄官方 CLI 的 ImageService**(`POST /v2/images/generations`),产物是 24 小时有效的 COS 签名 URL,插件会提醒你及时下载。**同一个工具也能改图**:给 `image` 参数(**字符串数组**,元素可以是本地路径 / `file://` / `http(s)` / data URL / 裸 base64,上限 8 MB;一张图也要写成 `["/abs/a.png"]`)就自动切到 `POST /v2/images/edits` 并用带 `image-to-image` 标签的模型(国内 `hunyuan-image-alpha-edit`、国际 `hy-image-3.5`),不给就是文生图——**模式由「有没有图」唯一决定,没有 `mode` 参数**。输入图只归一成上游要的 data URL,**不缩放、不裁剪、不转格式**;读不到图、格式错、超限都在发请求之前报错,不算一次花钱的失败。**`size` 是必填参数,不写就直接报错**——早期版本不填会静默按 `1024x1024` 出图,模型于是学会了「什么都不写,让它自己猜」,最后连横竖都没交代就出一张方图。现在写成「宽x高」或 `auto`(工具描述里按「具体像素 → 比例词 → 档位词 → 改图 `auto` → 用途 → 表外比例 → 只提方向 → 默认档」八阶顺序命中,命中即停;比例词单列一阶是因为「9:16」「3:4」既不是像素也不是档位,「改成 9:16」曾经会掉进 `auto` 那阶、输出仍是横图还不报错;这一阶里每个比例词只对应一个像素值——旧稿写「『9:16』`1440x2560` 或 `1024x1536` 按长边需求选」,而后一个其实是 2:3,选它等于对用户说谎;用途表每行自带方向、命中一行就用它,只有用户另外明说的方向与该行不符时才改——第十二轮补的那条链尾裁决句「用途和方向同时出现时按方向」第十三轮被删了,因为它自己造了双解:「做张手机壁纸,横着看的那种」会同时命中用途表的竖档和裁决句的横档;现在方向并进表里,「配张图,要横的」直接给 `1536x1024`,不会出成方图;第十五轮又拆出两阶——「表外比例」(4:5、21:9、5:4)不再写「套最近档」,而是**给算式**(长边尽量取 2560、宽乘高不超 4,194,304,超了就把长边往下取、另一边按比例算完取整:21:9 → `2560x1097`,4:5 → `1831x2289`,回复里写明实际出的比例),「只提了方向」单独成一阶统管所有方向词(横 `1536x1024` / 竖 `1024x1536` / 方 `1024x1024`),④ 与 ⑤ 都只留引用——**引用悬空比重复更危险:重复最多是不一致,悬空是那一条请求根本没有出口**;第十七轮又补三处:`1080P` / `720P` 各给横竖两个值(只写 `1920x1080` 时「1080P 手机壁纸」只能落横图,与「手机壁纸算竖」正面冲突)、`①` 步明说「规整这一步是你自己做」(schema 的 `pattern` 只收 `x`/`X`/`×`,带空格或 `*`、`by` 的值会被宿主直接拒掉)、`⑥` 表外比例的例子改成能被算法复核的 `21:9 → 2560x1097` 与 `4:5 → 1831x2289`——旧例子 `1600x2000` 长边既不是「尽量 2560」、面积也只有 3.2M,照着算和照着抄得到两个不同答案):合法范围是两边各 512–2560 像素、宽乘高不超过约 419 万像素(2026-10-25 逐档实测:`1024x1536` / `2048x2048` / `2048x1536` / `2560x1440` / `2560x1600` 都成功且输出宽高与请求一致;`2560x2560` 起被直接拒绝),**越界不再报错**——`fitIntoRange()` 会按「`2560/长边`」与「`√(4194304/面积)`」中更小的比例等比缩/放后照常出图,并在 `hint` 里写明「按你给的 X 缩放成 WxH」,同时用 `requestedSize` 回带你原本写的值(写 `auto` 时就是 `auto`),所以「用户要 4K、实际出 2560x1440 档」这件事可以被程序识别、不必正则抠散文(`4K` 在描述里不设独立档:横竖方分别与 2K 同档,因为工具上限是**单边 2560、面积 4,194,304**,写不出真 4K——上限只能用这一组数说,`2048x2048` 才是顶格的那一档)。`region` 与 `size` 都在输出的 `required` 里(两个都由工具自己算,一定在),想按区记账或按尺寸做后处理直接读字段即可。**改图(带 `image`)推荐直接写 `size: "auto"`**:工具会从图片字节里解出第一张的宽高(PNG / JPEG / GIF / WEBP),按同比例给一个长边 1024–1536 的画布(`1600x900` → `1536x864`),模型看不到原图也不必猜比例——只有比对 5:1 更细长、等比缩数学上解不出合法值时,才退回方向常用档并在 `hint` 里写明「比例有变化」。**改图如果写了具体比例(不是 `auto`),裁切/留白这件事要在调用前说**:模型调用前量不到输入图比例,事后问「要不要改用 auto」等于先用掉一次积分再问——现在的写法是「先说一句会按这个比例裁切/留白、原版式可能被切,他同意再调」。本地因此只剩一种尺寸失败:比例极端到缩不出合法值(`INVALID_ARGS`,不扣积分)。再大只能走超分,单纯调参数已经到顶。**它真的花钱**,所以工具描述第二段就把价目写出来——国内版约 5.71 积分/张、国际版约 0.03 积分/张(同一计量单位、相差约 190 倍),模型和你开局就知道这一张多少钱,并且知道「走哪个区这一次改不了、也查不到,只能以返回的 `region` 为准」(所以描述里不要求模型在调用前报价,只要求如实报两个区、并点明差约 190 倍);真实扣费仍以返回的 `credit` 为准,结果里同时写明**这次走的是国内版还是国际版**、用的哪个模型、实际扣了多少积分(区域从凭据 domain 现算,两区都开着时优先国内版)。描述里不点名具体模型 id,免得模型主动去猜——`model` 一般留空最稳;失败后有 30 秒冷却(但参数写错、没登录、模型不存在这三类一分钱没花,不进冷却),也不提供「一次画四张」这类不可控支出的参数。工具定义是手写的 raw JSON Schema,**没有引入任何新依赖**。第十九轮又收了三处「同一件事两个口径」:① 尺寸链的入口加了**主体门禁**——主体没问清之前整条链一条都不许走(旧稿 (a) 让他先问「想画什么」、第 2 阶又已经把 `2560x1440` 填好,「随便画个 `16:9` 的」于是自编主体扣一次费);② 用途表补了**方行遇方向**那一支(配图是方行,旧稿只写「横行要竖」「竖行要横」,「给这篇文章配张图,要横的」无定义、会填 `1024x1024` 与同段例子 `1536x1024` 打架);③ **批量只剩一张同意卡**——旧稿开头让「先报张数和总价」、紧接着又让「多版挑一张先出 1 张」,用户批的是 4 张预算、拿到 1 张;现在统一成「先出 1 张给你看,满意再按张补后面的,每张单独计费」。同时把「重试」写成一次**新的计费决策**(`INVALID_ARGS` / `NOT_LOGGED_IN` 改完直接重试,其余情形重试前按两档重新报价取同意),并把「已经拿到过 `credit`」收紧成「**本次调用**拿到过」——190 倍差正是跨区、跨模型产生的,拿上一次的单价报这一次等于报错价。第二十、二十一轮又收了三处**同一事实两个出口**:① 用户说「我这张是 1600x900」时,① 的触发词(数字 + x)会先吞掉它、脚注又说该写 `auto`——现在第 4 阶第一句先分类「这是输出尺寸还是输入图尺寸」,输入尺寸永远不填进 `size`;② 「单张不必为『要不要花一次积分』单独请示」这句被两个盲读子代理判成最危险的一句(它把授权扩张到不等裁切确认也能扣费),换成一份**五条清单**(超过一张 / 改变原图版式 / 要真调才能报价 / 主体没定 / 用户要的做不到)——命中两条以上合成一次问完,都不成立才直接调;③ 主体例子原来「秋季新品静物」是正例、「秋季新品」是反例,而用户原话正是后者,现在换成「一束向日葵」。第二十二轮又收掉三处「照字面执行必然出错」:① **4K 不再既算档位词又算「做不到」**——七条第 5 条原来写「用户要的东西本工具做不到(真 4K…)」要先停,第 3 阶又让「照 2K 填、出完再说明」直接调,同一句「来张 4K 壁纸」两个出口;现在清单里只留「明确要 `3840x2160` 这类超过 2560 的像素」——**档位词是用户的说法,不是他的诉求**。② **改图的「告知」与「请示」钉进同一个句号**:(b) 说单张只告知、④ 说裁切要等同意,「把这张 `1600x900` 改成 `9:16`」同时命中两条,裁切不可逆、价格可逆,不能共用一句话。③ **「4 张要多少钱」有了分支**:只说张数没说同异时,先问「要一样的还是各不相同的」。另修 ③ 的 4K 算术错(`3840x2160` 是 16:9,等比缩是 `2560x1440`;`2560x1350` 属于`4096x2160`),并把 ⑤ 的「方向 × 用途」三支枚举收成「冲突就交换宽高、相同就照这一行走」。第二十二轮第三批又把三处「作用域/台词」收掉:① **多图三态从「超过一张」的门里提出来**——「要一样就做不到、不报价不调用」原来写在「要超过一张时先判」这道门内,用户说「上次那张再画一遍,要一样」只要 1 张、门不成立,「直接调」与「不调用」两条都逐字可读(0 次或 1 次扣费),现在改成「跟要几张无关,先判要的是『一样』还是『不同』」,并把「没有 seed、不存历史、不能重放」提为全局事实;② **改图的 prompt 台词只剩一套**——旧稿一处让写「只换画布」、另一处让只写「保持主体和光线不变」,而「只换画布」是事实错误(工具会裁切或留白,画面内容会变);③ **4K 那句话术收窄成条件句**——只有用户提的档位超出上限时才补「最长边 2560」,只说 2K 的用户不再被告知「出不了真 4K」。另把「只提了方向」从用途表里拆走(「竖版海报」要说到「海报」才算用途,只说「竖版」是方向词),并给第 4 阶补一句「同一句里既有输入图尺寸又有比例时,输入那个数不参与匹配」——旧派发顺序会让「这张 4000x1000 的图改成 4:5」填成 4000x1000、被缩成 `2560x640`,方向相反还照扣费。取证、协议与联调记录见 [docs/IMAGE_GEN.md](docs/IMAGE_GEN.md)。
57
+ - **视频生成工具 `workbuddy_draw_video`(国内版 / 国际版,默认关闭,逐区授权)** —— 把 WorkBuddy 的视频能力交给 agent:「帮我把这段描述做成 5 秒视频」,模型自己调用工具,跑完把 **mp4 的本地路径**贴回来(视频是二进制,只回 `file://` 路径并渲染成链接,不塞进对话体)。**它和生图不是一个形状**:视频是**异步任务**,`POST /v2/videos/generations` 只回一个 `taskId`,插件再轮询 `POST /v2/videos/tasks` 直到 `completed`(5 秒一次、上限 10 分钟),最后把产物下载到 `os.tmpdir()/workbuddy-video-gen/`。**同一个工具也做图生视频**:给 `image` 参数(字符串或单元素字符串数组、**只收一张**——与生图那边「纯数组、可多张」不同)就切到 `image-to-video` 标签组并按输入图决定比例,不给就是文生视频——**模式由「有没有图」唯一决定**。其余参数:`seconds`(默认 5,须在该模型 `[min,max]` 内)、`resolution`(不在模型 `resolutions` 内会回落默认值并给出告警)、`aspect_ratio`(仅文生视频,`16:9`/`9:16`/`1:1`)、`negative_prompt`、`enable_audio`。**这八个以外的字段一律 `INVALID_ARGS`**:`size`(生图那边才有的)、`ratio`、`n`、`return_base64` 这类从别的生图工具串进来的写法会在发请求前就被点名拒掉,而不是静默忽略让模型以为横竖版生效了——视频按次扣积分,一次几十秒,错一次代价不小。**默认不开启**、逐区勾选「允许模型自主生视频」,不勾时工具**根本不注册**;失败后 60 秒冷却,但参数错、没登录、读不到输入图、以及**上游在建任务之前就退回的 4xx**(它明说没扣积分)这类**一分钱没花**的失败不进冷却——改完参数可以立刻重试,不用白等一分钟;上游若在拒绝文案里报了时长区间(`supported range: 4-15 seconds`),插件会记住它,下次同样的越界值直接在本地拦下。**模型可按模式钉住**:卡片「能力」栏在视频开关下方按文生 / 图生各给一行选择框,写进 `preferredVideoModels`(按区、按标签存);它是**软约束**——显式 `model` 写错照旧报错,钉住的模型若已从目录里消失则静默回落到组内第一个。两个区的模型目录不同(国内区 `kling-video-v3` / `minimax-video-h3`,国际区 `kling-video-v3`),id 不跨区。**实测单价(国内区)**:图生视频 4 秒 57.14(`minimax-video-h3`)/ 68.57(`kling-video-v3`),文生视频 5 秒 71.43 / 128.57 积分;**产物实测**是 H.264 + AAC、24fps 的 `1280x720` 或 `1344x768`(没有 1080p,`resolution: "1080p"` 会被拒并回落默认),视频码率 3.7–11.5 Mbps,秒数以 24fps 帧数为准(请求 5 秒得 5.09–5.17 秒)。取证、协议与联调记录见 [docs/VIDEO_GEN.md](docs/VIDEO_GEN.md)。
54
58
 
55
59
  - **本机账号切换** —— 自动发现 WorkBuddy 桌面端留下的多个登录凭据,可按区域切换账号;Token 不写入 DSH 设置。
56
60
  - **对话输入框积分读数(国内版 / 国际版自动切换)** —— 对话输入框左侧工具栏常驻一行可点击的读数(如 `WB CN · 1,072`),**按本会话当前选中的模型自动切换区域**:选中 WB CN 的模型就显示国内版余额,选中 WB AI 的模型就显示国际版余额;用其它 provider 的模型时该读数完全不出现。每 5 分钟自动刷新,也可点开手动刷新。点击读数弹出面板:**按账号列出的余额表格**,点某一行即可切换到该账号(与卡片上的账号选择是同一个设置);**当前不能用的账号会在行内标出原因**(如「被限流」「积分耗尽」),标注口径与账号池表格一致。面板里的余额只在打开时才去查,因此不会让 5 分钟的后台刷新按账号数翻倍。要关掉某一边,就在卡片对应区域的 tab 下取消勾选「在输入框工具栏显示积分读数」;该区域的供应商被关闭时,读数不显示、开关也置灰。同一个开关下面还有「显示位置」这一行:默认在输入框工具栏(与模型选择同一行,位于模型选择器左侧、与权限切换器隔开),改成「输入框下方」后读数落到轮次/步数/token 统计那一行——装了别的插件把工具栏座位占掉时用得上。
@@ -271,6 +275,74 @@ dsh plugin --profile web add dsh-connect-workbuddy # Web
271
275
  dsh plugin --profile dsh-tui add dsh-connect-workbuddy # TUI
272
276
  ```
273
277
 
278
+ ### 安装报 `ERR_PNPM_IGNORED_BUILDS`?先看这条
279
+
280
+ ```
281
+ [ERR_PNPM_IGNORED_BUILDS] Ignored build scripts: <某个包>
282
+ dsh: plugin command failed; diagnostics: …/operation-xxxx/pnpm.log
283
+ ```
284
+
285
+ **这个错误几乎总是别的插件的,不是本插件的。** 本插件的 `dependencies` 只有
286
+ `@deepseek-ai/schemastery` 一个,没有任何 `preinstall` / `install` / `postinstall`
287
+ 脚本,也没有 `optionalDependencies` 或原生模块(`native/turing-sdk/worker.cjs` 是
288
+ 纯文本 JS)。所以它不可能产生「被拦下的构建脚本」。
289
+
290
+ 那为什么装本插件时会报?**因为 pnpm 每次 `add` 都会重新校验整个 profile 的依赖树。**
291
+ 如果树里已经有某个包声明了构建脚本、而 pnpm 没有拿到批准,`strictDepBuilds`
292
+ (pnpm 11 起的默认值 `true`)就会让**这一整次安装失败**——装的哪个包都一样。实测
293
+ 在同一个 profile 里装 `dsh-better-sidebar`、`dsh-better-reasoning-effort` 也会报
294
+ 同一句,而干净的 profile 装本插件是 1.5 秒成功。
295
+
296
+ **怎么定位是哪个包。** 看报错里 `Ignored build scripts:` 冒号后面那个名字,那是
297
+ **别人的包**。例如:
298
+
299
+ ```
300
+ [ERR_PNPM_IGNORED_BUILDS] Ignored build scripts: dsh-purge@file:../../vendor/dsh-purge
301
+ ```
302
+
303
+ `@file:…` 说明它不是从 npm 装的,而是一个**本地目录**。上面这个路径是相对 profile
304
+ 目录写的:`<DSH Home>/profiles/<profile>/../../vendor/dsh-purge` 就是
305
+ `<DSH Home>/vendor/dsh-purge`。也就是说这个包被放在了 DSH Home 下的 `vendor/` 里,
306
+ 再由 profile 以 file 协议引用。这类包最容易出问题:它的 `postinstall` 指向的文件
307
+ 可能没被打进那个目录,于是即使放行,执行时还会报 `Cannot find module …`。
308
+
309
+ (路径按报错原文推算,用来定位是哪个目录;具体是谁、为什么把包装在那里,得看那个
310
+ 包自己的安装说明。)
311
+
312
+ **三条修法,按推荐顺序:**
313
+
314
+ 1. **卸掉那个包**(最干净)——如果它不是你正在用的插件:
315
+ ```sh
316
+ dsh plugin --profile <你的profile> remove <那个包名>
317
+ ```
318
+ 2. **让 pnpm 不再因为被拒的构建脚本整体失败**——编辑 profile 的
319
+ `pnpm-workspace.yaml`(位置:`<DSH Home>/profiles/<profile>/pnpm-workspace.yaml`,
320
+ Windows 上是 `C:\Users\<你>\.dsh\profiles\<profile>\pnpm-workspace.yaml`),加一行:
321
+ ```yaml
322
+ strictDepBuilds: false
323
+ ```
324
+ 这不会执行任何脚本,只是把「有脚本没被批准」从**错误**降级为**警告**。
325
+ 3. **显式放行那个包**——只有在你确实需要它的构建脚本时:
326
+ ```yaml
327
+ allowBuilds:
328
+ "dsh-purge@file:vendor/dsh-purge": true
329
+ ```
330
+ ⚠️ 两件事:key 必须是**完整标识**——写 `"dsh-purge@file:vendor/dsh-purge"`,
331
+ 只写包名 `dsh-purge` 在 pnpm 11 里对 `file:` 依赖不生效(实测仍报同一句);
332
+ 而且放行后会**真的去执行**那个脚本,如果它本身是坏的,你会从
333
+ `IGNORED_BUILDS` 变成 `Cannot find module`——那就回到第 1 条,卸掉它。
334
+
335
+ > 这三条与 [issue #204](https://github.com/dingminhua/dsh-connect-workbuddy/issues/204)
336
+ > 对应。那条 issue 里的自动摘要把原因写成「本插件依赖了原生模块、pnpm 默认拦了它的
337
+ > 构建脚本」,**这个归因是错的**——那个 `dsh-purge` 不是本插件的依赖。
338
+ >
339
+ > 那个自动摘要来自插件市场(`dsh-plugin-hub`)安装器,已在其
340
+ > [#583](https://github.com/dshplugin/dsh-plugin-hub/issues/583) 里修正:从 2.2.8 起,
341
+ > 当 `Ignored build scripts:` 里的包**全是** `file:` / `link:` 本地依赖时,它不再
342
+ > 归因给被装的那个插件(已发布的插件不可能依赖用户 profile 里的路径),改为提示
343
+ > 用户自己去 profile 的 `package.json` 里找那些 `file:` / `link:` 条目。混合列表
344
+ > (本地 + registry)仍归给作者,因为其中可能真有插件的传递依赖。
345
+
274
346
  ## 更新
275
347
 
276
348
  > **市场里显示几就是几,那是快照;`npm view dsh-connect-workbuddy version` 与 [Releases](https://github.com/dingminhua/dsh-connect-workbuddy/releases) 才是准的。**
@@ -310,7 +382,7 @@ dsh plugin --profile desktop exec dsh-connect-workbuddy doctor # 第一行就
310
382
 
311
383
  | 方面 | Windows | macOS | Linux |
312
384
  | --- | --- | --- | --- |
313
- | 凭据默认目录 | `%LOCALAPPDATA%` / `%APPDATA%` 优先,未设时回落 `<home>\AppData`(重定向配置文件仍可解析) | `~/Library/Application Support/CodeBuddyExtension/Data/Public/auth` | `$XDG_CONFIG_HOME` 优先,未设时回落 `~/.config` |
385
+ | 凭据默认目录 | `%LOCALAPPDATA%` / `%APPDATA%` 优先,未设时回落 `<home>\AppData`(重定向配置文件仍可解析) | `~/Library/Application Support/CodeBuddyExtension/Data/Public/auth` | `$XDG_CONFIG_HOME`(缺省 `~/.config`)**先**,其后追加 `$XDG_DATA_HOME`(缺省 `~/.local/share`)(issue #190) |
314
386
  | 桌面 App 可执行文件 | `%LOCALAPPDATA%\Programs\WorkBuddy`、`%LOCALAPPDATA%\WorkBuddy`、两个 `Program Files`(按 `WorkBuddy.exe` 定位) | 读 bundle 的 `Info.plist` 取 `CFBundleExecutable`(真实值 **`Electron`**,不是按 App 名猜);含国际版 `WorkBuddy AI.app` 与 `/Applications` 下的子目录 | 不适用(加密凭据场景下 Linux 无对应 App;用 `WORKBUDDY_AUTH_FILE` 指定凭据) |
315
387
  | 进程心跳的时间戳来源 | PowerShell `Get-Process` 的 `StartTime`(POSIX 无 `ps -lstart` 等价物) | `ps -o lstart=` | `ps -o lstart=` |
316
388
  | 子进程的窗口 | **必须 `windowsHide`**:宿主本身没有控制台(GUI 进程),漏设会让每次探测都在屏幕上闪一个可见的黑框 | 不适用(该选项仅 Windows 生效) | 不适用 |
@@ -345,15 +417,20 @@ tar xzf codebuddy-cred.tgz -C "${XDG_CONFIG_HOME:-$HOME/.config}"
345
417
  dsh plugin --profile web exec dsh-connect-workbuddy status
346
418
  ```
347
419
 
348
- > ⚠️ **Linux 上没有 `~/.local/share` 这条路。** 插件的候选目录由 `src/auth.ts` 的 `defaultDesktopAuthDirs()` 决定,**Linux 只读 `$XDG_CONFIG_HOME`(缺省 `~/.config`)**:
420
+ > **Linux 会依次看两套 XDG 目录**(issue #190 修正了这里原先的说法)。插件的候选目录由 `src/auth.ts` 的 `defaultDesktopAuthDirs()` 决定:
349
421
  >
350
- > | 平台 | 插件实际读取的凭据目录 |
422
+ > | 平台 | 插件实际读取的凭据目录(按探测顺序) |
351
423
  > | --- | --- |
352
424
  > | macOS | `~/Library/Application Support/CodeBuddyExtension/Data/Public/auth` |
353
- > | Linux | `${XDG_CONFIG_HOME:-~/.config}/CodeBuddyExtension/Data/Public/auth` |
425
+ > | Linux | ① `${XDG_CONFIG_HOME:-~/.config}/CodeBuddyExtension/Data/Public/auth` ② `${XDG_DATA_HOME:-~/.local/share}/CodeBuddyExtension/Data/Public/auth` |
354
426
  > | Windows | `%LOCALAPPDATA%` 与 `%APPDATA%` 下的 `CodeBuddyExtension\Data\Public\auth` |
427
+ > | HarmonyOS | `${WORKBUDDY_USER_HOME:-/storage/Users/currentUser}/.local/share/CodeBuddyExtension/Data/Public/auth` |
428
+ >
429
+ > 这里原先写着"Linux 上没有 `~/.local/share` 这条路"——那是**当时的实现**,不是平台事实。`Data/Public/auth` 是数据,按 XDG 惯例本就在 `$XDG_DATA_HOME` 下,issue #190 的报告机器实测也在那里。
430
+ >
431
+ > ⚠️ **但 `~/.config` 仍然排在前面。** 顺序决定"不设 `WORKBUDDY_AUTH_FILE` 时用哪一个",而 `~/.config` 是上线以来的行为;Linux 候选从未经真机逐项验证,把新目录提到前面会改变老用户的解析结果而没有证据支撑。这次只做加法。
355
432
  >
356
- > 所以**只把凭据解到 `~/.local/share` 是不会被读到的**——要么解到上面列出的目录,要么用 `WORKBUDDY_AUTH_FILE` 直接指向那份 auth 文件(显式指定时该目录下的同级备份文件仍会一并扫描,账号切换照常可用)。
433
+ > 仍然可以完全不依赖这些默认值:用 `WORKBUDDY_AUTH_FILE` 直接指向那份 auth 文件(显式指定时该目录下的同级备份文件仍会一并扫描,账号切换照常可用)。
357
434
 
358
435
  > 🔐 **加密凭据(WorkBuddy 5.6.0 起)不能靠搬运解决。** 新版桌面端把 auth 文件里的 token 字段加密了,密钥由 App 的原生绑定在**运行时现取**、不落盘。因此一台没有 App 的服务器上,即使把加密后的 auth 文件拷过去也**读不出来**(插件会如实报告未登录,而不会退化成读出一个残缺 token)。可行的做法是**从一台仍在运行 5.6.0 之前版本、或凭据未加密的机器上搬运**,或者在该服务器上安装 App 以取得密钥。
359
436
  >
@@ -491,6 +568,8 @@ dsh plugin --profile <web|desktop|dsh-tui> exec dsh-connect-workbuddy logout #
491
568
  | `WORKBUDDY_TURING_PRODUCT_NAME` | `WorkBuddy` | SDK 初始化自称的产品名 |
492
569
  | `WORKBUDDY_TURING_PRODUCT_VERSION` | 插件版本 | SDK 初始化自称的产品版本 |
493
570
  | `WORKBUDDY_TURING_KEYCHAIN_STORAGE` | 未设(=关) | 设 `1` 允许 SDK 启用其自身的设备缓存存储;默认关闭——插件不把自己的设备状态写进用户机器的钥匙串 |
571
+ | `WORKBUDDY_DEVICE_SDK_ENABLED` | 未设(=关) | SDK 总开关的**旁路**,供 `doctor` 这种读不到插件配置的独立进程使用:`1` / `true` = 开。卡片里的同名开关(`deviceSdkEnabled`,**默认关**)是常规入口;两者同义,插件永远显式传值,所以不会打架。关着时不发现 SDK、不起子进程、不预热。排障时想看「这个 SDK 到底能不能用」,用 `WORKBUDDY_DEVICE_SDK_ENABLED=1 node lib/bin.js doctor` 临时打开 |
572
+ | `WORKBUDDY_USER_HOME` | 未设(=`/storage/Users/currentUser`) | **仅 HarmonyOS**:用户可见的家目录根。鸿蒙上 `os.homedir()` 返回的是应用沙箱(`/data/storage/el2/base/haps/entry/files`),不能用来拼凭据路径,所以由这条变量或系统固定挂载点决定(issue #190) |
494
573
 
495
574
  > **为什么这三条命令能在「什么都没装」的机器上跑(issue #47)**
496
575
  >
package/docs/WINDOWS.md CHANGED
@@ -26,16 +26,17 @@ Windows 在本项目里不是「顺带能跑」的平台,而是**有专属分
26
26
  | 4 | 设置写入回读校验(`src/client/account-selection.ts`) | 写入后**回读校验**:profile 的 `cordis.patch.yml` 被占用会让 rename 覆盖失败,而 `set()` 的 promise 仍 resolve | 用户看到假确认(显示「已清除」但没落盘)→ issue #11 |
27
27
  | 5 | 子进程启动选项:`src/host-heartbeat.ts` `PROCESS_PROBE_OPTIONS` 与 `src/at-rest.ts` `fetchAtRestKeyPayload()` | 一律带 `windowsHide: true`(POSIX 忽略该选项) | **宿主本身没有控制台**(Electron GUI 进程,实测 `MainWindowHandle = 0`),Windows 会给子进程**新建一个可见的控制台窗口** → 每次进程存活判定都在屏幕上闪一次黑框 |
28
28
  | 6 | `src/at-rest.ts` `readAtRestKey()` → `findWorkbuddyAppExecutableWithSource()` | 字段密钥**不带参数**调用时才走注册表回退(`reg query` × 3 个卸载 hive);这个探测曾被**只按成功结果**缓存 | 桌面端不在候选目录、凭据又是加密的机器上,`scanAll()` 会**逐文件**重跑整套探测。issue #77 实测:19.1 s 的请求里 15.3 s 花在 `spawnSync`,约 **135 个 `reg query` 子进程**(`findWorkbuddyAppExecutable()` 被调用 45 次)→ 打开页面白等 60 s。POSIX 上这一支根本不跑,**在 macOS 开发机上永远看不到** |
29
- | 7 | `src/windows-acl.ts` `protectCredentialDirectory()`(issue #183) | 凭据库的访问权限**不能靠 `mode: 0o600`**:Windows 上 `fs.writeFile` / `fs.rename` 的 `mode` 被接受但不生效,权限完全由继承的 DACL 决定。改为在**写入之前**对 vault 根目录发一次 `icacls`(`/inheritance:r` + `*S-1-3-4`、`*S-1-5-18`、`*S-1-5-32-544`,含 `(OI)(CI)`),靠 Windows 的继承传播覆盖整棵子树 | vault 里是**明文** `accessToken` / `refreshToken`。未加固时实测该文件被 `<机器>\CodexSandboxUsers`(DSH 自己沙箱账户)以 `Modify` 读取,且本机 `~/.dsh` 还额外带着 `Everyone: FullControl` → 本机任何低权限进程都能取到可用 JWT |
29
+ | 7 | `src/windows-acl.ts` `protectCredentialDirectory()`(issue #183;issue #208 加了对 `$DSH_HOME` 的拒绝) | 凭据库的访问权限**不能靠 `mode: 0o600`**:Windows 上 `fs.writeFile` / `fs.rename` 的 `mode` 被接受但不生效,权限完全由继承的 DACL 决定。改为在**写入之前**对 vault 根目录发一次 `icacls`(`/inheritance:r` + `*S-1-3-4`、`*S-1-5-18`、`*S-1-5-32-544`,含 `(OI)(CI)`),靠 Windows 的继承传播覆盖整棵子树 | vault 里是**明文** `accessToken` / `refreshToken`。未加固时实测该文件被 `<机器>\CodexSandboxUsers`(DSH 自己沙箱账户)以 `Modify` 读取,且本机 `~/.dsh` 还额外带着 `Everyone: FullControl` → 本机任何低权限进程都能取到可用 JWT |
30
30
 
31
31
  **第 7 条为什么单列**:它是本项目里**第一个「静默失效的防御」**——`mode: 0o600` 看起来像已做了权限限制,代码注释、目录名(`vault`)和既有文档都暗示这一点,而 Windows 上它**什么都不做**。这类缺陷的危险不在于写错,而在于**看起来已经写对了**:没有报错、没有日志、`doctor` 也一切正常。真机取证(2026-10-27,Windows 11)用 `Get-Acl` 读到的事实与代码意图相反,这才把它暴露出来。
32
32
 
33
- **加固的四条实测结论**(A 档,真机 `icacls` / `Get-Acl`):
33
+ **加固的五条实测结论**(A 档,真机 `icacls` / `Get-Acl`;第 5 条来自 issue #208 的现场报告):
34
34
 
35
35
  1. **`/T` 必须禁用**。`icacls <dir> /T /inheritance:r /grant:r "*S-1-3-4:(OI)(CI)(F)"` 会让它走过的**每个文件得到空 DACL**(实测 `ACEcount=0`)——比原来更糟,因为谁都读不了,包括插件自己。正确形态是目录用 `(OI)(CI)`、文件用裸 `(F)`;本实现的写入路径只加固目录,靠传播覆盖文件。
36
36
  2. **一次 `icacls` 覆盖整棵树,不需要遍历**。实测:对一个同时含 `cn/`、`global/` 子目录与文件、且全部带 `Everyone`/`CodexSandboxUsers` 的根目录只跑一次 `icacls`,事后根、两个子目录、子目录里的文件全部变成恰好三条 ACE(`weak=0`)。因此实现里没有按目录遍历,也没有按文件逐个加固。
37
37
  3. **加固必须在写入之前**。`writeFileAtomic` 是「写临时 inode → rename 覆盖」,替换出来的是**新 inode**;写在之后加固既留下 pre-rename 窗口,也会被下一次替换抹掉。
38
- 4. **要加固 vault 根目录,不只是 region 目录**。`Everyone: FullControl` 是从 `~/.dsh` 继承到 `…/workbuddy-vault` 上的;只加固 `<vault>/<region>` 时根目录仍可写,任何进程都能替换掉 region 目录本身。`writeVaultEntry()` 传的是 `dirname(dir)`。
38
+ 4. **要加固 vault 根目录,不只是 region 目录**。`Everyone: FullControl` 是从 `~/.dsh` 继承到 `…/workbuddy-vault` 上的;只加固 `<vault>/<region>` 时根目录仍可写,任何进程都能替换掉 region 目录本身。写入路径因此加固 **vault 根**,由 `src/auth.ts` 的 `vaultRootToHarden()` 决定——**不是**裸的 `dirname(dir)`。
39
+ 5. **绝不可加固 `$DSH_HOME` 本身或其祖先**(issue #208)。`/inheritance:r` 会抹掉 home 下**其它目录**从 home 继承来的 ACE:`attachments`、会话、profile 配置都会变成连属主都读不了。这不是假设——报告者实测 `<DSH_HOME>\attachments` 报 `EPERM: operation not permitted, scandir`,任何图片发送都失败,而 UI 只显示宿主的 `prompt rejected (session/agent-busy)`,把人指向会话与模型能力这类完全无关的方向。**成因**:未按区域限定的 store(`doctor` 用 `makeAnyStore()` 建的那种)其 vault 目录**就是** `<DSH_HOME>/workbuddy-vault`,于是 `dirname` 算出 `<DSH_HOME>`。**两层防护**:`vaultRootToHarden()` 选对目标;`harnessHomeRefusal()` 在 `src/windows-acl.ts` 里对 home **及其祖先**一律返回 `skipped`(不起子进程,且不打印「用 takeown 修复」这类误导性提示)。等价拼写(尾分隔符、`.` / `sub/..`)同样被拒。`tests/issue208-acl-harness-home-guard.spec.ts` 钉住这两层,并同时钉住「一个真实的 vault 根仍然会被加固」——否则这道闸会静默关掉 #183 的全部保护。
39
40
 
40
41
  **成本是这里的一等约束**(A 档实测):`icacls` 是子进程,静止态 19–52 ms,**并行负载下最高 1242 ms**。因此实现遵守两条:一个目录**一次**调用;同一路径**正在进行的**加固被 join 而不重复发起。这不是提前优化——最初「每次写入后再加固一次文件」的版本把 `tests/issue12-region-hiding.spec.ts` 的 1 s 轮询预算顶穿,才定位到成本形态并改成现在这样。**改动这里的调用次数或等待策略时,请以该用例为成本哨兵。**
41
42
 
package/lib/bin.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { $t as readDeviceTokenFile, C as FALLBACK_WORKBUDDY_MODELS_GLOBAL, H as legacyWorkbuddyOwnAuthPath, I as defaultDesktopAuthCandidates, J as APP_VERSION, K as workbuddyOwnAuthPath, L as defaultDesktopAuthDirs, M as WORKBUDDY_VAULT_DIRNAME, N as WorkBuddyCredentialStore, Qt as WORKBUDDY_DEVICE_TOKEN_FILE_ENV, S as FALLBACK_WORKBUDDY_MODELS, Z as DEFAULT_WIRE_PROFILE, a as readHostHeartbeat, an as protectCredentialDirectory, bn as hostPeersInfo, c as WORKBUDDY_CONNECT_VERSION, d as rosterSeenPath, en as ensureDeviceSalt, et as WorkBuddyUpstreamClient, f as piAiRuntimeInfo, fn as findWorkbuddyAppExecutableWithSource, in as inspectCredentialDirectory, it as describeRequestHeaderNames, j as WORKBUDDY_AUTH_FILE_ENV, m as createTuringSdk, nn as deriveDeviceId, o as workbuddyHostHeartbeatPath, on as WORKBUDDY_APP_EXECUTABLE_ENV, q as workbuddyVaultDir, r as isHeartbeatProcessAlive, tn as readDeviceSalt, u as describeRosterSeenPayload, v as readDeviceSettings, xn as resolveDshHome } from "./host-heartbeat-09tOJATV.js";
2
+ import { $t as ensureDeviceSalt, C as FALLBACK_WORKBUDDY_MODELS_GLOBAL, H as legacyWorkbuddyOwnAuthPath, I as defaultDesktopAuthCandidates, J as APP_VERSION, K as workbuddyOwnAuthPath, L as defaultDesktopAuthDirs, M as WORKBUDDY_VAULT_DIRNAME, N as WorkBuddyCredentialStore, Qt as readDeviceTokenFile, S as FALLBACK_WORKBUDDY_MODELS, Z as DEFAULT_WIRE_PROFILE, Zt as WORKBUDDY_DEVICE_TOKEN_FILE_ENV, a as readHostHeartbeat, an as WORKBUDDY_APP_EXECUTABLE_ENV, bn as resolveDshHome, c as WORKBUDDY_CONNECT_VERSION, d as rosterSeenPath, dn as findWorkbuddyAppExecutableWithSource, en as readDeviceSalt, et as WorkBuddyUpstreamClient, f as piAiRuntimeInfo, in as protectCredentialDirectory, it as describeRequestHeaderNames, j as WORKBUDDY_AUTH_FILE_ENV, m as createTuringSdk, o as workbuddyHostHeartbeatPath, q as workbuddyVaultDir, r as isHeartbeatProcessAlive, rn as inspectCredentialDirectory, tn as deriveDeviceId, u as describeRosterSeenPayload, v as readDeviceSettings, yn as hostPeersInfo } from "./host-heartbeat-DFqDsnte.js";
3
3
  import { readFile } from "node:fs/promises";
4
4
  import { dirname, join } from "node:path";
5
5
  import { realpathSync } from "node:fs";
@@ -343,12 +343,15 @@ async function doctor(jsonOutput) {
343
343
  const rootOutcome = await protectCredentialDirectory(dirname(directory));
344
344
  const outcome = await protectCredentialDirectory(directory);
345
345
  const acl = await inspectCredentialDirectory(directory);
346
+ const skipped = [rootOutcome, outcome].find((candidate) => candidate.state === "skipped");
347
+ const failed = [outcome, rootOutcome].find((candidate) => candidate.state === "failed");
346
348
  return [region, {
347
349
  directory: acl.directory,
348
350
  state: acl.state,
349
351
  ...acl.weak === void 0 ? {} : { unexpected: acl.weak },
350
352
  ...acl.reason === void 0 ? {} : { reason: acl.reason },
351
- ...outcome.state === "failed" ? { protectError: outcome.reason } : rootOutcome.state === "failed" ? { protectError: rootOutcome.reason } : {}
353
+ ...failed !== void 0 && failed.state === "failed" ? { protectError: failed.reason } : {},
354
+ ...skipped !== void 0 && skipped.state === "skipped" ? { protectSkipped: skipped.reason } : {}
352
355
  }];
353
356
  }));
354
357
  /** Indexed by region so the human output cannot silently skip a missing one. */
@@ -531,8 +534,13 @@ async function doctor(jsonOutput) {
531
534
  }),
532
535
  ...credentialAcl.flatMap(([region, entry]) => {
533
536
  if (entry.state !== "exposed") return [];
534
- return [`The ${region} credential vault holds PLAINTEXT tokens but its folder permissions do not restrict them${entry.unexpected === void 0 ? "" : ` (readable by ${entry.unexpected.join(", ")})`}: ${entry.directory}. Re-run doctor to retry the repair, or fix it by hand with: icacls "${entry.directory}" /inheritance:r /grant:r "*S-1-3-4:(OI)(CI)(F)" /grant:r "*S-1-5-18:(OI)(CI)(F)" /grant:r "*S-1-5-32-544:(OI)(CI)(F)"`];
535
- })
537
+ return [`The ${region} credential vault holds PLAINTEXT tokens but its folder permissions do not restrict them${entry.unexpected === void 0 ? "" : ` (readable by ${entry.unexpected.join(", ")})`}: ${entry.directory}. Re-run doctor to retry the repair, or fix it by hand with: icacls "${entry.directory}" /inheritance:r /grant:r "%USERNAME%:(OI)(CI)(F)" /grant:r "*S-1-5-18:(OI)(CI)(F)" /grant:r "*S-1-5-32-544:(OI)(CI)(F)"`];
538
+ }),
539
+ ...credentialAcl.flatMap(([region, entry]) => {
540
+ if (entry.state !== "failed" && entry.state !== "unverified") return [];
541
+ return [`The ${region} credential vault ACL could NOT be verified or repaired this run${entry.reason === void 0 ? "" : ` Reason: ${entry.reason}`}: ${entry.directory}. If the directory is suddenly unreadable (EPERM on stat/readdir), its owner is probably not your user account — recover with (elevated): takeown /F "${entry.directory}" /R /D Y && icacls "${entry.directory}" /reset /T, then re-run doctor.`];
542
+ }),
543
+ ...credentialAcl.flatMap(([, entry]) => entry.protectSkipped === void 0 ? [] : [entry.protectSkipped])
536
544
  ]
537
545
  };
538
546
  if (jsonOutput) printJson(report);