@@ -13,6 +13,27 @@ const OPENAI_RESPONSES_DEBUG_EVENT_SEQUENCE = false; // true: shows the sequence
1313const OPENAI_RESPONSES_SAME_PART_SPACER = '\n\n' ; // true: shows the sequence of events
1414
1515
16+ /**
17+ * Safely sanitizes a URL for display in placeholders by removing query parameters and paths
18+ * to prevent leaking sensitive information while keeping the domain recognizable.
19+ */
20+ function sanitizeUrlForDisplay ( url : string | null ) : string {
21+ if ( ! url ) return 'unknown' ;
22+ try {
23+ const urlObj = new URL ( url ) ;
24+ // Return just the protocol and hostname (e.g., "https://example.com")
25+ return `${ urlObj . protocol } //${ urlObj . hostname } ` ;
26+ } catch ( error ) {
27+ // If URL parsing fails, try to extract just the domain part manually
28+ const match = url . match ( / ^ h t t p s ? : \/ \/ ( [ ^ / ? # ] + ) / ) ;
29+ if ( match )
30+ return `${ url . split ( '://' ) [ 0 ] } ://${ match [ 1 ] } ` ;
31+ // Fallback: return a generic indicator
32+ return 'website' ;
33+ }
34+ }
35+
36+
1637type TResponse = OpenAIWire_API_Responses . Response ;
1738type TOutputItem = OpenAIWire_API_Responses . Response [ 'output' ] [ number ] ;
1839type TEventType = OpenAIWire_API_Responses . StreamingEvent [ 'type' ] ;
@@ -311,8 +332,25 @@ export function createOpenAIResponsesEventParser(): ChatGenerateParseFunction {
311332 pt . sendVoidPlaceholder ( 'web_search' , `${ action . query } : completed` ) ;
312333 break ;
313334
335+ case 'open_page' :
336+ // Action: opening/visiting a specific web page
337+ const sanitizedUrl = sanitizeUrlForDisplay ( action . url ) ;
338+ pt . sendVoidPlaceholder ( 'web_search' , `Opening ${ action . url ? sanitizedUrl : 'Opening page...' } ` ) ;
339+ break ;
340+
341+ case 'find_in_page' :
342+ // Action: searching for a pattern within an opened page
343+ const sanitizedPageUrl = sanitizeUrlForDisplay ( action . url ) ;
344+ if ( action . pattern && action . url )
345+ pt . sendVoidPlaceholder ( 'web_search' , `Searching for "${ action . pattern } " on ${ sanitizedPageUrl } ` ) ;
346+ else if ( action . pattern )
347+ pt . sendVoidPlaceholder ( 'web_search' , `Searching for "${ action . pattern } "` ) ;
348+ else
349+ pt . sendVoidPlaceholder ( 'web_search' , 'Searching in page...' ) ;
350+ break ;
351+
314352 default :
315- console . log ( `[DEV] AIX: Unknown web_search_call action type: ${ action . type } ` , { action } ) ;
353+ console . log ( `[DEV] AIX: Unknown web_search_call action type: ${ action ? .type } ` , { action } ) ;
316354 break ;
317355 }
318356 break ;
0 commit comments