@bpmsoftwaresolutions/ai-engine-client 1.1.41 → 1.1.43
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/index.js +225 -12
package/package.json
CHANGED
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.
|
|
2
|
+
export const AI_ENGINE_CLIENT_VERSION = '1.1.43';
|
|
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,205 @@ 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
|
+
} = {}) {
|
|
536
|
+
return this._request('/api/agent-communications/inbox', {
|
|
537
|
+
query: {
|
|
538
|
+
recipient_agent_session_id: cleanText(recipient_agent_session_id) || cleanText(recipientAgentSessionId),
|
|
539
|
+
recipient_role_key: cleanText(recipient_role_key) || cleanText(recipientRoleKey),
|
|
540
|
+
},
|
|
541
|
+
});
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
async sendCommunicationMessage({
|
|
545
|
+
communicationThreadId,
|
|
546
|
+
communication_thread_id,
|
|
547
|
+
threadId,
|
|
548
|
+
senderAgentSessionId,
|
|
549
|
+
sender_agent_session_id,
|
|
550
|
+
recipientAgentSessionId,
|
|
551
|
+
recipient_agent_session_id,
|
|
552
|
+
recipientRoleKey,
|
|
553
|
+
recipient_role_key,
|
|
554
|
+
messageKind,
|
|
555
|
+
message_kind,
|
|
556
|
+
bodyMarkdown,
|
|
557
|
+
body_markdown,
|
|
558
|
+
messageStatus,
|
|
559
|
+
message_status,
|
|
560
|
+
payload = {},
|
|
561
|
+
scope = {},
|
|
562
|
+
requiredResponseSchema = {},
|
|
563
|
+
required_response_schema = {},
|
|
564
|
+
metadata = {},
|
|
565
|
+
} = {}) {
|
|
566
|
+
return this._request('/api/agent-communications/messages', {
|
|
567
|
+
method: 'POST',
|
|
568
|
+
body: {
|
|
569
|
+
communication_thread_id: cleanText(communication_thread_id) || cleanText(communicationThreadId) || cleanText(threadId),
|
|
570
|
+
sender_agent_session_id: cleanText(sender_agent_session_id) || cleanText(senderAgentSessionId),
|
|
571
|
+
recipient_agent_session_id: cleanText(recipient_agent_session_id) || cleanText(recipientAgentSessionId),
|
|
572
|
+
recipient_role_key: cleanText(recipient_role_key) || cleanText(recipientRoleKey),
|
|
573
|
+
message_kind: cleanText(message_kind) || cleanText(messageKind),
|
|
574
|
+
message_status: cleanText(message_status) || cleanText(messageStatus) || 'sent',
|
|
575
|
+
body_markdown: cleanText(body_markdown) || cleanText(bodyMarkdown),
|
|
576
|
+
payload: isPlainObject(payload) ? payload : {},
|
|
577
|
+
scope: isPlainObject(scope) ? scope : {},
|
|
578
|
+
required_response_schema: isPlainObject(requiredResponseSchema)
|
|
579
|
+
? requiredResponseSchema
|
|
580
|
+
: (isPlainObject(required_response_schema) ? required_response_schema : {}),
|
|
581
|
+
metadata: isPlainObject(metadata) ? metadata : {},
|
|
582
|
+
},
|
|
583
|
+
});
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
async acceptCommunicationMessage(messageId) {
|
|
587
|
+
return this._request(`/api/agent-communications/messages/${encodeURIComponent(messageId)}/accept`, {
|
|
588
|
+
method: 'POST',
|
|
589
|
+
body: {},
|
|
590
|
+
});
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
async respondToCommunicationMessage({
|
|
594
|
+
agentMessageId,
|
|
595
|
+
agent_message_id,
|
|
596
|
+
messageId,
|
|
597
|
+
status,
|
|
598
|
+
bodyMarkdown,
|
|
599
|
+
body_markdown,
|
|
600
|
+
payload = {},
|
|
601
|
+
metadata = {},
|
|
602
|
+
evidenceRefs,
|
|
603
|
+
evidence_refs,
|
|
604
|
+
} = {}) {
|
|
605
|
+
const normalizedMessageId = cleanText(agent_message_id) || cleanText(agentMessageId) || cleanText(messageId);
|
|
606
|
+
if (!normalizedMessageId) {
|
|
607
|
+
throw new Error('agent_message_id is required.');
|
|
608
|
+
}
|
|
609
|
+
return this._request(`/api/agent-communications/messages/${encodeURIComponent(normalizedMessageId)}/respond`, {
|
|
610
|
+
method: 'POST',
|
|
611
|
+
body: {
|
|
612
|
+
status: cleanText(status) || 'answered',
|
|
613
|
+
body_markdown: cleanText(body_markdown) || cleanText(bodyMarkdown),
|
|
614
|
+
payload: isPlainObject(payload) ? payload : {},
|
|
615
|
+
metadata: isPlainObject(metadata) ? metadata : {},
|
|
616
|
+
evidence_refs: Array.isArray(evidence_refs) ? evidence_refs : (Array.isArray(evidenceRefs) ? evidenceRefs : []),
|
|
617
|
+
},
|
|
618
|
+
});
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
async attachCommunicationMessageEvidence({
|
|
622
|
+
agentMessageId,
|
|
623
|
+
agent_message_id,
|
|
624
|
+
messageId,
|
|
625
|
+
evidenceType,
|
|
626
|
+
evidence_type,
|
|
627
|
+
evidenceRef,
|
|
628
|
+
evidence_ref,
|
|
629
|
+
sourceTruth,
|
|
630
|
+
source_truth,
|
|
631
|
+
trustLevel,
|
|
632
|
+
trust_level,
|
|
633
|
+
metadata = {},
|
|
634
|
+
} = {}) {
|
|
635
|
+
const normalizedMessageId = cleanText(agent_message_id) || cleanText(agentMessageId) || cleanText(messageId);
|
|
636
|
+
if (!normalizedMessageId) {
|
|
637
|
+
throw new Error('agent_message_id is required.');
|
|
638
|
+
}
|
|
639
|
+
return this._request(`/api/agent-communications/messages/${encodeURIComponent(normalizedMessageId)}/attach-evidence`, {
|
|
640
|
+
method: 'POST',
|
|
641
|
+
body: {
|
|
642
|
+
evidence_type: cleanText(evidence_type) || cleanText(evidenceType),
|
|
643
|
+
evidence_ref: cleanText(evidence_ref) || cleanText(evidenceRef),
|
|
644
|
+
source_truth: cleanText(source_truth) || cleanText(sourceTruth),
|
|
645
|
+
trust_level: cleanText(trust_level) || cleanText(trustLevel) || 'candidate',
|
|
646
|
+
metadata: isPlainObject(metadata) ? metadata : {},
|
|
647
|
+
},
|
|
648
|
+
});
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
async createCommunicationHandoff({
|
|
652
|
+
workflowRunId,
|
|
653
|
+
workflow_run_id,
|
|
654
|
+
title,
|
|
655
|
+
agentSessionId,
|
|
656
|
+
agent_session_id,
|
|
657
|
+
handoffKind,
|
|
658
|
+
handoff_kind,
|
|
659
|
+
handoffPriority,
|
|
660
|
+
handoff_priority,
|
|
661
|
+
summaryText,
|
|
662
|
+
summary_text,
|
|
663
|
+
handoffPayload = {},
|
|
664
|
+
handoff_payload = {},
|
|
665
|
+
createdBy,
|
|
666
|
+
created_by,
|
|
667
|
+
supersedesHandoffId,
|
|
668
|
+
supersedes_handoff_id,
|
|
669
|
+
} = {}) {
|
|
670
|
+
return this._request('/api/agent-communications/handoffs', {
|
|
671
|
+
method: 'POST',
|
|
672
|
+
body: {
|
|
673
|
+
workflow_run_id: cleanText(workflow_run_id) || cleanText(workflowRunId),
|
|
674
|
+
title: cleanText(title),
|
|
675
|
+
agent_session_id: cleanText(agent_session_id) || cleanText(agentSessionId),
|
|
676
|
+
handoff_kind: cleanText(handoff_kind) || cleanText(handoffKind) || 'general',
|
|
677
|
+
handoff_priority: cleanText(handoff_priority) || cleanText(handoffPriority) || 'normal',
|
|
678
|
+
summary_text: cleanText(summary_text) || cleanText(summaryText),
|
|
679
|
+
handoff_payload: isPlainObject(handoffPayload)
|
|
680
|
+
? handoffPayload
|
|
681
|
+
: (isPlainObject(handoff_payload) ? handoff_payload : {}),
|
|
682
|
+
created_by: cleanText(created_by) || cleanText(createdBy),
|
|
683
|
+
supersedes_handoff_id: cleanText(supersedes_handoff_id) || cleanText(supersedesHandoffId),
|
|
684
|
+
},
|
|
685
|
+
});
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
async acceptCommunicationHandoff(handoffId) {
|
|
689
|
+
return this._request(`/api/agent-communications/handoffs/${encodeURIComponent(handoffId)}/accept`, {
|
|
690
|
+
method: 'POST',
|
|
691
|
+
body: {},
|
|
692
|
+
});
|
|
693
|
+
}
|
|
694
|
+
|
|
485
695
|
async currentProjectStatus({ projectId } = {}) {
|
|
486
696
|
return this._request('/api/operator/current-project-status', {
|
|
487
697
|
query: { project_id: projectId },
|
|
@@ -1587,23 +1797,26 @@ export class AIEngineClient {
|
|
|
1587
1797
|
}
|
|
1588
1798
|
}
|
|
1589
1799
|
|
|
1590
|
-
if (!resolvedWorkflowId) {
|
|
1800
|
+
if (resolvedRuns.length > 0 && !resolvedWorkflowId) {
|
|
1591
1801
|
throw new Error('workflowId could not be resolved for project cleanup.');
|
|
1592
1802
|
}
|
|
1593
|
-
|
|
1594
|
-
|
|
1803
|
+
|
|
1804
|
+
const cleanupPayload = {
|
|
1805
|
+
project_id: normalizedProjectId,
|
|
1806
|
+
reason: normalizedReason,
|
|
1807
|
+
operator_identity: normalizedOperatorIdentity,
|
|
1808
|
+
run_terminal_status: cleanText(runTerminalStatus) || 'failed',
|
|
1809
|
+
};
|
|
1810
|
+
if (resolvedWorkflowId) {
|
|
1811
|
+
cleanupPayload.workflow_id = resolvedWorkflowId;
|
|
1812
|
+
}
|
|
1813
|
+
if (resolvedRuns.length > 0) {
|
|
1814
|
+
cleanupPayload.workflow_run_ids = resolvedRuns;
|
|
1595
1815
|
}
|
|
1596
1816
|
|
|
1597
1817
|
return this._request('/api/operator/cleanup', {
|
|
1598
1818
|
method: 'POST',
|
|
1599
|
-
body:
|
|
1600
|
-
project_id: normalizedProjectId,
|
|
1601
|
-
workflow_id: resolvedWorkflowId,
|
|
1602
|
-
workflow_run_ids: resolvedRuns,
|
|
1603
|
-
reason: normalizedReason,
|
|
1604
|
-
operator_identity: normalizedOperatorIdentity,
|
|
1605
|
-
run_terminal_status: cleanText(runTerminalStatus) || 'failed',
|
|
1606
|
-
},
|
|
1819
|
+
body: cleanupPayload,
|
|
1607
1820
|
});
|
|
1608
1821
|
}
|
|
1609
1822
|
|