Commit Graph
68 Commits
Author SHA1 Message Date
yetone 61394481c7 agent: DeepSeek Harness Desktop is found on Linux (AUR, .deb, AppImage entry)
xianhongtao (magpie 0.1.3232, Arch Linux) has DeepSeek Harness Desktop
from the AUR (deepseek-harness-desktop 0.2.2rc.1-1) and no dsh CLI.
magpie knew the app on macOS and Windows only, so it said "DeepSeek
Harness CLI not found ~/.dsh/profiles/web/cordis.patch.yml".

HasApp for dsh now also finds the Linux app (linuxApp, desktopapp_xdg.go):
- a folder holding the Electron executable deepseek-harness with
  resources/app.asar beside it: /usr/lib/deepseek-harness-desktop (the
  AUR's) or /opt/DeepSeek Harness (electron-builder's .deb/.rpm);
- or the app's desktop entry in the XDG data dirs (XDG_DATA_HOME first,
  then XDG_DATA_DIRS, the first file of a name wins, Hidden=true hides
  it): Name=DeepSeek Harness, Type Application, MimeType holding
  x-scheme-handler/dsh, and its Exec program there (on PATH, or an
  absolute executable file: an AppImage anywhere). Scans of a folder are
  kept by its mtime, trusted only when read over a second after it
  changed and for a minute at most.
Linux only; macOS and Windows keep their own checks.

