From 18fe752c4872929030ba05302daaa50ff8c7a4ad Mon Sep 17 00:00:00 2001 From: Tak Hoffman <781889+Takhoffman@users.noreply.github.com> Date: Fri, 27 Mar 2026 21:25:15 -0500 Subject: [PATCH] fix(regression): restore googlechat cold-runtime chunking --- extensions/googlechat/src/channel.test.ts | 9 +++++++++ extensions/googlechat/src/channel.ts | 3 ++- src/plugin-sdk/googlechat.ts | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/extensions/googlechat/src/channel.test.ts b/extensions/googlechat/src/channel.test.ts index 1b29ab00fee..7b623956bc0 100644 --- a/extensions/googlechat/src/channel.test.ts +++ b/extensions/googlechat/src/channel.test.ts @@ -102,6 +102,15 @@ function setupRuntimeMediaMocks(params: { loadFileName: string; loadBytes: strin } describe("googlechatPlugin outbound sendMedia", () => { + it("chunks outbound text without requiring Google Chat runtime initialization", () => { + const chunker = googlechatPlugin.outbound?.chunker; + if (!chunker) { + throw new Error("Expected googlechatPlugin.outbound.chunker to be defined"); + } + + expect(chunker("alpha beta", 5)).toEqual(["alpha", "beta"]); + }); + it("loads local media with mediaLocalRoots via runtime media loader", async () => { const { loadWebMedia, fetchRemoteMedia } = setupRuntimeMediaMocks({ loadFileName: "image.png", diff --git a/extensions/googlechat/src/channel.ts b/extensions/googlechat/src/channel.ts index 70f6f7d3cac..04257101575 100644 --- a/extensions/googlechat/src/channel.ts +++ b/extensions/googlechat/src/channel.ts @@ -24,6 +24,7 @@ import { } from "openclaw/plugin-sdk/status-helpers"; import { buildChannelConfigSchema, + chunkTextForOutbound, DEFAULT_ACCOUNT_ID, createAccountStatusSink, getChatChannelMeta, @@ -349,7 +350,7 @@ export const googlechatPlugin = createChatChannelPlugin({ outbound: { base: { deliveryMode: "direct", - chunker: (text, limit) => getGoogleChatRuntime().channel.text.chunkMarkdownText(text, limit), + chunker: chunkTextForOutbound, chunkerMode: "markdown", textChunkLimit: 4000, resolveTarget: ({ to }) => { diff --git a/src/plugin-sdk/googlechat.ts b/src/plugin-sdk/googlechat.ts index 7b880497479..3416ef742cd 100644 --- a/src/plugin-sdk/googlechat.ts +++ b/src/plugin-sdk/googlechat.ts @@ -27,6 +27,7 @@ export { formatPairingApproveHint } from "../channels/plugins/helpers.js"; export { fetchRemoteMedia } from "../media/fetch.js"; export { resolveChannelMediaMaxBytes } from "../channels/plugins/media-limits.js"; export { loadWebMedia } from "./web-media.js"; +export { chunkTextForOutbound } from "./text-chunking.js"; export { addWildcardAllowFrom, mergeAllowFromEntries,