notices: the release carries the third-party licence notices

The owner asked for the licence notices in the release package (moejs
alpha.11 compiles Intl's data in, which carries its own notices).
THIRD_PARTY_NOTICES is embedded in the binary (main.go, //go:embed) and
handed to internal/notices; `magpie licenses` prints it, GET /api/notices
serves it, and Settings › About has an Open-source licenses row that
opens it in a dialog, in every language. `make app` copies the file into
the .app's Resources too. The core's scripts are 1,527,245 bytes, their
budget raised to it with no room added; app.js stays under its own.

Run at this head (rebased on origin/main):
- win-run (Windows 11): go vet -tags nogui . ./internal/notices
  ./internal/cli; go test TestNoticesFollowMoejs (.), ./internal/cli,
  TestCoreScriptBudget (./internal/gui): ok.
- wsl-run (Ubuntu 24.04): go vet -tags nogui ./..., go build -tags
  nogui: ok.
Run at the pre-rebase head 14e2d13fb, on mote (macOS):
- gofmt; make app's copy byte-identical to the file; `magpie licenses`
  output equal to the file; GOOS=linux/windows vet and build;
  go test . ./internal/cli: ok. ./internal/gui: only
  TestMainWindowCorners red, the same on origin/main (#3949).
- about-notices.test.cjs: chromium and webkit, en zh zh-TW ja de, 1100
  and 420px: all ok.
Broken by hand: TestNoticesFollowMoejs red with the embedded file cut.
Not run: the GUI suite at this head. The rebase met main's cancelAsk
helper where showNotices sat, and the dialog's Done now uses it (the
same stopPropagation + closeConfirmAsk). The whole GUI suite at
14e2d13fb was cut off when mote went down at load ~50: the files it
reached outside About had reds, most of them 180s browser-launch
timeouts, the rest passing in other languages or the other engine; they
are run again once mote is back, and any that stay red are filed.
This commit is contained in:
yetone
2026-10-28 16:40:03 +08:00
parent 1d7ca4c6b7
commit e8c7dddcb4
11 changed files with 149 additions and 6 deletions
+1
View File
@@ -63,6 +63,7 @@ app: build
@cp magpie magpie.app/Contents/MacOS/magpie
@cp build/darwin/magpie.icns magpie.app/Contents/Resources/magpie.icns
@cp build/darwin/Assets.car magpie.app/Contents/Resources/Assets.car
@cp THIRD_PARTY_NOTICES magpie.app/Contents/Resources/THIRD_PARTY_NOTICES
@sed 's/@VERSION@/$(VERSION)/' build/darwin/Info.plist > magpie.app/Contents/Info.plist
@echo " magpie.app"
+8
View File
@@ -21,6 +21,7 @@ import (
"github.com/yetone/magpie/internal/gateway"
"github.com/yetone/magpie/internal/imagemcp"
"github.com/yetone/magpie/internal/netproxy"
"github.com/yetone/magpie/internal/notices"
"github.com/yetone/magpie/internal/pluginrt"
"github.com/yetone/magpie/internal/proc"
"github.com/yetone/magpie/internal/profile"
@@ -147,6 +148,7 @@ const usage = `magpie — one place to pick every agent's model
magpie update auto [on|off] [download|notify] [30m|1h|6h|24h]
whether the app looks for updates by itself, how often (6h), and whether
it downloads one at once or only says it is out (notify: for metered networks)
magpie licenses the third-party notices of what magpie is built with
agents: claude (cc), codex, gemini, opencode (oc), mimocode, deveco, pi, goose, cursor, zed, copilot, crush, aside
`
@@ -175,6 +177,9 @@ func Main(v string) {
case "-h", "--help", "help":
fmt.Print(usage)
return
case "licenses":
fmt.Print(notices.Text)
return
}
}
fmt.Fprintln(os.Stderr, "magpie:", err)
@@ -416,6 +421,9 @@ func run(args []string) error {
case "-v", "--version", "version":
fmt.Println("magpie", version)
return nil
case "licenses":
fmt.Print(notices.Text)
return nil
case "ls", "list":
// in the order the app lists them; those hidden there come last, dimmed
shown, hidden := settings.Arrange(settings.Load(), agent.Detected(), func(a *agent.Agent) string { return a.ID })
+6
View File
@@ -43,6 +43,7 @@ import (
"github.com/yetone/magpie/internal/mcpauth"
"github.com/yetone/magpie/internal/middleware"
"github.com/yetone/magpie/internal/netproxy"
"github.com/yetone/magpie/internal/notices"
"github.com/yetone/magpie/internal/plugin"
"github.com/yetone/magpie/internal/profile"
"github.com/yetone/magpie/internal/provider"
@@ -116,6 +117,11 @@ func cliBehindRoutes(mux *http.ServeMux) {
mux.HandleFunc("GET /api/cli", func(rw http.ResponseWriter, r *http.Request) {
writeJSON(rw, update.ReadCLI())
})
// Settings › About's Open-source licenses: the notices this binary
// carries (notices.Text, THIRD_PARTY_NOTICES)
mux.HandleFunc("GET /api/notices", func(rw http.ResponseWriter, r *http.Request) {
writeJSON(rw, map[string]string{"text": notices.Text})
})
mux.HandleFunc("POST /api/cli", func(rw http.ResponseWriter, r *http.Request) {
var in struct {
Shell string `json:"shell"`
+2
View File
@@ -4382,3 +4382,5 @@ body .row.agent .ag-prefs .row.pref .who { display: block; }
.sess-pick.led-more { padding: 0 6px; }
.sess-pick.led-more svg { transform: none; }
.sess-tools .led-rename { flex: none; width: 180px; height: 26px; padding: 0 8px; border-radius: 7px; font-size: 12px; }
/* Settings › About › Open-source licenses: the notices, as written */
.notices-text { margin: 0; font: 11px/1.5 var(--code); white-space: pre-wrap; overflow-wrap: anywhere; }
+20
View File
@@ -17848,6 +17848,23 @@ function askReset(q) {
}
// closes a confirmation, nothing more (its Cancel, or an OK that only dismisses)
function cancelAsk(e) { e.stopPropagation(); closeConfirmAsk(); }
// THIRD_PARTY_NOTICES, which every build carries
async function showNotices() {
let text;
try { text = (await api("notices")).text; } catch (e) { status(e.message, "err"); return; }
const ed = el("div", "editor wide notices");
const head = el("div", "ehead");
head.append(el("b", "", t("Open-source licenses")));
const bar = el("div", "bar");
const ok = el("button", "text primary", t("Done"));
ok.onclick = cancelAsk;
bar.append(el("span", "grow"), ok);
ed.append(head, el("pre", "notices-text", text), bar);
confirmAsk = ed;
openModal(ed);
$("#modal").classList.add("lib");
ok.focus({ preventScroll: true });
}
function closeConfirmAsk() {
if (!confirmAsk) return;
// Escape and the backdrop must not expose row actions while a bulk write
@@ -19592,6 +19609,9 @@ function renderSettings() {
const site = el("button", "text", t("Open"));
site.onclick = () => api("open", { url: "https://usemagpie.ai" }).catch(() => {});
row(t("Website"), t("downloads, docs and what's new"), "usemagpie.ai", site);
const lic = el("button", "text", t("View"));
lic.onclick = showNotices;
row(t("Open-source licenses"), t("the notices of the code and data magpie is built with"), "", lic);
const join = el("button", "discord");
join.innerHTML = DISCORD_SVG;
join.append(el("span", "", t("Join Discord")));
+4 -4
View File
@@ -2542,7 +2542,7 @@ const I18N = {
"Couldn't add the plugin {spec}: {error}": "无法添加插件 {spec}:{error}",
"Library brought in and written into the agents": "资源库已导入,并已写入各 agent",
"{agent} couldn't get {what}: {error}": "{agent} 未能写入 {what}:{error}",
"Website": "官网", "downloads, docs and what's new": "下载、文档和更新内容", "Community": "社区", "questions, ideas and feedback, on Discord or GitHub": "提问、想法和反馈,Discord 或 GitHub 都可以", "Join Discord": "加入 Discord",
"Website": "官网", "Open-source licenses": "开源许可", "the notices of the code and data magpie is built with": "magpie 所用代码和数据的许可声明", "downloads, docs and what's new": "下载、文档和更新内容", "Community": "社区", "questions, ideas and feedback, on Discord or GitHub": "提问、想法和反馈,Discord 或 GitHub 都可以", "Join Discord": "加入 Discord",
"Copy": "复制",
"Copied": "已复制",
"Region": "区域",
@@ -6570,7 +6570,7 @@ const I18N = {
"Couldn't add the plugin {spec}: {error}": "無法新增外掛 {spec}:{error}",
"Library brought in and written into the agents": "資源庫已匯入,並已寫入各 agent",
"{agent} couldn't get {what}: {error}": "{agent} 未能寫入 {what}:{error}",
"Website": "官網", "downloads, docs and what's new": "下載、文件和更新內容", "Community": "社群",
"Website": "官網", "Open-source licenses": "開源授權", "the notices of the code and data magpie is built with": "magpie 所用程式碼和資料的授權聲明", "downloads, docs and what's new": "下載、文件和更新內容", "Community": "社群",
"questions, ideas and feedback, on Discord or GitHub": "提問、想法和反饋,Discord 或 GitHub 都可以",
"Join Discord": "加入 Discord",
"Copy": "複製",
@@ -10598,7 +10598,7 @@ const I18N = {
"Couldn't add the plugin {spec}: {error}": "プラグイン {spec} を追加できませんでした:{error}",
"Library brought in and written into the agents": "ライブラリを取り込み、エージェントに書き込みました",
"{agent} couldn't get {what}: {error}": "{agent} に {what} を書き込めませんでした:{error}",
"Website": "公式サイト", "downloads, docs and what's new": "ダウンロード、ドキュメント、更新内容", "Community": "コミュニティ",
"Website": "公式サイト", "Open-source licenses": "オープンソースライセンス", "the notices of the code and data magpie is built with": "magpie が使用するコードとデータのライセンス表記", "downloads, docs and what's new": "ダウンロード、ドキュメント、更新内容", "Community": "コミュニティ",
"questions, ideas and feedback, on Discord or GitHub": "質問、アイデア、フィードバックは Discord または GitHub で",
"Join Discord": "Discord に参加",
"Copy": "コピー",
@@ -14636,7 +14636,7 @@ const I18N = {
"Couldn't add the plugin {spec}: {error}": "Die Erweiterung {spec} konnte nicht hinzugefügt werden: {error}",
"Library brought in and written into the agents": "Bibliothek importiert und in die Agenten geschrieben",
"{agent} couldn't get {what}: {error}": "{agent} konnte {what} nicht übernehmen: {error}",
"Website": "Website", "downloads, docs and what's new": "Downloads, Dokumentation und Neuigkeiten", "Community": "Community",
"Website": "Website", "Open-source licenses": "Open-Source-Lizenzen", "the notices of the code and data magpie is built with": "die Lizenzhinweise des Codes und der Daten, mit denen magpie gebaut ist", "downloads, docs and what's new": "Downloads, Dokumentation und Neuigkeiten", "Community": "Community",
"questions, ideas and feedback, on Discord or GitHub": "Fragen, Ideen und Feedback auf Discord oder GitHub",
"Join Discord": "Discord beitreten",
"Copy": "Kopieren",
File diff suppressed because one or more lines are too long
+50
View File
@@ -0,0 +1,50 @@
const assert = require("node:assert/strict");
const { test } = require("node:test");
const { chromium, webkit } = require("playwright");
const { fixture } = require("./fixtures/caller-keys.cjs");
const { openPart } = require("./reader.cjs");
// Every build carries moejs's third-party notices (THIRD_PARTY_NOTICES,
// embedded in the binary); Settings › About's Open-source licenses shows
// them whole, scrolled inside the dialog, in every language and at the tray
// panel's width.
const words = {
en: "Open-source licenses", zh: "开源许可", "zh-TW": "開源授權", ja: "オープンソースライセンス", de: "Open-Source-Lizenzen",
};
const text = "magpie third-party notices\n" + "x".repeat(300) + "\n" + "line\n".repeat(400) + "4. V8 (ported code)\n";
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
for (const lang of Object.keys(words)) {
for (const width of [1100, 420]) {
test(`${engine} ${lang} ${width}: About shows the third-party notices`, async (t) => {
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
t.after(() => browser.close());
const page = await (await browser.newContext({ viewport: { width, height: 800 }, reducedMotion: "reduce" })).newPage();
page.setDefaultTimeout(6000);
const errors = [];
page.on("pageerror", (e) => errors.push(e.message));
await page.route("**/*", fixture(lang, "light", []));
await page.route("**/api/notices", (r) => r.fulfill({ json: { text } }));
await page.goto("http://magpie.test/");
await page.locator("#prefs").click();
await openPart(page, "about");
const row = page.locator("#about .row", { has: page.locator(".who", { hasText: words[lang] }) });
await row.locator("button.text").click();
const pre = page.locator("#modal .notices-text");
await pre.waitFor();
assert.equal(await pre.textContent(), text);
assert.equal(await page.locator("#modal .ehead b").textContent(), words[lang]);
// the long text scrolls in the dialog, which stays inside the window
const fits = await page.evaluate(() => {
const d = document.querySelector("#modal").firstElementChild.getBoundingClientRect();
const body = document.querySelector("#modal .ebody");
return { inside: d.right <= innerWidth && d.bottom <= innerHeight, scrolls: body.scrollHeight > body.clientHeight, wide: document.documentElement.scrollWidth <= innerWidth };
});
assert.deepEqual(fits, { inside: true, scrolls: true, wide: true });
await page.locator("#modal .bar button.primary").click();
await page.locator("#modal").waitFor({ state: "hidden" });
assert.deepEqual(errors, []);
});
}
}
}
+8
View File
@@ -0,0 +1,8 @@
// Package notices holds the third-party notices every magpie binary
// carries: THIRD_PARTY_NOTICES at the repository's root, which package main
// embeds and hands over before anything runs. `magpie licenses` prints it,
// and Settings › About shows it.
package notices
// Text is THIRD_PARTY_NOTICES, set by package main.
var Text string
+14 -1
View File
@@ -3,7 +3,10 @@
package main
import (
_ "embed"
"github.com/yetone/magpie/internal/cli"
"github.com/yetone/magpie/internal/notices"
// the built-in plugins, registered with the runtime (internal/pluginrt)
_ "github.com/yetone/magpie/plugins/all"
)
@@ -12,4 +15,14 @@ import (
// Dockerfile, magpie-releases), so it stays in package main.
var version = "dev"
func main() { cli.Main(version) }
// the notices of what is compiled into every build (moejs's Intl data and
// code), carried by the binary itself, since most release assets are a
// bare binary
//
//go:embed THIRD_PARTY_NOTICES
var thirdParty string
func main() {
notices.Text = thirdParty
cli.Main(version)
}
+35
View File
@@ -0,0 +1,35 @@
package main
import (
"os"
"strings"
"testing"
)
// moejs compiles Intl's CLDR, Unicode, ICU and V8 material into every build
// and asks a program that includes it to carry sections 1 to 4 of its
// notices. The binary carries THIRD_PARTY_NOTICES; this holds it to the
// moejs version go.mod builds with, so an upgrade copies the new notices.
func TestNoticesFollowMoejs(t *testing.T) {
b, err := os.ReadFile("go.mod")
if err != nil {
t.Fatal(err)
}
var v string
for _, l := range strings.Split(string(b), "\n") {
if f := strings.Fields(l); len(f) >= 2 && f[0] == "github.com/MoeForge/moejs" {
v = f[1]
}
}
if v == "" {
t.Fatal("go.mod requires no github.com/MoeForge/moejs")
}
if !strings.Contains(thirdParty, "THIRD_PARTY_NOTICES at "+v+",") {
t.Errorf("THIRD_PARTY_NOTICES is not moejs %s's: copy sections 1 to 4 of its notices", v)
}
for _, s := range []string{"1. Unicode CLDR", "2. Unicode Character Database", "3. ICU", "4. V8"} {
if !strings.Contains(thirdParty, "\n"+s) {
t.Errorf("THIRD_PARTY_NOTICES has no section %q", s)
}
}
}