@bpmsoftwaresolutions/ai-engine-client 1.1.45 → 1.1.47

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 +482 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bpmsoftwaresolutions/ai-engine-client",
3
- "version": "1.1.45",
3
+ "version": "1.1.47",
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.45';
2
+ export const AI_ENGINE_CLIENT_VERSION = '1.1.47';
3
3
  export const GOVERNED_MUTATION_REQUIRED_CAPABILITIES = [
4
4
  'executeVerifiedMutation',
5
5
  'post_mutation_verification',
@@ -20,6 +20,99 @@ export const LOGA_INTERACTION_CONTRACT = 'loga-choreography/v1';
20
20
  export const LOGA_NAVIGATION_CONTRACT = 'loga-navigation/v1';
21
21
  export const LOGA_PROJECTION_WORKFLOW = 'loga-document-projection';
22
22
  export const TASK_BOUND_SUBSTRATE_EXECUTION_POLICY = 'task_bound_substrate_execution/v1';
23
+ export const AGENT_COMMUNICATION_CONTRACT_VERSION = 'v1';
24
+ export const AGENT_COMMUNICATION_THREAD_TYPES = ['request', 'review', 'handoff', 'coordination', 'task', 'escalation'];
25
+ export const AGENT_COMMUNICATION_MESSAGE_KINDS = [
26
+ 'request',
27
+ 'response',
28
+ 'review',
29
+ 'handoff',
30
+ 'blocker',
31
+ 'evidence',
32
+ 'decision_request',
33
+ 'task_request',
34
+ 'review_request',
35
+ 'evidence_response',
36
+ ];
37
+ export const AGENT_COMMUNICATION_TRANSFER_KINDS = [
38
+ 'upstream_remediation',
39
+ 'review_request',
40
+ 'handoff',
41
+ 'coordination',
42
+ 'evidence_delivery',
43
+ ];
44
+ export const AGENT_COMMUNICATION_TRANSFER_MODES = ['bundle', 'artifact_refs', 'inline_payload'];
45
+ export const AGENT_COMMUNICATION_TRANSFER_LIFECYCLE_STATES = [
46
+ 'created',
47
+ 'delivered',
48
+ 'accepted',
49
+ 'in_progress',
50
+ 'responded',
51
+ 'closed',
52
+ 'failed',
53
+ 'superseded',
54
+ ];
55
+ export const AGENT_COMMUNICATION_TRANSFER_RECEIPT_TYPES = [
56
+ 'delivery_receipt',
57
+ 'acceptance_receipt',
58
+ 'evidence_receipt',
59
+ 'closure_receipt',
60
+ 'failure_receipt',
61
+ ];
62
+ export const AGENT_COMMUNICATION_RECIPIENT_MODES = ['role', 'agent_session'];
63
+
64
+ function normalizeEnum(value, allowed, defaultValue, fieldName, aliases = {}) {
65
+ const text = cleanText(value);
66
+ if (!text) return defaultValue;
67
+ let normalized = text.toLowerCase();
68
+ if (Object.prototype.hasOwnProperty.call(aliases, normalized)) {
69
+ normalized = aliases[normalized];
70
+ }
71
+ if (!allowed.includes(normalized)) {
72
+ throw new Error(`${fieldName} must be one of ${allowed.join(', ')}.`);
73
+ }
74
+ return normalized;
75
+ }
76
+
77
+ function normalizeThreadType(value) {
78
+ return normalizeEnum(value, AGENT_COMMUNICATION_THREAD_TYPES, 'coordination', 'thread_type', {
79
+ task_request: 'request',
80
+ task: 'request',
81
+ review_request: 'review',
82
+ handoff_request: 'handoff',
83
+ });
84
+ }
85
+
86
+ function normalizeMessageKind(value) {
87
+ return normalizeEnum(value, AGENT_COMMUNICATION_MESSAGE_KINDS, 'request', 'message_kind', {
88
+ task: 'request',
89
+ note: 'request',
90
+ update: 'response',
91
+ });
92
+ }
93
+
94
+ function normalizeTransferKind(value) {
95
+ return normalizeEnum(value, AGENT_COMMUNICATION_TRANSFER_KINDS, 'upstream_remediation', 'transfer_kind', {
96
+ remediation_request: 'upstream_remediation',
97
+ review: 'review_request',
98
+ });
99
+ }
100
+
101
+ function normalizeTransferMode(value) {
102
+ return normalizeEnum(value, AGENT_COMMUNICATION_TRANSFER_MODES, 'inline_payload', 'transfer_mode');
103
+ }
104
+
105
+ function normalizeTransferLifecycleStatus(value) {
106
+ return normalizeEnum(value, AGENT_COMMUNICATION_TRANSFER_LIFECYCLE_STATES, 'created', 'lifecycle_status');
107
+ }
108
+
109
+ function normalizeTransferReceiptType(value) {
110
+ return normalizeEnum(value, AGENT_COMMUNICATION_TRANSFER_RECEIPT_TYPES, 'delivery_receipt', 'receipt_type');
111
+ }
112
+
113
+ function normalizeRecipientMode(value) {
114
+ return normalizeEnum(value, AGENT_COMMUNICATION_RECIPIENT_MODES, 'role', 'recipient_mode');
115
+ }
23
116
 
24
117
  function trimTrailingSlash(value) {
25
118
  return String(value || '').replace(/\/+$/, '');
@@ -310,6 +403,19 @@ export class AIEngineClient {
310
403
  getThread: (threadId) => this.getCommunicationThread(threadId),
311
404
  listInbox: (request) => this.listCommunicationInbox(request),
312
405
  sendMessage: (request) => this.sendCommunicationMessage(request),
406
+ getCommunicationCapabilities: (request) => this.getCommunicationCapabilities(request),
407
+ getDeploymentCapabilities: (request) => this.getDeploymentCapabilities(request),
408
+ bootstrap: (request) => this.bootstrapCommunication(request),
409
+ negotiateTransfer: (request) => this.negotiateCommunicationTransfer(request),
410
+ resolveCommunicationTarget: (request) => this.resolveCommunicationTarget(request),
411
+ createEvidencePacket: (request) => this.createCommunicationEvidencePacket(request),
412
+ transferWorkPacket: (request) => this.transferWorkPacket(request),
413
+ listFrictionTaxonomy: (request) => this.listCommunicationFrictionTaxonomy(request),
414
+ recordFrictionEvent: (request) => this.recordCommunicationFrictionEvent(request),
415
+ createTransferReceipt: (request) => this.recordCommunicationTransferReceipt(request),
416
+ acceptTransferPacket: (request) => this.acceptCommunicationTransferPacket(request),
417
+ closeTransferPacket: (request) => this.closeCommunicationTransferPacket(request),
418
+ getTransferHealth: (request) => this.getCommunicationTransferHealth(request),
313
419
  createBundle: (request) => this.createCommunicationBundle(request),
314
420
  getBundle: (bundleId) => this.getCommunicationBundle(bundleId),
315
421
  listBundles: (request) => this.listCommunicationBundles(request),
@@ -502,6 +608,250 @@ export class AIEngineClient {
502
608
  });
503
609
  }
504
610
 
611
+ async getCommunicationCapabilities() {
612
+ return this._request('/api/agent-communications/capabilities');
613
+ }
614
+
615
+ async getDeploymentCapabilities() {
616
+ return this._request('/api/agent-communications/deployment-capabilities');
617
+ }
618
+
619
+ async bootstrapCommunication() {
620
+ return this._request('/api/agent-communications/bootstrap');
621
+ }
622
+
623
+ async negotiateCommunicationTransfer({
624
+ preferredModes,
625
+ preferred_modes,
626
+ preferred,
627
+ capabilities = {},
628
+ estimatedPayloadKb,
629
+ estimated_payload_kb,
630
+ requiresReceipts = true,
631
+ requires_receipts = true,
632
+ supportsHashValidation = true,
633
+ supports_hash_validation = true,
634
+ transferKind,
635
+ transfer_kind,
636
+ workflowRunId,
637
+ workflow_run_id,
638
+ } = {}) {
639
+ const normalizedPreferredModes = Array.isArray(preferred_modes)
640
+ ? preferred_modes
641
+ : (Array.isArray(preferredModes) ? preferredModes : (Array.isArray(preferred) ? preferred : ['bundle', 'artifact_refs', 'inline_payload']));
642
+ return this._request('/api/agent-communications/transfers/negotiate', {
643
+ method: 'POST',
644
+ body: {
645
+ preferred_modes: normalizedPreferredModes.map((mode) => normalizeTransferMode(mode)),
646
+ capabilities: isPlainObject(capabilities) ? capabilities : {},
647
+ estimated_payload_kb: Number(estimated_payload_kb ?? estimatedPayloadKb ?? 0) || undefined,
648
+ requires_receipts: Boolean(requires_receipts ?? requiresReceipts),
649
+ supports_hash_validation: Boolean(supports_hash_validation ?? supportsHashValidation),
650
+ transfer_kind: normalizeTransferKind(transfer_kind ?? transferKind ?? 'upstream_remediation'),
651
+ workflow_run_id: cleanText(workflow_run_id) || cleanText(workflowRunId),
652
+ },
653
+ });
654
+ }
655
+
656
+ async resolveCommunicationTarget({
657
+ intent,
658
+ transferKind,
659
+ transfer_kind,
660
+ recipientMode,
661
+ recipient_mode,
662
+ preferredRoleKey,
663
+ preferred_role_key,
664
+ preferredAgentSessionId,
665
+ preferred_agent_session_id,
666
+ workflowRunId,
667
+ workflow_run_id,
668
+ } = {}) {
669
+ return this._request('/api/agent-communications/targets/resolve', {
670
+ method: 'POST',
671
+ body: {
672
+ intent: cleanText(intent) || cleanText(transfer_kind) || cleanText(transferKind),
673
+ recipient_mode: normalizeRecipientMode(recipient_mode ?? recipientMode ?? 'role'),
674
+ preferred_role_key: cleanText(preferred_role_key) || cleanText(preferredRoleKey),
675
+ preferred_agent_session_id: cleanText(preferred_agent_session_id) || cleanText(preferredAgentSessionId),
676
+ workflow_run_id: cleanText(workflow_run_id) || cleanText(workflowRunId),
677
+ },
678
+ });
679
+ }
680
+
681
+ async createCommunicationEvidencePacket({
682
+ workflowRunId,
683
+ workflow_run_id,
684
+ transferKind,
685
+ transfer_kind,
686
+ objective,
687
+ requestedOutcome,
688
+ requested_outcome,
689
+ artifacts = [],
690
+ artifactRefs,
691
+ artifact_refs,
692
+ issues = [],
693
+ issueRefs,
694
+ issue_refs,
695
+ expectedEvidence = [],
696
+ expected_evidence,
697
+ metadata = {},
698
+ } = {}) {
699
+ return this._request('/api/agent-communications/evidence-packets', {
700
+ method: 'POST',
701
+ body: {
702
+ workflow_run_id: cleanText(workflow_run_id) || cleanText(workflowRunId),
703
+ transfer_kind: normalizeTransferKind(transfer_kind ?? transferKind ?? 'upstream_remediation'),
704
+ objective: cleanText(objective),
705
+ requested_outcome: cleanText(requested_outcome) || cleanText(requestedOutcome),
706
+ artifacts: Array.isArray(artifacts) ? artifacts : (Array.isArray(artifact_refs) ? artifact_refs : (Array.isArray(artifactRefs) ? artifactRefs : [])),
707
+ issues: Array.isArray(issues) ? issues : (Array.isArray(issue_refs) ? issue_refs : (Array.isArray(issueRefs) ? issueRefs : [])),
708
+ expected_evidence: Array.isArray(expected_evidence) ? expected_evidence : (Array.isArray(expectedEvidence) ? expectedEvidence : []),
709
+ metadata: isPlainObject(metadata) ? metadata : {},
710
+ },
711
+ });
712
+ }
713
+
714
+ async listCommunicationFrictionTaxonomy({
715
+ categoryGroup,
716
+ category_group,
717
+ isActive,
718
+ is_active,
719
+ } = {}) {
720
+ return this._request('/api/agent-communications/friction-taxonomy', {
721
+ query: {
722
+ category_group: cleanText(category_group) || cleanText(categoryGroup),
723
+ is_active: is_active !== undefined ? String(Boolean(is_active)) : (isActive !== undefined ? String(Boolean(isActive)) : undefined),
724
+ },
725
+ });
726
+ }
727
+
728
+ async recordCommunicationFrictionEvent({
729
+ workflowRunId,
730
+ workflow_run_id,
731
+ workTransferPacketId,
732
+ work_transfer_packet_id,
733
+ communicationThreadId,
734
+ communication_thread_id,
735
+ communicationMessageId,
736
+ communication_message_id,
737
+ taxonomyKey,
738
+ taxonomy_key,
739
+ frictionType,
740
+ friction_type,
741
+ severity,
742
+ observedBehavior,
743
+ observed_behavior,
744
+ attemptedAction,
745
+ attempted_action,
746
+ resolutionPath,
747
+ resolution_path,
748
+ missingSurfaceKey,
749
+ missing_surface_key,
750
+ promotionCandidate,
751
+ promotion_candidate,
752
+ repeatedCount,
753
+ repeated_count,
754
+ metadata = {},
755
+ } = {}) {
756
+ return this._request('/api/agent-communications/friction-events', {
757
+ method: 'POST',
758
+ body: {
759
+ workflow_run_id: cleanText(workflow_run_id) || cleanText(workflowRunId),
760
+ work_transfer_packet_id: cleanText(work_transfer_packet_id) || cleanText(workTransferPacketId),
761
+ communication_thread_id: cleanText(communication_thread_id) || cleanText(communicationThreadId),
762
+ communication_message_id: cleanText(communication_message_id) || cleanText(communicationMessageId),
763
+ taxonomy_key: cleanText(taxonomy_key) || cleanText(taxonomyKey) || 'enum_drift',
764
+ friction_type: cleanText(friction_type) || cleanText(frictionType) || 'discovery',
765
+ severity: cleanText(severity) || 'warning',
766
+ observed_behavior: cleanText(observed_behavior) || cleanText(observedBehavior),
767
+ attempted_action: cleanText(attempted_action) || cleanText(attemptedAction),
768
+ resolution_path: cleanText(resolution_path) || cleanText(resolutionPath),
769
+ missing_surface_key: cleanText(missing_surface_key) || cleanText(missingSurfaceKey),
770
+ promotion_candidate: Boolean(promotion_candidate ?? promotionCandidate),
771
+ repeated_count: Number(repeated_count ?? repeatedCount ?? 1) || 1,
772
+ metadata: isPlainObject(metadata) ? metadata : {},
773
+ },
774
+ });
775
+ }
776
+
777
+ async transferWorkPacket({
778
+ workflowRunId,
779
+ workflow_run_id,
780
+ transferKind,
781
+ transfer_kind,
782
+ objective,
783
+ requestedOutcome,
784
+ requested_outcome,
785
+ target = {},
786
+ artifacts = [],
787
+ issues = [],
788
+ expectedEvidence = [],
789
+ preferredModes,
790
+ preferred_modes,
791
+ preferred,
792
+ capabilities = {},
793
+ estimatedPayloadKb,
794
+ estimated_payload_kb,
795
+ requiresReceipts = true,
796
+ requires_receipts = true,
797
+ supportsHashValidation = true,
798
+ supports_hash_validation = true,
799
+ senderAgentSessionId,
800
+ sender_agent_session_id,
801
+ senderActorSessionId,
802
+ sender_actor_session_id,
803
+ subject,
804
+ bodyMarkdown,
805
+ body_markdown,
806
+ parentThreadId,
807
+ parent_thread_id,
808
+ recipientMode,
809
+ recipient_mode,
810
+ recipientRoleKey,
811
+ recipient_role_key,
812
+ recipientAgentSessionId,
813
+ recipient_agent_session_id,
814
+ cleanupPolicy,
815
+ cleanup_policy,
816
+ } = {}) {
817
+ const normalizedTarget = isPlainObject(target) ? target : {};
818
+ const normalizedWorkflowRunId = cleanText(workflow_run_id) || cleanText(workflowRunId);
819
+ const normalizedTransferKind = normalizeTransferKind(transfer_kind ?? transferKind ?? 'upstream_remediation');
820
+ const normalizedPreferredModes = Array.isArray(preferred_modes)
821
+ ? preferred_modes
822
+ : (Array.isArray(preferredModes) ? preferredModes : (Array.isArray(preferred) ? preferred : ['bundle', 'artifact_refs', 'inline_payload']));
823
+ const normalizedTargetMode = cleanText(normalizedTarget.recipient_mode) || cleanText(normalizedTarget.recipientMode) || cleanText(recipient_mode) || cleanText(recipientMode) || 'role';
824
+ return this._request('/api/agent-communications/work-transfers', {
825
+ method: 'POST',
826
+ body: {
827
+ workflow_run_id: normalizedWorkflowRunId,
828
+ transfer_kind: normalizedTransferKind,
829
+ objective: cleanText(objective),
830
+ requested_outcome: cleanText(requested_outcome) || cleanText(requestedOutcome),
831
+ target: {
832
+ intent: cleanText(normalizedTarget.intent) || normalizedTransferKind,
833
+ recipient_mode: normalizeRecipientMode(normalizedTargetMode),
834
+ preferred_role_key: cleanText(normalizedTarget.preferred_role_key) || cleanText(normalizedTarget.preferredRoleKey) || cleanText(recipient_role_key) || cleanText(recipientRoleKey),
835
+ preferred_agent_session_id: cleanText(normalizedTarget.preferred_agent_session_id) || cleanText(normalizedTarget.preferredAgentSessionId) || cleanText(recipient_agent_session_id) || cleanText(recipientAgentSessionId),
836
+ },
837
+ artifacts: Array.isArray(artifacts) ? artifacts : [],
838
+ issues: Array.isArray(issues) ? issues : [],
839
+ expected_evidence: Array.isArray(expectedEvidence) ? expectedEvidence : [],
840
+ preferred_modes: normalizedPreferredModes.map((mode) => normalizeTransferMode(mode)),
841
+ capabilities: isPlainObject(capabilities) ? capabilities : {},
842
+ estimated_payload_kb: Number(estimated_payload_kb ?? estimatedPayloadKb ?? 0) || undefined,
843
+ requires_receipts: Boolean(requires_receipts ?? requiresReceipts),
844
+ supports_hash_validation: Boolean(supports_hash_validation ?? supportsHashValidation),
845
+ sender_agent_session_id: cleanText(sender_agent_session_id) || cleanText(senderAgentSessionId),
846
+ sender_actor_session_id: cleanText(sender_actor_session_id) || cleanText(senderActorSessionId),
847
+ subject: cleanText(subject),
848
+ body_markdown: cleanText(body_markdown) || cleanText(bodyMarkdown),
849
+ parent_thread_id: cleanText(parent_thread_id) || cleanText(parentThreadId),
850
+ cleanup_policy: cleanText(cleanup_policy) || cleanText(cleanupPolicy),
851
+ },
852
+ });
853
+ }
854
+
505
855
  async openCommunicationThread({
506
856
  workflowRunId,
507
857
  workflow_run_id,
@@ -522,7 +872,7 @@ export class AIEngineClient {
522
872
  body: {
523
873
  workflow_run_id: cleanText(workflow_run_id) || cleanText(workflowRunId),
524
874
  parent_thread_id: cleanText(parent_thread_id) || cleanText(parentThreadId),
525
- thread_type: cleanText(thread_type) || cleanText(threadType),
875
+ thread_type: normalizeThreadType(cleanText(thread_type) || cleanText(threadType)),
526
876
  subject: cleanText(subject),
527
877
  objective: cleanText(objective),
528
878
  created_by_agent_session_id: cleanText(created_by_agent_session_id) || cleanText(createdByAgentSessionId),
@@ -585,7 +935,7 @@ export class AIEngineClient {
585
935
  sender_agent_session_id: cleanText(sender_agent_session_id) || cleanText(senderAgentSessionId),
586
936
  recipient_agent_session_id: cleanText(recipient_agent_session_id) || cleanText(recipientAgentSessionId),
587
937
  recipient_role_key: cleanText(recipient_role_key) || cleanText(recipientRoleKey),
588
- message_kind: cleanText(message_kind) || cleanText(messageKind),
938
+ message_kind: normalizeMessageKind(cleanText(message_kind) || cleanText(messageKind)),
589
939
  message_status: cleanText(message_status) || cleanText(messageStatus) || 'sent',
590
940
  body_markdown: cleanText(body_markdown) || cleanText(bodyMarkdown),
591
941
  payload: isPlainObject(payload) ? payload : {},
@@ -836,6 +1186,135 @@ export class AIEngineClient {
836
1186
  });
837
1187
  }
838
1188
 
1189
+ async recordCommunicationTransferReceipt({
1190
+ workTransferPacketId,
1191
+ work_transfer_packet_id,
1192
+ receiptType,
1193
+ receipt_type,
1194
+ receiptStatus,
1195
+ receipt_status,
1196
+ actorSessionId,
1197
+ actor_session_id,
1198
+ agentSessionId,
1199
+ agent_session_id,
1200
+ claimId,
1201
+ claim_id,
1202
+ evidenceRef,
1203
+ evidence_ref,
1204
+ evidenceSha256,
1205
+ evidence_sha256,
1206
+ evidence = {},
1207
+ manifestSha256,
1208
+ manifest_sha256,
1209
+ closureReason,
1210
+ closure_reason,
1211
+ failureReason,
1212
+ failure_reason,
1213
+ lifecycleStatus,
1214
+ lifecycle_status,
1215
+ metadata = {},
1216
+ } = {}) {
1217
+ const normalizedPacketId = cleanText(work_transfer_packet_id) || cleanText(workTransferPacketId);
1218
+ if (!normalizedPacketId) throw new Error('work_transfer_packet_id is required.');
1219
+ return this._request(`/api/agent-communications/transfers/${encodeURIComponent(normalizedPacketId)}/receipts`, {
1220
+ method: 'POST',
1221
+ body: {
1222
+ receipt_type: normalizeTransferReceiptType(cleanText(receipt_type) || cleanText(receiptType) || 'delivery_receipt'),
1223
+ receipt_status: cleanText(receipt_status) || cleanText(receiptStatus) || 'recorded',
1224
+ actor_session_id: cleanText(actor_session_id) || cleanText(actorSessionId),
1225
+ agent_session_id: cleanText(agent_session_id) || cleanText(agentSessionId),
1226
+ claim_id: cleanText(claim_id) || cleanText(claimId),
1227
+ evidence_ref: cleanText(evidence_ref) || cleanText(evidenceRef),
1228
+ evidence_sha256: cleanText(evidence_sha256) || cleanText(evidenceSha256),
1229
+ evidence: isPlainObject(evidence) ? evidence : {},
1230
+ manifest_sha256: cleanText(manifest_sha256) || cleanText(manifestSha256),
1231
+ closure_reason: cleanText(closure_reason) || cleanText(closureReason),
1232
+ failure_reason: cleanText(failure_reason) || cleanText(failureReason),
1233
+ lifecycle_status: cleanText(lifecycle_status) || cleanText(lifecycleStatus),
1234
+ metadata: isPlainObject(metadata) ? metadata : {},
1235
+ },
1236
+ });
1237
+ }
1238
+
1239
+ async acceptCommunicationTransferPacket({
1240
+ workTransferPacketId,
1241
+ work_transfer_packet_id,
1242
+ acceptedByAgentSessionId,
1243
+ accepted_by_agent_session_id,
1244
+ acceptedByActorSessionId,
1245
+ accepted_by_actor_session_id,
1246
+ acceptedByClaimId,
1247
+ accepted_by_claim_id,
1248
+ advanceToInProgress,
1249
+ advance_to_in_progress,
1250
+ metadata = {},
1251
+ } = {}) {
1252
+ const normalizedPacketId = cleanText(work_transfer_packet_id) || cleanText(workTransferPacketId);
1253
+ if (!normalizedPacketId) throw new Error('work_transfer_packet_id is required.');
1254
+ return this._request(`/api/agent-communications/transfers/${encodeURIComponent(normalizedPacketId)}/accept`, {
1255
+ method: 'POST',
1256
+ body: {
1257
+ accepted_by_agent_session_id: cleanText(accepted_by_agent_session_id) || cleanText(acceptedByAgentSessionId),
1258
+ accepted_by_actor_session_id: cleanText(accepted_by_actor_session_id) || cleanText(acceptedByActorSessionId),
1259
+ accepted_by_claim_id: cleanText(accepted_by_claim_id) || cleanText(acceptedByClaimId),
1260
+ advance_to_in_progress: Boolean(advance_to_in_progress ?? advanceToInProgress),
1261
+ metadata: isPlainObject(metadata) ? metadata : {},
1262
+ },
1263
+ });
1264
+ }
1265
+
1266
+ async closeCommunicationTransferPacket({
1267
+ workTransferPacketId,
1268
+ work_transfer_packet_id,
1269
+ closureStatus,
1270
+ closure_status,
1271
+ closureReason,
1272
+ closure_reason,
1273
+ failureReason,
1274
+ failure_reason,
1275
+ closedByAgentSessionId,
1276
+ closed_by_agent_session_id,
1277
+ closedByActorSessionId,
1278
+ closed_by_actor_session_id,
1279
+ closedByClaimId,
1280
+ closed_by_claim_id,
1281
+ evidence = {},
1282
+ evidenceManifestSha256,
1283
+ evidence_manifest_sha256,
1284
+ metadata = {},
1285
+ } = {}) {
1286
+ const normalizedPacketId = cleanText(work_transfer_packet_id) || cleanText(workTransferPacketId);
1287
+ if (!normalizedPacketId) throw new Error('work_transfer_packet_id is required.');
1288
+ return this._request(`/api/agent-communications/transfers/${encodeURIComponent(normalizedPacketId)}/close`, {
1289
+ method: 'POST',
1290
+ body: {
1291
+ closure_status: normalizeTransferLifecycleStatus(cleanText(closure_status) || cleanText(closureStatus) || 'closed'),
1292
+ closure_reason: cleanText(closure_reason) || cleanText(closureReason),
1293
+ failure_reason: cleanText(failure_reason) || cleanText(failureReason),
1294
+ closed_by_agent_session_id: cleanText(closed_by_agent_session_id) || cleanText(closedByAgentSessionId),
1295
+ closed_by_actor_session_id: cleanText(closed_by_actor_session_id) || cleanText(closedByActorSessionId),
1296
+ closed_by_claim_id: cleanText(closed_by_claim_id) || cleanText(closedByClaimId),
1297
+ evidence: isPlainObject(evidence) ? evidence : {},
1298
+ evidence_manifest_sha256: cleanText(evidence_manifest_sha256) || cleanText(evidenceManifestSha256),
1299
+ metadata: isPlainObject(metadata) ? metadata : {},
1300
+ },
1301
+ });
1302
+ }
1303
+
1304
+ async getCommunicationTransferHealth({
1305
+ workflowRunId,
1306
+ workflow_run_id,
1307
+ workTransferPacketId,
1308
+ work_transfer_packet_id,
1309
+ } = {}) {
1310
+ return this._request('/api/agent-communications/transfers/health', {
1311
+ query: {
1312
+ workflow_run_id: cleanText(workflow_run_id) || cleanText(workflowRunId),
1313
+ work_transfer_packet_id: cleanText(work_transfer_packet_id) || cleanText(workTransferPacketId),
1314
+ },
1315
+ });
1316
+ }
1317
+
839
1318
  async acceptCommunicationMessage(messageId) {
840
1319
  return this._request(`/api/agent-communications/messages/${encodeURIComponent(messageId)}/accept`, {
841
1320
  method: 'POST',