Files
plugins/packages/meowcode/meowcode.test.mjs
T
MuLiu_SaMa 418d81d896 agent-meowcode 0.1.0: MeowCode as a magpie agent (#1107)
Adds MeowCode (https://github.com/MuLiuSaMa/MeowCode) to the Agents page. magpie writes %APPDATA%\MeowCode\agent\magpie.json, an overlay MeowCode 1.3.0+ reads at start-up and never writes; the user's own providers and keys are untouched. The row's notice says it needs MeowCode 1.3.0 or later.

By @MuLiuSaMa (#1107).

Reviewed at 4593caec:
- MeowCode's reader, desktop/magpie-overlay.cjs, is the same blob (59e0c926) at 3d47a099 and at the v1.3.0 release tag; it reads every field this package writes, keeps only magpie/ ids with loopback baseUrls, and treats {} as no overlay.
- WSL, HOME=$(mktemp -d), merged onto main c95e20a3: bun test in packages/meowcode 5 pass; bun scripts/check.mjs meowcode ok.
- Not tried: a real MeowCode install (Windows only); the author's screenshots cover the real run.
2026-11-14 01:45:20 +08:00

81 lines
2.8 KiB
JavaScript

import { expect, test } from "bun:test"
import { agent, connect } from "./meowcode.agent.js"
const gateway = { url: "http://127.0.0.1:3425", v1: "http://127.0.0.1:3425/v1", key: "magpie-meowcode" }
const models = [
{ id: "deepseek/pro", name: "DeepSeek Pro", context: 128000, output: 8192, images: false },
{ id: "kimi/k2", name: "Kimi K2", context: 256000, output: 16384, images: true },
]
test("says where MeowCode keeps the overlay magpie writes, and never it alone", () => {
expect(agent).toMatchObject({
id: "meowcode",
config: "$APPDATA/MeowCode/agent/magpie.json",
format: "json",
model: "providerId",
prefix: "magpie/",
dir: "$APPDATA/MeowCode/agent",
ua: ["meowcode"],
})
// base is only for an agent magpie starts, and MeowCode is not one
expect(agent.base).toBeUndefined()
expect(agent.launch).toBeUndefined()
expect(agent.merge).toBeUndefined()
})
test("writes one provider per model, on the gateway's OpenAI-compatible endpoint", () => {
const out = connect({ gateway, model: models[0], models })
expect(out.magpieKey).toBe("magpie-meowcode")
expect(out.providers).toEqual([
{
id: "magpie/deepseek/pro",
name: "Magpie",
baseUrl: "http://127.0.0.1:3425/v1",
model: "deepseek/pro",
displayName: "DeepSeek Pro",
protocol: "openai-chat-completions",
authStyle: "none",
extraHeaders: { Authorization: "Bearer magpie-meowcode" },
enabled: true,
inputModalities: ["text"],
contextWindow: 128000,
maxTokens: 8192,
},
{
id: "magpie/kimi/k2",
name: "Magpie",
baseUrl: "http://127.0.0.1:3425/v1",
model: "kimi/k2",
displayName: "Kimi K2",
protocol: "openai-chat-completions",
authStyle: "none",
extraHeaders: { Authorization: "Bearer magpie-meowcode" },
enabled: true,
inputModalities: ["text", "image"],
contextWindow: 256000,
maxTokens: 16384,
},
])
})
test("names the model's id without magpie's prefix, which is the record's alone", () => {
const out = connect({ gateway, model: models[1], models })
expect(out.providers[1].model).toBe("kimi/k2")
expect(out.providers[1].id).toBe("magpie/kimi/k2")
})
test("keeps the model magpie picked even when the catalog has not caught up", () => {
const out = connect({ gateway, model: { id: "new/one" }, models: [] })
expect(out.providers.map((p) => p.id)).toEqual(["magpie/new/one"])
expect(out.providers[0].model).toBe("new/one")
expect(out.providers[0].displayName).toBeUndefined()
})
test("leaves out what it has no answer for", () => {
const out = connect({ gateway, model: null, models: [{ id: "plain" }] })
expect(out.providers[0].displayName).toBeUndefined()
expect(out.providers[0].contextWindow).toBeUndefined()
expect(out.providers[0].maxTokens).toBeUndefined()
})