Commit Graph
4 Commits
Author SHA1 Message Date
yetone 5499be8536 page-chat 0.1.7: magpie's own MCP servers that are on are used beside the Library's (ferock on Discord)
ferock on Discord: with "使用 magpie 的全部 MCP 服务器" on, a chat got
only the servers in library.json, never magpie's own web search, image
recognition or image generation.

ownMcp (lib/gateway.mjs) asks the gateway's GET /v1/magpie/mcp (magpie
v0.1.2397) for the ones on now and mounts each at the gateway's address
with the gateway key. readMcp adds them after the Library's, which every
route takes its MCP list from: the page's list (libraryView), a chat's
tools, a tool call and the connection check; a Library server of the
same name (an installed magpie-image) is used in its place. One turned
off in magpie's Settings is left out of the next chat. An older magpie
(404), a gateway that doesn't answer, or a bad reply lists none, as
before. lib/mcp.mjs loadServers (library.json only) is unchanged; the
page calls listTools/callTool with server objects, never by name.

Run (mote): bun test chat.test.mjs, 29 pass; the new test is red on the
old lib (Expected 2 more tools, Received 0), checked by hand.
bun scripts/check.mjs ok. magpie's side was run against its real binary
(magpie commit cac655c14's body).

Not tried: the page in magpie's window against a real magpie with the
switch on (the test drives the page's service with a fake gateway).
2026-10-31 20:38:10 +08:00
Magiczerowxy 20a3898bf5 page-chat 0.1.4: model brand icons, data-URI images only (a remote image is a link), gateway port from magpie's settings.json, by Magic_zero (#534)
page-chat 0.1.4, by Magic_zero (Magiczerowxy). This adds:
- model brand icons in the picker and the transcript, from @lobehub/icons (MIT, chat/icons/models/NOTICE);
- inline images, base64 data URIs only. A remote ![](https://…) image is shown as a link the user can click and is never fetched, so a reply can't send data off the machine through an image URL;
- the gateway port read from magpie's settings.json, read-only and 127.0.0.1 only, after an explicit gateway or MAGPIE_ADDR;
- a switch for the system prompt;
- stdio MCP servers run in a workspace folder of their own;
- code fences kept whole while a reply streams.

The suggestion buttons and the 「模型」 label are gone from the empty state. finish() still renders a reply that arrives in one chunk (the fix from #498).

Run at the reviewed head 8ded766, on the Mac mini (Bun 1.4.2, sandbox HOME):
- bun test: 3871 pass, 0 fail, 9 skip. bun scripts/check.mjs: exit 0.
- A Playwright probe ran the real service against a fake gateway that sends the reply in one SSE chunk, and recorded every request leaving 127.0.0.1. The reply carried md, http, protocol-relative and blob images, HTML img, srcset, picture, inline style url(), a <style> block, a link around an image, a reference-style image, a bare URL, KaTeX \includegraphics and \href, and a data:image/svg+xml with script, onload, <image href> and CSS url(); the probe also opened that SVG in the lightbox. No request left the machine and the reply rendered. Run in Chromium on the Mac mini, and in Chromium and WebKit on Linux (magpie-desktop). WebKit didn't launch on the loaded Mac mini.
- Broken by hand: letting https images through safeImgSrc turns "the chat UI never auto-loads a remote image" red, and the probe records the request to attacker.example. finish() back to checking only .md-stable turns "finish() renders a reply that arrived in one chunk" red, and the probe shows an empty body.

Not tried: the real magpie window, and a portable install's data/settings.json.
2026-10-31 10:10:30 +08:00
yetone 4a46212f89 page-chat 0.1.2: opened from another machine, the page reaches its service through magpie web
aigcfree (Discord DM) runs `magpie web --addr 0.0.0.0:3430` on an Ubuntu
server behind nginx, and opens it from a Windows PC. The chat tab showed
"127.0.0.1 refused to connect": boot.js sent the frame to 127.0.0.1, the
viewer's own PC. 0.1.1 (8a9680b) explains an SSH tunnel instead. With a
magpie that proxies a page's service, no tunnel is needed:

- package.json declares magpie.page.service {port: 3477, option: "port"},
  the same port index.mjs listens on. magpie web then proxies the service
  under the page's token (/_magpie/plugin/<token>/_magpie/service/) and the
  bridge hands that address to the page as magpie.service.
- boot.js goes to magpie.service when it is an http(s) address. Without
  one (the desktop window, or an older magpie) it behaves as 0.1.1: on
  loopback it goes to 127.0.0.1, from another machine it explains the
  tunnel.
- The chat client asks api/... by relative address (app.js, index.html,
  library.mjs's icon URLs), so it works under the proxied path. Served
  from 127.0.0.1:<port>/ these resolve as before.

The service still listens on 127.0.0.1 only, and still checks Host,
Origin and its token. magpie's proxy sets Host to 127.0.0.1:<port>.

Run: bun test packages/chat (16 pass) and bun scripts/check.mjs on mote.
Real: a sandbox magpie web on mote (0.0.0.0, LAN), this package installed
from a folder, a fake gateway. Playwright on the Windows box opened the
chat tab over the LAN in Chromium and WebKit, sent a message, and got the
streamed answer; the fake gateway logged both requests.
Broken by hand: the service branch in boot.js off, 2 tests red.
Not tried: behind a real nginx; the desktop window with this version (the
fallback is the 0.1.1 path, covered by the launcher tests).
2026-10-29 13:26:58 +08:00
yetoneandMagiczerowxy 4193f7410c chat: Magic_zero's magpie-chat page, as published at Magiczerowxy/magpie-chat 15de02d
The files its package.json ships, unchanged, from
https://github.com/Magiczerowxy/magpie-chat at 15de02d (0.1.18). The
vendored KaTeX is katex@0.16.11's dist, byte for byte (checked against
npm's tarball). Not published from this commit: the next ones close the
local service to other pages and fit it to the repo.

Co-authored-by: Magiczerowxy <magiczerowxy@users.noreply.github.com>
2026-10-29 09:01:47 +08:00