@bpmsoftwaresolutions/ai-engine-client 1.1.85 → 1.1.87

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.
@@ -1,7 +1,43 @@
1
1
  export function createRetrievalWrapperDomain(client) {
2
2
  return {
3
- getCommandCard: (request) => client.getCommandCard(request),
4
- getSymbolDefinition: (request) => client.getSymbolDefinition(request),
5
- getRelatedCode: (request) => client.getRelatedCode(request),
3
+ getCommandCard({ commandKey, alias, intentText, requestedBy } = {}) {
4
+ return client._request('/api/operator/retrieval/wrapper/command-card', {
5
+ query: { command_key: commandKey, alias, intent_text: intentText, requested_by: requestedBy },
6
+ });
7
+ },
8
+
9
+ resolveOperatingProcedure({ procedureKey, intentText, requestedBy } = {}) {
10
+ return client._request('/api/operator/retrieval/wrapper/operating-procedure', {
11
+ query: { procedure_key: procedureKey, intent_text: intentText, requested_by: requestedBy },
12
+ });
13
+ },
14
+
15
+ getSymbolDefinition({ symbolKey, qualifiedName, symbolName, projectScope, includeCode = true, maxLines = 120, requestedBy } = {}) {
16
+ return client._request('/api/operator/retrieval/wrapper/symbol-definition', {
17
+ query: {
18
+ symbol_key: symbolKey,
19
+ qualified_name: qualifiedName,
20
+ symbol_name: symbolName,
21
+ project_scope: projectScope,
22
+ include_code: includeCode,
23
+ max_lines: maxLines,
24
+ requested_by: requestedBy,
25
+ },
26
+ });
27
+ },
28
+
29
+ getRelatedCode({ symbolKey, qualifiedName, relationshipType, depth = 1, includeCode = false, maxLines = 80, requestedBy } = {}) {
30
+ return client._request('/api/operator/retrieval/wrapper/related-code', {
31
+ query: {
32
+ symbol_key: symbolKey,
33
+ qualified_name: qualifiedName,
34
+ relationship_type: relationshipType,
35
+ depth,
36
+ include_code: includeCode,
37
+ max_lines: maxLines,
38
+ requested_by: requestedBy,
39
+ },
40
+ });
41
+ },
6
42
  };
7
43
  }
