@axonflow/sdk 1.1.0 → 1.2.1

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 (60) hide show
  1. package/README.md +134 -1
  2. package/dist/cjs/client.d.ts +78 -3
  3. package/dist/cjs/client.d.ts.map +1 -1
  4. package/dist/cjs/client.js +281 -57
  5. package/dist/cjs/client.js.map +1 -1
  6. package/dist/cjs/errors.d.ts +51 -0
  7. package/dist/cjs/errors.d.ts.map +1 -0
  8. package/dist/cjs/errors.js +84 -0
  9. package/dist/cjs/errors.js.map +1 -0
  10. package/dist/cjs/index.d.ts +3 -2
  11. package/dist/cjs/index.d.ts.map +1 -1
  12. package/dist/cjs/index.js +10 -2
  13. package/dist/cjs/index.js.map +1 -1
  14. package/dist/cjs/interceptors/anthropic.d.ts.map +1 -1
  15. package/dist/cjs/interceptors/anthropic.js +5 -5
  16. package/dist/cjs/interceptors/anthropic.js.map +1 -1
  17. package/dist/cjs/interceptors/openai.d.ts.map +1 -1
  18. package/dist/cjs/interceptors/openai.js +4 -4
  19. package/dist/cjs/interceptors/openai.js.map +1 -1
  20. package/dist/cjs/types/gateway.d.ts +83 -0
  21. package/dist/cjs/types/gateway.d.ts.map +1 -0
  22. package/dist/cjs/types/gateway.js +9 -0
  23. package/dist/cjs/types/gateway.js.map +1 -0
  24. package/dist/cjs/types/index.d.ts +1 -0
  25. package/dist/cjs/types/index.d.ts.map +1 -1
  26. package/dist/cjs/types/index.js +1 -0
  27. package/dist/cjs/types/index.js.map +1 -1
  28. package/dist/cjs/utils/helpers.d.ts.map +1 -1
  29. package/dist/cjs/utils/helpers.js +3 -1
  30. package/dist/cjs/utils/helpers.js.map +1 -1
  31. package/dist/esm/client.d.ts +78 -3
  32. package/dist/esm/client.d.ts.map +1 -1
  33. package/dist/esm/client.js +281 -57
  34. package/dist/esm/client.js.map +1 -1
  35. package/dist/esm/errors.d.ts +51 -0
  36. package/dist/esm/errors.d.ts.map +1 -0
  37. package/dist/esm/errors.js +75 -0
  38. package/dist/esm/errors.js.map +1 -0
  39. package/dist/esm/index.d.ts +3 -2
  40. package/dist/esm/index.d.ts.map +1 -1
  41. package/dist/esm/index.js +3 -1
  42. package/dist/esm/index.js.map +1 -1
  43. package/dist/esm/interceptors/anthropic.d.ts.map +1 -1
  44. package/dist/esm/interceptors/anthropic.js +5 -5
  45. package/dist/esm/interceptors/anthropic.js.map +1 -1
  46. package/dist/esm/interceptors/openai.d.ts.map +1 -1
  47. package/dist/esm/interceptors/openai.js +4 -4
  48. package/dist/esm/interceptors/openai.js.map +1 -1
  49. package/dist/esm/types/gateway.d.ts +83 -0
  50. package/dist/esm/types/gateway.d.ts.map +1 -0
  51. package/dist/esm/types/gateway.js +8 -0
  52. package/dist/esm/types/gateway.js.map +1 -0
  53. package/dist/esm/types/index.d.ts +1 -0
  54. package/dist/esm/types/index.d.ts.map +1 -1
  55. package/dist/esm/types/index.js +1 -0
  56. package/dist/esm/types/index.js.map +1 -1
  57. package/dist/esm/utils/helpers.d.ts.map +1 -1
  58. package/dist/esm/utils/helpers.js +3 -1
  59. package/dist/esm/utils/helpers.js.map +1 -1
  60. package/package.json +10 -5
package/README.md CHANGED
@@ -59,6 +59,48 @@ const response = await protectedOpenAI.chat.completions.create({
59
59
  });
60
60
  ```
61
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
+
62
104
  ### Legacy API Key Auth (Deprecated)
63
105
 
64
106
  > **⚠️ Deprecated**: `apiKey` authentication is deprecated. Please migrate to license-based authentication using `licenseKey`.
@@ -166,7 +208,7 @@ For customers running within AWS VPC, use the private endpoint for sub-10ms late
166
208
  ```typescript
