@bpmsoftwaresolutions/ai-engine-client 1.1.55 → 1.1.57

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +299 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bpmsoftwaresolutions/ai-engine-client",
3
- "version": "1.1.55",
3
+ "version": "1.1.57",
4
4
  "description": "Thin npm client for the AI Engine operator and retrieval APIs",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
package/src/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  const DEFAULT_TIMEOUT_MS = 30000;
2
- export const AI_ENGINE_CLIENT_VERSION = '1.1.55';
2
+ export const AI_ENGINE_CLIENT_VERSION = '1.1.57';
3
3
  export const GOVERNED_MUTATION_REQUIRED_CAPABILITIES = [
4
4
  'executeVerifiedMutation',
5
5
  'post_mutation_verification',
@@ -409,7 +409,7 @@ export class AIEngineClient {
409
409
  openThread: (request) => this.openCommunicationThread(request),
410
410
  getThread: (threadId) => this.getCommunicationThread(threadId),
411
411
  listInbox: (request) => this.listCommunicationInbox(request),
412
- sendMessage: (request) => this.sendCommunicationMessage(request),
412
+ sendMessage: (request) => this._sendAgentCommsMessage(request),
413
413
  getCommunicationCapabilities: (request) => this.getCommunicationCapabilities(request),
414
414
  getCollaborationCapabilities: (request) => this.getCollaborationCapabilities(request),
415
415
  getDeploymentCapabilities: (request) => this.getDeploymentCapabilities(request),
@@ -440,9 +440,20 @@ export class AIEngineClient {
440
440
  acceptHandoff: (request) => this.acceptCommunicationHandoff(request),
441
441
  whoIsOnline: (request) => this.whoIsOnline(request),
442
442
  findOnlineParticipant: (request) => this.findOnlineParticipant(request),
443
+ listCommunicationChannels: (request) => this.listCommunicationChannels(request),
444
+ listOpenCommunicationChannels: (request) => this.listOpenCommunicationChannels(request),
445
+ getCommunicationChannelStatus: (request) => this.getCommunicationChannelStatus(request),
446
+ getCommunicationChannelParticipants: (request) => this.getCommunicationChannelParticipants(request),
447
+ getPresenceBoard: (request) => this.getPresenceBoard(request),
448
+ getChannelPresence: (request) => this.getChannelPresence(request),
449
+ markParticipantOnline: (request) => this.markParticipantOnline(request),
450
+ markParticipantOffline: (request) => this.markParticipantOffline(request),
443
451
  sendToParticipant: (request) => this.sendToParticipant(request),
444
452
  sendToRole: (request) => this.sendToRole(request),
445
453
  getMyInbox: (request) => this.getMyInbox(request),
454
+ verifyMessageSent: (request) => this.verifyMessageSent(request),
455
+ verifyMessageReceived: (request) => this.verifyMessageReceived(request),
456
+ getMessageDeliveryReceipt: (request) => this.getMessageDeliveryReceipt(request),
446
457
  connectToTransferChannel: (request) => this.connectToTransferChannel(request),
447
458
  respondToMessageWatch: (request) => this.respondToMessageWatch(request),
448
459
  };
@@ -456,9 +467,21 @@ export class AIEngineClient {
456
467
  requestClosure: (request) => this.requestCollaborationClosure(request),
457
468
  whoIsOnline: (request) => this.whoIsOnline(request),
458
469
  findOnlineParticipant: (request) => this.findOnlineParticipant(request),
470
+ listCommunicationChannels: (request) => this.listCommunicationChannels(request),
471
+ listOpenCommunicationChannels: (request) => this.listOpenCommunicationChannels(request),
472
+ getCommunicationChannelStatus: (request) => this.getCommunicationChannelStatus(request),
473
+ getCommunicationChannelParticipants: (request) => this.getCommunicationChannelParticipants(request),
474
+ getPresenceBoard: (request) => this.getPresenceBoard(request),
475
+ getChannelPresence: (request) => this.getChannelPresence(request),
476
+ markParticipantOnline: (request) => this.markParticipantOnline(request),
477
+ markParticipantOffline: (request) => this.markParticipantOffline(request),
459
478
  sendToParticipant: (request) => this.sendToParticipant(request),
460
479
  sendToRole: (request) => this.sendToRole(request),
461
480
  getMyInbox: (request) => this.getMyInbox(request),
481
+ sendMessage: (request) => this._sendAgentCommsMessage(request),
482
+ verifyMessageSent: (request) => this.verifyMessageSent(request),
483
+ verifyMessageReceived: (request) => this.verifyMessageReceived(request),
484
+ getMessageDeliveryReceipt: (request) => this.getMessageDeliveryReceipt(request),
462
485
  };
463
486
  }
464
487
 
@@ -649,6 +672,197 @@ export class AIEngineClient {
649
672
  return this._request('/api/agent-communications/deployment-capabilities');
650
673
  }
651
674
 
675
+ async listCommunicationChannels({
676
+ workflowRunId,
677
+ workflow_run_id,
678
+ workTransferPacketId,
679
+ work_transfer_packet_id,
680
+ status,
681
+ channelStatus,
682
+ channel_status,
683
+ } = {}) {
684
+ return this._request('/api/agent-communications/transfer-channels', {
685
+ query: {
686
+ workflow_run_id: cleanText(workflow_run_id) || cleanText(workflowRunId),
687
+ work_transfer_packet_id: cleanText(work_transfer_packet_id) || cleanText(workTransferPacketId),
688
+ status: cleanText(status) || cleanText(channel_status) || cleanText(channelStatus),
689
+ },
690
+ });
691
+ }
692
+
693
+ async listOpenCommunicationChannels(request = {}) {
694
+ return this.listCommunicationChannels({ ...request, status: 'open' });
695
+ }
696
+
697
+ async getCommunicationChannelStatus({
698
+ transferChannelId,
699
+ transfer_channel_id,
700
+ channelId,
701
+ channel_id,
702
+ } = {}) {
703
+ const normalizedTransferChannelId = cleanText(transfer_channel_id) || cleanText(transferChannelId) || cleanText(channel_id) || cleanText(channelId);
704
+ if (!normalizedTransferChannelId) throw new Error('transferChannelId is required.');
705
+ return this._request(`/api/agent-communications/transfer-channels/${encodeURIComponent(normalizedTransferChannelId)}/status`);
706
+ }
707
+
708
+ async getCommunicationChannelParticipants({
709
+ transferChannelId,
710
+ transfer_channel_id,
711
+ channelId,
712
+ channel_id,
713
+ } = {}) {
714
+ const normalizedTransferChannelId = cleanText(transfer_channel_id) || cleanText(transferChannelId) || cleanText(channel_id) || cleanText(channelId);
715
+ if (!normalizedTransferChannelId) throw new Error('transferChannelId is required.');
716
+ return this._request(`/api/agent-communications/transfer-channels/${encodeURIComponent(normalizedTransferChannelId)}/participants`);
717
+ }
718
+
719
+ async getPresenceBoard({
720
+ workflowRunId,
721
+ workflow_run_id,
722
+ transferChannelId,
723
+ transfer_channel_id,
724
+ participantRole,
725
+ participant_role,
726
+ role,
727
+ capability,
728
+ includeStale,
729
+ include_stale,
730
+ } = {}) {
731
+ const normalizedTransferChannelId = cleanText(transfer_channel_id) || cleanText(transferChannelId);
732
+ const path = normalizedTransferChannelId
733
+ ? `/api/operator/projections/agent-communications/presence/${encodeURIComponent(normalizedTransferChannelId)}`
734
+ : '/api/operator/projections/agent-communications/presence';
735
+ return this._requestLogaProjection(path, {
736
+ query: {
737
+ workflow_run_id: cleanText(workflow_run_id) || cleanText(workflowRunId),
738
+ transfer_channel_id: normalizedTransferChannelId,
739
+ participant_role: cleanText(participant_role) || cleanText(participantRole) || cleanText(role),
740
+ capability: cleanText(capability),
741
+ include_stale: include_stale ?? includeStale,
742
+ },
743
+ });
744
+ }
745
+
746
+ async getChannelPresence({
747
+ transferChannelId,
748
+ transfer_channel_id,
749
+ channelId,
750
+ channel_id,
751
+ workflowRunId,
752
+ workflow_run_id,
753
+ participantRole,
754
+ participant_role,
755
+ role,
756
+ capability,
757
+ includeStale,
758
+ include_stale,
759
+ } = {}) {
760
+ const normalizedTransferChannelId = cleanText(transfer_channel_id) || cleanText(transferChannelId) || cleanText(channel_id) || cleanText(channelId);
761
+ if (!normalizedTransferChannelId) {
762
+ throw new Error('transferChannelId is required.');
763
+ }
764
+ return this._requestLogaProjection(`/api/operator/projections/agent-communications/presence/${encodeURIComponent(normalizedTransferChannelId)}`, {
765
+ query: {
766
+ workflow_run_id: cleanText(workflow_run_id) || cleanText(workflowRunId),
767
+ participant_role: cleanText(participant_role) || cleanText(participantRole) || cleanText(role),
768
+ capability: cleanText(capability),
769
+ include_stale: include_stale ?? includeStale,
770
+ },
771
+ });
772
+ }
773
+
774
+ async markParticipantOnline({
775
+ transferChannelId,
776
+ transfer_channel_id,
777
+ channelId,
778
+ channel_id,
779
+ workTransferPacketId,
780
+ work_transfer_packet_id,
781
+ packetId,
782
+ packet_id,
783
+ workflowRunId,
784
+ workflow_run_id,
785
+ participantRole,
786
+ participant_role,
787
+ currentPhase,
788
+ current_phase,
789
+ currentTaskSummary,
790
+ current_task_summary,
791
+ agentSessionId,
792
+ agent_session_id,
793
+ actorSessionId,
794
+ actor_session_id,
795
+ observedAt,
796
+ observed_at,
797
+ metadata = {},
798
+ } = {}) {
799
+ const normalizedTransferChannelId = cleanText(transfer_channel_id) || cleanText(transferChannelId) || cleanText(channel_id) || cleanText(channelId);
800
+ if (!normalizedTransferChannelId) throw new Error('transferChannelId is required.');
801
+ return this._request(`/api/agent-communications/transfer-channels/${encodeURIComponent(normalizedTransferChannelId)}/presence/online`, {
802
+ method: 'POST',
803
+ body: {
804
+ transfer_channel_id: normalizedTransferChannelId,
805
+ work_transfer_packet_id: cleanText(work_transfer_packet_id) || cleanText(workTransferPacketId) || cleanText(packet_id) || cleanText(packetId),
806
+ workflow_run_id: cleanText(workflow_run_id) || cleanText(workflowRunId),
807
+ participant_role: cleanText(participant_role) || cleanText(participantRole),
808
+ current_phase: cleanText(current_phase) || cleanText(currentPhase),
809
+ current_task_summary: cleanText(current_task_summary) || cleanText(currentTaskSummary),
810
+ agent_session_id: cleanText(agent_session_id) || cleanText(agentSessionId),
811
+ actor_session_id: cleanText(actor_session_id) || cleanText(actorSessionId),
812
+ observed_at: cleanText(observed_at) || cleanText(observedAt),
813
+ metadata: isPlainObject(metadata) ? metadata : {},
814
+ is_active: true,
815
+ activity_state: 'active',
816
+ },
817
+ });
818
+ }
819
+
820
+ async markParticipantOffline({
821
+ transferChannelId,
822
+ transfer_channel_id,
823
+ channelId,
824
+ channel_id,
825
+ workTransferPacketId,
826
+ work_transfer_packet_id,
827
+ packetId,
828
+ packet_id,
829
+ workflowRunId,
830
+ workflow_run_id,
831
+ participantRole,
832
+ participant_role,
833
+ currentPhase,
834
+ current_phase,
835
+ currentTaskSummary,
836
+ current_task_summary,
837
+ agentSessionId,
838
+ agent_session_id,
839
+ actorSessionId,
840
+ actor_session_id,
841
+ observedAt,
842
+ observed_at,
843
+ metadata = {},
844
+ } = {}) {
845
+ const normalizedTransferChannelId = cleanText(transfer_channel_id) || cleanText(transferChannelId) || cleanText(channel_id) || cleanText(channelId);
846
+ if (!normalizedTransferChannelId) throw new Error('transferChannelId is required.');
847
+ return this._request(`/api/agent-communications/transfer-channels/${encodeURIComponent(normalizedTransferChannelId)}/presence/offline`, {
848
+ method: 'POST',
849
+ body: {
850
+ transfer_channel_id: normalizedTransferChannelId,
851
+ work_transfer_packet_id: cleanText(work_transfer_packet_id) || cleanText(workTransferPacketId) || cleanText(packet_id) || cleanText(packetId),
852
+ workflow_run_id: cleanText(workflow_run_id) || cleanText(workflowRunId),
853
+ participant_role: cleanText(participant_role) || cleanText(participantRole),
854
+ current_phase: cleanText(current_phase) || cleanText(currentPhase),
855
+ current_task_summary: cleanText(current_task_summary) || cleanText(currentTaskSummary),
856
+ agent_session_id: cleanText(agent_session_id) || cleanText(agentSessionId),
857
+ actor_session_id: cleanText(actor_session_id) || cleanText(actorSessionId),
858
+ observed_at: cleanText(observed_at) || cleanText(observedAt),
859
+ metadata: isPlainObject(metadata) ? metadata : {},
860
+ is_active: false,
861
+ activity_state: 'offline',
862
+ },
863
+ });
864
+ }
865
+
652
866
  async reviewCollaborationProposal({
653
867
  transferChannelId,
654
868
  transfer_channel_id,
@@ -1462,6 +1676,89 @@ export class AIEngineClient {
1462
1676
  });
1463
1677
  }
1464
1678
 
1679
+ async verifyMessageSent({ messageId, message_id } = {}) {
1680
+ const normalizedMessageId = cleanText(message_id) || cleanText(messageId);
1681
+ if (!normalizedMessageId) throw new Error('message_id is required.');
1682
+ return this._request(`/api/agent-communications/messages/${encodeURIComponent(normalizedMessageId)}/verify-sent`, {
1683
+ method: 'POST',
1684
+ body: { message_id: normalizedMessageId },
1685
+ });
1686
+ }
1687
+
1688
+ async verifyMessageReceived({
1689
+ messageId,
1690
+ message_id,
1691
+ recipientAgentSessionId,
1692
+ recipient_agent_session_id,
1693
+ recipientRole,
1694
+ recipient_role,
1695
+ role,
1696
+ participantId,
1697
+ participant_id,
1698
+ } = {}) {
1699
+ const normalizedMessageId = cleanText(message_id) || cleanText(messageId);
1700
+ if (!normalizedMessageId) throw new Error('message_id is required.');
1701
+ return this._request(`/api/agent-communications/messages/${encodeURIComponent(normalizedMessageId)}/verify-received`, {
1702
+ method: 'POST',
1703
+ body: {
1704
+ message_id: normalizedMessageId,
1705
+ recipient_agent_session_id: cleanText(recipient_agent_session_id) || cleanText(recipientAgentSessionId),
1706
+ recipient_role: cleanText(recipient_role) || cleanText(recipientRole) || cleanText(role),
1707
+ participant_id: cleanText(participant_id) || cleanText(participantId),
1708
+ },
1709
+ });
1710
+ }
1711
+
1712
+ async getMessageDeliveryReceipt({ messageId, message_id } = {}) {
1713
+ const normalizedMessageId = cleanText(message_id) || cleanText(messageId);
1714
+ if (!normalizedMessageId) throw new Error('message_id is required.');
1715
+ return this._request(`/api/agent-communications/messages/${encodeURIComponent(normalizedMessageId)}/delivery-receipt`, {
1716
+ method: 'GET',
1717
+ });
1718
+ }
1719
+
1720
+ async _sendAgentCommsMessage(request = {}) {
1721
+ const hasThreadContext = Boolean(
1722
+ cleanText(request.communication_thread_id)
1723
+ || cleanText(request.communicationThreadId)
1724
+ || cleanText(request.thread_id)
1725
+ || cleanText(request.threadId)
1726
+ || cleanText(request.recipient_role_key)
1727
+ || cleanText(request.recipientRoleKey)
1728
+ );
1729
+ const hasTransferChannelContext = Boolean(
1730
+ cleanText(request.transfer_channel_id)
1731
+ || cleanText(request.transferChannelId)
1732
+ || cleanText(request.channel_id)
1733
+ || cleanText(request.channelId)
1734
+ || cleanText(request.sender_role)
1735
+ || cleanText(request.senderRole)
1736
+ || cleanText(request.recipient_role)
1737
+ || cleanText(request.recipientRole)
1738
+ || cleanText(request.role)
1739
+ || cleanText(request.participant_role)
1740
+ || cleanText(request.participantRole)
1741
+ || cleanText(request.participant_id)
1742
+ || cleanText(request.participantId)
1743
+ || cleanText(request.recipient_participant_id)
1744
+ || cleanText(request.recipientParticipantId)
1745
+ );
1746
+ if (hasTransferChannelContext && !hasThreadContext) {
1747
+ if (
1748
+ cleanText(request.participant_id)
1749
+ || cleanText(request.participantId)
1750
+ || cleanText(request.recipient_participant_id)
1751
+ || cleanText(request.recipientParticipantId)
1752
+ || cleanText(request.recipient_agent_session_id)
1753
+ || cleanText(request.recipientAgentSessionId)
1754
+ ) {
1755
+ return this.sendToParticipant(request);
1756
+ }
1757
+ return this.sendToRole(request);
1758
+ }
1759
+ return this.sendCommunicationMessage(request);
1760
+ }
1761
+
1465
1762
  async sendCommunicationMessage({
1466
1763
  communicationThreadId,
1467
1764
  communication_thread_id,