diff --git a/README.md b/README.md index cea54f86d..c4da84e55 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ Runs on macOS, Windows and Linux (menu bar app, window, TUI, web UI and CLI), in curl -fsSL https://usemagpie.ai/install.sh | sh ``` -Mac builds are signed and notarised, and every build updates itself. On Linux the script installs the desktop app, or the terminal build where there is no desktop or its WebKitGTK isn't installed (it says which package to add); `--gui` or `--tui` chooses. Behind a firewall, use `--proxy` or `--mirror`. Or `go install github.com/yetone/magpie@latest`, or the [Docker image](https://usemagpie.ai/docs/docker). Remove what the script installed with `curl -fsSL https://usemagpie.ai/install.sh | sh -s -- --uninstall`; your settings in `~/.config/magpie` stay unless you add `--purge`, which disconnects your agents and deletes them too. +Mac builds are signed and notarised, and every build updates itself. On Linux the script installs the desktop app, and on a desktop without WebKitGTK 4.1 installs it first with your package manager (sudo asks for your password); with no desktop, or no terminal to ask at, it installs the terminal build and says which package to add. `--gui` or `--tui` chooses. Behind a firewall, use `--proxy` or `--mirror`. Or `go install github.com/yetone/magpie@latest`, or the [Docker image](https://usemagpie.ai/docs/docker). Remove what the script installed with `curl -fsSL https://usemagpie.ai/install.sh | sh -s -- --uninstall`; your settings in `~/.config/magpie` stay unless you add `--purge`, which disconnects your agents and deletes them too. **2 · Add a provider.** Open magpie and go to **Providers → Add provider**. Pick a preset and paste a key, or sign in with a subscription. diff --git a/README.zh-CN.md b/README.zh-CN.md index ea097c075..57019e35b 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -52,7 +52,7 @@ curl -fsSL https://usemagpie.ai/install.sh | sh ``` -Mac 版已签名并公证,每个版本都会自动更新。Linux 上脚本装桌面版;没有桌面或没装 WebKitGTK 时装终端版(并告诉你该装哪个包),用 `--gui` 或 `--tui` 可以自己选。网络受限时可用 `--proxy` 或 `--mirror`。也可以 `go install github.com/yetone/magpie@latest`,或者用 [Docker 镜像](https://usemagpie.ai/docs/zh/docker)。 用 `curl -fsSL https://usemagpie.ai/install.sh | sh -s -- --uninstall` 卸载脚本装上的东西;`~/.config/magpie` 里的设置会保留,加 `--purge` 才会断开 Agent 并一起删除。 +Mac 版已签名并公证,每个版本都会自动更新。Linux 上脚本装桌面版,桌面上没装 WebKitGTK 4.1 时会先用系统的包管理器装上(sudo 会要密码);没有桌面或没有终端可问时装终端版,并告诉你该装哪个包。用 `--gui` 或 `--tui` 可以自己选。网络受限时可用 `--proxy` 或 `--mirror`。也可以 `go install github.com/yetone/magpie@latest`,或者用 [Docker 镜像](https://usemagpie.ai/docs/zh/docker)。 用 `curl -fsSL https://usemagpie.ai/install.sh | sh -s -- --uninstall` 卸载脚本装上的东西;`~/.config/magpie` 里的设置会保留,加 `--purge` 才会断开 Agent 并一起删除。 **2 · 添加 provider**。打开 magpie,进入 **Providers → 添加 provider**。选一个预设、粘贴 key,或者登录一个订阅。 diff --git a/docs/reference.md b/docs/reference.md index 4515c488d..687c34b42 100644 --- a/docs/reference.md +++ b/docs/reference.md @@ -2602,24 +2602,31 @@ with a link builder: . Download the app for macOS, Windows or Linux from [usemagpie.ai](https://usemagpie.ai), or install it from a terminal (on -Linux, the desktop app when GTK 3 and WebKitGTK 4.1 are installed, the -terminal build otherwise): +Linux, the desktop app, with WebKitGTK 4.1 installed for it on a desktop +that lacks it; the terminal build where there is no desktop): ```sh curl -fsSL https://usemagpie.ai/install.sh | sh ``` -On Linux the installer asks nothing. A computer with a desktop (a -graphical session, the user's graphical login when run over ssh, or a -desktop installed in `xsessions` / `wayland-sessions`) but without the -app's libraries gets the terminal build, and the installer ends with the -command that installs them on that distribution (`sudo apt install -libwebkit2gtk-4.1-0` on Debian and Ubuntu, `sudo dnf install -webkit2gtk4.1` on Fedora, `sudo pacman -S --needed webkit2gtk-4.1` on -Arch, `sudo zypper install libwebkit2gtk-4_1-0` on openSUSE); run it again -afterwards for the app. `--gui` installs the app at once, before its -libraries; `--tui` (or `MAGPIE_CLI=1`) installs the terminal build on a -desktop too. The libraries are looked up with `ldconfig -p`, in `/sbin` +On a Linux computer with a desktop (a graphical session, the user's +graphical login when run over ssh, or a desktop installed in `xsessions` / +`wayland-sessions`) but without the app's libraries, the installer +installs WebKitGTK 4.1 (which brings GTK 3) with the distribution's +package manager, says so in one line first, and then installs the desktop +app: `apt-get install -y libwebkit2gtk-4.1-0` on Debian and Ubuntu +(`apt-get update` and once more when the lists are missing or stale), +`dnf install -y webkit2gtk4.1` on Fedora, `pacman -S --needed --noconfirm +webkit2gtk-4.1` on Arch, `zypper --non-interactive install +libwebkit2gtk-4_1-0` on openSUSE, through `sudo` (which asks for the +password) unless it runs as root. It does so only when someone is at the +terminal: `curl … | sh` gives the script the pipe for stdin, so it reads +`/dev/tty`. With no terminal (CI, a Dockerfile), no `sudo`, another +distribution, or an install that fails, it installs the terminal build and +ends with the command that installs the libraries; run it again afterwards +for the app. `--gui` installs the app either way (the libraries too, at a +terminal); `--tui` (or `MAGPIE_CLI=1`) installs the terminal build on a +desktop and installs no package. The libraries are looked up with `ldconfig -p`, in `/sbin` as well, since a Debian user's `PATH` doesn't have it, and in the usual library folders where there is no cache. On musl (Alpine) it is always the terminal build. diff --git a/site/install.test.mjs b/site/install.test.mjs index a1e6373f2..0965db900 100644 --- a/site/install.test.mjs +++ b/site/install.test.mjs @@ -1,7 +1,7 @@ import { test } from "node:test"; import assert from "node:assert/strict"; import { createHash } from "node:crypto"; -import { mkdtempSync, mkdirSync, writeFileSync, readFileSync, existsSync, statSync, rmSync } from "node:fs"; +import { mkdtempSync, mkdirSync, writeFileSync, readFileSync, existsSync, statSync, rmSync, symlinkSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; import { spawnSync } from "node:child_process"; @@ -9,7 +9,19 @@ import { fileURLToPath } from "node:url"; const installer = fileURLToPath(new URL("./public/install.sh", import.meta.url)); -function install(t, { termux = true, arch = "aarch64", override = false, prefixOnly = false, missing = false, corrupt = false, desktop = false, github = false, args = [], env: extra = {}, tamper = "", libs = desktop, cli = !desktop, distro = "ID=ubuntu\nID_LIKE=debian\n", sessions = [], login = "" } = {}) { +// systemPath: a folder of links to what the script runs, without sudo, for +// a computer that has none +function systemPath(dir) { + const sys = join(dir, "sys"); + mkdirSync(sys, { recursive: true }); + for (const n of ["sh", "dash", "bash", "sed", "head", "tr", "grep", "cut", "mktemp", "rm", "mkdir", "install", "cat", "sha256sum", "shasum", "ls", "rmdir", "mv", "ln", "chmod", "env", "perl"]) { + const w = spawnSync("sh", ["-c", `command -v ${n}`], { encoding: "utf8" }).stdout.trim(); + if (w.startsWith("/")) symlinkSync(w, join(sys, n)); + } + return sys; +} + +function install(t, { termux = true, arch = "aarch64", override = false, prefixOnly = false, missing = false, corrupt = false, desktop = false, github = false, args = [], env: extra = {}, tamper = "", libs = desktop, cli = !desktop, distro = "ID=ubuntu\nID_LIKE=debian\n", sessions = [], login = "", tty = false, uid = 1000, sudo = true, pmFails = false } = {}) { const dir = mkdtempSync(join(tmpdir(), "magpie-install-")); t.after(() => rmSync(dir, { recursive: true, force: true })); const tools = join(dir, "tools"); @@ -47,6 +59,26 @@ id=\${INSTALL_LOGIN%% *} type=\${INSTALL_LOGIN#* } [ "$1 $3 $4 $5" = "show-user -p Display --value" ] && [ -n "$id" ] && echo "$id" [ "$1 $2 $3 $4 $5" = "show-session $id -p Type --value" ] && [ -n "$id" ] && echo "$type" exit 0 +`, { mode: 0o755 }); + // the package managers, sudo and id: each call logged ("sudo" before a + // command sudo ran), and an install puts the libraries in ldconfig's + // cache unless it fails + const pmLog = join(dir, "pm-log"); + const ldTxt = join(tools, "ldconfig.txt").replaceAll("\\", "/"); + for (const pm of ["apt-get", "dnf", "pacman", "zypper"]) { + writeFileSync(join(tools, pm), `#!/bin/sh +echo "\${INSTALL_SUDO:+sudo }${pm} $*" >> "$INSTALL_PM_LOG" +case "$*" in update|"") exit 0 ;; esac +[ -z "$INSTALL_PM_FAILS" ] || exit 100 +[ "$INSTALL_PM_FAILS_ONCE" != 1 ] || [ -e "$INSTALL_PM_LOG.once" ] || { : > "$INSTALL_PM_LOG.once"; exit 100; } +printf '\\tlibgtk-3.so.0 (libc6,x86-64) => /usr/lib/libgtk-3.so.0\\n\\tlibwebkit2gtk-4.1.so.0 (libc6,x86-64) => /usr/lib/libwebkit2gtk-4.1.so.0\\n' >> "${ldTxt}" +`, { mode: 0o755 }); + } + if (sudo) writeFileSync(join(tools, "sudo"), `#!/bin/sh +INSTALL_SUDO=1 exec "$@" +`, { mode: 0o755 }); + writeFileSync(join(tools, "id"), `#!/bin/sh +case "$1" in -u) echo ${uid};; *) echo tester;; esac `, { mode: 0o755 }); const dataDirs = join(dir, "data-dirs"); for (const s of sessions) { @@ -88,7 +120,12 @@ else fs.writeFileSync(args[args.indexOf("-o") + 1], tamper && url.startsWith(tam XDG_DATA_DIRS: dataDirs, INSTALL_LOGIN: login, MAGPIE_OS_RELEASE: join(dir, "os-release"), - PATH: tools + ":" + process.env.PATH, + // no terminal unless a test gives it one: the run never reaches a real + // sudo or package manager + MAGPIE_TTY: tty ? join(dir, "tty") : join(dir, "no-tty"), + INSTALL_PM_LOG: pmLog, + INSTALL_PM_FAILS: pmFails ? "1" : "", + PATH: tools + ":" + (sudo ? process.env.PATH : systemPath(dir)), XDG_CONFIG_HOME: join(dir, "config"), XDG_DATA_HOME: join(dir, "share"), INSTALL_REQUESTS: requests, @@ -100,13 +137,14 @@ else fs.writeFileSync(args[args.indexOf("-o") + 1], tamper && url.startsWith(tam MAGPIE_MIRROR: "", ...extra, }; + if (tty) writeFileSync(join(dir, "tty"), ""); const read = (p) => (existsSync(p) ? readFileSync(p, "utf8") : ""); const run = (args) => { rmSync(requests, { force: true }); rmSync(env.INSTALL_ARGS, { force: true }); const result = spawnSync("sh", [installer, ...args], { env, encoding: "utf8" }); const calls = read(env.INSTALL_ARGS).trim().split("\n").filter(Boolean).map((l) => JSON.parse(l)); - return { ...result, requests: read(requests), calls }; + return { ...result, requests: read(requests), calls, pm: read(pmLog) }; }; return { ...run(args), run, bin, file, payload, home, env, share: env.XDG_DATA_HOME, config: env.XDG_CONFIG_HOME }; } @@ -411,3 +449,70 @@ test("--tui and MAGPIE_CLI=1 install the terminal build on a desktop with WebKit assert.match(help.stdout, /--gui .*desktop app/); assert.match(help.stdout, /--tui .*terminal build/); }); + +// shuhai on Discord: "为什么不能帮用户直接装好?" A desktop without +// WebKitGTK 4.1 has it installed with the distribution's package manager, +// through sudo, when someone is at the terminal (curl | sh: /dev/tty, not +// stdin), and then gets the desktop app. Anything else keeps the terminal +// build and the command. +test("a desktop without WebKitGTK at a terminal has it installed through sudo and gets the desktop app", (t) => { + for (const [distro, want] of [ + ["ID=ubuntu\nID_LIKE=debian\n", "sudo apt-get install -y libwebkit2gtk-4.1-0"], + ["ID=fedora\n", "sudo dnf install -y webkit2gtk4.1"], + ["ID=endeavouros\nID_LIKE=arch\n", "sudo pacman -S --needed --noconfirm webkit2gtk-4.1"], + ['ID="opensuse-tumbleweed"\nID_LIKE="opensuse suse"\n', "sudo zypper --non-interactive install libwebkit2gtk-4_1-0"], + ]) { + const r = linux(t, { libs: false, tty: true, distro, env: { DISPLAY: ":0" } }); + assert.ok(r.gui, distro + r.stdout); + assert.equal(r.pm, want + "\n", distro); + // what and why, said before sudo asks + assert.match(r.stdout, new RegExp(`needs WebKitGTK 4\\.1, so installing it: ${want.replace(/[.+]/g, "\\$&")} \\(sudo may ask for your password\\)`)); + assert.doesNotMatch(r.stdout, /aren't installed|didn't work|run this again/); + } +}); + +test("as root the package manager runs without sudo", (t) => { + const r = linux(t, { libs: false, tty: true, uid: 0, env: { DISPLAY: ":0" } }); + assert.ok(r.gui); + assert.equal(r.pm, "apt-get install -y libwebkit2gtk-4.1-0\n"); + assert.doesNotMatch(r.stdout, /sudo/); +}); + +test("with no terminal, no sudo, an unknown distribution or a failed install, the terminal build and the command", (t) => { + for (const opts of [ + { tty: false }, + { tty: true, sudo: false }, + { tty: true, distro: "ID=void\n" }, + { tty: true, distro: "ID=nixos\n" }, + ]) { + const r = linux(t, { libs: false, env: { DISPLAY: ":0" }, ...opts }); + assert.equal(r.gui, false, JSON.stringify(opts)); + assert.equal(r.pm, "", JSON.stringify(opts)); + assert.doesNotMatch(r.stdout, /installing it|didn't work/); + assert.match(r.stdout, /has a desktop, but the desktop app needs GTK 3 and WebKitGTK 4\.1, which aren't installed/); + } + const f = linux(t, { libs: false, tty: true, pmFails: true, env: { DISPLAY: ":0" } }); + assert.equal(f.gui, false); + // apt read its lists again and tried once more + assert.equal(f.pm, "sudo apt-get install -y libwebkit2gtk-4.1-0\nsudo apt-get update\nsudo apt-get install -y libwebkit2gtk-4.1-0\n"); + assert.match(last(f, 5), /installing GTK 3 and WebKitGTK 4\.1 for the desktop app didn't work/); + assert.match(last(f, 4), /sudo apt install libwebkit2gtk-4\.1-0/); +}); + +test("a stale apt list is read again and the install tried once more", (t) => { + const r = linux(t, { libs: false, tty: true, env: { DISPLAY: ":0", INSTALL_PM_FAILS_ONCE: "1" } }); + assert.ok(r.gui, r.stdout); + assert.equal(r.pm, "sudo apt-get install -y libwebkit2gtk-4.1-0\nsudo apt-get update\nsudo apt-get install -y libwebkit2gtk-4.1-0\n"); +}); + +test("--gui installs WebKitGTK at a terminal too; --tui, MAGPIE_CLI=1 and a headless computer never do", (t) => { + const g = linux(t, { libs: false, tty: true, args: ["--gui"] }); + assert.ok(g.gui); + assert.equal(g.pm, "sudo apt-get install -y libwebkit2gtk-4.1-0\n"); + assert.doesNotMatch(g.stdout, /aren't installed/); + for (const opts of [{ args: ["--tui"], env: { DISPLAY: ":0" } }, { cli: true, env: { DISPLAY: ":0" } }, {}]) { + const r = linux(t, { libs: false, tty: true, ...opts }); + assert.equal(r.gui, false, JSON.stringify(opts)); + assert.equal(r.pm, "", JSON.stringify(opts)); + } +}); diff --git a/site/public/docs/ja/start.html b/site/public/docs/ja/start.html index 0376ef2c6..c9c9bc78b 100644 --- a/site/public/docs/ja/start.html +++ b/site/public/docs/ja/start.html @@ -287,7 +287,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 を通ります。

