@axonflow/sdk 1.2.0 → 1.3.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 (101) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +313 -9
  3. package/dist/cjs/client.d.ts +106 -41
  4. package/dist/cjs/client.d.ts.map +1 -1
  5. package/dist/cjs/client.js +446 -198
  6. package/dist/cjs/client.js.map +1 -1
  7. package/dist/cjs/errors.d.ts +51 -0
  8. package/dist/cjs/errors.d.ts.map +1 -0
  9. package/dist/cjs/errors.js +84 -0
  10. package/dist/cjs/errors.js.map +1 -0
  11. package/dist/cjs/index.d.ts +6 -2
  12. package/dist/cjs/index.d.ts.map +1 -1
  13. package/dist/cjs/index.js +16 -2
  14. package/dist/cjs/index.js.map +1 -1
  15. package/dist/cjs/interceptors/anthropic.d.ts +1 -1
  16. package/dist/cjs/interceptors/anthropic.d.ts.map +1 -1
  17. package/dist/cjs/interceptors/anthropic.js +6 -6
  18. package/dist/cjs/interceptors/anthropic.js.map +1 -1
  19. package/dist/cjs/interceptors/bedrock.d.ts +141 -0
  20. package/dist/cjs/interceptors/bedrock.d.ts.map +1 -0
  21. package/dist/cjs/interceptors/bedrock.js +259 -0
  22. package/dist/cjs/interceptors/bedrock.js.map +1 -0
  23. package/dist/cjs/interceptors/gemini.d.ts +81 -0
  24. package/dist/cjs/interceptors/gemini.d.ts.map +1 -0
  25. package/dist/cjs/interceptors/gemini.js +110 -0
  26. package/dist/cjs/interceptors/gemini.js.map +1 -0
  27. package/dist/cjs/interceptors/ollama.d.ts +143 -0
  28. package/dist/cjs/interceptors/ollama.d.ts.map +1 -0
  29. package/dist/cjs/interceptors/ollama.js +150 -0
  30. package/dist/cjs/interceptors/ollama.js.map +1 -0
  31. package/dist/cjs/interceptors/openai.d.ts +1 -1
  32. package/dist/cjs/interceptors/openai.d.ts.map +1 -1
  33. package/dist/cjs/interceptors/openai.js +5 -5
  34. package/dist/cjs/interceptors/openai.js.map +1 -1
  35. package/dist/cjs/types/config.d.ts +7 -1
  36. package/dist/cjs/types/config.d.ts.map +1 -1
  37. package/dist/cjs/types/gateway.d.ts +51 -114
  38. package/dist/cjs/types/gateway.d.ts.map +1 -1
  39. package/dist/cjs/types/gateway.js +2 -7
  40. package/dist/cjs/types/gateway.js.map +1 -1
  41. package/dist/cjs/types/index.d.ts +1 -0
  42. package/dist/cjs/types/index.d.ts.map +1 -1
  43. package/dist/cjs/types/index.js +1 -0
  44. package/dist/cjs/types/index.js.map +1 -1
  45. package/dist/cjs/types/proxy.d.ts +78 -0
  46. package/dist/cjs/types/proxy.d.ts.map +1 -0
  47. package/dist/cjs/types/proxy.js +9 -0
  48. package/dist/cjs/types/proxy.js.map +1 -0
  49. package/dist/cjs/utils/helpers.d.ts.map +1 -1
  50. package/dist/cjs/utils/helpers.js +3 -1
  51. package/dist/cjs/utils/helpers.js.map +1 -1
  52. package/dist/esm/client.d.ts +106 -41
  53. package/dist/esm/client.d.ts.map +1 -1
  54. package/dist/esm/client.js +446 -198
  55. package/dist/esm/client.js.map +1 -1
  56. package/dist/esm/errors.d.ts +51 -0
  57. package/dist/esm/errors.d.ts.map +1 -0
  58. package/dist/esm/errors.js +75 -0
  59. package/dist/esm/errors.js.map +1 -0
  60. package/dist/esm/index.d.ts +6 -2
  61. package/dist/esm/index.d.ts.map +1 -1
  62. package/dist/esm/index.js +6 -1
  63. package/dist/esm/index.js.map +1 -1
  64. package/dist/esm/interceptors/anthropic.d.ts +1 -1
  65. package/dist/esm/interceptors/anthropic.d.ts.map +1 -1
  66. package/dist/esm/interceptors/anthropic.js +6 -6
  67. package/dist/esm/interceptors/anthropic.js.map +1 -1
  68. package/dist/esm/interceptors/bedrock.d.ts +141 -0
  69. package/dist/esm/interceptors/bedrock.d.ts.map +1 -0
  70. package/dist/esm/interceptors/bedrock.js +220 -0
  71. package/dist/esm/interceptors/bedrock.js.map +1 -0
  72. package/dist/esm/interceptors/gemini.d.ts +81 -0
  73. package/dist/esm/interceptors/gemini.d.ts.map +1 -0
  74. package/dist/esm/interceptors/gemini.js +105 -0
  75. package/dist/esm/interceptors/gemini.js.map +1 -0
  76. package/dist/esm/interceptors/ollama.d.ts +143 -0
  77. package/dist/esm/interceptors/ollama.d.ts.map +1 -0
  78. package/dist/esm/interceptors/ollama.js +144 -0
  79. package/dist/esm/interceptors/ollama.js.map +1 -0
  80. package/dist/esm/interceptors/openai.d.ts +1 -1
  81. package/dist/esm/interceptors/openai.d.ts.map +1 -1
  82. package/dist/esm/interceptors/openai.js +5 -5
  83. package/dist/esm/interceptors/openai.js.map +1 -1
  84. package/dist/esm/types/config.d.ts +7 -1
  85. package/dist/esm/types/config.d.ts.map +1 -1
  86. package/dist/esm/types/gateway.d.ts +51 -114
  87. package/dist/esm/types/gateway.d.ts.map +1 -1
  88. package/dist/esm/types/gateway.js +2 -7
  89. package/dist/esm/types/gateway.js.map +1 -1
  90. package/dist/esm/types/index.d.ts +1 -0
  91. package/dist/esm/types/index.d.ts.map +1 -1
  92. package/dist/esm/types/index.js +1 -0
  93. package/dist/esm/types/index.js.map +1 -1
  94. package/dist/esm/types/proxy.d.ts +78 -0
  95. package/dist/esm/types/proxy.d.ts.map +1 -0
  96. package/dist/esm/types/proxy.js +8 -0
  97. package/dist/esm/types/proxy.js.map +1 -0
  98. package/dist/esm/utils/helpers.d.ts.map +1 -1
  99. package/dist/esm/utils/helpers.js +3 -1
  100. package/dist/esm/utils/helpers.js.map +1 -1
  101. package/package.json +22 -7
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 AxonFlow
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # AxonFlow SDK for TypeScript
2
2
 
