agent: Avibe, magpie as a model source through its Model Hub (alex_metacraft on X)

Avibe (avibe-bot/avibe, avibe-os on PyPI, the `vibe` CLI) runs its own
agent, Vibey, and Claude Code, Codex and OpenCode, all on models from its
Model Hub. Its sources live in model_hub.sources of config/config.json in
$AVIBE_HOME (else ~/.avibe, else a legacy ~/.vibe_remote), but a source
can't be written there by hand: its key is sealed in the hub's credential
store and Avibe puts it into its agents' route chains as it is made.

So the Avibe row adds "magpie" the way Avibe's Models page does, through
its internal API (POST /internal/model-hub on state/dispatch.sock, or on
Windows the loopback port + bearer of runtime/control-ipc/endpoint.json):
create_source with kind api_key, vendor custom, base_url the gateway's
/v1, key agentKey("avibe"), protocol openai_chat and save_unverified.
Avibe then lists the models from /v1/models and adds the source to
Vibey's, Claude's, Codex's and OpenCode's chains itself.

- openai_chat, not openai_responses: for a Responses source Avibe's
  CLIProxyAPI runs Codex's executor, which sends codex-tui headers the
  gateway would take for Codex.
- Off is delete_source with force, sent again with the would_remove_hops
  and would_interrupt Avibe answers, as its page confirms them. Sync is
  refresh_source the same way; on a moved gateway the source is made
  again (the key goes with the address; patch_source can't change it).
- The source id is stashed; a custom source at the gateway's /v1 counts
  as magpie's too and is stashed once seen.
- Every change needs Avibe running; otherwise the switch says to run
  `vibe start` (errAvibeDown). Nothing is written to config.json.
- A sync moves the source only from the gateway's own address on an
  older port (avibeMoved). One the user pointed at a NAS's or the LAN's
  magpie, a local proxy's route, or a WSL distro's way to Windows stays,
  as kept.away keeps every file-written agent's; a Rewire after a port
  move sets it again through the field's Set.
- Every test of the package but Avibe's own finds an Avibe running for
  each home (runningAvibe, served in-process), so the tests that connect
  every agent (gateway moved, LAN and proxy addresses kept, drift,
  ListOnly) take Avibe in too.
- The logo is a tile solid to its edges, so it joins app.css's tile rule
  (icon-tile.test.cjs went red without it).
- AVIBE_HOME joins agentenv and the ~-expanding path vars (Avibe expands
  it). Icon from Avibe's assets/logo.png (MIT), 64px.

Run:
- Real Avibe 3.2.5 (uv tool install avibe-os) in a sandbox HOME in WSL
  magpie-desktop, with a fake OpenAI server as the gateway: magpie's own
  code (a throwaway test, AVIBE_HOME + MAGPIE_ADDR) connected it, Avibe
  discovered both fake models with "Authorization: Bearer magpie-avibe"
  and put the source in vibey/claude/codex/opencode chains; Sync
  refreshed; a gateway move to :3592 made the source again there and
  stashed the new id; a second run found the source by address alone
  and still followed the move; off removed it (list_sources []).
  Earlier, by hand: Anthropic /v1/messages and /v1/responses through the
  hub reached the fake as chat completions.
- wsl-run, at this head rebased on origin/main 021a6e1fd (then 401187300, where the Avibe and all-agents tests, i18n-keys, icon-tile and the gui -run set were run again: ok on Linux and Windows): go test
  -tags nogui ./internal/agent ./internal/appdir ./internal/agentenv:
  appdir, agentenv ok; agent ok but TestGrokInstalled, red on WSL2 at
  main (#3548).
- win-run: the Avibe tests and the all-agents tests (drift, port move,
  LAN, proxy, ListOnly, pickers): ok. The whole internal/agent package
  on Windows (one commit earlier) has main's known Windows reds (#4115,
  #5068, #4846, #5130, #5344, ...); its two Avibe reds (drift, ListOnly)
  are what runningAvibe fixed.
- vet (on the Windows box): windows, GOOS=darwin, GOOS=linux nogui on
  agent/appdir/agentenv: ok.
  gofmt clean.
- GUI (chromium + webkit, win-run): i18n-keys, i18n-en-no-cjk,
  icon-one-tone, routing-client-icons, icon-tile: 63 of 63 ok; go test
  ./internal/gui -run 'Icon|Budget|CSS|I18n|Picker': ok.
- mote refused SSH all session, so everything ran on wsl-run/win-run.

Broken by hand:
- a sync moving any address that isn't the gateway's: the LAN- and
  proxy-kept tests red on Avibe's config.json.
- app.css without avibe in the tile rule: icon-tile.test.cjs red.
- protocol openai_responses: TestAvibeAddsMagpieAsAModelSource red.
- confirmed() not resending the echoed hops: the add, knows-its-source
  and follows-the-gateway tests red (source_in_route_chain).

Not tried: magpie on Windows wiring an Avibe that runs inside WSL; a
real Vibey turn against the real gateway (the fake stood in for it);
macOS with a real Avibe.
This commit is contained in:
yetone
2026-11-10 19:36:59 +08:00
parent e8fbee60ea
commit 9c39edb92c
16 changed files with 788 additions and 7 deletions
+1 -1
View File
@@ -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 · miniQ · MiniMax Code · Droid · Cline · Qoder · Qoder CN · Grok Build · Grok App · ZCode · WorkBuddy · WorkBuddy AI · CodeBuddy · Pencil · OpenPencil · OpenBot · Craft Agents · 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 · Craft Agents · NewMax · LiveAgent · Raycast · Kiro Crew · OpenMausBot · T3 Code · OpenHanako · AtomCode · Snow CLI · Alma · Cindy · Lody · AionUi · Cherry Studio · Ante · AstrBot · QwenPaw · OpenClaw · Avibe
</td></tr>
</table>
+1 -1
View File
@@ -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 · miniQ · MiniMax Code · Droid · Cline · Qoder · Qoder CN · Grok Build · Grok App · ZCode · WorkBuddy · WorkBuddy AI · CodeBuddy · Pencil · OpenPencil · OpenBot · Craft Agents · 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 · Craft Agents · NewMax · LiveAgent · Raycast · Kiro Crew · OpenMausBot · T3 Code · OpenHanako · AtomCode · Snow CLI · Alma · Cindy · Lody · AionUi · Cherry Studio · Ante · AstrBot · QwenPaw · OpenClaw · Avibe
</td></tr>
</table>
+1
View File
@@ -159,6 +159,7 @@ line; agents connected to magpie lose it when it quits.
| LiveAgent | `config.json` (JSONC, K-brain's) in `$LIVEAGENT_HOME`, else `$K_BRAIN_HOME`, else the folder `~/.liveagent/data-dir.json` points to, else `~/.liveagent` (every OS) | provider (`magpie`, `magpie-responses` and `magpie-anthropic` entries in its `providers`, each model on the one of the API it is served on natively: Chat Completions and Responses at the gateway's `/v1` as OpenAI providers whose request format the user can switch in LiveAgent and magpie keeps, Anthropic Messages at its root; magpie's models in its model picker; a model or provider of magpie's deleted in LiveAgent stays out; a default still K-brain's own demo model becomes magpie's first; refused while LiveAgent or its `k-brain` backend runs, as it writes its settings back whenever one changes) |
| T3 Code | `~/.t3/userdata/settings.json` (`$T3CODE_HOME/userdata`) | provider (a `magpie` provider instance on Claude Code, magpie's models as its custom models; a `magpie-codex` instance on Codex, whose `launchArgs` are Codex's own `-c` overrides to magpie and a `magpie-codex-models.json` catalog beside the settings. The harness is picked in T3's model picker) |
| OpenMausBot | `~/.openmausbot/config.json` (`$OMB_DATA_DIR`) | provider (a `magpie` engine in `instances`: OpenMausBot's own Claude endpoint shape, Claude Code with `ANTHROPIC_BASE_URL` at the gateway and magpie's models as its `endpointModels`, in its own `CLAUDE_CONFIG_DIR` under `providers/magpie`. With no `instances` saved, OpenMausBot's default engines are written beside it. OpenMausBot reads it when it starts) |
| Avibe | `~/.avibe/config/config.json` (`$AVIBE_HOME`; `~/.vibe_remote` from before 3.0), changed through its control socket `state/dispatch.sock` (Windows: `runtime/control-ipc/endpoint.json`) while it runs | provider (a `magpie` model source on its Models page: custom vendor, OpenAI chat completions at the gateway's `/v1`, with Avibe's own key; Avibe lists magpie's models from the gateway and adds the source to Vibey's, Claude Code's, Codex's and OpenCode's routes. Avibe has to be running to connect or disconnect it) |
| OpenHanako | `~/.hanako/provider-catalog.json` + `agents/<id>/config.yaml` (`$HANA_HOME`; its local API while it runs) | model (the primary agent's; magpie's models as a provider) |
| AtomCode | `~/.atomcode/config.toml` (`$ATOMCODE_HOME`) | model, effort (a `magpie` provider account, one model table per catalog model as its own sign-in writes) |
| Snow CLI | `~/.snow/profiles/magpie.json` (`$SNOW_CONFIG_DIR`), made the active profile and copied to `config.json` | model (the user's other profiles' models too; Snow App takes the profile in with "Sync Snow CLI API config") |
+2 -1
View File
@@ -51,7 +51,7 @@ something else shows up as drift.
- magpie only removes what it wrote. Anything else in an agent's config stays as it was.
- agy's shell function (`update.ShellFunction`, [`shellfn.go`](../../internal/update/shellfn.go)) sits between `# >>> magpie agy >>>` and `# <<< magpie agy <<<`, the only lines magpie writes or takes out of a profile. The profiles are those `cliProfile` names (zsh's in `ZDOTDIR` when set, bash's, fish's `config.fish`), plus PowerShell 7's and Windows PowerShell's on Windows when their execution policy runs a profile. A missing profile is made only for the shell a terminal opens. Only a file inside the home is written, writes go through temp-and-rename, and a profile that can't be read is left alone. Picking one of magpie's models and every `Sync` on one put it there, which covers users wired before it existed. Stepping out and a `Sync` off magpie take it out. agy in a WSL distro gets the function in the distro's own profiles (`agyDistroProfiles` in [`agy.go`](../../internal/agent/agy.go), through `update.ShellFunctionAt`): `~/.bashrc`, `~/.zshrc` and `~/.config/fish/config.fish` where each is, and the profile of the login shell the distro's `/etc/passwd` names (bash when it names none) made where it isn't. The distro's `ZDOTDIR` and `XDG_CONFIG_HOME` aren't read. No magpie runs there, so the function (`agyDistroFunction`) reads `settings.json`'s model with `sed` and carries the gateway's address as the distro reaches it (`place.gw`, Windows' under NAT) and the key it takes from there (`agentKeyAt`, the WSL key under NAT). `Sync` writes it again, so an address WSL changed on a restart follows, and until then `Check` reports a function naming another address. A user's own `alias agy` still wins over it. A terminal opened before the change still needs the `Launch` command.
- A sync brings magpie's models up to date, not where the agent reaches magpie. Every `Sync` that `SyncCatalog` runs (each start and update of magpie, a provider added, and a plugin signed in to, out of or renewed, or listing other models than the last time: `plugin.OnChange` and `plugin.OnListed` call `catalog.Touched`, #2373) goes through `synced`, which passes each file written through `kept.away` (`edit.Filtered`, [`keptaway.go`](../../internal/agent/keptaway.go)). The filter sees every file written through `edit` while it is on, from any goroutine and under whatever lock the writer holds, so it takes none a writer may hold: the gateway's address and the LAN key are read before it is on (`keeping`), and magpie's own files (`magpieFile`: its folder as named or where its links lead, such as a `~/.config` linked into a dotfiles repo) are left as they are (ylorn on Discord: `settings.Save` under the settings' lock reached a filter that read the settings, and the app hung ~10s after every start; `TestOwnWritesDuringASyncWithALinkedConfig`). In a file without the gateway's own address, whose magpie the user pointed at an address on another machine (a NAS's, or this machine's LAN address), and with no address a WSL distro was seen at, that address stays in place of `gateway.URL()`, with the path before magpie's every URL at it had (`awayPath`: a reverse proxy's `/magpie`; on loopback, a local proxy's route where magpie answered or hasn't been asked), and so does the key that went with it in place of magpie's own (coeo91 on Discord: the base URL went back to 127.0.0.1 after an update or restart). An address on this machine's loopback follows the gateway; with more than one address or key gone, the write is left as it is. Picking a model in magpie still points the agent at this magpie, but for Claude Code at a proxy to it (above). ZCode and WorkBuddy keep such an address in their own writers too (`zcodeAddress`, `buddyWriteAt`).
- An agent whose `Sync` does nothing but bring a block of magpie's name up to the catalog is `ListOnly` (OpenCode, MiMo Code and the other OpenCode forms, Pi and its forks, Goose, Crush, Air, AtomCode, Command Code, Droid, Fx, jcode, Kimi, MiniMax, Mothx, omp, OpenChamber, OpenClaw, OpenMausBot, OpenPencil, Penguin, Qwen Code, T3 Code). `SyncCatalog` runs it only while the agent is connected (`Wired`), as its switch on the Agents page says: a custom provider the user named magpie in the agent, with a few models picked by hand, was written over with the whole catalog at every start (yyddbds on Discord, Xiaomi MiMo; `TestCatalogSyncLeavesAHandWrittenMagpieBlock`). A list magpie wrote while connected waits, while the agent runs a model of its own, until a model of magpie's is picked again; a model of magpie's picked by hand on a provider the user wrote doesn't connect it (`handWired`, above). Every `ListOnly` agent magpie connects reads as `Wired` (`TestListOnlyAgentsReadConnected`). Agents whose `Sync` also repairs while not connected (Codex, Claude, Grok, Hermes' bots) are not `ListOnly`. magpie keeps no copy of a list it wrote over before this, so such a list stays full until the user trims it.
- An agent whose `Sync` does nothing but bring a block of magpie's name up to the catalog is `ListOnly` (OpenCode, MiMo Code and the other OpenCode forms, Pi and its forks, Goose, Crush, Air, AtomCode, Command Code, Droid, Fx, jcode, Kimi, MiniMax, Mothx, omp, OpenChamber, OpenClaw, OpenMausBot, Avibe, OpenPencil, Penguin, Qwen Code, T3 Code). `SyncCatalog` runs it only while the agent is connected (`Wired`), as its switch on the Agents page says: a custom provider the user named magpie in the agent, with a few models picked by hand, was written over with the whole catalog at every start (yyddbds on Discord, Xiaomi MiMo; `TestCatalogSyncLeavesAHandWrittenMagpieBlock`). A list magpie wrote while connected waits, while the agent runs a model of its own, until a model of magpie's is picked again; a model of magpie's picked by hand on a provider the user wrote doesn't connect it (`handWired`, above). Every `ListOnly` agent magpie connects reads as `Wired` (`TestListOnlyAgentsReadConnected`). Agents whose `Sync` also repairs while not connected (Codex, Claude, Grok, Hermes' bots) are not `ListOnly`. magpie keeps no copy of a list it wrote over before this, so such a list stays full until the user trims it.
- `SyncCatalog` holds the catalog it builds (`provider.Hold`), the plugins' providers and sign-ins among it, for up to a second. Those `catalog.Touched` drops are told in the background, so a plugin change also drops what is held at once (`plugin.OnChangeNow`, [`hold.go`](../../internal/provider/hold.go)): the host's "auth" event is read before its reply to the sign-in that saved it, and a look at the accounts once the sign-in returns sees it (#2449: `magpie plugin login` found no account while a sync ran; `TestHeldGoesWithAPluginChange`).
- JetBrains Air's `magpie-opencode.json` keeps user-added fields in `provider.magpie`, including nested options, on sync and model picks (`air` in [`air.go`](../../internal/agent/air.go), using `theirsKept` in [`sync.go`](../../internal/agent/sync.go)). The gateway fields and complete model list are still replaced, so removed models leave the list.
- Air comes in two forms that read different files, both wired by `airAt` in [`air.go`](../../internal/agent/air.go). The Air app (`air`) reads `acp.json` in its own config folder. The Air plugin in JetBrains IDEs (`air-ide`; bundled from 2026.3, from Marketplace in 2026.2) reads `~/.jetbrains/acp.json` on every system, the file AI Assistant's custom agents are in too (`AcpConfigurationLoader` in the plugin's `intellij.air.backend.acp.runtime`, checked in air-plugin 262.8665.521). Each gets its own Magpie entry and `magpie-opencode.json` beside its `acp.json`. `air-ide` shows for an IDE config folder of 2026.2 or later, or with its entry already there (`TestAirIDEDetectedByIDEVersion`). Neither has a base URL for its own agents (JetBrains AI, the agent's login, or an Anthropic, OpenAI, Gemini or OpenRouter key); The plugin's Codex on its own login runs this computer's `codex` (the terminal's `PATH`, else the `@openai/codex` it installs) as `codex app-server` with the user's `CODEX_HOME` or `~/.codex`, and sets no `model_provider` (`CodexAppServerProcessKt`); its menu is Codex's `model/list` and its default `config/read`'s model. Its Claude Agent runs `claude` with only Air's hooks in `--settings`. So both go through magpie while Codex and Claude Code are connected here. The Air app's Codex runs with a `CODEX_HOME` of its own and JetBrains' gateway (`codexRuntimeEnvironment`, `[model_providers.air-gateway]`), and never does. The model on either Air row is the Magpie agent's alone, and the opened row says which of Air's own agents go through magpie (`airSaid` in `app.js`, `agent-air-own.test.cjs`; jumy_18634 on Discord).
@@ -129,6 +129,7 @@ something else shows up as drift.
- Claude Code's tool search (`ENABLE_TOOL_SEARCH`, `claudeSearchEnv` in [`claude.go`](../../internal/agent/claude.go)) is written `"true"` while Claude Code is routed through magpie. On, MCP tools are named in a reminder and loaded by `ToolSearch` when the model needs them, not sent whole on every request. Claude Code before 2.1.304 keeps it off behind an `ANTHROPIC_BASE_URL` other than Anthropic's, so the MCP router's tools all went on each request (cybercaius on Discord: 245 tools, 124K tokens of a 341K context; 2.1.290 through a sandbox gateway sent 242,346 bytes of tools, 27,443 with it on); 2.1.304 and later turn it on there themselves, and `"true"` also keeps it on in a conversation begun without it. The gateway carries deferred tools to every upstream (`Tool.Deferred`, `withoutDeferredTools`). magpie's value is kept apart in the stash (`claude.tool_search`); a value the user set, an empty one too, is theirs; it goes when Claude Code is taken off magpie (`desktopOnly`, `unroute`; `TestClaudeToolSearchOn`). T3 Code's magpie instance carries `"true"` in its environment unless the user gave it a value there (`TestT3CodeToolSearchOn`).
- 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.
- Avibe (`avibe.go`, `avibe-os` on PyPI, the `vibe` CLI) keeps its model sources in `model_hub.sources` of `config/config.json` in its home (`$AVIBE_HOME`, else `~/.avibe`, else a legacy `~/.vibe_remote`: `config/paths.py`). A source can't be written there by hand: its key is sealed in the Model Hub's store and Avibe adds it to its agents' route chains as it is made. So magpie adds the `magpie` source through the same internal API Avibe's Models page uses (`POST /internal/model-hub`, `core/handlers/model_hub/rpc.py`) on the control socket `state/dispatch.sock` in its home, or on Windows the loopback port and bearer token in `runtime/control-ipc/endpoint.json` (`core/control_ipc.py`). `create_source` makes an `api_key` source of vendor `custom` at the gateway's `/v1` with `agentKey("avibe")`, protocol `openai_chat` and `save_unverified` (Avibe's probe can't tell which protocol a gateway serving all of them speaks); Avibe then lists the models from `/v1/models` itself. Chat completions, not Responses: for a Responses source its CLIProxyAPI runs Codex's executor, which sends `codex-tui` headers the gateway would take for Codex. Its id is stashed (`avibe.source:<home>`); a source of the custom vendor at the gateway's `/v1` counts as magpie's too. `delete_source` and `refresh_source` are sent with `force` and then again with the `would_remove_hops` and `would_interrupt` Avibe answers with, as its page confirms them. A gateway address change makes the source again (the key goes with the address and `patch_source` can't change it). Every change needs Avibe running (`avibeLive` probes `list_sources`; `errAvibeDown`); `Sync` refreshes the source's models while it runs.
- 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`).
+1
View File
@@ -322,6 +322,7 @@ func onMachine(home, cfg string) []*Agent {
kiroCrew(home),
t3code(home),
openMausBot(home),
avibe(home),
hanako(home),
atomcode(home),
snow(home),
+406
View File
@@ -0,0 +1,406 @@
package agent
// Avibe (avibe-bot/avibe, MIT, the avibe-os package and its `vibe` CLI) is
// a local agent OS: its own agent, Vibey, and the Claude Code, Codex and
// OpenCode it runs all take their models from its Model Hub, a gateway of
// its own (CLIProxyAPI) in front of the model sources added on its Models
// page. Its home is $AVIBE_HOME, else ~/.avibe (~/.vibe_remote before 3.0:
// config/paths.py), and the sources are model_hub.sources in
// config/config.json there.
//
// magpie is one such source, "magpie": an API-key source of the custom
// vendor at the gateway's /v1, spoken to as chat completions with an agent
// key of Avibe's own. A hub source serves every backend
// (source_eligible_for_backend), the Model Hub translating Claude's and
// Codex's requests, and Avibe lists its models from the gateway's
// /v1/models itself, so the models picked for Avibe on the Agents page
// are what it offers.
//
// Chat completions rather than Responses: for a Responses source the Model
// Hub runs Codex's executor, which names itself codex-tui and would be
// taken for Codex itself (fromCodex); for chat it passes the backend's own
// headers on.
//
// A source can't be written into config.json by hand: each is checked
// whole, its key lives in the Model Hub's store under a credential_ref, and
// Avibe adds it to its agents' route chains as it is added. So magpie adds
// and removes it as Avibe's Models page does, through Avibe's internal API
// (core/handlers/model_hub/rpc.py), while Avibe runs:
//
// POST /internal/model-hub {"operation": "create_source"|"delete_source"|"refresh_source", "payload": {…}}
//
// on the socket state/dispatch.sock in its home (core/control_ipc.py), or
// on Windows at the loopback port runtime/control-ipc/endpoint.json gives
// with its bearer token. The source's id is stashed, so a renamed one is
// still magpie's.
import (
"bytes"
"context"
"encoding/json"
"errors"
"fmt"
"io"
"net"
"net/http"
"os"
"path/filepath"
"runtime"
"strings"
"time"
"github.com/yetone/magpie/internal/appdir"
"github.com/yetone/magpie/internal/edit"
)
// avibeStash is the stash key for the id of magpie's source in the Avibe
// at dir.
func avibeStash(dir string) string { return "avibe.source:" + dir }
// errAvibeDown is a change asked of an Avibe that isn't running.
var errAvibeDown = errors.New("Avibe adds and removes model sources only while it runs: start it (vibe start), then try again")
func avibe(home string) *Agent {
dir := avibeHome(home)
path := filepath.Join(dir, "config", "config.json")
wired := func() bool { _, ok := avibeOurs(dir, path); return ok }
return &Agent{
ID: "avibe", Name: "Avibe", Icon: "avibe", Aliases: []string{"vibe", "vibey", "avibe-os"},
Dir: dir, Path: path,
detect: func() bool { return isDir(dir) },
ListsModels: true,
ListOnly: true,
// a model picked or dropped for Avibe reaches its source when it
// lists the gateway's models again; Avibe does that itself only
// for a listing older than half an hour
Sync: func() error {
src, ok := avibeOurs(dir, path)
if !ok {
return nil
}
c := avibeLive(dir)
if c == nil {
return nil
}
if avibeMoved(src.BaseURL) {
return avibeWire(c, dir, src, true)
}
avibeKeep(dir, src.ID)
return c.confirmed("refresh_source", map[string]any{"source_id": src.ID})
},
Check: func() string {
src, ok := avibeOurs(dir, path)
if !ok {
return ""
}
return wiringOff("Avibe", path, func(string) (string, bool) { return strings.TrimSuffix(src.BaseURL, "/"), true }, "base_url", gatewayV1())
},
Fields: []Field{{
Key: "provider", Label: "provider",
Get: func() string {
if wired() {
return magpieID
}
return ""
},
Set: func(v string) error {
src, there := avibeOurs(dir, path)
if v == "" && !there {
return nil
}
if v != "" && there && strings.TrimSuffix(src.BaseURL, "/") == gatewayV1() {
avibeKeep(dir, src.ID)
return nil
}
c := avibeLive(dir)
if c == nil {
return errAvibeDown
}
if v == "" {
if err := c.confirmed("delete_source", map[string]any{"source_id": src.ID}); err != nil {
return err
}
forget(avibeStash(dir))
return nil
}
return avibeWire(c, dir, src, there)
},
Options: func(map[string]string) []Option {
return []Option{{Value: magpieID, Label: "magpie", Icon: "magpie", Note: "a model source on Avibe's Models page, for Vibey and the agents it runs"}}
},
}},
}
}
// avibeWire adds magpie's source to the Avibe c serves, in place of src
// when there is one: its key is sealed in the Model Hub and goes with the
// gateway's address, so a source on an old address is made again rather
// than patched.
func avibeWire(c *avibeClient, dir string, src avibeSource, there bool) error {
if there {
if err := c.confirmed("delete_source", map[string]any{"source_id": src.ID}); err != nil {
return err
}
}
id, err := c.create()
if err != nil {
return err
}
stash(map[string]string{avibeStash(dir): id})
return nil
}
// avibeStashed is the id of the source magpie added to the Avibe at dir.
func avibeStashed(dir string) string {
stashMu.Lock()
defer stashMu.Unlock()
return stashShared()[avibeStash(dir)]
}
// avibeKeep stashes id as magpie's source in the Avibe at dir, one found
// by its address (added by hand, or before the stash was lost), so it is
// still known once the gateway moves.
func avibeKeep(dir, id string) {
if avibeStashed(dir) != id {
stash(map[string]string{avibeStash(dir): id})
}
}
// avibeHome is Avibe's home: $AVIBE_HOME, else ~/.avibe, else the
// ~/.vibe_remote of an Avibe from before the move (paths.py's
// get_vibe_remote_dir).
func avibeHome(home string) string {
if d := strings.TrimSpace(appdir.Getenv("AVIBE_HOME")); d != "" {
if rest, ok := strings.CutPrefix(d, "~"); ok && (rest == "" || rest[0] == '/' || rest[0] == filepath.Separator) {
d = home + rest
}
if abs, err := filepath.Abs(d); err == nil {
d = abs
}
return d
}
d := filepath.Join(home, ".avibe")
if _, err := os.Lstat(d); err != nil {
if legacy := filepath.Join(home, ".vibe_remote"); isDir(legacy) {
return legacy
}
}
return d
}
// avibeSource is a model source as config.json keeps it.
type avibeSource struct {
ID string `json:"id"`
Vendor string `json:"vendor"`
DisplayName string `json:"display_name"`
BaseURL string `json:"base_url"`
}
// avibeOurs is magpie's source in the config.json at path: the one whose
// id magpie stashed when it added it, else one of the custom vendor at the
// gateway (added by hand on Avibe's Models page).
func avibeOurs(dir, path string) (avibeSource, bool) {
raw, ok := edit.GetJSON(path, "model_hub.sources")
if !ok {
return avibeSource{}, false
}
var srcs []avibeSource
if json.Unmarshal([]byte(raw), &srcs) != nil {
return avibeSource{}, false
}
if id := avibeStashed(dir); id != "" {
for _, s := range srcs {
if s.ID == id {
return s, true
}
}
}
for _, s := range srcs {
if s.ID != "" && s.Vendor == "custom" && strings.TrimSuffix(s.BaseURL, "/") == gatewayV1() {
return s, true
}
}
return avibeSource{}, false
}
// avibeProbe gives up quickly: an Avibe that doesn't answer at once isn't
// running.
const avibeProbe = 1500 * time.Millisecond
// avibeWait is how long a change may take: adding a source lists its
// models, and removing one rewrites every route chain it is in.
const avibeWait = 30 * time.Second
// avibeClient is a running Avibe's internal API.
type avibeClient struct {
http *http.Client
base string
token string
}
// avibeMoved says base, magpie's source's address, is the gateway's own
// on an older port, which a sync moves to where the gateway is now. One
// the user pointed at magpie on another machine (a NAS's, the LAN
// address), through a local proxy's route (a path before /v1), or the way
// a WSL distro reaches Windows stays where it is, as every other agent's
// sync keeps it (kept.away).
func avibeMoved(base string) bool {
base = strings.TrimSuffix(base, "/")
if base == gatewayV1() {
return false
}
root := strings.TrimSuffix(base, "/v1")
return root != base && !onAnotherMachine(root) && !loopbackWithPath(root) && !wslHost(root)
}
// avibeLive is avibeConnect, for the tests to stand in for.
var avibeLive = avibeConnect
// avibeConnect is the internal API of the Avibe at dir if it answers, nil
// if it isn't running: its socket, or on Windows its endpoint file,
// outlives a crash.
func avibeConnect(dir string) *avibeClient {
c := avibeAt(dir)
if c == nil {
return nil
}
ctx, cancel := context.WithTimeout(context.Background(), avibeProbe)
defer cancel()
if _, err := c.callCtx(ctx, "list_sources", map[string]any{}); err != nil {
return nil
}
return c
}
// avibeAt is where the Avibe at dir listens, as its own CLI finds it
// (control_ipc.py's resolve_client_endpoint), or nil with nothing there.
func avibeAt(dir string) *avibeClient {
if runtime.GOOS == "windows" {
b, err := os.ReadFile(filepath.Join(dir, "runtime", "control-ipc", "endpoint.json"))
if err != nil {
return nil
}
var d struct {
Transport string `json:"transport"`
Host string `json:"host"`
Port int `json:"port"`
Token string `json:"bearer_token"`
}
if json.Unmarshal(b, &d) != nil || d.Transport != "tcp" || d.Host != "127.0.0.1" || d.Port <= 0 || d.Port > 65535 || d.Token == "" {
return nil
}
return &avibeClient{http: &http.Client{}, base: fmt.Sprintf("http://127.0.0.1:%d", d.Port), token: d.Token}
}
sock := filepath.Join(dir, "state", "dispatch.sock")
if fi, err := os.Stat(sock); err != nil || fi.Mode()&os.ModeSocket == 0 {
return nil
}
tr := &http.Transport{DialContext: func(ctx context.Context, _, _ string) (net.Conn, error) {
var d net.Dialer
return d.DialContext(ctx, "unix", sock)
}}
return &avibeClient{http: &http.Client{Transport: tr}, base: "http://localhost"}
}
// avibeError is a refusal from Avibe's Model Hub.
type avibeError struct {
Code, Detail string
// what it would take away, for a change it asks to have confirmed
Hops, Interrupts json.RawMessage
}
func (e *avibeError) Error() string {
msg := "Avibe: " + e.Code
if e.Detail != "" && e.Detail != "modelHub.errors."+e.Code {
msg += " (" + e.Detail + ")"
}
return msg
}
func (c *avibeClient) call(op string, payload map[string]any) (json.RawMessage, error) {
ctx, cancel := context.WithTimeout(context.Background(), avibeWait)
defer cancel()
return c.callCtx(ctx, op, payload)
}
func (c *avibeClient) callCtx(ctx context.Context, op string, payload map[string]any) (json.RawMessage, error) {
b, err := json.Marshal(map[string]any{"operation": op, "payload": payload})
if err != nil {
return nil, err
}
req, err := http.NewRequestWithContext(ctx, "POST", c.base+"/internal/model-hub", bytes.NewReader(b))
if err != nil {
return nil, err
}
req.Header.Set("Content-Type", "application/json")
if c.token != "" {
req.Header.Set("Authorization", "Bearer "+c.token)
}
resp, err := c.http.Do(req)
if err != nil {
return nil, fmt.Errorf("Avibe: %w", err)
}
defer resp.Body.Close()
var out struct {
OK bool `json:"ok"`
Result json.RawMessage `json:"result"`
Error string `json:"error"`
Detail string `json:"detail"`
Hops json.RawMessage `json:"would_remove_hops"`
Interrupts json.RawMessage `json:"would_interrupt"`
}
if err := json.NewDecoder(io.LimitReader(resp.Body, 32<<20)).Decode(&out); err != nil {
return nil, fmt.Errorf("Avibe: %s %s: %w", resp.Status, op, err)
}
if !out.OK {
if out.Error == "" {
out.Error = resp.Status
}
return nil, &avibeError{Code: out.Error, Detail: out.Detail, Hops: out.Hops, Interrupts: out.Interrupts}
}
return out.Result, nil
}
// confirmed runs a change Avibe may ask to have confirmed first, as its
// Models page does when a source leaves routes behind: asked again with
// what it said it would take away. The user asked for it in magpie.
func (c *avibeClient) confirmed(op string, payload map[string]any) error {
payload["force"] = true
_, err := c.call(op, payload)
var e *avibeError
if !errors.As(err, &e) || (len(e.Hops) == 0 && len(e.Interrupts) == 0) {
return err
}
if len(e.Hops) > 0 {
payload["would_remove_hops"] = e.Hops
}
if len(e.Interrupts) > 0 {
payload["would_interrupt"] = e.Interrupts
}
_, err = c.call(op, payload)
return err
}
// create adds magpie's source and gives its id. It is saved without
// Avibe's protocol probe, which can't tell the gateway's protocols apart
// (it serves them all), and lists its models from the gateway at once.
func (c *avibeClient) create() (string, error) {
res, err := c.call("create_source", map[string]any{"source": map[string]any{
"kind": "api_key", "vendor": "custom", "display_name": magpieID,
"base_url": gatewayV1(), "key": agentKey("avibe"),
"protocol": "openai_chat", "supply_channel": "hub", "billing": "metered",
"save_unverified": true,
}})
if err != nil {
return "", err
}
var out struct {
Source struct {
ID string `json:"id"`
} `json:"source"`
}
if json.Unmarshal(res, &out) != nil || out.Source.ID == "" {
return "", errors.New("Avibe added no source")
}
return out.Source.ID, nil
}
+361
View File
@@ -0,0 +1,361 @@
package agent
import (
"encoding/json"
"errors"
"fmt"
"net"
"net/http"
"net/http/httptest"
"os"
"path/filepath"
"runtime"
"slices"
"strings"
"sync"
"testing"
"github.com/yetone/magpie/internal/edit"
)
// fakeAvibe is Avibe's internal Model Hub API (core/handlers/model_hub/
// rpc.py) as magpie uses it, over the control socket of the home it serves
// (on Windows, the loopback port and bearer token of its endpoint file),
// keeping its sources in config/config.json as Avibe does. A source in a
// route chain is removed or refreshed only when asked again with what
// that takes away, as Avibe's own page confirms it.
type fakeAvibe struct {
dir string
mu sync.Mutex
ops []string
created []map[string]any
refresh int
next int
}
func serveFakeAvibe(t *testing.T, dir string) *fakeAvibe {
t.Helper()
f := &fakeAvibe{dir: dir}
if err := os.MkdirAll(filepath.Join(dir, "config"), 0o700); err != nil {
t.Fatal(err)
}
f.write(nil)
var ln net.Listener
var err error
token := ""
if runtime.GOOS == "windows" {
ln, err = net.Listen("tcp", "127.0.0.1:0")
if err != nil {
t.Fatal(err)
}
token = "tok-" + t.Name()
desc := filepath.Join(dir, "runtime", "control-ipc", "endpoint.json")
os.MkdirAll(filepath.Dir(desc), 0o700)
b, _ := json.Marshal(map[string]any{"schema_version": 1, "transport": "tcp", "host": "127.0.0.1", "port": ln.Addr().(*net.TCPAddr).Port, "instance_id": "x", "bearer_token": token})
os.WriteFile(desc, b, 0o600)
} else {
sock := filepath.Join(dir, "state", "dispatch.sock")
os.MkdirAll(filepath.Dir(sock), 0o700)
ln, err = net.Listen("unix", sock)
if err != nil {
t.Fatal(err)
}
}
srv := &http.Server{Handler: f.handler(token)}
go srv.Serve(ln)
t.Cleanup(func() { srv.Close() })
t.Setenv("AVIBE_HOME", dir)
was := avibeLive
avibeLive = avibeConnect
t.Cleanup(func() { avibeLive = was })
return f
}
// handler is the API, asking for token as Windows' endpoint does.
func (f *fakeAvibe) handler(token string) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.Method != "POST" || r.URL.Path != "/internal/model-hub" || (token != "" && r.Header.Get("Authorization") != "Bearer "+token) {
http.Error(w, "no", http.StatusNotFound)
return
}
var req struct {
Operation string `json:"operation"`
Payload map[string]any `json:"payload"`
}
json.NewDecoder(r.Body).Decode(&req)
res, code, detail := f.handle(req.Operation, req.Payload)
w.Header().Set("Content-Type", "application/json")
if code != "" {
w.WriteHeader(http.StatusConflict)
out := map[string]any{"ok": false, "error": code, "detail": "modelHub.errors." + code}
for k, v := range detail {
out[k] = v
}
json.NewEncoder(w).Encode(out)
return
}
json.NewEncoder(w).Encode(map[string]any{"ok": true, "result": res})
})
}
// runningAvibes are the Avibes every test but avibe_test.go's own finds
// running (main_test.go), one a home, served in the process: an Avibe takes
// magpie only while it runs, so without one the tests that connect every
// agent (a gateway moved, a LAN or proxy address kept) would leave it out.
var runningAvibes = struct {
sync.Mutex
at map[string]*fakeAvibe
}{at: map[string]*fakeAvibe{}}
func runningAvibe(dir string) *avibeClient {
runningAvibes.Lock()
f := runningAvibes.at[dir]
if f == nil {
f = &fakeAvibe{dir: dir}
runningAvibes.at[dir] = f
}
runningAvibes.Unlock()
return &avibeClient{http: &http.Client{Transport: handlerTransport{f.handler("")}}, base: "http://localhost"}
}
type handlerTransport struct{ h http.Handler }
func (t handlerTransport) RoundTrip(r *http.Request) (*http.Response, error) {
w := httptest.NewRecorder()
t.h.ServeHTTP(w, r)
return w.Result(), nil
}
func (f *fakeAvibe) sources() []map[string]any {
raw, _ := edit.GetJSON(filepath.Join(f.dir, "config", "config.json"), "model_hub.sources")
var out []map[string]any
json.Unmarshal([]byte(raw), &out)
return out
}
func (f *fakeAvibe) write(srcs []map[string]any) {
os.MkdirAll(filepath.Join(f.dir, "config"), 0o700)
if srcs == nil {
srcs = []map[string]any{}
}
b, _ := json.MarshalIndent(map[string]any{"model_hub": map[string]any{"sources": srcs}, "language": "zh"}, "", " ")
os.WriteFile(filepath.Join(f.dir, "config", "config.json"), b, 0o600)
}
// confirms says the payload repeats what removing the source takes away.
func confirms(p map[string]any) bool {
hops, _ := p["would_remove_hops"].([]any)
return p["force"] == true && len(hops) == 1 && fmt.Sprint(hops[0]) == "vibey:0"
}
func (f *fakeAvibe) handle(op string, p map[string]any) (any, string, map[string]any) {
f.mu.Lock()
defer f.mu.Unlock()
f.ops = append(f.ops, op)
srcs := f.sources()
find := func() int {
return slices.IndexFunc(srcs, func(s map[string]any) bool { return s["id"] == p["source_id"] })
}
inChain := map[string]any{"would_remove_hops": []string{"vibey:0"}, "would_interrupt": []string{}}
switch op {
case "list_sources":
return map[string]any{"sources": srcs}, "", nil
case "create_source":
s, _ := p["source"].(map[string]any)
f.created = append(f.created, s)
f.next++
id := fmt.Sprintf("src_%d", f.next)
saved := map[string]any{"id": id, "kind": s["kind"], "vendor": s["vendor"], "display_name": s["display_name"], "base_url": s["base_url"], "protocol": s["protocol"]}
f.write(append(srcs, saved))
return map[string]any{"source": saved}, "", nil
case "delete_source":
i := find()
if i < 0 {
return nil, "source_not_found", nil
}
if !confirms(p) {
return nil, "source_in_route_chain", inChain
}
f.write(slices.Delete(srcs, i, i+1))
return map[string]any{"deleted": true}, "", nil
case "refresh_source":
if find() < 0 {
return nil, "source_not_found", nil
}
if !confirms(p) {
return nil, "source_in_route_chain", inChain
}
f.refresh++
return map[string]any{}, "", nil
}
return nil, "unknown_operation", nil
}
// avibeTestHome is a home for Avibe short enough for a unix socket's path
// (104 bytes on macOS, which t.TempDir's names can pass).
func avibeTestHome(t *testing.T) string {
t.Helper()
syncHome(t)
d, err := os.MkdirTemp("", "avb")
if err != nil {
t.Fatal(err)
}
t.Cleanup(func() { os.RemoveAll(d) })
return filepath.Join(d, ".avibe")
}
// Connecting Avibe adds magpie as a model source through Avibe's own API,
// as its Models page does: an API-key source of the custom vendor at the
// gateway's /v1, spoken to as chat completions (a Responses source would
// reach the gateway as Codex) with Avibe's own key, saved without the probe
// that can't tell the gateway's protocols apart. Disconnecting removes it,
// confirming the routes it leaves, as Avibe asks (alex_metacraft on X).
func TestAvibeAddsMagpieAsAModelSource(t *testing.T) {
dir := avibeTestHome(t)
f := serveFakeAvibe(t, dir)
a := avibe(os.Getenv("HOME"))
if a.Dir != dir || !a.Detected() {
t.Fatalf("Avibe at %s not found (%s)", dir, a.Dir)
}
if a.Wired() {
t.Fatal("wired before it was connected")
}
if err := a.Field("provider").Set(magpieID); err != nil {
t.Fatal(err)
}
if len(f.created) != 1 {
t.Fatalf("created %v", f.created)
}
s := f.created[0]
for k, v := range map[string]any{"kind": "api_key", "vendor": "custom", "display_name": "magpie", "base_url": gatewayV1(), "key": agentKey("avibe"), "protocol": "openai_chat", "save_unverified": true} {
if s[k] != v {
t.Errorf("source %s = %v, want %v", k, s[k], v)
}
}
if got := a.Field("provider").Get(); got != magpieID || !a.Wired() {
t.Errorf("connected source not read back: %q", got)
}
if msg := a.Check(); msg != "" {
t.Errorf("Check: %s", msg)
}
// connecting again adds no second source
if err := a.Field("provider").Set(magpieID); err != nil || len(f.created) != 1 {
t.Errorf("connected twice: %v %d", err, len(f.created))
}
if err := a.Sync(); err != nil || f.refresh != 1 {
t.Errorf("Sync didn't list the gateway's models again: %v, %d refreshes", err, f.refresh)
}
if err := a.Field("provider").Set(""); err != nil {
t.Fatal(err)
}
if n := len(f.sources()); n != 0 || a.Wired() {
t.Errorf("source still there after disconnect: %v", f.sources())
}
if avibeStashed(dir) != "" {
t.Error("source id still stashed")
}
}
// A source the user renamed in Avibe is still magpie's (its id was
// stashed); one they added by hand at the gateway is too; a source of
// their own elsewhere is never touched.
func TestAvibeKnowsItsSource(t *testing.T) {
dir := avibeTestHome(t)
f := serveFakeAvibe(t, dir)
mine := map[string]any{"id": "src_mine", "vendor": "openai", "display_name": "OpenAI", "base_url": "https://api.openai.com/v1"}
f.write([]map[string]any{mine, {"id": "src_hand", "vendor": "custom", "display_name": "gw", "base_url": gatewayV1() + "/"}})
a := avibe(os.Getenv("HOME"))
if !a.Wired() {
t.Fatal("a source at the gateway added by hand isn't read as connected")
}
// it is magpie's from then on, wherever the gateway goes
if err := a.Field("provider").Set(magpieID); err != nil || len(f.created) != 0 || avibeStashed(dir) != "src_hand" {
t.Errorf("connect over one added by hand: %v, %d made, stash %q", err, len(f.created), avibeStashed(dir))
}
if err := a.Field("provider").Set(""); err != nil {
t.Fatal(err)
}
if got := f.sources(); len(got) != 1 || got[0]["id"] != "src_mine" {
t.Fatalf("after disconnect: %v", got)
}
if err := a.Field("provider").Set(magpieID); err != nil {
t.Fatal(err)
}
srcs := f.sources()
srcs[1]["display_name"] = "my gateway"
f.write(srcs)
if !a.Wired() {
t.Error("renamed source not read as magpie's")
}
}
// The gateway on another address: the key goes with the address, so the
// source is made again there rather than left pointing at the old one.
func TestAvibeFollowsTheGateway(t *testing.T) {
dir := avibeTestHome(t)
f := serveFakeAvibe(t, dir)
a := avibe(os.Getenv("HOME"))
if err := a.Field("provider").Set(magpieID); err != nil {
t.Fatal(err)
}
t.Setenv("MAGPIE_ADDR", "127.0.0.1:3426")
if msg := a.Check(); !strings.Contains(msg, "base_url") {
t.Errorf("Check on a moved gateway: %q", msg)
}
if err := a.Sync(); err != nil {
t.Fatal(err)
}
srcs := f.sources()
if len(srcs) != 1 || srcs[0]["base_url"] != "http://127.0.0.1:3426/v1" || len(f.created) != 2 {
t.Fatalf("after the move: %v (%d made)", srcs, len(f.created))
}
if avibeStashed(dir) != srcs[0]["id"] {
t.Errorf("stash %q, source %v", avibeStashed(dir), srcs[0]["id"])
}
}
// Avibe changes its sources only while it runs; the switch says to start
// it rather than writing a file Avibe would refuse.
func TestAvibeNeedsItRunning(t *testing.T) {
dir := avibeTestHome(t)
os.MkdirAll(filepath.Join(dir, "config"), 0o700)
t.Setenv("AVIBE_HOME", dir)
was := avibeLive
avibeLive = avibeConnect
t.Cleanup(func() { avibeLive = was })
a := avibe(os.Getenv("HOME"))
if err := a.Field("provider").Set(magpieID); !errors.Is(err, errAvibeDown) {
t.Errorf("connect with Avibe stopped: %v", err)
}
if err := a.Field("provider").Set(""); err != nil {
t.Errorf("disconnect with nothing connected: %v", err)
}
if err := a.Sync(); err != nil {
t.Errorf("Sync: %v", err)
}
if _, err := os.Stat(filepath.Join(dir, "config", "config.json")); err == nil {
t.Error("config.json written while Avibe is stopped")
}
}
// Avibe's home is $AVIBE_HOME (~ expanded), else ~/.avibe, else the
// ~/.vibe_remote an older Avibe made (config/paths.py).
func TestAvibeHome(t *testing.T) {
home := syncHome(t)
if d := avibeHome(home); d != filepath.Join(home, ".avibe") {
t.Errorf("default: %s", d)
}
os.MkdirAll(filepath.Join(home, ".vibe_remote"), 0o700)
if d := avibeHome(home); d != filepath.Join(home, ".vibe_remote") {
t.Errorf("legacy: %s", d)
}
os.MkdirAll(filepath.Join(home, ".avibe"), 0o700)
if d := avibeHome(home); d != filepath.Join(home, ".avibe") {
t.Errorf("both: %s", d)
}
t.Setenv("AVIBE_HOME", "~/elsewhere")
if d := avibeHome(home); d != filepath.Join(home, "elsewhere") {
t.Errorf("AVIBE_HOME: %s", d)
}
}
+1 -1
View File
@@ -61,7 +61,7 @@ func TestEveryPickerOfMagpiesModelsCanBeNarrowed(t *testing.T) {
if len(bare) > 0 {
t.Errorf("magpie's models are put in these agents' pickers with no way to pick which: %v", bare)
}
for _, id := range []string{"zcode", "pencil", "openpencil", "openbot", "newmax", "liveagent", "t3code", "openmausbot", "workbuddy", "workbuddy-ai", copilotJBID, CursorLocalID} {
for _, id := range []string{"zcode", "pencil", "openpencil", "openbot", "newmax", "liveagent", "t3code", "openmausbot", "avibe", "workbuddy", "workbuddy-ai", copilotJBID, CursorLocalID} {
if !slices.Contains(menus, id) {
t.Errorf("%s's row has no model list to pick in (ListsModels): %v", id, menus)
}
+4
View File
@@ -51,6 +51,10 @@ func TestMain(m *testing.M) {
// refused every test that turns magpie on for each agent; the tests
// about it say their own
ombRunning = func() bool { return false }
// nor is an Avibe this machine runs reached: each home's Avibe runs
// in the test (runningAvibe), and the tests about Avibe serve their own
// (avibe_test.go)
avibeLive = runningAvibe
// nor which OpenCode this machine has: an OpenCode 2 on PATH turned
// every OpenCode test's file into OpenCode 2's words; the tests about
// it say their own (opencode_v2_test.go)
+1
View File
@@ -41,6 +41,7 @@ func syncHome(t *testing.T) string {
t.Setenv("DS_BOT_HOME", "")
t.Setenv("DS_BOT_SHELL_DATA", "")
t.Setenv("OMB_DATA_DIR", "")
t.Setenv("AVIBE_HOME", "")
t.Setenv("OMO_CODING_AGENT_DIR", "")
t.Setenv("SENPI_CODING_AGENT_DIR", "")
t.Setenv("PRIME_AGENT_CODING_AGENT_DIR", "")
+2
View File
@@ -78,6 +78,8 @@ var Vars = []string{
"LIVEAGENT_HOME", "K_BRAIN_HOME",
// OpenMausBot's data folder (its config.json), ~/.openmausbot without it
"OMB_DATA_DIR",
// Avibe's home (its config/config.json and its control socket), ~/.avibe without it
"AVIBE_HOME",
// AstrBot's root, the folder holding its data/ (else ~/.astrbot, the desktop app's)
"ASTRBOT_ROOT",
// jcode's folder, ~/.jcode without it
+1 -1
View File
@@ -90,7 +90,7 @@ func usable(name, v string) bool {
switch name {
case "PI_CODING_AGENT_DIR", "PI_CODING_AGENT_SESSION_DIR", "PRIME_AGENT_CODING_AGENT_DIR", "HANA_HOME", "T3CODE_HOME",
"MU_AGENT_DIR", "KYRN_AGENT_DIR", "MU_CODING_AGENT_DIR", "KYRN_CODING_AGENT_DIR",
"OPENCLAW_HOME", "OPENCLAW_STATE_DIR", "OPENCLAW_CONFIG_PATH", "QWENPAW_WORKING_DIR", "QWENPAW_SECRET_DIR":
"OPENCLAW_HOME", "OPENCLAW_STATE_DIR", "OPENCLAW_CONFIG_PATH", "QWENPAW_WORKING_DIR", "QWENPAW_SECRET_DIR", "AVIBE_HOME":
return v == "~" || strings.HasPrefix(v, "~/") || (runtime.GOOS == "windows" && strings.HasPrefix(v, `~\`))
}
return false
+1 -1
View File
@@ -187,7 +187,7 @@ code { font: var(--code-style, normal) var(--code-weight, 400) 11.5px var(--code
they read a size bigger than a line logo beside them, so they are drawn at
the size Alma's and Cindy's tiles have of their own. icon-tile.test.cjs
measures every file in icons/ and keeps this list whole. */
.ic:is([data-icon="aihubmix-color"], [data-icon="atomcode"], [data-icon="cherryin-color"], [data-icon="codebuddy-color"], [data-icon="codex-color"], [data-icon="crush"], [data-icon="geminicli-color"], [data-icon="hanako"], [data-icon="hunyuan-color"], [data-icon="kilo"], [data-icon="kimi-code-desktop"], [data-icon="kiro-color"], [data-icon="lody"], [data-icon="mistermorph-color"], [data-icon="mlx-serve"], [data-icon="monica-color"], [data-icon="nanobot-color"], [data-icon="openbot"], [data-icon="penguin-color"], [data-icon="phala-color"], [data-icon="pipellm-color"], [data-icon="qoder"], [data-icon="snow"], [data-icon="targon-color"], [data-icon="typesafe"], [data-icon="workbuddy-color"], [data-icon="yuanbao-color"], [data-icon="zcode"], [data-icon="zoo-code"]) > * { width: 82%; height: 82%; }
.ic:is([data-icon="aihubmix-color"], [data-icon="atomcode"], [data-icon="avibe"], [data-icon="cherryin-color"], [data-icon="codebuddy-color"], [data-icon="codex-color"], [data-icon="crush"], [data-icon="geminicli-color"], [data-icon="hanako"], [data-icon="hunyuan-color"], [data-icon="kilo"], [data-icon="kimi-code-desktop"], [data-icon="kiro-color"], [data-icon="lody"], [data-icon="mistermorph-color"], [data-icon="mlx-serve"], [data-icon="monica-color"], [data-icon="nanobot-color"], [data-icon="openbot"], [data-icon="penguin-color"], [data-icon="phala-color"], [data-icon="pipellm-color"], [data-icon="qoder"], [data-icon="snow"], [data-icon="targon-color"], [data-icon="typesafe"], [data-icon="workbuddy-color"], [data-icon="yuanbao-color"], [data-icon="zcode"], [data-icon="zoo-code"]) > * { width: 82%; height: 82%; }
.ic.generic { color: var(--muted); }
/* maskSpan's shelf: a hidden user of every mask picture loaded, so a logo drawn again paints at once (#1847) */
.mask-shelf { position: fixed; top: 0; left: 0; width: 0; height: 0; overflow: hidden; visibility: hidden; pointer-events: none; }
+1 -1
View File
@@ -360,7 +360,7 @@ function toneCheck(img) {
swap();
}, { once: true });
}
const pngIcons = new Set(["crush", "zcode", "alma", "hanako", "cindy", "lody", "typesafe", "atomcode", "snow", "mlx-serve", "mothx", "zoo-code", "kimi-code-desktop", "openbot"]);
const pngIcons = new Set(["crush", "zcode", "alma", "hanako", "cindy", "lody", "typesafe", "atomcode", "snow", "mlx-serve", "mothx", "zoo-code", "kimi-code-desktop", "openbot", "avibe"]);
// lazy: a picture in a long list (Plugins' rows) is asked for near the
// screen: each SVG an <img> draws is a ~0.6 MB webview document, kept (#909)
+4
View File
@@ -1707,6 +1707,7 @@ const I18N = {
"agent default": "Agent 默认值",
"every magpie model in T3 Code twice: magpie on Claude Code, magpie · Codex on Codex; pick one in T3's model picker": "magpie 的全部模型在 T3 Code 里出现两次:magpie 走 Claude Code,magpie · Codex 走 Codex;在 T3 的模型选择器里选一个",
"every magpie model under OpenMausBot's magpie engine; pick it for a bot": "magpie 的全部模型都在 OpenMausBot 的 magpie 引擎下;给机器人选它即可",
"a model source on Avibe's Models page, for Vibey and the agents it runs": "Avibe 模型页里的一个模型来源,供 Vibey 和它运行的智能体使用",
"default": "默认",
"default ({level})": "默认({level})",
"off": "关闭",
@@ -6634,6 +6635,7 @@ const I18N = {
"agent default": "Agent 預設值",
"every magpie model in T3 Code twice: magpie on Claude Code, magpie · Codex on Codex; pick one in T3's model picker": "magpie 的全部模型在 T3 Code 裡出現兩次:magpie 走 Claude Code,magpie · Codex 走 Codex;在 T3 的模型選擇器裡選一個",
"every magpie model under OpenMausBot's magpie engine; pick it for a bot": "magpie 的全部模型都在 OpenMausBot 的 magpie 引擎下;為機器人選它即可",
"a model source on Avibe's Models page, for Vibey and the agents it runs": "Avibe 模型頁裡的一個模型來源,供 Vibey 和它執行的智慧體使用",
"default": "預設",
"default ({level})": "預設({level})",
"off": "關閉",
@@ -11531,6 +11533,7 @@ const I18N = {
"agent default": "エージェントのデフォルト",
"every magpie model in T3 Code twice: magpie on Claude Code, magpie · Codex on Codex; pick one in T3's model picker": "magpie のすべてのモデルが T3 Code に 2 回並びます:magpie は Claude Code、magpie · Codex は Codex で動きます。T3 のモデルピッカーで選んでください",
"every magpie model under OpenMausBot's magpie engine; pick it for a bot": "magpie のすべてのモデルが OpenMausBot の magpie エンジンに並びます。ボットにそれを選んでください",
"a model source on Avibe's Models page, for Vibey and the agents it runs": "Avibe の Models ページのモデルソース。Vibey と Avibe が動かすエージェントが使います",
"default": "デフォルト",
"default ({level})": "デフォルト({level})",
"off": "オフ",
@@ -16459,6 +16462,7 @@ const I18N = {
"agent default": "Standard des Agenten",
"every magpie model in T3 Code twice: magpie on Claude Code, magpie · Codex on Codex; pick one in T3's model picker": "alle magpie-Modelle zweimal in T3 Code: magpie über Claude Code, magpie · Codex über Codex; wähle eins in T3s Modellauswahl",
"every magpie model under OpenMausBot's magpie engine; pick it for a bot": "alle magpie-Modelle unter der magpie-Engine von OpenMausBot; wähle sie für einen Bot",
"a model source on Avibe's Models page, for Vibey and the agents it runs": "eine Modellquelle auf der Models-Seite von Avibe, für Vibey und die Agenten, die es ausführt",
"default": "Standard",
"default ({level})": "Standard ({level})",
"off": "aus",
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB