@bpmsoftwaresolutions/ai-engine-client 1.1.42 → 1.1.44

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 +214 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bpmsoftwaresolutions/ai-engine-client",
3
- "version": "1.1.42",
3
+ "version": "1.1.44",
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.42';
2
+ export const AI_ENGINE_CLIENT_VERSION = '1.1.44';
3
3
  export const GOVERNED_MUTATION_REQUIRED_CAPABILITIES = [
4
4
  'executeVerifiedMutation',
5
5
  'post_mutation_verification',
@@ -305,6 +305,17 @@ export class AIEngineClient {
305
305
  this.actions = {
306
306
  submit: (request) => this.submitActionIntent(request),
307
307
  };
308
+ this.agentComms = {
309
+ openThread: (request) => this.openCommunicationThread(request),
310
+ getThread: (threadId) => this.getCommunicationThread(threadId),
311
+ listInbox: (request) => this.listCommunicationInbox(request),
312
+ sendMessage: (request) => this.sendCommunicationMessage(request),
313
+ acceptMessage: (messageId) => this.acceptCommunicationMessage(messageId),
314
+ respondWithEvidence: (request) => this.respondToCommunicationMessage(request),
315
+ attachEvidence: (request) => this.attachCommunicationMessageEvidence(request),
316
+ createHandoff: (request) => this.createCommunicationHandoff(request),
317
+ acceptHandoff: (request) => this.acceptCommunicationHandoff(request),
318
+ };
308
319
  }
309
320
 
310
321
  static fromEnv(options = {}) {
@@ -482,6 +493,208 @@ export class AIEngineClient {
482
493
  });
483
494
  }
484
495
 
