77 DEFAULT_SERVER_SETTINGS ,
88 ProviderInstanceId ,
99 ThreadId ,
10+ TurnItemId ,
1011 AuthOrchestrationOperateScope ,
1112 ORCHESTRATION_V2_WS_METHODS ,
1213 AuthOrchestrationReadScope ,
@@ -472,6 +473,12 @@ it.effect("separates host file URLs from readable attachment URLs", () =>
472473 { _tag : "workspace-file" , threadId : ThreadId . make ( "thread" ) , path : "file.txt" } ,
473474 { _tag : "media-file" , threadId : ThreadId . make ( "thread" ) , path : "/repo/image.png" } ,
474475 { _tag : "draft-workspace-file" , cwd : "/repo" , path : "file.txt" } ,
476+ {
477+ _tag : "tool-input-html" ,
478+ threadId : ThreadId . make ( "thread" ) ,
479+ itemId : TurnItemId . make ( "html" ) ,
480+ revision : "completed" ,
481+ } ,
475482 ] as const ) {
476483 expect (
477484 yield * client [ WS_METHODS . assetsCreateUrl ] ( { resource } ) . pipe ( Effect . flip ) ,
@@ -484,6 +491,54 @@ it.effect("separates host file URLs from readable attachment URLs", () =>
484491 } ) . pipe ( Effect . scoped ) ,
485492) ;
486493
494+ it . effect ( "requires both thread and host-file access for HTML tool previews" , ( ) =>
495+ Effect . gen ( function * ( ) {
496+ const group = WsRpcGroup . omit (
497+ ...[ ...WsRpcGroup . requests . keys ( ) ] . filter (
498+ (
499+ tag ,
500+ ) : tag is Exclude < keyof typeof RPC_REQUIRED_SCOPES , typeof WS_METHODS . assetsCreateUrl > =>
501+ tag !== WS_METHODS . assetsCreateUrl ,
502+ ) ,
503+ ) ;
504+ const resource = {
505+ _tag : "tool-input-html" as const ,
506+ threadId : ThreadId . make ( "thread" ) ,
507+ itemId : TurnItemId . make ( "html" ) ,
508+ revision : "completed" ,
509+ } ;
510+ let handled = 0 ;
511+ for ( const scopes of [
512+ [ AuthFilesystemReadScope ] ,
513+ [ AuthOrchestrationReadScope , AuthFilesystemReadScope ] ,
514+ ] ) {
515+ const client = yield * RpcTest . makeClient ( group ) . pipe (
516+ Effect . provide (
517+ Layer . mergeAll (
518+ group . toLayerHandler ( WS_METHODS . assetsCreateUrl , ( ) =>
519+ Effect . sync ( ( ) => {
520+ handled ++ ;
521+ return { relativeUrl : "/api/assets/html" , expiresAt : 1 } ;
522+ } ) ,
523+ ) ,
524+ RpcAuthorization . layer ( scopes ) ,
525+ ) ,
526+ ) ,
527+ ) ;
528+ if ( scopes . length === 1 ) {
529+ expect (
530+ yield * client [ WS_METHODS . assetsCreateUrl ] ( { resource } ) . pipe ( Effect . flip ) ,
531+ ) . toMatchObject ( { requiredPermission : AuthOrchestrationReadScope } ) ;
532+ } else {
533+ expect ( yield * client [ WS_METHODS . assetsCreateUrl ] ( { resource } ) ) . toMatchObject ( {
534+ relativeUrl : "/api/assets/html" ,
535+ } ) ;
536+ }
537+ }
538+ expect ( handled ) . toBe ( 1 ) ;
539+ } ) . pipe ( Effect . scoped ) ,
540+ ) ;
541+
487542it . effect ( "denies manual cleanup before the handler without settings permission" , ( ) =>
488543 Effect . gen ( function * ( ) {
489544 const group = WsRpcGroup . omit (
0 commit comments