@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.
Files changed (108) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +386 -0
  3. package/dist/cjs/client.d.ts +60 -0
  4. package/dist/cjs/client.d.ts.map +1 -0
  5. package/dist/cjs/client.js +364 -0
  6. package/dist/cjs/client.js.map +1 -0
  7. package/dist/cjs/index.d.ts +22 -0
  8. package/dist/cjs/index.d.ts.map +1 -0
  9. package/dist/cjs/index.js +29 -0
  10. package/dist/cjs/index.js.map +1 -0
  11. package/dist/cjs/interceptors/anthropic.d.ts +16 -0
  12. package/dist/cjs/interceptors/anthropic.d.ts.map +1 -0
  13. package/dist/cjs/interceptors/anthropic.js +74 -0
  14. package/dist/cjs/interceptors/anthropic.js.map +1 -0
  15. package/dist/cjs/interceptors/base.d.ts +23 -0
  16. package/dist/cjs/interceptors/base.d.ts.map +1 -0
  17. package/dist/cjs/interceptors/base.js +10 -0
  18. package/dist/cjs/interceptors/base.js.map +1 -0
  19. package/dist/cjs/interceptors/openai.d.ts +16 -0
  20. package/dist/cjs/interceptors/openai.d.ts.map +1 -0
  21. package/dist/cjs/interceptors/openai.js +73 -0
  22. package/dist/cjs/interceptors/openai.js.map +1 -0
  23. package/dist/cjs/types/config.d.ts +62 -0
  24. package/dist/cjs/types/config.d.ts.map +1 -0
  25. package/dist/cjs/types/config.js +3 -0
  26. package/dist/cjs/types/config.js.map +1 -0
  27. package/dist/cjs/types/connector.d.ts +31 -0
  28. package/dist/cjs/types/connector.d.ts.map +1 -0
  29. package/dist/cjs/types/connector.js +6 -0
  30. package/dist/cjs/types/connector.js.map +1 -0
  31. package/dist/cjs/types/index.d.ts +7 -0
  32. package/dist/cjs/types/index.d.ts.map +1 -0
  33. package/dist/cjs/types/index.js +23 -0
  34. package/dist/cjs/types/index.js.map +1 -0
  35. package/dist/cjs/types/planning.d.ts +29 -0
  36. package/dist/cjs/types/planning.d.ts.map +1 -0
  37. package/dist/cjs/types/planning.js +6 -0
  38. package/dist/cjs/types/planning.js.map +1 -0
  39. package/dist/cjs/types/policy.d.ts +48 -0
  40. package/dist/cjs/types/policy.d.ts.map +1 -0
  41. package/dist/cjs/types/policy.js +3 -0
  42. package/dist/cjs/types/policy.js.map +1 -0
  43. package/dist/cjs/types/request.d.ts +56 -0
  44. package/dist/cjs/types/request.d.ts.map +1 -0
  45. package/dist/cjs/types/request.js +3 -0
  46. package/dist/cjs/types/request.js.map +1 -0
  47. package/dist/cjs/types/response.d.ts +82 -0
  48. package/dist/cjs/types/response.d.ts.map +1 -0
  49. package/dist/cjs/types/response.js +3 -0
  50. package/dist/cjs/types/response.js.map +1 -0
  51. package/dist/cjs/utils/helpers.d.ts +25 -0
  52. package/dist/cjs/utils/helpers.d.ts.map +1 -0
  53. package/dist/cjs/utils/helpers.js +54 -0
  54. package/dist/cjs/utils/helpers.js.map +1 -0
  55. package/dist/esm/client.d.ts +60 -0
  56. package/dist/esm/client.d.ts.map +1 -0
  57. package/dist/esm/client.js +360 -0
  58. package/dist/esm/client.js.map +1 -0
  59. package/dist/esm/index.d.ts +22 -0
  60. package/dist/esm/index.d.ts.map +1 -0
  61. package/dist/esm/index.js +23 -0
  62. package/dist/esm/index.js.map +1 -0
  63. package/dist/esm/interceptors/anthropic.d.ts +16 -0
  64. package/dist/esm/interceptors/anthropic.d.ts.map +1 -0
  65. package/dist/esm/interceptors/anthropic.js +69 -0
  66. package/dist/esm/interceptors/anthropic.js.map +1 -0
  67. package/dist/esm/interceptors/base.d.ts +23 -0
  68. package/dist/esm/interceptors/base.d.ts.map +1 -0
  69. package/dist/esm/interceptors/base.js +6 -0
  70. package/dist/esm/interceptors/base.js.map +1 -0
  71. package/dist/esm/interceptors/openai.d.ts +16 -0
  72. package/dist/esm/interceptors/openai.d.ts.map +1 -0
  73. package/dist/esm/interceptors/openai.js +68 -0
  74. package/dist/esm/interceptors/openai.js.map +1 -0
  75. package/dist/esm/package.json +3 -0
  76. package/dist/esm/types/config.d.ts +62 -0
  77. package/dist/esm/types/config.d.ts.map +1 -0
  78. package/dist/esm/types/config.js +2 -0
  79. package/dist/esm/types/config.js.map +1 -0
  80. package/dist/esm/types/connector.d.ts +31 -0
  81. package/dist/esm/types/connector.d.ts.map +1 -0
  82. package/dist/esm/types/connector.js +5 -0
  83. package/dist/esm/types/connector.js.map +1 -0
  84. package/dist/esm/types/index.d.ts +7 -0
  85. package/dist/esm/types/index.d.ts.map +1 -0
  86. package/dist/esm/types/index.js +7 -0
  87. package/dist/esm/types/index.js.map +1 -0
  88. package/dist/esm/types/planning.d.ts +29 -0
  89. package/dist/esm/types/planning.d.ts.map +1 -0
  90. package/dist/esm/types/planning.js +5 -0
  91. package/dist/esm/types/planning.js.map +1 -0
  92. package/dist/esm/types/policy.d.ts +48 -0
  93. package/dist/esm/types/policy.d.ts.map +1 -0
  94. package/dist/esm/types/policy.js +2 -0
  95. package/dist/esm/types/policy.js.map +1 -0
  96. package/dist/esm/types/request.d.ts +56 -0
  97. package/dist/esm/types/request.d.ts.map +1 -0
  98. package/dist/esm/types/request.js +2 -0
  99. package/dist/esm/types/request.js.map +1 -0
  100. package/dist/esm/types/response.d.ts +82 -0
  101. package/dist/esm/types/response.d.ts.map +1 -0
  102. package/dist/esm/types/response.js +2 -0
  103. package/dist/esm/types/response.js.map +1 -0
  104. package/dist/esm/utils/helpers.d.ts +25 -0
  105. package/dist/esm/utils/helpers.d.ts.map +1 -0
  106. package/dist/esm/utils/helpers.js +46 -0
  107. package/dist/esm/utils/helpers.js.map +1 -0
  108. package/package.json +63 -0
