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.
56 lines
2.2 KiB
JavaScript
56 lines
2.2 KiB
JavaScript
// 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: the wsh CLI, or Wave's config directory
|
|
bin: "wsh",
|
|
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: "",
|
|
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: mode,
|
|
}
|
|
}
|