auto-reply: enrich chat status

This commit is contained in:
Peter Steinberger
2025-12-07 16:53:19 +00:00
parent 1f0ee9837b
commit e2c6546b61
9 changed files with 283 additions and 1 deletions

View File

@@ -3,6 +3,13 @@ import { afterEach, describe, expect, it, vi } from "vitest";
import * as tauRpc from "../process/tau-rpc.js";
import { getReplyFromConfig } from "./reply.js";
const webMocks = vi.hoisted(() => ({
webAuthExists: vi.fn().mockResolvedValue(true),
getWebAuthAgeMs: vi.fn().mockReturnValue(120_000),
}));
vi.mock("../web/session.js", () => webMocks);
const baseCfg = {
inbound: {
reply: {
@@ -52,6 +59,23 @@ describe("trigger handling", () => {
expect(runner).not.toHaveBeenCalled();
});
it("reports status without invoking the agent", async () => {
const runner = vi.fn();
const res = await getReplyFromConfig(
{
Body: "/status",
From: "+1002",
To: "+2000",
},
{},
baseCfg,
runner,
);
const text = Array.isArray(res) ? res[0]?.text : res?.text;
expect(text).toContain("Status");
expect(runner).not.toHaveBeenCalled();
});
it("ignores think directives that only appear in the context wrapper", async () => {
const rpcMock = vi.spyOn(tauRpc, "runPiRpc").mockResolvedValue({
stdout: