From 66df5f2bcba18f7bd79e01ede32706a0b28306bc Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Sun, 15 Mar 2026 18:58:28 -0700 Subject: [PATCH] Matrix: guard optional outbound handlers --- extensions/matrix/src/channel.ts | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/extensions/matrix/src/channel.ts b/extensions/matrix/src/channel.ts index 5d6f2a9d9b2..6b0380bc19e 100644 --- a/extensions/matrix/src/channel.ts +++ b/extensions/matrix/src/channel.ts @@ -288,10 +288,27 @@ export const matrixPlugin: ChannelPlugin = { chunker: (text, limit) => getMatrixRuntime().channel.text.chunkMarkdownText!(text, limit), chunkerMode: "markdown", textChunkLimit: 4000, - sendText: async (params) => (await loadMatrixChannelRuntime()).matrixOutbound.sendText!(params), - sendMedia: async (params) => - (await loadMatrixChannelRuntime()).matrixOutbound.sendMedia!(params), - sendPoll: async (params) => (await loadMatrixChannelRuntime()).matrixOutbound.sendPoll!(params), + sendText: async (params) => { + const outbound = (await loadMatrixChannelRuntime()).matrixOutbound; + if (!outbound.sendText) { + throw new Error("Matrix outbound text delivery is unavailable"); + } + return await outbound.sendText(params); + }, + sendMedia: async (params) => { + const outbound = (await loadMatrixChannelRuntime()).matrixOutbound; + if (!outbound.sendMedia) { + throw new Error("Matrix outbound media delivery is unavailable"); + } + return await outbound.sendMedia(params); + }, + sendPoll: async (params) => { + const outbound = (await loadMatrixChannelRuntime()).matrixOutbound; + if (!outbound.sendPoll) { + throw new Error("Matrix outbound poll delivery is unavailable"); + } + return await outbound.sendPoll(params); + }, }, status: { defaultRuntime: {