agents: DS Bot, wired in the DSH home it runs on

DS Bot (github.com/Fei2411/DS-Bot, Apache-2.0, dsbot.app) is a DSH plugin
and an Electron app built on it. The app ships its own DSH (0.2.2-rc.1 in
0.3.0) and runs it with DSH_HOME at a data folder of its own, booting the
profile ds-bot, and never reads ~/.dsh: magpie's dsh row didn't reach it.

It is a row of its own now, ds-bot (dsbot.go), wired by dsh's code on its
folder (dshOn, split out of dshAt): magpie's routes and start in
profiles/ds-bot/cordis.patch.yml, the key in that folder's .env and
.credentials.yaml. The folder is $DS_BOT_HOME, else locations.json's
dataDir in the app's userData ($DS_BOT_SHELL_DATA, else <config>/DS Bot,
or the legacy DeepSeek Bot), else ~/.ds-bot, as the app's first-run.mjs and
legacy.mjs choose it. A locations.json that can't be read or names no
folder is unknown: nothing is read or written. The routes there list the
models shown for DS Bot on the Agents page (dshListFor), and the serving
round fills a profile the app makes there as it does ~/.dsh's
(dshHomesRounds). Found by DS Bot.app (io.github.fei2411.dsbot) or its
Windows per-user install (guid from its electron-builder.yml). Three
notices, translated into zh, zh-TW, ja and de. DS_BOT_HOME and
DS_BOT_SHELL_DATA are in agentenv's sandbox list.

Run:
- go test ./internal/agent/ ./internal/agentenv/ ./internal/gui/
  ./internal/cli/ ./internal/appdir/ on mote: ok but
  internal/gui TestMainWindowCorners/macOS_26_SDK, red on mote's macOS 27
  whatever the change (#3949).
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet
  ./... on mote: ok. gofmt -l: clean.
- node --test i18n-keys, i18n-en-no-cjk, agent-notice-lang (chromium), and
  agent-notice-lang in webkit: all pass but i18n-keys "a plugin's words
  are its own", red on main for three plugin words (#5332, #5426, #5482).
- Real DS Bot 0.3.0 (DS-Bot-0.3.0-mac-arm64.zip) on mote, all in a sandbox
  HOME with DS_BOT_HOME, DS_BOT_SHELL_DATA and DS_BOT_WORKSPACE under it:
  a magpie built from this tree (nogui), MAGPIE_ADDR 127.0.0.1:3572, a
  fake OpenAI upstream on 3571 added as a provider. `magpie ds-bot
  magpie/fake/m1` before the app was ever opened wrote the profile; the
  app's first start kept it (agent-default-model still magpie's) and added
  its own files beside it. Its Chief Bot offered "Magpie: m1 · fake, m2 ·
  fake"; picking m1 and sending "ping" over CDP went through magpie to the
  fake (POST /v1/chat/completions model m1, stream) and "pong from fake"
  showed. `magpie ds-bot default` then took every magpie entry out and the
  .env with it. Only my own pids (app, serve, fake) were stopped.

Broken by hand, each red, then put back:
- dsbot's desktopApps entry out: TestDsBotWired (not detected).
- dshListFor always "dsh": TestDsBotOwnModels.
- dshHomesRounds without DS Bot's home: TestDsBotProfileMadeWhileServing.
- a bad locations.json taken for ~/.ds-bot: TestDsBotDataFolder.
On the old code the tests don't build (no ds-bot row at all).

