@@ -796,6 +796,26 @@ let firstCredentialToken = '';
796796 assert . equal ( privateStateBody . recordCounts . total , 0 ) ;
797797 assert . equal ( privateStateBody . recordCounts . pendingReview , 0 ) ;
798798
799+ const newerConcurrentUse = await postJson (
800+ `/v1/mcp/grants/${ encodeURIComponent ( mcpGrantId ) } /agent/state` ,
801+ { } ,
802+ { authorization : `Bearer ${ MCP_SERVICE_SECRET } ` } ,
803+ NOW + 57 ,
804+ ) ;
805+ assert . equal ( newerConcurrentUse . status , 200 , await newerConcurrentUse . clone ( ) . text ( ) ) ;
806+
807+ const olderConcurrentUse = await postJson (
808+ `/v1/mcp/grants/${ encodeURIComponent ( mcpGrantId ) } /resolve` ,
809+ { } ,
810+ { authorization : `Bearer ${ MCP_SERVICE_SECRET } ` } ,
811+ NOW + 56 ,
812+ ) ;
813+ assert . equal ( olderConcurrentUse . status , 200 , await olderConcurrentUse . clone ( ) . text ( ) ) ;
814+ const olderConcurrentUseBody = await olderConcurrentUse . json ( ) as {
815+ authorization : { lastUsedAt : number } ;
816+ } ;
817+ assert . equal ( olderConcurrentUseBody . authorization . lastUsedAt , NOW + 57 ) ;
818+
799819 await postJson ( '/__test/set-agent-status' , {
800820 handle : 'selene-test-agent' ,
801821 status : 'suspended' ,
@@ -1080,21 +1100,22 @@ let firstCredentialToken = '';
10801100 assert . equal ( sentBoxBody . directMessages [ 0 ] ?. bodyMarkdown , directMessageBody . bodyMarkdown ) ;
10811101 assert . equal ( sentBoxBody . nextCursor , null ) ;
10821102
1083- const recipientUnread = await postJson (
1084- `/v1/mcp/grants/${ encodeURIComponent ( recipientGrant . grantId ) } /direct-messages/unread-count` ,
1085- { } ,
1086- mcpServiceHeaders ( ) ,
1087- NOW + 23_002 ,
1088- ) ;
1103+ const [ recipientUnread , recipientInbox ] = await Promise . all ( [
1104+ postJson (
1105+ `/v1/mcp/grants/${ encodeURIComponent ( recipientGrant . grantId ) } /direct-messages/unread-count` ,
1106+ { } ,
1107+ mcpServiceHeaders ( ) ,
1108+ NOW + 23_002 ,
1109+ ) ,
1110+ postJson (
1111+ `/v1/mcp/grants/${ encodeURIComponent ( recipientGrant . grantId ) } /direct-messages/list` ,
1112+ { box : 'inbox' , limit : 10 } ,
1113+ mcpServiceHeaders ( ) ,
1114+ NOW + 23_003 ,
1115+ ) ,
1116+ ] ) ;
10891117 assert . equal ( recipientUnread . status , 200 , await recipientUnread . clone ( ) . text ( ) ) ;
10901118 assert . deepEqual ( await recipientUnread . json ( ) , { unreadCount : 1 } ) ;
1091-
1092- const recipientInbox = await postJson (
1093- `/v1/mcp/grants/${ encodeURIComponent ( recipientGrant . grantId ) } /direct-messages/list` ,
1094- { box : 'inbox' , limit : 10 } ,
1095- mcpServiceHeaders ( ) ,
1096- NOW + 23_003 ,
1097- ) ;
10981119 assert . equal ( recipientInbox . status , 200 , await recipientInbox . clone ( ) . text ( ) ) ;
10991120 const recipientInboxBody = await recipientInbox . json ( ) as {
11001121 directMessages : Array < { id : string ; sender : { handle : string } ; bodyMarkdown : string ; readAt : number | null } > ;
0 commit comments