@a2a-js/sdk 0.3.7 → 0.3.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +70 -0
- package/dist/{chunk-SJNAG4AL.js → chunk-EGOOH5HP.js} +1 -55
- package/dist/chunk-F6ACNKFR.js +41 -0
- package/dist/chunk-QQCCX2KH.js +3338 -0
- package/dist/{chunk-LTPINR5K.js → chunk-S53FFHPM.js} +3 -98
- package/dist/chunk-TS5RMC7F.js +56 -0
- package/dist/chunk-U3QAVT4H.js +1986 -0
- package/dist/chunk-UHZEIZLS.js +62 -0
- package/dist/client/index.cjs +2118 -26
- package/dist/client/index.d.cts +4 -415
- package/dist/client/index.d.ts +4 -415
- package/dist/client/index.js +111 -35
- package/dist/client/transports/grpc/index.cjs +4601 -0
- package/dist/client/transports/grpc/index.d.cts +42 -0
- package/dist/client/transports/grpc/index.d.ts +42 -0
- package/dist/client/transports/grpc/index.js +262 -0
- package/dist/core-BAzQJfA2.d.ts +416 -0
- package/dist/core-Ci-lR0jz.d.cts +416 -0
- package/dist/server/express/index.cjs +2134 -120
- package/dist/server/express/index.js +80 -20
- package/dist/server/grpc/index.cjs +4560 -0
- package/dist/server/grpc/index.d.cts +1053 -0
- package/dist/server/grpc/index.d.ts +1053 -0
- package/dist/server/grpc/index.js +186 -0
- package/dist/server/index.cjs +1 -1
- package/dist/server/index.js +8 -4
- package/package.json +41 -3
package/dist/client/index.d.cts
CHANGED
|
@@ -1,149 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
type SendMessageResult = Message | Task;
|
|
5
|
-
interface A2AClientOptions {
|
|
6
|
-
agentCardPath?: string;
|
|
7
|
-
fetchImpl?: typeof fetch;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* A2AClient is a TypeScript HTTP client for interacting with A2A-compliant agents.
|
|
11
|
-
* Only JSON-RPC transport is supported.
|
|
12
|
-
* @deprecated Use {@link ClientFactory}
|
|
13
|
-
*/
|
|
14
|
-
declare class A2AClient {
|
|
15
|
-
private static emptyOptions?;
|
|
16
|
-
private readonly agentCardPromise;
|
|
17
|
-
private readonly customFetchImpl?;
|
|
18
|
-
private serviceEndpointUrl?;
|
|
19
|
-
private transport?;
|
|
20
|
-
private requestIdCounter;
|
|
21
|
-
/**
|
|
22
|
-
* Constructs an A2AClient instance from an AgentCard.
|
|
23
|
-
* @param agentCard The AgentCard object.
|
|
24
|
-
* @param options Optional. The options for the A2AClient including the fetch/auth implementation.
|
|
25
|
-
*/
|
|
26
|
-
constructor(agentCard: AgentCard | string, options?: A2AClientOptions);
|
|
27
|
-
/**
|
|
28
|
-
* Dynamically resolves the fetch implementation to use for requests.
|
|
29
|
-
* Prefers a custom implementation if provided, otherwise falls back to the global fetch.
|
|
30
|
-
* @returns The fetch implementation.
|
|
31
|
-
* @param args Arguments to pass to the fetch implementation.
|
|
32
|
-
* @throws If no fetch implementation is available.
|
|
33
|
-
*/
|
|
34
|
-
private _fetch;
|
|
35
|
-
/**
|
|
36
|
-
* Creates an A2AClient instance by fetching the AgentCard from a URL then constructing the A2AClient.
|
|
37
|
-
* @param agentCardUrl The URL of the agent card.
|
|
38
|
-
* @param options Optional. The options for the A2AClient including the fetch/auth implementation.
|
|
39
|
-
* @returns A Promise that resolves to a new A2AClient instance.
|
|
40
|
-
*/
|
|
41
|
-
static fromCardUrl(agentCardUrl: string, options?: A2AClientOptions): Promise<A2AClient>;
|
|
42
|
-
/**
|
|
43
|
-
* Sends a message to the agent.
|
|
44
|
-
* The behavior (blocking/non-blocking) and push notification configuration
|
|
45
|
-
* are specified within the `params.configuration` object.
|
|
46
|
-
* Optionally, `params.message.contextId` or `params.message.taskId` can be provided.
|
|
47
|
-
* @param params The parameters for sending the message, including the message content and configuration.
|
|
48
|
-
* @returns A Promise resolving to SendMessageResponse, which can be a Message, Task, or an error.
|
|
49
|
-
*/
|
|
50
|
-
sendMessage(params: MessageSendParams): Promise<SendMessageResponse>;
|
|
51
|
-
/**
|
|
52
|
-
* Sends a message to the agent and streams back responses using Server-Sent Events (SSE).
|
|
53
|
-
* Push notification configuration can be specified in `params.configuration`.
|
|
54
|
-
* Optionally, `params.message.contextId` or `params.message.taskId` can be provided.
|
|
55
|
-
* Requires the agent to support streaming (`capabilities.streaming: true` in AgentCard).
|
|
56
|
-
* @param params The parameters for sending the message.
|
|
57
|
-
* @returns An AsyncGenerator yielding A2AStreamEventData (Message, Task, TaskStatusUpdateEvent, or TaskArtifactUpdateEvent).
|
|
58
|
-
* The generator throws an error if streaming is not supported or if an HTTP/SSE error occurs.
|
|
59
|
-
*/
|
|
60
|
-
sendMessageStream(params: MessageSendParams): AsyncGenerator<A2AStreamEventData, void, undefined>;
|
|
61
|
-
/**
|
|
62
|
-
* Sets or updates the push notification configuration for a given task.
|
|
63
|
-
* Requires the agent to support push notifications (`capabilities.pushNotifications: true` in AgentCard).
|
|
64
|
-
* @param params Parameters containing the taskId and the TaskPushNotificationConfig.
|
|
65
|
-
* @returns A Promise resolving to SetTaskPushNotificationConfigResponse.
|
|
66
|
-
*/
|
|
67
|
-
setTaskPushNotificationConfig(params: TaskPushNotificationConfig): Promise<SetTaskPushNotificationConfigResponse>;
|
|
68
|
-
/**
|
|
69
|
-
* Gets the push notification configuration for a given task.
|
|
70
|
-
* @param params Parameters containing the taskId.
|
|
71
|
-
* @returns A Promise resolving to GetTaskPushNotificationConfigResponse.
|
|
72
|
-
*/
|
|
73
|
-
getTaskPushNotificationConfig(params: TaskIdParams): Promise<GetTaskPushNotificationConfigResponse>;
|
|
74
|
-
/**
|
|
75
|
-
* Lists the push notification configurations for a given task.
|
|
76
|
-
* @param params Parameters containing the taskId.
|
|
77
|
-
* @returns A Promise resolving to ListTaskPushNotificationConfigResponse.
|
|
78
|
-
*/
|
|
79
|
-
listTaskPushNotificationConfig(params: ListTaskPushNotificationConfigParams): Promise<ListTaskPushNotificationConfigResponse>;
|
|
80
|
-
/**
|
|
81
|
-
* Deletes the push notification configuration for a given task.
|
|
82
|
-
* @param params Parameters containing the taskId and push notification configuration ID.
|
|
83
|
-
* @returns A Promise resolving to DeleteTaskPushNotificationConfigResponse.
|
|
84
|
-
*/
|
|
85
|
-
deleteTaskPushNotificationConfig(params: DeleteTaskPushNotificationConfigParams): Promise<DeleteTaskPushNotificationConfigResponse>;
|
|
86
|
-
/**
|
|
87
|
-
* Retrieves a task by its ID.
|
|
88
|
-
* @param params Parameters containing the taskId and optional historyLength.
|
|
89
|
-
* @returns A Promise resolving to GetTaskResponse, which contains the Task object or an error.
|
|
90
|
-
*/
|
|
91
|
-
getTask(params: TaskQueryParams): Promise<GetTaskResponse>;
|
|
92
|
-
/**
|
|
93
|
-
* Cancels a task by its ID.
|
|
94
|
-
* @param params Parameters containing the taskId.
|
|
95
|
-
* @returns A Promise resolving to CancelTaskResponse, which contains the updated Task object or an error.
|
|
96
|
-
*/
|
|
97
|
-
cancelTask(params: TaskIdParams): Promise<CancelTaskResponse>;
|
|
98
|
-
/**
|
|
99
|
-
* @template TExtensionParams The type of parameters for the custom extension method.
|
|
100
|
-
* @template TExtensionResponse The type of response expected from the custom extension method.
|
|
101
|
-
* This should extend JSONRPCResponse. This ensures the extension response is still a valid A2A response.
|
|
102
|
-
* @param method Custom JSON-RPC method defined in the AgentCard's extensions.
|
|
103
|
-
* @param params Extension paramters defined in the AgentCard's extensions.
|
|
104
|
-
* @returns A Promise that resolves to the RPC response.
|
|
105
|
-
*/
|
|
106
|
-
callExtensionMethod<TExtensionParams, TExtensionResponse extends JSONRPCResponse>(method: string, params: TExtensionParams): Promise<TExtensionResponse>;
|
|
107
|
-
/**
|
|
108
|
-
* Resubscribes to a task's event stream using Server-Sent Events (SSE).
|
|
109
|
-
* This is used if a previous SSE connection for an active task was broken.
|
|
110
|
-
* Requires the agent to support streaming (`capabilities.streaming: true` in AgentCard).
|
|
111
|
-
* @param params Parameters containing the taskId.
|
|
112
|
-
* @returns An AsyncGenerator yielding A2AStreamEventData (Message, Task, TaskStatusUpdateEvent, or TaskArtifactUpdateEvent).
|
|
113
|
-
*/
|
|
114
|
-
resubscribeTask(params: TaskIdParams): AsyncGenerator<A2AStreamEventData, void, undefined>;
|
|
115
|
-
private _getOrCreateTransport;
|
|
116
|
-
/**
|
|
117
|
-
* Fetches the Agent Card from the agent's well-known URI and caches its service endpoint URL.
|
|
118
|
-
* This method is called by the constructor.
|
|
119
|
-
* @param agentBaseUrl The base URL of the A2A agent (e.g., https://agent.example.com)
|
|
120
|
-
* @param agentCardPath path to the agent card, defaults to .well-known/agent-card.json
|
|
121
|
-
* @returns A Promise that resolves to the AgentCard.
|
|
122
|
-
*/
|
|
123
|
-
private _fetchAndCacheAgentCard;
|
|
124
|
-
/**
|
|
125
|
-
* Retrieves the Agent Card.
|
|
126
|
-
* If an `agentBaseUrl` is provided, it fetches the card from that specific URL.
|
|
127
|
-
* Otherwise, it returns the card fetched and cached during client construction.
|
|
128
|
-
* @param agentBaseUrl Optional. The base URL of the agent to fetch the card from.
|
|
129
|
-
* @param agentCardPath path to the agent card, defaults to .well-known/agent-card.json
|
|
130
|
-
* If provided, this will fetch a new card, not use the cached one from the constructor's URL.
|
|
131
|
-
* @returns A Promise that resolves to the AgentCard.
|
|
132
|
-
*/
|
|
133
|
-
getAgentCard(agentBaseUrl?: string, agentCardPath?: string): Promise<AgentCard>;
|
|
134
|
-
/**
|
|
135
|
-
* Determines the agent card URL based on the agent URL.
|
|
136
|
-
* @param agentBaseUrl The agent URL.
|
|
137
|
-
* @param agentCardPath Optional relative path to the agent card, defaults to .well-known/agent-card.json
|
|
138
|
-
*/
|
|
139
|
-
private resolveAgentCardUrl;
|
|
140
|
-
/**
|
|
141
|
-
* Gets the RPC service endpoint URL. Ensures the agent card has been fetched first.
|
|
142
|
-
* @returns A Promise that resolves to the service endpoint URL string.
|
|
143
|
-
*/
|
|
144
|
-
private _getServiceEndpoint;
|
|
145
|
-
private invokeJsonRpc;
|
|
146
|
-
}
|
|
1
|
+
import { T as TransportFactory, C as ClientConfig, a as TransportProtocolName, b as Client, c as Transport, R as RequestOptions, S as SendMessageResult, A as A2AStreamEventData } from '../core-Ci-lR0jz.cjs';
|
|
2
|
+
export { d as A2AClient, e as A2AClientOptions, g as AfterArgs, B as BeforeArgs, f as CallInterceptor, l as ClientCallContext, n as ClientCallContextKey, h as ClientCallInput, i as ClientCallResult, m as ContextUpdate, j as ServiceParameters, k as ServiceParametersUpdate, w as withA2AExtensions } from '../core-Ci-lR0jz.cjs';
|
|
3
|
+
import { ae as AgentCard, x as MessageSendParams, $ as TaskPushNotificationConfig, a3 as GetTaskPushNotificationConfigParams, a7 as ListTaskPushNotificationConfigParams, a9 as DeleteTaskPushNotificationConfigParams, X as TaskQueryParams, ay as Task, Z as TaskIdParams, j as JSONRPCResponse } from '../extensions-DvruCIzw.cjs';
|
|
147
4
|
|
|
148
5
|
interface HttpHeaders {
|
|
149
6
|
[key: string]: string;
|
|
@@ -234,274 +91,6 @@ declare const AgentCardResolver: {
|
|
|
234
91
|
default: DefaultAgentCardResolver;
|
|
235
92
|
};
|
|
236
93
|
|
|
237
|
-
/**
|
|
238
|
-
* Function that applies an update to a {@link ClientCallContext}.
|
|
239
|
-
*/
|
|
240
|
-
type ContextUpdate = (context: ClientCallContext) => void;
|
|
241
|
-
/**
|
|
242
|
-
* Opaque context object to carry per-call context data.
|
|
243
|
-
* Use {@link ClientCallContextKey} to create typed keys for storing and retrieving values.
|
|
244
|
-
*/
|
|
245
|
-
type ClientCallContext = Record<symbol, unknown>;
|
|
246
|
-
declare const ClientCallContext: {
|
|
247
|
-
/**
|
|
248
|
-
* Create a new {@link ClientCallContext} with optional updates applied.
|
|
249
|
-
*/
|
|
250
|
-
create: (...updates: ContextUpdate[]) => ClientCallContext;
|
|
251
|
-
/**
|
|
252
|
-
* Create a new {@link ClientCallContext} based on an existing one with updates applied.
|
|
253
|
-
*/
|
|
254
|
-
createFrom: (context: ClientCallContext | undefined, ...updates: ContextUpdate[]) => ClientCallContext;
|
|
255
|
-
};
|
|
256
|
-
/**
|
|
257
|
-
* Each instance represents a unique key for storing
|
|
258
|
-
* and retrieving typed values in a {@link ClientCallContext}.
|
|
259
|
-
*
|
|
260
|
-
* @example
|
|
261
|
-
* ```ts
|
|
262
|
-
* const key = new ClientCallContextKey<string>('My key');
|
|
263
|
-
* const context = ClientCallContext.create(key.set('example-value'));
|
|
264
|
-
* const value = key.get(context); // 'example-value'
|
|
265
|
-
* ```
|
|
266
|
-
*/
|
|
267
|
-
declare class ClientCallContextKey<T> {
|
|
268
|
-
readonly symbol: symbol;
|
|
269
|
-
constructor(description: string);
|
|
270
|
-
set(value: T): ContextUpdate;
|
|
271
|
-
get(context: ClientCallContext): T | undefined;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
interface CallInterceptor {
|
|
275
|
-
/**
|
|
276
|
-
* Invoked before transport method.
|
|
277
|
-
*/
|
|
278
|
-
before(args: BeforeArgs): Promise<void>;
|
|
279
|
-
/**
|
|
280
|
-
* Invoked after transport method.
|
|
281
|
-
*/
|
|
282
|
-
after(args: AfterArgs): Promise<void>;
|
|
283
|
-
}
|
|
284
|
-
interface BeforeArgs<K extends keyof Client = keyof Client> {
|
|
285
|
-
/**
|
|
286
|
-
* Identifies the client method invoked and its payload.
|
|
287
|
-
* Payload inside the input object can be modified.
|
|
288
|
-
*/
|
|
289
|
-
readonly input: ClientCallInput<K>;
|
|
290
|
-
/**
|
|
291
|
-
* Identifies the agent card cached on the client
|
|
292
|
-
*/
|
|
293
|
-
readonly agentCard: AgentCard;
|
|
294
|
-
/**
|
|
295
|
-
* If set by the interceptor, stops execution, invokes "after"
|
|
296
|
-
* for executed interceptors and returns the result. Transport is not called.
|
|
297
|
-
*/
|
|
298
|
-
earlyReturn?: ClientCallResult<K>;
|
|
299
|
-
/**
|
|
300
|
-
* Options passed to the client.
|
|
301
|
-
*/
|
|
302
|
-
options?: RequestOptions;
|
|
303
|
-
}
|
|
304
|
-
interface AfterArgs<K extends keyof Client = keyof Client> {
|
|
305
|
-
/**
|
|
306
|
-
* Identifies the client method invoked and its result.
|
|
307
|
-
* Payload inside the result object can be modified.
|
|
308
|
-
*/
|
|
309
|
-
readonly result: ClientCallResult<K>;
|
|
310
|
-
/**
|
|
311
|
-
* Identifies the agent card cached on the client
|
|
312
|
-
*/
|
|
313
|
-
readonly agentCard: AgentCard;
|
|
314
|
-
/**
|
|
315
|
-
* If set by the interceptor, stops execution and returns result value,
|
|
316
|
-
* remaining interceptors are not executed.
|
|
317
|
-
*/
|
|
318
|
-
earlyReturn?: boolean;
|
|
319
|
-
/**
|
|
320
|
-
* Options passed to the client.
|
|
321
|
-
*/
|
|
322
|
-
options?: RequestOptions;
|
|
323
|
-
}
|
|
324
|
-
type ClientCallInput<K extends keyof Client = keyof Client> = MethodInput<Client, K>;
|
|
325
|
-
type ClientCallResult<K extends keyof Client = keyof Client> = MethodResult<Client, K, ResultsOverrides>;
|
|
326
|
-
/**
|
|
327
|
-
* For
|
|
328
|
-
*
|
|
329
|
-
* interface Foo {
|
|
330
|
-
* f1(arg: string): Promise<Result1>;
|
|
331
|
-
* f2(arg: number): Promise<Result2>;
|
|
332
|
-
* }
|
|
333
|
-
*
|
|
334
|
-
* MethodInputs<Foo> resolves to
|
|
335
|
-
*
|
|
336
|
-
* {
|
|
337
|
-
* readonly method: "f1";
|
|
338
|
-
* value: string;
|
|
339
|
-
* } | {
|
|
340
|
-
* readonly method: "f2";
|
|
341
|
-
* value: number;
|
|
342
|
-
* }
|
|
343
|
-
*/
|
|
344
|
-
type MethodInput<T, TMembers extends keyof T = keyof T> = {
|
|
345
|
-
[M in TMembers]: T[M] extends (options: RequestOptions | undefined) => unknown ? {
|
|
346
|
-
readonly method: M;
|
|
347
|
-
value?: never;
|
|
348
|
-
} : T[M] extends (payload: infer P) => unknown ? {
|
|
349
|
-
readonly method: M;
|
|
350
|
-
value: P;
|
|
351
|
-
} : never;
|
|
352
|
-
}[TMembers];
|
|
353
|
-
/**
|
|
354
|
-
* For
|
|
355
|
-
*
|
|
356
|
-
* interface Foo {
|
|
357
|
-
* f1(): Promise<Result1>;
|
|
358
|
-
* f2(): Promise<Result2>;
|
|
359
|
-
* }
|
|
360
|
-
*
|
|
361
|
-
* MethodsResults<Foo> resolves to
|
|
362
|
-
*
|
|
363
|
-
* {
|
|
364
|
-
* readonly method: "f1";
|
|
365
|
-
* value: Result1;
|
|
366
|
-
* } | {
|
|
367
|
-
* readonly method: "f2";
|
|
368
|
-
* value: Result2;
|
|
369
|
-
* }
|
|
370
|
-
*/
|
|
371
|
-
type MethodResult<T, TMembers extends keyof T = keyof T, TOverrides = object> = {
|
|
372
|
-
[M in TMembers]: M extends keyof TOverrides ? {
|
|
373
|
-
readonly method: M;
|
|
374
|
-
value: TOverrides[M];
|
|
375
|
-
} : T[M] extends (payload: unknown) => infer R ? {
|
|
376
|
-
readonly method: M;
|
|
377
|
-
value: Awaited<R>;
|
|
378
|
-
} : never;
|
|
379
|
-
}[TMembers];
|
|
380
|
-
interface ResultsOverrides {
|
|
381
|
-
sendMessageStream: A2AStreamEventData;
|
|
382
|
-
resubscribeTask: A2AStreamEventData;
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
type ServiceParametersUpdate = (parameters: ServiceParameters) => void;
|
|
386
|
-
type ServiceParameters = Record<string, string>;
|
|
387
|
-
declare const ServiceParameters: {
|
|
388
|
-
create(...updates: ServiceParametersUpdate[]): ServiceParameters;
|
|
389
|
-
createFrom: (serviceParameters: ServiceParameters | undefined, ...updates: ServiceParametersUpdate[]) => ServiceParameters;
|
|
390
|
-
};
|
|
391
|
-
declare function withA2AExtensions(...extensions: Extensions): ServiceParametersUpdate;
|
|
392
|
-
|
|
393
|
-
interface Transport {
|
|
394
|
-
getExtendedAgentCard(options?: RequestOptions): Promise<AgentCard>;
|
|
395
|
-
sendMessage(params: MessageSendParams, options?: RequestOptions): Promise<SendMessageResult>;
|
|
396
|
-
sendMessageStream(params: MessageSendParams, options?: RequestOptions): AsyncGenerator<A2AStreamEventData, void, undefined>;
|
|
397
|
-
setTaskPushNotificationConfig(params: TaskPushNotificationConfig, options?: RequestOptions): Promise<TaskPushNotificationConfig>;
|
|
398
|
-
getTaskPushNotificationConfig(params: GetTaskPushNotificationConfigParams, options?: RequestOptions): Promise<TaskPushNotificationConfig>;
|
|
399
|
-
listTaskPushNotificationConfig(params: ListTaskPushNotificationConfigParams, options?: RequestOptions): Promise<TaskPushNotificationConfig[]>;
|
|
400
|
-
deleteTaskPushNotificationConfig(params: DeleteTaskPushNotificationConfigParams, options?: RequestOptions): Promise<void>;
|
|
401
|
-
getTask(params: TaskQueryParams, options?: RequestOptions): Promise<Task>;
|
|
402
|
-
cancelTask(params: TaskIdParams, options?: RequestOptions): Promise<Task>;
|
|
403
|
-
resubscribeTask(params: TaskIdParams, options?: RequestOptions): AsyncGenerator<A2AStreamEventData, void, undefined>;
|
|
404
|
-
}
|
|
405
|
-
interface TransportFactory {
|
|
406
|
-
get protocolName(): string;
|
|
407
|
-
create(url: string, agentCard: AgentCard): Promise<Transport>;
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
interface ClientConfig {
|
|
411
|
-
/**
|
|
412
|
-
* Whether client prefers to poll for task updates instead of blocking until a terminal state is reached.
|
|
413
|
-
* If set to true, non-streaming send message result might be a Message or a Task in any (including non-terminal) state.
|
|
414
|
-
* Callers are responsible for running the polling loop. This configuration does not apply to streaming requests.
|
|
415
|
-
*/
|
|
416
|
-
polling?: boolean;
|
|
417
|
-
/**
|
|
418
|
-
* Specifies the default list of accepted media types to apply for all "send message" calls.
|
|
419
|
-
*/
|
|
420
|
-
acceptedOutputModes?: string[];
|
|
421
|
-
/**
|
|
422
|
-
* Specifies the default push notification configuration to apply for every Task.
|
|
423
|
-
*/
|
|
424
|
-
pushNotificationConfig?: PushNotificationConfig;
|
|
425
|
-
/**
|
|
426
|
-
* Interceptors invoked for each request.
|
|
427
|
-
*/
|
|
428
|
-
interceptors?: CallInterceptor[];
|
|
429
|
-
}
|
|
430
|
-
interface RequestOptions {
|
|
431
|
-
/**
|
|
432
|
-
* Signal to abort request execution.
|
|
433
|
-
*/
|
|
434
|
-
signal?: AbortSignal;
|
|
435
|
-
/**
|
|
436
|
-
* A key-value map for passing horizontally applicable context or parameters.
|
|
437
|
-
* All parameters are passed to the server via underlying transports (e.g. In JsonRPC via Headers).
|
|
438
|
-
*/
|
|
439
|
-
serviceParameters?: ServiceParameters;
|
|
440
|
-
/**
|
|
441
|
-
* Arbitrary data available to interceptors and transport implementation.
|
|
442
|
-
*/
|
|
443
|
-
context?: ClientCallContext;
|
|
444
|
-
}
|
|
445
|
-
declare class Client {
|
|
446
|
-
readonly transport: Transport;
|
|
447
|
-
private agentCard;
|
|
448
|
-
readonly config?: ClientConfig;
|
|
449
|
-
constructor(transport: Transport, agentCard: AgentCard, config?: ClientConfig);
|
|
450
|
-
/**
|
|
451
|
-
* If the current agent card supports the extended feature, it will try to fetch the extended agent card from the server,
|
|
452
|
-
* Otherwise it will return the current agent card value.
|
|
453
|
-
*/
|
|
454
|
-
getAgentCard(options?: RequestOptions): Promise<AgentCard>;
|
|
455
|
-
/**
|
|
456
|
-
* Sends a message to an agent to initiate a new interaction or to continue an existing one.
|
|
457
|
-
* Uses blocking mode by default.
|
|
458
|
-
*/
|
|
459
|
-
sendMessage(params: MessageSendParams, options?: RequestOptions): Promise<SendMessageResult>;
|
|
460
|
-
/**
|
|
461
|
-
* Sends a message to an agent to initiate/continue a task AND subscribes the client to real-time updates for that task.
|
|
462
|
-
* Performs fallback to non-streaming if not supported by the agent.
|
|
463
|
-
*/
|
|
464
|
-
sendMessageStream(params: MessageSendParams, options?: RequestOptions): AsyncGenerator<A2AStreamEventData, void, undefined>;
|
|
465
|
-
/**
|
|
466
|
-
* Sets or updates the push notification configuration for a specified task.
|
|
467
|
-
* Requires the server to have AgentCard.capabilities.pushNotifications: true.
|
|
468
|
-
*/
|
|
469
|
-
setTaskPushNotificationConfig(params: TaskPushNotificationConfig, options?: RequestOptions): Promise<TaskPushNotificationConfig>;
|
|
470
|
-
/**
|
|
471
|
-
* Retrieves the current push notification configuration for a specified task.
|
|
472
|
-
* Requires the server to have AgentCard.capabilities.pushNotifications: true.
|
|
473
|
-
*/
|
|
474
|
-
getTaskPushNotificationConfig(params: TaskIdParams, options?: RequestOptions): Promise<TaskPushNotificationConfig>;
|
|
475
|
-
/**
|
|
476
|
-
* Retrieves the associated push notification configurations for a specified task.
|
|
477
|
-
* Requires the server to have AgentCard.capabilities.pushNotifications: true.
|
|
478
|
-
*/
|
|
479
|
-
listTaskPushNotificationConfig(params: ListTaskPushNotificationConfigParams, options?: RequestOptions): Promise<TaskPushNotificationConfig[]>;
|
|
480
|
-
/**
|
|
481
|
-
* Deletes an associated push notification configuration for a task.
|
|
482
|
-
*/
|
|
483
|
-
deleteTaskPushNotificationConfig(params: DeleteTaskPushNotificationConfigParams, options?: RequestOptions): Promise<void>;
|
|
484
|
-
/**
|
|
485
|
-
* Retrieves the current state (including status, artifacts, and optionally history) of a previously initiated task.
|
|
486
|
-
*/
|
|
487
|
-
getTask(params: TaskQueryParams, options?: RequestOptions): Promise<Task>;
|
|
488
|
-
/**
|
|
489
|
-
* Requests the cancellation of an ongoing task. The server will attempt to cancel the task,
|
|
490
|
-
* but success is not guaranteed (e.g., the task might have already completed or failed, or cancellation might not be supported at its current stage).
|
|
491
|
-
*/
|
|
492
|
-
cancelTask(params: TaskIdParams, options?: RequestOptions): Promise<Task>;
|
|
493
|
-
/**
|
|
494
|
-
* Allows a client to reconnect to an updates stream for an ongoing task after a previous connection was interrupted.
|
|
495
|
-
*/
|
|
496
|
-
resubscribeTask(params: TaskIdParams, options?: RequestOptions): AsyncGenerator<A2AStreamEventData, void, undefined>;
|
|
497
|
-
private applyClientConfig;
|
|
498
|
-
private executeWithInterceptors;
|
|
499
|
-
private interceptBefore;
|
|
500
|
-
private interceptAfter;
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
type TransportProtocolName = 'JSONRPC' | 'HTTP+JSON' | 'GRPC' | (string & {});
|
|
504
|
-
|
|
505
94
|
interface ClientFactoryOptions {
|
|
506
95
|
/**
|
|
507
96
|
* Transport factories to use.
|
|
@@ -663,4 +252,4 @@ declare class RestTransportFactory implements TransportFactory {
|
|
|
663
252
|
create(url: string, _agentCard: AgentCard): Promise<Transport>;
|
|
664
253
|
}
|
|
665
254
|
|
|
666
|
-
export {
|
|
255
|
+
export { AgentCardResolver, type AgentCardResolverOptions, AuthenticatedExtendedCardNotConfiguredError, type AuthenticationHandler, Client, ClientConfig, ClientFactory, ClientFactoryOptions, ContentTypeNotSupportedError, DefaultAgentCardResolver, type HttpHeaders, InvalidAgentResponseError, JsonRpcTransport, JsonRpcTransportFactory, type JsonRpcTransportOptions, PushNotificationNotSupportedError, RequestOptions, RestTransport, RestTransportFactory, type RestTransportOptions, TaskNotCancelableError, TaskNotFoundError, Transport, TransportFactory, UnsupportedOperationError, createAuthenticatingFetchWithRetry };
|