From b48ed56635d3b8240474de58486a8a967f85926b Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Thu, 8 Jan 2026 22:58:15 +0100 Subject: [PATCH] test: add DM elevated regression coverage --- src/auto-reply/reply.triggers.test.ts | 39 +++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/auto-reply/reply.triggers.test.ts b/src/auto-reply/reply.triggers.test.ts index 8a4ed150f..fb7ad374d 100644 --- a/src/auto-reply/reply.triggers.test.ts +++ b/src/auto-reply/reply.triggers.test.ts @@ -427,6 +427,45 @@ describe("trigger handling", () => { }); }); + it("allows elevated directive in direct chats without mentions", async () => { + await withTempHome(async (home) => { + const cfg = { + agent: { + model: "anthropic/claude-opus-4-5", + workspace: join(home, "clawd"), + elevated: { + allowFrom: { whatsapp: ["+1000"] }, + }, + }, + whatsapp: { + allowFrom: ["+1000"], + }, + session: { store: join(home, "sessions.json") }, + }; + + const res = await getReplyFromConfig( + { + Body: "/elevated on", + From: "+1000", + To: "+2000", + Provider: "whatsapp", + SenderE164: "+1000", + }, + {}, + cfg, + ); + const text = Array.isArray(res) ? res[0]?.text : res?.text; + expect(text).toContain("Elevated mode enabled"); + + const storeRaw = await fs.readFile(cfg.session.store, "utf-8"); + const store = JSON.parse(storeRaw) as Record< + string, + { elevatedLevel?: string } + >; + expect(store[MAIN_SESSION_KEY]?.elevatedLevel).toBe("on"); + }); + }); + it("ignores inline elevated directive for unapproved sender", async () => { await withTempHome(async (home) => { vi.mocked(runEmbeddedPiAgent).mockResolvedValue({