diff --git a/README.md b/README.md index cf890a6a5..ccf2521a5 100644 --- a/README.md +++ b/README.md @@ -283,7 +283,7 @@ Find them under Plugins › Discover › Gateway middleware. See [Gateway middle ## Privacy -Your prompts, replies, keys and accounts go only to the providers you use. Once a day a released magpie tells us it is in use: a random id, its version and system, and which agents, providers and models it is used with, by magpie's own ids (a provider you added yourself is only `custom`), and for each partner listed first in the add sheet, how many times a day it was shown, opened and added (counts only). No names, URLs, accounts, keys, prompts or usage. Turn part or all of it off in **Settings → Privacy**, or with `DO_NOT_TRACK=1`. A partner's website and key links go through `usemagpie.ai/go/…`, which counts the click, and usemagpie.ai counts fetches of the partner list; the server sees these whatever the settings, and keeps no id or address. [What is sent, exactly](docs/reference.md#counting-users). +Your prompts, replies, keys and accounts go only to the providers you use. Once a day a released magpie tells us it is in use: a random id, its version and system, and which agents, providers and models it is used with, by magpie's own ids (a provider you added yourself is only `custom`), and for each partner listed first in the add sheet, how many times a day it was shown, opened and added (counts only). No names, URLs, accounts, keys, prompts or usage. Turn part or all of it off in **Settings → Privacy**, or with `DO_NOT_TRACK=1`. A partner's website and key links go through `usemagpie.ai/go/…`, which counts the click, and usemagpie.ai counts fetches of the partner list; the server sees these whatever the settings, and keeps no id or address. Icons named by a plugin, an import link or the library are fetched through `usemagpie.ai/api/icon`, so their hosts see Cloudflare's address, not yours; the server only passes the picture on, and counts and keeps nothing. [What is sent, exactly](docs/reference.md#counting-users). ## Community diff --git a/README.zh-CN.md b/README.zh-CN.md index 40e9abacf..5905eb6c4 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -283,7 +283,7 @@ magpie plugin options model-map '{"mapping": {"fast": "deepseek/deepseek-chat"}} ## 隐私 -你的提示词、回复、密钥和账号只发给你用的供应商。正式版 magpie 每天告诉我们一次它在用:一个随机 ID、版本和系统,以及用了哪些 agent、供应商和模型,只用 magpie 自己的 ID(你自己添加的供应商只记作 `custom`),以及添加供应商页里排在最前的合作伙伴每天被展示、打开和添加的次数(只有次数)。不发送名称、URL、账号、密钥、提示词和用量。可以在 **设置 → 隐私** 里关掉一部分或全部,也可以设 `DO_NOT_TRACK=1`。合作伙伴的官网和获取 Key 链接经 `usemagpie.ai/go/…` 跳转并计一次点击,usemagpie.ai 也统计合作伙伴列表的拉取次数;这是服务器本身看到的,不受设置影响,不记录 ID 和 IP。[具体发送哪些内容](docs/reference.md#counting-users)。 +你的提示词、回复、密钥和账号只发给你用的供应商。正式版 magpie 每天告诉我们一次它在用:一个随机 ID、版本和系统,以及用了哪些 agent、供应商和模型,只用 magpie 自己的 ID(你自己添加的供应商只记作 `custom`),以及添加供应商页里排在最前的合作伙伴每天被展示、打开和添加的次数(只有次数)。不发送名称、URL、账号、密钥、提示词和用量。可以在 **设置 → 隐私** 里关掉一部分或全部,也可以设 `DO_NOT_TRACK=1`。合作伙伴的官网和获取 Key 链接经 `usemagpie.ai/go/…` 跳转并计一次点击,usemagpie.ai 也统计合作伙伴列表的拉取次数;这是服务器本身看到的,不受设置影响,不记录 ID 和 IP。插件、导入链接和库里的图标经 `usemagpie.ai/api/icon` 获取,图标所在的服务器只看到 Cloudflare 的地址,看不到你的 IP;这台服务器只转发图片,不计数也不记录。[具体发送哪些内容](docs/reference.md#counting-users)。 ## 社区 diff --git a/docs/reference.md b/docs/reference.md index a74b6008d..7f1fb85ad 100644 --- a/docs/reference.md +++ b/docs/reference.md @@ -2152,6 +2152,15 @@ and the country, while a partner is listed. Each event has an id of its own: no install id, address or account goes with it. The code is [site/worker.js](../site/worker.js). +A plugin's, an import link's and the library's icons sit on hosts their +authors picked. magpie fetches each through +`https://usemagpie.ai/api/icon?url=`, so the host sees +Cloudflare's address and never the user's. The worker sends only +`Accept: image/*` and its own User-Agent, passes on a PNG, JPEG, GIF, WebP, +ICO or SVG of at most 1 MB and refuses anything else, and counts and keeps +nothing. The code is [internal/iconproxy](../internal/iconproxy/iconproxy.go) +and `icon` in [site/worker.js](../site/worker.js). + ## Community Questions, setups worth sharing, ideas, bugs: come talk to us and other diff --git a/internal/iconproxy/iconproxy.go b/internal/iconproxy/iconproxy.go new file mode 100644 index 000000000..5a350dd48 --- /dev/null +++ b/internal/iconproxy/iconproxy.go @@ -0,0 +1,28 @@ +// Package iconproxy names where magpie downloads a remote picture from. A +// plugin's, an import link's or the library's icon sits on a host its author +// picked, and fetching it straight from there would hand that author the +// user's IP each time a page showed it. Every such fetch goes through +// usemagpie.ai's /api/icon instead (site/worker.js), which asks the host +// itself and passes on only an image; the host sees Cloudflare's address. +package iconproxy + +import ( + "net/url" + "os" +) + +// Base is the proxy's endpoint. MAGPIE_ICON_PROXY replaces it, for tests. +const Base = "https://usemagpie.ai/api/icon" + +// URL is the address to fetch the picture at u through. One on usemagpie.ai +// already is asked for as it is: the worker needn't fetch its own site. +func URL(u string) string { + if p, err := url.Parse(u); err == nil && p.Scheme == "https" && p.Host == "usemagpie.ai" { + return u + } + base := Base + if v := os.Getenv("MAGPIE_ICON_PROXY"); v != "" { + base = v + } + return base + "?url=" + url.QueryEscape(u) +} diff --git a/internal/iconproxy/iconproxy_test.go b/internal/iconproxy/iconproxy_test.go new file mode 100644 index 000000000..40e6cea14 --- /dev/null +++ b/internal/iconproxy/iconproxy_test.go @@ -0,0 +1,35 @@ +package iconproxy + +import ( + "net/url" + "testing" +) + +func TestURLCarriesThePictureWhole(t *testing.T) { + t.Setenv("MAGPIE_ICON_PROXY", "") + pic := "https://github.com/magpie-community.png?size=96&x=a b#c" + got := URL(pic) + u, err := url.Parse(got) + if err != nil { + t.Fatal(err) + } + if u.Scheme+"://"+u.Host+u.Path != Base { + t.Fatalf("URL(%q) = %q, not on %s", pic, got, Base) + } + if q := u.Query(); len(q) != 1 || q.Get("url") != pic { + t.Fatalf("URL(%q) = %q: query %v", pic, got, q) + } +} + +func TestURLLeavesUsemagpieAlone(t *testing.T) { + t.Setenv("MAGPIE_ICON_PROXY", "") + for u, want := range map[string]string{ + "https://usemagpie.ai/partners/x.png": "https://usemagpie.ai/partners/x.png", + "https://usemagpie.ai.evil.example/x.png": Base + "?url=" + url.QueryEscape("https://usemagpie.ai.evil.example/x.png"), + "https://evil.example/?usemagpie.ai": Base + "?url=" + url.QueryEscape("https://evil.example/?usemagpie.ai"), + } { + if got := URL(u); got != want { + t.Errorf("URL(%q) = %q, want %q", u, got, want) + } + } +} diff --git a/internal/library/icon_proxy_test.go b/internal/library/icon_proxy_test.go new file mode 100644 index 000000000..44d81e749 --- /dev/null +++ b/internal/library/icon_proxy_test.go @@ -0,0 +1,46 @@ +package library + +import ( + "net/http" + "net/http/httptest" + "path/filepath" + "testing" +) + +// A market icon is asked for through usemagpie.ai's icon proxy, never from +// the host its author picked, which would see the user's IP. +func TestIconGoesThroughTheProxy(t *testing.T) { + h := sandbox(t) + t.Setenv("XDG_CACHE_HOME", filepath.Join(h, ".cache")) + png := []byte("\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR") + var asked []string + proxy := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { + asked = append(asked, r.URL.Query().Get("url")) + rw.Header().Set("Content-Type", "image/png") + rw.Write(png) + })) + defer proxy.Close() + t.Setenv("MAGPIE_ICON_PROXY", proxy.URL+"/api/icon") + + // a server the registry showed, its icon on its author's host; .invalid + // never resolves, so reaching it straight fails the test + const avatar = "https://author.invalid/logo.png?v=2" + seenServers.Lock() + seenServers.m["io.example/proxy-test"] = MarketServer{Icon: avatar} + seenServers.Unlock() + t.Cleanup(func() { + seenServers.Lock() + delete(seenServers.m, "io.example/proxy-test") + seenServers.Unlock() + }) + b, ct, err := Icon(avatar) + if err != nil { + t.Fatal(err) + } + if string(b) != string(png) || ct != "image/png" { + t.Fatalf("Icon = %q %q", b, ct) + } + if len(asked) != 1 || asked[0] != avatar { + t.Fatalf("the proxy was asked for %q, want [%s]", asked, avatar) + } +} diff --git a/internal/library/market.go b/internal/library/market.go index a49f15438..224757604 100644 --- a/internal/library/market.go +++ b/internal/library/market.go @@ -22,6 +22,7 @@ import ( "time" "github.com/yetone/magpie/internal/appdir" + "github.com/yetone/magpie/internal/iconproxy" ) // The market is where the page finds MCP servers and skills to add in one @@ -1112,8 +1113,10 @@ func offered(u string) bool { return false } +// fetchImage downloads an icon through usemagpie.ai's icon proxy, so the +// host a server's author picked never sees the user's IP. func fetchImage(u string) ([]byte, string, error) { - b, err := get(u, "image/*", 1<<20) + b, err := get(iconproxy.URL(u), "image/*", 1<<20) if err != nil { return nil, "", err } diff --git a/internal/provider/icon.go b/internal/provider/icon.go index e77f2b63b..9a88f9717 100644 --- a/internal/provider/icon.go +++ b/internal/provider/icon.go @@ -17,6 +17,8 @@ import ( "strings" "sync" "time" + + "github.com/yetone/magpie/internal/iconproxy" ) // A provider's own picture lives in the icons folder beside providers.json, @@ -70,15 +72,19 @@ func StoreIcon(data []byte) (string, error) { // user confirms the import, never at parse time; the URL is re-checked here // so a crafted request can't point magpie at anything but a public https // picture, and the read stops one byte past MaxIcon so a huge body is -// refused rather than buffered. +// refused rather than buffered. The picture is asked for through +// usemagpie.ai's icon proxy, so its host never sees the user's IP. func FetchIcon(ctx context.Context, rawURL string) (string, error) { u, err := iconURL(rawURL) if err != nil { return "", err } - return fetchIcon(ctx, guardClient(), u) + return fetchIcon(ctx, iconClient(), iconproxy.URL(u)) } +// iconClient is the client FetchIcon uses; tests point it at a local proxy. +var iconClient = guardClient + // guardClient is the http.Client icon fetches use: the default transport — // so the proxy settings still apply — but with dialing wrapped in publicDial. // diff --git a/internal/provider/icon_proxy_test.go b/internal/provider/icon_proxy_test.go new file mode 100644 index 000000000..7c529b999 --- /dev/null +++ b/internal/provider/icon_proxy_test.go @@ -0,0 +1,49 @@ +package provider + +import ( + "context" + "net/http" + "net/http/httptest" + "path/filepath" + "strings" + "testing" +) + +// A plugin's or an import link's icon is asked for through usemagpie.ai's +// icon proxy, so the host its author picked never sees the user's IP. +func TestFetchIconGoesThroughTheProxy(t *testing.T) { + home := t.TempDir() + t.Setenv("HOME", home) + t.Setenv("USERPROFILE", home) + t.Setenv("XDG_CONFIG_HOME", filepath.Join(home, ".config")) + + png := []byte("\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR") + var asked []string + proxy := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { + asked = append(asked, r.URL.Path+" "+r.URL.Query().Get("url")) + rw.Header().Set("Content-Type", "image/png") + rw.Write(png) + })) + defer proxy.Close() + t.Setenv("MAGPIE_ICON_PROXY", proxy.URL+"/api/icon") + client := iconClient + iconClient = proxy.Client + t.Cleanup(func() { iconClient = client }) + + // .invalid never resolves: reaching it straight fails the test + const pic = "https://author.invalid/logo.png?v=2" + ref, err := FetchIcon(context.Background(), pic) + if err != nil { + t.Fatal(err) + } + if !strings.HasSuffix(ref, ".png") { + t.Fatalf("ref = %q", ref) + } + if len(asked) != 1 || asked[0] != "/api/icon "+pic { + t.Fatalf("the proxy was asked %q", asked) + } + // the import link's own checks still come first + if _, err := FetchIcon(context.Background(), "http://author.invalid/logo.png"); err == nil || len(asked) != 1 { + t.Fatalf("an http icon went out: %v, %q", err, asked) + } +} diff --git a/site/public/docs/import.html b/site/public/docs/import.html index aee6f452a..ba0dd12e1 100644 --- a/site/public/docs/import.html +++ b/site/public/docs/import.html @@ -233,7 +233,7 @@ href = "https://usemagpie.ai/import#" + urlencode({
  • No silent overwrites. When the id is already taken, the dialog says so and the button reads Replace.
  • https only. Plain http is refused except to this machine or the local network; file:, credentials in URLs and other schemes are refused outright.
  • Read once. Inside the app, the link’s contents are handed to the window a single time; a reload doesn’t bring the dialog back.
  • -
  • Icons are fetched, not embedded. An icon= URL is downloaded by magpie itself, only after the user confirms the import, only over https, and only into its own icons folder — at most 1 MB, and the type is checked. The host is resolved at connection time and magpie refuses to connect when it lands on loopback, private, link-local or reserved addresses, so a name that points back at the user’s own machine (or a DNS-rebinding trick) is refused. The page and the dialog never load a remote picture directly.
  • +
  • Icons are fetched, not embedded. An icon= URL is downloaded by magpie, only after the user confirms the import, only over https, and only into its own icons folder — at most 1 MB, and the type is checked. magpie asks for it through usemagpie.ai’s icon proxy, so your host sees Cloudflare’s address and never the user’s, and the fetch is made from Cloudflare, where nothing on the user’s own machine or network can be reached. A loopback or local-network name is refused before anything is asked. The page and the dialog never load a remote picture directly.
  • Keys stay out of servers. The web link keeps parameters in the fragment. The key ends up only in ~/.config/magpie/providers.json, readable by the user alone.
  • Keys in links are secrets. Put a key in a link only on a page that user alone sees, and prefer a key minted for magpie that they can revoke. Never put a shared key in a public link.
    diff --git a/site/public/docs/ja/import.html b/site/public/docs/ja/import.html index 341ad681c..21796020c 100644 --- a/site/public/docs/ja/import.html +++ b/site/public/docs/ja/import.html @@ -233,7 +233,7 @@ href = "https://usemagpie.ai/import#" + urlencode({
  • 黙って上書きしない。id がすでに使われている場合、ダイアログがそう伝え、ボタンは置き換えになります。
  • https のみ。このマシンとローカルネットワーク宛て以外の http は拒否されます。file:、URL 内の認証情報、その他のスキームは即座に拒否されます。
  • 読み込みは一度だけ。アプリ内では、リンクの内容がウィンドウに一度だけ渡されます。再読み込みしてもダイアログは再表示されません。
  • -
  • アイコンは埋め込まず、取得する。icon= の URL は magpie 自身がダウンロードします。ユーザーがインポートを確認した後だけ、https 経由だけ、自身のアイコンフォルダへだけ — 最大 1 MB で、形式もチェックされます。ホストは接続時に名前解決され、ループバック、プライベート、リンクローカル、予約済みアドレスに解決された場合は接続を拒否するため、ユーザー自身のマシンを指す名前(や DNS リバインディング)は拒否されます。ページとダイアログがリモートの画像を直接読み込むことはありません。
  • +
  • アイコンは埋め込まず、取得する。icon= の URL は magpie がダウンロードします。ユーザーがインポートを確認した後だけ、https 経由だけ、自身のアイコンフォルダへだけ — 最大 1 MB で、形式もチェックされます。取得は usemagpie.ai のアイコンプロキシを経由するので、あなたのサーバーに見えるのはユーザーの IP ではなく Cloudflare のアドレスです。リクエストは Cloudflare から出るため、ユーザー自身のマシンやローカルネットワークには届きません。ループバックやローカルネットワークの名前は、リクエストの前に拒否されます。ページとダイアログがリモートの画像を直接読み込むことはありません。
  • キーはサーバーを通らない。Web リンクはパラメータをフラグメントに置きます。キーは最終的に ~/.config/magpie/providers.json にのみ保存され、ユーザー本人しか読めません。
  • リンク内のキーは機密情報です。キーをリンクに入れるのは、そのユーザー本人しか見られないページだけにし、できれば magpie 用に発行した、取り消し可能なキーを使ってください。共有キーを公開リンクに入れてはいけません。
    diff --git a/site/public/docs/ja/start.html b/site/public/docs/ja/start.html index 6a13d90d8..ba28c75f1 100644 --- a/site/public/docs/ja/start.html +++ b/site/public/docs/ja/start.html @@ -269,7 +269,7 @@ magpie claude group/opus-anywhere # これを使う

    インストーラと magpie update にプロキシを渡します:curl -fsSL https://usemagpie.ai/install.sh | sh -s -- --proxy http://127.0.0.1:7890、または magpie update --proxy socks5://127.0.0.1:1080(http・https・socks5・socks5h に対応。HTTPS_PROXY と ALL_PROXY も使われます)。--mirror <prefix> を付けると、指定した GitHub ダウンロードミラーから <prefix>https://github.com/… としてリリースファイルを取得します。magpie update mirror <prefix> でアプリ自身の更新を含め毎回使い、magpie update mirror off で解除します。指定しない限りミラーは使われず、ファイルの SHA-256 はミラーではなく常に usemagpie.ai から取得するので、ミラーが書き換えたファイルはインストールされません。アプリ自身の更新は Settings → Proxy を通ります。

    magpie は何を送信しますか?

    -

    プロンプト、返答、キー、アカウントは、使っているプロバイダーにだけ送られます。間に magpie 自身のサーバーはありません。リリース版の magpie は 1 日 1 回、使われていることを知らせます。何人が使っていて、何を優先して面倒を見るべきかを知るためです。送るのは、このコンピュータで作ったランダムな ID、magpie のバージョンとシステム、そして使っているエージェント、プロバイダー、モデルを magpie 自身の ID(claude、deepseek、deepseek/deepseek-v4)で、それぞれの数とともに。自分で追加したプロバイダーとそのモデルは custom とだけ記録します。プロバイダー追加シートの先頭に載るパートナーについては、1 日に表示された回数、開かれた回数、追加された回数も送ります(回数のみ)。名前、Base URL、アカウント、キー、プロンプト、使用量は送りません。設定 → プライバシー → 使っているエージェント、プロバイダー、モデルを共有 でエージェント、プロバイダー、モデルとパートナーの回数を外せます。ユーザー数に含める、DO_NOT_TRACK=1、MAGPIE_NO_STATS=1 のどれかですべてオフになります。ソースからのビルドは送信しません。パートナーの公式サイトと「キーを取得」のリンクは usemagpie.ai/go/… を経由し、移動の前にクリックを 1 回数えます(どのパートナーか、どのリンクか、国)。usemagpie.ai はパートナー一覧が取得された回数も数えます。これはサーバー自身が見るもので、どの Web サイトのアクセス集計とも同じく、上の設定には左右されません。ID、IP アドレス、アカウントは記録しません。詳しくはリファレンスを。

    +

    プロンプト、返答、キー、アカウントは、使っているプロバイダーにだけ送られます。間に magpie 自身のサーバーはありません。リリース版の magpie は 1 日 1 回、使われていることを知らせます。何人が使っていて、何を優先して面倒を見るべきかを知るためです。送るのは、このコンピュータで作ったランダムな ID、magpie のバージョンとシステム、そして使っているエージェント、プロバイダー、モデルを magpie 自身の ID(claude、deepseek、deepseek/deepseek-v4)で、それぞれの数とともに。自分で追加したプロバイダーとそのモデルは custom とだけ記録します。プロバイダー追加シートの先頭に載るパートナーについては、1 日に表示された回数、開かれた回数、追加された回数も送ります(回数のみ)。名前、Base URL、アカウント、キー、プロンプト、使用量は送りません。設定 → プライバシー → 使っているエージェント、プロバイダー、モデルを共有 でエージェント、プロバイダー、モデルとパートナーの回数を外せます。ユーザー数に含める、DO_NOT_TRACK=1、MAGPIE_NO_STATS=1 のどれかですべてオフになります。ソースからのビルドは送信しません。パートナーの公式サイトと「キーを取得」のリンクは usemagpie.ai/go/… を経由し、移動の前にクリックを 1 回数えます(どのパートナーか、どのリンクか、国)。usemagpie.ai はパートナー一覧が取得された回数も数えます。これはサーバー自身が見るもので、どの Web サイトのアクセス集計とも同じく、上の設定には左右されません。ID、IP アドレス、アカウントは記録しません。プラグイン、インポートリンク、ライブラリが示すアイコンは usemagpie.ai/api/icon を経由して取得するので、アイコンのあるサーバーに見えるのはあなたの IP ではなく Cloudflare のアドレスです。このサーバーは画像を中継するだけで、数えることも記録することもしません。詳しくはリファレンスを。

    エージェントが 502 を返す、または接続できず、magpie の Routing タブに何も出ない?

    プロキシアプリ(Surge、Clash、mihomo など。システムプロキシ、TUN、拡張モードのいずれかが有効)が、エージェントから http://127.0.0.1:3425 へのリクエストを横取りして別の場所へ送っているため、magpie に届いていません。除外リスト(skip-proxy、バイパス)に 127.0.0.1 を書くだけでは足りないことがあります。Codex など一部のエージェントは、それでもプロキシを通します。ローカルアドレスを直結にするルールを、他のルールより前に追加してください:

    diff --git a/site/public/docs/start.html b/site/public/docs/start.html index 72b767a9b..98a5d67b8 100644 --- a/site/public/docs/start.html +++ b/site/public/docs/start.html @@ -269,7 +269,7 @@ magpie claude group/opus-anywhere # use it

    Give the installer and magpie update a proxy: curl -fsSL https://usemagpie.ai/install.sh | sh -s -- --proxy http://127.0.0.1:7890, or magpie update --proxy socks5://127.0.0.1:1080 (http, https, socks5 and socks5h; HTTPS_PROXY and ALL_PROXY are honoured too). --mirror <prefix> fetches the release file from a GitHub download mirror you choose, as <prefix>https://github.com/…; magpie update mirror <prefix> keeps it for every update, the app’s too, and magpie update mirror off removes it. No mirror is used unless you give one, and the file’s SHA-256 still comes from usemagpie.ai, never from the mirror: a file the mirror changed is refused. The app’s own updates go through Settings → Proxy.

    What does magpie send about me?

    -

    Your prompts, replies, keys and accounts go only to the providers you use; magpie has no server of its own in the path. Once a day a released magpie tells us it is in use, so we know how many people use it and what to look after first: a random id made up on your computer, magpie’s version and your system, and which agents, providers and models it is used with, by magpie’s own ids (claude, deepseek, deepseek/deepseek-v4) with how many of each. A provider you added yourself, and a model on it, is only custom. For each partner listed first in the add sheet, how many times a day it was shown, opened and added from goes with them, as counts only. No names, base URLs, accounts, keys, prompts or usage are sent. Settings → Privacy → Share the agents, providers and models I use leaves out the agents, providers and models, and the partner counts; Count me as a user, DO_NOT_TRACK=1 or MAGPIE_NO_STATS=1 turns it all off. Builds from source never send it. A partner's website and key-page links go through usemagpie.ai/go/…, which counts the click (the partner, which link, and a country) before sending you on, and usemagpie.ai counts how many times the partner list is fetched. The server sees these whatever the settings say, as any website sees its visits; no id, address or account is kept with them. The details are in the reference.

    +

    Your prompts, replies, keys and accounts go only to the providers you use; magpie has no server of its own in the path. Once a day a released magpie tells us it is in use, so we know how many people use it and what to look after first: a random id made up on your computer, magpie’s version and your system, and which agents, providers and models it is used with, by magpie’s own ids (claude, deepseek, deepseek/deepseek-v4) with how many of each. A provider you added yourself, and a model on it, is only custom. For each partner listed first in the add sheet, how many times a day it was shown, opened and added from goes with them, as counts only. No names, base URLs, accounts, keys, prompts or usage are sent. Settings → Privacy → Share the agents, providers and models I use leaves out the agents, providers and models, and the partner counts; Count me as a user, DO_NOT_TRACK=1 or MAGPIE_NO_STATS=1 turns it all off. Builds from source never send it. A partner's website and key-page links go through usemagpie.ai/go/…, which counts the click (the partner, which link, and a country) before sending you on, and usemagpie.ai counts how many times the partner list is fetched. The server sees these whatever the settings say, as any website sees its visits; no id, address or account is kept with them. Icons named by a plugin, an import link or the library are fetched through usemagpie.ai/api/icon, so their hosts see Cloudflare's address, not yours; the server only passes the picture on, and counts and keeps nothing. The details are in the reference.

    The agent gets 502 or can’t connect, and nothing shows in magpie’s Routing tab?

    A proxy app (Surge, Clash, mihomo and the like, with system proxy, TUN or enhanced mode on) has taken the agent’s request to http://127.0.0.1:3425 and sent it somewhere else, so it never reaches magpie. The bypass list (skip-proxy, “bypass”) isn’t always enough: some agents, Codex among them, send it through the proxy anyway. Add rules that send the local addresses direct, ahead of your other rules:

    diff --git a/site/public/docs/zh/import.html b/site/public/docs/zh/import.html index 69ff9e67a..4d15cef8f 100644 --- a/site/public/docs/zh/import.html +++ b/site/public/docs/zh/import.html @@ -233,7 +233,7 @@ href = "https://usemagpie.ai/import#" + urlencode({
  • 不会悄悄覆盖。id 已被占用时,对话框会说明,按钮也会变成「替换」。
  • 只接受 https。除了本机和局域网,一律拒绝 http;file:、URL 里带账号密码以及其他协议直接拒绝。
  • 只读一次。在应用里,链接内容只交给窗口一次;刷新后对话框不会再出现。
  • -
  • 图标是下载的,不是嵌入的。icon= 地址由 magpie 自己下载,只在用户确认导入之后,只走 https,只存进它自己的图标目录,最大 1 MB,并校验类型。域名在连接时解析,落到回环、内网、链路本地或保留地址时 magpie 拒绝连接,所以指回用户本机的域名(或 DNS 重绑定)都会被拒绝。页面和对话框从不直接加载远程图片。
  • +
  • 图标是下载的,不是嵌入的。icon= 地址由 magpie 下载,只在用户确认导入之后,只走 https,只存进它自己的图标目录,最大 1 MB,并校验类型。magpie 经 usemagpie.ai 的图标代理去取,所以你的服务器只看到 Cloudflare 的地址,看不到用户的 IP;请求从 Cloudflare 发出,碰不到用户本机和内网。回环或内网的域名在发出请求前就被拒绝。页面和对话框从不直接加载远程图片。
  • 密钥不经过服务器。网页链接把参数放在 # 片段里。密钥最终只存在 ~/.config/magpie/providers.json,只有用户本人可读。
  • 链接里的密钥就是机密。只在该用户本人能看到的页面上把密钥放进链接,最好是专门给 magpie 生成、可以随时吊销的密钥。绝不要把共享密钥放进公开链接。
    diff --git a/site/public/docs/zh/start.html b/site/public/docs/zh/start.html index 8f7d71dbf..bb1aa0ead 100644 --- a/site/public/docs/zh/start.html +++ b/site/public/docs/zh/start.html @@ -269,7 +269,7 @@ magpie claude group/opus-anywhere # 使用它

    给安装脚本和 magpie update 加代理:curl -fsSL https://usemagpie.ai/install.sh | sh -s -- --proxy http://127.0.0.1:7890,或 magpie update --proxy socks5://127.0.0.1:1080(支持 http、https、socks5、socks5h;环境变量 HTTPS_PROXY、ALL_PROXY 同样生效)。--mirror <前缀> 从你指定的 GitHub 下载镜像取发布文件,即 <前缀>https://github.com/…;magpie update mirror <前缀> 让之后每次更新(包括应用自己的更新)都用它,magpie update mirror off 取消。不指定就不用任何镜像;文件的 SHA-256 始终来自 usemagpie.ai,而不是镜像,镜像改过的文件会被拒绝安装。应用自己的更新走 设置 → 代理。

    magpie 会发送我的哪些信息?

    -

    你的提示词、回复、密钥和账号只发给你用的供应商,中间没有 magpie 自己的服务器。正式发布的 magpie 每天告诉我们一次它在用,好让我们知道有多少人在用、该先照顾哪些:本机随机生成的 ID、magpie 版本和系统,以及用了哪些 agent、供应商和模型,只用 magpie 自己的 ID(claude、deepseek、deepseek/deepseek-v4)和各自的数量。你自己添加的供应商及其上的模型只记作 custom。添加供应商页里排在最前的合作伙伴,每天被展示、打开和添加的次数也一并发送,只有次数。不发送名称、Base URL、账号、密钥、提示词和用量。设置 → 隐私 → 分享我用的 agent、provider 和模型 可以去掉 agent、供应商、模型和合作伙伴次数这部分;计入用户数、DO_NOT_TRACK=1 或 MAGPIE_NO_STATS=1 全部关闭。从源码构建的版本从不发送。合作伙伴的官网和「获取 Key」链接经 usemagpie.ai/go/… 跳转,跳转前记一次点击(哪个合作伙伴、哪个链接、哪个国家),usemagpie.ai 也会统计合作伙伴列表被拉取的次数。这部分是服务器本身看到的,和任何网站统计访问一样,不受上面的设置影响;不记录 ID、IP 和账号。详见参考文档。

    +

    你的提示词、回复、密钥和账号只发给你用的供应商,中间没有 magpie 自己的服务器。正式发布的 magpie 每天告诉我们一次它在用,好让我们知道有多少人在用、该先照顾哪些:本机随机生成的 ID、magpie 版本和系统,以及用了哪些 agent、供应商和模型,只用 magpie 自己的 ID(claude、deepseek、deepseek/deepseek-v4)和各自的数量。你自己添加的供应商及其上的模型只记作 custom。添加供应商页里排在最前的合作伙伴,每天被展示、打开和添加的次数也一并发送,只有次数。不发送名称、Base URL、账号、密钥、提示词和用量。设置 → 隐私 → 分享我用的 agent、provider 和模型 可以去掉 agent、供应商、模型和合作伙伴次数这部分;计入用户数、DO_NOT_TRACK=1 或 MAGPIE_NO_STATS=1 全部关闭。从源码构建的版本从不发送。合作伙伴的官网和「获取 Key」链接经 usemagpie.ai/go/… 跳转,跳转前记一次点击(哪个合作伙伴、哪个链接、哪个国家),usemagpie.ai 也会统计合作伙伴列表被拉取的次数。这部分是服务器本身看到的,和任何网站统计访问一样,不受上面的设置影响;不记录 ID、IP 和账号。插件、导入链接和库里的图标经 usemagpie.ai/api/icon 获取,图标所在的服务器只看到 Cloudflare 的地址,看不到你的 IP;这台服务器只转发图片,不计数也不记录。详见参考文档。

    Agent 报 502 或连不上,magpie 的路由标签页里却什么都没有?

    代理软件(Surge、Clash、mihomo 等,开了系统代理、TUN 或增强模式)把 Agent 发往 http://127.0.0.1:3425 的请求接走、转去了别处,请求根本没到 magpie。只在跳过列表(skip-proxy、「绕过」)里写 127.0.0.1 不一定够:有些 Agent(比如 Codex)照样会走代理。在代理软件里加两条本地地址直连的规则,放在其他规则前面:

    diff --git a/site/worker.js b/site/worker.js index ce7b1344c..1f3b3cc30 100644 --- a/site/worker.js +++ b/site/worker.js @@ -12,6 +12,10 @@ // their website and key links through /go // /go//keys[/], /go//site[/] // a partner's key page or website, counted +// /api/icon?url= +// a picture a plugin, market or import link names, +// fetched here so its host sees Cloudflare, not the +// user (the app fetches every remote icon this way) // /download the Apple Silicon dmg // /download/mac-arm64 the same; /download/mac-intel the Intel dmg // /download/windows the Windows app (x64); /download/windows-arm64 @@ -87,6 +91,7 @@ export default { .map((r) => ({ ...r, notes: inLang(r.notes, lang) })); return json({ releases: pick }, 200, cacheFor(got)); } + if (url.pathname === "/api/icon") return icon(url.searchParams.get("url")); if (url.pathname === "/download" || url.pathname.startsWith("/download/")) { const want = url.pathname.split("/")[2] || "mac-arm64"; const got = await latest(ctx, env); @@ -574,6 +579,90 @@ async function checksums(tag) { return sums; } +// ---- icons ------------------------------------------------------------------ + +// An icon a plugin's package.json, a market listing or an import link names +// is fetched here, not by the app, so its host learns nothing about who +// looks: a plugin author's https picture would otherwise see the IP of +// everyone who opened Discover. Nothing of the asker's request is passed +// on, only the picture comes back, and Cloudflare keeps it a day. +export const ICON_MAX = 1 << 20; // the app's MaxIcon + +export async function icon(raw) { + let u; + try { + u = new URL(raw); + } catch { + return new Response("not a URL\n", { status: 400 }); + } + if (u.protocol !== "https:" || u.username || u.password || (u.port && u.port !== "443")) + return new Response("only a public https picture\n", { status: 400 }); + // the app asks for usemagpie.ai's own pictures straight; asking here for + // one would only send the worker round to itself + if (u.hostname === "usemagpie.ai" || u.hostname.endsWith(".usemagpie.ai")) + return new Response("a usemagpie.ai picture is fetched as it is\n", { status: 400 }); + let res; + try { + res = await fetch(u.toString(), { + headers: { Accept: "image/*", "User-Agent": "magpie-icon/1 (+https://usemagpie.ai)" }, + redirect: "follow", + signal: AbortSignal.timeout(10000), + // a missing or failing picture is asked for again soon, not in a day + cf: { cacheEverything: true, cacheTtlByStatus: { "200-299": 86400, "404": 300, "500-599": 0 } }, + }); + } catch (e) { + return new Response("could not fetch the picture\n", { status: 502 }); + } + if (!res.ok) return new Response(`the picture's host answered ${res.status}\n`, { status: 502 }); + const b = await readUpTo(res, ICON_MAX + 1); + if (b.byteLength > ICON_MAX) return new Response("the picture is over 1 MB\n", { status: 413 }); + const type = imageType(new Uint8Array(b)); + if (!type) return new Response("not a picture\n", { status: 415 }); + return new Response(b, { + headers: { + "Content-Type": type, + "Cache-Control": "public, max-age=86400", + "X-Content-Type-Options": "nosniff", + "Content-Security-Policy": "default-src 'none'; style-src 'unsafe-inline'; sandbox", + }, + }); +} + +async function readUpTo(res, max) { + const r = res.body.getReader(); + const parts = []; + let n = 0; + while (n < max) { + const { done, value } = await r.read(); + if (done) break; + parts.push(value); + n += value.byteLength; + } + r.cancel().catch(() => {}); + const out = new Uint8Array(Math.min(n, max)); + let at = 0; + for (const p of parts) { + const take = p.subarray(0, out.length - at); + out.set(take, at); + at += take.length; + if (at >= out.length) break; + } + return out.buffer; +} + +// imageType is the picture's type by its bytes, as the app's StoreIcon +// takes them: PNG, JPEG, GIF, WebP, ICO or SVG; "" for anything else. +export function imageType(b) { + const at = (i, ...xs) => xs.every((x, k) => b[i + k] === x); + if (at(0, 0x89, 0x50, 0x4e, 0x47)) return "image/png"; + if (at(0, 0xff, 0xd8, 0xff)) return "image/jpeg"; + if (at(0, 0x47, 0x49, 0x46, 0x38)) return "image/gif"; + if (at(0, 0x52, 0x49, 0x46, 0x46) && at(8, 0x57, 0x45, 0x42, 0x50)) return "image/webp"; + if (at(0, 0, 0, 1, 0)) return "image/x-icon"; + if (new TextDecoder().decode(b.subarray(0, 1024)).toLowerCase().includes(" { Math.random = random; } }); + +// /api/icon fetches a picture for the app so its host sees Cloudflare, not +// the user: nothing of the asker's request goes on, and only a picture +// comes back. +test("icon proxy passes on a picture and nothing of the asker", async () => { + const PNG = new Uint8Array([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 1, 2, 3]); + const was = globalThis.fetch; + const asked = []; + globalThis.fetch = async (u, init = {}) => { + asked.push({ u: String(u), init }); + if (String(u) === "https://author.example/logo.png") return new Response(PNG); + if (String(u) === "https://author.example/page") return new Response(""); + if (String(u) === "https://author.example/big.png") return new Response(new Uint8Array(2 << 20).fill(0x89)); + if (String(u) === "https://author.example/gone.png") return new Response("no", { status: 404 }); + throw new Error("a test reached " + u); // never the real network + }; + try { + const req = new Request("https://usemagpie.ai/api/icon?url=" + encodeURIComponent("https://author.example/logo.png"), { + headers: { Cookie: "lang=zh", "User-Agent": "magpie/0.1.1168", "X-Forwarded-For": "203.0.113.9", "CF-Connecting-IP": "203.0.113.9" }, + }); + const res = await worker.fetch(req, {}, { waitUntil() {} }); + assert.equal(res.status, 200); + assert.equal(res.headers.get("Content-Type"), "image/png"); + assert.deepEqual(new Uint8Array(await res.arrayBuffer()), PNG); + const sent = asked.find((a) => a.u === "https://author.example/logo.png"); + const h = new Headers(sent.init.headers); + assert.deepEqual([...h.keys()].sort(), ["accept", "user-agent"]); + assert.doesNotMatch(h.get("user-agent"), /0\.1\.1168/); + + const ask = async (u) => (await worker.fetch(new Request("https://usemagpie.ai/api/icon?url=" + encodeURIComponent(u)), {}, { waitUntil() {} })).status; + assert.equal(await ask("https://author.example/page"), 415); + assert.equal(await ask("https://author.example/big.png"), 413); + assert.equal(await ask("https://author.example/gone.png"), 502); + assert.equal(await ask("http://author.example/logo.png"), 400); + assert.equal(await ask("https://u:p@author.example/logo.png"), 400); + assert.equal(await ask("https://author.example:8443/logo.png"), 400); + assert.equal(await ask("not a url"), 400); + assert.equal(await ask("https://usemagpie.ai/api/icon?url=x"), 400); + assert.equal(await ask("https://www.usemagpie.ai/logo.png"), 400); + assert.ok(asked.every((a) => !new URL(a.u).hostname.endsWith("usemagpie.ai")), "the worker asked itself"); + } finally { + globalThis.fetch = was; + } +});