@bpmsoftwaresolutions/ai-engine-client 1.1.58 → 1.1.60

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 +98 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bpmsoftwaresolutions/ai-engine-client",
3
- "version": "1.1.58",
3
+ "version": "1.1.60",
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.58';
2
+ export const AI_ENGINE_CLIENT_VERSION = '1.1.60';
3
3
  export const GOVERNED_MUTATION_REQUIRED_CAPABILITIES = [
4
4
  'executeVerifiedMutation',
5
5
  'post_mutation_verification',
@@ -207,6 +207,19 @@ function cleanText(value) {
207
207
  return text || null;
208
208
  }
209
209
 
210
+ function compareSemanticVersions(left, right) {
211
+ const leftParts = String(left || '').split('.').map((part) => Number.parseInt(part, 10) || 0);
212
+ const rightParts = String(right || '').split('.').map((part) => Number.parseInt(part, 10) || 0);
213
+ const width = Math.max(leftParts.length, rightParts.length);
214
+ for (let index = 0; index < width; index += 1) {
215
+ const a = leftParts[index] || 0;
216
+ const b = rightParts[index] || 0;
217
+ if (a > b) return 1;
218
+ if (a < b) return -1;
219
+ }
220
+ return 0;
221
+ }
222
+
210
223
  function looksLikeUuid(value) {
211
224
  const text = cleanText(value);
212
225
  return Boolean(text && /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(text));
@@ -459,6 +472,7 @@ export class AIEngineClient {
459
472
  sendCoordinationPong: (request) => this.sendCoordinationPong(request),
460
473
  getCoordinationPingPongStatus: (request) => this.getCoordinationPingPongStatus(request),
461
474
  stopCoordinationPingPong: (request) => this.stopCoordinationPingPong(request),
475
+ checkCoordinationPingPongPreflight: (request) => this.checkCoordinationPingPongPreflight(request),
462
476
  connectToTransferChannel: (request) => this.connectToTransferChannel(request),
463
477
  respondToMessageWatch: (request) => this.respondToMessageWatch(request),
464
478
  };
@@ -492,6 +506,7 @@ export class AIEngineClient {
492
506
  sendCoordinationPong: (request) => this.sendCoordinationPong(request),
493
507
  getCoordinationPingPongStatus: (request) => this.getCoordinationPingPongStatus(request),
494
508
  stopCoordinationPingPong: (request) => this.stopCoordinationPingPong(request),
509
+ checkCoordinationPingPongPreflight: (request) => this.checkCoordinationPingPongPreflight(request),
495
510
  };
496
511
  }
497
512
 
@@ -682,6 +697,79 @@ export class AIEngineClient {
682
697
  return this._request('/api/agent-communications/deployment-capabilities');
683
698
  }
684
699
 
700
+ async checkCoordinationPingPongPreflight({
701
+ packageVersion,
702
+ } = {}) {
703
+ const capabilities = await this.getCollaborationCapabilities();
704
+ const requiredMethods = [
705
+ 'startCoordinationPingPong',
706
+ 'sendCoordinationPing',
707
+ 'sendCoordinationPong',
708
+ 'getCoordinationPingPongStatus',
709
+ 'stopCoordinationPingPong',
710
+ ];
711
+ const resolvedPackageVersion = cleanText(packageVersion) || AI_ENGINE_CLIENT_VERSION;
712
+ const minimumClientVersion = cleanText(capabilities.minimum_client_version) || resolvedPackageVersion;
713
+ const supported = Boolean(capabilities.coordination_ping_pong_supported);
714
+ const reportedMethods = Array.isArray(capabilities.required_methods) && capabilities.required_methods.length > 0
715
+ ? capabilities.required_methods
716
+ : capabilities.collaboration_choreography_methods;
717
+ const missingMethods = requiredMethods.filter((method) => !Array.isArray(reportedMethods) || !reportedMethods.includes(method));
718
+ const issues = [];
719
+ if (!supported) {
720
+ issues.push({
721
+ drift_type: 'capability_drift',
722
+ rule: 'coordination_ping_pong_unsupported',
723
+ message: 'Coordination Ping Pong is not supported by the deployed collaboration capability surface.',
724
+ });
725
+ }
726
+ if (compareSemanticVersions(resolvedPackageVersion, minimumClientVersion) < 0) {
727
+ issues.push({
728
+ drift_type: 'capability_drift',
729
+ rule: 'package_version_below_minimum',
730
+ message: `Package version ${resolvedPackageVersion} is below required minimum ${minimumClientVersion}.`,
731
+ package_version: resolvedPackageVersion,
732
+ required_minimum_version: minimumClientVersion,
733
+ });
734
+ }
735
+ if (missingMethods.length > 0) {
736
+ issues.push({
737
+ drift_type: 'deployment_drift',
738
+ rule: 'missing_ping_pong_methods',
739
+ message: `Missing required coordination methods: ${missingMethods.join(', ')}.`,
740
+ missing_methods: missingMethods,
741
+ });
742
+ }
743
+ if (issues.length > 0) {
744
+ return {
745
+ ok: false,
746
+ supported: false,
747
+ minimum_client_version: minimumClientVersion,
748
+ package_version: resolvedPackageVersion,
749
+ coordination_ping_pong_supported: supported,
750
+ required_methods: requiredMethods,
751
+ capabilities,
752
+ issues,
753
+ stop_reason: {
754
+ code: 'coordination_ping_pong_preflight_failed',
755
+ message: 'Coordination Ping Pong is not ready to start.',
756
+ details: { issues },
757
+ },
758
+ };
759
+ }
760
+ return {
761
+ ok: true,
762
+ supported: true,
763
+ minimum_client_version: minimumClientVersion,
764
+ package_version: resolvedPackageVersion,
765
+ coordination_ping_pong_supported: supported,
766
+ required_methods: requiredMethods,
767
+ capabilities,
768
+ issues: [],
769
+ stop_reason: null,
770
+ };
771
+ }
772
+
685
773
  async listCommunicationChannels({
686
774
  workflowRunId,
687
775
  workflow_run_id,
@@ -1839,6 +1927,15 @@ export class AIEngineClient {
1839
1927
  stop_reason: resolved.stop_reason,
1840
1928
  };
1841
1929
  }
1930
+ const preflight = await this.checkCoordinationPingPongPreflight({ packageVersion: this.clientVersion });
1931
+ if (!preflight.ok) {
1932
+ return {
1933
+ started: false,
1934
+ sent: false,
1935
+ stop_reason: preflight.stop_reason,
1936
+ coordination_ping_pong_preflight: preflight,
1937
+ };
1938
+ }
1842
1939
  return this._request(`/api/agent-communications/transfer-channels/${encodeURIComponent(resolved.channel_id)}/coordination/ping-pong/start`, {
1843
1940
  method: 'POST',
1844
1941
  body: {