32 lines
1.3 KiB
TypeScript
32 lines
1.3 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
import { parseConfig } from "../src/config.js";
|
|
|
|
const platforms = {
|
|
qq: { enabled: true, appId: "id", clientSecret: "secret", connectionMode: "websocket" as const },
|
|
feishu: {}, wecom: {}, webhook: {}, weixin: {}
|
|
};
|
|
|
|
test("migrates a v1 Kimi config and preserves QQ fields", () => {
|
|
const config = parseConfig({
|
|
server: { port: 8787 }, policy: {}, defaultAgent: "kimi",
|
|
agents: [{ name: "kimi", command: "/home/ubuntu/.kimi-code/bin/kimi", args: ["-p"], cwd: "/tmp" }], platforms
|
|
});
|
|
assert.equal(config.configVersion, 2);
|
|
assert.deepEqual(config.backends[0].args, ["acp"]);
|
|
assert.equal(config.roles[0].workspace, "/tmp");
|
|
assert.equal(config.platforms.qq.clientSecret, "secret");
|
|
assert.equal(config.platforms.qq.connectionMode, "websocket");
|
|
});
|
|
|
|
test("does not silently migrate a non-Kimi CLI agent", () => {
|
|
assert.throws(() => parseConfig({ defaultAgent: "echo", agents: [{ name: "echo", command: "node" }], platforms }), /only supports a Kimi/);
|
|
});
|
|
|
|
test("validates role references and absolute workspace", () => {
|
|
assert.throws(() => parseConfig({
|
|
configVersion: 2, backends: [{ id: "kimi", command: "kimi", args: ["acp"] }], defaultRole: "a",
|
|
roles: [{ id: "a", backend: "missing", workspace: "relative" }], platforms
|
|
}), /workspace must be absolute/);
|
|
});
|