agent: miniQ, its provider on magpie's gateway (xiancrong on X)
miniQ (LeadingThink/miniQ, 0.1.213) is a desktop coworker and a `miniq`
terminal, both clients of one miniq-daemon. Its model is one provider in
<data dir>/settings.json, {baseUrl, apiKey, model, apiProtocol}: the data
dir is $MINIQ_DATA_DIR, else the folder miniq-data-dir.json names, else
%LOCALAPPDATA%\miniq or ~/.local/share/miniq (macOS too).
Picking one of magpie's models writes the provider as the gateway's /v1,
magpie's key for miniQ (it sends no User-Agent of its own), the catalog id
and apiProtocol chat_completions ("auto" guesses a protocol from the model
name). What the user had is stashed whole and put back on Disconnect; the
rest of settings.json is left alone. A settings.json magpie made is 0600
and goes again when magpie steps out. The daemon reads settings.json once
and writes its copy back on every change, so a running one is told too:
settings.update over the WebSocket daemon.json names, as miniQ's own
Settings does, which also moves open chats. Notice compares the daemon's
settings.get with the file and asks for a restart when they differ.
"On magpie" is known by magpie's key, so a moved port or a proxy in front
of the gateway is told apart by Check (baseUrl and apiKey). WSL: the
distro's ~/.local/share/miniq. Icon, i18n (zh, zh-TW, ja, de), READMEs,
reference, site, MINIQ_DATA_DIR in agentenv.Vars.
Run:
- At the pushed head, rebased on 286e3b6d5: internal/agent and
internal/agentenv ok; i18n-keys, agent-notice-lang, icon-tile 29 of 29.
- mote: go test ./internal/agent/ ./internal/agentenv/ ok;
./internal/gui/ and ./internal/cli/ ok except
TestGatewayModeStatsNameTheGatewaySessions, run in mote's first local
hour (00:2x), which is #5690.
- GUI on mote, chromium and webkit: i18n-keys, i18n-en-no-cjk,
agent-notice-lang, gui-de, gui-ja, gui-zh-tw, icon-one-tone, icon-tile,
routing-client-icons, usage-agent-filter-icons, agent-connect,
agent-models, agent-layout: 110 of 110.
- Windows (win-run): TestMiniq*, TestOwnProviderNamedAsMagpies/miniq,
TestFolderVarsAreListed ok (the LOCALAPPDATA path).
- gofmt; go vet darwin, linux nogui, windows.
- Real miniQ in a sandbox on mote: the 0.1.213 aarch64 terminal tarball,
sha256 checked against terminal.json, miniq-daemon on a sandbox
MINIQ_DATA_DIR, a fake OpenAI upstream at MAGPIE_ADDR (uncommitted
test). Set magpie/deepseek/pro: the running daemon's settings.get
showed the gateway's /v1 at once; `miniq exec --no-start "say pong"`
sent POST /v1/chat/completions with Bearer magpie-miniq and model
deepseek/pro and printed the reply. Set "": the daemon and the file
were back on the user's provider with their key; nothing else in
settings.json changed. Run twice, before and after the key fix.
Broken by hand:
- push sent "settings.nothing": TestMiniq red ("the daemon was told
nothing").
- apiProtocol dropped from the provider: TestMiniq red.
- on() by URL only (the first version): TestPortMovesEveryAgent,
TestDriftUnwiredEveryAgent/miniq and TestReverseProxyIsStillMagpie red.
Not tried:
- miniQ's desktop app; only the terminal and daemon ran.
- Windows and WSL with a real miniQ.
- Session titles: miniQ asks a hard-coded gemini-3.8-flash on the same
provider for them; without such a model at magpie the chat stays
untitled (miniQ retries later). Nothing in its settings changes that.
- A project's own model in miniQ overrides the global one, as in miniQ.
- settings.update can't remove a provider, so a daemon that had none
before magpie keeps magpie's until it restarts; the notice says so.
This commit is contained in:
@@ -82,7 +82,7 @@ magpie finds the subscriptions your agents are signed in to by reading their sig
|
||||
<table>
|
||||
<tr><td>
|
||||
|
||||
Claude Code · Claude Desktop · Claude Science · Codex · Gemini CLI · Antigravity CLI · OpenCode · OpenChamber · MiMo Code · DevEco Code · Pi · oh-my-pi · StepCode · MothX · PenguinHarness · Aside · OmO · Prime Agent · mu · Goose · Cursor CLI · Cursor Private Inference · Zed · VS Code Chat · VS Code Insiders · VSCodium Chat · Zoo Code · JetBrains Air · Air (JetBrains IDEs) · Copilot (JetBrains) · Copilot CLI · Crush · DeepSeek Harness · Reasonix Studio · Command Code · fx · Devin · Hermes Agent · Mister Morph · Kimi Code · jcode · Qwen Code · Muse Code · Empryo · nanobot · MiniMax Code · Droid · Cline · Qoder · Qoder CN · Grok Build · Grok App · ZCode · WorkBuddy · WorkBuddy AI · CodeBuddy · Pencil · OpenPencil · OpenBot · NewMax · LiveAgent · Raycast · Kiro Crew · OpenMausBot · T3 Code · OpenHanako · AtomCode · Snow CLI · Alma · Cindy · Lody · AionUi · Cherry Studio · Ante · AstrBot · QwenPaw · OpenClaw
|
||||
Claude Code · Claude Desktop · Claude Science · Codex · Gemini CLI · Antigravity CLI · OpenCode · OpenChamber · MiMo Code · DevEco Code · Pi · oh-my-pi · StepCode · MothX · PenguinHarness · Aside · OmO · Prime Agent · mu · Goose · Cursor CLI · Cursor Private Inference · Zed · VS Code Chat · VS Code Insiders · VSCodium Chat · Zoo Code · JetBrains Air · Air (JetBrains IDEs) · Copilot (JetBrains) · Copilot CLI · Crush · DeepSeek Harness · Reasonix Studio · Command Code · fx · Devin · Hermes Agent · Mister Morph · Kimi Code · jcode · Qwen Code · Muse Code · Empryo · nanobot · miniQ · MiniMax Code · Droid · Cline · Qoder · Qoder CN · Grok Build · Grok App · ZCode · WorkBuddy · WorkBuddy AI · CodeBuddy · Pencil · OpenPencil · OpenBot · NewMax · LiveAgent · Raycast · Kiro Crew · OpenMausBot · T3 Code · OpenHanako · AtomCode · Snow CLI · Alma · Cindy · Lody · AionUi · Cherry Studio · Ante · AstrBot · QwenPaw · OpenClaw
|
||||
|
||||
</td></tr>
|
||||
</table>
|
||||
|
||||
+1
-1
@@ -82,7 +82,7 @@ magpie 通过读取智能体的登录信息(Claude Code 和 Codex 的文件、
|
||||
<table>
|
||||
<tr><td>
|
||||
|
||||
Claude Code · Claude Desktop · Claude Science · Codex · Gemini CLI · Antigravity CLI · OpenCode · OpenChamber · MiMo Code · DevEco Code · Pi · oh-my-pi · StepCode · MothX · PenguinHarness · Aside · OmO · Prime Agent · mu · Goose · Cursor CLI · Cursor Private Inference · Zed · VS Code Chat · VS Code Insiders · VSCodium Chat · Zoo Code · JetBrains Air · Air (JetBrains IDEs) · Copilot (JetBrains) · Copilot CLI · Crush · DeepSeek Harness · Reasonix Studio · Command Code · fx · Devin · Hermes Agent · Mister Morph · Kimi Code · jcode · Qwen Code · Muse Code · Empryo · nanobot · MiniMax Code · Droid · Cline · Qoder · Qoder CN · Grok Build · Grok App · ZCode · WorkBuddy · WorkBuddy AI · CodeBuddy · Pencil · OpenPencil · OpenBot · NewMax · LiveAgent · Raycast · Kiro Crew · OpenMausBot · T3 Code · OpenHanako · AtomCode · Snow CLI · Alma · Cindy · Lody · AionUi · Cherry Studio · Ante · AstrBot · QwenPaw · OpenClaw
|
||||
Claude Code · Claude Desktop · Claude Science · Codex · Gemini CLI · Antigravity CLI · OpenCode · OpenChamber · MiMo Code · DevEco Code · Pi · oh-my-pi · StepCode · MothX · PenguinHarness · Aside · OmO · Prime Agent · mu · Goose · Cursor CLI · Cursor Private Inference · Zed · VS Code Chat · VS Code Insiders · VSCodium Chat · Zoo Code · JetBrains Air · Air (JetBrains IDEs) · Copilot (JetBrains) · Copilot CLI · Crush · DeepSeek Harness · Reasonix Studio · Command Code · fx · Devin · Hermes Agent · Mister Morph · Kimi Code · jcode · Qwen Code · Muse Code · Empryo · nanobot · miniQ · MiniMax Code · Droid · Cline · Qoder · Qoder CN · Grok Build · Grok App · ZCode · WorkBuddy · WorkBuddy AI · CodeBuddy · Pencil · OpenPencil · OpenBot · NewMax · LiveAgent · Raycast · Kiro Crew · OpenMausBot · T3 Code · OpenHanako · AtomCode · Snow CLI · Alma · Cindy · Lody · AionUi · Cherry Studio · Ante · AstrBot · QwenPaw · OpenClaw
|
||||
|
||||
</td></tr>
|
||||
</table>
|
||||
|
||||
@@ -130,6 +130,7 @@ line; agents connected to magpie lose it when it quits.
|
||||
| Muse Code | `~/.config/muse/settings.json` (`$XDG_CONFIG_HOME`) | model (endpoint_transport to the gateway, auth none; magpie's models in Muse's list) |
|
||||
| Empryo | `~/.empryo/config.json` | defaultModel (a `magpie` provider at the gateway in `providers`) |
|
||||
| nanobot | `~/.nanobot/config.json` | model (`agents.defaults`: provider `magpie`, model `magpie/<id>` and its context window; a `magpie` provider at the gateway in `providers`. A `modelPreset` that would go over it is stashed and put back on off. Its gateway and WebUI take a change at their next reply) |
|
||||
| miniQ | `~/.local/share/miniq/settings.json` (`%LOCALAPPDATA%\miniq` on Windows, `$MINIQ_DATA_DIR` or the folder `miniq-data-dir.json` names) | model (`provider`: `baseUrl` at the gateway's `/v1`, miniQ's own key, `model` the catalog id, `apiProtocol` `chat_completions`; the user's provider is stashed whole and put back on off. A running daemon is told through its `settings.update` RPC) |
|
||||
| Ante | `~/.ante/catalog.json` and `settings.json` (`$ANTE_HOME`) | provider, model (a `magpie` provider on OpenAiCompatible, with no auth of magpie's: the gateway lets this machine in with any token and Ante counts a provider with none as authenticated; magpie's models in Ante's model picker, and Ante started on magpie, which is what its settings' `provider` decides) |
|
||||
| AstrBot | `data/cmd_config.json` under `$ASTRBOT_ROOT`, else `~/.astrbot` (the desktop app's) | model (a `magpie` entry in `provider_sources` and magpie's models in `provider`, the user's own entries kept; the default chat model in `agent_runner.config.model.provider_id`, or `provider_settings.default_provider_id` on AstrBot before 4.28's agent runner; restart AstrBot after connecting; Docker installs aren't reached) |
|
||||
| QwenPaw | each agent's `agent.json` in its workspace (`~/.qwenpaw/workspaces/<agent>`, the agents listed in `config.json`), under `$QWENPAW_WORKING_DIR`, else a legacy `~/.copaw`, else `~/.qwenpaw` | model (a `magpie` custom provider in `providers/custom/magpie.json` under QwenPaw's secret folder, `$QWENPAW_SECRET_DIR` or `~/.qwenpaw.secret`, OpenAI Chat at the gateway with magpie's models; the agent's `active_model` set to it, what was there put back on Disconnect; one row per agent, `qwenpaw` the default and `qwenpaw#<id>` the others; an agent on an ACP backend isn't listed; restart QwenPaw after the first connect), effort (the agent's `thinking_level`; magpie's models with reasoning levels are declared `thinking_param_style: "effort"` so QwenPaw applies it) |
|
||||
|
||||
@@ -125,6 +125,7 @@ something else shows up as drift.
|
||||
- Claude Desktop's Code tab gets tool search only with Desktop's own `toolSearchEnabled` policy on (3p only, off by default). Off, Desktop 2.7032 (`Ztr` "off") starts Claude Code with `CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1`, and Claude Code (2.1.312, 2.1.316: `oae` returns "standard") then keeps tool search off whatever `ENABLE_TOOL_SEARCH` says, so every MCP tool went whole on each request (bigcat1800 on Discord: 13 MCP servers, ~162K tokens; a sandbox CLI with 60 MCP tools sent 83 tools, 205KB). On, with the gateway provider and a bundled Claude Code of 2.1.247 or later, Desktop hands the CLI `ENABLE_TOOL_SEARCH=force` as a managed setting and the same CLI sent 13 tools, MCP ones behind `ToolSearch`, 56KB, asking only `tool-search-tool-2025-10-19` of the betas. magpie's profile gets `toolSearchEnabled: true` once, on a switch on and from Sync, as `claudeAiImport` is (`desktopSeedToolSearch`, `desktopSeedOnce`, mark `claude-desktop.tool-search`): a value the user set, false too, or took away since, stays theirs (`TestClaudeDesktopTurnsOnToolSearch`). A profile the user applied for magpie's gateway (`desktopAppliedGateway`) is not written.
|
||||
- OpenMausBot (`openmausbot.go`) runs each bot on an engine from `instances` in `~/.openmausbot/config.json` (`$OMB_DATA_DIR`, `server/config.ts` in its source). magpie writes the `magpie` engine as OpenMausBot's own Claude endpoint (`newClaudeEndpoint`, `claude-endpoints.ts`): driver `claudeAgent`, access `custom`, `config.configDir` under `providers/magpie` so OpenMausBot starts Claude Code with its own `CLAUDE_CONFIG_DIR` and strips account keys the engine doesn't set (`claudeEnvironment`, `claude.ts`), `ANTHROPIC_BASE_URL`, `ANTHROPIC_AUTH_TOKEN` and `ANTHROPIC_API_KEY` at the gateway, and magpie's models as `config.endpointModels`, kept to the ids OpenMausBot's `CLAUDE_MODEL_ID` accepts (one bad id makes it refuse the whole engine). A non-empty `instances` is the whole fleet, so with none saved magpie writes OpenMausBot's `DEFAULT_FLEET` beside it (`ombFleet`, stashed as `openmausbot.fleet`) and takes it out again on off if the user hasn't changed it (`TestOpenMausBotFleetChanged`). The name, a model picked from the list, other env and a `cli` are the user's. OpenMausBot reads the file once at start and writes back the fleet it holds whenever an engine is edited in it, so the switch is refused while it runs (`errOMBRunning`; not checked on Windows) and the notice asks to quit it first. That write-back, and an edit of magpie's engine there (`updateClaudeEndpoint` keeps only the model picked and its tiers), leave `endpointModels` without models picked in magpie, and no catalog change follows to sync it again: while magpie serves, `KeepOpenMausBotListed` runs the sync every 30 seconds when the saved list differs from magpie's (`ombListStale`; maxleebeta on Discord, 11-08: Antigravity's models missing from its search). A copy started before magpie's last change to the engine (`ombPart`: the gateway, the first model and the list) offers the row's Restart (`restartApps`, `OpenMausBot.app` and `OpenMausBot.exe`). Codex bots use `~/.codex`, which magpie's Codex wiring already covers.
|
||||
- nanobot (`nanobot.go`, HKUDS/nanobot) answers with `agents.defaults.model`, asked of `agents.defaults.provider`, in `~/.nanobot/config.json` (`config/loader.py`), unless `agents.defaults.modelPreset` names a preset, which goes over both (`Config.resolve_preset`). Any key under `providers` that isn't one of nanobot's own is an OpenAI-compatible endpoint, and a model `<key>/<id>` is sent to it as `<id>` (`create_dynamic_spec`). magpie writes `providers.magpie` (`apiBase` at the gateway's `/v1`, its key, and `extraHeaders` with `User-Agent: nanobot`, by which the gateway tells its requests) and sets provider `magpie`, model `magpie/<id>` and `contextWindowTokens` to the window magpie knows. What the user had in those keys and a `modelPreset` (either spelling: nanobot reads camelCase and snake_case alike) are stashed and put back on off, and `providers.magpie` goes then. nanobot's gateway watches the file and takes a change at its next turn (`config/watcher.py`); `nanobot agent` reads it once.
|
||||
- miniQ (`miniq.go`, LeadingThink/miniQ) has one provider, `provider` in its daemon's `settings.json` (`{baseUrl, apiKey, model, apiProtocol}`, miniq-models `ProviderConfig`), in the data folder `$MINIQ_DATA_DIR`, else the one `miniq-data-dir.json` beside the default names, else `%LOCALAPPDATA%\miniq` or `~/.local/share/miniq` (macOS too). magpie writes the gateway's `/v1`, miniQ's own key (it sends no User-Agent of its own), the catalog id and `apiProtocol` `chat_completions`, since `auto` guesses Responses or Anthropic Messages from a model's name. The user's provider is stashed whole (key and `reasoningEffort` too) and put back on off; with none, the file magpie made goes. The daemon loads settings.json once and writes its whole copy back on every settings change, so magpie also sends a running daemon `settings.update` over the WebSocket `daemon.json` names (`miniqRPC`), which moves open chats to the new model. It can't take a provider out, so Notice asks the daemon (`settings.get`) and says to restart miniQ when its provider isn't the file's. A project's own model settings in miniQ go over the global one.
|
||||
- T3 Code runs a thread on the harness of the provider instance its model is picked under, so magpie writes two instances (karissasel_ on X: only Claude Code could be picked). `magpie` runs Claude Code, as above. `magpie-codex` ("magpie · Codex", `t3CodexJSON` in [`t3code.go`](../../internal/agent/t3code.go)) runs Codex: its `config.launchArgs`, which T3 hands to `codex app-server` and the `-c` pairs of to `codex exec`, are Codex's own overrides, making `magpie` its `model_provider` (the same table `codex.go` writes) and `magpie-codex-models.json`, written beside settings.json from `codexcat`, its `model_catalog_json`. Each value is quoted for T3's `tokenizeCliArgs` (`t3Arg`; `TestT3CodeCodexInstance` reads them back with a port of it). `~/.codex/config.toml` is not written, and a `binaryPath` or `homePath` the user gave T3's own `codex` instance is carried over. The name, on/off and unknown keys are the user's; the launch args and catalog are magpie's, and Check says when the launch args no longer reach the gateway (`t3CodexOff`). An older Claude-only wiring gets the Codex instance on its next Sync once; one the user removed stays removed (`t3code.codex` in the stash) until magpie is turned on for T3 again (`TestT3CodeCodexInstanceAddedOnce`).
|
||||
- Claude Code takes one window (`CLAUDE_CODE_MAX_CONTEXT_TOKENS`, `claudeContextEnv` in [`claude.go`](../../internal/agent/claude.go)) for every model it doesn't know. Claude Code alone on magpie is told its main model's (`claudeWindow`), and a model picked in its `/model` (magpie's `modelPicker`) runs at that one value. Beside a main that is one of Claude's own models (or a group of them), with no tier that isn't, nothing is told, so a model picked there ran at Claude Code's own 200K: a routing group of a 500K GPT and a 1M Claude did (young02036 on Discord). Then (`pickerApart`) the `/model` rows (`pickerRefs`) count as tiers do in the layout below. While Claude Desktop is on magpie too, its Code tab runs Claude Code on the same `~/.claude/settings.json` with every model Desktop lists, so magpie tells it the largest window of those and of Claude Code's own models (its main, tiers and `/model` rows), and holds each model below it to its own with `modelSettings.<id>.autoCompactWindow` (`claudePlan` in [`claude_budget.go`](../../internal/agent/claude_budget.go), #2025: the least held a 1M model to 131K). A model handed by a `[1m]` id (Desktop's under `DesktopLongest`, or Claude Code's own) counts by its 1M too, so it still runs at 1M when Claude Code stops taking the id for 1M (the 1M beta turned away once, `CLAUDE_CODE_DISABLE_1M_CONTEXT`); left out, a 1M model beside a 272K GPT was told 272K (dumplings on Discord). Claude Code 2.1.296 matches that key by the id it was handed, lowercased and without `[1m]`; it comes before the top-level `autoCompactWindow`, which serves a model without one. `CLAUDE_CODE_AUTO_COMPACT_WINDOW` would take precedence over both, so in this mode magpie's working window goes in the top-level `autoCompactWindow` instead, and an entry is written only where a model's window or its own threshold differs from what it would run at without one. magpie's entries and top-level value are stashed (`claude.model_budgets`, `claude.compact_default`) and go when Desktop leaves magpie; the user's own entries, top-level value and variables stay, a user's entry past its model's window (or `auto`) holds the largest to that window, and with a `CLAUDE_CODE_AUTO_COMPACT_WINDOW` of the user's the least window is told as before. A Code tab session whose environment host is WSL runs on the distro's Claude Code, which reads `${CLAUDE_CONFIG_DIR:-$HOME/.claude}` there (Desktop 4.29.0's remote probe) and not Windows' file, so each `claude@wsl:<distro>` is told the same while Windows' Desktop is on magpie (`desktopOn`), on magpie itself or not; it read 200K for a 500K group before (young02036 on Discord).
|
||||
- Claude Code is told what each of magpie's models can do in `CLAUDE_CODE_MODEL_CAPABILITIES` (`claudeCapsEnv`, `claudeCapabilities` in [`claude.go`](../../internal/agent/claude.go)): `<model>=effort[,xhigh_effort][,max_effort]` for those it is shown, and, while Claude Desktop is on magpie, for Desktop's `mythos-magpie-<number>` ids its Code tab hands it. A Claude model Claude Code knows gets no more than Claude Code gives it (Opus and Sonnet 4.6: no xhigh), and one with no known levels isn't named. A model that reaches max without xhigh (GLM-5.3 at low/high/max, DeepSeek V4 at high/max) is said to have xhigh too: the gateway runs xhigh at max for it (`fitEffort`), and Claude Code 2.1.299 turns Ultracode down without `xhigh_effort` ("Ultracode isn't available on …"), which in Desktop is the Ultracode level and dynamic workflows (leesunrise2364 on Discord; `TestClaudeModelCapabilities`). A value of the user's is left alone.
|
||||
|
||||
@@ -295,6 +295,7 @@ func onMachine(home, cfg string) []*Agent {
|
||||
muse(cfg),
|
||||
empryo(home),
|
||||
nanobot(home),
|
||||
miniq(home),
|
||||
ante(home),
|
||||
astrbot(home),
|
||||
qwenpaw(home),
|
||||
|
||||
@@ -139,7 +139,7 @@ func TestPiConnectedBeforeStaysConnected(t *testing.T) {
|
||||
// a provider magpie didn't put there as the user's, as Pi does.
|
||||
func TestHandWiredMagpieProviderSiblings(t *testing.T) {
|
||||
ids := []string{"agy", "opencode", "openchamber", "mimocode", "deveco", "pi", "aside", "omo", "prime-agent", "mu", "goose", "zed", "vscode",
|
||||
"crush", "dsh", "ds-bot", "commandcode", "fx", "omp", "hermes", "morph", "kimi", "empryo", "nanobot", "minimax-code", "droid",
|
||||
"crush", "dsh", "ds-bot", "commandcode", "fx", "omp", "hermes", "morph", "kimi", "empryo", "nanobot", "miniq", "minimax-code", "droid",
|
||||
"qoder", "qoder-cn", "grok", "atomcode", "cline", "snow"}
|
||||
for _, id := range ids {
|
||||
t.Run(id, func(t *testing.T) {
|
||||
|
||||
@@ -0,0 +1,320 @@
|
||||
package agent
|
||||
|
||||
// miniQ (LeadingThink/miniQ; xiancrong on X) is a desktop AI coworker and a
|
||||
// `miniq` terminal client, both clients of one miniq-daemon. Its provider is
|
||||
// one OpenAI- or Anthropic-compatible endpoint the user sets in Settings or
|
||||
// with `miniq configure --base-url`: settings.json's "provider",
|
||||
// {baseUrl, apiKey, model, apiProtocol, reasoningEffort?} (miniq-models
|
||||
// ProviderConfig; read at 2e97b359, 0.1.213). settings.json sits in the
|
||||
// daemon's data folder: $MINIQ_DATA_DIR, else the folder named by
|
||||
// miniq-data-dir.json beside the default, else %LOCALAPPDATA%\miniq or
|
||||
// ~/.local/share/miniq, macOS too (miniq-local data_dir).
|
||||
//
|
||||
// So magpie writes the provider as the gateway's /v1 with miniQ's own key
|
||||
// (it sends no User-Agent of its own, so the key names it), the model's
|
||||
// catalog id and apiProtocol chat_completions: "auto" would guess Responses
|
||||
// or Anthropic Messages from a model's name. The user's provider is stashed
|
||||
// whole and put back when magpie steps out; the rest of settings.json (MCP
|
||||
// servers, approvals, hooks, remote access) stays as it is.
|
||||
//
|
||||
// The daemon reads settings.json once, at its start, and writes its own
|
||||
// copy back on every settings change, so a running one is told too: its
|
||||
// settings.update RPC over the local WebSocket daemon.json names, as the
|
||||
// desktop's Settings does, which also moves open chats onto the new model.
|
||||
// A daemon that can't be told keeps the old provider until it restarts.
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/url"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/coder/websocket"
|
||||
"github.com/tidwall/gjson"
|
||||
|
||||
"github.com/yetone/magpie/internal/edit"
|
||||
)
|
||||
|
||||
// miniqDataDir is miniQ's data folder at the place, as miniq-local's
|
||||
// data_dir finds it; ~/.local/share/miniq in a WSL distro, whose variables
|
||||
// and pointer magpie doesn't read.
|
||||
func miniqDataDir(at place) string {
|
||||
if d := at.getenv("MINIQ_DATA_DIR"); d != "" {
|
||||
return d
|
||||
}
|
||||
def := at.join(".local", "share", "miniq")
|
||||
if app := at.getenv("LOCALAPPDATA"); app != "" {
|
||||
def = filepath.Join(app, "miniq")
|
||||
}
|
||||
// miniq-data-dir.json, beside the default, names a folder the user
|
||||
// moved it to in Settings; on this machine only, as one in a distro
|
||||
// names a path of the distro's
|
||||
if at.spell != nil {
|
||||
return def
|
||||
}
|
||||
if b, err := os.ReadFile(filepath.Join(filepath.Dir(def), "miniq-data-dir.json")); err == nil {
|
||||
var c struct {
|
||||
DataDir string `json:"data_dir"`
|
||||
}
|
||||
if json.Unmarshal(b, &c) == nil && c.DataDir != "" {
|
||||
return c.DataDir
|
||||
}
|
||||
}
|
||||
return def
|
||||
}
|
||||
|
||||
func miniq(home string) *Agent { return miniqAt(here(home)) }
|
||||
|
||||
// miniqIn is miniQ in a WSL distro (see wsl.go).
|
||||
func miniqIn(at place) *Agent { return miniqAt(at) }
|
||||
|
||||
// miniqProtocol is the apiProtocol magpie's provider is written with.
|
||||
const miniqProtocol = "chat_completions"
|
||||
|
||||
// miniqRPC calls method on the miniQ daemon whose data folder is dir,
|
||||
// over the local WebSocket its daemon.json names, and returns the result;
|
||||
// ok false with no error is no daemon to ask (none running, or a
|
||||
// daemon.json a daemon that didn't exit cleanly left behind).
|
||||
func miniqRPC(dir, method string, params any) (res gjson.Result, ok bool, err error) {
|
||||
b, err := os.ReadFile(filepath.Join(dir, "daemon.json"))
|
||||
if err != nil {
|
||||
return res, false, nil
|
||||
}
|
||||
var d struct {
|
||||
Port int `json:"port"`
|
||||
Token string `json:"token"`
|
||||
}
|
||||
if err := json.Unmarshal(b, &d); err != nil || d.Port == 0 || d.Token == "" {
|
||||
return res, false, nil
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
|
||||
defer cancel()
|
||||
u := "ws://127.0.0.1:" + strconv.Itoa(d.Port) + "/ws?token=" + url.QueryEscape(d.Token)
|
||||
c, _, err := websocket.Dial(ctx, u, nil)
|
||||
if err != nil {
|
||||
return res, false, nil
|
||||
}
|
||||
defer c.CloseNow()
|
||||
c.SetReadLimit(8 << 20)
|
||||
req, _ := json.Marshal(map[string]any{"jsonrpc": "2.0", "id": 1, "method": method, "params": params})
|
||||
if err := c.Write(ctx, websocket.MessageText, req); err != nil {
|
||||
return res, false, err
|
||||
}
|
||||
for {
|
||||
_, msg, err := c.Read(ctx)
|
||||
if err != nil {
|
||||
return res, false, err
|
||||
}
|
||||
r := gjson.ParseBytes(msg)
|
||||
if !r.Get("jsonrpc").Exists() || r.Get("id").Raw != "1" {
|
||||
continue // an event the daemon sends every client
|
||||
}
|
||||
c.Close(websocket.StatusNormalClosure, "")
|
||||
if e := r.Get("error"); e.Exists() {
|
||||
return res, true, fmt.Errorf("miniQ refused %s: %s", method, e.Get("message").String())
|
||||
}
|
||||
return r.Get("result"), true, nil
|
||||
}
|
||||
}
|
||||
|
||||
// miniqAt is miniQ with its home at at.home, reaching the gateway as at
|
||||
// does.
|
||||
func miniqAt(at place) *Agent {
|
||||
dir := miniqDataDir(at)
|
||||
path := filepath.Join(dir, "settings.json")
|
||||
key := "miniq:" + path + ":"
|
||||
keyProvider := key + "provider"
|
||||
// keyNew marks a settings.json magpie made
|
||||
keyNew := key + "new"
|
||||
prov := func() gjson.Result {
|
||||
raw, err := edit.Read(path)
|
||||
if err != nil {
|
||||
return gjson.Result{}
|
||||
}
|
||||
return gjson.GetBytes(raw, "provider")
|
||||
}
|
||||
// on: magpie's provider is miniQ's, known by magpie's key for miniQ,
|
||||
// which stays where the gateway's port moved or the user put a proxy
|
||||
// in front of it (Check tells the address apart), or by the gateway's
|
||||
// own address with a key of the user's
|
||||
on := func() bool {
|
||||
p := prov()
|
||||
return keyHolds(p.Get("apiKey").String(), agentKeyAt("miniq", at.gw())) ||
|
||||
sameGateway(p.Get("baseUrl").String(), at.v1())
|
||||
}
|
||||
// push tells a running daemon the provider written; one that can't
|
||||
// be told is left to Notice
|
||||
push := func(p map[string]any) {
|
||||
if _, _, err := miniqRPC(dir, "settings.update", map[string]any{"provider": p}); err != nil {
|
||||
log.Printf("miniQ: %v", err)
|
||||
}
|
||||
}
|
||||
// pushOf is settings.update's provider params for a provider as
|
||||
// settings.json has it
|
||||
pushOf := func(p gjson.Result) map[string]any {
|
||||
m := map[string]any{
|
||||
"baseUrl": p.Get("baseUrl").String(), "model": p.Get("model").String(),
|
||||
"apiProtocol": "auto",
|
||||
}
|
||||
if v := p.Get("apiProtocol").String(); v != "" {
|
||||
m["apiProtocol"] = v
|
||||
}
|
||||
if k := p.Get("apiKey").String(); k != "" {
|
||||
m["apiKey"] = k
|
||||
} else {
|
||||
m["clearApiKey"] = true
|
||||
}
|
||||
return m
|
||||
}
|
||||
// write writes settings.json's provider, the file made private first
|
||||
// where there is none: it holds keys, and miniQ writes it 0600
|
||||
write := func(v any) error {
|
||||
if !isFile(path) {
|
||||
if err := os.MkdirAll(dir, 0o755); err != nil {
|
||||
return err
|
||||
}
|
||||
if f, err := os.OpenFile(path, os.O_CREATE|os.O_EXCL|os.O_WRONLY, 0o600); err == nil {
|
||||
f.WriteString("{}\n")
|
||||
f.Close()
|
||||
}
|
||||
}
|
||||
return edit.SetJSON(path, edit.KV{Path: "provider", Value: v})
|
||||
}
|
||||
// restore puts back the provider the user had, with v as its model if
|
||||
// v isn't ""; none, where they had none, and the file goes where magpie
|
||||
// made it
|
||||
restore := func(v string) error {
|
||||
if v != "" && !gjson.Valid(unstashPeek(keyProvider)) {
|
||||
return errors.New("miniQ had no provider of its own to use " + v + " with: set one in miniQ's Settings")
|
||||
}
|
||||
was := unstash(keyProvider)
|
||||
made := unstash(keyNew) != ""
|
||||
if was != "" && gjson.Valid(was) {
|
||||
var p map[string]any
|
||||
json.Unmarshal([]byte(was), &p)
|
||||
if v != "" {
|
||||
p["model"] = v
|
||||
}
|
||||
if err := write(p); err != nil {
|
||||
return err
|
||||
}
|
||||
b, _ := json.Marshal(p)
|
||||
push(pushOf(gjson.ParseBytes(b)))
|
||||
return nil
|
||||
}
|
||||
if !isFile(path) {
|
||||
return nil
|
||||
}
|
||||
// none of theirs: miniQ goes back to its own default (settings.update
|
||||
// can't take a provider out, so a running daemon keeps magpie's
|
||||
// until it restarts, which Notice says)
|
||||
if err := edit.DelJSON(path, "provider"); err != nil {
|
||||
return err
|
||||
}
|
||||
if made {
|
||||
if raw, err := edit.Read(path); err == nil && len(gjson.ParseBytes(raw).Map()) == 0 {
|
||||
return edit.Remove(path)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
return atomic(&Agent{
|
||||
ID: "miniq", Name: "miniQ", Icon: "miniq-color", Spelled: prefixed, NoNames: true,
|
||||
Bin: "miniq", Dir: dir, Path: path,
|
||||
// the daemon's provider, where one runs, is the one written: one
|
||||
// that couldn't be told keeps what it started with
|
||||
Notice: func() string {
|
||||
res, ok, _ := miniqRPC(dir, "settings.get", map[string]any{})
|
||||
if !ok {
|
||||
return ""
|
||||
}
|
||||
d, f := res.Get("provider"), prov()
|
||||
if strings.TrimRight(d.Get("baseUrl").String(), "/") != strings.TrimRight(f.Get("baseUrl").String(), "/") ||
|
||||
d.Get("model").String() != f.Get("model").String() {
|
||||
return noticeMiniq.String()
|
||||
}
|
||||
return ""
|
||||
},
|
||||
Check: func() string {
|
||||
if !on() {
|
||||
return ""
|
||||
}
|
||||
p := prov()
|
||||
return wiringOff("miniQ", path, func(k string) (string, bool) {
|
||||
r := p.Get(k)
|
||||
return r.String(), r.Exists()
|
||||
}, "baseUrl", at.v1(), "apiKey", agentKeyAt("miniq", at.gw()))
|
||||
},
|
||||
Fields: []Field{{
|
||||
Key: "model", Label: "model",
|
||||
Get: func() string {
|
||||
m := prov().Get("model").String()
|
||||
if m != "" && on() {
|
||||
return magpieID + "/" + m
|
||||
}
|
||||
return m
|
||||
},
|
||||
Set: func(v string) error {
|
||||
if ref, ok := strings.CutPrefix(v, magpieID+"/"); ok && isMagpie(ref) {
|
||||
if !on() {
|
||||
// what the user had, unless magpie stashed it already
|
||||
forget(keyProvider, keyNew)
|
||||
kv := map[string]string{keyProvider: prov().Raw}
|
||||
if !isFile(path) {
|
||||
kv[keyNew] = "1"
|
||||
}
|
||||
stash(kv)
|
||||
}
|
||||
p := map[string]any{
|
||||
"baseUrl": at.v1(), "apiKey": agentKeyAt("miniq", at.gw()),
|
||||
"model": ref, "apiProtocol": miniqProtocol,
|
||||
}
|
||||
if err := write(p); err != nil {
|
||||
return err
|
||||
}
|
||||
push(p)
|
||||
return nil
|
||||
}
|
||||
if on() {
|
||||
return restore(v)
|
||||
}
|
||||
p := prov()
|
||||
if !p.Exists() {
|
||||
if v == "" {
|
||||
return nil
|
||||
}
|
||||
return errors.New("miniQ has no provider of its own to use " + v + " with: set one in miniQ's Settings")
|
||||
}
|
||||
if v == "" || v == p.Get("model").String() {
|
||||
return nil
|
||||
}
|
||||
if err := edit.SetJSON(path, edit.KV{Path: "provider.model", Value: v}); err != nil {
|
||||
return err
|
||||
}
|
||||
m := pushOf(p)
|
||||
m["model"] = v
|
||||
push(m)
|
||||
return nil
|
||||
},
|
||||
Options: func(cur map[string]string) []Option {
|
||||
var own []Option
|
||||
if c := cur["model"]; c != "" && !usesMagpie(c) {
|
||||
own = append(own, Option{Value: c, Icon: modelIcon("", c)})
|
||||
}
|
||||
return withVia(group("miniQ", own), "miniq", magpieID+"/")
|
||||
},
|
||||
}},
|
||||
}, path)
|
||||
}
|
||||
|
||||
// what miniQ says after a change (notice.go)
|
||||
var (
|
||||
noticeMiniq = newNotice("Restart miniQ to use this: its running daemon keeps the provider it started with.")
|
||||
)
|
||||
@@ -0,0 +1,277 @@
|
||||
package agent
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
"github.com/coder/websocket"
|
||||
"github.com/tidwall/gjson"
|
||||
|
||||
"github.com/yetone/magpie/internal/gateway"
|
||||
)
|
||||
|
||||
// fakeMiniqDaemon is a miniq-daemon's local WebSocket as the daemon serves
|
||||
// it (server.rs ws_upgrade, gateway/settings.rs): a token in the query,
|
||||
// JSON-RPC settings.update and settings.get, and an event sent to every
|
||||
// client before any reply. It writes daemon.json into dir and keeps the
|
||||
// provider it was last told, as the daemon keeps its settings in memory.
|
||||
type fakeMiniqDaemon struct {
|
||||
mu sync.Mutex
|
||||
provider map[string]any // what the daemon holds; nil for none
|
||||
updates []map[string]any
|
||||
refuse bool
|
||||
}
|
||||
|
||||
func newFakeMiniqDaemon(t *testing.T, dir string, provider map[string]any) *fakeMiniqDaemon {
|
||||
t.Helper()
|
||||
d := &fakeMiniqDaemon{provider: provider}
|
||||
const token = "tok en&1"
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.URL.Path != "/ws" || r.URL.Query().Get("token") != token {
|
||||
w.WriteHeader(http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
c, err := websocket.Accept(w, r, nil)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
defer c.CloseNow()
|
||||
ctx := r.Context()
|
||||
c.Write(ctx, websocket.MessageText, []byte(`{"type":"session_updated","id":1}`))
|
||||
for {
|
||||
_, msg, err := c.Read(ctx)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
req := gjson.ParseBytes(msg)
|
||||
out := map[string]any{"jsonrpc": "2.0", "id": json.RawMessage(req.Get("id").Raw)}
|
||||
d.mu.Lock()
|
||||
switch req.Get("method").String() {
|
||||
case "settings.update":
|
||||
var p map[string]any
|
||||
json.Unmarshal([]byte(req.Get("params.provider").Raw), &p)
|
||||
d.updates = append(d.updates, p)
|
||||
if d.refuse {
|
||||
out["error"] = map[string]any{"code": -32602, "message": "provider baseUrl is invalid"}
|
||||
break
|
||||
}
|
||||
d.provider = map[string]any{"baseUrl": p["baseUrl"], "model": p["model"], "apiProtocol": p["apiProtocol"]}
|
||||
out["result"] = map[string]any{"provider": d.provider}
|
||||
case "settings.get":
|
||||
out["result"] = map[string]any{"provider": d.provider}
|
||||
}
|
||||
d.mu.Unlock()
|
||||
b, _ := json.Marshal(out)
|
||||
c.Write(ctx, websocket.MessageText, b)
|
||||
}
|
||||
}))
|
||||
t.Cleanup(srv.Close)
|
||||
_, port, _ := net.SplitHostPort(srv.Listener.Addr().String())
|
||||
p, _ := strconv.Atoi(port)
|
||||
b, _ := json.Marshal(map[string]any{"port": p, "token": token, "pid": 1})
|
||||
os.MkdirAll(dir, 0o755)
|
||||
os.WriteFile(filepath.Join(dir, "daemon.json"), b, 0o600)
|
||||
return d
|
||||
}
|
||||
|
||||
func (d *fakeMiniqDaemon) last(t *testing.T) map[string]any {
|
||||
t.Helper()
|
||||
d.mu.Lock()
|
||||
defer d.mu.Unlock()
|
||||
if len(d.updates) == 0 {
|
||||
t.Fatal("the daemon was told nothing")
|
||||
}
|
||||
return d.updates[len(d.updates)-1]
|
||||
}
|
||||
|
||||
func miniqHome(t *testing.T) (home, dir string) {
|
||||
t.Helper()
|
||||
home, _ = museHome(t)
|
||||
t.Setenv("MINIQ_DATA_DIR", "")
|
||||
t.Setenv("LOCALAPPDATA", "")
|
||||
return home, filepath.Join(home, ".local", "share", "miniq")
|
||||
}
|
||||
|
||||
func TestMiniq(t *testing.T) {
|
||||
home, dir := miniqHome(t)
|
||||
path := filepath.Join(dir, "settings.json")
|
||||
os.MkdirAll(dir, 0o755)
|
||||
// a user's own, as miniQ's Settings writes it: Zaiwen's endpoint and
|
||||
// key, an MCP server, approvals and remote access
|
||||
orig := `{
|
||||
"provider": {"baseUrl": "https://oneapi.zaiwenai.com/v1", "apiKey": "sk-zaiwen", "model": "glm-4.6", "apiProtocol": "auto", "reasoningEffort": "high"},
|
||||
"mcpServers": {"docs": {"command": "npx", "args": ["docs-mcp"]}},
|
||||
"approvalMode": "auto",
|
||||
"remoteAccess": {"enabled": true, "relayUrl": "wss://relay.example", "deviceName": "mac", "deviceId": "d1"}
|
||||
}
|
||||
`
|
||||
os.WriteFile(path, []byte(orig), 0o600)
|
||||
var want map[string]any
|
||||
json.Unmarshal([]byte(orig), &want)
|
||||
read := func() map[string]any {
|
||||
t.Helper()
|
||||
var m map[string]any
|
||||
b, _ := os.ReadFile(path)
|
||||
if err := json.Unmarshal(b, &m); err != nil {
|
||||
t.Fatalf("%v\n%s", err, b)
|
||||
}
|
||||
return m
|
||||
}
|
||||
daemon := newFakeMiniqDaemon(t, dir, map[string]any{"baseUrl": "https://oneapi.zaiwenai.com/v1", "model": "glm-4.6"})
|
||||
|
||||
a := miniq(home)
|
||||
if a.Path != path || a.Dir != dir {
|
||||
t.Fatalf("path: %s %s", a.Path, a.Dir)
|
||||
}
|
||||
f := a.Field("model")
|
||||
if f.Get() != "glm-4.6" || a.Check() != "" || a.Notice() != "" {
|
||||
t.Fatalf("own: %q %q %q", f.Get(), a.Check(), a.Notice())
|
||||
}
|
||||
var vals []string
|
||||
for _, o := range f.Options(a.Values()) {
|
||||
vals = append(vals, o.Value)
|
||||
}
|
||||
if !strings.Contains(strings.Join(vals, " "), "glm-4.6 magpie/deepseek/pro") {
|
||||
t.Fatalf("options: %v", vals)
|
||||
}
|
||||
|
||||
for range 2 { // twice: what the user had is stashed once
|
||||
if err := f.Set("magpie/deepseek/pro"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
m := read()
|
||||
key := agentKeyAt("miniq", gateway.URL())
|
||||
wantP := map[string]any{"baseUrl": gatewayV1(), "apiKey": key, "model": "deepseek/pro", "apiProtocol": "chat_completions"}
|
||||
if !reflect.DeepEqual(m["provider"], wantP) {
|
||||
t.Fatalf("provider: %v", m["provider"])
|
||||
}
|
||||
for _, k := range []string{"mcpServers", "approvalMode", "remoteAccess"} {
|
||||
if !reflect.DeepEqual(m[k], want[k]) {
|
||||
t.Fatalf("%s: %v", k, m[k])
|
||||
}
|
||||
}
|
||||
// the running daemon was told, so it uses magpie now and won't write
|
||||
// Zaiwen's provider back at its next settings change
|
||||
if got := daemon.last(t); !reflect.DeepEqual(got, wantP) {
|
||||
t.Fatalf("daemon told: %v", got)
|
||||
}
|
||||
if f.Get() != "magpie/deepseek/pro" || a.Check() != "" || a.Notice() != "" {
|
||||
t.Fatalf("on: %q %q %q", f.Get(), a.Check(), a.Notice())
|
||||
}
|
||||
|
||||
// magpie's key taken out by hand
|
||||
b, _ := os.ReadFile(path)
|
||||
os.WriteFile(path, []byte(strings.Replace(string(b), key, "sk-other", 1)), 0o600)
|
||||
if !strings.Contains(a.Check(), "apiKey") {
|
||||
t.Fatalf("check: %q", a.Check())
|
||||
}
|
||||
os.WriteFile(path, b, 0o600)
|
||||
|
||||
// stepping out puts back the user's provider whole, key and effort
|
||||
// too, and tells the daemon, with their key
|
||||
if err := f.Set(""); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
m = read()
|
||||
if !reflect.DeepEqual(m["provider"], want["provider"]) {
|
||||
t.Fatalf("restored: %v", m["provider"])
|
||||
}
|
||||
if got := daemon.last(t); got["baseUrl"] != "https://oneapi.zaiwenai.com/v1" || got["apiKey"] != "sk-zaiwen" || got["model"] != "glm-4.6" {
|
||||
t.Fatalf("daemon told: %v", got)
|
||||
}
|
||||
|
||||
// a model of the user's own while magpie's is on steps magpie out with
|
||||
// that model on their provider
|
||||
f.Set("magpie/deepseek/flash")
|
||||
if err := f.Set("glm-4.5"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if p := read()["provider"].(map[string]any); p["baseUrl"] != "https://oneapi.zaiwenai.com/v1" || p["model"] != "glm-4.5" || p["apiKey"] != "sk-zaiwen" {
|
||||
t.Fatalf("own over magpie: %v", p)
|
||||
}
|
||||
|
||||
// a daemon that refuses keeps what it had: said
|
||||
daemon.mu.Lock()
|
||||
daemon.refuse = true
|
||||
daemon.mu.Unlock()
|
||||
if err := f.Set("magpie/deepseek/pro"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if a.Notice() == "" {
|
||||
t.Fatal("no notice for a daemon on the old provider")
|
||||
}
|
||||
}
|
||||
|
||||
// TestMiniqMadeFile: with no settings.json (miniQ on MINIQ_* variables or
|
||||
// its default), magpie's is made private and goes again when magpie steps
|
||||
// out; a daemon that can't take a provider out is told to restart.
|
||||
func TestMiniqMadeFile(t *testing.T) {
|
||||
home, dir := miniqHome(t)
|
||||
path := filepath.Join(dir, "settings.json")
|
||||
a := miniq(home)
|
||||
f := a.Field("model")
|
||||
if err := f.Set("magpie/deepseek/flash"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
st, err := os.Stat(path)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if runtime.GOOS != "windows" && st.Mode().Perm() != 0o600 {
|
||||
t.Fatalf("mode: %v", st.Mode())
|
||||
}
|
||||
if f.Get() != "magpie/deepseek/flash" {
|
||||
t.Fatalf("get: %q", f.Get())
|
||||
}
|
||||
if err := f.Set("glm-4.6"); err == nil {
|
||||
t.Fatal("an own model with no provider of the user's to send it to")
|
||||
}
|
||||
newFakeMiniqDaemon(t, dir, map[string]any{"baseUrl": gatewayV1(), "model": "deepseek/flash"})
|
||||
if err := f.Set(""); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := os.Stat(path); !os.IsNotExist(err) {
|
||||
b, _ := os.ReadFile(path)
|
||||
t.Fatalf("made file left: %s", b)
|
||||
}
|
||||
if a.Notice() == "" {
|
||||
t.Fatal("no notice for a daemon still on magpie")
|
||||
}
|
||||
}
|
||||
|
||||
// TestMiniqDataDir: settings.json is where miniq-local's data_dir puts it.
|
||||
func TestMiniqDataDir(t *testing.T) {
|
||||
home, def := miniqHome(t)
|
||||
if d := miniqDataDir(here(home)); d != def {
|
||||
t.Fatalf("default: %s", d)
|
||||
}
|
||||
app := filepath.Join(home, "AppData", "Local")
|
||||
t.Setenv("LOCALAPPDATA", app)
|
||||
if d := miniqDataDir(here(home)); d != filepath.Join(app, "miniq") {
|
||||
t.Fatalf("LOCALAPPDATA: %s", d)
|
||||
}
|
||||
// moved in miniQ's Settings: the pointer beside the default
|
||||
moved := filepath.Join(home, "elsewhere", "miniq")
|
||||
b, _ := json.Marshal(map[string]string{"data_dir": moved})
|
||||
os.MkdirAll(app, 0o755)
|
||||
os.WriteFile(filepath.Join(app, "miniq-data-dir.json"), b, 0o644)
|
||||
if d := miniqDataDir(here(home)); d != moved {
|
||||
t.Fatalf("moved: %s", d)
|
||||
}
|
||||
env := filepath.Join(home, "env-miniq")
|
||||
t.Setenv("MINIQ_DATA_DIR", env)
|
||||
if a := miniq(home); a.Path != filepath.Join(env, "settings.json") {
|
||||
t.Fatalf("MINIQ_DATA_DIR: %s", a.Path)
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
// own deepseek/deepseek-v4-pro).
|
||||
func TestOwnProviderNamedAsMagpies(t *testing.T) {
|
||||
ids := []string{"agy", "opencode", "openchamber", "mimocode", "deveco", "pi", "aside", "omo", "prime-agent", "mu", "goose", "zed", "vscode",
|
||||
"crush", "dsh", "ds-bot", "commandcode", "fx", "omp", "hermes", "morph", "kimi", "empryo", "nanobot", "minimax-code", "droid",
|
||||
"crush", "dsh", "ds-bot", "commandcode", "fx", "omp", "hermes", "morph", "kimi", "empryo", "nanobot", "miniq", "minimax-code", "droid",
|
||||
"qoder", "qoder-cn", "grok", "atomcode", "cline", "snow", "qwenpaw"}
|
||||
for _, id := range ids {
|
||||
t.Run(id, func(t *testing.T) {
|
||||
@@ -27,6 +27,10 @@ func TestOwnProviderNamedAsMagpies(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
f := &a.Fields[0]
|
||||
if id == "miniq" {
|
||||
// a provider of the user's own, for its own model to be on
|
||||
hanakoWrite(t, a.Path, `{"provider":{"baseUrl":"https://relay.example/v1","apiKey":"sk-own","model":"glm-4.5","apiProtocol":"auto"}}`, 0o600)
|
||||
}
|
||||
if id == "cline" {
|
||||
// a model of OpenRouter's, the provider Cline is on
|
||||
hanakoWrite(t, a.Path, `{"version":1,"modes":{},"providers":{},"lastUsedProvider":"openrouter"}`, 0o600)
|
||||
|
||||
@@ -699,6 +699,8 @@ var wslKinds = []wslKind{
|
||||
// no bin: nanobot is other tools' name too
|
||||
{id: "nanobot", name: "nanobot", dir: ".nanobot", in: nanobotIn,
|
||||
restart: newNotice("{agent} in WSL {distro}: its gateway and WebUI take this at their next reply; restart an open `nanobot agent` chat to use it there.")},
|
||||
{id: "miniq", name: "miniQ", dir: ".local/share/miniq", bin: "miniq", in: miniqIn,
|
||||
restart: newNotice("{agent} in WSL {distro}: magpie tells its running daemon; if it still answers with the old model, restart miniQ there.")},
|
||||
// Ante ships macOS and Linux builds alone, and suggests WSL on Windows,
|
||||
// so a Windows machine's Ante is usually this one
|
||||
{id: "ante", name: "Ante", dir: ".ante", bin: "ante", in: anteIn,
|
||||
|
||||
@@ -94,6 +94,8 @@ var Vars = []string{
|
||||
"DEVECO_CONFIG_DIR",
|
||||
// alma-server's data folder (Alma without a desktop, on Linux)
|
||||
"ALMA_DATA_DIR",
|
||||
// miniQ's data folder, its settings.json and daemon.json in it
|
||||
"MINIQ_DATA_DIR",
|
||||
// Reasonix Studio and its native CLI share this config home
|
||||
"REASONIX_HOME",
|
||||
// Reasonix's state folder, where it reads REASONIX.md
|
||||
|
||||
@@ -4651,6 +4651,7 @@ const I18N = {
|
||||
"Droid reads its settings at start-up — restart open droid sessions to use this.": "Droid 启动时读取设置,需重启已打开的 droid 会话才会生效。",
|
||||
"Empryo reads its config at start-up — restart open empryo sessions to use this.": "Empryo 启动时读取配置,需重启已打开的 empryo 会话才会生效。",
|
||||
"nanobot's gateway and WebUI take this at their next reply; restart an open `nanobot agent` chat to use it there.": "nanobot 的 gateway 和 WebUI 会在下一次回复时用上它;已打开的 `nanobot agent` 对话需重启才会生效。",
|
||||
"Restart miniQ to use this: its running daemon keeps the provider it started with.": "重启 miniQ 才会生效:正在运行的后台仍用启动时的服务商。",
|
||||
"Gemini CLI reads its settings at start-up — restart open gemini sessions to see this.": "Gemini CLI 启动时读取设置,需重启已打开的 gemini 会话才能看到。",
|
||||
"Goose loads its providers at start-up — quit and reopen Goose (and open goose sessions) to use magpie's models.": "Goose 启动时加载供应商,需退出并重新打开 Goose(以及已打开的 goose 会话)才能使用 magpie 的模型。",
|
||||
"Grok Build reads its settings at start-up — restart open grok sessions to use this.": "Grok Build 启动时读取设置,需重启已打开的 grok 会话才会生效。",
|
||||
@@ -4721,6 +4722,7 @@ const I18N = {
|
||||
"{agent} in WSL {distro} reads its config at start-up — restart open dsh sessions to use this.": "WSL {distro} 中的 {agent} 启动时读取配置,需重启已打开的 dsh 会话才会生效。",
|
||||
"{agent} in WSL {distro} reads its config at start-up — restart open empryo sessions to use this.": "WSL {distro} 中的 {agent} 启动时读取配置,需重启已打开的 empryo 会话才会生效。",
|
||||
"{agent} in WSL {distro}: its gateway and WebUI take this at their next reply; restart an open `nanobot agent` chat to use it there.": "WSL {distro} 中的 {agent}:它的 gateway 和 WebUI 会在下一次回复时用上它;已打开的 `nanobot agent` 对话需重启才会生效。",
|
||||
"{agent} in WSL {distro}: magpie tells its running daemon; if it still answers with the old model, restart miniQ there.": "WSL {distro} 中的 {agent}:magpie 会通知它正在运行的后台;若仍用旧模型回复,请在那里重启 miniQ。",
|
||||
"{agent} in WSL {distro} reads its config at start-up — restart open mimo sessions to use this.": "WSL {distro} 中的 {agent} 启动时读取配置,需重启已打开的 mimo 会话才会生效。",
|
||||
"{agent} in WSL {distro} reads its config at start-up — restart open opencode sessions to use this.": "WSL {distro} 中的 {agent} 启动时读取配置,需重启已打开的 opencode 会话才会生效。",
|
||||
"{agent} in WSL {distro} reads its model when a session starts — restart open codebuddy sessions, or run /clear in them, to use this.": "WSL {distro} 中的 {agent} 在会话开始时读取模型,需重启已打开的 codebuddy 会话或在其中运行 /clear 才会生效。",
|
||||
@@ -9534,6 +9536,7 @@ const I18N = {
|
||||
"Droid reads its settings at start-up — restart open droid sessions to use this.": "Droid 啟動時讀取設定,需重啟已打開的 droid 會話才會生效。",
|
||||
"Empryo reads its config at start-up — restart open empryo sessions to use this.": "Empryo 啟動時讀取設定,需重啟已打開的 empryo 會話才會生效。",
|
||||
"nanobot's gateway and WebUI take this at their next reply; restart an open `nanobot agent` chat to use it there.": "nanobot 的 gateway 和 WebUI 會在下一次回覆時用上它;已開啟的 `nanobot agent` 對話需重啟才會生效。",
|
||||
"Restart miniQ to use this: its running daemon keeps the provider it started with.": "重新啟動 miniQ 才會生效:正在執行的背景服務仍用啟動時的服務商。",
|
||||
"Gemini CLI reads its settings at start-up — restart open gemini sessions to see this.": "Gemini CLI 啟動時讀取設定,需重啟已打開的 gemini 會話才能看到。",
|
||||
"Goose loads its providers at start-up — quit and reopen Goose (and open goose sessions) to use magpie's models.": "Goose 啟動時載入供應商,需退出並重新打開 Goose(以及已打開的 goose 會話)才能使用 magpie 的模型。",
|
||||
"Grok Build reads its settings at start-up — restart open grok sessions to use this.": "Grok Build 啟動時讀取設定,需重啟已打開的 grok 會話才會生效。",
|
||||
@@ -9604,6 +9607,7 @@ const I18N = {
|
||||
"{agent} in WSL {distro} reads its config at start-up — restart open dsh sessions to use this.": "WSL {distro} 中的 {agent} 啟動時讀取設定,需重啟已打開的 dsh 會話才會生效。",
|
||||
"{agent} in WSL {distro} reads its config at start-up — restart open empryo sessions to use this.": "WSL {distro} 中的 {agent} 啟動時讀取設定,需重啟已打開的 empryo 會話才會生效。",
|
||||
"{agent} in WSL {distro}: its gateway and WebUI take this at their next reply; restart an open `nanobot agent` chat to use it there.": "WSL {distro} 中的 {agent}:它的 gateway 和 WebUI 會在下一次回覆時用上它;已開啟的 `nanobot agent` 對話需重啟才會生效。",
|
||||
"{agent} in WSL {distro}: magpie tells its running daemon; if it still answers with the old model, restart miniQ there.": "WSL {distro} 中的 {agent}:magpie 會通知它正在執行的背景服務;若仍用舊模型回覆,請在那裡重新啟動 miniQ。",
|
||||
"{agent} in WSL {distro} reads its config at start-up — restart open mimo sessions to use this.": "WSL {distro} 中的 {agent} 啟動時讀取設定,需重啟已打開的 mimo 會話才會生效。",
|
||||
"{agent} in WSL {distro} reads its config at start-up — restart open opencode sessions to use this.": "WSL {distro} 中的 {agent} 啟動時讀取設定,需重啟已打開的 opencode 會話才會生效。",
|
||||
"{agent} in WSL {distro} reads its model when a session starts — restart open codebuddy sessions, or run /clear in them, to use this.": "WSL {distro} 中的 {agent} 在會話開始時讀取模型,需重啟已打開的 codebuddy 會話或在其中執行 /clear 才會生效。",
|
||||
@@ -14419,6 +14423,7 @@ const I18N = {
|
||||
"Droid reads its settings at start-up — restart open droid sessions to use this.": "Droid は起動時に設定を読み込みます。反映するには開いている droid セッションを再起動してください。",
|
||||
"Empryo reads its config at start-up — restart open empryo sessions to use this.": "Empryo は起動時に設定を読み込みます。反映するには開いている empryo セッションを再起動してください。",
|
||||
"nanobot's gateway and WebUI take this at their next reply; restart an open `nanobot agent` chat to use it there.": "nanobot の gateway と WebUI は次の返信からこれを使います。開いている `nanobot agent` のチャットは再起動すると反映されます。",
|
||||
"Restart miniQ to use this: its running daemon keeps the provider it started with.": "反映するには miniQ を再起動してください。実行中のデーモンは起動時のプロバイダーを使い続けます。",
|
||||
"Gemini CLI reads its settings at start-up — restart open gemini sessions to see this.": "Gemini CLI は起動時に設定を読み込みます。反映するには開いている gemini セッションを再起動してください。",
|
||||
"Goose loads its providers at start-up — quit and reopen Goose (and open goose sessions) to use magpie's models.": "Goose は起動時にプロバイダを読み込みます。magpie のモデルを使うには Goose(と開いている goose セッション)を終了して開き直してください。",
|
||||
"Grok Build reads its settings at start-up — restart open grok sessions to use this.": "Grok Build は起動時に設定を読み込みます。反映するには開いている grok セッションを再起動してください。",
|
||||
@@ -14489,6 +14494,7 @@ const I18N = {
|
||||
"{agent} in WSL {distro} reads its config at start-up — restart open dsh sessions to use this.": "WSL {distro} の {agent} は起動時に設定を読み込みます。反映するには開いている dsh セッションを再起動してください。",
|
||||
"{agent} in WSL {distro} reads its config at start-up — restart open empryo sessions to use this.": "WSL {distro} の {agent} は起動時に設定を読み込みます。反映するには開いている empryo セッションを再起動してください。",
|
||||
"{agent} in WSL {distro}: its gateway and WebUI take this at their next reply; restart an open `nanobot agent` chat to use it there.": "WSL {distro} の {agent}:gateway と WebUI は次の返信からこれを使います。開いている `nanobot agent` のチャットは再起動すると反映されます。",
|
||||
"{agent} in WSL {distro}: magpie tells its running daemon; if it still answers with the old model, restart miniQ there.": "WSL {distro} の {agent}:magpie は実行中のデーモンに伝えます。古いモデルで返答が続く場合は、そこで miniQ を再起動してください。",
|
||||
"{agent} in WSL {distro} reads its config at start-up — restart open mimo sessions to use this.": "WSL {distro} の {agent} は起動時に設定を読み込みます。反映するには開いている mimo セッションを再起動してください。",
|
||||
"{agent} in WSL {distro} reads its config at start-up — restart open opencode sessions to use this.": "WSL {distro} の {agent} は起動時に設定を読み込みます。反映するには開いている opencode セッションを再起動してください。",
|
||||
"{agent} in WSL {distro} reads its model when a session starts — restart open codebuddy sessions, or run /clear in them, to use this.": "WSL {distro} の {agent} はセッション開始時にモデルを読み込みます。反映するには開いている codebuddy セッションを再起動するか、その中で /clear を実行してください。",
|
||||
@@ -19304,6 +19310,7 @@ const I18N = {
|
||||
"Droid reads its settings at start-up — restart open droid sessions to use this.": "Droid liest seine Einstellungen beim Start – offene droid-Sitzungen neu starten, damit es gilt.",
|
||||
"Empryo reads its config at start-up — restart open empryo sessions to use this.": "Empryo liest seine Konfiguration beim Start – offene empryo-Sitzungen neu starten, damit es gilt.",
|
||||
"nanobot's gateway and WebUI take this at their next reply; restart an open `nanobot agent` chat to use it there.": "nanobots Gateway und WebUI übernehmen das bei der nächsten Antwort; einen offenen `nanobot agent`-Chat neu starten, damit es dort gilt.",
|
||||
"Restart miniQ to use this: its running daemon keeps the provider it started with.": "Starte miniQ neu, damit es gilt: sein laufender Daemon behält den Anbieter, mit dem er gestartet ist.",
|
||||
"Gemini CLI reads its settings at start-up — restart open gemini sessions to see this.": "Gemini CLI liest seine Einstellungen beim Start – offene gemini-Sitzungen neu starten, um es zu sehen.",
|
||||
"Goose loads its providers at start-up — quit and reopen Goose (and open goose sessions) to use magpie's models.": "Goose lädt seine Anbieter beim Start – Goose (und offene goose-Sitzungen) beenden und neu öffnen, um magpies Modelle zu nutzen.",
|
||||
"Grok Build reads its settings at start-up — restart open grok sessions to use this.": "Grok Build liest seine Einstellungen beim Start – offene grok-Sitzungen neu starten, damit es gilt.",
|
||||
@@ -19374,6 +19381,7 @@ const I18N = {
|
||||
"{agent} in WSL {distro} reads its config at start-up — restart open dsh sessions to use this.": "{agent} in WSL {distro} liest seine Konfiguration beim Start – offene dsh-Sitzungen neu starten, damit es gilt.",
|
||||
"{agent} in WSL {distro} reads its config at start-up — restart open empryo sessions to use this.": "{agent} in WSL {distro} liest seine Konfiguration beim Start – offene empryo-Sitzungen neu starten, damit es gilt.",
|
||||
"{agent} in WSL {distro}: its gateway and WebUI take this at their next reply; restart an open `nanobot agent` chat to use it there.": "{agent} in WSL {distro}: Gateway und WebUI übernehmen das bei der nächsten Antwort; einen offenen `nanobot agent`-Chat neu starten, damit es dort gilt.",
|
||||
"{agent} in WSL {distro}: magpie tells its running daemon; if it still answers with the old model, restart miniQ there.": "{agent} in WSL {distro}: magpie teilt es seinem laufenden Daemon mit; antwortet er weiter mit dem alten Modell, starte miniQ dort neu.",
|
||||
"{agent} in WSL {distro} reads its config at start-up — restart open mimo sessions to use this.": "{agent} in WSL {distro} liest seine Konfiguration beim Start – offene mimo-Sitzungen neu starten, damit es gilt.",
|
||||
"{agent} in WSL {distro} reads its config at start-up — restart open opencode sessions to use this.": "{agent} in WSL {distro} liest seine Konfiguration beim Start – offene opencode-Sitzungen neu starten, damit es gilt.",
|
||||
"{agent} in WSL {distro} reads its model when a session starts — restart open codebuddy sessions, or run /clear in them, to use this.": "{agent} in WSL {distro} liest sein Modell beim Start einer Sitzung – offene codebuddy-Sitzungen neu starten oder darin /clear ausführen, damit es gilt.",
|
||||
@@ -19584,6 +19592,7 @@ const NOTICES = [
|
||||
"Droid reads its settings at start-up — restart open droid sessions to use this.",
|
||||
"Empryo reads its config at start-up — restart open empryo sessions to use this.",
|
||||
"nanobot's gateway and WebUI take this at their next reply; restart an open `nanobot agent` chat to use it there.",
|
||||
"Restart miniQ to use this: its running daemon keeps the provider it started with.",
|
||||
"Gemini CLI reads its settings at start-up — restart open gemini sessions to see this.",
|
||||
"Goose loads its providers at start-up — quit and reopen Goose (and open goose sessions) to use magpie's models.",
|
||||
"Grok Build reads its settings at start-up — restart open grok sessions to use this.",
|
||||
@@ -19651,6 +19660,7 @@ const NOTICES = [
|
||||
"{agent} in WSL {distro} reads its config at start-up — restart open dsh sessions to use this.",
|
||||
"{agent} in WSL {distro} reads its config at start-up — restart open empryo sessions to use this.",
|
||||
"{agent} in WSL {distro}: its gateway and WebUI take this at their next reply; restart an open `nanobot agent` chat to use it there.",
|
||||
"{agent} in WSL {distro}: magpie tells its running daemon; if it still answers with the old model, restart miniQ there.",
|
||||
"{agent} in WSL {distro} reads its config at start-up — restart open mimo sessions to use this.",
|
||||
"{agent} in WSL {distro} reads its config at start-up — restart open opencode sessions to use this.",
|
||||
"{agent} in WSL {distro} reads its model when a session starts — restart open codebuddy sessions, or run /clear in them, to use this.",
|
||||
|
||||
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 17 KiB |
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 17 KiB |
@@ -519,6 +519,7 @@ footer a:hover { color: var(--ink); }
|
||||
<li><img src="/icons/meta-color.svg" alt="">Muse Code</li>
|
||||
<li><img src="/icons/empryo-color.svg" alt="">Empryo</li>
|
||||
<li><img src="/icons/nanobot-color.svg" alt="">nanobot</li>
|
||||
<li><img src="/icons/miniq-color.svg" alt="">miniQ</li>
|
||||
<li><img src="/icons/minimax-color.svg" alt="">MiniMax Code</li>
|
||||
<li><img class="bird" src="/icons/factory.svg" alt="">Droid</li>
|
||||
<li><img class="bird" src="/icons/xai.svg" alt="">Grok Build</li>
|
||||
|
||||
Reference in New Issue
Block a user