Siblings: everything reading HasApp for dsh follows: the profile a fresh
~/.dsh gets (profiles/desktop), the desktop lead and notices, cliHeld and
CLIMissing (so the GUI's and the CLI's "CLI not found" go away). The
"running" check for noticeDsh2 also knows deepseek-harness, the app's
Linux executable. With both profiles present (the reporter's case) Path
stays profiles/web as on macOS; the desktop lead picks the model shown.

Run (mote, through mote-run):
- go test -count=1 -race -run 'TestDshLinux|TestDshDesktop|TestCodexLinux|Lody' ./internal/agent/: ok
- go test -count=1 ./internal/agent/ ./internal/gui/ ./internal/cli/: ok
- gofmt -l clean; go vet ./...; GOOS=linux go vet -tags nogui ./...;
  GOOS=windows go vet ./...; GOOS=linux/windows go build: ok
Run (wsl-run, magpie-desktop, Ubuntu 24.04): the TestDshLinux tests
-count=3: ok. The first WSL run caught a stale scan of a folder made
again within the same mtime tick; the 1s rule fixes it.

Broken by hand (mote), each red, then restored:
- installed() without onLinux: all three new tests red ("the AUR's app:
  app false, CLI missing true", "the AUR's entry, its program on PATH,
  not found", the profile = profiles/web, want profiles/desktop);
- no scheme check: "another app's entry taken for DeepSeek Harness's";
- no Hidden check: "an entry the user hid still counts".

Not tried: a real AUR, .deb or AppImage install of DeepSeek Harness
Desktop (the fixtures are the AUR PKGBUILD's entry and layout as the
reporter gave them, and AppImageLauncher's entry shape); the GUI suite
(no GUI file changed). The full suite runs after the push.

Reported-by: xianhongtao (Discord)
2026-11-07 19:48:49 +08:00
yetone 49f207c784 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
2026-11-07 05:43:04 +08:00
yetone be5e8f29f1 dsh: its own models are the two it ships, deepseek-flash named DeepSeek-V4.1-Flash (Kylin_Cloud on X)
Kylin_Cloud (X, 11-06, v0.1.2606): DeepSeek Harness's direct models in
magpie listed deepseek-v4-flash, which dsh doesn't have, and showed
deepseek-flash as "DeepSeek-V41-Flash"; dsh's built-ins are only
DeepSeek-V4.1-Flash and DeepSeek-V4-Pro.

Cause: dshModels is a table copied by hand from dsh 0.1.5 (4091b9dfd),
not generated from models.dev and not a label prettifier. dsh's own
table is @deepseek-ai/dsh-llm-deepseek's DEFAULT_MODELS; packed from npm:
  0.1.0-rc.8, 0.1.2-rc.1  deepseek-v4-flash, deepseek-v4-pro (+ vision-exp)
  0.1.5-rc.3              deepseek-flash "DeepSeek-V41-Flash", v4-flash, v4-pro
  0.1.6-alpha.2..0.2.0    deepseek-flash "DeepSeek-V41-Flash", deepseek-v4-pro
  0.2.1-rc.5, 0.2.2-rc.1  deepseek-flash "DeepSeek-V4.1-Flash", deepseek-v4-pro
The installed dsh here (0.2.1-rc.2) has the same two. So "V41" was dsh's
own name from 0.1.5 to 0.2.0, kept after dsh renamed it, and
deepseek-v4-flash left dsh in 0.1.6 while magpie kept offering it.
No other code makes a label from "4.1": V41 is in dsh.go alone.

Now dshModels is dsh's two, named as dsh 0.2.1 on names them. The WSL
(stopped distro) picker reads the same table.

A profile already starting on deepseek-v4-flash: magpie reads it as it is
and doesn't rewrite settings.yaml or the patch list; it is no longer
offered in the list. Since dsh 0.1.6 dsh itself refuses it
(dsh-api-session-controller requireModel: "Select an available model
before sending a message.", it checks listModels, i.e. DEFAULT_MODELS),
so that start was already broken in dsh before this change; picking
either model in magpie or in dsh fixes it.

Siblings pinning the old three: internal/gui's TestAgentOwnModelsHidden
(red under the full suite with the new table, now dsh's two) and the GUI
fixture agent-models-own.test.cjs, which also had made-up labels.

Run (mote, rebased on origin/main f47390bf3):
- TestDshOwnModelsAreDshs: red on the old table (lists deepseek-v4-flash,
  "DeepSeek-V41-Flash"), and red again with only the label fixed (still
  lists deepseek-v4-flash); green with the change.
- go test ./internal/agent: ok.
- node --test agent-models-own.test.cjs (chromium + webkit, en/zh/de/ja,
  narrow and wide): 16/16 ok. i18n-keys: "a plugin's words are its own"
  red, the same three words already filed (#5327, #5332, #5426, #5482),
  not touched by this change.
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet
  ./..., GOOS=linux/windows go build: ok. gofmt -l: nothing.
- go test -timeout 45m ./... (shared lock): every package ok but gui and
  provider. gui: TestAgentOwnModelsHidden (fixed above), and
  TestMainWindowCorners (#3949) and TestPanelHiddenByWailsMarksPageOutOfSight
  (#5322), both filed; provider: TestRenewLoginsKeepsClaudeReading (#5481,
  filed). After the fix go test ./internal/gui: only TestMainWindowCorners
  (#3949) red.

Not tried: a real dsh session started on deepseek-v4-flash (the refusal
above is read from dsh's source); dsh before 0.1.5 (it had no
deepseek-flash; every dsh on npm since 0.1.6 has it); Windows/WSL run.

At the pushed head (rebased on b020ae102, which touches gateway, provider
and agent's Claude Desktop only): go vet ./internal/agent ./internal/gui,
go test ./internal/agent -run Dsh and ./internal/gui -run
TestAgentOwnModels: ok.
2026-11-06 16:51:15 +08:00
yetone 844c355059 dsh: the model shown is the start of the profile in use, and the round's log says what it wrote (#5222)
#5222: with DeepSeek Harness Desktop and four profiles, the desktop
profile started on hy4free while web, headless and open-design started
on deepseek-v4.1-flash, and magpie's log said "wrote dsh's route again"
every half minute or so. Read against dsh 0.2.1-rc.2's own source and
reproduced in a sandbox HOME with dsh's real save (saveSelection through
ConfigEditor.edit and its yaml 2.9.1 library):

- dsh saves a model picked in it into the profile in use alone. The
  profiles drifting apart is dsh's design, and each start is the user's
  own: magpie copies it nowhere.
- magpie never wrote over that pick. After dsh's save the next round
  wrote once, moving magpie's web search entry to follow the new start,
  and then wrote nothing. The log called that "wrote dsh's route again",
  which read as magpie rewriting agent-default-model.
- magpie read the start from the web profile alone, so with the desktop
  app in use the Agents page showed a model its sessions don't start on,
  and picking what it showed changed nothing there.
- A session dsh already has keeps the model of its last request until a
  model is picked in it (selectionFor in dsh-api-session-controller), as
  noticeDsh1 says. The reporter's 429s were OpenCode Zen Free's own free
  limit, reached by a session still on it; the gateway didn't change the
  model.

Now the model and effort fields read the desktop profile when DeepSeek
Harness Desktop is installed (dshLead), else web's as before, and effort
levels are checked against that model. The round logs "dsh's web search
in <file> follows the model it starts on now" when that entry is all it
moved; "wrote dsh's route again" is kept for the route itself.

Run (mote, on origin/main 7dd2434d3; rebased onto 78128b510, which touches
no internal/agent file, and -run TestDsh ./internal/agent run again at
the pushed head: ok):
- go test -run TestDsh ./internal/agent: ok
- go test ./internal/agent, go vet ./internal/agent with GOOS linux and
  windows, gofmt -l: ok (internal/agent 230.6s)
- TestDshShowsTheStartOfTheProfileInUse uses the bytes dsh's own save
  wrote in the sandbox.

Broken by hand, each red:
- dshLead ignoring the desktop profile: "model shown =
  magpie/deepseek/pro, want the desktop profile's magpie/deepseek/flash".
- the search-only write logged as a route write: "the round's log doesn't
  say its one write was the search entry".

Not tried: the real DeepSeek Harness Desktop app with the reporter's
profiles; a user who runs dsh's web profile while the desktop app is
installed still sees the desktop profile's start. Not changed: magpie's
writers find the first agent-default-model entry while dsh writes the
last (dshFind vs findLastIndex); no profile with two was seen (#5229).
2026-11-04 19:23:49 +08:00
yetone 35c47f762f agent: the window's drift poll parses dsh's YAML once per change, not per field and per look
The window asks /api/drift every 15s. On the owner's live magpie a heap
profile showed Drift and Values allocating ~3.3 GB in 37 minutes, most
of it DeepSeek Harness: settings.yaml (80 KB) parsed again for each
field GetYAML read (465 MB of it), and each profile entry's YAML parsed
again on each of dshCheck's looks (dshHomeHas, dshOver, dshConfigIndex,
dshRoutesIn, dshConfig).

- edit.loadYAML memoizes the parsed root through filememo, keyed by the
  file's stat, and shares it with GetYAML, GetYAMLMap, GetYAMLList and
  GetYAMLText, which only read it. Writes go through their own parse as
  before. BlockList skips the decode for a text that starts as a block
  list (blockSequence), which every dsh patch list does.
- dshNodeShared parses an entry's text once and shares the node with the
  read-only lookers (dshConfig, dshConfigIndex, dshRoutesIn, dshOver's
  patch side). The writers (dshOver's base, the route and start writes)
  keep dshNode's own copy. 512 entries kept at most.

Run on mote (macOS 27.2):
- Probe on copies of the owner's real ~/.dsh (settings.yaml, config.yaml,
  the desktop and web profiles; probe not committed, copies deleted):
  a.Values() + a.Drift() per poll, 20 polls: 16381 KB / 223788 allocs
  per poll with the edit change alone -> 4355 KB / 2588 allocs.
- TestGetYAMLParsesTheFileOnce (new): a look at a 3000-entry file
  allocates under a tenth of its size; sees SetYAML, another process's
  write, a removed file and a list-topped file.
  TestBlockSequenceAgreesWithADecode (new): ~24 texts against yaml's own
  decode.
- TestDshLookParsesAnEntryOnce (new): with dshConfig and dshConfigIndex
  put back on dshNode by hand: "27388 allocations, want a few", red.
  Restored: ok. It also checks a writer's change never shows in a look.
- go test ./internal/agent ./internal/edit: ok (164.2s, 5.9s).
  go vet both: ok. gofmt -l: clean.

Not tried: the full suite (only internal/agent and internal/edit
call these); a live window poll after the release.
2026-11-02 06:30:12 +08:00
yetone 3defaf6622 dsh: a new desktop profile gets magpie's routes when the start is the user's (zyh6036 on X)
DeepSeek Harness Desktop 0.2.1-rc.5's picker listed only "DeepSeek 账号".
The app reads $DSH_HOME/profiles/desktop (apps/desktop/src/paths.ts) and
makes it from an empty template on its first start. dshFillNewProfiles
gave such a profile magpie's routes only when a wired profile started on
one of magpie's models; with the web profile wired but started on one of
dsh's own, it returned early and the desktop profile stayed bare. Now a
bare profile gets the routes alone in that case (no start written, the
user's pick stays theirs), and nothing is filled when no profile is wired.

Run:
- go test ./internal/agent -run TestDshFillNewProfiles on mote at
  ed5872d18: the new TestDshFillNewProfilesWhenTheStartIsTheUsers red on
  the old code (desktop profile left as the template), green after.
- go vet ./internal/agent (darwin, GOOS=linux, GOOS=windows) and
  go test -count=1 -timeout 45m ./internal/agent on mote: ok (183s).
- Real DeepSeek Harness Desktop 0.2.1-rc.5 (official zip, sha512 checked
  against nightly-mac.yml) on mote, sandbox DSH_HOME, not signed in:
  first start wrote profiles/desktop/cordis.patch.yml as the empty
  template; with a route-only patch (no agent-default-model), as this
  change writes, the picker listed the Magpie group (35 models).

Broken by hand: the no-profile-wired guard taken out, the test's last
check goes red (web and desktop templates filled).

Not tried: the reporter's own patch (not sent yet); a signed-in DeepSeek
account in the desktop app; the full go test ./... suite; Windows.

At the pushed head (rebased on e84870f17): go test -count=1 -run Dsh
./internal/agent on mote ok, gofmt -l clean.
2026-11-01 13:29:19 +08:00
yetone cdfdb62c69 agent: a model field's list is joined with the catalog once while neither changed
Each agent's model field returned append(its own models,
viaMagpieShared(...)...), a copy of the whole catalog's options for
each field of each agent on every poll: Picks was 94.7 MB of 496 MB
over forty polls of the Agents page with real accounts. withVia keeps
the joined list per agent and prefix while the own models read the same
(sameOption, field by field) and the catalog's list is the very one
kept (same array), and joins it again when either changed. The list is
read only and clipped, as viaMagpieShared's is; every caller of a
field's Options reads it, Picks clones it before it drops anything.
The 52 `return append(own, viaMagpieShared(...)...)` sites call it.
omp's and Reasonix's planner edit the joined list after the append, and
Grok's writes Same into its copy, so they keep their own copies.

TestWithViaKeepsTheJoinedList: the same own models give the same array,
own models changed in a value or only an icon are joined anew, a
provider saved since is listed, and nothing joined is the catalog's own
list. TestSameOptionReadsEveryField sets each field of Option alone and
fails when sameOption doesn't see it. Broken by hand: never answering
from the kept list ("the same own models joined the catalog again"),
and FastFor left out of sameOption ("sameOption doesn't read
Option.FastFor").

Run on mote: both tests alone 3 of 3; internal/agent, internal/tui and
internal/cli ok; internal/gui red only on TestSettingsSaveKeepsWhatItDoesNotSend
(#4514) and TestMainWindowCorners (#3949); gofmt, vet and GOOS=windows
and linux vet clean. Real accounts in a sandbox HOME, forty polls:
Picks 94.7 MB -> 51.2 MB, state 190.8 MB -> 154.0 MB, state and drift
replies byte for byte the same as before. Footprint peak 136 MB.
2026-11-01 07:54:54 +08:00
ggbdpq 1cf66e4b17 agent: a tool asked on Responses says strict: false, its optional parameters stay optional (#3055)
What changed: OpenAI's Responses API takes a function tool whose strict
is left out as a strict-mode one and normalizes its schema, where every
property is required, so a tool's optional parameters came back filled
(#3055, ArakawaHenri). pi-ai (dsh's llm-pi-ai, Pi and its kin) says
strict: false on an ordinary tool only when the model's compat says
supportsStrictMode, which it takes as false where the compat is left
out. magpie now says it: every model of a dsh route whose api stands as
openai-responses carries compat.supportsStrictMode, by the api the route
has now (the one the user picked in dsh's Models page kept), not by its
name, beside the keys they set there (dshKeepCompat); and piModelJSON
says it for a model best served on Responses, which Pi's and StepCode's
models.json carry (Pencil's entries stay on Chat throughout). omp's
models.yml is left alone: omp turns a models.yml away over a field its
schema doesn't name (16.3.5 over a max), so the compat needs an omp
version of its own pinned first. docs/subsystems/agent-wiring.md says
so.

Run: new TestDshTellsAResponsesToolsStrictIsOff and
TestPiTellsAResponsesToolsStrictIsOff fail without the change (the
first with "a model asked on Responses isn't told strict is off:
Compat:<nil>", the second with "resp/gpt-5.5 is asked on Responses and
isn't told strict is off") and pass with it; removing only the dsh case
turns the first red and only it, removing only the piModelJSON compat
line turns the second red and only it. go test ./internal/agent/
(TestMothX fails the same with both files back at the baseline here, so
not from this change), gofmt -l on the changed files (nothing), go vet
./..., GOOS=linux GOARCH=amd64 go vet -tags nogui ./...,
GOOS=windows GOARCH=amd64 go vet ./..., go build . (darwin arm64),
GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build -tags nogui .,
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -tags nogui .,
GOOS=windows GOARCH=amd64 go build -o /dev/null .

Landed (yetone). Broken by hand on mote: with the dsh case and
piModelJSON's compat line taken out, both new tests are red ("a model
asked on Responses isn't told strict is off: … Compat:<nil>",
"resp/gpt-5.5 is asked on Responses and isn't told strict is off").
Run at the pushed head: go test ./... -timeout 45m on mote with this branch on 41b5c0f19: 83 packages ok. internal/gui is red on TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and TestMainWindowCorners (#3949), both red alone at 41b5c0f19 too, and on TestColdTurnsTaken (#4510). internal/update is red on TestRelaunchOpenTriedAgain (#3881). The last two pass alone at 41b5c0f19 and here. Rebased on f856d381a: agent, gateway, plugin, provider and sessions ok, gui red on #4514 and #3949 only, gofmt -l clean, go vet ok for linux (nogui), windows and darwin. Rebased on bb478f0e5: agent and gateway ok, gui the same. The last rebase, onto 573b21f4b, brings in only internal/gui/providers*.go and internal/provider/models.go, which this branch doesn't touch.

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-01 06:21:39 +08:00
yetone bb478f0e50 agent: a look that only ranges over magpie's models reads the list kept
magpieModels gives each caller its own copy of the list it keeps per
agent. Most callers only range over it, or count it, and a range copies
each model anyway, so the copy guarded nothing for them (the models'
own lists were shared before too: the copy was shallow). sharedModels
is the list kept, read only; every `range magpieModels(` and
`len(magpieModels(` in internal/agent (39 files) takes it. Callers that
keep the list, append to it or hand it on still get their copy.

Real accounts (sandbox copy of the owner's HOME, network blocked), 40
polls of /api/state, /api/providers and drift, pprof alloc_space
between two heap snapshots, 616405061 (mrows) vs this (mshare):
  stampedLists.get's slices.Clone 36.7 MB -> gone (under pprof's cut);
  most of it was piOffered (22.5 MB) and claudeViaMagpie (13.7 MB)
  total 637 MB -> 584 MB (runs vary +-25 MB)
  /api/state and drift bodies byte-identical, /api/providers equal but
  for `fetched` and `lapsed` (a refused refresh in the blocked sandbox)

TestModelReadersShareTheList: sharedModels gives the kept array, not a
copy, and no non-test file in internal/agent ranges over or counts
magpieModels(. Broken by hand on mote: sharedModels through get fails
"a shared look copies the kept list"; one `range magpieModels("kimi")`
put back fails naming kimi.go.

Run on mote at this tree (before rebase): gofmt; go vet for darwin,
windows and linux; the new test with TestMagpieModelsKeptWhileCatalogStays,
TestKeptListSharedWithoutACopy and TestViaMagpieKept 3/3 ok;
go test ./internal/agent ok (201s); go test ./internal/gui: only the
known reds TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and
TestMainWindowCorners (#3949).
Not run: the full ./... suite.
2026-11-01 06:09:56 +08:00
yetone dd7442f283 agent: a look at the via-magpie options shares the kept list
viaMagpie handed every caller its own copy of the options list it keeps
per stamp, and a window poll asks for it from most agents' fields and
pickers. In a real-account sandbox (abr.sh, 20 polls of drift, state and
providers on v0.1.2463) those copies were 33.7 MB of slices.Clone, plus
~8 MB more on the way, of the 713 MB the polls allocated.

viaMagpieShared returns the kept list itself, clipped, so an append
makes the caller's own array. The 58 callers that only read it, or
append onto it, now take it; viaMagpie (a copy) stays for the ones that
change it.

TestKeptListSharedWithoutACopy checks that 20 shared looks return the
kept array, and that an append onto a shared look and a write into
get's copy leave the kept list as it was.

Run on mote at this tree:
- gofmt, go vet (darwin, GOOS=windows, GOOS=linux with gateway),
  go build ./...: ok.
- Broken by hand (shared returns slices.Clone): the test is red, "a
  shared look copies the kept list".
- go test -count=1 ./internal/agent: ok (480s).

Not run: internal/gateway and internal/gui packages on this tree.
2026-11-01 04:25:59 +08:00
yetone 544b91ca87 dsh: magpie's routes wait for a slow reply as long as the gateway does (tim on Discord)
tim's first "who are you" to gemini-3.8 through the third-party plugin
magpie-gemini-web 0.8.0 took minutes in dsh and ended in 499 ("the agent
canceled the request"). dsh hung up: llm-pi-ai gives a turn up after 5
minutes with no pi-ai event (DEFAULT_STREAM_IDLE_TIMEOUT_MS, every
dsh-llm-pi-ai from 0.1.5 to 0.2.2), and the gateway's ": keepalive"
comments (keepQueued, keepQuiet) are not events. The plugin serves one
request at a time (maxConcurrency 1), dsh's own session title goes to the
same route model in parallel, and the plugin's backend sends no byte
before its first token, so the turn's 5 minutes ran out in magpie's queue
and the backend while the gateway (10 minutes for headers) and the plugin
(240s per wait, then its own 504) were still waiting.

Every one of magpie's dsh routes (patch lists and deepseek-acp's
settings.yaml, all through dshPutProviders) now has streamIdleTimeoutMs:
600000 (dshIdleWait), the gateway's upstreamHeaderWait. A value already on
the route, set in dsh's Models page or by hand, stays. Codex's
comment-blind limit is still met in the gateway (agentQuietMost); dsh's is
a route setting. The plugin's own slowness is its maintainer's and is not
changed here.

Verified:
- New tests TestDshRoutesWaitAsLongAsTheGateway and
  TestDshRouteKeepsTheUsersIdleWait (internal/agent/dsh_idle_test.go),
  green on mote. Broken by hand: without the field the first fails
  ("route magpie waits 0ms for the next event, want 600000"); without the
  keep the second fails ("sync 1: the user's 120000 became 600000").
- Real dsh 0.2.1-rc.2 (headless, sandbox HOME/DSH_HOME, the route as
  magpie writes it, a fake Chat server on 127.0.0.1:3561 that answers
  after 8s): streamIdleTimeoutMs 3000 -> "TIMEOUT: pi-ai stream idle
  timeout after 3000ms"; 600000 -> "hello there", exit 0. With headers
  sent at once and ": keepalive" every second it still timed out at 3000,
  so comments don't feed the watchdog. dsh-llm-pi-ai 0.1.5-rc.3,
  0.1.7-rc.2, 0.2.0-rc.2 and 0.2.1-rc.5 (npm pack, read) all take the
  field per provider, max MAX_TIMER_DELAY_MS.
- gofmt -l clean. On mote: go vet ./..., GOOS=linux go vet -tags nogui
  ./..., GOOS=windows go vet ./..., go build, GOOS=linux go build -tags
  nogui, GOOS=windows go build: all ok.
- Full suite, go test -tags nogui -count=1 -timeout 45m ./..., on the
  Linux box (wsl-run, magpie-desktop; mote had two full suites running)
  at d714c4216 + this change: 83 packages ok; internal/agent red on
  TestInstalledVersion, TestGrokInstalled,
  TestCursorFolderFromTheEditorIsNotTheCLI, TestOmpDetectedWithPiDir
  (#4033, #3548) and internal/gui on TestSettingsSaveKeepsWhatItDoesNotSend
  (#4514) and TestColdTurnsTaken (#4510). The first five fail the same
  on origin/main 15066f84f run alone there; TestColdTurnsTaken passed
  alone on main and failed alone with this change (5 counts, gui only,
  which this change doesn't touch), as #4510 describes.
- After rebasing on 2597c9636, internal/agent again on the Linux box: the
  new tests pass; reds TestInstalledVersion, TestGrokInstalled,
  TestCopilotFolderFromAnIDEPluginIsNotTheCLI,
  TestQoderSettingsFromAnIDEPluginIsNotTheCLI/qoder-cn,
  TestOmpDetectedWithPiDir, all the #4033 class (Qoder noted there).

Not tried: tim's own setup (the plugin is not run against a Google
account); a real 5-to-10-minute wait in dsh; Windows.
2026-11-01 04:23:05 +08:00
yetone 49b8c64559 dsh: deepseek-acp gets magpie's route in settings.yaml, and the key store is owner-only
liby233 on Discord: dsh in an editor over ACP (deepseek-acp, CodeG, the
desktop app) listed only DeepSeek's own models. Checked against the real
packages from npm (deepseek-acp 0.9.0, dsh 0.2.1-rc.5): deepseek-acp
mounts FileSettings on $DSH_HOME/settings.yaml alone, never profiles/,
and loads the pi-ai plugin only when that file mentions "llm-pi-ai". Its
credentials-local store throws when .credentials.yaml is readable beyond
its owner ("run chmod 600"), so a 0644 store stops it from starting.

- settings.yaml gets llm-pi-ai.providers.magpie, built by the same code
  as the profiles' route (dshPutProviders), at 0600 when magpie creates
  it. It gets no agent-default-model of magpie's. The user's routes,
  other sections, comments, mode and the api they chose for magpie's
  route are kept. Disconnect takes only magpie's route out, and the
  section too when nothing else is left in it.
- dsh 0.2 renames settings.yaml to settings.yaml.imported (over the one
  before) at each full start and imports it into the profile. The
  serving round, Sync, Set and Unwire write it again. The user's own
  import from before magpie's first write is copied once to
  settings.yaml.imported.kept, so magpie's import never overwrites it.
- .credentials.yaml is made owner-only (go-rwx) on every write and every
  Sync, whoever made it 0644. In a WSL distro, a file written through
  \\wsl.localhost comes out 0644, so the chmod runs inside the distro:
  wsl.exe -d <distro> -e chmod go-rwx <path>. A failure is logged and
  doesn't fail the write.

Run:
- internal/agent on mote (ok) and its Dsh/WSL tests on Windows
  (xiaomi-gpu, ok); gofmt; go vet on darwin, GOOS=linux -tags nogui
  and GOOS=windows.
- The new tests (dsh_acp_test.go) were broken by hand, each turning red:
  dshSettingsAgain disabled, ownerOnly disabled, dshKeepImported
  disabled, and the round's call removed.
- Real runs on mote in a sandbox HOME (~/runs/realdsh-home), never a
  live ~/.dsh. After magpie's Pick, real deepseek-acp's session/new
  listed magpie::deepseek/pro and magpie::deepseek/flash; without
  settings.yaml it listed only DeepSeek's. With a 0644 store its boot
  failed with the credentials-local error, and it started once magpie
  had made the store 0600. `dsh --profile web --dump-config` shows
  agent-default-model magpie and the route. `dsh headless` ate
  settings.yaml into the headless profile, and magpie's round
  (dshWiredOnce) wrote it again, after which ACP listed magpie's models
  again.
- On magpie-desktop: `wsl.exe -d magpie-desktop -e chmod go-rwx` takes
  a file written through UNC from 644 to 600.

Not tried:
- magpie's own write into a real WSL distro end to end; only the
  command form above, and fakeWSL in tests.
- A WSL distro has no serving round, so after dsh eats settings.yaml
  there, it comes back only on magpie's next Sync or model pick.
- A dsh from before profiles (config.yaml only) is left as before.

Also: fakeWSL answers the chmod without recording it, since it is neither
a start nor a probe (TestWSLMoreAgentsStopped counts starts).
2026-10-31 22:00:28 +08:00
yetone 73a12e8bf6 wsl: a distro's agent folder that is a link is opened where it leads (#4502)
On Windows, adding a skill or switching RTK on for an agent in WSL failed
with `mkdir \\wsl.localhost\<distro>\root\.codex: Cannot create a file
when that file already exists` (linusxiong). In the distro ~/.codex is a
link to /mnt/c/Users/<user>/.codex. Through \\wsl.localhost Windows can't
follow a link the distro has: a mkdir of it says it exists, and nothing
below it can be made, written, read or listed. ggbdpq found and explained
the link (thanks); their patch, which takes that EEXIST as "there", wasn't
used: the writes below the link fail next (its test passed because a
symlink here is followed).

The fix, for every agent folder and every writer through \\wsl.localhost:
- The WSL probe asks `readlink -f` in the distro where each agent folder,
  its skills folder and the folders beside them lead (wslLinkPaths ->
  distro.Links; a $HOME that is itself through a link is left alone), and
  which drive each Windows mount is (win:/mnt/c C: -> distro.Drives).
- distro.open opens a path at or below a link where it leads: on a Windows
  drive, the drive's own path (C:\Users\<user>\.codex); elsewhere in the
  distro, through \\wsl.localhost again. native spells it back through
  the link, so the agent is told its own path.
- A link readlink couldn't resolve is never guessed at: distro.open
  errors, and the agent is unreached (Agent.Unreached: its notice says
  why; every field Set and Sync returns it).
- Writers: the agents' own files (place.join/place.open, every
  filepath.Join(at.home, ...) in internal/agent), the library's WSL
  targets (wslOpen/wslOpened; one "wsl" problem per agent and nothing
  written), RTK (rtkAt, rtkInstall checks agent.WSLOpen before its mkdir),
  the Sessions page's WSL reads (sessions.WSLHome.Open) and the Copilot
  CLI sign-in read (provider.CopilotWSLHomes -> CopilotWSLDirs).
- Not changed: magpie's image MCP server opens arbitrary paths an agent
  in WSL gives it the same way; filed as #4578. Links deeper than the
  probed paths (other than <agent dir>/skills) aren't resolved. A distro
  probed by an older magpie has no Links until probed again (each run).

Run:
- Real Windows box (xiaomi-gpu, distro magpie-desktop, sandbox
  /tmp/x4502/home with .codex -> /mnt/c/Users/yeton/runs/x4502-target/.codex,
  .claude -> /tmp/x4502/data/claude, .pi -> a missing folder), a throwaway
  Windows test running the real probe with that HOME: probe said
  link:.codex /mnt/c/..., link:.claude /tmp/x4502/data/claude, link:.pi,
  win:/mnt/c C:, win:/mnt/d D:. The old way, MkdirAll(\\wsl.localhost\
  magpie-desktop\tmp\x4502\home\.codex\skills\pdf) = "Cannot create a file
  when that file already exists" (the report's error). distro.open wrote
  SKILL.md to C:\Users\yeton\runs\x4502-target\.codex\skills\pdf and to
  \\wsl.localhost\magpie-desktop\tmp\x4502\data\claude\skills\pdf, both
  read back with cat in the distro through the links; .pi said "~/.pi in
  WSL magpie-desktop is a link magpie couldn't follow". Sandbox and target
  removed after.
- New tests with a fake distro whose ~/.codex and ~/.claude are links to
  /mnt/c/... that don't exist here, so, as through \\wsl.localhost,
  nothing below them can be made: TestWSLFolderIsALinkToC,
  TestWSLFolderLinkUnresolved, TestRTKWSLFolderIsALink,
  TestRTKWSLFolderLinkUnresolved (library); TestWSLProbeLinks (runs the
  probe script), TestWSLOpenThroughLinks, TestWSLAgentFolderIsALink
  (config and a Claude session read on C:), TestWSLAgentFolderLinkUnresolved
  (agent).
- Broken by hand: the library tests on the base (with a no-op
  FakeWSLDrives) fail with "mkdir .../home/me/.codex: file exists", the
  report's error; with ggbdpq's patch applied they still fail (the skill
  mkdir, and RTK's hook not written).
- mote: go build ./...; go vet of agent, library, sessions, provider for
  darwin, GOOS=windows (and linux for agent, library); gofmt -l clean;
  go test -timeout 45m ./internal/agent ./internal/library
  ./internal/sessions ./internal/provider: all ok.
- Windows (win-run): the same four packages. The new tests pass (the
  RTK ones skip: the fake distro runs sh). 32 tests are red, all already
  red at the base c63c2136b run on the same box, and filed (#4115, #2808:
  Hermes profiles, Codex keychain, Agy, desktop entries, ...); the Hermes
  ones fail alike on base and branch with -count=3.

- Rebased on origin/main 3ecc02b78 (it changed internal/agent): at this
  head on mote, go build ./..., go vet of the four packages for darwin,
  windows and linux, gofmt -l, go test ./internal/agent ./internal/library:
  ok.

Not tried: the full ./... suite; the GUI (no GUI change; the unreached
notice uses the existing Notice); a real Codex/Claude Code run against
the moved files in the distro.
2026-10-31 21:29:22 +08:00
yetone e2a65cbc9b dsh: a start on a found group's old id moves onto the id its route lists (zyh6036 on X)
zyh6036 on X: DeepSeek Harness Desktop showed no model after magpie
turned dsh on and the app restarted, while the profile's patch file was
full of magpie's gateway.

Cause: a dsh start (agent-default-model) magpie had set to a found
routing group keeps the id the group had then, group/auto-<slug>. Since
81a24cf8f the group is listed as auto/<model>, and that is the only id
magpie's routes list. dsh looks up the start by route and id, finds
nothing, and shows "Select model" with nothing picked. The owner's live
desktop profile was in this state: the start was
"group/auto-gpt-6-sol" and the route listed auto/gpt-6-sol.
renameFoundGroups never reached it, because it moves only values that
applied.json records, and there was no dsh record there.

Fix: dshStartOnItsRoute already moves a start onto the route its model
is on now. It now also moves a start whose id magpie no longer lists it
by (provider.PublicRef for a found group, provider.RenamedRef for a
renamed provider) onto the id the route lists. The effort and the other
keys in the entry stay. It runs on every route write, in every profile
(desktop, web, CLI) and in the home layer, so KeepDshWired repairs an
existing install within a round. The fix is not OS-specific.

Run at this head (rebased on bb5eb83c3), on mote (macOS) through mote-run:
- go test ./internal/agent ./internal/provider -count=1 -timeout 45m:
  ok (284s, 164s)
- go test ./internal/agent -run 'Dsh|FoundGroup|Drift|Keeps': ok
- GOOS=windows go vet ./...: ok
- GOOS=linux go vet ./internal/agent ./internal/provider: ok
  (a GOOS=linux vet of ./... from macOS stops in wails' cgo files)
- go vet ./internal/agent (darwin): ok
- gofmt -l: clean
The full suite was not run, so that another session's suite on mote
isn't held up (one full suite per machine). Only internal/agent changed.
The -run 'Dsh|...' subset ran before the rebase.

Broken by hand: with dsh.go at HEAD,
TestDshStartOnAFoundGroupsOldIdMovesOntoItsId fails, and the start
stays "group/auto-pro" in the web profile.

Real app: DeepSeek Harness 0.2.1-rc.5 on mote, each run in a sandbox
HOME and DSH_HOME:
- Fresh wiring shows magpie's models, whether the app was opened first
  or magpie wrote first.
- A copy of the owner's live desktop patch: every route is listed, but
  the seat reads "Select model".
- The same copy with the start as the fix writes it (auto/gpt-6-sol):
  the seat reads "GPT-6 Sol · routing group High", ticked in the picker.

Not tried:
- Running the fixed magpie binary itself against that copy. The unit
  test covers the magpie side.
- Windows' desktop app.
- Whether zyh6036's install was in this state. A store or key that
  doesn't resolve also empties the list (seen with no key at all), and
  their reply will say which.
2026-10-31 20:18:40 +08:00
yetone 5cc2eea2fe dsh: a dsh CLI that has booted no profile yet is wired in its web profile, not config.yaml (liby233)
liby233 on Discord: in WSL magpie wired dsh in ~/.dsh/config.yaml, and dsh
saw magpie's models only once they were written to its settings.yaml.
With no ~/.dsh/profiles, dshAt fell back to the "pre-0.1.5" config.yaml.
No dsh on npm reads that file. 0.0.1-rc.1 (the first), 0.0.1-rc.5,
0.1.0-rc.8, 0.1.1-rc.1/rc.2, 0.1.2-rc.1, 0.1.3-alpha.2 and 0.2.1-rc.5 all
boot $DSH_HOME/profiles/<name> (grepped from their npm tarballs). A dsh
makes no profile until one is first booted, so a fresh CLI install,
in a distro or not, was wired in a file that nothing reads.

- With no profile, and a dsh that is not from before profiles, magpie
  writes profiles/web/cordis.patch.yml as dsh's template, as it does
  for Desktop (#2279). dsh's initProfile adds package.json,
  pnpm-workspace.yaml and cordis.yml next to it and keeps the file.
- "Before profiles" is judged by the CLI's version where it is known
  (locally from its package.json; in a distro the WSL probe now asks
  dsh --version). Otherwise config.yaml is used only when it holds an
  entry that isn't magpie's. That keeps the legacy path for a genuinely
  old dsh.
- The sync carries a magpie model already wired in config.yaml (the
  reporter's state) into the profiles and drops magpie's entries from
  config.yaml. It does this whether or not dsh has since booted a bare
  web profile, and only where no profile has a model or wiring of its
  own.
- Disconnecting before dsh ever booted the web profile removes what
  magpie made, as for Desktop.

Tests: TestDshCLIWithNoProfileYet and TestDshConfigYamlCarriedToProfiles
(new), plus wslMore's dsh row, now profiles/web. All three are red on the
old dsh.go: "names .../.dsh/config.yaml, not the web profile's patch
list", and the web profile is left as dsh's bare template after the sync.
Tests pin dshVersion, so a dsh on the test machine decides nothing.

Run (go test -timeout 45m, logs teed and grepped):
- gofmt -l internal/agent: clean. go vet ./internal/agent on darwin,
  GOOS=linux and GOOS=windows (mote): ok.
- go test -run 'TestDsh|WSL' ./internal/agent: ok on mote (macOS),
  magpie-desktop (WSL Ubuntu 24.04, nogui) and xiaomi-gpu (Windows 11).
- Full suite `go test ./...` on mote at this change on origin/main
  8680ffa41: 82 packages ok; internal/gui red only in
  TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and
  TestMainWindowCorners/macOS_26_SDK (#3949), both filed before this and
  in code this change doesn't reach.
- Rebased again onto origin/main 70d50254c (it changed internal/agent's
  new_session_effort and rename_group tests). At this pushed head: vet
  (darwin, linux, windows) ok, and internal/agent, internal/cli ok;
  internal/gui has the same two reds and no others.
- Rebased once more onto e484b1e93, which touches internal/provider only.
  At that head (the pushed one): go build ./..., go vet internal/agent and
  internal/provider, and go test -run 'TestDsh|WSL' ./internal/agent all
  ok on mote.
- Real dsh 0.2.1-rc.5 from npm in magpie-desktop, in sandbox HOMEs under
  ~/dshprobe (never the live ~/.dsh), with this commit's CLI built there
  (nogui):
  A. Empty HOME, `magpie dsh magpie/relay/glm-4.6`: only
     profiles/web/cordis.patch.yml was written, holding llm-pi-ai's
     magpie route, agent-default-model and web-search-deepseek.
     `dsh --profile web --dump-config` shows llm-pi-ai baseURL
     127.0.0.1:3425/v1 and agent-default-model relay/glm-4.6. dsh added
     package.json, pnpm-workspace.yaml and cordis.yml and kept magpie's
     entries. `magpie dsh default` then left dsh's bare template.
  B. origin/main's CLI wired config.yaml (the reporter's state). The
     dump showed no magpie route. `dsh --profile web --dump-config`
     booted web, then this CLI's `magpie sync` moved the route and model
     into profiles/web and emptied config.yaml, and the dump showed them.
  C. Wired and never booted: `magpie dsh default` removed profiles/.
Not tried: the reporter's own machine and dsh version, a running
`dsh web` session picking the model up live, the desktop app, and a
pre-npm dsh that reads config.yaml (none could be found).
2026-10-31 19:50:39 +08:00
yetone 0c4e3455ee agents: a line magpie writes into a TOML, YAML or env config has a note above it saying so
Jevik_AI on X deleted magpie's folders by hand. Codex's config.toml kept
openai_base_url = "http://127.0.0.1:3425/backend-api/codex", with nothing
in the file naming magpie, and every Codex turn failed with a 502.

Each line magpie writes that points at the gateway, or at magpie's model
list, now gets a comment line of its own just above it:

  # magpie: Codex on magpie's local gateway; Disconnect in magpie or
  #   `magpie uninstall` undoes it, or delete this line and the model line
  model_provider = "magpie"

- Only a line the write adds or changes, or one that had a note, gets one.
  A line of the user's own that magpie leaves alone gets none.
- The note is never on the value's line. Grok App's providers.rs reads the
  rest of a line as the value, and an end-of-line comment broke
  TestGrokApp in a first try.
- Every write takes the notes out and puts back the ones still needed, so
  a note goes with its line and Disconnect leaves none.
- No note in JSON. A YAML note that would change what the file reads as
  isn't added.
- Wired in run (agent.MarkWritten); tests leave edit.Mark nil so their
  exact bytes stay.

Run at this commit's tree (worktree, sandbox HOME, private GOCACHE):
- gofmt -l clean; go vet darwin, GOOS=windows, GOOS=linux -tags nogui ok.
- go test -tags nogui -run Mark ./internal/edit ./internal/agent: ok.
- ./internal/agent and ./internal/edit whole with edit.Mark forced on for
  every test (a snapshot with lineNote set in agent's TestMain): edit ok;
  agent fails only TestDshRouteKeepsTheAPIPickedInDsh and
  TestDshSearchThroughGateway, which compare exact bytes and see the note
  line. With Mark unset (as shipped) they pass.
- Real Codex: built magpie from this tree, `magpie codex fakeai/fake-1` in
  a sandbox HOME. config.toml got the three notes above model_provider,
  model_catalog_json and openai_base_url; `codex mcp list` and `codex
  features list` (codex-cli 0.162.1) read it, rc 0, and Python's tomllib
  reads the same values. `magpie codex default` took them out.
- Broken by hand: a note on every line, not only changed ones ->
  TestMarkTOML and TestMarkOnlyWhatMagpieWrites red.

- The notes' line filter is withoutNotes, unexported: an exported
  Unmarked put a word the routing plugin translates into a Go file, and
  i18n-keys' "a plugin's words are its own" went red on it. It passes
  now.

Full suite: run with the uninstall commit that follows, recorded there.
2026-10-29 17:42:35 +08:00
yetone f6ed2c99bc effort: a vendor's light and extra_high are low and xhigh, in dsh, Pi and the gateway
nianshou5 (Discord) runs Trae's DeepSeek V4.1 Flash through the Our Free
Model plugin (github:mu-zi-lee/magpie-our-free-model). Its variants are
Trae's own names, light, high and extra_high, and dsh offered only
default and high: dshModelLevels (and Pi's piThinkingLevels) matched a
model's efforts to pi-ai's level names only, so light and extra_high
were dropped. The gateway dropped them too: effortOf read "light" as no
effort, and NearestEffort fitted an agent's low or xhigh to the plugin's
high.

catalog.EffortAliases names light as low and extra_high as xhigh
(EffortLevel). NearestEffort places a model's levels by the level they
name and returns the model's own word; the gateway's effortOf reads an
alias as its level. dsh's reasoningEfforts and Pi's thinkingLevelMap map
dsh's low/xhigh to the model's own word (modelEffort), which llm-pi-ai
sends on the wire as written (resolveModelReasoning in dsh-llm-pi-ai
reads each value as "the spelling dispatch sends"). Levels a user kept
are untouched: only the names a model lists are mapped.

Tests: TestDshOffersTraeNamedLevels (agent), TestNearestEffortTakesVendorWords
(catalog), TestPluginThinkingOff's new fake-trae subtests (gateway, a
real plugin host with the fake plugin listing light/high/extra_high).
Broken by hand: modelEffort without the alias, dsh levels [high] (the
report's picker); NearestEffort without EffortLevel, low/xhigh sent as
high; effortOf without the alias, light/extra_high sent as nothing.

Run on mote at this tree (base e4ccf67b1): go build, GOOS=linux and
GOOS=windows go vet -tags nogui ./... ok; go test -tags nogui -timeout 45m
./... : 73 packages ok, three red that are red the same on origin/main
7f32f0ec9 run alone: internal/agent TestWSLColdPlaceOpensNothing (#3924),
internal/tui TestTUIFetchesSubscriptionModels (#3919), internal/provider
synctest crash in TestUnreadLoginsWriteErrorsKeepCredentials (#3632), so
the rest of internal/provider didn't run. No GUI file changed.
Rebased on 7f32f0ec9 (one agent file changed there): go build ./...,
internal/catalog whole and gateway/agent -run Effort|Dsh|Pi|ThinkingOff|Level
ok at this head.

Not tried: a real dsh session against the user's plugin (no Our Free
Model account here); dsh's parsing of a non-pi-ai wire value was read
from its source, not run.
2026-10-28 04:34:45 +08:00
yetone e54a7d50b9 agent: a stopped WSL distro's files are never opened, which started it again (#3896)
The reporter stopped Ubuntu-24.04 with "Detect agents in WSL" on, and
magpie started it again within seconds. Opening any path under
\\wsl.localhost\<distro> starts a stopped distro, and every /api/state
did that:

- wslAgentsOf built every WSL kind at a stopped distro's place, found
  or not, only to ask Detected(). Two builders read files even at a cold
  place: hermesActive read ~/.hermes/active_profile and dshAt listed
  ~/.dsh/profiles. Now only the kinds the probe found are built (the
  same test: wslAgent's detect is k.found), and both builders read
  nothing when the place is cold.
- The Agents page asks every agent's pickers for options, and a stopped
  distro's agent kept the live options for fields with no asleep
  options of their own: Codex's memories and subagent effort read
  ~/.codex/config.toml (19 times a call), Grok Build's model read
  models_cache.json and config.toml, dsh's model listed its profiles.
  Each now has asleep options built from magpie alone: Codex's
  memories as its model, its subagent effort from magpie's catalog,
  Grok's from the live catalog, dsh's own models taken as 0.1.5 on
  (as its effort already was).

TestWSLColdPlaceOpensNothing builds every kind at a stopped distro over
a home with each kind's files, runs Values, Notice, Drift, Wired and
every field's Options, and fails on any path under it the os package
was asked to stat or open (-test.testlogfile). Red on the old code:
the hermes and dsh reads from building, then the 19 Codex, the Grok
and the dsh reads from the options.

Run at the pushed head:
tree a9e2aaf4ee, on origin/main d83f887a7 with 3116b8f58 (#3884,
JoeyWu-tech's patch, so TestFolderVarsAreListed is green), go1.26.8,
darwin/arm64: gofmt -l clean; go vet -tags nogui for linux, windows and
darwin of agent, gui, agentenv and library: ok; go test -count=1
-timeout 45m ./internal/agent ./internal/gui ./internal/agentenv
./internal/library: all ok (./internal/testenv
ok at the base before, 2a19245ce). Those packages ran at 2b0387574;
rebased on d83f887a7 (a gateway routing change only), vet x3 of agent
and agentenv and go test -run 'TestWSL|TestFolderVarsAreListed'
./internal/agent ran again: ok.

Real use on the Windows box (WSL 2, an Alpine distro of
mine, `magpie web` built with an os package that prints every
\\wsl.localhost path it is asked to stat or open):
- Before: terminate the distro, idle 10s (it stays Stopped), one
  /api/state, and it is Running again; the trace showed hermes and dsh.
- After: terminate, idle, then /api/state and
  /api/agent-models/claude@wsl:magpie-3896 three times each: the
  distro stays Stopped, and of the 45 traced accesses in that time
  none is under magpie-3896 (all are magpie-desktop's, which runs).

Not tried: the reporter's Ubuntu-24.04 with mirrored networking, and
a stopped distro with Codex, Grok or dsh really installed (the test
covers their files).
2026-10-27 23:52:55 +08:00
yetone 466cafa0cf idle: the loops that look every few seconds wake together on the clock's beat (#3185)
An idle magpie serve still woke ~6 times a second with nothing to do.
Its loops each kept a ticker of their own, started at their own instant:
awake.Keep (5s), the plugin config's KeepFresh (5s), the middleware
observer (5s), OTel's session watch (5s idle), the Codex daemon check
(15s), dsh's wiring (30s), the model lists' look (1m). Every one woke
the process apart, a few threads each time.

internal/beat's Next(every) fires at the next multiple of every on the
clock, so the 5s loops come due at one instant, the 15s and 30s ones on
every third and sixth of it, and the runtime runs timers due together
in one wakeup. Each loop now waits on beat.Next instead of its ticker.
No channel is shared between callers (a synctest bubble's channel
reached from another crashes the process, #3632).

Run at this head (05ea29ac8 + this):
- Sandbox HOME serve, idle, 90s warm-up then 120s of proc_pid_rusage
  (pkg_idle_wkups + interrupt_wkups), old (origin/main 19253f67b) and new
  taking turns: old 6.1, 5.3, 6.2 wakeups/s; new 2.7, 2.6 (an earlier
  shared-timer form of beat), 3.0 (this one). CPU 0.20-0.36 ms/s old,
  0.11-0.22 new.
- TestIntervalsMeet (5s/15s/30s/1m beats from 09:00:03.2 and on a beat),
  TestNextFires; go test ./internal/beat ./internal/awake
  ./internal/middleware ./internal/otlp -count=3, ./internal/pluginrt,
  ./internal/agent -run 'Dsh|CodexDaemon', ./internal/provider -skip
  TestUnreadLoginsWriteErrorsKeepCredentials (#3632): ok.
  ./internal/pluginrt -count=3 fails TestKeepFreshFollowsPluginsYml
  ("two plugins fresh-test") on origin/main too; -count=1 is ok.
- gofmt; go vet darwin, GOOS=linux and GOOS=windows -tags nogui.
Not tried: a GUI build's wakeups (the tray process has AppKit's own).
2026-10-26 10:27:01 +08:00
yetone 3b5a2f612d dsh: Max reaches GLM-5.3 as max, asked adaptively with its level
01huadalang on Discord (10-24): DSH Desktop on magpie-anthropic, zcode
GLM-5.3 at Max; magpie's Routing log showed 77 of 78 requests at low,
one at high, never max.

What DSH sends, from the real app (DSH Desktop 0.2.1-rc.3's app.asar,
pi-ai 1.1.0 and dsh-llm-pi-ai, run read-only through node with
magpie's GLM-5.3 entry): at Max and at High alike, max_tokens 128000
and thinking enabled, budget_tokens 16384. pi-ai's clampReasoning turns
xhigh and max into high before thinkingBudgetForLevel, so no
thinkingBudgets setting can give Max a budget of its own. At Low it
sends 2048; with reasoning off, no thinking field.

What magpie did with it: 16384 is read as high (effortOfBudget) and
sent as output_config.effort high, so Max could never reach max. The
"low" rows were not reproduced: no request DSH builds at Max reads as
low here, and Z.ai refused none of the shapes (live, below), so no
refusal memory lowered it. A 2048 budget (a session or a subagent DSH
runs at Low; dsh-tool-subagent lets the model pick reasoning_effort)
reads as low, and that is the likeliest source. It is asked of the
reporter.

The fix, zero-config: Z.ai's GLM-5.2 and GLM-5.3 (the GLM half of
effortInOutputConfig) are written into dsh's magpie-anthropic route
with compat.forceAdaptiveThinking (gateway.AdaptiveWithEffort, beside
AdaptiveThinking). MiniMax-M3.1-Flash, the other half, is left on its
budget: adaptive wasn't tried on MiniMax (no key), so it is on #3496. pi-ai then sends thinking adaptive and
output_config.effort from magpie's thinkingLevelMap, max as max
(checked against the real asar: low/high/max each go as themselves).
The gateway already passes adaptive thinking with output_config.effort
through for these models (fitted to their levels, withOutputEffort;
TestGLMEffortInOutputConfig pins it), so the gateway only gains
AdaptiveWithEffort. No client name is keyed on, and a budget alone is
read as before. An adaptive-to-budget rewrite in withOutputEffort was
tried first and dropped: TestGLMEffortInOutputConfig pins adaptive
passing through, and Z.ai takes it.

Live, Z.ai GLM-5.3 with the zcode key (sandbox script, key never
printed): adaptive and enabled+effort both accepted; effort max
thought 1237-1427 chars against 426 at high, so max is a real tier.

Run, at this head rebased on origin/main 3be1f14eb (head 7ae044226):
- go build ./...; go vet of gateway and agent for darwin, linux and
  windows; gofmt -l clean.
- go test ./internal/gateway/ ./internal/agent/ ./internal/plugin/
  -timeout 45m at this head: ok (655s, 469s, 187s)
  (an earlier run, with the dropped rewrite, was red on
  TestGLMEffortInOutputConfig only, which led to dropping it).
- Own GOCACHE: the shared one had files trimmed mid-build by another
  run (vet "could not import sort").
- A first run hit "no space left on device" from another session's
  disk use (18G free after); rerun in full.
Broken by hand: with dshKindConfig back on AdaptiveThinking alone,
TestDshMaxReachesOutputEffortModels is red for GLM-5.3 and GLM-5.2. TestAdaptiveOnOutputEffortModelAsksItsLevel (the
gateway end, through a fake zcode plugin) passes on the old gateway
too: it holds that DSH's new shape reaches the vendor and the Routing
log as max, not a gateway change.
Not tried: DSH Desktop itself against this build (the app isn't
installed here; its pi-ai was run from the asar instead); MiniMax with
adaptive (left out, #3496); the whole go test ./... and GUI suite (no GUI change).
Siblings left alone, filed as #3496: Pi and omp hit the same pi-ai
clamp, MiniMax-M3.1-Flash above, and dsh to a DeepSeek model on DeepSeek's host (#3298) still
goes as a 16384 budget, since dsh's compat is per model id.
2026-10-24 23:27:25 +08:00
yetone 34f9686bd2 agent: dsh's desktop app is DeepSeek's own DeepSeek Harness; the community DeepSeek Hermes is not it
WuSix on Discord (Windows 11), on v0.1.1337: the desktop app still isn't
in magpie's Agents, and the repo 0c679c640 built on
(motongv/deepseek-hermes-desktop, "DeepSeek Hermes") is not DeepSeek's.
The official one is github.com/deepseek-ai/deepseek-harness.

What was wrong: 0c679c640 took a community Electron wrapper around
`dsh web` for the app WuSix runs, and listed dsh, wrote the web profile
and dropped dsh's key store for it. That is taken out whole (dshHermes,
the store switch, the web-profile app file, noticeDsh6 and its zh, zh-TW,
ja and de strings, the Running pattern, dsh_hermes_test.go). A user that
v0.1.1337 wired this way keeps profiles/web, which is dsh web's own
profile; the next Apply or Sync writes the key store again.

The official app, read from its source (deepseek-harness at 687f282e8,
dsh-v0.2.1-rc.2) and its real release files:
- apps/desktop/scripts/electron-builder-config.mjs: productName
  DeepSeek Harness, appId from DSH_DESKTOP_APP_ID; first config
  19444907f0 hard-codes com.deepseek.dsh. NSIS per-user
  (perMachine false), a folder the user may pick; installer.nsh writes
  HKCU ${INSTALL_REGISTRY_KEY} InstallLocation and refuses all-users.
- deepseek-harness-0.2.1-rc.2-mac-arm64.zip (sha512 as the feed
  download.deepseek.com/dsh-desk/feeds/mac-arm64/nightly-mac.yml says):
  DeepSeek Harness.app, CFBundleIdentifier com.deepseek.dsh, 0.2.1-rc.2,
  team NAN929V4UM.
- deepseek-harness-0.2.1-rc.2-win-x64.exe installed with /S on the
  Windows 11 box (26200): %LOCALAPPDATA%\Programs\DeepSeek Harness\
  DeepSeek Harness.exe, HKCU\Software\1bf39983-50d0-5fe0-9ef4-
  cece76f67c5e InstallLocation, Uninstall entry DisplayVersion
  0.2.1-rc.2, DisplayIcon <exe>,0. Nothing under HKLM.
- packages/util/home-paths/src/index.ts (defaultDshHome = ~/.dsh,
  DSH_HOME) and apps/desktop/src/paths.ts (profiles/desktop, "shared
  with npm-installed dsh"): the same ~/.dsh as the CLI on every OS.
- No Linux desktop build is published (UPDATE_TARGETS is mac-arm64,
  mac-x64, win-x64; dsh-latest-linux-x64.AppImage is 404); Linux has
  the npm CLI only.
magpie's desktopApps["dsh"] already had all of these (#2279, #2325);
the row is named DeepSeek Harness, the app's own name.

Run:
- Windows box, sandbox USERPROFILE/APPDATA/LOCALAPPDATA (Programs a
  junction to the real one, where the installer put the app), no ~\.dsh:
  the released v0.1.1337 magpie-cli-windows-amd64.exe and this commit's
  build both list "DeepSeek Harness ... ~\.dsh\profiles\desktop\
  cordis.patch.yml" in `magpie ls`. So on a default install v0.1.1337
  already listed it; what WuSix sees isn't reproduced. An unconnected
  agent sits under the Agents page's 未设置 (Not set up) fold; WuSix's
  screenshot and install folder are still to be asked for.
- macOS: the real 0.2.1-rc.2 .app in a sandbox HOME's Applications:
  HasApp true, version 0.2.1-rc.2, `magpie ls` lists it.
- New tests: TestDshOnlyTheOfficialApp (red on 0c679c640's dsh.go:
  "DeepSeek Hermes taken for DeepSeek Harness: detected true") and
  TestDshWindowsAsTheInstallerRegistersIt (the registry values above,
  and the GUID as UUID v5 of com.deepseek.dsh in electron-builder's
  namespace).
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows.
- GUI: i18n-keys, agent-notice-lang, gui-de, gui-ja, gui-zh-tw: 34/34.
- Full suite: not run at push time (queued behind the suite lock;
  pushed per the owner's ship-at-once rule). TestDsh*, TestDesktop*,
  TestCLIMissing*, TestRegistered* rerun ok at the rebased head on
  origin/main 03951798a; the full run follows through the lock, reds filed.

Not tried:
- The real app opened (neither the .app nor the .exe was started), so
  no request from it through the gateway.
- WuSix's own machine: why their row doesn't show is still unknown.
2026-10-23 22:26:33 +08:00
yetone 0c679c6404 agent: DeepSeek Hermes, dsh's web UI in a window, is found and wired as dsh
WuSix on Discord: magpie's Agents page didn't find the "DeepSeek Hermes"
desktop app, so its models were added in the app by hand.

DeepSeek Hermes is motongv/deepseek-hermes-desktop 1.0.0, an Electron
window around `dsh web` (not Nous Research's Hermes Agent). Read from its
real release files: the macOS zip's Info.plist (bundle id
com.deepseek.hermes.desktop, 1.0.0) and the Windows NSIS installer's
header (InstallLocation under HKCU/HKLM Software\df9f5892-ad1c-5623-a260-
30fb0acc7e55, default %LOCALAPPDATA%\Programs\DeepSeek Hermes\DeepSeek
Hermes.exe). Both bundle @deepseek-ai/dsh 0.1.0-rc.6, which boots the
`web` profile in ~/.dsh (DSH_HOME). There is no Linux build.

Before: with no dsh CLI the dsh row was 未找到 CLI with its settings
hidden, an unopened app wasn't found at all, and a pick would have made
DeepSeek Harness Desktop's profiles/desktop, which Hermes never reads.

Now:
- desktopapp: installed() also takes the Windows exe under the app folders
  or the registered InstallLocation; HasApp uses it.
- dsh: DeepSeek Hermes counts as dsh's app. With it (and no Harness
  Desktop) magpie writes profiles/web/cordis.patch.yml and the key in .env
  only. rc.6's dsh-credentials-local reads only the flat store and refuses
  to start on the version 1 .credentials.yaml magpie writes for Harness
  Desktop ("the value for "version" ... must be a string"), so that store is
  not written, and one magpie wrote before (nothing but its key) is
  removed. A store with the user's own keys is left alone. With Harness
  Desktop also installed, its profile and store are used as before.
- noticeDsh6 for an unopened Hermes, in zh, zh-TW, ja and de.

Run:
- Real rc.6 in a sandbox HOME (npm --before=2026-08-17), never the live ~/.dsh:
  - `dsh -p headless` with magpie's route and the key in .env only against
    a fake gateway: POST /v1/chat/completions, model deepseek/deepseek-chat,
    Bearer key, answered.
  - With magpie's v1 store: `dsh web` exits on the error above; without it,
    it boots.
  - A web profile holding only magpie's cordis.patch.yml, `dsh web
    --dump-config`: rc=0, dsh added package.json, cordis.yml and
    pnpm-workspace.yaml, the patch was byte-identical after, and the
    composed config has the magpie route, agent-default-model and
    web-search-deepseek.
- New tests TestDshHermesFound/Windows/Wired. On the old code (0815c9186)
  all three are red: "never opened: detected false", "under Programs not
  found", "the web profile magpie made". The opened-with-no-CLI step alone
  is red too ("opened: detected true, CLI missing true").
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows.
- GUI: i18n-keys, agent-notice-lang, gui-de, gui-ja, gui-zh-tw: 34/34.
- Full suite: set -o pipefail; go test -tags nogui -timeout 45m ./... at
  this commit on origin/main a77b5b4fc: 69 packages ok (internal/agent
  420s, internal/gateway 567s, internal/gui 159s), no FAIL.

Not tried:
- The real app itself (neither the .app nor the .exe was run); detection
  is from the release files' bytes.
- With both Hermes and Harness Desktop installed, Harness's v1 store still
  stops Hermes's rc.6 from starting; magpie keeps the store Harness needs.
  A user's own v1 store does the same, which isn't magpie's to change.
- The Windows run on the Windows box.
2026-10-23 19:35:50 +08:00
yetone ca4a1cde0d dsh: maxTokens leaves dsh half its window, or a quarter for output where that is more (#3298 item 3)
822f2b304 (#2823) held the maxTokens magpie lists for dsh to a quarter
of the window, because dsh reserves it, plus 65536 of headroom, before
it compacts (compaction-basic's resolveCompactSpec: threshold = min(0.8W,
W - maxTokens - 65536)). On a large window the quarter cut more than
compaction needs: DeepSeek's own deepseek-flash, 1000000/393216, was
listed at 250000, though all 393216 leaves dsh 541248 (54%).

Now the cap is max(W/4, W/2 - 65536): the output may take what leaves
dsh half the window to compact in, or a quarter of the window where that
is more (every window under 262144, where there is no half to spare
beside the headroom). A Max output the user set is still written as set
(outputOr), and contextWindow and /v1/models don't change.

dsh 0.2.0-rc.2's own resolveCompactSpec, run on the installed
compaction-basic over each figure (threshold tokens):

| window / output | vendor | quarter (main) | now |
| 524288 / 524288 | no message budget | 131072 -> 327680 | 196608 -> 262144 |
| 500000 / 393216 (#2823) | 41248 | 125000 -> 309464 | 184464 -> 250000 |
| 131072 / 65536 | no pressure budget | 32768 -> 32768 | 32768 -> 32768 |
| 1000000 / 393216 | 541248 | 250000 -> 684464 | 393216 -> 541248 |
| 400000 / 128000 | 206464 | 100000 -> 234464 | 128000 -> 206464 |
| 200000 / 393216 | no message budget | 50000 -> 84464 | 50000 -> 84464 |
| 128000 / 393216 | no message budget | 32000 -> 30464 | 32000 -> 30464 |

#2823's case stays fixed: 250000 is half its 500000 window (its
reporter's own plan A), against 41248 before 822f2b304; it is lower than
the quarter's 309464, which is the trade. The 128K and 200K windows
#3298 names don't change: any output above the quarter there takes it
straight out of what dsh compacts at, and a user who wants more sets Max
output.

Tests: TestDshOutputLeavesCompactionRoom's table takes the new figures
and adds DeepSeek's 1000000/393216 (393216), 200000 and 128000 windows;
its check now holds dsh's threshold at half the window where the window
has one, never under what a quarter leaves. TestDshModelLimits'
400000/128000 is now 128000; TestMaxTokensWithinContextWindow's dsh
figure follows the formula (its windows are all under 262144). Broken by
hand: the quarter alone (main) is red on 4 cases ("maxTokens 250000;
want ... 393216"), W/2 - 65536 alone on 3 (131072 gets 1), no cap
(pre-#2823) on #2823's own cases (524288/524288, 524288/1048576,
500000/393216, 131072/65536) and the 200K and 128K windows. docs/subsystems/agent-wiring.md says the new rule.

Run at 5adad1877 (this commit on top of item 4's): gofmt -l (nothing),
go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet
./... (all clean), go build for darwin, linux (nogui) and windows (ok),
and go test -tags nogui -timeout 45m ./...: all 69 packages ok, exit 0
(gateway 505s, agent 401s, provider 197s).

Not tried: a real DSH session against a 1M DeepSeek model through
magpie; the thresholds above come from dsh's resolveCompactSpec run
directly. Windows under ~87K (64000/384000 -> 16000) still leave dsh no
pressure budget, on main too; that needs a policy of its own and isn't
changed here.
2026-10-23 01:20:37 +08:00
yetone 489d816213 agent: dsh's wiring round does nothing when nothing it reads changed
A user's live heap profile showed 35.7 GB allocated in 48 minutes with
~157 MB live. 12.1 GB of that was one path: KeepDshWired -> keepDshWired
-> dshWiredOnce. It runs every 30 s, and each time it rebuilt the whole
catalog and every route, only to write nothing. Within it:
magpieModels("dsh") 9.5 GB, dshRouteAgain 4.8 GB, dshPutRoute 3.8 GB, and
Exposed/Catalog/heldOf/entriesOf ~7.7 GB under them. heldOf caches only
during a Hold.

What changed:
- provider.StampNow (hold.go) records what the catalog is built from,
  without building it:
  - held.gen, which Changed and a plugin's change move
  - filememo.Gen
  - the environment
  - the stat stamps of providers.json, settings.json and the catalog's
    cache file, which another process's writes move
- keepDshWired keeps a dshRounds between rounds.
  - It builds magpieModels again only when the stamp moved, or when its
    models are dshModelsFor (5 min) old. The 5-minute rebuild covers what
    no stamp sees: another app's account file, or a model retired by date.
  - It skips the round when these are all the same as at the last round,
    and that round wrote nothing and left the files as it found them:
    - the bytes of dsh's files: every profile's cordis.patch.yml, the
      home layer, settings.yaml, .env, .credentials.yaml, config.yaml
    - the gateway URL
    - the hash of the models
  - A read error other than "missing" hashes as unknown, so the round
    runs.
- dshWiredOnce (Sync, Connect, tests) still always does a full round.
- No singleflight and no new lock: the round already runs under dshWrites.
- docs/subsystems/agent-wiring.md says so.

Not done: caching Exposed/Catalog/entriesOf outside a Hold. Their output
depends on time (retiredNow, disabledNow) and on files other apps write,
and nothing signals a change in either, so nothing would bound how stale
the cache gets.

Measured with a throwaway test in a sandbox HOME, on top of 4f044c24c:
12 providers from a real models.json, 270 models, 3 dsh profiles.
- Before, per round: 132.61 MB, 900,624 allocations (~265 MB/min).
- After, nothing changed: 0.26 MB, 119 allocations.
- After, models older than dshModelsFor: 30.77 MB, 88,336 allocations.
  The dsh parse and write are skipped because the models' hash is the
  same.
- Averaged over time: ~6.7 MB/min, against ~265 MB/min before.

New tests:
- TestDshRoundWithNothingChangedBuildsNothing: AllocsPerRun must be at
  most 300; it is 77 now.
- TestDshRoundAfterAChangeWritesAgain covers each change:
  - a provider saved
  - a setting saved
  - the patch list written over
  - providers.json written by another magpie
  - a change no stamp sees, picked up after dshModelsFor

Broken by hand, each went red:
- skip always off: the allocation test, at 2099 allocations
- stamp check removed: the provider, setting and another-magpie cases
- roots left out of the stamp: the another-magpie case
- aging removed: the unseen-change case
- file bytes left out of the sum: the patch-list case and
  TestKeepDshWiredWritesTheRouteAgain

Run at this tree. It is built on origin/main dee5c9d75 plus a cherry-pick
of 4f044c24c, which is not part of this commit.
- gofmt -l internal/agent internal/provider: clean.
- GOOS=linux and GOOS=windows go vet -tags nogui ./...: clean.
- darwin go vet ./...: clean.
- set -o pipefail; go test -count=1 -timeout 45m ./internal/agent/...
  ./internal/provider/...: ok agent 2146.7s, ok provider 709.9s.
- An earlier run that also took ./internal/gateway/ and
  ./internal/catalog/:
  - catalog: ok, 6.5s.
  - gateway: hit the 45m timeout (FAIL 2701.3s). Other sessions' GUI
    suites had the machine at a load average of ~548. The output's tail
    was cut off, so which test was running isn't known. Gateway doesn't
    call StampNow or the dsh round. Not rerun at a normal load.
2026-10-20 20:32:05 +08:00
yetoneandLoKi 822f2b3042 agent: dsh lists a vendor's reply limit at most a quarter of the window, so it has room to compact (#2823, LoKi on Discord)
dsh takes a model entry's maxTokens as the output of every request. Before
deciding when to compact, it reserves that output plus 65536 of headroom
out of contextWindow (dsh-compaction-basic resolveCompactSpec). When a
vendor's reply limit is close to its window, dsh compacts at a sliver of
the window, or can't compact at all. magpie now lists a vendor's figure
held to a quarter of the window (dshMaxTokens). It does this on every
pi-ai route and in the legacy llm-deepseek entry, the same rule VS Code
and Copilot in JetBrains already use. A Max output the user set stays as
they set it (outputOr).

LoKi's patch capped only an output >= the window. That misses #2823's own
case (a group at 500000 / 393216) and outputs above window - 65536, such
as 131072 / 65536. The quarter rule covers all of them, and a cap can only
lower the reservation.

Run: real dsh 0.2.0-rc.2 headless, sandbox HOME/DSH_HOME, a fake OpenAI
SSE server with a tool-call step so pre-step compaction runs, and an
observe-only loader hook on resolveCompactSpec.

  origin/main e5b57794e:
    524288/524288   "leaving no message budget"
    500000/393216   threshold 41248
    131072/65536    "leaving no pressure budget"
    1000000/393216  threshold 541248

  this change (maxTokens / threshold / retain):
    524288   131072 / 327680 / 62914
    500000   125000 / 309464 / 60000
    131072    32768 /  32768 / 15728
    1000000  250000 / 684464 / 120000

  The request's max_tokens matches each new value.

Tests: TestDshOutputLeavesCompactionRoom (every route plus legacy;
vendor, user-set, unknown window and unknown output cases).
TestDshModelLimits now expects 100000 for 400000/128000, and
TestMaxTokensWithinContextWindow (the every-agent guard, which the first
full run caught) holds dsh to a quarter of a known window.
Broken by hand:
  - dsh.go reverted: 4 vendor cases and TestDshModelLimits red.
  - Only the legacy writer reverted: 4 llm-deepseek failures.
  - outputOr dropped: the user-output cases red.
  - Old dsh.go under the new TestMaxTokensWithinContextWindow: 3 dsh rows
    red (32000, 51200, 16000).

Checks: gofmt -l clean. go vet darwin, linux -tags nogui and windows ok.
go test -timeout 45m ./... at e5b57794e plus this change, before the
sync_test fix: every package ok except internal/agent, where
TestMaxTokensWithinContextWindow was red (fixed here), and
internal/gateway, where TestDesktopSubagentUnsetDoesNotDecode was red (1
alloc, want 0). That is #2699, an allocation counted from another
goroutine in a whole-package run. It passes alone -count=3, and this
change touches no gateway code. After the fix, internal/agent ran whole
and was ok (2084s), and vet on all 3 OSes was ok again.

The Windows TempDir flake LoKi saw in
TestDshSetEffortWritesALegacyEntryWithTheCatalog did not reproduce: 10
runs of ^TestDsh on the Windows box passed. A goroutine/file probe at
each TestDsh cleanup (macOS and Windows) found no late writer. Filed as
#2982.

Co-authored-by: LoKi <317300729+lokic7123-star@users.noreply.github.com>
2026-10-20 03:12:29 +08:00
yetoneandggbdpq f191d6423b agent, library: a dsh patch list that opens with a YAML document start marker is edited, the marker kept (#2667)
What changed
- dshParse (internal/agent/dsh.go) and dshRead (internal/library/dsh.go)
  let a patch list open with "---", YAML's document start marker, where
  before they failed the file as "not a list of entries magpie can edit".
  The marker goes in the head and is written back with it.
- The marker counts only at the left edge, with at most a comment after it,
  and only before anything but blank and comment lines. A second "---"
  (a second document), one after the first entry, an indented one, "----",
  "--- x" or one after "[]" still fail the file instead of being kept as
  if they were the list's. ggbdpq's patch took a bare "---" anywhere before
  the first entry, so "---\n---\n- a" (two documents) was edited as one list.
- The only line-scanning YAML readers with this check are these two; the
  rest go through yaml.v3 (edit.GetYAMLTop/SetYAMLTop read node lines and
  take a leading --- already).

Run (macOS arm64, go1.26.8, load average 130-270 from other sessions)
- New tests: TestDshDocStart and TestDshDocStartOnlyFirst (agent),
  TestDshDocStartPatchList and TestDshDocStartOnlyFirst (library). The
  #2667 fixture is the reporter's bytes.
- Broken by hand, each red: marker never taken (all four red with the
  reported error); no only-once guard (both OnlyFirst red on
  "---\n---\n- id: a"); library alone reverted (library red, agent green);
  anything after "--- " taken (both OnlyFirst red on "--- x").
- gofmt -l: clean. go vet ./... (darwin), GOOS=linux and GOOS=windows
  go vet -tags nogui ./...: clean.
- go test -tags nogui -timeout 45m ./... under set -o pipefail, sandbox
  HOME, at 244538d6d (this change on 9f9bfc160): 64 packages ok; red were
  only internal/agent and internal/gateway at the 45m timeout, with no test
  failing (#2544, #2108). Rerun at the same head with -timeout 110m:
  internal/agent ok 2112s, internal/gateway ok 1817s.
- Rebased onto 17557132c (7 commits, none in the dsh files or internal/edit):
  go build -tags nogui ./..., go vet -tags nogui on agent and library, and
  -run TestDsh in internal/agent and internal/library rerun, ok. The
  full suite was not rerun on that base.
- An earlier full run on 7660399a1 also had internal/middleware
  TestOnUsageRows "strategies.seen: took too long" under load (filed #2687;
  ok alone in 2.9s) and TestPluginStreamLargeReplies client timeouts (#2551).
- Not run: the GUI suite (no GUI change); a real dsh binary.
- Found on the way, filed, not changed here: edit.BlockList drops block
  entries after a root flow list ("[]\n- id: a" -> "[]"), #2674.

Co-authored-by: ggbdpq <ggbdpq@gmail.com>
2026-10-17 18:51:53 +08:00
yetone 51adf96958 agent: a compat switch set by hand on a DSH model stays through a model refresh (#2504)
h4rk8s: a compat parameter set in DSH's Models page (maxTokensField, say)
went each time magpie wrote its routes again, because the route's
"models" list was put whole, and a model that only works with it failed
again.

dshPutRoute now carries every compat key from the model as it is in the
file onto the same model as magpie writes it, when the model is on the
same route and that route is still on the same protocol (api). A model
new to the route, or one on a route whose api changed, starts without
them. A switch magpie sets itself (forceAdaptiveThinking) is put as
magpie has it now. Name, contextWindow, maxTokens are still written from
the catalog.

Run:
- TestDshRefreshKeepsHandSetCompat: red with the dshKeepCompat call
  removed ("the hand-set compat went: map[]"), green with it; two syncs
  in a row keep it, deepseek/flash takes none, the stale name/context are
  rewritten.
- TestDshKeepCompatNotAcrossProtocols: an api change drops it.
- gofmt -l clean; go vet -tags nogui for darwin, linux, windows.
Full suite: go test -tags nogui -timeout 45m ./... (pipefail, suite-lock) at the four #2494/#2504/#2505/#2490 commits on origin/main a751f5282: 65 packages ok, among them internal/agent (2124s), internal/gateway (1845s) and internal/sessions (148s). internal/gui was red on TestSetAnswersWhileDevinAndProvidersHang alone (the state after a set took 11.5s at load ~250; #1375); internal/gui run again alone: ok (206s).
2026-10-17 00:39:36 +08:00
yetone 0889fdb844 agent: a model picked for dsh says that a session made before keeps its model, also with no dsh running, and how to switch it there (#2359, IanLi592)
IanLi592 picked a non-DeepSeek model for DeepSeek Harness in magpie, went
on in a workspace's session made earlier, and it still went to DeepSeek on
their DeepSeek key. That is dsh's design: magpie writes
agent-default-model in the profile's cordis.patch.yml, which dsh reads for
new sessions only; a session keeps the provider/model in its own log
(dsh-agent-default-model README: "An existing session whose request log
already names a selection keeps that selection"; dsh-client-ui-model-
selection: switch with /model or the composer's model control). Read in
dsh 0.2.0-rc.2's installed packages.

magpie told them so only while dsh was running (Running gate in dsh's
Notice), and said "one already open", while a closed session reopened later
keeps its model too. For dsh 0.1.5+ (a profile patch exists) the notice is
now given after every pick, and says a session made before keeps its
model, open now or reopened later, until /model or the model button by its
message box picks another. Before 0.1.5 the restart advice stays as it was,
given while dsh runs. Session logs are dsh's and stay untouched. Strings in
zh, zh-TW, ja, de and NOTICES.

Tested: TestDshPickSaysOldSessionsKeepTheirModel (sandbox home with a web
profile, Running stubbed false). With dsh.go and i18n.js put back it fails:
"a pick says nothing of the sessions dsh already has: \"dsh's web search
goes through magpie, ...\"". go test -run 'TestDsh|TestEveryNoticeIsTranslated'
./internal/agent ok; agent-notice-lang and i18n-keys GUI tests pass in
Chromium and WebKit (14/14 each); gofmt clean; vet darwin/linux/windows on
internal/agent ok. Not tried in the real dsh app (the notice is magpie's
text; dsh's behaviour is from its own package docs).

Rebased onto 370eaba97: dsh's Notice keeps the base's first branch (a
desktop app never opened says noticeDsh5 alone, #2279), then this
commit's profile-before-Running order; the zh/zh-TW/ja/de NOTICES
entries keep the new noticeDsh5 string beside the reworded noticeDsh1.
TestDsh and TestEveryNoticeIsTranslated: ok.

Full suite: SUITE_LINE
2026-10-15 23:08:03 +08:00
yetone 2a1637f4f6 agent: DeepSeek Harness Desktop is wired when installed but never opened, and found in any folder it was installed to on Windows (#2279, liangjinyuan-sihan)
DeepSeek Harness Desktop already reads magpie's route: its lib/main.js
(0.2.0-rc.2, the latest on its update feed, read from download.deepseek.com's
dmg and Windows installer) resolves $DSH_HOME, else ~/.dsh, and runs on
profiles/desktop, so the CLI's wiring applies. Three gaps remained:

- Installed but never opened, there is no ~/.dsh: the row wasn't listed,
  and connecting wrote the legacy config.yaml the app never reads. magpie
  now writes profiles/desktop/cordis.patch.yml from dsh's own template
  (PROFILE_PATCH_TEMPLATE) with its routes; the app's initProfile writes
  only missing files, so its first start keeps them. The notice says it
  starts on this when first opened (noticeDsh5, in all 5 languages).
  Disconnect before that first start removes what magpie made, when
  nothing else is there; afterwards only magpie's entries go.
- On Windows the installer lets the user pick the folder and registers it
  under HKCU\Software\1bf39983-50d0-5fe0-9ef4-cece76f67c5e InstallLocation
  (read from the NSIS script of dsh-latest-windows-x64.exe). magpie reads
  that, so a custom folder is found, and the Uninstall entry's
  DisplayVersion gives the version shown.

Tests: TestDshDesktopNeverOpened (pick on a never-opened app writes the
desktop profile, a user's key in .credentials.yaml and the user's own start
survive Disconnect, the app's first start is told apart),
TestDshDesktopRegisteredFolder (registry stubbed; exe must be there; WSL
twin has none).

Run on this tree, rebased onto 707fbb249:
- gofmt -l: clean; go vet darwin, GOOS=windows, GOOS=linux -tags nogui
- go test -tags nogui ./internal/agent/: ok (846s, loaded box)
- GUI, Chromium and WebKit: agent-notice-lang, gui-de, gui-ja,
  gui-zh-tw, agent-app-version, agent-cli-missing: 79 pass
Full suite: SUITE_LINE

Not tried: the real app was not run (Electron's userData isn't fully
redirected by a sandbox HOME); it was inspected statically (dmg mounted
read-only, app.asar extracted, NSIS header decoded). The registry reader
was not run on a real Windows install; the test stubs the registry.
2026-10-15 23:08:02 +08:00
yetone 66b8999e0d dsh: Reconnect puts magpie's key over one in dsh's key store that magpie refuses, and Disconnect puts it back (#1419, DannyJRu)
DannyJRu (dsh desktop 0.2.0-rc.2 on Windows, magpie 0.1.1226): the row said
"已不经过 magpie:配置已变更", its tooltip that ~/.dsh/.credentials.yaml holds
another MAGPIE_GATEWAY_KEY; Reconnect showed its success toast and the row
stayed red. dshCreds left any value there that isn't magpie's own token or
LAN secret, so Apply again could never fix what the check reported, and the
check sent the user to dsh's Models page instead.

The store wins over .env in dsh, and MAGPIE_GATEWAY_KEY is the name only
magpie's route reads, so a value there the gateway refuses fails every turn
through magpie. Now a model picked here, which is what Reconnect (Apply
again) does, replaces such a value with magpie's key and stashes it;
Disconnect puts it back. The sync and the serving round still leave it (no
silent overwrite of a value the user set), a caller key the gateway takes
stays (#1332), and so does any key when dsh points at a magpie on another
machine, which only that one can judge. The check now says Apply again
fixes it (Disconnect puts the old one back), except for a gateway on
another machine, where the old advice stands.

TestDshApplyReplacesAKeyTheGatewayRefuses: the sync leaves a refused key and
the check reports it; a model set replaces it, keeps the store's other
refs, and the check is quiet; Disconnect puts it back; a caller key the
gateway takes isn't replaced. It fails on the old dsh.go. go test -run Dsh
./internal/agent passes; gofmt clean; GOOS=linux and windows go vet
-tags nogui pass. Not tried with the real dsh desktop app on Windows; why
the reporter's store holds a refused value isn't known (an old caller key,
or one typed in dsh's Models page), and they are asked to confirm.
2026-10-14 05:27:14 +08:00
yetone f96b7e842c agent: dsh's web search asks the searcher picked under Settings › Web search, not the model dsh starts on (我只会玩单机 on Discord)
magpie's web-search-deepseek row in dsh's cordis.patch.yml was written
with the model dsh starts on (ref). The gateway then sent each search to
that model, which can't search itself and asked the searcher in turn:
two requests per search, and timeouts when the start model can't take
concurrent calls. The user had picked "6 Luna" under Settings › Web
search, and it was never written.

gateway.NamedSearchModel gives the searcher Settings names as
"<provider>/<model>" (empty when none is named, search is off, the one
named can't be used, or it searches with no model). dshSearchModel uses
it for the row on Set and on dshRouteAgain's ~30s pass, so a change in
Settings reaches dsh's file, and clearing it gives the start model
back. A row the user wrote themselves (no # magpie) stays untouched.

Run: go test -tags nogui ./internal/agent -run TestDsh (ok);
TestDshSearchAsksNamedSearcher fails with dsh.go and dsh_search.go
reverted; gofmt -l clean. Not tried with a real dsh, nor whether a real
searcher model answers dsh's web_search end to end.
2026-10-12 22:08:57 +08:00
yetone 814a5ed73c agent: dsh asks each of magpie's models on its own API, a route per protocol (01huadalang on Discord)
dsh's llm-pi-ai sets one api for a whole route, so magpie's single
"magpie" route asked every model over Chat Completions. A GPT served on
Responses, or a Claude served on Messages, was translated from Chat, and
its sealed reasoning was lost between tool calls. 01huadalang asked for a
group per protocol.

What changed:
- dshPutRoute writes up to three routes from each model's catalog APIs
  (dshRouteOf): magpie (openai-completions, as before, for Chat models,
  Gemini-native ones, groups and agent-bridged sign-ins),
  magpie-responses (openai-responses, gateway /v1) and magpie-anthropic
  (anthropic-messages, the gateway root, forceAdaptiveThinking where
  gateway.AdaptiveThinking). A route left with no models is taken out.
  An api the user picked for a route in dsh's Models page is kept, and so
  are keys they added to it.
- The start (agent-default-model) names its model's route on a pick, an
  effort change, and the home layer's mirror. Sync moves a start on one of
  magpie's routes to the route its model is now on (dshStartOnItsRoute),
  keeping its mark, effort and other keys. A start on the user's own
  route stays.
- dshCheck checks each route's baseURL against its own api, and asks the
  route the start names to list its model.
- Disconnect, dshOurs, dshKeepPick and dshFillNewProfiles know all three
  routes. sessions' dshGatewayProvider counts dsh sessions on any of
  them as magpie's.
- docs/subsystems/agent-wiring.md: a line on the routes.

Known limit: a dsh session resumed on a model that has since moved
routes asks for the model to be picked again once, since dsh finds a
model by route and id.

Run:
- go test -tags nogui ./internal/agent (whole package, default order)
  and ./internal/sessions -run TestDsh: pass. New tests
  TestDshRoutesAModelOnItsNativeAPI,
  TestDshSyncMovesAStartToItsModelsRoute,
  TestDshCheckSaysAStartOnAnotherRoutesModel and
  TestDshGatewayProviderTakesEveryRouteOfMagpies. With dshRouteOf forced
  back to the single route, the three agent tests go red.
- Real dsh (headless, sandbox HOME and DSH_HOME) on patches magpie wrote,
  pointed at a fake gateway: the start on magpie answered from
  /v1/chat/completions, the one on magpie-responses from /v1/responses
  (reasoning.effort high), and the one on magpie-anthropic sent
  /v1/messages with thinking adaptive and output_config.effort high. dsh
  accepted all three routes. Its Anthropic turn then ended on my fake's
  SSE, not on the wiring.
- gofmt -l clean. go vet -tags nogui for darwin, GOOS=linux and
  GOOS=windows on internal/agent and internal/sessions.
2026-10-11 04:52:26 +08:00
yetone 20582866a5 agent, gui: an agent's advice after a change reads in the window's language (#1508, NovaTrailX)
A Chinese window said "ZCode 已接入 magpie. ZCode reads its providers at
start-up — restart ZCode …": the notice an agent gives after a change
(state.notice) was English text written in place in each agent's file, and
i18n.js had no entry for any of them.

What changed:
- internal/agent/notice.go: a notice is a template registered with
  newNotice ("Restart {agent} to …"), filled with say(kv...); Notices()
  lists every one. All the agents' notices (claude, codex daemon, zcode,
  agy, cursor-local, wsl, AstrBot's added today, …) are now such templates, the issue's list
  being a sample of them.
- i18n.js: every template has a zh, zh-TW, ja and de translation, and
  NOTICES lists them. tNotice() reads a notice of several joined: longest
  template first, a {slot} never runs over a sentence's end, and a notice
  with any part that has no template (a plugin's own) reads as given
  rather than half in each language. withNotice() joins the status line
  and the notice with 。 in zh/ja.
- app.js: the six places that showed state.notice use withNotice.

Tests:
- TestEveryNoticeIsTranslated: every Notices() template is in NOTICES and
  in each language table, with the same slots. Fails with the zh ZCode
  line deleted from i18n.js (tried).
- TestNoticesAreTemplates: an AST scan for English written in place as a
  Notice. Fails with zcode.go's literal put back (tried).
- tests/agent-notice-lang.test.cjs: every template, filled, alone and
  joined, plus a plugin's notice, and connecting ZCode as the reporter
  did; en, zh, zh-TW, ja, de at 1100 and 420px, Chromium and WebKit:
  22/22. Its zh subtests fail without the zh line.

Run: go test -tags nogui ./internal/agent ./internal/gui; gofmt -l;
GOOS=linux and GOOS=windows go vet -tags nogui ./internal/agent
./internal/gui; the full GUI suite (node --test, both engines, -concurrency 6,
machine load ~140): 5130/5195, 64 failing in 22 files. Rerun alone, 16
files pass; mobile-web, old-webkit, panel-usage and routing-context/
group/keys-fold fail the same on the base commit, b6a263b9.

go test -tags nogui -timeout 40m ./... on the rebased tree: every package
ok but internal/gateway, whose TestQueuedStreamKeptAliveForTheMinute hit
its 1.5s read deadline at a machine load of ~130; it passes -count=3 run
alone, and this change touches nothing it runs.
2026-10-11 02:34:30 +08:00
yetone 603dc0c44f dsh: Disconnect keeps the model picked in dsh 0.2, which saves it into magpie's agent-default-model entry (#1392)
What dsh 0.2.0-rc.2 changed (read in @deepseek-ai/dsh-settings and
dsh-agent-default-model from npm): ~/.dsh/settings.yaml is gone. On its
first boot dsh renames it to settings.yaml.imported and merges its sections
into the booted profile's patch list (profiles/<name>/cordis.patch.yml);
nothing reads the .imported file afterwards. A /model pick is no longer
kept in settings.yaml either: agentDefaultModel.saveSelection goes through
ConfigEditor.edit, which replaces the config of the profile's last
agent-default-model entry. That entry is magpie's, so the user's pick sits
under magpie's "# magpie" mark. Profile paths, the home layer, .env and
.credentials.yaml are unchanged.

What broke: Disconnect took that entry for magpie's own, dropped it and put
back what magpie stashed from before it connected, so the model picked in
dsh (or imported from settings.yaml) was lost. Seen with real dsh
0.2.0-rc.2: after the import, Disconnect left `[]` and dsh started on its
shipped deepseek-flash instead of the imported deepseek-v4-flash.

Fix: dshKeepPick, run per profile before Disconnect takes magpie's wiring
out, hands a marked agent-default-model that is off magpie's route back to
the user (mark removed, old stash discarded). An entry on magpie's route,
or one on the pre-0.1.5 wiring, is still magpie's. dshStart still reads a
settings.yaml not yet imported, which dsh will put over the booted profile.

Run: TestDshPickSavedIntoMagpiesEntryOutlivesDisconnect (fixture from the
patch real dsh 0.2.0-rc.2 wrote) fails on the old code ("the pick made in
dsh was lost", the stashed deepseek-v4-pro came back) and passes. Real dsh
0.2.0-rc.2 under a temp HOME/DSH_HOME, fake gateway on 127.0.0.1:3561:
`dsh headless "say hi"` sent POST /v1/chat/completions, Bearer magpie,
model deepseek/pro to it, before and after a settings.yaml import; after
Disconnect `dsh headless --dump-config` keeps deepseek-v4-flash;
reconnecting sends deepseek/flash to the fake gateway. go test -tags nogui
./... (temp HOME, pinned caches) passes, -race -count=5 -run TestDsh
passes, gofmt -l clean, go vet and GOOS=linux/windows go vet -tags nogui
./internal/agent pass.
2026-10-09 22:26:00 +08:00
yetone 8e0e7d3c40 dsh: the desktop app's profile made while magpie runs gets magpie's route within a round, not at magpie's next start (star on Discord)
star on Discord reported DeepSeek Harness Desktop with the red
"已不经过 magpie" line. One way there that a desktop user meets: the
CLI's web profile wired, then the desktop app opened for the first time
while magpie runs. dsh makes profiles/desktop/cordis.patch.yml as its
empty template ([]), dshCheck says the desktop profile has none of
magpie's models (Drift "unwired"), and only dshSync — the catalog sync,
at magpie's start or a catalog change — filled new profiles, so it stayed
so until Reapply or a restart. The reporter's exact detail is cut off in
the screenshot, so this is a likely cause, not a confirmed one.

dshWiredOnce, the 30s serving round, now runs dshFillNewProfiles over a
profile that is dsh's empty template, beside the wired ones: magpie's
route and start go in as the catalog sync would put them. A profile with
entries of its own and no route is the user's and is still left alone.

Run: TestDshDesktopProfileMadeWhileServing fails on the old code ("the
round left the desktop profile bare"), passes with the fix, and checks a
user's own unrouted profile is not written. go test -tags nogui
./internal/agent ./internal/gui under a temp HOME with pinned caches: ok;
go test -race -run TestDsh -count=3: ok. gofmt clean; go vet darwin,
GOOS=linux -tags nogui, GOOS=windows; go build darwin, linux nogui,
windows: ok. Not tried with the real desktop app live.
2026-10-09 12:56:08 +08:00
yetone ee3f83b59d agents: DeepSeek Harness Desktop installed is no missing dsh CLI — its version shows instead of 未找到 CLI (star on Discord)
star on Discord: "DeepSeek Harness 就是现在已经有桌面版了,但是他还是非要找CLI".
With DeepSeek Harness Desktop in use and no dsh on PATH, the Agents page
said 未找到 CLI and Install another agent offered npm's dsh: CLIMissing
(#843) took ~/.dsh without a CLI for an uninstall. The desktop app
(DeepSeek Harness.app, com.deepseek.dsh, 0.2.0-rc.2 from
download.deepseek.com) keeps the same ~/.dsh — its own profile,
profiles/desktop/cordis.patch.yml, and .credentials.yaml — and needs no
CLI; its terminal command (Manage dsh Command…) is optional.

- desktopapp.go: dsh's app is known by its bundle id on macOS and by
  %LOCALAPPDATA%\Programs\DeepSeek Harness\DeepSeek Harness.exe on
  Windows (electron-builder per-user NSIS, productName DeepSeek Harness,
  getWindowsInstallationDirName); HasApp says either is installed.
- install.go: CLIMissing is false with the agent's desktop app installed,
  so the GUI row, Install another agent and /api all follow; the app's
  version shows through the existing CLI().App path.
- dsh.go: the restart notice also sees DeepSeek Harness.app running.

The red "已不经过 magpie" line in the report is a separate dshCheck
finding, not caused by the missing CLI: a desktop-only ~/.dsh shaped
from the app's real new-profile template wires cleanly (Check "", no
Drift; TestDshDesktopOnlyWired). The reporter's exact detail is cut off
in the screenshot and is not reproduced.

Run: TestDshDesktopAppIsNoMissingCLI fails on the old code ("with the
desktop app: missing true, offered true"; with the Windows path removed,
"with the Windows app: missing true, offered true"), passes with the
fix. go test -tags nogui ./internal/agent ./internal/gui under a temp
HOME with pinned caches: ok. gofmt -l clean; go vet darwin, GOOS=linux
-tags nogui, GOOS=windows on both packages; go build darwin,
GOOS=linux -tags nogui, GOOS=windows: ok. Not tried: the real desktop
app running live (not installed here; its userData isn't redirected by
a sandbox HOME), a real Windows install.
2026-10-09 12:56:08 +08:00
小七 172f45a5e6 agent: dsh's check stays quiet when its key store holds a caller key of this gateway's (#1332) (#1339)
The drift check asked only whether refs.MAGPIE_GATEWAY_KEY equals the key
magpie writes into .env, so a caller key the gateway itself issued — which
dsh's store prefers and the gateway authenticates — was named as "another
MAGPIE_GATEWAY_KEY" and the user was told to remove it there, while
delete → disconnect → re-apply wrote the very same state back. The check
now asks the gateway's own Authenticate first: a key it takes means dsh is
going through magpie, and only a key it would refuse (a foreign one, a
switched-off one) is drift. The .env side needs nothing: the serving round
rewrites .env to magpie's key, so a stray value there heals itself.

TestDshStoreHoldingAGatewayCallerKey (a key from access.Update add-key in
the store's refs) failed without the change with the "holds another
MAGPIE_GATEWAY_KEY" drift; with it the check is quiet, and a key the
gateway doesn't take still reports.

Verified: go test -tags nogui ./internal/agent -count=1; the three dsh
store tests under -race -count=10; gofmt -l clean; go vet -tags nogui
./internal/agent; go build and GOOS=linux/GOOS=windows go build -tags
nogui.

Generated-by: GLM-5.3-Flash (ZCode)
2026-10-08 23:51:34 +08:00
yetone 1d1c9e07d2 agent: without dsh, the dsh round every 30 s doesn't build magpie's whole catalog for no patch list (H20 on Discord: magpie idles near 500 MB)
dshWiredOnce built magpieModels("dsh") before looking for a profile, so every magpie, dsh or not, built the catalog every 30 s and threw it away: 93% of what a magpie at rest allocated (pprof heap?gc=1 delta over 120 s, a linux nogui `magpie web` in Docker on a copy of a real config with 13.5k Codex and Claude Code sessions mounted read-only). That garbage kept the heap at its GC goal, about twice what it keeps. It now returns before the catalog when there is no profile; with one, nothing changes.

Same measurement, this commit and the warm-up one together: idle allocation 73 MB per 2 min -> 6.8 MB (3.8 MB of it the profile read itself); RSS at rest after the first minutes ~250 MB -> ~203 MB, the heap no longer climbing 125 -> 192 MB between GCs. TestDshRoundWithoutDshBuildsNoCatalog fails without the change (475 allocations a round) and passes with it. go test -tags nogui ./internal/agent (Docker golang:1.26.8, non-root, temp HOME), go vet -tags nogui ./internal/agent for linux, windows and darwin, and gofmt -l pass. Not measured on macOS: a fresh build there hangs at exec behind syspolicyd today.
2026-10-08 21:21:01 +08:00
wizzy-yangandwizzy-yang a0cc4562e7 agent: a dsh patch list that lost its route to dsh's own save is written back quietly (#1029)
dsh reads a patch list live and keeps the model its sessions start on
across its own saves of the file (its desktop app writes the list anew
from a snapshot as it saves), but such a save has been seen to take
magpie's route out while keeping the start: the providers beside
magpie's stayed, the start still named magpie's, and the row went red
"no longer goes through magpie" until Apply again — which the next save
reddened again.

The start naming a model of magpie's is what says magpie was not taken
off: taking it off is the switch's doing and it takes the start with it,
and a list whose start is dsh's own or the user's stays as it is. So
dshRouteAgain writes the route back beside the user's own where the
start survives it, and dshCheck says nothing for the loss where a round
can repair it — said with no catalog to write from, it stands as before.

yetone's review of #1029: the home layer is only written into where it
already holds an llm-pi-ai entry of its own — its config replaces every
profile's whole entry (dshOver), so one magpie added there would take the
user's own providers out of dsh's list (#804) — and the loop over the
other profiles no longer skips itself with no catalog: only a profile the
round can write back is passed over, and one taken off magpie for real is
still said. A list still on the old wiring is dshMove's, not the round's
to write beside.

Co-authored-by: wizzy-yang <wizzy-yang@users.noreply.github.com>
2026-10-06 22:09:44 +08:00
yetone 5839e08189 dsh: the gateway key also goes into dsh's own key store, which the desktop app reads (#969, pan17: in the DeepSeek Harness desktop app every turn failed with llm-pi-ai: no credential for provider route "magpie"; its profile resolves MAGPIE_GATEWAY_KEY, which is not set — store MAGPIE_GATEWAY_KEY through the credentials service (the web Models page writes it) or export it (MISSING_CREDENTIAL), while magpie showed dsh connected) — the route was in the desktop profile (magpie writes every profile; the GUI names only the first, profiles/web, which read as "magpie wrote the npm dsh's config"), but magpie put the key only in ~/.dsh/.env. In dsh 0.2 the .env files are layers the product CLI's boot (dsh-app-boot) loads; dsh-credentials-local resolves inherited environment > $DSH_HOME/.credentials.yaml > project .env > home .env, and "a composition the product CLI did not boot has only the inherited environment as its layer". So the desktop app never saw the key. magpie now also writes refs.MAGPIE_GATEWAY_KEY into ~/.dsh/.credentials.yaml, dsh's own store, which its Models page writes and every dsh reads. Details: a new store is made owner-only, version 1 (dsh refuses a store other users can read); the user's other refs, records and comments are kept; a different key of the user's under magpie's name is left alone (the check already reports it); a store in dsh's pre-release flat layout isn't touched; going back to dsh's own models takes magpie's key out. The check now asks for Apply again when the store lacks the key; a dsh wired by an earlier magpie gets it from the catalog sync magpie runs as it starts. The output of a fresh write and a merge into a store with refs, a grant record and a comment both parse with dsh 0.2.0-rc.2's own parseCredentialsDocument. TestDshDesktopGetsTheKeyFromItsStore (web+desktop profiles as on the reporter's machine) and TestDshStoreOfTheUsersOwn fail without the change and pass; -race -count=5 on the dsh tests. Fixtures that stood for "wired" with .env alone now hold the store too. Not tried with the real desktop app (not installed here; the reporter is on Windows); they're asked to confirm. go test ./internal/agent/, go vet, darwin, linux (nogui) and windows builds pass. 2026-10-06 14:13:53 +08:00
yetone 6f1da2c585 agent: DeepSeek Harness's own models say they go straight to DeepSeek (#955) — #834 had every agent's own models say which way they go, Codex's, Grok Build's and Antigravity CLI's custom ones; dsh's three (DeepSeek-V41-Flash, V4-Pro, V4-Flash) still said nothing (EZN7L2C3: DeepSeek Harness 未看到同样的直连入口). Since dsh 0.1.5 magpie is a custom provider beside dsh's own llm-deepseek row, which is left to dsh, so its own models go to DeepSeek on its own key: they now say direct, DeepSeek. Before 0.1.5 magpie took that row over, so nothing is said there. TestOwnModelsSayTheirPath fails without it. go vet, go test ./internal/agent ./internal/gui, GOOS=windows build pass; agent-own-path, agent-path-same and claude-picker-fold pass in Chromium and WebKit, en and zh (no GUI code changed). 2026-10-06 10:44:33 +08:00
yetone fbaf27bce1 agent: dsh's web search goes through magpie while dsh is on one of magpie's models (Packing1 on Discord)
dsh's web search is a plugin of its own, web-search-deepseek, which signs each search to DeepSeek's Anthropic API with DEEPSEEK_API_KEY, so a dsh that reaches its models through magpie alone failed every search asking for that key. While dsh starts on a model of magpie's, magpie writes a marked web-search-deepseek entry in each profile: the gateway's /v1 as baseURL, MAGPIE_GATEWAY_KEY as apiKeyEnv and that model. The gateway answers the plugin's web_search_20250305 request as Anthropic does, by the model's own search or magpie's (web_search_tool_result blocks). A row of the user's, or a DEEPSEEK_API_KEY dsh has in .env or its key store, is left as it is. The entry goes with dsh's own model or Disconnect, and moves with the gateway's address. The row's Notice says when magpie has nothing to search with. TestDshSearchThroughGateway is new and fails without the change. Tested end to end in a sandbox (own HOME and DSH_HOME, gateway on 3493, the real DeepSeek account): real dsh 0.2.0-rc.2 headless called web_search, got eight results through magpie, and answered https://golang.google.cn/blog/go1.26; magpie dsh default took the entry out of all three profiles. go vet, go build (darwin, GOOS=linux nogui, GOOS=windows) and go test -tags nogui ./... under a temp HOME pass.
2026-10-05 22:58:12 +08:00
yetone e77a373792 agent: every agent in a WSL distro under NAT is given the LAN sharing key, not "magpie" (whqtian on Discord) — v0.1.972 gave it to omp only, and OpenCode in WSL was still written "apiKey": "magpie" with Windows' address, which the gateway takes from loopback only. keyAt(gw) is the key for a gateway URL: the LAN sharing key when the URL isn't this machine's and sharing is on, else gateway.Token; OpenCode (and MiMo Code), Crush, Pi/omo, Codex, Claude Code, Kimi Code, Hermes, Grok, MiniMax Code, Droid, Morph, dsh, Qoder/Qoder CN and omp write it, their Checks compare against it (an old "magpie" there shows as drift), and ourKey still sees a LAN-keyed config as magpie's. TestGatewayKeyBeyondLoopback fails without the change. go vet ./..., go test -tags nogui ./internal/agent ./internal/gui ./internal/gateway ./internal/access ./internal/provider under a temp HOME, GOOS=linux/windows go build pass. 2026-10-05 15:19:09 +08:00
tsuixl f5d777c58b fix(dsh): 保留家级模型选择并修正补丁配置继承 (#838) 2026-10-05 07:48:17 +08:00
yetone 165fee0df5 agent: an agent's own provider named as one of magpie's isn't magpie's, in every agent that spells a model provider/model (the rest of #835) — OpenHanako's own deepseek/deepseek-v4-pro read as magpie's deepseek, and so did a model of any agent's own provider whose name magpie has a provider by: Pi's, Crush's, Hermes's, OpenCode's relay/glm-4.6 with magpie's relay had the row connected on the agent's own model, and Disconnect from magpie put that model back and left the row connected. An agent says how magpie's values are spelled in it (Spelled, replacing #835's Prefixed): magpie/<ref> for Antigravity CLI, Pi, OmO, Aside, Goose, Zed, VS Code, Crush, DeepSeek Harness, Command Code, fx, omp, Hermes, Mister Morph, Kimi Code, Empryo, MiniMax Code, Droid, Qoder, Qoder CN, Grok Build, AtomCode, Cline and OpenHanako, whose every Get spells magpie's so (a sandbox Set of magpie/relay/glm-4.6 read back as that in each); for OpenCode, MiMo Code and OpenChamber also a provider of the config's own that sends to magpie's gateway, as openCodeRef names a model there. A stopped WSL distro's agent keeps its live one's. Left as they are: Claude Code, Claude Desktop, Codex, Gemini CLI, Cursor, Copilot, Devin (magpie's are bare refs there), Muse Code (a model with / is magpie's by design: Meta's have none), Alma (its own are providerId:model), Air (magpie's only). TestOwnProviderNamedAsMagpies (26 agents: own relay/glm-4.6 not connected, Connect, Disconnect puts it back and the row is off) fails on the old code in each; TestOpenCodeGatewayProviderIsMagpies. go vet, builds (darwin, GOOS=linux nogui, GOOS=windows) and go test -tags nogui -count=1 ./... under a temp HOME pass. 2026-10-05 06:49:45 +08:00
yetone 9761248de3 agent: dsh's home patch layer, ~/.dsh/cordis.patch.yml, gets magpie's route and start model when it overrides the profiles' (#804, liuweifeng) — dsh applies $DSH_HOME/cordis.patch.yml over every profile's own, so a llm-pi-ai or agent-default-model entry there replaced what magpie wrote in profiles/*/cordis.patch.yml, and dsh ran the home layer's old snapshot while magpie read as connected. When the home layer has a llm-pi-ai entry, magpie's route is written in it beside the user's routes (a sync, a model picked, the 30 s round, and taken out on Disconnect); when it has an agent-default-model, the model and effort magpie set go there (the user's one stashed and put back when magpie's goes). A home layer without those entries is left as it is. Reading goes by the home layer too (the model and effort shown, Joined, the checks), and Check says when the home layer's llm-pi-ai lacks magpie's route. TestDshHomePatchLayer and TestDshHomePatchLayerUnwire fail on the old code. go vet, builds (darwin, GOOS=linux nogui, GOOS=windows) and go test -tags nogui -count=1 ./... under a temp HOME pass (TestProvidersAnswerWhileListsComeIn and TestUserPath flaked, pass alone). 2026-10-05 00:39:40 +08:00
tobitege 21702d01ff Add German translation; harden paths against unset env vars (#770)
* Add German translation and harden paths against unset env vars

Add a German locale to the GUI, tray menu, usage alerts and website home page, and refuse to start when the home folder is unset or relative so nothing is written under the working folder; the pi plugin no longer adopts the user's PI_CODING_AGENT_DIR, and an inherited APPIMAGE no longer selects portable mode. Scripts refuse to run from the wrong folder or empty a shared out folder, and a new internal/testenv sandboxes every test package from the user's real files, which also fixes the Claude picker and Termux installer tests on Windows.

* Makefile: know magpie's folder by its go.mod, so paths with spaces work

The check compared $(CURDIR) with $(dir $(abspath …)), which make splits on spaces, so a checkout under 'My Projects' or 'John Doe' refused every target. It now reads go.mod relative to the working folder and wants magpie's module there: make -C and a symlinked Makefile work, make -f from another folder still stops before any recipe runs.

* i18n: German for the strings main added since, with a parity test

75 strings main added (group order, patterns, slow-start wait, usage caps, RTK savings …) get their German, and two that main dropped go. gui-de.test.cjs checks, as gui-ja does, that de has every zh string with its placeholders and tags, and that the window reads in German when picked or on a German system.

* appdir: ignore relative folder variables when reading, keep them for children

CheckEnv no longer unsets anything. magpie reads the XDG folders, APPDATA/LOCALAPPDATA and every agent's folder variable through appdir.Getenv/LookupEnv, which pass over a relative value; the environment stays as it is, so the agents magpie starts get the variable as the user set it. That covers what proc.UserPath lends from the login shell too, which is set after main's check and reached the desktop app unchecked. On Windows a path rooted on the current drive (\Users\x, Git Bash's /c/x) counts as usable, and magpie version and help answer without a home, before run makes any folder.

* Sandbox the tests main added since

internal/wslrun gets testenv's TestMain, and four tests main added that set HOME alone set their home with testenv.SetHome, so on Windows they don't read the runner's profile through USERPROFILE.

* agentenv: PI_CONFIG_DIR and OPENCODE_DB take relative names on purpose

omp puts $PI_CONFIG_DIR under the home and OpenCode a relative $OPENCODE_DB in its data folder, so neither depends on the working folder: appdir no longer passes them over.

* i18n: German for the Library's multi-select and System One's decision API

The 19 strings main added since (#791's skill multi-select, the decision API snippets) get their German; the one main replaced (four APIs → five APIs) goes.

* appdir: tidy the import into magpie's group; say what Go makes of /c/x

The appdir import joins the group of magpie's own imports where a file has one. rooted's comment now says that Go takes a Git Bash path like /c/x as \c\x on the current drive, not C:\x.
2026-10-04 23:30:56 +08:00
yetone 2dc8e249cb agent: dsh on a DeepSeek model picked in its own /model stays connected while magpie's route is in its list (Fate on Discord: DSH went back to Not connected) — magpie connects dsh by putting its route among dsh's custom providers and starting it on one of magpie's models; a model of DeepSeek's own picked in dsh is saved in its settings.yaml over the patch list, and the Agents page, which called an agent connected only when its model field was magpie's, showed it Not connected, though the route, its key and magpie's models in dsh's /model were all still there. dsh now has Joined (the first profile's patch list has magpie's route), as Codex signed in with ChatGPT does, so it reads Connected · pick magpie's models with /model, and a pick off magpie while joined isn't drift ("changed outside magpie"). Disconnect in that state has an Unwire that takes the route, the start magpie wrote and the key out of every profile and .env and leaves the model picked in dsh; on one of magpie's models it does nothing and the model set back does it all, as before. TestDshOwnPickStaysConnected (connect, a DeepSeek pick in settings.yaml: wired, no drift; Disconnect: the template as it was, no key, the pick kept) fails on the old code. go vet, builds (darwin, GOOS=linux nogui, GOOS=windows) and go test -tags nogui -count=1 ./... under a temp HOME pass. 2026-10-04 22:03:41 +08:00
yetone 6953627b10 agents: DeepSeek Harness in a WSL distro (lgtm on Discord: wsl中安装的dsh,目前magpie还是扫描不到,可以添加上吗?) — dsh was this machine's only: dsh(home) read DSH_HOME and wrote the gateway's own address. It is now dshAt(place), as Empryo and the others are: its home is the distro's ~/.dsh (a distro's DSH_HOME can't be read), and the gateway it names in a profile's route, the legacy llm-deepseek entry and Check is the place's (gw threaded through dshSync, dshSet, dshSetEffort, dshCheck and the route writers). wslKinds lists it (dir .dsh, bin dsh); a stopped distro's thinking options come from magpie alone, as its patch lists can't be looked at. KeepDshWired stays this machine's: a distro's route is written again on a sync. TestWSLDshProfiles (a profile's route names 172.20.0.1, a sync and dshWiredOnce leave it) and dsh in wslMore (probe, pick, stopped) fail without it. go vet ./internal/..., go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build, go test -tags nogui -count=1 ./... under a temp HOME pass. 2026-10-03 11:17:55 +08:00
yetone 9845e3af51 dsh: magpie's route keeps the protocol picked for it in dsh's Models page, OpenAI Responses or Anthropic Messages, where each round put Chat Completions back (01huadalang on Discord: 这些协议怎么改 responses,在 dsh 改了一会就会被 magpie 接管) — the route was written whole each round, api: openai-completions included (dshRouteConfig), so a route switched to OpenAI Responses in dsh's Models page went back to Chat Completions within the 30 s the loop takes. Each round now reads the route's api from the profile's patch list and keeps it when it is one of the three llm-pi-ai protocols the gateway serves (dshAPI: openai-completions at /v1/chat/completions, openai-responses at /v1/responses, anthropic-messages at /v1/messages); none, or one the gateway has no endpoint for (google-generative-ai), goes back to openai-completions. The base goes with the protocol (dshBaseURL): pi-ai hands it to the vendor's SDK as it is, and Anthropic's adds /v1/messages itself, so anthropic-messages is at the gateway's root and the two OpenAI ones at its /v1 (as omp and Pi have it); dshCheck asks for the same base, so a route on Messages isn't reported as pointed elsewhere. On Messages a Claude that thinks only adaptively gets compat.forceAdaptiveThinking, which llm-pi-ai offers there, since pi-ai asks every other model for a thinking budget it turns away. reasoningEfforts are as before on all three: llm-pi-ai (0.2.0-rc.2) makes them pi-ai's thinkingLevelMap, sent as reasoning_effort on Chat, reasoning.effort on Responses (off as the map's none, a model without none having off hidden) and output_config.effort for an adaptive Claude on Messages. TestDshRouteKeepsTheAPIPickedInDsh (a loop round and a sync on a route set to openai-responses, to anthropic-messages at the /v1 base, to google-generative-ai and to none; dsh's check clean, a second round writing nothing) fails without the change (openai-responses written back as openai-completions). TestDshResponsesReachChatVendor sends pi-ai's Responses request, with dsh's User-Agent, to the gateway for a model served on Chat Completions alone: it is asked in Chat with reasoning_effort high, the image, tool call and output carried over, and the reply comes back as Responses events. Read from the installed dsh's llm-pi-ai and pi-ai only; no dsh profile, live agent config or running magpie was touched. go vet ./internal/..., go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build, go test -tags nogui -count=1 ./... under a temp HOME pass (TestFXInState failed once on its TempDir cleanup, passes alone). 2026-10-02 19:41:21 +08:00