@assistant-ui/react-a2a 0.2.5 → 0.2.7
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 +47 -1
- package/dist/A2AClient.d.ts +43 -0
- package/dist/A2AClient.d.ts.map +1 -0
- package/dist/A2AClient.js +358 -0
- package/dist/A2AClient.js.map +1 -0
- package/dist/A2AThreadRuntimeCore.d.ts +75 -0
- package/dist/A2AThreadRuntimeCore.d.ts.map +1 -0
- package/dist/A2AThreadRuntimeCore.js +483 -0
- package/dist/A2AThreadRuntimeCore.js.map +1 -0
- package/dist/conversions.d.ts +14 -0
- package/dist/conversions.d.ts.map +1 -0
- package/dist/conversions.js +92 -0
- package/dist/conversions.js.map +1 -0
- package/dist/index.d.ts +7 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -6
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +228 -84
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +4 -9
- package/dist/types.js.map +1 -1
- package/dist/useA2ARuntime.d.ts +35 -48
- package/dist/useA2ARuntime.d.ts.map +1 -1
- package/dist/useA2ARuntime.js +126 -172
- package/dist/useA2ARuntime.js.map +1 -1
- package/package.json +9 -9
- package/src/A2AClient.test.ts +773 -0
- package/src/A2AClient.ts +519 -0
- package/src/A2AThreadRuntimeCore.test.ts +692 -0
- package/src/A2AThreadRuntimeCore.ts +633 -0
- package/src/conversions.test.ts +276 -0
- package/src/conversions.ts +115 -0
- package/src/index.ts +66 -6
- package/src/types.ts +276 -95
- package/src/useA2ARuntime.ts +204 -296
- package/dist/A2AMessageAccumulator.d.ts +0 -16
- package/dist/A2AMessageAccumulator.d.ts.map +0 -1
- package/dist/A2AMessageAccumulator.js +0 -29
- package/dist/A2AMessageAccumulator.js.map +0 -1
- package/dist/appendA2AChunk.d.ts +0 -3
- package/dist/appendA2AChunk.d.ts.map +0 -1
- package/dist/appendA2AChunk.js +0 -110
- package/dist/appendA2AChunk.js.map +0 -1
- package/dist/convertA2AMessages.d.ts +0 -64
- package/dist/convertA2AMessages.d.ts.map +0 -1
- package/dist/convertA2AMessages.js +0 -90
- package/dist/convertA2AMessages.js.map +0 -1
- package/dist/testUtils.d.ts +0 -4
- package/dist/testUtils.d.ts.map +0 -1
- package/dist/testUtils.js +0 -6
- package/dist/testUtils.js.map +0 -1
- package/dist/useA2AMessages.d.ts +0 -25
- package/dist/useA2AMessages.d.ts.map +0 -1
- package/dist/useA2AMessages.js +0 -122
- package/dist/useA2AMessages.js.map +0 -1
- package/src/A2AMessageAccumulator.ts +0 -48
- package/src/appendA2AChunk.ts +0 -121
- package/src/convertA2AMessages.ts +0 -108
- package/src/testUtils.ts +0 -11
- package/src/useA2AMessages.ts +0 -180
package/src/types.ts
CHANGED
|
@@ -1,114 +1,295 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// A2A v1.0 Protocol Types
|
|
2
|
+
// Enum values use lowercase internally; normalized from ProtoJSON SCREAMING_SNAKE_CASE on read.
|
|
3
|
+
// Wire format uses ROLE_USER/ROLE_AGENT and TASK_STATE_* per ADR-001.
|
|
3
4
|
|
|
4
|
-
|
|
5
|
+
export const A2A_PROTOCOL_VERSION = "1.0";
|
|
6
|
+
|
|
7
|
+
// === Roles ===
|
|
8
|
+
export type A2ARole = "unspecified" | "user" | "agent";
|
|
9
|
+
|
|
10
|
+
// === Part (content unit) ===
|
|
11
|
+
export type A2APart = {
|
|
12
|
+
text?: string | undefined;
|
|
13
|
+
raw?: string | undefined; // base64 encoded bytes
|
|
14
|
+
url?: string | undefined;
|
|
15
|
+
data?: unknown; // google.protobuf.Value
|
|
16
|
+
|
|
17
|
+
metadata?: Record<string, unknown> | undefined;
|
|
18
|
+
filename?: string | undefined;
|
|
19
|
+
mediaType?: string | undefined; // MIME type
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// === Message ===
|
|
5
23
|
export type A2AMessage = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
24
|
+
messageId: string;
|
|
25
|
+
contextId?: string | undefined;
|
|
26
|
+
taskId?: string | undefined;
|
|
27
|
+
role: A2ARole;
|
|
28
|
+
parts: A2APart[];
|
|
29
|
+
metadata?: Record<string, unknown> | undefined;
|
|
30
|
+
extensions?: string[] | undefined;
|
|
31
|
+
referenceTaskIds?: string[] | undefined;
|
|
13
32
|
};
|
|
14
33
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
|
18
|
-
|
|
|
34
|
+
// === Task State ===
|
|
35
|
+
export type A2ATaskState =
|
|
36
|
+
| "unspecified"
|
|
37
|
+
| "submitted"
|
|
38
|
+
| "working"
|
|
39
|
+
| "completed"
|
|
40
|
+
| "failed"
|
|
41
|
+
| "canceled"
|
|
42
|
+
| "input_required"
|
|
43
|
+
| "rejected"
|
|
44
|
+
| "auth_required";
|
|
19
45
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
46
|
+
// === Task Status ===
|
|
47
|
+
export type A2ATaskStatus = {
|
|
48
|
+
state: A2ATaskState;
|
|
49
|
+
message?: A2AMessage | undefined;
|
|
50
|
+
timestamp?: string | undefined; // ISO 8601
|
|
25
51
|
};
|
|
26
52
|
|
|
53
|
+
// === Artifact ===
|
|
27
54
|
export type A2AArtifact = {
|
|
55
|
+
artifactId: string;
|
|
56
|
+
name?: string | undefined;
|
|
57
|
+
description?: string | undefined;
|
|
58
|
+
parts: A2APart[];
|
|
59
|
+
metadata?: Record<string, unknown> | undefined;
|
|
60
|
+
extensions?: string[] | undefined;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
// === Task ===
|
|
64
|
+
export type A2ATask = {
|
|
65
|
+
id: string;
|
|
66
|
+
contextId?: string | undefined;
|
|
67
|
+
status: A2ATaskStatus;
|
|
68
|
+
artifacts?: A2AArtifact[] | undefined;
|
|
69
|
+
history?: A2AMessage[] | undefined;
|
|
70
|
+
metadata?: Record<string, unknown> | undefined;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
// === Streaming Events ===
|
|
74
|
+
export type A2ATaskStatusUpdateEvent = {
|
|
75
|
+
taskId: string;
|
|
76
|
+
contextId: string; // REQUIRED per proto
|
|
77
|
+
status: A2ATaskStatus;
|
|
78
|
+
metadata?: Record<string, unknown> | undefined;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export type A2ATaskArtifactUpdateEvent = {
|
|
82
|
+
taskId: string;
|
|
83
|
+
contextId: string; // REQUIRED per proto
|
|
84
|
+
artifact: A2AArtifact;
|
|
85
|
+
append?: boolean | undefined;
|
|
86
|
+
lastChunk?: boolean | undefined;
|
|
87
|
+
metadata?: Record<string, unknown> | undefined;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export type A2AStreamEvent =
|
|
91
|
+
| { type: "task"; task: A2ATask }
|
|
92
|
+
| { type: "message"; message: A2AMessage }
|
|
93
|
+
| { type: "statusUpdate"; event: A2ATaskStatusUpdateEvent }
|
|
94
|
+
| { type: "artifactUpdate"; event: A2ATaskArtifactUpdateEvent };
|
|
95
|
+
|
|
96
|
+
// === Authentication ===
|
|
97
|
+
export type A2AAuthenticationInfo = {
|
|
98
|
+
scheme: string;
|
|
99
|
+
credentials?: string | undefined;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
// === Push Notification Config ===
|
|
103
|
+
export type A2ATaskPushNotificationConfig = {
|
|
104
|
+
tenant?: string | undefined;
|
|
105
|
+
id?: string | undefined;
|
|
106
|
+
taskId?: string | undefined;
|
|
107
|
+
url: string;
|
|
108
|
+
token?: string | undefined;
|
|
109
|
+
authentication?: A2AAuthenticationInfo | undefined;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
export type A2AListTaskPushNotificationConfigsResponse = {
|
|
113
|
+
configs: A2ATaskPushNotificationConfig[];
|
|
114
|
+
nextPageToken?: string | undefined;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
// === Request/Response Types ===
|
|
118
|
+
export type A2ASendMessageConfiguration = {
|
|
119
|
+
acceptedOutputModes?: string[] | undefined;
|
|
120
|
+
taskPushNotificationConfig?: A2ATaskPushNotificationConfig | undefined;
|
|
121
|
+
historyLength?: number | undefined;
|
|
122
|
+
returnImmediately?: boolean | undefined;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export type A2AListTasksRequest = {
|
|
126
|
+
contextId?: string | undefined;
|
|
127
|
+
status?: A2ATaskState | undefined;
|
|
128
|
+
pageSize?: number | undefined;
|
|
129
|
+
pageToken?: string | undefined;
|
|
130
|
+
historyLength?: number | undefined;
|
|
131
|
+
statusTimestampAfter?: string | undefined; // ISO 8601
|
|
132
|
+
includeArtifacts?: boolean | undefined;
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
export type A2AListTasksResponse = {
|
|
136
|
+
tasks: A2ATask[];
|
|
137
|
+
nextPageToken: string;
|
|
138
|
+
pageSize: number;
|
|
139
|
+
totalSize: number;
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
// === Structured Error (google.rpc.Status) ===
|
|
143
|
+
export type A2AErrorInfo = {
|
|
144
|
+
code: number;
|
|
145
|
+
status: string;
|
|
146
|
+
message: string;
|
|
147
|
+
details?: unknown[] | undefined;
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
// === Security Schemes ===
|
|
151
|
+
export type A2AApiKeySecurityScheme = {
|
|
152
|
+
description?: string | undefined;
|
|
153
|
+
location: string; // "query" | "header" | "cookie"
|
|
28
154
|
name: string;
|
|
29
|
-
parts: A2AArtifactPart[];
|
|
30
155
|
};
|
|
31
156
|
|
|
32
|
-
export type
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
metadata?: Record<string, any>;
|
|
157
|
+
export type A2AHttpAuthSecurityScheme = {
|
|
158
|
+
description?: string | undefined;
|
|
159
|
+
scheme: string; // e.g. "Bearer"
|
|
160
|
+
bearerFormat?: string | undefined;
|
|
37
161
|
};
|
|
38
162
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
163
|
+
export type A2AAuthorizationCodeOAuthFlow = {
|
|
164
|
+
authorizationUrl: string;
|
|
165
|
+
tokenUrl: string;
|
|
166
|
+
refreshUrl?: string | undefined;
|
|
167
|
+
scopes: Record<string, string>;
|
|
168
|
+
pkceRequired?: boolean | undefined;
|
|
43
169
|
};
|
|
44
170
|
|
|
45
|
-
export
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
StateUpdate = "state-update",
|
|
51
|
-
Error = "error",
|
|
52
|
-
}
|
|
171
|
+
export type A2AClientCredentialsOAuthFlow = {
|
|
172
|
+
tokenUrl: string;
|
|
173
|
+
refreshUrl?: string | undefined;
|
|
174
|
+
scopes: Record<string, string>;
|
|
175
|
+
};
|
|
53
176
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
177
|
+
export type A2ADeviceCodeOAuthFlow = {
|
|
178
|
+
deviceAuthorizationUrl: string;
|
|
179
|
+
tokenUrl: string;
|
|
180
|
+
refreshUrl?: string | undefined;
|
|
181
|
+
scopes: Record<string, string>;
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
/** @deprecated Use Authorization Code + PKCE instead. */
|
|
185
|
+
export type A2AImplicitOAuthFlow = {
|
|
186
|
+
authorizationUrl?: string | undefined;
|
|
187
|
+
refreshUrl?: string | undefined;
|
|
188
|
+
scopes?: Record<string, string> | undefined;
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
/** @deprecated Use Authorization Code + PKCE or Device Code. */
|
|
192
|
+
export type A2APasswordOAuthFlow = {
|
|
193
|
+
tokenUrl?: string | undefined;
|
|
194
|
+
refreshUrl?: string | undefined;
|
|
195
|
+
scopes?: Record<string, string> | undefined;
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
export type A2AOAuthFlows = {
|
|
199
|
+
authorizationCode?: A2AAuthorizationCodeOAuthFlow | undefined;
|
|
200
|
+
clientCredentials?: A2AClientCredentialsOAuthFlow | undefined;
|
|
201
|
+
/** @deprecated */
|
|
202
|
+
implicit?: A2AImplicitOAuthFlow | undefined;
|
|
203
|
+
/** @deprecated */
|
|
204
|
+
password?: A2APasswordOAuthFlow | undefined;
|
|
205
|
+
deviceCode?: A2ADeviceCodeOAuthFlow | undefined;
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
export type A2AOAuth2SecurityScheme = {
|
|
209
|
+
description?: string | undefined;
|
|
210
|
+
flows: A2AOAuthFlows;
|
|
211
|
+
oauth2MetadataUrl?: string | undefined;
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
export type A2AOpenIdConnectSecurityScheme = {
|
|
215
|
+
description?: string | undefined;
|
|
216
|
+
openIdConnectUrl: string;
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
export type A2AMutualTlsSecurityScheme = {
|
|
220
|
+
description?: string | undefined;
|
|
60
221
|
};
|
|
61
222
|
|
|
62
|
-
|
|
63
|
-
|
|
223
|
+
export type A2ASecurityScheme = {
|
|
224
|
+
apiKeySecurityScheme?: A2AApiKeySecurityScheme | undefined;
|
|
225
|
+
httpAuthSecurityScheme?: A2AHttpAuthSecurityScheme | undefined;
|
|
226
|
+
oauth2SecurityScheme?: A2AOAuth2SecurityScheme | undefined;
|
|
227
|
+
openIdConnectSecurityScheme?: A2AOpenIdConnectSecurityScheme | undefined;
|
|
228
|
+
mtlsSecurityScheme?: A2AMutualTlsSecurityScheme | undefined;
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
export type A2ASecurityRequirement = {
|
|
232
|
+
schemes: Record<string, { list: string[] }>;
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
// === Agent Card Signature (JWS) ===
|
|
236
|
+
export type A2AAgentCardSignature = {
|
|
237
|
+
protected: string; // base64url-encoded JWS header
|
|
238
|
+
signature: string; // base64url-encoded signature
|
|
239
|
+
header?: Record<string, unknown> | undefined;
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
// === Agent Card ===
|
|
243
|
+
export type A2AAgentSkill = {
|
|
64
244
|
id: string;
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
export type
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
245
|
+
name: string;
|
|
246
|
+
description: string;
|
|
247
|
+
tags: string[];
|
|
248
|
+
examples?: string[] | undefined;
|
|
249
|
+
inputModes?: string[] | undefined;
|
|
250
|
+
outputModes?: string[] | undefined;
|
|
251
|
+
securityRequirements?: A2ASecurityRequirement[] | undefined;
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
export type A2AAgentCapabilities = {
|
|
255
|
+
streaming?: boolean | undefined;
|
|
256
|
+
pushNotifications?: boolean | undefined;
|
|
257
|
+
extensions?:
|
|
258
|
+
| Array<{
|
|
259
|
+
uri: string;
|
|
260
|
+
description?: string | undefined;
|
|
261
|
+
required?: boolean | undefined;
|
|
262
|
+
params?: Record<string, unknown> | undefined;
|
|
263
|
+
}>
|
|
264
|
+
| undefined;
|
|
265
|
+
extendedAgentCard?: boolean | undefined;
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
export type A2AAgentInterface = {
|
|
269
|
+
url: string;
|
|
270
|
+
protocolBinding: string;
|
|
271
|
+
protocolVersion: string;
|
|
272
|
+
tenant?: string | undefined;
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
export type A2AAgentCard = {
|
|
276
|
+
name: string;
|
|
277
|
+
description: string;
|
|
278
|
+
supportedInterfaces: A2AAgentInterface[]; // REQUIRED per proto
|
|
279
|
+
provider?:
|
|
280
|
+
| {
|
|
281
|
+
organization: string;
|
|
282
|
+
url: string;
|
|
283
|
+
}
|
|
284
|
+
| undefined;
|
|
285
|
+
version: string;
|
|
286
|
+
documentationUrl?: string | undefined;
|
|
287
|
+
capabilities: A2AAgentCapabilities;
|
|
288
|
+
securitySchemes?: Record<string, A2ASecurityScheme> | undefined;
|
|
289
|
+
securityRequirements?: A2ASecurityRequirement[] | undefined;
|
|
290
|
+
defaultInputModes: string[];
|
|
291
|
+
defaultOutputModes: string[];
|
|
292
|
+
skills: A2AAgentSkill[];
|
|
293
|
+
signatures?: A2AAgentCardSignature[] | undefined;
|
|
294
|
+
iconUrl?: string | undefined;
|
|
295
|
+
};
|