fix(regression): restore matrix cold-runtime chunking

This commit is contained in:
Tak Hoffman
2026-03-27 21:14:25 -05:00
parent e83b1d7c43
commit 23d5bad3ae
5 changed files with 20 additions and 3 deletions

View File

@@ -34,3 +34,4 @@ export type {
WizardPrompter,
} from "openclaw/plugin-sdk/matrix";
export { formatZonedTimestamp } from "openclaw/plugin-sdk/matrix";
export { chunkTextForOutbound } from "openclaw/plugin-sdk/matrix";

View File

@@ -49,6 +49,7 @@ import {
import {
buildChannelConfigSchema,
buildProbeChannelStatusSummary,
chunkTextForOutbound,
collectStatusIssuesFromLastError,
DEFAULT_ACCOUNT_ID,
PAIRING_APPROVED_MESSAGE,
@@ -454,7 +455,7 @@ export const matrixPlugin: ChannelPlugin<ResolvedMatrixAccount, MatrixProbe> =
},
outbound: {
deliveryMode: "direct",
chunker: (text, limit) => getMatrixRuntime().channel.text.chunkMarkdownText!(text, limit),
chunker: chunkTextForOutbound,
chunkerMode: "markdown",
textChunkLimit: 4000,
...createRuntimeOutboundDelegates({

View File

@@ -31,6 +31,16 @@ describe("matrixOutbound cfg threading", () => {
mocks.sendPollMatrix.mockResolvedValue({ eventId: "$poll", roomId: "!room:example" });
});
it("chunks outbound text without requiring Matrix runtime initialization", () => {
const chunker = matrixOutbound.chunker;
if (!chunker) {
throw new Error("matrixOutbound.chunker missing");
}
expect(() => chunker("hello world", 5)).not.toThrow();
expect(chunker("hello world", 5)).toEqual(["hello", "world"]);
});
it("passes resolved cfg to sendMessageMatrix for text sends", async () => {
const cfg = {
channels: {

View File

@@ -1,10 +1,14 @@
import { sendMessageMatrix, sendPollMatrix } from "./matrix/send.js";
import { resolveOutboundSendDep, type ChannelOutboundAdapter } from "./runtime-api.js";
import {
chunkTextForOutbound,
resolveOutboundSendDep,
type ChannelOutboundAdapter,
} from "./runtime-api.js";
import { getMatrixRuntime } from "./runtime.js";
export const matrixOutbound: ChannelOutboundAdapter = {
deliveryMode: "direct",
chunker: (text, limit) => getMatrixRuntime().channel.text.chunkMarkdownText(text, limit),
chunker: chunkTextForOutbound,
chunkerMode: "markdown",
textChunkLimit: 4000,
sendText: async ({ cfg, to, text, deps, replyToId, threadId, accountId, audioAsVoice }) => {

View File

@@ -45,6 +45,7 @@ export {
} from "../channels/plugins/config-helpers.js";
export { buildChannelConfigSchema } from "../channels/plugins/config-schema.js";
export { formatPairingApproveHint } from "../channels/plugins/helpers.js";
export { chunkTextForOutbound } from "./text-chunking.js";
export {
buildSingleChannelSecretPromptState,
addWildcardAllowFrom,