@a2a-js/sdk 0.3.4 → 0.3.6

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.
@@ -1,6 +1,7 @@
1
1
  import { EventEmitter } from 'events';
2
- import { B as Message, aw as Task, aO as TaskStatusUpdateEvent, aQ as TaskArtifactUpdateEvent, y as PushNotificationConfig, ac as AgentCard, w as MessageSendParams, V as TaskQueryParams, X as TaskIdParams, Z as TaskPushNotificationConfig, a1 as GetTaskPushNotificationConfigParams, a5 as ListTaskPushNotificationConfigParams, a7 as DeleteTaskPushNotificationConfigParams, i as JSONRPCResponse, au as JSONRPCError } from '../types-DNKcmF0f.cjs';
3
- import { A as A2ARequestHandler } from '../a2a_request_handler-DUvKWfix.cjs';
2
+ import { F as Message, ay as Task, aQ as TaskStatusUpdateEvent, aS as TaskArtifactUpdateEvent, z as PushNotificationConfig, ae as AgentCard, x as MessageSendParams, X as TaskQueryParams, Z as TaskIdParams, $ as TaskPushNotificationConfig, a3 as GetTaskPushNotificationConfigParams, a7 as ListTaskPushNotificationConfigParams, a9 as DeleteTaskPushNotificationConfigParams, j as JSONRPCResponse, aw as JSONRPCError } from '../extensions-DvruCIzw.cjs';
3
+ import { S as ServerCallContext, A as A2ARequestHandler } from '../a2a_request_handler-B3LxMq3P.cjs';
4
+ export { a as UnauthenticatedUser, U as User } from '../a2a_request_handler-B3LxMq3P.cjs';
4
5
 
5
6
  type AgentExecutionEvent = Message | Task | TaskStatusUpdateEvent | TaskArtifactUpdateEvent;
