@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.
@@ -0,0 +1,1986 @@
1
+ import {
2
+ A2AError
3
+ } from "./chunk-UHZEIZLS.js";
4
+
5
+ // src/types/pb/a2a_types.ts
6
+ function taskStateFromJSON(object) {
7
+ switch (object) {
8
+ case 0:
9
+ case "TASK_STATE_UNSPECIFIED":
10
+ return 0 /* TASK_STATE_UNSPECIFIED */;
11
+ case 1:
12
+ case "TASK_STATE_SUBMITTED":
13
+ return 1 /* TASK_STATE_SUBMITTED */;
14
+ case 2:
15
+ case "TASK_STATE_WORKING":
16
+ return 2 /* TASK_STATE_WORKING */;
17
+ case 3:
18
+ case "TASK_STATE_COMPLETED":
19
+ return 3 /* TASK_STATE_COMPLETED */;
20
+ case 4:
21
+ case "TASK_STATE_FAILED":
22
+ return 4 /* TASK_STATE_FAILED */;
23
+ case 5:
24
+ case "TASK_STATE_CANCELLED":
25
+ return 5 /* TASK_STATE_CANCELLED */;
26
+ case 6:
27
+ case "TASK_STATE_INPUT_REQUIRED":
28
+ return 6 /* TASK_STATE_INPUT_REQUIRED */;
29
+ case 7:
30
+ case "TASK_STATE_REJECTED":
31
+ return 7 /* TASK_STATE_REJECTED */;
32
+ case 8:
33
+ case "TASK_STATE_AUTH_REQUIRED":
34
+ return 8 /* TASK_STATE_AUTH_REQUIRED */;
35
+ case -1:
36
+ case "UNRECOGNIZED":
37
+ default:
38
+ return -1 /* UNRECOGNIZED */;
39
+ }
40
+ }
41
+ function taskStateToJSON(object) {
42
+ switch (object) {
43
+ case 0 /* TASK_STATE_UNSPECIFIED */:
44
+ return "TASK_STATE_UNSPECIFIED";
45
+ case 1 /* TASK_STATE_SUBMITTED */:
46
+ return "TASK_STATE_SUBMITTED";
47
+ case 2 /* TASK_STATE_WORKING */:
48
+ return "TASK_STATE_WORKING";
49
+ case 3 /* TASK_STATE_COMPLETED */:
50
+ return "TASK_STATE_COMPLETED";
51
+ case 4 /* TASK_STATE_FAILED */:
52
+ return "TASK_STATE_FAILED";
53
+ case 5 /* TASK_STATE_CANCELLED */:
54
+ return "TASK_STATE_CANCELLED";
55
+ case 6 /* TASK_STATE_INPUT_REQUIRED */:
56
+ return "TASK_STATE_INPUT_REQUIRED";
57
+ case 7 /* TASK_STATE_REJECTED */:
58
+ return "TASK_STATE_REJECTED";
59
+ case 8 /* TASK_STATE_AUTH_REQUIRED */:
60
+ return "TASK_STATE_AUTH_REQUIRED";
61
+ case -1 /* UNRECOGNIZED */:
62
+ default:
63
+ return "UNRECOGNIZED";
64
+ }
65
+ }
66
+ function roleFromJSON(object) {
67
+ switch (object) {
68
+ case 0:
69
+ case "ROLE_UNSPECIFIED":
70
+ return 0 /* ROLE_UNSPECIFIED */;
71
+ case 1:
72
+ case "ROLE_USER":
73
+ return 1 /* ROLE_USER */;
74
+ case 2:
75
+ case "ROLE_AGENT":
76
+ return 2 /* ROLE_AGENT */;
77
+ case -1:
78
+ case "UNRECOGNIZED":
79
+ default:
80
+ return -1 /* UNRECOGNIZED */;
81
+ }
82
+ }
83
+ function roleToJSON(object) {
84
+ switch (object) {
85
+ case 0 /* ROLE_UNSPECIFIED */:
86
+ return "ROLE_UNSPECIFIED";
87
+ case 1 /* ROLE_USER */:
88
+ return "ROLE_USER";
89
+ case 2 /* ROLE_AGENT */:
90
+ return "ROLE_AGENT";
91
+ case -1 /* UNRECOGNIZED */:
92
+ default:
93
+ return "UNRECOGNIZED";
94
+ }
95
+ }
96
+ var SendMessageConfiguration = {
97
+ fromJSON(object) {
98
+ return {
99
+ acceptedOutputModes: globalThis.Array.isArray(object?.acceptedOutputModes) ? object.acceptedOutputModes.map((e) => globalThis.String(e)) : globalThis.Array.isArray(object?.accepted_output_modes) ? object.accepted_output_modes.map(
100
+ (e) => globalThis.String(e)
101
+ ) : [],
102
+ pushNotification: isSet(object.pushNotification) ? PushNotificationConfig.fromJSON(object.pushNotification) : isSet(object.push_notification) ? PushNotificationConfig.fromJSON(object.push_notification) : void 0,
103
+ historyLength: isSet(object.historyLength) ? globalThis.Number(object.historyLength) : isSet(object.history_length) ? globalThis.Number(object.history_length) : 0,
104
+ blocking: isSet(object.blocking) ? globalThis.Boolean(object.blocking) : false
105
+ };
106
+ },
107
+ toJSON(message) {
108
+ const obj = {};
109
+ if (message.acceptedOutputModes?.length) {
110
+ obj.acceptedOutputModes = message.acceptedOutputModes;
111
+ }
112
+ if (message.pushNotification !== void 0) {
113
+ obj.pushNotification = PushNotificationConfig.toJSON(message.pushNotification);
114
+ }
115
+ if (message.historyLength !== 0) {
116
+ obj.historyLength = Math.round(message.historyLength);
117
+ }
118
+ if (message.blocking !== false) {
119
+ obj.blocking = message.blocking;
120
+ }
121
+ return obj;
122
+ }
123
+ };
124
+ var Task = {
125
+ fromJSON(object) {
126
+ return {
127
+ id: isSet(object.id) ? globalThis.String(object.id) : "",
128
+ contextId: isSet(object.contextId) ? globalThis.String(object.contextId) : isSet(object.context_id) ? globalThis.String(object.context_id) : "",
129
+ status: isSet(object.status) ? TaskStatus.fromJSON(object.status) : void 0,
130
+ artifacts: globalThis.Array.isArray(object?.artifacts) ? object.artifacts.map((e) => Artifact.fromJSON(e)) : [],
131
+ history: globalThis.Array.isArray(object?.history) ? object.history.map((e) => Message.fromJSON(e)) : [],
132
+ metadata: isObject(object.metadata) ? object.metadata : void 0
133
+ };
134
+ },
135
+ toJSON(message) {
136
+ const obj = {};
137
+ if (message.id !== "") {
138
+ obj.id = message.id;
139
+ }
140
+ if (message.contextId !== "") {
141
+ obj.contextId = message.contextId;
142
+ }
143
+ if (message.status !== void 0) {
144
+ obj.status = TaskStatus.toJSON(message.status);
145
+ }
146
+ if (message.artifacts?.length) {
147
+ obj.artifacts = message.artifacts.map((e) => Artifact.toJSON(e));
148
+ }
149
+ if (message.history?.length) {
150
+ obj.history = message.history.map((e) => Message.toJSON(e));
151
+ }
152
+ if (message.metadata !== void 0) {
153
+ obj.metadata = message.metadata;
154
+ }
155
+ return obj;
156
+ }
157
+ };
158
+ var TaskStatus = {
159
+ fromJSON(object) {
160
+ return {
161
+ state: isSet(object.state) ? taskStateFromJSON(object.state) : 0,
162
+ update: isSet(object.message) ? Message.fromJSON(object.message) : isSet(object.update) ? Message.fromJSON(object.update) : void 0,
163
+ timestamp: isSet(object.timestamp) ? globalThis.String(object.timestamp) : void 0
164
+ };
165
+ },
166
+ toJSON(message) {
167
+ const obj = {};
168
+ if (message.state !== 0) {
169
+ obj.state = taskStateToJSON(message.state);
170
+ }
171
+ if (message.update !== void 0) {
172
+ obj.message = Message.toJSON(message.update);
173
+ }
174
+ if (message.timestamp !== void 0) {
175
+ obj.timestamp = message.timestamp;
176
+ }
177
+ return obj;
178
+ }
179
+ };
180
+ var Part = {
181
+ fromJSON(object) {
182
+ return {
183
+ part: isSet(object.text) ? { $case: "text", value: globalThis.String(object.text) } : isSet(object.file) ? { $case: "file", value: FilePart.fromJSON(object.file) } : isSet(object.data) ? { $case: "data", value: DataPart.fromJSON(object.data) } : void 0
184
+ };
185
+ },
186
+ toJSON(message) {
187
+ const obj = {};
188
+ if (message.part?.$case === "text") {
189
+ obj.text = message.part.value;
190
+ } else if (message.part?.$case === "file") {
191
+ obj.file = FilePart.toJSON(message.part.value);
192
+ } else if (message.part?.$case === "data") {
193
+ obj.data = DataPart.toJSON(message.part.value);
194
+ }
195
+ return obj;
196
+ }
197
+ };
198
+ var FilePart = {
199
+ fromJSON(object) {
200
+ return {
201
+ file: isSet(object.fileWithUri) ? { $case: "fileWithUri", value: globalThis.String(object.fileWithUri) } : isSet(object.file_with_uri) ? { $case: "fileWithUri", value: globalThis.String(object.file_with_uri) } : isSet(object.fileWithBytes) ? { $case: "fileWithBytes", value: Buffer.from(bytesFromBase64(object.fileWithBytes)) } : isSet(object.file_with_bytes) ? { $case: "fileWithBytes", value: Buffer.from(bytesFromBase64(object.file_with_bytes)) } : void 0,
202
+ mimeType: isSet(object.mimeType) ? globalThis.String(object.mimeType) : isSet(object.mime_type) ? globalThis.String(object.mime_type) : ""
203
+ };
204
+ },
205
+ toJSON(message) {
206
+ const obj = {};
207
+ if (message.file?.$case === "fileWithUri") {
208
+ obj.fileWithUri = message.file.value;
209
+ } else if (message.file?.$case === "fileWithBytes") {
210
+ obj.fileWithBytes = base64FromBytes(message.file.value);
211
+ }
212
+ if (message.mimeType !== "") {
213
+ obj.mimeType = message.mimeType;
214
+ }
215
+ return obj;
216
+ }
217
+ };
218
+ var DataPart = {
219
+ fromJSON(object) {
220
+ return { data: isObject(object.data) ? object.data : void 0 };
221
+ },
222
+ toJSON(message) {
223
+ const obj = {};
224
+ if (message.data !== void 0) {
225
+ obj.data = message.data;
226
+ }
227
+ return obj;
228
+ }
229
+ };
230
+ var Message = {
231
+ fromJSON(object) {
232
+ return {
233
+ messageId: isSet(object.messageId) ? globalThis.String(object.messageId) : isSet(object.message_id) ? globalThis.String(object.message_id) : "",
234
+ contextId: isSet(object.contextId) ? globalThis.String(object.contextId) : isSet(object.context_id) ? globalThis.String(object.context_id) : "",
235
+ taskId: isSet(object.taskId) ? globalThis.String(object.taskId) : isSet(object.task_id) ? globalThis.String(object.task_id) : "",
236
+ role: isSet(object.role) ? roleFromJSON(object.role) : 0,
237
+ content: globalThis.Array.isArray(object?.content) ? object.content.map((e) => Part.fromJSON(e)) : [],
238
+ metadata: isObject(object.metadata) ? object.metadata : void 0,
239
+ extensions: globalThis.Array.isArray(object?.extensions) ? object.extensions.map((e) => globalThis.String(e)) : []
240
+ };
241
+ },
242
+ toJSON(message) {
243
+ const obj = {};
244
+ if (message.messageId !== "") {
245
+ obj.messageId = message.messageId;
246
+ }
247
+ if (message.contextId !== "") {
248
+ obj.contextId = message.contextId;
249
+ }
250
+ if (message.taskId !== "") {
251
+ obj.taskId = message.taskId;
252
+ }
253
+ if (message.role !== 0) {
254
+ obj.role = roleToJSON(message.role);
255
+ }
256
+ if (message.content?.length) {
257
+ obj.content = message.content.map((e) => Part.toJSON(e));
258
+ }
259
+ if (message.metadata !== void 0) {
260
+ obj.metadata = message.metadata;
261
+ }
262
+ if (message.extensions?.length) {
263
+ obj.extensions = message.extensions;
264
+ }
265
+ return obj;
266
+ }
267
+ };
268
+ var Artifact = {
269
+ fromJSON(object) {
270
+ return {
271
+ artifactId: isSet(object.artifactId) ? globalThis.String(object.artifactId) : isSet(object.artifact_id) ? globalThis.String(object.artifact_id) : "",
272
+ name: isSet(object.name) ? globalThis.String(object.name) : "",
273
+ description: isSet(object.description) ? globalThis.String(object.description) : "",
274
+ parts: globalThis.Array.isArray(object?.parts) ? object.parts.map((e) => Part.fromJSON(e)) : [],
275
+ metadata: isObject(object.metadata) ? object.metadata : void 0,
276
+ extensions: globalThis.Array.isArray(object?.extensions) ? object.extensions.map((e) => globalThis.String(e)) : []
277
+ };
278
+ },
279
+ toJSON(message) {
280
+ const obj = {};
281
+ if (message.artifactId !== "") {
282
+ obj.artifactId = message.artifactId;
283
+ }
284
+ if (message.name !== "") {
285
+ obj.name = message.name;
286
+ }
287
+ if (message.description !== "") {
288
+ obj.description = message.description;
289
+ }
290
+ if (message.parts?.length) {
291
+ obj.parts = message.parts.map((e) => Part.toJSON(e));
292
+ }
293
+ if (message.metadata !== void 0) {
294
+ obj.metadata = message.metadata;
295
+ }
296
+ if (message.extensions?.length) {
297
+ obj.extensions = message.extensions;
298
+ }
299
+ return obj;
300
+ }
301
+ };
302
+ var TaskStatusUpdateEvent = {
303
+ fromJSON(object) {
304
+ return {
305
+ taskId: isSet(object.taskId) ? globalThis.String(object.taskId) : isSet(object.task_id) ? globalThis.String(object.task_id) : "",
306
+ contextId: isSet(object.contextId) ? globalThis.String(object.contextId) : isSet(object.context_id) ? globalThis.String(object.context_id) : "",
307
+ status: isSet(object.status) ? TaskStatus.fromJSON(object.status) : void 0,
308
+ final: isSet(object.final) ? globalThis.Boolean(object.final) : false,
309
+ metadata: isObject(object.metadata) ? object.metadata : void 0
310
+ };
311
+ },
312
+ toJSON(message) {
313
+ const obj = {};
314
+ if (message.taskId !== "") {
315
+ obj.taskId = message.taskId;
316
+ }
317
+ if (message.contextId !== "") {
318
+ obj.contextId = message.contextId;
319
+ }
320
+ if (message.status !== void 0) {
321
+ obj.status = TaskStatus.toJSON(message.status);
322
+ }
323
+ if (message.final !== false) {
324
+ obj.final = message.final;
325
+ }
326
+ if (message.metadata !== void 0) {
327
+ obj.metadata = message.metadata;
328
+ }
329
+ return obj;
330
+ }
331
+ };
332
+ var TaskArtifactUpdateEvent = {
333
+ fromJSON(object) {
334
+ return {
335
+ taskId: isSet(object.taskId) ? globalThis.String(object.taskId) : isSet(object.task_id) ? globalThis.String(object.task_id) : "",
336
+ contextId: isSet(object.contextId) ? globalThis.String(object.contextId) : isSet(object.context_id) ? globalThis.String(object.context_id) : "",
337
+ artifact: isSet(object.artifact) ? Artifact.fromJSON(object.artifact) : void 0,
338
+ append: isSet(object.append) ? globalThis.Boolean(object.append) : false,
339
+ lastChunk: isSet(object.lastChunk) ? globalThis.Boolean(object.lastChunk) : isSet(object.last_chunk) ? globalThis.Boolean(object.last_chunk) : false,
340
+ metadata: isObject(object.metadata) ? object.metadata : void 0
341
+ };
342
+ },
343
+ toJSON(message) {
344
+ const obj = {};
345
+ if (message.taskId !== "") {
346
+ obj.taskId = message.taskId;
347
+ }
348
+ if (message.contextId !== "") {
349
+ obj.contextId = message.contextId;
350
+ }
351
+ if (message.artifact !== void 0) {
352
+ obj.artifact = Artifact.toJSON(message.artifact);
353
+ }
354
+ if (message.append !== false) {
355
+ obj.append = message.append;
356
+ }
357
+ if (message.lastChunk !== false) {
358
+ obj.lastChunk = message.lastChunk;
359
+ }
360
+ if (message.metadata !== void 0) {
361
+ obj.metadata = message.metadata;
362
+ }
363
+ return obj;
364
+ }
365
+ };
366
+ var PushNotificationConfig = {
367
+ fromJSON(object) {
368
+ return {
369
+ id: isSet(object.id) ? globalThis.String(object.id) : "",
370
+ url: isSet(object.url) ? globalThis.String(object.url) : "",
371
+ token: isSet(object.token) ? globalThis.String(object.token) : "",
372
+ authentication: isSet(object.authentication) ? AuthenticationInfo.fromJSON(object.authentication) : void 0
373
+ };
374
+ },
375
+ toJSON(message) {
376
+ const obj = {};
377
+ if (message.id !== "") {
378
+ obj.id = message.id;
379
+ }
380
+ if (message.url !== "") {
381
+ obj.url = message.url;
382
+ }
383
+ if (message.token !== "") {
384
+ obj.token = message.token;
385
+ }
386
+ if (message.authentication !== void 0) {
387
+ obj.authentication = AuthenticationInfo.toJSON(message.authentication);
388
+ }
389
+ return obj;
390
+ }
391
+ };
392
+ var AuthenticationInfo = {
393
+ fromJSON(object) {
394
+ return {
395
+ schemes: globalThis.Array.isArray(object?.schemes) ? object.schemes.map((e) => globalThis.String(e)) : [],
396
+ credentials: isSet(object.credentials) ? globalThis.String(object.credentials) : ""
397
+ };
398
+ },
399
+ toJSON(message) {
400
+ const obj = {};
401
+ if (message.schemes?.length) {
402
+ obj.schemes = message.schemes;
403
+ }
404
+ if (message.credentials !== "") {
405
+ obj.credentials = message.credentials;
406
+ }
407
+ return obj;
408
+ }
409
+ };
410
+ var AgentInterface = {
411
+ fromJSON(object) {
412
+ return {
413
+ url: isSet(object.url) ? globalThis.String(object.url) : "",
414
+ transport: isSet(object.transport) ? globalThis.String(object.transport) : ""
415
+ };
416
+ },
417
+ toJSON(message) {
418
+ const obj = {};
419
+ if (message.url !== "") {
420
+ obj.url = message.url;
421
+ }
422
+ if (message.transport !== "") {
423
+ obj.transport = message.transport;
424
+ }
425
+ return obj;
426
+ }
427
+ };
428
+ var AgentCard = {
429
+ fromJSON(object) {
430
+ return {
431
+ protocolVersion: isSet(object.protocolVersion) ? globalThis.String(object.protocolVersion) : isSet(object.protocol_version) ? globalThis.String(object.protocol_version) : "",
432
+ name: isSet(object.name) ? globalThis.String(object.name) : "",
433
+ description: isSet(object.description) ? globalThis.String(object.description) : "",
434
+ url: isSet(object.url) ? globalThis.String(object.url) : "",
435
+ preferredTransport: isSet(object.preferredTransport) ? globalThis.String(object.preferredTransport) : isSet(object.preferred_transport) ? globalThis.String(object.preferred_transport) : "",
436
+ additionalInterfaces: globalThis.Array.isArray(object?.additionalInterfaces) ? object.additionalInterfaces.map((e) => AgentInterface.fromJSON(e)) : globalThis.Array.isArray(object?.additional_interfaces) ? object.additional_interfaces.map((e) => AgentInterface.fromJSON(e)) : [],
437
+ provider: isSet(object.provider) ? AgentProvider.fromJSON(object.provider) : void 0,
438
+ version: isSet(object.version) ? globalThis.String(object.version) : "",
439
+ documentationUrl: isSet(object.documentationUrl) ? globalThis.String(object.documentationUrl) : isSet(object.documentation_url) ? globalThis.String(object.documentation_url) : "",
440
+ capabilities: isSet(object.capabilities) ? AgentCapabilities.fromJSON(object.capabilities) : void 0,
441
+ securitySchemes: isObject(object.securitySchemes) ? globalThis.Object.entries(object.securitySchemes).reduce(
442
+ (acc, [key, value]) => {
443
+ acc[key] = SecurityScheme.fromJSON(value);
444
+ return acc;
445
+ },
446
+ {}
447
+ ) : isObject(object.security_schemes) ? globalThis.Object.entries(object.security_schemes).reduce(
448
+ (acc, [key, value]) => {
449
+ acc[key] = SecurityScheme.fromJSON(value);
450
+ return acc;
451
+ },
452
+ {}
453
+ ) : {},
454
+ security: globalThis.Array.isArray(object?.security) ? object.security.map((e) => Security.fromJSON(e)) : [],
455
+ defaultInputModes: globalThis.Array.isArray(object?.defaultInputModes) ? object.defaultInputModes.map((e) => globalThis.String(e)) : globalThis.Array.isArray(object?.default_input_modes) ? object.default_input_modes.map((e) => globalThis.String(e)) : [],
456
+ defaultOutputModes: globalThis.Array.isArray(object?.defaultOutputModes) ? object.defaultOutputModes.map((e) => globalThis.String(e)) : globalThis.Array.isArray(object?.default_output_modes) ? object.default_output_modes.map((e) => globalThis.String(e)) : [],
457
+ skills: globalThis.Array.isArray(object?.skills) ? object.skills.map((e) => AgentSkill.fromJSON(e)) : [],
458
+ supportsAuthenticatedExtendedCard: isSet(object.supportsAuthenticatedExtendedCard) ? globalThis.Boolean(object.supportsAuthenticatedExtendedCard) : isSet(object.supports_authenticated_extended_card) ? globalThis.Boolean(object.supports_authenticated_extended_card) : false,
459
+ signatures: globalThis.Array.isArray(object?.signatures) ? object.signatures.map((e) => AgentCardSignature.fromJSON(e)) : []
460
+ };
461
+ },
462
+ toJSON(message) {
463
+ const obj = {};
464
+ if (message.protocolVersion !== "") {
465
+ obj.protocolVersion = message.protocolVersion;
466
+ }
467
+ if (message.name !== "") {
468
+ obj.name = message.name;
469
+ }
470
+ if (message.description !== "") {
471
+ obj.description = message.description;
472
+ }
473
+ if (message.url !== "") {
474
+ obj.url = message.url;
475
+ }
476
+ if (message.preferredTransport !== "") {
477
+ obj.preferredTransport = message.preferredTransport;
478
+ }
479
+ if (message.additionalInterfaces?.length) {
480
+ obj.additionalInterfaces = message.additionalInterfaces.map((e) => AgentInterface.toJSON(e));
481
+ }
482
+ if (message.provider !== void 0) {
483
+ obj.provider = AgentProvider.toJSON(message.provider);
484
+ }
485
+ if (message.version !== "") {
486
+ obj.version = message.version;
487
+ }
488
+ if (message.documentationUrl !== "") {
489
+ obj.documentationUrl = message.documentationUrl;
490
+ }
491
+ if (message.capabilities !== void 0) {
492
+ obj.capabilities = AgentCapabilities.toJSON(message.capabilities);
493
+ }
494
+ if (message.securitySchemes) {
495
+ const entries = globalThis.Object.entries(message.securitySchemes);
496
+ if (entries.length > 0) {
497
+ obj.securitySchemes = {};
498
+ entries.forEach(([k, v]) => {
499
+ obj.securitySchemes[k] = SecurityScheme.toJSON(v);
500
+ });
501
+ }
502
+ }
503
+ if (message.security?.length) {
504
+ obj.security = message.security.map((e) => Security.toJSON(e));
505
+ }
506
+ if (message.defaultInputModes?.length) {
507
+ obj.defaultInputModes = message.defaultInputModes;
508
+ }
509
+ if (message.defaultOutputModes?.length) {
510
+ obj.defaultOutputModes = message.defaultOutputModes;
511
+ }
512
+ if (message.skills?.length) {
513
+ obj.skills = message.skills.map((e) => AgentSkill.toJSON(e));
514
+ }
515
+ if (message.supportsAuthenticatedExtendedCard !== false) {
516
+ obj.supportsAuthenticatedExtendedCard = message.supportsAuthenticatedExtendedCard;
517
+ }
518
+ if (message.signatures?.length) {
519
+ obj.signatures = message.signatures.map((e) => AgentCardSignature.toJSON(e));
520
+ }
521
+ return obj;
522
+ }
523
+ };
524
+ var AgentProvider = {
525
+ fromJSON(object) {
526
+ return {
527
+ url: isSet(object.url) ? globalThis.String(object.url) : "",
528
+ organization: isSet(object.organization) ? globalThis.String(object.organization) : ""
529
+ };
530
+ },
531
+ toJSON(message) {
532
+ const obj = {};
533
+ if (message.url !== "") {
534
+ obj.url = message.url;
535
+ }
536
+ if (message.organization !== "") {
537
+ obj.organization = message.organization;
538
+ }
539
+ return obj;
540
+ }
541
+ };
542
+ var AgentCapabilities = {
543
+ fromJSON(object) {
544
+ return {
545
+ streaming: isSet(object.streaming) ? globalThis.Boolean(object.streaming) : false,
546
+ pushNotifications: isSet(object.pushNotifications) ? globalThis.Boolean(object.pushNotifications) : isSet(object.push_notifications) ? globalThis.Boolean(object.push_notifications) : false,
547
+ extensions: globalThis.Array.isArray(object?.extensions) ? object.extensions.map((e) => AgentExtension.fromJSON(e)) : []
548
+ };
549
+ },
550
+ toJSON(message) {
551
+ const obj = {};
552
+ if (message.streaming !== false) {
553
+ obj.streaming = message.streaming;
554
+ }
555
+ if (message.pushNotifications !== false) {
556
+ obj.pushNotifications = message.pushNotifications;
557
+ }
558
+ if (message.extensions?.length) {
559
+ obj.extensions = message.extensions.map((e) => AgentExtension.toJSON(e));
560
+ }
561
+ return obj;
562
+ }
563
+ };
564
+ var AgentExtension = {
565
+ fromJSON(object) {
566
+ return {
567
+ uri: isSet(object.uri) ? globalThis.String(object.uri) : "",
568
+ description: isSet(object.description) ? globalThis.String(object.description) : "",
569
+ required: isSet(object.required) ? globalThis.Boolean(object.required) : false,
570
+ params: isObject(object.params) ? object.params : void 0
571
+ };
572
+ },
573
+ toJSON(message) {
574
+ const obj = {};
575
+ if (message.uri !== "") {
576
+ obj.uri = message.uri;
577
+ }
578
+ if (message.description !== "") {
579
+ obj.description = message.description;
580
+ }
581
+ if (message.required !== false) {
582
+ obj.required = message.required;
583
+ }
584
+ if (message.params !== void 0) {
585
+ obj.params = message.params;
586
+ }
587
+ return obj;
588
+ }
589
+ };
590
+ var AgentSkill = {
591
+ fromJSON(object) {
592
+ return {
593
+ id: isSet(object.id) ? globalThis.String(object.id) : "",
594
+ name: isSet(object.name) ? globalThis.String(object.name) : "",
595
+ description: isSet(object.description) ? globalThis.String(object.description) : "",
596
+ tags: globalThis.Array.isArray(object?.tags) ? object.tags.map((e) => globalThis.String(e)) : [],
597
+ examples: globalThis.Array.isArray(object?.examples) ? object.examples.map((e) => globalThis.String(e)) : [],
598
+ inputModes: globalThis.Array.isArray(object?.inputModes) ? object.inputModes.map((e) => globalThis.String(e)) : globalThis.Array.isArray(object?.input_modes) ? object.input_modes.map((e) => globalThis.String(e)) : [],
599
+ outputModes: globalThis.Array.isArray(object?.outputModes) ? object.outputModes.map((e) => globalThis.String(e)) : globalThis.Array.isArray(object?.output_modes) ? object.output_modes.map((e) => globalThis.String(e)) : [],
600
+ security: globalThis.Array.isArray(object?.security) ? object.security.map((e) => Security.fromJSON(e)) : []
601
+ };
602
+ },
603
+ toJSON(message) {
604
+ const obj = {};
605
+ if (message.id !== "") {
606
+ obj.id = message.id;
607
+ }
608
+ if (message.name !== "") {
609
+ obj.name = message.name;
610
+ }
611
+ if (message.description !== "") {
612
+ obj.description = message.description;
613
+ }
614
+ if (message.tags?.length) {
615
+ obj.tags = message.tags;
616
+ }
617
+ if (message.examples?.length) {
618
+ obj.examples = message.examples;
619
+ }
620
+ if (message.inputModes?.length) {
621
+ obj.inputModes = message.inputModes;
622
+ }
623
+ if (message.outputModes?.length) {
624
+ obj.outputModes = message.outputModes;
625
+ }
626
+ if (message.security?.length) {
627
+ obj.security = message.security.map((e) => Security.toJSON(e));
628
+ }
629
+ return obj;
630
+ }
631
+ };
632
+ var AgentCardSignature = {
633
+ fromJSON(object) {
634
+ return {
635
+ protected: isSet(object.protected) ? globalThis.String(object.protected) : "",
636
+ signature: isSet(object.signature) ? globalThis.String(object.signature) : "",
637
+ header: isObject(object.header) ? object.header : void 0
638
+ };
639
+ },
640
+ toJSON(message) {
641
+ const obj = {};
642
+ if (message.protected !== "") {
643
+ obj.protected = message.protected;
644
+ }
645
+ if (message.signature !== "") {
646
+ obj.signature = message.signature;
647
+ }
648
+ if (message.header !== void 0) {
649
+ obj.header = message.header;
650
+ }
651
+ return obj;
652
+ }
653
+ };
654
+ var TaskPushNotificationConfig = {
655
+ fromJSON(object) {
656
+ return {
657
+ name: isSet(object.name) ? globalThis.String(object.name) : "",
658
+ pushNotificationConfig: isSet(object.pushNotificationConfig) ? PushNotificationConfig.fromJSON(object.pushNotificationConfig) : isSet(object.push_notification_config) ? PushNotificationConfig.fromJSON(object.push_notification_config) : void 0
659
+ };
660
+ },
661
+ toJSON(message) {
662
+ const obj = {};
663
+ if (message.name !== "") {
664
+ obj.name = message.name;
665
+ }
666
+ if (message.pushNotificationConfig !== void 0) {
667
+ obj.pushNotificationConfig = PushNotificationConfig.toJSON(message.pushNotificationConfig);
668
+ }
669
+ return obj;
670
+ }
671
+ };
672
+ var StringList = {
673
+ fromJSON(object) {
674
+ return { list: globalThis.Array.isArray(object?.list) ? object.list.map((e) => globalThis.String(e)) : [] };
675
+ },
676
+ toJSON(message) {
677
+ const obj = {};
678
+ if (message.list?.length) {
679
+ obj.list = message.list;
680
+ }
681
+ return obj;
682
+ }
683
+ };
684
+ var Security = {
685
+ fromJSON(object) {
686
+ return {
687
+ schemes: isObject(object.schemes) ? globalThis.Object.entries(object.schemes).reduce(
688
+ (acc, [key, value]) => {
689
+ acc[key] = StringList.fromJSON(value);
690
+ return acc;
691
+ },
692
+ {}
693
+ ) : {}
694
+ };
695
+ },
696
+ toJSON(message) {
697
+ const obj = {};
698
+ if (message.schemes) {
699
+ const entries = globalThis.Object.entries(message.schemes);
700
+ if (entries.length > 0) {
701
+ obj.schemes = {};
702
+ entries.forEach(([k, v]) => {
703
+ obj.schemes[k] = StringList.toJSON(v);
704
+ });
705
+ }
706
+ }
707
+ return obj;
708
+ }
709
+ };
710
+ var SecurityScheme = {
711
+ fromJSON(object) {
712
+ return {
713
+ scheme: isSet(object.apiKeySecurityScheme) ? { $case: "apiKeySecurityScheme", value: APIKeySecurityScheme.fromJSON(object.apiKeySecurityScheme) } : isSet(object.api_key_security_scheme) ? { $case: "apiKeySecurityScheme", value: APIKeySecurityScheme.fromJSON(object.api_key_security_scheme) } : isSet(object.httpAuthSecurityScheme) ? { $case: "httpAuthSecurityScheme", value: HTTPAuthSecurityScheme.fromJSON(object.httpAuthSecurityScheme) } : isSet(object.http_auth_security_scheme) ? { $case: "httpAuthSecurityScheme", value: HTTPAuthSecurityScheme.fromJSON(object.http_auth_security_scheme) } : isSet(object.oauth2SecurityScheme) ? { $case: "oauth2SecurityScheme", value: OAuth2SecurityScheme.fromJSON(object.oauth2SecurityScheme) } : isSet(object.oauth2_security_scheme) ? { $case: "oauth2SecurityScheme", value: OAuth2SecurityScheme.fromJSON(object.oauth2_security_scheme) } : isSet(object.openIdConnectSecurityScheme) ? {
714
+ $case: "openIdConnectSecurityScheme",
715
+ value: OpenIdConnectSecurityScheme.fromJSON(object.openIdConnectSecurityScheme)
716
+ } : isSet(object.open_id_connect_security_scheme) ? {
717
+ $case: "openIdConnectSecurityScheme",
718
+ value: OpenIdConnectSecurityScheme.fromJSON(object.open_id_connect_security_scheme)
719
+ } : isSet(object.mtlsSecurityScheme) ? { $case: "mtlsSecurityScheme", value: MutualTlsSecurityScheme.fromJSON(object.mtlsSecurityScheme) } : isSet(object.mtls_security_scheme) ? { $case: "mtlsSecurityScheme", value: MutualTlsSecurityScheme.fromJSON(object.mtls_security_scheme) } : void 0
720
+ };
721
+ },
722
+ toJSON(message) {
723
+ const obj = {};
724
+ if (message.scheme?.$case === "apiKeySecurityScheme") {
725
+ obj.apiKeySecurityScheme = APIKeySecurityScheme.toJSON(message.scheme.value);
726
+ } else if (message.scheme?.$case === "httpAuthSecurityScheme") {
727
+ obj.httpAuthSecurityScheme = HTTPAuthSecurityScheme.toJSON(message.scheme.value);
728
+ } else if (message.scheme?.$case === "oauth2SecurityScheme") {
729
+ obj.oauth2SecurityScheme = OAuth2SecurityScheme.toJSON(message.scheme.value);
730
+ } else if (message.scheme?.$case === "openIdConnectSecurityScheme") {
731
+ obj.openIdConnectSecurityScheme = OpenIdConnectSecurityScheme.toJSON(message.scheme.value);
732
+ } else if (message.scheme?.$case === "mtlsSecurityScheme") {
733
+ obj.mtlsSecurityScheme = MutualTlsSecurityScheme.toJSON(message.scheme.value);
734
+ }
735
+ return obj;
736
+ }
737
+ };
738
+ var APIKeySecurityScheme = {
739
+ fromJSON(object) {
740
+ return {
741
+ description: isSet(object.description) ? globalThis.String(object.description) : "",
742
+ location: isSet(object.location) ? globalThis.String(object.location) : "",
743
+ name: isSet(object.name) ? globalThis.String(object.name) : ""
744
+ };
745
+ },
746
+ toJSON(message) {
747
+ const obj = {};
748
+ if (message.description !== "") {
749
+ obj.description = message.description;
750
+ }
751
+ if (message.location !== "") {
752
+ obj.location = message.location;
753
+ }
754
+ if (message.name !== "") {
755
+ obj.name = message.name;
756
+ }
757
+ return obj;
758
+ }
759
+ };
760
+ var HTTPAuthSecurityScheme = {
761
+ fromJSON(object) {
762
+ return {
763
+ description: isSet(object.description) ? globalThis.String(object.description) : "",
764
+ scheme: isSet(object.scheme) ? globalThis.String(object.scheme) : "",
765
+ bearerFormat: isSet(object.bearerFormat) ? globalThis.String(object.bearerFormat) : isSet(object.bearer_format) ? globalThis.String(object.bearer_format) : ""
766
+ };
767
+ },
768
+ toJSON(message) {
769
+ const obj = {};
770
+ if (message.description !== "") {
771
+ obj.description = message.description;
772
+ }
773
+ if (message.scheme !== "") {
774
+ obj.scheme = message.scheme;
775
+ }
776
+ if (message.bearerFormat !== "") {
777
+ obj.bearerFormat = message.bearerFormat;
778
+ }
779
+ return obj;
780
+ }
781
+ };
782
+ var OAuth2SecurityScheme = {
783
+ fromJSON(object) {
784
+ return {
785
+ description: isSet(object.description) ? globalThis.String(object.description) : "",
786
+ flows: isSet(object.flows) ? OAuthFlows.fromJSON(object.flows) : void 0,
787
+ oauth2MetadataUrl: isSet(object.oauth2MetadataUrl) ? globalThis.String(object.oauth2MetadataUrl) : isSet(object.oauth2_metadata_url) ? globalThis.String(object.oauth2_metadata_url) : ""
788
+ };
789
+ },
790
+ toJSON(message) {
791
+ const obj = {};
792
+ if (message.description !== "") {
793
+ obj.description = message.description;
794
+ }
795
+ if (message.flows !== void 0) {
796
+ obj.flows = OAuthFlows.toJSON(message.flows);
797
+ }
798
+ if (message.oauth2MetadataUrl !== "") {
799
+ obj.oauth2MetadataUrl = message.oauth2MetadataUrl;
800
+ }
801
+ return obj;
802
+ }
803
+ };
804
+ var OpenIdConnectSecurityScheme = {
805
+ fromJSON(object) {
806
+ return {
807
+ description: isSet(object.description) ? globalThis.String(object.description) : "",
808
+ openIdConnectUrl: isSet(object.openIdConnectUrl) ? globalThis.String(object.openIdConnectUrl) : isSet(object.open_id_connect_url) ? globalThis.String(object.open_id_connect_url) : ""
809
+ };
810
+ },
811
+ toJSON(message) {
812
+ const obj = {};
813
+ if (message.description !== "") {
814
+ obj.description = message.description;
815
+ }
816
+ if (message.openIdConnectUrl !== "") {
817
+ obj.openIdConnectUrl = message.openIdConnectUrl;
818
+ }
819
+ return obj;
820
+ }
821
+ };
822
+ var MutualTlsSecurityScheme = {
823
+ fromJSON(object) {
824
+ return { description: isSet(object.description) ? globalThis.String(object.description) : "" };
825
+ },
826
+ toJSON(message) {
827
+ const obj = {};
828
+ if (message.description !== "") {
829
+ obj.description = message.description;
830
+ }
831
+ return obj;
832
+ }
833
+ };
834
+ var OAuthFlows = {
835
+ fromJSON(object) {
836
+ return {
837
+ flow: isSet(object.authorizationCode) ? { $case: "authorizationCode", value: AuthorizationCodeOAuthFlow.fromJSON(object.authorizationCode) } : isSet(object.authorization_code) ? { $case: "authorizationCode", value: AuthorizationCodeOAuthFlow.fromJSON(object.authorization_code) } : isSet(object.clientCredentials) ? { $case: "clientCredentials", value: ClientCredentialsOAuthFlow.fromJSON(object.clientCredentials) } : isSet(object.client_credentials) ? { $case: "clientCredentials", value: ClientCredentialsOAuthFlow.fromJSON(object.client_credentials) } : isSet(object.implicit) ? { $case: "implicit", value: ImplicitOAuthFlow.fromJSON(object.implicit) } : isSet(object.password) ? { $case: "password", value: PasswordOAuthFlow.fromJSON(object.password) } : void 0
838
+ };
839
+ },
840
+ toJSON(message) {
841
+ const obj = {};
842
+ if (message.flow?.$case === "authorizationCode") {
843
+ obj.authorizationCode = AuthorizationCodeOAuthFlow.toJSON(message.flow.value);
844
+ } else if (message.flow?.$case === "clientCredentials") {
845
+ obj.clientCredentials = ClientCredentialsOAuthFlow.toJSON(message.flow.value);
846
+ } else if (message.flow?.$case === "implicit") {
847
+ obj.implicit = ImplicitOAuthFlow.toJSON(message.flow.value);
848
+ } else if (message.flow?.$case === "password") {
849
+ obj.password = PasswordOAuthFlow.toJSON(message.flow.value);
850
+ }
851
+ return obj;
852
+ }
853
+ };
854
+ var AuthorizationCodeOAuthFlow = {
855
+ fromJSON(object) {
856
+ return {
857
+ authorizationUrl: isSet(object.authorizationUrl) ? globalThis.String(object.authorizationUrl) : isSet(object.authorization_url) ? globalThis.String(object.authorization_url) : "",
858
+ tokenUrl: isSet(object.tokenUrl) ? globalThis.String(object.tokenUrl) : isSet(object.token_url) ? globalThis.String(object.token_url) : "",
859
+ refreshUrl: isSet(object.refreshUrl) ? globalThis.String(object.refreshUrl) : isSet(object.refresh_url) ? globalThis.String(object.refresh_url) : "",
860
+ scopes: isObject(object.scopes) ? globalThis.Object.entries(object.scopes).reduce(
861
+ (acc, [key, value]) => {
862
+ acc[key] = globalThis.String(value);
863
+ return acc;
864
+ },
865
+ {}
866
+ ) : {}
867
+ };
868
+ },
869
+ toJSON(message) {
870
+ const obj = {};
871
+ if (message.authorizationUrl !== "") {
872
+ obj.authorizationUrl = message.authorizationUrl;
873
+ }
874
+ if (message.tokenUrl !== "") {
875
+ obj.tokenUrl = message.tokenUrl;
876
+ }
877
+ if (message.refreshUrl !== "") {
878
+ obj.refreshUrl = message.refreshUrl;
879
+ }
880
+ if (message.scopes) {
881
+ const entries = globalThis.Object.entries(message.scopes);
882
+ if (entries.length > 0) {
883
+ obj.scopes = {};
884
+ entries.forEach(([k, v]) => {
885
+ obj.scopes[k] = v;
886
+ });
887
+ }
888
+ }
889
+ return obj;
890
+ }
891
+ };
892
+ var ClientCredentialsOAuthFlow = {
893
+ fromJSON(object) {
894
+ return {
895
+ tokenUrl: isSet(object.tokenUrl) ? globalThis.String(object.tokenUrl) : isSet(object.token_url) ? globalThis.String(object.token_url) : "",
896
+ refreshUrl: isSet(object.refreshUrl) ? globalThis.String(object.refreshUrl) : isSet(object.refresh_url) ? globalThis.String(object.refresh_url) : "",
897
+ scopes: isObject(object.scopes) ? globalThis.Object.entries(object.scopes).reduce(
898
+ (acc, [key, value]) => {
899
+ acc[key] = globalThis.String(value);
900
+ return acc;
901
+ },
902
+ {}
903
+ ) : {}
904
+ };
905
+ },
906
+ toJSON(message) {
907
+ const obj = {};
908
+ if (message.tokenUrl !== "") {
909
+ obj.tokenUrl = message.tokenUrl;
910
+ }
911
+ if (message.refreshUrl !== "") {
912
+ obj.refreshUrl = message.refreshUrl;
913
+ }
914
+ if (message.scopes) {
915
+ const entries = globalThis.Object.entries(message.scopes);
916
+ if (entries.length > 0) {
917
+ obj.scopes = {};
918
+ entries.forEach(([k, v]) => {
919
+ obj.scopes[k] = v;
920
+ });
921
+ }
922
+ }
923
+ return obj;
924
+ }
925
+ };
926
+ var ImplicitOAuthFlow = {
927
+ fromJSON(object) {
928
+ return {
929
+ authorizationUrl: isSet(object.authorizationUrl) ? globalThis.String(object.authorizationUrl) : isSet(object.authorization_url) ? globalThis.String(object.authorization_url) : "",
930
+ refreshUrl: isSet(object.refreshUrl) ? globalThis.String(object.refreshUrl) : isSet(object.refresh_url) ? globalThis.String(object.refresh_url) : "",
931
+ scopes: isObject(object.scopes) ? globalThis.Object.entries(object.scopes).reduce(
932
+ (acc, [key, value]) => {
933
+ acc[key] = globalThis.String(value);
934
+ return acc;
935
+ },
936
+ {}
937
+ ) : {}
938
+ };
939
+ },
940
+ toJSON(message) {
941
+ const obj = {};
942
+ if (message.authorizationUrl !== "") {
943
+ obj.authorizationUrl = message.authorizationUrl;
944
+ }
945
+ if (message.refreshUrl !== "") {
946
+ obj.refreshUrl = message.refreshUrl;
947
+ }
948
+ if (message.scopes) {
949
+ const entries = globalThis.Object.entries(message.scopes);
950
+ if (entries.length > 0) {
951
+ obj.scopes = {};
952
+ entries.forEach(([k, v]) => {
953
+ obj.scopes[k] = v;
954
+ });
955
+ }
956
+ }
957
+ return obj;
958
+ }
959
+ };
960
+ var PasswordOAuthFlow = {
961
+ fromJSON(object) {
962
+ return {
963
+ tokenUrl: isSet(object.tokenUrl) ? globalThis.String(object.tokenUrl) : isSet(object.token_url) ? globalThis.String(object.token_url) : "",
964
+ refreshUrl: isSet(object.refreshUrl) ? globalThis.String(object.refreshUrl) : isSet(object.refresh_url) ? globalThis.String(object.refresh_url) : "",
965
+ scopes: isObject(object.scopes) ? globalThis.Object.entries(object.scopes).reduce(
966
+ (acc, [key, value]) => {
967
+ acc[key] = globalThis.String(value);
968
+ return acc;
969
+ },
970
+ {}
971
+ ) : {}
972
+ };
973
+ },
974
+ toJSON(message) {
975
+ const obj = {};
976
+ if (message.tokenUrl !== "") {
977
+ obj.tokenUrl = message.tokenUrl;
978
+ }
979
+ if (message.refreshUrl !== "") {
980
+ obj.refreshUrl = message.refreshUrl;
981
+ }
982
+ if (message.scopes) {
983
+ const entries = globalThis.Object.entries(message.scopes);
984
+ if (entries.length > 0) {
985
+ obj.scopes = {};
986
+ entries.forEach(([k, v]) => {
987
+ obj.scopes[k] = v;
988
+ });
989
+ }
990
+ }
991
+ return obj;
992
+ }
993
+ };
994
+ var SendMessageRequest = {
995
+ fromJSON(object) {
996
+ return {
997
+ request: isSet(object.message) ? Message.fromJSON(object.message) : isSet(object.request) ? Message.fromJSON(object.request) : void 0,
998
+ configuration: isSet(object.configuration) ? SendMessageConfiguration.fromJSON(object.configuration) : void 0,
999
+ metadata: isObject(object.metadata) ? object.metadata : void 0
1000
+ };
1001
+ },
1002
+ toJSON(message) {
1003
+ const obj = {};
1004
+ if (message.request !== void 0) {
1005
+ obj.message = Message.toJSON(message.request);
1006
+ }
1007
+ if (message.configuration !== void 0) {
1008
+ obj.configuration = SendMessageConfiguration.toJSON(message.configuration);
1009
+ }
1010
+ if (message.metadata !== void 0) {
1011
+ obj.metadata = message.metadata;
1012
+ }
1013
+ return obj;
1014
+ }
1015
+ };
1016
+ var SendMessageResponse = {
1017
+ fromJSON(object) {
1018
+ return {
1019
+ payload: isSet(object.task) ? { $case: "task", value: Task.fromJSON(object.task) } : isSet(object.message) ? { $case: "msg", value: Message.fromJSON(object.message) } : isSet(object.msg) ? { $case: "msg", value: Message.fromJSON(object.msg) } : void 0
1020
+ };
1021
+ },
1022
+ toJSON(message) {
1023
+ const obj = {};
1024
+ if (message.payload?.$case === "task") {
1025
+ obj.task = Task.toJSON(message.payload.value);
1026
+ } else if (message.payload?.$case === "msg") {
1027
+ obj.message = Message.toJSON(message.payload.value);
1028
+ }
1029
+ return obj;
1030
+ }
1031
+ };
1032
+ var StreamResponse = {
1033
+ fromJSON(object) {
1034
+ return {
1035
+ payload: isSet(object.task) ? { $case: "task", value: Task.fromJSON(object.task) } : isSet(object.message) ? { $case: "msg", value: Message.fromJSON(object.message) } : isSet(object.msg) ? { $case: "msg", value: Message.fromJSON(object.msg) } : isSet(object.statusUpdate) ? { $case: "statusUpdate", value: TaskStatusUpdateEvent.fromJSON(object.statusUpdate) } : isSet(object.status_update) ? { $case: "statusUpdate", value: TaskStatusUpdateEvent.fromJSON(object.status_update) } : isSet(object.artifactUpdate) ? { $case: "artifactUpdate", value: TaskArtifactUpdateEvent.fromJSON(object.artifactUpdate) } : isSet(object.artifact_update) ? { $case: "artifactUpdate", value: TaskArtifactUpdateEvent.fromJSON(object.artifact_update) } : void 0
1036
+ };
1037
+ },
1038
+ toJSON(message) {
1039
+ const obj = {};
1040
+ if (message.payload?.$case === "task") {
1041
+ obj.task = Task.toJSON(message.payload.value);
1042
+ } else if (message.payload?.$case === "msg") {
1043
+ obj.message = Message.toJSON(message.payload.value);
1044
+ } else if (message.payload?.$case === "statusUpdate") {
1045
+ obj.statusUpdate = TaskStatusUpdateEvent.toJSON(message.payload.value);
1046
+ } else if (message.payload?.$case === "artifactUpdate") {
1047
+ obj.artifactUpdate = TaskArtifactUpdateEvent.toJSON(message.payload.value);
1048
+ }
1049
+ return obj;
1050
+ }
1051
+ };
1052
+ var ListTaskPushNotificationConfigResponse = {
1053
+ fromJSON(object) {
1054
+ return {
1055
+ configs: globalThis.Array.isArray(object?.configs) ? object.configs.map((e) => TaskPushNotificationConfig.fromJSON(e)) : [],
1056
+ nextPageToken: isSet(object.nextPageToken) ? globalThis.String(object.nextPageToken) : isSet(object.next_page_token) ? globalThis.String(object.next_page_token) : ""
1057
+ };
1058
+ },
1059
+ toJSON(message) {
1060
+ const obj = {};
1061
+ if (message.configs?.length) {
1062
+ obj.configs = message.configs.map((e) => TaskPushNotificationConfig.toJSON(e));
1063
+ }
1064
+ if (message.nextPageToken !== "") {
1065
+ obj.nextPageToken = message.nextPageToken;
1066
+ }
1067
+ return obj;
1068
+ }
1069
+ };
1070
+ function bytesFromBase64(b64) {
1071
+ return Uint8Array.from(globalThis.Buffer.from(b64, "base64"));
1072
+ }
1073
+ function base64FromBytes(arr) {
1074
+ return globalThis.Buffer.from(arr).toString("base64");
1075
+ }
1076
+ function isObject(value) {
1077
+ return typeof value === "object" && value !== null;
1078
+ }
1079
+ function isSet(value) {
1080
+ return value !== null && value !== void 0;
1081
+ }
1082
+
1083
+ // src/types/converters/id_decoding.ts
1084
+ var CONFIG_REGEX = /^tasks\/([^/]+)\/pushNotificationConfigs\/([^/]+)$/;
1085
+ var TASK_ONLY_REGEX = /^tasks\/([^/]+)(?:\/|$)/;
1086
+ var extractTaskId = (name) => {
1087
+ const match = name.match(TASK_ONLY_REGEX);
1088
+ if (!match) {
1089
+ throw A2AError.invalidParams(`Invalid or missing task ID in: "${name}"`);
1090
+ }
1091
+ return match[1];
1092
+ };
1093
+ var generateTaskName = (taskId) => {
1094
+ return `tasks/${taskId}`;
1095
+ };
1096
+ var extractTaskAndPushNotificationConfigId = (name) => {
1097
+ const match = name.match(CONFIG_REGEX);
1098
+ if (!match) {
1099
+ throw A2AError.invalidParams(`Invalid or missing config ID in: "${name}"`);
1100
+ }
1101
+ return { taskId: match[1], configId: match[2] };
1102
+ };
1103
+ var generatePushNotificationConfigName = (taskId, configId) => {
1104
+ return `tasks/${taskId}/pushNotificationConfigs/${configId}`;
1105
+ };
1106
+
1107
+ // src/types/converters/to_proto.ts
1108
+ var ToProto = class _ToProto {
1109
+ static agentCard(agentCard) {
1110
+ return {
1111
+ protocolVersion: agentCard.protocolVersion,
1112
+ name: agentCard.name,
1113
+ description: agentCard.description,
1114
+ url: agentCard.url,
1115
+ preferredTransport: agentCard.preferredTransport ?? "",
1116
+ additionalInterfaces: agentCard.additionalInterfaces?.map((i) => _ToProto.agentInterface(i)) ?? [],
1117
+ provider: _ToProto.agentProvider(agentCard.provider),
1118
+ version: agentCard.version,
1119
+ documentationUrl: agentCard.documentationUrl ?? "",
1120
+ capabilities: _ToProto.agentCapabilities(agentCard.capabilities),
1121
+ securitySchemes: agentCard.securitySchemes ? Object.fromEntries(
1122
+ Object.entries(agentCard.securitySchemes).map(([key, value]) => [
1123
+ key,
1124
+ _ToProto.securityScheme(value)
1125
+ ])
1126
+ ) : {},
1127
+ security: agentCard.security?.map((s) => _ToProto.security(s)) ?? [],
1128
+ defaultInputModes: agentCard.defaultInputModes,
1129
+ defaultOutputModes: agentCard.defaultOutputModes,
1130
+ skills: agentCard.skills.map((s) => _ToProto.agentSkill(s)),
1131
+ supportsAuthenticatedExtendedCard: agentCard.supportsAuthenticatedExtendedCard,
1132
+ signatures: agentCard.signatures?.map((s) => _ToProto.agentCardSignature(s)) ?? []
1133
+ };
1134
+ }
1135
+ static agentCardSignature(signatures) {
1136
+ return {
1137
+ protected: signatures.protected,
1138
+ signature: signatures.signature,
1139
+ header: signatures.header
1140
+ };
1141
+ }
1142
+ static agentSkill(skill) {
1143
+ return {
1144
+ id: skill.id,
1145
+ name: skill.name,
1146
+ description: skill.description,
1147
+ tags: skill.tags ?? [],
1148
+ examples: skill.examples ?? [],
1149
+ inputModes: skill.inputModes ?? [],
1150
+ outputModes: skill.outputModes ?? [],
1151
+ security: skill.security ? skill.security.map((s) => _ToProto.security(s)) : []
1152
+ };
1153
+ }
1154
+ static security(security) {
1155
+ return {
1156
+ schemes: Object.fromEntries(
1157
+ Object.entries(security).map(([key, value]) => {
1158
+ return [key, { list: value }];
1159
+ })
1160
+ )
1161
+ };
1162
+ }
1163
+ static securityScheme(scheme) {
1164
+ switch (scheme.type) {
1165
+ case "apiKey":
1166
+ return {
1167
+ scheme: {
1168
+ $case: "apiKeySecurityScheme",
1169
+ value: {
1170
+ name: scheme.name,
1171
+ location: scheme.in,
1172
+ description: scheme.description ?? ""
1173
+ }
1174
+ }
1175
+ };
1176
+ case "http":
1177
+ return {
1178
+ scheme: {
1179
+ $case: "httpAuthSecurityScheme",
1180
+ value: {
1181
+ description: scheme.description ?? "",
1182
+ scheme: scheme.scheme,
1183
+ bearerFormat: scheme.bearerFormat ?? ""
1184
+ }
1185
+ }
1186
+ };
1187
+ case "mutualTLS":
1188
+ return {
1189
+ scheme: {
1190
+ $case: "mtlsSecurityScheme",
1191
+ value: {
1192
+ description: scheme.description ?? ""
1193
+ }
1194
+ }
1195
+ };
1196
+ case "oauth2":
1197
+ return {
1198
+ scheme: {
1199
+ $case: "oauth2SecurityScheme",
1200
+ value: {
1201
+ description: scheme.description ?? "",
1202
+ flows: _ToProto.oauthFlows(scheme.flows),
1203
+ oauth2MetadataUrl: scheme.oauth2MetadataUrl ?? ""
1204
+ }
1205
+ }
1206
+ };
1207
+ case "openIdConnect":
1208
+ return {
1209
+ scheme: {
1210
+ $case: "openIdConnectSecurityScheme",
1211
+ value: {
1212
+ description: scheme.description ?? "",
1213
+ openIdConnectUrl: scheme.openIdConnectUrl
1214
+ }
1215
+ }
1216
+ };
1217
+ default:
1218
+ throw A2AError.internalError(`Unsupported security scheme type`);
1219
+ }
1220
+ }
1221
+ static oauthFlows(flows) {
1222
+ if (flows.implicit) {
1223
+ return {
1224
+ flow: {
1225
+ $case: "implicit",
1226
+ value: {
1227
+ authorizationUrl: flows.implicit.authorizationUrl,
1228
+ scopes: flows.implicit.scopes,
1229
+ refreshUrl: flows.implicit.refreshUrl ?? ""
1230
+ }
1231
+ }
1232
+ };
1233
+ } else if (flows.password) {
1234
+ return {
1235
+ flow: {
1236
+ $case: "password",
1237
+ value: {
1238
+ tokenUrl: flows.password.tokenUrl,
1239
+ scopes: flows.password.scopes,
1240
+ refreshUrl: flows.password.refreshUrl ?? ""
1241
+ }
1242
+ }
1243
+ };
1244
+ } else if (flows.clientCredentials) {
1245
+ return {
1246
+ flow: {
1247
+ $case: "clientCredentials",
1248
+ value: {
1249
+ tokenUrl: flows.clientCredentials.tokenUrl,
1250
+ scopes: flows.clientCredentials.scopes,
1251
+ refreshUrl: flows.clientCredentials.refreshUrl ?? ""
1252
+ }
1253
+ }
1254
+ };
1255
+ } else if (flows.authorizationCode) {
1256
+ return {
1257
+ flow: {
1258
+ $case: "authorizationCode",
1259
+ value: {
1260
+ authorizationUrl: flows.authorizationCode.authorizationUrl,
1261
+ tokenUrl: flows.authorizationCode.tokenUrl,
1262
+ scopes: flows.authorizationCode.scopes,
1263
+ refreshUrl: flows.authorizationCode.refreshUrl ?? ""
1264
+ }
1265
+ }
1266
+ };
1267
+ } else {
1268
+ throw A2AError.internalError(`Unsupported OAuth flows`);
1269
+ }
1270
+ }
1271
+ static agentInterface(agentInterface) {
1272
+ return {
1273
+ transport: agentInterface.transport,
1274
+ url: agentInterface.url
1275
+ };
1276
+ }
1277
+ static agentProvider(agentProvider) {
1278
+ if (!agentProvider) {
1279
+ return void 0;
1280
+ }
1281
+ return {
1282
+ url: agentProvider.url,
1283
+ organization: agentProvider.organization
1284
+ };
1285
+ }
1286
+ static agentCapabilities(capabilities) {
1287
+ return {
1288
+ streaming: capabilities.streaming,
1289
+ pushNotifications: capabilities.pushNotifications,
1290
+ extensions: capabilities.extensions ? capabilities.extensions.map((e) => _ToProto.agentExtension(e)) : []
1291
+ };
1292
+ }
1293
+ static agentExtension(extension) {
1294
+ return {
1295
+ uri: extension.uri,
1296
+ description: extension.description ?? "",
1297
+ required: extension.required ?? false,
1298
+ params: extension.params
1299
+ };
1300
+ }
1301
+ static listTaskPushNotificationConfig(config) {
1302
+ return {
1303
+ configs: config.map((c) => _ToProto.taskPushNotificationConfig(c)),
1304
+ nextPageToken: ""
1305
+ };
1306
+ }
1307
+ static getTaskPushNotificationConfigParams(config) {
1308
+ return {
1309
+ name: generatePushNotificationConfigName(config.id, config.pushNotificationConfigId)
1310
+ };
1311
+ }
1312
+ static listTaskPushNotificationConfigParams(config) {
1313
+ return {
1314
+ parent: generateTaskName(config.id),
1315
+ pageToken: "",
1316
+ pageSize: 0
1317
+ };
1318
+ }
1319
+ static deleteTaskPushNotificationConfigParams(config) {
1320
+ return {
1321
+ name: generatePushNotificationConfigName(config.id, config.pushNotificationConfigId)
1322
+ };
1323
+ }
1324
+ static taskPushNotificationConfig(config) {
1325
+ return {
1326
+ name: generatePushNotificationConfigName(
1327
+ config.taskId,
1328
+ config.pushNotificationConfig.id ?? ""
1329
+ ),
1330
+ pushNotificationConfig: _ToProto.pushNotificationConfig(config.pushNotificationConfig)
1331
+ };
1332
+ }
1333
+ static taskPushNotificationConfigCreate(config) {
1334
+ return {
1335
+ parent: generateTaskName(config.taskId),
1336
+ config: _ToProto.taskPushNotificationConfig(config),
1337
+ configId: config.pushNotificationConfig.id
1338
+ };
1339
+ }
1340
+ static pushNotificationConfig(config) {
1341
+ if (!config) {
1342
+ return void 0;
1343
+ }
1344
+ return {
1345
+ id: config.id ?? "",
1346
+ url: config.url,
1347
+ token: config.token ?? "",
1348
+ authentication: _ToProto.pushNotificationAuthenticationInfo(config.authentication)
1349
+ };
1350
+ }
1351
+ static pushNotificationAuthenticationInfo(authInfo) {
1352
+ if (!authInfo) {
1353
+ return void 0;
1354
+ }
1355
+ return {
1356
+ schemes: authInfo.schemes,
1357
+ credentials: authInfo.credentials ?? ""
1358
+ };
1359
+ }
1360
+ static messageStreamResult(event) {
1361
+ if (event.kind === "message") {
1362
+ return {
1363
+ payload: {
1364
+ $case: "msg",
1365
+ value: _ToProto.message(event)
1366
+ }
1367
+ };
1368
+ } else if (event.kind === "task") {
1369
+ return {
1370
+ payload: {
1371
+ $case: "task",
1372
+ value: _ToProto.task(event)
1373
+ }
1374
+ };
1375
+ } else if (event.kind === "status-update") {
1376
+ return {
1377
+ payload: {
1378
+ $case: "statusUpdate",
1379
+ value: _ToProto.taskStatusUpdateEvent(event)
1380
+ }
1381
+ };
1382
+ } else if (event.kind === "artifact-update") {
1383
+ return {
1384
+ payload: {
1385
+ $case: "artifactUpdate",
1386
+ value: _ToProto.taskArtifactUpdateEvent(event)
1387
+ }
1388
+ };
1389
+ } else {
1390
+ throw A2AError.internalError("Invalid event type");
1391
+ }
1392
+ }
1393
+ static taskStatusUpdateEvent(event) {
1394
+ return {
1395
+ taskId: event.taskId,
1396
+ status: _ToProto.taskStatus(event.status),
1397
+ contextId: event.contextId,
1398
+ metadata: event.metadata,
1399
+ final: event.final
1400
+ };
1401
+ }
1402
+ static taskArtifactUpdateEvent(event) {
1403
+ return {
1404
+ taskId: event.taskId,
1405
+ artifact: _ToProto.artifact(event.artifact),
1406
+ contextId: event.contextId,
1407
+ metadata: event.metadata,
1408
+ append: event.append,
1409
+ lastChunk: event.lastChunk
1410
+ };
1411
+ }
1412
+ static messageSendResult(params) {
1413
+ if (params.kind === "message") {
1414
+ return {
1415
+ payload: {
1416
+ $case: "msg",
1417
+ value: _ToProto.message(params)
1418
+ }
1419
+ };
1420
+ } else if (params.kind === "task") {
1421
+ return {
1422
+ payload: {
1423
+ $case: "task",
1424
+ value: _ToProto.task(params)
1425
+ }
1426
+ };
1427
+ }
1428
+ }
1429
+ static message(message) {
1430
+ if (!message) {
1431
+ return void 0;
1432
+ }
1433
+ return {
1434
+ messageId: message.messageId,
1435
+ content: message.parts.map((p) => _ToProto.part(p)),
1436
+ contextId: message.contextId ?? "",
1437
+ taskId: message.taskId ?? "",
1438
+ role: _ToProto.role(message.role),
1439
+ metadata: message.metadata,
1440
+ extensions: message.extensions ?? []
1441
+ };
1442
+ }
1443
+ static role(role) {
1444
+ switch (role) {
1445
+ case "agent":
1446
+ return 2 /* ROLE_AGENT */;
1447
+ case "user":
1448
+ return 1 /* ROLE_USER */;
1449
+ default:
1450
+ throw A2AError.internalError(`Invalid role`);
1451
+ }
1452
+ }
1453
+ static task(task) {
1454
+ return {
1455
+ id: task.id,
1456
+ contextId: task.contextId,
1457
+ status: _ToProto.taskStatus(task.status),
1458
+ artifacts: task.artifacts?.map((a) => _ToProto.artifact(a)) ?? [],
1459
+ history: task.history?.map((m) => _ToProto.message(m)) ?? [],
1460
+ metadata: task.metadata
1461
+ };
1462
+ }
1463
+ static taskStatus(status) {
1464
+ return {
1465
+ state: _ToProto.taskState(status.state),
1466
+ update: _ToProto.message(status.message),
1467
+ timestamp: status.timestamp
1468
+ };
1469
+ }
1470
+ static artifact(artifact) {
1471
+ return {
1472
+ artifactId: artifact.artifactId,
1473
+ name: artifact.name ?? "",
1474
+ description: artifact.description ?? "",
1475
+ parts: artifact.parts.map((p) => _ToProto.part(p)),
1476
+ metadata: artifact.metadata,
1477
+ extensions: artifact.extensions ? artifact.extensions : []
1478
+ };
1479
+ }
1480
+ static taskState(state) {
1481
+ switch (state) {
1482
+ case "submitted":
1483
+ return 1 /* TASK_STATE_SUBMITTED */;
1484
+ case "working":
1485
+ return 2 /* TASK_STATE_WORKING */;
1486
+ case "input-required":
1487
+ return 6 /* TASK_STATE_INPUT_REQUIRED */;
1488
+ case "rejected":
1489
+ return 7 /* TASK_STATE_REJECTED */;
1490
+ case "auth-required":
1491
+ return 8 /* TASK_STATE_AUTH_REQUIRED */;
1492
+ case "completed":
1493
+ return 3 /* TASK_STATE_COMPLETED */;
1494
+ case "failed":
1495
+ return 4 /* TASK_STATE_FAILED */;
1496
+ case "canceled":
1497
+ return 5 /* TASK_STATE_CANCELLED */;
1498
+ case "unknown":
1499
+ return 0 /* TASK_STATE_UNSPECIFIED */;
1500
+ default:
1501
+ return -1 /* UNRECOGNIZED */;
1502
+ }
1503
+ }
1504
+ static part(part) {
1505
+ if (part.kind === "text") {
1506
+ return {
1507
+ part: { $case: "text", value: part.text }
1508
+ };
1509
+ }
1510
+ if (part.kind === "file") {
1511
+ let filePart;
1512
+ if ("uri" in part.file) {
1513
+ filePart = {
1514
+ file: { $case: "fileWithUri", value: part.file.uri },
1515
+ mimeType: part.file.mimeType
1516
+ };
1517
+ } else if ("bytes" in part.file) {
1518
+ filePart = {
1519
+ file: { $case: "fileWithBytes", value: Buffer.from(part.file.bytes, "base64") },
1520
+ mimeType: part.file.mimeType
1521
+ };
1522
+ } else {
1523
+ throw A2AError.internalError("Invalid file part");
1524
+ }
1525
+ return {
1526
+ part: { $case: "file", value: filePart }
1527
+ };
1528
+ }
1529
+ if (part.kind === "data") {
1530
+ return {
1531
+ part: { $case: "data", value: { data: part.data } }
1532
+ };
1533
+ }
1534
+ throw A2AError.internalError("Invalid part type");
1535
+ }
1536
+ static messageSendParams(params) {
1537
+ return {
1538
+ request: _ToProto.message(params.message),
1539
+ configuration: _ToProto.configuration(params.configuration),
1540
+ metadata: params.metadata
1541
+ };
1542
+ }
1543
+ static configuration(configuration) {
1544
+ if (!configuration) {
1545
+ return void 0;
1546
+ }
1547
+ return {
1548
+ blocking: configuration.blocking,
1549
+ acceptedOutputModes: configuration.acceptedOutputModes ?? [],
1550
+ pushNotification: _ToProto.pushNotificationConfig(configuration.pushNotificationConfig),
1551
+ historyLength: configuration.historyLength ?? 0
1552
+ };
1553
+ }
1554
+ static taskQueryParams(params) {
1555
+ return {
1556
+ name: generateTaskName(params.id),
1557
+ historyLength: params.historyLength ?? 0
1558
+ };
1559
+ }
1560
+ static cancelTaskRequest(params) {
1561
+ return {
1562
+ name: generateTaskName(params.id)
1563
+ };
1564
+ }
1565
+ static taskIdParams(params) {
1566
+ return {
1567
+ name: generateTaskName(params.id)
1568
+ };
1569
+ }
1570
+ static getAgentCardRequest() {
1571
+ return {};
1572
+ }
1573
+ };
1574
+
1575
+ // src/types/converters/from_proto.ts
1576
+ var FromProto = class _FromProto {
1577
+ static taskQueryParams(request) {
1578
+ return {
1579
+ id: extractTaskId(request.name),
1580
+ historyLength: request.historyLength
1581
+ };
1582
+ }
1583
+ static taskIdParams(request) {
1584
+ return {
1585
+ id: extractTaskId(request.name)
1586
+ };
1587
+ }
1588
+ static getTaskPushNotificationConfigParams(request) {
1589
+ const { taskId, configId } = extractTaskAndPushNotificationConfigId(request.name);
1590
+ return {
1591
+ id: taskId,
1592
+ pushNotificationConfigId: configId
1593
+ };
1594
+ }
1595
+ static listTaskPushNotificationConfigParams(request) {
1596
+ return {
1597
+ id: extractTaskId(request.parent)
1598
+ };
1599
+ }
1600
+ static createTaskPushNotificationConfig(request) {
1601
+ if (!request.config?.pushNotificationConfig) {
1602
+ throw A2AError.invalidParams(
1603
+ "Request must include a `config` object with a `pushNotificationConfig`"
1604
+ );
1605
+ }
1606
+ return {
1607
+ taskId: extractTaskId(request.parent),
1608
+ pushNotificationConfig: _FromProto.pushNotificationConfig(
1609
+ request.config.pushNotificationConfig
1610
+ )
1611
+ };
1612
+ }
1613
+ static deleteTaskPushNotificationConfigParams(request) {
1614
+ const { taskId, configId } = extractTaskAndPushNotificationConfigId(request.name);
1615
+ return {
1616
+ id: taskId,
1617
+ pushNotificationConfigId: configId
1618
+ };
1619
+ }
1620
+ static message(message) {
1621
+ if (!message) {
1622
+ return void 0;
1623
+ }
1624
+ return {
1625
+ kind: "message",
1626
+ messageId: message.messageId,
1627
+ parts: message.content.map((p) => _FromProto.part(p)),
1628
+ contextId: message.contextId || void 0,
1629
+ taskId: message.taskId || void 0,
1630
+ role: _FromProto.role(message.role),
1631
+ metadata: message.metadata,
1632
+ extensions: message.extensions
1633
+ };
1634
+ }
1635
+ static role(role) {
1636
+ switch (role) {
1637
+ case 2 /* ROLE_AGENT */:
1638
+ return "agent";
1639
+ case 1 /* ROLE_USER */:
1640
+ return "user";
1641
+ default:
1642
+ throw A2AError.invalidParams(`Invalid role: ${role}`);
1643
+ }
1644
+ }
1645
+ static messageSendConfiguration(configuration) {
1646
+ if (!configuration) {
1647
+ return void 0;
1648
+ }
1649
+ return {
1650
+ blocking: configuration.blocking,
1651
+ acceptedOutputModes: configuration.acceptedOutputModes,
1652
+ pushNotificationConfig: _FromProto.pushNotificationConfig(configuration.pushNotification)
1653
+ };
1654
+ }
1655
+ static pushNotificationConfig(config) {
1656
+ if (!config) {
1657
+ return void 0;
1658
+ }
1659
+ return {
1660
+ id: config.id,
1661
+ url: config.url,
1662
+ token: config.token || void 0,
1663
+ authentication: _FromProto.pushNotificationAuthenticationInfo(config.authentication)
1664
+ };
1665
+ }
1666
+ static pushNotificationAuthenticationInfo(authInfo) {
1667
+ if (!authInfo) {
1668
+ return void 0;
1669
+ }
1670
+ return {
1671
+ schemes: authInfo.schemes,
1672
+ credentials: authInfo.credentials
1673
+ };
1674
+ }
1675
+ static part(part) {
1676
+ if (part.part?.$case === "text") {
1677
+ return {
1678
+ kind: "text",
1679
+ text: part.part.value
1680
+ };
1681
+ }
1682
+ if (part.part?.$case === "file") {
1683
+ const filePart = part.part.value;
1684
+ if (filePart.file?.$case === "fileWithUri") {
1685
+ return {
1686
+ kind: "file",
1687
+ file: {
1688
+ uri: filePart.file.value,
1689
+ mimeType: filePart.mimeType
1690
+ }
1691
+ };
1692
+ } else if (filePart.file?.$case === "fileWithBytes") {
1693
+ return {
1694
+ kind: "file",
1695
+ file: {
1696
+ bytes: filePart.file.value.toString("base64"),
1697
+ mimeType: filePart.mimeType
1698
+ }
1699
+ };
1700
+ }
1701
+ throw A2AError.invalidParams("Invalid file part type");
1702
+ }
1703
+ if (part.part?.$case === "data") {
1704
+ return {
1705
+ kind: "data",
1706
+ data: part.part.value.data
1707
+ };
1708
+ }
1709
+ throw A2AError.invalidParams("Invalid part type");
1710
+ }
1711
+ static messageSendParams(request) {
1712
+ return {
1713
+ message: _FromProto.message(request.request),
1714
+ configuration: _FromProto.messageSendConfiguration(request.configuration),
1715
+ metadata: request.metadata
1716
+ };
1717
+ }
1718
+ static sendMessageResult(response) {
1719
+ if (response.payload?.$case === "task") {
1720
+ return _FromProto.task(response.payload.value);
1721
+ } else if (response.payload?.$case === "msg") {
1722
+ return _FromProto.message(response.payload.value);
1723
+ }
1724
+ throw A2AError.invalidParams("Invalid SendMessageResponse: missing result");
1725
+ }
1726
+ static task(task) {
1727
+ return {
1728
+ kind: "task",
1729
+ id: task.id,
1730
+ status: _FromProto.taskStatus(task.status),
1731
+ contextId: task.contextId,
1732
+ artifacts: task.artifacts?.map((a) => _FromProto.artifact(a)),
1733
+ history: task.history?.map((h) => _FromProto.message(h)),
1734
+ metadata: task.metadata
1735
+ };
1736
+ }
1737
+ static taskStatus(status) {
1738
+ return {
1739
+ message: _FromProto.message(status.update),
1740
+ state: _FromProto.taskState(status.state),
1741
+ timestamp: status.timestamp
1742
+ };
1743
+ }
1744
+ static taskState(state) {
1745
+ switch (state) {
1746
+ case 1 /* TASK_STATE_SUBMITTED */:
1747
+ return "submitted";
1748
+ case 2 /* TASK_STATE_WORKING */:
1749
+ return "working";
1750
+ case 6 /* TASK_STATE_INPUT_REQUIRED */:
1751
+ return "input-required";
1752
+ case 3 /* TASK_STATE_COMPLETED */:
1753
+ return "completed";
1754
+ case 5 /* TASK_STATE_CANCELLED */:
1755
+ return "canceled";
1756
+ case 4 /* TASK_STATE_FAILED */:
1757
+ return "failed";
1758
+ case 7 /* TASK_STATE_REJECTED */:
1759
+ return "rejected";
1760
+ case 8 /* TASK_STATE_AUTH_REQUIRED */:
1761
+ return "auth-required";
1762
+ case 0 /* TASK_STATE_UNSPECIFIED */:
1763
+ return "unknown";
1764
+ default:
1765
+ throw A2AError.invalidParams(`Invalid task state: ${state}`);
1766
+ }
1767
+ }
1768
+ static artifact(artifact) {
1769
+ return {
1770
+ artifactId: artifact.artifactId,
1771
+ name: artifact.name || void 0,
1772
+ description: artifact.description || void 0,
1773
+ parts: artifact.parts.map((p) => _FromProto.part(p)),
1774
+ metadata: artifact.metadata
1775
+ };
1776
+ }
1777
+ static taskPushNotificationConfig(request) {
1778
+ return {
1779
+ taskId: extractTaskId(request.name),
1780
+ pushNotificationConfig: _FromProto.pushNotificationConfig(request.pushNotificationConfig)
1781
+ };
1782
+ }
1783
+ static listTaskPushNotificationConfig(request) {
1784
+ return request.configs.map((c) => _FromProto.taskPushNotificationConfig(c));
1785
+ }
1786
+ static agentCard(agentCard) {
1787
+ return {
1788
+ additionalInterfaces: agentCard.additionalInterfaces?.map((i) => _FromProto.agentInterface(i)),
1789
+ capabilities: agentCard.capabilities ? _FromProto.agentCapabilities(agentCard.capabilities) : {},
1790
+ defaultInputModes: agentCard.defaultInputModes,
1791
+ defaultOutputModes: agentCard.defaultOutputModes,
1792
+ description: agentCard.description,
1793
+ documentationUrl: agentCard.documentationUrl || void 0,
1794
+ name: agentCard.name,
1795
+ preferredTransport: agentCard.preferredTransport,
1796
+ provider: agentCard.provider ? _FromProto.agentProvider(agentCard.provider) : void 0,
1797
+ protocolVersion: agentCard.protocolVersion,
1798
+ security: agentCard.security?.map((s) => _FromProto.security(s)),
1799
+ securitySchemes: agentCard.securitySchemes ? Object.fromEntries(
1800
+ Object.entries(agentCard.securitySchemes).map(([key, value]) => [
1801
+ key,
1802
+ _FromProto.securityScheme(value)
1803
+ ])
1804
+ ) : {},
1805
+ skills: agentCard.skills.map((s) => _FromProto.skills(s)),
1806
+ signatures: agentCard.signatures?.map((s) => _FromProto.agentCardSignature(s)),
1807
+ supportsAuthenticatedExtendedCard: agentCard.supportsAuthenticatedExtendedCard,
1808
+ url: agentCard.url,
1809
+ version: agentCard.version
1810
+ };
1811
+ }
1812
+ static agentCapabilities(capabilities) {
1813
+ return {
1814
+ extensions: capabilities.extensions?.map((e) => _FromProto.agentExtension(e)),
1815
+ pushNotifications: capabilities.pushNotifications,
1816
+ streaming: capabilities.streaming
1817
+ };
1818
+ }
1819
+ static agentExtension(extension) {
1820
+ return {
1821
+ uri: extension.uri,
1822
+ description: extension.description || void 0,
1823
+ required: extension.required,
1824
+ params: extension.params
1825
+ };
1826
+ }
1827
+ static agentInterface(intf) {
1828
+ return {
1829
+ transport: intf.transport,
1830
+ url: intf.url
1831
+ };
1832
+ }
1833
+ static agentProvider(provider) {
1834
+ return {
1835
+ organization: provider.organization,
1836
+ url: provider.url
1837
+ };
1838
+ }
1839
+ static security(security) {
1840
+ return Object.fromEntries(
1841
+ Object.entries(security.schemes)?.map(([key, value]) => [key, value.list])
1842
+ );
1843
+ }
1844
+ static securityScheme(securitySchemes) {
1845
+ switch (securitySchemes.scheme?.$case) {
1846
+ case "apiKeySecurityScheme":
1847
+ return {
1848
+ type: "apiKey",
1849
+ name: securitySchemes.scheme.value.name,
1850
+ in: securitySchemes.scheme.value.location,
1851
+ description: securitySchemes.scheme.value.description || void 0
1852
+ };
1853
+ case "httpAuthSecurityScheme":
1854
+ return {
1855
+ type: "http",
1856
+ scheme: securitySchemes.scheme.value.scheme,
1857
+ bearerFormat: securitySchemes.scheme.value.bearerFormat || void 0,
1858
+ description: securitySchemes.scheme.value.description || void 0
1859
+ };
1860
+ case "mtlsSecurityScheme":
1861
+ return {
1862
+ type: "mutualTLS",
1863
+ description: securitySchemes.scheme.value.description || void 0
1864
+ };
1865
+ case "oauth2SecurityScheme":
1866
+ return {
1867
+ type: "oauth2",
1868
+ description: securitySchemes.scheme.value.description || void 0,
1869
+ flows: _FromProto.oauthFlows(securitySchemes.scheme.value.flows),
1870
+ oauth2MetadataUrl: securitySchemes.scheme.value.oauth2MetadataUrl || void 0
1871
+ };
1872
+ case "openIdConnectSecurityScheme":
1873
+ return {
1874
+ type: "openIdConnect",
1875
+ description: securitySchemes.scheme.value.description || void 0,
1876
+ openIdConnectUrl: securitySchemes.scheme.value.openIdConnectUrl
1877
+ };
1878
+ default:
1879
+ throw A2AError.internalError(`Unsupported security scheme type`);
1880
+ }
1881
+ }
1882
+ static oauthFlows(flows) {
1883
+ switch (flows.flow?.$case) {
1884
+ case "implicit":
1885
+ return {
1886
+ implicit: {
1887
+ authorizationUrl: flows.flow.value.authorizationUrl,
1888
+ scopes: flows.flow.value.scopes,
1889
+ refreshUrl: flows.flow.value.refreshUrl || void 0
1890
+ }
1891
+ };
1892
+ case "password":
1893
+ return {
1894
+ password: {
1895
+ refreshUrl: flows.flow.value.refreshUrl || void 0,
1896
+ scopes: flows.flow.value.scopes,
1897
+ tokenUrl: flows.flow.value.tokenUrl
1898
+ }
1899
+ };
1900
+ case "authorizationCode":
1901
+ return {
1902
+ authorizationCode: {
1903
+ refreshUrl: flows.flow.value.refreshUrl || void 0,
1904
+ authorizationUrl: flows.flow.value.authorizationUrl,
1905
+ scopes: flows.flow.value.scopes,
1906
+ tokenUrl: flows.flow.value.tokenUrl
1907
+ }
1908
+ };
1909
+ case "clientCredentials":
1910
+ return {
1911
+ clientCredentials: {
1912
+ refreshUrl: flows.flow.value.refreshUrl || void 0,
1913
+ scopes: flows.flow.value.scopes,
1914
+ tokenUrl: flows.flow.value.tokenUrl
1915
+ }
1916
+ };
1917
+ default:
1918
+ throw A2AError.internalError(`Unsupported OAuth flows`);
1919
+ }
1920
+ }
1921
+ static skills(skill) {
1922
+ return {
1923
+ id: skill.id,
1924
+ name: skill.name,
1925
+ description: skill.description,
1926
+ tags: skill.tags,
1927
+ examples: skill.examples,
1928
+ inputModes: skill.inputModes,
1929
+ outputModes: skill.outputModes,
1930
+ security: skill.security?.map((s) => _FromProto.security(s))
1931
+ };
1932
+ }
1933
+ static agentCardSignature(signatures) {
1934
+ return {
1935
+ protected: signatures.protected,
1936
+ signature: signatures.signature,
1937
+ header: signatures.header
1938
+ };
1939
+ }
1940
+ static taskStatusUpdateEvent(event) {
1941
+ return {
1942
+ kind: "status-update",
1943
+ taskId: event.taskId,
1944
+ status: _FromProto.taskStatus(event.status),
1945
+ contextId: event.contextId,
1946
+ metadata: event.metadata,
1947
+ final: event.final
1948
+ };
1949
+ }
1950
+ static taskArtifactUpdateEvent(event) {
1951
+ return {
1952
+ kind: "artifact-update",
1953
+ taskId: event.taskId,
1954
+ artifact: _FromProto.artifact(event.artifact),
1955
+ contextId: event.contextId,
1956
+ metadata: event.metadata,
1957
+ lastChunk: event.lastChunk
1958
+ };
1959
+ }
1960
+ static messageStreamResult(event) {
1961
+ switch (event.payload?.$case) {
1962
+ case "msg":
1963
+ return _FromProto.message(event.payload.value);
1964
+ case "task":
1965
+ return _FromProto.task(event.payload.value);
1966
+ case "statusUpdate":
1967
+ return _FromProto.taskStatusUpdateEvent(event.payload.value);
1968
+ case "artifactUpdate":
1969
+ return _FromProto.taskArtifactUpdateEvent(event.payload.value);
1970
+ default:
1971
+ throw A2AError.internalError("Invalid event type in StreamResponse");
1972
+ }
1973
+ }
1974
+ };
1975
+
1976
+ export {
1977
+ Task,
1978
+ AgentCard,
1979
+ TaskPushNotificationConfig,
1980
+ SendMessageRequest,
1981
+ SendMessageResponse,
1982
+ StreamResponse,
1983
+ ListTaskPushNotificationConfigResponse,
1984
+ ToProto,
1985
+ FromProto
1986
+ };