@@ -32,19 +32,21 @@ const SERVER_TOOL_MAPPINGS: Partial<Record<ToolState, NotificationStatus>> = {
3232export async function notifyServerTool (
3333 toolId : string ,
3434 toolName : string ,
35- toolState : ToolState
35+ toolState : ToolState ,
36+ executionStartTime ?: string
3637) : Promise < void > {
3738 const notificationStatus = SERVER_TOOL_MAPPINGS [ toolState ]
3839 if ( ! notificationStatus ) {
3940 throw new Error ( `Invalid tool state: ${ toolState } ` )
4041 }
41- await notify ( toolId , toolName , toolState )
42+ await notify ( toolId , toolName , toolState , executionStartTime )
4243}
4344
4445export async function notify (
4546 toolId : string ,
4647 toolName : string ,
47- toolState : ToolState
48+ toolState : ToolState ,
49+ executionStartTime ?: string
4850) : Promise < void > {
4951 // toolState must be in STATE_MAPPINGS
5052 const notificationStatus = STATE_MAPPINGS [ toolState ]
@@ -55,8 +57,15 @@ export async function notify(
5557 // Get the state message from tool metadata
5658 const metadata = toolRegistry . getToolMetadata ( toolId )
5759 let stateMessage = metadata ?. stateMessages ?. [ notificationStatus ]
60+
61+ // If no message from metadata, provide default messages
5862 if ( ! stateMessage ) {
59- stateMessage = ''
63+ if ( notificationStatus === 'background' ) {
64+ const timeInfo = executionStartTime ? ` Started at: ${ executionStartTime } .` : ''
65+ stateMessage = `The user has moved tool execution to the background and it is not complete, it will run asynchronously.${ timeInfo } `
66+ } else {
67+ stateMessage = ''
68+ }
6069 }
6170
6271 // Call backend confirm route
@@ -68,9 +77,7 @@ export async function notify(
6877 body : JSON . stringify ( {
6978 toolCallId : toolId ,
7079 status : notificationStatus ,
71- toolName,
72- toolState,
73- stateMessage,
80+ message : stateMessage ,
7481 } ) ,
7582 } )
7683}
0 commit comments