@@ -0,0 +1,372 @@
1
+ import {
2
+ cleanText,
3
+ isPlainObject,
4
+ normalizeRecipientMode,
5
+ normalizeTransferKind,
6
+ normalizeTransferLifecycleStatus,
7
+ normalizeTransferMode,
8
+ normalizeTransferReceiptType,
9
+ } from '../utils/communication.js';
10
+
11
+ export function createTransferBundlesDomain(client) {
12
+ return {
13
+ transferWorkPacket: (request) => transferWorkPacket(client, request),
14
+ getTransferBundle: (bundleId) => getCommunicationBundle(client, bundleId),
15
+ listTransferBundles: (request) => listCommunicationBundles(client, request),
16
+ createTransferReceipt: (request) => recordCommunicationTransferReceipt(client, request),
17
+ listTransferReceipts: (request) => listTransferReceipts(client, request),
18
+ createCommunicationBundle: (request) => createCommunicationBundle(client, request),
19
+ getCommunicationBundle: (bundleId) => getCommunicationBundle(client, bundleId),
20
+ listCommunicationBundles: (request) => listCommunicationBundles(client, request),
21
+ addCommunicationBundleItem: (request) => addCommunicationBundleItem(client, request),
22
+ uploadCommunicationBundle: (request) => uploadCommunicationBundle(client, request),
23
+ attachCommunicationBundleToMessage: (request) => attachCommunicationBundleToMessage(client, request),
24
+ recordCommunicationBundleReceipt: (request) => recordCommunicationBundleReceipt(client, request),
25
+ recordCommunicationBundleCleanupEvent: (request) => recordCommunicationBundleCleanupEvent(client, request),
26
+ claimCommunicationBundle: (request) => claimCommunicationBundle(client, request),
27
+ recordCommunicationTransferReceipt: (request) => recordCommunicationTransferReceipt(client, request),
28
+ };
29
+ }
30
+
31
+ export async function transferWorkPacket(client, request = {}) {
32
+ const normalizedTarget = isPlainObject(request.target) ? request.target : {};
33
+ const normalizedWorkflowRunId = cleanText(request.workflow_run_id) || cleanText(request.workflowRunId);
34
+ const normalizedTransferKind = normalizeTransferKind(request.transfer_kind ?? request.transferKind ?? 'upstream_remediation');
35
+ const normalizedPreferredModes = Array.isArray(request.preferred_modes)
36
+ ? request.preferred_modes
37
+ : (Array.isArray(request.preferredModes) ? request.preferredModes : (Array.isArray(request.preferred) ? request.preferred : ['bundle', 'artifact_refs', 'inline_payload']));
38
+ const normalizedTargetMode = cleanText(normalizedTarget.recipient_mode) || cleanText(normalizedTarget.recipientMode) || cleanText(request.recipient_mode) || cleanText(request.recipientMode) || 'role';
39
+ return client._request('/api/agent-communications/work-transfers', {
40
+ method: 'POST',
41
+ body: {
42
+ workflow_run_id: normalizedWorkflowRunId,
43
+ transfer_kind: normalizedTransferKind,
44
+ objective: cleanText(request.objective),
45
+ requested_outcome: cleanText(request.requested_outcome) || cleanText(request.requestedOutcome),
46
+ target: {
47
+ intent: cleanText(normalizedTarget.intent) || normalizedTransferKind,
48
+ recipient_mode: normalizeRecipientMode(normalizedTargetMode),
49
+ preferred_role_key: cleanText(normalizedTarget.preferred_role_key) || cleanText(normalizedTarget.preferredRoleKey) || cleanText(request.recipient_role_key) || cleanText(request.recipientRoleKey),
50
+ preferred_agent_session_id: cleanText(normalizedTarget.preferred_agent_session_id) || cleanText(normalizedTarget.preferredAgentSessionId) || cleanText(request.recipient_agent_session_id) || cleanText(request.recipientAgentSessionId),
51
+ },
52
+ artifacts: Array.isArray(request.artifacts) ? request.artifacts : [],
53
+ issues: Array.isArray(request.issues) ? request.issues : [],
54
+ expected_evidence: Array.isArray(request.expectedEvidence) ? request.expectedEvidence : [],
55
+ preferred_modes: normalizedPreferredModes.map((mode) => normalizeTransferMode(mode)),
56
+ capabilities: isPlainObject(request.capabilities) ? request.capabilities : {},
57
+ estimated_payload_kb: Number(request.estimated_payload_kb ?? request.estimatedPayloadKb ?? 0) || undefined,
58
+ requires_receipts: Boolean(request.requires_receipts ?? request.requiresReceipts),
59
+ supports_hash_validation: Boolean(request.supports_hash_validation ?? request.supportsHashValidation),
60
+ sender_agent_session_id: cleanText(request.sender_agent_session_id) || cleanText(request.senderAgentSessionId) || client.agentSessionId,
61
+ sender_actor_session_id: cleanText(request.sender_actor_session_id) || cleanText(request.senderActorSessionId),
62
+ message_kind: cleanText(request.message_kind) || cleanText(request.messageKind),
63
+ subject: cleanText(request.subject),
64
+ body_markdown: cleanText(request.body_markdown) || cleanText(request.bodyMarkdown),
65
+ parent_thread_id: cleanText(request.parent_thread_id) || cleanText(request.parentThreadId),
66
+ cleanup_policy: cleanText(request.cleanup_policy) || cleanText(request.cleanupPolicy),
67
+ },
68
+ });
69
+ }
70
+
71
+ export async function listTransferReceipts(client, { workTransferPacketId, work_transfer_packet_id, workflowRunId, workflow_run_id } = {}) {
72
+ const normalizedPacketId = cleanText(work_transfer_packet_id) || cleanText(workTransferPacketId);
73
+ if (!normalizedPacketId) throw new Error('work_transfer_packet_id is required.');
74
+ return client._request(`/api/agent-communications/transfers/${encodeURIComponent(normalizedPacketId)}/receipts`, {
75
+ method: 'GET',
76
+ query: {
77
+ workflow_run_id: cleanText(workflow_run_id) || cleanText(workflowRunId),
78
+ },
79
+ });
80
+ }
81
+
82
+ export async function createTransferReceipt(client, request = {}) {
83
+ return recordCommunicationTransferReceipt(client, request);
84
+ }
85
+
86
+ export async function createCommunicationBundle(client, {
87
+ workflowRunId,
88
+ workflow_run_id,
89
+ communicationThreadId,
90
+ communication_thread_id,
91
+ threadId,
92
+ sourceAgentSessionId,
93
+ source_agent_session_id,
94
+ sourceActorSessionId,
95
+ source_actor_session_id,
96
+ recipientAgentSessionId,
97
+ recipient_agent_session_id,
98
+ recipientRoleKey,
99
+ recipient_role_key,
100
+ bundleKind,
101
+ bundle_kind,
102
+ cleanupPolicy,
103
+ cleanup_policy,
104
+ manifest = {},
105
+ manifestSha256,
106
+ manifest_sha256,
107
+ blobUri,
108
+ blob_uri,
109
+ blobSha256,
110
+ blob_sha256,
111
+ blobContainerName,
112
+ blob_container_name,
113
+ blobObjectKey,
114
+ blob_object_key,
115
+ metadata = {},
116
+ } = {}) {
117
+ return client._request('/api/agent-communications/bundles', {
118
+ method: 'POST',
119
+ body: {
120
+ workflow_run_id: cleanText(workflow_run_id) || cleanText(workflowRunId),
121
+ communication_thread_id: cleanText(communication_thread_id) || cleanText(communicationThreadId) || cleanText(threadId),
122
+ source_agent_session_id: cleanText(source_agent_session_id) || cleanText(sourceAgentSessionId),
123
+ source_actor_session_id: cleanText(source_actor_session_id) || cleanText(sourceActorSessionId),
124
+ recipient_agent_session_id: cleanText(recipient_agent_session_id) || cleanText(recipientAgentSessionId),
125
+ recipient_role_key: cleanText(recipient_role_key) || cleanText(recipientRoleKey),
126
+ bundle_kind: cleanText(bundle_kind) || cleanText(bundleKind) || 'transfer',
127
+ cleanup_policy: cleanText(cleanup_policy) || cleanText(cleanupPolicy) || 'cleanup_after_receipt',
128
+ manifest: isPlainObject(manifest) ? manifest : {},
129
+ manifest_sha256: cleanText(manifest_sha256) || cleanText(manifestSha256),
130
+ blob_uri: cleanText(blob_uri) || cleanText(blobUri),
131
+ blob_sha256: cleanText(blob_sha256) || cleanText(blobSha256),
132
+ blob_container_name: cleanText(blob_container_name) || cleanText(blobContainerName),
133
+ blob_object_key: cleanText(blob_object_key) || cleanText(blobObjectKey),
134
+ metadata: isPlainObject(metadata) ? metadata : {},
135
+ },
136
+ });
137
+ }
138
+
139
+ export async function getCommunicationBundle(client, bundleId) {
140
+ return client._request(`/api/agent-communications/bundles/${encodeURIComponent(bundleId)}`);
141
+ }
142
+
143
+ export async function listCommunicationBundles(client, { workflowRunId, workflow_run_id } = {}) {
144
+ return client._request('/api/agent-communications/bundles', {
145
+ query: { workflow_run_id: cleanText(workflow_run_id) || cleanText(workflowRunId) },
146
+ });
147
+ }
148
+
149
+ export async function addCommunicationBundleItem(client, {
150
+ communicationBundleId,
151
+ communication_bundle_id,
152
+ itemOrder,
153
+ item_order,
154
+ itemKind,
155
+ item_kind,
156
+ itemRef,
157
+ item_ref,
158
+ itemName,
159
+ item_name,
160
+ itemSha256,
161
+ item_sha256,
162
+ required,
163
+ metadata = {},
164
+ } = {}) {
165
+ const normalizedBundleId = cleanText(communication_bundle_id) || cleanText(communicationBundleId);
166
+ if (!normalizedBundleId) throw new Error('communication_bundle_id is required.');
167
+ return client._request(`/api/agent-communications/bundles/${encodeURIComponent(normalizedBundleId)}/items`, {
168
+ method: 'POST',
169
+ body: {
170
+ item_order: Number(item_order ?? itemOrder ?? 0),
171
+ item_kind: cleanText(item_kind) || cleanText(itemKind) || 'artifact',
172
+ item_ref: cleanText(item_ref) || cleanText(itemRef),
173
+ item_name: cleanText(item_name) || cleanText(itemName),
174
+ item_sha256: cleanText(item_sha256) || cleanText(itemSha256),
175
+ required: required !== undefined ? Boolean(required) : true,
176
+ metadata: isPlainObject(metadata) ? metadata : {},
177
+ },
178
+ });
179
+ }
180
+
181
+ export async function uploadCommunicationBundle(client, {
182
+ communicationBundleId,
183
+ communication_bundle_id,
184
+ blobUri,
185
+ blob_uri,
186
+ blobSha256,
187
+ blob_sha256,
188
+ blobContainerName,
189
+ blob_container_name,
190
+ blobObjectKey,
191
+ blob_object_key,
192
+ manifest = {},
193
+ manifestSha256,
194
+ manifest_sha256,
195
+ uploadedAt,
196
+ uploaded_at,
197
+ } = {}) {
198
+ const normalizedBundleId = cleanText(communication_bundle_id) || cleanText(communicationBundleId);
199
+ if (!normalizedBundleId) throw new Error('communication_bundle_id is required.');
200
+ return client._request(`/api/agent-communications/bundles/${encodeURIComponent(normalizedBundleId)}/upload`, {
201
+ method: 'POST',
202
+ body: {
203
+ blob_uri: cleanText(blob_uri) || cleanText(blobUri),
204
+ blob_sha256: cleanText(blob_sha256) || cleanText(blobSha256),
205
+ blob_container_name: cleanText(blob_container_name) || cleanText(blobContainerName),
206
+ blob_object_key: cleanText(blob_object_key) || cleanText(blobObjectKey),
207
+ manifest: isPlainObject(manifest) ? manifest : {},
208
+ manifest_sha256: cleanText(manifest_sha256) || cleanText(manifestSha256),
209
+ uploaded_at: cleanText(uploaded_at) || cleanText(uploadedAt),
210
+ },
211
+ });
212
+ }
213
+
214
+ export async function attachCommunicationBundleToMessage(client, {
215
+ communicationBundleId,
216
+ communication_bundle_id,
217
+ agentMessageId,
218
+ agent_message_id,
219
+ messageId,
220
+ messageStatus,
221
+ message_status,
222
+ } = {}) {
223
+ const normalizedBundleId = cleanText(communication_bundle_id) || cleanText(communicationBundleId);
224
+ if (!normalizedBundleId) throw new Error('communication_bundle_id is required.');
225
+ return client._request(`/api/agent-communications/bundles/${encodeURIComponent(normalizedBundleId)}/attach-to-message`, {
226
+ method: 'POST',
227
+ body: {
228
+ agent_message_id: cleanText(agent_message_id) || cleanText(agentMessageId) || cleanText(messageId),
229
+ message_status: cleanText(message_status) || cleanText(messageStatus),
230
+ },
231
+ });
232
+ }
233
+
234
+ export async function recordCommunicationBundleReceipt(client, {
235
+ communicationBundleId,
236
+ communication_bundle_id,
237
+ recipientAgentSessionId,
238
+ recipient_agent_session_id,
239
+ recipientActorSessionId,
240
+ recipient_actor_session_id,
241
+ receiptStatus,
242
+ receipt_status,
243
+ manifestSha256,
244
+ manifest_sha256,
245
+ blobSha256,
246
+ blob_sha256,
247
+ fetchedItemCount,
248
+ fetched_item_count,
249
+ explicitlyAcceptedItemCount,
250
+ explicitly_accepted_item_count,
251
+ allRequiredItemsFetched,
252
+ all_required_items_fetched,
253
+ checksumsVerified,
254
+ checksums_verified,
255
+ receipt = {},
256
+ metadata = {},
257
+ } = {}) {
258
+ const normalizedBundleId = cleanText(communication_bundle_id) || cleanText(communicationBundleId);
259
+ if (!normalizedBundleId) throw new Error('communication_bundle_id is required.');
260
+ return client._request(`/api/agent-communications/bundles/${encodeURIComponent(normalizedBundleId)}/receipts`, {
261
+ method: 'POST',
262
+ body: {
263
+ recipient_agent_session_id: cleanText(recipient_agent_session_id) || cleanText(recipientAgentSessionId),
264
+ recipient_actor_session_id: cleanText(recipient_actor_session_id) || cleanText(recipientActorSessionId),
265
+ receipt_status: cleanText(receipt_status) || cleanText(receiptStatus) || 'received',
266
+ manifest_sha256: cleanText(manifest_sha256) || cleanText(manifestSha256),
267
+ blob_sha256: cleanText(blob_sha256) || cleanText(blobSha256),
268
+ fetched_item_count: Number(fetched_item_count ?? fetchedItemCount ?? 0),
269
+ explicitly_accepted_item_count: Number(explicitly_accepted_item_count ?? explicitlyAcceptedItemCount ?? 0),
270
+ all_required_items_fetched: Boolean(all_required_items_fetched ?? allRequiredItemsFetched ?? false),
271
+ checksums_verified: Boolean(checksums_verified ?? checksumsVerified ?? false),
272
+ receipt: isPlainObject(receipt) ? receipt : {},
273
+ metadata: isPlainObject(metadata) ? metadata : {},
274
+ },
275
+ });
276
+ }
277
+
278
+ export async function recordCommunicationBundleCleanupEvent(client, {
279
+ communicationBundleId,
280
+ communication_bundle_id,
281
+ cleanupStatus,
282
+ cleanup_status,
283
+ cleanupReason,
284
+ cleanup_reason,
285
+ blobUri,
286
+ blob_uri,
287
+ deletedAt,
288
+ deleted_at,
289
+ errorMessage,
290
+ error_message,
291
+ metadata = {},
292
+ } = {}) {
293
+ const normalizedBundleId = cleanText(communication_bundle_id) || cleanText(communicationBundleId);
294
+ if (!normalizedBundleId) throw new Error('communication_bundle_id is required.');
295
+ return client._request(`/api/agent-communications/bundles/${encodeURIComponent(normalizedBundleId)}/cleanup-events`, {
296
+ method: 'POST',
297
+ body: {
298
+ cleanup_status: cleanText(cleanup_status) || cleanText(cleanupStatus) || 'cleanup_failed',
299
+ cleanup_reason: cleanText(cleanup_reason) || cleanText(cleanupReason),
300
+ blob_uri: cleanText(blob_uri) || cleanText(blobUri),
301
+ deleted_at: cleanText(deleted_at) || cleanText(deletedAt),
302
+ error_message: cleanText(error_message) || cleanText(errorMessage),
303
+ metadata: isPlainObject(metadata) ? metadata : {},
304
+ },
305
+ });
306
+ }
307
+
308
+ export async function claimCommunicationBundle(client, {
309
+ communicationBundleId,
310
+ communication_bundle_id,
311
+ claimedAt,
312
+ claimed_at,
313
+ } = {}) {
314
+ const normalizedBundleId = cleanText(communication_bundle_id) || cleanText(communicationBundleId);
315
+ if (!normalizedBundleId) throw new Error('communication_bundle_id is required.');
316
+ return client._request(`/api/agent-communications/bundles/${encodeURIComponent(normalizedBundleId)}/claim`, {
317
+ method: 'POST',
318
+ body: {
319
+ claimed_at: cleanText(claimed_at) || cleanText(claimedAt),
320
+ },
321
+ });
322
+ }
323
+
324
+ export async function recordCommunicationTransferReceipt(client, {
325
+ workTransferPacketId,
326
+ work_transfer_packet_id,
327
+ receiptType,
328
+ receipt_type,
329
+ receiptStatus,
330
+ receipt_status,
331
+ actorSessionId,
332
+ actor_session_id,
333
+ agentSessionId,
334
+ agent_session_id,
335
+ claimId,
336
+ claim_id,
337
+ evidenceRef,
338
+ evidence_ref,
339
+ evidenceSha256,
340
+ evidence_sha256,
341
+ evidence = {},
342
+ manifestSha256,
343
+ manifest_sha256,
344
+ closureReason,
345
+ closure_reason,
346
+ failureReason,
347
+ failure_reason,
348
+ lifecycleStatus,
349
+ lifecycle_status,
350
+ metadata = {},
351
+ } = {}) {
352
+ const normalizedPacketId = cleanText(work_transfer_packet_id) || cleanText(workTransferPacketId);
353
+ if (!normalizedPacketId) throw new Error('work_transfer_packet_id is required.');
354
+ return client._request(`/api/agent-communications/transfers/${encodeURIComponent(normalizedPacketId)}/receipts`, {
355
+ method: 'POST',
356
+ body: {
357
+ receipt_type: normalizeTransferReceiptType(cleanText(receipt_type) || cleanText(receiptType) || 'delivery_receipt'),
358
+ receipt_status: cleanText(receipt_status) || cleanText(receiptStatus) || 'recorded',
359
+ actor_session_id: cleanText(actor_session_id) || cleanText(actorSessionId),
360
+ agent_session_id: cleanText(agent_session_id) || cleanText(agentSessionId) || client.agentSessionId,
361
+ claim_id: cleanText(claim_id) || cleanText(claimId),
362
+ evidence_ref: cleanText(evidence_ref) || cleanText(evidenceRef),
363
+ evidence_sha256: cleanText(evidence_sha256) || cleanText(evidenceSha256),
364
+ evidence: isPlainObject(evidence) ? evidence : {},
365
+ manifest_sha256: cleanText(manifest_sha256) || cleanText(manifestSha256),
366
+ closure_reason: cleanText(closure_reason) || cleanText(closureReason),
367
+ failure_reason: cleanText(failure_reason) || cleanText(failureReason),
368
+ lifecycle_status: cleanText(lifecycle_status) || cleanText(lifecycleStatus),
369
+ metadata: isPlainObject(metadata) ? metadata : {},
370
+ },
371
+ });
372
+ }