fix: carry room event gateway actions

This commit is contained in:
Peter Steinberger
2026-05-15 16:13:01 +01:00
parent ddcfde1489
commit f1351bcbcf
5 changed files with 34 additions and 3 deletions
@@ -138,6 +138,28 @@ describe("telegram bot message processor", () => {
);
});
it("does not send early typing cues for room events", async () => {
const sendTyping = vi.fn().mockResolvedValue(undefined);
buildTelegramMessageContext.mockResolvedValue(
createMessageContext({
sendTyping,
ctxPayload: {
From: "telegram:123",
To: "telegram:123",
ChatType: "group",
RawBody: "ambient",
InboundTurnKind: "room_event",
},
}),
);
const processMessage = createTelegramMessageProcessor(baseDeps);
await processSampleMessage(processMessage);
expect(sendTyping).not.toHaveBeenCalled();
expect(dispatchTelegramMessage).toHaveBeenCalledTimes(1);
});
it("skips dispatch when no context is produced", async () => {
buildTelegramMessageContext.mockResolvedValue(null);
const processMessage = createTelegramMessageProcessor(baseDeps);
+5 -3
View File
@@ -155,9 +155,11 @@ export const createTelegramMessageProcessor = (deps: TelegramMessageProcessorDep
(options?.ingressBuffer ? ` buffer=${options.ingressBuffer}` : ""),
);
}
void context.sendTyping().catch((err) => {
logVerbose(`telegram early typing cue failed for chat ${context.chatId}: ${String(err)}`);
});
if (context.ctxPayload.InboundTurnKind !== "room_event") {
void context.sendTyping().catch((err) => {
logVerbose(`telegram early typing cue failed for chat ${context.chatId}: ${String(err)}`);
});
}
telegramInboundLog.info(
formatTelegramInboundLogLine({
from: context.ctxPayload.From,
+1
View File
@@ -79,6 +79,7 @@ export const MessageActionParamsSchema = Type.Object(
senderIsOwner: Type.Optional(Type.Boolean()),
sessionKey: Type.Optional(Type.String()),
sessionId: Type.Optional(Type.String()),
inboundTurnKind: Type.Optional(Type.String({ enum: ["user_request", "room_event"] })),
agentId: Type.Optional(Type.String()),
toolContext: Type.Optional(MessageActionToolContextSchema),
idempotencyKey: NonEmptyString,
+4
View File
@@ -1265,6 +1265,7 @@ describe("gateway send mirroring", () => {
emoji: "✅",
},
requesterSenderId: "trusted-user",
inboundTurnKind: "room_event",
toolContext: {
currentGraphChannelId: "graph:team/chan",
currentChannelProvider: "whatsapp",
@@ -1291,6 +1292,9 @@ describe("gateway send mirroring", () => {
undefined,
{ channel: "whatsapp" },
);
expect(mocks.dispatchChannelMessageAction).toHaveBeenCalledWith(
expect.objectContaining({ inboundTurnKind: "room_event" }),
);
});
it("passes agent-scoped media roots to gateway message actions", async () => {
+2
View File
@@ -287,6 +287,7 @@ export const sendHandlers: GatewayRequestHandlers = {
senderIsOwner?: boolean;
sessionKey?: string;
sessionId?: string;
inboundTurnKind?: "user_request" | "room_event";
agentId?: string;
toolContext?: {
currentChannelId?: string;
@@ -364,6 +365,7 @@ export const sendHandlers: GatewayRequestHandlers = {
senderIsOwner,
sessionKey: normalizeOptionalString(request.sessionKey) ?? undefined,
sessionId: normalizeOptionalString(request.sessionId) ?? undefined,
inboundTurnKind: request.inboundTurnKind,
agentId: normalizeOptionalString(request.agentId) ?? undefined,
mediaLocalRoots: getAgentScopedMediaLocalRoots(
cfg,