mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 23:48:28 +00:00
fix: newline chunking across channels
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import { createReplyReferencePlanner } from "../../auto-reply/reply/reply-reference.js";
|
||||
import { isSilentReplyText, SILENT_REPLY_TOKEN } from "../../auto-reply/tokens.js";
|
||||
import type { ChunkMode } from "../../auto-reply/chunk.js";
|
||||
import { chunkMarkdownTextWithMode } from "../../auto-reply/chunk.js";
|
||||
import type { ReplyPayload } from "../../auto-reply/types.js";
|
||||
import type { MarkdownTableMode } from "../../config/types.base.js";
|
||||
import type { RuntimeEnv } from "../../runtime.js";
|
||||
@@ -118,6 +120,7 @@ export async function deliverSlackSlashReplies(params: {
|
||||
ephemeral: boolean;
|
||||
textLimit: number;
|
||||
tableMode?: MarkdownTableMode;
|
||||
chunkMode?: ChunkMode;
|
||||
}) {
|
||||
const messages: string[] = [];
|
||||
const chunkLimit = Math.min(params.textLimit, 4000);
|
||||
@@ -129,9 +132,16 @@ export async function deliverSlackSlashReplies(params: {
|
||||
.filter(Boolean)
|
||||
.join("\n");
|
||||
if (!combined) continue;
|
||||
for (const chunk of markdownToSlackMrkdwnChunks(combined, chunkLimit, {
|
||||
tableMode: params.tableMode,
|
||||
})) {
|
||||
const chunkMode = params.chunkMode ?? "length";
|
||||
const markdownChunks =
|
||||
chunkMode === "newline"
|
||||
? chunkMarkdownTextWithMode(combined, chunkLimit, chunkMode)
|
||||
: [combined];
|
||||
const chunks = markdownChunks.flatMap((markdown) =>
|
||||
markdownToSlackMrkdwnChunks(markdown, chunkLimit, { tableMode: params.tableMode }),
|
||||
);
|
||||
if (!chunks.length && combined) chunks.push(combined);
|
||||
for (const chunk of chunks) {
|
||||
messages.push(chunk);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { SlackActionMiddlewareArgs, SlackCommandMiddlewareArgs } from "@slack/bolt";
|
||||
import type { ChatCommandDefinition, CommandArgs } from "../../auto-reply/commands-registry.js";
|
||||
import { resolveChunkMode } from "../../auto-reply/chunk.js";
|
||||
import { resolveEffectiveMessagesConfig } from "../../agents/identity.js";
|
||||
import {
|
||||
buildCommandTextFromArgs,
|
||||
@@ -429,6 +430,7 @@ export function registerSlackMonitorSlashCommands(params: {
|
||||
respond,
|
||||
ephemeral: slashCommand.ephemeral,
|
||||
textLimit: ctx.textLimit,
|
||||
chunkMode: resolveChunkMode(cfg, "slack", route.accountId),
|
||||
tableMode: resolveMarkdownTableMode({
|
||||
cfg,
|
||||
channel: "slack",
|
||||
@@ -448,6 +450,7 @@ export function registerSlackMonitorSlashCommands(params: {
|
||||
respond,
|
||||
ephemeral: slashCommand.ephemeral,
|
||||
textLimit: ctx.textLimit,
|
||||
chunkMode: resolveChunkMode(cfg, "slack", route.accountId),
|
||||
tableMode: resolveMarkdownTableMode({
|
||||
cfg,
|
||||
channel: "slack",
|
||||
|
||||
Reference in New Issue
Block a user