@@ -250,7 +250,10 @@ it.effect.each([
250250 const { accessibilityTree : _tree , ...boundedMetadata } = metadata ;
251251 expect ( snapshot . isError ) . toBe ( false ) ;
252252 expect ( snapshot . structuredContent ) . toEqual ( metadata ) ;
253- const [ text , ...rest ] = snapshot . content ;
253+ const [ identity , text , ...rest ] = snapshot . content ;
254+ expect ( identity ?. type === "text" ? decodeJsonText ( identity . text ) : null ) . toEqual ( {
255+ url : page . url ,
256+ } ) ;
254257 expect ( text ?. type === "text" ? decodeJsonText ( text . text ) : null ) . toEqual ( boundedMetadata ) ;
255258 expect ( rest ) . toEqual ( [
256259 {
@@ -279,7 +282,12 @@ it.effect.each([
279282 Effect . provideService ( McpInvocationContext . McpInvocationContext , invocation ) ,
280283 Effect . provideService ( McpSchema . McpServerClient , client ) ,
281284 ) ;
282- expect ( nextDefault . content . map ( ( content ) => content . type ) ) . toEqual ( [ "text" , "text" , "image" ] ) ;
285+ expect ( nextDefault . content . map ( ( content ) => content . type ) ) . toEqual ( [
286+ "text" ,
287+ "text" ,
288+ "text" ,
289+ "image" ,
290+ ] ) ;
283291 expect ( nextDefault . structuredContent ) . toEqual ( { ...page , title : "Snapshot 7" , screenshot } ) ;
284292 expect ( requests ) . toBe ( 7 ) ;
285293 } ) ,
@@ -329,7 +337,7 @@ it.effect("saves the snapshot PNG on request and reports its path", () =>
329337 / ^ b r o w s e r - s c r e e n s h o t - e x a m p l e - t e s t - [ 0 - 9 a - z ] + - [ 0 - 9 a - f ] { 8 } \. p n g $ / ,
330338 ) ;
331339 expect ( Buffer . from ( yield * fileSystem . readFile ( screenshotPath ! ) ) . toString ( ) ) . toBe ( "png" ) ;
332- const text = snapshot . content . find ( ( content ) => content . type === "text" ) ;
340+ const [ , text ] = snapshot . content ;
333341 expect ( text ?. type === "text" ? text . text : "" ) . toContain ( screenshotPath ) ;
334342
335343 const unsaved = yield * callSnapshot ( { } ) ;
@@ -429,7 +437,10 @@ it.effect("keeps the snapshot text under the agent's output ceiling", () =>
429437 const snapshot = yield * callSnapshot ( { includeImage : false } ) ;
430438
431439 expect ( snapshot . isError ) . toBe ( false ) ;
432- const [ text , notice ] = snapshot . content ;
440+ const [ identity , text , notice ] = snapshot . content ;
441+ expect ( identity ?. type === "text" ? decodeJsonText ( identity . text ) : null ) . toEqual ( {
442+ url : oversized . url ,
443+ } ) ;
433444 expect ( text ?. type ) . toBe ( "text" ) ;
434445 const body = text ?. type === "text" ? text . text : "" ;
435446 expect ( Buffer . byteLength ( body , "utf8" ) ) . toBeLessThanOrEqual (
@@ -471,7 +482,7 @@ it.effect("bounds the snapshot text even when nothing but logs and the title are
471482
472483 const snapshot = yield * callSnapshot ( { includeImage : false } ) ;
473484
474- const [ text ] = snapshot . content ;
485+ const [ , text ] = snapshot . content ;
475486 const body = text ?. type === "text" ? text . text : "" ;
476487 expect ( Buffer . byteLength ( body , "utf8" ) ) . toBeLessThanOrEqual (
477488 McpHttpServer . MAX_SNAPSHOT_TEXT_BYTES ,
@@ -482,7 +493,7 @@ it.effect("bounds the snapshot text even when nothing but logs and the title are
482493 } ;
483494 expect ( parsed . title . length ) . toBe ( 2_049 ) ;
484495 expect ( parsed . consoleEntries [ 0 ] ?. text . length ) . toBe ( 501 ) ;
485- const notice = snapshot . content [ 1 ] ;
496+ const notice = snapshot . content [ 2 ] ;
486497 const noticeText = notice ?. type === "text" ? notice . text : "" ;
487498 expect ( noticeText ) . toContain ( "url or title after 2048 characters" ) ;
488499 expect ( noticeText ) . toContain ( "console entries text after 500 characters" ) ;
@@ -533,7 +544,7 @@ it.effect("sheds log entries before locators when every list is full", () =>
533544
534545 const snapshot = yield * callSnapshot ( { includeImage : false } ) ;
535546
536- const [ text , notice ] = snapshot . content ;
547+ const [ , text , notice ] = snapshot . content ;
537548 const body = text ?. type === "text" ? text . text : "" ;
538549 expect ( Buffer . byteLength ( body , "utf8" ) ) . toBeLessThanOrEqual (
539550 McpHttpServer . MAX_SNAPSHOT_TEXT_BYTES ,
@@ -615,6 +626,10 @@ it.effect("registers annotated tools and preserves authenticated request context
615626 Effect . gen ( function * ( ) {
616627 const server = yield * McpServer . McpServer ;
617628 const broker = yield * PreviewAutomationBroker . PreviewAutomationBroker ;
629+ const toolIcon = {
630+ _tag : "website" as const ,
631+ pageUrl : "http://example.test/" ,
632+ } ;
618633 const routedRequests : Array < {
619634 readonly operation : string ;
620635 readonly tabId ?: string | undefined ;
@@ -664,7 +679,7 @@ it.effect("registers annotated tools and preserves authenticated request context
664679 expect ( clickTool ?. tool . annotations ?. readOnlyHint ) . toBe ( false ) ;
665680 expect ( clickTool ?. tool . annotations ?. destructiveHint ) . toBe ( true ) ;
666681 expect ( clickTool ?. tool . annotations ?. openWorldHint ) . toBe ( true ) ;
667- expect ( clickTool ?. tool . outputSchema ) . toEqual ( {
682+ expect ( clickTool ?. tool . outputSchema ) . toMatchObject ( {
668683 type : "object" ,
669684 additionalProperties : false ,
670685 description : "The preview action completed successfully." ,
@@ -721,10 +736,12 @@ it.effect("registers annotated tools and preserves authenticated request context
721736 Effect . provideService ( McpSchema . McpServerClient , client ) ,
722737 ) ;
723738 expect ( evaluated . isError ) . toBe ( false ) ;
724- expect ( evaluated . structuredContent ) . toEqual ( { value : [ "Connect" , "Continue" ] } ) ;
725- expect ( evaluated . content ) . toEqual ( [
726- { type : "text" , text : '{"value":["Connect","Continue"]}' } ,
727- ] ) ;
739+ expect ( evaluated . structuredContent ) . toEqual ( { value : [ "Connect" , "Continue" ] , toolIcon } ) ;
740+ const evaluatedText = evaluated . content [ 0 ] ;
741+ expect ( evaluatedText ?. type === "text" ? decodeJsonText ( evaluatedText . text ) : null ) . toEqual ( {
742+ toolIcon,
743+ value : [ "Connect" , "Continue" ] ,
744+ } ) ;
728745
729746 const actionRequests = [
730747 { name : "preview_click" , arguments : { x : 10 , y : 10 } } ,
@@ -741,8 +758,10 @@ it.effect("registers annotated tools and preserves authenticated request context
741758 Effect . provideService ( McpSchema . McpServerClient , client ) ,
742759 ) ;
743760 expect ( result . isError ) . toBe ( false ) ;
744- expect ( result . structuredContent ) . toEqual ( { } ) ;
745- expect ( result . content ) . toEqual ( [ { type : "text" , text : "{}" } ] ) ;
761+ expect ( result . structuredContent ) . toEqual ( { toolIcon } ) ;
762+ expect ( routedRequests . at ( - 1 ) ?. operation ) . toBe ( "status" ) ;
763+ const text = result . content [ 0 ] ;
764+ expect ( text ?. type === "text" ? decodeJsonText ( text . text ) : null ) . toEqual ( { toolIcon } ) ;
746765 }
747766 } ) ,
748767 ) . pipe ( Effect . provide ( TestLayer ) ) ,
0 commit comments