@@ -143,6 +143,52 @@ describe("runMessageAction send validation", () => {
143143 expect ( JSON . stringify ( result . toolResult ?. content ) ) . not . toContain ( "hello from codex" ) ;
144144 } ) ;
145145
146+ it ( "uses the current internal UI source as the automatic WebChat send sink" , async ( ) => {
147+ const result = await runMessageAction ( {
148+ cfg : emptyConfig ,
149+ action : "send" ,
150+ params : {
151+ message : "hello from webchat" ,
152+ } ,
153+ toolContext : {
154+ currentChannelProvider : "webchat" ,
155+ } ,
156+ sessionKey : "agent:main" ,
157+ sourceReplyDeliveryMode : "automatic" ,
158+ } ) ;
159+
160+ expect ( result ) . toMatchObject ( {
161+ kind : "send" ,
162+ channel : "webchat" ,
163+ to : "current-run" ,
164+ handledBy : "internal-source" ,
165+ payload : {
166+ status : "ok" ,
167+ deliveryStatus : "sent" ,
168+ sourceReplySink : "internal-ui" ,
169+ sourceReply : {
170+ text : "hello from webchat" ,
171+ } ,
172+ } ,
173+ } ) ;
174+ } ) ;
175+
176+ it ( "does not infer the automatic WebChat send sink when delivery mode is omitted" , async ( ) => {
177+ await expect (
178+ runMessageAction ( {
179+ cfg : emptyConfig ,
180+ action : "send" ,
181+ params : {
182+ message : "hello from webchat" ,
183+ } ,
184+ toolContext : {
185+ currentChannelProvider : "webchat" ,
186+ } ,
187+ sessionKey : "agent:main" ,
188+ } ) ,
189+ ) . rejects . toThrow ( / r e q u i r e s a t a r g e t / i) ;
190+ } ) ;
191+
146192 it . each ( [ "agent:voice:agent:channel:room" , "agent:main:telegram::group:room" ] ) (
147193 "keeps malformed session route %s on the internal source sink" ,
148194 async ( sessionKey ) => {
@@ -237,18 +283,18 @@ describe("runMessageAction send validation", () => {
237283 expect ( JSON . stringify ( result . payload ) ) . not . toContain ( "turn2view0" ) ;
238284 } ) ;
239285
240- it ( "does not infer an internal UI sink outside message-tool-only source delivery" , async ( ) => {
286+ it ( "does not infer a non-webchat source sink outside message-tool-only source delivery" , async ( ) => {
241287 await expect (
242288 runMessageAction ( {
243289 cfg : emptyConfig ,
244290 action : "send" ,
245291 params : {
246- message : "hello from codex " ,
292+ message : "telegram reply " ,
247293 } ,
248294 toolContext : {
249- currentChannelProvider : "webchat " ,
295+ currentChannelProvider : "telegram " ,
250296 } ,
251- sessionKey : "agent:main" ,
297+ sessionKey : "agent:main:telegram:direct:123456789 " ,
252298 sourceReplyDeliveryMode : "automatic" ,
253299 } ) ,
254300 ) . rejects . toThrow ( / r e q u i r e s a t a r g e t / i) ;
0 commit comments