fix(commands): harden model alias parsing

This commit is contained in:
Peter Steinberger
2026-01-07 19:58:23 +00:00
parent bb29a3ee3f
commit 7ce1f635cd
6 changed files with 51 additions and 8 deletions

View File

@@ -144,6 +144,36 @@ describe("directive parsing", () => {
expect(res.cleaned).toBe("please now");
});
it("keeps reserved command aliases from matching after trimming", async () => {
await withTempHome(async (home) => {
vi.mocked(runEmbeddedPiAgent).mockReset();
const res = await getReplyFromConfig(
{
Body: "/help",
From: "+1222",
To: "+1222",
},
{},
{
agent: {
model: "anthropic/claude-opus-4-5",
workspace: path.join(home, "clawd"),
models: {
"anthropic/claude-opus-4-5": { alias: " help " },
},
},
whatsapp: { allowFrom: ["*"] },
session: { store: path.join(home, "sessions.json") },
},
);
const text = Array.isArray(res) ? res[0]?.text : res?.text;
expect(text).toContain("Help");
expect(runEmbeddedPiAgent).not.toHaveBeenCalled();
});
});
it("errors on invalid queue options", async () => {
await withTempHome(async (home) => {
vi.mocked(runEmbeddedPiAgent).mockReset();