@@ -0,0 +1,364 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AxonFlow = void 0;
4
+ const openai_1 = require("./interceptors/openai");
5
+ const anthropic_1 = require("./interceptors/anthropic");
6
+ const helpers_1 = require("./utils/helpers");
7
+ /**
8
+ * Main AxonFlow client for invisible AI governance
9
+ */
10
+ class AxonFlow {
11
+ constructor(config) {
12
+ this.interceptors = [];
13
+ // Set defaults
14
+ this.config = {
15
+ apiKey: config.apiKey,
16
+ endpoint: config.endpoint || 'https://staging-eu.getaxonflow.com',
17
+ mode: config.mode || 'production',
18
+ tenant: config.tenant || 'default',
19
+ debug: config.debug || false,
20
+ timeout: config.timeout || 30000,
21
+ retry: config.retry || { enabled: true, maxAttempts: 3, delay: 1000 },
22
+ cache: config.cache || { enabled: true, ttl: 60000 }
23
+ };
24
+ // Initialize interceptors
25
+ this.interceptors = [
26
+ new openai_1.OpenAIInterceptor(),
27
+ new anthropic_1.AnthropicInterceptor()
28
+ ];
29
+ if (this.config.debug) {
30
+ (0, helpers_1.debugLog)('AxonFlow initialized', { mode: this.config.mode, endpoint: this.config.endpoint });
31
+ }
32
+ }
33
+ /**
34
+ * Main method to protect AI calls with governance
35
+ * @param aiCall The AI call to protect
36
+ * @returns The AI response after governance
37
+ */
38
+ async protect(aiCall) {
39
+ try {
40
+ // Extract request details from the AI call
41
+ const aiRequest = await this.extractRequest(aiCall);
42
+ if (this.config.debug) {
43
+ (0, helpers_1.debugLog)('Protecting AI call', { provider: aiRequest.provider, model: aiRequest.model });
44
+ }
45
+ // Create governance request
46
+ const governanceRequest = {
47
+ requestId: (0, helpers_1.generateRequestId)(),
48
+ timestamp: Date.now(),
49
+ aiRequest,
50
+ mode: this.config.mode,
51
+ tenant: this.config.tenant
52
+ };
53
+ // Check policies with AxonFlow Agent
54
+ const governanceResponse = await this.checkPolicies(governanceRequest);
55
+ // If denied, throw error
56
+ if (!governanceResponse.allowed) {
57
+ const violation = governanceResponse.violations?.[0];
58
+ throw new Error(`Request blocked by AxonFlow: ${violation?.description || 'Policy violation'}`);
59
+ }
60
+ // Execute the AI call (possibly with modifications)
61
+ const modifiedCall = governanceResponse.modifiedRequest
62
+ ? () => Promise.resolve(governanceResponse.modifiedRequest)
63
+ : aiCall;
64
+ const result = await modifiedCall();
65
+ // Log audit trail
66
+ await this.logAudit(governanceResponse);
67
+ return result;
68
+ }
69
+ catch (error) {
70
+ if (this.config.debug) {
71
+ (0, helpers_1.debugLog)('Error in protect()', error);
72
+ }
73
+ // In production, fail open (allow the call) if AxonFlow is unavailable
74
+ if (this.config.mode === 'production' && this.isAxonFlowError(error)) {
75
+ console.warn('AxonFlow unavailable, failing open');
76
+ return aiCall();
77
+ }
78
+ throw error;
79
+ }
80
+ }
81
+ /**
82
+ * Extract request details from an AI call
83
+ */
84
+ async extractRequest(aiCall) {
85
+ // Try each interceptor to see if it can handle this call
86
+ for (const interceptor of this.interceptors) {
87
+ if (interceptor.canHandle(aiCall)) {
88
+ return interceptor.extractRequest(aiCall);
89
+ }
90
+ }
91
+ // Generic extraction if no specific interceptor matches
92
+ return {
93
+ provider: 'unknown',
94
+ model: 'unknown',
95
+ prompt: aiCall.toString(),
96
+ parameters: {}
97
+ };
98
+ }
99
+ /**
100
+ * Check policies with AxonFlow Agent
101
+ */
102
+ async checkPolicies(request) {
103
+ const url = `${this.config.endpoint}/api/request`;
104
+ // Transform SDK request to Agent API format
105
+ const agentRequest = {
106
+ query: request.aiRequest.prompt,
107
+ user_token: this.config.apiKey,
108
+ client_id: this.config.tenant,
109
+ request_type: 'llm_chat',
110
+ context: {
111
+ provider: request.aiRequest.provider,
112
+ model: request.aiRequest.model,
113
+ parameters: request.aiRequest.parameters,
114
+ requestId: request.requestId,
115
+ mode: this.config.mode
116
+ }
117
+ };
118
+ const response = await fetch(url, {
119
+ method: 'POST',
120
+ headers: {
121
+ 'Content-Type': 'application/json'
122
+ },
123
+ body: JSON.stringify(agentRequest),
124
+ signal: AbortSignal.timeout(this.config.timeout)
125
+ });
126
+ if (!response.ok) {
127
+ const errorText = await response.text();
128
+ throw new Error(`AxonFlow API error: ${response.status} ${response.statusText} - ${errorText}`);
129
+ }
130
+ const agentResponse = await response.json();
131
+ // Transform Agent API response to SDK format
132
+ return {
133
+ requestId: request.requestId,
134
+ allowed: !agentResponse.blocked,
135
+ violations: agentResponse.blocked ? [{
136
+ type: 'security',
137
+ severity: 'high',
138
+ description: agentResponse.block_reason || 'Request blocked by policy',
139
+ policy: 'agent-policy',
140
+ action: 'blocked'
141
+ }] : [],
142
+ modifiedRequest: agentResponse.data,
143
+ policies: [],
144
+ audit: {
145
+ timestamp: Date.now(),
146
+ duration: parseInt(agentResponse.policy_info?.processing_time?.replace('ms', '') || '0'),
147
+ tenant: this.config.tenant
148
+ }
149
+ };
150
+ }
151
+ /**
152
+ * Log audit trail
153
+ */
154
+ async logAudit(response) {
155
+ // Audit logging is handled server-side by the Agent
156
+ // Just log locally if debug mode is enabled
157
+ if (this.config.debug) {
158
+ (0, helpers_1.debugLog)('Request processed', {
159
+ allowed: response.allowed,
160
+ violations: response.violations?.length || 0,
161
+ duration: response.audit.duration
162
+ });
163
+ }
164
+ }
165
+ /**
166
+ * Check if an error is from AxonFlow (vs the AI provider)
167
+ */
168
+ isAxonFlowError(error) {
169
+ return error?.message?.includes('AxonFlow') ||
170
+ error?.message?.includes('governance') ||
171
+ error?.message?.includes('fetch');
172
+ }
173
+ /**
174
+ * Create a sandbox client for testing
175
+ */
176
+ static sandbox(apiKey = 'demo-key') {
177
+ return new AxonFlow({
178
+ apiKey,
179
+ mode: 'sandbox',
180
+ endpoint: 'https://staging-eu.getaxonflow.com',
181
+ debug: true
182
+ });
183
+ }
184
+ /**
185
+ * List all available MCP connectors from the marketplace
186
+ */
187
+ async listConnectors() {
188
+ const url = `${this.config.endpoint}/api/connectors`;
189
+ const response = await fetch(url, {
190
+ method: 'GET',
191
+ signal: AbortSignal.timeout(this.config.timeout)
192
+ });
193
+ if (!response.ok) {
194
+ throw new Error(`Failed to list connectors: ${response.status} ${response.statusText}`);
195
+ }
196
+ const connectors = await response.json();
197
+ if (this.config.debug) {
198
+ (0, helpers_1.debugLog)('Listed connectors', { count: connectors.length });
199
+ }
200
+ return connectors;
201
+ }
202
+ /**
203
+ * Install an MCP connector from the marketplace
204
+ */
205
+ async installConnector(request) {
206
+ const url = `${this.config.endpoint}/api/connectors/install`;
207
+ const response = await fetch(url, {
208
+ method: 'POST',
209
+ headers: {
210
+ 'Content-Type': 'application/json',
211
+ 'X-Client-Secret': this.config.apiKey
212
+ },
213
+ body: JSON.stringify(request),
214
+ signal: AbortSignal.timeout(this.config.timeout)
215
+ });
216
+ if (!response.ok) {
217
+ const errorText = await response.text();
218
+ throw new Error(`Failed to install connector: ${response.status} ${response.statusText} - ${errorText}`);
219
+ }
220
+ if (this.config.debug) {
221
+ (0, helpers_1.debugLog)('Connector installed', { name: request.name });
222
+ }
223
+ }
224
+ /**
225
+ * Execute a query against an installed MCP connector
226
+ */
227
+ async queryConnector(connectorName, query, params) {
228
+ const agentRequest = {
229
+ query,
230
+ user_token: this.config.apiKey,
231
+ client_id: this.config.tenant,
232
+ request_type: 'mcp-query',
233
+ context: {
234
+ connector: connectorName,
235
+ params: params || {}
236
+ }
237
+ };
238
+ const url = `${this.config.endpoint}/api/request`;
239
+ const response = await fetch(url, {
240
+ method: 'POST',
241
+ headers: {
242
+ 'Content-Type': 'application/json'
243
+ },
244
+ body: JSON.stringify(agentRequest),
245
+ signal: AbortSignal.timeout(this.config.timeout)
246
+ });
247
+ if (!response.ok) {
248
+ const errorText = await response.text();
249
+ throw new Error(`Connector query failed: ${response.status} ${response.statusText} - ${errorText}`);
250
+ }
251
+ const agentResponse = await response.json();
252
+ if (this.config.debug) {
253
+ (0, helpers_1.debugLog)('Connector query executed', { connector: connectorName });
254
+ }
255
+ return {
256
+ success: agentResponse.success,
257
+ data: agentResponse.data,
258
+ error: agentResponse.error,
259
+ meta: agentResponse.metadata
260
+ };
261
+ }
262
+ /**
263
+ * Generate a multi-agent execution plan from a natural language query
264
+ */
265
+ async generatePlan(query, domain) {
266
+ const agentRequest = {
267
+ query,
268
+ user_token: this.config.apiKey,
269
+ client_id: this.config.tenant,
270
+ request_type: 'multi-agent-plan',
271
+ context: domain ? { domain } : {}
272
+ };
273
+ const url = `${this.config.endpoint}/api/request`;
274
+ const response = await fetch(url, {
275
+ method: 'POST',
276
+ headers: {
277
+ 'Content-Type': 'application/json'
278
+ },
279
+ body: JSON.stringify(agentRequest),
280
+ signal: AbortSignal.timeout(this.config.timeout)
281
+ });
282
+ if (!response.ok) {
283
+ const errorText = await response.text();
284
+ throw new Error(`Plan generation failed: ${response.status} ${response.statusText} - ${errorText}`);
285
+ }
286
+ const agentResponse = await response.json();
287
+ if (!agentResponse.success) {
288
+ throw new Error(`Plan generation failed: ${agentResponse.error}`);
289
+ }
290
+ if (this.config.debug) {
291
+ (0, helpers_1.debugLog)('Plan generated', { planId: agentResponse.plan_id });
292
+ }
293
+ return {
294
+ planId: agentResponse.plan_id,
295
+ steps: agentResponse.data?.steps || [],
296
+ domain: agentResponse.data?.domain || domain || 'generic',
297
+ complexity: agentResponse.data?.complexity || 0,
298
+ parallel: agentResponse.data?.parallel || false,
299
+ metadata: agentResponse.metadata || {}
300
+ };
301
+ }
302
+ /**
303
+ * Execute a previously generated multi-agent plan
304
+ */
305
+ async executePlan(planId) {
306
+ const agentRequest = {
307
+ query: '',
308
+ user_token: this.config.apiKey,
309
+ client_id: this.config.tenant,
310
+ request_type: 'execute-plan',
311
+ context: { plan_id: planId }
312
+ };
313
+ const url = `${this.config.endpoint}/api/request`;
314
+ const response = await fetch(url, {
315
+ method: 'POST',
316
+ headers: {
317
+ 'Content-Type': 'application/json'
318
+ },
319
+ body: JSON.stringify(agentRequest),
320
+ signal: AbortSignal.timeout(this.config.timeout)
321
+ });
322
+ if (!response.ok) {
323
+ const errorText = await response.text();
324
+ throw new Error(`Plan execution failed: ${response.status} ${response.statusText} - ${errorText}`);
325
+ }
326
+ const agentResponse = await response.json();
327
+ if (this.config.debug) {
328
+ (0, helpers_1.debugLog)('Plan executed', { planId, success: agentResponse.success });
329
+ }
330
+ return {
331
+ planId,
332
+ status: agentResponse.success ? 'completed' : 'failed',
333
+ result: agentResponse.result,
334
+ stepResults: agentResponse.metadata?.step_results,
335
+ error: agentResponse.error,
336
+ duration: agentResponse.metadata?.duration
337
+ };
338
+ }
339
+ /**
340
+ * Get the status of a running or completed plan
341
+ */
342
+ async getPlanStatus(planId) {
343
+ const url = `${this.config.endpoint}/api/plans/${planId}`;
344
+ const response = await fetch(url, {
345
+ method: 'GET',
346
+ signal: AbortSignal.timeout(this.config.timeout)
347
+ });
348
+ if (!response.ok) {
349
+ const errorText = await response.text();
350
+ throw new Error(`Get plan status failed: ${response.status} ${response.statusText} - ${errorText}`);
351
+ }
352
+ const status = await response.json();
353
+ return {
354
+ planId,
355
+ status: status.status,
356
+ result: status.result,
357
+ stepResults: status.step_results,
358
+ error: status.error,
359
+ duration: status.duration
360
+ };
361
+ }
362
+ }
363
+ exports.AxonFlow = AxonFlow;
364
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":";;;AAWA,kDAA0D;AAC1D,wDAAgE;AAEhE,6CAA8D;AAE9D;;GAEG;AACH,MAAa,QAAQ;IAInB,YAAY,MAAsB;QAF1B,iBAAY,GAAsB,EAAE,CAAC;QAG3C,eAAe;QACf,IAAI,CAAC,MAAM,GAAG;YACZ,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,oCAAoC;YACjE,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,YAAY;YACjC,MAAM,EAAE,MAAM,CAAC,MAAM,IAAI,SAAS;YAClC,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,KAAK;YAC5B,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,KAAK;YAChC,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE;YACrE,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE;SACrD,C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AK,CAAC,aAAa,CAAC,MAAc;QAChC,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,cAAc,MAAM,EAAE,CAAC;QAE1D,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;YAChC,MAAM,EAAE,KAAK;YACb,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC;SACjD,CAAC,CAAC;QAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;YACxC,MAAM,IAAI,KAAK,CAAC,2BAA2B,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,UAAU,MAAM,SAAS,EAAE,CAAC,CAAC;QACtG,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QAErC,OAAO;YACL,MAAM;YACN,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,WAAW,EAAE,MAAM,CAAC,YAAY;YAChC,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,QAAQ,EAAE,MAAM,CAAC,QAAQ;SAC1B,CAAC;IACJ,CAAC;CACF;AA9ZD,4BA8ZC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * AxonFlow SDK - Invisible AI Governance Layer
3
+ *
4
+ * Add enterprise-grade governance to your AI applications with just 3 lines of code.
5
+ * No UI changes. No user training. Just drop-in protection.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * import { AxonFlow } from '@axonflow/sdk';
10
+ *
11
+ * const axonflow = new AxonFlow({ apiKey: 'your-key' });
12
+ * const response = await axonflow.protect(() => openai.complete(prompt));
13
+ * ```
14
+ */
15
+ export { AxonFlow } from './client';
16
+ export { wrapOpenAIClient } from './interceptors/openai';
17
+ export { wrapAnthropicClient } from './interceptors/anthropic';
18
+ export type { AxonFlowConfig, AIRequest, GovernanceRequest, GovernanceResponse, PolicyDecision, Violation, Policy, PolicyRule } from './types';
19
+ export declare const VERSION = "0.1.0";
20
+ import { AxonFlow } from './client';
21
+ export default AxonFlow;
22
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAG/D,YAAY,EACV,cAAc,EACd,SAAS,EACT,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EACd,SAAS,EACT,MAAM,EACN,UAAU,EACX,MAAM,SAAS,CAAC;AAGjB,eAAO,MAAM,OAAO,UAAU,CAAC;AAG/B,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,eAAe,QAAQ,CAAC"}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ /**
3
+ * AxonFlow SDK - Invisible AI Governance Layer
4
+ *
5
+ * Add enterprise-grade governance to your AI applications with just 3 lines of code.
6
+ * No UI changes. No user training. Just drop-in protection.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * import { AxonFlow } from '@axonflow/sdk';
11
+ *
12
+ * const axonflow = new AxonFlow({ apiKey: 'your-key' });
13
+ * const response = await axonflow.protect(() => openai.complete(prompt));
14
+ * ```
15
+ */
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.VERSION = exports.wrapAnthropicClient = exports.wrapOpenAIClient = exports.AxonFlow = void 0;
18
+ var client_1 = require("./client");
19
+ Object.defineProperty(exports, "AxonFlow", { enumerable: true, get: function () { return client_1.AxonFlow; } });
20
+ var openai_1 = require("./interceptors/openai");
21
+ Object.defineProperty(exports, "wrapOpenAIClient", { enumerable: true, get: function () { return openai_1.wrapOpenAIClient; } });
22
+ var anthropic_1 = require("./interceptors/anthropic");
23
+ Object.defineProperty(exports, "wrapAnthropicClient", { enumerable: true, get: function () { return anthropic_1.wrapAnthropicClient; } });
24
+ // Export version
25
+ exports.VERSION = '0.1.0';
26
+ // Default export for convenience
27
+ const client_2 = require("./client");
28
+ exports.default = client_2.AxonFlow;
29
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;;AAEH,mCAAoC;AAA3B,kGAAA,QAAQ,OAAA;AACjB,gDAAyD;AAAhD,0GAAA,gBAAgB,OAAA;AACzB,sDAA+D;AAAtD,gHAAA,mBAAmB,OAAA;AAc5B,iBAAiB;AACJ,QAAA,OAAO,GAAG,OAAO,CAAC;AAE/B,iCAAiC;AACjC,qCAAoC;AACpC,kBAAe,iBAAQ,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { BaseInterceptor } from './base';
2
+ import { AIRequest } from '../types';
3
+ /**
4
+ * Interceptor for Anthropic Claude API calls
5
+ */
6
+ export declare class AnthropicInterceptor extends BaseInterceptor {
7
+ canHandle(aiCall: any): boolean;
8
+ extractRequest(aiCall: any): AIRequest;
9
+ executeWithModifications(aiCall: any, modifications: any): Promise<any>;
10
+ getProvider(): string;
11
+ }
12
+ /**
13
+ * Helper to wrap Anthropic client for easier interception
14
+ */
15
+ export declare function wrapAnthropicClient(anthropicClient: any, axonflow: any): any;
16
+ //# sourceMappingURL=anthropic.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anthropic.d.ts","sourceRoot":"","sources":["../../../src/interceptors/anthropic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,eAAe;IACvD,SAAS,CAAC,MAAM,EAAE,GAAG,GAAG,OAAO;IAQ/B,cAAc,CAAC,MAAM,EAAE,GAAG,GAAG,SAAS;IAsBtC,wBAAwB,CAAC,MAAM,EAAE,GAAG,EAAE,aAAa,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IAKvE,WAAW,IAAI,MAAM;CAGtB;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,eAAe,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,GAAG,GAAG,CA4B5E"}
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AnthropicInterceptor = void 0;
4
+ exports.wrapAnthropicClient = wrapAnthropicClient;
5
+ const base_1 = require("./base");
6
+ /**
7
+ * Interceptor for Anthropic Claude API calls
8
+ */
9
+ class AnthropicInterceptor extends base_1.BaseInterceptor {
10
+ canHandle(aiCall) {
11
+ // Check if this looks like an Anthropic call
12
+ const callString = aiCall.toString();
13
+ return callString.includes('anthropic') ||
14
+ callString.includes('claude') ||
15
+ callString.includes('messages.create');
16
+ }
17
+ extractRequest(aiCall) {
18
+ // Try to extract Anthropic-specific details
19
+ const callString = aiCall.toString();
20
+ // Try to detect model
21
+ let model = 'unknown';
22
+ if (callString.includes('claude-3')) {
23
+ model = 'claude-3';
24
+ }
25
+ else if (callString.includes('claude-2')) {
26
+ model = 'claude-2';
27
+ }
28
+ return {
29
+ provider: 'anthropic',
30
+ model,
31
+ prompt: callString,
32
+ parameters: {
33
+ // Would extract max_tokens, temperature, etc. in production
34
+ }
35
+ };
36
+ }
37
+ executeWithModifications(aiCall, modifications) {
38
+ // Execute the call with any modifications from governance
39
+ return aiCall();
40
+ }
41
+ getProvider() {
42
+ return 'anthropic';
43
+ }
44
+ }
45
+ exports.AnthropicInterceptor = AnthropicInterceptor;
46
+ /**
47
+ * Helper to wrap Anthropic client for easier interception
48
+ */
49
+ function wrapAnthropicClient(anthropicClient, axonflow) {
50
+ // Create a proxy that intercepts method calls
51
+ return new Proxy(anthropicClient, {
52
+ get(target, prop, receiver) {
53
+ const original = Reflect.get(target, prop, receiver);
54
+ // If it's the messages object
55
+ if (prop === 'messages' && typeof original === 'object') {
56
+ return new Proxy(original, {
57
+ get(messagesTarget, messagesProp) {
58
+ const messagesOriginal = Reflect.get(messagesTarget, messagesProp);
59
+ // If it's the create method
60
+ if (messagesProp === 'create' && typeof messagesOriginal === 'function') {
61
+ return async (...args) => {
62
+ // Protect the call with AxonFlow
63
+ return axonflow.protect(() => messagesOriginal.apply(messagesTarget, args));
64
+ };
65
+ }
66
+ return messagesOriginal;
67
+ }
68
+ });
69
+ }
70
+ return original;
71
+ }
72
+ });
73
+ }
74
+ //# sourceMappingURL=anthropic.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anthropic.js","sourceRoot":"","sources":["../../../src/interceptors/anthropic.ts"],"names":[],"mappings":";;;AAkDA,kDA4BC;AA9ED,iCAAyC;AAGzC;;GAEG;AACH,MAAa,oBAAqB,SAAQ,sBAAe;IACvD,SAAS,CAAC,MAAW;QACnB,6CAA6C;QAC7C,MAAM,UAAU,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC;QACrC,OAAO,UAAU,CAAC,QAAQ,CAAC,WAAW,CAAC;YAChC,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC;YAC7B,UAAU,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAC;IAChD,CAAC;IAED,cAAc,CAAC,MAAW;QACxB,4CAA4C;QAC5C,MAAM,UAAU,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC;QAErC,sBAAsB;QACtB,IAAI,KAAK,GAAG,SAAS,CAAC;QACtB,IAAI,UAAU,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;YACpC,KAAK,GAAG,UAAU,CAAC;QACrB,CAAC;aAAM,IAAI,UAAU,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CA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AAC;YAED,OAAO,QAAQ,CAAC;QAClB,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { AIRequest } from '../types';
2
+ /**
3
+ * Base interceptor interface for different AI providers
4
+ */
5
+ export declare abstract class BaseInterceptor {
6
+ /**
7
+ * Check if this interceptor can handle the given AI call
8
+ */
9
+ abstract canHandle(aiCall: any): boolean;
10
+ /**
11
+ * Extract request details from the AI call
12
+ */
13
+ abstract extractRequest(aiCall: any): AIRequest;
14
+ /**
15
+ * Execute the AI call with modifications
16
+ */
17
+ abstract executeWithModifications(aiCall: any, modifications: any): Promise<any>;
18
+ /**
19
+ * Get the provider name
20
+ */
21
+ abstract getProvider(): string;
22
+ }
23
+ //# sourceMappingURL=base.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../src/interceptors/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC;;GAEG;AACH,8BAAsB,eAAe;IACnC;;OAEG;IACH,QAAQ,CAAC,SAAS,CAAC,MAAM,EAAE,GAAG,GAAG,OAAO;IAExC;;OAEG;IACH,QAAQ,CAAC,cAAc,CAAC,MAAM,EAAE,GAAG,GAAG,SAAS;IAE/C;;OAEG;IACH,QAAQ,CAAC,wBAAwB,CAAC,MAAM,EAAE,GAAG,EAAE,aAAa,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IAEhF;;OAEG;IACH,QAAQ,CAAC,WAAW,IAAI,MAAM;CAC/B"}
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseInterceptor = void 0;
4
+ /**
5
+ * Base interceptor interface for different AI providers
6
+ */
7
+ class BaseInterceptor {
8
+ }
9
+ exports.BaseInterceptor = BaseInterceptor;
10
+ //# sourceMappingURL=base.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.js","sourceRoot":"","sources":["../../../src/interceptors/base.ts"],"names":[],"mappings":";;;AAEA;;GAEG;AACH,MAAsB,eAAe;CAoBpC;AApBD,0CAoBC"}
@@ -0,0 +1,16 @@
1
+ import { BaseInterceptor } from './base';
2
+ import { AIRequest } from '../types';
3
+ /**
4
+ * Interceptor for OpenAI API calls
5
+ */
6
+ export declare class OpenAIInterceptor extends BaseInterceptor {
7
+ canHandle(aiCall: any): boolean;
8
+ extractRequest(aiCall: any): AIRequest;
9
+ executeWithModifications(aiCall: any, modifications: any): Promise<any>;
10
+ getProvider(): string;
11
+ }
12
+ /**
13
+ * Helper to wrap OpenAI client for easier interception
14
+ */
15
+ export declare function wrapOpenAIClient(openaiClient: any, axonflow: any): any;
16
+ //# sourceMappingURL=openai.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../../src/interceptors/openai.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,eAAe;IACpD,SAAS,CAAC,MAAM,EAAE,GAAG,GAAG,OAAO;IAS/B,cAAc,CAAC,MAAM,EAAE,GAAG,GAAG,SAAS;IAuBtC,wBAAwB,CAAC,MAAM,EAAE,GAAG,EAAE,aAAa,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IAMvE,WAAW,IAAI,MAAM;CAGtB;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,GAAG,GAAG,CAwBtE"}