icon: remote icons are fetched through usemagpie.ai/api/icon, so their hosts never see the user's IP

A plugin's package.json icon, an import link's icon= and the library's
market icons sit on hosts their authors pick. magpie fetched each straight
from there, so an author could log the IP of everyone who opened Discover
or the library. The owner asked for icons to keep showing without that.

- site/worker.js: /api/icon?url=<https URL> fetches the picture from
  Cloudflare with only Accept: image/* and its own User-Agent, follows
  redirects, caps it at 1 MB (the app's MaxIcon), passes on only PNG,
  JPEG, GIF, WebP, ICO or SVG (by bytes, as StoreIcon), and counts and
  keeps nothing. It refuses http, userinfo, a non-443 port and
  usemagpie.ai itself; 404s are cached 5 minutes, 5xx not at all.
- internal/iconproxy: URL(u) is the proxied address (MAGPIE_ICON_PROXY
  for tests); a picture already on usemagpie.ai is asked for as it is.
- provider.FetchIcon (plugin, import link and partner icons) and
  library.fetchImage (market icons, avatars) fetch through it. The
  import link's checks (https, public host) still come first; there is
  no direct fallback. provider.FaviconFor still reads the user's own
  provider's site directly: they already send it their requests.
- Privacy text in README en/zh, docs/reference.md and site docs
  start/import in en/zh/ja says so.

Ran:
- node --test site/*.test.mjs: 28 pass. The new test asks with Cookie,
  UA, X-Forwarded-For and CF-Connecting-IP and checks only accept and
  user-agent go upstream; 415/413/502/400 cases; its fetch stub throws
  instead of reaching the network. With the usemagpie.ai refusal
  removed by hand it goes red (27/1).
- TestFetchIconGoesThroughTheProxy and TestIconGoesThroughTheProxy
  (author host is .invalid; an httptest server stands in for the proxy):
  with the proxy taken out by hand both go red (provider: lookup
  author.invalid; library: the proxy was never asked), green restored.
- go test ./internal/iconproxy ./internal/provider ./internal/library
  ./internal/gui: ok. gofmt -l clean; go vet darwin (those four),
  linux (iconproxy, provider, library), windows (all four): clean.
This commit is contained in:
yetone
2026-10-11 01:28:22 +08:00
parent f8767d1980
commit f04792f906
17 changed files with 320 additions and 11 deletions
+1 -1
View File
@@ -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
+1 -1
View File
@@ -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)。
## 社区
+9
View File
@@ -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=<https 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
+28
View File
@@ -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)
}
+35
View File
@@ -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)
}
}
}
+46
View File
@@ -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)
}
}
+4 -1
View File
@@ -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
}
+8 -2
View File
@@ -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.
//
+49
View File
@@ -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)
}
}
+1 -1
View File
@@ -233,7 +233,7 @@ href = <span class="s">"https://usemagpie.ai/import#"</span> + urlencode({
<li><b>No silent overwrites.</b> When the id is already taken, the dialog says so and the button reads <em>Replace</em>.</li>
<li><b>https only.</b> Plain http is refused except to this machine or the local network; <code>file:</code>, credentials in URLs and other schemes are refused outright.</li>
<li><b>Read once.</b> Inside the app, the link’s contents are handed to the window a single time; a reload doesn’t bring the dialog back.</li>
<li><b>Icons are fetched, not embedded.</b> An <code>icon=</code> 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&nbsp;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.</li>
<li><b>Icons are fetched, not embedded.</b> An <code>icon=</code> 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&nbsp;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.</li>
<li><b>Keys stay out of servers.</b> The web link keeps parameters in the fragment. The key ends up only in <code>~/.config/magpie/providers.json</code>, readable by the user alone.</li>
</ul>
<div class="note"><b>Keys in links are secrets.</b> 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.</div>
+1 -1
View File
@@ -233,7 +233,7 @@ href = <span class="s">"https://usemagpie.ai/import#"</span> + urlencode({
<li><b>黙って上書きしない。</b>id がすでに使われている場合、ダイアログがそう伝え、ボタンは<em>置き換え</em>になります。</li>
<li><b>https のみ。</b>このマシンとローカルネットワーク宛て以外の http は拒否されます。<code>file:</code>、URL 内の認証情報、その他のスキームは即座に拒否されます。</li>
<li><b>読み込みは一度だけ。</b>アプリ内では、リンクの内容がウィンドウに一度だけ渡されます。再読み込みしてもダイアログは再表示されません。</li>
<li><b>アイコンは埋め込まず、取得する。</b><code>icon=</code> の URL は magpie 自身がダウンロードします。ユーザーがインポートを確認した後だけ、https 経由だけ、自身のアイコンフォルダへだけ — 最大 1&nbsp;MB で、形式もチェックされます。ホストは接続時に名前解決され、ループバック、プライベート、リンクローカル、予約済みアドレスに解決された場合は接続を拒否するため、ユーザー自身のマシンを指す名前(や DNS リバインディング)は拒否されます。ページとダイアログがリモートの画像を直接読み込むことはありません。</li>
<li><b>アイコンは埋め込まず、取得する。</b><code>icon=</code> の URL は magpie がダウンロードします。ユーザーがインポートを確認した後だけ、https 経由だけ、自身のアイコンフォルダへだけ — 最大 1&nbsp;MB で、形式もチェックされます。取得は usemagpie.ai のアイコンプロキシを経由するので、あなたのサーバーに見えるのはユーザーの IP ではなく Cloudflare のアドレスです。リクエストは Cloudflare から出るため、ユーザー自身のマシンやローカルネットワークには届きません。ループバックやローカルネットワークの名前は、リクエストの前に拒否されます。ページとダイアログがリモートの画像を直接読み込むことはありません。</li>
<li><b>キーはサーバーを通らない。</b>Web リンクはパラメータをフラグメントに置きます。キーは最終的に <code>~/.config/magpie/providers.json</code> にのみ保存され、ユーザー本人しか読めません。</li>
</ul>
<div class="note"><b>リンク内のキーは機密情報です。</b>キーをリンクに入れるのは、そのユーザー本人しか見られないページだけにし、できれば magpie 用に発行した、取り消し可能なキーを使ってください。共有キーを公開リンクに入れてはいけません。</div>
+1 -1
View File
@@ -269,7 +269,7 @@ magpie claude group/opus-anywhere <span class="c"># これを使う</span></p
<p>インストーラと <code>magpie update</code> にプロキシを渡します:<code>curl -fsSL https://usemagpie.ai/install.sh | sh -s -- --proxy http://127.0.0.1:7890</code>、または <code>magpie update --proxy socks5://127.0.0.1:1080</code>(http・https・socks5・socks5h に対応。<code>HTTPS_PROXY</code> と <code>ALL_PROXY</code> も使われます)。<code>--mirror &lt;prefix&gt;</code> を付けると、指定した GitHub ダウンロードミラーから <code>&lt;prefix&gt;https://github.com/…</code> としてリリースファイルを取得します。<code>magpie update mirror &lt;prefix&gt;</code> でアプリ自身の更新を含め毎回使い、<code>magpie update mirror off</code> で解除します。指定しない限りミラーは使われず、ファイルの SHA-256 はミラーではなく常に usemagpie.ai から取得するので、ミラーが書き換えたファイルはインストールされません。アプリ自身の更新は <span class="ui">Settings</span> → <span class="ui">Proxy</span> を通ります。</p>
<h3 id="privacy">magpie は何を送信しますか?</h3>
<p>プロンプト、返答、キー、アカウントは、使っているプロバイダーにだけ送られます。間に magpie 自身のサーバーはありません。リリース版の magpie は 1 日 1 回、使われていることを知らせます。何人が使っていて、何を優先して面倒を見るべきかを知るためです。送るのは、このコンピュータで作ったランダムな ID、magpie のバージョンとシステム、そして使っているエージェント、プロバイダー、モデルを magpie 自身の ID(<code>claude</code>、<code>deepseek</code>、<code>deepseek/deepseek-v4</code>)で、それぞれの数とともに。自分で追加したプロバイダーとそのモデルは <code>custom</code> とだけ記録します。プロバイダー追加シートの先頭に載るパートナーについては、1 日に表示された回数、開かれた回数、追加された回数も送ります(回数のみ)。名前、Base URL、アカウント、キー、プロンプト、使用量は送りません。<span class="ui">設定</span> → <span class="ui">プライバシー</span> → <span class="ui">使っているエージェント、プロバイダー、モデルを共有</span> でエージェント、プロバイダー、モデルとパートナーの回数を外せます。<span class="ui">ユーザー数に含める</span>、<code>DO_NOT_TRACK=1</code>、<code>MAGPIE_NO_STATS=1</code> のどれかですべてオフになります。ソースからのビルドは送信しません。パートナーの公式サイトと「キーを取得」のリンクは <code>usemagpie.ai/go/…</code> を経由し、移動の前にクリックを 1 回数えます(どのパートナーか、どのリンクか、国)。usemagpie.ai はパートナー一覧が取得された回数も数えます。これはサーバー自身が見るもので、どの Web サイトのアクセス集計とも同じく、上の設定には左右されません。ID、IP アドレス、アカウントは記録しません。詳しくは<a href="https://github.com/yetone/magpie/blob/main/docs/reference.md#counting-users">リファレンス</a>を。</p>
<p>プロンプト、返答、キー、アカウントは、使っているプロバイダーにだけ送られます。間に magpie 自身のサーバーはありません。リリース版の magpie は 1 日 1 回、使われていることを知らせます。何人が使っていて、何を優先して面倒を見るべきかを知るためです。送るのは、このコンピュータで作ったランダムな ID、magpie のバージョンとシステム、そして使っているエージェント、プロバイダー、モデルを magpie 自身の ID(<code>claude</code>、<code>deepseek</code>、<code>deepseek/deepseek-v4</code>)で、それぞれの数とともに。自分で追加したプロバイダーとそのモデルは <code>custom</code> とだけ記録します。プロバイダー追加シートの先頭に載るパートナーについては、1 日に表示された回数、開かれた回数、追加された回数も送ります(回数のみ)。名前、Base URL、アカウント、キー、プロンプト、使用量は送りません。<span class="ui">設定</span> → <span class="ui">プライバシー</span> → <span class="ui">使っているエージェント、プロバイダー、モデルを共有</span> でエージェント、プロバイダー、モデルとパートナーの回数を外せます。<span class="ui">ユーザー数に含める</span>、<code>DO_NOT_TRACK=1</code>、<code>MAGPIE_NO_STATS=1</code> のどれかですべてオフになります。ソースからのビルドは送信しません。パートナーの公式サイトと「キーを取得」のリンクは <code>usemagpie.ai/go/…</code> を経由し、移動の前にクリックを 1 回数えます(どのパートナーか、どのリンクか、国)。usemagpie.ai はパートナー一覧が取得された回数も数えます。これはサーバー自身が見るもので、どの Web サイトのアクセス集計とも同じく、上の設定には左右されません。ID、IP アドレス、アカウントは記録しません。プラグイン、インポートリンク、ライブラリが示すアイコンは <code>usemagpie.ai/api/icon</code> を経由して取得するので、アイコンのあるサーバーに見えるのはあなたの IP ではなく Cloudflare のアドレスです。このサーバーは画像を中継するだけで、数えることも記録することもしません。詳しくは<a href="https://github.com/yetone/magpie/blob/main/docs/reference.md#counting-users">リファレンス</a>を。</p>
<h3 id="proxy-loopback">エージェントが 502 を返す、または接続できず、magpie の Routing タブに何も出ない?</h3>
<p>プロキシアプリ(Surge、Clash、mihomo など。システムプロキシ、TUN、拡張モードのいずれかが有効)が、エージェントから <code>http://127.0.0.1:3425</code> へのリクエストを横取りして別の場所へ送っているため、magpie に届いていません。除外リスト(<code>skip-proxy</code>、バイパス)に 127.0.0.1 を書くだけでは足りないことがあります。Codex など一部のエージェントは、それでもプロキシを通します。ローカルアドレスを直結にするルールを、他のルールより前に追加してください:</p>
+1 -1
View File
@@ -269,7 +269,7 @@ magpie claude group/opus-anywhere <span class="c"># use it</span></pre>
<p>Give the installer and <code>magpie update</code> a proxy: <code>curl -fsSL https://usemagpie.ai/install.sh | sh -s -- --proxy http://127.0.0.1:7890</code>, or <code>magpie update --proxy socks5://127.0.0.1:1080</code> (http, https, socks5 and socks5h; <code>HTTPS_PROXY</code> and <code>ALL_PROXY</code> are honoured too). <code>--mirror &lt;prefix&gt;</code> fetches the release file from a GitHub download mirror you choose, as <code>&lt;prefix&gt;https://github.com/…</code>; <code>magpie update mirror &lt;prefix&gt;</code> keeps it for every update, the app’s too, and <code>magpie update mirror off</code> 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 <span class="ui">Settings</span> → <span class="ui">Proxy</span>.</p>
<h3 id="privacy">What does magpie send about me?</h3>
<p>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 (<code>claude</code>, <code>deepseek</code>, <code>deepseek/deepseek-v4</code>) with how many of each. A provider you added yourself, and a model on it, is only <code>custom</code>. 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. <span class="ui">Settings</span> → <span class="ui">Privacy</span> → <span class="ui">Share the agents, providers and models I use</span> leaves out the agents, providers and models, and the partner counts; <span class="ui">Count me as a user</span>, <code>DO_NOT_TRACK=1</code> or <code>MAGPIE_NO_STATS=1</code> turns it all off. Builds from source never send it. A partner's website and key-page links go through <code>usemagpie.ai/go/…</code>, 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 <a href="https://github.com/yetone/magpie/blob/main/docs/reference.md#counting-users">reference</a>.</p>
<p>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 (<code>claude</code>, <code>deepseek</code>, <code>deepseek/deepseek-v4</code>) with how many of each. A provider you added yourself, and a model on it, is only <code>custom</code>. 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. <span class="ui">Settings</span> → <span class="ui">Privacy</span> → <span class="ui">Share the agents, providers and models I use</span> leaves out the agents, providers and models, and the partner counts; <span class="ui">Count me as a user</span>, <code>DO_NOT_TRACK=1</code> or <code>MAGPIE_NO_STATS=1</code> turns it all off. Builds from source never send it. A partner's website and key-page links go through <code>usemagpie.ai/go/…</code>, 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 <code>usemagpie.ai/api/icon</code>, 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 <a href="https://github.com/yetone/magpie/blob/main/docs/reference.md#counting-users">reference</a>.</p>
<h3 id="proxy-loopback">The agent gets 502 or can’t connect, and nothing shows in magpie’s Routing tab?</h3>
<p>A proxy app (Surge, Clash, mihomo and the like, with system proxy, TUN or enhanced mode on) has taken the agent’s request to <code>http://127.0.0.1:3425</code> and sent it somewhere else, so it never reaches magpie. The bypass list (<code>skip-proxy</code>, “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:</p>
+1 -1
View File
@@ -233,7 +233,7 @@ href = <span class="s">"https://usemagpie.ai/import#"</span> + urlencode({
<li><b>不会悄悄覆盖。</b>id 已被占用时,对话框会说明,按钮也会变成「替换」。</li>
<li><b>只接受 https。</b>除了本机和局域网,一律拒绝 http;<code>file:</code>、URL 里带账号密码以及其他协议直接拒绝。</li>
<li><b>只读一次。</b>在应用里,链接内容只交给窗口一次;刷新后对话框不会再出现。</li>
<li><b>图标是下载的,不是嵌入的。</b><code>icon=</code> 地址由 magpie 自己下载,只在用户确认导入之后,只走 https,只存进它自己的图标目录,最大 1&nbsp;MB,并校验类型。域名在连接时解析,落到回环、内网、链路本地或保留地址时 magpie 拒绝连接,所以指回用户本机的域名(或 DNS 重绑定)都会被拒绝。页面和对话框从不直接加载远程图片。</li>
<li><b>图标是下载的,不是嵌入的。</b><code>icon=</code> 地址由 magpie 下载,只在用户确认导入之后,只走 https,只存进它自己的图标目录,最大 1&nbsp;MB,并校验类型。magpie 经 usemagpie.ai 的图标代理去取,所以你的服务器只看到 Cloudflare 的地址,看不到用户的 IP;请求从 Cloudflare 发出,碰不到用户本机和内网。回环或内网的域名在发出请求前就被拒绝。页面和对话框从不直接加载远程图片。</li>
<li><b>密钥不经过服务器。</b>网页链接把参数放在 # 片段里。密钥最终只存在 <code>~/.config/magpie/providers.json</code>,只有用户本人可读。</li>
</ul>
<div class="note"><b>链接里的密钥就是机密。</b>只在该用户本人能看到的页面上把密钥放进链接,最好是专门给 magpie 生成、可以随时吊销的密钥。绝不要把共享密钥放进公开链接。</div>
+1 -1
View File
@@ -269,7 +269,7 @@ magpie claude group/opus-anywhere <span class="c"># 使用它</span></pre>
<p>给安装脚本和 <code>magpie update</code> 加代理:<code>curl -fsSL https://usemagpie.ai/install.sh | sh -s -- --proxy http://127.0.0.1:7890</code>,或 <code>magpie update --proxy socks5://127.0.0.1:1080</code>(支持 http、https、socks5、socks5h;环境变量 <code>HTTPS_PROXY</code>、<code>ALL_PROXY</code> 同样生效)。<code>--mirror &lt;前缀&gt;</code> 从你指定的 GitHub 下载镜像取发布文件,即 <code>&lt;前缀&gt;https://github.com/…</code>;<code>magpie update mirror &lt;前缀&gt;</code> 让之后每次更新(包括应用自己的更新)都用它,<code>magpie update mirror off</code> 取消。不指定就不用任何镜像;文件的 SHA-256 始终来自 usemagpie.ai,而不是镜像,镜像改过的文件会被拒绝安装。应用自己的更新走 <span class="ui">设置</span> → <span class="ui">代理</span>。</p>
<h3 id="privacy">magpie 会发送我的哪些信息?</h3>
<p>你的提示词、回复、密钥和账号只发给你用的供应商,中间没有 magpie 自己的服务器。正式发布的 magpie 每天告诉我们一次它在用,好让我们知道有多少人在用、该先照顾哪些:本机随机生成的 ID、magpie 版本和系统,以及用了哪些 agent、供应商和模型,只用 magpie 自己的 ID(<code>claude</code>、<code>deepseek</code>、<code>deepseek/deepseek-v4</code>)和各自的数量。你自己添加的供应商及其上的模型只记作 <code>custom</code>。添加供应商页里排在最前的合作伙伴,每天被展示、打开和添加的次数也一并发送,只有次数。不发送名称、Base URL、账号、密钥、提示词和用量。<span class="ui">设置</span> → <span class="ui">隐私</span> → <span class="ui">分享我用的 agent、provider 和模型</span> 可以去掉 agent、供应商、模型和合作伙伴次数这部分;<span class="ui">计入用户数</span>、<code>DO_NOT_TRACK=1</code> 或 <code>MAGPIE_NO_STATS=1</code> 全部关闭。从源码构建的版本从不发送。合作伙伴的官网和「获取 Key」链接经 <code>usemagpie.ai/go/…</code> 跳转,跳转前记一次点击(哪个合作伙伴、哪个链接、哪个国家),usemagpie.ai 也会统计合作伙伴列表被拉取的次数。这部分是服务器本身看到的,和任何网站统计访问一样,不受上面的设置影响;不记录 ID、IP 和账号。详见<a href="https://github.com/yetone/magpie/blob/main/docs/reference.md#counting-users">参考文档</a>。</p>
<p>你的提示词、回复、密钥和账号只发给你用的供应商,中间没有 magpie 自己的服务器。正式发布的 magpie 每天告诉我们一次它在用,好让我们知道有多少人在用、该先照顾哪些:本机随机生成的 ID、magpie 版本和系统,以及用了哪些 agent、供应商和模型,只用 magpie 自己的 ID(<code>claude</code>、<code>deepseek</code>、<code>deepseek/deepseek-v4</code>)和各自的数量。你自己添加的供应商及其上的模型只记作 <code>custom</code>。添加供应商页里排在最前的合作伙伴,每天被展示、打开和添加的次数也一并发送,只有次数。不发送名称、Base URL、账号、密钥、提示词和用量。<span class="ui">设置</span> → <span class="ui">隐私</span> → <span class="ui">分享我用的 agent、provider 和模型</span> 可以去掉 agent、供应商、模型和合作伙伴次数这部分;<span class="ui">计入用户数</span>、<code>DO_NOT_TRACK=1</code> 或 <code>MAGPIE_NO_STATS=1</code> 全部关闭。从源码构建的版本从不发送。合作伙伴的官网和「获取 Key」链接经 <code>usemagpie.ai/go/…</code> 跳转,跳转前记一次点击(哪个合作伙伴、哪个链接、哪个国家),usemagpie.ai 也会统计合作伙伴列表被拉取的次数。这部分是服务器本身看到的,和任何网站统计访问一样,不受上面的设置影响;不记录 ID、IP 和账号。插件、导入链接和库里的图标经 <code>usemagpie.ai/api/icon</code> 获取,图标所在的服务器只看到 Cloudflare 的地址,看不到你的 IP;这台服务器只转发图片,不计数也不记录。详见<a href="https://github.com/yetone/magpie/blob/main/docs/reference.md#counting-users">参考文档</a>。</p>
<h3 id="proxy-loopback">Agent 报 502 或连不上,magpie 的路由标签页里却什么都没有?</h3>
<p>代理软件(Surge、Clash、mihomo 等,开了系统代理、TUN 或增强模式)把 Agent 发往 <code>http://127.0.0.1:3425</code> 的请求接走、转去了别处,请求根本没到 magpie。只在跳过列表(<code>skip-proxy</code>、「绕过」)里写 127.0.0.1 不一定够:有些 Agent(比如 Codex)照样会走代理。在代理软件里加两条本地地址直连的规则,放在其他规则前面:</p>
+89
View File
@@ -12,6 +12,10 @@
// their website and key links through /go
// /go/<id>/keys[/<region>], /go/<id>/site[/<region>]
// a partner's key page or website, counted
// /api/icon?url=<https 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("<svg")) return "image/svg+xml";
return "";
}
function json(v, status = 200, headers = {}) {
return new Response(JSON.stringify(v), {
status,
+44
View File
@@ -398,3 +398,47 @@ test("partners: the list's fetches are counted, one in ten", async () => {
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("<html><script>x</script></html>");
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;
}
});