63cd0e4bf92e482cc338a606dea4e208bc20cdb7
8
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
b38ad66551 |
page-chat 0.1.8: the service takes its port once the old host lets go, instead of giving up after 6s (ferock on Discord)
ferock on Discord, after page-chat updated itself to 0.1.7: typing a
system prompt said "保存失败:Failed to fetch", and every message after
failed the same way. The system prompt wasn't the cause. Nothing was
listening on the page's port any more.
magpie swaps plugin hosts when a plugin is updated, installed or set
(Restart, or another magpie's change to plugins.json). An old host that
is still finishing a call (a reply, a tool call) keeps running, up to 10
minutes, and its page service keeps 3477. The new host's service tried
for 6s, threw "3477 一直被占用", and never tried again. When the old
host left, nobody had the port. The page's frame stayed on
127.0.0.1:3477, and every fetch failed until magpie was restarted.
startServer now tries for those 6s (bindTries x 500ms) without holding
up the host. Then it goes on trying once a second in the background
until the port is free, and stops when the service is closed. The page's
next request gets 403 with the new token, and the page reloads itself
as before. index.mjs logs "listening" when the port is bound.
Run (mote):
- Reproduced with real magpie serve (magpie origin/main 36af588e2) in a
sandbox HOME, page-chat on port 3592. A plugin tool that takes 40s was
in flight while page-chat 0.1.6 was auto-updated to 0.1.7 by
KeepUpdated, or while another plugin was added. 0.1.7's service logged
"could not start: 3592 一直被占用", and every save to /api/settings got
000 (no listener) after the old host left, even with a fresh token.
With this change the same run logs "还被占着" and then "listening".
A save gets 403 (new token), and the page's reload saves 200.
- Without a busy host, an update came back on its own (403, reload). So
did saves of Chinese, quoted, multi-line and 50k-char system prompts
and a chat on 0.1.7. None of them failed.
- bun test chat.test.mjs: 31 pass. The two new tests are red on the old
lib ("58585 一直被占用,服务起不来"), checked by hand.
- bun scripts/check.mjs ok.
Not tried: magpie's desktop window (WebKit). The page there was not
driven; its 403 reload path is unchanged.
|
||
|
|
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). |
||
|
|
39de03001d |
page-chat 0.1.6: one switch uses every MCP server in magpie's Library (Magiczerowxy/magpie-chat#4)
ferocknew asked for a way to give new chats every MCP server without ticking each one. The MCP list in the settings sidebar now starts with a switch, "使用 magpie 的全部 MCP 服务器". On, a chat uses every server in library.json, read again on each chat, so a server added to magpie later is in too; the rows show checked and disabled. Off (the default, and what a 0.1.5 settings.json reads as), ticking works as before, and the ticks set before turning it on come back. The whole path: the setting is mcpAll in the service's settings (cleanSettings keeps it, default false). runChat wants tools when mcpAll is on even with nothing ticked, and pickServers() picks every Library server; "检查连接" (/api/mcp/tools) checks the same set. The page sends useTools when mcpAll is on. The service picks servers from the saved settings, while the page saves them 320ms after a change, so send() now saves pending settings before /api/chat; a switch flipped just before sending (or a server just ticked) counts. Run (mote, bun 1.4.2, HOME a temp dir): bun test chat.test.mjs, 28 pass; bun scripts/check.mjs chat ok. Three new tests: a chat against two fake Streamable-HTTP MCP servers gets only the ticked one with the switch off, both with it on and nothing ticked, a third added to library.json after turning it on, and /api/mcp/tools lists all three; a 0.1.5 settings.json reads as off; the page's wantsTools and the save-before-send. Broken by hand: pickServers ignoring mcpAll fails the first two tests; cleanSettings dropping mcpAll fails the same two; useTools back to "mcp ticked" fails the third. Real page, Playwright 1.62.0, 1200 and 760 wide: switch off by default with the old tick, on makes every row checked and disabled, flipping it and pressing Enter saves settings before /api/chat with useTools true, still on after reload, off brings back the old tick, rows clickable. Chromium on mote, 18 of 18; WebKit on Linux (WSL magpie-desktop), 18 of 18, since WebKit on mote didn't launch within 180s (other sessions' WebKit processes were running there). Not tried: a real magpie window with real MCP servers and a real model call (the gateway in the browser run was absent; tool lists came from fakes); stdio servers under the switch (same pick, only http was run); macOS WebKit; languages other than Chinese (the page has no i18n). |
||
|
|
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  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. |
||
|
|
db0a9cdafd |
page-chat 0.1.3: smoother streaming, rename, width sync, English effort names (#498)
page-chat 0.1.3 (Magiczerowxy): streaming renders the settled blocks once and only the tail per frame; conversations can be renamed (PATCH /api/conversations/:id, title only, token-guarded); a Sync switch keeps the conversation and composer widths equal (composerWidth floor 35); effort names in English with xhigh; a draft row for a new conversation; a status line under each reply. An empty configDir now reads the library from the real config folder.
Reviewed at 7c0f68df74bef05ece6f037d574f0c50688c2bb8 (third round; the two earlier reviews' points were checked at this head).
Run on mote (macOS, Bun 1.4.2, Node 22, Playwright 1.62.0), sandbox HOME:
- packages/chat: bun test, 20 pass / 0 fail.
- Whole repo at the PR head: bun test 3284 pass / 8 skip / 0 fail; bun scripts/check.mjs ok.
- Whole repo at the PR head merged with origin/main
|
||
|
|
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 (
|
||
|
|
bdf3bf8405 |
page-chat: a token and a Host check guard the local service; port option honoured
The service on 127.0.0.1:3477 answered Origin: null (any site's sandboxed iframe or a data: page) with ACAO null, and had no Host check, so a hostile page could POST /api/chat on the user's magpie gateway key, read and rewrite conversations and settings, and drive MCP tools; a DNS-rebound page could read conversations with a plain GET. - Every /api/ route except ping, fonts.css and icon/* now needs a per-process token (x-magpie-chat-token, timing-safe compare). The token is put in index.html as a meta tag, and index.html goes out without CORS, so only a page that navigated to the service can read it. app.js sends it on every call and reloads once when the service restarted. - The Host must be 127.0.0.1:<port> or localhost:<port>, checked first. - index.mjs starts the service when the host calls server(), not on import, and passes the plugin option's port, which page/boot.js already read; before, a port set in the options moved the page and not the service. - Port 0 binds a free port (tests); the actual port is used for the Host and Origin lists. - /api/icon's remote icon answered 302 without a Location; it has one. - /api/bootstrap reports the package version instead of "0.1.0". - package.json: 0.1.0 in magpie-community/plugins, author credit, start runs serve.mjs. Co-authored-by: Magiczerowxy <magiczerowxy@users.noreply.github.com> |
||
|
|
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> |