fix(regression): restore imessage cold-runtime chunking

This commit is contained in:
Tak Hoffman
2026-03-27 20:49:24 -05:00
parent dd78b16cdc
commit a724246547
4 changed files with 19 additions and 2 deletions

View File

@@ -3,6 +3,7 @@ export {
PAIRING_APPROVED_MESSAGE,
buildComputedAccountStatusSnapshot,
buildChannelConfigSchema,
chunkTextForOutbound,
collectStatusIssuesFromLastError,
formatTrimmedAllowFromEntries,
getChatChannelMeta,

View File

@@ -21,6 +21,14 @@ function requireIMessageSendMedia() {
return sendMedia;
}
function requireIMessageChunker() {
const chunker = imessagePlugin.outbound?.chunker;
if (!chunker) {
throw new Error("imessage outbound.chunker unavailable");
}
return chunker;
}
const requestMock = vi.fn();
const stopMock = vi.fn();
@@ -184,6 +192,13 @@ describe("imessagePlugin outbound", () => {
sendIMessage,
});
});
it("chunks outbound text without requiring iMessage runtime initialization", () => {
const chunker = requireIMessageChunker();
expect(() => chunker("hello world", 5)).not.toThrow();
expect(chunker("hello world", 5)).toEqual(["hello", "world"]);
});
});
describe("imessageOutbound", () => {

View File

@@ -9,6 +9,7 @@ import {
createDefaultChannelRuntimeState,
} from "openclaw/plugin-sdk/status-helpers";
import {
chunkTextForOutbound,
collectStatusIssuesFromLastError,
DEFAULT_ACCOUNT_ID,
formatTrimmedAllowFromEntries,
@@ -21,7 +22,6 @@ import {
resolveIMessageGroupToolPolicy,
} from "./group-policy.js";
import type { IMessageProbe } from "./probe.js";
import { getIMessageRuntime } from "./runtime.js";
import { imessageSetupAdapter } from "./setup-core.js";
import {
createIMessagePluginBase,
@@ -194,7 +194,7 @@ export const imessagePlugin: ChannelPlugin<ResolvedIMessageAccount, IMessageProb
outbound: {
base: {
deliveryMode: "direct",
chunker: (text, limit) => getIMessageRuntime().channel.text.chunkText(text, limit),
chunker: chunkTextForOutbound,
chunkerMode: "text",
textChunkLimit: 4000,
},

View File

@@ -51,6 +51,7 @@ export {
export { IMessageConfigSchema } from "../config/zod-schema.providers-core.js";
export { resolveChannelMediaMaxBytes } from "../channels/plugins/media-limits.js";
export { chunkTextForOutbound } from "./text-chunking.js";
export {
buildComputedAccountStatusSnapshot,
collectStatusIssuesFromLastError,