mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-25 08:02:04 +00:00
fix(regression): restore imessage cold-runtime chunking
This commit is contained in:
@@ -3,6 +3,7 @@ export {
|
||||
PAIRING_APPROVED_MESSAGE,
|
||||
buildComputedAccountStatusSnapshot,
|
||||
buildChannelConfigSchema,
|
||||
chunkTextForOutbound,
|
||||
collectStatusIssuesFromLastError,
|
||||
formatTrimmedAllowFromEntries,
|
||||
getChatChannelMeta,
|
||||
|
||||
@@ -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", () => {
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user