Not tried: the Windows app (install path and registry guid read from its
electron-builder.yml, not from an installed copy); Linux (its AppImage and
deb aren't looked for; the data folder its first start makes finds it);
a real vendor behind magpie; a default Bot model set in DS Bot (the notice
says it wins, per its models.js). Not done: usage gives DS Bot no
User-Agent of its own (its DSH's requests likely count as dsh's), and the
Sessions page doesn't read its data folder's sessions.

Reported-by: rnhung
This commit is contained in:
yetone
2026-11-07 05:43:04 +08:00
parent 9ed0f1fa49
commit 49f207c784
13 changed files with 619 additions and 81 deletions
+1
View File
@@ -85,6 +85,7 @@ something else shows up as drift.
- Each of magpie's routes has `streamIdleTimeoutMs: 600000` (`dshIdleWait`), the gateway's own wait for a reply's headers (`upstreamHeaderWait`, 10 minutes). llm-pi-ai gives a turn up after 5 minutes without a pi-ai event (`DEFAULT_STREAM_IDLE_TIMEOUT_MS`, 0.1.5 to 0.2.2), and the gateway's `: keepalive` comments (`keepQueued`, `keepQuiet`) are not events: real dsh 0.2.1-rc.2 timed out at a route's 3000ms with comments every second. A turn queued behind dsh's own title request on a plugin serving one request at a time (magpie-gemini-web, `maxConcurrency: 1`) was cut while the gateway and the plugin still waited, and recorded as 499 (tim on Discord). A value already on the route, set in dsh or by hand, stays (`TestDshRoutesWaitAsLongAsTheGateway`, `TestDshRouteKeepsTheUsersIdleWait`). Codex's comment-blind limit is met in the gateway instead (`agentQuietMost`).
- While magpie serves, `KeepDshWired` writes the routes again every 30 seconds, since dsh writes over its patch list. A round that writes nothing is kept (`dshRounds`), and the next round does nothing when nothing it reads has changed since. It checks the bytes of dsh's files (every profile's `cordis.patch.yml`, the home layer, `settings.yaml`, `.env`, `.credentials.yaml`, `config.yaml`) and the gateway's address. It also checks `provider.StampNow`: no Changed, plugin change or `filememo.Forget`, the same environment, and the providers', settings' and catalog's files unchanged. The models are built again when that stamp moves, and at least every `dshModelsFor` (5 minutes) for what no stamp sees, such as another app's account file or a date-retired model. Building the whole catalog and every route each round allocated 12 GB of a user's 35.7 GB in 48 minutes (`TestDshRoundWithNothingChangedBuildsNothing`, `TestDshRoundAfterAChangeWritesAgain`).
- DeepSeek Harness Desktop (macOS arm64 and Windows x64; no Linux build) reads the same `$DSH_HOME` or `~/.dsh` as the CLI, as its own profile `profiles/desktop` (`resolveDshHome` and `resolveDesktopPaths` in the app's `lib/main.js`; `defaultDshHome` in github.com/deepseek-ai/deepseek-harness's `packages/util/home-paths/src/index.ts` and `apps/desktop/src/paths.ts`), so it takes magpie's routes with no wiring of its own (#2279, liangjinyuan-sihan). A profile dsh makes after another was wired (the app opened for the first time after the CLI's web profile) is given magpie's routes by the catalog sync and the serving round (`dshFillNewProfiles`), with the start model the wired ones start on when that is one of magpie's, and with no start when the user picked one of dsh's own there: only the routes, beside dsh's models. That second case was left as dsh's empty template, so the app's picker listed only the DeepSeek account (zyh6036 on X, `TestDshFillNewProfilesWhenTheStartIsTheUsers`). With no profile wired, none is filled. Only that app, from deepseek-ai/deepseek-harness (bundle id `com.deepseek.dsh`, productName DeepSeek Harness in `apps/desktop/scripts/electron-builder-config.mjs`), is dsh's: the community "DeepSeek Hermes" (motongv/deepseek-hermes-desktop) v0.1.1337 took for it is not listed or written for (WuSix on Discord, `TestDshOnlyTheOfficialApp`). It is found by `/Applications/DeepSeek Harness.app`, by `%LOCALAPPDATA%\Programs\DeepSeek Harness`, or by the folder its current-user installer records under `HKCU\Software\1bf39983-50d0-5fe0-9ef4-cece76f67c5e` (`InstallLocation`), whose Uninstall key gives the version (`registered` in [`desktopapp.go`](../../internal/agent/desktopapp.go)), so a user who picked another folder is found. With the app installed but never opened there is no `~/.dsh`: the row is still listed, and connecting writes `profiles/desktop/cordis.patch.yml` from dsh's own template (`dshProfileTemplate`) with magpie's routes, which the app keeps on its first start, since it writes only the files that are missing. The notice says the app starts on it the first time it opens (`noticeDsh5`). Disconnect before that first start removes the profile magpie made when nothing else is in it (`dshTidyUnopened`); once the app has opened it, the profile stays and only magpie's entries go (`TestDshDesktopNeverOpened`, `TestDshDesktopRegisteredFolder`; the registry as 0.2.1-rc.2's installer writes it, `TestDshWindowsAsTheInstallerRegistersIt`).
- DS Bot (github.com/Fei2411/DS-Bot, Apache-2.0; rnhung on Discord) is a DSH plugin and an Electron app built on it. The plugin, loaded into DSH Desktop or `dsh web`, runs on `~/.dsh` and so takes the dsh row's routes. The app ships its own DSH (0.2.2-rc.1 in DS Bot 0.3.0) and runs it with `DSH_HOME` at a data folder of its own, booting the profile `ds-bot`, and never reads `~/.dsh`, so it is a row of its own, `ds-bot` ([`dsbot.go`](../../internal/agent/dsbot.go)), wired by dsh's code on that folder (`dshOn`). The folder is `$DS_BOT_HOME`, else `dataDir` in `locations.json` in the app's Electron userData (`$DS_BOT_SHELL_DATA`, else `<config dir>/DS Bot`, or `DeepSeek Bot`, its name before, while that one is there and DS Bot's has no `locations.json`), else `~/.ds-bot` (`chooseLocations` and `configureIdentity` in the app's `app/src/first-run.mjs` and `legacy.mjs`). A `locations.json` that can't be read or names no folder is unknown: nothing is read or written, never `~/.ds-bot` in its place. The models listed are DS Bot's own on the Agents page: `dshApps` notes the folder as DS Bot's, and every route written under it is built from `magpieModels("ds-bot")` (`dshListFor`), including the serving round's (`dshHomesRounds`). A new Bot starts on DSH's `agent-default-model` unless a default Bot model is set in the app, and a Bot made before keeps its own (the notice says so). It is found by `DS Bot.app` (`io.github.fei2411.dsbot`) or the Windows per-user install under `HKCU\Software\32c46dfc-ed78-5d41-85a4-a3c7f083f2e0`; Linux's AppImage and deb aren't looked for, so there the folder its first start makes finds it. Installed and never opened, connecting writes `profiles/ds-bot/cordis.patch.yml` from dsh's template, which DS Bot 0.3.0's first start keeps (its template is dsh's byte for byte), and Disconnect before then takes it out (`TestDsBotWired`, `TestDsBotDataFolder`, `TestDsBotProfileMadeWhileServing`, `TestDsBotOwnModels`).
- Ante's `catalog.json` keeps user-added fields in `providers.magpie` the same way (`ante` in [`ante.go`](../../internal/agent/ante.go)); its `auth`, `http_headers`, `extra_body` and `stream_idle_timeout_secs` are what a gateway shared on the local network or reached from WSL needs to send a key. Ante starts a session on the `provider` and `model` of `settings.json`, not on what its catalog holds (#1210), so magpie sets that pair and puts back what it found there; a pick the user makes in Ante while magpie is wired is theirs and stands.
- QwenPaw keeps each agent's model in `active_model` of its workspace's `agent.json` (the agents listed in `config.json` under `$QWENPAW_WORKING_DIR`, a legacy `~/.copaw`, or `~/.qwenpaw`) and its providers as files under its secret folder (`$QWENPAW_SECRET_DIR`, also read from the working folder's `.env`, else `<working folder>.secret`) (`qwenpaw` and `qwenpawAgents` in [`qwenpaw.go`](../../internal/agent/qwenpaw.go)). magpie writes `providers/custom/magpie.json` as QwenPaw's console saves a custom provider (OpenAI Chat at the gateway's `/v1`, the key in plain text, which QwenPaw encrypts at its next start, magpie's models in `extra_models`), keeps what the user changes there (a model's `config_overrides`, headers, generation settings), and sets the agent's `active_model` to `magpie`/`<provider>/<model>`, putting back what it found there. A model with reasoning levels is declared `thinking_param_style: "effort"` with the levels QwenPaw names in `reasoning_effort_options` (no `none`: QwenPaw turns an off into Qwen's and DeepSeek's `extra_body` switches), since QwenPaw applies an agent's `thinking_level` only to a model whose card says how it thinks; the effort field is that `thinking_level` in `agent.json`, written with no `thinking_budget`, `inherit` when cleared. Each QwenPaw agent on QwenPaw's own backend is a row (`qwenpaw#<id>` beside the default's `qwenpaw`); the provider file goes when no agent's model, fallback or subagent model names it. QwenPaw reads `agent.json` again when it changes but its providers only at start-up, so the notice says to restart it after the first connect.
- AstrBot keeps its providers in `data/cmd_config.json` under its root (`$ASTRBOT_ROOT`, else `~/.astrbot`, the desktop app's, else `~/astrbot`), written with a UTF-8 BOM, which magpie keeps (`astrbot` in [`astrbot.go`](../../internal/agent/astrbot.go)). magpie adds a `magpie` entry to `provider_sources` and one `magpie/<model>` entry per model to `provider`, keeps the user's own entries byte for byte and keeps what the user changes in magpie's (timeout, proxy, enable), and sets the default chat model (`agent_runner.config.model.provider_id`, or `provider_settings.default_provider_id` before the agent runner), putting back what it found there. A pick the user makes while magpie is wired is theirs and stands. The first connect copies the file to `cmd_config.json.before-magpie`. AstrBot reads the file only at start-up and its WebUI writes it back whole on save, so the agent's notice says to restart AstrBot before saving in the WebUI. A Docker install's root is inside its container, which magpie doesn't reach.