Skip to content

Commit 26c4e7d

Browse files
authored
feat: add list and delete task push notification config rpc method and custom rpc methods for extensions (#119)
- Added missing standard rpc methods defined: - `tasks/pushNotificationConfig/list` - `tasks/pushNotificationConfig/delete` - additionally, exposing generic method to support custom rpc methods Fixes #118 🦕
1 parent 45a211a commit 26c4e7d

File tree

2 files changed

+412
-3
lines changed

2 files changed

+412
-3
lines changed

src/client/client.ts

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ import {
2929
GetTaskPushNotificationConfigSuccessResponse,
3030
TaskResubscriptionRequest,
3131
A2AError,
32-
SendMessageSuccessResponse
32+
SendMessageSuccessResponse,
33+
ListTaskPushNotificationConfigParams,
34+
ListTaskPushNotificationConfigResponse,
35+
DeleteTaskPushNotificationConfigResponse,
36+
DeleteTaskPushNotificationConfigParams
3337
} from '../types.js'; // Assuming schema.ts is in the same directory or appropriately pathed
3438
import { AGENT_CARD_PATH } from "../constants.js";
3539

@@ -300,6 +304,30 @@ export class A2AClient {
300304
);
301305
}
302306

307+
/**
308+
* Lists the push notification configurations for a given task.
309+
* @param params Parameters containing the taskId.
310+
* @returns A Promise resolving to ListTaskPushNotificationConfigResponse.
311+
*/
312+
public async listTaskPushNotificationConfig(params: ListTaskPushNotificationConfigParams): Promise<ListTaskPushNotificationConfigResponse> {
313+
return this._postRpcRequest<ListTaskPushNotificationConfigParams, ListTaskPushNotificationConfigResponse>(
314+
"tasks/pushNotificationConfig/list",
315+
params
316+
);
317+
}
318+
319+
/**
320+
* Deletes the push notification configuration for a given task.
321+
* @param params Parameters containing the taskId and push notification configuration ID.
322+
* @returns A Promise resolving to DeleteTaskPushNotificationConfigResponse.
323+
*/
324+
public async deleteTaskPushNotificationConfig(params: DeleteTaskPushNotificationConfigParams): Promise<DeleteTaskPushNotificationConfigResponse> {
325+
return this._postRpcRequest<DeleteTaskPushNotificationConfigParams, DeleteTaskPushNotificationConfigResponse>(
326+
"tasks/pushNotificationConfig/delete",
327+
params
328+
);
329+
}
330+
303331

304332
/**
305333
* Retrieves a task by its ID.
@@ -319,6 +347,19 @@ export class A2AClient {
319347
return this._postRpcRequest<TaskIdParams, CancelTaskResponse>("tasks/cancel", params);
320348
}
321349

350+
/**
351+
* @template TExtensionParams The type of parameters for the custom extension method.
352+
* @template TExtensionResponse The type of response expected from the custom extension method.
353+
* This should extend JSONRPCResponse. This ensures the extension response is still a valid A2A response.
354+
* @param method Custom JSON-RPC method defined in the AgentCard's extensions.
355+
* @param params Extension paramters defined in the AgentCard's extensions.
356+
* @returns A Promise that resolves to the RPC response.
357+
*/
358+
public async callExtensionMethod<TExtensionParams, TExtensionResponse extends JSONRPCResponse>(method: string, params: TExtensionParams) {
359+
return this._postRpcRequest<TExtensionParams, TExtensionResponse>(method, params);
360+
}
361+
362+
322363
/**
323364
* Resubscribes to a task's event stream using Server-Sent Events (SSE).
324365
* This is used if a previous SSE connection for an active task was broken.

0 commit comments

Comments
 (0)