@axonflow/sdk 3.3.1 → 3.5.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 (50) hide show
  1. package/README.md +5 -5
  2. package/dist/cjs/client.d.ts +118 -1
  3. package/dist/cjs/client.d.ts.map +1 -1
  4. package/dist/cjs/client.js +215 -0
  5. package/dist/cjs/client.js.map +1 -1
  6. package/dist/cjs/index.d.ts +3 -1
  7. package/dist/cjs/index.d.ts.map +1 -1
  8. package/dist/cjs/index.js.map +1 -1
  9. package/dist/cjs/types/hitl.d.ts +109 -0
  10. package/dist/cjs/types/hitl.d.ts.map +1 -0
  11. package/dist/cjs/types/hitl.js +5 -0
  12. package/dist/cjs/types/hitl.js.map +1 -0
  13. package/dist/cjs/types/index.d.ts +2 -0
  14. package/dist/cjs/types/index.d.ts.map +1 -1
  15. package/dist/cjs/types/index.js +2 -0
  16. package/dist/cjs/types/index.js.map +1 -1
  17. package/dist/cjs/types/media.d.ts +68 -0
  18. package/dist/cjs/types/media.d.ts.map +1 -0
  19. package/dist/cjs/types/media.js +9 -0
  20. package/dist/cjs/types/media.js.map +1 -0
  21. package/dist/cjs/types/proxy.d.ts +5 -0
  22. package/dist/cjs/types/proxy.d.ts.map +1 -1
  23. package/dist/cjs/types/workflows.d.ts +7 -0
  24. package/dist/cjs/types/workflows.d.ts.map +1 -1
  25. package/dist/cjs/types/workflows.js.map +1 -1
  26. package/dist/esm/client.d.ts +118 -1
  27. package/dist/esm/client.d.ts.map +1 -1
  28. package/dist/esm/client.js +215 -0
  29. package/dist/esm/client.js.map +1 -1
  30. package/dist/esm/index.d.ts +3 -1
  31. package/dist/esm/index.d.ts.map +1 -1
  32. package/dist/esm/index.js.map +1 -1
  33. package/dist/esm/types/hitl.d.ts +109 -0
  34. package/dist/esm/types/hitl.d.ts.map +1 -0
  35. package/dist/esm/types/hitl.js +4 -0
  36. package/dist/esm/types/hitl.js.map +1 -0
  37. package/dist/esm/types/index.d.ts +2 -0
  38. package/dist/esm/types/index.d.ts.map +1 -1
  39. package/dist/esm/types/index.js +2 -0
  40. package/dist/esm/types/index.js.map +1 -1
  41. package/dist/esm/types/media.d.ts +68 -0
  42. package/dist/esm/types/media.d.ts.map +1 -0
  43. package/dist/esm/types/media.js +8 -0
  44. package/dist/esm/types/media.js.map +1 -0
  45. package/dist/esm/types/proxy.d.ts +5 -0
  46. package/dist/esm/types/proxy.d.ts.map +1 -1
  47. package/dist/esm/types/workflows.d.ts +7 -0
  48. package/dist/esm/types/workflows.d.ts.map +1 -1
  49. package/dist/esm/types/workflows.js.map +1 -1
  50. package/package.json +1 -1
@@ -434,6 +434,14 @@ export class AxonFlow {
434
434
  request_type: options.requestType,
435
435
  context: options.context || {},
436
436
  };
437
+ if (options.media && options.media.length > 0) {
438
+ agentRequest.media = options.media.map(m => ({
439
+ source: m.source,
440
+ base64_data: m.base64Data,
441
+ url: m.url,
442
+ mime_type: m.mimeType,
443
+ }));
444
+ }
437
445
  const url = `${this.config.endpoint}/api/request`;
438
446
  const headers = {
439
447
  'Content-Type': 'application/json',
@@ -533,6 +541,31 @@ export class AxonFlow {
533
541
  action: data.budget_info.action,
534
542
  };
535
543
  }
