Files
plugins/packages/wave/wave.agent.js
T
atttmin 35468c76d7 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>
2026-11-11 12:39:43 +08:00

35 lines
1.3 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: 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,
},
}
}