agent-wave 0.1.1: the mode names its model, sets a thinking level, and Wave is found by wsh (#1106)

Wave's magpie mode now carries the picked model's name ("Magpie · <model>"),
display:order 1 and the crow icon, and ai:thinkinglevel from the model's
efforts (medium, then high, then low; left out when it has none). The agent
also detects Wave by the wsh CLI, attributes usage by Wave's User-Agent, and
shows a notice on picking the Magpie mode in Wave. connect still returns one
whole `magpie` object, so a disconnect removes the mode. By aibot88.

Checked against Wave's source (pkg/wconfig/settingsconfig.go): display:order,
display:icon and ai:thinkinglevel (enum low/medium/high) are AIModeConfigType
fields. magpie passes name and efforts to connect (internal/agent/plugged.go),
and bin/ua/notice are agentplug.Desc fields.

Run at the reviewed head 008cd8bb4, HOME=$(mktemp -d):
- packages/wave: bun test 5 pass, 0 fail (mote)
- bun scripts/check.mjs wave: ok
Broken by hand: putting "high" ahead of "medium" turns the thinking-level
test red (4 pass, 1 fail, magpie-desktop WSL); restored.

The author ran it on magpie 0.1.3900 with Wave 0.14.5 on macOS.
Not tried by the reviewer: a real Wave install.
This commit is contained in:
汤杭运
2026-11-14 00:28:26 +08:00
committed by GitHub
parent e488064e06
commit 27ce92fd8f
4 changed files with 46 additions and 15 deletions
+1 -1
View File
@@ -14,7 +14,7 @@ Then pick one of magpie's models in Wave's row. magpie writes one mode,
```json
{
"magpie": {
"display:name": "Magpie",
"display:name": "Magpie · GLM-5.3-Flash",
"ai:model": "v2ex/glm-5.3-flash",
"ai:endpoint": "http://127.0.0.1:3425/v1/chat/completions",
"ai:apitype": "openai-chat",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@magpie-community/agent-wave",
"version": "0.1.0",
"version": "0.1.1",
"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"],
+30 -9
View File
@@ -8,7 +8,8 @@ export const agent = {
id: "wave",
name: "Wave",
icon: "https://github.com/wavetermdev.png",
// detection: Wave's config directory exists
// detection: the wsh CLI, or Wave's config directory
bin: "wsh",
dir: "~/.config/waveterm",
config: "~/.config/waveterm/waveai.json",
format: "json",
@@ -16,19 +17,39 @@ export const agent = {
model: "magpie.ai:model",
// Wave passes ai:model as-is to the gateway, so no prefix
prefix: "",
ua: ["waveterm", "wave"],
notice:
"Wave reads waveai.json live; pick the Magpie mode in Wave AI's mode dropdown once, or run `wsh setconfig waveai:defaultmode=magpie`. Wave 实时读取 waveai.json;在 Wave AI 面板的模式下拉里选一次 Magpie,或执行 `wsh setconfig waveai:defaultmode=magpie`。",
}
// Wave's thinking levels are just low/medium/high; pick the closest a
// model's efforts offer, or leave the mode without one.
function thinkingLevel(model) {
const efforts = model?.efforts || []
for (const level of ["medium", "high", "low"]) {
if (efforts.includes(level)) return level
}
return undefined
}
export function connect({ gateway, model }) {
const caps = model?.images ? ["tools", "images"] : ["tools"]
const name = model?.name || model?.id
const mode = {
"display:name": name ? `Magpie · ${name}` : "Magpie",
"display:order": 1,
// FontAwesome's bird, the closest it has to a magpie
"display:icon": "crow",
"ai:model": model?.id ?? "",
"ai:endpoint": gateway.v1 + "/chat/completions",
"ai:apitype": "openai-chat",
"ai:apitoken": gateway.key,
"ai:capabilities": caps,
}
const thinking = thinkingLevel(model)
if (thinking) mode["ai:thinkinglevel"] = thinking
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,
},
magpie: mode,
}
}
+14 -4
View File
@@ -16,7 +16,7 @@ test("shows Wave's own icon, as the package gives it", async () => {
expect(pkg.magpie.icon).toBe(agent.icon)
})
test("writes the whole magpie mode, with display:name, and nothing else", () => {
test("writes the whole magpie mode, 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 },
@@ -26,7 +26,9 @@ test("writes the whole magpie mode, with display:name, and nothing else", () =>
// a single "magpie" object, so switching off removes the mode entirely
expect(Object.keys(out)).toEqual(["magpie"])
expect(out.magpie).toEqual({
"display:name": "Magpie",
"display:name": "Magpie · GLM-5.3-Flash",
"display:order": 1,
"display:icon": "crow",
"ai:model": "v2ex/glm-5.3-flash",
"ai:endpoint": "http://127.0.0.1:3425/v1/chat/completions",
"ai:apitype": "openai-chat",
@@ -35,10 +37,18 @@ test("writes the whole magpie mode, with display:name, and nothing else", () =>
})
})
test("declares images when the model takes them", () => {
test("declares images and a thinking level when the model offers 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 },
model: { id: "zhipu/glm-5.3-flash", images: true, efforts: ["low", "medium", "high"] },
})
expect(out.magpie["ai:capabilities"]).toEqual(["tools", "images"])
expect(out.magpie["ai:thinkinglevel"]).toBe("medium")
})
test("tolerates being called without a model", () => {
const out = connect({ gateway: { v1: "http://127.0.0.1:3425/v1", key: "magpie-wave" } })
expect(out.magpie["display:name"]).toBe("Magpie")
expect(out.magpie["ai:endpoint"]).toBe("http://127.0.0.1:3425/v1/chat/completions")
expect(out.magpie["ai:thinkinglevel"]).toBeUndefined()
})