@axonflow/sdk 1.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.
- package/LICENSE +21 -0
- package/README.md +386 -0
- package/dist/cjs/client.d.ts +60 -0
- package/dist/cjs/client.d.ts.map +1 -0
- package/dist/cjs/client.js +364 -0
- package/dist/cjs/client.js.map +1 -0
- package/dist/cjs/index.d.ts +22 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +29 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/interceptors/anthropic.d.ts +16 -0
- package/dist/cjs/interceptors/anthropic.d.ts.map +1 -0
- package/dist/cjs/interceptors/anthropic.js +74 -0
- package/dist/cjs/interceptors/anthropic.js.map +1 -0
- package/dist/cjs/interceptors/base.d.ts +23 -0
- package/dist/cjs/interceptors/base.d.ts.map +1 -0
- package/dist/cjs/interceptors/base.js +10 -0
- package/dist/cjs/interceptors/base.js.map +1 -0
- package/dist/cjs/interceptors/openai.d.ts +16 -0
- package/dist/cjs/interceptors/openai.d.ts.map +1 -0
- package/dist/cjs/interceptors/openai.js +73 -0
- package/dist/cjs/interceptors/openai.js.map +1 -0
- package/dist/cjs/types/config.d.ts +62 -0
- package/dist/cjs/types/config.d.ts.map +1 -0
- package/dist/cjs/types/config.js +3 -0
- package/dist/cjs/types/config.js.map +1 -0
- package/dist/cjs/types/connector.d.ts +31 -0
- package/dist/cjs/types/connector.d.ts.map +1 -0
- package/dist/cjs/types/connector.js +6 -0
- package/dist/cjs/types/connector.js.map +1 -0
- package/dist/cjs/types/index.d.ts +7 -0
- package/dist/cjs/types/index.d.ts.map +1 -0
- package/dist/cjs/types/index.js +23 -0
- package/dist/cjs/types/index.js.map +1 -0
- package/dist/cjs/types/planning.d.ts +29 -0
- package/dist/cjs/types/planning.d.ts.map +1 -0
- package/dist/cjs/types/planning.js +6 -0
- package/dist/cjs/types/planning.js.map +1 -0
- package/dist/cjs/types/policy.d.ts +48 -0
- package/dist/cjs/types/policy.d.ts.map +1 -0
- package/dist/cjs/types/policy.js +3 -0
- package/dist/cjs/types/policy.js.map +1 -0
- package/dist/cjs/types/request.d.ts +56 -0
- package/dist/cjs/types/request.d.ts.map +1 -0
- package/dist/cjs/types/request.js +3 -0
- package/dist/cjs/types/request.js.map +1 -0
- package/dist/cjs/types/response.d.ts +82 -0
- package/dist/cjs/types/response.d.ts.map +1 -0
- package/dist/cjs/types/response.js +3 -0
- package/dist/cjs/types/response.js.map +1 -0
- package/dist/cjs/utils/helpers.d.ts +25 -0
- package/dist/cjs/utils/helpers.d.ts.map +1 -0
- package/dist/cjs/utils/helpers.js +54 -0
- package/dist/cjs/utils/helpers.js.map +1 -0
- package/dist/esm/client.d.ts +60 -0
- package/dist/esm/client.d.ts.map +1 -0
- package/dist/esm/client.js +360 -0
- package/dist/esm/client.js.map +1 -0
- package/dist/esm/index.d.ts +22 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +23 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/interceptors/anthropic.d.ts +16 -0
- package/dist/esm/interceptors/anthropic.d.ts.map +1 -0
- package/dist/esm/interceptors/anthropic.js +69 -0
- package/dist/esm/interceptors/anthropic.js.map +1 -0
- package/dist/esm/interceptors/base.d.ts +23 -0
- package/dist/esm/interceptors/base.d.ts.map +1 -0
- package/dist/esm/interceptors/base.js +6 -0
- package/dist/esm/interceptors/base.js.map +1 -0
- package/dist/esm/interceptors/openai.d.ts +16 -0
- package/dist/esm/interceptors/openai.d.ts.map +1 -0
- package/dist/esm/interceptors/openai.js +68 -0
- package/dist/esm/interceptors/openai.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/types/config.d.ts +62 -0
- package/dist/esm/types/config.d.ts.map +1 -0
- package/dist/esm/types/config.js +2 -0
- package/dist/esm/types/config.js.map +1 -0
- package/dist/esm/types/connector.d.ts +31 -0
- package/dist/esm/types/connector.d.ts.map +1 -0
- package/dist/esm/types/connector.js +5 -0
- package/dist/esm/types/connector.js.map +1 -0
- package/dist/esm/types/index.d.ts +7 -0
- package/dist/esm/types/index.d.ts.map +1 -0
- package/dist/esm/types/index.js +7 -0
- package/dist/esm/types/index.js.map +1 -0
- package/dist/esm/types/planning.d.ts +29 -0
- package/dist/esm/types/planning.d.ts.map +1 -0
- package/dist/esm/types/planning.js +5 -0
- package/dist/esm/types/planning.js.map +1 -0
- package/dist/esm/types/policy.d.ts +48 -0
- package/dist/esm/types/policy.d.ts.map +1 -0
- package/dist/esm/types/policy.js +2 -0
- package/dist/esm/types/policy.js.map +1 -0
- package/dist/esm/types/request.d.ts +56 -0
- package/dist/esm/types/request.d.ts.map +1 -0
- package/dist/esm/types/request.js +2 -0
- package/dist/esm/types/request.js.map +1 -0
- package/dist/esm/types/response.d.ts +82 -0
- package/dist/esm/types/response.d.ts.map +1 -0
- package/dist/esm/types/response.js +2 -0
- package/dist/esm/types/response.js.map +1 -0
- package/dist/esm/utils/helpers.d.ts +25 -0
- package/dist/esm/utils/helpers.d.ts.map +1 -0
- package/dist/esm/utils/helpers.js +46 -0
- package/dist/esm/utils/helpers.js.map +1 -0
- package/package.json +63 -0
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
ADDED
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
# AxonFlow SDK for TypeScript
|
|
2
|
+
|
|
3
|
+
Add invisible AI governance to your applications in 3 lines of code. No UI changes. No user training. Just drop-in enterprise protection.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @axonflow/sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
### Basic Usage
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { AxonFlow } from '@axonflow/sdk';
|
|
17
|
+
import OpenAI from 'openai';
|
|
18
|
+
|
|
19
|
+
// Initialize your AI client as usual
|
|
20
|
+
const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
|
|
21
|
+
|
|
22
|
+
// Add AxonFlow governance (3 lines)
|
|
23
|
+
const axonflow = new AxonFlow({ apiKey: process.env.AXONFLOW_API_KEY });
|
|
24
|
+
|
|
25
|
+
// Wrap any AI call with protect()
|
|
26
|
+
const response = await axonflow.protect(async () => {
|
|
27
|
+
return openai.chat.completions.create({
|
|
28
|
+
model: 'gpt-4',
|
|
29
|
+
messages: [{ role: 'user', content: 'Process this customer data...' }]
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Even Easier with Client Wrapping
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
import { AxonFlow, wrapOpenAIClient } from '@axonflow/sdk';
|
|
38
|
+
import OpenAI from 'openai';
|
|
39
|
+
|
|
40
|
+
const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
|
|
41
|
+
const axonflow = new AxonFlow({ apiKey: process.env.AXONFLOW_API_KEY });
|
|
42
|
+
|
|
43
|
+
// Wrap the entire client - all calls are now protected
|
|
44
|
+
const protectedOpenAI = wrapOpenAIClient(openai, axonflow);
|
|
45
|
+
|
|
46
|
+
// Use normally - governance happens invisibly
|
|
47
|
+
const response = await protectedOpenAI.chat.completions.create({
|
|
48
|
+
model: 'gpt-4',
|
|
49
|
+
messages: [{ role: 'user', content: 'Process this customer data...' }]
|
|
50
|
+
});
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## React Example
|
|
54
|
+
|
|
55
|
+
```tsx
|
|
56
|
+
import { AxonFlow } from '@axonflow/sdk';
|
|
57
|
+
import { useState } from 'react';
|
|
58
|
+
|
|
59
|
+
const axonflow = new AxonFlow({ apiKey: 'your-key' });
|
|
60
|
+
|
|
61
|
+
function ChatComponent() {
|
|
62
|
+
const [response, setResponse] = useState('');
|
|
63
|
+
|
|
64
|
+
const handleSubmit = async (prompt: string) => {
|
|
65
|
+
// Your existing OpenAI call, now protected
|
|
66
|
+
const result = await axonflow.protect(async () => {
|
|
67
|
+
return fetch('/api/openai', {
|
|
68
|
+
method: 'POST',
|
|
69
|
+
body: JSON.stringify({ prompt })
|
|
70
|
+
}).then(r => r.json());
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
setResponse(result.text);
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
return (
|
|
77
|
+
// Your existing UI - no changes needed
|
|
78
|
+
<div>...</div>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Next.js API Route
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
// pages/api/chat.ts
|
|
87
|
+
import { AxonFlow } from '@axonflow/sdk';
|
|
88
|
+
import OpenAI from 'openai';
|
|
89
|
+
|
|
90
|
+
const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
|
|
91
|
+
const axonflow = new AxonFlow({ apiKey: process.env.AXONFLOW_API_KEY });
|
|
92
|
+
|
|
93
|
+
export default async function handler(req, res) {
|
|
94
|
+
const { prompt } = req.body;
|
|
95
|
+
|
|
96
|
+
try {
|
|
97
|
+
// Protect the OpenAI call
|
|
98
|
+
const response = await axonflow.protect(async () => {
|
|
99
|
+
return openai.chat.completions.create({
|
|
100
|
+
model: 'gpt-3.5-turbo',
|
|
101
|
+
messages: [{ role: 'user', content: prompt }]
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
res.json({ success: true, response });
|
|
106
|
+
} catch (error) {
|
|
107
|
+
// AxonFlow will block requests that violate policies
|
|
108
|
+
res.status(403).json({ error: error.message });
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Configuration Options
|
|
114
|
+
|
|
115
|
+
```typescript
|
|
116
|
+
const axonflow = new AxonFlow({
|
|
117
|
+
apiKey: 'your-api-key', // Required (use client_id from AxonFlow)
|
|
118
|
+
|
|
119
|
+
// Optional settings
|
|
120
|
+
mode: 'production', // or 'sandbox' for testing
|
|
121
|
+
endpoint: 'https://staging-eu.getaxonflow.com', // Default public endpoint
|
|
122
|
+
tenant: 'your-tenant-id', // For multi-tenant setups (use client_id)
|
|
123
|
+
debug: true, // Enable debug logging
|
|
124
|
+
|
|
125
|
+
// Retry configuration
|
|
126
|
+
retry: {
|
|
127
|
+
enabled: true,
|
|
128
|
+
maxAttempts: 3,
|
|
129
|
+
delay: 1000
|
|
130
|
+
},
|
|
131
|
+
|
|
132
|
+
// Cache configuration
|
|
133
|
+
cache: {
|
|
134
|
+
enabled: true,
|
|
135
|
+
ttl: 60000 // 1 minute
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### VPC Private Endpoint (Low-Latency)
|
|
141
|
+
|
|
142
|
+
For customers running within AWS VPC, use the private endpoint for sub-10ms latency:
|
|
143
|
+
|
|
144
|
+
```typescript
|
|
145
|
+
const axonflow = new AxonFlow({
|
|
146
|
+
apiKey: 'your-client-id',
|
|
147
|
+
endpoint: 'https://10.0.2.67:8443', // VPC private endpoint (EU)
|
|
148
|
+
tenant: 'your-client-id',
|
|
149
|
+
mode: 'production'
|
|
150
|
+
});
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
**Performance:**
|
|
154
|
+
- Public endpoint: ~100ms (internet routing)
|
|
155
|
+
- VPC private endpoint: <10ms P99 (intra-VPC routing)
|
|
156
|
+
|
|
157
|
+
**Note:** VPC endpoints require AWS VPC peering setup with AxonFlow infrastructure.
|
|
158
|
+
|
|
159
|
+
## Sandbox Mode (Testing)
|
|
160
|
+
|
|
161
|
+
```typescript
|
|
162
|
+
// Use sandbox mode for testing without affecting production
|
|
163
|
+
const axonflow = AxonFlow.sandbox('demo-key');
|
|
164
|
+
|
|
165
|
+
// Test with aggressive policies
|
|
166
|
+
const response = await axonflow.protect(async () => {
|
|
167
|
+
return openai.chat.completions.create({
|
|
168
|
+
model: 'gpt-4',
|
|
169
|
+
messages: [{
|
|
170
|
+
role: 'user',
|
|
171
|
+
content: 'My SSN is 123-45-6789' // Will be blocked/redacted
|
|
172
|
+
}]
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## What Gets Protected?
|
|
178
|
+
|
|
179
|
+
AxonFlow automatically:
|
|
180
|
+
- **Blocks** prompts containing sensitive data (PII, credentials, etc.)
|
|
181
|
+
- **Redacts** personal information from responses
|
|
182
|
+
- **Enforces** rate limits and usage quotas
|
|
183
|
+
- **Prevents** prompt injection attacks
|
|
184
|
+
- **Logs** all requests for compliance audit trails
|
|
185
|
+
- **Monitors** costs and usage patterns
|
|
186
|
+
|
|
187
|
+
## Error Handling
|
|
188
|
+
|
|
189
|
+
```typescript
|
|
190
|
+
try {
|
|
191
|
+
const response = await axonflow.protect(() => openai.complete(prompt));
|
|
192
|
+
} catch (error) {
|
|
193
|
+
if (error.message.includes('blocked by AxonFlow')) {
|
|
194
|
+
// Request violated a policy
|
|
195
|
+
console.log('Policy violation:', error.message);
|
|
196
|
+
} else {
|
|
197
|
+
// Other errors (network, API, etc.)
|
|
198
|
+
console.error('API error:', error);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
## Production Best Practices
|
|
204
|
+
|
|
205
|
+
1. **Environment Variables**: Never hardcode API keys
|
|
206
|
+
```typescript
|
|
207
|
+
const axonflow = new AxonFlow({
|
|
208
|
+
apiKey: process.env.AXONFLOW_API_KEY
|
|
209
|
+
});
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
2. **Fail Open**: In production, AxonFlow fails open if unreachable
|
|
213
|
+
```typescript
|
|
214
|
+
// If AxonFlow is down, the original call proceeds
|
|
215
|
+
// This ensures your app stays operational
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
3. **Tenant Isolation**: Use tenant IDs for multi-tenant apps
|
|
219
|
+
```typescript
|
|
220
|
+
const axonflow = new AxonFlow({
|
|
221
|
+
apiKey: 'your-key',
|
|
222
|
+
tenant: getCurrentTenantId()
|
|
223
|
+
});
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
## Support
|
|
227
|
+
|
|
228
|
+
- Documentation: https://docs.axonflow.com
|
|
229
|
+
- Email: support@axonflow.com
|
|
230
|
+
- GitHub: https://github.com/axonflow/sdk-typescript
|
|
231
|
+
|
|
232
|
+
## MCP Connector Marketplace
|
|
233
|
+
|
|
234
|
+
Integrate with external data sources using AxonFlow's MCP (Model Context Protocol) connectors:
|
|
235
|
+
|
|
236
|
+
### List Available Connectors
|
|
237
|
+
|
|
238
|
+
```typescript
|
|
239
|
+
const connectors = await axonflow.listConnectors();
|
|
240
|
+
|
|
241
|
+
connectors.forEach(conn => {
|
|
242
|
+
console.log(`Connector: ${conn.name} (${conn.type})`);
|
|
243
|
+
console.log(` Description: ${conn.description}`);
|
|
244
|
+
console.log(` Installed: ${conn.installed}`);
|
|
245
|
+
console.log(` Capabilities: ${conn.capabilities.join(', ')}`);
|
|
246
|
+
});
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
### Install a Connector
|
|
250
|
+
|
|
251
|
+
```typescript
|
|
252
|
+
await axonflow.installConnector({
|
|
253
|
+
connector_id: 'amadeus-travel',
|
|
254
|
+
name: 'amadeus-prod',
|
|
255
|
+
tenant_id: 'your-tenant-id',
|
|
256
|
+
options: {
|
|
257
|
+
environment: 'production'
|
|
258
|
+
},
|
|
259
|
+
credentials: {
|
|
260
|
+
api_key: process.env.AMADEUS_API_KEY,
|
|
261
|
+
api_secret: process.env.AMADEUS_API_SECRET
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
console.log('Connector installed successfully!');
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
### Query a Connector
|
|
269
|
+
|
|
270
|
+
```typescript
|
|
271
|
+
// Query the Amadeus connector for flight information
|
|
272
|
+
const resp = await axonflow.queryConnector(
|
|
273
|
+
'amadeus-prod',
|
|
274
|
+
'Find flights from Paris to Amsterdam on Dec 15',
|
|
275
|
+
{
|
|
276
|
+
origin: 'CDG',
|
|
277
|
+
destination: 'AMS',
|
|
278
|
+
date: '2025-12-15'
|
|
279
|
+
}
|
|
280
|
+
);
|
|
281
|
+
|
|
282
|
+
if (resp.success) {
|
|
283
|
+
console.log('Flight data:', resp.data);
|
|
284
|
+
} else {
|
|
285
|
+
console.error('Query failed:', resp.error);
|
|
286
|
+
}
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
## Multi-Agent Planning (MAP)
|
|
290
|
+
|
|
291
|
+
Generate and execute complex multi-step plans using AI agent orchestration:
|
|
292
|
+
|
|
293
|
+
### Generate a Plan
|
|
294
|
+
|
|
295
|
+
```typescript
|
|
296
|
+
// Generate a travel planning workflow
|
|
297
|
+
const plan = await axonflow.generatePlan(
|
|
298
|
+
'Plan a 3-day trip to Paris with moderate budget',
|
|
299
|
+
'travel' // Domain hint (optional)
|
|
300
|
+
);
|
|
301
|
+
|
|
302
|
+
console.log(`Generated plan ${plan.planId} with ${plan.steps.length} steps`);
|
|
303
|
+
console.log(`Complexity: ${plan.complexity}, Parallel: ${plan.parallel}`);
|
|
304
|
+
|
|
305
|
+
plan.steps.forEach((step, i) => {
|
|
306
|
+
console.log(` Step ${i + 1}: ${step.name} (${step.type})`);
|
|
307
|
+
console.log(` Description: ${step.description}`);
|
|
308
|
+
console.log(` Agent: ${step.agent}`);
|
|
309
|
+
if (step.dependsOn.length > 0) {
|
|
310
|
+
console.log(` Depends on: ${step.dependsOn.join(', ')}`);
|
|
311
|
+
}
|
|
312
|
+
});
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
### Execute a Plan
|
|
316
|
+
|
|
317
|
+
```typescript
|
|
318
|
+
// Execute the generated plan
|
|
319
|
+
const execResp = await axonflow.executePlan(plan.planId);
|
|
320
|
+
|
|
321
|
+
console.log(`Plan Status: ${execResp.status}`);
|
|
322
|
+
console.log(`Duration: ${execResp.duration}`);
|
|
323
|
+
|
|
324
|
+
if (execResp.status === 'completed') {
|
|
325
|
+
console.log(`Result:\n${execResp.result}`);
|
|
326
|
+
|
|
327
|
+
// Access individual step results
|
|
328
|
+
Object.entries(execResp.stepResults || {}).forEach(([stepId, result]) => {
|
|
329
|
+
console.log(` ${stepId}:`, result);
|
|
330
|
+
});
|
|
331
|
+
} else if (execResp.status === 'failed') {
|
|
332
|
+
console.error(`Error: ${execResp.error}`);
|
|
333
|
+
}
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
### Check Plan Status
|
|
337
|
+
|
|
338
|
+
```typescript
|
|
339
|
+
// For long-running plans, check status periodically
|
|
340
|
+
const status = await axonflow.getPlanStatus(plan.planId);
|
|
341
|
+
|
|
342
|
+
console.log(`Plan Status: ${status.status}`);
|
|
343
|
+
if (status.status === 'running') {
|
|
344
|
+
console.log('Plan is still executing...');
|
|
345
|
+
}
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
### Complete Example: Trip Planning with MAP
|
|
349
|
+
|
|
350
|
+
```typescript
|
|
351
|
+
import { AxonFlow } from '@axonflow/sdk';
|
|
352
|
+
|
|
353
|
+
async function planTrip() {
|
|
354
|
+
// Initialize client
|
|
355
|
+
const axonflow = new AxonFlow({
|
|
356
|
+
apiKey: process.env.AXONFLOW_API_KEY,
|
|
357
|
+
debug: true
|
|
358
|
+
});
|
|
359
|
+
|
|
360
|
+
// 1. Generate multi-agent plan
|
|
361
|
+
const plan = await axonflow.generatePlan(
|
|
362
|
+
'Plan a 3-day trip to Paris for 2 people with moderate budget',
|
|
363
|
+
'travel'
|
|
364
|
+
);
|
|
365
|
+
|
|
366
|
+
console.log(`ā
Generated plan with ${plan.steps.length} steps (parallel: ${plan.parallel})`);
|
|
367
|
+
|
|
368
|
+
// 2. Execute the plan
|
|
369
|
+
console.log('\nš Executing plan...');
|
|
370
|
+
const execResp = await axonflow.executePlan(plan.planId);
|
|
371
|
+
|
|
372
|
+
// 3. Display results
|
|
373
|
+
if (execResp.status === 'completed') {
|
|
374
|
+
console.log(`\nā
Plan completed in ${execResp.duration}`);
|
|
375
|
+
console.log(`\nš Complete Itinerary:\n${execResp.result}`);
|
|
376
|
+
} else {
|
|
377
|
+
console.error(`\nā Plan failed: ${execResp.error}`);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
planTrip().catch(console.error);
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
## License
|
|
385
|
+
|
|
386
|
+
MIT
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { AxonFlowConfig, ConnectorMetadata, ConnectorInstallRequest, ConnectorResponse, PlanResponse, PlanExecutionResponse } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Main AxonFlow client for invisible AI governance
|
|
4
|
+
*/
|
|
5
|
+
export declare class AxonFlow {
|
|
6
|
+
private config;
|
|
7
|
+
private interceptors;
|
|
8
|
+
constructor(config: AxonFlowConfig);
|
|
9
|
+
/**
|
|
10
|
+
* Main method to protect AI calls with governance
|
|
11
|
+
* @param aiCall The AI call to protect
|
|
12
|
+
* @returns The AI response after governance
|
|
13
|
+
*/
|
|
14
|
+
protect<T = any>(aiCall: () => Promise<T>): Promise<T>;
|
|
15
|
+
/**
|
|
16
|
+
* Extract request details from an AI call
|
|
17
|
+
*/
|
|
18
|
+
private extractRequest;
|
|
19
|
+
/**
|
|
20
|
+
* Check policies with AxonFlow Agent
|
|
21
|
+
*/
|
|
22
|
+
private checkPolicies;
|
|
23
|
+
/**
|
|
24
|
+
* Log audit trail
|
|
25
|
+
*/
|
|
26
|
+
private logAudit;
|
|
27
|
+
/**
|
|
28
|
+
* Check if an error is from AxonFlow (vs the AI provider)
|
|
29
|
+
*/
|
|
30
|
+
private isAxonFlowError;
|
|
31
|
+
/**
|
|
32
|
+
* Create a sandbox client for testing
|
|
33
|
+
*/
|
|
34
|
+
static sandbox(apiKey?: string): AxonFlow;
|
|
35
|
+
/**
|
|
36
|
+
* List all available MCP connectors from the marketplace
|
|
37
|
+
*/
|
|
38
|
+
listConnectors(): Promise<ConnectorMetadata[]>;
|
|
39
|
+
/**
|
|
40
|
+
* Install an MCP connector from the marketplace
|
|
41
|
+
*/
|
|
42
|
+
installConnector(request: ConnectorInstallRequest): Promise<void>;
|
|
43
|
+
/**
|
|
44
|
+
* Execute a query against an installed MCP connector
|
|
45
|
+
*/
|
|
46
|
+
queryConnector(connectorName: string, query: string, params?: any): Promise<ConnectorResponse>;
|
|
47
|
+
/**
|
|
48
|
+
* Generate a multi-agent execution plan from a natural language query
|
|
49
|
+
*/
|
|
50
|
+
generatePlan(query: string, domain?: string): Promise<PlanResponse>;
|
|
51
|
+
/**
|
|
52
|
+
* Execute a previously generated multi-agent plan
|
|
53
|
+
*/
|
|
54
|
+
executePlan(planId: string): Promise<PlanExecutionResponse>;
|
|
55
|
+
/**
|
|
56
|
+
* Get the status of a running or completed plan
|
|
57
|
+
*/
|
|
58
|
+
getPlanStatus(planId: string): Promise<PlanExecutionResponse>;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +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,EACtB,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;IA0CpG;;OAEG;IACG,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IA6CzE;;OAEG;IACG,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAyCjE;;OAEG;IACG,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC;CAwBpE"}
|