3
+ [![npm version](https://img.shields.io/npm/v/@axonflow/sdk.svg)](https://www.npmjs.com/package/@axonflow/sdk)
4
+ [![npm downloads](https://img.shields.io/npm/dm/@axonflow/sdk.svg)](https://www.npmjs.com/package/@axonflow/sdk)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.0-blue.svg)](https://www.typescriptlang.org/)
7
+
3
8
  Add invisible AI governance to your applications in 3 lines of code. No UI changes. No user training. Just drop-in enterprise protection.
4
9
 
5
10
  ## Installation
@@ -10,7 +15,7 @@ npm install @axonflow/sdk
10
15
 
11
16
  ## Quick Start
12
17
 
13
- ### Basic Usage
18
+ ### Basic Usage (License-Based Auth)
14
19
 
15
20
  ```typescript
16
21
  import { AxonFlow } from '@axonflow/sdk';
@@ -19,8 +24,10 @@ import OpenAI from 'openai';
19
24
  // Initialize your AI client as usual
20
25
  const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
21
26
 
22
- // Add AxonFlow governance (3 lines)
23
- const axonflow = new AxonFlow({ apiKey: process.env.AXONFLOW_API_KEY });
27
+ // Add AxonFlow governance with license key (recommended)
28
+ const axonflow = new AxonFlow({
29
+ licenseKey: process.env.AXONFLOW_LICENSE_KEY
30
+ });
24
31
 
25
32
  // Wrap any AI call with protect()
26
33
  const response = await axonflow.protect(async () => {
@@ -38,7 +45,9 @@ import { AxonFlow, wrapOpenAIClient } from '@axonflow/sdk';
38
45
  import OpenAI from 'openai';
39
46
 
40
47
  const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
41
- const axonflow = new AxonFlow({ apiKey: process.env.AXONFLOW_API_KEY });
48
+ const axonflow = new AxonFlow({
49
+ licenseKey: process.env.AXONFLOW_LICENSE_KEY
50
+ });
42
51
 
43
52
  // Wrap the entire client - all calls are now protected
44
53
  const protectedOpenAI = wrapOpenAIClient(openai, axonflow);
@@ -50,13 +59,185 @@ const response = await protectedOpenAI.chat.completions.create({
50
59
  });
51
60
  ```
52
61
 
62
+ ### Self-Hosted Mode (No License Required)
63
+
64
+ Connect to a self-hosted AxonFlow instance running via docker-compose:
65
+
66
+ ```typescript
67
+ import { AxonFlow } from '@axonflow/sdk';
68
+ import OpenAI from 'openai';
69
+
70
+ const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
71
+
72
+ // Self-hosted (localhost) - no license key needed!
73
+ const axonflow = new AxonFlow({
74
+ endpoint: 'http://localhost:8081'
75
+ // That's it - no authentication required for localhost
76
+ });
77
+
78
+ // Use normally - same features as production
79
+ const response = await axonflow.protect(async () => {
80
+ return openai.chat.completions.create({
81
+ model: 'gpt-4',
82
+ messages: [{ role: 'user', content: 'Test with self-hosted AxonFlow' }]
83
+ });
84
+ });
85
+ ```
86
+
87
+ **Self-hosted deployment:**
88
+ ```bash
89
+ # Clone and start AxonFlow
90
+ git clone https://github.com/getaxonflow/axonflow.git
91
+ cd axonflow
92
+ export OPENAI_API_KEY=sk-your-key-here
93
+ docker-compose up
94
+
95
+ # SDK connects to http://localhost:8081 - no license needed!
96
+ ```
97
+
98
+ **Features:**
99
+ - ✅ Full AxonFlow features without license
100
+ - ✅ Perfect for local development and testing
101
+ - ✅ Same API as production
102
+ - ✅ Automatically detects localhost and skips authentication
103
+
104
+ ### Legacy API Key Auth (Deprecated)
105
+
106
+ > **⚠️ Deprecated**: `apiKey` authentication is deprecated. Please migrate to license-based authentication using `licenseKey`.
107
+
108
+ ```typescript
109
+ // Legacy method (still supported for backward compatibility)
110
+ const axonflow = new AxonFlow({ apiKey: process.env.AXONFLOW_API_KEY });
111
+ ```
112
+
113
+ ## Proxy Mode (executeQuery)
114
+
115
+ Proxy Mode routes all requests through AxonFlow's `/api/request` endpoint, providing a simpler integration pattern with automatic policy enforcement:
116
+
117
+ ### Basic Query Execution
118
+
119
+ ```typescript
120
+ import { AxonFlow, PolicyViolationError } from '@axonflow/sdk';
121
+
122
+ const axonflow = new AxonFlow({
123
+ licenseKey: process.env.AXONFLOW_LICENSE_KEY
124
+ });
125
+
126
+ // Execute a chat query with policy enforcement
127
+ const response = await axonflow.executeQuery({
128
+ userToken: 'user-123',
129
+ query: 'Explain quantum computing in simple terms',
130
+ requestType: 'chat',
131
+ context: {
132
+ provider: 'openai',
133
+ model: 'gpt-4'
134
+ }
135
+ });
136
+
137
+ if (response.success) {
138
+ console.log('Response:', response.data);
139
+ console.log('Policies evaluated:', response.policyInfo?.policiesEvaluated);
140
+ }
141
+ ```
142
+
143
+ ### Handling Policy Violations
144
+
145
+ ```typescript
146
+ try {
147
+ await axonflow.executeQuery({
148
+ userToken: 'user-123',
149
+ query: 'Process this SSN: 123-45-6789',
150
+ requestType: 'chat'
151
+ });
152
+ } catch (error) {
153
+ if (error instanceof PolicyViolationError) {
154
+ console.log('Request blocked:', error.blockReason);
155
+ console.log('Violating policies:', error.policies);
156
+ }
157
+ }
158
+ ```
159
+
160
+ ### SQL Query Governance
161
+
162
+ ```typescript
163
+ // SQL queries get additional injection detection
164
+ const sqlResponse = await axonflow.executeQuery({
165
+ userToken: 'analyst-user',
166
+ query: 'SELECT name, email FROM customers WHERE status = active LIMIT 100',
167
+ requestType: 'sql'
168
+ });
169
+ ```
170
+
171
+ ### Health Check
172
+
173
+ ```typescript
174
+ // Check if AxonFlow agent is healthy
175
+ const health = await axonflow.healthCheck();
176
+
177
+ if (health.status === 'healthy') {
178
+ console.log('Agent version:', health.version);
179
+ console.log('Uptime:', health.uptime);
180
+ } else {
181
+ console.warn('Agent status:', health.status);
182
+ }
183
+ ```
184
+
185
+ ### Request Types
186
+
187
+ | Request Type | Description |
188
+ |--------------|-------------|
189
+ | `chat` | General chat/LLM queries |
190
+ | `sql` | SQL queries (with injection detection) |
191
+ | `mcp-query` | MCP connector queries |
192
+ | `multi-agent-plan` | Generate multi-agent plans |
193
+ | `execute-plan` | Execute a generated plan |
194
+
195
+ ## Gateway Mode (Direct LLM Calls)
196
+
197
+ Gateway Mode is for advanced users who want to make direct LLM calls while still getting policy enforcement:
198
+
199
+ ```typescript
200
+ // Step 1: Pre-check policies
201
+ const ctx = await axonflow.getPolicyApprovedContext({
202
+ userToken: 'user-jwt',
203
+ query: 'Analyze customer data',
204
+ dataSources: ['postgres']
205
+ });
206
+
207
+ if (!ctx.approved) {
208
+ throw new Error(`Blocked: ${ctx.blockReason}`);
209
+ }
210
+
211
+ // Step 2: Make direct LLM call with approved data
212
+ const llmResponse = await openai.chat.completions.create({
213
+ model: 'gpt-4',
214
+ messages: [{ role: 'user', content: JSON.stringify(ctx.approvedData) }]
215
+ });
216
+
217
+ // Step 3: Audit the call
218
+ await axonflow.auditLLMCall({
219
+ contextId: ctx.contextId,
220
+ responseSummary: llmResponse.choices[0].message.content.substring(0, 100),
221
+ provider: 'openai',
222
+ model: 'gpt-4',
223
+ tokenUsage: {
224
+ promptTokens: llmResponse.usage.prompt_tokens,
225
+ completionTokens: llmResponse.usage.completion_tokens,
226
+ totalTokens: llmResponse.usage.total_tokens
227
+ },
228
+ latencyMs: 250
229
+ });
230
+ ```
231
+
53
232
  ## React Example
54
233
 
55
234
  ```tsx
56
235
  import { AxonFlow } from '@axonflow/sdk';
57
236
  import { useState } from 'react';
58
237
 
59
- const axonflow = new AxonFlow({ apiKey: 'your-key' });
238
+ const axonflow = new AxonFlow({
239
+ licenseKey: process.env.REACT_APP_AXONFLOW_LICENSE_KEY
240
+ });
60
241
 
61
242
  function ChatComponent() {
62
243
  const [response, setResponse] = useState('');
@@ -88,7 +269,9 @@ import { AxonFlow } from '@axonflow/sdk';
88
269
  import OpenAI from 'openai';
89
270
 
90
271
  const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
91
- const axonflow = new AxonFlow({ apiKey: process.env.AXONFLOW_API_KEY });
272
+ const axonflow = new AxonFlow({
273
+ licenseKey: process.env.AXONFLOW_LICENSE_KEY
274
+ });
92
275
 
93
276
  export default async function handler(req, res) {
94
277
  const { prompt } = req.body;
@@ -144,7 +327,7 @@ For customers running within AWS VPC, use the private endpoint for sub-10ms late
144
327
  ```typescript
145
328
  const axonflow = new AxonFlow({
146
329
  apiKey: 'your-client-id',
147
- endpoint: 'https://10.0.2.67:8443', // VPC private endpoint (EU)
330
+ endpoint: 'https://vpc-private-endpoint.getaxonflow.com:8443', // VPC private endpoint
148
331
  tenant: 'your-client-id',
149
332
  mode: 'production'
150
333
  });
@@ -286,6 +469,97 @@ if (resp.success) {
286
469
  }
287
470
  ```
288
471
 
472
+ ### Production Connectors (November 2025)
473
+
474
+ AxonFlow now supports **7 production-ready connectors**:
475
+
476
+ #### Salesforce CRM Connector
477
+
478
+ Query Salesforce data using SOQL:
479
+
480
+ ```typescript
481
+ // Query Salesforce contacts
482
+ const contacts = await axonflow.queryConnector(
483
+ 'salesforce-crm',
484
+ 'Find all contacts for account Acme Corp',
485
+ {
486
+ soql: "SELECT Id, Name, Email, Phone FROM Contact WHERE AccountId = '001xx000003DHP0'"
487
+ }
488
+ );
489
+
490
+ console.log(`Found ${contacts.data.length} contacts`);
491
+ ```
492
+
493
+ **Authentication:** OAuth 2.0 password grant (configured in AxonFlow dashboard)
494
+
495
+ #### Snowflake Data Warehouse Connector
496
+
497
+ Execute analytics queries on Snowflake:
498
+
499
+ ```typescript
500
+ // Query Snowflake for sales analytics
501
+ const analytics = await axonflow.queryConnector(
502
+ 'snowflake-warehouse',
503
+ 'Get monthly revenue for last 12 months',
504
+ {
505
+ sql: `SELECT DATE_TRUNC('month', order_date) as month,
506
+ COUNT(*) as orders,
507
+ SUM(amount) as revenue
508
+ FROM orders
509
+ WHERE order_date >= DATEADD(month, -12, CURRENT_DATE())
510
+ GROUP BY month
511
+ ORDER BY month`
512
+ }
513
+ );
514
+
515
+ console.log('Revenue data:', analytics.data);
516
+ ```
517
+
518
+ **Authentication:** Key-pair JWT authentication (configured in AxonFlow dashboard)
519
+
520
+ #### Slack Connector
521
+
522
+ Send notifications and alerts to Slack channels:
523
+
524
+ ```typescript
525
+ // Send Slack notification
526
+ const result = await axonflow.queryConnector(
527
+ 'slack-workspace',
528
+ 'Send deployment notification to #engineering channel',
529
+ {
530
+ channel: '#engineering',
531
+ text: '🚀 Deployment complete! All systems operational.',
532
+ blocks: [
533
+ {
534
+ type: 'section',
535
+ text: {
536
+ type: 'mrkdwn',
537
+ text: '*Deployment Status*\n✅ All systems operational'
538
+ }
539
+ }
540
+ ]
541
+ }
542
+ );
543
+
544
+ console.log('Message sent:', result.success);
545
+ ```
546
+
547
+ **Authentication:** OAuth 2.0 bot token (configured in AxonFlow dashboard)
548
+
549
+ #### Available Connectors
550
+
551
+ | Connector | Type | Use Case |
552
+ |-----------|------|----------|
553
+ | PostgreSQL | Database | Relational data access |
554
+ | Redis | Cache | Distributed rate limiting |
555
+ | Slack | Communication | Team notifications |
556
+ | Salesforce | CRM | Customer data, SOQL queries |
557
+ | Snowflake | Data Warehouse | Analytics, reporting |
558
+ | Amadeus GDS | Travel | Flight/hotel booking |
559
+ | Cassandra | NoSQL | Distributed database |
560
+
561
+ For complete connector documentation, see [https://docs.getaxonflow.com/mcp](https://docs.getaxonflow.com/mcp)
562
+
289
563
  ## Multi-Agent Planning (MAP)
290
564
 
291
565
  Generate and execute complex multi-step plans using AI agent orchestration:
@@ -351,9 +625,9 @@ if (status.status === 'running') {
351
625
  import { AxonFlow } from '@axonflow/sdk';
352
626
 
353
627
  async function planTrip() {
354
- // Initialize client
628
+ // Initialize client with license key
355
629
  const axonflow = new AxonFlow({
356
- apiKey: process.env.AXONFLOW_API_KEY,
630
+ licenseKey: process.env.AXONFLOW_LICENSE_KEY,
357
631
  debug: true
358
632
  });
359
633
 
@@ -381,6 +655,36 @@ async function planTrip() {
381
655
  planTrip().catch(console.error);
382
656
  ```
383
657
 
658
+ ## Migration Guide
659
+
660
+ ### Migrating from API Key to License Key
661
+
662
+ If you're currently using `apiKey` authentication, migrate to license-based authentication:
663
+
664
+ **Before:**
665
+ ```typescript
666
+ const axonflow = new AxonFlow({
667
+ apiKey: process.env.AXONFLOW_API_KEY
668
+ });
669
+ ```
670
+
671
+ **After:**
672
+ ```typescript
673
+ const axonflow = new AxonFlow({
674
+ licenseKey: process.env.AXONFLOW_LICENSE_KEY
675
+ });
676
+ ```
677
+
678
+ **How to get a license key:**
679
+ 1. Contact AxonFlow support at [dev@getaxonflow.com](mailto:dev@getaxonflow.com)
680
+ 2. License keys are provided as part of your AxonFlow subscription
681
+ 3. Store keys securely in environment variables or secrets management systems
682
+
683
+ **Backward Compatibility:**
684
+ - The SDK maintains full backward compatibility with `apiKey`
685
+ - No breaking changes - existing code continues to work
686
+ - You can migrate at your own pace
687
+
384
688
  ## License
385
689
 
386
690
  MIT
@@ -1,4 +1,4 @@
1
- import { AxonFlowConfig, ConnectorMetadata, ConnectorInstallRequest, ConnectorResponse, PlanResponse, PlanExecutionResponse, PreCheckRequest, PolicyApprovalResult, TokenUsage, AuditResult } from './types';
1
+ import { AxonFlowConfig, ConnectorMetadata, ConnectorInstallRequest, ConnectorResponse, PlanResponse, PlanExecutionResponse, PolicyApprovalResult, PolicyApprovalOptions, AuditResult, AuditOptions, ExecuteQueryOptions, ExecuteQueryResponse, HealthStatus } from './types';
2
2
  /**
3
3
  * Main AxonFlow client for invisible AI governance
4
4
  */
@@ -32,6 +32,47 @@ export declare class AxonFlow {
32
32
  * Create a sandbox client for testing
33
33
  */
34
34
  static sandbox(apiKey?: string): AxonFlow;
35
+ /**
36
+ * Check if AxonFlow Agent is healthy and available.
37
+ *
38
+ * @returns HealthStatus object with agent health information
39
+ *
40
+ * @example
41
+ * ```typescript
42
+ * const health = await axonflow.healthCheck();
43
+ * if (health.status === 'healthy') {
44
+ * console.log('Agent is healthy');
45
+ * }
46
+ * ```
47
+ */
48
+ healthCheck(): Promise<HealthStatus>;
49
+ /**
50
+ * Execute a query through AxonFlow with policy enforcement (Proxy Mode).
51
+ *
52
+ * This is the primary method for Proxy Mode, where AxonFlow handles policy
53
+ * checking and optionally routes requests to LLM providers.
54
+ *
55
+ * @param options - Query execution options
56
+ * @returns ExecuteQueryResponse with results or error information
57
+ * @throws PolicyViolationError if request is blocked by policy
58
+ * @throws AuthenticationError if credentials are invalid
59
+ * @throws APIError for other API errors
60
+ *
61
+ * @example
62
+ * ```typescript
63
+ * const response = await axonflow.executeQuery({
64
+ * userToken: 'user-123',
65
+ * query: 'Explain quantum computing',
66
+ * requestType: 'chat',
67
+ * context: { provider: 'openai', model: 'gpt-4' }
68
+ * });
69
+ *
70
+ * if (response.success) {
71
+ * console.log('Response:', response.data);
72
+ * }
73
+ * ```
74
+ */
75
+ executeQuery(options: ExecuteQueryOptions): Promise<ExecuteQueryResponse>;
35
76
  /**
36
77
  * List all available MCP connectors from the marketplace
37
78
  */
@@ -46,66 +87,90 @@ export declare class AxonFlow {
46
87
  queryConnector(connectorName: string, query: string, params?: any): Promise<ConnectorResponse>;
47
88
  /**
48
89
  * Generate a multi-agent execution plan from a natural language query
90
+ * @param query - Natural language query describing the task
91
+ * @param domain - Optional domain hint (travel, healthcare, etc.)
92
+ * @param userToken - Optional user token for authentication (defaults to tenant/client_id)
49
93
  */
50
- generatePlan(query: string, domain?: string): Promise<PlanResponse>;
94
+ generatePlan(query: string, domain?: string, userToken?: string): Promise<PlanResponse>;
51
95
  /**
52
96
  * Execute a previously generated multi-agent plan
97
+ * @param planId - ID of the plan to execute
98
+ * @param userToken - Optional user token for authentication (defaults to tenant/client_id)
53
99
  */
54
- executePlan(planId: string): Promise<PlanExecutionResponse>;
100
+ executePlan(planId: string, userToken?: string): Promise<PlanExecutionResponse>;
55
101
  /**
56
102
  * Get the status of a running or completed plan
57
103
  */
58
104
  getPlanStatus(planId: string): Promise<PlanExecutionResponse>;
59
105
  /**
60
- * Perform policy pre-check before making LLM call
61
- *
62
- * This is the first step in Gateway Mode. Call this before making your
63
- * LLM call to ensure policy compliance.
106
+ * Gateway Mode: Pre-check policy approval before making a direct LLM call.
107
+ * Alias for getPolicyApprovedContext() for simpler API.
108
+ */
109
+ preCheck(options: PolicyApprovalOptions): Promise<PolicyApprovalResult>;
110
+ /**
111
+ * Gateway Mode: Get policy-approved context before making a direct LLM call.
64
112
  *
65
- * @param request Pre-check request containing user token, query, and optional data sources
66
- * @returns PolicyApprovalResult with context ID and approved data (if any)
113
+ * Use this when you want to:
114
+ * - Make direct LLM calls (not through AxonFlow proxy)
115
+ * - Have full control over your LLM provider/model selection
116
+ * - Minimize latency by calling LLM directly
67
117
  *
68
118
  * @example
69
- * const result = await axonflow.getPolicyApprovedContext({
70
- * userToken: 'user-jwt-token',
71
- * dataSources: ['postgres', 'salesforce'],
72
- * query: 'Find all patients with recent lab results'
119
+ * ```typescript
120
+ * const ctx = await axonflow.getPolicyApprovedContext({
121
+ * userToken: 'user-jwt',
122
+ * query: 'Analyze this customer data',
123
+ * dataSources: ['postgres']
73
124
  * });
74
125
  *
75
- * if (!result.approved) {
76
- * throw new Error(`Request blocked: ${result.blockReason}`);
126
+ * if (!ctx.approved) {
127
+ * throw new Error(`Blocked: ${ctx.blockReason}`);
77
128
  * }
78
129
  *
79
- * // Use result.approvedData to build your LLM prompt
80
- * const prompt = buildPrompt(result.approvedData);
130
+ * // Make direct LLM call with approved data
131
+ * const response = await openai.chat.completions.create({
132
+ * model: 'gpt-4',
133
+ * messages: [{ role: 'user', content: JSON.stringify(ctx.approvedData) }]
134
+ * });
135
+ *
136
+ * // Audit the call
137
+ * await axonflow.auditLLMCall({
138
+ * contextId: ctx.contextId,
139
+ * responseSummary: response.choices[0].message.content.substring(0, 100),
140
+ * provider: 'openai',
141
+ * model: 'gpt-4',
142
+ * tokenUsage: {
143
+ * promptTokens: response.usage.prompt_tokens,
144
+ * completionTokens: response.usage.completion_tokens,
145
+ * totalTokens: response.usage.total_tokens
146
+ * },
147
+ * latencyMs: 250
148
+ * });
149
+ * ```
81
150
  */
82
- getPolicyApprovedContext(request: PreCheckRequest): Promise<PolicyApprovalResult>;
151
+ getPolicyApprovedContext(options: PolicyApprovalOptions): Promise<PolicyApprovalResult>;
83
152
  /**
84
- * Report LLM call details for audit logging
153
+ * Gateway Mode: Audit an LLM call after completion.
85
154
  *
86
- * This is the second step in Gateway Mode. Call this after making your
87
- * LLM call to record it in the audit trail.
88
- *
89
- * @param contextId Context ID from getPolicyApprovedContext()
90
- * @param responseSummary Brief summary of the LLM response (not full response)
91
- * @param provider LLM provider name
92
- * @param model Model name
93
- * @param tokenUsage Token counts from LLM response
94
- * @param latencyMs Time taken for LLM call in milliseconds
95
- * @param metadata Optional additional metadata
96
- * @returns AuditResult confirming the audit was recorded
155
+ * Call this after making a direct LLM call to log the audit trail.
156
+ * This is required for compliance and monitoring.
97
157
  *
98
158
  * @example
99
- * const result = await axonflow.auditLLMCall(
100
- * ctx.contextId,
101
- * 'Found 5 patients with recent lab results',
102
- * 'openai',
103
- * 'gpt-4',
104
- * { promptTokens: 100, completionTokens: 50, totalTokens: 150 },
105
- * 250,
106
- * { sessionId: 'session-123' }
107
- * );
108
- */
109
- auditLLMCall(contextId: string, responseSummary: string, provider: string, model: string, tokenUsage: TokenUsage, latencyMs: number, metadata?: Record<string, any>): Promise<AuditResult>;
159
+ * ```typescript
160
+ * await axonflow.auditLLMCall({
161
+ * contextId: ctx.contextId,
162
+ * responseSummary: 'Generated report with 5 items',
163
+ * provider: 'openai',
164
+ * model: 'gpt-4',
165
+ * tokenUsage: {
166
+ * promptTokens: 100,
167
+ * completionTokens: 50,
168
+ * totalTokens: 150
169
+ * },
170
+ * latencyMs: 250
171
+ * });
172
+ * ```
173
+ */
174
+ auditLLMCall(options: AuditOptions): Promise<AuditResult>;
110
175
  }
111
176
  //# sourceMappingURL=client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EAId,iBAAiB,EACjB,uBAAuB,EACvB,iBAAiB,EACjB,YAAY,EACZ,qBAAqB,EACrB,eAAe,EACf,oBAAoB,EACpB,UAAU,EACV,WAAW,EACZ,MAAM,SAAS,CAAC;AAMjB;;GAEG;AACH,qBAAa,QAAQ;IACnB,OAAO,CAAC,MAAM,CAA2B;IACzC,OAAO,CAAC,YAAY,CAAyB;gBAEjC,MAAM,EAAE,cAAc;IAwBlC;;;;OAIG;IACG,OAAO,CAAC,CAAC,GAAG,GAAG,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAqD5D;;OAEG;YACW,cAAc;IAiB5B;;OAEG;YACW,aAAa;IAuD3B;;OAEG;YACW,QAAQ;IAYtB;;OAEG;IACH,OAAO,CAAC,eAAe;IAMvB;;OAEG;IACH,MAAM,CAAC,OAAO,CAAC,MAAM,GAAE,MAAmB,GAAG,QAAQ;IASrD;;OAEG;IACG,cAAc,IAAI,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAqBpD;;OAEG;IACG,gBAAgB,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC;IAuBvE;;OAEG;IACG,cAAc,CAAC,aAAa,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,iBAAiB,CAAC;IA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