19 Commits
Author SHA1 Message Date
yetone 201bd27706 chat 0.1.14: the model picker is clamped to the room above the composer (qiwiview on X)
positionPop sized the menu from the button's top, but the menu sits above
the composer, so with many models it ran out of the page frame's top and the
first models couldn't be scrolled to. It now measures from the composer's
top, has no 220px floor, and opens downward when that has more room.

Run: new pop-clamp.gui.mjs (60 models, heights 320/420/600/900, chromium and
webkit) on mote: 8 ok. On the old app.js: 8 FAIL, menu top -45 to -50.
Not tried: the live magpie window; bun check.
2026-11-12 07:45:31 +08:00
yetone 740e1af252 tests: grok's nocli puts PATH back when its file ends, so gumloop's Node children find node on CI
publish.yml has been red on main since 7ebab07c (run 43011771755, and
43012668584, 43012789287 after it): 4 of gumloop's regression tests
failed with `Executable not found in $PATH: "node"`, so dist and npm
were skipped and gumloop 0.1.0 and agy-cli 0.1.19 reached neither.

Cause: bun test runs every file of the root run in one process.
packages/grok/nocli.mjs sets PATH=/usr/bin:/bin (and HOME, USERPROFILE,
GROK_HOME, GROK_BIN_DIR) for grok's files and never put them back, so
every file after grok's ran with that PATH. On ubuntu CI node is
actions/setup-node's, under /opt/hostedtoolcache, so gumloop's
spawn("node") found none whenever bun ran grok's files before
gumloop's (CI's order). Locally bun ran gumloop first, so it passed.

Change:
- grok/nocli.mjs: the first noRealGrok of a file snapshots process.env
  and registers an afterAll that puts it back, removing what was added.
- gumloop/regression.test.mjs: node's absolute path is found once with
  Bun.which at load and spawned by path; not found, the Node tests fail
  as before (no skip).
- Siblings the same way (a file-level env change never put back), found
  by a full-run env audit: chat/chat.test.mjs (XDG_CONFIG_HOME pointing
  at its deleted temp dir, MAGPIE_API_KEY/GATEWAY_KEY/ADDR deleted) and
  cursor/calls.test.mjs (XDG_DATA_HOME) now restore them in afterAll.
  window-warmup's fake-gateway.ts/scheduler.test.ts XDG pins are left,
  filed as #996 (fake-gateway is also the --serve demo's).
  Other PATH writers (devin, gcp-ai, grok's own tests, sap-aicore,
  agy-cli, layerfs) already restore theirs; the audit saw PATH change
  only at grok's files.

Ran (magpie-desktop WSL, node only in ~/sdk/node/bin, bun 1.4.2):
- Red first, origin/main: `bun test --randomize --seed=3` (and 5) on
  grok/loop-check + gumloop/regression: the 4 CI failures, same error;
  also with --preload ./packages/grok/nocli.mjs.
