Files
magpie/internal/agent/omp_wsl_test.go
T
yetone 31626c1543 agent: an omp in WSL under NAT gets the gateway's network key, and one bun installed is found and asked its version (whqtian on Discord: a WSL omp connected only once auth: none was swapped for the key by hand, and Kimi K3's max still read xhigh) — a distro not in mirrored networking reaches the gateway at Windows' address (172.23.80.1), where a request without a named key is turned away, yet magpie wrote auth: none there too. Its models.yml now carries the key the gateway is shared on the network with (access.LANSecret: the default LAN key, "" while nothing is shared or it is off) in place of auth: none; an omp on loopback stays keyless. The probe asked omp its version only when sh -l found it on PATH, but bun's and nvm's installers put theirs on PATH in ~/.bashrc, which sh -l doesn't read: the version stayed unknown and max was offered as xhigh, as for an omp older than 16.4.0. It now also looks in ~/.bun/bin, ~/.local/bin, ~/.npm-global/bin, ~/.volta/bin, pnpm's, nvm's, mise's and asdf's folders, and runs --version with the command's folder on PATH, where bun's #!/usr/bin/env bun finds bun. TestOmpKeyBeyondLoopback (NAT address shared or not, loopback, localhost) and TestWSLProbeFindsBunOmp (the probe script run with a bun-installed omp off PATH; fails on the old script: no bin, no version). go vet, builds (darwin, GOOS=linux nogui, GOOS=windows) and go test -tags nogui -count=1 ./... under a temp HOME pass but for TestSavedButSignedOutClaudeServed, which timed out once under load and passes 3 of 3 alone.
2026-10-05 14:40:49 +08:00

34 lines
1.3 KiB
Go

package agent
import (
"strings"
"testing"
)
// A WSL omp's version is asked in the distro by its probe, so its models
// offer max from 16.4.0 as the omp on this machine's do (whqtian on
// Discord: a WSL omp still had max made xhigh, its version not known).
// One on Windows' drives isn't asked, and one that says no version is
// taken for an older omp as before.
func TestWSLOmpVersionProbed(t *testing.T) {
if !strings.Contains(wslProbeScript, `echo "ver:omp $(PATH="${p%/*}:$PATH" timeout 10 "$p" --version`) || !strings.Contains(wslProbeScript, `/mnt/*) ;;`) {
t.Fatalf("the probe doesn't ask omp its version: %s", wslProbeScript)
}
if strings.Contains(wslProbeScript, `"ver:codex`) {
t.Error("the probe asks a kind that doesn't need it")
}
d := parseProbe("U", "home:/home/me\nbin:omp /home/me/.bun/bin/omp\nver:omp omp/16.5.1\n")
if d == nil || d.Versions["omp"] != "16.5.1" {
t.Fatalf("version not read: %+v", d)
}
if v := d.place("omp@wsl:U").version; v != "16.5.1" || !ompTakesMax(v) {
t.Errorf("omp@wsl:U's place has version %q", v)
}
if v := d.place("pi@wsl:U").version; v != "" {
t.Errorf("pi got omp's version %q", v)
}
if d := parseProbe("U", "home:/home/me\nver:omp sh: omp: not found\n"); d == nil || d.Versions["omp"] != "" || ompTakesMax(d.place("omp@wsl:U").version) {
t.Errorf("no version said, yet %+v", d)
}
}