wave 0.1.0: Wave Terminal as a magpie agent (#938)

Adds Wave Terminal (waveterm) as a magpie agent. connect writes one whole
"magpie" mode in ~/.config/waveterm/waveai.json (display:name, model,
the gateway's /chat/completions endpoint, openai-chat, the key, and
capabilities with images when the model takes them), so switching off
removes the mode and leaves the user's own modes alone.

Run at 2f08c0df merged with origin/main c27ba5f7, on the Windows box with
a fresh HOME: bun test packages/wave 4 pass, scripts/check.mjs exit 0.
Broken by hand: removing display:name turns the connect test red.
Not tried: a real Wave app run (Electron, not run headless).

Co-authored-by: atttmin <46617048+atttmin@users.noreply.github.com>
This commit is contained in:
atttmin
2026-11-11 12:39:43 +08:00
committed by GitHub
parent c27ba5f700
commit 35468c76d7
5 changed files with 135 additions and 1 deletions
+37
View File
@@ -0,0 +1,37 @@
# @magpie-community/agent-wave
[Wave Terminal](https://waveterm.dev) as a magpie agent. magpie has no setup of
its own for Wave; with this plugin it is on magpie's Agents page like the agents
magpie ships with.
```sh
magpie plugin add @magpie-community/agent-wave
```
Then pick one of magpie's models in Wave's row. magpie writes one mode,
`magpie`, into `~/.config/waveterm/waveai.json`:
```json
{
"magpie": {
"display:name": "Magpie",
"ai:model": "v2ex/glm-5.3-flash",
"ai:endpoint": "http://127.0.0.1:3425/v1/chat/completions",
"ai:apitype": "openai-chat",
"ai:apitoken": "magpie-wave",
"ai:capabilities": ["tools"]
}
}
```
Your other modes and settings stay. Picking a model of your own again, or
switching Wave off, takes the `magpie` mode out entirely and puts your
settings back as they were. Wave watches its config directory, so the mode
shows up in the dropdown right away — pick **Magpie** there to use it (or set
`"waveai:defaultmode": "magpie"` in `~/.config/waveterm/settings.json`).
Wave reads its AI modes from `~/.config/waveterm` by default; on another setup
it may use `$XDG_CONFIG_HOME/waveterm`, `$WAVETERM_CONFIG_HOME` or the legacy
`~/.waveterm/config`. This plugin targets the default `~/.config/waveterm`.
How agent plugins work: [usemagpie.ai/docs/plugins#agents](https://usemagpie.ai/docs/plugins#agents).
+18
View File
@@ -0,0 +1,18 @@
{
"name": "@magpie-community/agent-wave",
"version": "0.1.0",
"description": "Wave Terminal (waveterm) as a magpie agent: pick one of magpie's models for it on the Agents page",
"type": "module",
"files": ["wave.agent.js", "README.md"],
"keywords": ["magpie", "magpie-agent", "wave", "waveterm", "llm-gateway"],
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/magpie-community/plugins.git",
"directory": "packages/wave"
},
"magpie": {
"agent": "./wave.agent.js",
"icon": "https://github.com/wavetermdev.png"
}
}
+34
View File
@@ -0,0 +1,34 @@
// Wave Terminal (waveterm) keeps its AI modes in ~/.config/waveterm/waveai.json.
// We give Wave one fixed mode, "magpie", managed as a whole object: connect
// returns the full mode — display:name included, which Wave's schema requires
// — and magpie writes it as one key, so switching off removes "magpie"
// entirely and leaves the user's own modes as they were. The model magpie
// picks is written separately as magpie.ai:model.
export const agent = {
id: "wave",
name: "Wave",
icon: "https://github.com/wavetermdev.png",
// detection: Wave's config directory exists
dir: "~/.config/waveterm",
config: "~/.config/waveterm/waveai.json",
format: "json",
// the model magpie picks, inside the mode object (Wave's ai:model)
model: "magpie.ai:model",
// Wave passes ai:model as-is to the gateway, so no prefix
prefix: "",
}
export function connect({ gateway, model }) {
const caps = model?.images ? ["tools", "images"] : ["tools"]
return {
// one whole object, so a disconnect takes the mode out with it
magpie: {
"display:name": "Magpie",
"ai:model": model?.id ?? "",
"ai:endpoint": gateway.v1 + "/chat/completions",
"ai:apitype": "openai-chat",
"ai:apitoken": gateway.key,
"ai:capabilities": caps,
},
}
}
+44
View File
@@ -0,0 +1,44 @@
import { expect, test } from "bun:test"
import { agent, connect } from "./wave.agent.js"
test("says where Wave keeps its model", () => {
expect(agent).toMatchObject({
id: "wave",
config: "~/.config/waveterm/waveai.json",
model: "magpie.ai:model",
prefix: "",
})
})
test("shows Wave's own icon, as the package gives it", async () => {
const pkg = await Bun.file(new URL("./package.json", import.meta.url)).json()
expect(agent.icon).toBe("https://github.com/wavetermdev.png")
expect(pkg.magpie.icon).toBe(agent.icon)
})
test("writes the whole magpie mode, with display:name, and nothing else", () => {
const out = connect({
gateway: { url: "http://127.0.0.1:3425", v1: "http://127.0.0.1:3425/v1", key: "magpie-wave" },
model: { id: "v2ex/glm-5.3-flash", name: "GLM-5.3-Flash", images: false },
models: [],
agent: { id: "wave", config: "/Users/u/.config/waveterm/waveai.json" },
})
// a single "magpie" object, so switching off removes the mode entirely
expect(Object.keys(out)).toEqual(["magpie"])
expect(out.magpie).toEqual({
"display:name": "Magpie",
"ai:model": "v2ex/glm-5.3-flash",
"ai:endpoint": "http://127.0.0.1:3425/v1/chat/completions",
"ai:apitype": "openai-chat",
"ai:apitoken": "magpie-wave",
"ai:capabilities": ["tools"],
})
})
test("declares images when the model takes them", () => {
const out = connect({
gateway: { v1: "http://127.0.0.1:3425/v1", key: "magpie-wave" },
model: { id: "zhipu/glm-5.3-flash", images: true },
})
expect(out.magpie["ai:capabilities"]).toEqual(["tools", "images"])
})
+2 -1
View File
@@ -284,6 +284,7 @@
{ "package": "@magpie-community/page-model-quota", "name": "Model Quota", "kind": "page", "community": true,
"summary": { "en": "How many tokens each model has left, merged across every account and provider: each quota window is turned into tokens from your own usage history and split by the model's share in it.", "zh": "每个模型在所有账号、所有供应商的池子里还剩多少 token:用你自己的用量历史把每个额度窗口换算成 token,再按模型在窗口里的占比摊开。" } },
{ "package": "@magpie-community/page-harnessweight", "name": "HarnessWeight", "kind": "page", "community": true,
"summary": { "en": "Compare agent harnesses behind your gateway by input tokens, cache, failures, latency and estimated tool-definition size. Its local service reads this machine's usage ledger; a read-only hook samples tool sizes and tracks in-flight requests.", "zh": "按 Agent 对比网关后面的输入 token、缓存、失败率、延迟与工具定义体积估算。本机服务读取用量记录,只读 hook 采样工具大小并追踪进行中的请求。" } }
"summary": { "en": "Compare agent harnesses behind your gateway by input tokens, cache, failures, latency and estimated tool-definition size. Its local service reads this machine's usage ledger; a read-only hook samples tool sizes and tracks in-flight requests.", "zh": "按 Agent 对比网关后面的输入 token、缓存、失败率、延迟与工具定义体积估算。本机服务读取用量记录,只读 hook 采样工具大小并追踪进行中的请求。" } },
{ "package": "@magpie-community/agent-wave", "name": "Wave", "kind": "agent", "community": true, "icon": "https://github.com/wavetermdev.png", "summary": {"en": "Wave Terminal (waveterm) on magpie's Agents page: pick one of magpie's models for it, and switch it off to put its config back.", "zh": "把 Wave Terminal(waveterm)加到 magpie 的 Agent 页:给它选 magpie 的模型,关掉即恢复它原来的配置。"}}
]
}