magpie wrote modelProvider gemini, the model and its custom models into agy's settings.json. That made every agy an API-key session: no Google account, so no remote control (needs the sign-in plus Google's server-side flag), and a plain agy asked for GEMINI_API_KEY too. Now they go in ~/.gemini/antigravity-cli/magpie-settings.json, handed to agy as --settings for the one session (the launch command, magpie agy run, and the function in a shell or a WSL distro). settings.json stays the user's. An older wiring is given back (stashed model and provider) at the next Sync or pick. agy remote-control and --remote-control run plain, on the sign-in. Run (mote): go vet, GOOS=windows and linux nogui vet, agent/cli/sessions/update packages (see push note). Real agy 1.5.3 in a sandbox HOME: plain agy with the user's untouched settings.json now asks for sign-in (no GEMINI_API_KEY error); the new launch reached a stub gateway at /v1beta/models/<m>:streamGenerateContent. Broken by hand: remote-control bypass removed, TestAgyRun red; TestAgy red on the old code (settings.json written). Not tried: real remote control (needs a Google sign-in, none in the sandbox); signed-in BYOM custom models; Windows PowerShell function run.
69 lines
2.5 KiB
Go
69 lines
2.5 KiB
Go
//go:build !windows
|
|
|
|
package agent
|
|
|
|
import (
|
|
"os"
|
|
"os/exec"
|
|
"path/filepath"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// The function agy magpie puts in a POSIX profile is read by every shell
|
|
// that reads the file: dash too, as sh -lc when ~/.profile reads ~/.bashrc
|
|
// (ljlwlcz on X: fnOS, where bash's "function agy {" failed an SSH probe's
|
|
// sh -lc). Each shell here reads the block after an alias named agy, as a
|
|
// profile does, and then agy starts the agy on PATH.
|
|
func TestAgyFunctionInEveryPOSIXShell(t *testing.T) {
|
|
var shells []string
|
|
for _, sh := range []string{"dash", "sh", "bash", "zsh", "mksh", "busybox"} {
|
|
if p, err := exec.LookPath(sh); err == nil {
|
|
shells = append(shells, p)
|
|
}
|
|
}
|
|
if len(shells) == 0 {
|
|
t.Skip("no POSIX shell here")
|
|
}
|
|
dir := t.TempDir()
|
|
bin := filepath.Join(dir, "bin")
|
|
home := filepath.Join(dir, "home")
|
|
settings := filepath.Join(home, ".gemini", "antigravity-cli", "magpie-settings.json")
|
|
if err := os.MkdirAll(bin, 0o755); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := os.MkdirAll(filepath.Dir(settings), 0o755); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
stub := "#!/bin/sh\necho \"agy key=$GEMINI_API_KEY gw=$GOOGLE_GEMINI_BASE_URL args=$*\"\n"
|
|
if err := os.WriteFile(filepath.Join(bin, "agy"), []byte(stub), 0o755); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := os.WriteFile(settings, []byte("{\n \"model\": \"magpie/relay/glm-4.6\"\n}\n"), 0o644); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
gone := filepath.Join(dir, "no such magpie")
|
|
for _, c := range []struct{ name, fn, want string }{
|
|
{"here", agyFunction("posix", gone), "agy key= gw= args=a b"},
|
|
{"distro", agyDistroFunction("posix", "k'1", "http://172.20.0.1:3425"), "agy key=k'1 gw=http://172.20.0.1:3425 args=--settings " + settings + " --model magpie/relay/glm-4.6 a b"},
|
|
} {
|
|
profile := filepath.Join(dir, c.name+".profile")
|
|
body := "alias agy='echo ALIAS' 2>/dev/null\n# >>> magpie agy >>>\n" + c.fn + "\n# <<< magpie agy <<<\n"
|
|
if err := os.WriteFile(profile, []byte(body), 0o644); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
for _, sh := range shells {
|
|
args := []string{"-c", `. "$1" && agy a b`, "sh", profile}
|
|
if filepath.Base(sh) == "busybox" {
|
|
args = append([]string{"sh"}, args...)
|
|
}
|
|
cmd := exec.Command(sh, args...)
|
|
cmd.Env = []string{"HOME=" + home, "PATH=" + bin + ":/usr/bin:/bin"}
|
|
out, err := cmd.CombinedOutput()
|
|
if got := strings.TrimSpace(string(out)); err != nil || got != c.want {
|
|
t.Errorf("%s in %s: %v\n%s\nwant %s\nprofile:\n%s", c.name, sh, err, got, c.want, body)
|
|
}
|
|
}
|
|
}
|
|
}
|