Skip to content

Commit f1c5ef1

Browse files
committed
apply suggested changes
1 parent f900592 commit f1c5ef1

File tree

3 files changed

+14
-28
lines changed

3 files changed

+14
-28
lines changed

src/client/streamableHttp.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,20 @@ export class StreamableHTTPError extends Error {
2323
/**
2424
* Options for starting or authenticating an SSE connection
2525
*/
26-
export interface StartSSEOptions {
26+
interface StartSSEOptions {
2727
/**
2828
* The ID of the last received event, used for resuming a disconnected stream
2929
*/
3030
lastEventId?: string;
31+
3132
/**
3233
* The callback function that is invoked when the last event ID changes
3334
*/
3435
onLastEventIdUpdate?: (event: string) => void
36+
3537
/**
36-
* When reconnecting to a long-running SSE stream, we need to make sure that message id matches
38+
* Override Message ID to associate with the replay message
39+
* so that response can be associate with the new resumed request.
3740
*/
3841
replayMessageId?: string | number;
3942
}
@@ -358,7 +361,7 @@ export class StreamableHTTPClientTransport implements Transport {
358361
this.onclose?.();
359362
}
360363

361-
async send(message: JSONRPCMessage | JSONRPCMessage[], options?: { resumptionToken?: string, onresumptiontoken?: (event: string) => void }): Promise<void> {
364+
async send(message: JSONRPCMessage | JSONRPCMessage[], options?: { resumptionToken?: string, onresumptiontoken?: (token: string) => void }): Promise<void> {
362365
try {
363366
// If client passes in a lastEventId in the request options, we need to reconnect the SSE stream
364367
const lastEventId = options?.resumptionToken

src/shared/protocol.ts

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {
2222
Result,
2323
ServerCapabilities,
2424
} from "../types.js";
25-
import { Transport } from "./transport.js";
25+
import { Transport, TransportSendOptions } from "./transport.js";
2626

2727
/**
2828
* Callback for progress notifications.
@@ -82,26 +82,7 @@ export type RequestOptions = {
8282
* If not specified, there is no maximum total timeout.
8383
*/
8484
maxTotalTimeout?: number;
85-
86-
/**
87-
* May be used to indicate to the transport which incoming request to associate this outgoing request with.
88-
*/
89-
relatedRequestId?: RequestId;
90-
91-
/**
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.
95-
*/
96-
resumptionToken?: string;
97-
98-
/**
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.
102-
*/
103-
onresumptiontoken?: (token: string) => void;
104-
};
85+
} & TransportSendOptions;
10586

10687
/**
10788
* Options that can be given per notification.

src/shared/transport.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
import { JSONRPCMessage, RequestId } from "../types.js";
22

33
/**
4-
* Options for sending a JSON-RPC message.
5-
*/
6-
export interface TransportSendOptions {
4+
* Options for sending a JSON-RPC message.
5+
*/
6+
export type TransportSendOptions = {
77
/**
88
* If present, `relatedRequestId` is used to indicate to the transport which incoming request to associate this outgoing message with.
9-
*/
9+
*/
1010
relatedRequestId?: RequestId;
11+
1112
/**
1213
* The resumption token used to continue long-running requests that were interrupted.
1314
*
1415
* This allows clients to reconnect and continue from where they left off, if supported by the transport.
1516
*/
1617
resumptionToken?: string;
18+
1719
/**
1820
* A callback that is invoked when the resumption token changes, if supported by the transport.
1921
*

0 commit comments

Comments
 (0)