Commit Graph
202 Commits
Author SHA1 Message Date
yetone d1f8d8aae7 agent: Cherry Studio adds magpie through its providers link (plugins#865)
Cherry Studio (CherryHQ) shows on the Agents page, and with
`magpie cherrystudio`, on macOS, Windows and Linux. Its row is the link
its main process takes, cherrystudio://providers/api-keys?v=1&data=, with
the gateway at <gw>/v1 as an OpenAI-compatible provider named magpie and
the named key agentKeyAt("cherrystudio"). Cherry Studio asks the user to
confirm it. magpie writes nothing into its store. "Added" is read
untouched from its 2.x database (Data/cherrystudio.sqlite, user_provider),
in the default userData and every one boot-config.json moved it to. A
database or boot-config that can't be read, or a 1.x userData (Local
Storage, no database), is unknown. The data is standard base64, because
Cherry Studio swaps raw + and / before parsing and back after. /api/open
lets that link through. aionui's database status is generalized into
dbStatus{has} so both apps share it. Icon: Cherry Studio's own logo, not
cherryin-color (a different product).

Run (mote, at this change on origin/main c66cdbea9; then rebased on
0f04dca6e and run again: vet of agent/gui/cli, Windows vet of agent/gui,
and the Cherry, AionUi, gateway-key and import-link tests, ok):
- gofmt -l clean; go vet ./internal/agent ./internal/gui ./internal/cli;
  GOOS=linux go vet -tags nogui ./...; GOOS=windows go vet ./...
- go test -tags nogui -count=1 ./internal/agent ./internal/gui
  ./internal/cli: agent and cli ok; gui ok but TestCoreScriptBudget, red the
  same on a clean c66cdbea9 (#4526, 1533856 > 1533802)
- node --test import-row.test.cjs i18n-keys.test.cjs: import-row 20/20,
  chromium and webkit, en/zh/zh-TW/ja/de, and 420px wide; i18n-keys red
  only on "a plugin's words are its own", the same on clean c66cdbea9
  (#5332, #5426, #5482). No new strings.
- TestCherryStudioLinkParsedAs2_1_10 runs the link through 2.1.10's own
  parser (copied into testdata) and the renderer's zod checks, with
  gateways whose base64 spells + and /.
- Real try on mote (macOS 27.2, arm64): released Cherry Studio 2.1.10 in a
  sandbox HOME and --user-data-dir, with a sandbox magpie of this tree on
  127.0.0.1:3561 and a fake upstream. `magpie cherrystudio add` opened the
  dialog with base URL http://127.0.0.1:3561/v1 and the key
  magpie-cherrystudio. Add saved it, turned off as every Cherry provider
  is. `magpie cherrystudio` then said added, read while the app ran (WAL).
  Sync models listed fake/fake-1 from the gateway, and adding it turned
  the provider on. A chat got the fake upstream's reply, and magpie usage
  counted it as Cherry Studio's. A link sent while the first-run welcome
  page was up showed no dialog; after "set up later" it did.

Broken by hand, each red, then restored:
- URL-safe base64: TestCherryStudioLinkParsedAs2_1_10 (baseUrl decoded as
  /x~>/v1 and /xy\x7f?/v1)
- no closing quote/slash on the address match: TestCherryStudioHas
  (another port's provider counted)
- the /api/open prefix dropped: TestCherryStudioImportRow
- Cherry Studio dropped from /api/open's app case:
  TestImportLinkNothingOpens

Not tried: a real run on Windows or Linux (detection is unit tests
only); Cherry Studio 1.x, which reads as unknown; a real vendor upstream
(the try used a fake). Full suite not run at push.

Reported-by: mysterysqwq
2026-11-08 19:09:21 +08:00
yetone 32fc5809e1 agents: OpenMausBot gets magpie as an engine of its own, written as its own Claude endpoints are (a user on X)
A user on X asked for OpenMausBot (github.com/milind-soni/OpenMausBot,
read at 516ca75; released 0.1.145). Its bots run on engines from
`instances` in ~/.openmausbot/config.json ($OMB_DATA_DIR,
server/config.ts:713). Without this, a Claude bot reached magpie only
through ~/.claude/settings.json, and its picker listed Claude's static
models alone: OpenMausBot doesn't read the model from env
(readClaudeModelCatalog, claude.ts:296-316).

- openmausbot.go writes `instances.magpie` in the shape of OpenMausBot's
  own "Claude endpoint" (newClaudeEndpoint, claude-endpoints.ts:91-139):
  - driver claudeAgent, access custom
  - config.configDir is <data>/providers/magpie. Given that,
    OpenMausBot starts Claude Code with that CLAUDE_CONFIG_DIR and
    strips account keys the engine doesn't set (claudeEnvironment,
    claude.ts:111-136, 158-179), so the engine owns its routing.
  - requireApiKey
  - ANTHROPIC_BASE_URL, AUTH_TOKEN, API_KEY and MODEL point at the
    gateway
  - endpointModels holds magpie's models, kept to the ids
    CLAUDE_MODEL_ID accepts. One bad id makes OpenMausBot refuse the
    whole engine (claude.ts:636).
- A non-empty `instances` is the whole fleet (config.ts:1173). With
  none saved, magpie writes DEFAULT_FLEET (instance-fleets.ts) beside
  magpie, stashed as openmausbot.fleet. Off takes the fleet out again
  if the user hasn't changed it.
- What stays the user's: the engine's name, a model they picked from
  the list, their other env and an inherited `cli`.
- Check reports the base URL drifting away from the gateway.
- OpenMausBot reads config.json once at start (index.ts:780), and an
  engine edited in it writes back the fleet it holds
  (routes/instances.ts:132, config.ts:997-1012). So Set is refused
  while it runs (errOMBRunning), and the notice asks to quit it first,
  since Windows can't tell.
- ListOnly, ListsModels, OMB_DATA_DIR in agentenv. The icon is
  OpenMausBot's build/icon.svg (Apache-2.0).
- i18n in zh, zh-TW, ja and de. Docs: reference, agent-wiring, both
  READMEs.
- Codex bots use ~/.codex (codex.ts:373-386), which the Codex wiring
  already covers.
- The agent package's TestMain holds ombRunning false. An OpenMausBot
  open on the test machine refused every test that turns magpie on for
  each agent: my own sandbox OpenMausBot on mote turned
  TestSyncKeepsAnAddressOnAnotherMachine, TestListOnlyAgentsReadConnected
  and TestReverseProxyIsStillMagpie red. With a process named
  openmausbot running, they now pass. LiveAgent's, OpenPencil's and
  NewMax's running checks have the same hole and are left to #5587.

Run (all on mote):
- gofmt -l: clean
- go vet ./... on darwin, GOOS=linux -tags nogui and GOOS=windows: ok
- go build for the same three targets: ok
- go test -tags nogui ./... -timeout 45m at e1453a168 (this change on
  origin/main 30ae0e3f9): 88 packages ok, none failed. Rebased after
  it onto e932cd258, which changes internal/library and adds one GUI
  test only. At the pushed head: go vet of internal/agent and
  internal/library, and go test of internal/agent, agentenv and
  appdir, all ok.
- GUI: the 71 files this change reaches, in chromium and webkit, every
  language they cover: agent-*, agents-*, i18n-*, icon-*, gui-de,
  gui-ja, gui-zh-tw, about-notices, deprecation-notice, header-relang,
  market-icon-corners. 1145 of 1146 pass. The one red is i18n-keys'
  "a plugin's words are its own" for plugins' "Use the library's",
  "No session ID" and "View routing", the same on main and filed
  (#5332, #5426, #5482). The whole GUI suite was started too and
  stopped at 369 ok, 0 failed: at ~5h on mote it runs after this push.

Real OpenMausBot: 0.1.145's arm64 app was run on mote, its own server
(ELECTRON_RUN_AS_NODE, Resources/server/index.js) with HOME and
OMB_DATA_DIR in a sandbox, on a free port, against a config.json
magpie's Set wrote. /api/instances listed 28 engines, among them
`magpie`: access custom, claudeEndpoint at http://127.0.0.1:3425, and
models relay/glm-4.6 and relay/gpt-5.5 in its picker, with the first as
default. It read "unavailable: `claude` CLI not found" only because the
sandbox PATH had no claude. The file was left as magpie wrote it.

Broken by hand:
- The fleet not written: TestOpenMausBotEngine red.
- The model-id filter taken out: TestOpenMausBotEngine and
  TestOpenMausBotKeepsTheUsers red ("relay/glm 4.6 (beta)"). Green
  before a bad id was added to the fixture, so one was added.

Not tried:
- A bot turn through Claude Code to a gateway. No claude CLI or
  account on mote.
- The desktop app's window, Linux and Windows builds.
- An OpenMausBot running while magpie writes. The refusal is
  unit-tested only.
2026-11-07 13:13:36 +08:00
yetone e6b9d1199c readme: Kimi's thanks sits just above the sponsor row
The owner wants the line up top: "Thanks to Kimi for supporting magpie
and the open source community" now sits between the badges and the
Sponsors (赞助商) label, centred like them, in README.md and
README.zh-CN.md. The Acknowledgements (致谢) section 218b38c59 added at
the bottom is gone. Links are unchanged (/go/kimi/readme,
/go/kimi-cn/readme).

Run: no code changed; read the diff of both files.
2026-11-06 17:17:17 +08:00
yetone 218b38c596 readme: Kimi is thanked in its own section instead of the sponsor row
Kimi asked not to sit in a row of gateways. Its logo leaves the sponsor
row in README.md and README.zh-CN.md, and an Acknowledgements (致谢)
section before the license says "Thanks to Kimi for supporting magpie
and the open source community", linked through the same /go/kimi/readme
and /go/kimi-cn/readme redirects (both checked: 302 to kimi.ai/code and
kimi.com/code with aff=magpie). The other five logos keep their order,
three in the first row and two in the second.

Run: no code changed; checked the rows' alt texts and both redirects.
2026-11-06 17:10:35 +08:00
yetone e17c6976b2 provider: Voyage AI preset, its embedding and rerank models (heatonz on Discord)
heatonz on Discord asked for Voyage AI, its embeddings and rerank. The
gateway already had /v1/embeddings and /v1/rerank; what was missing was
a way to add Voyage and have its models found there.

- presets.go: `voyage`, a vendor with an API key at
  https://api.voyageai.com/v1 (docs.voyageai.com, keys at
  dashboard.voyageai.com). Voyage has no /models, so it is NoList and
  the preset names its models in two new PresetDef fields, Embeddings
  (voyage-4-large, -4, -4-lite, code-4, finance-2, law-2, 3-large, 3.5,
  3.5-lite, code-3, code-2) and Rerankers (rerank-3, -3-lite, 2.5,
  2.5-lite), as Voyage's docs list them on 11-06. Region gets
  Rerankers too.
- models.go: planMedia marks each plan model with what it serves
  (catalog.Model.Serves), falls back to the preset's own lists when the
  provider has no region, and PlanRerankers / PlanRetrieval(kind) sit
  beside PlanEmbeddings. A NoList provider's ListAll has them too,
  marked, so catalog.Chat keeps them out of agents' lists, keys and
  Routing's chat pickers.
- gateway: resolveRetrievalModel and servesKind look up the kind asked
  for (PlanRetrieval(kind)) and not only embeddings. Before this, a plan's
  embedding model named on /v1/rerank was sent there, and a plan's
  reranker was never found.
- catalog.ServesOf: `voyage-*` is an embedding model (its ids have no
  "embed"), so Test, detection and a relay serving voyage ids know it.
- test.go / gui providers.go: the retrieval-only Test fallback and the
  editor's "retrieval" count read PlanRetrieval as well.
- docs/reference.md: a new "Embeddings and rerank" section with both
  routes' bodies (OpenAI's for embeddings; the Cohere/Jina/Voyage shape
  for rerank, top_n or top_k) and the Voyage preset. READMEs and the
  import docs pages (en, ja, zh) list it.

Not served: Voyage's contextualized and multimodal embeddings (their own
endpoints). A Voyage 4xx comes back as its raw {"detail": ...} body with
its status (errorSaid has no "detail" reader).

Tests (no network; a fake built from Voyage's documented request and
reply shapes): TestVoyageEmbeddingsAndRerank (bare and provider ids,
input_type/output_dimension and top_k/return_documents passed on, usage
total_tokens recorded), TestVoyageModelsStayOnTheirRoutes,
TestVoyageRefusalSaysWhy, TestVoyagePreset,
TestVoyageTestAsksItsRetrievalAPIs, TestServesOf's voyage cases.

Run on mote: go test -count=1 -timeout 45m ./internal/provider
./internal/catalog ./internal/gui ./internal/gateway. provider, catalog
and gateway ok. gui has one red, TestMainWindowCorners/macOS_26_SDK,
which is #3949 (red on macOS 27); this change doesn't touch AppKit.
go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet
./... ok. gofmt -l clean.

Broken by hand:
- resolveRetrievalModel/servesKind back on PlanEmbeddings:
  TestVoyageEmbeddingsAndRerank red (rerank-3: 404 "magpie knows no
  model"), TestVoyageModelsStayOnTheirRoutes red (voyage-4 on /v1/rerank
  answered 200).
- the voyage- prefix out of ServesOf: TestServesOf and TestVoyagePreset
  red.

Not tried: against the real API. No Voyage key was available, so the
endpoints, auth and shapes come from Voyage's docs alone. Not tried in
the GUI's Add sheet by hand, and not on Windows or Linux beyond vet.
2026-11-06 10:17:08 +08:00
yetone 9d143eacab uninstall: install.sh --uninstall disconnects every agent first, a deleted magpie too
whimsical_wolf_15477 (Discord): after uninstalling magpie, Codex didn't go
back to its own config. `install.sh --uninstall` deleted the magpie command
and app and left every agent wired to a gateway that no longer runs: Codex
kept openai_base_url (or model_provider = "magpie" and model_catalog_json)
pointing at 127.0.0.1. A magpie deleted by hand undid nothing either, and
`--purge` refused with no magpie left to run.

- `magpie uninstall --keep-data` (uninstall.KeepData): every agent
  disconnected and its own values put back from stash.json, the service,
  autostart, shortcut, scheme and helpers removed, magpie's settings,
  providers and usage kept.
- install.sh --uninstall runs `magpie uninstall --yes --keep-data` (--purge:
  `--yes`) before deleting anything, and stops if it fails. With no magpie
  of its own (deleted by hand) but magpie's config left, it fetches the
  newest release into a temporary folder, checks its sha256, runs that, and
  deletes it after. An older magpie without --keep-data gets the newest one
  for this too. A magpie on PATH that the script didn't install is left to
  its own `magpie uninstall`, and said so.
- MAGPIE_UNINSTALL_SCRIPT=1: under the script magpie doesn't ask to delete
  a path that the script deletes next.
