@@ -20,6 +20,7 @@ import {
2020 AgentCard ,
2121 CancelTaskRequest ,
2222 DeleteTaskPushNotificationConfigRequest ,
23+ GetExtendedAgentCardRequest ,
2324 GetTaskPushNotificationConfigRequest ,
2425 GetTaskRequest ,
2526 ListTaskPushNotificationConfigsRequest ,
@@ -60,14 +61,22 @@ export class RestTransport implements Transport {
6061 this . customFetchImpl = options . fetchImpl ;
6162 }
6263
64+ private _buildPath ( path : string , tenant ?: string ) : string {
65+ return tenant ? '/' + encodeURIComponent ( tenant ) + path : path ;
66+ }
67+
6368 get protocolName ( ) : string {
6469 return PROTOCOL_NAME ;
6570 }
6671
67- async getExtendedAgentCard ( options ?: RequestOptions ) : Promise < AgentCard > {
72+ async getExtendedAgentCard (
73+ params : GetExtendedAgentCardRequest ,
74+ options ?: RequestOptions
75+ ) : Promise < AgentCard > {
76+ const path = this . _buildPath ( '/extendedAgentCard' , params . tenant ) ;
6877 const response = await this . _sendRequest < undefined , AgentCard > (
6978 'GET' ,
70- '/extendedAgentCard' ,
79+ path ,
7180 undefined ,
7281 options ,
7382 undefined ,
@@ -81,9 +90,10 @@ export class RestTransport implements Transport {
8190 options ?: RequestOptions
8291 ) : Promise < SendMessageResult > {
8392 const requestBody = params ;
93+ const path = this . _buildPath ( '/message:send' , params . tenant ) ;
8494 const response = await this . _sendRequest < SendMessageRequest , SendMessageResponse > (
8595 'POST' ,
86- '/message:send' ,
96+ path ,
8797 requestBody ,
8898 options ,
8999 SendMessageRequest ,
@@ -97,34 +107,38 @@ export class RestTransport implements Transport {
97107 options ?: RequestOptions
98108 ) : AsyncGenerator < StreamResponse , void , undefined > {
99109 const requestBody = SendMessageRequest . toJSON ( params ) ;
100- yield * this . _sendStreamingRequest ( '/message:stream' , requestBody , options ) ;
110+ const path = this . _buildPath ( '/message:stream' , params . tenant ) ;
111+ yield * this . _sendStreamingRequest ( path , requestBody , options ) ;
101112 }
102113
103114 async createTaskPushNotificationConfig (
104115 params : TaskPushNotificationConfig ,
105116 options ?: RequestOptions
106117 ) : Promise < TaskPushNotificationConfig > {
107- const response = await this . _sendRequest <
108- TaskPushNotificationConfig ,
109- TaskPushNotificationConfig
110- > (
111- 'POST' ,
118+ const path = this . _buildPath (
112119 `/tasks/${ encodeURIComponent ( params . taskId ) } /pushNotificationConfigs` ,
113- params ,
114- options ,
120+ params . tenant
121+ ) ;
122+ const response = await this . _sendRequest <
115123 TaskPushNotificationConfig ,
116124 TaskPushNotificationConfig
117- ) ;
125+ > ( 'POST' , path , params , options , TaskPushNotificationConfig , TaskPushNotificationConfig ) ;
118126 return response ;
119127 }
120128
121129 async getTaskPushNotificationConfig (
122130 params : GetTaskPushNotificationConfigRequest ,
123131 options ?: RequestOptions
124132 ) : Promise < TaskPushNotificationConfig > {
125- const response = await this . _sendRequest < undefined , TaskPushNotificationConfig > (
133+ const path = this . _buildPath (
134+ `/tasks/${ encodeURIComponent ( params . taskId ) } /pushNotificationConfigs/${ encodeURIComponent (
135+ params . id
136+ ) } `,
137+ params . tenant
138+ ) ;
139+ const response = await this . _sendRequest < void , TaskPushNotificationConfig > (
126140 'GET' ,
127- `/tasks/ ${ params . taskId } /pushNotificationConfigs/ ${ params . id } ` ,
141+ path ,
128142 undefined ,
129143 options ,
130144 undefined ,
@@ -137,9 +151,13 @@ export class RestTransport implements Transport {
137151 params : ListTaskPushNotificationConfigsRequest ,
138152 options ?: RequestOptions
139153 ) : Promise < ListTaskPushNotificationConfigsResponse > {
140- const response = await this . _sendRequest < undefined , ListTaskPushNotificationConfigsResponse > (
154+ const path = this . _buildPath (
155+ `/tasks/${ encodeURIComponent ( params . taskId ) } /pushNotificationConfigs` ,
156+ params . tenant
157+ ) ;
158+ const response = await this . _sendRequest < void , ListTaskPushNotificationConfigsResponse > (
141159 'GET' ,
142- `/tasks/ ${ params . taskId } /pushNotificationConfigs` ,
160+ path ,
143161 undefined ,
144162 options ,
145163 undefined ,
@@ -152,24 +170,26 @@ export class RestTransport implements Transport {
152170 params : DeleteTaskPushNotificationConfigRequest ,
153171 options ?: RequestOptions
154172 ) : Promise < void > {
155- await this . _sendRequest < undefined , void > (
156- 'DELETE' ,
157- `/tasks/${ params . taskId } /pushNotificationConfigs/${ params . id } ` ,
158- undefined ,
159- options ,
160- undefined ,
161- undefined
173+ const path = this . _buildPath (
174+ `/tasks/${ encodeURIComponent ( params . taskId ) } /pushNotificationConfigs/${ encodeURIComponent (
175+ params . id
176+ ) } `,
177+ params . tenant
162178 ) ;
179+ await this . _sendRequest < void , void > ( 'DELETE' , path , undefined , options , undefined , undefined ) ;
163180 }
164181
165182 async getTask ( params : GetTaskRequest , options ?: RequestOptions ) : Promise < Task > {
166183 const queryParams = new URLSearchParams ( ) ;
167184 if ( params . historyLength !== undefined ) {
168- queryParams . set ( 'historyLength' , String ( params . historyLength ) ) ;
185+ queryParams . set ( 'historyLength' , params . historyLength . toString ( ) ) ;
169186 }
170187 const queryString = queryParams . toString ( ) ;
171- const path = `/tasks/${ params . id } ${ queryString ? `?${ queryString } ` : '' } ` ;
172- const response = await this . _sendRequest < undefined , Task > (
188+ const path = this . _buildPath (
189+ `/tasks/${ encodeURIComponent ( params . id ) } ${ queryString ? `?${ queryString } ` : '' } ` ,
190+ params . tenant
191+ ) ;
192+ const response = await this . _sendRequest < void , Task > (
173193 'GET' ,
174194 path ,
175195 undefined ,
@@ -181,9 +201,10 @@ export class RestTransport implements Transport {
181201 }
182202
183203 async cancelTask ( params : CancelTaskRequest , options ?: RequestOptions ) : Promise < Task > {
184- const response = await this . _sendRequest < undefined , Task > (
204+ const path = this . _buildPath ( `/tasks/${ encodeURIComponent ( params . id ) } :cancel` , params . tenant ) ;
205+ const response = await this . _sendRequest < void , Task > (
185206 'POST' ,
186- `/tasks/ ${ params . id } :cancel` ,
207+ path ,
187208 undefined ,
188209 options ,
189210 undefined ,
@@ -194,7 +215,6 @@ export class RestTransport implements Transport {
194215
195216 async listTasks ( params : ListTasksRequest , options ?: RequestOptions ) : Promise < ListTasksResponse > {
196217 const queryParams = new URLSearchParams ( ) ;
197- if ( params . tenant ) queryParams . set ( 'tenant' , params . tenant ) ;
198218 if ( params . contextId ) queryParams . set ( 'contextId' , params . contextId ) ;
199219 if ( params . status !== undefined && params . status !== TaskState . TASK_STATE_UNSPECIFIED ) {
200220 queryParams . set ( 'status' , taskStateToJSON ( params . status ) ) ;
@@ -209,9 +229,9 @@ export class RestTransport implements Transport {
209229 queryParams . set ( 'includeArtifacts' , String ( params . includeArtifacts ) ) ;
210230
211231 const queryString = queryParams . toString ( ) ;
212- const path = `/tasks${ queryString ? `?${ queryString } ` : '' } ` ;
232+ const path = this . _buildPath ( `/tasks${ queryString ? `?${ queryString } ` : '' } ` , params . tenant ) ;
213233
214- const response = await this . _sendRequest < undefined , ListTasksResponse > (
234+ const response = await this . _sendRequest < void , ListTasksResponse > (
215235 'GET' ,
216236 path ,
217237 undefined ,
@@ -226,7 +246,11 @@ export class RestTransport implements Transport {
226246 params : SubscribeToTaskRequest ,
227247 options ?: RequestOptions
228248 ) : AsyncGenerator < StreamResponse , void , undefined > {
229- yield * this . _sendStreamingRequest ( `/tasks/${ params . id } :subscribe` , undefined , options ) ;
249+ const path = this . _buildPath (
250+ `/tasks/${ encodeURIComponent ( params . id ) } :subscribe` ,
251+ params . tenant
252+ ) ;
253+ yield * this . _sendStreamingRequest ( path , undefined , options ) ;
230254 }
231255
232256 private _fetch ( ...args : Parameters < typeof fetch > ) : ReturnType < typeof fetch > {
0 commit comments