544
+ // Parse media analysis if present
545
+ if (data.media_analysis) {
546
+ result.mediaAnalysis = {
547
+ results: (data.media_analysis.results ?? []).map((r) => ({
548
+ mediaIndex: r.media_index ?? 0,
549
+ sha256Hash: r.sha256_hash ?? '',
550
+ hasFaces: r.has_faces ?? false,
551
+ faceCount: r.face_count ?? 0,
552
+ hasBiometricData: r.has_biometric_data ?? false,
553
+ nsfwScore: r.nsfw_score ?? 0,
554
+ violenceScore: r.violence_score ?? 0,
555
+ contentSafe: r.content_safe !== undefined ? r.content_safe : true,
556
+ documentType: r.document_type,
557
+ isSensitiveDocument: r.is_sensitive_document ?? false,
558
+ hasPII: r.has_pii ?? false,
559
+ piiTypes: r.pii_types,
560
+ hasExtractedText: r.has_extracted_text ?? false,
561
+ extractedTextLength: r.extracted_text_length ?? 0,
562
+ estimatedCostUsd: r.estimated_cost_usd ?? 0,
563
+ warnings: r.warnings,
564
+ })),
565
+ totalCostUsd: data.media_analysis.total_cost_usd ?? 0,
566
+ analysisTimeMs: data.media_analysis.analysis_time_ms ?? 0,
567
+ };
568
+ }
536
569
  if (this.config.debug) {
537
570
  debugLog('Proxy Mode: proxyLLMCall result', {
538
571
  success: result.success,
@@ -3264,6 +3297,25 @@ export class AxonFlow {
3264
3297
  const request = reason ? { reason } : {};
3265
3298
  await this.orchestratorRequest('POST', `/api/v1/workflows/${workflowId}/abort`, request);
3266
3299
  }
3300
+ /**
3301
+ * Fail a workflow.
3302
+ *
3303
+ * Call this when a workflow has encountered an unrecoverable error and should
3304
+ * be marked as failed. Unlike abort (which is user-initiated), fail indicates
3305
+ * the workflow could not complete due to an error condition.
3306
+ *
3307
+ * @example
3308
+ * ```typescript
3309
+ * await client.failWorkflow('wf_123', 'Step 3 exceeded retry limit');
3310
+ * ```
3311
+ */
3312
+ async failWorkflow(workflowId, reason) {
3313
+ if (!workflowId) {
3314
+ throw new ConfigurationError('Workflow ID is required');
3315
+ }
3316
+ const request = reason ? { reason } : {};
3317
+ await this.orchestratorRequest('POST', `/api/v1/workflows/${workflowId}/fail`, request);
3318
+ }
3267
3319
  /**
3268
3320
  * Mark a workflow step as completed.
3269
3321
  *
@@ -4359,6 +4411,169 @@ export class AxonFlow {
4359
4411
  const body = reason ? { reason } : {};
4360
4412
  await this.orchestratorRequest('POST', `/api/v1/unified/executions/${executionId}/cancel`, body);
4361
4413
  }
4414
+ // ===========================================================================
4415
+ // HITL (Human-in-the-Loop) Queue Methods (Enterprise)
4416
+ // ===========================================================================
4417
+ /**
4418
+ * List pending approval requests in the HITL queue.
4419
+ *
4420
+ * Returns a paginated list of approval requests that require human review.
4421
+ * Filter by status and severity to find requests that need attention.
4422
+ *
4423
+ * Enterprise Feature: Requires AxonFlow Enterprise license.
4424
+ *
4425
+ * @param options - Filter and pagination options
4426
+ * @returns Paginated list of HITL approval requests
4427
+ *
4428
+ * @example
4429
+ * ```typescript
4430
+ * // List all pending requests
4431
+ * const result = await client.listHITLQueue();
4432
+ * console.log(`${result.total} pending requests`);
4433
+ *
4434
+ * // List critical pending requests
4435
+ * const critical = await client.listHITLQueue({
4436
+ * status: 'pending',
4437
+ * severity: 'critical',
4438
+ * limit: 10
4439
+ * });
4440
+ * ```
4441
+ */
4442
+ async listHITLQueue(options) {
4443
+ const params = new URLSearchParams();
4444
+ if (options?.status) {
4445
+ params.set('status', options.status);
4446
+ }
4447
+ if (options?.severity) {
4448
+ params.set('severity', options.severity);
4449
+ }
4450
+ if (options?.limit !== undefined) {
4451
+ params.set('limit', options.limit.toString());
4452
+ }
4453
+ if (options?.offset !== undefined) {
4454
+ params.set('offset', options.offset.toString());
4455
+ }
4456
+ const queryString = params.toString();
4457
+ const path = `/api/v1/hitl/queue${queryString ? `?${queryString}` : ''}`;
4458
+ if (this.config.debug) {
4459
+ debugLog('Listing HITL queue', { options });
4460
+ }
4461
+ const response = await this.orchestratorRequest('GET', path);
4462
+ return {
4463
+ items: response.data || [],
4464
+ total: response.meta?.total ?? 0,
4465
+ has_more: (response.meta?.offset ?? 0) + (response.data?.length ?? 0) < (response.meta?.total ?? 0),
4466
+ };
4467
+ }
4468
+ /**
4469
+ * Get a specific HITL approval request by ID.
4470
+ *
4471
+ * Enterprise Feature: Requires AxonFlow Enterprise license.
4472
+ *
4473
+ * @param requestId - The approval request ID
4474
+ * @returns The approval request details
4475
+ *
4476
+ * @example
4477
+ * ```typescript
4478
+ * const request = await client.getHITLRequest('req_abc123');
4479
+ * console.log(`Query: ${request.original_query}`);
4480
+ * console.log(`Policy: ${request.triggered_policy_name}`);
4481
+ * console.log(`Severity: ${request.severity}`);
4482
+ * ```
4483
+ */
4484
+ async getHITLRequest(requestId) {
4485
+ if (!requestId) {
4486
+ throw new ConfigurationError('Request ID is required');
4487
+ }
4488
+ if (this.config.debug) {
4489
+ debugLog('Getting HITL request', { requestId });
4490
+ }
4491
+ const response = await this.orchestratorRequest('GET', `/api/v1/hitl/queue/${requestId}`);
4492
+ return response.data;
4493
+ }
4494
+ /**
4495
+ * Approve an HITL request.
4496
+ *
4497
+ * Approves the specified approval request, allowing the original query to proceed.
4498
+ *
4499
+ * Enterprise Feature: Requires AxonFlow Enterprise license.
4500
+ *
4501
+ * @param requestId - The approval request ID
4502
+ * @param review - Reviewer information and optional comment
4503
+ *
4504
+ * @example
4505
+ * ```typescript
4506
+ * await client.approveHITLRequest('req_abc123', {
4507
+ * reviewer_id: 'user_456',
4508
+ * reviewer_email: 'reviewer@example.com',
4509
+ * comment: 'Approved after verifying compliance'
4510
+ * });
4511
+ * ```
4512
+ */
4513
+ async approveHITLRequest(requestId, review) {
4514
+ if (!requestId) {
4515
+ throw new ConfigurationError('Request ID is required');
4516
+ }
4517
+ if (this.config.debug) {
4518
+ debugLog('Approving HITL request', { requestId, reviewerId: review.reviewer_id });
4519
+ }
4520
+ await this.orchestratorRequest('POST', `/api/v1/hitl/queue/${requestId}/approve`, review);
4521
+ }
4522
+ /**
4523
+ * Reject an HITL request.
4524
+ *
4525
+ * Rejects the specified approval request, blocking the original query.
4526
+ *
4527
+ * Enterprise Feature: Requires AxonFlow Enterprise license.
4528
+ *
4529
+ * @param requestId - The approval request ID
4530
+ * @param review - Reviewer information and optional comment
4531
+ *
4532
+ * @example
4533
+ * ```typescript
4534
+ * await client.rejectHITLRequest('req_abc123', {
4535
+ * reviewer_id: 'user_456',
4536
+ * reviewer_email: 'reviewer@example.com',
4537
+ * comment: 'Rejected: query contains PII data'
4538
+ * });
4539
+ * ```
4540
+ */
4541
+ async rejectHITLRequest(requestId, review) {
4542
+ if (!requestId) {
4543
+ throw new ConfigurationError('Request ID is required');
4544
+ }
4545
+ if (this.config.debug) {
4546
+ debugLog('Rejecting HITL request', { requestId, reviewerId: review.reviewer_id });
4547
+ }
4548
+ await this.orchestratorRequest('POST', `/api/v1/hitl/queue/${requestId}/reject`, review);
4549
+ }
4550
+ /**
4551
+ * Get HITL queue dashboard statistics.
4552
+ *
4553
+ * Returns summary statistics about the HITL queue including
4554
+ * pending counts, priority breakdown, and age of oldest request.
4555
+ *
4556
+ * Enterprise Feature: Requires AxonFlow Enterprise license.
4557
+ *
4558
+ * @returns HITL queue statistics
4559
+ *
4560
+ * @example
4561
+ * ```typescript
4562
+ * const stats = await client.getHITLStats();
4563
+ * console.log(`Pending: ${stats.total_pending}`);
4564
+ * console.log(`Critical: ${stats.critical_priority}`);
4565
+ * if (stats.oldest_pending_hours && stats.oldest_pending_hours > 24) {
4566
+ * console.warn('Oldest request is over 24 hours old!');
4567
+ * }
4568
+ * ```
4569
+ */
4570
+ async getHITLStats() {
4571
+ if (this.config.debug) {
4572
+ debugLog('Getting HITL stats');
4573
+ }
4574
+ const response = await this.orchestratorRequest('GET', '/api/v1/hitl/stats');
4575
+ return response.data;
4576
+ }
4362
4577
  /**
4363
4578
  * Stream real-time execution status updates via Server-Sent Events (SSE).
4364
4579
  *