Linux ではインストーラはどのビルドを入れますか?

-

GTK 3 と WebKitGTK 4.1 が入っていればデスクトップアプリ(ウィンドウ、トレイアイコン、アプリメニューの項目)です。デスクトップがあってもそれらが無いときはターミナル版(magpie tui、magpie web と CLI)を入れ、最後にそのディストリビューションで入れるコマンドを表示します。Debian・Ubuntu なら sudo apt install libwebkit2gtk-4.1-0、Fedora なら sudo dnf install webkit2gtk4.1 です。入れたあとインストーラをもう一度実行するとアプリになります。デスクトップ上で実行しても ssh 越しでも、グラフィカルなセッション、あなたのグラフィカルなログイン、ログインできるデスクトップ環境のどれかがあればデスクトップありと判断します。デスクトップの無いサーバーにはターミナル版です。何も質問しないので curl … | sh はそのまま無人で動きます。自分で選ぶには --gui(アプリを先に、ライブラリは後で)か --tui を付けます:curl -fsSL https://usemagpie.ai/install.sh | sh -s -- --tui。

+

GTK 3 と WebKitGTK 4.1 が入っていればデスクトップアプリ(ウィンドウ、トレイアイコン、アプリメニューの項目)です。デスクトップがあってもそれらが無いときは、パッケージマネージャー(apt、dnf、pacman、zypper)で sudo を通して WebKitGTK 4.1 を入れ(sudo がパスワードを尋ねます)、それからアプリを入れます。パスワードを尋ねる前に何を入れるかを表示します。端末が無いとき(CI、Dockerfile)、sudo が無いとき、知らないディストリビューションやインストールに失敗したときはターミナル版(magpie tui、magpie web と CLI)を入れ、最後に入れるコマンドを表示します。Debian・Ubuntu なら sudo apt install libwebkit2gtk-4.1-0、Fedora なら sudo dnf install webkit2gtk4.1 です。入れたあとインストーラをもう一度実行するとアプリになります。デスクトップ上で実行しても ssh 越しでも、グラフィカルなセッション、あなたのグラフィカルなログイン、ログインできるデスクトップ環境のどれかがあればデスクトップありと判断します。デスクトップの無いサーバーにはターミナル版です。自分で選ぶには --gui(ライブラリを今入れられなくてもアプリ)か --tui(ターミナル版、パッケージは入れない)を付けます:curl -fsSL https://usemagpie.ai/install.sh | sh -s -- --tui。

