refactor: simplify chunk mode handling for BlueBubbles
- Removed `chunkMode` configuration from various account schemas and types, centralizing chunk mode logic to BlueBubbles only. - Updated `processMessage` to default to "newline" for BlueBubbles chunking. - Adjusted tests to reflect changes in chunk mode handling for BlueBubbles, ensuring proper functionality.
This commit is contained in:
parent
50cec30c76
commit
824154deba
@ -1851,11 +1851,7 @@ async function processMessage(
|
|||||||
account.config.textChunkLimit && account.config.textChunkLimit > 0
|
account.config.textChunkLimit && account.config.textChunkLimit > 0
|
||||||
? account.config.textChunkLimit
|
? account.config.textChunkLimit
|
||||||
: DEFAULT_TEXT_LIMIT;
|
: DEFAULT_TEXT_LIMIT;
|
||||||
const chunkMode = core.channel.text.resolveChunkMode(
|
const chunkMode = account.config.chunkMode ?? "newline";
|
||||||
config,
|
|
||||||
"bluebubbles",
|
|
||||||
account.accountId,
|
|
||||||
);
|
|
||||||
const tableMode = core.channel.text.resolveMarkdownTableMode({
|
const tableMode = core.channel.text.resolveMarkdownTableMode({
|
||||||
cfg: config,
|
cfg: config,
|
||||||
channel: "bluebubbles",
|
channel: "bluebubbles",
|
||||||
|
|||||||
@ -50,7 +50,6 @@ export const MatrixConfigSchema = z.object({
|
|||||||
replyToMode: z.enum(["off", "first", "all"]).optional(),
|
replyToMode: z.enum(["off", "first", "all"]).optional(),
|
||||||
threadReplies: z.enum(["off", "inbound", "always"]).optional(),
|
threadReplies: z.enum(["off", "inbound", "always"]).optional(),
|
||||||
textChunkLimit: z.number().optional(),
|
textChunkLimit: z.number().optional(),
|
||||||
chunkMode: z.enum(["length", "newline"]).optional(),
|
|
||||||
mediaMaxMb: z.number().optional(),
|
mediaMaxMb: z.number().optional(),
|
||||||
autoJoin: z.enum(["always", "allowlist", "off"]).optional(),
|
autoJoin: z.enum(["always", "allowlist", "off"]).optional(),
|
||||||
autoJoinAllowlist: z.array(allowFromEntry).optional(),
|
autoJoinAllowlist: z.array(allowFromEntry).optional(),
|
||||||
|
|||||||
@ -69,8 +69,6 @@ export type MatrixConfig = {
|
|||||||
threadReplies?: "off" | "inbound" | "always";
|
threadReplies?: "off" | "inbound" | "always";
|
||||||
/** Outbound text chunk size (chars). Default: 4000. */
|
/** Outbound text chunk size (chars). Default: 4000. */
|
||||||
textChunkLimit?: number;
|
textChunkLimit?: number;
|
||||||
/** Chunking mode: "length" (default) splits by size, "newline" splits on every newline. */
|
|
||||||
chunkMode?: "length" | "newline";
|
|
||||||
/** Max outbound media size in MB. */
|
/** Max outbound media size in MB. */
|
||||||
mediaMaxMb?: number;
|
mediaMaxMb?: number;
|
||||||
/** Auto-join invites (always|allowlist|off). Default: always. */
|
/** Auto-join invites (always|allowlist|off). Default: always. */
|
||||||
|
|||||||
@ -25,7 +25,6 @@ const MattermostAccountSchemaBase = z
|
|||||||
groupAllowFrom: z.array(z.union([z.string(), z.number()])).optional(),
|
groupAllowFrom: z.array(z.union([z.string(), z.number()])).optional(),
|
||||||
groupPolicy: GroupPolicySchema.optional().default("allowlist"),
|
groupPolicy: GroupPolicySchema.optional().default("allowlist"),
|
||||||
textChunkLimit: z.number().int().positive().optional(),
|
textChunkLimit: z.number().int().positive().optional(),
|
||||||
chunkMode: z.enum(["length", "newline"]).optional(),
|
|
||||||
blockStreaming: z.boolean().optional(),
|
blockStreaming: z.boolean().optional(),
|
||||||
blockStreamingCoalesce: BlockStreamingCoalesceSchema.optional(),
|
blockStreamingCoalesce: BlockStreamingCoalesceSchema.optional(),
|
||||||
})
|
})
|
||||||
|
|||||||
@ -36,8 +36,6 @@ export type MattermostAccountConfig = {
|
|||||||
groupPolicy?: GroupPolicy;
|
groupPolicy?: GroupPolicy;
|
||||||
/** Outbound text chunk size (chars). Default: 4000. */
|
/** Outbound text chunk size (chars). Default: 4000. */
|
||||||
textChunkLimit?: number;
|
textChunkLimit?: number;
|
||||||
/** Chunking mode: "length" (default) splits by size, "newline" splits on every newline. */
|
|
||||||
chunkMode?: "length" | "newline";
|
|
||||||
/** Disable block streaming for this account. */
|
/** Disable block streaming for this account. */
|
||||||
blockStreaming?: boolean;
|
blockStreaming?: boolean;
|
||||||
/** Merge streamed block replies before sending. */
|
/** Merge streamed block replies before sending. */
|
||||||
|
|||||||
@ -44,7 +44,6 @@ export const NextcloudTalkAccountSchemaBase = z
|
|||||||
dmHistoryLimit: z.number().int().min(0).optional(),
|
dmHistoryLimit: z.number().int().min(0).optional(),
|
||||||
dms: z.record(z.string(), DmConfigSchema.optional()).optional(),
|
dms: z.record(z.string(), DmConfigSchema.optional()).optional(),
|
||||||
textChunkLimit: z.number().int().positive().optional(),
|
textChunkLimit: z.number().int().positive().optional(),
|
||||||
chunkMode: z.enum(["length", "newline"]).optional(),
|
|
||||||
blockStreaming: z.boolean().optional(),
|
blockStreaming: z.boolean().optional(),
|
||||||
blockStreamingCoalesce: BlockStreamingCoalesceSchema.optional(),
|
blockStreamingCoalesce: BlockStreamingCoalesceSchema.optional(),
|
||||||
mediaMaxMb: z.number().positive().optional(),
|
mediaMaxMb: z.number().positive().optional(),
|
||||||
|
|||||||
@ -62,8 +62,6 @@ export type NextcloudTalkAccountConfig = {
|
|||||||
dms?: Record<string, DmConfig>;
|
dms?: Record<string, DmConfig>;
|
||||||
/** Outbound text chunk size (chars). Default: 4000. */
|
/** Outbound text chunk size (chars). Default: 4000. */
|
||||||
textChunkLimit?: number;
|
textChunkLimit?: number;
|
||||||
/** Chunking mode: "length" (default) splits by size, "newline" splits on every newline. */
|
|
||||||
chunkMode?: "length" | "newline";
|
|
||||||
/** Disable block streaming for this account. */
|
/** Disable block streaming for this account. */
|
||||||
blockStreaming?: boolean;
|
blockStreaming?: boolean;
|
||||||
/** Merge streamed block replies before sending. */
|
/** Merge streamed block replies before sending. */
|
||||||
|
|||||||
@ -299,20 +299,20 @@ describe("resolveChunkMode", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("returns length for internal channel", () => {
|
it("returns length for internal channel", () => {
|
||||||
const cfg = { channels: { telegram: { chunkMode: "newline" as const } } };
|
const cfg = { channels: { bluebubbles: { chunkMode: "newline" as const } } };
|
||||||
expect(resolveChunkMode(cfg, "__internal__")).toBe("length");
|
expect(resolveChunkMode(cfg, "__internal__")).toBe("length");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("supports provider-level overrides", () => {
|
it("supports provider-level overrides for bluebubbles", () => {
|
||||||
const cfg = { channels: { telegram: { chunkMode: "newline" as const } } };
|
const cfg = { channels: { bluebubbles: { chunkMode: "newline" as const } } };
|
||||||
expect(resolveChunkMode(cfg, "telegram")).toBe("newline");
|
expect(resolveChunkMode(cfg, "bluebubbles")).toBe("newline");
|
||||||
expect(resolveChunkMode(cfg, "discord")).toBe("length");
|
expect(resolveChunkMode(cfg, "discord")).toBe("length");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("supports account-level overrides", () => {
|
it("supports account-level overrides for bluebubbles", () => {
|
||||||
const cfg = {
|
const cfg = {
|
||||||
channels: {
|
channels: {
|
||||||
telegram: {
|
bluebubbles: {
|
||||||
chunkMode: "length" as const,
|
chunkMode: "length" as const,
|
||||||
accounts: {
|
accounts: {
|
||||||
primary: { chunkMode: "newline" as const },
|
primary: { chunkMode: "newline" as const },
|
||||||
@ -320,7 +320,12 @@ describe("resolveChunkMode", () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
expect(resolveChunkMode(cfg, "telegram", "primary")).toBe("newline");
|
expect(resolveChunkMode(cfg, "bluebubbles", "primary")).toBe("newline");
|
||||||
expect(resolveChunkMode(cfg, "telegram", "other")).toBe("length");
|
expect(resolveChunkMode(cfg, "bluebubbles", "other")).toBe("length");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("ignores chunkMode for non-bluebubbles providers", () => {
|
||||||
|
const cfg = { channels: { ["telegram" as string]: { chunkMode: "newline" as const } } };
|
||||||
|
expect(resolveChunkMode(cfg, "telegram")).toBe("length");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -101,6 +101,8 @@ export function resolveChunkMode(
|
|||||||
accountId?: string | null,
|
accountId?: string | null,
|
||||||
): ChunkMode {
|
): ChunkMode {
|
||||||
if (!provider || provider === INTERNAL_MESSAGE_CHANNEL) return DEFAULT_CHUNK_MODE;
|
if (!provider || provider === INTERNAL_MESSAGE_CHANNEL) return DEFAULT_CHUNK_MODE;
|
||||||
|
// Chunk mode is only supported for BlueBubbles.
|
||||||
|
if (provider !== "bluebubbles") return DEFAULT_CHUNK_MODE;
|
||||||
const channelsConfig = cfg?.channels as Record<string, unknown> | undefined;
|
const channelsConfig = cfg?.channels as Record<string, unknown> | undefined;
|
||||||
const providerConfig = (channelsConfig?.[provider] ??
|
const providerConfig = (channelsConfig?.[provider] ??
|
||||||
(cfg as Record<string, unknown> | undefined)?.[provider]) as ProviderChunkConfig | undefined;
|
(cfg as Record<string, unknown> | undefined)?.[provider]) as ProviderChunkConfig | undefined;
|
||||||
|
|||||||
@ -69,7 +69,7 @@ export function resolveBlockStreamingChunking(
|
|||||||
});
|
});
|
||||||
const chunkCfg = cfg?.agents?.defaults?.blockStreamingChunk;
|
const chunkCfg = cfg?.agents?.defaults?.blockStreamingChunk;
|
||||||
|
|
||||||
// Check if channel has chunkMode: "newline" - if so, use newline-based streaming
|
// BlueBubbles-only: if chunkMode is "newline", use newline-based streaming
|
||||||
const channelChunkMode = resolveChunkMode(cfg, providerKey, accountId);
|
const channelChunkMode = resolveChunkMode(cfg, providerKey, accountId);
|
||||||
if (channelChunkMode === "newline") {
|
if (channelChunkMode === "newline") {
|
||||||
// For newline mode: use very low minChars to flush quickly on newlines
|
// For newline mode: use very low minChars to flush quickly on newlines
|
||||||
@ -103,7 +103,7 @@ export function resolveBlockStreamingCoalescing(
|
|||||||
): BlockStreamingCoalescing | undefined {
|
): BlockStreamingCoalescing | undefined {
|
||||||
const providerKey = normalizeChunkProvider(provider);
|
const providerKey = normalizeChunkProvider(provider);
|
||||||
|
|
||||||
// When chunkMode is "newline", disable coalescing entirely to send each line immediately
|
// BlueBubbles-only: when chunkMode is "newline", disable coalescing to send each line immediately
|
||||||
const channelChunkMode = resolveChunkMode(cfg, providerKey, accountId);
|
const channelChunkMode = resolveChunkMode(cfg, providerKey, accountId);
|
||||||
if (channelChunkMode === "newline") {
|
if (channelChunkMode === "newline") {
|
||||||
return undefined;
|
return undefined;
|
||||||
|
|||||||
@ -108,8 +108,6 @@ export type DiscordAccountConfig = {
|
|||||||
groupPolicy?: GroupPolicy;
|
groupPolicy?: GroupPolicy;
|
||||||
/** Outbound text chunk size (chars). Default: 2000. */
|
/** Outbound text chunk size (chars). Default: 2000. */
|
||||||
textChunkLimit?: number;
|
textChunkLimit?: number;
|
||||||
/** Chunking mode: "length" (default) splits by size, "newline" splits on every newline. */
|
|
||||||
chunkMode?: "length" | "newline";
|
|
||||||
/** Disable block streaming for this account. */
|
/** Disable block streaming for this account. */
|
||||||
blockStreaming?: boolean;
|
blockStreaming?: boolean;
|
||||||
/** Merge streamed block replies before sending. */
|
/** Merge streamed block replies before sending. */
|
||||||
|
|||||||
@ -54,8 +54,6 @@ export type IMessageAccountConfig = {
|
|||||||
mediaMaxMb?: number;
|
mediaMaxMb?: number;
|
||||||
/** Outbound text chunk size (chars). Default: 4000. */
|
/** Outbound text chunk size (chars). Default: 4000. */
|
||||||
textChunkLimit?: number;
|
textChunkLimit?: number;
|
||||||
/** Chunking mode: "length" (default) splits by size, "newline" splits on every newline. */
|
|
||||||
chunkMode?: "length" | "newline";
|
|
||||||
blockStreaming?: boolean;
|
blockStreaming?: boolean;
|
||||||
/** Merge streamed block replies before sending. */
|
/** Merge streamed block replies before sending. */
|
||||||
blockStreamingCoalesce?: BlockStreamingCoalesceConfig;
|
blockStreamingCoalesce?: BlockStreamingCoalesceConfig;
|
||||||
|
|||||||
@ -72,8 +72,6 @@ export type MSTeamsConfig = {
|
|||||||
groupPolicy?: GroupPolicy;
|
groupPolicy?: GroupPolicy;
|
||||||
/** Outbound text chunk size (chars). Default: 4000. */
|
/** Outbound text chunk size (chars). Default: 4000. */
|
||||||
textChunkLimit?: number;
|
textChunkLimit?: number;
|
||||||
/** Chunking mode: "length" (default) splits by size, "newline" splits on every newline. */
|
|
||||||
chunkMode?: "length" | "newline";
|
|
||||||
/** Merge streamed block replies before sending. */
|
/** Merge streamed block replies before sending. */
|
||||||
blockStreamingCoalesce?: BlockStreamingCoalesceConfig;
|
blockStreamingCoalesce?: BlockStreamingCoalesceConfig;
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -56,8 +56,6 @@ export type SignalAccountConfig = {
|
|||||||
dms?: Record<string, DmConfig>;
|
dms?: Record<string, DmConfig>;
|
||||||
/** Outbound text chunk size (chars). Default: 4000. */
|
/** Outbound text chunk size (chars). Default: 4000. */
|
||||||
textChunkLimit?: number;
|
textChunkLimit?: number;
|
||||||
/** Chunking mode: "length" (default) splits by size, "newline" splits on every newline. */
|
|
||||||
chunkMode?: "length" | "newline";
|
|
||||||
blockStreaming?: boolean;
|
blockStreaming?: boolean;
|
||||||
/** Merge streamed block replies before sending. */
|
/** Merge streamed block replies before sending. */
|
||||||
blockStreamingCoalesce?: BlockStreamingCoalesceConfig;
|
blockStreamingCoalesce?: BlockStreamingCoalesceConfig;
|
||||||
|
|||||||
@ -116,8 +116,6 @@ export type SlackAccountConfig = {
|
|||||||
/** Per-DM config overrides keyed by user ID. */
|
/** Per-DM config overrides keyed by user ID. */
|
||||||
dms?: Record<string, DmConfig>;
|
dms?: Record<string, DmConfig>;
|
||||||
textChunkLimit?: number;
|
textChunkLimit?: number;
|
||||||
/** Chunking mode: "length" (default) splits by size, "newline" splits on every newline. */
|
|
||||||
chunkMode?: "length" | "newline";
|
|
||||||
blockStreaming?: boolean;
|
blockStreaming?: boolean;
|
||||||
/** Merge streamed block replies before sending. */
|
/** Merge streamed block replies before sending. */
|
||||||
blockStreamingCoalesce?: BlockStreamingCoalesceConfig;
|
blockStreamingCoalesce?: BlockStreamingCoalesceConfig;
|
||||||
|
|||||||
@ -80,8 +80,6 @@ export type TelegramAccountConfig = {
|
|||||||
dms?: Record<string, DmConfig>;
|
dms?: Record<string, DmConfig>;
|
||||||
/** Outbound text chunk size (chars). Default: 4000. */
|
/** Outbound text chunk size (chars). Default: 4000. */
|
||||||
textChunkLimit?: number;
|
textChunkLimit?: number;
|
||||||
/** Chunking mode: "length" (default) splits by size, "newline" splits on every newline. */
|
|
||||||
chunkMode?: "length" | "newline";
|
|
||||||
/** Disable block streaming for this account. */
|
/** Disable block streaming for this account. */
|
||||||
blockStreaming?: boolean;
|
blockStreaming?: boolean;
|
||||||
/** Chunking config for draft streaming in `streamMode: "block"`. */
|
/** Chunking config for draft streaming in `streamMode: "block"`. */
|
||||||
|
|||||||
@ -55,8 +55,6 @@ export type WhatsAppConfig = {
|
|||||||
dms?: Record<string, DmConfig>;
|
dms?: Record<string, DmConfig>;
|
||||||
/** Outbound text chunk size (chars). Default: 4000. */
|
/** Outbound text chunk size (chars). Default: 4000. */
|
||||||
textChunkLimit?: number;
|
textChunkLimit?: number;
|
||||||
/** Chunking mode: "length" (default) splits by size, "newline" splits on every newline. */
|
|
||||||
chunkMode?: "length" | "newline";
|
|
||||||
/** Maximum media file size in MB. Default: 50. */
|
/** Maximum media file size in MB. Default: 50. */
|
||||||
mediaMaxMb?: number;
|
mediaMaxMb?: number;
|
||||||
/** Disable block streaming for this account. */
|
/** Disable block streaming for this account. */
|
||||||
@ -124,8 +122,6 @@ export type WhatsAppAccountConfig = {
|
|||||||
/** Per-DM config overrides keyed by user ID. */
|
/** Per-DM config overrides keyed by user ID. */
|
||||||
dms?: Record<string, DmConfig>;
|
dms?: Record<string, DmConfig>;
|
||||||
textChunkLimit?: number;
|
textChunkLimit?: number;
|
||||||
/** Chunking mode: "length" (default) splits by size, "newline" splits on every newline. */
|
|
||||||
chunkMode?: "length" | "newline";
|
|
||||||
mediaMaxMb?: number;
|
mediaMaxMb?: number;
|
||||||
blockStreaming?: boolean;
|
blockStreaming?: boolean;
|
||||||
/** Merge streamed block replies before sending. */
|
/** Merge streamed block replies before sending. */
|
||||||
|
|||||||
@ -102,7 +102,6 @@ export const TelegramAccountSchemaBase = z
|
|||||||
dmHistoryLimit: z.number().int().min(0).optional(),
|
dmHistoryLimit: z.number().int().min(0).optional(),
|
||||||
dms: z.record(z.string(), DmConfigSchema.optional()).optional(),
|
dms: z.record(z.string(), DmConfigSchema.optional()).optional(),
|
||||||
textChunkLimit: z.number().int().positive().optional(),
|
textChunkLimit: z.number().int().positive().optional(),
|
||||||
chunkMode: z.enum(["length", "newline"]).optional(),
|
|
||||||
blockStreaming: z.boolean().optional(),
|
blockStreaming: z.boolean().optional(),
|
||||||
draftChunk: BlockStreamingChunkSchema.optional(),
|
draftChunk: BlockStreamingChunkSchema.optional(),
|
||||||
blockStreamingCoalesce: BlockStreamingCoalesceSchema.optional(),
|
blockStreamingCoalesce: BlockStreamingCoalesceSchema.optional(),
|
||||||
@ -213,7 +212,6 @@ export const DiscordAccountSchema = z
|
|||||||
dmHistoryLimit: z.number().int().min(0).optional(),
|
dmHistoryLimit: z.number().int().min(0).optional(),
|
||||||
dms: z.record(z.string(), DmConfigSchema.optional()).optional(),
|
dms: z.record(z.string(), DmConfigSchema.optional()).optional(),
|
||||||
textChunkLimit: z.number().int().positive().optional(),
|
textChunkLimit: z.number().int().positive().optional(),
|
||||||
chunkMode: z.enum(["length", "newline"]).optional(),
|
|
||||||
blockStreaming: z.boolean().optional(),
|
blockStreaming: z.boolean().optional(),
|
||||||
blockStreamingCoalesce: BlockStreamingCoalesceSchema.optional(),
|
blockStreamingCoalesce: BlockStreamingCoalesceSchema.optional(),
|
||||||
maxLinesPerMessage: z.number().int().positive().optional(),
|
maxLinesPerMessage: z.number().int().positive().optional(),
|
||||||
@ -403,7 +401,6 @@ export const SlackAccountSchema = z
|
|||||||
dmHistoryLimit: z.number().int().min(0).optional(),
|
dmHistoryLimit: z.number().int().min(0).optional(),
|
||||||
dms: z.record(z.string(), DmConfigSchema.optional()).optional(),
|
dms: z.record(z.string(), DmConfigSchema.optional()).optional(),
|
||||||
textChunkLimit: z.number().int().positive().optional(),
|
textChunkLimit: z.number().int().positive().optional(),
|
||||||
chunkMode: z.enum(["length", "newline"]).optional(),
|
|
||||||
blockStreaming: z.boolean().optional(),
|
blockStreaming: z.boolean().optional(),
|
||||||
blockStreamingCoalesce: BlockStreamingCoalesceSchema.optional(),
|
blockStreamingCoalesce: BlockStreamingCoalesceSchema.optional(),
|
||||||
mediaMaxMb: z.number().positive().optional(),
|
mediaMaxMb: z.number().positive().optional(),
|
||||||
@ -497,7 +494,6 @@ export const SignalAccountSchemaBase = z
|
|||||||
dmHistoryLimit: z.number().int().min(0).optional(),
|
dmHistoryLimit: z.number().int().min(0).optional(),
|
||||||
dms: z.record(z.string(), DmConfigSchema.optional()).optional(),
|
dms: z.record(z.string(), DmConfigSchema.optional()).optional(),
|
||||||
textChunkLimit: z.number().int().positive().optional(),
|
textChunkLimit: z.number().int().positive().optional(),
|
||||||
chunkMode: z.enum(["length", "newline"]).optional(),
|
|
||||||
blockStreaming: z.boolean().optional(),
|
blockStreaming: z.boolean().optional(),
|
||||||
blockStreamingCoalesce: BlockStreamingCoalesceSchema.optional(),
|
blockStreamingCoalesce: BlockStreamingCoalesceSchema.optional(),
|
||||||
mediaMaxMb: z.number().int().positive().optional(),
|
mediaMaxMb: z.number().int().positive().optional(),
|
||||||
@ -551,7 +547,6 @@ export const IMessageAccountSchemaBase = z
|
|||||||
includeAttachments: z.boolean().optional(),
|
includeAttachments: z.boolean().optional(),
|
||||||
mediaMaxMb: z.number().int().positive().optional(),
|
mediaMaxMb: z.number().int().positive().optional(),
|
||||||
textChunkLimit: z.number().int().positive().optional(),
|
textChunkLimit: z.number().int().positive().optional(),
|
||||||
chunkMode: z.enum(["length", "newline"]).optional(),
|
|
||||||
blockStreaming: z.boolean().optional(),
|
blockStreaming: z.boolean().optional(),
|
||||||
blockStreamingCoalesce: BlockStreamingCoalesceSchema.optional(),
|
blockStreamingCoalesce: BlockStreamingCoalesceSchema.optional(),
|
||||||
groups: z
|
groups: z
|
||||||
@ -710,7 +705,6 @@ export const MSTeamsConfigSchema = z
|
|||||||
groupAllowFrom: z.array(z.string()).optional(),
|
groupAllowFrom: z.array(z.string()).optional(),
|
||||||
groupPolicy: GroupPolicySchema.optional().default("allowlist"),
|
groupPolicy: GroupPolicySchema.optional().default("allowlist"),
|
||||||
textChunkLimit: z.number().int().positive().optional(),
|
textChunkLimit: z.number().int().positive().optional(),
|
||||||
chunkMode: z.enum(["length", "newline"]).optional(),
|
|
||||||
blockStreamingCoalesce: BlockStreamingCoalesceSchema.optional(),
|
blockStreamingCoalesce: BlockStreamingCoalesceSchema.optional(),
|
||||||
mediaAllowHosts: z.array(z.string()).optional(),
|
mediaAllowHosts: z.array(z.string()).optional(),
|
||||||
requireMention: z.boolean().optional(),
|
requireMention: z.boolean().optional(),
|
||||||
|
|||||||
@ -30,7 +30,6 @@ export const WhatsAppAccountSchema = z
|
|||||||
dmHistoryLimit: z.number().int().min(0).optional(),
|
dmHistoryLimit: z.number().int().min(0).optional(),
|
||||||
dms: z.record(z.string(), DmConfigSchema.optional()).optional(),
|
dms: z.record(z.string(), DmConfigSchema.optional()).optional(),
|
||||||
textChunkLimit: z.number().int().positive().optional(),
|
textChunkLimit: z.number().int().positive().optional(),
|
||||||
chunkMode: z.enum(["length", "newline"]).optional(),
|
|
||||||
mediaMaxMb: z.number().int().positive().optional(),
|
mediaMaxMb: z.number().int().positive().optional(),
|
||||||
blockStreaming: z.boolean().optional(),
|
blockStreaming: z.boolean().optional(),
|
||||||
blockStreamingCoalesce: BlockStreamingCoalesceSchema.optional(),
|
blockStreamingCoalesce: BlockStreamingCoalesceSchema.optional(),
|
||||||
@ -86,7 +85,6 @@ export const WhatsAppConfigSchema = z
|
|||||||
dmHistoryLimit: z.number().int().min(0).optional(),
|
dmHistoryLimit: z.number().int().min(0).optional(),
|
||||||
dms: z.record(z.string(), DmConfigSchema.optional()).optional(),
|
dms: z.record(z.string(), DmConfigSchema.optional()).optional(),
|
||||||
textChunkLimit: z.number().int().positive().optional(),
|
textChunkLimit: z.number().int().positive().optional(),
|
||||||
chunkMode: z.enum(["length", "newline"]).optional(),
|
|
||||||
mediaMaxMb: z.number().int().positive().optional().default(50),
|
mediaMaxMb: z.number().int().positive().optional().default(50),
|
||||||
blockStreaming: z.boolean().optional(),
|
blockStreaming: z.boolean().optional(),
|
||||||
blockStreamingCoalesce: BlockStreamingCoalesceSchema.optional(),
|
blockStreamingCoalesce: BlockStreamingCoalesceSchema.optional(),
|
||||||
|
|||||||
@ -1,8 +1,4 @@
|
|||||||
import {
|
import { resolveTextChunkLimit } from "../../auto-reply/chunk.js";
|
||||||
chunkTextWithMode,
|
|
||||||
resolveChunkMode,
|
|
||||||
resolveTextChunkLimit,
|
|
||||||
} from "../../auto-reply/chunk.js";
|
|
||||||
import type { ReplyPayload } from "../../auto-reply/types.js";
|
import type { ReplyPayload } from "../../auto-reply/types.js";
|
||||||
import { resolveChannelMediaMaxBytes } from "../../channels/plugins/media-limits.js";
|
import { resolveChannelMediaMaxBytes } from "../../channels/plugins/media-limits.js";
|
||||||
import { loadChannelOutboundAdapter } from "../../channels/plugins/outbound/load.js";
|
import { loadChannelOutboundAdapter } from "../../channels/plugins/outbound/load.js";
|
||||||
@ -196,7 +192,6 @@ export async function deliverOutboundPayloads(params: {
|
|||||||
fallbackLimit: handler.textChunkLimit,
|
fallbackLimit: handler.textChunkLimit,
|
||||||
})
|
})
|
||||||
: undefined;
|
: undefined;
|
||||||
const chunkMode = resolveChunkMode(cfg, channel, accountId);
|
|
||||||
const isSignalChannel = channel === "signal";
|
const isSignalChannel = channel === "signal";
|
||||||
const signalTableMode = isSignalChannel
|
const signalTableMode = isSignalChannel
|
||||||
? resolveMarkdownTableMode({ cfg, channel: "signal", accountId })
|
? resolveMarkdownTableMode({ cfg, channel: "signal", accountId })
|
||||||
@ -217,11 +212,7 @@ export async function deliverOutboundPayloads(params: {
|
|||||||
results.push(await handler.sendText(text));
|
results.push(await handler.sendText(text));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Use newline chunking if explicitly configured, otherwise use the adapter's chunker
|
const chunks = handler.chunker(text, textLimit);
|
||||||
const chunks =
|
|
||||||
chunkMode === "newline"
|
|
||||||
? chunkTextWithMode(text, textLimit, chunkMode)
|
|
||||||
: handler.chunker(text, textLimit);
|
|
||||||
for (const chunk of chunks) {
|
for (const chunk of chunks) {
|
||||||
throwIfAborted(abortSignal);
|
throwIfAborted(abortSignal);
|
||||||
results.push(await handler.sendText(chunk));
|
results.push(await handler.sendText(chunk));
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user