6
7
  interface ExecutionEventBus {
@@ -19,11 +20,12 @@ declare class DefaultExecutionEventBus extends EventEmitter implements Execution
19
20
 
20
21
  declare class RequestContext {
21
22
  readonly userMessage: Message;
22
- readonly task?: Task;
23
- readonly referenceTasks?: Task[];
24
23
  readonly taskId: string;
25
24
  readonly contextId: string;
26
- constructor(userMessage: Message, taskId: string, contextId: string, task?: Task, referenceTasks?: Task[]);
25
+ readonly task?: Task;
26
+ readonly referenceTasks?: Task[];
27
+ readonly context?: ServerCallContext;
28
+ constructor(userMessage: Message, taskId: string, contextId: string, task?: Task, referenceTasks?: Task[], context?: ServerCallContext);
27
29
  }
28
30
 
29
31
  interface AgentExecutor {
@@ -53,13 +55,13 @@ declare class DefaultExecutionEventBusManager implements ExecutionEventBusManage
53
55
  /**
54
56
  * Creates or retrieves an existing ExecutionEventBus based on the taskId.
55
57
  * @param taskId The ID of the task.
56
- * @returns An instance of IExecutionEventBus.
58
+ * @returns An instance of ExecutionEventBus.
57
59
  */
58
60
  createOrGetByTaskId(taskId: string): ExecutionEventBus;
59
61
  /**
60
62
  * Retrieves an existing ExecutionEventBus based on the taskId.
61
63
  * @param taskId The ID of the task.
62
- * @returns An instance of IExecutionEventBus or undefined if not found.
64
+ * @returns An instance of ExecutionEventBus or undefined if not found.
63
65
  */
64
66
  getByTaskId(taskId: string): ExecutionEventBus | undefined;
65
67
  /**
@@ -102,16 +104,18 @@ interface TaskStore {
102
104
  /**
103
105
  * Saves a task.
104
106
  * Overwrites existing data if the task ID exists.
105
- * @param data An object containing the task.
107
+ * @param task The task to save.
108
+ * @param context The context of the current call.
106
109
  * @returns A promise resolving when the save operation is complete.
107
110
  */
108
- save(task: Task): Promise<void>;
111
+ save(task: Task, context?: ServerCallContext): Promise<void>;
109
112
  /**
110
113
  * Loads a task by task ID.
111
114
  * @param taskId The ID of the task to load.
115
+ * @param context The context of the current call.
112
116
  * @returns A promise resolving to an object containing the Task, or undefined if not found.
113
117
  */
114
- load(taskId: string): Promise<Task | undefined>;
118
+ load(taskId: string, context?: ServerCallContext): Promise<Task | undefined>;
115
119
  }
116
120
  declare class InMemoryTaskStore implements TaskStore {
117
121
  private store;
@@ -137,35 +141,38 @@ interface PushNotificationSender {
137
141
 
138
142
  declare class DefaultRequestHandler implements A2ARequestHandler {
139
143
  private readonly agentCard;
140
- private readonly extendedAgentCard?;
141
144
  private readonly taskStore;
142
145
  private readonly agentExecutor;
143
146
  private readonly eventBusManager;
144
147
  private readonly pushNotificationStore?;
145
148
  private readonly pushNotificationSender?;
146
- constructor(agentCard: AgentCard, taskStore: TaskStore, agentExecutor: AgentExecutor, eventBusManager?: ExecutionEventBusManager, pushNotificationStore?: PushNotificationStore, pushNotificationSender?: PushNotificationSender, extendedAgentCard?: AgentCard);
149
+ private readonly extendedAgentCardProvider?;
150
+ constructor(agentCard: AgentCard, taskStore: TaskStore, agentExecutor: AgentExecutor, eventBusManager?: ExecutionEventBusManager, pushNotificationStore?: PushNotificationStore, pushNotificationSender?: PushNotificationSender, extendedAgentCardProvider?: AgentCard | ExtendedAgentCardProvider);
147
151
  getAgentCard(): Promise<AgentCard>;
148
- getAuthenticatedExtendedAgentCard(): Promise<AgentCard>;
152
+ getAuthenticatedExtendedAgentCard(context?: ServerCallContext): Promise<AgentCard>;
149
153
  private _createRequestContext;
150
154
  private _processEvents;
151
- sendMessage(params: MessageSendParams): Promise<Message | Task>;
152
- sendMessageStream(params: MessageSendParams): AsyncGenerator<Message | Task | TaskStatusUpdateEvent | TaskArtifactUpdateEvent, void, undefined>;
153
- getTask(params: TaskQueryParams): Promise<Task>;
154
- cancelTask(params: TaskIdParams): Promise<Task>;
155
- setTaskPushNotificationConfig(params: TaskPushNotificationConfig): Promise<TaskPushNotificationConfig>;
156
- getTaskPushNotificationConfig(params: TaskIdParams | GetTaskPushNotificationConfigParams): Promise<TaskPushNotificationConfig>;
157
- listTaskPushNotificationConfigs(params: ListTaskPushNotificationConfigParams): Promise<TaskPushNotificationConfig[]>;
158
- deleteTaskPushNotificationConfig(params: DeleteTaskPushNotificationConfigParams): Promise<void>;
159
- resubscribe(params: TaskIdParams): AsyncGenerator<Task | TaskStatusUpdateEvent | TaskArtifactUpdateEvent, void, undefined>;
155
+ sendMessage(params: MessageSendParams, context?: ServerCallContext): Promise<Message | Task>;
156
+ sendMessageStream(params: MessageSendParams, context?: ServerCallContext): AsyncGenerator<Message | Task | TaskStatusUpdateEvent | TaskArtifactUpdateEvent, void, undefined>;
157
+ getTask(params: TaskQueryParams, context?: ServerCallContext): Promise<Task>;
158
+ cancelTask(params: TaskIdParams, context?: ServerCallContext): Promise<Task>;
159
+ setTaskPushNotificationConfig(params: TaskPushNotificationConfig, context?: ServerCallContext): Promise<TaskPushNotificationConfig>;
160
+ getTaskPushNotificationConfig(params: TaskIdParams | GetTaskPushNotificationConfigParams, context?: ServerCallContext): Promise<TaskPushNotificationConfig>;
161
+ listTaskPushNotificationConfigs(params: ListTaskPushNotificationConfigParams, context?: ServerCallContext): Promise<TaskPushNotificationConfig[]>;
162
+ deleteTaskPushNotificationConfig(params: DeleteTaskPushNotificationConfigParams, context?: ServerCallContext): Promise<void>;
163
+ resubscribe(params: TaskIdParams, context?: ServerCallContext): AsyncGenerator<Task | TaskStatusUpdateEvent | TaskArtifactUpdateEvent, void, undefined>;
160
164
  private _sendPushNotificationIfNeeded;
165
+ private _handleProcessingError;
161
166
  }
167
+ type ExtendedAgentCardProvider = (context?: ServerCallContext) => Promise<AgentCard>;
162
168
 
163
169
  declare class ResultManager {
164
- private taskStore;
170
+ private readonly taskStore;
171
+ private readonly serverCallContext?;
165
172
  private currentTask?;
166
173
  private latestUserMessage?;
167
174
  private finalMessageResult?;
168
- constructor(taskStore: TaskStore);
175
+ constructor(taskStore: TaskStore, serverCallContext?: ServerCallContext);
169
176
  setContext(latestUserMessage: Message): void;
170
177
  /**
171
178
  * Processes an agent execution event and updates the task store.
@@ -198,7 +205,9 @@ declare class JsonRpcTransportHandler {
198
205
  * For streaming methods, it returns an AsyncGenerator of JSONRPCResult.
199
206
  * For non-streaming methods, it returns a Promise of a single JSONRPCMessage (Result or ErrorResponse).
200
207
  */
201
- handle(requestBody: any): Promise<JSONRPCResponse | AsyncGenerator<JSONRPCResponse, void, undefined>>;
208
+ handle(requestBody: any, context?: ServerCallContext): Promise<JSONRPCResponse | AsyncGenerator<JSONRPCResponse, void, undefined>>;
209
+ private isRequestValid;
210
+ private paramsAreValid;
202
211
  }
203
212
 
204
213
  /**
@@ -237,10 +246,11 @@ interface DefaultPushNotificationSenderOptions {
237
246
  }
238
247
  declare class DefaultPushNotificationSender implements PushNotificationSender {
239
248
  private readonly pushNotificationStore;
249
+ private notificationChain;
240
250
  private readonly options;
241
251
  constructor(pushNotificationStore: PushNotificationStore, options?: DefaultPushNotificationSenderOptions);
242
252
  send(task: Task): Promise<void>;
243
253
  private _dispatchNotification;
244
254
  }
245
255
 
246
- export { A2AError, A2ARequestHandler, type AgentExecutionEvent, type AgentExecutor, DefaultExecutionEventBus, DefaultExecutionEventBusManager, DefaultPushNotificationSender, type DefaultPushNotificationSenderOptions, DefaultRequestHandler, type ExecutionEventBus, type ExecutionEventBusManager, ExecutionEventQueue, InMemoryPushNotificationStore, InMemoryTaskStore, JsonRpcTransportHandler, type PushNotificationSender, type PushNotificationStore, RequestContext, ResultManager, type TaskStore };
256
+ export { A2AError, A2ARequestHandler, type AgentExecutionEvent, type AgentExecutor, DefaultExecutionEventBus, DefaultExecutionEventBusManager, DefaultPushNotificationSender, type DefaultPushNotificationSenderOptions, DefaultRequestHandler, type ExecutionEventBus, type ExecutionEventBusManager, ExecutionEventQueue, type ExtendedAgentCardProvider, InMemoryPushNotificationStore, InMemoryTaskStore, JsonRpcTransportHandler, type PushNotificationSender, type PushNotificationStore, RequestContext, ResultManager, ServerCallContext, type TaskStore };
@@ -1,6 +1,7 @@
1
1
  import { EventEmitter } from 'events';
2
- import { B as Message, aw as Task, aO as TaskStatusUpdateEvent, aQ as TaskArtifactUpdateEvent, y as PushNotificationConfig, ac as AgentCard, w as MessageSendParams, V as TaskQueryParams, X as TaskIdParams, Z as TaskPushNotificationConfig, a1 as GetTaskPushNotificationConfigParams, a5 as ListTaskPushNotificationConfigParams, a7 as DeleteTaskPushNotificationConfigParams, i as JSONRPCResponse, au as JSONRPCError } from '../types-DNKcmF0f.js';
3
- import { A as A2ARequestHandler } from '../a2a_request_handler-B5t-IxgA.js';
2
+ import { F as Message, ay as Task, aQ as TaskStatusUpdateEvent, aS as TaskArtifactUpdateEvent, z as PushNotificationConfig, ae as AgentCard, x as MessageSendParams, X as TaskQueryParams, Z as TaskIdParams, $ as TaskPushNotificationConfig, a3 as GetTaskPushNotificationConfigParams, a7 as ListTaskPushNotificationConfigParams, a9 as DeleteTaskPushNotificationConfigParams, j as JSONRPCResponse, aw as JSONRPCError } from '../extensions-DvruCIzw.js';
3
+ import { S as ServerCallContext, A as A2ARequestHandler } from '../a2a_request_handler-BuP9LgXH.js';
4
+ export { a as UnauthenticatedUser, U as User } from '../a2a_request_handler-BuP9LgXH.js';
4
5
 
5
6
  type AgentExecutionEvent = Message | Task | TaskStatusUpdateEvent | TaskArtifactUpdateEvent;
6
7
  interface ExecutionEventBus {
@@ -19,11 +20,12 @@ declare class DefaultExecutionEventBus extends EventEmitter implements Execution
19
20
 
20
21
  declare class RequestContext {
21
22
  readonly userMessage: Message;
22
- readonly task?: Task;
23
- readonly referenceTasks?: Task[];
24
23
  readonly taskId: string;
25
24
  readonly contextId: string;
26
- constructor(userMessage: Message, taskId: string, contextId: string, task?: Task, referenceTasks?: Task[]);
25
+ readonly task?: Task;
26
+ readonly referenceTasks?: Task[];
27
+ readonly context?: ServerCallContext;
28
+ constructor(userMessage: Message, taskId: string, contextId: string, task?: Task, referenceTasks?: Task[], context?: ServerCallContext);
27
29
  }
28
30
 
29
31
  interface AgentExecutor {
@@ -53,13 +55,13 @@ declare class DefaultExecutionEventBusManager implements ExecutionEventBusManage
53
55
  /**
54
56
  * Creates or retrieves an existing ExecutionEventBus based on the taskId.
55
57
  * @param taskId The ID of the task.
56
- * @returns An instance of IExecutionEventBus.
58
+ * @returns An instance of ExecutionEventBus.
57
59
  */
58
60
  createOrGetByTaskId(taskId: string): ExecutionEventBus;
59
61
  /**
60
62
  * Retrieves an existing ExecutionEventBus based on the taskId.
61
63
  * @param taskId The ID of the task.
62
- * @returns An instance of IExecutionEventBus or undefined if not found.
64
+ * @returns An instance of ExecutionEventBus or undefined if not found.
63
65
  */
64
66
  getByTaskId(taskId: string): ExecutionEventBus | undefined;
65
67
  /**
@@ -102,16 +104,18 @@ interface TaskStore {
102
104
  /**
103
105
  * Saves a task.
104
106
  * Overwrites existing data if the task ID exists.
105
- * @param data An object containing the task.
107
+ * @param task The task to save.
108
+ * @param context The context of the current call.
106
109
  * @returns A promise resolving when the save operation is complete.
107
110
  */
108
- save(task: Task): Promise<void>;
111
+ save(task: Task, context?: ServerCallContext): Promise<void>;
109
112
  /**
110
113
  * Loads a task by task ID.
111
114
  * @param taskId The ID of the task to load.
115
+ * @param context The context of the current call.
112
116
  * @returns A promise resolving to an object containing the Task, or undefined if not found.
113
117
  */
114
- load(taskId: string): Promise<Task | undefined>;
118
+ load(taskId: string, context?: ServerCallContext): Promise<Task | undefined>;
115
119
  }
116
120
  declare class InMemoryTaskStore implements TaskStore {
117
121
  private store;
@@ -137,35 +141,38 @@ interface PushNotificationSender {
137
141
 
138
142
  declare class DefaultRequestHandler implements A2ARequestHandler {
139
143
  private readonly agentCard;
140
- private readonly extendedAgentCard?;
141
144
  private readonly taskStore;
142
145
  private readonly agentExecutor;
143
146
  private readonly eventBusManager;
144
147
  private readonly pushNotificationStore?;
145
148
  private readonly pushNotificationSender?;
146
- constructor(agentCard: AgentCard, taskStore: TaskStore, agentExecutor: AgentExecutor, eventBusManager?: ExecutionEventBusManager, pushNotificationStore?: PushNotificationStore, pushNotificationSender?: PushNotificationSender, extendedAgentCard?: AgentCard);
149
+ private readonly extendedAgentCardProvider?;
150
+ constructor(agentCard: AgentCard, taskStore: TaskStore, agentExecutor: AgentExecutor, eventBusManager?: ExecutionEventBusManager, pushNotificationStore?: PushNotificationStore, pushNotificationSender?: PushNotificationSender, extendedAgentCardProvider?: AgentCard | ExtendedAgentCardProvider);
147
151
  getAgentCard(): Promise<AgentCard>;
148
- getAuthenticatedExtendedAgentCard(): Promise<AgentCard>;
152
+ getAuthenticatedExtendedAgentCard(context?: ServerCallContext): Promise<AgentCard>;
149
153
  private _createRequestContext;
150
154
  private _processEvents;
151
- sendMessage(params: MessageSendParams): Promise<Message | Task>;
152
- sendMessageStream(params: MessageSendParams): AsyncGenerator<Message | Task | TaskStatusUpdateEvent | TaskArtifactUpdateEvent, void, undefined>;
153
- getTask(params: TaskQueryParams): Promise<Task>;
154
- cancelTask(params: TaskIdParams): Promise<Task>;
155
- setTaskPushNotificationConfig(params: TaskPushNotificationConfig): Promise<TaskPushNotificationConfig>;
156
- getTaskPushNotificationConfig(params: TaskIdParams | GetTaskPushNotificationConfigParams): Promise<TaskPushNotificationConfig>;
157
- listTaskPushNotificationConfigs(params: ListTaskPushNotificationConfigParams): Promise<TaskPushNotificationConfig[]>;
158
- deleteTaskPushNotificationConfig(params: DeleteTaskPushNotificationConfigParams): Promise<void>;
159
- resubscribe(params: TaskIdParams): AsyncGenerator<Task | TaskStatusUpdateEvent | TaskArtifactUpdateEvent, void, undefined>;
155
+ sendMessage(params: MessageSendParams, context?: ServerCallContext): Promise<Message | Task>;
156
+ sendMessageStream(params: MessageSendParams, context?: ServerCallContext): AsyncGenerator<Message | Task | TaskStatusUpdateEvent | TaskArtifactUpdateEvent, void, undefined>;
157
+ getTask(params: TaskQueryParams, context?: ServerCallContext): Promise<Task>;
158
+ cancelTask(params: TaskIdParams, context?: ServerCallContext): Promise<Task>;
159
+ setTaskPushNotificationConfig(params: TaskPushNotificationConfig, context?: ServerCallContext): Promise<TaskPushNotificationConfig>;
160
+ getTaskPushNotificationConfig(params: TaskIdParams | GetTaskPushNotificationConfigParams, context?: ServerCallContext): Promise<TaskPushNotificationConfig>;
161
+ listTaskPushNotificationConfigs(params: ListTaskPushNotificationConfigParams, context?: ServerCallContext): Promise<TaskPushNotificationConfig[]>;
162
+ deleteTaskPushNotificationConfig(params: DeleteTaskPushNotificationConfigParams, context?: ServerCallContext): Promise<void>;
163
+ resubscribe(params: TaskIdParams, context?: ServerCallContext): AsyncGenerator<Task | TaskStatusUpdateEvent | TaskArtifactUpdateEvent, void, undefined>;
160
164
  private _sendPushNotificationIfNeeded;
165
+ private _handleProcessingError;
161
166
  }
167
+ type ExtendedAgentCardProvider = (context?: ServerCallContext) => Promise<AgentCard>;
162
168
 
163
169
  declare class ResultManager {
164
- private taskStore;
170
+ private readonly taskStore;
171
+ private readonly serverCallContext?;
165
172
  private currentTask?;
166
173
  private latestUserMessage?;
167
174
  private finalMessageResult?;
168
- constructor(taskStore: TaskStore);
175
+ constructor(taskStore: TaskStore, serverCallContext?: ServerCallContext);
169
176
  setContext(latestUserMessage: Message): void;
170
177
  /**
171
178
  * Processes an agent execution event and updates the task store.
@@ -198,7 +205,9 @@ declare class JsonRpcTransportHandler {
198
205
  * For streaming methods, it returns an AsyncGenerator of JSONRPCResult.
199
206
  * For non-streaming methods, it returns a Promise of a single JSONRPCMessage (Result or ErrorResponse).
200
207
  */
201
- handle(requestBody: any): Promise<JSONRPCResponse | AsyncGenerator<JSONRPCResponse, void, undefined>>;
208
+ handle(requestBody: any, context?: ServerCallContext): Promise<JSONRPCResponse | AsyncGenerator<JSONRPCResponse, void, undefined>>;
209
+ private isRequestValid;
210
+ private paramsAreValid;
202
211
  }
203
212
 
204
213
  /**
@@ -237,10 +246,11 @@ interface DefaultPushNotificationSenderOptions {
237
246
  }
238
247
  declare class DefaultPushNotificationSender implements PushNotificationSender {
239
248
  private readonly pushNotificationStore;
249
+ private notificationChain;
240
250
  private readonly options;
241
251
  constructor(pushNotificationStore: PushNotificationStore, options?: DefaultPushNotificationSenderOptions);
242
252
  send(task: Task): Promise<void>;
243
253
  private _dispatchNotification;
244
254
  }
245
255
 
246
- export { A2AError, A2ARequestHandler, type AgentExecutionEvent, type AgentExecutor, DefaultExecutionEventBus, DefaultExecutionEventBusManager, DefaultPushNotificationSender, type DefaultPushNotificationSenderOptions, DefaultRequestHandler, type ExecutionEventBus, type ExecutionEventBusManager, ExecutionEventQueue, InMemoryPushNotificationStore, InMemoryTaskStore, JsonRpcTransportHandler, type PushNotificationSender, type PushNotificationStore, RequestContext, ResultManager, type TaskStore };
256
+ export { A2AError, A2ARequestHandler, type AgentExecutionEvent, type AgentExecutor, DefaultExecutionEventBus, DefaultExecutionEventBusManager, DefaultPushNotificationSender, type DefaultPushNotificationSenderOptions, DefaultRequestHandler, type ExecutionEventBus, type ExecutionEventBusManager, ExecutionEventQueue, type ExtendedAgentCardProvider, InMemoryPushNotificationStore, InMemoryTaskStore, JsonRpcTransportHandler, type PushNotificationSender, type PushNotificationStore, RequestContext, ResultManager, ServerCallContext, type TaskStore };