magpie をアンインストールするには?

スクリプトでインストールした場合:curl -fsSL https://usemagpie.ai/install.sh | sh -s -- --uninstall で、スクリプトが置いたものを取り除きます。magpie コマンド、macOS ではアプリ、Linux ではメニュー項目・アイコン・magpie:// のハンドラ、それに Linux ではもう無い magpie を起動してしまうサービスとログイン時の起動です。~/.config/magpie の設定・プロバイダ・使用量は残るので、再インストールすれば戻ります。接続したエージェントはそれまで magpie のアドレスを指したままです。--purge を付けると先に magpie uninstall --yes を実行し、すべてのエージェントの接続を外して元の設定に戻してから、magpie の設定・プロバイダ・使用量を削除します。ほかの方法でインストールした場合は、magpie uninstall または Settings → magpie をアンインストール が --purge と同じことを行い、プログラム本体は手動で削除します。

diff --git a/site/public/docs/start.html b/site/public/docs/start.html index 876ce7467..89084e375 100644 --- a/site/public/docs/start.html +++ b/site/public/docs/start.html @@ -287,7 +287,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.

Which build does the installer put on Linux?

-

The desktop app (window, tray icon and a menu entry) when GTK 3 and WebKitGTK 4.1 are installed. A computer with a desktop but without them gets the terminal build (magpie tui, magpie web and the CLI), and the installer ends with the command that installs them on your distribution, such as sudo apt install libwebkit2gtk-4.1-0 on Debian and Ubuntu or sudo dnf install webkit2gtk4.1 on Fedora; run the installer again afterwards for the app. A desktop counts whether you run it there or over ssh: a graphical session, your graphical login, or a desktop installed to log in to. A server without one gets the terminal build. Nothing is asked, so curl … | sh runs unattended; to choose yourself, add --gui (the app now, the libraries after) or --tui: curl -fsSL https://usemagpie.ai/install.sh | sh -s -- --tui.

