2ff85f8a2bc33f87aa1fdfefce580433afff76e3
9
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
c48fccfad7 |
plugin: the dist index is read from GitHub beside jsDelivr's copy, so a plugin npm doesn't have is offered its newer version
star21321321124 on Discord: CodeArts 0.2.3 showed "已自动更新", the page said
every plugin was up to date, and Update did nothing, with 0.2.4 on the
plugins repo's dist branch. npm has neither CodeArts nor River (E404), so
npmAsk's version is the dist index's latest. With the 「国内镜像」 switch on,
index.json was read from jsDelivr first, and a 200 from it was final. A
jsDelivr edge serves the branch as it was when it cached it (s-maxage=43200):
on 10-28 gcore.jsdelivr.net served the index with codearts latest 0.2.3
(age 6631s) while raw.githubusercontent.com, cdn and fastly had 0.2.4. So
the hourly update, Check for updates and Update all saw 0.2.3.
readDistIndex now asks raw.githubusercontent.com beside the mirror (with
the switch on) and merges the two copies: every version either names,
each package's newer latest. Each version keeps the sha512 its own copy of
the branch names, which installDist checks the tarball against as before.
GitHub is waited for 5s (distGrace) past the mirror's answer; unreachable,
the mirror's copy is read alone, as before. Switch off: one read, as before.
River: on dist at 0.1.0 only, nothing newer; the test holds it "current".
Run (mote, at this tree rebased on
|
||
|
|
e4ccf67b11 |
plugin: GitHub's search gets 60s a page, and a mirror is asked without the token (#3923)
MYCF711 (#3923) measured a page of GitHub's search from mainland China: 29-36s straight to api.github.com, 3-7s through gh-proxy. The Plugins page's GitHub list was empty there, for two reasons: - askTagged's taggedWait (8s) bounded the search pages as well as the wait for the repositories' reads. The first page timed out, the ask failed whole, and nothing was cached. Each search page now has its own taggedSearch (60s). taggedWait starts after the search and bounds only the reads, as before. Through a mirror, candidateContext gives the official address half of the 60s and the mirror the rest. - source.Do never used a mirror for a request carrying Authorization, and ghtoken sets it on every api.github.com request when a GitHub token is set. With a token in Settings, MAGPIE_MIRRORS did nothing. A request to a GitHub host whose only credential is Authorization (bare) now goes to the official address with the token and to the mirror without it. A cookie, a key header, a token in the query, URL userinfo, or any other host still keeps the request official. The caller's request keeps its header. - ghtoken.Do now reads who answered from resp.Request: a mirror's answer to the bare request doesn't count as carrying the token, and a 401 from a mirror doesn't mark the token refused. Tests: - TestTaggedReposSlowSearch: a search answering after 3x taggedWait still lists; one that never answers fails at taggedSearch. - TestDoKeepsCredentialsOfficial, rewritten to the new contract: the official address gets the token, the mirror gets none, and the caller's request is unchanged. Cookie, query token and npm still stay official. - TestMirrorAnswerIsNotTheToken (ghtoken). Run on mote: - go test -tags nogui -count=1 ./internal/source ./internal/ghtoken ./internal/plugin ./internal/library: all ok. - Broken by hand: with the old source.go, ghtoken.go and github.go, all three tests went red ("requests = [https://api.github.com/repos/o/r]"; "token=true"; "context deadline exceeded" at taggedWait). - Locally: gofmt -l clean; go vet for linux and windows on the three packages; go build -tags nogui ./... Not tried: - The real network from mainland China. - A live gh-proxy answer to an anonymous api.github.com search. - Not changed: the mirror for api.github.com still waits for MAGPIE_MIRRORS. Without it, the 60s alone covers the ~30s page. - No GUI file was run: the page's fixtures fake /api/plugins/github, and nothing in the window changed. Reported by MYCF711. |
||
|
|
3a89dd53c0 |
pii: the masking model downloads through magpie's proxy, and from hf-mirror when huggingface.co fails (hh0592821 on Discord)
hh0592821 (China) couldn't download the local masking model: "EOF",
"x509: certificate is valid for *.facebook.com ... not huggingface.co",
"net/http: TLS handshake timeout", while the same file came through
their proxy outside magpie.
Cause: internal/pii's download client cloned http.DefaultTransport when
the package loaded, before netproxy.Install set its Proxy, so it kept
only ProxyFromEnvironment. An app started from the Dock has no
HTTPS_PROXY, so the proxy set in magpie and the system's were both
skipped, and the request went direct to a poisoned huggingface.co. Every
other client magpie builds (update, mcp_check, mcpauth, gateway/mcp)
sets t.Proxy = netproxy.Func; pii was the only one built at init without
it. And hf-mirror was asked only with the 「国内镜像」 switch on.
Fix:
- pii's client: t.Proxy = netproxy.Func, through netproxy.Dispatch,
ResponseHeaderTimeout kept.
- source.URLs: a masking model's file (the two pinned repos' /resolve/
paths, https, no query; modelMirror) has hf-mirror after
huggingface.co with the switch off and no MAGPIE_MIRRORS; with the
switch on it stays first, once. fetch still checks each file against
its pinned sha256, so a mirror can't hand over anything else.
- docs/subsystems/gateway-routing.md says both.
Checked against the real mirror (curl, outside the tests): hf-mirror.com
serves AstrLink Guard's three files at 7216b6a3 with their pinned sizes
and sha256 (model_int8.onnx 330781 0a070d31..., model_int8.onnx_data
37124608 0ba34216..., tokenizer.json 1502881 0cf3b235...). For Privacy
Filter's gguf it answers 308 back to huggingface.co, so the mirror
helps AstrLink Guard (the default) only.
Tests, none reaching the network: TestFetchGoesThroughMagpiesProxy (proxy
set in Settings is an httptest server; a fetch of a TEST-NET-1 URL is
answered by it), TestModelFromTheMirrorWhenHuggingFaceFails (huggingface.co
failing with the reporter's certificate error, a handshake timeout and
EOF: the file comes from hf-mirror; a mirror file that isn't the pinned
one fails the checksum), TestModelMirrorWithoutTheSwitch,
TestModelFallsToTheMirror (source).
Broken by hand, each red then restored: without t.Proxy =
netproxy.Func, TestFetchGoesThroughMagpiesProxy is red (context deadline,
direct dial); with modelMirror out of URLs, the three mirror tests are
red.
Run: the full suite (go test -tags nogui -timeout 45m ./..., sandbox
HOME) at 7065e3734, this change on the zoecats commit on
|
||
|
|
0db804999e |
pii: AstrLink Guard as a second local model (#3578)
pii.Model is a local model (ID, Supported, Installed, Size, Find, Now,
Download, Cancel, Warm, Stop, Remove); pii.Models lists Privacy Filter
and AstrLink Guard, pii.Of finds one by id. pii.Choose decides which
one runs: the user's pick; else Privacy Filter for a user who has it on
or downloaded, so no one's model changes under them; else AstrLink
Guard, the default for everyone who turns the model on from now on.
Why AstrLink Guard as the default. On 234 segments of real code and
config (131 KB: Go, TS, lockfiles, go.sum, CI and agent configs),
Privacy Filter found 100 spans in 26 segments, 39 after redact's checks
(38 go.sum hashes and "Zed"); AstrLink Guard found 2, 1 after the
checks. On the masking eval (42 values to mask, 113 to keep), the
model alone: Privacy Filter 40/42 and 47/113 wrongly, AstrLink Guard
38/42 and 3/113; with the rules and checks both are 41/42 and 1/113.
It is 39 MB, not 1.6 GB, runs on any CPU in magpie's process, and
needs no native helper.
Its three files come from Hugging Face at revision 7216b6a3 (v0.1.3),
each checked against the sha256 in the publisher's SHA256SUMS:
int8/model_int8.onnx 0a070d31…, int8/model_int8.onnx_data 0ba34216…,
int8/tokenizer.json 0cf3b235…; from hf-mirror first in China, as
Privacy Filter's are. It is loaded on the first request and let go
after 10 minutes with none; a failure holds requests back with the
same backoff as Privacy Filter's. Its labels are named as Privacy
Filter's, so redact's checks read both alike.
TestGuardFilesAreThePublishers holds each pinned path and sha256 to
the publisher's SHA256SUMS lines (testdata); it is red with the
tokenizer at the repo root, which is a 404 (found by a real download).
Run: go test -race -count=2 ./internal/pii ./internal/source; a real
download from huggingface.co into a sandbox HOME through
Of(Choose("", false)).Download (8.7s), then Find: 张伟, 13800138000,
zhangwei@example.cn, 北京市朝阳区建国路88号 and an sk-proj key found,
nothing in a go.sum line or "gpt-5.1-codex, go 1.26.8, README.md";
load 104 ms, three texts in 177 ms. All at the pushed head.
Not tried: a real download on Windows or Linux.
|
||
|
|
c0dad80da1 |
redact, pii: a local model finds what the masking rules can't (#1977)
WIP on pf/serve, recovered after the scratchpad holding it was wiped. internal/pii downloads OpenAI's Privacy Filter (q8 GGUF, sha256 pinned) and pf-serve, runs it on the GPU first, and answers redact's Model; settings.RedactModel turns it on, per computer. Off by default. Run: go vet and go test -race on internal/redact, pii, source, settings (all ok). Not yet released: pf-serve's serveSHA is empty until pf-v1 is tagged. |
||
|
|
ff72eeda52 |
source: the last-source budget test reads which context ended instead of racing sleeps (#2608)
TestDoLastSourceUsesRemainingBudget slept 1100ms (official) and 700ms
(mirror) under a 2s parent, leaving ~300ms for scheduling. It now uses a
controlled RoundTripper: the official request waits on its candidate
context and must end with context.Canceled (its half of the budget), and
the mirror request must carry the parent's deadline and end with
DeadlineExceeded no earlier than it. A second test adds #2608's 350ms
pause before the mirror request. Patch by ump45nose; the review dropped
an unused parentDeadline field.
What ran (worktree at origin/main
|
||
|
|
21702d01ff |
Add German translation; harden paths against unset env vars (#770)
* Add German translation and harden paths against unset env vars Add a German locale to the GUI, tray menu, usage alerts and website home page, and refuse to start when the home folder is unset or relative so nothing is written under the working folder; the pi plugin no longer adopts the user's PI_CODING_AGENT_DIR, and an inherited APPIMAGE no longer selects portable mode. Scripts refuse to run from the wrong folder or empty a shared out folder, and a new internal/testenv sandboxes every test package from the user's real files, which also fixes the Claude picker and Termux installer tests on Windows. * Makefile: know magpie's folder by its go.mod, so paths with spaces work The check compared $(CURDIR) with $(dir $(abspath …)), which make splits on spaces, so a checkout under 'My Projects' or 'John Doe' refused every target. It now reads go.mod relative to the working folder and wants magpie's module there: make -C and a symlinked Makefile work, make -f from another folder still stops before any recipe runs. * i18n: German for the strings main added since, with a parity test 75 strings main added (group order, patterns, slow-start wait, usage caps, RTK savings …) get their German, and two that main dropped go. gui-de.test.cjs checks, as gui-ja does, that de has every zh string with its placeholders and tags, and that the window reads in German when picked or on a German system. * appdir: ignore relative folder variables when reading, keep them for children CheckEnv no longer unsets anything. magpie reads the XDG folders, APPDATA/LOCALAPPDATA and every agent's folder variable through appdir.Getenv/LookupEnv, which pass over a relative value; the environment stays as it is, so the agents magpie starts get the variable as the user set it. That covers what proc.UserPath lends from the login shell too, which is set after main's check and reached the desktop app unchecked. On Windows a path rooted on the current drive (\Users\x, Git Bash's /c/x) counts as usable, and magpie version and help answer without a home, before run makes any folder. * Sandbox the tests main added since internal/wslrun gets testenv's TestMain, and four tests main added that set HOME alone set their home with testenv.SetHome, so on Windows they don't read the runner's profile through USERPROFILE. * agentenv: PI_CONFIG_DIR and OPENCODE_DB take relative names on purpose omp puts $PI_CONFIG_DIR under the home and OpenCode a relative $OPENCODE_DB in its data folder, so neither depends on the working folder: appdir no longer passes them over. * i18n: German for the Library's multi-select and System One's decision API The 19 strings main added since (#791's skill multi-select, the decision API snippets) get their German; the one main replaced (four APIs → five APIs) goes. * appdir: tidy the import into magpie's group; say what Go makes of /c/x The appdir import joins the group of magpie's own imports where a file has one. rooted's comment now says that Go takes a Git Bash path like /c/x as \c\x on the current drive, not C:\x. |
||
|
|
860ed6618d | plugins: a 「国内镜像」 switch on the Plugins page downloads the list, plugins and Bun from mirrors in China first (Discord, akic404: GitHub/npm are slow from the mainland; asked for ghproxy) — Plugins › Mirrors in China, off by default, kept in settings (chinaMirror). On, source asks a copy of the very file before its official address: npm's registry (packages, versions, search) at registry.npmmirror.com, Bun's release zips at registry.npmmirror.com/-/binary/bun, and the community registry.json at cdn.jsdelivr.net/gh/magpie-community/plugins@<branch>; bun add gets BUN_CONFIG_REGISTRY=npmmirror unless the environment names a registry. No proxy: gh-proxy (MAGPIE_MIRRORS' GitHub fallback) handles nothing the switch sends, since a proxy could hand back other code. A mirror asked first that can't answer (404/403/5xx, e.g. a version it hasn't synced) falls through to the official address; npm's weekly downloads stay api.npmjs.org's (npmmirror counts its own). Checked by hand: npmmirror's bun-v1.4.2 darwin-aarch64 zip has the SHA-256 pinned in bun.go, jsDelivr's registry.json is byte-identical to raw.githubusercontent's, and bun 1.4.2 add through npmmirror locks the same sha512 integrity npmjs gives. TestChinaFirst, TestChinaComesFirst, TestChinaMirrorAnswers, TestChinaMirrorsMissIsAskedOfficially, TestDoFaithful, TestBunInstallsFromChinaMirror and TestPluginsMirrorSwitch cover it. A live run with the switch on fetched the list from jsDelivr, npm info from npmmirror and Bun from npmmirror (checksum passed); a sandbox magpie web showed the switch in the Plugins head, saved it, kept it after a reload, and a click didn't move the page. go vet, builds (darwin, GOOS=linux, GOOS=windows) and go test -tags nogui -count=1 ./... under a temp HOME pass. Not tried from inside mainland China. | ||
|
|
cb82822f3d | source: add opt-in China mirror fallback (#566) |