- Same seeds with this change: 95 pass 0 fail (new gumloop test plus
  origin/main's copy of it).
- Broken by hand: afterAll(putBack) commented out -> both seeds red
  again, 4 fail.
- Root `HOME=$(mktemp -d) bun test` (with an env-audit preload): 8298
  pass, 19 skip, 0 fail, 8317 tests, 584 files; PATH back to the start
  value at the first file after grok's.
- Touched packages (chat, cursor, grok, gumloop, qoder) after the
  chat/cursor change: 1117 pass 0 fail, each XDG value back to start.

Not tried: ubuntu CI itself before pushing (publish.yml runs it next);
Windows (nocli sets PATH empty there, restored the same way).
2026-11-11 19:53:46 +08:00
yetone 34786edadb qoder 0.2.65: two tool calls at one index with their own ids are two (#930)
Qoder Ultimate sent two native tool calls at tool_calls[].index 0, each
with its own id and name. events() kept one call per upstream index, so
the second call's arguments were sent as more of the first:
{"key":"A"}{"key":"B"}, which the client refused as unparseable JSON.

A fragment with a non-empty id that differs from the open call's id at
that index now starts a new call with an output index of its own. A
fragment with no id, or the open call's id, still goes on with the open
call (OpenAI's argument fragments, and relays that repeat the id). A call
pushed aside before it got a name still counts as nameless (#579).
After two ids at one index, id-less fragments go to the newer call; the
report suggested failing there instead, but OpenAI streams each call's
fragments right after its start, so the newest is the one open.

Siblings with the same index-keyed fold, fixed the same way:
- zed 0.1.19: chatWhole (a streamed chat reply folded for stream:false).
- codearts 0.3.7: completionFromChunks.
- zen-free 0.1.27: stream.mjs chatAccumulator, and tool-response.mjs's
  chat buffer, which gives each call its own index when two collided.
- page-chat 0.1.13: lib/server.mjs folds through toolCallFolder.
Looked at and left: codearts' stream name restorer and kimi-desktop's
Agent hold pass fragments through unchanged and join no arguments;
zed's streaming path passes Zed's chunks through, and magpie's gateway
already starts a new call on a new id (internal/gateway/chat.go).

Run (WSL magpie-desktop, bun 1.4.2, node 22):
- pedh's repro.mjs with his fixture: [0,0] gave one tool event plus an
  args event on 0.2.64; now two tool events (index 0 and 1), each with
  valid JSON. [0,1] unchanged.
- HOME=$(mktemp -d) bun test packages/qoder packages/zed
  packages/codearts packages/zen-free packages/chat: 987 pass, 0 fail,
  1 skip (the epub reader's, as before). bun scripts/check.mjs: every
  package and registry.json ok.

Broken by hand:
- qoder back to index-only: 3 of the new tests fail (two ids, id-less
  after a second id, streaming adapter).
- qoder starting a call on any fragment without the open id: 8 fail,
  the id-less continuation test among them.
- qoder treating any id as new: the repeated-id test fails.
- zed, codearts, zen-free (both) on main's code and chat keyed by index
  only: each new collision test fails (5 of 5).

Not tried: a real Qoder account (no Qoder Ultimate here), real Zed,
CodeArts or OpenCode Zen replies with a collision, and the chat page
in a browser.

Reported-by: pedh <pedh@users.noreply.github.com>
2026-11-10 16:56:37 +08:00
Duhu 36141e381e chat 0.1.12: recall tools from unspaced Chinese questions in large MCP catalogs (duhu2000, #872)
The chat page picks up to 12 tools from a large MCP catalog. It now splits unspaced Chinese into two-character terms instead of treating the whole question as one word. Terms are weighted by how rare they are in the catalog (IDF), and a tool named exactly in the question, hyphenated names included, is boosted to the top. The selection moves into lib/tool-selection.mjs with its own tests. page-chat goes to 0.1.12.

Run at d10e93a62832e31ead84ddef438b615b13935e26 merged onto main 1aab125bf, on a separate macOS machine (bun 1.4.2, sandbox HOME):
- packages/chat `bun test`: 75 pass, 1 skip, 0 fail.
- `bun scripts/check.mjs`: exit 0.
- Root `bun test`: 21 fail and 4 errors in devin, zcode and window-warmup, none in chat. Main 1aab125bf shows the same 21 and 4 in the same tests. The devin and zcode ones refuse a HOME that isn't from `mktemp -d`.
- Broken by hand, one at a time: without the exact-name boost, "exact identifier outranks…" goes red. With IDF replaced by 1, "rare term outranks…" goes red. Without `-` in the Latin term regex, the exact-identifier test goes red.

Version: page-chat is served from the dist branch, where the newest is 0.1.11.
2026-11-09 18:38:39 +08:00
yetone f1421352d2 chat: the epub reader test retries a slow browser start instead of one 15s race (#684)
Cause: the test raced one cold browser launch against a fixed 15s timer.
A passing CI run takes 1.3-1.5s (runs 41710048801, 41709930999, 41689486507);
run 41718344236 took 16.6s, so a cold runner start, not the reader, failed the
test and blocked every package's publish.

Now each try gets its own profile and 10s (7x a normal run); a try that posts
nothing is killed and replaced, up to 3 tries, with the test timeout at 60s. A
browser that exits by itself still fails at once. The test only; no package
file changes, so no version bump (chat's "files" omit tests).

Run on mote (bun 1.4.2, Playwright's Chromium 1234):
- Injected a wrapper browser that sleeps 25s on its first launch: the old test
  fails "browser timed out" at 15.06s, the new one passes in 11.7s.
- Normal launch: new test passes in 2.0s.
- Whole suite: 5349 pass, 19 skip, 0 fail (the browser test skips without a
  browser in PATH; it was run separately as above). bun scripts/check.mjs ok.
Not tried: GitHub's runner itself; CI's run is the check.
2026-11-04 07:23:16 +08:00
ninon 85a6fd5485 chat 0.1.11: attachments reach the model, saves serialized, tool history by round (#645)
By ninondev (#645). Squashed at the reviewed head 764fbfc.

Changes in packages/chat, 0.1.10 -> 0.1.11:
- Attachments reach the model:
  - A .md, .markdown or .txt file, or any text/* file, is sent as UTF-8 text in a 【文档:name】 block. Bad bytes are an error, not mojibake.
  - An image's data URL gets its real MIME type, even when the browser said application/octet-stream or gave no type.
  - Send waits for every upload still in progress, not only the books.
  - A failed upload is dropped with a toast. It no longer goes in as a local copy that skipped the size caps.
- Conversation saves:
  - Writes are serialized per conversation id. Once a delete has gone through, any write still queued is skipped.
  - A new conversation gets its id on the client up front. A save that finishes after the user has switched conversations no longer takes over the open one.
  - Opening one conversation and then another quickly no longer shows the first.
- Tool history:
  - The server sends a "round" event each turn of the tool loop, and the history is replayed round by round.
  - Tool-call ids are unique across rounds (call_<round>_<i>).
  - Each tool result is capped at 60000 chars, the same in the stream and in the history.
  - A stop is checked before each tool call and after the MCP read.
  - A connection-error card is not replayed to the model.
- epub-reader.test.mjs launches Chromium with --use-mock-keychain.

Run at 764fbfc on mote (macOS), each with HOME=$(mktemp -d):
- `bun test` (whole repo): 4857 pass, 14 skip, 0 fail, across 370 files.
- `bun test packages/chat`: 68 pass, 1 skip, 0 fail.
- `bun scripts/check.mjs`: exits 0.
- The epub browser test with EPUB_TEST_BROWSER set to Playwright's Chromium: 2 of 2 pass.
- A review-only end-to-end run (not committed) in Playwright Chromium and WebKit 1.62, at a 1100px width, with the real chat server and a fake gateway:
  - It attaches scene.md (no MIME type) and photo.png (application/octet-stream), types a question and sends.
  - It checks that the gateway got the markdown text, an image/png data URL and the typed text.
  - It reloads, reopens the conversation from the sidebar and asks a follow-up. The history still has the markdown and the image, and there is exactly one saved conversation.
  - All checks pass in both engines. With origin/main's packages/chat the same run fails 8 checks: the markdown and the image never reach the gateway.

Broken by hand:
- Without the per-round tool-call id dedupe, "tool history preserves round order ... repeated IDs" goes red.
- With only the first throwIfAborted removed, the stop tests stay green, because the second check covers it.

Read for harm: no new hosts, no credential or keychain access, no dependencies.
Not tried: a real model or real MCP servers behind magpie's gateway.
2026-11-03 02:45:17 +08:00
ninon 75a1937e23 chat: rank MCP tools using the typed question (#631)
chat: an attached EPUB's text no longer decides which MCP tools are picked (#623)

The page sends the typed text as userText beside the message that has the
book in it, and the server ranks MCP tools on userText when it is there,
on content otherwise. The gateway still gets the whole book; userText is
never sent to it. page-chat 0.1.10. By ninondev (#631).

Run at cb07bd6 on mote (bun 1.4.2, temp HOME): packages/chat bun test
35 pass, 1 skip, 0 fail; scripts/check.mjs chat ok.
Broken by hand: origin/main's server.mjs, then origin/main's app.js,
each alone: the new test goes red (34 pass, 1 fail).
Not tried: the real page in magpie's window with a real EPUB and MCP server.
2026-11-02 18:55:23 +08:00
ninon 63cd0e4bf9 chat: send an EPUB's text with chat messages (#621, ninondev)
Chat (page-chat 0.1.8 -> 0.1.9) can send an EPUB's text with a message. The book is read in the page (chat/epub-reader.js: its own ZIP reader with size, CRC and encryption checks, DecompressionStream inflate, chapters parsed inert in spine order, no external resource loaded, no script run), never uploaded. Each request to the gateway inlines the text once in the user message that carried it, between 【电子书:name】 and 【电子书结束】; the same book again is a note, a failed read is a note and a toast. Send waits while a book is read, and switching chats drops a book still being read. Image-only user messages now stay in history.

Run at 1cb1ecb400fe31bbc1f58463af09af757374d27e:
- CI (pr.yml, ubuntu): HOME=$(mktemp -d) bun test and bun scripts/check.mjs green; the spawned-Chrome reader test ran and passed there (10.5s).
- mote: packages/chat bun test 34 pass; the reader test's own Chrome spawn gets no page load over ssh on macOS (and in WSL), so its fixtures were run again through Playwright 1.62 Chromium and WebKit: 2 pass, 21 expects, each engine.
- End to end on mote, Chromium and WebKit, 420px: startServer with a sandbox config and HOME, a fake gateway, the real page; attached Project Gutenberg's Alice (132,120 chars) and 紅樓夢 (876,576 chars) EPUBs, sent, then followed up. Each gateway request carried the book once, before the question, with no base64 or EPUB data; the follow-up carried user,assistant,user with the book once. The page made no request outside its own service.

Not changed: the MCP tool pick still scores the last message, which on a book's first message is the whole book (filed as #623).
2026-11-02 16:01:29 +08:00
yetone 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.
2026-11-01 12:25:02 +08:00
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
yetone 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).
2026-10-31 12:25:16 +08:00
MagiczerowxyandMagiczerowxy 0b463793be page-chat 0.1.5: README names the settings.json gateway port (#542)
page-chat 0.1.5 documents the gateway port it now reads from magpie's settings.json (#534's follow-up).

The README order now matches chat's code at 20a3898: MAGPIE_CHAT_GATEWAY, then MAGPIE_ADDR, then settings.json's port, then 127.0.0.1:3425. settings.json is listed as read for fonts and the port.

Run: read the diff against packages/chat's gateway lookup at 20a3898. It is docs plus the version bump; no code changed, so no tests were run.

Co-authored-by: Magiczerowxy <Magiczerowxy@users.noreply.github.com>
2026-10-31 10:28:19 +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
Magiczerowxy 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 fdc5002: bun test 3655 pass / 8 skip / 0 fail; bun scripts/check.mjs ok.
- Playwright probe, Chromium and WebKit, against lib/server.mjs with a fake gateway: a reply whose whole SSE arrives in one write, and one paced 30ms apart, both show "Hello there. / Second para." after the stream ends.

Broken by hand:
- finish()'s fallback put back to the old `.md-stable` check: the one-write reply shows "" in both engines (paced still fine).
- server.mjs `const dir = dirArg;` again: "an empty configDir reads the library from the real config folder" goes red (19 pass / 1 fail).

Earlier rounds (4d36cae, both engines): renaming the open conversation survives the next message; a token change reloads the page once; README edited on the original; LF line endings.

Not tried: inside the real magpie window (the probe loads the page from the package's own server).
2026-10-30 01:43:05 +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
yetone 8a9680b4cb page-chat 0.1.1: opened from another machine (magpie web on a server), the launcher explains the SSH tunnel instead of navigating to a refused 127.0.0.1 2026-10-29 13:14:24 +08:00
yetoneandMagiczerowxy 526c7853c3 page-chat 0.1.0: Magic_zero's chat page, with tests, a registry entry and check.mjs for a page's host part
Lists Magic_zero's (Magiczerowxy) magpie-chat as @magpie-community/page-chat:
a chat page in magpie's window over magpie's own gateway, models, MCP
servers, instructions and skills. Not a provider or a relay: it signs in
to nothing and every request goes through magpie's gateway.

- chat.test.mjs starts the service on a free port against a fake
  gateway in a temp config folder: no token (Origin null and none), a
  wrong token, another Origin and a rebound Host are refused and nothing
  reaches the gateway; with the token a chat streams with the caller key;
  the icon redirect has a Location; boot.js makes no request; app.js
  sends the token.
- scripts/check.mjs takes the OpenCode v1 default export {id, server}
  as magpie's host does, and doesn't start a page's server (it would bind
  a port and write config); layerfs's tools are still checked.
- package.json declares the port option (3477) both parts read; boot.js's
  comment says so instead of a fallback to 3478 that never existed.
- README in the repo's style with credit, what the service reads and
  sends, who can use it, and the changes from the original.
- registry.json entry and a row in the Pages table.

Run on mote (bun 1.4.2) at this tree:
- cd packages/chat && HOME=$(mktemp -d) bun test: 11 pass.
- HOME=$(mktemp -d) bun test (whole repo): 3119 pass, 0 fail, 3127
  tests across 261 files; bun scripts/check.mjs: exit 0, chat and
  layerfs ok.
Broken by hand: with the token check off, "a page without the token
can't chat" went red; with the Host check off, "a DNS-rebound Host is
refused" went red.
Not tried: the page in a real magpie window (sandboxed frame navigation
and the host calling server()).

Co-authored-by: Magiczerowxy <magiczerowxy@users.noreply.github.com>
2026-10-29 09:07:44 +08:00
yetoneandMagiczerowxy 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>
2026-10-29 09:03:53 +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