+

The desktop app (window, tray icon and a menu entry) when GTK 3 and WebKitGTK 4.1 are installed. On a computer with a desktop but without them, the installer installs WebKitGTK 4.1 with your package manager (apt, dnf, pacman or zypper), through sudo, which asks for your password, and then the app; it says what it installs before it asks. Run without a terminal (CI, a Dockerfile), without sudo, on another distribution or when that install fails, it installs the terminal build (magpie tui, magpie web and the CLI) and ends with the command that installs them, such as sudo apt install libwebkit2gtk-4.1-0 on Debian and Ubuntu or sudo dnf install webkit2gtk4.1 on Fedora; run the installer again afterwards for the app. A desktop counts whether you run it there or over ssh: a graphical session, your graphical login, or a desktop installed to log in to. A server without one gets the terminal build. To choose yourself, add --gui (the app even when its libraries can't be installed now) or --tui (the terminal build, and no package installed): curl -fsSL https://usemagpie.ai/install.sh | sh -s -- --tui.

How do I uninstall magpie?

Installed with the script: curl -fsSL https://usemagpie.ai/install.sh | sh -s -- --uninstall takes off what it put there: the magpie command, and the app on macOS or its menu entry, icon and magpie:// handler on Linux, with magpie’s service and opening at login there, which would start a magpie that is gone. Your settings, providers and usage in ~/.config/magpie stay, for when you install again; agents you connected keep magpie’s address until then. Add --purge to have magpie uninstall --yes run first: it disconnects every agent and puts back what each had, then deletes magpie’s settings, providers and usage. Installed another way, magpie uninstall or Settings → Uninstall magpie does what --purge does and leaves the program itself for you to delete.

diff --git a/site/public/docs/zh/start.html b/site/public/docs/zh/start.html index 7b5599188..4162e9232 100644 --- a/site/public/docs/zh/start.html +++ b/site/public/docs/zh/start.html @@ -287,7 +287,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,而不是镜像,镜像改过的文件会被拒绝安装。应用自己的更新走 设置 → 代理。

Linux 上安装脚本装的是哪个版本?

-

装了 GTK 3 和 WebKitGTK 4.1 时装桌面版(窗口、托盘图标和应用菜单项)。有桌面但缺这两个库时,先装终端版(magpie tui、magpie web 和命令行),脚本最后会给出你这个发行版装库的命令,比如 Debian、Ubuntu 上是 sudo apt install libwebkit2gtk-4.1-0,Fedora 上是 sudo dnf install webkit2gtk4.1;装好后再运行一次安装脚本就换成桌面版。在桌面上运行还是 ssh 进去运行都算有桌面:有图形会话、你登录着图形界面,或者装了可登录的桌面环境。没有桌面的服务器装终端版。脚本什么都不问,curl … | sh 可以无人值守;想自己选,加 --gui(先装桌面版,库之后再装)或 --tui:curl -fsSL https://usemagpie.ai/install.sh | sh -s -- --tui。

+

装了 GTK 3 和 WebKitGTK 4.1 时装桌面版(窗口、托盘图标和应用菜单项)。有桌面但缺这两个库时,脚本会用系统的包管理器(apt、dnf、pacman 或 zypper)通过 sudo 装上 WebKitGTK 4.1(sudo 会要你的密码),再装桌面版;要密码之前会先说要装什么。没有终端(CI、Dockerfile)、没有 sudo、发行版不认识或者装库失败时,先装终端版(magpie tui、magpie web 和命令行),最后给出装库的命令,比如 Debian、Ubuntu 上是 sudo apt install libwebkit2gtk-4.1-0,Fedora 上是 sudo dnf install webkit2gtk4.1;装好后再运行一次安装脚本就换成桌面版。在桌面上运行还是 ssh 进去运行都算有桌面:有图形会话、你登录着图形界面,或者装了可登录的桌面环境。没有桌面的服务器装终端版。想自己选,加 --gui(库现在装不上也装桌面版)或 --tui(装终端版,不装任何系统包):curl -fsSL https://usemagpie.ai/install.sh | sh -s -- --tui。

怎么卸载 magpie?

用安装脚本装的:curl -fsSL https://usemagpie.ai/install.sh | sh -s -- --uninstall 会拿掉它装上的东西:magpie 命令,macOS 上的应用,Linux 上的菜单项、图标和 magpie:// 链接处理,以及 Linux 上会去启动一个已不存在的 magpie 的后台服务和开机启动。~/.config/magpie 里的设置、provider 和用量都保留,重新安装就回来;已连接的 Agent 在那之前仍指向 magpie 的地址。加上 --purge 会先运行 magpie uninstall --yes:断开每个 Agent 并恢复它原来的配置,再删除 magpie 的设置、provider 和用量。用其他方式装的,magpie uninstall 或 设置 → 卸载 magpie 做的就是 --purge 那些事,程序本身留给你删除。

diff --git a/site/public/install.sh b/site/public/install.sh index 9ba680846..4ef044c0b 100644 --- a/site/public/install.sh +++ b/site/public/install.sh @@ -5,9 +5,12 @@ # writable) and links the magpie command into ~/.local/bin. # Linux: puts magpie in ~/.local/bin — the desktop app (with a menu entry) # when GTK 3 and WebKitGTK 4.1 are installed, the terminal build otherwise. -# A computer with a desktop but without them gets the terminal build and -# the command that installs them on its distribution; --gui and --tui -# choose instead (MAGPIE_CLI=1 is --tui). Nothing is asked. +# A computer with a desktop but without them has WebKitGTK 4.1 installed +# with its package manager (apt-get, dnf, pacman or zypper, through sudo, +# which asks for the password) when someone is at the terminal, then gets +# the desktop app; with no terminal, no sudo or a failed install, the +# terminal build and the command that installs them. --gui and --tui +# choose instead (MAGPIE_CLI=1 is --tui). # Termux: installs the Android terminal build into $PREFIX/bin. # Every download is checked against the release's SHA-256. # @@ -22,8 +25,8 @@ # list and its SHA-256 still come from usemagpie.ai, # never from the mirror, so a file the mirror changed is # refused. -# --gui the desktop app, on Linux even before its libraries are -# installed (it opens once they are) +# --gui the desktop app, on Linux even when its libraries can't +# be installed now (it opens once they are) # --tui the terminal build (TUI, web UI and CLI), on Linux even # with a desktop (MAGPIE_CLI=1 does the same) # --uninstall takes off what this script put there: the magpie @@ -65,7 +68,7 @@ while [ $# -gt 0 ]; do " --proxy http://, https://, socks5:// or socks5h:// proxy for the downloads (or MAGPIE_PROXY=)" \ " --mirror GitHub download mirror put before the release's github.com URL (or MAGPIE_MIRROR=);" \ " the SHA-256 is still checked against $site's" \ - " --gui Linux: the desktop app, even before GTK 3 and WebKitGTK 4.1 are installed" \ + " --gui Linux: the desktop app, even when GTK 3 and WebKitGTK 4.1 can't be installed now" \ " --tui Linux: the terminal build (TUI, web UI, CLI), even on a desktop (or MAGPIE_CLI=1)" \ " --uninstall take off what this script installed; your settings in ~/.config/magpie stay" \ " --purge with --uninstall: also disconnect every agent and delete magpie's settings (magpie uninstall)" @@ -248,9 +251,13 @@ has_desktop() { return 1 } -# gui_packages: the command that installs the desktop app's libraries on -# this distribution, or nothing when it isn't one we know +# gui_packages: sets pkg, the package that brings WebKitGTK 4.1 (and GTK 3 +# with it) on this distribution, pm, the package manager this script runs +# to install it, and hint, the command to tell the user; each is empty when +# the distribution isn't one we know (pm too where installing it isn't +# quick: Gentoo builds it from source) gui_packages() { + pkg='' pm='' hint='' id='' like='' # MAGPIE_OS_RELEASE: another os-release, for the installer's tests rel=${MAGPIE_OS_RELEASE:-/etc/os-release} @@ -262,21 +269,58 @@ gui_packages() { for d in $id $like; do case "$d" in debian|ubuntu|linuxmint|pop|elementary|zorin|kali|raspbian|deepin|uos) - echo "sudo apt install libwebkit2gtk-4.1-0"; return ;; + pm=apt-get pkg=libwebkit2gtk-4.1-0 hint="sudo apt install libwebkit2gtk-4.1-0" ;; fedora|rhel|centos|rocky|almalinux|nobara|openeuler|anolis) - echo "sudo dnf install webkit2gtk4.1"; return ;; + pm=dnf pkg=webkit2gtk4.1 hint="sudo dnf install webkit2gtk4.1" ;; arch|manjaro|endeavouros|cachyos|garuda) - echo "sudo pacman -S --needed webkit2gtk-4.1"; return ;; + pm=pacman pkg=webkit2gtk-4.1 hint="sudo pacman -S --needed webkit2gtk-4.1" ;; opensuse*|suse|sles) - echo "sudo zypper install libwebkit2gtk-4_1-0"; return ;; + pm=zypper pkg=libwebkit2gtk-4_1-0 hint="sudo zypper install libwebkit2gtk-4_1-0" ;; void) - echo "sudo xbps-install -S libwebkit2gtk41"; return ;; + hint="sudo xbps-install -S libwebkit2gtk41" ;; gentoo) - echo "sudo emerge net-libs/webkit-gtk:4.1"; return ;; + hint="sudo emerge net-libs/webkit-gtk:4.1" ;; + *) continue ;; esac + return 0 done } +# install_gui_libs: installs WebKitGTK 4.1 with the distribution's package +# manager, saying first what and why, when someone is at the terminal to +# answer sudo's password (or the script runs as root). curl | sh gives the +# script the pipe for stdin, so the terminal is /dev/tty, and every command +# here reads it. Fails, and the caller falls back to the terminal build, +# with no terminal, no sudo, a package manager we don't run, or a failed +# install. MAGPIE_TTY: another terminal, for the installer's tests. +install_gui_libs() { + tried= + gui_packages + [ -n "$pm" ] && command -v "$pm" >/dev/null 2>&1 || return 1 + tty=${MAGPIE_TTY:-/dev/tty} + # a subshell: a redirection that fails would end the script itself + (: <"$tty") 2>/dev/null || return 1 + as= + if [ "$(id -u 2>/dev/null)" != 0 ]; then + command -v sudo >/dev/null 2>&1 || return 1 + as=sudo + fi + case "$pm" in + apt-get) set -- apt-get install -y "$pkg" ;; + dnf) set -- dnf install -y "$pkg" ;; + pacman) set -- pacman -S --needed --noconfirm "$pkg" ;; + zypper) set -- zypper --non-interactive install "$pkg" ;; + esac + tried=1 + say "the desktop app needs WebKitGTK 4.1, so installing it: ${as:+$as }$*${as:+ (sudo may ask for your password)}" + # apt's package lists can be missing (a fresh system) or out of date + # (a 404 for a version gone from the mirror): read them again and retry + if $as "$@" <"$tty"; then : + elif [ "$pm" = apt-get ] && $as apt-get update <"$tty" && $as "$@" <"$tty"; then : + else return 1; fi + has_gui_libs +} + case "$(uname -m)" in arm64|aarch64) arch=arm64 ;; x86_64|amd64) arch=amd64 ;; @@ -289,11 +333,14 @@ case "$os" in file="magpie-cli-linux-$arch" case "$build" in gui) ! musl || die "the desktop app is built for glibc and can't run on musl (Alpine): install the terminal build with --tui" - file="magpie-linux-$arch" ;; + file="magpie-linux-$arch" + has_gui_libs || install_gui_libs || true ;; tui) ;; *) if musl; then : elif has_gui_libs; then file="magpie-linux-$arch" - elif has_desktop; then nolibs=1; fi ;; + elif has_desktop; then + if install_gui_libs; then file="magpie-linux-$arch"; else nolibs=1; fi + fi ;; esac ;; esac @@ -380,16 +427,18 @@ esac # the desktop app without what it needs: what installs it, said last so it # is what the user reads if [ "$file" = "magpie-linux-$arch" ] && ! has_gui_libs; then - pkgs=$(gui_packages) + gui_packages say "" - say "the desktop app needs GTK 3 and WebKitGTK 4.1, which aren't installed; it opens once they are:" - say " ${pkgs:-install WebKitGTK 4.1 (webkit2gtk 4.1) from your distribution}" + if [ -n "${tried:-}" ]; then say "installing GTK 3 and WebKitGTK 4.1 didn't work (see above); the desktop app opens once they are installed:" + else say "the desktop app needs GTK 3 and WebKitGTK 4.1, which aren't installed; it opens once they are:"; fi + say " ${hint:-install WebKitGTK 4.1 (webkit2gtk 4.1) from your distribution}" elif [ -n "${nolibs:-}" ]; then - pkgs=$(gui_packages) + gui_packages say "" - say "this computer has a desktop, but the desktop app needs GTK 3 and WebKitGTK 4.1, which aren't installed," + if [ -n "${tried:-}" ]; then say "this computer has a desktop, but installing GTK 3 and WebKitGTK 4.1 for the desktop app didn't work (see above)," + else say "this computer has a desktop, but the desktop app needs GTK 3 and WebKitGTK 4.1, which aren't installed,"; fi say "so the terminal build was installed. For the desktop app, install them and run this again:" - say " ${pkgs:-install WebKitGTK 4.1 (webkit2gtk 4.1) from your distribution}" + say " ${hint:-install WebKitGTK 4.1 (webkit2gtk 4.1) from your distribution}" say " curl -fsSL $site/install.sh | sh" say "or install the desktop app now and the libraries after: curl -fsSL $site/install.sh | sh -s -- --gui" fi