diff --git a/internal/agent/dsh.go b/internal/agent/dsh.go index 694cbf22d..82419d34b 100644 --- a/internal/agent/dsh.go +++ b/internal/agent/dsh.go @@ -74,10 +74,18 @@ var dshModels = []Option{ {Value: "deepseek-v4-flash", Label: "DeepSeek-V4-Flash", Icon: "deepseek-color", Group: "DeepSeek Harness"}, } -func dsh(home string) *Agent { - dir := os.Getenv("DSH_HOME") +func dsh(home string) *Agent { return dshAt(here(home)) } + +// dshIn is DeepSeek Harness in a WSL distro (see wsl.go). +func dshIn(at place) *Agent { return dshAt(at) } + +// dshAt is DeepSeek Harness with its home at at.home, reaching the gateway +// as at does. A distro's DSH_HOME can't be read, so there it is ~/.dsh. +func dshAt(at place) *Agent { + gw := at.gw + dir := at.getenv("DSH_HOME") if dir == "" { - dir = filepath.Join(home, ".dsh") + dir = filepath.Join(at.home, ".dsh") } path := filepath.Join(dir, "config.yaml") if files := dshProfiles(dir); len(files) > 0 { @@ -87,7 +95,7 @@ func dsh(home string) *Agent { ID: "dsh", Name: "DeepSeek Harness", Icon: "deepseek-color", Aliases: []string{"deepseek-harness"}, UA: []string{"deepseek-harness"}, Bin: "dsh", Dir: dir, Path: path, - Sync: func() error { return dshSync(dir) }, + Sync: func() error { return dshSync(dir, gw()) }, Notice: func() string { var notes []string if Running(`(^|/)dsh( |$)`) { @@ -103,11 +111,11 @@ func dsh(home string) *Agent { } return strings.Join(notes, " ") }, - Check: func() string { return dshCheck(dir) }, + Check: func() string { return dshCheck(dir, gw()) }, Fields: []Field{{ Key: "model", Label: "model", Get: func() string { return dshGet(dir) }, - Set: func(v string) error { return dshSet(dir, v) }, + Set: func(v string) error { return dshSet(dir, v, gw()) }, Options: func(map[string]string) []Option { return append(append([]Option{}, dshModels...), viaMagpie("dsh", magpieID+"/")...) }, @@ -118,7 +126,7 @@ func dsh(home string) *Agent { // dsh's own default is high) Key: "effort", Label: "thinking", Get: func() string { return dshGetEffort(dir) }, - Set: func(v string) error { return dshSetEffort(dir, v) }, + Set: func(v string) error { return dshSetEffort(dir, v, gw()) }, Options: func(cur map[string]string) []Option { // a model through magpie that lists no levels has none in // dsh (its route gives it no reasoningEfforts), so none is @@ -446,7 +454,7 @@ func dshGetLegacy(path string) string { // elsewhere, the model it starts on one the route doesn't list, or — since // 0.1.5 — the key it names gone from .env, or another key under that name in // dsh's own store, which it reads first. -func dshCheck(dir string) string { +func dshCheck(dir, gw string) string { if !usesMagpie(dshGet(dir)) { return "" } @@ -463,7 +471,7 @@ func dshCheck(dir string) string { } } get := func(string) (string, bool) { return base, base != "" } - return wiringOff("DeepSeek Harness", path, get, "baseURL", gatewayV1()) + return wiringOff("DeepSeek Harness", path, get, "baseURL", gw+"/v1") } // a profile of dsh's (its desktop app's) without magpie's route: // sessions there list dsh's own models alone @@ -491,7 +499,7 @@ func dshCheck(dir string) string { if route == nil { api = "" // dsh's DeepSeek row taken over: Chat Completions } - if off := wiringOff("DeepSeek Harness", files[0], get, "baseURL", dshBaseURL(dshAPI(api))); off != "" { + if off := wiringOff("DeepSeek Harness", files[0], get, "baseURL", dshBaseURL(dshAPI(api), gw)); off != "" { return off } // dsh counts a model its provider doesn't list as none at all and refuses @@ -557,7 +565,7 @@ var dshWrites sync.Mutex // dshSet writes v as the model new sessions start on: a catalog model // through the gateway, one of dsh's own models directly, or "" for dsh's own // default. Every profile gets it; config.yaml only where there are none. -func dshSet(dir, v string) error { +func dshSet(dir, v, gw string) error { dshWrites.Lock() defer dshWrites.Unlock() ref, viaGateway := strings.CutPrefix(v, magpieID+"/") @@ -568,16 +576,16 @@ func dshSet(dir, v string) error { models := magpieModels("dsh") files := dshProfiles(dir) if len(files) == 0 { - return dshSetFile(legacy, v, false, models) + return dshSetFile(legacy, v, false, models, gw) } for _, f := range files { - if err := dshSetFile(f, v, true, models); err != nil { + if err := dshSetFile(f, v, true, models, gw); err != nil { return err } } // what an older dsh was given is no use now if _, err := os.Stat(legacy); err == nil { - if err := dshSetFile(legacy, "", false, models); err != nil { + if err := dshSetFile(legacy, "", false, models, gw); err != nil { return err } } @@ -617,7 +625,7 @@ func dshEnv(dir string, on bool) error { // dshSetFile writes v into one patch list; modern is the layout of dsh // 0.1.5 on. -func dshSetFile(path, v string, modern bool, models []catalog.Model) error { +func dshSetFile(path, v string, modern bool, models []catalog.Model, gw string) error { head, items, err := dshRead(path) if err != nil { return err @@ -659,12 +667,12 @@ func dshSetFile(path, v string, modern bool, models []catalog.Model) error { drop("api-gateway") drop("agent-loop") drop("llm-deepseek") - if items, err = dshPutRoute(items, false, nil); err != nil { + if items, err = dshPutRoute(items, false, nil, gw); err != nil { return err } case modern && viaGateway: drop("llm-deepseek") // magpie's before it was a provider of its own - if items, err = dshPutRoute(items, true, models); err != nil { + if items, err = dshPutRoute(items, true, models, gw); err != nil { return err } if !contains(dshLevels(ref), effort) { @@ -673,7 +681,7 @@ func dshSetFile(path, v string, modern bool, models []catalog.Model) error { put("agent-default-model", dshDefaultLines(dshRoute, ref, effort)) case modern: drop("llm-deepseek") - if items, err = dshPutRoute(items, false, nil); err != nil { + if items, err = dshPutRoute(items, false, nil, gw); err != nil { return err } if !contains(dshEfforts, effort) { @@ -681,7 +689,7 @@ func dshSetFile(path, v string, modern bool, models []catalog.Model) error { } put("agent-default-model", dshDefaultLines("deepseek-official", v, effort)) case viaGateway: - put("llm-deepseek", dshProviderLines(effort, models)) + put("llm-deepseek", dshProviderLines(effort, models, gw)) put("agent-loop", dshLoopLines(ref)) put("api-gateway", dshRouteLines(ref)) default: @@ -696,7 +704,7 @@ func dshSetFile(path, v string, modern bool, models []catalog.Model) error { // custom providers of the llm-pi-ai entry, or with on false takes it out. // Other routes there, the user's or ones dsh added beside magpie's, stay; an // entry left with nothing goes. -func dshPutRoute(items []dshItem, on bool, models []catalog.Model) ([]dshItem, error) { +func dshPutRoute(items []dshItem, on bool, models []catalog.Model, gw string) ([]dshItem, error) { i := dshFindLast(items, dshPiRow) if i < 0 && !on { return items, nil @@ -722,7 +730,7 @@ func dshPutRoute(items []dshItem, on bool, models []catalog.Model) ([]dshItem, e api = v.Value } var route yaml.Node - if err := route.Encode(dshRouteConfig(models, api)); err != nil { + if err := route.Encode(dshRouteConfig(models, api, gw)); err != nil { return nil, err } // what dsh's Models page added to it (a default level, headers) @@ -810,11 +818,11 @@ func dshAPI(cur string) string { // base to the vendor's SDK as it is, and Anthropic's adds /v1/messages // itself, so Anthropic's Messages API is at the gateway's root; OpenAI's // SDK adds only /chat/completions or /responses, so those are at its /v1. -func dshBaseURL(api string) string { +func dshBaseURL(api, gw string) string { if api == "anthropic-messages" { - return gateway.URL() + return gw } - return gatewayV1() + return gw + "/v1" } // dshPiLevels maps each of dsh's thinking levels a model takes to the @@ -888,9 +896,9 @@ func dshLevels(ref string) []string { // makes them pi-ai's thinkingLevelMap, sent as reasoning_effort on Chat // Completions, reasoning.effort on Responses and, for a Claude thinking // adaptively, output_config.effort on Messages. -func dshRouteConfig(models []catalog.Model, api string) dshPiRoute { +func dshRouteConfig(models []catalog.Model, api, gw string) dshPiRoute { api = dshAPI(api) - r := dshPiRoute{DisplayName: "Magpie", APIKeyEnv: dshKeyRef, API: api, BaseURL: dshBaseURL(api), Models: []dshPiModel{}} + r := dshPiRoute{DisplayName: "Magpie", APIKeyEnv: dshKeyRef, API: api, BaseURL: dshBaseURL(api, gw), Models: []dshPiModel{}} for _, m := range models { e := dshPiModel{ID: m.ID, Name: m.Name, ContextWindow: m.Context} if m.Output > 0 { @@ -920,7 +928,7 @@ func yamlQuote(s string) string { // the gateway, with the catalog as the models its /model offers and the key // in the entry. effort is the thinking effort sessions start with, high // (dsh's own default) when "". -func dshProviderLines(effort string, models []catalog.Model) []string { +func dshProviderLines(effort string, models []catalog.Model, gw string) []string { if effort == "" { effort = "high" } @@ -928,7 +936,7 @@ func dshProviderLines(effort string, models []catalog.Model) []string { "- id: llm-deepseek " + dshMark, " config:", " apiKey: " + yamlQuote(gateway.Token), - " baseURL: " + yamlQuote(gatewayV1()), + " baseURL: " + yamlQuote(gw+"/v1"), " thinking: enabled", " reasoningEffort: " + effort, " models:", @@ -998,13 +1006,13 @@ func dshRouteLines(model string) []string { // llm-deepseek entry before 0.1.5), in every patch list that has it; a // profile still on dsh's DeepSeek row taken over moves to the route. // Nothing else in the patch lists changes. -func dshSync(dir string) error { +func dshSync(dir, gw string) error { dshWrites.Lock() defer dshWrites.Unlock() models := magpieModels("dsh") files := dshProfiles(dir) if len(files) == 0 { - return dshSyncLegacy(filepath.Join(dir, "config.yaml"), models) + return dshSyncLegacy(filepath.Join(dir, "config.yaml"), models, gw) } defer func() { // the key under the name the route gives it, moved from the old one @@ -1018,7 +1026,7 @@ func dshSync(dir string) error { continue } if dshOldWiring(items) { - if err := dshMove(f, items, models); err != nil { + if err := dshMove(f, items, models, gw); err != nil { return err } continue @@ -1026,11 +1034,11 @@ func dshSync(dir string) error { if !dshWired(items) { continue } - if _, err := dshRouteAgain(f, models); err != nil { + if _, err := dshRouteAgain(f, models, gw); err != nil { return err } } - return dshFillNewProfiles(files, models) + return dshFillNewProfiles(files, models, gw) } // dshRouteAgain writes magpie's route again in one patch list where it is no @@ -1042,7 +1050,7 @@ func dshSync(dir string) error { // and the write, which is the newer of the two: the next round reads it. // models is the catalog the round read: with none there is no route to write, // and writing an empty one would take a working list away. -func dshRouteAgain(f string, models []catalog.Model) (bool, error) { +func dshRouteAgain(f string, models []catalog.Model, gw string) (bool, error) { if len(models) == 0 { return false, nil } @@ -1056,7 +1064,7 @@ func dshRouteAgain(f string, models []catalog.Model) (bool, error) { } i := dshFindLast(items, dshPiRow) before := strings.Join(items[i].lines, "\n") - if items, err = dshPutRoute(items, true, models); err != nil { + if items, err = dshPutRoute(items, true, models, gw); err != nil { return false, nil } if strings.Join(items[i].lines, "\n") == before { @@ -1125,7 +1133,7 @@ func dshWiredOnce() string { var trouble []string models := magpieModels("dsh") for _, f := range dshProfiles(dir) { - written, err := dshRouteAgain(f, models) + written, err := dshRouteAgain(f, models, gateway.URL()) if err != nil { trouble = append(trouble, fmt.Sprintf("writing dsh's route again in %s: %s", f, dshWriteError(err))) continue @@ -1162,7 +1170,7 @@ func dshHome() string { // dshMove moves a profile magpie wired by taking over dsh's DeepSeek row // onto magpie's route, the model and effort kept. -func dshMove(f string, items []dshItem, models []catalog.Model) error { +func dshMove(f string, items []dshItem, models []catalog.Model, gw string) error { model := "" if i := dshFindLast(items, "agent-default-model"); i >= 0 { if c := dshConfig(items[i]); c["provider"] == "deepseek-official" { @@ -1183,11 +1191,11 @@ func dshMove(f string, items []dshItem, models []catalog.Model) error { } return dshWrite(f, head, items) } - return dshSetFile(f, magpieID+"/"+model, true, models) + return dshSetFile(f, magpieID+"/"+model, true, models, gw) } // dshSyncLegacy is dshSync on a config.yaml before 0.1.5. -func dshSyncLegacy(f string, models []catalog.Model) error { +func dshSyncLegacy(f string, models []catalog.Model, gw string) error { head, items, err := dshRead(f) if err != nil { return nil @@ -1199,7 +1207,7 @@ func dshSyncLegacy(f string, models []catalog.Model) error { if len(models) == 0 { return nil } - lines := dshProviderLines(dshEffortIn(items), models) + lines := dshProviderLines(dshEffortIn(items), models, gw) if strings.Join(lines, "\n") == strings.Join(items[i].lines, "\n") { return nil } @@ -1211,7 +1219,7 @@ func dshSyncLegacy(f string, models []catalog.Model) error { // desktop app's, opened for the first time after the web's was wired — // magpie's route, and the model magpie set in the others when it starts on // none of the user's: until then it lists dsh's own models alone. -func dshFillNewProfiles(files []string, models []catalog.Model) error { +func dshFillNewProfiles(files []string, models []catalog.Model, gw string) error { if len(models) == 0 { return nil } @@ -1241,13 +1249,13 @@ func dshFillNewProfiles(files []string, models []catalog.Model) error { continue } if i := dshFind(items, "agent-default-model"); i < 0 || dshOurs(items[i]) { - if err := dshSetFile(f, magpieID+"/"+model, true, models); err != nil { + if err := dshSetFile(f, magpieID+"/"+model, true, models, gw); err != nil { return err } continue } // a model of the user's: magpie's are listed beside it - if items, err = dshPutRoute(items, true, models); err != nil { + if items, err = dshPutRoute(items, true, models, gw); err != nil { continue } if err := dshWrite(f, head, items); err != nil { @@ -1321,7 +1329,7 @@ func dshGetEffort(dir string) string { // dshSetEffort writes v as the effort sessions start with: into // agent-default-model (0.1.5 on), or into magpie's llm-deepseek entry // before, dsh's own row being used whole when there is none. -func dshSetEffort(dir, v string) error { +func dshSetEffort(dir, v, gw string) error { dshWrites.Lock() defer dshWrites.Unlock() files := dshProfiles(dir) @@ -1387,7 +1395,7 @@ func dshSetEffort(dir, v string) error { if len(models) == 0 { return fmt.Errorf("DeepSeek Harness has no models to write: magpie has none to hand it") } - items[i].lines = dshProviderLines(v, models) + items[i].lines = dshProviderLines(v, models, gw) return dshWrite(f, head, items) } } diff --git a/internal/agent/dsh_route_test.go b/internal/agent/dsh_route_test.go index e4868f3d3..f4e60a605 100644 --- a/internal/agent/dsh_route_test.go +++ b/internal/agent/dsh_route_test.go @@ -381,13 +381,13 @@ func TestDshRouteAgainLeavesTheRouteWithNoCatalog(t *testing.T) { web := filepath.Join(home, ".dsh", "profiles", "web", "cordis.patch.yml") os.MkdirAll(filepath.Dir(web), 0o755) os.WriteFile(web, []byte(stale), 0o644) - if _, err := dshRouteAgain(web, magpieModels("dsh")); err != nil { + if _, err := dshRouteAgain(web, magpieModels("dsh"), gateway.URL()); err != nil { t.Fatal(err) } if b, _ := os.ReadFile(web); string(b) != stale { t.Fatalf("a route written with no catalog:\n%s", b) } - if err := dshSync(filepath.Join(home, ".dsh")); err != nil { + if err := dshSync(filepath.Join(home, ".dsh"), gateway.URL()); err != nil { t.Fatal(err) } if b, _ := os.ReadFile(web); string(b) != stale { @@ -450,7 +450,7 @@ func TestDshFillNewProfilesLeavesABareProfileWithNoCatalog(t *testing.T) { "- id: agent-default-model\n config:\n provider: magpie\n model: deepseek/pro\n"), 0o644) bare := "# A new profile.\n[]\n" os.WriteFile(desktop, []byte(bare), 0o644) - if err := dshSync(dir); err != nil { + if err := dshSync(dir, gateway.URL()); err != nil { t.Fatal(err) } if b, _ := os.ReadFile(desktop); string(b) != bare { @@ -467,7 +467,7 @@ func TestDshFillNewProfilesFillsABareProfile(t *testing.T) { dshRouteFixture("deepseek/pro", "deepseek/flash")+ "- id: agent-default-model\n config:\n provider: magpie\n model: deepseek/flash\n"), 0o644) os.WriteFile(desktop, []byte("# A new profile.\n[]\n"), 0o644) - if err := dshSync(dir); err != nil { + if err := dshSync(dir, gateway.URL()); err != nil { t.Fatal(err) } b, _ := os.ReadFile(desktop) diff --git a/internal/agent/dsh_test.go b/internal/agent/dsh_test.go index b2a2b3a43..38eaaa2cd 100644 --- a/internal/agent/dsh_test.go +++ b/internal/agent/dsh_test.go @@ -9,6 +9,7 @@ import ( "gopkg.in/yaml.v3" "github.com/yetone/magpie/internal/catalog" + "github.com/yetone/magpie/internal/gateway" "github.com/yetone/magpie/internal/provider" ) @@ -190,7 +191,7 @@ func TestDshModelLimits(t *testing.T) { }); err != nil { t.Fatal(err) } - b, _ := yaml.Marshal(dshRouteConfig(magpieModels("dsh"), "")) + b, _ := yaml.Marshal(dshRouteConfig(magpieModels("dsh"), "", gateway.URL())) s := string(b) want := ` - id: v/see name: see · V @@ -282,7 +283,7 @@ func TestDshSetEffortLeavesALegacyEntryWithNoCatalogAlone(t *testing.T) { if err := os.WriteFile(path, []byte(own), 0o644); err != nil { t.Fatal(err) } - if err := dshSetEffort(dir, "high"); err == nil { + if err := dshSetEffort(dir, "high", gateway.URL()); err == nil { t.Fatal("an empty catalog should refuse the write") } if b, _ := os.ReadFile(path); string(b) != own { @@ -309,7 +310,7 @@ func TestDshSetEffortWritesALegacyEntryWithTheCatalog(t *testing.T) { if err := os.WriteFile(path, []byte("# mine\n- id: llm-deepseek # magpie\n config:\n models:\n - id: \"deepseek/pro\"\n"), 0o644); err != nil { t.Fatal(err) } - if err := dshSetEffort(dir, "high"); err != nil { + if err := dshSetEffort(dir, "high", gateway.URL()); err != nil { t.Fatal(err) } b, _ := os.ReadFile(path) diff --git a/internal/agent/sync_test.go b/internal/agent/sync_test.go index a70e2f556..7e8634cbd 100644 --- a/internal/agent/sync_test.go +++ b/internal/agent/sync_test.go @@ -12,6 +12,7 @@ import ( "github.com/yetone/magpie/internal/catalog" "github.com/yetone/magpie/internal/codexcat" "github.com/yetone/magpie/internal/edit" + "github.com/yetone/magpie/internal/gateway" "github.com/yetone/magpie/internal/provider" "github.com/yetone/magpie/internal/settings" "gopkg.in/yaml.v3" @@ -143,7 +144,7 @@ func TestMaxTokensWithinContextWindow(t *testing.T) { pi, _ := json.Marshal(magpieProviderJSON("pi")) cline, _ := json.Marshal(clineModels("")) omp, _ := yaml.Marshal(ompProvider()) - dshRoute, _ := yaml.Marshal(dshRouteConfig(magpieModels("dsh"), "")) + dshRoute, _ := yaml.Marshal(dshRouteConfig(magpieModels("dsh"), "", gateway.URL())) droid, _ := json.Marshal(droidEntries()) qoder, _ := json.Marshal(qoderProvider("qoder", "")) hanako, _ := json.Marshal(hanakoProvider()) diff --git a/internal/agent/wsl.go b/internal/agent/wsl.go index d7d5f697e..7da243484 100644 --- a/internal/agent/wsl.go +++ b/internal/agent/wsl.go @@ -318,6 +318,21 @@ var wslKinds = []wslKind{ return append(miniMaxOwnOptions("", cur["model"]), viaMagpie("minimax-code", magpieID+"/")...) } }}, + {id: "dsh", name: "DeepSeek Harness", dir: ".dsh", bin: "dsh", in: dshIn, + restart: "reads its config at start-up — restart open dsh sessions to use this.", + asleep: func(key string) func(map[string]string) []Option { + // the thinking levels hang on which patch lists there are, the + // distro's files: a dsh of today's (0.1.5 on) is taken + if key != "effort" { + return nil + } + return func(cur map[string]string) []Option { + if ref, ok := strings.CutPrefix(cur["model"], magpieID+"/"); ok { + return static(dshLevels(ref)...) + } + return static(dshEfforts...) + } + }}, {id: "empryo", name: "Empryo", dir: ".empryo", bin: "empryo", in: empryoIn, restart: "reads its config at start-up — restart open empryo sessions to use this."}, {id: "muse", name: "Muse Code", dir: ".config/muse", bin: "muse", in: museIn, diff --git a/internal/agent/wsl_more_test.go b/internal/agent/wsl_more_test.go index 93959960d..f3fe9a19c 100644 --- a/internal/agent/wsl_more_test.go +++ b/internal/agent/wsl_more_test.go @@ -29,6 +29,7 @@ var wslMore = []struct { {"fx", ".fx/settings.json", "/v1"}, {"commandcode", ".commandcode/providers.json", "/v1"}, {"minimax-code", ".minimax/config.yaml", ""}, + {"dsh", ".dsh/config.yaml", "/v1"}, {"muse", ".config/muse/settings.json", "/v1"}, {"qoder", ".qoder/settings.json", "/v1"}, {"qoder-cn", ".qoder-cn/settings.json", "/v1"}, @@ -41,7 +42,7 @@ func moveHostDirs(t *testing.T) string { t.Helper() moved := t.TempDir() for _, v := range []string{"OPENCODE_CONFIG_DIR", "MIMOCODE_HOME", "KIMI_CODE_HOME", "KIMI_SHARE_DIR", "PI_CODING_AGENT_DIR", - "HERMES_HOME", "GROK_HOME", "FACTORY_HOME_OVERRIDE", "MINIMAX_DATA_DIR", "QODER_CONFIG_DIR", "QODERCN_CONFIG_DIR"} { + "HERMES_HOME", "GROK_HOME", "FACTORY_HOME_OVERRIDE", "MINIMAX_DATA_DIR", "QODER_CONFIG_DIR", "QODERCN_CONFIG_DIR", "DSH_HOME"} { t.Setenv(v, filepath.Join(moved, v)) } return moved @@ -271,3 +272,49 @@ func TestWSLStoppedPickFindsItsFiles(t *testing.T) { t.Fatal("a ~/.kimi-code the old kimi-cli never reads") } } + +// lgtm on Discord: wsl中安装的dsh,目前magpie还是扫描不到. A dsh of today's +// in a distro keeps its profiles' patch lists in the distro's ~/.dsh: a pick +// puts magpie's route in them naming the gateway as the distro reaches it, +// and neither a sync nor this machine's 30-second round puts it back at +// this machine's address. +func TestWSLDshProfiles(t *testing.T) { + home := syncHome(t) + moved := moveHostDirs(t) + root := t.TempDir() + web := filepath.Join(root, "home", "me", ".dsh", "profiles", "web", "cordis.patch.yml") + os.MkdirAll(filepath.Dir(web), 0o755) + os.WriteFile(web, []byte("# Your patch layer for this dsh profile.\n[]\n"), 0o644) + d := distro{Name: "Ubuntu", Root: root, Home: "/home/me", Has: map[string]bool{"bin:dsh": true}, + Gateway: "172.20.0.1", Running: true} + a := wslAgent(wslKindOf("dsh"), d) + if a.ID != "dsh@wsl:Ubuntu" || a.Path != web { + t.Fatalf("%+v", a) + } + if err := a.Field("model").Set("magpie/relay/glm-4.6"); err != nil { + t.Fatal(err) + } + gw := "http://172.20.0.1:" + gateway.Port() + "/v1" + body := readFile(web) + if !strings.Contains(body, "baseURL: "+gw) || !strings.Contains(body, `model: "relay/glm-4.6"`) || strings.Contains(body, "127.0.0.1") { + t.Fatalf("lacks %s:\n%s", gw, body) + } + if v := a.Field("model").Get(); v != "magpie/relay/glm-4.6" { + t.Fatalf("model %q", v) + } + if msg := a.Check(); msg != "" { + t.Fatal(msg) + } + if err := a.Sync(); err != nil { + t.Fatal(err) + } + dshWiredOnce() + if got := readFile(web); got != body { + t.Fatalf("written again:\n%s", got) + } + for _, dir := range []string{filepath.Join(home, ".dsh"), moved} { + if es, _ := os.ReadDir(dir); len(es) > 0 { + t.Fatalf("this machine's %s was touched", dir) + } + } +}