496
+ async openCommunicationThread({
497
+ workflowRunId,
498
+ workflow_run_id,
499
+ threadType,
500
+ thread_type,
501
+ subject,
502
+ objective,
503
+ parentThreadId,
504
+ parent_thread_id,
505
+ createdByAgentSessionId,
506
+ created_by_agent_session_id,
507
+ createdByActorSessionId,
508
+ created_by_actor_session_id,
509
+ metadata,
510
+ } = {}) {
511
+ return this._request('/api/agent-communications/threads', {
512
+ method: 'POST',
513
+ body: {
514
+ workflow_run_id: cleanText(workflow_run_id) || cleanText(workflowRunId),
515
+ parent_thread_id: cleanText(parent_thread_id) || cleanText(parentThreadId),
516
+ thread_type: cleanText(thread_type) || cleanText(threadType),
517
+ subject: cleanText(subject),
518
+ objective: cleanText(objective),
519
+ created_by_agent_session_id: cleanText(created_by_agent_session_id) || cleanText(createdByAgentSessionId),
520
+ created_by_actor_session_id: cleanText(created_by_actor_session_id) || cleanText(createdByActorSessionId),
521
+ metadata: isPlainObject(metadata) ? metadata : {},
522
+ },
523
+ });
524
+ }
525
+
526
+ async getCommunicationThread(threadId) {
527
+ return this._request(`/api/agent-communications/threads/${encodeURIComponent(threadId)}`);
528
+ }
529
+
530
+ async listCommunicationInbox({
531
+ recipientAgentSessionId,
532
+ recipient_agent_session_id,
533
+ recipientRoleKey,
534
+ recipient_role_key,
535
+ workflowRunId,
536
+ workflow_run_id,
537
+ } = {}) {
538
+ return this._request('/api/agent-communications/inbox', {
539
+ query: {
540
+ recipient_agent_session_id: cleanText(recipient_agent_session_id) || cleanText(recipientAgentSessionId),
541
+ recipient_role_key: cleanText(recipient_role_key) || cleanText(recipientRoleKey),
542
+ workflow_run_id: cleanText(workflow_run_id) || cleanText(workflowRunId),
543
+ },
544
+ });
545
+ }
546
+
547
+ async sendCommunicationMessage({
548
+ communicationThreadId,
549
+ communication_thread_id,
550
+ threadId,
551
+ senderAgentSessionId,
552
+ sender_agent_session_id,
553
+ recipientAgentSessionId,
554
+ recipient_agent_session_id,
555
+ recipientRoleKey,
556
+ recipient_role_key,
557
+ messageKind,
558
+ message_kind,
559
+ bodyMarkdown,
560
+ body_markdown,
561
+ messageStatus,
562
+ message_status,
563
+ payload = {},
564
+ scope = {},
565
+ requiredResponseSchema = {},
566
+ required_response_schema = {},
567
+ metadata = {},
568
+ } = {}) {
569
+ return this._request('/api/agent-communications/messages', {
570
+ method: 'POST',
571
+ body: {
572
+ communication_thread_id: cleanText(communication_thread_id) || cleanText(communicationThreadId) || cleanText(threadId),
573
+ sender_agent_session_id: cleanText(sender_agent_session_id) || cleanText(senderAgentSessionId),
574
+ recipient_agent_session_id: cleanText(recipient_agent_session_id) || cleanText(recipientAgentSessionId),
575
+ recipient_role_key: cleanText(recipient_role_key) || cleanText(recipientRoleKey),
576
+ message_kind: cleanText(message_kind) || cleanText(messageKind),
577
+ message_status: cleanText(message_status) || cleanText(messageStatus) || 'sent',
578
+ body_markdown: cleanText(body_markdown) || cleanText(bodyMarkdown),
579
+ payload: isPlainObject(payload) ? payload : {},
580
+ scope: isPlainObject(scope) ? scope : {},
581
+ required_response_schema: isPlainObject(requiredResponseSchema)
582
+ ? requiredResponseSchema
583
+ : (isPlainObject(required_response_schema) ? required_response_schema : {}),
584
+ metadata: isPlainObject(metadata) ? metadata : {},
585
+ },
586
+ });
587
+ }
588
+
589
+ async acceptCommunicationMessage(messageId) {
590
+ return this._request(`/api/agent-communications/messages/${encodeURIComponent(messageId)}/accept`, {
591
+ method: 'POST',
592
+ body: {},
593
+ });
594
+ }
595
+
596
+ async respondToCommunicationMessage({
597
+ agentMessageId,
598
+ agent_message_id,
599
+ messageId,
600
+ status,
601
+ bodyMarkdown,
602
+ body_markdown,
603
+ payload = {},
604
+ metadata = {},
605
+ evidenceRefs,
606
+ evidence_refs,
607
+ } = {}) {
608
+ const normalizedMessageId = cleanText(agent_message_id) || cleanText(agentMessageId) || cleanText(messageId);
609
+ if (!normalizedMessageId) {
610
+ throw new Error('agent_message_id is required.');
611
+ }
612
+ return this._request(`/api/agent-communications/messages/${encodeURIComponent(normalizedMessageId)}/respond-with-evidence`, {
613
+ method: 'POST',
614
+ body: {
615
+ status: cleanText(status) || 'answered',
616
+ body_markdown: cleanText(body_markdown) || cleanText(bodyMarkdown),
617
+ payload: isPlainObject(payload) ? payload : {},
618
+ metadata: isPlainObject(metadata) ? metadata : {},
619
+ evidence_refs: Array.isArray(evidence_refs) ? evidence_refs : (Array.isArray(evidenceRefs) ? evidenceRefs : []),
620
+ },
621
+ });
622
+ }
623
+
624
+ async attachCommunicationMessageEvidence({
625
+ agentMessageId,
626
+ agent_message_id,
627
+ messageId,
628
+ evidenceType,
629
+ evidence_type,
630
+ evidenceRef,
631
+ evidence_ref,
632
+ sourceTruth,
633
+ source_truth,
634
+ trustLevel,
635
+ trust_level,
636
+ metadata = {},
637
+ } = {}) {
638
+ const normalizedMessageId = cleanText(agent_message_id) || cleanText(agentMessageId) || cleanText(messageId);
639
+ if (!normalizedMessageId) {
640
+ throw new Error('agent_message_id is required.');
641
+ }
642
+ return this._request(`/api/agent-communications/messages/${encodeURIComponent(normalizedMessageId)}/evidence-links`, {
643
+ method: 'POST',
644
+ body: {
645
+ evidence_type: cleanText(evidence_type) || cleanText(evidenceType),
646
+ evidence_ref: cleanText(evidence_ref) || cleanText(evidenceRef),
647
+ source_truth: cleanText(source_truth) || cleanText(sourceTruth),
648
+ trust_level: cleanText(trust_level) || cleanText(trustLevel) || 'candidate',
649
+ metadata: isPlainObject(metadata) ? metadata : {},
650
+ },
651
+ });
652
+ }
653
+
654
+ async createCommunicationHandoff({
655
+ workflowRunId,
656
+ workflow_run_id,
657
+ title,
658
+ agentSessionId,
659
+ agent_session_id,
660
+ handoffKind,
661
+ handoff_kind,
662
+ handoffPriority,
663
+ handoff_priority,
664
+ summaryText,
665
+ summary_text,
666
+ handoffPayload = {},
667
+ handoff_payload = {},
668
+ createdBy,
669
+ created_by,
670
+ supersedesHandoffId,
671
+ supersedes_handoff_id,
672
+ } = {}) {
673
+ return this._request('/api/agent-communications/handoffs', {
674
+ method: 'POST',
675
+ body: {
676
+ workflow_run_id: cleanText(workflow_run_id) || cleanText(workflowRunId),
677
+ title: cleanText(title),
678
+ agent_session_id: cleanText(agent_session_id) || cleanText(agentSessionId),
679
+ handoff_kind: cleanText(handoff_kind) || cleanText(handoffKind) || 'general',
680
+ handoff_priority: cleanText(handoff_priority) || cleanText(handoffPriority) || 'normal',
681
+ summary_text: cleanText(summary_text) || cleanText(summaryText),
682
+ handoff_payload: isPlainObject(handoffPayload)
683
+ ? handoffPayload
684
+ : (isPlainObject(handoff_payload) ? handoff_payload : {}),
685
+ created_by: cleanText(created_by) || cleanText(createdBy),
686
+ supersedes_handoff_id: cleanText(supersedes_handoff_id) || cleanText(supersedesHandoffId),
687
+ },
688
+ });
689
+ }
690
+
691
+ async acceptCommunicationHandoff(handoffId) {
692
+ return this._request(`/api/agent-communications/handoffs/${encodeURIComponent(handoffId)}/accept`, {
693
+ method: 'POST',
694
+ body: {},
695
+ });
696
+ }
697
+
485
698
  async currentProjectStatus({ projectId } = {}) {
486
699
  return this._request('/api/operator/current-project-status', {
487
700
  query: { project_id: projectId },