Files
plugins/packages/chat/package.json
T
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

69 lines
2.1 KiB
JSON

{
"name": "@magpie-community/page-chat",
"version": "0.1.11",
"description": "在 magpie 窗口里加一个「对话」页面:用 magpie 自己的模型、MCP 服务器、指令和技能聊天,支持图片与 LaTeX。A chat page inside magpie's window: talk with magpie's own models, MCP servers, instructions and skills, with images and LaTeX.",
"author": "Magic_zero (https://github.com/Magiczerowxy)",
"files": [
"index.mjs",
"lib",
"chat",
"page",
"assets",
"serve.mjs",
"start-server.cmd",
"start-server.vbs",
"install-autostart.cmd",
"install-autostart.ps1",
"README.md",
"SERVE.md",
"LICENSE"
],
"keywords": [
"magpie",
"magpie-page",
"magpie-plugin",
"opencode",
"opencode-plugin",
"chat",
"llm"
],
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/magpie-community/plugins.git",
"directory": "packages/chat"
},
"bugs": {
"url": "https://github.com/magpie-community/plugins/issues"
},
"homepage": "https://github.com/Magiczerowxy/magpie-chat#readme",
"engines": {
"magpie": ">=0.1.1340"
},
"magpie": {
"icon": "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMjggMTI4IiB3aWR0aD0iMTI4IiBoZWlnaHQ9IjEyOCI+CiAgPHJlY3Qgd2lkdGg9IjEyOCIgaGVpZ2h0PSIxMjgiIHJ4PSIyOCIgZmlsbD0iIzRmNDZlNSIvPgogIDxwYXRoIGQ9Ik0zMCAzOGg2OGE4IDggMCAwIDEgOCA4djM0YTggOCAwIDAgMS04IDhINjBsLTE2IDE0di0xNGgtMTRhOCA4IDAgMCAxLTgtOFY0NmE4IDggMCAwIDEgOC04eiIgZmlsbD0iI2ZmZiIvPgogIDxnIGZpbGw9IiM0ZjQ2ZTUiPgogICAgPGNpcmNsZSBjeD0iNDYiIGN5PSI1OCIgcj0iNSIvPgogICAgPGNpcmNsZSBjeD0iNjQiIGN5PSI1OCIgcj0iNSIvPgogICAgPGNpcmNsZSBjeD0iODIiIGN5PSI1OCIgcj0iNSIvPgogIDwvZz4KPC9zdmc+Cg==",
"page": {
"title": "Chat",
"titles": {
"zh": "对话",
"zh-TW": "對話",
"ja": "チャット"
},
"file": "page/index.html",
"icon": "assets/icon.svg",
"service": {
"port": 3477,
"option": "port"
}
},
"options": {
"port": 3477
}
},
"scripts": {
"start": "node serve.mjs"
},
"main": "./index.mjs",
"type": "module"
}