@axonflow/sdk 3.7.0 → 4.0.0

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 (48) hide show
  1. package/README.md +6 -2
  2. package/dist/cjs/client.d.ts +16 -1
  3. package/dist/cjs/client.d.ts.map +1 -1
  4. package/dist/cjs/client.js +71 -4
  5. package/dist/cjs/client.js.map +1 -1
  6. package/dist/cjs/index.d.ts +3 -3
  7. package/dist/cjs/index.d.ts.map +1 -1
  8. package/dist/cjs/index.js +2 -1
  9. package/dist/cjs/index.js.map +1 -1
  10. package/dist/cjs/telemetry.d.ts +25 -0
  11. package/dist/cjs/telemetry.d.ts.map +1 -0
  12. package/dist/cjs/telemetry.js +137 -0
  13. package/dist/cjs/telemetry.js.map +1 -0
  14. package/dist/cjs/types/config.d.ts +10 -0
  15. package/dist/cjs/types/config.d.ts.map +1 -1
  16. package/dist/cjs/types/proxy.d.ts +24 -0
  17. package/dist/cjs/types/proxy.d.ts.map +1 -1
  18. package/dist/cjs/types/workflows.d.ts +19 -2
  19. package/dist/cjs/types/workflows.d.ts.map +1 -1
  20. package/dist/cjs/types/workflows.js.map +1 -1
  21. package/dist/cjs/version.d.ts +8 -0
  22. package/dist/cjs/version.d.ts.map +1 -0
  23. package/dist/cjs/version.js +11 -0
  24. package/dist/cjs/version.js.map +1 -0
  25. package/dist/esm/client.d.ts +16 -1
  26. package/dist/esm/client.d.ts.map +1 -1
  27. package/dist/esm/client.js +71 -4
  28. package/dist/esm/client.js.map +1 -1
  29. package/dist/esm/index.d.ts +3 -3
  30. package/dist/esm/index.d.ts.map +1 -1
  31. package/dist/esm/index.js +1 -1
  32. package/dist/esm/index.js.map +1 -1
  33. package/dist/esm/telemetry.d.ts +25 -0
  34. package/dist/esm/telemetry.d.ts.map +1 -0
  35. package/dist/esm/telemetry.js +134 -0
  36. package/dist/esm/telemetry.js.map +1 -0
  37. package/dist/esm/types/config.d.ts +10 -0
  38. package/dist/esm/types/config.d.ts.map +1 -1
  39. package/dist/esm/types/proxy.d.ts +24 -0
  40. package/dist/esm/types/proxy.d.ts.map +1 -1
  41. package/dist/esm/types/workflows.d.ts +19 -2
  42. package/dist/esm/types/workflows.d.ts.map +1 -1
  43. package/dist/esm/types/workflows.js.map +1 -1
  44. package/dist/esm/version.d.ts +8 -0
  45. package/dist/esm/version.d.ts.map +1 -0
  46. package/dist/esm/version.js +8 -0
  47. package/dist/esm/version.js.map +1 -0
  48. package/package.json +1 -2
@@ -1,5 +1,23 @@
1
+ import { VERSION } from './version.js';
2
+ import { sendTelemetryPing } from './telemetry.js';
1
3
  import { AuthenticationError, APIError, PolicyViolationError, ConfigurationError, ConnectorError, PlanExecutionError, VersionConflictError, } from './errors.js';
2
4
  import { generateRequestId, debugLog } from './utils/helpers.js';
5
+ /**
6
+ * Compare two semver version strings numerically.
7
+ * Returns -1 if a < b, 0 if equal, 1 if a > b.
8
+ */
9
+ function compareSemver(a, b) {
10
+ const parseVersion = (v) => v.split('.').map(p => parseInt(p.split('-')[0], 10) || 0);
11
+ const aParts = parseVersion(a);
12
+ const bParts = parseVersion(b);
13
+ const len = Math.max(aParts.length, bParts.length);
14
+ for (let i = 0; i < len; i++) {
15
+ const diff = (aParts[i] || 0) - (bParts[i] || 0);
16
+ if (diff !== 0)
17
+ return diff < 0 ? -1 : 1;
18
+ }
19
+ return 0;
20
+ }
3
21
  /**
4
22
  * Main AxonFlow client for invisible AI governance
5
23
  */
@@ -47,6 +65,14 @@ export class AxonFlow {
47
65
  authMethod,
48
66
  });
49
67
  }
68
+ // Send telemetry ping (fire-and-forget).
69
+ sendTelemetryPing({
70
+ mode: this.config.mode,
71
+ explicitMode: config.mode,
72
+ endpoint: this.config.endpoint,
73
+ telemetryEnabled: config.telemetry,
74
+ debug: this.config.debug,
75
+ });
50
76
  }