- docs (en/zh/ja start.html #uninstall) and READMEs: what the line does,
  that it works for a magpie already deleted, and Codex's lines by hand.

Run (WSL magpie-desktop; mote's disk is full, nothing run or deleted there):
- go test -tags nogui -run "Uninstall|Help|TestKeepData" ./internal/cli/
  ./internal/uninstall/: ok. node --test site/install.test.mjs: all pass.
- The new install tests against the old install.sh: 5 red. Broken by hand
  (--keep-data case removed, Data() back in KeepData): TestUninstallKeepData
  and TestKeepData red.
- Real e2e: magpie built from this tree, Codex wired in a sandbox HOME
  (not signed in, and ChatGPT signed in), magpie installed and deleted by
  hand; install.sh --uninstall with a local feed. config.toml's diff before
  wiring vs after is the [model_providers.magpie] table only (kept on
  purpose for threads started on magpie); model, effort, openai_base_url,
  model_provider and model_catalog_json are the user's again; settings kept.
- gofmt -l clean; go vet GOOS=windows/darwin/linux (nogui) for the two
  packages; sh -n and dash -n install.sh.

Not tried: macOS's zip path for a deleted magpie run for real (tests cover
it with fakes), Termux, Windows (no install.sh there; docs say download
magpie again and use Settings › Uninstall). The full internal/cli package
timed out at 10m under WSL load in providers_unreadable_cli_test (not
touched here); see the full suite record.
2026-11-05 12:52:46 +08:00
yetone c03dee7e3e agent: LiveAgent, magpie's models in its model picker (xiaoxiaofei. on Discord)
xiaoxiaofei. asked for LiveAgent (Stack-Cairn/LiveAgent, v2). LiveAgent 2
is a Tauri app that runs its models through K-brain, a Go backend it
starts as `k-brain backend -data-dir <root>`; every provider lives in
<root>/config.json (JSONC, Pi's provider shape). Root: $LIVEAGENT_HOME,
else $K_BRAIN_HOME, else the folder ~/.liveagent/data-dir.json points to,
else ~/.liveagent, on every OS (LiveAgent's data_home.rs and
kbrain_backend.rs, K-brain's internal/config and internal/storage).

Connect adds providers.magpie: type claude_code + api anthropic-messages
(what LiveAgent's own settings write for an Anthropic-compatible
provider), baseUrl the gateway root (K-brain appends /v1 and posts
/messages with X-Api-Key), the key naming LiveAgent, activeModels null,
modelOrder in magpie's order, models sorted by id with display name,
window, output limit and input [text, image]. K-brain decodes with
unknown fields refused, so only its fields are written. A default or
compact model still K-brain's endpoint-less demo model1 becomes magpie's
first; the user's own pick stays. Through a sync the user's name, the
models they turned off, their order, K-brain's metadata and a model's
own displayName stay; a new model is on and last; nothing to change
writes nothing. A file K-brain wouldn't read as providers (not an
object, providers not an object, top-level models, a bare provider) is
left alone. Disconnect takes the entry out, puts picks back to K-brain's
default, gives a file left with no provider K-brain's demo back (its CLI
restores config.json.bak, which could hold magpie's, from a file with
none), and removes a file holding only what magpie made. LiveAgent's
backend holds the settings and writes them whole on any change, so a
change is refused while liveagent or k-brain runs (macOS/Linux; the
notice says to quit it first, in every language). Logo: the app's own
64px icon (src-tauri/icons/64x64.png, MIT) in an SVG.

Run on mote at this tree:
- gofmt -l clean; go vet ./internal/agent ./internal/agentenv for darwin,
  linux (nogui) and windows
- go test -tags nogui ./internal/agent -run 'LiveAgent|GatewayKey|ListsModels'
  ok; ./internal/agentenv ok; ./internal/gui: only TestCoreScriptBudget
  red, which is red on its base too (app.js untouched here; #5139)
- GUI icon-tile, i18n-keys, agent-notice-lang, gui-zh-tw, gui-ja, gui-de:
  Chromium 27/27, WebKit 27/27
Broken by hand on mote, each red: the user's activeModels not kept
(TestLiveAgentProvider "activeModels after sync [], want [...]"); the
demo provider not put back (TestLiveAgentMakesItsFile "emptied file");
the demo default not replaced (TestLiveAgentProvider, TestLiveAgentMakesItsFile).

Real use on mote (sandbox HOME and LIVEAGENT_HOME, this magpie on
127.0.0.1:3562, a fake Anthropic upstream on 3561, LiveAgent 2.0.5's
bundled k-brain from the release dmg):
- k-brain backend's first start wrote config.json as {}; magpie
  liveagent magpie then wrote providers.magpie and the default pick
- `k-brain run "Reply with exactly: pong"` (K-brain's CLI, same config
  and routing code) answered "pong"; the upstream saw POST /v1/messages
  from magpie
- the backend LiveAgent starts listed magpie's model in /v1/models with
  it as the default, and its /v1/text/generate answered "pong" through
  magpie
- with k-brain running, connect/disconnect were refused with the notice;
  after it quit, disconnect removed the file magpie made
Not tried: LiveAgent's window itself (its model picker was not opened;
the backend's API it reads was); LiveAgent on Linux or Windows; a real
vendor reply (fake upstream).
2026-11-04 18:41:13 +08:00
yetone 5f0a84a003 agent: Air in JetBrains IDEs gets magpie's Magpie agent in ~/.jetbrains/acp.json (Jumy on Discord)
Jumy asked for the "air-plugin" new in IntelliJ IDEA 2026.3 (Settings ›
AI › Air). magpie's air agent wrote the Air app's acp.json, in
~/Library/Application Support/JetBrains/Air, which the IDE plugin never
reads: the plugin (com.intellij.air, air-plugin-262.8665.521-mac-arm64
from JetBrains Marketplace) loads its custom ACP agents in
AcpConfigurationLoader (intellij.air.backend.acp.runtime) from
user.home/.jetbrains/acp.json on every system, the file AI Assistant's
custom agents use too; AgentServerConfig takes command, args, env,
use_idea_mcp and use_custom_mcp. The standalone app (Air-262.1037.14,
Fleet-based) reads acp.json from its own configs folder
(genericAcpConfigPath), so the two are separate files.

Air's own agents have no base URL: JetBrains AI, the agent's own login,
or an Anthropic, OpenAI, Gemini or OpenRouter key under AI › Air ›
Accounts. So the IDE gets the same route as the app: a new air-ide agent
("Air (JetBrains IDEs)", aliases air-plugin, air-in-ides) writes a
Magpie entry (opencode acp, OPENCODE_CONFIG naming magpie-opencode.json
beside acp.json) and nothing else; the user's agents and
default_mcp_settings stay, and disconnecting takes out that entry and
that file. air and air-ide share airAt. air-ide shows for an IDE config
folder of 2026.2 or later (the plugin is bundled from 2026.3), or with
its entry already in acp.json. Notice in en, zh, zh-TW, ja, de; README,
reference and agent-wiring rows.

Run at this head (rebased on ed978e560), on mote:
- go test -tags nogui ./internal/agent ./internal/gui: ok.
  ./internal/cli: TestEveryRouteHasACommandOrIsNamed red, the
  checkin-account route, #4826, not this change.
- go vet darwin, GOOS=linux, GOOS=windows (agent, gui); gofmt -l clean.
- -run Air on Windows (win-run) and Linux (wsl-run): ok.
- GUI i18n-keys, agent-notice-lang, about-notices, agents-last-known in
  chromium and webkit: all pass.
Broken by hand: air-ide on the app's folder fails
TestAirIDEAddsMagpieAgent; a version check of > in place of >= fails
TestAirIDEDetectedByIDEVersion on GoLand2026.2.
Not tried: a real IntelliJ IDEA 2026.3 with the plugin listing Magpie
(the plugin's watcher should pick up acp.json; JetBrains' docs say to
restart the IDE, which the notice says); opencode acp itself was checked
under the app's entry in 5a0559d37, the entry is the same here.
2026-11-02 19:00:29 +08:00
yetone 066ece93bb provider: LongCat is a vendor preset, Meituan's LongCat API platform with chat completions, Responses and Anthropic messages (hoobnn on Discord)
LongCat makes its own models (LongCat-2.5, launched 11-02) and serves them
at api.longcat.chat. magpie had LongCat's icon but no preset for it.

The new preset is longcat ("LongCat", KindVendor, icon longcat, catalog
models.dev's longcat). It uses:
- chat completions and Responses at https://api.longcat.chat/openai/v1;
- Anthropic messages at https://api.longcat.chat/anthropic;
- docs at longcat.chat/platform/docs/zh/api-docs, keys at
  longcat.chat/platform/api_keys.
The key goes as a Bearer. magpie sends both headers, and the docs ask for
Bearer on both endpoints; x-api-key alone gets "missing_api_key". The model
list is /openai/v1/models. longcat.chat's and longcat.ai's accounts use the
same API host (both sites' api-docs pages name api.longcat.chat).

An entry at those endpoints imports as the preset, for example CC Switch's
Claude Code and Codex entries from LongCat's cc-switch page. OpenCode's
auth.json "longcat" (models.dev's id) maps to the preset too. The README
(en, zh), docs/reference.md and the site's import pages (en, zh, ja, and
import.html, with the icon) list it.

Sources, read 11-02: api-docs, api/models, api/model, api/model-params,
api/chat, api/messages, image-video-understanding, cc-switch, pricing/
longcat-2.5, change-log, faq.

Probed without a key, from this machine: /openai/v1/models and
/anthropic/v1/models answer 401 authentication_error "missing_api_key".
/openai/v1/chat/completions, /openai/v1/responses and
/anthropic/v1/messages with a bad Bearer answer 401 "incorrect api key".

Run at this head (base d24be3c25, origin/main at push), on mote:
- TestLongCatPreset and TestLongCatList (the docs' literal /models
  example) pass. TestLongCatPreset goes red with the OpenCode mapping taken
  out ("OpenCode import: … Skip:it has no base URL").
- gofmt -l and GOOS=linux / GOOS=windows go vet ./internal/provider are
  clean.
- go test -tags nogui -timeout 45m ./... is ok except three tests that
  have issues already:
  - TestEveryRouteHasACommandOrIsNamed (#4826) is red on a clean
    d24be3c25 too.
  - TestKeepOffWaitsForTheSetting (#3687) is red on a clean d24be3c25 too.
  - TestCodexPoolSaysTheClientsVersion (#4807) is red in the full package
    run and passes 3 of 3 alone on d24be3c25.
- GUI add-sheet and add-button pass in Chromium and WebKit (12/12). No GUI
  file changed: the add sheet draws presets from /api.

Not tried:
- a real LongCat key or a real request (none available).
- LongCat-2.5's window (1M), output cap (256K) and image input. These come
  from models.dev, which so far lists only LongCat-2.0 and
  LongCat-2.5-Preview, and LongCat's /models gives no facts. Until
  models.dev adds LongCat-2.5, magpie doesn't know them for it.
- LongCat's thinking switch ({"type":"enabled"|"disabled"}).
2026-11-02 13:44:11 +08:00
yetone 611ce90d15 agent: OpenBot, magpie's models in its model picker (jiezhengj)
OpenBot (nightly-labs/openbot, openbot.run, v0.58.0) is a new row on the
Agents page. jiezhengj on Discord asked for it: today they type magpie's
address into OpenBot by hand and add each model one at a time.

OpenBot lists the user's own OpenAI-compatible endpoints from
openbot-custom-providers-v1.json in its userData folder:
~/Library/Application Support/OpenBot, %APPDATA%\OpenBot, or
~/.config/OpenBot. Connecting adds an entry with id "magpie" pointing at
the gateway's /v1 and holding the models picked for OpenBot, with
secret null. OpenBot seals an entry's key in safeStorage, which magpie
doesn't open, so the entry has no key. OpenBot hands it to OpenCode
keyless, and the gateway accepts it as a request from this computer.

What the entry keeps to:
- OpenBot's decoders drop the whole list over one bad entry. So the entry
  has at most 64 models, only ids OpenBot accepts as magpie/<id>, and a
  context window only inside 1,024 to 100,000,000.
- The user's other entries stay. The name, harness and secret they give
  magpie's entry in OpenBot stay too.
- A sync with nothing to change doesn't write.
- A file whose version isn't the number 1, or whose providers isn't a
  list, is one OpenBot refuses itself, so magpie leaves it alone.
- Disconnect takes out magpie's entry, and the file too when only the
  version and an empty list are left.

OpenBot reads the file at start, so while it runs, a notice says to
restart it. The notice is in every language.

OpenBot is detected by its userData folder, OpenBot.app
(app.openbot.desktop), or OpenBot.exe under %LOCALAPPDATA%\Programs or
%ProgramFiles%. Docs updated: agent-wiring.md, reference.md, and both
READMEs.

Run at the pushed head, on mote:
- gofmt -l: clean.
- go vet -tags nogui for internal/agent and internal/gui, and for ./...
  with GOOS=linux and GOOS=windows: ok.
- go test -tags nogui -count=1 -timeout 45m on internal/agent and every
  package that imports it (., backup, cli, davsync, gui, library,
  profile, stats, tui, uninstall, plugins/...): ok.
- GUI: agent-notice-lang, i18n-keys, header-relang and about-notices in
  Chromium and WebKit: 58 of 58 pass.

After rebasing on d20caffae (appdir, i18n.js and gui changed on main), these were run again: gofmt; linux and windows vet of agent, gui and appdir; go test of the same three: ok. The four GUI files plus checkin-now-account: 80 of 80 pass.

Real OpenBot 0.58.0: the arm64 zip, sha512 checked against
latest-mac.yml, notarized by Akudama GmbH. It ran on mote under a
sandbox HOME with --user-data-dir and --use-mock-keychain, on a file
that magpie's own openBotWire wrote.
- OpenBot started without setting the file aside.
- Asked over CDP, window.openbot.customProviders.list() returned magpie's
  entry with all three models and harness opencode.
- Saving another endpoint in OpenBot wrote magpie's entry back unchanged.
- The notice's pgrep pattern matched the running OpenBot.

Broken by hand, each red:
- the 64 cap
- the id filter
- the version check
- keeping the user's name, secret and harness
- writing version 1 into a new file
- the notice's Running check

One break stayed green: dropping openBotWire's own no-change check.
edit.SetJSON already skips a write that changes nothing, so the test
holds at that layer.

Not tried:
- a chat through OpenBot to the gateway. OpenBot's onboarding and its
  OpenCode download were not gone through, so no request reached magpie.
- OpenBot's MCP servers. They live in its SQLite database, which magpie
  doesn't write; magpie's /mcp/magpie/... servers are added by hand.
- Windows. Its install folder is read from electron-builder's defaults,
  not from a real install.
- Linux and the AppImage.
- A request from OpenBot is counted under OpenCode's name, since
  OpenCode sends it.
2026-11-02 05:37:32 +08:00
yetone 5dfbca6274 cli: magpie settings list|get|set|reset, through the window's own save (#4745)
Stage 1 of #4745 (StringKe): every setting POST /api/settings saves can
be read and set from the terminal.

- internal/settingsapi holds the save the handler made: Merge (the
  carry of keys a page leaves out, moved verbatim from api.go, plus
  upstream's RouterNote line), the vision/imageGen/searcher checks,
  settings.Save's own checks, catalog.Touched. POST /api/settings and
  `magpie settings` both call settingsapi.Apply, so a value is checked
  and saved one way. It sits outside internal/gui so the nogui build
  has it.
- `magpie settings` (list, the default, with value, default and
  choices; get; set; reset to settings.Defaults()), --json on list and
  get. Body sends the whole file with one key changed, so a key the
  save keeps when absent (noBird, refusalRetries, ...) is set even to
  off. A flag where a key or value goes, an unknown key (with near
  matches named) or a refused value writes nothing and exits 1;
  --help prints usage.
- Parity guards: TestKeysAreWhatTheSaveWrites (each Settings field sent
  changed on its own; what the save takes must equal Keys),
  TestSettingsCLISetsWhatTheWindowSaves (every key the page's prefsKeep
  and savePrefs send is a key), TestEveryRouteHasACommandOrIsNamed
  (each /api route has a command or a reason in notYet, which later
  stages shrink; 36 have one now).
- Item 3 of the stage (per-provider CLI-only fields in the window) is
  left for stage 2.
- The open app's in-process follow-ups (fonts, Dock, tray menu, alerts,
  language, update re-check) run only from the window's save: #4752.

Run (mote, at the pushed head 1c3591b5d + this):
- gofmt -l; go vet ./...; GOOS=linux go vet -tags nogui ./...;
  GOOS=windows go vet ./...; GOOS=linux go build -tags nogui;
  GOOS=windows go build: clean (before rebase, the vets again after).
- go test internal/settingsapi, internal/settings, internal/cli: ok.
  internal/gui -run Settings|Prefs|Keep after the rebase: ok. The full
  internal/gui run before the rebase had three reds:
  TestSettingsSaveKeepsWhatItDoesNotSend (BusyLoad, fixed on main in
  b646a9127), TestColdTurnsTaken (fixed on main in 647323409) and
  TestMainWindowCorners/macOS_26_SDK (#3949, mote is macOS 27).
- Real run in a sandbox HOME on mote with a magpie built from this:
  settings --help / help, list, get, set theme dark, noBird on,
  redactWords "acme, globex", usageAlert 85; refused theme neon, `them`
  (names theme), usageAlert lots, trayUsageEvery 4, vision
  nobody/nothing, each exit 1 with settings.json unchanged; set
  usageAlert --help printed usage and wrote nothing. Then `magpie web`
  with MAGPIE_WEB_KEY: GET /api/settings read back each value the CLI
  set; POST /api/settings lang ja, then `settings get lang` said ja;
  reset theme gave system.

Broken by hand, each red, then put back: noBird dropped from Keys
(TestKeys, TestBodySetsOneKeyOnly, the CLI set test and the GUI parity
test red); Body dropping false values (TestBodySetsOneKeyOnly and the
CLI "noBird off" check red); a route taken out of notYet and another
renamed (TestEveryRouteHasACommandOrIsNamed red, 3 errors). On the old
code the new tests don't compile (no settingsapi, no command).

Not tried: a real run on Windows or Linux; the live app reacting to a
CLI write while open (#4752); the GUI node suite (no page file changed).
2026-11-01 15:57:43 +08:00
yetone 93879515a0 agent: QwenPaw, each of its agents' active_model one of magpie's (pkh1585 on Discord)
pkh1585 asked for QwenPaw (AgentScope, github.com/agentscope-ai/QwenPaw)
on Discord. Read in its source, 2.2.2.post1, as data:

- Its folder is QWENPAW_WORKING_DIR, else ~/.copaw when that exists (the
  old name), else ~/.qwenpaw; WORKING_DIR/.env is loaded without
  overriding the environment. config.json's agents.profiles lists the
  agents, each with a workspace_dir whose agent.json holds active_model
  {provider_id, model}, read again on each message.
- Providers are no plain config: SECRET_DIR (QWENPAW_SECRET_DIR, else
  "<WORKING_DIR>.secret") holds providers/{builtin,custom}/<id>.json,
  read once at start. A plain api_key there is encrypted to "ENC:" at
  start, so that is the place QwenPaw itself keeps keys.

What magpie does now:

- `magpie qwenpaw <model>` and the GUI: a row per QwenPaw agent
  (qwenpaw#<id>, the default one as plain qwenpaw), skipping agents whose
  backend is ACP (another CLI runs those) and agents turned off.
- Connecting writes providers/custom/magpie.json (mode 600, the gateway's
  /v1 and the magpie-qwenpaw key, magpie's models as extra_models with
  their window, output and tool use) and sets that agent's active_model
  to {magpie, <provider>/<model>}. The old active_model is stashed as it
  was and put back verbatim on disconnect, absent and null included.
  The provider file is removed only when no QwenPaw agent still uses it.
- A sync after QwenPaw re-saved the provider (encrypted key, discovered
  models, its own defaults) keeps what QwenPaw wrote and changes only
  what magpie owns, so a second connect leaves the file as it is.
- The notice says QwenPaw reads providers at start-up: restart it once
  after connecting and after magpie's models change. New text in every
  locale.
- appdir: QWENPAW_WORKING_DIR and QWENPAW_SECRET_DIR take ~/ as QwenPaw's
  expanduser does; agentenv clears them in tests.
- README (en, zh), docs/reference.md, agent-wiring.md, the site's agent
  list and start pages (en, zh, ja), icon.

Run:
- internal/agent's QwenPaw tests (Connect, AgentsAreRows, SyncKeeps-
  WhatQwenPawChanged, Check, NotStartedYet, Folders, OwnModelAfter-
  Magpies, SyncAfterQwenPawSaved, NullModelRestored) on mote, and the
  all-agent tests (applied, rewire, lan_kept, proxy_kept, spelled) with
  a QwenPaw fixture.
- Broken by hand, each red: always rewriting the key
  (SyncKeepsWhatQwenPawChanged), removing the provider while another
  agent uses it (AgentsAreRows), no backend filter (AgentsAreRows lists
  qwenpaw#coder), dropping the keep of QwenPaw's own fields
  (SyncAfterQwenPawSaved), IsObject for Exists (NullModelRestored).
- Real QwenPaw 2.2.2.post1 (Python 3.12 via uv) in a sandbox HOME on
  the Linux box (WSL magpie-desktop), magpie on 3741, a fake OpenAI
  upstream on 3742: first start wrote config.json and agent.json;
  `magpie provider add fake …`, `magpie serve`, `magpie qwenpaw
  magpie/fake/echo-1`; after a restart QwenPaw encrypted the key (ENC:)
  and `qwenpaw agents chat` answered "PAWPAW-OK from the fake upstream",
  its log "built agent … model=magpie/fake/echo-1"; the upstream saw
  /v1/chat/completions model echo-1 streamed, magpie's usage.jsonl
  agent qwenpaw status 200. A second connect and `magpie models` left
  the provider file unchanged. `magpie qwenpaw default` took
  active_model back out (the only diff in agent.json) and removed the
  provider; QwenPaw started clean after.
- gofmt -l clean; go vet darwin, GOOS=linux and GOOS=windows -tags nogui.
- Full suite on mote (go test -tags nogui -count=1 -timeout 45m ./...)
  at 9554883db on d714c4216: 84 packages ok, internal/gui red on
  TestSettingsSaveKeepsWhatItDoesNotSend only (SearchAll from
  b09349d17, red on main, #4514). Rebased onto 15066f84f (an appdir
  change among the four new commits): appdir, agentenv, agent,
  filememo, gateway ok again, gui the same #4514 red; vet darwin,
  linux and windows of agent, appdir, agentenv ok. Rebased again onto
  dd7442f28 (edit, provider and agent changes): edit, provider, agent,
  appdir, agentenv ok, vet linux and windows of agent ok. Rebased onto
  6a23d9d75 (606743831's registry-following agent variables, which
  QWENPAW_WORKING_DIR and QWENPAW_SECRET_DIR now follow as agentenv
  vars): appdir, edit, agentenv, agent ok, vet linux and windows ok.
  Rebased onto 61b536d78 (provider's model lists): agent, appdir ok.
- GUI on mote, the files this reaches (i18n-keys, gui-de, gui-ja,
  gui-zh-tw, agent-connect, agent-layout, agent-notice-lang, brand,
  builtins, desktop-lang, header-relang, icon-tile, icon-url):
  Chromium 103/104, WebKit 59/60, the one red each gui-ja's ja for
  removing an agent's only account (a7b47d57e, #4580). The whole GUI
  suite wasn't run: mote had three other sessions' whole GUI suites
  running (load ~130) and WSL one more.

Not tried: Windows, the macOS desktop app, QwenPaw in WSL wired from
Windows magpie, the ACP backend, QwenPaw's web console after connecting,
a real legacy ~/.copaw.
2026-11-01 05:00:36 +08:00
yetone 2cfb8351d0 install.sh: a Linux desktop without WebKitGTK 4.1 has it installed through sudo, then gets the desktop app (shuhai)
shuhai on Discord, on f68ddca37's hint: "为什么不能帮用户直接装好?" On a
desktop without WebKitGTK 4.1 the installer put in the terminal build and
told the user to `sudo apt install libwebkit2gtk-4.1-0` and run it again.

Now, on a desktop without the libraries (and with --gui), when someone is
at the terminal, the script installs WebKitGTK 4.1 (GTK 3 comes with it)
with the distribution's package manager, says first in one line what and
why, and installs the desktop app:
- apt-get install -y libwebkit2gtk-4.1-0 (Debian/Ubuntu family), and when
  that fails, apt-get update and once more (lists missing or stale);
- dnf install -y webkit2gtk4.1 (Fedora/RHEL family);
- pacman -S --needed --noconfirm webkit2gtk-4.1 (Arch family; no -Sy, so
  no partial upgrade);
- zypper --non-interactive install libwebkit2gtk-4_1-0 (openSUSE).
Through sudo, which asks for the password itself; as root, without it.
"At the terminal" is /dev/tty opening (in a subshell, since a failed
redirection would end the script): curl | sh gives the script the pipe
for stdin, so every package command reads /dev/tty too, never the script.
No terminal, no sudo, the package manager missing, Void/Gentoo/another
distribution, or the install failing: the terminal build and the command,
as before, with "didn't work (see above)" when it was tried. --tui and
MAGPIE_CLI=1 install no package; a headless computer neither.
MAGPIE_TTY points the check at another file for the tests.
Docs: reference.md Install, README en/zh, docs start (en/zh/ja).

Run:
- sh -n, dash -n; shellcheck -s sh: only SC2010 at the uninstall's
  ls | grep, there before.
- site/install.test.mjs, 5 new tests (fake sudo, id and package managers;
  every distro's command, root without sudo, no tty, no sudo on PATH,
  Void, NixOS, a failing install, apt's update-and-retry, --gui, --tui,
  MAGPIE_CLI, headless): red on origin/main's install.sh (the 5 new fail,
  19 pass), green after. CI's site step (sh -n + node --test
  site/*.test.mjs) at this head, rebased on origin/main: 63/63 on mote
  (macOS sh) and 63/63 on magpie-desktop through wsl-run (/bin/sh = dash).
- Real installs in fresh containers (Docker on xiaomi-gpu, amd64), a user
  u with sudo, DISPLAY=:0, `cat install.sh | sh` (stdin a pipe), the
  terminal kept with setpriv (su -c starts a session without one),
  v0.1.2399/2400 from the real feed; then ldd (nothing missing),
  `magpie version`, and the package query:
  - Debian 12, sudo with a password, typed by expect at sudo's prompt,
    package lists deleted first: install failed "Unable to locate", apt-get
    update, retry ok, desktop app, libwebkit2gtk-4.1-0 installed;
  - Ubuntu 24.04 (NOPASSWD): libwebkit2gtk-4.1-0, desktop app;
  - Fedora 44, password via expect: webkit2gtk4.1, desktop app;
  - Arch (archlinux:latest): webkit2gtk-4.1 2.54.2, desktop app;
  - openSUSE Tumbleweed and Leap 15.6: libwebkit2gtk-4_1-0, desktop app;
  - Debian 12 as root: apt-get without sudo, desktop app;
  - Ubuntu 24.04 --gui: installed, desktop app; --tui: terminal build,
    nothing installed;
  - Debian 12 without -t (no terminal): terminal build + the apt line, no
    install tried; without sudo at a terminal: the same;
  - Ubuntu 20.04 (no WebKitGTK 4.1 in focal): install, update, retry all
    fail "Unable to locate", then the terminal build and the "didn't work
    (see above)" hint.

Not tried: a real desktop VM (the containers fake one with DISPLAY=:0);
the installed app wasn't opened, only `magpie version`. Void and Gentoo
stay hint-only (Gentoo would build WebKit from source). Debian 11 failed
in the container's own setup (archives unreachable), so focal stood in
for a distribution without 4.1. A held dpkg lock (unattended-upgrades)
would fail the install and fall back; not reproduced. On focal the hint
still names libwebkit2gtk-4.1-0, which focal lacks, as before.
2026-10-31 21:52:54 +08:00
yetone f68ddca370 install.sh: a Linux desktop gets the desktop app, or the command that installs its WebKitGTK; --gui and --tui choose (shuhai)
shuhai on Discord: on a Linux desktop install.sh installed the terminal
build, and a desktop user expects the app. The script chose by
`ldconfig -p` alone, and on Debian a user's PATH has no /sbin, so
ldconfig wasn't found and every Debian desktop got the terminal build
even with WebKitGTK 4.1 installed. Without the libraries, the only hint
was a line mid-output.

Now, with nothing asked (curl | sh stays unattended):
- the libraries are looked up with ldconfig from PATH, /sbin or /usr/sbin,
  and in the usual lib folders when there is no cache (NixOS, Guix);
  GTK 3 is checked beside WebKitGTK 4.1, which brings the rest the app
  links (readelf -d of v0.1.2359's magpie-linux-amd64: gtk-3, webkit2gtk-4.1,
  soup-3.0, javascriptcoregtk-4.1, glib, X11, wayland-client, glibc);
- libraries there: the desktop app, as before;
- a desktop without them: the terminal build, and last in the output the
  distribution's command (apt/dnf/pacman/zypper/xbps/emerge from
  os-release ID and ID_LIKE), "run this again", or --gui. A desktop is
  DISPLAY, WAYLAND_DISPLAY, XDG_CURRENT_DESKTOP/XDG_SESSION_DESKTOP/
  DESKTOP_SESSION, XDG_SESSION_TYPE x11/wayland, the user's logind
  Display session when its Type is x11/wayland/mir (over ssh; logind
  falls back to a tty login, which doesn't count), or a session file in
  xsessions/wayland-sessions under XDG_DATA_DIRS;
- headless without them: the terminal build, with no desktop advice;
- --gui: the app even before its libraries, with the package to add;
  --tui (or MAGPIE_CLI=1, kept) the terminal build on a desktop too;
- musl (Alpine): always the terminal build; --gui refuses, since the
  app is built against glibc.
Docs: reference.md Install, README en/zh, docs start FAQ (en/zh/ja,
#linux-build).

Run:
- shellcheck -s sh: only SC2010 at the uninstall's `ls | grep`, there
  before this change. sh -n and dash -n clean.
- site/install.test.mjs (5 new tests): 19/19 on mote (macOS sh) and on
  magpie-desktop through wsl-run (dash); CI's site step
  (sh -n + node --test site/*.test.mjs) 58/58 on magpie-desktop and 58/58
  on mote.
- Red on the old install.sh: tests 16-19 fail (desktop advice, headless
  advice, --gui, --tui). With the logind Type check taken out by hand,
  the headless test fails on login "135 tty".
- Real installs on magpie-desktop (Ubuntu 24.04, XFCE, WSLg, /bin/sh =
  dash), `cat install.sh | env ... sh -s`, stdin a pipe, into a /tmp
  sandbox HOME/XDG dirs/MAGPIE_BIN_DIR, each removed after, v0.1.2360
  downloaded from the real feed and `magpie version` run:
  session with DISPLAY/WAYLAND_DISPLAY: desktop app + menu entry;
  env -i with PATH=/usr/local/bin:/usr/bin:/bin: desktop app (the old
  script gave the terminal build here, run the same way);
  an ldconfig whose cache lacks the libs + DISPLAY=:0, and the same in
  env -i (found by /usr/share/xsessions): terminal build + the apt line;
  that with XDG_DATA_DIRS=/nonexistent: terminal build, quiet; --gui
  there: desktop app + the apt line; --tui in the session: terminal build.
  The first run found the tty-login fallback (logind's Display=135 is
  this WSL user's pts session), fixed before commit.
- site/install.test.mjs on Windows (win-run): 0/19, the same 14 old
  tests too: the box has no sh for spawnSync; CI runs this file on Linux
  only.

Not tried: a real Debian, Fedora, Arch or openSUSE box, or a box without
WebKitGTK installed (simulated with a fake ldconfig); the package names
were checked against each index (Ubuntu noble, Debian bookworm, Arch,
Fedora mdapi, Tumbleweed oss, void-packages, Gentoo), not installed. The
installed app wasn't opened (only `magpie version`), to keep off ports
other sessions use there. Termux and macOS paths are unchanged and their
tests pass.
2026-10-31 17:27:55 +08:00
yetone 305c624eda install.sh: --uninstall takes off what it installed, --purge the settings too
pota on Discord: the Linux install script only installs. Now
curl -fsSL https://usemagpie.ai/install.sh | sh -s -- --uninstall
takes off what the script put there, and nothing of the user's:

- Linux: $bin/magpie, the menu entry (while it starts this magpie, or
  one that is gone; another magpie's stays), its icon, the
  x-scheme-handler/magpie=magpie.desktop line xdg-mime wrote (that line
  only), and the menu's mimeinfo.cache when it lists nothing else. The
  service and login entry go too while they start this magpie, since
  left they would start a program that is gone at each login
  (`magpie daemon uninstall`, systemctl as a fallback).
- macOS: magpie.app in /Applications or ~/Applications and the
  ~/.local/bin link into it. Termux: $PREFIX/bin/magpie.
- ~/.config/magpie stays and the script says so. A magpie still
  running is named with its pid; it ends when the user quits it.
- --purge runs `magpie uninstall --yes` first (agents disconnected and
  put back, magpie's folders deleted), then the above. With no magpie
  to ask it refuses, and if magpie uninstall fails nothing of the
  install is taken, so it can be run again.
- Nothing is downloaded; the uninstall runs before the CPU check.

Docs: an FAQ entry "How do I uninstall magpie?" in docs/start (en, zh,
ja), and a line in both READMEs' install note.

Run at 41357f393: node --test site/install.test.mjs worker.test.mjs
stable.test.mjs on mote (53 pass) and install.test.mjs in WSL
magpie-desktop (dash as sh, GNU sed; 14 pass); dash -n ok.

Real run in WSL magpie-desktop (Ubuntu 24.04, WebKitGTK 4.1), sandbox
HOME, env -i, the real 0.1.2345 release from usemagpie.ai:
- install put .local/bin/magpie, applications/magpie.desktop,
  mimeinfo.cache, icons/hicolor/256x256/apps/magpie.png and the
  mimeapps.list line.
- --uninstall, with a settings.json and a text/html line of the user's
  added: removed all of those; left .config/magpie/settings.json, the
  user's mimeapps line and the empty .config, .local/bin and
  .local/share folders.
- install again, then --purge: the real magpie uninstall ran (service,
  login, shortcut, magpie:// links, .config/.cache/.local/share magpie
  deleted), then the binary and the mimeapps line went; left only the
  empty folders and the user's mimeapps.list.
- --purge with no magpie: exit 1, nothing changed.
An earlier run caught that magpie uninstall removes the menu entry
first, which had left the icon and mimeapps line behind; fixed and the
test now covers it.

Broken by hand: origin/main's install.sh turns the four new tests red;
the mimeapps rewrite, the login entry removal and the magpie uninstall
call, each taken out, turn their tests red.

Not tried: macOS and Termux for real (the script's /Applications can't
be sandboxed; the unit test covers Termux's path), a real systemd
user service (a sandbox HOME's unit isn't the user manager's), and a
desktop entry with a quoted Exec path containing a quote.
2026-10-31 16:09:55 +08:00
yetone 0804f2d97d search: Tencent Cloud's Yuanbao Search (wsa) is a built-in search API (plugins#509)
chenjiangzi asked for Tencent Cloud's WSA SearchPro (元宝搜索). It is added
as vendor "wsa", following Doubao Search (dca3e2d71), from Tencent's
own docs:
- API-key method (cloud.tencent.com/document/product/1806/130615):
  POST https://api.wsa.cloud.tencent.com/SearchPro with
  Authorization: Bearer <key> and a JSON body {"Query", "Cnt": 10}.
  Keys come from console.cloud.tencent.com/wsapi/index (KeysURL).
- SearchPro (121811): Response.Pages is an array of JSON strings, each
  with title, url, date, passage and content. The text is passage, or
  content when passage is empty or only the title. Tags are stripped.
- Errors (121818/121820, 130615): HTTP 200 with Response.Error{Code,
  Message}. AuthFailure*, UnauthorizedOperation and ResourceNotFound are
  turned away (403); ResourceUnavailable (欠费), LimitExceeded and
  ResourceInsufficient are out of credit (402); RequestLimitExceeded* is
  rate limited (429); others are plain errors, with the key masked.

The fixtures in testdata are the docs' two example replies. 130615's is
shown with its quotes escaped twice, which isn't JSON; they were
unescaped once and nothing else changed. The GUI's picker is built from
SearchVendors, so no GUI file changes. README (en, zh), the CLI help and
gateway-routing.md name it.

Run on mote (mote-run), at the rebased head:
- go test -run 'SearchAPI|WSASearch|Volcengine|Search' ./internal/gateway/
  ./internal/gui/
  ./internal/provider/ ./internal/cli/: ok
- go vet -tags nogui darwin/linux/windows: ok; gofmt -l clean
- GUI (no GUI file changes; the picker reads SearchVendors):
  search-api.test.cjs in Chromium 4/4 ok. Its WebKit cases and
  searcher-pick timed out at browserType.launch (180s) on mote,
  where ~57 WebKit pw_run launches from several sessions hang. Not
  a result about this change; WebKit not run.

Broken by hand, each made TestWSASearchAPI red: the wsaSearchError call
removed, and Cnt dropped from the body.

Not tried: the real API. No WSA key was available, so the request,
reply and error mapping rest on Tencent's docs only. The full go test
./... is to follow.
2026-10-30 14:56:01 +08:00
yetone dca3e2d716 search: Doubao Search (Volcengine) as a search API (CyberCaius on Discord)
CyberCaius asked on Discord #help (10-30) for Volcengine's Doubao search
under Settings › Models › Search APIs, or a custom API address. Volcengine's
Doubao Search Custom (豆包搜索 Custom版, once 联网搜索 / 融合信息搜索,
docs.volcengine.com/docs/networked-search/networked-search, the same page
as volcengine.com/docs/87772/2272953) can now be added with its API key:

- provider.SearchVendors: volcengine, "Doubao Search (Volcengine)", at
  https://open.feedcoopapi.com, keys at
  console.volcengine.com/search-infinity/api-key, after DeepSeek. The GUI
  takes its vendors from SearchVendors, so it shows in the Search API
  picker with its Get a key link and base URL field; no GUI file changes.
- askSearchAPI: POST /search_api/web_search, Bearer key (the default, as
  the docs and volcengine/mcp-server's askecho_search_infinity send it),
  body {Query, SearchType: "web", Count: searchHits, Filter: {NeedUrl:
  true}}. The query is cut to the 100 characters the docs allow. NeedUrl
  leaves out its 火山如意 cards, which have no URL to cite.
- readVolcSearch reads Result.WebResults: Summary as the page's text (the
  docs recommend it for models; Content is the whole page, Snippet
  ~200 chars "only for list display"), Snippet when there is no Summary,
  PublishTime as the page's age, a 1970-01-01 time (its image example's
  stand-in) as none, and a result with no Url left out.
- volcSearchError: its errors are in ResponseMetadata.Error, a code the
  docs list, and the docs don't say the HTTP status, so the code decides:
  10401/10403/10409 rest the key as turned away (403), 10406/10408/
  10410/10412 (free searches spent with none paid, no plan, plan spent)
  as out of credit (402), 700429 as rate limited (429). Any other code is
  a plain error, a 200 carrying one included. The key is masked in the
  error as for every vendor.
- A custom address: every search API already takes a base URL (#1580,
  the field under the key in Settings, url= in the CLI), so an endpoint
  that answers as Tavily, SearXNG, Brave, Exa, Firecrawl, You.com,
  DeepSeek or now Doubao Search does can be set there. There is no common
  format across the vendors (each has its own path, body and reply), so
  no separate "custom" vendor was added.
- Siblings: CLI usage (main.go, search_cli.go's api list and empty-state
  hint), README.md, README.zh-CN.md, gateway-routing.md's path list and
  refusal paragraph.

The test's reply is the docs' own web-search response example, byte for
byte (testdata/volcengine_web_search.json); its error replies are the
docs' error example with its "// 该字段为错误码" note taken out (not JSON).
Not tried against the real API: no Volcengine search key in this run.

Run (worktree on origin/main c941e0877, then rebased on d31710c71):
- TestVolcengineSearchAPI (new): red on the old code (no such vendor).
  Broken by hand six ways, each red with its own message: Summary not read
  (Snippet's text), volcSearchError not called (200 10403 read as "no
  Result in it"), query not cut (150 characters went), NeedUrl dropped
  (body {"Filter":{}}), 1970 age kept, 10412 not mapped (plain error, not
  a refusal). Restored: ok.
- go test -run Search ./internal/gateway/, go test ./internal/provider/
  ./internal/cli/: ok, before and after the rebase.
- gofmt -l internal: nothing. go vet -tags nogui ./... on darwin,
  GOOS=linux, GOOS=windows: ok.
- Not run before the push: the full go test ./... . mote had three other
  sessions' full suites running at load 140-230; it runs after the push
  and its result goes on the report.
2026-10-30 13:28:45 +08:00
yetone 3c6b7d585f agent: OpenClaw is wired up like the other agents
arthur041691 (Discord #help) runs OpenClaw for WhatsApp and asked for it in
Agents. Connecting writes magpie as a custom provider of OpenClaw's own, in
openclaw.json, and makes the picked model agents.defaults.model's primary.

What is written, from OpenClaw's source at 5bab0c14 (npm 2026.10.8, dc2523e):
- the file: OPENCLAW_CONFIG_PATH, else $OPENCLAW_STATE_DIR/openclaw.json,
  else ~/.openclaw-<profile> for a named OPENCLAW_PROFILE, else
  ~/.openclaw; ~ is OPENCLAW_HOME when set (src/config/paths.ts,
  src/config/state-dir.ts, src/cli/profile-utils.ts). OPENCLAW_PROFILE is
  a name, not a path (agentenv.NotPaths); the other three expand a
  leading ~, as resolveUserPath does (appdir.usable).
- models.providers.magpie: baseUrl (the gateway's /v1), apiKey (the
  OpenClaw-named gateway key), api "openai-completions", and every model
  magpie serves with id, name, input, reasoning and contextWindow
  (src/config/zod-schema.core.ts, docs/gateway/config-tools/custom-providers.md).
  A user's own keys on a model entry (headers, maxTokens…) stay on Sync.
- agents.defaults.model keeps its shape (string or {primary, fallbacks});
  agents.defaults.models gets the ref's {} entry as `openclaw models set`
  adds it (src/commands/models/shared.ts), only when that map exists; a
  non-empty modelPolicy.allow gets "magpie/*" when nothing there lets
  magpie's models in (src/agents/model-selection-normalize.ts).
- Model changes are hot-reloaded (docs/gateway/configuration/hot-reload.md);
  a chat that already has a model keeps it (docs/concepts/models.md), so
  the notice says to send /model default there. Translated in every
  language.
- The file is written through temp-and-rename; a new one is 0600 in a
  0700 folder, as OpenClaw makes it (src/config/io.write.ts). A file that
  isn't JSON after comments are blanked (JSON5's bare keys) is left alone
  with an error, never read as empty.
- Disconnect puts back the model there was, removes magpie's provider,
  its {} entries, the allow entry and any object magpie made, and the
  file itself if magpie made it.

Icon: a mask drawn from OpenClaw's ui/public/favicon.svg (MIT).

Run, on mote at this tree:
- go test -tags nogui ./internal/agent -run OpenClaw plus the every-agent
  tests (drift, port move, sync on another machine, reverse proxy, LAN,
  pinned key per writer, notices translated), ./internal/appdir,
  ./internal/agentenv: ok.
- Broken by hand, each red then green again: no stash restore
  (TestOpenClaw, Shapes, AllowList), user keys dropped
  (SyncKeepsTheirs), no allow entry (AllowList), no JSON5 guard
  (JSON5LeftAlone), profile ignored (Paths), OPENCLAW_PROFILE back as a
  path variable (Paths).
- Real OpenClaw 2026.10.8 from npm, Node 24.22.2, sandbox HOME on mote:
  onboard --non-interactive made the file (its bytes are the test
  fixture); magpie's code connected it; `openclaw config validate` ok;
  `openclaw models list` shows magpie/kimi/k2 as default; `openclaw agent
  --local` sent POST /v1/chat/completions with Bearer magpie-openclaw and
  model kimi/k2 to a fake gateway on 3425 and showed its reply; no
  agents/*/models.json override was written; Disconnect gave the file
  back byte for byte and it validates.
- GUI: i18n-keys, agent-notice-lang, icon-tile, about-notices,
  agent-connect (Chromium and WebKit): 53/53.
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows ok.
- Full suite, go test -tags nogui -timeout 45m ./... at fe05f0a72 + this
  change: 76 packages ok; internal/provider red on
  TestClaudeAccountServesModelsListedSinceItsFetch only, green alone
  -count=5: the known #3174 (untouched here).
- Rebased on b2d005bf3 (grok.go, i18n.js changed there): internal/agent,
  appdir, agentenv, gui and the five GUI files above again, all ok.

Not tried: per-agent model overrides (agents.list[].model), a config
split with $include, a chat already pinned to a model, Windows and Linux
OpenClaw installs, a real WhatsApp channel.
2026-10-29 05:06:50 +08:00
yetone b2d005bf38 gateway: a MiniMax API key makes videos with H3 (_tigerqueen_05867)
A MiniMax API-key provider (api.minimax.io, api.minimaxi.com, api.minimax.cn)
now lists MiniMax-H3, -H3-Highspeed, -H3-Lite and -H3-Max as video models.
They are never in chat lists. generate_video and /v1/videos start a task at
<host>/v2/video_generation, poll /v2/query/video_generation/<id> and hand back
the MP4. The prompt, seconds (raised to each model's minimum and capped at
15), resolution (from Extra or size, clamped to the model), ratio, first and
last frame and up to 9 reference images go through. /v1/videos now reads
last_frame; MiniMax and a remote magpie pass it on, other videomakers
ignore it. The MCP schema is unchanged.

Failures say which one it is: a turned-away key (1004/2049/401), no
pay-as-you-go balance (1008/402), refused input or output (1026/1027), a
Token Plan key without H3 (2061/2068/2057, which moves on to the next key),
or the rate limit. AutoVideomaker puts MiniMax last, so generate_video,
which has no model argument, uses MiniMax-H3 only when nothing else makes
videos. All of it is gated on a MiniMax host, so no other vendor changes.

Run on mote at 798c8fd48 (base a0ba8e1f2). The pushed head's only other
change is fb5959553, one test file in internal/usage, which none of these
packages import:
- gofmt -l: nothing listed.
- go vet ./... (darwin), GOOS=linux -tags nogui, GOOS=windows: ok.
- go test -tags nogui -timeout 45m ./internal/gateway ./internal/provider
  ./internal/imagemcp: ok (gateway 557s, provider 95s, imagemcp 6.5s).

The fake server answers with the literal samples from MiniMax's docs (create,
succeeded, failed 1026, 401, 402, 422), plus a task stuck past the timeout.

Broken by hand, each watched go red:
- no Videomakers hook (the old code): TestMiniMaxKeysMakeH3Videos,
  TestMiniMaxH3IsNoChatModel, TestImageMCPMakesMiniMaxVideos.
- minimaxWhy returning "": TestMiniMaxVideoFailuresSayWhy.
- MiniMax not put last: TestMiniMaxComesAfterOtherVideomakers.
- no move past a Token Plan key: TestMiniMaxVideoMovesPastATokenPlanKey.

Not tried:
- the real MiniMax API: no MiniMax key is on this machine. The bodies follow
  the docs' samples only.
- the GUI: nothing changed there (it lists no video models per provider).
- test runs on Windows and Linux; vet only.
- last_frame from the MCP tool, whose schema doesn't take it.
2026-10-29 04:56:46 +08:00
yetone 6ecc65b6db agent: the CodeBuddy IDE is CodeBuddy too, found with no CLI
bjzhangwn on X: magpie supported CodeBuddy only as its CLI, not the IDE.
The CodeBuddy IDE (4.12.2, codebuddy.ai's CodeBuddy.app,
com.tencent.codebuddy, and codebuddy.cn's CodeBuddy CN.app,
com.tencent.codebuddycn) reads the file magpie already writes for the
CLI: its genie extension's CustomModelsProductProvider loads
~/.codebuddy/models.json's "models" (a string id and url each) and
"availableModels", and lists them in its own picker. So one row,
renamed CodeBuddy, stands for both. desktopApps gets a "codebuddy"
entry, with a "more" list for the second build's bundle id. A `sign`
lists the row with only the IDE installed. That row shows the IDE's
version, is never "CLI not found", and the CLI isn't offered for install.

Tests: TestCodeBuddyIDEIsCodeBuddy uses the real Info.plist bytes of
both builds, cut to their first keys. TestCodeBuddyIDEReadsMagpieModels
reads the written models.json the way the IDE's loader does.

Run (mote, macOS 27):
- gofmt -l: clean.
- GOOS=linux and GOOS=windows go vet of ./internal/agent/... and
  ./internal/sessions/..., plus GOOS=windows -tags nogui ./internal/gui:
  ok.
- go test -timeout 45m -count=1 ./... at d4f1d6480 plus this change:
  76 packages ok. One red, internal/gui TestMainWindowCorners/macOS_26_SDK,
  is #3949 (macOS 27, same output, untouched here).
- Rebased on origin/main 2ff85f8a2: internal/agent and internal/sessions
  ok again at the pushed head.
- Broken by hand, TestCodeBuddyIDEIsCodeBuddy goes red each way: with
  the sign off, and with the CN bundle id wrong.

Real app: the 4.12.2 builds (intl, then CN) ran on mote under a sandbox
HOME with --user-data-dir. Both logged "Loaded custom models config from
user: <home>/.codebuddy/models.json, valid=1" for magpie's entry.

Not tried:
- Hot reload is unconfirmed. In the not-signed-in sandbox, neither a
  rename nor an in-place edit made it load again (the cloud product
  fetch never finished), though its code fs.watches the file and
  debounces a sync.
- No chat through the gateway: it needs a CodeBuddy sign-in.
- The IDE's Windows and Linux install paths, so off a Mac it is found
  by ~/.codebuddy alone.
- The IDE ignores CODEBUDDY_CONFIG_DIR.
2026-10-28 22:48:07 +08:00
yetone f95121dd05 README: sponsors in two rows of three, each logo in an equal slot
Six logos wrapped onto a row of five and a lone AIGoCode. Now a <br>
after the third, and every logo is width=144 height=36 so the columns
line up (SVGs keep their ratio inside the box). AIGoCode's PNG is
640x170, which would stretch at 4:1, so the READMEs use a copy padded
to 680x170 (light and dark); the home page keeps the original.

Run: mote-run node --test site/*.test.mjs, 45/45 pass. Rendered the
rows in headless Chrome on a dark background and checked the columns line up.
Not tried: GitHub's own render (it goes live with the push).
2026-10-28 16:02:07 +08:00
yetone dfb73a04ef site, README: AIGoCode's dark logo in dark mode
AIGoCode sent the logo on a navy background; the navy is taken out to
transparency (colours un-blended at the edges) and the logo is placed in
the light PNG's 640x170 box, so the card doesn't move between themes.
Checked by eye over a dark and a white background.
Ran: node --test site/*.test.mjs on mote, 45/45 pass.
2026-10-28 15:52:01 +08:00
yetone 0f053024f5 README, site: link Apache Magpie and the ASF in the not-affiliated note
Jarek Potiuk (Apache Magpie PMC) suggested linking magpie.apache.org and
apache.org instead of naming them, to avoid any other confusion. Both
READMEs and the site footer (en, zh, ja, de) now link them.

Run: node --test site/*.test.mjs on mote, 45 of 45 pass.
2026-10-28 07:25:32 +08:00
yetone dc1cfe0156 site: AIGoCode on usemagpie.ai's Sponsored by and in the READMEs
AIGoCode took the home and README seats together (paid, Wise USD).
A fifth home card after SoleAPI, and a logo at the end of the Sponsors
row in README.md and README.zh-CN.md.

The logo is the 1280x368 PNG AIGoCode sent, cropped to its content and
scaled to 640x170. Its blue and purple mark sits on transparency and
reads on white, #1c1c1e and GitHub's #0d1117, so one copy serves both
themes. The en and zh taglines are AIGoCode's own; ja and de are
translated from them.

/go/aigocode/home sends the browser to https://www.aigocode.net/ and
/go/aigocode/readme to https://www.aigocode.net/invite/MAGPIE, the link
AIGoCode gave for the README (first top-up bonus).

Not tried: AIGoCode's API in a real agent. The owner chose to go live
without a test key; neither seat puts AIGoCode in the app.

Run: node --test site/*.test.mjs (45 pass). Logo rendered on light and
dark backgrounds and looked at.
2026-10-28 05:02:45 +08:00
yetone 5a9fb36a10 README, site: magpie is not affiliated with Apache Magpie or the ASF
Apache Magpie's PMC asked about the shared name. magpie keeps its name
(a common word, thousands of older projects use it) and says plainly it
is not affiliated with Apache Magpie or the Apache Software Foundation:
a line under License in both READMEs and in the site footer (en, zh,
ja, de).

Ran: node --test site/*.test.mjs (45 pass).
2026-10-28 00:40:23 +08:00
yetone e7173958e9 agent: NewMax, magpie's models in its model picker (jwaitq on Discord)
jwaitq asked in #general (10-27) for NewMax (newmax.cc), an Electron app
built on the Claude Agent SDK. NewMax keeps its settings in
~/.newmax/newmax.db ($NEWMAX_USER_DATA_DIR wins), a SQLite table
settings(key, value) whose "app" row is JSON.stringify of every setting.
Connect adds one Anthropic-format provider, id magpie-gateway, with
magpie's gateway root (NewMax adds /v1/messages itself), its key and up to
20 models (NewMax's MAX_MODELS), appends it to providerOrder and, when
the user had kept NewMax's default, picks it. The row is edited by
splicing raw JSON in one immediate transaction, so every other byte the
user has stays as written. Disconnect removes the entry and its order id,
puts providerId/model back to "default" when they were magpie's, and
deletes the row when magpie made it. NewMax holds settings in memory and
writes the whole row on any change, so magpie refuses to write while
NewMax runs (macOS/Linux, matched on the program, not on a folder named
newmax) and says why in every language.

Run:
- go test -tags nogui -count=1 -timeout 45m ./internal/agent
  ./internal/agentenv ./internal/appdir ./internal/sessions at this head
  (rebased on 5e3dd1d52): ok
- gofmt -l clean; go vet darwin, linux (nogui) and windows on the touched
  packages
- GUI i18n-keys and agent-notice-lang, Chromium and WebKit: 15/15 each
Broken by hand, each red: user entry's name/off overwritten
(TestNewMaxProvider), running check removed (TestNewMaxLeavesAlone), row
kept after off (TestNewMaxMakesItsRow), pick left on magpie
(TestNewMaxProvider), no model cap (TestNewMaxModelCap), the first
process pattern that matched a shell in a newmax folder
(TestNewMaxProcess).

Real use: NewMax 1.1.22 (macOS dmg) in a sandbox HOME and
NEWMAX_USER_DATA_DIR, with this magpie on a sandbox port. Connect was
refused while NewMax ran; after quitting it wrote the row; on relaunch
NewMax's picker listed and picked magpie's models, its ClaudeProxy sent
to magpie's /v1/messages, and "Reply with exactly: pong" came back
"pong" through magpie to a fake Anthropic upstream. NewMax's own 58KB
row afterwards (47 providers) kept magpie's entry as written; disconnect
then removed only that entry, its order id and the pick
(live/deepseek/deepseek-flash -> default), every other byte the same.

Not tried: NewMax on Linux or Windows (Windows has no running check, as
pgrep isn't there); a real vendor reply through NewMax (the sandbox used
a fake upstream).
2026-10-27 11:03:41 +08:00
yetone 3fd7e16983 agent: PenguinHarness is installed from the Agents page and served by magpie with nothing to set up
rankyurky asked on Discord #feedback for PenguinHarness (npm
@prismshadow/penguin-cli, command penguin). Every value comes from
Penguin's own source (0.2.17):

- Config: $PENGUIN_HOME (else ~/.penguin/data, every OS) /
  $PENGUIN_PROJECT_ID (else default_project) /.project_config.toml.
  magpie writes [providers.magpie] (base_url, client_type, api_key),
  one [[models]] entry per magpie model (context_window, vision,
  max_tokens, [models.pricing] in usd_per_mtok) and default_model in
  Penguin's own inline spelling. Penguin's server reads the file again
  when its mtime changes, so no restart; a default naming no entry is
  refused by Penguin, so Check fails when one is missing.
- A file magpie creates is 0600 in a 0700 folder, as Penguin keeps it.
  Disconnect restores the user's own default_model (or none), drops a
  magpie vision model, and removes the file when magpie made it.
  Penguin's own entries, providers and command_policy rules are kept.
- A sync that changes nothing writes nothing (bytes and mtime kept), so
  Penguin's watcher isn't woken.
- Install: curl -fsSL https://penguin.ooo/install.sh | sh, or
  irm https://penguin.ooo/install.ps1 | iex on Windows; update: npm, or
  penguin update --yes for the tarball, except on Windows where
  update.ts refuses it.
- WSL: a penguin kind with no restart notice; the WSL test now expects
  an empty Notice for a kind with no restart.
- agentenv: PENGUIN_HOME, PENGUIN_PROJECT_ID; the project id is in
  NotPaths, or appdir dropped a value like "work" as a relative path.
- edit.SetTOMLArrayTables: replaces every [[name]] entry with key =
  value (with child tables) by blocks, or removes them; blank lines
  between replaced entries go with them, and an unchanged result isn't
  written.
- GUI: penguin-color.svg icon; README (en, zh-CN), docs/reference.md
  and docs/subsystems/agent-wiring.md.

Run (worktree at ca9b5048e, GOMODCACHE/GOCACHE pinned):
- go test -tags nogui -timeout 45m ./internal/agent ./internal/edit
  ./internal/agentenv ./internal/appdir ./internal/usage: all ok but
  TestWSLMoreAgentsPick (penguin has no restart notice), fixed in the
  test; rerun -run 'TestWSL|TestPenguin|TestEveryAgent|TestFolderVars|
  TestEveryNotice' ok.
- internal/gui: TestCoreScriptBudget, TestAssetTypesHoldAgainstTheRegistry,
  icon and i18n guards ok; no budget raised.
- GUI Playwright, chromium and webkit: i18n-keys, getting-started,
  agent-cli-missing, agent-update-all, gui-ja, gui-de, gui-zh-tw:
  123 tests, 123 pass. The icon renders in colour in both engines.
- gofmt -l internal/ clean; go vet -tags nogui ./... with GOOS linux,
  windows and darwin clean.
- Real Penguin 0.2.17 (npm, Node 25) in a sandbox HOME against a sandbox
  magpie serve and a fake upstream: penguin run -m "Say PONG" answered
  "PONG from fake" through magpie (usage agent "penguin",
  /v1/responses -> /v1/chat/completions); switching the model in magpie
  took effect with no Penguin restart; a no-op sync kept bytes and
  mtime; magpie penguin default restored the user's custom/my-own and
  left no magpie line; with no prior file it was created 0600 and
  removed on disconnect. The fixture is the file Penguin itself wrote.

- Rebased on origin/main d9a8148d7 and run again there: internal/agent -run
  'TestPenguin|TestWSL|TestEveryAgent|TestFolderVars|TestEveryNotice|
  TestSync', internal/edit, internal/agentenv and the internal/gui
  guards ok; gofmt clean.

Broken by hand, each went red: the no-op skip (mtime test), the 0600
create, the inline default_model spelling, the own-default restore,
removing magpie's file, dropping the vision model, the NotPaths entry,
and both SetTOMLArrayTables fixes (blank-line growth, unchanged write).

Not tried: the full ./... suite (machine load ~190-200, as asked); a
Windows or WSL real binary; Penguin's desktop app; a real vendor key
through Penguin. Penguin sends the openai SDK's User-Agent, so the
agent is named from its key, not its UA.
2026-10-27 01:38:45 +08:00
yetone ea1f9492bc cli: magpie tools lists, and magpie tool calls, the tools magpie's MCP servers give agents (iwinux)
iwinux on Discord (#feedback) wanted magpie's image generation, image
recognition and web search without going through an agent's MCP, and had
written a Python script for generate_image. magpie now has it:

  magpie tools [<name>]
  magpie tool <name> [--<param> <value>…] [<words>…] [-o <file|folder>] [--json]

Both ask the running gateway's own MCP servers (gateway.OwnMCPServers:
image, vision, web-search, plugin tools) over HTTP, with the local token
and the magpie-tool/1 User-Agent, so the tools, schemas, models from
Settings and usage counting are the ones an agent gets. Nothing is
started besides (#3318: the cases sit before startUp, beside mcp).

- Parameters are read against the tool's inputSchema: types (integer,
  number, boolean, array given once per item, object as JSON), enum, -
  and _ alike, --p v or --p=v. The words left over are the tool's one
  required text, else its prompt. An unknown flag or parameter, a missing
  required one, a bad value, a value given twice or both words and the
  same --param are refused with "nothing was called"; no request is sent.
- A file path a parameter takes (its description says file and path)
  is made absolute, since the gateway doesn't know the current folder.
- --help prints toolUsage (static): help is handled before anything runs.
- A still-being-made answer is waited on with generation_result (1s
  between asks, 30 min at most). The gateway's image server now says so
  in _meta too: usemagpie.ai/pending is the id, usemagpie.ai/files the
  files made ({url, inline}); an older gateway is read from its text.
- Images and videos are saved through imagemcp.Target (now exported):
  -o file or folder, else the current folder named from the prompt,
  numbered when more than one, never over a file that is there; a file
  not inline is downloaded by its path from the gateway asked (the token
  goes nowhere else). --json prints the raw answer and saves nothing.
- No magpie at the address: "magpie isn't running at <url>: open the app
  or run magpie serve". MAGPIE_GATEWAY=<url> points at another.

Docs: usage lines in magpie help, docs/reference.md (Use), the gateway
routing subsystem page (_meta and the CLI), README en/zh, site docs start
page en/zh/ja.

Tests (internal/cli/tool_cli_test.go, never the network; every test sets
MAGPIE_GATEWAY to its own httptest server):
- TestToolsListsTheServersTools, TestToolReadsParameters,
  TestToolRefusesWhatItDoesntKnowAndCallsNothing (no tools/call, no file),
  TestToolHelpCallsNothing (no request at all), TestToolSavesTheImage,
  TestToolWaitsOnWhatIsStillMade (pending _meta, then the old text form,
  download with the key from the gateway asked, not the URL's host),
  TestToolErrorIsSaid, TestToolSaysMagpieIsntRunning,
  TestToolDrawsThroughTheGateway (the real gateway.New().Handler() with a
  fake vendor: lists, draws, saves the vendor's PNG).
- TestImageMCPDrawsAndServesTheImage, ...SlowDrawingIsWaitedOn and
  ...MakesVideos now check the _meta. Red on the old behaviour: with
  withMeta setting nothing (what main answers) all three fail ("_meta
  map[], want pending img_…").
- Broken by hand: dropping the unknown-parameter check makes
  TestToolRefuses… red (the --model call was made); saving an inline
  image by its URL instead makes TestToolSavesTheImage red. Both restored.
- TestHelpOnEveryCommandDoesNothing covers tool and tools.

Run with this change on origin/main 630fd1d69, then rebased on cebd0d4c3
(internal/pii, internal/gui, docs and site/ changed between, nothing
this change touches): there
gofmt, go vet of cli/gateway/imagemcp, internal/cli, internal/imagemcp and
the gateway's TestImageMCP/TestVisionMCP/TestSearchMCP again, ok.
At 630fd1d69:
- gofmt -l: nothing. go vet ./...; GOOS=linux go vet -tags nogui
  ./internal/...; GOOS=windows go vet ./internal/...: clean.
- go test ./... -timeout 45m: internal/gateway, imagemcp and the rest ok;
  ten packages failed with "no space left on device" (the machine's disk
  was full from other runs). Those rerun when space was back: agent, cli,
  davsync, gui, library, sessions, settings, tui, usage, usageapi,
  wslrun, plugins/... ok. internal/provider crashes in
  TestUnreadLoginsWriteErrorsKeepCredentials with "close of synctest
  channel from outside bubble" (filememo.Forget), twice: that is #3632,
  open, on main since 091153bf7, nothing this change touches.
- Real try: a nogui build of this head as magpie serve on 127.0.0.1:3482
  under a scratch HOME, a custom provider pointed at a local fake images
  API. magpie tools listed image, vision and web-search with their
  parameters; generate_image "…" --size 1024x1024 -o hero.png saved a PNG
  and the vendor got prompt and size; --n 2 --quality high saved two
  numbered files; --model was refused before calling; analyze_image and
  web_search said what to set up (no vision model or search API there);
  --help asked nothing. Usage counted the calls as magpie's own.

Not tried: a real image vendor, a real vision or search model, a video,
a plugin's tool through magpie tool, Windows and Linux runs (vet only).
2026-10-26 18:42:35 +08:00
yetone 11c3fbb197 README: say masking is off by default, and when a quota has nowhere to go
A review on X (zhengtang364848, 10-26) tested magpie in Docker and
found three README lines that read stronger than the default:

- "keys, passwords and emails in a prompt are masked" — masking is off
  until Settings → Privacy turns it on; the bullet now says so, and the
  masking section's last line says it's off until turned on.
- An email at a test domain stayed as written with masking on. That is
  realEmail in internal/redact/redact.go leaving example.com/.org/.net,
  localhost, .test, .invalid and .example alone on purpose; the masking
  section now names them.
- "when a quota runs out, it quietly moves on to the next account" — a
  provider's next account takes over, and a group moves on to another
  model or provider; with one account and no group the 429 reaches the
  agent, as the review saw. The bullet now says that.

English and 简体中文 both. Docs only: no test reads these lines
(grep for README.md in *_test.go and the GUI tests), nothing run.
2026-10-26 16:03:45 +08:00
yetone 67271e7020 site: WandAPI is a README sponsor
WandAPI took a README seat with its in-app one. README.md shows its
English banner ("Connect to global AI models"), README.zh-CN.md its
Chinese one ("畅连全球AI大模型"). Their SVGs switch colours with a
prefers-color-scheme rule inside; each is kept as a light copy (the rule
taken out) and a dark copy (the rule's colours as the only ones), shown
through <picture> like the other sponsors. All paths, no text or outside
references. Both link usemagpie.ai/go/wandapi/readme, which sponsors.js
sends to wandapi.ai/r/magpierepo, the link WandAPI gave for the README.

Run: node --test site/*.test.mjs (31 of 31 ok). The four banners rendered
with rsvg-convert on white and on GitHub's dark background and looked at.
After the deploy, /go/wandapi/readme is checked for its 302.
2026-10-25 23:44:25 +08:00
yetone 4b1994ad31 agent: AionUi, added through its add-provider link
seven7032 on Discord asked how to connect AionUi to magpie. AionUi
keeps its providers in its own SQLite database
(<userData>/aionui/aionui-backend.db, WAL mode), each key encrypted, so
there is no config file for magpie to write. The one supported way in
is its deeplink. AionUi 2.2.2's main process parses it
(parseDeepLinkUrl), and its renderer opens Settings -> Model with the
add form filled in, which the user confirms:

  aionui://add-provider?api_key=magpie-aionui&base_url=<gw>/v1&name=magpie&platform=custom

The AionUi row works the way Cindy's and Lody's do:
- Add magpie opens that link. /api/open allows the aionui://add-provider?
  prefix only. `magpie aionui add` opens it from the CLI.
- The key is agentKeyAt("aionui"), so it becomes the LAN key while
  sharing is on (added to TestPinnedGatewayKeyForEveryWriter).
- "custom" is AionUi's OpenAI-compatible platform. Its base URLs end in
  /v1, as its own OpenAI preset's does.
- Added reads providers.base_url for the gateway's address without
  touching the database (sessions.OpenUntouched, from the previous
  commit). A database that can't be read is unknown, never "not added".
  The last read is kept while the database and its log keep their size
  and time, for 15s at most, so the Agents poll doesn't copy a running
  AionUi's database every time.
- It is detected by userData/aionui (os.UserConfigDir()/AionUi on every
  OS).
- As with Cindy and Lody, the TUI leaves the row out (nothing to pick).

Tests:
- TestAionUiLink: the link's exact bytes.
- TestAionUiLinkParsedAs2_2_2: runs the link through
  testdata/aionui/deeplink-2.2.2.js, which is parseDeepLinkUrl copied
  byte for byte from 2.2.2's app.asar (out/main/index.js 50995-51021)
  plus the renderer's add-provider mapping and the form prefill. The
  result is action add-provider, route /settings/model, and the form gets
  platform custom, the /v1 base URL and the key.
- TestAionUiHas: a fixture database built from 2.2.2's real providers
  schema (taken from the database 2.2.2 made at first start). It covers
  none, another gateway, a row present only in the log of a running app,
  and a closed app, and checks that AionUi's folder is unchanged each
  time.
- TestAionUiUnreadableIsUnknown, TestAionUiStatusRereadsOnChange,
  TestAionUiDetect, TestAionUiImportRow (GUI: the row, unknown status,
  and /api/open refusing other aionui:// links).
- import-row.test.cjs gains the AionUi row (icon, known status in each
  language, the click opens the exact link, and it fits at 420px), in
  chromium and webkit across en, zh, zh-TW, ja and de. The same file
  now waits for the rows to settle before its alignment check: under
  load 105 one run caught Cindy's button mid-resize at 193.4px beside
  the picker's 194.4px. The old file passed 3/3 alone, so it is a
  timing assumption, not a layout bug.

Run at 18041fc5b (this change on origin/main 714ab8e8b):
- go test ./... -timeout 45m, through the suite lock: every package ok
  except internal/proc's TestNoCommandBypassesProc, red on
  internal/tui/keep.go:102 from 75e78a5a0 on main (#3567, which has a
  fix on skygunner's fork).
- gofmt -l clean; GOOS=linux go vet -tags nogui ./... and GOOS=windows
  go vet of agent, gui, cli and sessions clean.
- import-row.test.cjs: 20/20 in chromium and webkit.
- The whole GUI suite (make test-ui, 882 files) was still running at
  push, so it is not recorded here.
Rebased onto cbbf3163c, which changes GUI assets and api.go. At the
pushed head: go vet of the four packages is clean; go test
./internal/gui ok; the AionUi, Cindy and pinned-key agent tests are ok.
import-row.test.cjs at load ~210: one run had 19/20, and that run's
output wasn't kept, so I can't name the failing case. The next three
runs were 20/20.

Tried: magpie built at this commit with -tags nogui under a sandbox
HOME. `magpie aionui` printed "magpie aionui add  to add magpie" with
AionUi's folder and no database. With a copy of the real 2.2.2 database
holding one row at the gateway's /v1, it printed "magpie added".

Broken by hand:
- Dropping the aionui prefix from /api/open: TestAionUiImportRow red
  ("AionUi's link was not handed to the desktop").
- The reader put back to a plain mode=ro open: TestAionUiHas red
  ("AionUi's folder changed: aionui-backend.db ->
  aionui-backend.db,aionui-backend.db-shm,aionui-backend.db-wal").
Both were restored and are green.

Not tried: the add form, the saved row and gateway traffic. The
released AionUi 2.2.2 desktop app asks for an aionui.com sign-in before
any page, Settings included. That sign-in was not faked, and no
aionui.com account was available, so the link has never been opened in
a signed-in AionUi end to end. Also not tried: what AionUi saves for
platform custom when it is confirmed, AionUi's User-Agent (so none is
matched), and the aionui:// handler on Linux and Windows (Electron's
setAsDefaultProtocolClient, unverified there).
2026-10-25 16:49:29 +08:00
yetone 5509128b1b readme, site: privacy masking gets its own section, with the Masking page
The owner asked for masking to be shown prominently in the README and on
usemagpie.ai. Each says what masking does, how, and what it costs:

- README.md, README.zh-CN.md: a bullet in "Is magpie for you?", a
  "Privacy masking" section second under What it does (screenshot, a
  table of how values are found, put back, kept off disk and shown, and
  the trade-off: the model sees the placeholder, so a task about the
  value needs Never mask), and a line in Privacy linking to it.
- site/public/index.html, site/i18n.js: a #masking section after the
  menu bar, a nav link, en/zh/ja/de strings; the screenshot follows the
  language (de keeps the English one).
- site/public/docs/{,zh/,ja/}privacy.html: a "Masking what goes to
  providers" section and its TOC entry.
- site/public/img/masking{,-zh,-ja}-{light,dark}.png: Insights › Masking
  drawn by the real GUI assets in Chromium with mocked /api data, 1912px.

Every claim was checked against the code: off by default
(settings.Redact omitempty), 503 when asked for and not serving
(reference.md), the local model's 1.6 GB (internal/pii modelSize), the
UI names in each language from internal/gui/assets/i18n.js.

Run at this tree: site `node --test` 31 pass 0 fail (worker.test.mjs
checks every key in every language). The section rendered with each
dictionary applied in Playwright Chromium: en 1280 light, zh 1280 dark,
ja 390 light, de 760 dark; no horizontal scroll, the right screenshot
per language. Not tried: `wrangler dev` (it fails to start on ICON_MAX,
unrelated); the deployed site is checked with curl after deploy.
2026-10-25 04:41:06 +08:00
yetone b5d46acbed agent: Kiro Crew runs on a harness connected to magpie
Vincent on Discord asked for Kiro Crew (kirodotdev/KiroCrew v0.9.0: the
KiroCrew.app desktop app, the kirocrew CLI, its dashboard and the Gateway
on :5476). Crew has no model provider of its own. It runs each session on
an ACP harness picked by agent.acp_backend (and dispatched members by
agent.member_acp_backend) in $KIROCREW_HOME/config.json, default
~/.kiro/crew (src/kiro_crew/config/paths.py, loader.py, sections.py;
ACP_BACKENDS_MEMBER_DISPATCH in agent_sdk/backends.py).

Connecting sets those keys to an agent already connected to magpie,
tried in this order: Codex, Claude Code, OpenCode, Pi, Goose. One whose ACP
adapter is installed (codex-acp, claude-agent-acp, pi-acp) wins, so one
click is enough. magpie looks for the adapter where Crew does and installs
nothing; when it's missing, the notice gives the npm command. With no harness
connected the connect is refused with a message naming which agents to
connect. A harness set in config.local.json wins over config.json, so magpie
doesn't write it and the row says so. The previous values are stashed. On
Disconnect they are put back, but only for keys that still hold what magpie
wrote, and a file magpie created is removed once it's empty. The row reads as
connected only while its harness is still wired to magpie. deepseek is not
offered: Crew runs it as dsh --profile acp, which magpie's dsh wiring doesn't
reach. KIROCREW_HOME and the adapter path variables are read from the login
shell (agentenv).

Run (Go and the GUI files at base 137187a40, then again after the rebase onto 3d758d034):
- go test -tags nogui ./internal/agent ./internal/agentenv: ok, in a
  sandbox HOME
- gofmt -l is clean; GOOS=linux and GOOS=windows go vet -tags nogui
  ./internal/agent/... ./internal/agentenv/...: ok
- GUI: the new agent-kiro-crew-lang.test.cjs (refusals, notice and words in
  en, zh, zh-TW, ja and de; chromium and webkit; 1100 and 420px) 22/22. The
  agent*, gui-*, i18n* and header-relang files (45), concurrency 2 at load
  ~250: 632/633. The red was agent-models-own, chromium en 420, where the dsh
  row's model click timed out at 5s (#1666, filed). After the rebase that
  file and the new one, run alone: 38/38.
- After the rebase: go build ./...; the KiroCrew, Notice, FolderVars,
  EveryPicker and ListsModels tests: ok. go test ./internal/gui: everything
  passed except TestMainWindowCorners, which was killed at its 40s
  measurement at load ~200 (#1936, #2645, both filed; this change touches
  no window code).
- No go test ./... at the pushed head before the push: the machine is at
  load 200-300, other sessions are queued for the suite lock, and ships go
  out at once (owner, 10-22). Queued to run behind them at the pushed
  head.
- Real Kiro Crew: Crew v0.9.0 was installed from source into a sandbox venv,
  and its own loader (load_config_with_content_stamp, overlay_pins) read the
  config.json magpie wrote over the real Codex wiring in a sandbox HOME:
  acp_backend='codex', member_acp_backend='codex'. With a config.local.json
  pin it reads the pinned value and overlay_pins is True. Disconnect gave the
  user's file back as it was, and removed the file magpie had created.

Broken by hand, each red:
- restore off: Connect, PicksAHarness, HarnessPick, MakesItsFile
- the pin check off: LocalPin
- adapter preference off: PicksAHarness
- the member key always written: PicksAHarness, HarnessPick
- harness wiring unchecked in on(): FollowsItsHarness, OnRealCodexWiring
- the ja translation of the pinned refusal removed: the new GUI test, ja at
  both widths

Not tried: Crew's Gateway starting a real session through codex-acp
against magpie's gateway, and none of Crew's harnesses was run under it.
Adapter paths on Windows. A user who pinned agent.model to a kiro-only
model on a non-kiro harness.
2026-10-24 20:59:25 +08:00
yetone 3840333c51 site: APIKEY.FAN is a README sponsor
APIKEY.FAN added a README seat to its in-app one. README.md shows its
English logo ("Enterprise AI Gateway"), README.zh-CN.md its Chinese one
("企业级 AI 中转站"), each with a dark copy whose #111111 lettering is
#F2F2F2, the orange mark unchanged. Both link usemagpie.ai/go/apikeyfan/readme,
which sponsors.js sends to apikey.fan/?aff=mg_readme, the link APIKEY.FAN
gave for the README.

Run: node --test site/*.test.mjs (30 of 30 ok). The four logos rendered
with rsvg-convert on white and on GitHub's dark background and looked at.
After the deploy, /go/apikeyfan/readme is checked for its 302.
2026-10-24 20:50:18 +08:00
yetone eee9ece293 readme: the Sponsors label stands a paragraph's space above the logos
The owner (10-23, a screenshot of the README in dark mode): "Sponsors"
sat right on the logos. A <br> kept it in the logos' paragraph; a blank
line makes it its own, so GitHub's paragraph margin (16px) comes between.
English and 简体中文 alike.

Checked: gh api markdown (gfm) renders <sub>Sponsors</sub> in its own <p>,
the logos in the next.
2026-10-23 16:20:00 +08:00
yetone be002aca05 site: Kimi Code is a partner in the Add sheet and a README sponsor
Kimi took an in-app seat and a README seat. The partner "kimi" (Kimi
Code) has four regions under "Plan": the Kimi Code membership in China
(api.kimi.com/coding, catalog kimi-code-plan-cn, the default) and
globally (api.kimi.ai/coding, kimi-code-plan-global), and Moonshot's pay
as you go in China and globally (catalog moonshotai), with the endpoints
and catalogs of the built-in kimi-code, kimi-code-cn and moonshot
presets, so the plan's handling (keyed on those catalogs and hosts) is
the same. Each region's key page and website is Kimi's aff=magpie link
for it. The tagline is in all five app languages; it is listed in every
language from 10-23, with no end set yet.

README.md links sponsor "kimi" (www.kimi.ai/code), README.zh-CN.md
"kimi-cn" (www.kimi.com/code), with a light and a dark logo. The icon
and logos are drawn from Kimi's mark.

Run: node --test site/*.test.mjs (30 of 30 ok). The served feed
(worker.js served() over partners.js) parsed with partnerFeed and passed
checkPartner and validPartners in a throwaway test in internal/provider:
one partner, the cn region's endpoints as default, every link a /go one.
Not tried: the app's Add sheet with this feed; the editor's link reads
usemagpie.ai, not www.kimi.com, until the app shows a partner's own host.
2026-10-23 15:12:19 +08:00
yetone 3c38fe5c99 agent: Zoo Code (VS Code) through its autoImportSettingsPath (wani on Discord)
wani on Discord (#feedback) asked for Zoo Code (zoocode.dev), a fork of Roo
Code for VS Code and JetBrains.

Route: Zoo Code keeps its provider profiles in VS Code's SecretStorage,
which magpie can't write. The one file it reads is the one its
zoo-code.autoImportSettingsPath setting names. On every activation
(src/utils/autoImportSettings.ts, Zoo Code 3.90.0) it imports that file as
Settings → Import does (importSettingsFromPath). magpie writes
<User>/globalStorage/zoocodeorganization.zoo-code/settings/magpie-import.json
with one profile, "magpie": apiProvider openai on the gateway's
/v1 Chat Completions, key magpie-zoo-code, the chosen model, and an
openAiCustomModelInfo built from the catalog (contextWindow, else Zoo's own
128000 default; maxTokens only when an output limit is known). It points
the setting at that file in the default settings.json and in each VS Code
profile's. A value the user set themselves is stashed and restored by
Disconnect. The file sits outside magpie's folder so that a sync keeps an
address the user moved (kept.away skips magpie's own folder). Requests say
"ZooCode/<version>", and usage names them zoo-code.

Limits (also in docs/reference.md → Zoo Code):
- Zoo reads the file only at start: the notice asks for Developer: Reload
  Window.
- While connected, each start switches Zoo back to the magpie profile.
- Disconnect stops the import but can't delete the imported profile
  from SecretStorage. The user switches away from it or deletes it in Zoo.
- VS Code Stable only.

JetBrains is not wired. Zoo Code for JetBrains runs the extension in its own
extension host, which is handed an empty configuration on every start
(RPCManager.startInitialize in Zoo-Code-JetBrains), so the setting never
reaches it. Its secrets sit in ~/.zoo-code/secrets.json, an internal store
with no lock and no documented format. Neither is a clean route.

Tests (internal/agent/zoocode_test.go):
- TestZooCode: connect, model switch, a stale key that Check reports and
  Sync fixes, and disconnect putting the user's own import path back byte
  for byte with the file removed.
- TestZooCodeFresh and TestZooCodeProfiles: VS Code profiles, including one
  made after connecting.
- TestZooCodeDetectAndUA: Roo alone is not detected; ZooCode/3.90.0 maps to
  zoo-code.
Broken by hand (the restore disabled): TestZooCode and TestZooCodeProfiles
went red.
The generated file was checked with bun against Zoo's own zod schemas
(providerSettingsWithIdSchema, isProviderName; zod 4.6.7 from its repo):
valid, every field kept, current profile in apiConfigs.

Run, set -o pipefail, GOMODCACHE pinned, sandbox HOME:
- First full run, with this change on ba319a758 at 49bec8c4f:
  - gofmt -l clean.
  - go vet darwin, GOOS=linux -tags nogui and GOOS=windows: clean.
  - go test -timeout 45m ./...: 67 packages ok, including gateway 2543s,
    gui 509s and library 2326s.
  - internal/agent was red: TestSyncKeepsAnAddressOnAnotherMachine. The
    import file was then in magpie's folder, which kept.away skips, so a
    NAS address was lost. The file was moved into Zoo's globalStorage
    folder. The package also hit the 45m deadline under load (#2544).
- After the fix: -run 'ZooCode|TestSyncKeepsAnAddressOnAnotherMachine|
  TestReverseProxyIsStillMagpie' ./internal/agent was ok in 112.9s.
- At 0aa9c53ce: gofmt -l clean, internal/agent vet clean three ways, and
  go test -timeout 90m ./internal/agent ./internal/library ./internal/gui
  ok (agent 1912s, library 1299s, gui 420s).
- GUI suite in both engines: 283/283 in chromium and 283/283 in webkit
  (playwright 1.62.0). It covers the 44 files the change can reach:
  gui-de, gui-ja, gui-zh-tw, i18n-keys, agent-notice-lang,
  models-add-and-icons, mono-icon-redraw and every agent-*.

After rebasing onto origin/main 049040283 (which changed internal/agent/claude.go):
- go vet ./internal/agent clean three ways; linux nogui and windows
  builds ok.
- -run 'ZooCode|Compact|TestSyncKeepsAnAddressOnAnotherMachine|UserAgent|AgentOf'
  ./internal/agent ok in 35.9s.
- The darwin go build of the binary hit a full disk at link (this
  machine's, 369M free), not a code error.

Not tried: real VS Code (not installed on this machine), Windows and Linux.
2026-10-21 18:43:06 +08:00
yetone c12ba4fbc4 readme: the Sponsors logos have two em spaces between them, not one collapsed space
The owner saw APINEBULA and 零词元 touching in the README's Sponsors row.
The two links were separated by a newline only. They now sit on one line
with &emsp;&emsp; between them, in README.md and README.zh-CN.md. Ran
the row through GitHub's markdown API: the two em spaces survive
sanitising.
2026-10-20 01:09:10 +08:00
yetone d432920f02 search: DeepSeek's Search API as a search API vendor (TJHHHH on Discord)
DeepSeek's own Search API (api-docs.deepseek.com/guides/search) can now be
added as a search API, with a DeepSeek API key:
- provider.SearchVendors: deepseek, at https://api.deepseek.com, keys at
  platform.deepseek.com/api_keys, offered after You.com.
- askSearchAPI: POST /v1/tools/search, Bearer key (the default), body
  {query, count: searchHits}. The query is cut to the 128 characters the
  docs allow (a longer one is a 400); need_content stays false.
- readSearchAPI reads its summary (the docs' text "for a model",
  ~600-800 chars) as the page's text, since content is empty without
  need_content; its snippet stands in when there is no summary, and its
  date (RFC 3339 or null) is the page's age. Other vendors' fields are
  read as before; summary and snippet are only fallbacks after content.
- 402 (no balance) and 429 (5 QPS per account) already rest a key as out
  of credit and rate limited (searchRestFor); the test pins it for
  deepseek.
- Siblings: CLI usage (main.go, search_cli.go's api list and empty-state
  hint), README.md, README.zh-CN.md, gateway-routing.md's path list. The
  GUI takes its vendors from SearchVendors (no vendor list in app.js or
  i18n), so no GUI file changes.

Not tried against the real DeepSeek API (no key in this run); the fake is
built from the docs' response shape, with null site_name/date and empty
summary/content. Note DeepSeek bills direct API calls ($0.75 per 1,000
non-empty searches).

Run (worktree on origin/main bad4508c4 + this, the Factory and the Qoder
mover commits; machine load 130-345):
- TestDeepSeekSearchAPI (new) passes. Broken by hand five ways, each red
  with its own message: summary not read (Text "Download Go."), query not
  cut ("a long query went as 200 characters"), date not read (Age ""),
  path /search instead of /v1/tools/search, snippet not read (second
  page's Text ""). Restored: ok.
- gofmt -l internal cmd: nothing.
- go vet -tags nogui ./... on darwin, GOOS=linux, GOOS=windows: all ok.
- set -o pipefail; go test -tags nogui -timeout 45m ./... under a scratch
  HOME: 65 packages ok (gateway 2654.9s, provider 930.5s, cli 533.2s);
  internal/agent timed out at 45m (2704s, TestReverseProxyIsStillMagpie/
  nginx running). That is #2723, untouched by these commits; rerun alone
  with -timeout 90m: ok 3565.0s. Recorded on #2723.

After rebasing onto origin/main 89521b03d (13 new commits, none in the
search or mover files): gofmt -l . empty; go vet -tags nogui ./... ok on
darwin, linux, windows; go test -run 'Search|Mover|Moved|Migrat|Plugin'
./internal/gateway/ ./internal/provider/ ok (173.4s, 89.8s); go test
./internal/cli/ ok (286.5s). The full suite was not rerun at the rebased
head.
2026-10-17 21:24:33 +08:00
yetone 138188a36d readme: 零词元 joins the README sponsors, a logo beside APINEBULA's
零词元 (zzq.si) paid for the README seat (owner confirmed the payment). Its
logo goes in the en and zh READMEs' Sponsors row after APINEBULA's, by
payment order, 36px high. The SVGs are the two they sent by mail, byte for
byte (sha256 93e7deae… for light; the dark one only turns the text white),
through <picture> like APINEBULA's. The link goes through
usemagpie.ai/go/zerotoken/readme to https://zzq.si, so its clicks are
counted; sponsors.js gives it a readme link only, as it has no home seat.

Run: node --test site/worker.test.mjs site/install.test.mjs (30 pass). Both
logos rendered in chromium, light and dark: the right one per scheme, same
height as APINEBULA's. Worker deployed (version 75899fbb); curl on
usemagpie.ai: /go/zerotoken/readme -> 302 https://zzq.si, /go/apinebula/readme
unchanged. Not checked: how GitHub itself renders the row (seen after push).
2026-10-16 23:29:45 +08:00
yetone c5f15cae7c provider: Amazon Bedrock's Mantle endpoint (@marktoown on X)
"添加 AmazonBedrock 的时候,API 还是旧的 Bedrock-runtime 节点,不支持最新的
Bedrock-mantle 节点". The reporter wanted to add Amazon Bedrock at its
Mantle endpoint, but magpie only offered bedrock-runtime.

What it does:
- A new vendor preset, bedrock-mantle ("Amazon Bedrock (Mantle)"), takes
  the same Bedrock API key as the runtime.
  - It has 17 regions of its own (mantleRegions): the
    bedrock-mantle.{region}.api.aws hosts that answered on 2026-10-16.
    The runtime's eu-west-3 has no Mantle host.
  - Chat completions and Responses go to /v1, and Messages to
    /anthropic.
  - Unlike the runtime, its models are listed from GET /v1/models.
    NoList stays on the runtime preset only.
- Mantle serves each OpenAI-style model under one prefix.
  - OpenAI's closed GPTs and xAI's Grok are under /openai/v1. Every
    other model is under /v1. Asking at the wrong prefix gets "model `x`
    isn't supported on this route".
  - provider.MantleBase picks the prefix from the model id. The
    gateway's forwardOnce and the provider test's tinyBody both use it.
  - For a model whose maker the rule doesn't know, the gateway asks
    again once at the other prefix when Mantle refuses it for its route
    (internal/gateway/mantle.go).
  - When the second prefix takes it, the gateway remembers that prefix
    in unfit. When both refuse, the client gets the first refusal and
    nothing is remembered.
- IsBedrockMantle is true for the preset and for any provider added at a
  Mantle host. IsBedrock includes it, so the shared Bedrock rules apply
  to Mantle too:
  - Claude goes on Messages only.
  - The key is sent as x-api-key alone, which is what Mantle's own
    examples send.
  - max_completion_tokens is used, and metadata is stripped.
  - Beta renames and refusals apply.
  - There is no Priority.
  - GPTs go to Responses first.
- I checked every other IsBedrock caller. None is runtime-only except
  the legacy /openai/v1 -> Responses migration in normalize, which is
  harmless for Mantle.
- A provider added by its Mantle address gets the APIs it wasn't given
  (mantleEndpoints, in normalize). A chat or Responses URL given at
  /openai/v1 is moved to /v1, because /openai/v1/models is a 404 and the
  list lives at /v1/models.
- GUI: the editor's Key header row is hidden for a Mantle Anthropic
  address, as it already was for the runtime's.
- Docs: README (en, zh) preset lists, docs/reference.md,
  providers-accounts.md (a new row) and gateway-routing.md (a new row,
  plus a test command).

What was run, in the worktree at e72b6a332 (origin/main):
- New tests: TestBedrockMantlePreset, TestBedrockMantleByAddress,
  TestMantleBase (internal/provider) and TestBedrockMantleRoutes
  (internal/gateway, against a fake Mantle that serves each model at
  one prefix only and refuses the other with Mantle's words). All pass.
- Each was broken by hand and went red:
  - The reroute call removed: newmaker got a 400.
  - The prefix pick turned off: gpt-5.5 got a 400.
  - mantleEndpoints made a no-op: the endpoints were not filled in.
  - mantleHost made false: the provider was not taken for Mantle.
  - On the old source, the gateway test fails with 'no preset
    "bedrock-mantle"' and the provider tests don't compile.
- GUI: I added a Mantle case to provider-auth-header.test.cjs.
  - It passes 20/20 in chromium and webkit, en and zh.
  - Against the old app.js, chromium fails 2 of 10 on the new
    assertion.
  - add-sheet 6/6, tencent-cloud 12/12, strip-scrollbar 2/2,
    zhipu-team 12/12 and volc-access-key 12/12 pass in both engines.
- gofmt -l prints nothing.
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet
  -tags nogui ./... and GOOS=windows go vet ./... all exit 0.
- go build, GOOS=linux go build -tags nogui and GOOS=windows go build
  all exit 0.
- Full suite: go test -p 2 -tags nogui -count=1 -timeout 45m ./...
  (sandbox HOME).
  - 64 packages ok.
  - internal/agent and internal/gateway hit the 45m timeout with no
    test failing. Load average was 260-380 from other sessions, with
    about 68 other test binaries running.
  - A second 45m run of those two timed out the same way, again with no
    test failing, and different tests were running at the timeout each
    time.
  - The two were run again with -timeout 150m (-p 2, the same load):
    internal/agent ok in 2988.8s and internal/gateway ok in 2972.4s,
    both just past 45 minutes.

What was not tried:
- The real Mantle API. The owner has no Bedrock key (no Bedrock
  provider in providers.json, and AWS_BEARER_TOKEN_BEDROCK is unset).
  The only real-API evidence is unauthenticated probes of the hosts and
  the routes they answer on.
- The per-model prefix rule, /v1/models, Messages with x-api-key, and
  the "isn't supported on this route" refusal come from AWS's docs and
  model cards, not from a signed request.
- The Mantle Anthropic base's own model list (/anthropic/v1/models) was
  not checked. The list is taken from /v1/models.
- The GUI was not tried in the real desktop app.
- The gui-zh-tw, gui-ja and gui-de suites were not run, since no string
  was added.

Rebased onto origin/main e243937ca (no conflicts). At the rebased head:
go test -run 'Mantle|Bedrock' ./internal/provider ./internal/gateway ok,
gofmt -l of the changed files empty, GOOS=linux and GOOS=windows go vet
-tags nogui of both packages exit 0. The full suite above ran at
e72b6a332, not again at the rebased head.
2026-10-16 19:30:42 +08:00
yetone a15e576564 agent: OpenPencil uses magpie's models (@JC_be_better on X)
OpenPencil (ZSeven-W/openpencil, the openpencil-desktop app) keeps the
builtin agents its chat runs on in settings.json under Rust's
dirs::config_dir()/openpencil (read from its settings_io.rs and
settings_payload.rs). magpie adds one builtin_agents entry, id "magpie",
kind openai-compat at the gateway's /v1 with the magpie-openpencil key,
preset custom, the picked models as OpenPencil writes a list: the first
as `model`, `models` only for two or more, at most 64. The user's other
entries and settings stay, and so do the display_name and enabled they
give magpie's entry; a sync with nothing to change doesn't write. A file
magpie makes gets "version": 1 (OpenPencil sets a file without it aside
as corrupt); a file with another version, or none, is left alone.
Disconnect takes the entry out, and the file when nothing else is left.
OpenPencil reads the file once at start and writes it all back when it
quits, so a change is refused while openpencil-desktop runs (Windows
can't be asked, so the notice says to quit it first). Notice translated
in zh-CN, zh-TW, ja and de. README (en, zh-CN), docs/reference.md and
docs/subsystems/agent-wiring.md list it.

open-pencil/open-pencil, the other app of the name, keeps its providers
in its webview's localStorage, so it gets no row.

Run, under a scratchpad HOME with GOCACHE/GOMODCACHE pinned:
- go test -p 2 -tags nogui -count=1 -timeout 45m ./...: ok, 66 packages
  ok, 18 with no test files
- gofmt -l: clean; GOOS=linux and GOOS=windows go vet -tags nogui ./...: clean
- go test ./internal/agent -run '^TestOpenPencil': ok
- node --test agent-notice-lang, i18n-keys, header-relang (Chromium and
  WebKit, every language, wide and narrow): 37/37 pass
Broken by hand, each went red: the running check, the 64 cap, the
version check, keeping the user's display_name, the no-op sync, and
writing the version into a new file.

Real use: OpenPencil v0.8.4 (latest release, arm64, sha256 checked against
its SHA256SUMS) under a sandbox HOME, started on a settings.json magpie
wrote with the user's own Anthropic entry beside it. It started and ran
15s with the file intact and no .corrupt copy. v0.8.4 has no `models`
field, so it lists only the first magpie model; main lists them all.

Not tried: a chat request through OpenPencil's UI; its exit save (it
didn't quit on an AppleEvent and was stopped with TERM, so the write-back
wasn't seen); Linux and Windows; a build of OpenPencil's main.
2026-10-16 11:43:51 +08:00
yetone 5c0049a38c agent: MothX is an Agents-page row, wired into ~/.mothx/settings.json, and Disconnect puts it back (#2353, zhenruyan)
MothX (oschina/mothx, formerly vibecoding; npm mothx-installer) reads its
providers and start-up model from one settings.json: $MOTHX_DIR, else
%APPDATA%\mothx on Windows, else ~/.mothx. This follows zhenruyan's fork
(#2353) and the jcode/Prime Agent pattern.

What changed
- internal/agent/mothx.go: the agent. Connect writes provider "magpie"
  (openai-chat at the gateway's /v1, key magpie-mothx, one entry per magpie
  model with reasoning, input, contextWindow, maxTokens, cost) beside the
  user's own providers, and sets defaultProvider/defaultModel; "thinking"
  is defaultThinkingLevel, narrowed to the levels magpie knows for the
  model (none → off). thinkingFormat "openai" makes MothX send
  reasoning_effort for every model; without it MothX guesses Qwen's
  enable_thinking/thinking_budget or DeepSeek's thinking from the model id.
  A thinkingFormat or headers the user put in magpie's block are kept.
  Model options: the user's own providers' models, the current built-in
  pick (deepseek-openai/…), then magpie's.
- Disconnect: settings.json is copied aside before magpie's first write
  (beforeMagpie) and put back byte for byte when nothing else changed; a
  file that wasn't there goes again. When MothX rewrote it meanwhile
  (/model, /statusline … global: SaveGlobalSettings marshals the whole
  struct), only magpie's provider, the pick and a providers object left
  empty go; the user's changes stay.
- Detection, the restart notice (mothx or vibecoding running; translated in
  zh-CN, zh-TW, ja, de), WSL distros (~/.mothx), MOTHX_DIR in agentenv and
  the WSL dir moves, CLI updates through npm mothx-installer.
- usage names its requests: the User-Agent is "Vibecoding Client/<ver>",
  matched by the alias vibecoding (usage.AgentOf takes the first word).
- GUI: the icon (upstream docs/assets/mothx-small.png, MIT).
- Docs: README en/zh lists, docs/reference.md (table row, provider-scoped
  list, notes), docs/subsystems/agent-wiring.md.
- Not in this commit: MothX as a Library skills target (its own goal).

Run
- go test -p 1 -tags nogui: TestMothX* (real first-run settings.json as
  the fixture; user keys, headers and thinkingFormat kept; no-op Sync and
  same-value Set leave bytes and mtime alone; Disconnect byte-identical;
  no-file round trip x2; changes while connected kept; MOTHX_DIR/Windows/
  WSL dirs; thinking levels), TestAgentOf, TestEveryNoticeIsTranslated,
  TestEveryAgentNamedByItsKey, TestWSLMore*; then ./internal/agent
  (1120s at load ~100; an earlier run hit the default 10m timeout inside TestReasonixConcurrentEditsAndSync at load ~50, not a failure), ./internal/agentenv, ./internal/usage: ok.
- Broken by hand, each red then restored: no take() (TestMothX and
  RoundTripNoFile red), user thinkingFormat not kept, thinkingFormat
  "openai" dropped, the vibecoding alias dropped (TestAgentOf: got
  "Vibecoding"), the empty-providers cleanup (KeepsWhatChanged red).
- gofmt -l clean; GOOS=darwin/linux/windows go vet -tags nogui ./... clean.
- GUI (playwright 1.62.0, chromium and webkit): agent-notice-lang,
  models-add-and-icons, pi-default-note 30/30; a scratch check of the
  MothX row (icon loads, connect, notice in the window's language, fits)
  in en/zh/zh-TW/ja/de at 1100 and 420: 22/22.
- Real binary, MothX 1.3.104 (npm mothx-installer) in a sandbox HOME
  against a sandbox `magpie serve` and a fake OpenAI upstream:
  - `magpie mothx magpie/fake/echo-1` wrote the block; `mothx doctor`
    showed provider magpie, model fake/echo-1.
  - `mothx -P "Say PONG"` answered from the fake; usage.jsonl recorded
    agent mothx, provider fake.
  - Adding qwen3.7-plus to the provider live-synced the block (context,
    maxTokens, cost, reasoning). With thinking high, MothX sent
    reasoning_effort "high"; with thinkingFormat removed by hand it sent
    enable_thinking/thinking_budget instead, and `magpie provider refresh`
    put "openai" back.
  - The interactive TUI (tmux) started on "magpie | Qwen3.7 Plus · fake"
    and got the fake's reply; `magpie mothx effort medium` while it ran
    printed the restart notice.
  - `/statusline refresh 5 global` in the TUI rewrote the whole file
    (dropped reasoning:false, added responses:{…} to magpie's block);
    `magpie mothx` still read connected. `magpie mothx default` then left
    the original plus the user's refreshInterval, and (after the cleanup
    above) no empty providers.
- Not tried: Windows and WSL with the real binary; a real vendor key.

Full suite: SUITE_LINE
2026-10-15 23:08:03 +08:00
yetone 0dbb1a8490 library: subagents are written once and given to every agent in its own format, with what each agent can't bind shown (#2283, chuanchinatest)
The Library has a Subagents tab beside Hooks. A subagent is a name, a
description, a prompt, and the library's skills and MCP servers it uses.
magpie writes it to each ticked agent's user-level folder in that agent's
format, rewrites it on every change, and takes back only files it wrote.

Where each one goes (syncSubagents, subagentSpecOf):
- Claude Code: ~/.claude/agents/<n>.md, with skills and mcpServers
- Codex: $CODEX_HOME/agents/<n>.toml (name, description, developer_instructions)
- OpenCode: ~/.config/opencode/agents/<n>.md (mode: subagent)
- Gemini CLI ~/.gemini/agents, Qwen Code ~/.qwen/agents, Grok ~/.grok/agents,
  Cursor ~/.cursor/agents, Copilot CLI ~/.copilot/agents/<n>.agent.md
- Factory Droid: ~/.factory/droids/<n>.md, with mcpServers
Skills and servers are named only where the agent's file can name them.
The page says, per agent, which of the two it won't bind, and that only
the Cursor app reads ~/.cursor/agents (cursor-agent reads a project's only).
Agents in WSL and agents with no user-level folder are greyed out.

The user's own files: every file is recorded by the hash of what magpie
wrote (Applied.Subagents). A same-name file of the user's is never written
over (the agent gets a problem). A file the user edited is theirs from then
on: it is neither rewritten nor removed. A carried library doesn't carry
subagents yet (as with hooks).

The Library's tabs now wrap onto a second line rather than scroll a narrow
window sideways (eight tabs in German at 560px). library-servers-bulk's
window goes from 1000 to 1100px tall to keep its stated premise that the
whole list fits.

Run:
- gofmt -l, and go vet -tags nogui for darwin, windows and linux: clean.
- go test of internal/library, internal/gui and the packages that import
  internal/library, at this head: green.
Full suite: SUITE_LINE
- New tests: TestSubagentsEachAgentsFile, TestSubagentsLeaveTheUsersFiles
  (covers the user editing magpie's file and then a sync), TestSubagentCheck.
- GUI: library-subagents (new) passes in Chromium and WebKit, at 1100 and
  420, in en, zh, zh-TW, ja and de. Also all library-*, gui-ja, gui-de,
  gui-zh-tw, i18n-keys, images-library-way, skill-* and mcp-* tests pass.
  Greying out the WSL agent was broken by hand, and library-subagents
  went red.
- Real binaries in a sandbox HOME against a fake upstream: each one sees
  the subagent magpie wrote.
  - Claude Code 2.1.300: it is listed in the system prompt.
  - OpenCode 2.0.25: debug agents.
  - Grok 1.0.50: grok inspect.
  - Codex 0.162.1: spawn_agent's roles, with --enable multi_agent_v2. v1
    showed no spawn_agent with a custom provider.
  - Gemini CLI 0.63.0: <subagent> in the request.
  - Qwen Code 0.21.9: its agent types.

Not tried: Factory Droid and Copilot CLI (both need a sign-in; Copilot
stops on auth before it reads agents), and the Cursor app.
2026-10-15 23:08:03 +08:00
yetone d8d52c6e97 agent: Raycast is an agent magpie connects: a magpie entry in its Custom Providers' providers.yaml, magpie's models in Raycast AI's picker (lx_78654 on Discord)
lx_78654 asked on Discord: "agents能否加一个raycast".

Raycast AI takes models of the user's own as Custom Providers (Raycast
Pro, "Available on: Mac, Windows"), from ~/.config/raycast/ai/
providers.yaml in the user's folder on both systems
(https://manual.raycast.com/ai/custom-providers). Raycast watches the file,
so no restart notice.

What changed:
- internal/agent/raycast.go: a new agent, "raycast". One field, provider:
  connecting adds an entry, id magpie, to the providers list: the gateway's
  /v1 (OpenAI compatible, no /chat/completions), an api_keys alias holding
  magpie-raycast (Raycast's User-Agent isn't known, so its key tells it
  apart), and one model per magpie model with name, context and all five
  abilities said (Raycast assumes tools and vision off when left out):
  tools and system_message on, vision for a model taking images,
  temperature off for one that refuses it, reasoning_effort for one with
  effort levels. ListsModels: the model is picked in Raycast.
  - The list is edited as a yaml node, so the user's other providers, the
    top-level tools block (anchors too) and comments stay.
  - A key the user adds to magpie's entry or to one of its models
    (include_user_email, a description) is kept on a sync; a model gone
    from the catalog leaves the list. A sync with nothing to change
    doesn't write.
  - Disconnect takes the entry out, the list when it was the only one, and
    a file left with nothing in it (Raycast's providers.template.yaml is
    never touched). A providers key that isn't a list is refused and the
    file left as it is.
  - Detected by Raycast.app (com.raycast.macos) or the ~/.config/raycast
    folder.
- agents.go: registers it.
- icons/raycast.svg: Raycast's mark from Simple Icons (CC0), currentColor.
- docs/reference.md, docs/subsystems/agent-wiring.md, README.md,
  README.zh-CN.md: Raycast's row and its place in the agent list.

What was run:
- go test -p 1 -tags nogui ./internal/agent -run '^TestRaycast' in a
  sandbox HOME: ok. The fixture is the manual's LM Studio and tools
  examples, with comments and an anchor; the result is decoded strictly
  (KnownFields) into the manual's schema. Red by hand when I:
  - turned off the no-op check ("a sync with nothing to change wrote");
  - replaced the merge with magpie's entry alone (the user's
    include_user_email and a model's description gone).
- go test -p 1 -tags nogui ./internal/agentenv: ok.
- The whole ./internal/agent package didn't finish here: the first run hit
  the 10m default timeout at TestInstalledVersion with the machine at load
  ~110 (other sessions' suites), the second (-timeout 40m) ran 20 minutes
  with no FAIL and then stopped on "no space left on device" when the disk
  filled (0 GB free, not this run's files). It needs a run on CI.
- gofmt -l; GOOS={darwin,linux,windows} go vet -tags nogui ./internal/agent: ok.

Not tried with a real Raycast. On Windows it is found by the
~/.config/raycast folder only (its install path isn't verified). WSL isn't
covered.

Full suite: SUITE_LINE
2026-10-15 23:08:02 +08:00
yetone 92ac1c878e search: the web search MCP server has a web_fetch tool that reads a page by its URL (#2286, blackrion)
An agent that mounted magpie's web search over MCP (Cursor, Claude Desktop)
found pages it couldn't open: it has no fetch tool of its own. web_fetch
(url, max_chars, offset) reads one.

- The URL is the agent's, so the page is downloaded the way a caller's
  image is (publicClient): public addresses only, every resolved address
  checked and pinned, redirects (at most 5) checked the same, a request
  from this computer included; only http and https. 30 s and 5 MiB at most.
- HTML is decoded from its charset (x/net/html/charset; golang.org/x/net
  added) and given as Markdown: title, headings, lists, links made
  absolute, code and pre; script, style, hidden elements dropped. Other
  text as it is; anything else, or a 4xx/5xx, is the tool's error.
- 20000 characters by default (at most 100000) from offset, with the
  offset the rest starts at.
- Each call reserves the gateway key's limit, as a search does.
- The tool description is neutral (names neither magpie nor a vendor).
- GUI: the MCP row's text names both tools (en, zh, zh-TW, ja, de).
  Docs: gateway-routing's MCP section, README (en, zh-CN).

Run: go test -tags nogui ./internal/gateway -run 'WebFetch|SearchMCP';
GOOS=linux/windows go vet ./internal/gateway; gofmt -l clean. GUI:
search-mcp, i18n-keys, gui-ja, gui-de, gui-zh-tw 32/32 (chromium +
webkit). Broken by hand: webFetchClient = http.DefaultClient turns
TestWebFetchOnlyPublic red (the local test server was reached).
Tried by hand (a throwaway test, not committed) against go.dev/doc,
en.wikipedia.org/wiki/Magpie and http://github.com/yetone (redirected to
https; links come out by name, not the pinned address: the first try gave
https://216.239.34.21:443/..., fixed by taking each redirect's URL from
CheckRedirect), and an httpbin redirect to 127.0.0.1, refused.

Full suite: SUITE_LINE
2026-10-15 23:08:00 +08:00
yetone ec13d1162a search: the search APIs are dragged into the order they are asked in, and each switches off without losing its key (#2286, blackrion)
The search APIs were asked in the order they were added, and the only way
to keep one out of the chain (to try another alone, or rest one whose
credit is nearly spent) was to remove it and paste its key again later.

- provider: SearchAPI.Off; SearchAPIs() leaves an API switched off out, so
  neither a model's search nor the web_search MCP asks it. SwitchSearchAPI
  keeps key, URL and place; SetSearchAPI keeps Off. ArrangeSearchAPIs puts
  them in the vendors' order, refuses an unknown or twice-named vendor, and
  keeps one not named after them. RestoreSearchAPIs now puts a backup's
  APIs in the backup's order (one only here after them), so a restored
  order and Off come back as they were; sync already mirrors the list.
- GUI: each API's row and its keys' row are one unit, dragged off its
  buttons with dragRows (as routing's groups, #779) or moved with Alt+↑/↓,
  renumbered at once, focus kept, redrawn as saved if the order is
  refused. A lib-switch per row posts {vendor, on}; one off is dimmed and
  says Off; Search first with counts only APIs that are on. The row's
  buttons wrap instead of running past a 420px window.
- CLI: magpie search off|on <api>, move <api> <n>; the list says off.
- POST /api/settings/search-api takes {arrange} and {vendor, on}.
- Docs: gateway-routing "The search APIs' order, and one switched off",
  gui-shell, README (en, zh-CN).

Run: go test -tags nogui ./internal/provider ./internal/cli ./internal/gui
./internal/gateway (TestSearch*) ./internal/backup ./internal/davsync;
GOOS=linux/windows go vet of the touched packages; gofmt -l clean.
GUI: search-order.test.cjs 16/16 (chromium + webkit, en/zh/ja/de,
1100/420), and search-api, search-first, search-instead, search-keys,
search-mcp, searcher-pick, i18n-keys, gui-ja, gui-de, gui-zh-tw 100/100.
Broken by hand: SearchAPIs without the Off filter turns
TestSearchAPIOrderAndOff and TestSearchCLIOffAndMove red; the GUI
counting off APIs for Search first turns search-order red.
Full suite: SUITE_LINE
2026-10-15 23:08:00 +08:00
Leon Zhao c6bd4e9707 agent: let Lody confirm local provider imports
Offer Lody a versioned import link for Claude, Codex, Pi, DSH,
Kimi Code, Grok and Bub. Export only loopback endpoints and the public
magpie-lody token. Leave Lody data untouched and show a confirmation hint
when the app exposes no public import-status reader.

Verified: go test -tags nogui ./... in a temporary HOME with pinned Go
caches; native, Linux nogui and Windows vet/build; gofmt and diff checks;
17 Chromium/WebKit import-row and locale checks. The actual Lody parser
accepted all seven targets with IPv4, localhost, IPv6 and canonical ports.

Negative controls: removing registration fails
TestLodyDetectionAndRegistration with "Lody missing from Agents";
removing URL handoff fails TestLodyImportHandoff with
"Lody import was not handed to the desktop". Restored tests pass.

Desktop launch and Linux/Windows runtime behavior were not exercised.

Cherry-picked onto main (4a6bf80f4) from Leeeon233/magpie
feat/lody-integration (ab6c6dd27): README lists resolved with Lody after
Cindy beside main's new agents; /api/open keeps main's OpenURL error path
(#2043) and takes lody:// beside cindy://; the test's fake Windows
returns OpenURL's error as main's interface now does.
2026-10-15 21:18:41 +08:00
yetone 0c1e9b79d3 agent: Claude Science runs on magpie's gateway, its daemon restarted with ANTHROPIC_BASE_URL (leesunrise2364)
Claude Science (Anthropic's research app, 0.1.62, "operon") has no
third-party inference setting, but its daemon reads ANTHROPIC_BASE_URL
(http allowed on loopback). It still requires its own Claude sign-in
(no API keys); magpie never bypasses, forges or forwards it.

- agent/claudescience.go: a claude-science agent, found in the Mac
  bundle, %LOCALAPPDATA%\Programs\ClaudeScience or ~/.local/bin.
  Connecting runs `claude-science stop` then
  `serve --detached --no-browser --port <its port>` with
  ANTHROPIC_BASE_URL set to the gateway, in that process only (no
  user-wide env); disconnecting restarts it without the variable. A
  mark in magpie's config notes the pid/port/URL; a daemon started
  elsewhere shows as drift, never stopped behind the user's back.
  KeepClaudeScience (WhileServing) starts it again on the gateway when
  none runs (after a reboot). Setting the same value again is a no-op,
  so Connect's connect+Apply restarts once.
- gateway/science.go: a request with X-Anthropic-Surface: operon is
  Claude Science's. /v1/models lists every model by a
  claude-magpie-<n> alias with a non-slug name (its picker drops other
  ids); a Claude id magpie doesn't serve (its default, its haiku) goes
  to the model last picked, else the first listed. Its sk-ant-oat
  bearer is dropped like any Claude sign-in.
- Notice in 5 languages; agent-wiring and gateway-routing docs; README.

Run:
- go test -tags nogui ./internal/agent -run ClaudeScience and
  ./internal/gateway -run TestClaudeScience: pass; each broken by hand
  (no variable in env, keeper touching a running daemon, no
  scienceTurn, isClaudeScience off) went red.
- Real 0.1.62 binary in a sandbox HOME on macOS (from the dmg, port
  8481): connect restarted it once with ANTHROPIC_BASE_URL (ps -E),
  connect again was a no-op, disconnect restarted it without, the
  keeper in `magpie serve` restarted a stopped daemon with it.
- Sandbox gateway with a mock provider, sent the app's post-sign-in
  headers (a made-up sk-ant-oat bearer, X-Anthropic-Surface: operon,
  oauth beta): /v1/models gave the aliases, model retrieve worked, a
  streamed turn and a haiku request went to the mock's model, the
  upstream saw only the provider key, sk-ant 0 times in its log.
- Windows 11: the real daemon runs in a sandbox profile against a
  sandbox gateway; before sign-in it asks nothing.
- gofmt -l clean; go vet darwin, linux (nogui), windows clean; full
  go test -tags nogui ./... green except six packages that hit the
  10m timeout at load average 250-460 (other sessions); agent,
  gateway, cli, gui, library, provider rerun with -timeout 50m: all
  ok; GUI agent-notice-lang + i18n-keys in
  chromium and webkit at 1100/420, 5 languages: 25/25.
- Rebased onto origin/main 6 commits back (874e4e8ad; 29 upstream
  commits incl. gateway.go, i18n.js): vet darwin/linux(nogui)/windows
  clean; go test -tags nogui agent, gateway, cli, gui: ok; GUI
  notice/i18n 25/25. The Windows sandbox gateway was swapped to that
  build and the app's headers replayed through it: the alias list, a
  tools turn and a haiku request reached mock-sci-1, sk-ant 0 times in
  the upstream log.
- Rebased again onto ce5d9f9d4 (6 commits: affinity, max output,
  OpenCode Gemini, i18n.js): vet on 3 OSes clean; gateway
  -run 'TestClaudeScience|Affinity|UserOutput|MaxOutput|OpenCodeGemini|
  TestClaudeDesktop|Alias', agent -run 'ClaudeScience|TestEveryNotice|
  TestAgentConnect|TestRewire', gui notice/i18n Go tests: ok; GUI
  notice/i18n 25/25.

Not tried: a real Claude sign-in (left to the owner) and so any turn
the app itself sends; whether the Mac/Windows window attaches to the
daemon magpie started rather than starting its own (drift is shown
and fixed by picking magpie again); Linux.
2026-10-14 22:24:11 +08:00
yetone a5d72a095b gateway, gui, cli: a search API's keys take turns, a refused one rests, and each Tavily key shows what it has used (SlouchyQuill)
SlouchyQuill on Discord asked for a Tavily key pool after
dsh-tavily-pool: several keys, each key's quota shown, keys rotated.
Before this, the comma-separated keys (#1477) always started from the
key that last answered, so one key took every search until it was
refused, a refused key kept no rest of its own, and nothing showed what
a key had left.

What changed:
- Turns (internal/gateway/search_keys.go). Searches take turns over the
  keys by default (round robin, a counter per vendor). pick=order (CLI)
  or In order (Settings) always starts from the first key; the pick is
  saved in SearchAPI.Pick.
- Rests. A refused key rests: 401/403 for 10m ("turned away"), 402 for
  1h ("out of credit"), 429 for its Retry-After held to 30s-10m (1m
  without one). 432/433 count as out of credit from Tavily only; from
  any other vendor they rest as a rate limit. A resting key is asked
  after the others, soonest back first, so failover is kept, and it
  wakes when it answers. Rests are keyed by a hash of the key.
- Quota (internal/gateway/search_quota.go). Each Tavily key's quota is
  read from GET /usage with that key. The fixture is the documented
  reply from docs.tavily.com. The key's own limit is used when it has
  one; otherwise its plan's plan_limit/plan_usage, which the account's
  keys share. A failed read, or a reply missing those fields, says
  unknown and why, never 0. A read is kept 2m unless asked fresh. A key
  found used up with no pay-as-you-go credit rests 1h; a later read
  with credit wakes it.
- Keys never appear in full. The vendor's error has the key masked
  (tvly-…abcd), and errors name "key N (tvly-…abcd)".
- GUI. Settings › Models › Web search adds a "Keys of <API>" row under
  an API with several keys or with Tavily's: In turn / In order, each
  key masked with what it has used and why it is asked last, and Check
  again. There is an API for it (POST /api/settings/search-quota), and
  13 strings in zh, zh-TW, ja and de.
- CLI. `magpie search` lists the pick and each Tavily key's quota, read
  fresh; `magpie search add … pick=turns|order`.
- Docs. gateway-routing.md has a new section "A search API's keys";
  both READMEs have a line on web search.

What was run:
- go test -tags nogui ./internal/gateway ./internal/provider
  ./internal/cli ./internal/gui: ok. After the last rebase, provider
  and cli again, and gateway -race -run Search.
- New tests: TestReadTavilyUsage, TestSearchKeysTakeTurnsRoundRobin,
  TestSearchKeyRefusedRests, TestSearchRestFor, TestSearchQuotas and
  TestSearchKeyNeverInFull. Each guarantee was broken by hand and its
  tests went red:
  - turns pinned to the first key: RoundRobin and RefusedRests;
  - rests ignored: TestSearchAPIKeysTakeTurns, RefusedRests and
    TestSearchQuotas;
  - key masking removed: NeverInFull;
  - a failed read reported as known: TestSearchQuotas.
- gofmt -l; go vet -tags nogui for darwin, linux and windows on the
  four packages.
- GUI: search-keys.test.cjs covers en, zh, zh-TW, ja and de ×
  Chromium and WebKit × 1100 and 420px: 20/20. Without the new
  .search-keys .val wrap rule, de at 420px fails ("Erneut prüfen" went
  past the window's edge).
  - search-api, search-first, search-instead, search-mcp,
    searcher-pick, settings-search, provider-search, gui-de, gui-ja and
    i18n-keys: 56/56 in each engine.
  - Full suite in Chromium (concurrency 6, load ~40): 4498/4504. The
    files that failed (gateway-key-groups, rest-try-now,
    routing-wb-restricted, text-size, usage-sum-whole) were rerun
    alone. All pass except usage-sum-whole, which fails now and then
    on an origin/main worktree too under the same load (#1864, #2023;
    rest-try-now and routing-wb-restricted are #1905). None of them
    touch search.
- Real Tavily API with two invalid keys: /search returns 401
  {"detail":{"error":"Unauthorized: missing or invalid API key."}},
  which counts as a refusal. Both keys rest 10m as turned away, the
  error names them only masked, and both quotas read "unknown · 401".
  Checked through a test and through the nogui CLI binary in a sandbox
  HOME.

Not tried: a valid key's /usage against the real API. No Tavily key
was at hand, so the quota parsing is checked against the documented
bytes only.
2026-10-14 08:24:03 +08:00