feat: add closeSSEStream callback to RequestHandlerExtra (#1166)

This commit is contained in:
Felix Weinberger 2025-12-01 16:18:29 +00:00 • committed by GitHub
commit fab7e1e9b3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -283,6 +283,13 @@ export type RequestHandlerExtra<SendRequestT extends Request, SendNotificationT
* This is used by certain transports to correctly associate related messages.
*/
sendRequest: <U extends AnySchema>(request: SendRequestT, resultSchema: U, options?: TaskRequestOptions) => Promise<SchemaOutput<U>>;
/**
* Closes the SSE stream for this request, triggering client reconnection.
* Only available when using StreamableHTTPServerTransport with eventStore configured.
* Use this to implement polling behavior during long-running operations.
*/
closeSSEStream?: () => void;
};
/**
@ -728,7 +735,8 @@ export abstract class Protocol<SendRequestT extends Request, SendNotificationT e
requestInfo: extra?.requestInfo,
taskId: relatedTaskId,
taskStore: taskStore,
taskRequestedTtl: taskCreationParams?.ttl
taskRequestedTtl: taskCreationParams?.ttl,
closeSSEStream: extra?.closeSSEStream
};
// Starting with Promise.resolve() puts any synchronous errors into the monad as well.