fix: newline chunking across channels
This commit is contained in:
@@ -22,6 +22,7 @@ export type ResolvedWhatsAppAccount = {
|
||||
groupPolicy?: GroupPolicy;
|
||||
dmPolicy?: DmPolicy;
|
||||
textChunkLimit?: number;
|
||||
chunkMode?: "length" | "newline";
|
||||
mediaMaxMb?: number;
|
||||
blockStreaming?: boolean;
|
||||
ackReaction?: WhatsAppAccountConfig["ackReaction"];
|
||||
@@ -150,6 +151,7 @@ export function resolveWhatsAppAccount(params: {
|
||||
groupAllowFrom: accountCfg?.groupAllowFrom ?? rootCfg?.groupAllowFrom,
|
||||
groupPolicy: accountCfg?.groupPolicy ?? rootCfg?.groupPolicy,
|
||||
textChunkLimit: accountCfg?.textChunkLimit ?? rootCfg?.textChunkLimit,
|
||||
chunkMode: accountCfg?.chunkMode ?? rootCfg?.chunkMode,
|
||||
mediaMaxMb: accountCfg?.mediaMaxMb ?? rootCfg?.mediaMaxMb,
|
||||
blockStreaming: accountCfg?.blockStreaming ?? rootCfg?.blockStreaming,
|
||||
ackReaction: accountCfg?.ackReaction ?? rootCfg?.ackReaction,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { chunkMarkdownText } from "../../auto-reply/chunk.js";
|
||||
import { chunkMarkdownTextWithMode, type ChunkMode } from "../../auto-reply/chunk.js";
|
||||
import type { MarkdownTableMode } from "../../config/types.base.js";
|
||||
import { convertMarkdownTables } from "../../markdown/tables.js";
|
||||
import type { ReplyPayload } from "../../auto-reply/types.js";
|
||||
@@ -15,6 +15,7 @@ export async function deliverWebReply(params: {
|
||||
msg: WebInboundMsg;
|
||||
maxMediaBytes: number;
|
||||
textLimit: number;
|
||||
chunkMode?: ChunkMode;
|
||||
replyLogger: {
|
||||
info: (obj: unknown, msg: string) => void;
|
||||
warn: (obj: unknown, msg: string) => void;
|
||||
@@ -26,8 +27,9 @@ export async function deliverWebReply(params: {
|
||||
const { replyResult, msg, maxMediaBytes, textLimit, replyLogger, connectionId, skipLog } = params;
|
||||
const replyStarted = Date.now();
|
||||
const tableMode = params.tableMode ?? "code";
|
||||
const chunkMode = params.chunkMode ?? "length";
|
||||
const convertedText = convertMarkdownTables(replyResult.text || "", tableMode);
|
||||
const textChunks = chunkMarkdownText(convertedText, textLimit);
|
||||
const textChunks = chunkMarkdownTextWithMode(convertedText, textLimit, chunkMode);
|
||||
const mediaList = replyResult.mediaUrls?.length
|
||||
? replyResult.mediaUrls
|
||||
: replyResult.mediaUrl
|
||||
|
||||
@@ -79,6 +79,7 @@ export async function monitorWebChannel(
|
||||
groupAllowFrom: account.groupAllowFrom,
|
||||
groupPolicy: account.groupPolicy,
|
||||
textChunkLimit: account.textChunkLimit,
|
||||
chunkMode: account.chunkMode,
|
||||
mediaMaxMb: account.mediaMaxMb,
|
||||
blockStreaming: account.blockStreaming,
|
||||
groups: account.groups,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { resolveIdentityNamePrefix } from "../../../agents/identity.js";
|
||||
import { resolveTextChunkLimit } from "../../../auto-reply/chunk.js";
|
||||
import { resolveChunkMode, resolveTextChunkLimit } from "../../../auto-reply/chunk.js";
|
||||
import {
|
||||
formatInboundEnvelope,
|
||||
resolveEnvelopeFormatOptions,
|
||||
@@ -229,6 +229,7 @@ export async function processMessage(params: {
|
||||
: undefined;
|
||||
|
||||
const textLimit = params.maxMediaTextChunkLimit ?? resolveTextChunkLimit(params.cfg, "whatsapp");
|
||||
const chunkMode = resolveChunkMode(params.cfg, "whatsapp", params.route.accountId);
|
||||
const tableMode = resolveMarkdownTableMode({
|
||||
cfg: params.cfg,
|
||||
channel: "whatsapp",
|
||||
@@ -338,6 +339,7 @@ export async function processMessage(params: {
|
||||
msg: params.msg,
|
||||
maxMediaBytes: params.maxMediaBytes,
|
||||
textLimit,
|
||||
chunkMode,
|
||||
replyLogger: params.replyLogger,
|
||||
connectionId: params.connectionId,
|
||||
// Tool + block updates are noisy; skip their log lines.
|
||||
|
||||
Reference in New Issue
Block a user