Skip to content

Commit 2ca5eba

Browse files
refactor: remove public requestStream() overrides from Client and Server
The requestStream() method is task infrastructure - when used without tasks, it's just a trivial wrapper around request(). Task usage requires importing from experimental anyway (for TaskStore). By removing these public overrides, users must access requestStream() via experimental.tasks.requestStream(), making it clearer that streaming is part of the experimental tasks feature.
1 parent 7860ba0 commit 2ca5eba

File tree

2 files changed

+1
-85
lines changed

2 files changed

+1
-85
lines changed

src/client/index.ts

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { mergeCapabilities, Protocol, type ProtocolOptions, type RequestOptions } from '../shared/protocol.js';
22
import type { Transport } from '../shared/transport.js';
3-
import { ResponseMessage, takeResult } from '../shared/responseMessage.js';
3+
import { takeResult } from '../shared/responseMessage.js';
44

55
import {
66
type CallToolRequest,
@@ -704,45 +704,4 @@ export class Client<
704704
async sendRootsListChanged() {
705705
return this.notification({ method: 'notifications/roots/list_changed' });
706706
}
707-
708-
/**
709-
* Sends a request and returns an AsyncGenerator that yields response messages.
710-
* The generator is guaranteed to end with either a 'result' or 'error' message.
711-
*
712-
* This method provides streaming access to request processing, allowing you to
713-
* observe intermediate task status updates for task-augmented requests.
714-
*
715-
* @example
716-
* ```typescript
717-
* const stream = client.requestStream(request, resultSchema, options);
718-
* for await (const message of stream) {
719-
* switch (message.type) {
720-
* case 'taskCreated':
721-
* console.log('Task created:', message.task.taskId);
722-
* break;
723-
* case 'taskStatus':
724-
* console.log('Task status:', message.task.status);
725-
* break;
726-
* case 'result':
727-
* console.log('Final result:', message.result);
728-
* break;
729-
* case 'error':
730-
* console.error('Error:', message.error);
731-
* break;
732-
* }
733-
* }
734-
* ```
735-
*
736-
* @param request - The request to send
737-
* @param resultSchema - Zod schema for validating the result
738-
* @param options - Optional request options (timeout, signal, task creation params, etc.)
739-
* @returns AsyncGenerator that yields ResponseMessage objects
740-
*/
741-
requestStream<T extends AnyObjectSchema>(
742-
request: ClientRequest | RequestT,
743-
resultSchema: T,
744-
options?: RequestOptions
745-
): AsyncGenerator<ResponseMessage<SchemaOutput<T>>, void, void> {
746-
return super.requestStream(request, resultSchema, options);
747-
}
748707
}

src/server/index.ts

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { mergeCapabilities, Protocol, type NotificationOptions, type ProtocolOptions, type RequestOptions } from '../shared/protocol.js';
2-
import { ResponseMessage } from '../shared/responseMessage.js';
32
import {
43
type ClientCapabilities,
54
type CreateMessageRequest,
@@ -42,7 +41,6 @@ import { AjvJsonSchemaValidator } from '../validation/ajv-provider.js';
4241
import type { JsonSchemaType, jsonSchemaValidator } from '../validation/types.js';
4342
import {
4443
AnyObjectSchema,
45-
AnySchema,
4644
getObjectShape,
4745
isZ4Schema,
4846
safeParse,
@@ -465,47 +463,6 @@ export class Server<
465463
return this._capabilities;
466464
}
467465

468-
/**
469-
* Sends a request and returns an AsyncGenerator that yields response messages.
470-
* The generator is guaranteed to end with either a 'result' or 'error' message.
471-
*
472-
* This method provides streaming access to request processing, allowing you to
473-
* observe intermediate task status updates for task-augmented requests.
474-
*
475-
* @example
476-
* ```typescript
477-
* const stream = server.requestStream(request, resultSchema, options);
478-
* for await (const message of stream) {
479-
* switch (message.type) {
480-
* case 'taskCreated':
481-
* console.log('Task created:', message.task.taskId);
482-
* break;
483-
* case 'taskStatus':
484-
* console.log('Task status:', message.task.status);
485-
* break;
486-
* case 'result':
487-
* console.log('Final result:', message.result);
488-
* break;
489-
* case 'error':
490-
* console.error('Error:', message.error);
491-
* break;
492-
* }
493-
* }
494-
* ```
495-
*
496-
* @param request - The request to send
497-
* @param resultSchema - Zod schema for validating the result
498-
* @param options - Optional request options (timeout, signal, task creation params, etc.)
499-
* @returns AsyncGenerator that yields ResponseMessage objects
500-
*/
501-
requestStream<T extends AnySchema>(
502-
request: ServerRequest | RequestT,
503-
resultSchema: T,
504-
options?: RequestOptions
505-
): AsyncGenerator<ResponseMessage<SchemaOutput<T>>, void, void> {
506-
return super.requestStream(request, resultSchema, options);
507-
}
508-
509466
async ping() {
510467
return this.request({ method: 'ping' }, EmptyResultSchema);
511468
}

0 commit comments

Comments
 (0)