@bpmsoftwaresolutions/ai-engine-client 1.1.97 → 1.1.99
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/package.json +1 -1
- package/src/client.js +20 -956
- package/src/compat/aliases.js +160 -0
- package/src/domains/agent-communications.js +576 -1
- package/src/domains/communication-tickets.js +379 -0
- package/src/domains/database/schema.js +46 -6
- package/src/domains/database.js +6 -0
- package/src/domains/external-audio.js +30 -0
- package/src/domains/external-projects.js +29 -0
- package/src/domains/external-workflow-artifacts.js +14 -0
- package/src/domains/message-watch.js +35 -0
- package/src/domains/refactoring-transfers.js +405 -0
- package/src/index.js +1 -1
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
cleanText,
|
|
3
|
+
isPlainObject,
|
|
4
|
+
normalizeConnectionFirstMessageKind,
|
|
5
|
+
normalizeMessageKind,
|
|
6
|
+
normalizeRecipientMode,
|
|
7
|
+
normalizeTransferKind,
|
|
8
|
+
normalizeTransferLifecycleStatus,
|
|
9
|
+
normalizeTransferMode,
|
|
10
|
+
normalizeThreadType,
|
|
11
|
+
} from '../utils/communication.js';
|
|
2
12
|
|
|
3
13
|
function normalizeTransferChannelId(request = {}) {
|
|
4
14
|
return cleanText(request.transfer_channel_id) || cleanText(request.transferChannelId) || cleanText(request.channel_id) || cleanText(request.channelId);
|
|
@@ -9,6 +19,29 @@ export function createAgentCommunicationsDomain(client) {
|
|
|
9
19
|
startAgentConnection: (request) => startAgentConnection(client, request),
|
|
10
20
|
establishAgentCommunicationChannel: (request) => establishAgentCommunicationChannel(client, request),
|
|
11
21
|
runInterAgentMessagingLoop: (request) => runInterAgentMessagingLoop(client, request),
|
|
22
|
+
bootstrapCommunication: (request) => bootstrapCommunication(client, request),
|
|
23
|
+
negotiateCommunicationTransfer: (request) => negotiateCommunicationTransfer(client, request),
|
|
24
|
+
resolveCommunicationTarget: (request) => resolveCommunicationTarget(client, request),
|
|
25
|
+
createCommunicationEvidencePacket: (request) => createCommunicationEvidencePacket(client, request),
|
|
26
|
+
listCommunicationFrictionTaxonomy: (request) => listCommunicationFrictionTaxonomy(client, request),
|
|
27
|
+
recordCommunicationFrictionEvent: (request) => recordCommunicationFrictionEvent(client, request),
|
|
28
|
+
openCommunicationThread: (request) => openCommunicationThread(client, request),
|
|
29
|
+
getCommunicationThread: (threadId) => getCommunicationThread(client, threadId),
|
|
30
|
+
listCommunicationInbox: (request) => listCommunicationInbox(client, request),
|
|
31
|
+
getMyInbox: (request) => getMyInbox(client, request),
|
|
32
|
+
verifyMessageSent: (request) => verifyMessageSent(client, request),
|
|
33
|
+
verifyMessageReceived: (request) => verifyMessageReceived(client, request),
|
|
34
|
+
getMessageDeliveryReceipt: (request) => getMessageDeliveryReceipt(client, request),
|
|
35
|
+
_sendAgentCommsMessage: (request) => _sendAgentCommsMessage(client, request),
|
|
36
|
+
sendCommunicationMessage: (request) => sendCommunicationMessage(client, request),
|
|
37
|
+
acceptCommunicationTransferPacket: (request) => acceptCommunicationTransferPacket(client, request),
|
|
38
|
+
closeCommunicationTransferPacket: (request) => closeCommunicationTransferPacket(client, request),
|
|
39
|
+
getCommunicationTransferHealth: (request) => getCommunicationTransferHealth(client, request),
|
|
40
|
+
acceptCommunicationMessage: (messageId) => acceptCommunicationMessage(client, messageId),
|
|
41
|
+
respondToCommunicationMessage: (request) => respondToCommunicationMessage(client, request),
|
|
42
|
+
attachCommunicationMessageEvidence: (request) => attachCommunicationMessageEvidence(client, request),
|
|
43
|
+
createCommunicationHandoff: (request) => createCommunicationHandoff(client, request),
|
|
44
|
+
acceptCommunicationHandoff: (handoffId) => acceptCommunicationHandoff(client, handoffId),
|
|
12
45
|
};
|
|
13
46
|
}
|
|
14
47
|
|
|
@@ -883,3 +916,545 @@ export async function runInterAgentMessagingLoop(client, {
|
|
|
883
916
|
status_payload: statusPayload,
|
|
884
917
|
};
|
|
885
918
|
}
|
|
919
|
+
|
|
920
|
+
export async function bootstrapCommunication(client) {
|
|
921
|
+
return client._request('/api/agent-communications/bootstrap');
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
export async function negotiateCommunicationTransfer(client, {
|
|
925
|
+
preferredModes,
|
|
926
|
+
preferred_modes,
|
|
927
|
+
preferred,
|
|
928
|
+
capabilities = {},
|
|
929
|
+
estimatedPayloadKb,
|
|
930
|
+
estimated_payload_kb,
|
|
931
|
+
requiresReceipts = true,
|
|
932
|
+
requires_receipts = true,
|
|
933
|
+
supportsHashValidation = true,
|
|
934
|
+
supports_hash_validation = true,
|
|
935
|
+
transferKind,
|
|
936
|
+
transfer_kind,
|
|
937
|
+
workflowRunId,
|
|
938
|
+
workflow_run_id,
|
|
939
|
+
} = {}) {
|
|
940
|
+
const normalizedPreferredModes = Array.isArray(preferred_modes)
|
|
941
|
+
? preferred_modes
|
|
942
|
+
: (Array.isArray(preferredModes) ? preferredModes : (Array.isArray(preferred) ? preferred : ['bundle', 'artifact_refs', 'inline_payload']));
|
|
943
|
+
return client._request('/api/agent-communications/transfers/negotiate', {
|
|
944
|
+
method: 'POST',
|
|
945
|
+
body: {
|
|
946
|
+
preferred_modes: normalizedPreferredModes.map((mode) => normalizeTransferMode(mode)),
|
|
947
|
+
capabilities: isPlainObject(capabilities) ? capabilities : {},
|
|
948
|
+
estimated_payload_kb: Number(estimated_payload_kb ?? estimatedPayloadKb ?? 0) || undefined,
|
|
949
|
+
requires_receipts: Boolean(requires_receipts ?? requiresReceipts),
|
|
950
|
+
supports_hash_validation: Boolean(supports_hash_validation ?? supportsHashValidation),
|
|
951
|
+
transfer_kind: normalizeTransferKind(transfer_kind ?? transferKind ?? 'upstream_remediation'),
|
|
952
|
+
workflow_run_id: cleanText(workflow_run_id) || cleanText(workflowRunId),
|
|
953
|
+
},
|
|
954
|
+
});
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
export async function resolveCommunicationTarget(client, {
|
|
958
|
+
intent,
|
|
959
|
+
transferKind,
|
|
960
|
+
transfer_kind,
|
|
961
|
+
recipientMode,
|
|
962
|
+
recipient_mode,
|
|
963
|
+
preferredRoleKey,
|
|
964
|
+
preferred_role_key,
|
|
965
|
+
preferredAgentSessionId,
|
|
966
|
+
preferred_agent_session_id,
|
|
967
|
+
workflowRunId,
|
|
968
|
+
workflow_run_id,
|
|
969
|
+
} = {}) {
|
|
970
|
+
return client._request('/api/agent-communications/targets/resolve', {
|
|
971
|
+
method: 'POST',
|
|
972
|
+
body: {
|
|
973
|
+
intent: cleanText(intent) || cleanText(transfer_kind) || cleanText(transferKind),
|
|
974
|
+
recipient_mode: normalizeRecipientMode(recipient_mode ?? recipientMode ?? 'role'),
|
|
975
|
+
preferred_role_key: cleanText(preferred_role_key) || cleanText(preferredRoleKey),
|
|
976
|
+
preferred_agent_session_id: cleanText(preferred_agent_session_id) || cleanText(preferredAgentSessionId),
|
|
977
|
+
workflow_run_id: cleanText(workflow_run_id) || cleanText(workflowRunId),
|
|
978
|
+
},
|
|
979
|
+
});
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
export async function createCommunicationEvidencePacket(client, {
|
|
983
|
+
workflowRunId,
|
|
984
|
+
workflow_run_id,
|
|
985
|
+
transferKind,
|
|
986
|
+
transfer_kind,
|
|
987
|
+
objective,
|
|
988
|
+
requestedOutcome,
|
|
989
|
+
requested_outcome,
|
|
990
|
+
artifacts = [],
|
|
991
|
+
artifactRefs,
|
|
992
|
+
artifact_refs,
|
|
993
|
+
issues = [],
|
|
994
|
+
issueRefs,
|
|
995
|
+
issue_refs,
|
|
996
|
+
expectedEvidence = [],
|
|
997
|
+
expected_evidence,
|
|
998
|
+
metadata = {},
|
|
999
|
+
} = {}) {
|
|
1000
|
+
return client._request('/api/agent-communications/evidence-packets', {
|
|
1001
|
+
method: 'POST',
|
|
1002
|
+
body: {
|
|
1003
|
+
workflow_run_id: cleanText(workflow_run_id) || cleanText(workflowRunId),
|
|
1004
|
+
transfer_kind: normalizeTransferKind(transfer_kind ?? transferKind ?? 'upstream_remediation'),
|
|
1005
|
+
objective: cleanText(objective),
|
|
1006
|
+
requested_outcome: cleanText(requested_outcome) || cleanText(requestedOutcome),
|
|
1007
|
+
artifacts: Array.isArray(artifacts) ? artifacts : (Array.isArray(artifact_refs) ? artifact_refs : (Array.isArray(artifactRefs) ? artifactRefs : [])),
|
|
1008
|
+
issues: Array.isArray(issues) ? issues : (Array.isArray(issue_refs) ? issue_refs : (Array.isArray(issueRefs) ? issueRefs : [])),
|
|
1009
|
+
expected_evidence: Array.isArray(expected_evidence) ? expected_evidence : (Array.isArray(expectedEvidence) ? expectedEvidence : []),
|
|
1010
|
+
metadata: isPlainObject(metadata) ? metadata : {},
|
|
1011
|
+
},
|
|
1012
|
+
});
|
|
1013
|
+
}
|
|
1014
|
+
|
|
1015
|
+
export async function listCommunicationFrictionTaxonomy(client, {
|
|
1016
|
+
categoryGroup,
|
|
1017
|
+
category_group,
|
|
1018
|
+
isActive,
|
|
1019
|
+
is_active,
|
|
1020
|
+
} = {}) {
|
|
1021
|
+
return client._request('/api/agent-communications/friction-taxonomy', {
|
|
1022
|
+
query: {
|
|
1023
|
+
category_group: cleanText(category_group) || cleanText(categoryGroup),
|
|
1024
|
+
is_active: is_active !== undefined ? String(Boolean(is_active)) : (isActive !== undefined ? String(Boolean(isActive)) : undefined),
|
|
1025
|
+
},
|
|
1026
|
+
});
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
export async function recordCommunicationFrictionEvent(client, {
|
|
1030
|
+
workflowRunId,
|
|
1031
|
+
workflow_run_id,
|
|
1032
|
+
workTransferPacketId,
|
|
1033
|
+
work_transfer_packet_id,
|
|
1034
|
+
communicationThreadId,
|
|
1035
|
+
communication_thread_id,
|
|
1036
|
+
communicationMessageId,
|
|
1037
|
+
communication_message_id,
|
|
1038
|
+
taxonomyKey,
|
|
1039
|
+
taxonomy_key,
|
|
1040
|
+
frictionType,
|
|
1041
|
+
friction_type,
|
|
1042
|
+
severity,
|
|
1043
|
+
observedBehavior,
|
|
1044
|
+
observed_behavior,
|
|
1045
|
+
attemptedAction,
|
|
1046
|
+
attempted_action,
|
|
1047
|
+
resolutionPath,
|
|
1048
|
+
resolution_path,
|
|
1049
|
+
missingSurfaceKey,
|
|
1050
|
+
missing_surface_key,
|
|
1051
|
+
promotionCandidate,
|
|
1052
|
+
promotion_candidate,
|
|
1053
|
+
repeatedCount,
|
|
1054
|
+
repeated_count,
|
|
1055
|
+
metadata = {},
|
|
1056
|
+
} = {}) {
|
|
1057
|
+
return client._request('/api/agent-communications/friction-events', {
|
|
1058
|
+
method: 'POST',
|
|
1059
|
+
body: {
|
|
1060
|
+
workflow_run_id: cleanText(workflow_run_id) || cleanText(workflowRunId),
|
|
1061
|
+
work_transfer_packet_id: cleanText(work_transfer_packet_id) || cleanText(workTransferPacketId),
|
|
1062
|
+
communication_thread_id: cleanText(communication_thread_id) || cleanText(communicationThreadId),
|
|
1063
|
+
communication_message_id: cleanText(communication_message_id) || cleanText(communicationMessageId),
|
|
1064
|
+
taxonomy_key: cleanText(taxonomy_key) || cleanText(taxonomyKey) || 'enum_drift',
|
|
1065
|
+
friction_type: cleanText(friction_type) || cleanText(frictionType) || 'discovery',
|
|
1066
|
+
severity: cleanText(severity) || 'warning',
|
|
1067
|
+
observed_behavior: cleanText(observed_behavior) || cleanText(observedBehavior),
|
|
1068
|
+
attempted_action: cleanText(attempted_action) || cleanText(attemptedAction),
|
|
1069
|
+
resolution_path: cleanText(resolution_path) || cleanText(resolutionPath),
|
|
1070
|
+
missing_surface_key: cleanText(missing_surface_key) || cleanText(missingSurfaceKey),
|
|
1071
|
+
promotion_candidate: Boolean(promotion_candidate ?? promotionCandidate),
|
|
1072
|
+
repeated_count: Number(repeated_count ?? repeatedCount ?? 1) || 1,
|
|
1073
|
+
metadata: isPlainObject(metadata) ? metadata : {},
|
|
1074
|
+
},
|
|
1075
|
+
});
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1078
|
+
export async function openCommunicationThread(client, {
|
|
1079
|
+
workflowRunId,
|
|
1080
|
+
workflow_run_id,
|
|
1081
|
+
threadType,
|
|
1082
|
+
thread_type,
|
|
1083
|
+
subject,
|
|
1084
|
+
objective,
|
|
1085
|
+
parentThreadId,
|
|
1086
|
+
parent_thread_id,
|
|
1087
|
+
createdByAgentSessionId,
|
|
1088
|
+
created_by_agent_session_id,
|
|
1089
|
+
createdByActorSessionId,
|
|
1090
|
+
created_by_actor_session_id,
|
|
1091
|
+
metadata,
|
|
1092
|
+
} = {}) {
|
|
1093
|
+
return client._request('/api/agent-communications/threads', {
|
|
1094
|
+
method: 'POST',
|
|
1095
|
+
body: {
|
|
1096
|
+
workflow_run_id: cleanText(workflow_run_id) || cleanText(workflowRunId),
|
|
1097
|
+
parent_thread_id: cleanText(parent_thread_id) || cleanText(parentThreadId),
|
|
1098
|
+
thread_type: normalizeThreadType(cleanText(thread_type) || cleanText(threadType)),
|
|
1099
|
+
subject: cleanText(subject),
|
|
1100
|
+
objective: cleanText(objective),
|
|
1101
|
+
created_by_agent_session_id: cleanText(created_by_agent_session_id) || cleanText(createdByAgentSessionId),
|
|
1102
|
+
created_by_actor_session_id: cleanText(created_by_actor_session_id) || cleanText(createdByActorSessionId),
|
|
1103
|
+
metadata: isPlainObject(metadata) ? metadata : {},
|
|
1104
|
+
},
|
|
1105
|
+
});
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1108
|
+
export async function getCommunicationThread(client, threadId) {
|
|
1109
|
+
return client._request(`/api/agent-communications/threads/${encodeURIComponent(threadId)}`);
|
|
1110
|
+
}
|
|
1111
|
+
|
|
1112
|
+
export async function listCommunicationInbox(client, {
|
|
1113
|
+
recipientAgentSessionId,
|
|
1114
|
+
recipient_agent_session_id,
|
|
1115
|
+
recipientRoleKey,
|
|
1116
|
+
recipient_role_key,
|
|
1117
|
+
workflowRunId,
|
|
1118
|
+
workflow_run_id,
|
|
1119
|
+
} = {}) {
|
|
1120
|
+
return client._request('/api/agent-communications/inbox', {
|
|
1121
|
+
query: {
|
|
1122
|
+
recipient_agent_session_id: cleanText(recipient_agent_session_id) || cleanText(recipientAgentSessionId),
|
|
1123
|
+
recipient_role_key: cleanText(recipient_role_key) || cleanText(recipientRoleKey),
|
|
1124
|
+
workflow_run_id: cleanText(workflow_run_id) || cleanText(workflowRunId),
|
|
1125
|
+
},
|
|
1126
|
+
});
|
|
1127
|
+
}
|
|
1128
|
+
|
|
1129
|
+
export async function getMyInbox(client, {
|
|
1130
|
+
recipientAgentSessionId,
|
|
1131
|
+
recipient_agent_session_id,
|
|
1132
|
+
recipientRoleKey,
|
|
1133
|
+
recipient_role_key,
|
|
1134
|
+
workflowRunId,
|
|
1135
|
+
workflow_run_id,
|
|
1136
|
+
} = {}) {
|
|
1137
|
+
return client._request('/api/agent-communications/inbox/me', {
|
|
1138
|
+
query: {
|
|
1139
|
+
recipient_agent_session_id: cleanText(recipient_agent_session_id) || cleanText(recipientAgentSessionId),
|
|
1140
|
+
recipient_role_key: cleanText(recipient_role_key) || cleanText(recipientRoleKey),
|
|
1141
|
+
workflow_run_id: cleanText(workflow_run_id) || cleanText(workflowRunId),
|
|
1142
|
+
},
|
|
1143
|
+
});
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1146
|
+
export async function verifyMessageSent(client, { messageId, message_id } = {}) {
|
|
1147
|
+
const normalizedMessageId = cleanText(message_id) || cleanText(messageId);
|
|
1148
|
+
if (!normalizedMessageId) throw new Error('message_id is required.');
|
|
1149
|
+
return client._request(`/api/agent-communications/messages/${encodeURIComponent(normalizedMessageId)}/verify-sent`, {
|
|
1150
|
+
method: 'POST',
|
|
1151
|
+
body: { message_id: normalizedMessageId },
|
|
1152
|
+
});
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1155
|
+
export async function verifyMessageReceived(client, {
|
|
1156
|
+
messageId,
|
|
1157
|
+
message_id,
|
|
1158
|
+
recipientAgentSessionId,
|
|
1159
|
+
recipient_agent_session_id,
|
|
1160
|
+
recipientRole,
|
|
1161
|
+
recipient_role,
|
|
1162
|
+
role,
|
|
1163
|
+
participantId,
|
|
1164
|
+
participant_id,
|
|
1165
|
+
} = {}) {
|
|
1166
|
+
const normalizedMessageId = cleanText(message_id) || cleanText(messageId);
|
|
1167
|
+
if (!normalizedMessageId) throw new Error('message_id is required.');
|
|
1168
|
+
return client._request(`/api/agent-communications/messages/${encodeURIComponent(normalizedMessageId)}/verify-received`, {
|
|
1169
|
+
method: 'POST',
|
|
1170
|
+
body: {
|
|
1171
|
+
message_id: normalizedMessageId,
|
|
1172
|
+
recipient_agent_session_id: cleanText(recipient_agent_session_id) || cleanText(recipientAgentSessionId),
|
|
1173
|
+
recipient_role: cleanText(recipient_role) || cleanText(recipientRole) || cleanText(role),
|
|
1174
|
+
participant_id: cleanText(participant_id) || cleanText(participantId),
|
|
1175
|
+
},
|
|
1176
|
+
});
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1179
|
+
export async function getMessageDeliveryReceipt(client, { messageId, message_id } = {}) {
|
|
1180
|
+
const normalizedMessageId = cleanText(message_id) || cleanText(messageId);
|
|
1181
|
+
if (!normalizedMessageId) throw new Error('message_id is required.');
|
|
1182
|
+
return client._request(`/api/agent-communications/messages/${encodeURIComponent(normalizedMessageId)}/delivery-receipt`, {
|
|
1183
|
+
method: 'GET',
|
|
1184
|
+
});
|
|
1185
|
+
}
|
|
1186
|
+
|
|
1187
|
+
export async function _sendAgentCommsMessage(client, request = {}) {
|
|
1188
|
+
const hasThreadContext = Boolean(
|
|
1189
|
+
cleanText(request.communication_thread_id)
|
|
1190
|
+
|| cleanText(request.communicationThreadId)
|
|
1191
|
+
|| cleanText(request.thread_id)
|
|
1192
|
+
|| cleanText(request.threadId)
|
|
1193
|
+
|| cleanText(request.recipient_role_key)
|
|
1194
|
+
|| cleanText(request.recipientRoleKey)
|
|
1195
|
+
);
|
|
1196
|
+
const hasTransferChannelContext = Boolean(
|
|
1197
|
+
cleanText(request.transfer_channel_id)
|
|
1198
|
+
|| cleanText(request.transferChannelId)
|
|
1199
|
+
|| cleanText(request.channel_id)
|
|
1200
|
+
|| cleanText(request.channelId)
|
|
1201
|
+
|| cleanText(request.sender_role)
|
|
1202
|
+
|| cleanText(request.senderRole)
|
|
1203
|
+
|| cleanText(request.recipient_role)
|
|
1204
|
+
|| cleanText(request.recipientRole)
|
|
1205
|
+
|| cleanText(request.role)
|
|
1206
|
+
|| cleanText(request.participant_role)
|
|
1207
|
+
|| cleanText(request.participantRole)
|
|
1208
|
+
|| cleanText(request.participant_id)
|
|
1209
|
+
|| cleanText(request.participantId)
|
|
1210
|
+
|| cleanText(request.recipient_participant_id)
|
|
1211
|
+
|| cleanText(request.recipientParticipantId)
|
|
1212
|
+
);
|
|
1213
|
+
if (hasTransferChannelContext && !hasThreadContext) {
|
|
1214
|
+
if (
|
|
1215
|
+
cleanText(request.participant_id)
|
|
1216
|
+
|| cleanText(request.participantId)
|
|
1217
|
+
|| cleanText(request.recipient_participant_id)
|
|
1218
|
+
|| cleanText(request.recipientParticipantId)
|
|
1219
|
+
|| cleanText(request.recipient_agent_session_id)
|
|
1220
|
+
|| cleanText(request.recipientAgentSessionId)
|
|
1221
|
+
) {
|
|
1222
|
+
return client.sendToParticipant(request);
|
|
1223
|
+
}
|
|
1224
|
+
return client.sendToRole(request);
|
|
1225
|
+
}
|
|
1226
|
+
return client.sendCommunicationMessage(request);
|
|
1227
|
+
}
|
|
1228
|
+
|
|
1229
|
+
export async function sendCommunicationMessage(client, {
|
|
1230
|
+
communicationThreadId,
|
|
1231
|
+
communication_thread_id,
|
|
1232
|
+
threadId,
|
|
1233
|
+
communicationBundleId,
|
|
1234
|
+
communication_bundle_id,
|
|
1235
|
+
senderAgentSessionId,
|
|
1236
|
+
sender_agent_session_id,
|
|
1237
|
+
recipientAgentSessionId,
|
|
1238
|
+
recipient_agent_session_id,
|
|
1239
|
+
recipientRoleKey,
|
|
1240
|
+
recipient_role_key,
|
|
1241
|
+
messageKind,
|
|
1242
|
+
message_kind,
|
|
1243
|
+
bodyMarkdown,
|
|
1244
|
+
body_markdown,
|
|
1245
|
+
messageStatus,
|
|
1246
|
+
message_status,
|
|
1247
|
+
payload = {},
|
|
1248
|
+
scope = {},
|
|
1249
|
+
requiredResponseSchema = {},
|
|
1250
|
+
required_response_schema = {},
|
|
1251
|
+
metadata = {},
|
|
1252
|
+
} = {}) {
|
|
1253
|
+
return client._request('/api/agent-communications/messages', {
|
|
1254
|
+
method: 'POST',
|
|
1255
|
+
body: {
|
|
1256
|
+
communication_thread_id: cleanText(communication_thread_id) || cleanText(communicationThreadId) || cleanText(threadId),
|
|
1257
|
+
communication_bundle_id: cleanText(communication_bundle_id) || cleanText(communicationBundleId),
|
|
1258
|
+
sender_agent_session_id: cleanText(sender_agent_session_id) || cleanText(senderAgentSessionId) || client.agentSessionId,
|
|
1259
|
+
recipient_agent_session_id: cleanText(recipient_agent_session_id) || cleanText(recipientAgentSessionId),
|
|
1260
|
+
recipient_role_key: cleanText(recipient_role_key) || cleanText(recipientRoleKey),
|
|
1261
|
+
message_kind: normalizeMessageKind(cleanText(message_kind) || cleanText(messageKind)),
|
|
1262
|
+
message_status: cleanText(message_status) || cleanText(messageStatus) || 'sent',
|
|
1263
|
+
body_markdown: cleanText(body_markdown) || cleanText(bodyMarkdown),
|
|
1264
|
+
payload: isPlainObject(payload) ? payload : {},
|
|
1265
|
+
scope: isPlainObject(scope) ? scope : {},
|
|
1266
|
+
required_response_schema: isPlainObject(requiredResponseSchema)
|
|
1267
|
+
? requiredResponseSchema
|
|
1268
|
+
: (isPlainObject(required_response_schema) ? required_response_schema : {}),
|
|
1269
|
+
metadata: isPlainObject(metadata) ? metadata : {},
|
|
1270
|
+
},
|
|
1271
|
+
});
|
|
1272
|
+
}
|
|
1273
|
+
|
|
1274
|
+
export async function acceptCommunicationTransferPacket(client, {
|
|
1275
|
+
workTransferPacketId,
|
|
1276
|
+
work_transfer_packet_id,
|
|
1277
|
+
acceptedByAgentSessionId,
|
|
1278
|
+
accepted_by_agent_session_id,
|
|
1279
|
+
acceptedByActorSessionId,
|
|
1280
|
+
accepted_by_actor_session_id,
|
|
1281
|
+
acceptedByClaimId,
|
|
1282
|
+
accepted_by_claim_id,
|
|
1283
|
+
advanceToInProgress,
|
|
1284
|
+
advance_to_in_progress,
|
|
1285
|
+
metadata = {},
|
|
1286
|
+
} = {}) {
|
|
1287
|
+
const normalizedPacketId = cleanText(work_transfer_packet_id) || cleanText(workTransferPacketId);
|
|
1288
|
+
if (!normalizedPacketId) throw new Error('work_transfer_packet_id is required.');
|
|
1289
|
+
return client._request(`/api/agent-communications/transfers/${encodeURIComponent(normalizedPacketId)}/accept`, {
|
|
1290
|
+
method: 'POST',
|
|
1291
|
+
body: {
|
|
1292
|
+
accepted_by_agent_session_id: cleanText(accepted_by_agent_session_id) || cleanText(acceptedByAgentSessionId),
|
|
1293
|
+
accepted_by_actor_session_id: cleanText(accepted_by_actor_session_id) || cleanText(acceptedByActorSessionId),
|
|
1294
|
+
accepted_by_claim_id: cleanText(accepted_by_claim_id) || cleanText(acceptedByClaimId),
|
|
1295
|
+
advance_to_in_progress: Boolean(advance_to_in_progress ?? advanceToInProgress),
|
|
1296
|
+
metadata: isPlainObject(metadata) ? metadata : {},
|
|
1297
|
+
},
|
|
1298
|
+
});
|
|
1299
|
+
}
|
|
1300
|
+
|
|
1301
|
+
export async function closeCommunicationTransferPacket(client, {
|
|
1302
|
+
workTransferPacketId,
|
|
1303
|
+
work_transfer_packet_id,
|
|
1304
|
+
closureStatus,
|
|
1305
|
+
closure_status,
|
|
1306
|
+
closureReason,
|
|
1307
|
+
closure_reason,
|
|
1308
|
+
failureReason,
|
|
1309
|
+
failure_reason,
|
|
1310
|
+
closedByAgentSessionId,
|
|
1311
|
+
closed_by_agent_session_id,
|
|
1312
|
+
closedByActorSessionId,
|
|
1313
|
+
closed_by_actor_session_id,
|
|
1314
|
+
closedByClaimId,
|
|
1315
|
+
closed_by_claim_id,
|
|
1316
|
+
evidence = {},
|
|
1317
|
+
evidenceManifestSha256,
|
|
1318
|
+
evidence_manifest_sha256,
|
|
1319
|
+
metadata = {},
|
|
1320
|
+
} = {}) {
|
|
1321
|
+
const normalizedPacketId = cleanText(work_transfer_packet_id) || cleanText(workTransferPacketId);
|
|
1322
|
+
if (!normalizedPacketId) throw new Error('work_transfer_packet_id is required.');
|
|
1323
|
+
return client._request(`/api/agent-communications/transfers/${encodeURIComponent(normalizedPacketId)}/close`, {
|
|
1324
|
+
method: 'POST',
|
|
1325
|
+
body: {
|
|
1326
|
+
closure_status: normalizeTransferLifecycleStatus(cleanText(closure_status) || cleanText(closureStatus) || 'closed'),
|
|
1327
|
+
closure_reason: cleanText(closure_reason) || cleanText(closureReason),
|
|
1328
|
+
failure_reason: cleanText(failure_reason) || cleanText(failureReason),
|
|
1329
|
+
closed_by_agent_session_id: cleanText(closed_by_agent_session_id) || cleanText(closedByAgentSessionId),
|
|
1330
|
+
closed_by_actor_session_id: cleanText(closed_by_actor_session_id) || cleanText(closedByActorSessionId),
|
|
1331
|
+
closed_by_claim_id: cleanText(closed_by_claim_id) || cleanText(closedByClaimId),
|
|
1332
|
+
evidence: isPlainObject(evidence) ? evidence : {},
|
|
1333
|
+
evidence_manifest_sha256: cleanText(evidence_manifest_sha256) || cleanText(evidenceManifestSha256),
|
|
1334
|
+
metadata: isPlainObject(metadata) ? metadata : {},
|
|
1335
|
+
},
|
|
1336
|
+
});
|
|
1337
|
+
}
|
|
1338
|
+
|
|
1339
|
+
export async function getCommunicationTransferHealth(client, {
|
|
1340
|
+
workflowRunId,
|
|
1341
|
+
workflow_run_id,
|
|
1342
|
+
workTransferPacketId,
|
|
1343
|
+
work_transfer_packet_id,
|
|
1344
|
+
} = {}) {
|
|
1345
|
+
return client._request('/api/agent-communications/transfers/health', {
|
|
1346
|
+
query: {
|
|
1347
|
+
workflow_run_id: cleanText(workflow_run_id) || cleanText(workflowRunId),
|
|
1348
|
+
work_transfer_packet_id: cleanText(work_transfer_packet_id) || cleanText(workTransferPacketId),
|
|
1349
|
+
},
|
|
1350
|
+
});
|
|
1351
|
+
}
|
|
1352
|
+
|
|
1353
|
+
export async function acceptCommunicationMessage(client, messageId) {
|
|
1354
|
+
return client._request(`/api/agent-communications/messages/${encodeURIComponent(messageId)}/accept`, {
|
|
1355
|
+
method: 'POST',
|
|
1356
|
+
body: {},
|
|
1357
|
+
});
|
|
1358
|
+
}
|
|
1359
|
+
|
|
1360
|
+
export async function respondToCommunicationMessage(client, {
|
|
1361
|
+
agentMessageId,
|
|
1362
|
+
agent_message_id,
|
|
1363
|
+
messageId,
|
|
1364
|
+
status,
|
|
1365
|
+
bodyMarkdown,
|
|
1366
|
+
body_markdown,
|
|
1367
|
+
payload = {},
|
|
1368
|
+
metadata = {},
|
|
1369
|
+
evidenceRefs,
|
|
1370
|
+
evidence_refs,
|
|
1371
|
+
} = {}) {
|
|
1372
|
+
const normalizedMessageId = cleanText(agent_message_id) || cleanText(agentMessageId) || cleanText(messageId);
|
|
1373
|
+
if (!normalizedMessageId) {
|
|
1374
|
+
throw new Error('agent_message_id is required.');
|
|
1375
|
+
}
|
|
1376
|
+
return client._request(`/api/agent-communications/messages/${encodeURIComponent(normalizedMessageId)}/respond-with-evidence`, {
|
|
1377
|
+
method: 'POST',
|
|
1378
|
+
body: {
|
|
1379
|
+
status: cleanText(status) || 'answered',
|
|
1380
|
+
body_markdown: cleanText(body_markdown) || cleanText(bodyMarkdown),
|
|
1381
|
+
payload: isPlainObject(payload) ? payload : {},
|
|
1382
|
+
metadata: isPlainObject(metadata) ? metadata : {},
|
|
1383
|
+
evidence_refs: Array.isArray(evidence_refs) ? evidence_refs : (Array.isArray(evidenceRefs) ? evidenceRefs : []),
|
|
1384
|
+
},
|
|
1385
|
+
});
|
|
1386
|
+
}
|
|
1387
|
+
|
|
1388
|
+
export async function attachCommunicationMessageEvidence(client, {
|
|
1389
|
+
agentMessageId,
|
|
1390
|
+
agent_message_id,
|
|
1391
|
+
messageId,
|
|
1392
|
+
evidenceType,
|
|
1393
|
+
evidence_type,
|
|
1394
|
+
evidenceRef,
|
|
1395
|
+
evidence_ref,
|
|
1396
|
+
sourceTruth,
|
|
1397
|
+
source_truth,
|
|
1398
|
+
trustLevel,
|
|
1399
|
+
trust_level,
|
|
1400
|
+
metadata = {},
|
|
1401
|
+
} = {}) {
|
|
1402
|
+
const normalizedMessageId = cleanText(agent_message_id) || cleanText(agentMessageId) || cleanText(messageId);
|
|
1403
|
+
if (!normalizedMessageId) {
|
|
1404
|
+
throw new Error('agent_message_id is required.');
|
|
1405
|
+
}
|
|
1406
|
+
return client._request(`/api/agent-communications/messages/${encodeURIComponent(normalizedMessageId)}/evidence-links`, {
|
|
1407
|
+
method: 'POST',
|
|
1408
|
+
body: {
|
|
1409
|
+
evidence_type: cleanText(evidence_type) || cleanText(evidenceType),
|
|
1410
|
+
evidence_ref: cleanText(evidence_ref) || cleanText(evidenceRef),
|
|
1411
|
+
source_truth: cleanText(source_truth) || cleanText(sourceTruth),
|
|
1412
|
+
trust_level: cleanText(trust_level) || cleanText(trustLevel) || 'candidate',
|
|
1413
|
+
metadata: isPlainObject(metadata) ? metadata : {},
|
|
1414
|
+
},
|
|
1415
|
+
});
|
|
1416
|
+
}
|
|
1417
|
+
|
|
1418
|
+
export async function createCommunicationHandoff(client, {
|
|
1419
|
+
workflowRunId,
|
|
1420
|
+
workflow_run_id,
|
|
1421
|
+
title,
|
|
1422
|
+
agentSessionId,
|
|
1423
|
+
agent_session_id,
|
|
1424
|
+
handoffKind,
|
|
1425
|
+
handoff_kind,
|
|
1426
|
+
handoffPriority,
|
|
1427
|
+
handoff_priority,
|
|
1428
|
+
summaryText,
|
|
1429
|
+
summary_text,
|
|
1430
|
+
handoffPayload = {},
|
|
1431
|
+
handoff_payload = {},
|
|
1432
|
+
createdBy,
|
|
1433
|
+
created_by,
|
|
1434
|
+
supersedesHandoffId,
|
|
1435
|
+
supersedes_handoff_id,
|
|
1436
|
+
} = {}) {
|
|
1437
|
+
return client._request('/api/agent-communications/handoffs', {
|
|
1438
|
+
method: 'POST',
|
|
1439
|
+
body: {
|
|
1440
|
+
workflow_run_id: cleanText(workflow_run_id) || cleanText(workflowRunId),
|
|
1441
|
+
title: cleanText(title),
|
|
1442
|
+
agent_session_id: cleanText(agent_session_id) || cleanText(agentSessionId) || client.agentSessionId,
|
|
1443
|
+
handoff_kind: cleanText(handoff_kind) || cleanText(handoffKind) || 'general',
|
|
1444
|
+
handoff_priority: cleanText(handoff_priority) || cleanText(handoffPriority) || 'normal',
|
|
1445
|
+
summary_text: cleanText(summary_text) || cleanText(summaryText),
|
|
1446
|
+
handoff_payload: isPlainObject(handoffPayload)
|
|
1447
|
+
? handoffPayload
|
|
1448
|
+
: (isPlainObject(handoff_payload) ? handoff_payload : {}),
|
|
1449
|
+
created_by: cleanText(created_by) || cleanText(createdBy),
|
|
1450
|
+
supersedes_handoff_id: cleanText(supersedes_handoff_id) || cleanText(supersedesHandoffId),
|
|
1451
|
+
},
|
|
1452
|
+
});
|
|
1453
|
+
}
|
|
1454
|
+
|
|
1455
|
+
export async function acceptCommunicationHandoff(client, handoffId) {
|
|
1456
|
+
return client._request(`/api/agent-communications/handoffs/${encodeURIComponent(handoffId)}/accept`, {
|
|
1457
|
+
method: 'POST',
|
|
1458
|
+
body: {},
|
|
1459
|
+
});
|
|
1460
|
+
}
|