51
77
  /**
52
78
  * Get authentication headers based on configured credentials.
@@ -67,6 +93,8 @@ export class AxonFlow {
67
93
  if (this.config.clientId) {
68
94
  headers['X-Tenant-ID'] = this.config.clientId;
69
95
  }
96
+ // Include SDK version for version discovery and compatibility checks
97
+ headers['User-Agent'] = `axonflow-sdk-typescript/${VERSION}`;
70
98
  return headers;
71
99
  }
72
100
  /**
@@ -285,6 +313,24 @@ export class AxonFlow {
285
313
  debug: true,
286
314
  });
287
315
  }
316
+ /**
317
+ * Check if a health response indicates support for a named capability.
318
+ *
319
+ * @param health - HealthStatus returned from healthCheck()
320
+ * @param name - Capability name to check (e.g. "mcp-policy-check", "circuit-breaker")
321
+ * @returns true if the capability is present in the health response
322
+ *
323
+ * @example
324
+ * ```typescript
325
+ * const health = await axonflow.healthCheck();
326
+ * if (AxonFlow.hasCapability(health, 'mcp-policy-check')) {
327
+ * // Platform supports MCP policy check endpoints
328
+ * }
329
+ * ```
330
+ */
331
+ static hasCapability(health, name) {
332
+ return health.capabilities?.some(c => c.name === name) ?? false;
333
+ }
288
334
  // ============================================================================
289
335
  // Proxy Mode Methods
290
336
  // ============================================================================
@@ -306,6 +352,7 @@ export class AxonFlow {
306
352
  try {
307
353
  const response = await fetch(url, {
308
354
  method: 'GET',
355
+ headers: this.getAuthHeaders(),
309
356
  signal: AbortSignal.timeout(this.config.timeout),
310
357
  });
311
358
  if (!response.ok) {
@@ -317,11 +364,23 @@ export class AxonFlow {
317
364
  };
318
365
  }
319
366
  const data = await response.json();
367
+ // Warn if SDK version is below platform minimum
368
+ if (data.sdk_compatibility?.min_sdk_version &&
369
+ compareSemver(VERSION, data.sdk_compatibility.min_sdk_version) < 0) {
370
+ console.warn(`[AxonFlow SDK] WARNING: SDK version ${VERSION} is below minimum supported version ${data.sdk_compatibility.min_sdk_version}. Please upgrade.`);
371
+ }
320
372
  return {
321
373
  status: data.status === 'healthy' ? 'healthy' : 'degraded',
322
374
  version: data.version,
323
375
  uptime: data.uptime,
324
376
  components: data.components,
377
+ capabilities: data.capabilities,
378
+ sdkCompatibility: data.sdk_compatibility
379
+ ? {
380
+ minSdkVersion: data.sdk_compatibility.min_sdk_version,
381
+ recommendedSdkVersion: data.sdk_compatibility.recommended_sdk_version,
382
+ }
383
+ : undefined,
325
384
  };
326
385
  }
327
386
  catch (error) {
@@ -356,6 +415,7 @@ export class AxonFlow {
356
415
  try {
357
416
  const response = await fetch(url, {
358
417
  method: 'GET',
418
+ headers: this.getAuthHeaders(),
359
419
  signal: AbortSignal.timeout(this.config.timeout),
360
420
  });
361
421
  if (!response.ok) {
@@ -372,6 +432,13 @@ export class AxonFlow {
372
432
  version: data.version,
373
433
  uptime: data.uptime,
374
434
  components: data.components,
435
+ capabilities: data.capabilities,
436
+ sdkCompatibility: data.sdk_compatibility
437
+ ? {
438
+ minSdkVersion: data.sdk_compatibility.min_sdk_version,
439
+ recommendedSdkVersion: data.sdk_compatibility.recommended_sdk_version,
440
+ }
441
+ : undefined,
375
442
  };
376
443
  }
377
444
  catch (error) {
@@ -790,9 +857,7 @@ export class AxonFlow {
790
857
  if (options.parameters) {
791
858
  body.parameters = options.parameters;
792
859
  }
793
- if (options.operation) {
794
- body.operation = options.operation;
795
- }
860
+ body.operation = options.operation || 'execute';
796
861
  if (this.config.debug) {
797
862
  debugLog('MCP Check Input', {
798
863
  connectorType: options.connectorType,
@@ -3338,7 +3403,6 @@ export class AxonFlow {
3338
3403
  * const workflow = await client.createWorkflow({
3339
3404
  * workflow_name: 'customer-support-agent',
3340
3405
  * source: 'langgraph',
3341
- * total_steps: 5,
3342
3406
  * metadata: { customer_id: 'cust-123' }
3343
3407
  * });
3344
3408
  * console.log(`Workflow created: ${workflow.workflow_id}`);
@@ -3517,6 +3581,9 @@ export class AxonFlow {
3517
3581
  if (options?.offset !== undefined) {
3518
3582
  params.set('offset', options.offset.toString());
3519
3583
  }
3584
+ if (options?.trace_id) {
3585
+ params.set('trace_id', options.trace_id);
3586
+ }
3520
3587
  const queryString = params.toString();
3521
3588
  const path = queryString ? `/api/v1/workflows?${queryString}` : '/api/v1/workflows';
3522
3589
  const response = await this.orchestratorRequest('GET', path);