33 chunkMarkdownTextWithMode ,
44 type ChunkMode ,
55} from "../../auto-reply/chunk.js" ;
6+ import type { OpenClawConfig } from "../../config/types.js" ;
67import type { OutboundDeliveryFormattingOptions } from "./formatting.js" ;
78import type { ReplyToOverride } from "./reply-policy.js" ;
89
@@ -29,7 +30,11 @@ export type OutboundMessageUnit =
2930export type OutboundMessageChunker = (
3031 text : string ,
3132 limit : number ,
32- ctx ?: { formatting ?: OutboundDeliveryFormattingOptions } ,
33+ ctx ?: {
34+ formatting ?: OutboundDeliveryFormattingOptions ;
35+ cfg ?: OpenClawConfig ;
36+ accountId ?: string | null ;
37+ } ,
3338) => string [ ] ;
3439
3540type PlanReplyToConsumption = < T extends OutboundMessageSendOverrides > ( overrides : T ) => T ;
@@ -55,10 +60,14 @@ function chunkTextForPlan(params: {
5560 limit : number ;
5661 chunker : OutboundMessageChunker ;
5762 formatting ?: OutboundDeliveryFormattingOptions ;
63+ cfg ?: OpenClawConfig ;
64+ accountId ?: string | null ;
5865} ) : string [ ] {
59- return params . formatting
60- ? params . chunker ( params . text , params . limit , { formatting : params . formatting } )
61- : params . chunker ( params . text , params . limit ) ;
66+ return params . chunker ( params . text , params . limit , {
67+ formatting : params . formatting ,
68+ cfg : params . cfg ,
69+ accountId : params . accountId ,
70+ } ) ;
6271}
6372
6473export function planOutboundTextMessageUnits ( params : {
@@ -70,6 +79,8 @@ export function planOutboundTextMessageUnits(params: {
7079 textLimit ?: number ;
7180 chunkMode ?: ChunkMode ;
7281 formatting ?: OutboundDeliveryFormattingOptions ;
82+ cfg ?: OpenClawConfig ;
83+ accountId ?: string | null ;
7384 consumeReplyTo ?: PlanReplyToConsumption ;
7485} ) : OutboundMessageUnit [ ] {
7586 const planTextUnit = ( text : string ) : OutboundMessageUnit => ( {
@@ -106,6 +117,8 @@ export function planOutboundTextMessageUnits(params: {
106117 limit : params . textLimit ,
107118 chunker : params . chunker ,
108119 formatting : params . formatting ,
120+ cfg : params . cfg ,
121+ accountId : params . accountId ,
109122 } ) ;
110123 if ( ! chunks . length && blockChunk ) {
111124 chunks . push ( blockChunk ) ;
@@ -122,6 +135,8 @@ export function planOutboundTextMessageUnits(params: {
122135 limit : params . textLimit ,
123136 chunker : params . chunker ,
124137 formatting : params . formatting ,
138+ cfg : params . cfg ,
139+ accountId : params . accountId ,
125140 } ) . map ( planChunkedTextUnit ) ;
126141}
127142
0 commit comments