@bpmsoftwaresolutions/ai-engine-client 1.1.31 → 1.1.33

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 +84 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bpmsoftwaresolutions/ai-engine-client",
3
- "version": "1.1.31",
3
+ "version": "1.1.33",
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.31';
2
+ export const AI_ENGINE_CLIENT_VERSION = '1.1.33';
3
3
  export const GOVERNED_MUTATION_REQUIRED_CAPABILITIES = [
4
4
  'executeVerifiedMutation',
5
5
  'post_mutation_verification',
@@ -19,6 +19,7 @@ export const LOGA_CONTRACT = 'ai-engine-ui/v1';
19
19
  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
+ export const TASK_BOUND_SUBSTRATE_EXECUTION_POLICY = 'task_bound_substrate_execution/v1';
22
23
 
23
24
  function trimTrailingSlash(value) {
24
25
  return String(value || '').replace(/\/+$/, '');
@@ -122,6 +123,35 @@ function isPlainObject(value) {
122
123
  return value !== null && typeof value === 'object' && !Array.isArray(value);
123
124
  }
124
125
 
126
+ function normalizeTaskBindingPolicy(taskBinding, { expectedAction = null } = {}) {
127
+ if (!isPlainObject(taskBinding)) return taskBinding;
128
+ const taskId = cleanText(taskBinding.task_id || taskBinding.implementation_item_task_id);
129
+ const roadmapItemId = cleanText(taskBinding.roadmap_item_id || taskBinding.implementation_item_id);
130
+ const taskStatus = cleanText(taskBinding.task_status || taskBinding.status);
131
+ const allowedActions = cleanList(taskBinding.allowed_actions);
132
+ const substrateAction = cleanText(taskBinding.substrate_action) || cleanText(expectedAction);
133
+ return {
134
+ ...taskBinding,
135
+ ...(taskId ? { task_id: taskId } : {}),
136
+ ...(roadmapItemId ? { roadmap_item_id: roadmapItemId, implementation_item_id: roadmapItemId } : {}),
137
+ ...(taskStatus ? { task_status: taskStatus } : {}),
138
+ ...(allowedActions.length > 0 ? { allowed_actions: allowedActions } : {}),
139
+ ...(substrateAction ? { substrate_action: substrateAction } : {}),
140
+ policy_key: cleanText(taskBinding.policy_key) || 'task_bound_substrate_execution',
141
+ policy_version: cleanText(taskBinding.policy_version) || 'v1',
142
+ policy_identifier: cleanText(taskBinding.policy_identifier) || TASK_BOUND_SUBSTRATE_EXECUTION_POLICY,
143
+ };
144
+ }
145
+
146
+ function normalizeMetadataTaskBinding(metadata, { expectedAction = null } = {}) {
147
+ if (!isPlainObject(metadata)) return metadata;
148
+ if (!isPlainObject(metadata.task_binding)) return metadata;
149
+ return {
150
+ ...metadata,
151
+ task_binding: normalizeTaskBindingPolicy(metadata.task_binding, { expectedAction }),
152
+ };
153
+ }
154
+
125
155
  function isActiveBinding(binding) {
126
156
  return isPlainObject(binding) && (
127
157
  binding.is_active === true ||
@@ -221,6 +251,13 @@ export class AIEngineClient {
221
251
  promoteUxGateRemediationImplementationCandidate: (remediationId, payload) =>
222
252
  this.promoteUxGateRemediationImplementationCandidate(remediationId, payload),
223
253
  getUxGateRemediationProjection: (remediationId) => this.getLogaUxGateRemediationProjection(remediationId),
254
+ getGeneratedExecutionUsabilityProjection: (query) => this.getLogaGeneratedExecutionUsabilityProjection(query),
255
+ };
256
+ this.executionTelemetry = {
257
+ getCurrent: () => this.getExecutionTelemetryCurrent(),
258
+ listProcessRuns: (query) => this.listExecutionProcessRuns(query),
259
+ getProcessRun: (processRunId) => this.getExecutionProcessRun(processRunId),
260
+ getGeneratedExecutionUsability: (query) => this.getGeneratedExecutionUsability(query),
224
261
  };
225
262
  this.scripts = {
226
263
  generate: (payload) => this.generateScript(payload),
@@ -272,6 +309,32 @@ export class AIEngineClient {
272
309
  });
273
310
  }
274
311
 
312
+ async getExecutionTelemetryCurrent() {
313
+ return this._request('/api/operator/execution-telemetry/current');
314
+ }
315
+
316
+ async listExecutionProcessRuns({ limit, artifactKind, status, since } = {}) {
317
+ return this._request('/api/operator/execution-telemetry/process-runs', {
318
+ query: { limit, artifact_kind: artifactKind, status, since },
319
+ });
320
+ }
321
+
322
+ async getExecutionProcessRun(processRunId) {
323
+ return this._request(`/api/operator/execution-telemetry/process-runs/${processRunId}`);
324
+ }
325
+
326
+ async getGeneratedExecutionUsability({ artifactPath, limit } = {}) {
327
+ return this._request('/api/operator/generated-execution-usability', {
328
+ query: { artifact_path: artifactPath, limit },
329
+ });
330
+ }
331
+
332
+ async getLogaGeneratedExecutionUsabilityProjection({ artifactPath, limit } = {}) {
333
+ return this._requestLogaProjection('/api/loga/ai-engine/generated-execution-usability', {
334
+ query: { artifact_path: artifactPath, limit },
335
+ });
336
+ }
337
+
275
338
  async getAntiPatternRules() {
276
339
  return this._request('/api/governance/anti-pattern-rules');
277
340
  }
@@ -497,13 +560,22 @@ export class AIEngineClient {
497
560
  execution_purpose: executionPurpose,
498
561
  success_criteria: successCriteria,
499
562
  mutation_allowed: mutationAllowed,
500
- metadata,
563
+ metadata: normalizeMetadataTaskBinding(metadata),
501
564
  },
502
565
  });
503
566
  }
504
567
 
505
568
  async claimWorkItem(body = {}) {
506
- return this._request('/api/governance/claims/claim-work-item', { method: 'POST', body });
569
+ const normalizedBody = isPlainObject(body)
570
+ ? {
571
+ ...body,
572
+ ...(isPlainObject(body.task_binding)
573
+ ? { task_binding: normalizeTaskBindingPolicy(body.task_binding) }
574
+ : {}),
575
+ metadata: normalizeMetadataTaskBinding(body.metadata),
576
+ }
577
+ : body;
578
+ return this._request('/api/governance/claims/claim-work-item', { method: 'POST', body: normalizedBody });
507
579
  }
508
580
 
509
581
  async bindClaimedWorkItem({
@@ -873,9 +945,17 @@ export class AIEngineClient {
873
945
 
874
946
  async routeImplementationItem(implementationItemId, body = {}) {
875
947
  if (!implementationItemId) throw new Error('implementationItemId is required.');
948
+ const normalizedBody = isPlainObject(body)
949
+ ? {
950
+ ...body,
951
+ ...(isPlainObject(body.task_binding)
952
+ ? { task_binding: normalizeTaskBindingPolicy(body.task_binding) }
953
+ : {}),
954
+ }
955
+ : body;
876
956
  return this._request(`/api/governed-implementation/items/${encodeURIComponent(implementationItemId)}/routing`, {
877
957
  method: 'PATCH',
878
- body,
958
+ body: normalizedBody,
879
959
  });
880
960
  }
881
961