agent-bub 0.1.0: Bub as a magpie agent plugin (#81)
Adds packages/bub: Bub (bub.build) as a magpie agent plugin. It writes
~/.bub/config.yml with the model as magpie:<provider>/<model> and a
providers.magpie entry (type openai, magpie's /v1, Bub's own key), and
puts the file back when one of Bub's own models is picked or it is turned
off. Needs Bub 0.5.1 or later (bubbuild/bub#343). Plus its row in the
README's Agents table, which is now in alphabetical order.
Reviewed at 4b879fb (2026-10-11), with a real Bub 0.5.1 run against a
sandbox magpie. Since then only merges of main; the PR's own diff from the
merge base is the five files above, packages/bub unchanged since 4b879fb.
It waited only for a first npm publish, which the repo no longer requires
(README: a new plugin merges once its review is done; served from dist).
Run on mote at the merged tree (origin/main 202ec68 + head 13058fe92),
Bun 1.4.2: bun test packages/bub 7 pass; bun scripts/check.mjs all ok;
whole bun test with a temp HOME and TMPDIR 2949 pass, 8 skip, 0 fail.
Co-authored-by: Gabyran <Gabyran@users.noreply.github.com>
This commit is contained in:
@@ -133,9 +133,10 @@ it off puts the config back.
|
||||
| Package | Agent |
|
||||
|---|---|
|
||||
| [aider](packages/aider) | [Aider](https://aider.chat): `~/.aider.conf.yml`, through litellm's `openai/` prefix |
|
||||
| [bub](packages/bub) | [Bub](https://bub.build): `~/.bub/config.yml`, as the `magpie:` provider (needs Bub 0.5.1 or later) |
|
||||
| [kilo](packages/kilo) | [Kilo Code](https://kilo.ai): `~/.config/kilo/kilo.jsonc`, through an OpenAI-compatible provider |
|
||||
| [pig](packages/pig) | [PiG](https://github.com/MichaelKinsy/PiG): injects Magpie's endpoint and model catalog into `~/.pig/agent/models.json`; choose the model in PiG, startup settings stay unchanged |
|
||||
| [kimi-desktop](packages/kimi-desktop) | Ordinary [Kimi desktop](https://www.kimi.com/) Work, through its authenticated local runtime; not Kimi Code CLI |
|
||||
| [pig](packages/pig) | [PiG](https://github.com/MichaelKinsy/PiG): injects Magpie's endpoint and model catalog into `~/.pig/agent/models.json`; choose the model in PiG, startup settings stay unchanged |
|
||||
| [type4me](packages/type4me) | [Type4Me](https://github.com/joewongjc/type4me), macOS voice input: `~/Library/Application Support/Type4Me/magpie-agent.json`, for its LLM post-processing |
|
||||
|
||||
```sh
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
# @magpie-community/agent-bub
|
||||
|
||||
(中文说明在下面。)
|
||||
|
||||
[Bub](https://bub.build) as a magpie agent. magpie has no setup of its own for
|
||||
Bub; with this plugin it is on magpie's Agents page like the agents magpie
|
||||
ships with.
|
||||
|
||||
```sh
|
||||
magpie plugin add @magpie-community/agent-bub
|
||||
```
|
||||
|
||||
Then pick one of magpie's models in Bub's row. magpie writes into
|
||||
`~/.bub/config.yml`:
|
||||
|
||||
```yaml
|
||||
model: magpie:deepseek/deepseek-flash # magpie's model, through the provider below
|
||||
providers:
|
||||
magpie:
|
||||
type: openai
|
||||
api_base: http://127.0.0.1:3425/v1
|
||||
api_key: magpie-bub # Bub's own key, so Usage names it
|
||||
```
|
||||
|
||||
Your comments, `fallback_models` and your own providers stay. Picking one of
|
||||
Bub's own models again, `magpie bub default`, or switching it off puts every
|
||||
key back as it was (a file that had no `providers:` is left with
|
||||
`providers: {}`, which Bub reads). Restart `bub gateway` and open `bub chat`
|
||||
sessions after a change: Bub reads its settings when it starts.
|
||||
|
||||
## The Bub it needs
|
||||
|
||||
Bub 0.5.1 or later: from 0.5.1 Bub takes named providers under `providers:`
|
||||
([bubbuild/bub#343](https://github.com/bubbuild/bub/pull/343)). 0.5.0 and
|
||||
older don't. To update:
|
||||
|
||||
```sh
|
||||
uv tool install --reinstall bub # installed with pip: pip install -U bub
|
||||
```
|
||||
|
||||
An older Bub fails every turn on a `magpie:` model, before any request
|
||||
goes out: `'magpie' is not a supported provider`. If you see that, update Bub,
|
||||
or pick one of Bub's own models in the row (or run `magpie bub default`) to put
|
||||
the file back.
|
||||
|
||||
How agent plugins work: [usemagpie.ai/docs/plugins#agents](https://usemagpie.ai/docs/plugins#agents).
|
||||
|
||||
---
|
||||
|
||||
## 中文
|
||||
|
||||
[Bub](https://bub.build) 作为 magpie 的 Agent。magpie 没有内置 Bub 的接入;装上这个插件后,Bub 就和 magpie 自带的 Agent 一样出现在 Agent 页。
|
||||
|
||||
```sh
|
||||
magpie plugin add @magpie-community/agent-bub
|
||||
```
|
||||
|
||||
然后在 Bub 那一行选一个 magpie 的模型。magpie 会改写 `~/.bub/config.yml`:
|
||||
|
||||
```yaml
|
||||
model: magpie:deepseek/deepseek-flash # magpie 的模型,经下面这个 provider 访问
|
||||
providers:
|
||||
magpie:
|
||||
type: openai
|
||||
api_base: http://127.0.0.1:3425/v1
|
||||
api_key: magpie-bub # Bub 自己的 key,用量里能认出它
|
||||
```
|
||||
|
||||
你的注释、`fallback_models` 和自己的 provider 都会保留。再选回 Bub 自己的模型、运行 `magpie bub default`,或者关掉开关,每个键都恢复原样(原来没有 `providers:` 的文件会留下 `providers: {}`,Bub 能正常读)。改完要重启 `bub gateway`,并重新打开 `bub chat` 会话:Bub 在启动时才读设置。
|
||||
|
||||
## 需要的 Bub 版本
|
||||
|
||||
需要 Bub 0.5.1 或更新版本:从 0.5.1 起,Bub 支持在 `providers:` 下写具名 provider
|
||||
([bubbuild/bub#343](https://github.com/bubbuild/bub/pull/343))。0.5.0 及更早的版本没有。更新:
|
||||
|
||||
```sh
|
||||
uv tool install --reinstall bub # 用 pip 装的:pip install -U bub
|
||||
```
|
||||
|
||||
更早的 Bub 遇到 `magpie:` 模型,每一轮都会在请求发出之前失败:
|
||||
`'magpie' is not a supported provider`。看到这个报错,就更新 Bub;或者在这一行选回 Bub 自己的模型(或运行 `magpie bub default`),把文件恢复。
|
||||
|
||||
Agent 插件怎么工作:[usemagpie.ai/docs/zh/plugins#agents](https://usemagpie.ai/docs/zh/plugins#agents)。
|
||||
@@ -0,0 +1,17 @@
|
||||
export const agent = {
|
||||
id: "bub",
|
||||
name: "Bub",
|
||||
bin: "bub",
|
||||
dir: "~/.bub",
|
||||
config: "~/.bub/config.yml",
|
||||
model: "model",
|
||||
prefix: "magpie:",
|
||||
notice: "Bub reads its settings at start-up: restart bub gateway and open bub chat sessions to use the new model. This needs Bub 0.5.1 or later (uv tool install --reinstall bub); an older Bub fails every turn on a magpie: model.",
|
||||
}
|
||||
|
||||
export function connect({ gateway }) {
|
||||
const provider = { type: "openai", api_base: gateway.v1, api_key: gateway.key }
|
||||
const out = { "providers.magpie": provider }
|
||||
for (const [key, value] of Object.entries(provider)) out[`providers.magpie.${key}`] = value
|
||||
return out
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
import { expect, test } from "bun:test"
|
||||
import { agent, connect } from "./bub.agent.js"
|
||||
|
||||
const input = {
|
||||
gateway: { url: "http://127.0.0.1:3425", v1: "http://127.0.0.1:3425/v1", key: "magpie-bub" },
|
||||
model: { id: "deepseek/deepseek-flash", name: "DeepSeek Flash" },
|
||||
models: [],
|
||||
agent: { id: "bub", config: "/home/u/.bub/config.yml" },
|
||||
}
|
||||
|
||||
test("says where Bub keeps its model", () => {
|
||||
expect(agent).toMatchObject({ id: "bub", config: "~/.bub/config.yml", model: "model", prefix: "magpie:" })
|
||||
})
|
||||
|
||||
test("adds magpie as a provider of Bub's own, with Bub's own key", () => {
|
||||
expect(connect(input)["providers.magpie"]).toEqual({
|
||||
type: "openai",
|
||||
api_base: "http://127.0.0.1:3425/v1",
|
||||
api_key: "magpie-bub",
|
||||
})
|
||||
})
|
||||
|
||||
test("writes the provider whole, so putting it back never leaves one without a type", () => {
|
||||
const out = connect(input)
|
||||
expect(Object.keys(out)).toContain("providers.magpie")
|
||||
expect(out["providers.magpie"].type).toBe("openai")
|
||||
})
|
||||
|
||||
test("names each field of the provider too, for magpie to tell one changed by hand", () => {
|
||||
const out = connect(input)
|
||||
for (const [key, value] of Object.entries(out["providers.magpie"])) expect(out[`providers.magpie.${key}`]).toBe(value)
|
||||
expect(Object.keys(out)).toHaveLength(4)
|
||||
})
|
||||
|
||||
test("leaves the model and the user's other providers to magpie", () => {
|
||||
const keys = Object.keys(connect(input))
|
||||
expect(keys).not.toContain("model")
|
||||
expect(keys.every((k) => k === "providers.magpie" || k.startsWith("providers.magpie."))).toBe(true)
|
||||
})
|
||||
|
||||
test("says in the notice and in both halves of the README which Bub it needs and how to update", async () => {
|
||||
const readme = await Bun.file(new URL("./README.md", import.meta.url)).text()
|
||||
const [en, zh] = readme.split("\n## 中文\n")
|
||||
expect(zh).toBeDefined()
|
||||
for (const text of [agent.notice, en, zh]) {
|
||||
expect(text).toContain("0.5.1")
|
||||
expect(text).toContain("uv tool install --reinstall bub")
|
||||
}
|
||||
for (const text of [en, zh]) expect(text).toContain("bubbuild/bub#343")
|
||||
})
|
||||
|
||||
test("leads with the English README, the Chinese one below it", async () => {
|
||||
const readme = await Bun.file(new URL("./README.md", import.meta.url)).text()
|
||||
const [en, zh] = readme.split("\n## 中文\n")
|
||||
expect(en.replace("(中文说明在下面。)", "")).not.toMatch(/[\u4e00-\u9fff]/)
|
||||
expect(zh).toMatch(/[\u4e00-\u9fff]/)
|
||||
})
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"name": "@magpie-community/agent-bub",
|
||||
"version": "0.1.0",
|
||||
"description": "Bub (bub.build) as a magpie agent: pick one of magpie's models for it on the Agents page / Bub(bub.build)作为 magpie 的 Agent:在 Agent 页给它选 magpie 的模型",
|
||||
"type": "module",
|
||||
"files": ["bub.agent.js", "README.md"],
|
||||
"keywords": ["magpie", "magpie-agent", "bub", "llm-gateway"],
|
||||
"license": "MIT",
|
||||
"repository": { "type": "git", "url": "git+https://github.com/magpie-community/plugins.git", "directory": "packages/bub" },
|
||||
"magpie": { "agent": "./bub.agent.js" }
|
||||
}
|
||||
Reference in New Issue
Block a user