Skip to content

Commit 7b9fc50

Browse files
hasam-hasam1_cbaHasmH
authored andcommitted
feat: add generic method to support custom extensions
1 parent 8ff97bd commit 7b9fc50

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/client/client.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,19 @@ export class A2AClient {
347347
return this._postRpcRequest<TaskIdParams, CancelTaskResponse>("tasks/cancel", params);
348348
}
349349

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+
350363
/**
351364
* Resubscribes to a task's event stream using Server-Sent Events (SSE).
352365
* This is used if a previous SSE connection for an active task was broken.

0 commit comments

Comments
 (0)