@axonflow/sdk 8.0.0 → 8.2.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 (40) hide show
  1. package/README.md +18 -13
  2. package/dist/cjs/client.d.ts +42 -1
  3. package/dist/cjs/client.d.ts.map +1 -1
  4. package/dist/cjs/client.js +65 -0
  5. package/dist/cjs/client.js.map +1 -1
  6. package/dist/cjs/heartbeat.d.ts +1 -1
  7. package/dist/cjs/heartbeat.js +1 -1
  8. package/dist/cjs/index.d.ts +1 -1
  9. package/dist/cjs/index.d.ts.map +1 -1
  10. package/dist/cjs/index.js.map +1 -1
  11. package/dist/cjs/telemetry.d.ts +25 -2
  12. package/dist/cjs/telemetry.d.ts.map +1 -1
  13. package/dist/cjs/telemetry.js +23 -3
  14. package/dist/cjs/telemetry.js.map +1 -1
  15. package/dist/cjs/types/config.d.ts +26 -6
  16. package/dist/cjs/types/config.d.ts.map +1 -1
  17. package/dist/cjs/types/hitl.d.ts +66 -0
  18. package/dist/cjs/types/hitl.d.ts.map +1 -1
  19. package/dist/cjs/version.d.ts +1 -1
  20. package/dist/cjs/version.js +1 -1
  21. package/dist/esm/client.d.ts +42 -1
  22. package/dist/esm/client.d.ts.map +1 -1
  23. package/dist/esm/client.js +65 -0
  24. package/dist/esm/client.js.map +1 -1
  25. package/dist/esm/heartbeat.d.ts +1 -1
  26. package/dist/esm/heartbeat.js +1 -1
  27. package/dist/esm/index.d.ts +1 -1
  28. package/dist/esm/index.d.ts.map +1 -1
  29. package/dist/esm/index.js.map +1 -1
  30. package/dist/esm/telemetry.d.ts +25 -2
  31. package/dist/esm/telemetry.d.ts.map +1 -1
  32. package/dist/esm/telemetry.js +21 -3
  33. package/dist/esm/telemetry.js.map +1 -1
  34. package/dist/esm/types/config.d.ts +26 -6
  35. package/dist/esm/types/config.d.ts.map +1 -1
  36. package/dist/esm/types/hitl.d.ts +66 -0
  37. package/dist/esm/types/hitl.d.ts.map +1 -1
  38. package/dist/esm/version.d.ts +1 -1
  39. package/dist/esm/version.js +1 -1
  40. package/package.json +1 -1
@@ -224,6 +224,11 @@ export class AxonFlow {
224
224
  // from the bundled VERSION constant; no env override (the consumer
225
225
  // doesn't get to spoof its own client identity to the agent).
226
226
  headers['X-Axonflow-Client'] = `sdk-typescript/${VERSION}`;
227
+ // X-Client-ID (v9): server-side identity decisions don't have to
228
+ // re-decode Basic auth. The agent's apiAuthMiddleware overwrites
229
+ // the header with its auth-derived value, so caller-supplied
230
+ // values are harmless (no spoofing surface).
231
+ headers['X-Client-ID'] = effectiveClientId;
227
232
  return headers;
228
233
  }
229
234
  /**
@@ -5591,6 +5596,66 @@ export class AxonFlow {
5591
5596
  has_more: (response.meta?.offset ?? 0) + (response.data?.length ?? 0) < (response.meta?.total ?? 0),
5592
5597
  };
5593
5598
  }
5599
+ /**
5600
+ * Create a new HITL approval request via `POST /api/v1/hitl/queue`.
5601
+ *
5602
+ * Enterprise Feature: Requires AxonFlow Enterprise license. The
5603
+ * platform's handler returns 403 with `ErrHITLApprovalDisabledByTier`
5604
+ * when called against a community tier that hasn't enabled HITL, and
5605
+ * 401 when credentials are invalid.
5606
+ *
5607
+ * This is the explicit row-creation step for callers that detect
5608
+ * `require_approval` from a separate gate (`pre_check`,
5609
+ * `check_tool_input`, MAP plan approvals) and want the row enqueued
5610
+ * so a reviewer can act on it. After creating, either poll
5611
+ * `getHITLRequest(returned.request_id)` until terminal state, or pass
5612
+ * `notify_url` so the platform fires a signed webhook on the
5613
+ * transition (n8n Wait-node "On Webhook Call" pattern; ADK plugin
5614
+ * polling-free mode).
5615
+ *
5616
+ * @param input - Pre-populated {@link HITLCreateInput}. `client_id`,
5617
+ * `original_query`, and `request_type` are required; all other
5618
+ * fields are optional. Bad `notify_url` schemes are rejected by the
5619
+ * platform with HTTP 400; only `https://` (and `http://` for
5620
+ * self-hosted local-dev) are accepted.
5621
+ * @returns The created {@link HITLApprovalRequest} with `request_id`
5622
+ * populated.
5623
+ *
5624
+ * @example
5625
+ * ```typescript
5626
+ * const req = await client.createHITLRequest({
5627
+ * client_id: 'loan-desk',
5628
+ * original_query: 'disburse $50000 to cust-001',
5629
+ * request_type: 'adk-tool',
5630
+ * triggered_policy_id: 'loan-amount-cap',
5631
+ * triggered_policy_name: 'Loan amount cap',
5632
+ * trigger_reason: 'Disbursement above $10k requires manager approval',
5633
+ * severity: 'high',
5634
+ * notify_url: 'https://workflows.example.com/hooks/loan-approve',
5635
+ * });
5636
+ * console.log(`Created HITL approval ${req.request_id}`);
5637
+ * ```
5638
+ */
5639
+ async createHITLRequest(input) {
5640
+ if (!input?.client_id) {
5641
+ throw new ConfigurationError('client_id is required');
5642
+ }
5643
+ if (!input?.original_query) {
5644
+ throw new ConfigurationError('original_query is required');
5645
+ }
5646
+ if (!input?.request_type) {
5647
+ throw new ConfigurationError('request_type is required');
5648
+ }
5649
+ if (this.config.debug) {
5650
+ debugLog('Creating HITL request', {
5651
+ client_id: input.client_id,
5652
+ request_type: input.request_type,
5653
+ notify_url: input.notify_url,
5654
+ });
5655
+ }
5656
+ const response = await this.orchestratorRequest('POST', '/api/v1/hitl/queue', input);
5657
+ return response.data;
5658
+ }
5594
5659
  /**
5595
5660
  * Get a specific HITL approval request by ID.
5596
5661
  *