mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-24 07:31:44 +00:00
fix(regression): restore irc cold-runtime chunking
This commit is contained in:
18
extensions/irc/src/channel.test.ts
Normal file
18
extensions/irc/src/channel.test.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
import { ircPlugin } from "./channel.js";
|
||||
import { clearIrcRuntime } from "./runtime.js";
|
||||
|
||||
describe("irc outbound chunking", () => {
|
||||
afterEach(() => {
|
||||
clearIrcRuntime();
|
||||
});
|
||||
|
||||
it("chunks outbound text without requiring IRC runtime initialization", () => {
|
||||
const chunker = ircPlugin.outbound?.chunker;
|
||||
if (!chunker) {
|
||||
throw new Error("irc outbound.chunker unavailable");
|
||||
}
|
||||
|
||||
expect(chunker("alpha beta", 5)).toEqual(["alpha", "beta"]);
|
||||
});
|
||||
});
|
||||
@@ -16,6 +16,7 @@ import {
|
||||
createResolvedDirectoryEntriesLister,
|
||||
} from "openclaw/plugin-sdk/directory-runtime";
|
||||
import { runStoppablePassiveMonitor } from "openclaw/plugin-sdk/extension-shared";
|
||||
import { chunkTextForOutbound } from "openclaw/plugin-sdk/irc";
|
||||
import {
|
||||
createComputedAccountStatusAdapter,
|
||||
createDefaultChannelRuntimeState,
|
||||
@@ -333,7 +334,7 @@ export const ircPlugin: ChannelPlugin<ResolvedIrcAccount, IrcProbe> = createChat
|
||||
outbound: {
|
||||
base: {
|
||||
deliveryMode: "direct",
|
||||
chunker: (text, limit) => getIrcRuntime().channel.text.chunkMarkdownText(text, limit),
|
||||
chunker: chunkTextForOutbound,
|
||||
chunkerMode: "markdown",
|
||||
textChunkLimit: 350,
|
||||
},
|
||||
|
||||
@@ -4,3 +4,6 @@ import type { PluginRuntime } from "./runtime-api.js";
|
||||
const { setRuntime: setIrcRuntime, getRuntime: getIrcRuntime } =
|
||||
createPluginRuntimeStore<PluginRuntime>("IRC runtime not initialized");
|
||||
export { getIrcRuntime, setIrcRuntime };
|
||||
export function clearIrcRuntime() {
|
||||
setIrcRuntime(undefined as unknown as PluginRuntime);
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ export type { BaseProbeResult } from "../channels/plugins/types.js";
|
||||
export type { ChannelPlugin } from "../channels/plugins/types.plugin.js";
|
||||
export { getChatChannelMeta } from "../channels/registry.js";
|
||||
export { createChannelReplyPipeline } from "./channel-reply-pipeline.js";
|
||||
export { chunkTextForOutbound } from "./text-chunking.js";
|
||||
export type { OpenClawConfig } from "../config/config.js";
|
||||
export { isDangerousNameMatchingEnabled } from "../config/dangerous-name-matching.js";
|
||||
export {
|
||||
|
||||
Reference in New Issue
Block a user