A magpie started from Alfred under the MacSec DLP tool quit about two
seconds after launch, exit 1, no crash report. Its environment held an
entry with no "=" ("hains/MacSec/libesafenet.dylib", a fragment of the
tool's injected dylib path). The first SQLite open (a session scan)
reads SQLITE_TMPDIR through modernc's libc, whose getenv on darwin,
windows and the BSDs (libc.go, not the musl build Linux uses) hits that
entry, calls todo() and os.Exit(1): "libc.go:1816:getenv: TODOTODO
"SQLITE_TMPDIR" "hains/MacSec/libesafenet.dylib"", the reporter's line.
New package internal/sqlitedb is the one importer of modernc.org/sqlite
in magpie's own code (it replaces the blank imports in
internal/provider/importapps.go and internal/agent/cindy.go, the only
two). Its init hands libc.SetEnviron a copy of os.Environ with the
entries that have no "=" left out, before any open and before any
goroutine, which also keeps libc's unlocked first-use SetEnviron from
racing. modernc.org/libc becomes a direct requirement (v1.67.6, same
version). Snapshot timing: libc's copy is now taken at init, not at the
first open; nothing in magpie sets SQLITE_TMPDIR, TMPDIR or TZ, the
only variables SQLite reads.
Run (worktree at origin/main 01c41e8ba, sandbox HOME, go1.26.8 darwin):
- internal/sqlitedb: TestSQLiteSurvivesMalformedEnv starts the test
binary again with the reporter's entry first in a raw Env and opens
and reads a database there; TestWellFormed; and
TestOnlyThisPackageReachesSQLite (no non-test file outside
internal/sqlitedb imports modernc.org/sqlite or modernc.org/libc).
- Broken by hand: with init's SetEnviron call removed,
TestSQLiteSurvivesMalformedEnv goes red with the child's exit 1 and
the reporter's exact TODOTODO line. With cindy.go importing
modernc.org/sqlite again, the import guard goes red naming it.
- go test -p 1 -count=1 -tags nogui ./internal/sqlitedb ./internal/agent
./internal/provider ./internal/sessions ./internal/proc: all ok.
- gofmt -l: clean. go vet -tags nogui on the three packages for
GOOS=darwin, linux, windows: clean. go mod verify: ok.
- Real binary: go build -tags nogui, then execve'd (python ctypes, raw
envp) as `magpie sessions` with the reporter's entry and a sandbox
HOME holding an opencode.db: exit 0, it listed. The hand-broken
binary for comparison couldn't be linked (disk full), so that run
shows only that the fixed binary survives, not that this command
reached SQLite; the test above is what goes red on the old code.
- Not tried: the reporter's Alfred + MacSec machine, Windows.
- Linux getenv (musl-based) already skips such entries; the test passes
there either way.
Full suite: SUITE_LINE
An agent that mounted magpie's web search over MCP (Cursor, Claude Desktop)
found pages it couldn't open: it has no fetch tool of its own. web_fetch
(url, max_chars, offset) reads one.
- The URL is the agent's, so the page is downloaded the way a caller's
image is (publicClient): public addresses only, every resolved address
checked and pinned, redirects (at most 5) checked the same, a request
from this computer included; only http and https. 30 s and 5 MiB at most.
- HTML is decoded from its charset (x/net/html/charset; golang.org/x/net
added) and given as Markdown: title, headings, lists, links made
absolute, code and pre; script, style, hidden elements dropped. Other
text as it is; anything else, or a 4xx/5xx, is the tool's error.
- 20000 characters by default (at most 100000) from offset, with the
offset the rest starts at.
- Each call reserves the gateway key's limit, as a search does.
- The tool description is neutral (names neither magpie nor a vendor).
- GUI: the MCP row's text names both tools (en, zh, zh-TW, ja, de).
Docs: gateway-routing's MCP section, README (en, zh-CN).
Run: go test -tags nogui ./internal/gateway -run 'WebFetch|SearchMCP';
GOOS=linux/windows go vet ./internal/gateway; gofmt -l clean. GUI:
search-mcp, i18n-keys, gui-ja, gui-de, gui-zh-tw 32/32 (chromium +
webkit). Broken by hand: webFetchClient = http.DefaultClient turns
TestWebFetchOnlyPublic red (the local test server was reached).
Tried by hand (a throwaway test, not committed) against go.dev/doc,
en.wikipedia.org/wiki/Magpie and http://github.com/yetone (redirected to
https; links come out by name, not the pinned address: the first try gave
https://216.239.34.21:443/..., fixed by taking each redirect's URL from
CheckRedirect), and an httpbin redirect to 127.0.0.1, refused.
Full suite: SUITE_LINE
macOS race CI failed now and then with "write |1: file already closed"
on a Claude subscription run's first prompt
(TestClaudeAuthFailureFallsBackWithoutRetryingTheLogin in 37605014029,
TestClaudeLastWordsAreRead in 37464400652; 37612795871 got the same
failure as "broken pipe"). The Claude Code stand-in had already ended
when the first prompt was written, and Wait had closed its stdin.
It never ran. On the fork's macOS runners, a debug build that recorded
the process's status at the failed write caught 8 cases in 10 jobs.
Each was "signal: segmentation fault", under 1ms of CPU, nothing on
stderr, with no magpie abort or group kill. The crash report
(gateway.race-*.ips) says "crashed on child side of fork pre-exec":
__tsan::TraceSwitchPartImpl
syscall.rawSyscall
syscall.forkAndExecInChild
syscall.forkExec
os.StartProcess
exec.(*Cmd).Start
proc.StartTree
gateway.(*subscriptionRun).launch
This is golang/go#79804. From Go 1.26.0, darwin's raw syscall wrappers
are instrumented under -race, and forkAndExecInChild calls them in the
child of fork. Go 1.26.5 marks them //go:norace (#79806); go.mod's
1.26.3, which setup-go builds CI with, has the bug. Only -race test
binaries on macOS are affected, so released builds never were. Any
os/exec start in a macOS race test could hit it; the Claude
subscription tests were where it surfaced. Local runs on go1.27.1
couldn't reproduce it, because that release already has the fix.
1.26.8 is the latest 1.26 patch release.
A vendor or relay can hand out a ready-made provider as a link. The app
registers the magpie scheme (Info.plist on macOS, HKCU on Windows, a
.desktop handler on Linux), a second launch hands the link to the running
one, and the window shows what the link would add, with the hosts the
prompts and key would go to, before anything is saved. `magpie import`
does the same in a terminal.
The product, module path (github.com/yetone/magpie), binaries, env vars
(MAGPIE_ADDR, MAGPIE_DEV_UI, MAGPIE_THEME, MAGPIE_DEBUG), config and cache
folders (~/.config/magpie, ~/.cache/magpie), bundle id (com.yetone.magpie),
gateway provider id and token, and every UI string now say magpie.
On first run magpie copies ~/.config/dial and ~/.cache/dial to the new
folders when they don't exist yet (copy, not move, so a still-running dial
keeps working; the old folders can be deleted by hand later).
The logo is a small round magpie in profile: one path for the header and
the tray, and the app tile adds the white belly and the blue-green tail.
The header mark is drawn in ink rather than the accent colour, which
fought the text in light mode.
Wails v3 tray panel and window, TUI and CLI. Switches model, effort and
provider for Claude Code, Codex, Gemini CLI, OpenCode, Pi, Goose, Cursor,
Copilot CLI and Crush with format-preserving config edits. Providers page
and registry, stored keys, live vendor model lists, profiles.
Co-Authored-By: Claude <noreply@anthropic.com>