167
209
  const axonflow = new AxonFlow({
168
210
  apiKey: 'your-client-id',
169
- endpoint: 'https://10.0.2.67:8443', // VPC private endpoint (EU)
211
+ endpoint: 'https://vpc-private-endpoint.getaxonflow.com:8443', // VPC private endpoint
170
212
  tenant: 'your-client-id',
171
213
  mode: 'production'
172
214
  });
@@ -308,6 +350,97 @@ if (resp.success) {
308
350
  }
309
351
  ```
310
352
 
353
+ ### Production Connectors (November 2025)
354
+
355
+ AxonFlow now supports **7 production-ready connectors**:
356
+
357
+ #### Salesforce CRM Connector
358
+
359
+ Query Salesforce data using SOQL:
360
+
361
+ ```typescript
362
+ // Query Salesforce contacts
363
+ const contacts = await axonflow.queryConnector(
364
+ 'salesforce-crm',
365
+ 'Find all contacts for account Acme Corp',
366
+ {
367
+ soql: "SELECT Id, Name, Email, Phone FROM Contact WHERE AccountId = '001xx000003DHP0'"
368
+ }
369
+ );
370
+
371
+ console.log(`Found ${contacts.data.length} contacts`);
372
+ ```
373
+
374
+ **Authentication:** OAuth 2.0 password grant (configured in AxonFlow dashboard)
375
+
376
+ #### Snowflake Data Warehouse Connector
377
+
378
+ Execute analytics queries on Snowflake:
379
+
380
+ ```typescript
381
+ // Query Snowflake for sales analytics
382
+ const analytics = await axonflow.queryConnector(
383
+ 'snowflake-warehouse',
384
+ 'Get monthly revenue for last 12 months',
385
+ {
386
+ sql: `SELECT DATE_TRUNC('month', order_date) as month,
387
+ COUNT(*) as orders,
388
+ SUM(amount) as revenue
389
+ FROM orders
390
+ WHERE order_date >= DATEADD(month, -12, CURRENT_DATE())
391
+ GROUP BY month
392
+ ORDER BY month`
393
+ }
394
+ );
395
+
396
+ console.log('Revenue data:', analytics.data);
397
+ ```
398
+
399
+ **Authentication:** Key-pair JWT authentication (configured in AxonFlow dashboard)
400
+
401
+ #### Slack Connector
402
+
403
+ Send notifications and alerts to Slack channels:
404
+
405
+ ```typescript
406
+ // Send Slack notification
407
+ const result = await axonflow.queryConnector(
408
+ 'slack-workspace',
409
+ 'Send deployment notification to #engineering channel',
410
+ {
411
+ channel: '#engineering',
412
+ text: '🚀 Deployment complete! All systems operational.',
413
+ blocks: [
414
+ {
415
+ type: 'section',
416
+ text: {
417
+ type: 'mrkdwn',
418
+ text: '*Deployment Status*\n✅ All systems operational'
419
+ }
420
+ }
421
+ ]
422
+ }
423
+ );
424
+
425
+ console.log('Message sent:', result.success);
426
+ ```
427
+
428
+ **Authentication:** OAuth 2.0 bot token (configured in AxonFlow dashboard)
429
+
430
+ #### Available Connectors
431
+
432
+ | Connector | Type | Use Case |
433
+ |-----------|------|----------|
434
+ | PostgreSQL | Database | Relational data access |
435
+ | Redis | Cache | Distributed rate limiting |
436
+ | Slack | Communication | Team notifications |
437
+ | Salesforce | CRM | Customer data, SOQL queries |
438
+ | Snowflake | Data Warehouse | Analytics, reporting |
439
+ | Amadeus GDS | Travel | Flight/hotel booking |
440
+ | Cassandra | NoSQL | Distributed database |
441
+
442
+ For complete connector documentation, see [https://docs.getaxonflow.com/mcp](https://docs.getaxonflow.com/mcp)
443
+
311
444
  ## Multi-Agent Planning (MAP)
312
445
 
313
446
  Generate and execute complex multi-step plans using AI agent orchestration:
@@ -1,4 +1,4 @@
1
- import { AxonFlowConfig, ConnectorMetadata, ConnectorInstallRequest, ConnectorResponse, PlanResponse, PlanExecutionResponse } from './types';
1
+ import { AxonFlowConfig, ConnectorMetadata, ConnectorInstallRequest, ConnectorResponse, PlanResponse, PlanExecutionResponse, PolicyApprovalResult, PolicyApprovalOptions, AuditResult, AuditOptions } from './types';
2
2
  /**
3
3
  * Main AxonFlow client for invisible AI governance
4
4
  */
@@ -46,15 +46,90 @@ export declare class AxonFlow {
46
46
  queryConnector(connectorName: string, query: string, params?: any): Promise<ConnectorResponse>;
47
47
  /**
48
48
  * Generate a multi-agent execution plan from a natural language query
49
+ * @param query - Natural language query describing the task
50
+ * @param domain - Optional domain hint (travel, healthcare, etc.)
51
+ * @param userToken - Optional user token for authentication (defaults to tenant/client_id)
49
52
  */
50
- generatePlan(query: string, domain?: string): Promise<PlanResponse>;
53
+ generatePlan(query: string, domain?: string, userToken?: string): Promise<PlanResponse>;
51
54
  /**
52
55
  * Execute a previously generated multi-agent plan
56
+ * @param planId - ID of the plan to execute
57
+ * @param userToken - Optional user token for authentication (defaults to tenant/client_id)
53
58
  */
54
- executePlan(planId: string): Promise<PlanExecutionResponse>;
59
+ executePlan(planId: string, userToken?: string): Promise<PlanExecutionResponse>;
55
60
  /**
56
61
  * Get the status of a running or completed plan
57
62
  */
58
63
  getPlanStatus(planId: string): Promise<PlanExecutionResponse>;
64
+ /**
65
+ * Gateway Mode: Pre-check policy approval before making a direct LLM call.
66
+ * Alias for getPolicyApprovedContext() for simpler API.
67
+ */
68
+ preCheck(options: PolicyApprovalOptions): Promise<PolicyApprovalResult>;
69
+ /**
70
+ * Gateway Mode: Get policy-approved context before making a direct LLM call.
71
+ *
72
+ * Use this when you want to:
73
+ * - Make direct LLM calls (not through AxonFlow proxy)
74
+ * - Have full control over your LLM provider/model selection
75
+ * - Minimize latency by calling LLM directly
76
+ *
77
+ * @example
78
+ * ```typescript
79
+ * const ctx = await axonflow.getPolicyApprovedContext({
80
+ * userToken: 'user-jwt',
81
+ * query: 'Analyze this customer data',
82
+ * dataSources: ['postgres']
83
+ * });
84
+ *
85
+ * if (!ctx.approved) {
86
+ * throw new Error(`Blocked: ${ctx.blockReason}`);
87
+ * }
88
+ *
89
+ * // Make direct LLM call with approved data
90
+ * const response = await openai.chat.completions.create({
91
+ * model: 'gpt-4',
92
+ * messages: [{ role: 'user', content: JSON.stringify(ctx.approvedData) }]
93
+ * });
94
+ *
95
+ * // Audit the call
96
+ * await axonflow.auditLLMCall({
97
+ * contextId: ctx.contextId,
98
+ * responseSummary: response.choices[0].message.content.substring(0, 100),
99
+ * provider: 'openai',
100
+ * model: 'gpt-4',
101
+ * tokenUsage: {
102
+ * promptTokens: response.usage.prompt_tokens,
103
+ * completionTokens: response.usage.completion_tokens,
104
+ * totalTokens: response.usage.total_tokens
105
+ * },
106
+ * latencyMs: 250
107
+ * });
108
+ * ```
109
+ */
110
+ getPolicyApprovedContext(options: PolicyApprovalOptions): Promise<PolicyApprovalResult>;
111
+ /**
112
+ * Gateway Mode: Audit an LLM call after completion.
113
+ *
114
+ * Call this after making a direct LLM call to log the audit trail.
115
+ * This is required for compliance and monitoring.
116
+ *
117
+ * @example
118
+ * ```typescript
119
+ * await axonflow.auditLLMCall({
120
+ * contextId: ctx.contextId,
121
+ * responseSummary: 'Generated report with 5 items',
122
+ * provider: 'openai',
123
+ * model: 'gpt-4',
124
+ * tokenUsage: {
125
+ * promptTokens: 100,
126
+ * completionTokens: 50,
127
+ * totalTokens: 150
128
+ * },
129
+ * latencyMs: 250
130
+ * });
131
+ * ```
132
+ */
133
+ auditLLMCall(options: AuditOptions): Promise<AuditResult>;
59
134
  }
60
135
  //# 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,q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