@a2a-js/sdk 0.3.7 → 0.3.8
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 +10 -0
- package/dist/chunk-DHC2REQH.js +2145 -0
- package/dist/{chunk-LTPINR5K.js → chunk-NUQQPJNY.js} +3 -60
- package/dist/chunk-UHZEIZLS.js +62 -0
- package/dist/client/index.cjs +2157 -26
- package/dist/client/index.js +99 -27
- package/dist/server/express/index.cjs +2067 -14
- package/dist/server/express/index.js +71 -17
- package/dist/server/index.js +4 -2
- package/package.json +14 -1
- package/dist/chunk-SJNAG4AL.js +0 -122
|
@@ -792,6 +792,2016 @@ var RestTransportHandler = class _RestTransportHandler {
|
|
|
792
792
|
}
|
|
793
793
|
};
|
|
794
794
|
|
|
795
|
+
// src/types/pb/google/protobuf/timestamp.ts
|
|
796
|
+
var Timestamp = {
|
|
797
|
+
fromJSON(object) {
|
|
798
|
+
return {
|
|
799
|
+
seconds: isSet(object.seconds) ? globalThis.Number(object.seconds) : 0,
|
|
800
|
+
nanos: isSet(object.nanos) ? globalThis.Number(object.nanos) : 0
|
|
801
|
+
};
|
|
802
|
+
},
|
|
803
|
+
toJSON(message) {
|
|
804
|
+
const obj = {};
|
|
805
|
+
if (message.seconds !== 0) {
|
|
806
|
+
obj.seconds = Math.round(message.seconds);
|
|
807
|
+
}
|
|
808
|
+
if (message.nanos !== 0) {
|
|
809
|
+
obj.nanos = Math.round(message.nanos);
|
|
810
|
+
}
|
|
811
|
+
return obj;
|
|
812
|
+
}
|
|
813
|
+
};
|
|
814
|
+
function isSet(value) {
|
|
815
|
+
return value !== null && value !== void 0;
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
// src/types/pb/a2a.ts
|
|
819
|
+
function taskStateFromJSON(object) {
|
|
820
|
+
switch (object) {
|
|
821
|
+
case 0:
|
|
822
|
+
case "TASK_STATE_UNSPECIFIED":
|
|
823
|
+
return 0 /* TASK_STATE_UNSPECIFIED */;
|
|
824
|
+
case 1:
|
|
825
|
+
case "TASK_STATE_SUBMITTED":
|
|
826
|
+
return 1 /* TASK_STATE_SUBMITTED */;
|
|
827
|
+
case 2:
|
|
828
|
+
case "TASK_STATE_WORKING":
|
|
829
|
+
return 2 /* TASK_STATE_WORKING */;
|
|
830
|
+
case 3:
|
|
831
|
+
case "TASK_STATE_COMPLETED":
|
|
832
|
+
return 3 /* TASK_STATE_COMPLETED */;
|
|
833
|
+
case 4:
|
|
834
|
+
case "TASK_STATE_FAILED":
|
|
835
|
+
return 4 /* TASK_STATE_FAILED */;
|
|
836
|
+
case 5:
|
|
837
|
+
case "TASK_STATE_CANCELLED":
|
|
838
|
+
return 5 /* TASK_STATE_CANCELLED */;
|
|
839
|
+
case 6:
|
|
840
|
+
case "TASK_STATE_INPUT_REQUIRED":
|
|
841
|
+
return 6 /* TASK_STATE_INPUT_REQUIRED */;
|
|
842
|
+
case 7:
|
|
843
|
+
case "TASK_STATE_REJECTED":
|
|
844
|
+
return 7 /* TASK_STATE_REJECTED */;
|
|
845
|
+
case 8:
|
|
846
|
+
case "TASK_STATE_AUTH_REQUIRED":
|
|
847
|
+
return 8 /* TASK_STATE_AUTH_REQUIRED */;
|
|
848
|
+
case -1:
|
|
849
|
+
case "UNRECOGNIZED":
|
|
850
|
+
default:
|
|
851
|
+
return -1 /* UNRECOGNIZED */;
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
function taskStateToJSON(object) {
|
|
855
|
+
switch (object) {
|
|
856
|
+
case 0 /* TASK_STATE_UNSPECIFIED */:
|
|
857
|
+
return "TASK_STATE_UNSPECIFIED";
|
|
858
|
+
case 1 /* TASK_STATE_SUBMITTED */:
|
|
859
|
+
return "TASK_STATE_SUBMITTED";
|
|
860
|
+
case 2 /* TASK_STATE_WORKING */:
|
|
861
|
+
return "TASK_STATE_WORKING";
|
|
862
|
+
case 3 /* TASK_STATE_COMPLETED */:
|
|
863
|
+
return "TASK_STATE_COMPLETED";
|
|
864
|
+
case 4 /* TASK_STATE_FAILED */:
|
|
865
|
+
return "TASK_STATE_FAILED";
|
|
866
|
+
case 5 /* TASK_STATE_CANCELLED */:
|
|
867
|
+
return "TASK_STATE_CANCELLED";
|
|
868
|
+
case 6 /* TASK_STATE_INPUT_REQUIRED */:
|
|
869
|
+
return "TASK_STATE_INPUT_REQUIRED";
|
|
870
|
+
case 7 /* TASK_STATE_REJECTED */:
|
|
871
|
+
return "TASK_STATE_REJECTED";
|
|
872
|
+
case 8 /* TASK_STATE_AUTH_REQUIRED */:
|
|
873
|
+
return "TASK_STATE_AUTH_REQUIRED";
|
|
874
|
+
case -1 /* UNRECOGNIZED */:
|
|
875
|
+
default:
|
|
876
|
+
return "UNRECOGNIZED";
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
function roleFromJSON(object) {
|
|
880
|
+
switch (object) {
|
|
881
|
+
case 0:
|
|
882
|
+
case "ROLE_UNSPECIFIED":
|
|
883
|
+
return 0 /* ROLE_UNSPECIFIED */;
|
|
884
|
+
case 1:
|
|
885
|
+
case "ROLE_USER":
|
|
886
|
+
return 1 /* ROLE_USER */;
|
|
887
|
+
case 2:
|
|
888
|
+
case "ROLE_AGENT":
|
|
889
|
+
return 2 /* ROLE_AGENT */;
|
|
890
|
+
case -1:
|
|
891
|
+
case "UNRECOGNIZED":
|
|
892
|
+
default:
|
|
893
|
+
return -1 /* UNRECOGNIZED */;
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
function roleToJSON(object) {
|
|
897
|
+
switch (object) {
|
|
898
|
+
case 0 /* ROLE_UNSPECIFIED */:
|
|
899
|
+
return "ROLE_UNSPECIFIED";
|
|
900
|
+
case 1 /* ROLE_USER */:
|
|
901
|
+
return "ROLE_USER";
|
|
902
|
+
case 2 /* ROLE_AGENT */:
|
|
903
|
+
return "ROLE_AGENT";
|
|
904
|
+
case -1 /* UNRECOGNIZED */:
|
|
905
|
+
default:
|
|
906
|
+
return "UNRECOGNIZED";
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
var SendMessageConfiguration = {
|
|
910
|
+
fromJSON(object) {
|
|
911
|
+
return {
|
|
912
|
+
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(
|
|
913
|
+
(e) => globalThis.String(e)
|
|
914
|
+
) : [],
|
|
915
|
+
pushNotification: isSet2(object.pushNotification) ? PushNotificationConfig.fromJSON(object.pushNotification) : isSet2(object.push_notification) ? PushNotificationConfig.fromJSON(object.push_notification) : void 0,
|
|
916
|
+
historyLength: isSet2(object.historyLength) ? globalThis.Number(object.historyLength) : isSet2(object.history_length) ? globalThis.Number(object.history_length) : void 0,
|
|
917
|
+
blocking: isSet2(object.blocking) ? globalThis.Boolean(object.blocking) : void 0
|
|
918
|
+
};
|
|
919
|
+
},
|
|
920
|
+
toJSON(message) {
|
|
921
|
+
const obj = {};
|
|
922
|
+
if (message.acceptedOutputModes?.length) {
|
|
923
|
+
obj.acceptedOutputModes = message.acceptedOutputModes;
|
|
924
|
+
}
|
|
925
|
+
if (message.pushNotification !== void 0) {
|
|
926
|
+
obj.pushNotification = PushNotificationConfig.toJSON(message.pushNotification);
|
|
927
|
+
}
|
|
928
|
+
if (message.historyLength !== void 0) {
|
|
929
|
+
obj.historyLength = Math.round(message.historyLength);
|
|
930
|
+
}
|
|
931
|
+
if (message.blocking !== void 0) {
|
|
932
|
+
obj.blocking = message.blocking;
|
|
933
|
+
}
|
|
934
|
+
return obj;
|
|
935
|
+
}
|
|
936
|
+
};
|
|
937
|
+
var Task = {
|
|
938
|
+
fromJSON(object) {
|
|
939
|
+
return {
|
|
940
|
+
id: isSet2(object.id) ? globalThis.String(object.id) : void 0,
|
|
941
|
+
contextId: isSet2(object.contextId) ? globalThis.String(object.contextId) : isSet2(object.context_id) ? globalThis.String(object.context_id) : void 0,
|
|
942
|
+
status: isSet2(object.status) ? TaskStatus.fromJSON(object.status) : void 0,
|
|
943
|
+
artifacts: globalThis.Array.isArray(object?.artifacts) ? object.artifacts.map((e) => Artifact.fromJSON(e)) : [],
|
|
944
|
+
history: globalThis.Array.isArray(object?.history) ? object.history.map((e) => Message.fromJSON(e)) : [],
|
|
945
|
+
metadata: isObject(object.metadata) ? object.metadata : void 0
|
|
946
|
+
};
|
|
947
|
+
},
|
|
948
|
+
toJSON(message) {
|
|
949
|
+
const obj = {};
|
|
950
|
+
if (message.id !== void 0) {
|
|
951
|
+
obj.id = message.id;
|
|
952
|
+
}
|
|
953
|
+
if (message.contextId !== void 0) {
|
|
954
|
+
obj.contextId = message.contextId;
|
|
955
|
+
}
|
|
956
|
+
if (message.status !== void 0) {
|
|
957
|
+
obj.status = TaskStatus.toJSON(message.status);
|
|
958
|
+
}
|
|
959
|
+
if (message.artifacts?.length) {
|
|
960
|
+
obj.artifacts = message.artifacts.map((e) => Artifact.toJSON(e));
|
|
961
|
+
}
|
|
962
|
+
if (message.history?.length) {
|
|
963
|
+
obj.history = message.history.map((e) => Message.toJSON(e));
|
|
964
|
+
}
|
|
965
|
+
if (message.metadata !== void 0) {
|
|
966
|
+
obj.metadata = message.metadata;
|
|
967
|
+
}
|
|
968
|
+
return obj;
|
|
969
|
+
}
|
|
970
|
+
};
|
|
971
|
+
var TaskStatus = {
|
|
972
|
+
fromJSON(object) {
|
|
973
|
+
return {
|
|
974
|
+
state: isSet2(object.state) ? taskStateFromJSON(object.state) : void 0,
|
|
975
|
+
update: isSet2(object.message) ? Message.fromJSON(object.message) : isSet2(object.update) ? Message.fromJSON(object.update) : void 0,
|
|
976
|
+
timestamp: isSet2(object.timestamp) ? fromJsonTimestamp(object.timestamp) : void 0
|
|
977
|
+
};
|
|
978
|
+
},
|
|
979
|
+
toJSON(message) {
|
|
980
|
+
const obj = {};
|
|
981
|
+
if (message.state !== void 0) {
|
|
982
|
+
obj.state = taskStateToJSON(message.state);
|
|
983
|
+
}
|
|
984
|
+
if (message.update !== void 0) {
|
|
985
|
+
obj.message = Message.toJSON(message.update);
|
|
986
|
+
}
|
|
987
|
+
if (message.timestamp !== void 0) {
|
|
988
|
+
obj.timestamp = message.timestamp.toISOString();
|
|
989
|
+
}
|
|
990
|
+
return obj;
|
|
991
|
+
}
|
|
992
|
+
};
|
|
993
|
+
var Part = {
|
|
994
|
+
fromJSON(object) {
|
|
995
|
+
return {
|
|
996
|
+
part: isSet2(object.text) ? { $case: "text", value: globalThis.String(object.text) } : isSet2(object.file) ? { $case: "file", value: FilePart.fromJSON(object.file) } : isSet2(object.data) ? { $case: "data", value: DataPart.fromJSON(object.data) } : void 0
|
|
997
|
+
};
|
|
998
|
+
},
|
|
999
|
+
toJSON(message) {
|
|
1000
|
+
const obj = {};
|
|
1001
|
+
if (message.part?.$case === "text") {
|
|
1002
|
+
obj.text = message.part.value;
|
|
1003
|
+
} else if (message.part?.$case === "file") {
|
|
1004
|
+
obj.file = FilePart.toJSON(message.part.value);
|
|
1005
|
+
} else if (message.part?.$case === "data") {
|
|
1006
|
+
obj.data = DataPart.toJSON(message.part.value);
|
|
1007
|
+
}
|
|
1008
|
+
return obj;
|
|
1009
|
+
}
|
|
1010
|
+
};
|
|
1011
|
+
var FilePart = {
|
|
1012
|
+
fromJSON(object) {
|
|
1013
|
+
return {
|
|
1014
|
+
file: isSet2(object.fileWithUri) ? { $case: "fileWithUri", value: globalThis.String(object.fileWithUri) } : isSet2(object.file_with_uri) ? { $case: "fileWithUri", value: globalThis.String(object.file_with_uri) } : isSet2(object.fileWithBytes) ? { $case: "fileWithBytes", value: Buffer.from(bytesFromBase64(object.fileWithBytes)) } : isSet2(object.file_with_bytes) ? { $case: "fileWithBytes", value: Buffer.from(bytesFromBase64(object.file_with_bytes)) } : void 0,
|
|
1015
|
+
mimeType: isSet2(object.mimeType) ? globalThis.String(object.mimeType) : isSet2(object.mime_type) ? globalThis.String(object.mime_type) : void 0
|
|
1016
|
+
};
|
|
1017
|
+
},
|
|
1018
|
+
toJSON(message) {
|
|
1019
|
+
const obj = {};
|
|
1020
|
+
if (message.file?.$case === "fileWithUri") {
|
|
1021
|
+
obj.fileWithUri = message.file.value;
|
|
1022
|
+
} else if (message.file?.$case === "fileWithBytes") {
|
|
1023
|
+
obj.fileWithBytes = base64FromBytes(message.file.value);
|
|
1024
|
+
}
|
|
1025
|
+
if (message.mimeType !== void 0) {
|
|
1026
|
+
obj.mimeType = message.mimeType;
|
|
1027
|
+
}
|
|
1028
|
+
return obj;
|
|
1029
|
+
}
|
|
1030
|
+
};
|
|
1031
|
+
var DataPart = {
|
|
1032
|
+
fromJSON(object) {
|
|
1033
|
+
return { data: isObject(object.data) ? object.data : void 0 };
|
|
1034
|
+
},
|
|
1035
|
+
toJSON(message) {
|
|
1036
|
+
const obj = {};
|
|
1037
|
+
if (message.data !== void 0) {
|
|
1038
|
+
obj.data = message.data;
|
|
1039
|
+
}
|
|
1040
|
+
return obj;
|
|
1041
|
+
}
|
|
1042
|
+
};
|
|
1043
|
+
var Message = {
|
|
1044
|
+
fromJSON(object) {
|
|
1045
|
+
return {
|
|
1046
|
+
messageId: isSet2(object.messageId) ? globalThis.String(object.messageId) : isSet2(object.message_id) ? globalThis.String(object.message_id) : void 0,
|
|
1047
|
+
contextId: isSet2(object.contextId) ? globalThis.String(object.contextId) : isSet2(object.context_id) ? globalThis.String(object.context_id) : void 0,
|
|
1048
|
+
taskId: isSet2(object.taskId) ? globalThis.String(object.taskId) : isSet2(object.task_id) ? globalThis.String(object.task_id) : void 0,
|
|
1049
|
+
role: isSet2(object.role) ? roleFromJSON(object.role) : void 0,
|
|
1050
|
+
content: globalThis.Array.isArray(object?.content) ? object.content.map((e) => Part.fromJSON(e)) : [],
|
|
1051
|
+
metadata: isObject(object.metadata) ? object.metadata : void 0,
|
|
1052
|
+
extensions: globalThis.Array.isArray(object?.extensions) ? object.extensions.map((e) => globalThis.String(e)) : []
|
|
1053
|
+
};
|
|
1054
|
+
},
|
|
1055
|
+
toJSON(message) {
|
|
1056
|
+
const obj = {};
|
|
1057
|
+
if (message.messageId !== void 0) {
|
|
1058
|
+
obj.messageId = message.messageId;
|
|
1059
|
+
}
|
|
1060
|
+
if (message.contextId !== void 0) {
|
|
1061
|
+
obj.contextId = message.contextId;
|
|
1062
|
+
}
|
|
1063
|
+
if (message.taskId !== void 0) {
|
|
1064
|
+
obj.taskId = message.taskId;
|
|
1065
|
+
}
|
|
1066
|
+
if (message.role !== void 0) {
|
|
1067
|
+
obj.role = roleToJSON(message.role);
|
|
1068
|
+
}
|
|
1069
|
+
if (message.content?.length) {
|
|
1070
|
+
obj.content = message.content.map((e) => Part.toJSON(e));
|
|
1071
|
+
}
|
|
1072
|
+
if (message.metadata !== void 0) {
|
|
1073
|
+
obj.metadata = message.metadata;
|
|
1074
|
+
}
|
|
1075
|
+
if (message.extensions?.length) {
|
|
1076
|
+
obj.extensions = message.extensions;
|
|
1077
|
+
}
|
|
1078
|
+
return obj;
|
|
1079
|
+
}
|
|
1080
|
+
};
|
|
1081
|
+
var Artifact = {
|
|
1082
|
+
fromJSON(object) {
|
|
1083
|
+
return {
|
|
1084
|
+
artifactId: isSet2(object.artifactId) ? globalThis.String(object.artifactId) : isSet2(object.artifact_id) ? globalThis.String(object.artifact_id) : void 0,
|
|
1085
|
+
name: isSet2(object.name) ? globalThis.String(object.name) : void 0,
|
|
1086
|
+
description: isSet2(object.description) ? globalThis.String(object.description) : void 0,
|
|
1087
|
+
parts: globalThis.Array.isArray(object?.parts) ? object.parts.map((e) => Part.fromJSON(e)) : [],
|
|
1088
|
+
metadata: isObject(object.metadata) ? object.metadata : void 0,
|
|
1089
|
+
extensions: globalThis.Array.isArray(object?.extensions) ? object.extensions.map((e) => globalThis.String(e)) : []
|
|
1090
|
+
};
|
|
1091
|
+
},
|
|
1092
|
+
toJSON(message) {
|
|
1093
|
+
const obj = {};
|
|
1094
|
+
if (message.artifactId !== void 0) {
|
|
1095
|
+
obj.artifactId = message.artifactId;
|
|
1096
|
+
}
|
|
1097
|
+
if (message.name !== void 0) {
|
|
1098
|
+
obj.name = message.name;
|
|
1099
|
+
}
|
|
1100
|
+
if (message.description !== void 0) {
|
|
1101
|
+
obj.description = message.description;
|
|
1102
|
+
}
|
|
1103
|
+
if (message.parts?.length) {
|
|
1104
|
+
obj.parts = message.parts.map((e) => Part.toJSON(e));
|
|
1105
|
+
}
|
|
1106
|
+
if (message.metadata !== void 0) {
|
|
1107
|
+
obj.metadata = message.metadata;
|
|
1108
|
+
}
|
|
1109
|
+
if (message.extensions?.length) {
|
|
1110
|
+
obj.extensions = message.extensions;
|
|
1111
|
+
}
|
|
1112
|
+
return obj;
|
|
1113
|
+
}
|
|
1114
|
+
};
|
|
1115
|
+
var TaskStatusUpdateEvent = {
|
|
1116
|
+
fromJSON(object) {
|
|
1117
|
+
return {
|
|
1118
|
+
taskId: isSet2(object.taskId) ? globalThis.String(object.taskId) : isSet2(object.task_id) ? globalThis.String(object.task_id) : void 0,
|
|
1119
|
+
contextId: isSet2(object.contextId) ? globalThis.String(object.contextId) : isSet2(object.context_id) ? globalThis.String(object.context_id) : void 0,
|
|
1120
|
+
status: isSet2(object.status) ? TaskStatus.fromJSON(object.status) : void 0,
|
|
1121
|
+
final: isSet2(object.final) ? globalThis.Boolean(object.final) : void 0,
|
|
1122
|
+
metadata: isObject(object.metadata) ? object.metadata : void 0
|
|
1123
|
+
};
|
|
1124
|
+
},
|
|
1125
|
+
toJSON(message) {
|
|
1126
|
+
const obj = {};
|
|
1127
|
+
if (message.taskId !== void 0) {
|
|
1128
|
+
obj.taskId = message.taskId;
|
|
1129
|
+
}
|
|
1130
|
+
if (message.contextId !== void 0) {
|
|
1131
|
+
obj.contextId = message.contextId;
|
|
1132
|
+
}
|
|
1133
|
+
if (message.status !== void 0) {
|
|
1134
|
+
obj.status = TaskStatus.toJSON(message.status);
|
|
1135
|
+
}
|
|
1136
|
+
if (message.final !== void 0) {
|
|
1137
|
+
obj.final = message.final;
|
|
1138
|
+
}
|
|
1139
|
+
if (message.metadata !== void 0) {
|
|
1140
|
+
obj.metadata = message.metadata;
|
|
1141
|
+
}
|
|
1142
|
+
return obj;
|
|
1143
|
+
}
|
|
1144
|
+
};
|
|
1145
|
+
var TaskArtifactUpdateEvent = {
|
|
1146
|
+
fromJSON(object) {
|
|
1147
|
+
return {
|
|
1148
|
+
taskId: isSet2(object.taskId) ? globalThis.String(object.taskId) : isSet2(object.task_id) ? globalThis.String(object.task_id) : void 0,
|
|
1149
|
+
contextId: isSet2(object.contextId) ? globalThis.String(object.contextId) : isSet2(object.context_id) ? globalThis.String(object.context_id) : void 0,
|
|
1150
|
+
artifact: isSet2(object.artifact) ? Artifact.fromJSON(object.artifact) : void 0,
|
|
1151
|
+
append: isSet2(object.append) ? globalThis.Boolean(object.append) : void 0,
|
|
1152
|
+
lastChunk: isSet2(object.lastChunk) ? globalThis.Boolean(object.lastChunk) : isSet2(object.last_chunk) ? globalThis.Boolean(object.last_chunk) : void 0,
|
|
1153
|
+
metadata: isObject(object.metadata) ? object.metadata : void 0
|
|
1154
|
+
};
|
|
1155
|
+
},
|
|
1156
|
+
toJSON(message) {
|
|
1157
|
+
const obj = {};
|
|
1158
|
+
if (message.taskId !== void 0) {
|
|
1159
|
+
obj.taskId = message.taskId;
|
|
1160
|
+
}
|
|
1161
|
+
if (message.contextId !== void 0) {
|
|
1162
|
+
obj.contextId = message.contextId;
|
|
1163
|
+
}
|
|
1164
|
+
if (message.artifact !== void 0) {
|
|
1165
|
+
obj.artifact = Artifact.toJSON(message.artifact);
|
|
1166
|
+
}
|
|
1167
|
+
if (message.append !== void 0) {
|
|
1168
|
+
obj.append = message.append;
|
|
1169
|
+
}
|
|
1170
|
+
if (message.lastChunk !== void 0) {
|
|
1171
|
+
obj.lastChunk = message.lastChunk;
|
|
1172
|
+
}
|
|
1173
|
+
if (message.metadata !== void 0) {
|
|
1174
|
+
obj.metadata = message.metadata;
|
|
1175
|
+
}
|
|
1176
|
+
return obj;
|
|
1177
|
+
}
|
|
1178
|
+
};
|
|
1179
|
+
var PushNotificationConfig = {
|
|
1180
|
+
fromJSON(object) {
|
|
1181
|
+
return {
|
|
1182
|
+
id: isSet2(object.id) ? globalThis.String(object.id) : void 0,
|
|
1183
|
+
url: isSet2(object.url) ? globalThis.String(object.url) : void 0,
|
|
1184
|
+
token: isSet2(object.token) ? globalThis.String(object.token) : void 0,
|
|
1185
|
+
authentication: isSet2(object.authentication) ? AuthenticationInfo.fromJSON(object.authentication) : void 0
|
|
1186
|
+
};
|
|
1187
|
+
},
|
|
1188
|
+
toJSON(message) {
|
|
1189
|
+
const obj = {};
|
|
1190
|
+
if (message.id !== void 0) {
|
|
1191
|
+
obj.id = message.id;
|
|
1192
|
+
}
|
|
1193
|
+
if (message.url !== void 0) {
|
|
1194
|
+
obj.url = message.url;
|
|
1195
|
+
}
|
|
1196
|
+
if (message.token !== void 0) {
|
|
1197
|
+
obj.token = message.token;
|
|
1198
|
+
}
|
|
1199
|
+
if (message.authentication !== void 0) {
|
|
1200
|
+
obj.authentication = AuthenticationInfo.toJSON(message.authentication);
|
|
1201
|
+
}
|
|
1202
|
+
return obj;
|
|
1203
|
+
}
|
|
1204
|
+
};
|
|
1205
|
+
var AuthenticationInfo = {
|
|
1206
|
+
fromJSON(object) {
|
|
1207
|
+
return {
|
|
1208
|
+
schemes: globalThis.Array.isArray(object?.schemes) ? object.schemes.map((e) => globalThis.String(e)) : [],
|
|
1209
|
+
credentials: isSet2(object.credentials) ? globalThis.String(object.credentials) : void 0
|
|
1210
|
+
};
|
|
1211
|
+
},
|
|
1212
|
+
toJSON(message) {
|
|
1213
|
+
const obj = {};
|
|
1214
|
+
if (message.schemes?.length) {
|
|
1215
|
+
obj.schemes = message.schemes;
|
|
1216
|
+
}
|
|
1217
|
+
if (message.credentials !== void 0) {
|
|
1218
|
+
obj.credentials = message.credentials;
|
|
1219
|
+
}
|
|
1220
|
+
return obj;
|
|
1221
|
+
}
|
|
1222
|
+
};
|
|
1223
|
+
var AgentInterface = {
|
|
1224
|
+
fromJSON(object) {
|
|
1225
|
+
return {
|
|
1226
|
+
url: isSet2(object.url) ? globalThis.String(object.url) : void 0,
|
|
1227
|
+
transport: isSet2(object.transport) ? globalThis.String(object.transport) : void 0
|
|
1228
|
+
};
|
|
1229
|
+
},
|
|
1230
|
+
toJSON(message) {
|
|
1231
|
+
const obj = {};
|
|
1232
|
+
if (message.url !== void 0) {
|
|
1233
|
+
obj.url = message.url;
|
|
1234
|
+
}
|
|
1235
|
+
if (message.transport !== void 0) {
|
|
1236
|
+
obj.transport = message.transport;
|
|
1237
|
+
}
|
|
1238
|
+
return obj;
|
|
1239
|
+
}
|
|
1240
|
+
};
|
|
1241
|
+
var AgentCard = {
|
|
1242
|
+
fromJSON(object) {
|
|
1243
|
+
return {
|
|
1244
|
+
protocolVersion: isSet2(object.protocolVersion) ? globalThis.String(object.protocolVersion) : isSet2(object.protocol_version) ? globalThis.String(object.protocol_version) : void 0,
|
|
1245
|
+
name: isSet2(object.name) ? globalThis.String(object.name) : void 0,
|
|
1246
|
+
description: isSet2(object.description) ? globalThis.String(object.description) : void 0,
|
|
1247
|
+
url: isSet2(object.url) ? globalThis.String(object.url) : void 0,
|
|
1248
|
+
preferredTransport: isSet2(object.preferredTransport) ? globalThis.String(object.preferredTransport) : isSet2(object.preferred_transport) ? globalThis.String(object.preferred_transport) : void 0,
|
|
1249
|
+
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)) : [],
|
|
1250
|
+
provider: isSet2(object.provider) ? AgentProvider.fromJSON(object.provider) : void 0,
|
|
1251
|
+
version: isSet2(object.version) ? globalThis.String(object.version) : void 0,
|
|
1252
|
+
documentationUrl: isSet2(object.documentationUrl) ? globalThis.String(object.documentationUrl) : isSet2(object.documentation_url) ? globalThis.String(object.documentation_url) : void 0,
|
|
1253
|
+
capabilities: isSet2(object.capabilities) ? AgentCapabilities.fromJSON(object.capabilities) : void 0,
|
|
1254
|
+
securitySchemes: isObject(object.securitySchemes) ? globalThis.Object.entries(object.securitySchemes).reduce(
|
|
1255
|
+
(acc, [key, value]) => {
|
|
1256
|
+
acc[key] = SecurityScheme.fromJSON(value);
|
|
1257
|
+
return acc;
|
|
1258
|
+
},
|
|
1259
|
+
{}
|
|
1260
|
+
) : isObject(object.security_schemes) ? globalThis.Object.entries(object.security_schemes).reduce(
|
|
1261
|
+
(acc, [key, value]) => {
|
|
1262
|
+
acc[key] = SecurityScheme.fromJSON(value);
|
|
1263
|
+
return acc;
|
|
1264
|
+
},
|
|
1265
|
+
{}
|
|
1266
|
+
) : {},
|
|
1267
|
+
security: globalThis.Array.isArray(object?.security) ? object.security.map((e) => Security.fromJSON(e)) : [],
|
|
1268
|
+
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)) : [],
|
|
1269
|
+
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)) : [],
|
|
1270
|
+
skills: globalThis.Array.isArray(object?.skills) ? object.skills.map((e) => AgentSkill.fromJSON(e)) : [],
|
|
1271
|
+
supportsAuthenticatedExtendedCard: isSet2(object.supportsAuthenticatedExtendedCard) ? globalThis.Boolean(object.supportsAuthenticatedExtendedCard) : isSet2(object.supports_authenticated_extended_card) ? globalThis.Boolean(object.supports_authenticated_extended_card) : void 0,
|
|
1272
|
+
signatures: globalThis.Array.isArray(object?.signatures) ? object.signatures.map((e) => AgentCardSignature.fromJSON(e)) : []
|
|
1273
|
+
};
|
|
1274
|
+
},
|
|
1275
|
+
toJSON(message) {
|
|
1276
|
+
const obj = {};
|
|
1277
|
+
if (message.protocolVersion !== void 0) {
|
|
1278
|
+
obj.protocolVersion = message.protocolVersion;
|
|
1279
|
+
}
|
|
1280
|
+
if (message.name !== void 0) {
|
|
1281
|
+
obj.name = message.name;
|
|
1282
|
+
}
|
|
1283
|
+
if (message.description !== void 0) {
|
|
1284
|
+
obj.description = message.description;
|
|
1285
|
+
}
|
|
1286
|
+
if (message.url !== void 0) {
|
|
1287
|
+
obj.url = message.url;
|
|
1288
|
+
}
|
|
1289
|
+
if (message.preferredTransport !== void 0) {
|
|
1290
|
+
obj.preferredTransport = message.preferredTransport;
|
|
1291
|
+
}
|
|
1292
|
+
if (message.additionalInterfaces?.length) {
|
|
1293
|
+
obj.additionalInterfaces = message.additionalInterfaces.map((e) => AgentInterface.toJSON(e));
|
|
1294
|
+
}
|
|
1295
|
+
if (message.provider !== void 0) {
|
|
1296
|
+
obj.provider = AgentProvider.toJSON(message.provider);
|
|
1297
|
+
}
|
|
1298
|
+
if (message.version !== void 0) {
|
|
1299
|
+
obj.version = message.version;
|
|
1300
|
+
}
|
|
1301
|
+
if (message.documentationUrl !== void 0) {
|
|
1302
|
+
obj.documentationUrl = message.documentationUrl;
|
|
1303
|
+
}
|
|
1304
|
+
if (message.capabilities !== void 0) {
|
|
1305
|
+
obj.capabilities = AgentCapabilities.toJSON(message.capabilities);
|
|
1306
|
+
}
|
|
1307
|
+
if (message.securitySchemes) {
|
|
1308
|
+
const entries = globalThis.Object.entries(message.securitySchemes);
|
|
1309
|
+
if (entries.length > 0) {
|
|
1310
|
+
obj.securitySchemes = {};
|
|
1311
|
+
entries.forEach(([k, v]) => {
|
|
1312
|
+
obj.securitySchemes[k] = SecurityScheme.toJSON(v);
|
|
1313
|
+
});
|
|
1314
|
+
}
|
|
1315
|
+
}
|
|
1316
|
+
if (message.security?.length) {
|
|
1317
|
+
obj.security = message.security.map((e) => Security.toJSON(e));
|
|
1318
|
+
}
|
|
1319
|
+
if (message.defaultInputModes?.length) {
|
|
1320
|
+
obj.defaultInputModes = message.defaultInputModes;
|
|
1321
|
+
}
|
|
1322
|
+
if (message.defaultOutputModes?.length) {
|
|
1323
|
+
obj.defaultOutputModes = message.defaultOutputModes;
|
|
1324
|
+
}
|
|
1325
|
+
if (message.skills?.length) {
|
|
1326
|
+
obj.skills = message.skills.map((e) => AgentSkill.toJSON(e));
|
|
1327
|
+
}
|
|
1328
|
+
if (message.supportsAuthenticatedExtendedCard !== void 0) {
|
|
1329
|
+
obj.supportsAuthenticatedExtendedCard = message.supportsAuthenticatedExtendedCard;
|
|
1330
|
+
}
|
|
1331
|
+
if (message.signatures?.length) {
|
|
1332
|
+
obj.signatures = message.signatures.map((e) => AgentCardSignature.toJSON(e));
|
|
1333
|
+
}
|
|
1334
|
+
return obj;
|
|
1335
|
+
}
|
|
1336
|
+
};
|
|
1337
|
+
var AgentProvider = {
|
|
1338
|
+
fromJSON(object) {
|
|
1339
|
+
return {
|
|
1340
|
+
url: isSet2(object.url) ? globalThis.String(object.url) : void 0,
|
|
1341
|
+
organization: isSet2(object.organization) ? globalThis.String(object.organization) : void 0
|
|
1342
|
+
};
|
|
1343
|
+
},
|
|
1344
|
+
toJSON(message) {
|
|
1345
|
+
const obj = {};
|
|
1346
|
+
if (message.url !== void 0) {
|
|
1347
|
+
obj.url = message.url;
|
|
1348
|
+
}
|
|
1349
|
+
if (message.organization !== void 0) {
|
|
1350
|
+
obj.organization = message.organization;
|
|
1351
|
+
}
|
|
1352
|
+
return obj;
|
|
1353
|
+
}
|
|
1354
|
+
};
|
|
1355
|
+
var AgentCapabilities = {
|
|
1356
|
+
fromJSON(object) {
|
|
1357
|
+
return {
|
|
1358
|
+
streaming: isSet2(object.streaming) ? globalThis.Boolean(object.streaming) : void 0,
|
|
1359
|
+
pushNotifications: isSet2(object.pushNotifications) ? globalThis.Boolean(object.pushNotifications) : isSet2(object.push_notifications) ? globalThis.Boolean(object.push_notifications) : void 0,
|
|
1360
|
+
extensions: globalThis.Array.isArray(object?.extensions) ? object.extensions.map((e) => AgentExtension.fromJSON(e)) : []
|
|
1361
|
+
};
|
|
1362
|
+
},
|
|
1363
|
+
toJSON(message) {
|
|
1364
|
+
const obj = {};
|
|
1365
|
+
if (message.streaming !== void 0) {
|
|
1366
|
+
obj.streaming = message.streaming;
|
|
1367
|
+
}
|
|
1368
|
+
if (message.pushNotifications !== void 0) {
|
|
1369
|
+
obj.pushNotifications = message.pushNotifications;
|
|
1370
|
+
}
|
|
1371
|
+
if (message.extensions?.length) {
|
|
1372
|
+
obj.extensions = message.extensions.map((e) => AgentExtension.toJSON(e));
|
|
1373
|
+
}
|
|
1374
|
+
return obj;
|
|
1375
|
+
}
|
|
1376
|
+
};
|
|
1377
|
+
var AgentExtension = {
|
|
1378
|
+
fromJSON(object) {
|
|
1379
|
+
return {
|
|
1380
|
+
uri: isSet2(object.uri) ? globalThis.String(object.uri) : void 0,
|
|
1381
|
+
description: isSet2(object.description) ? globalThis.String(object.description) : void 0,
|
|
1382
|
+
required: isSet2(object.required) ? globalThis.Boolean(object.required) : void 0,
|
|
1383
|
+
params: isObject(object.params) ? object.params : void 0
|
|
1384
|
+
};
|
|
1385
|
+
},
|
|
1386
|
+
toJSON(message) {
|
|
1387
|
+
const obj = {};
|
|
1388
|
+
if (message.uri !== void 0) {
|
|
1389
|
+
obj.uri = message.uri;
|
|
1390
|
+
}
|
|
1391
|
+
if (message.description !== void 0) {
|
|
1392
|
+
obj.description = message.description;
|
|
1393
|
+
}
|
|
1394
|
+
if (message.required !== void 0) {
|
|
1395
|
+
obj.required = message.required;
|
|
1396
|
+
}
|
|
1397
|
+
if (message.params !== void 0) {
|
|
1398
|
+
obj.params = message.params;
|
|
1399
|
+
}
|
|
1400
|
+
return obj;
|
|
1401
|
+
}
|
|
1402
|
+
};
|
|
1403
|
+
var AgentSkill = {
|
|
1404
|
+
fromJSON(object) {
|
|
1405
|
+
return {
|
|
1406
|
+
id: isSet2(object.id) ? globalThis.String(object.id) : void 0,
|
|
1407
|
+
name: isSet2(object.name) ? globalThis.String(object.name) : void 0,
|
|
1408
|
+
description: isSet2(object.description) ? globalThis.String(object.description) : void 0,
|
|
1409
|
+
tags: globalThis.Array.isArray(object?.tags) ? object.tags.map((e) => globalThis.String(e)) : [],
|
|
1410
|
+
examples: globalThis.Array.isArray(object?.examples) ? object.examples.map((e) => globalThis.String(e)) : [],
|
|
1411
|
+
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)) : [],
|
|
1412
|
+
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)) : [],
|
|
1413
|
+
security: globalThis.Array.isArray(object?.security) ? object.security.map((e) => Security.fromJSON(e)) : []
|
|
1414
|
+
};
|
|
1415
|
+
},
|
|
1416
|
+
toJSON(message) {
|
|
1417
|
+
const obj = {};
|
|
1418
|
+
if (message.id !== void 0) {
|
|
1419
|
+
obj.id = message.id;
|
|
1420
|
+
}
|
|
1421
|
+
if (message.name !== void 0) {
|
|
1422
|
+
obj.name = message.name;
|
|
1423
|
+
}
|
|
1424
|
+
if (message.description !== void 0) {
|
|
1425
|
+
obj.description = message.description;
|
|
1426
|
+
}
|
|
1427
|
+
if (message.tags?.length) {
|
|
1428
|
+
obj.tags = message.tags;
|
|
1429
|
+
}
|
|
1430
|
+
if (message.examples?.length) {
|
|
1431
|
+
obj.examples = message.examples;
|
|
1432
|
+
}
|
|
1433
|
+
if (message.inputModes?.length) {
|
|
1434
|
+
obj.inputModes = message.inputModes;
|
|
1435
|
+
}
|
|
1436
|
+
if (message.outputModes?.length) {
|
|
1437
|
+
obj.outputModes = message.outputModes;
|
|
1438
|
+
}
|
|
1439
|
+
if (message.security?.length) {
|
|
1440
|
+
obj.security = message.security.map((e) => Security.toJSON(e));
|
|
1441
|
+
}
|
|
1442
|
+
return obj;
|
|
1443
|
+
}
|
|
1444
|
+
};
|
|
1445
|
+
var AgentCardSignature = {
|
|
1446
|
+
fromJSON(object) {
|
|
1447
|
+
return {
|
|
1448
|
+
protected: isSet2(object.protected) ? globalThis.String(object.protected) : void 0,
|
|
1449
|
+
signature: isSet2(object.signature) ? globalThis.String(object.signature) : void 0,
|
|
1450
|
+
header: isObject(object.header) ? object.header : void 0
|
|
1451
|
+
};
|
|
1452
|
+
},
|
|
1453
|
+
toJSON(message) {
|
|
1454
|
+
const obj = {};
|
|
1455
|
+
if (message.protected !== void 0) {
|
|
1456
|
+
obj.protected = message.protected;
|
|
1457
|
+
}
|
|
1458
|
+
if (message.signature !== void 0) {
|
|
1459
|
+
obj.signature = message.signature;
|
|
1460
|
+
}
|
|
1461
|
+
if (message.header !== void 0) {
|
|
1462
|
+
obj.header = message.header;
|
|
1463
|
+
}
|
|
1464
|
+
return obj;
|
|
1465
|
+
}
|
|
1466
|
+
};
|
|
1467
|
+
var TaskPushNotificationConfig = {
|
|
1468
|
+
fromJSON(object) {
|
|
1469
|
+
return {
|
|
1470
|
+
name: isSet2(object.name) ? globalThis.String(object.name) : void 0,
|
|
1471
|
+
pushNotificationConfig: isSet2(object.pushNotificationConfig) ? PushNotificationConfig.fromJSON(object.pushNotificationConfig) : isSet2(object.push_notification_config) ? PushNotificationConfig.fromJSON(object.push_notification_config) : void 0
|
|
1472
|
+
};
|
|
1473
|
+
},
|
|
1474
|
+
toJSON(message) {
|
|
1475
|
+
const obj = {};
|
|
1476
|
+
if (message.name !== void 0) {
|
|
1477
|
+
obj.name = message.name;
|
|
1478
|
+
}
|
|
1479
|
+
if (message.pushNotificationConfig !== void 0) {
|
|
1480
|
+
obj.pushNotificationConfig = PushNotificationConfig.toJSON(message.pushNotificationConfig);
|
|
1481
|
+
}
|
|
1482
|
+
return obj;
|
|
1483
|
+
}
|
|
1484
|
+
};
|
|
1485
|
+
var StringList = {
|
|
1486
|
+
fromJSON(object) {
|
|
1487
|
+
return { list: globalThis.Array.isArray(object?.list) ? object.list.map((e) => globalThis.String(e)) : [] };
|
|
1488
|
+
},
|
|
1489
|
+
toJSON(message) {
|
|
1490
|
+
const obj = {};
|
|
1491
|
+
if (message.list?.length) {
|
|
1492
|
+
obj.list = message.list;
|
|
1493
|
+
}
|
|
1494
|
+
return obj;
|
|
1495
|
+
}
|
|
1496
|
+
};
|
|
1497
|
+
var Security = {
|
|
1498
|
+
fromJSON(object) {
|
|
1499
|
+
return {
|
|
1500
|
+
schemes: isObject(object.schemes) ? globalThis.Object.entries(object.schemes).reduce(
|
|
1501
|
+
(acc, [key, value]) => {
|
|
1502
|
+
acc[key] = StringList.fromJSON(value);
|
|
1503
|
+
return acc;
|
|
1504
|
+
},
|
|
1505
|
+
{}
|
|
1506
|
+
) : {}
|
|
1507
|
+
};
|
|
1508
|
+
},
|
|
1509
|
+
toJSON(message) {
|
|
1510
|
+
const obj = {};
|
|
1511
|
+
if (message.schemes) {
|
|
1512
|
+
const entries = globalThis.Object.entries(message.schemes);
|
|
1513
|
+
if (entries.length > 0) {
|
|
1514
|
+
obj.schemes = {};
|
|
1515
|
+
entries.forEach(([k, v]) => {
|
|
1516
|
+
obj.schemes[k] = StringList.toJSON(v);
|
|
1517
|
+
});
|
|
1518
|
+
}
|
|
1519
|
+
}
|
|
1520
|
+
return obj;
|
|
1521
|
+
}
|
|
1522
|
+
};
|
|
1523
|
+
var SecurityScheme = {
|
|
1524
|
+
fromJSON(object) {
|
|
1525
|
+
return {
|
|
1526
|
+
scheme: isSet2(object.apiKeySecurityScheme) ? { $case: "apiKeySecurityScheme", value: APIKeySecurityScheme.fromJSON(object.apiKeySecurityScheme) } : isSet2(object.api_key_security_scheme) ? { $case: "apiKeySecurityScheme", value: APIKeySecurityScheme.fromJSON(object.api_key_security_scheme) } : isSet2(object.httpAuthSecurityScheme) ? { $case: "httpAuthSecurityScheme", value: HTTPAuthSecurityScheme.fromJSON(object.httpAuthSecurityScheme) } : isSet2(object.http_auth_security_scheme) ? { $case: "httpAuthSecurityScheme", value: HTTPAuthSecurityScheme.fromJSON(object.http_auth_security_scheme) } : isSet2(object.oauth2SecurityScheme) ? { $case: "oauth2SecurityScheme", value: OAuth2SecurityScheme.fromJSON(object.oauth2SecurityScheme) } : isSet2(object.oauth2_security_scheme) ? { $case: "oauth2SecurityScheme", value: OAuth2SecurityScheme.fromJSON(object.oauth2_security_scheme) } : isSet2(object.openIdConnectSecurityScheme) ? {
|
|
1527
|
+
$case: "openIdConnectSecurityScheme",
|
|
1528
|
+
value: OpenIdConnectSecurityScheme.fromJSON(object.openIdConnectSecurityScheme)
|
|
1529
|
+
} : isSet2(object.open_id_connect_security_scheme) ? {
|
|
1530
|
+
$case: "openIdConnectSecurityScheme",
|
|
1531
|
+
value: OpenIdConnectSecurityScheme.fromJSON(object.open_id_connect_security_scheme)
|
|
1532
|
+
} : isSet2(object.mtlsSecurityScheme) ? { $case: "mtlsSecurityScheme", value: MutualTlsSecurityScheme.fromJSON(object.mtlsSecurityScheme) } : isSet2(object.mtls_security_scheme) ? { $case: "mtlsSecurityScheme", value: MutualTlsSecurityScheme.fromJSON(object.mtls_security_scheme) } : void 0
|
|
1533
|
+
};
|
|
1534
|
+
},
|
|
1535
|
+
toJSON(message) {
|
|
1536
|
+
const obj = {};
|
|
1537
|
+
if (message.scheme?.$case === "apiKeySecurityScheme") {
|
|
1538
|
+
obj.apiKeySecurityScheme = APIKeySecurityScheme.toJSON(message.scheme.value);
|
|
1539
|
+
} else if (message.scheme?.$case === "httpAuthSecurityScheme") {
|
|
1540
|
+
obj.httpAuthSecurityScheme = HTTPAuthSecurityScheme.toJSON(message.scheme.value);
|
|
1541
|
+
} else if (message.scheme?.$case === "oauth2SecurityScheme") {
|
|
1542
|
+
obj.oauth2SecurityScheme = OAuth2SecurityScheme.toJSON(message.scheme.value);
|
|
1543
|
+
} else if (message.scheme?.$case === "openIdConnectSecurityScheme") {
|
|
1544
|
+
obj.openIdConnectSecurityScheme = OpenIdConnectSecurityScheme.toJSON(message.scheme.value);
|
|
1545
|
+
} else if (message.scheme?.$case === "mtlsSecurityScheme") {
|
|
1546
|
+
obj.mtlsSecurityScheme = MutualTlsSecurityScheme.toJSON(message.scheme.value);
|
|
1547
|
+
}
|
|
1548
|
+
return obj;
|
|
1549
|
+
}
|
|
1550
|
+
};
|
|
1551
|
+
var APIKeySecurityScheme = {
|
|
1552
|
+
fromJSON(object) {
|
|
1553
|
+
return {
|
|
1554
|
+
description: isSet2(object.description) ? globalThis.String(object.description) : void 0,
|
|
1555
|
+
location: isSet2(object.location) ? globalThis.String(object.location) : void 0,
|
|
1556
|
+
name: isSet2(object.name) ? globalThis.String(object.name) : void 0
|
|
1557
|
+
};
|
|
1558
|
+
},
|
|
1559
|
+
toJSON(message) {
|
|
1560
|
+
const obj = {};
|
|
1561
|
+
if (message.description !== void 0) {
|
|
1562
|
+
obj.description = message.description;
|
|
1563
|
+
}
|
|
1564
|
+
if (message.location !== void 0) {
|
|
1565
|
+
obj.location = message.location;
|
|
1566
|
+
}
|
|
1567
|
+
if (message.name !== void 0) {
|
|
1568
|
+
obj.name = message.name;
|
|
1569
|
+
}
|
|
1570
|
+
return obj;
|
|
1571
|
+
}
|
|
1572
|
+
};
|
|
1573
|
+
var HTTPAuthSecurityScheme = {
|
|
1574
|
+
fromJSON(object) {
|
|
1575
|
+
return {
|
|
1576
|
+
description: isSet2(object.description) ? globalThis.String(object.description) : void 0,
|
|
1577
|
+
scheme: isSet2(object.scheme) ? globalThis.String(object.scheme) : void 0,
|
|
1578
|
+
bearerFormat: isSet2(object.bearerFormat) ? globalThis.String(object.bearerFormat) : isSet2(object.bearer_format) ? globalThis.String(object.bearer_format) : void 0
|
|
1579
|
+
};
|
|
1580
|
+
},
|
|
1581
|
+
toJSON(message) {
|
|
1582
|
+
const obj = {};
|
|
1583
|
+
if (message.description !== void 0) {
|
|
1584
|
+
obj.description = message.description;
|
|
1585
|
+
}
|
|
1586
|
+
if (message.scheme !== void 0) {
|
|
1587
|
+
obj.scheme = message.scheme;
|
|
1588
|
+
}
|
|
1589
|
+
if (message.bearerFormat !== void 0) {
|
|
1590
|
+
obj.bearerFormat = message.bearerFormat;
|
|
1591
|
+
}
|
|
1592
|
+
return obj;
|
|
1593
|
+
}
|
|
1594
|
+
};
|
|
1595
|
+
var OAuth2SecurityScheme = {
|
|
1596
|
+
fromJSON(object) {
|
|
1597
|
+
return {
|
|
1598
|
+
description: isSet2(object.description) ? globalThis.String(object.description) : void 0,
|
|
1599
|
+
flows: isSet2(object.flows) ? OAuthFlows.fromJSON(object.flows) : void 0,
|
|
1600
|
+
oauth2MetadataUrl: isSet2(object.oauth2MetadataUrl) ? globalThis.String(object.oauth2MetadataUrl) : isSet2(object.oauth2_metadata_url) ? globalThis.String(object.oauth2_metadata_url) : void 0
|
|
1601
|
+
};
|
|
1602
|
+
},
|
|
1603
|
+
toJSON(message) {
|
|
1604
|
+
const obj = {};
|
|
1605
|
+
if (message.description !== void 0) {
|
|
1606
|
+
obj.description = message.description;
|
|
1607
|
+
}
|
|
1608
|
+
if (message.flows !== void 0) {
|
|
1609
|
+
obj.flows = OAuthFlows.toJSON(message.flows);
|
|
1610
|
+
}
|
|
1611
|
+
if (message.oauth2MetadataUrl !== void 0) {
|
|
1612
|
+
obj.oauth2MetadataUrl = message.oauth2MetadataUrl;
|
|
1613
|
+
}
|
|
1614
|
+
return obj;
|
|
1615
|
+
}
|
|
1616
|
+
};
|
|
1617
|
+
var OpenIdConnectSecurityScheme = {
|
|
1618
|
+
fromJSON(object) {
|
|
1619
|
+
return {
|
|
1620
|
+
description: isSet2(object.description) ? globalThis.String(object.description) : void 0,
|
|
1621
|
+
openIdConnectUrl: isSet2(object.openIdConnectUrl) ? globalThis.String(object.openIdConnectUrl) : isSet2(object.open_id_connect_url) ? globalThis.String(object.open_id_connect_url) : void 0
|
|
1622
|
+
};
|
|
1623
|
+
},
|
|
1624
|
+
toJSON(message) {
|
|
1625
|
+
const obj = {};
|
|
1626
|
+
if (message.description !== void 0) {
|
|
1627
|
+
obj.description = message.description;
|
|
1628
|
+
}
|
|
1629
|
+
if (message.openIdConnectUrl !== void 0) {
|
|
1630
|
+
obj.openIdConnectUrl = message.openIdConnectUrl;
|
|
1631
|
+
}
|
|
1632
|
+
return obj;
|
|
1633
|
+
}
|
|
1634
|
+
};
|
|
1635
|
+
var MutualTlsSecurityScheme = {
|
|
1636
|
+
fromJSON(object) {
|
|
1637
|
+
return { description: isSet2(object.description) ? globalThis.String(object.description) : void 0 };
|
|
1638
|
+
},
|
|
1639
|
+
toJSON(message) {
|
|
1640
|
+
const obj = {};
|
|
1641
|
+
if (message.description !== void 0) {
|
|
1642
|
+
obj.description = message.description;
|
|
1643
|
+
}
|
|
1644
|
+
return obj;
|
|
1645
|
+
}
|
|
1646
|
+
};
|
|
1647
|
+
var OAuthFlows = {
|
|
1648
|
+
fromJSON(object) {
|
|
1649
|
+
return {
|
|
1650
|
+
flow: isSet2(object.authorizationCode) ? { $case: "authorizationCode", value: AuthorizationCodeOAuthFlow.fromJSON(object.authorizationCode) } : isSet2(object.authorization_code) ? { $case: "authorizationCode", value: AuthorizationCodeOAuthFlow.fromJSON(object.authorization_code) } : isSet2(object.clientCredentials) ? { $case: "clientCredentials", value: ClientCredentialsOAuthFlow.fromJSON(object.clientCredentials) } : isSet2(object.client_credentials) ? { $case: "clientCredentials", value: ClientCredentialsOAuthFlow.fromJSON(object.client_credentials) } : isSet2(object.implicit) ? { $case: "implicit", value: ImplicitOAuthFlow.fromJSON(object.implicit) } : isSet2(object.password) ? { $case: "password", value: PasswordOAuthFlow.fromJSON(object.password) } : void 0
|
|
1651
|
+
};
|
|
1652
|
+
},
|
|
1653
|
+
toJSON(message) {
|
|
1654
|
+
const obj = {};
|
|
1655
|
+
if (message.flow?.$case === "authorizationCode") {
|
|
1656
|
+
obj.authorizationCode = AuthorizationCodeOAuthFlow.toJSON(message.flow.value);
|
|
1657
|
+
} else if (message.flow?.$case === "clientCredentials") {
|
|
1658
|
+
obj.clientCredentials = ClientCredentialsOAuthFlow.toJSON(message.flow.value);
|
|
1659
|
+
} else if (message.flow?.$case === "implicit") {
|
|
1660
|
+
obj.implicit = ImplicitOAuthFlow.toJSON(message.flow.value);
|
|
1661
|
+
} else if (message.flow?.$case === "password") {
|
|
1662
|
+
obj.password = PasswordOAuthFlow.toJSON(message.flow.value);
|
|
1663
|
+
}
|
|
1664
|
+
return obj;
|
|
1665
|
+
}
|
|
1666
|
+
};
|
|
1667
|
+
var AuthorizationCodeOAuthFlow = {
|
|
1668
|
+
fromJSON(object) {
|
|
1669
|
+
return {
|
|
1670
|
+
authorizationUrl: isSet2(object.authorizationUrl) ? globalThis.String(object.authorizationUrl) : isSet2(object.authorization_url) ? globalThis.String(object.authorization_url) : void 0,
|
|
1671
|
+
tokenUrl: isSet2(object.tokenUrl) ? globalThis.String(object.tokenUrl) : isSet2(object.token_url) ? globalThis.String(object.token_url) : void 0,
|
|
1672
|
+
refreshUrl: isSet2(object.refreshUrl) ? globalThis.String(object.refreshUrl) : isSet2(object.refresh_url) ? globalThis.String(object.refresh_url) : void 0,
|
|
1673
|
+
scopes: isObject(object.scopes) ? globalThis.Object.entries(object.scopes).reduce(
|
|
1674
|
+
(acc, [key, value]) => {
|
|
1675
|
+
acc[key] = globalThis.String(value);
|
|
1676
|
+
return acc;
|
|
1677
|
+
},
|
|
1678
|
+
{}
|
|
1679
|
+
) : {}
|
|
1680
|
+
};
|
|
1681
|
+
},
|
|
1682
|
+
toJSON(message) {
|
|
1683
|
+
const obj = {};
|
|
1684
|
+
if (message.authorizationUrl !== void 0) {
|
|
1685
|
+
obj.authorizationUrl = message.authorizationUrl;
|
|
1686
|
+
}
|
|
1687
|
+
if (message.tokenUrl !== void 0) {
|
|
1688
|
+
obj.tokenUrl = message.tokenUrl;
|
|
1689
|
+
}
|
|
1690
|
+
if (message.refreshUrl !== void 0) {
|
|
1691
|
+
obj.refreshUrl = message.refreshUrl;
|
|
1692
|
+
}
|
|
1693
|
+
if (message.scopes) {
|
|
1694
|
+
const entries = globalThis.Object.entries(message.scopes);
|
|
1695
|
+
if (entries.length > 0) {
|
|
1696
|
+
obj.scopes = {};
|
|
1697
|
+
entries.forEach(([k, v]) => {
|
|
1698
|
+
obj.scopes[k] = v;
|
|
1699
|
+
});
|
|
1700
|
+
}
|
|
1701
|
+
}
|
|
1702
|
+
return obj;
|
|
1703
|
+
}
|
|
1704
|
+
};
|
|
1705
|
+
var ClientCredentialsOAuthFlow = {
|
|
1706
|
+
fromJSON(object) {
|
|
1707
|
+
return {
|
|
1708
|
+
tokenUrl: isSet2(object.tokenUrl) ? globalThis.String(object.tokenUrl) : isSet2(object.token_url) ? globalThis.String(object.token_url) : void 0,
|
|
1709
|
+
refreshUrl: isSet2(object.refreshUrl) ? globalThis.String(object.refreshUrl) : isSet2(object.refresh_url) ? globalThis.String(object.refresh_url) : void 0,
|
|
1710
|
+
scopes: isObject(object.scopes) ? globalThis.Object.entries(object.scopes).reduce(
|
|
1711
|
+
(acc, [key, value]) => {
|
|
1712
|
+
acc[key] = globalThis.String(value);
|
|
1713
|
+
return acc;
|
|
1714
|
+
},
|
|
1715
|
+
{}
|
|
1716
|
+
) : {}
|
|
1717
|
+
};
|
|
1718
|
+
},
|
|
1719
|
+
toJSON(message) {
|
|
1720
|
+
const obj = {};
|
|
1721
|
+
if (message.tokenUrl !== void 0) {
|
|
1722
|
+
obj.tokenUrl = message.tokenUrl;
|
|
1723
|
+
}
|
|
1724
|
+
if (message.refreshUrl !== void 0) {
|
|
1725
|
+
obj.refreshUrl = message.refreshUrl;
|
|
1726
|
+
}
|
|
1727
|
+
if (message.scopes) {
|
|
1728
|
+
const entries = globalThis.Object.entries(message.scopes);
|
|
1729
|
+
if (entries.length > 0) {
|
|
1730
|
+
obj.scopes = {};
|
|
1731
|
+
entries.forEach(([k, v]) => {
|
|
1732
|
+
obj.scopes[k] = v;
|
|
1733
|
+
});
|
|
1734
|
+
}
|
|
1735
|
+
}
|
|
1736
|
+
return obj;
|
|
1737
|
+
}
|
|
1738
|
+
};
|
|
1739
|
+
var ImplicitOAuthFlow = {
|
|
1740
|
+
fromJSON(object) {
|
|
1741
|
+
return {
|
|
1742
|
+
authorizationUrl: isSet2(object.authorizationUrl) ? globalThis.String(object.authorizationUrl) : isSet2(object.authorization_url) ? globalThis.String(object.authorization_url) : void 0,
|
|
1743
|
+
refreshUrl: isSet2(object.refreshUrl) ? globalThis.String(object.refreshUrl) : isSet2(object.refresh_url) ? globalThis.String(object.refresh_url) : void 0,
|
|
1744
|
+
scopes: isObject(object.scopes) ? globalThis.Object.entries(object.scopes).reduce(
|
|
1745
|
+
(acc, [key, value]) => {
|
|
1746
|
+
acc[key] = globalThis.String(value);
|
|
1747
|
+
return acc;
|
|
1748
|
+
},
|
|
1749
|
+
{}
|
|
1750
|
+
) : {}
|
|
1751
|
+
};
|
|
1752
|
+
},
|
|
1753
|
+
toJSON(message) {
|
|
1754
|
+
const obj = {};
|
|
1755
|
+
if (message.authorizationUrl !== void 0) {
|
|
1756
|
+
obj.authorizationUrl = message.authorizationUrl;
|
|
1757
|
+
}
|
|
1758
|
+
if (message.refreshUrl !== void 0) {
|
|
1759
|
+
obj.refreshUrl = message.refreshUrl;
|
|
1760
|
+
}
|
|
1761
|
+
if (message.scopes) {
|
|
1762
|
+
const entries = globalThis.Object.entries(message.scopes);
|
|
1763
|
+
if (entries.length > 0) {
|
|
1764
|
+
obj.scopes = {};
|
|
1765
|
+
entries.forEach(([k, v]) => {
|
|
1766
|
+
obj.scopes[k] = v;
|
|
1767
|
+
});
|
|
1768
|
+
}
|
|
1769
|
+
}
|
|
1770
|
+
return obj;
|
|
1771
|
+
}
|
|
1772
|
+
};
|
|
1773
|
+
var PasswordOAuthFlow = {
|
|
1774
|
+
fromJSON(object) {
|
|
1775
|
+
return {
|
|
1776
|
+
tokenUrl: isSet2(object.tokenUrl) ? globalThis.String(object.tokenUrl) : isSet2(object.token_url) ? globalThis.String(object.token_url) : void 0,
|
|
1777
|
+
refreshUrl: isSet2(object.refreshUrl) ? globalThis.String(object.refreshUrl) : isSet2(object.refresh_url) ? globalThis.String(object.refresh_url) : void 0,
|
|
1778
|
+
scopes: isObject(object.scopes) ? globalThis.Object.entries(object.scopes).reduce(
|
|
1779
|
+
(acc, [key, value]) => {
|
|
1780
|
+
acc[key] = globalThis.String(value);
|
|
1781
|
+
return acc;
|
|
1782
|
+
},
|
|
1783
|
+
{}
|
|
1784
|
+
) : {}
|
|
1785
|
+
};
|
|
1786
|
+
},
|
|
1787
|
+
toJSON(message) {
|
|
1788
|
+
const obj = {};
|
|
1789
|
+
if (message.tokenUrl !== void 0) {
|
|
1790
|
+
obj.tokenUrl = message.tokenUrl;
|
|
1791
|
+
}
|
|
1792
|
+
if (message.refreshUrl !== void 0) {
|
|
1793
|
+
obj.refreshUrl = message.refreshUrl;
|
|
1794
|
+
}
|
|
1795
|
+
if (message.scopes) {
|
|
1796
|
+
const entries = globalThis.Object.entries(message.scopes);
|
|
1797
|
+
if (entries.length > 0) {
|
|
1798
|
+
obj.scopes = {};
|
|
1799
|
+
entries.forEach(([k, v]) => {
|
|
1800
|
+
obj.scopes[k] = v;
|
|
1801
|
+
});
|
|
1802
|
+
}
|
|
1803
|
+
}
|
|
1804
|
+
return obj;
|
|
1805
|
+
}
|
|
1806
|
+
};
|
|
1807
|
+
var SendMessageRequest = {
|
|
1808
|
+
fromJSON(object) {
|
|
1809
|
+
return {
|
|
1810
|
+
request: isSet2(object.message) ? Message.fromJSON(object.message) : isSet2(object.request) ? Message.fromJSON(object.request) : void 0,
|
|
1811
|
+
configuration: isSet2(object.configuration) ? SendMessageConfiguration.fromJSON(object.configuration) : void 0,
|
|
1812
|
+
metadata: isObject(object.metadata) ? object.metadata : void 0
|
|
1813
|
+
};
|
|
1814
|
+
},
|
|
1815
|
+
toJSON(message) {
|
|
1816
|
+
const obj = {};
|
|
1817
|
+
if (message.request !== void 0) {
|
|
1818
|
+
obj.message = Message.toJSON(message.request);
|
|
1819
|
+
}
|
|
1820
|
+
if (message.configuration !== void 0) {
|
|
1821
|
+
obj.configuration = SendMessageConfiguration.toJSON(message.configuration);
|
|
1822
|
+
}
|
|
1823
|
+
if (message.metadata !== void 0) {
|
|
1824
|
+
obj.metadata = message.metadata;
|
|
1825
|
+
}
|
|
1826
|
+
return obj;
|
|
1827
|
+
}
|
|
1828
|
+
};
|
|
1829
|
+
var SendMessageResponse = {
|
|
1830
|
+
fromJSON(object) {
|
|
1831
|
+
return {
|
|
1832
|
+
payload: isSet2(object.task) ? { $case: "task", value: Task.fromJSON(object.task) } : isSet2(object.message) ? { $case: "msg", value: Message.fromJSON(object.message) } : isSet2(object.msg) ? { $case: "msg", value: Message.fromJSON(object.msg) } : void 0
|
|
1833
|
+
};
|
|
1834
|
+
},
|
|
1835
|
+
toJSON(message) {
|
|
1836
|
+
const obj = {};
|
|
1837
|
+
if (message.payload?.$case === "task") {
|
|
1838
|
+
obj.task = Task.toJSON(message.payload.value);
|
|
1839
|
+
} else if (message.payload?.$case === "msg") {
|
|
1840
|
+
obj.message = Message.toJSON(message.payload.value);
|
|
1841
|
+
}
|
|
1842
|
+
return obj;
|
|
1843
|
+
}
|
|
1844
|
+
};
|
|
1845
|
+
var StreamResponse = {
|
|
1846
|
+
fromJSON(object) {
|
|
1847
|
+
return {
|
|
1848
|
+
payload: isSet2(object.task) ? { $case: "task", value: Task.fromJSON(object.task) } : isSet2(object.message) ? { $case: "msg", value: Message.fromJSON(object.message) } : isSet2(object.msg) ? { $case: "msg", value: Message.fromJSON(object.msg) } : isSet2(object.statusUpdate) ? { $case: "statusUpdate", value: TaskStatusUpdateEvent.fromJSON(object.statusUpdate) } : isSet2(object.status_update) ? { $case: "statusUpdate", value: TaskStatusUpdateEvent.fromJSON(object.status_update) } : isSet2(object.artifactUpdate) ? { $case: "artifactUpdate", value: TaskArtifactUpdateEvent.fromJSON(object.artifactUpdate) } : isSet2(object.artifact_update) ? { $case: "artifactUpdate", value: TaskArtifactUpdateEvent.fromJSON(object.artifact_update) } : void 0
|
|
1849
|
+
};
|
|
1850
|
+
},
|
|
1851
|
+
toJSON(message) {
|
|
1852
|
+
const obj = {};
|
|
1853
|
+
if (message.payload?.$case === "task") {
|
|
1854
|
+
obj.task = Task.toJSON(message.payload.value);
|
|
1855
|
+
} else if (message.payload?.$case === "msg") {
|
|
1856
|
+
obj.message = Message.toJSON(message.payload.value);
|
|
1857
|
+
} else if (message.payload?.$case === "statusUpdate") {
|
|
1858
|
+
obj.statusUpdate = TaskStatusUpdateEvent.toJSON(message.payload.value);
|
|
1859
|
+
} else if (message.payload?.$case === "artifactUpdate") {
|
|
1860
|
+
obj.artifactUpdate = TaskArtifactUpdateEvent.toJSON(message.payload.value);
|
|
1861
|
+
}
|
|
1862
|
+
return obj;
|
|
1863
|
+
}
|
|
1864
|
+
};
|
|
1865
|
+
var ListTaskPushNotificationConfigResponse = {
|
|
1866
|
+
fromJSON(object) {
|
|
1867
|
+
return {
|
|
1868
|
+
configs: globalThis.Array.isArray(object?.configs) ? object.configs.map((e) => TaskPushNotificationConfig.fromJSON(e)) : [],
|
|
1869
|
+
nextPageToken: isSet2(object.nextPageToken) ? globalThis.String(object.nextPageToken) : isSet2(object.next_page_token) ? globalThis.String(object.next_page_token) : void 0
|
|
1870
|
+
};
|
|
1871
|
+
},
|
|
1872
|
+
toJSON(message) {
|
|
1873
|
+
const obj = {};
|
|
1874
|
+
if (message.configs?.length) {
|
|
1875
|
+
obj.configs = message.configs.map((e) => TaskPushNotificationConfig.toJSON(e));
|
|
1876
|
+
}
|
|
1877
|
+
if (message.nextPageToken !== void 0) {
|
|
1878
|
+
obj.nextPageToken = message.nextPageToken;
|
|
1879
|
+
}
|
|
1880
|
+
return obj;
|
|
1881
|
+
}
|
|
1882
|
+
};
|
|
1883
|
+
function bytesFromBase64(b64) {
|
|
1884
|
+
return Uint8Array.from(globalThis.Buffer.from(b64, "base64"));
|
|
1885
|
+
}
|
|
1886
|
+
function base64FromBytes(arr) {
|
|
1887
|
+
return globalThis.Buffer.from(arr).toString("base64");
|
|
1888
|
+
}
|
|
1889
|
+
function fromTimestamp(t) {
|
|
1890
|
+
let millis = (t.seconds || 0) * 1e3;
|
|
1891
|
+
millis += (t.nanos || 0) / 1e6;
|
|
1892
|
+
return new globalThis.Date(millis);
|
|
1893
|
+
}
|
|
1894
|
+
function fromJsonTimestamp(o) {
|
|
1895
|
+
if (o instanceof globalThis.Date) {
|
|
1896
|
+
return o;
|
|
1897
|
+
} else if (typeof o === "string") {
|
|
1898
|
+
return new globalThis.Date(o);
|
|
1899
|
+
} else {
|
|
1900
|
+
return fromTimestamp(Timestamp.fromJSON(o));
|
|
1901
|
+
}
|
|
1902
|
+
}
|
|
1903
|
+
function isObject(value) {
|
|
1904
|
+
return typeof value === "object" && value !== null;
|
|
1905
|
+
}
|
|
1906
|
+
function isSet2(value) {
|
|
1907
|
+
return value !== null && value !== void 0;
|
|
1908
|
+
}
|
|
1909
|
+
|
|
1910
|
+
// src/types/converters/id_decoding.ts
|
|
1911
|
+
var CONFIG_REGEX = /^tasks\/([^/]+)\/pushNotificationConfigs\/([^/]+)$/;
|
|
1912
|
+
var TASK_ONLY_REGEX = /^tasks\/([^/]+)(?:\/|$)/;
|
|
1913
|
+
var extractTaskId = (name) => {
|
|
1914
|
+
const match = name.match(TASK_ONLY_REGEX);
|
|
1915
|
+
if (!match) {
|
|
1916
|
+
throw A2AError.invalidParams(`Invalid or missing task ID in: "${name}"`);
|
|
1917
|
+
}
|
|
1918
|
+
return match[1];
|
|
1919
|
+
};
|
|
1920
|
+
var generateTaskName = (taskId) => {
|
|
1921
|
+
return `tasks/${taskId}`;
|
|
1922
|
+
};
|
|
1923
|
+
var extractTaskAndPushNotificationConfigId = (name) => {
|
|
1924
|
+
const match = name.match(CONFIG_REGEX);
|
|
1925
|
+
if (!match) {
|
|
1926
|
+
throw A2AError.invalidParams(`Invalid or missing config ID in: "${name}"`);
|
|
1927
|
+
}
|
|
1928
|
+
return { taskId: match[1], configId: match[2] };
|
|
1929
|
+
};
|
|
1930
|
+
var generatePushNotificationConfigName = (taskId, configId) => {
|
|
1931
|
+
return `tasks/${taskId}/pushNotificationConfigs/${configId}`;
|
|
1932
|
+
};
|
|
1933
|
+
|
|
1934
|
+
// src/types/converters/from_proto.ts
|
|
1935
|
+
var FromProto = class _FromProto {
|
|
1936
|
+
static taskQueryParams(request) {
|
|
1937
|
+
return {
|
|
1938
|
+
id: extractTaskId(request.name),
|
|
1939
|
+
historyLength: request.historyLength
|
|
1940
|
+
};
|
|
1941
|
+
}
|
|
1942
|
+
static taskIdParams(request) {
|
|
1943
|
+
return {
|
|
1944
|
+
id: extractTaskId(request.name)
|
|
1945
|
+
};
|
|
1946
|
+
}
|
|
1947
|
+
static getTaskPushNotificationConfigParams(request) {
|
|
1948
|
+
const { taskId, configId } = extractTaskAndPushNotificationConfigId(request.name);
|
|
1949
|
+
return {
|
|
1950
|
+
id: taskId,
|
|
1951
|
+
pushNotificationConfigId: configId
|
|
1952
|
+
};
|
|
1953
|
+
}
|
|
1954
|
+
static listTaskPushNotificationConfigParams(request) {
|
|
1955
|
+
return {
|
|
1956
|
+
id: extractTaskId(request.parent)
|
|
1957
|
+
};
|
|
1958
|
+
}
|
|
1959
|
+
static createTaskPushNotificationConfig(request) {
|
|
1960
|
+
if (!request.config?.pushNotificationConfig) {
|
|
1961
|
+
throw A2AError.invalidParams(
|
|
1962
|
+
"Request must include a `config` object with a `pushNotificationConfig`"
|
|
1963
|
+
);
|
|
1964
|
+
}
|
|
1965
|
+
return {
|
|
1966
|
+
taskId: extractTaskId(request.parent),
|
|
1967
|
+
pushNotificationConfig: _FromProto.pushNotificationConfig(
|
|
1968
|
+
request.config.pushNotificationConfig
|
|
1969
|
+
)
|
|
1970
|
+
};
|
|
1971
|
+
}
|
|
1972
|
+
static deleteTaskPushNotificationConfigParams(request) {
|
|
1973
|
+
const { taskId, configId } = extractTaskAndPushNotificationConfigId(request.name);
|
|
1974
|
+
return {
|
|
1975
|
+
id: taskId,
|
|
1976
|
+
pushNotificationConfigId: configId
|
|
1977
|
+
};
|
|
1978
|
+
}
|
|
1979
|
+
static message(message) {
|
|
1980
|
+
if (!message) {
|
|
1981
|
+
return void 0;
|
|
1982
|
+
}
|
|
1983
|
+
return {
|
|
1984
|
+
kind: "message",
|
|
1985
|
+
messageId: message.messageId,
|
|
1986
|
+
parts: message.content.map((p) => _FromProto.parts(p)),
|
|
1987
|
+
contextId: message.contextId,
|
|
1988
|
+
taskId: message.taskId,
|
|
1989
|
+
role: _FromProto.role(message.role),
|
|
1990
|
+
metadata: message.metadata,
|
|
1991
|
+
extensions: message.extensions
|
|
1992
|
+
};
|
|
1993
|
+
}
|
|
1994
|
+
static role(role) {
|
|
1995
|
+
switch (role) {
|
|
1996
|
+
case 2 /* ROLE_AGENT */:
|
|
1997
|
+
return "agent";
|
|
1998
|
+
case 1 /* ROLE_USER */:
|
|
1999
|
+
return "user";
|
|
2000
|
+
default:
|
|
2001
|
+
throw A2AError.invalidParams(`Invalid role: ${role}`);
|
|
2002
|
+
}
|
|
2003
|
+
}
|
|
2004
|
+
static messageSendConfiguration(configuration) {
|
|
2005
|
+
if (!configuration) {
|
|
2006
|
+
return void 0;
|
|
2007
|
+
}
|
|
2008
|
+
return {
|
|
2009
|
+
blocking: configuration.blocking,
|
|
2010
|
+
acceptedOutputModes: configuration.acceptedOutputModes,
|
|
2011
|
+
pushNotificationConfig: _FromProto.pushNotificationConfig(configuration.pushNotification)
|
|
2012
|
+
};
|
|
2013
|
+
}
|
|
2014
|
+
static pushNotificationConfig(config) {
|
|
2015
|
+
if (!config) {
|
|
2016
|
+
return void 0;
|
|
2017
|
+
}
|
|
2018
|
+
return {
|
|
2019
|
+
id: config.id,
|
|
2020
|
+
url: config.url,
|
|
2021
|
+
token: config.token,
|
|
2022
|
+
authentication: _FromProto.pushNotificationAuthenticationInfo(config.authentication)
|
|
2023
|
+
};
|
|
2024
|
+
}
|
|
2025
|
+
static pushNotificationAuthenticationInfo(authInfo) {
|
|
2026
|
+
if (!authInfo) {
|
|
2027
|
+
return void 0;
|
|
2028
|
+
}
|
|
2029
|
+
return {
|
|
2030
|
+
schemes: authInfo.schemes,
|
|
2031
|
+
credentials: authInfo.credentials
|
|
2032
|
+
};
|
|
2033
|
+
}
|
|
2034
|
+
static parts(part) {
|
|
2035
|
+
if (part.part?.$case === "text") {
|
|
2036
|
+
return {
|
|
2037
|
+
kind: "text",
|
|
2038
|
+
text: part.part.value
|
|
2039
|
+
};
|
|
2040
|
+
}
|
|
2041
|
+
if (part.part?.$case === "file") {
|
|
2042
|
+
const filePart = part.part.value;
|
|
2043
|
+
if (filePart.file?.$case === "fileWithUri") {
|
|
2044
|
+
return {
|
|
2045
|
+
kind: "file",
|
|
2046
|
+
file: {
|
|
2047
|
+
uri: filePart.file.value,
|
|
2048
|
+
mimeType: filePart.mimeType
|
|
2049
|
+
}
|
|
2050
|
+
};
|
|
2051
|
+
} else if (filePart.file?.$case === "fileWithBytes") {
|
|
2052
|
+
return {
|
|
2053
|
+
kind: "file",
|
|
2054
|
+
file: {
|
|
2055
|
+
bytes: filePart.file.value.toString("base64"),
|
|
2056
|
+
mimeType: filePart.mimeType
|
|
2057
|
+
}
|
|
2058
|
+
};
|
|
2059
|
+
}
|
|
2060
|
+
throw A2AError.invalidParams("Invalid file part type");
|
|
2061
|
+
}
|
|
2062
|
+
if (part.part?.$case === "data") {
|
|
2063
|
+
return {
|
|
2064
|
+
kind: "data",
|
|
2065
|
+
data: part.part.value.data
|
|
2066
|
+
};
|
|
2067
|
+
}
|
|
2068
|
+
throw A2AError.invalidParams("Invalid part type");
|
|
2069
|
+
}
|
|
2070
|
+
static messageSendParams(request) {
|
|
2071
|
+
return {
|
|
2072
|
+
message: _FromProto.message(request.request),
|
|
2073
|
+
configuration: _FromProto.messageSendConfiguration(request.configuration),
|
|
2074
|
+
metadata: request.metadata
|
|
2075
|
+
};
|
|
2076
|
+
}
|
|
2077
|
+
static sendMessageResult(response) {
|
|
2078
|
+
if (response.payload?.$case === "task") {
|
|
2079
|
+
return _FromProto.task(response.payload.value);
|
|
2080
|
+
} else if (response.payload?.$case === "msg") {
|
|
2081
|
+
return _FromProto.message(response.payload.value);
|
|
2082
|
+
}
|
|
2083
|
+
throw A2AError.invalidParams("Invalid SendMessageResponse: missing result");
|
|
2084
|
+
}
|
|
2085
|
+
static task(task) {
|
|
2086
|
+
return {
|
|
2087
|
+
kind: "task",
|
|
2088
|
+
id: task.id,
|
|
2089
|
+
status: _FromProto.taskStatus(task.status),
|
|
2090
|
+
contextId: task.contextId,
|
|
2091
|
+
artifacts: task.artifacts?.map((a) => _FromProto.artifact(a)),
|
|
2092
|
+
history: task.history?.map((h) => _FromProto.message(h)),
|
|
2093
|
+
metadata: task.metadata
|
|
2094
|
+
};
|
|
2095
|
+
}
|
|
2096
|
+
static taskStatus(status) {
|
|
2097
|
+
return {
|
|
2098
|
+
message: _FromProto.message(status.update),
|
|
2099
|
+
state: _FromProto.taskState(status.state),
|
|
2100
|
+
timestamp: status.timestamp?.toISOString()
|
|
2101
|
+
};
|
|
2102
|
+
}
|
|
2103
|
+
static taskState(state) {
|
|
2104
|
+
switch (state) {
|
|
2105
|
+
case 1 /* TASK_STATE_SUBMITTED */:
|
|
2106
|
+
return "submitted";
|
|
2107
|
+
case 2 /* TASK_STATE_WORKING */:
|
|
2108
|
+
return "working";
|
|
2109
|
+
case 6 /* TASK_STATE_INPUT_REQUIRED */:
|
|
2110
|
+
return "input-required";
|
|
2111
|
+
case 3 /* TASK_STATE_COMPLETED */:
|
|
2112
|
+
return "completed";
|
|
2113
|
+
case 5 /* TASK_STATE_CANCELLED */:
|
|
2114
|
+
return "canceled";
|
|
2115
|
+
case 4 /* TASK_STATE_FAILED */:
|
|
2116
|
+
return "failed";
|
|
2117
|
+
case 7 /* TASK_STATE_REJECTED */:
|
|
2118
|
+
return "rejected";
|
|
2119
|
+
case 8 /* TASK_STATE_AUTH_REQUIRED */:
|
|
2120
|
+
return "auth-required";
|
|
2121
|
+
case 0 /* TASK_STATE_UNSPECIFIED */:
|
|
2122
|
+
return "unknown";
|
|
2123
|
+
default:
|
|
2124
|
+
throw A2AError.invalidParams(`Invalid task state: ${state}`);
|
|
2125
|
+
}
|
|
2126
|
+
}
|
|
2127
|
+
static artifact(artifact) {
|
|
2128
|
+
return {
|
|
2129
|
+
artifactId: artifact.artifactId,
|
|
2130
|
+
name: artifact.name,
|
|
2131
|
+
description: artifact.description,
|
|
2132
|
+
parts: artifact.parts.map((p) => _FromProto.parts(p)),
|
|
2133
|
+
metadata: artifact.metadata
|
|
2134
|
+
};
|
|
2135
|
+
}
|
|
2136
|
+
static taskPushNotificationConfig(request) {
|
|
2137
|
+
return {
|
|
2138
|
+
taskId: extractTaskId(request.name),
|
|
2139
|
+
pushNotificationConfig: _FromProto.pushNotificationConfig(request.pushNotificationConfig)
|
|
2140
|
+
};
|
|
2141
|
+
}
|
|
2142
|
+
static listTaskPushNotificationConfig(request) {
|
|
2143
|
+
return request.configs.map((c) => _FromProto.taskPushNotificationConfig(c));
|
|
2144
|
+
}
|
|
2145
|
+
static agentCard(agentCard) {
|
|
2146
|
+
return {
|
|
2147
|
+
additionalInterfaces: agentCard.additionalInterfaces?.map((i) => _FromProto.agentInterface(i)),
|
|
2148
|
+
capabilities: agentCard.capabilities ? _FromProto.agentCapabilities(agentCard.capabilities) : {},
|
|
2149
|
+
defaultInputModes: agentCard.defaultInputModes,
|
|
2150
|
+
defaultOutputModes: agentCard.defaultOutputModes,
|
|
2151
|
+
description: agentCard.description,
|
|
2152
|
+
documentationUrl: agentCard.documentationUrl,
|
|
2153
|
+
name: agentCard.name,
|
|
2154
|
+
preferredTransport: agentCard.preferredTransport,
|
|
2155
|
+
provider: agentCard.provider ? _FromProto.agentProvider(agentCard.provider) : void 0,
|
|
2156
|
+
protocolVersion: agentCard.protocolVersion,
|
|
2157
|
+
security: agentCard.security?.map((s) => _FromProto.security(s)),
|
|
2158
|
+
securitySchemes: agentCard.securitySchemes ? Object.fromEntries(
|
|
2159
|
+
Object.entries(agentCard.securitySchemes).map(([key, value]) => [
|
|
2160
|
+
key,
|
|
2161
|
+
_FromProto.securityScheme(value)
|
|
2162
|
+
])
|
|
2163
|
+
) : {},
|
|
2164
|
+
skills: agentCard.skills.map((s) => _FromProto.skills(s)),
|
|
2165
|
+
signatures: agentCard.signatures?.map((s) => _FromProto.agentCardSignature(s)),
|
|
2166
|
+
supportsAuthenticatedExtendedCard: agentCard.supportsAuthenticatedExtendedCard,
|
|
2167
|
+
url: agentCard.url,
|
|
2168
|
+
version: agentCard.version
|
|
2169
|
+
};
|
|
2170
|
+
}
|
|
2171
|
+
static agentCapabilities(capabilities) {
|
|
2172
|
+
return {
|
|
2173
|
+
extensions: capabilities.extensions?.map((e) => _FromProto.agentExtension(e)),
|
|
2174
|
+
pushNotifications: capabilities.pushNotifications,
|
|
2175
|
+
streaming: capabilities.streaming
|
|
2176
|
+
};
|
|
2177
|
+
}
|
|
2178
|
+
static agentExtension(extension) {
|
|
2179
|
+
return {
|
|
2180
|
+
uri: extension.uri ?? "",
|
|
2181
|
+
description: extension.description,
|
|
2182
|
+
required: extension.required,
|
|
2183
|
+
params: extension.params
|
|
2184
|
+
};
|
|
2185
|
+
}
|
|
2186
|
+
static agentInterface(intf) {
|
|
2187
|
+
return {
|
|
2188
|
+
transport: intf.transport ?? "",
|
|
2189
|
+
url: intf.url ?? ""
|
|
2190
|
+
};
|
|
2191
|
+
}
|
|
2192
|
+
static agentProvider(provider) {
|
|
2193
|
+
return {
|
|
2194
|
+
organization: provider.organization ?? "",
|
|
2195
|
+
url: provider.url ?? ""
|
|
2196
|
+
};
|
|
2197
|
+
}
|
|
2198
|
+
static security(security) {
|
|
2199
|
+
return Object.fromEntries(
|
|
2200
|
+
Object.entries(security.schemes)?.map(([key, value]) => [key, value.list])
|
|
2201
|
+
);
|
|
2202
|
+
}
|
|
2203
|
+
static securityScheme(securitySchemes) {
|
|
2204
|
+
switch (securitySchemes.scheme?.$case) {
|
|
2205
|
+
case "apiKeySecurityScheme":
|
|
2206
|
+
return {
|
|
2207
|
+
type: "apiKey",
|
|
2208
|
+
name: securitySchemes.scheme.value.name,
|
|
2209
|
+
in: securitySchemes.scheme.value.location,
|
|
2210
|
+
description: securitySchemes.scheme.value.description
|
|
2211
|
+
};
|
|
2212
|
+
case "httpAuthSecurityScheme":
|
|
2213
|
+
return {
|
|
2214
|
+
type: "http",
|
|
2215
|
+
scheme: securitySchemes.scheme.value.scheme,
|
|
2216
|
+
bearerFormat: securitySchemes.scheme.value.bearerFormat,
|
|
2217
|
+
description: securitySchemes.scheme.value.description
|
|
2218
|
+
};
|
|
2219
|
+
case "mtlsSecurityScheme":
|
|
2220
|
+
return {
|
|
2221
|
+
type: "mutualTLS",
|
|
2222
|
+
description: securitySchemes.scheme.value.description
|
|
2223
|
+
};
|
|
2224
|
+
case "oauth2SecurityScheme":
|
|
2225
|
+
return {
|
|
2226
|
+
type: "oauth2",
|
|
2227
|
+
description: securitySchemes.scheme.value.description,
|
|
2228
|
+
flows: _FromProto.oauthFlows(securitySchemes.scheme.value.flows),
|
|
2229
|
+
oauth2MetadataUrl: securitySchemes.scheme.value.oauth2MetadataUrl
|
|
2230
|
+
};
|
|
2231
|
+
case "openIdConnectSecurityScheme":
|
|
2232
|
+
return {
|
|
2233
|
+
type: "openIdConnect",
|
|
2234
|
+
description: securitySchemes.scheme.value.description,
|
|
2235
|
+
openIdConnectUrl: securitySchemes.scheme.value.openIdConnectUrl
|
|
2236
|
+
};
|
|
2237
|
+
default:
|
|
2238
|
+
throw A2AError.internalError(`Unsupported security scheme type`);
|
|
2239
|
+
}
|
|
2240
|
+
}
|
|
2241
|
+
static oauthFlows(flows) {
|
|
2242
|
+
switch (flows.flow?.$case) {
|
|
2243
|
+
case "implicit":
|
|
2244
|
+
return {
|
|
2245
|
+
implicit: {
|
|
2246
|
+
authorizationUrl: flows.flow.value.authorizationUrl,
|
|
2247
|
+
scopes: flows.flow.value.scopes,
|
|
2248
|
+
refreshUrl: flows.flow.value.refreshUrl
|
|
2249
|
+
}
|
|
2250
|
+
};
|
|
2251
|
+
case "password":
|
|
2252
|
+
return {
|
|
2253
|
+
password: {
|
|
2254
|
+
refreshUrl: flows.flow.value.refreshUrl,
|
|
2255
|
+
scopes: flows.flow.value.scopes,
|
|
2256
|
+
tokenUrl: flows.flow.value.tokenUrl
|
|
2257
|
+
}
|
|
2258
|
+
};
|
|
2259
|
+
case "authorizationCode":
|
|
2260
|
+
return {
|
|
2261
|
+
authorizationCode: {
|
|
2262
|
+
refreshUrl: flows.flow.value.refreshUrl,
|
|
2263
|
+
authorizationUrl: flows.flow.value.authorizationUrl,
|
|
2264
|
+
scopes: flows.flow.value.scopes,
|
|
2265
|
+
tokenUrl: flows.flow.value.tokenUrl
|
|
2266
|
+
}
|
|
2267
|
+
};
|
|
2268
|
+
case "clientCredentials":
|
|
2269
|
+
return {
|
|
2270
|
+
clientCredentials: {
|
|
2271
|
+
refreshUrl: flows.flow.value.refreshUrl,
|
|
2272
|
+
scopes: flows.flow.value.scopes,
|
|
2273
|
+
tokenUrl: flows.flow.value.tokenUrl
|
|
2274
|
+
}
|
|
2275
|
+
};
|
|
2276
|
+
default:
|
|
2277
|
+
throw A2AError.internalError(`Unsupported OAuth flows`);
|
|
2278
|
+
}
|
|
2279
|
+
}
|
|
2280
|
+
static skills(skill) {
|
|
2281
|
+
return {
|
|
2282
|
+
id: skill.id,
|
|
2283
|
+
name: skill.name,
|
|
2284
|
+
description: skill.description,
|
|
2285
|
+
tags: skill.tags,
|
|
2286
|
+
examples: skill.examples,
|
|
2287
|
+
inputModes: skill.inputModes,
|
|
2288
|
+
outputModes: skill.outputModes,
|
|
2289
|
+
security: skill.security?.map((s) => _FromProto.security(s))
|
|
2290
|
+
};
|
|
2291
|
+
}
|
|
2292
|
+
static agentCardSignature(signatures) {
|
|
2293
|
+
return {
|
|
2294
|
+
protected: signatures.protected,
|
|
2295
|
+
signature: signatures.signature,
|
|
2296
|
+
header: signatures.header
|
|
2297
|
+
};
|
|
2298
|
+
}
|
|
2299
|
+
static taskStatusUpdateEvent(event) {
|
|
2300
|
+
return {
|
|
2301
|
+
kind: "status-update",
|
|
2302
|
+
taskId: event.taskId,
|
|
2303
|
+
status: _FromProto.taskStatus(event.status),
|
|
2304
|
+
contextId: event.contextId,
|
|
2305
|
+
metadata: event.metadata,
|
|
2306
|
+
final: event.final
|
|
2307
|
+
};
|
|
2308
|
+
}
|
|
2309
|
+
static taskArtifactUpdateEvent(event) {
|
|
2310
|
+
return {
|
|
2311
|
+
kind: "artifact-update",
|
|
2312
|
+
taskId: event.taskId,
|
|
2313
|
+
artifact: _FromProto.artifact(event.artifact),
|
|
2314
|
+
contextId: event.contextId,
|
|
2315
|
+
metadata: event.metadata,
|
|
2316
|
+
lastChunk: event.lastChunk
|
|
2317
|
+
};
|
|
2318
|
+
}
|
|
2319
|
+
static messageStreamResult(event) {
|
|
2320
|
+
switch (event.payload?.$case) {
|
|
2321
|
+
case "msg": {
|
|
2322
|
+
const message = _FromProto.message(event.payload.value);
|
|
2323
|
+
if (!message) {
|
|
2324
|
+
throw A2AError.internalError("Invalid message in StreamResponse");
|
|
2325
|
+
}
|
|
2326
|
+
return message;
|
|
2327
|
+
}
|
|
2328
|
+
case "task":
|
|
2329
|
+
return _FromProto.task(event.payload.value);
|
|
2330
|
+
case "statusUpdate":
|
|
2331
|
+
return _FromProto.taskStatusUpdateEvent(event.payload.value);
|
|
2332
|
+
case "artifactUpdate":
|
|
2333
|
+
return _FromProto.taskArtifactUpdateEvent(event.payload.value);
|
|
2334
|
+
default:
|
|
2335
|
+
throw A2AError.internalError("Invalid event type in StreamResponse");
|
|
2336
|
+
}
|
|
2337
|
+
}
|
|
2338
|
+
};
|
|
2339
|
+
|
|
2340
|
+
// src/types/converters/to_proto.ts
|
|
2341
|
+
var ToProto = class _ToProto {
|
|
2342
|
+
static agentCard(agentCard) {
|
|
2343
|
+
return {
|
|
2344
|
+
protocolVersion: agentCard.protocolVersion,
|
|
2345
|
+
name: agentCard.name,
|
|
2346
|
+
description: agentCard.description,
|
|
2347
|
+
url: agentCard.url,
|
|
2348
|
+
preferredTransport: agentCard.preferredTransport,
|
|
2349
|
+
additionalInterfaces: agentCard.additionalInterfaces?.map((i) => _ToProto.agentInterface(i)) ?? [],
|
|
2350
|
+
provider: _ToProto.agentProvider(agentCard.provider),
|
|
2351
|
+
version: agentCard.version,
|
|
2352
|
+
documentationUrl: agentCard.documentationUrl,
|
|
2353
|
+
capabilities: _ToProto.agentCapabilities(agentCard.capabilities),
|
|
2354
|
+
securitySchemes: agentCard.securitySchemes ? Object.fromEntries(
|
|
2355
|
+
Object.entries(agentCard.securitySchemes).map(([key, value]) => [
|
|
2356
|
+
key,
|
|
2357
|
+
_ToProto.securityScheme(value)
|
|
2358
|
+
])
|
|
2359
|
+
) : {},
|
|
2360
|
+
security: agentCard.security?.map((s) => _ToProto.security(s)) ?? [],
|
|
2361
|
+
defaultInputModes: agentCard.defaultInputModes,
|
|
2362
|
+
defaultOutputModes: agentCard.defaultOutputModes,
|
|
2363
|
+
skills: agentCard.skills.map((s) => _ToProto.agentSkill(s)),
|
|
2364
|
+
supportsAuthenticatedExtendedCard: agentCard.supportsAuthenticatedExtendedCard,
|
|
2365
|
+
signatures: agentCard.signatures?.map((s) => _ToProto.agentCardSignature(s)) ?? []
|
|
2366
|
+
};
|
|
2367
|
+
}
|
|
2368
|
+
static agentCardSignature(signatures) {
|
|
2369
|
+
return {
|
|
2370
|
+
protected: signatures.protected,
|
|
2371
|
+
signature: signatures.signature,
|
|
2372
|
+
header: signatures.header
|
|
2373
|
+
};
|
|
2374
|
+
}
|
|
2375
|
+
static agentSkill(skill) {
|
|
2376
|
+
return {
|
|
2377
|
+
id: skill.id,
|
|
2378
|
+
name: skill.name,
|
|
2379
|
+
description: skill.description,
|
|
2380
|
+
tags: skill.tags ?? [],
|
|
2381
|
+
examples: skill.examples ?? [],
|
|
2382
|
+
inputModes: skill.inputModes ?? [],
|
|
2383
|
+
outputModes: skill.outputModes ?? [],
|
|
2384
|
+
security: skill.security ? skill.security.map((s) => _ToProto.security(s)) : []
|
|
2385
|
+
};
|
|
2386
|
+
}
|
|
2387
|
+
static security(security) {
|
|
2388
|
+
return {
|
|
2389
|
+
schemes: Object.fromEntries(
|
|
2390
|
+
Object.entries(security).map(([key, value]) => {
|
|
2391
|
+
return [key, { list: value }];
|
|
2392
|
+
})
|
|
2393
|
+
)
|
|
2394
|
+
};
|
|
2395
|
+
}
|
|
2396
|
+
static securityScheme(scheme) {
|
|
2397
|
+
switch (scheme.type) {
|
|
2398
|
+
case "apiKey":
|
|
2399
|
+
return {
|
|
2400
|
+
scheme: {
|
|
2401
|
+
$case: "apiKeySecurityScheme",
|
|
2402
|
+
value: {
|
|
2403
|
+
name: scheme.name,
|
|
2404
|
+
location: scheme.in,
|
|
2405
|
+
description: scheme.description
|
|
2406
|
+
}
|
|
2407
|
+
}
|
|
2408
|
+
};
|
|
2409
|
+
case "http":
|
|
2410
|
+
return {
|
|
2411
|
+
scheme: {
|
|
2412
|
+
$case: "httpAuthSecurityScheme",
|
|
2413
|
+
value: {
|
|
2414
|
+
description: scheme.description,
|
|
2415
|
+
scheme: scheme.scheme,
|
|
2416
|
+
bearerFormat: scheme.bearerFormat
|
|
2417
|
+
}
|
|
2418
|
+
}
|
|
2419
|
+
};
|
|
2420
|
+
case "mutualTLS":
|
|
2421
|
+
return {
|
|
2422
|
+
scheme: {
|
|
2423
|
+
$case: "mtlsSecurityScheme",
|
|
2424
|
+
value: {
|
|
2425
|
+
description: scheme.description
|
|
2426
|
+
}
|
|
2427
|
+
}
|
|
2428
|
+
};
|
|
2429
|
+
case "oauth2":
|
|
2430
|
+
return {
|
|
2431
|
+
scheme: {
|
|
2432
|
+
$case: "oauth2SecurityScheme",
|
|
2433
|
+
value: {
|
|
2434
|
+
description: scheme.description,
|
|
2435
|
+
flows: _ToProto.oauthFlows(scheme.flows),
|
|
2436
|
+
oauth2MetadataUrl: scheme.oauth2MetadataUrl
|
|
2437
|
+
}
|
|
2438
|
+
}
|
|
2439
|
+
};
|
|
2440
|
+
case "openIdConnect":
|
|
2441
|
+
return {
|
|
2442
|
+
scheme: {
|
|
2443
|
+
$case: "openIdConnectSecurityScheme",
|
|
2444
|
+
value: {
|
|
2445
|
+
description: scheme.description,
|
|
2446
|
+
openIdConnectUrl: scheme.openIdConnectUrl
|
|
2447
|
+
}
|
|
2448
|
+
}
|
|
2449
|
+
};
|
|
2450
|
+
default:
|
|
2451
|
+
throw A2AError.internalError(`Unsupported security scheme type`);
|
|
2452
|
+
}
|
|
2453
|
+
}
|
|
2454
|
+
static oauthFlows(flows) {
|
|
2455
|
+
if (flows.implicit) {
|
|
2456
|
+
return {
|
|
2457
|
+
flow: {
|
|
2458
|
+
$case: "implicit",
|
|
2459
|
+
value: {
|
|
2460
|
+
authorizationUrl: flows.implicit.authorizationUrl,
|
|
2461
|
+
scopes: flows.implicit.scopes,
|
|
2462
|
+
refreshUrl: flows.implicit.refreshUrl
|
|
2463
|
+
}
|
|
2464
|
+
}
|
|
2465
|
+
};
|
|
2466
|
+
} else if (flows.password) {
|
|
2467
|
+
return {
|
|
2468
|
+
flow: {
|
|
2469
|
+
$case: "password",
|
|
2470
|
+
value: {
|
|
2471
|
+
tokenUrl: flows.password.tokenUrl,
|
|
2472
|
+
scopes: flows.password.scopes,
|
|
2473
|
+
refreshUrl: flows.password.refreshUrl
|
|
2474
|
+
}
|
|
2475
|
+
}
|
|
2476
|
+
};
|
|
2477
|
+
} else if (flows.clientCredentials) {
|
|
2478
|
+
return {
|
|
2479
|
+
flow: {
|
|
2480
|
+
$case: "clientCredentials",
|
|
2481
|
+
value: {
|
|
2482
|
+
tokenUrl: flows.clientCredentials.tokenUrl,
|
|
2483
|
+
scopes: flows.clientCredentials.scopes,
|
|
2484
|
+
refreshUrl: flows.clientCredentials.refreshUrl
|
|
2485
|
+
}
|
|
2486
|
+
}
|
|
2487
|
+
};
|
|
2488
|
+
} else if (flows.authorizationCode) {
|
|
2489
|
+
return {
|
|
2490
|
+
flow: {
|
|
2491
|
+
$case: "authorizationCode",
|
|
2492
|
+
value: {
|
|
2493
|
+
authorizationUrl: flows.authorizationCode.authorizationUrl,
|
|
2494
|
+
tokenUrl: flows.authorizationCode.tokenUrl,
|
|
2495
|
+
scopes: flows.authorizationCode.scopes,
|
|
2496
|
+
refreshUrl: flows.authorizationCode.refreshUrl
|
|
2497
|
+
}
|
|
2498
|
+
}
|
|
2499
|
+
};
|
|
2500
|
+
} else {
|
|
2501
|
+
throw A2AError.internalError(`Unsupported OAuth flows`);
|
|
2502
|
+
}
|
|
2503
|
+
}
|
|
2504
|
+
static agentInterface(agentInterface) {
|
|
2505
|
+
return {
|
|
2506
|
+
transport: agentInterface.transport,
|
|
2507
|
+
url: agentInterface.url
|
|
2508
|
+
};
|
|
2509
|
+
}
|
|
2510
|
+
static agentProvider(agentProvider) {
|
|
2511
|
+
if (!agentProvider) {
|
|
2512
|
+
return void 0;
|
|
2513
|
+
}
|
|
2514
|
+
return {
|
|
2515
|
+
url: agentProvider.url,
|
|
2516
|
+
organization: agentProvider.organization
|
|
2517
|
+
};
|
|
2518
|
+
}
|
|
2519
|
+
static agentCapabilities(capabilities) {
|
|
2520
|
+
return {
|
|
2521
|
+
streaming: capabilities.streaming,
|
|
2522
|
+
pushNotifications: capabilities.pushNotifications,
|
|
2523
|
+
extensions: capabilities.extensions ? capabilities.extensions.map((e) => _ToProto.agentExtension(e)) : []
|
|
2524
|
+
};
|
|
2525
|
+
}
|
|
2526
|
+
static agentExtension(extension) {
|
|
2527
|
+
return {
|
|
2528
|
+
uri: extension.uri,
|
|
2529
|
+
description: extension.description,
|
|
2530
|
+
required: extension.required,
|
|
2531
|
+
params: extension.params
|
|
2532
|
+
};
|
|
2533
|
+
}
|
|
2534
|
+
static listTaskPushNotificationConfig(config) {
|
|
2535
|
+
return {
|
|
2536
|
+
configs: config.map((c) => _ToProto.taskPushNotificationConfig(c)),
|
|
2537
|
+
nextPageToken: ""
|
|
2538
|
+
};
|
|
2539
|
+
}
|
|
2540
|
+
static getTaskPushNotificationConfigParams(config) {
|
|
2541
|
+
return {
|
|
2542
|
+
name: generatePushNotificationConfigName(config.id, config.pushNotificationConfigId)
|
|
2543
|
+
};
|
|
2544
|
+
}
|
|
2545
|
+
static listTaskPushNotificationConfigParams(config) {
|
|
2546
|
+
return {
|
|
2547
|
+
parent: generateTaskName(config.id),
|
|
2548
|
+
pageToken: "",
|
|
2549
|
+
pageSize: 0
|
|
2550
|
+
};
|
|
2551
|
+
}
|
|
2552
|
+
static deleteTaskPushNotificationConfigParams(config) {
|
|
2553
|
+
return {
|
|
2554
|
+
name: generatePushNotificationConfigName(config.id, config.pushNotificationConfigId)
|
|
2555
|
+
};
|
|
2556
|
+
}
|
|
2557
|
+
static taskPushNotificationConfig(config) {
|
|
2558
|
+
return {
|
|
2559
|
+
name: generatePushNotificationConfigName(
|
|
2560
|
+
config.taskId,
|
|
2561
|
+
config.pushNotificationConfig.id ?? ""
|
|
2562
|
+
),
|
|
2563
|
+
pushNotificationConfig: _ToProto.pushNotificationConfig(config.pushNotificationConfig)
|
|
2564
|
+
};
|
|
2565
|
+
}
|
|
2566
|
+
static taskPushNotificationConfigCreate(config) {
|
|
2567
|
+
return {
|
|
2568
|
+
parent: generateTaskName(config.taskId),
|
|
2569
|
+
config: _ToProto.taskPushNotificationConfig(config),
|
|
2570
|
+
configId: config.pushNotificationConfig.id
|
|
2571
|
+
};
|
|
2572
|
+
}
|
|
2573
|
+
static pushNotificationConfig(config) {
|
|
2574
|
+
if (!config) {
|
|
2575
|
+
return void 0;
|
|
2576
|
+
}
|
|
2577
|
+
return {
|
|
2578
|
+
id: config.id,
|
|
2579
|
+
url: config.url,
|
|
2580
|
+
token: config.token,
|
|
2581
|
+
authentication: _ToProto.pushNotificationAuthenticationInfo(config.authentication)
|
|
2582
|
+
};
|
|
2583
|
+
}
|
|
2584
|
+
static pushNotificationAuthenticationInfo(authInfo) {
|
|
2585
|
+
if (!authInfo) {
|
|
2586
|
+
return void 0;
|
|
2587
|
+
}
|
|
2588
|
+
return {
|
|
2589
|
+
schemes: authInfo.schemes,
|
|
2590
|
+
credentials: authInfo.credentials
|
|
2591
|
+
};
|
|
2592
|
+
}
|
|
2593
|
+
static messageStreamResult(event) {
|
|
2594
|
+
if (event.kind === "message") {
|
|
2595
|
+
return {
|
|
2596
|
+
payload: {
|
|
2597
|
+
$case: "msg",
|
|
2598
|
+
value: _ToProto.message(event)
|
|
2599
|
+
}
|
|
2600
|
+
};
|
|
2601
|
+
} else if (event.kind === "task") {
|
|
2602
|
+
return {
|
|
2603
|
+
payload: {
|
|
2604
|
+
$case: "task",
|
|
2605
|
+
value: _ToProto.task(event)
|
|
2606
|
+
}
|
|
2607
|
+
};
|
|
2608
|
+
} else if (event.kind === "status-update") {
|
|
2609
|
+
return {
|
|
2610
|
+
payload: {
|
|
2611
|
+
$case: "statusUpdate",
|
|
2612
|
+
value: _ToProto.taskStatusUpdateEvent(event)
|
|
2613
|
+
}
|
|
2614
|
+
};
|
|
2615
|
+
} else if (event.kind === "artifact-update") {
|
|
2616
|
+
return {
|
|
2617
|
+
payload: {
|
|
2618
|
+
$case: "artifactUpdate",
|
|
2619
|
+
value: _ToProto.taskArtifactUpdateEvent(event)
|
|
2620
|
+
}
|
|
2621
|
+
};
|
|
2622
|
+
} else {
|
|
2623
|
+
throw A2AError.internalError("Invalid event type");
|
|
2624
|
+
}
|
|
2625
|
+
}
|
|
2626
|
+
static taskStatusUpdateEvent(event) {
|
|
2627
|
+
return {
|
|
2628
|
+
taskId: event.taskId,
|
|
2629
|
+
status: _ToProto.taskStatus(event.status),
|
|
2630
|
+
contextId: event.contextId,
|
|
2631
|
+
metadata: event.metadata,
|
|
2632
|
+
final: event.final
|
|
2633
|
+
};
|
|
2634
|
+
}
|
|
2635
|
+
static taskArtifactUpdateEvent(event) {
|
|
2636
|
+
return {
|
|
2637
|
+
taskId: event.taskId,
|
|
2638
|
+
artifact: _ToProto.artifact(event.artifact),
|
|
2639
|
+
contextId: event.contextId,
|
|
2640
|
+
metadata: event.metadata,
|
|
2641
|
+
append: event.append,
|
|
2642
|
+
lastChunk: event.lastChunk
|
|
2643
|
+
};
|
|
2644
|
+
}
|
|
2645
|
+
static messageSendResult(params) {
|
|
2646
|
+
if (params.kind === "message") {
|
|
2647
|
+
return {
|
|
2648
|
+
payload: {
|
|
2649
|
+
$case: "msg",
|
|
2650
|
+
value: _ToProto.message(params)
|
|
2651
|
+
}
|
|
2652
|
+
};
|
|
2653
|
+
} else if (params.kind === "task") {
|
|
2654
|
+
return {
|
|
2655
|
+
payload: {
|
|
2656
|
+
$case: "task",
|
|
2657
|
+
value: _ToProto.task(params)
|
|
2658
|
+
}
|
|
2659
|
+
};
|
|
2660
|
+
}
|
|
2661
|
+
}
|
|
2662
|
+
static message(message) {
|
|
2663
|
+
if (!message) {
|
|
2664
|
+
return void 0;
|
|
2665
|
+
}
|
|
2666
|
+
return {
|
|
2667
|
+
messageId: message.messageId,
|
|
2668
|
+
content: message.parts.map((p) => _ToProto.parts(p)),
|
|
2669
|
+
contextId: message.contextId,
|
|
2670
|
+
taskId: message.taskId,
|
|
2671
|
+
role: _ToProto.role(message.role),
|
|
2672
|
+
metadata: message.metadata,
|
|
2673
|
+
extensions: message.extensions ?? []
|
|
2674
|
+
};
|
|
2675
|
+
}
|
|
2676
|
+
static role(role) {
|
|
2677
|
+
switch (role) {
|
|
2678
|
+
case "agent":
|
|
2679
|
+
return 2 /* ROLE_AGENT */;
|
|
2680
|
+
case "user":
|
|
2681
|
+
return 1 /* ROLE_USER */;
|
|
2682
|
+
default:
|
|
2683
|
+
throw A2AError.internalError(`Invalid role`);
|
|
2684
|
+
}
|
|
2685
|
+
}
|
|
2686
|
+
static task(task) {
|
|
2687
|
+
return {
|
|
2688
|
+
id: task.id,
|
|
2689
|
+
contextId: task.contextId,
|
|
2690
|
+
status: _ToProto.taskStatus(task.status),
|
|
2691
|
+
artifacts: task.artifacts?.map((a) => _ToProto.artifact(a)) ?? [],
|
|
2692
|
+
history: task.history?.map((m) => _ToProto.message(m)) ?? [],
|
|
2693
|
+
metadata: task.metadata
|
|
2694
|
+
};
|
|
2695
|
+
}
|
|
2696
|
+
static taskStatus(status) {
|
|
2697
|
+
return {
|
|
2698
|
+
state: _ToProto.taskState(status.state),
|
|
2699
|
+
update: _ToProto.message(status.message),
|
|
2700
|
+
timestamp: status.timestamp ? new Date(status.timestamp) : void 0
|
|
2701
|
+
};
|
|
2702
|
+
}
|
|
2703
|
+
static artifact(artifact) {
|
|
2704
|
+
return {
|
|
2705
|
+
artifactId: artifact.artifactId,
|
|
2706
|
+
name: artifact.name,
|
|
2707
|
+
description: artifact.description,
|
|
2708
|
+
parts: artifact.parts.map((p) => _ToProto.parts(p)),
|
|
2709
|
+
metadata: artifact.metadata,
|
|
2710
|
+
extensions: artifact.extensions ? artifact.extensions : []
|
|
2711
|
+
};
|
|
2712
|
+
}
|
|
2713
|
+
static taskState(state) {
|
|
2714
|
+
switch (state) {
|
|
2715
|
+
case "submitted":
|
|
2716
|
+
return 1 /* TASK_STATE_SUBMITTED */;
|
|
2717
|
+
case "working":
|
|
2718
|
+
return 2 /* TASK_STATE_WORKING */;
|
|
2719
|
+
case "input-required":
|
|
2720
|
+
return 6 /* TASK_STATE_INPUT_REQUIRED */;
|
|
2721
|
+
case "rejected":
|
|
2722
|
+
return 7 /* TASK_STATE_REJECTED */;
|
|
2723
|
+
case "auth-required":
|
|
2724
|
+
return 8 /* TASK_STATE_AUTH_REQUIRED */;
|
|
2725
|
+
case "completed":
|
|
2726
|
+
return 3 /* TASK_STATE_COMPLETED */;
|
|
2727
|
+
case "failed":
|
|
2728
|
+
return 4 /* TASK_STATE_FAILED */;
|
|
2729
|
+
case "canceled":
|
|
2730
|
+
return 5 /* TASK_STATE_CANCELLED */;
|
|
2731
|
+
case "unknown":
|
|
2732
|
+
return 0 /* TASK_STATE_UNSPECIFIED */;
|
|
2733
|
+
default:
|
|
2734
|
+
return -1 /* UNRECOGNIZED */;
|
|
2735
|
+
}
|
|
2736
|
+
}
|
|
2737
|
+
static parts(part) {
|
|
2738
|
+
if (part.kind === "text") {
|
|
2739
|
+
return {
|
|
2740
|
+
part: { $case: "text", value: part.text }
|
|
2741
|
+
};
|
|
2742
|
+
}
|
|
2743
|
+
if (part.kind === "file") {
|
|
2744
|
+
let filePart;
|
|
2745
|
+
if ("uri" in part.file) {
|
|
2746
|
+
filePart = {
|
|
2747
|
+
file: { $case: "fileWithUri", value: part.file.uri },
|
|
2748
|
+
mimeType: part.file.mimeType
|
|
2749
|
+
};
|
|
2750
|
+
} else if ("bytes" in part.file) {
|
|
2751
|
+
filePart = {
|
|
2752
|
+
file: { $case: "fileWithBytes", value: Buffer.from(part.file.bytes, "base64") },
|
|
2753
|
+
mimeType: part.file.mimeType
|
|
2754
|
+
};
|
|
2755
|
+
} else {
|
|
2756
|
+
throw A2AError.internalError("Invalid file part");
|
|
2757
|
+
}
|
|
2758
|
+
return {
|
|
2759
|
+
part: { $case: "file", value: filePart }
|
|
2760
|
+
};
|
|
2761
|
+
}
|
|
2762
|
+
if (part.kind === "data") {
|
|
2763
|
+
return {
|
|
2764
|
+
part: { $case: "data", value: { data: part.data } }
|
|
2765
|
+
};
|
|
2766
|
+
}
|
|
2767
|
+
throw A2AError.internalError("Invalid part type");
|
|
2768
|
+
}
|
|
2769
|
+
static messageSendParams(params) {
|
|
2770
|
+
return {
|
|
2771
|
+
request: _ToProto.message(params.message),
|
|
2772
|
+
configuration: _ToProto.configuration(params.configuration),
|
|
2773
|
+
metadata: params.metadata
|
|
2774
|
+
};
|
|
2775
|
+
}
|
|
2776
|
+
static configuration(configuration) {
|
|
2777
|
+
if (!configuration) {
|
|
2778
|
+
return void 0;
|
|
2779
|
+
}
|
|
2780
|
+
return {
|
|
2781
|
+
blocking: configuration.blocking,
|
|
2782
|
+
acceptedOutputModes: configuration.acceptedOutputModes ?? [],
|
|
2783
|
+
pushNotification: _ToProto.pushNotificationConfig(configuration.pushNotificationConfig),
|
|
2784
|
+
historyLength: configuration.historyLength ?? 0
|
|
2785
|
+
};
|
|
2786
|
+
}
|
|
2787
|
+
static taskQueryParams(params) {
|
|
2788
|
+
return {
|
|
2789
|
+
name: generateTaskName(params.id),
|
|
2790
|
+
historyLength: params.historyLength ?? 0
|
|
2791
|
+
};
|
|
2792
|
+
}
|
|
2793
|
+
static cancelTaskRequest(params) {
|
|
2794
|
+
return {
|
|
2795
|
+
name: generateTaskName(params.id)
|
|
2796
|
+
};
|
|
2797
|
+
}
|
|
2798
|
+
static taskIdParams(params) {
|
|
2799
|
+
return {
|
|
2800
|
+
name: generateTaskName(params.id)
|
|
2801
|
+
};
|
|
2802
|
+
}
|
|
2803
|
+
};
|
|
2804
|
+
|
|
795
2805
|
// src/server/express/rest_handler.ts
|
|
796
2806
|
var restErrorHandler = (err, _req, res, next) => {
|
|
797
2807
|
if (err instanceof SyntaxError && "body" in err) {
|
|
@@ -816,13 +2826,16 @@ function restHandler(options) {
|
|
|
816
2826
|
res.setHeader(HTTP_EXTENSION_HEADER, Array.from(context.activatedExtensions));
|
|
817
2827
|
}
|
|
818
2828
|
};
|
|
819
|
-
const sendResponse = (res, statusCode, context, body) => {
|
|
2829
|
+
const sendResponse = (res, statusCode, context, body, responseType) => {
|
|
820
2830
|
setExtensionsHeader(res, context);
|
|
821
2831
|
res.status(statusCode);
|
|
822
2832
|
if (statusCode === HTTP_STATUS.NO_CONTENT) {
|
|
823
2833
|
res.end();
|
|
824
2834
|
} else {
|
|
825
|
-
|
|
2835
|
+
if (!responseType) {
|
|
2836
|
+
throw new Error("Bug: toJson serializer must be provided for non-204 responses.");
|
|
2837
|
+
}
|
|
2838
|
+
res.json(responseType.toJSON(body));
|
|
826
2839
|
}
|
|
827
2840
|
};
|
|
828
2841
|
const sendStreamResponse = async (res, stream, context) => {
|
|
@@ -843,10 +2856,14 @@ function restHandler(options) {
|
|
|
843
2856
|
res.flushHeaders();
|
|
844
2857
|
try {
|
|
845
2858
|
if (!firstResult.done) {
|
|
846
|
-
|
|
2859
|
+
const proto = ToProto.messageStreamResult(firstResult.value);
|
|
2860
|
+
const result = StreamResponse.toJSON(proto);
|
|
2861
|
+
res.write(formatSSEEvent(result));
|
|
847
2862
|
}
|
|
848
2863
|
for await (const event of { [Symbol.asyncIterator]: () => iterator }) {
|
|
849
|
-
|
|
2864
|
+
const proto = ToProto.messageStreamResult(event);
|
|
2865
|
+
const result = StreamResponse.toJSON(proto);
|
|
2866
|
+
res.write(formatSSEEvent(result));
|
|
850
2867
|
}
|
|
851
2868
|
} catch (streamError) {
|
|
852
2869
|
console.error("SSE streaming error:", streamError);
|
|
@@ -887,22 +2904,34 @@ function restHandler(options) {
|
|
|
887
2904
|
asyncHandler(async (req, res) => {
|
|
888
2905
|
const context = await buildContext(req);
|
|
889
2906
|
const result = await restTransportHandler.getAuthenticatedExtendedAgentCard(context);
|
|
890
|
-
|
|
2907
|
+
const protoResult = ToProto.agentCard(result);
|
|
2908
|
+
sendResponse(res, HTTP_STATUS.OK, context, protoResult, AgentCard);
|
|
891
2909
|
})
|
|
892
2910
|
);
|
|
893
2911
|
router.post(
|
|
894
2912
|
"/v1/message\\:send",
|
|
895
2913
|
asyncHandler(async (req, res) => {
|
|
896
2914
|
const context = await buildContext(req);
|
|
897
|
-
const
|
|
898
|
-
|
|
2915
|
+
const protoReq = SendMessageRequest.fromJSON(req.body);
|
|
2916
|
+
const params = FromProto.messageSendParams(protoReq);
|
|
2917
|
+
const result = await restTransportHandler.sendMessage(params, context);
|
|
2918
|
+
const protoResult = ToProto.messageSendResult(result);
|
|
2919
|
+
sendResponse(
|
|
2920
|
+
res,
|
|
2921
|
+
HTTP_STATUS.CREATED,
|
|
2922
|
+
context,
|
|
2923
|
+
protoResult,
|
|
2924
|
+
SendMessageResponse
|
|
2925
|
+
);
|
|
899
2926
|
})
|
|
900
2927
|
);
|
|
901
2928
|
router.post(
|
|
902
2929
|
"/v1/message\\:stream",
|
|
903
2930
|
asyncHandler(async (req, res) => {
|
|
904
2931
|
const context = await buildContext(req);
|
|
905
|
-
const
|
|
2932
|
+
const protoReq = SendMessageRequest.fromJSON(req.body);
|
|
2933
|
+
const params = FromProto.messageSendParams(protoReq);
|
|
2934
|
+
const stream = await restTransportHandler.sendMessageStream(params, context);
|
|
906
2935
|
await sendStreamResponse(res, stream, context);
|
|
907
2936
|
})
|
|
908
2937
|
);
|
|
@@ -913,9 +2942,11 @@ function restHandler(options) {
|
|
|
913
2942
|
const result = await restTransportHandler.getTask(
|
|
914
2943
|
req.params.taskId,
|
|
915
2944
|
context,
|
|
916
|
-
|
|
2945
|
+
//TODO: clarify for version 1.0.0 the format of the historyLength query parameter, and if history should always be added to the returned object
|
|
2946
|
+
req.query.historyLength ?? req.query.history_length
|
|
917
2947
|
);
|
|
918
|
-
|
|
2948
|
+
const protoResult = ToProto.task(result);
|
|
2949
|
+
sendResponse(res, HTTP_STATUS.OK, context, protoResult, Task);
|
|
919
2950
|
})
|
|
920
2951
|
);
|
|
921
2952
|
router.post(
|
|
@@ -923,7 +2954,8 @@ function restHandler(options) {
|
|
|
923
2954
|
asyncHandler(async (req, res) => {
|
|
924
2955
|
const context = await buildContext(req);
|
|
925
2956
|
const result = await restTransportHandler.cancelTask(req.params.taskId, context);
|
|
926
|
-
|
|
2957
|
+
const protoResult = ToProto.task(result);
|
|
2958
|
+
sendResponse(res, HTTP_STATUS.ACCEPTED, context, protoResult, Task);
|
|
927
2959
|
})
|
|
928
2960
|
);
|
|
929
2961
|
router.post(
|
|
@@ -944,7 +2976,14 @@ function restHandler(options) {
|
|
|
944
2976
|
task_id: req.params.taskId
|
|
945
2977
|
};
|
|
946
2978
|
const result = await restTransportHandler.setTaskPushNotificationConfig(config, context);
|
|
947
|
-
|
|
2979
|
+
const protoResult = ToProto.taskPushNotificationConfig(result);
|
|
2980
|
+
sendResponse(
|
|
2981
|
+
res,
|
|
2982
|
+
HTTP_STATUS.CREATED,
|
|
2983
|
+
context,
|
|
2984
|
+
protoResult,
|
|
2985
|
+
TaskPushNotificationConfig
|
|
2986
|
+
);
|
|
948
2987
|
})
|
|
949
2988
|
);
|
|
950
2989
|
router.get(
|
|
@@ -955,7 +2994,14 @@ function restHandler(options) {
|
|
|
955
2994
|
req.params.taskId,
|
|
956
2995
|
context
|
|
957
2996
|
);
|
|
958
|
-
|
|
2997
|
+
const protoResult = ToProto.listTaskPushNotificationConfig(result);
|
|
2998
|
+
sendResponse(
|
|
2999
|
+
res,
|
|
3000
|
+
HTTP_STATUS.OK,
|
|
3001
|
+
context,
|
|
3002
|
+
protoResult,
|
|
3003
|
+
ListTaskPushNotificationConfigResponse
|
|
3004
|
+
);
|
|
959
3005
|
})
|
|
960
3006
|
);
|
|
961
3007
|
router.get(
|
|
@@ -967,7 +3013,14 @@ function restHandler(options) {
|
|
|
967
3013
|
req.params.configId,
|
|
968
3014
|
context
|
|
969
3015
|
);
|
|
970
|
-
|
|
3016
|
+
const protoResult = ToProto.taskPushNotificationConfig(result);
|
|
3017
|
+
sendResponse(
|
|
3018
|
+
res,
|
|
3019
|
+
HTTP_STATUS.OK,
|
|
3020
|
+
context,
|
|
3021
|
+
protoResult,
|
|
3022
|
+
TaskPushNotificationConfig
|
|
3023
|
+
);
|
|
971
3024
|
})
|
|
972
3025
|
);
|
|
973
3026
|
router.delete(
|