@@ -25,11 +25,6 @@ import type { Client } from '../../client/client.js';
2525 * @internal
2626 */
2727interface ClientInternal {
28- requestStream < T extends AnyObjectSchema > (
29- request : Request ,
30- resultSchema : T ,
31- options ?: RequestOptions
32- ) : AsyncGenerator < ResponseMessage < SchemaOutput < T > > , void , void > ;
3328 isToolTask ( toolName : string ) : boolean ;
3429 getToolOutputValidator ( toolName : string ) : ( ( data : unknown ) => { valid : boolean ; errorMessage ?: string } ) | undefined ;
3530}
@@ -90,7 +85,6 @@ export class ExperimentalClientTasks {
9085 ) : AsyncGenerator < ResponseMessage < SchemaOutput < typeof CallToolResultSchema > > , void , void > {
9186 // Access Client's internal methods
9287 const clientInternal = this . _client as unknown as ClientInternal ;
93-
9488 // Add task creation parameters if server supports it and not explicitly provided
9589 const optionsWithTask = {
9690 ...options ,
@@ -99,7 +93,7 @@ export class ExperimentalClientTasks {
9993 task : options ?. task ?? ( clientInternal . isToolTask ( params . name ) ? { } : undefined )
10094 } ;
10195
102- const stream = clientInternal . requestStream ( { method : 'tools/call' , params } , CallToolResultSchema , optionsWithTask ) ;
96+ const stream = this . _client . tasks . requestStream ( { method : 'tools/call' , params } , CallToolResultSchema , optionsWithTask ) ;
10397
10498 // Get the validator for this tool (if it has an output schema)
10599 const validator = clientInternal . getToolOutputValidator ( params . name ) ;
@@ -170,9 +164,7 @@ export class ExperimentalClientTasks {
170164 * @experimental
171165 */
172166 async getTask ( taskId : string , options ?: RequestOptions ) : Promise < GetTaskResult > {
173- // Delegate to the client's underlying Protocol method
174- type ClientWithGetTask = { getTask ( params : { taskId : string } , options ?: RequestOptions ) : Promise < GetTaskResult > } ;
175- return ( this . _client as unknown as ClientWithGetTask ) . getTask ( { taskId } , options ) ;
167+ return this . _client . tasks . getTask ( { taskId } , options ) ;
176168 }
177169
178170 /**
@@ -186,16 +178,7 @@ export class ExperimentalClientTasks {
186178 * @experimental
187179 */
188180 async getTaskResult < T extends AnyObjectSchema > ( taskId : string , resultSchema ?: T , options ?: RequestOptions ) : Promise < SchemaOutput < T > > {
189- // Delegate to the client's underlying Protocol method
190- return (
191- this . _client as unknown as {
192- getTaskResult : < U extends AnyObjectSchema > (
193- params : { taskId : string } ,
194- resultSchema ?: U ,
195- options ?: RequestOptions
196- ) => Promise < SchemaOutput < U > > ;
197- }
198- ) . getTaskResult ( { taskId } , resultSchema , options ) ;
181+ return this . _client . tasks . getTaskResult ( { taskId } , resultSchema ! , options ) ;
199182 }
200183
201184 /**
@@ -208,12 +191,7 @@ export class ExperimentalClientTasks {
208191 * @experimental
209192 */
210193 async listTasks ( cursor ?: string , options ?: RequestOptions ) : Promise < ListTasksResult > {
211- // Delegate to the client's underlying Protocol method
212- return (
213- this . _client as unknown as {
214- listTasks : ( params ?: { cursor ?: string } , options ?: RequestOptions ) => Promise < ListTasksResult > ;
215- }
216- ) . listTasks ( cursor ? { cursor } : undefined , options ) ;
194+ return this . _client . tasks . listTasks ( cursor ? { cursor } : undefined , options ) ;
217195 }
218196
219197 /**
@@ -225,12 +203,7 @@ export class ExperimentalClientTasks {
225203 * @experimental
226204 */
227205 async cancelTask ( taskId : string , options ?: RequestOptions ) : Promise < CancelTaskResult > {
228- // Delegate to the client's underlying Protocol method
229- return (
230- this . _client as unknown as {
231- cancelTask : ( params : { taskId : string } , options ?: RequestOptions ) => Promise < CancelTaskResult > ;
232- }
233- ) . cancelTask ( { taskId } , options ) ;
206+ return this . _client . tasks . cancelTask ( { taskId } , options ) ;
234207 }
235208
236209 /**
@@ -252,14 +225,6 @@ export class ExperimentalClientTasks {
252225 resultSchema : T ,
253226 options ?: RequestOptions
254227 ) : AsyncGenerator < ResponseMessage < SchemaOutput < T > > , void , void > {
255- // Delegate to the client's underlying Protocol method
256- type ClientWithRequestStream = {
257- requestStream < U extends AnyObjectSchema > (
258- request : Request ,
259- resultSchema : U ,
260- options ?: RequestOptions
261- ) : AsyncGenerator < ResponseMessage < SchemaOutput < U > > , void , void > ;
262- } ;
263- return ( this . _client as unknown as ClientWithRequestStream ) . requestStream ( request , resultSchema , options ) ;
228+ return this . _client . tasks . requestStream ( request , resultSchema , options ) ;
264229 }
265230}
0 commit comments