agent: Claude Desktop from its MSIX isn't said to be off magpie when the package's copy is emptied, and Reconnect puts its gateway back (dumplings)
dumplings (Windows, Desktop 2.31226.0 from the MSIX) saw "Claude Desktop
已不经过 magpie:配置已变更" while Desktop ran on magpie, and Reconnect
didn't clear it; switching Desktop's provider off magpie and back did.
Two causes:
- Check went over both sets of folders magpie writes for a packaged
Desktop (the package's LocalCache and the real ones, as which build
is installed can't be told) and failed when either was off magpie.
2.31226 reads the real %LOCALAPPDATA%\Claude-3p (bg5eau, already in
desktopdir), so the package's copy, emptied, isn't Desktop off
magpie. desktopRead now judges only the set whose Claude-3p Desktop
ran in last ("Local State", desktopdir.LastRun), every set when it
ran in none, as before.
- Reapply on an unwired drift re-set the field drift shows on and
fields on magpie's models. Desktop's drift shows on a tier (sonnet,
on a magpie model), and its provider field ("magpie") isn't a model,
so the gateway was never written back. Reapply now also re-sets a
field whose value is magpie itself, as Wired already counts it.
The reporter's analysis said 2.31226's AppxManifest excludes
Claude-3p from virtualization; that manifest wasn't seen here (the
Windows box has no MSIX Desktop), the fix rests on Desktop reading the
real Claude-3p, which bg5eau's case showed.
Run: TestClaudeDesktopMSIXChecksTheFoldersDesktopRuns (MSIX layout:
package Roaming\Claude and Local\Claude-3p with an older Local State,
the real Claude-3p newer); red with Check over every set, and red
with Reapply without the magpie-valued field. go test -tags nogui for
internal/agent, internal/desktopdir, internal/gui, internal/library;
the agent package's TestClaudeDesktop* built for windows/amd64 and run
on the Windows box, all pass; gofmt -l; go vet -tags nogui on darwin,
GOOS=linux and GOOS=windows for internal/agent, internal/desktopdir.
This commit is contained in:
@@ -52,6 +52,7 @@ something else shows up as drift.
|
||||
- Codex's "subagent model" field writes nothing to Codex's config: its lead names each subagent's model in `spawn_agent`, which `[agents]` can't overrule. It is magpie's setting (`settings.CodexSubagentModel`, [`codex_subagent.go`](../../internal/provider/codex_subagent.go)), and the gateway moves the subagent's request onto it (see [gateway routing](gateway-routing.md)). Its options are only ChatGPT accounts' models, as a subagent's task is sealed for them. Its setter keeps a ChatGPT account's model no account serves now, so a profile or backup put back on another computer still applies (`ApplyFields` stops at the first failed Set), and refuses any other provider's model.
|
||||
- Snow CLI runs on one profile at a time (`profiles/<name>.json` in `~/.snow` or `$SNOW_CONFIG_DIR`, named in `active-profile.json`) and copies the active one over `config.json` at every start, `snow --ask` too ([`snow.go`](../../internal/agent/snow.go)). magpie writes a `magpie` profile, makes it the active one, and copies it to `config.json` itself, so a Snow already running and Snow App's "Sync Snow CLI API config" see the same. It is made from the profile the user was on, their settings kept and its OAuth sign-in left out. A vision model of that profile comes along only with an endpoint and key of its own (`snowOwnVision`), since one on the profile's would now go to the gateway. `maxContextTokens`, `maxTokens` and `supportsVision` follow the model from the catalog (`snowSynced`; `supportsVision` as every agent is told, true while magpie's Vision describes images); what magpie last wrote of them is stashed, and one the user changed since in Snow's own settings is kept through later picks and syncs. The small field is magpie's profile's `basicModel`, Snow's light model for summaries, compaction and file search: empty while it follows the main model, a model through magpie of its own kept through new main models and syncs; on a profile of the user's it offers nothing and is hidden. The thinking field is magpie's profile's `chatThinking` (`{enabled: true, reasoning_effort}`), the only thinking setting Snow reads on the chat protocol; empty deletes it, Snow's default, which sends thinking disabled. A chatThinking the user brought from their profile is shown, not written over. The profile they were on (or that there was no `active-profile.json`) and a `magpie.json` of their own are stashed and put back by Disconnect. A Snow from before profiles (`config.json` alone) gets the `default.json` Snow itself would have made of it, so its next start doesn't take magpie's for the user's. Picking a model of another of the user's profiles switches Snow to that profile.
|
||||
- A value an agent spells as its own provider's model is never taken for one of magpie's, even when magpie has a provider of the same name (`Spelled`, #835).
|
||||
- `Reapply` on `unwired` sets again every field on one of magpie's models and every field set to magpie itself (`magpieID`, as `Wired` takes it): Claude Desktop's drift shows on a tier, and its `provider` field is what writes the gateway back (dumplings on Discord). Claude Desktop's `Check` judges only the set of folders whose Claude-3p it ran in last (`desktopRead`, by `desktopdir.LastRun`), every set when it ran in none: magpie writes both of an MSIX install's sets, and 2.31226 reads the real `%LOCALAPPDATA%\Claude-3p`, so the package's copy being emptied is not Desktop off magpie.
|
||||
- `unreachable` never sets anything: the config is right, and the page's pill only says what has to listen. The exception is an address a WSL distro reached Windows at before (`distro.Was`, kept in `wsl.json`) while it reaches Windows at another now: the pill offers that one, and `Reapply` moves the config there (`Agent.move`, Codex's `codexMoveGateway`). An address no distro was seen at is the user's own and is never moved. An unknown answer (no probe yet) and a gateway down on loopback too are not drift. Tests stub `reachProbe` in `TestMain`.
|
||||
- Listing never starts a stopped WSL distro. A stopped distro's agent shows what was last seen there (`asleep`, `wsl.json`); setting one of its fields writes its files, which starts the distro.
|
||||
- Codex's sign-in (`login`) is ChatGPT (`""`, the default), Always ChatGPT (`chatgpt`) or magpie API (`api`). With ChatGPT, magpie's models join Codex's own beside the sign-in (`openai_base_url`), and while the Codex app holds the ChatGPT account Codex is signed in to (`codexUsedUp`, `provider.CodexUsedUp`: OpenAI no longer allows the account and it has no credits left, a workspace still within its overage excepted), magpie is made Codex's provider (`codex.out`): the Codex app sends nothing at all on an account it holds, a magpie model's turn included (#540), and as a provider of its own magpie is past that. A window at 100% with credits left doesn't count, and Codex stays signed in. Sync puts it back beside the sign-in once the account has room. Always ChatGPT never does that: Codex stays in its ChatGPT state, and the Codex app may send nothing till the account has room, while Codex CLI's turns still reach magpie by the base URL, and its routing and other accounts serve them.
|
||||
|
||||
@@ -351,7 +351,11 @@ func (a *Agent) Reapply() error {
|
||||
}
|
||||
vals := a.Values()
|
||||
for _, f := range a.Fields {
|
||||
if v := vals[f.Key]; v != "" && (d != nil && f.Key == d.Field || magpieValue(a, f, v, vals)) {
|
||||
// magpie as the agent's provider too (Claude Desktop's provider
|
||||
// field, beside its tiers on magpie's models), as Wired takes it:
|
||||
// left out, Reconnect set the tiers again and never the gateway
|
||||
// Check found off (dumplings on Discord)
|
||||
if v := vals[f.Key]; v != "" && (d != nil && f.Key == d.Field || v == magpieID || magpieValue(a, f, v, vals)) {
|
||||
if err := a.Apply(f.Key, v); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ import (
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/yetone/magpie/internal/desktopdir"
|
||||
"github.com/yetone/magpie/internal/edit"
|
||||
@@ -127,7 +128,7 @@ func claudeDesktop(home string) *Agent {
|
||||
if !desktopWiredAny(ps) {
|
||||
return ""
|
||||
}
|
||||
for _, p := range ps {
|
||||
for _, p := range desktopRead(ps) {
|
||||
if msg := desktopCheck(p); msg != "" {
|
||||
if len(ps) > 1 {
|
||||
msg += " (" + p.dir3p + ")"
|
||||
@@ -169,6 +170,28 @@ func claudeDesktop(home string) *Agent {
|
||||
}
|
||||
}
|
||||
|
||||
// desktopRead are the sets of Desktop's folders whose wiring counts: the
|
||||
// one whose Claude-3p Desktop ran in last, which is where it reads
|
||||
// deploymentMode and the gateway from, or every set when it has run in
|
||||
// none. Magpie writes both of a packaged Desktop's sets, not knowing the
|
||||
// build: 2.31226's MSIX keeps Claude-3p out of the package
|
||||
// (ExcludedDirectory), so the package's copy is one Desktop no longer
|
||||
// reads, and one gone from there (emptied by an update) isn't Desktop off
|
||||
// magpie (dumplings on Discord: "配置已变更" while Desktop ran on magpie).
|
||||
func desktopRead(ps []desktopPaths) []desktopPaths {
|
||||
var newest time.Time
|
||||
var at []desktopPaths
|
||||
for _, p := range ps {
|
||||
if t := desktopdir.LastRun(p.dir3p); t.After(newest) {
|
||||
newest, at = t, []desktopPaths{p}
|
||||
}
|
||||
}
|
||||
if at == nil {
|
||||
return ps
|
||||
}
|
||||
return at
|
||||
}
|
||||
|
||||
// desktopCheck is what keeps one set of Desktop's folders off magpie's
|
||||
// gateway, "" for nothing.
|
||||
func desktopCheck(p desktopPaths) string {
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/yetone/magpie/internal/desktopdir"
|
||||
"github.com/yetone/magpie/internal/gateway"
|
||||
@@ -470,3 +471,74 @@ func TestClaudeDesktopMSIXStashBefore(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// dumplings on Discord: Desktop 2.31226.0 from its MSIX on Windows runs in
|
||||
// the real %LOCALAPPDATA%\Claude-3p (its "Local State" there is the newest),
|
||||
// and the package's LocalCache copy, which magpie wrote too, is emptied.
|
||||
// Desktop is on magpie and the card doesn't say it was changed; the copy
|
||||
// Desktop reads turned back to 1p still does, and Reconnect with a tier on
|
||||
// one of magpie's models puts the gateway back, not only the tier.
|
||||
func TestClaudeDesktopMSIXChecksTheFoldersDesktopRuns(t *testing.T) {
|
||||
home, _ := desktopSandbox(t)
|
||||
old := desktopdir.OS
|
||||
desktopdir.OS = "windows"
|
||||
t.Cleanup(func() { desktopdir.OS = old })
|
||||
if err := provider.Save(provider.Provider{ID: "v", Name: "V", Chat: "http://127.0.0.1:1/v1", Key: "k", Models: []string{"a", "b"}}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
local := filepath.Join(home, "AppData", "Local")
|
||||
os.MkdirAll(filepath.Join(home, "AppData", "Roaming"), 0o755)
|
||||
pkg := filepath.Join(local, "Packages", "Claude_pzs8sxrjxfjjc", "LocalCache")
|
||||
pkg3p, real3p := filepath.Join(pkg, "Local", "Claude-3p"), filepath.Join(local, "Claude-3p")
|
||||
desktopWrite(t, filepath.Join(pkg, "Roaming", "Claude", "Local State"), `{}`)
|
||||
desktopWrite(t, filepath.Join(pkg3p, "Local State"), `{}`)
|
||||
desktopWrite(t, filepath.Join(real3p, "Local State"), `{}`)
|
||||
desktopWrite(t, filepath.Join(real3p, "claude_desktop_config.json"), `{"preferences":{"x":1}}`)
|
||||
then := time.Now().Add(-48 * time.Hour)
|
||||
for _, f := range []string{filepath.Join(pkg, "Roaming", "Claude", "Local State"), filepath.Join(pkg3p, "Local State")} {
|
||||
os.Chtimes(f, then, then)
|
||||
}
|
||||
a := claudeDesktop(home)
|
||||
if err := a.Field("provider").Set("magpie"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := a.Field("sonnet").Set("v/a"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if c := a.Check(); c != "" {
|
||||
t.Fatalf("check: %s", c)
|
||||
}
|
||||
// the update leaves the package's Claude-3p empty
|
||||
if err := os.RemoveAll(pkg3p); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
os.MkdirAll(pkg3p, 0o755)
|
||||
if c := a.Check(); c != "" {
|
||||
t.Errorf("the package's copy Desktop no longer reads: %s", c)
|
||||
}
|
||||
if d := a.Drift(); d != nil && d.Kind == "unwired" {
|
||||
t.Errorf("drift: %+v", d)
|
||||
}
|
||||
// the one Desktop runs in, turned back to 1p, is said
|
||||
r := desktopPathsOf(filepath.Join(local, "Claude"), real3p)
|
||||
desktopWrite(t, r.config3p, `{"deploymentMode":"1p","preferences":{"x":1}}`)
|
||||
if c := a.Check(); !strings.Contains(c, "no longer 3p") || !strings.Contains(c, real3p) {
|
||||
t.Fatalf("check: %q", c)
|
||||
}
|
||||
if d := a.Drift(); d == nil || d.Kind != "unwired" {
|
||||
t.Fatalf("drift: %+v", d)
|
||||
}
|
||||
// Reconnect: the gateway back, with the tier
|
||||
if err := a.Reapply(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if c := a.Check(); c != "" {
|
||||
t.Errorf("after Reconnect: %s", c)
|
||||
}
|
||||
if m := desktopJSON(t, r.config3p); m["deploymentMode"] != "3p" || m["preferences"] == nil {
|
||||
t.Errorf("%s: %v", r.config3p, m)
|
||||
}
|
||||
if got := a.Field("sonnet").Get(); got != "v/a" {
|
||||
t.Errorf("sonnet: %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,6 +143,9 @@ func Everywhere() []string {
|
||||
return out
|
||||
}
|
||||
|
||||
// LastRun is when Desktop last ran in any of dirs (lastRun).
|
||||
func LastRun(dirs ...string) time.Time { return lastRun(dirs...) }
|
||||
|
||||
// lastRun is when Desktop last ran in any of dirs, its userData folders:
|
||||
// the time Chromium's "Local State" there was written, zero for none. A
|
||||
// folder holding only claude_desktop_config.json (another tool's MCP
|
||||
|
||||
Reference in New Issue
Block a user