@@ -87,17 +87,20 @@ export type RequestOptions = {
87
87
* May be used to indicate to the transport which incoming request to associate this outgoing request with.
88
88
*/
89
89
relatedRequestId ?: RequestId ;
90
+
90
91
/**
91
- * The last event ID to associate with the request.
92
- * Used to resume long-running requests that were interrupted when creating a new client instance.
92
+ * The resumption token used to continue long-running requests that were interrupted.
93
+ *
94
+ * This allows clients to reconnect and continue from where they left off, if supported by the transport.
93
95
*/
94
- lastEventId ?: string ;
96
+ resumptionToken ?: string ;
95
97
96
98
/**
97
- * A callback that is invoked when the last event ID is updated.
98
- * This is used to notify the client that the last event ID has changed, so the client can update its state accordingly.
99
+ * A callback that is invoked when the resumption token changes, if supported by the transport.
100
+ *
101
+ * This allows clients to persist the latest token for potential reconnection.
99
102
*/
100
- onLastEventIdUpdate ?: ( event : string ) => void ;
103
+ onresumptiontoken ?: ( token : string ) => void ;
101
104
} ;
102
105
103
106
/**
@@ -512,7 +515,7 @@ export abstract class Protocol<
512
515
resultSchema : T ,
513
516
options ?: RequestOptions ,
514
517
) : Promise < z . infer < T > > {
515
- const { relatedRequestId, lastEventId , onLastEventIdUpdate } = options ?? { } ;
518
+ const { relatedRequestId, resumptionToken , onresumptiontoken } = options ?? { } ;
516
519
517
520
return new Promise ( ( resolve , reject ) => {
518
521
if ( ! this . _transport ) {
@@ -554,7 +557,7 @@ export abstract class Protocol<
554
557
requestId : messageId ,
555
558
reason : String ( reason ) ,
556
559
} ,
557
- } , { relatedRequestId, lastEventId , onLastEventIdUpdate } )
560
+ } , { relatedRequestId, resumptionToken , onresumptiontoken } )
558
561
. catch ( ( error ) =>
559
562
this . _onerror ( new Error ( `Failed to send cancellation: ${ error } ` ) ) ,
560
563
) ;
@@ -592,7 +595,7 @@ export abstract class Protocol<
592
595
593
596
this . _setupTimeout ( messageId , timeout , options ?. maxTotalTimeout , timeoutHandler , options ?. resetTimeoutOnProgress ?? false ) ;
594
597
595
- this . _transport . send ( jsonrpcRequest , { relatedRequestId, lastEventId , onLastEventIdUpdate } ) . catch ( ( error ) => {
598
+ this . _transport . send ( jsonrpcRequest , { relatedRequestId, resumptionToken , onresumptiontoken } ) . catch ( ( error ) => {
596
599
this . _cleanupTimeout ( messageId ) ;
597
600
reject ( error ) ;
598
601
} ) ;
0 commit comments