@@ -66,9 +66,9 @@ function unwrapOutputContent(content: unknown): { roleOverride: NormalizedRole |
6666 return { roleOverride, content : messageContent }
6767}
6868
69- function formatPlainText ( role : NormalizedRole | null , text : string ) : string {
69+ function formatPlainText ( role : NormalizedRole | null , text : string , agentLabel = 'coding agent' ) : string {
7070 if ( role === 'assistant' ) {
71- return `Claude Code : \n<text>${ text } </text>`
71+ return `${ agentLabel } : \n<text>${ text } </text>`
7272 }
7373 return `User sent message: \n<text>${ text } </text>`
7474}
@@ -80,9 +80,10 @@ export function formatPermissionRequest(
8080 sessionId : string ,
8181 requestId : string ,
8282 toolName : string ,
83- toolArgs : unknown
83+ toolArgs : unknown ,
84+ agentLabel = 'coding agent'
8485) : string {
85- return `Claude Code is requesting permission to use ${ toolName } (session ${ sessionId } ):
86+ return `${ agentLabel } is requesting permission to use ${ toolName } (session ${ sessionId } ):
8687<request_id>${ requestId } </request_id>
8788<tool_name>${ toolName } </tool_name>
8889<tool_args>${ JSON . stringify ( toolArgs ) } </tool_args>`
@@ -91,18 +92,18 @@ export function formatPermissionRequest(
9192/**
9293 * Format a single message for voice context
9394 */
94- export function formatMessage ( message : DecryptedMessage ) : string | null {
95+ export function formatMessage ( message : DecryptedMessage , agentLabel = 'coding agent' ) : string | null {
9596 const lines : string [ ] = [ ]
9697 const { role, content : wrappedContent } = unwrapRoleWrappedContent ( message )
9798 const { roleOverride, content } = unwrapOutputContent ( wrappedContent )
9899 const normalizedRole = roleOverride ?? role
99100
100101 if ( ! isContentArray ( content ) ) {
101102 if ( typeof content === 'string' ) {
102- return formatPlainText ( normalizedRole , content )
103+ return formatPlainText ( normalizedRole , content , agentLabel )
103104 }
104105 if ( isObject ( content ) && content . type === 'text' && typeof content . text === 'string' ) {
105- return formatPlainText ( normalizedRole , content . text )
106+ return formatPlainText ( normalizedRole , content . text , agentLabel )
106107 }
107108 return null
108109 }
@@ -117,13 +118,13 @@ export function formatMessage(message: DecryptedMessage): string | null {
117118
118119 for ( const item of content ) {
119120 if ( item . type === 'text' && item . text ) {
120- lines . push ( formatPlainText ( isAssistant ? 'assistant' : 'user' , item . text ) )
121+ lines . push ( formatPlainText ( isAssistant ? 'assistant' : 'user' , item . text , agentLabel ) )
121122 } else if ( item . type === 'tool_use' && ! VOICE_CONFIG . DISABLE_TOOL_CALLS ) {
122123 const name = item . name || 'unknown'
123124 if ( VOICE_CONFIG . LIMITED_TOOL_CALLS ) {
124- lines . push ( `Claude Code is using ${ name } ` )
125+ lines . push ( `${ agentLabel } is using ${ name } ` )
125126 } else {
126- lines . push ( `Claude Code is using ${ name } with arguments: <arguments>${ JSON . stringify ( item . input ) } </arguments>` )
127+ lines . push ( `${ agentLabel } is using ${ name } with arguments: <arguments>${ JSON . stringify ( item . input ) } </arguments>` )
127128 }
128129 }
129130 }
@@ -134,34 +135,34 @@ export function formatMessage(message: DecryptedMessage): string | null {
134135 return lines . join ( '\n\n' )
135136}
136137
137- export function formatNewSingleMessage ( sessionId : string , message : DecryptedMessage ) : string | null {
138- const formatted = formatMessage ( message )
138+ export function formatNewSingleMessage ( sessionId : string , message : DecryptedMessage , agentLabel = 'coding agent' ) : string | null {
139+ const formatted = formatMessage ( message , agentLabel )
139140 if ( ! formatted ) {
140141 return null
141142 }
142143 return 'New message in session: ' + sessionId + '\n\n' + formatted
143144}
144145
145- export function formatNewMessages ( sessionId : string , messages : DecryptedMessage [ ] ) : string | null {
146+ export function formatNewMessages ( sessionId : string , messages : DecryptedMessage [ ] , agentLabel = 'coding agent' ) : string | null {
146147 const formatted = [ ...messages ]
147148 . sort ( ( a , b ) => ( a . seq ?? 0 ) - ( b . seq ?? 0 ) )
148- . map ( formatMessage )
149+ . map ( m => formatMessage ( m , agentLabel ) )
149150 . filter ( Boolean )
150151 if ( formatted . length === 0 ) {
151152 return null
152153 }
153154 return 'New messages in session: ' + sessionId + '\n\n' + formatted . join ( '\n\n' )
154155}
155156
156- export function formatHistory ( sessionId : string , messages : DecryptedMessage [ ] ) : string {
157+ export function formatHistory ( sessionId : string , messages : DecryptedMessage [ ] , agentLabel = 'coding agent' ) : string {
157158 const messagesToFormat = VOICE_CONFIG . MAX_HISTORY_MESSAGES > 0
158159 ? messages . slice ( - VOICE_CONFIG . MAX_HISTORY_MESSAGES )
159160 : messages
160- const formatted = messagesToFormat . map ( formatMessage ) . filter ( Boolean )
161+ const formatted = messagesToFormat . map ( m => formatMessage ( m , agentLabel ) ) . filter ( Boolean )
161162 return 'History of messages in session: ' + sessionId + '\n\n' + formatted . join ( '\n\n' )
162163}
163164
164- export function formatSessionFull ( session : Session | null , messages : DecryptedMessage [ ] ) : string {
165+ export function formatSessionFull ( session : Session | null , messages : DecryptedMessage [ ] , agentLabel = 'coding agent' ) : string {
165166 if ( ! session ) {
166167 return 'Session not available'
167168 }
@@ -182,7 +183,7 @@ export function formatSessionFull(session: Session | null, messages: DecryptedMe
182183
183184 lines . push ( '## Our interaction history so far' )
184185 lines . push ( '' )
185- lines . push ( formatHistory ( session . id , messages ) )
186+ lines . push ( formatHistory ( session . id , messages , agentLabel ) )
186187
187188 return lines . join ( '\n\n' )
188189}
@@ -199,6 +200,6 @@ export function formatSessionFocus(sessionId: string, _metadata?: SessionMetadat
199200 return `Session became focused: ${ sessionId } `
200201}
201202
202- export function formatReadyEvent ( sessionId : string ) : string {
203- return `Claude Code done working in session: ${ sessionId } . The previous message(s) are the summary of the work done. Report this to the human immediately.`
203+ export function formatReadyEvent ( sessionId : string , agentLabel = 'coding agent' ) : string {
204+ return `${ agentLabel } done working in session: ${ sessionId } . The previous message(s) are the summary of the work done. Report this to the human immediately.`
204205}
0 commit comments