@@ -2,11 +2,11 @@ import assert from "node:assert/strict";
22import test from "node:test" ;
33
44import {
5+ classifySpeakableAgentText ,
56 createInitialMembershipGate ,
67 createLatestStateGate ,
78 createOrderedSpeaker ,
89 routeLiveAgentText ,
9- speakableAgentText ,
1010} from "./ttsLiveMessages.ts" ;
1111
1212const agents = new Set ( [ "agent" ] ) ;
@@ -18,59 +18,48 @@ const base = {
1818 content : "Hello there" ,
1919 tags : [ [ "h" , CHANNEL ] ] ,
2020} ;
21+ const speakableText = ( event , selfPubkey = "human" ) =>
22+ classifySpeakableAgentText ( event , agents , selfPubkey , CHANNEL ) . text ;
2123
2224test ( "speaks only new agent-authored text message events" , ( ) => {
25+ assert . equal ( speakableText ( base ) , "Hello there" ) ;
2326 assert . equal (
24- speakableAgentText ( base , agents , "human" , CHANNEL ) ,
25- "Hello there" ,
26- ) ;
27- assert . equal (
28- speakableAgentText ( { ...base , kind : 40002 } , agents , "human" , CHANNEL ) ,
27+ speakableText ( { ...base , kind : 40002 } ) ,
2928 "Hello there" ,
3029 "managed stream-message-v2 replies are spoken" ,
3130 ) ;
3231 assert . equal (
33- speakableAgentText ( { ...base , kind : 7 } , agents , "human" , CHANNEL ) ,
32+ speakableText ( { ...base , kind : 7 } ) ,
3433 null ,
3534 "reactions and other event kinds are excluded" ,
3635 ) ;
3736 assert . equal (
38- speakableAgentText ( { ...base , kind : 10 } , agents , "human" , CHANNEL ) ,
37+ speakableText ( { ...base , kind : 10 } ) ,
3938 null ,
4039 "edits and status events are excluded" ,
4140 ) ;
4241 assert . equal (
43- speakableAgentText ( { ...base , pubkey : "human" } , agents , "human" , CHANNEL ) ,
42+ speakableText ( { ...base , pubkey : "human" } ) ,
4443 null ,
4544 "human-authored messages are excluded" ,
4645 ) ;
4746 assert . equal (
48- speakableAgentText ( { ...base , content : " " } , agents , "human" , CHANNEL ) ,
47+ speakableText ( { ...base , content : " " } ) ,
4948 null ,
5049 "empty and non-text content are excluded" ,
5150 ) ;
5251 assert . equal (
53- speakableAgentText ( { ...base , content : "K" } , agents , "human" , CHANNEL ) ,
52+ speakableText ( { ...base , content : "K" } ) ,
5453 "K" ,
5554 "one-character agent text remains speakable" ,
5655 ) ;
5756 assert . equal (
58- speakableAgentText (
59- { ...base , content : "[System] tool started" } ,
60- agents ,
61- "human" ,
62- CHANNEL ,
63- ) ,
57+ speakableText ( { ...base , content : "[System] tool started" } ) ,
6458 null ,
6559 "legacy system rows are excluded" ,
6660 ) ;
6761 assert . equal (
68- speakableAgentText (
69- { ...base , tags : [ [ "h" , "another-huddle" ] ] } ,
70- agents ,
71- "human" ,
72- CHANNEL ,
73- ) ,
62+ speakableText ( { ...base , tags : [ [ "h" , "another-huddle" ] ] } ) ,
7463 null ,
7564 "messages for another huddle are excluded" ,
7665 ) ;
@@ -134,30 +123,19 @@ test("strips attachment markup and skips attachment-only events", () => {
134123 const url = "https://cdn.example/voice.png" ;
135124 const tags = [ ...base . tags , [ "imeta" , `url ${ url } ` , "m image/png" ] ] ;
136125 assert . equal (
137- speakableAgentText (
138- { ...base , content : `` , tags } ,
139- agents ,
140- "human" ,
141- CHANNEL ,
142- ) ,
126+ speakableText ( { ...base , content : `` , tags } ) ,
143127 null ,
144128 ) ;
145129 assert . equal (
146- speakableAgentText (
147- { ...base , content : `Here is the diagram.\n\n` , tags } ,
148- agents ,
149- "human" ,
150- CHANNEL ,
151- ) ,
130+ speakableText ( {
131+ ...base ,
132+ content : `Here is the diagram.\n\n` ,
133+ tags,
134+ } ) ,
152135 "Here is the diagram." ,
153136 ) ;
154137 assert . equal (
155- speakableAgentText (
156- { ...base , content : `||\n\n||` , tags } ,
157- agents ,
158- "human" ,
159- CHANNEL ,
160- ) ,
138+ speakableText ( { ...base , content : `||\n\n||` , tags } ) ,
161139 null ,
162140 ) ;
163141} ) ;
0 commit comments