@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.
- package/README.md +134 -1
- package/dist/cjs/client.d.ts +78 -3
- package/dist/cjs/client.d.ts.map +1 -1
- package/dist/cjs/client.js +281 -57
- package/dist/cjs/client.js.map +1 -1
- package/dist/cjs/errors.d.ts +51 -0
- package/dist/cjs/errors.d.ts.map +1 -0
- package/dist/cjs/errors.js +84 -0
- package/dist/cjs/errors.js.map +1 -0
- package/dist/cjs/index.d.ts +3 -2
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +10 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/interceptors/anthropic.d.ts.map +1 -1
- package/dist/cjs/interceptors/anthropic.js +5 -5
- package/dist/cjs/interceptors/anthropic.js.map +1 -1
- package/dist/cjs/interceptors/openai.d.ts.map +1 -1
- package/dist/cjs/interceptors/openai.js +4 -4
- package/dist/cjs/interceptors/openai.js.map +1 -1
- package/dist/cjs/types/gateway.d.ts +83 -0
- package/dist/cjs/types/gateway.d.ts.map +1 -0
- package/dist/cjs/types/gateway.js +9 -0
- package/dist/cjs/types/gateway.js.map +1 -0
- package/dist/cjs/types/index.d.ts +1 -0
- package/dist/cjs/types/index.d.ts.map +1 -1
- package/dist/cjs/types/index.js +1 -0
- package/dist/cjs/types/index.js.map +1 -1
- package/dist/cjs/utils/helpers.d.ts.map +1 -1
- package/dist/cjs/utils/helpers.js +3 -1
- package/dist/cjs/utils/helpers.js.map +1 -1
- package/dist/esm/client.d.ts +78 -3
- package/dist/esm/client.d.ts.map +1 -1
- package/dist/esm/client.js +281 -57
- package/dist/esm/client.js.map +1 -1
- package/dist/esm/errors.d.ts +51 -0
- package/dist/esm/errors.d.ts.map +1 -0
- package/dist/esm/errors.js +75 -0
- package/dist/esm/errors.js.map +1 -0
- package/dist/esm/index.d.ts +3 -2
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +3 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/interceptors/anthropic.d.ts.map +1 -1
- package/dist/esm/interceptors/anthropic.js +5 -5
- package/dist/esm/interceptors/anthropic.js.map +1 -1
- package/dist/esm/interceptors/openai.d.ts.map +1 -1
- package/dist/esm/interceptors/openai.js +4 -4
- package/dist/esm/interceptors/openai.js.map +1 -1
- package/dist/esm/types/gateway.d.ts +83 -0
- package/dist/esm/types/gateway.d.ts.map +1 -0
- package/dist/esm/types/gateway.js +8 -0
- package/dist/esm/types/gateway.js.map +1 -0
- package/dist/esm/types/index.d.ts +1 -0
- package/dist/esm/types/index.d.ts.map +1 -1
- package/dist/esm/types/index.js +1 -0
- package/dist/esm/types/index.js.map +1 -1
- package/dist/esm/utils/helpers.d.ts.map +1 -1
- package/dist/esm/utils/helpers.js +3 -1
- package/dist/esm/utils/helpers.js.map +1 -1
- package/package.json +10 -5
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* AxonFlow SDK Error Classes
|
|
4
|
+
*
|
|
5
|
+
* Custom error types for better error handling and type safety.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.APIError = exports.TimeoutError = exports.RateLimitError = exports.AuthenticationError = exports.PolicyViolationError = exports.AxonFlowError = void 0;
|
|
9
|
+
/**
|
|
10
|
+
* Base error class for all AxonFlow errors
|
|
11
|
+
*/
|
|
12
|
+
class AxonFlowError extends Error {
|
|
13
|
+
constructor(message) {
|
|
14
|
+
super(message);
|
|
15
|
+
this.name = 'AxonFlowError';
|
|
16
|
+
Object.setPrototypeOf(this, AxonFlowError.prototype);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.AxonFlowError = AxonFlowError;
|
|
20
|
+
/**
|
|
21
|
+
* Error thrown when a request is blocked by policy
|
|
22
|
+
*/
|
|
23
|
+
class PolicyViolationError extends AxonFlowError {
|
|
24
|
+
constructor(blockReason, policies) {
|
|
25
|
+
super(`Request blocked by policy: ${blockReason}`);
|
|
26
|
+
this.name = 'PolicyViolationError';
|
|
27
|
+
this.blockReason = blockReason;
|
|
28
|
+
this.policies = policies;
|
|
29
|
+
Object.setPrototypeOf(this, PolicyViolationError.prototype);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.PolicyViolationError = PolicyViolationError;
|
|
33
|
+
/**
|
|
34
|
+
* Error thrown when authentication fails
|
|
35
|
+
*/
|
|
36
|
+
class AuthenticationError extends AxonFlowError {
|
|
37
|
+
constructor(message = 'Authentication failed') {
|
|
38
|
+
super(message);
|
|
39
|
+
this.name = 'AuthenticationError';
|
|
40
|
+
Object.setPrototypeOf(this, AuthenticationError.prototype);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.AuthenticationError = AuthenticationError;
|
|
44
|
+
/**
|
|
45
|
+
* Error thrown when rate limit is exceeded
|
|
46
|
+
*/
|
|
47
|
+
class RateLimitError extends AxonFlowError {
|
|
48
|
+
constructor(limit, remaining, resetAt) {
|
|
49
|
+
super(`Rate limit exceeded: ${remaining}/${limit} remaining, resets at ${resetAt.toISOString()}`);
|
|
50
|
+
this.name = 'RateLimitError';
|
|
51
|
+
this.limit = limit;
|
|
52
|
+
this.remaining = remaining;
|
|
53
|
+
this.resetAt = resetAt;
|
|
54
|
+
Object.setPrototypeOf(this, RateLimitError.prototype);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.RateLimitError = RateLimitError;
|
|
58
|
+
/**
|
|
59
|
+
* Error thrown when a request times out
|
|
60
|
+
*/
|
|
61
|
+
class TimeoutError extends AxonFlowError {
|
|
62
|
+
constructor(timeoutMs) {
|
|
63
|
+
super(`Request timed out after ${timeoutMs}ms`);
|
|
64
|
+
this.name = 'TimeoutError';
|
|
65
|
+
this.timeoutMs = timeoutMs;
|
|
66
|
+
Object.setPrototypeOf(this, TimeoutError.prototype);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
exports.TimeoutError = TimeoutError;
|
|
70
|
+
/**
|
|
71
|
+
* Error thrown for API errors (non-2xx responses)
|
|
72
|
+
*/
|
|
73
|
+
class APIError extends AxonFlowError {
|
|
74
|
+
constructor(statusCode, statusText, body) {
|
|
75
|
+
super(`API error: ${statusCode} ${statusText} - ${body}`);
|
|
76
|
+
this.name = 'APIError';
|
|
77
|
+
this.statusCode = statusCode;
|
|
78
|
+
this.statusText = statusText;
|
|
79
|
+
this.body = body;
|
|
80
|
+
Object.setPrototypeOf(this, APIError.prototype);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
exports.APIError = APIError;
|
|
84
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH;;GAEG;AACH,MAAa,aAAc,SAAQ,KAAK;IACtC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;QAC5B,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;IACvD,CAAC;CACF;AAND,sCAMC;AAED;;GAEG;AACH,MAAa,oBAAqB,SAAQ,aAAa;IAIrD,YAAY,WAAmB,EAAE,QAAmB;QAClD,KAAK,CAAC,8BAA8B,WAAW,EAAE,CAAC,CAAC;QACnD,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;QACnC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,oBAAoB,CAAC,SAAS,CAAC,CAAC;IAC9D,CAAC;CACF;AAXD,oDAWC;AAED;;GAEG;AACH,MAAa,mBAAoB,SAAQ,aAAa;IACpD,YAAY,UA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UAAU,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC;IAClD,CAAC;CACF;AAbD,4BAaC"}
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -15,8 +15,9 @@
|
|
|
15
15
|
export { AxonFlow } from './client';
|
|
16
16
|
export { wrapOpenAIClient } from './interceptors/openai';
|
|
17
17
|
export { wrapAnthropicClient } from './interceptors/anthropic';
|
|
18
|
-
export
|
|
19
|
-
export
|
|
18
|
+
export { AxonFlowError, PolicyViolationError, AuthenticationError, RateLimitError, TimeoutError, APIError, } from './errors';
|
|
19
|
+
export type { AxonFlowConfig, AIRequest, GovernanceRequest, GovernanceResponse, PolicyDecision, Violation, Policy, PolicyRule, TokenUsage, RateLimitInfo, PolicyApprovalResult, PolicyApprovalOptions, AuditResult, AuditOptions, } from './types';
|
|
20
|
+
export declare const VERSION = "1.2.0";
|
|
20
21
|
import { AxonFlow } from './client';
|
|
21
22
|
export default AxonFlow;
|
|
22
23
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/cjs/index.d.ts.map
CHANGED
|
@@ -1 +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"}
|
|
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,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,mBAAmB,EACnB,cAAc,EACd,YAAY,EACZ,QAAQ,GACT,MAAM,UAAU,CAAC;AAGlB,YAAY,EACV,cAAc,EACd,SAAS,EACT,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EACd,SAAS,EACT,MAAM,EACN,UAAU,EAEV,UAAU,EACV,aAAa,EACb,oBAAoB,EACpB,qBAAqB,EACrB,WAAW,EACX,YAAY,GACb,MAAM,SAAS,CAAC;AAGjB,eAAO,MAAM,OAAO,UAAU,CAAC;AAG/B,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,eAAe,QAAQ,CAAC"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -14,15 +14,23 @@
|
|
|
14
14
|
* ```
|
|
15
15
|
*/
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.VERSION = exports.wrapAnthropicClient = exports.wrapOpenAIClient = exports.AxonFlow = void 0;
|
|
17
|
+
exports.VERSION = exports.APIError = exports.TimeoutError = exports.RateLimitError = exports.AuthenticationError = exports.PolicyViolationError = exports.AxonFlowError = exports.wrapAnthropicClient = exports.wrapOpenAIClient = exports.AxonFlow = void 0;
|
|
18
18
|
var client_1 = require("./client");
|
|
19
19
|
Object.defineProperty(exports, "AxonFlow", { enumerable: true, get: function () { return client_1.AxonFlow; } });
|
|
20
20
|
var openai_1 = require("./interceptors/openai");
|
|
21
21
|
Object.defineProperty(exports, "wrapOpenAIClient", { enumerable: true, get: function () { return openai_1.wrapOpenAIClient; } });
|
|
22
22
|
var anthropic_1 = require("./interceptors/anthropic");
|
|
23
23
|
Object.defineProperty(exports, "wrapAnthropicClient", { enumerable: true, get: function () { return anthropic_1.wrapAnthropicClient; } });
|
|
24
|
+
// Export error classes for proper error handling
|
|
25
|
+
var errors_1 = require("./errors");
|
|
26
|
+
Object.defineProperty(exports, "AxonFlowError", { enumerable: true, get: function () { return errors_1.AxonFlowError; } });
|
|
27
|
+
Object.defineProperty(exports, "PolicyViolationError", { enumerable: true, get: function () { return errors_1.PolicyViolationError; } });
|
|
28
|
+
Object.defineProperty(exports, "AuthenticationError", { enumerable: true, get: function () { return errors_1.AuthenticationError; } });
|
|
29
|
+
Object.defineProperty(exports, "RateLimitError", { enumerable: true, get: function () { return errors_1.RateLimitError; } });
|
|
30
|
+
Object.defineProperty(exports, "TimeoutError", { enumerable: true, get: function () { return errors_1.TimeoutError; } });
|
|
31
|
+
Object.defineProperty(exports, "APIError", { enumerable: true, get: function () { return errors_1.APIError; } });
|
|
24
32
|
// Export version
|
|
25
|
-
exports.VERSION = '
|
|
33
|
+
exports.VERSION = '1.2.0';
|
|
26
34
|
// Default export for convenience
|
|
27
35
|
const client_2 = require("./client");
|
|
28
36
|
exports.default = client_2.AxonFlow;
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +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;
|
|
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;AAE5B,iDAAiD;AACjD,mCAOkB;AANhB,uGAAA,aAAa,OAAA;AACb,8GAAA,oBAAoB,OAAA;AACpB,6GAAA,mBAAmB,OAAA;AACnB,wGAAA,cAAc,OAAA;AACd,sGAAA,YAAY,OAAA;AACZ,kGAAA,QAAQ,OAAA;AAsBV,iBAAiB;AACJ,QAAA,OAAO,GAAG,OAAO,CAAC;AAE/B,iCAAiC;AACjC,qCAAoC;AACpC,kBAAe,iBAAQ,CAAC"}
|
|
@@ -1 +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;
|
|
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;IAU/B,cAAc,CAAC,MAAM,EAAE,GAAG,GAAG,SAAS;IAsBtC,wBAAwB,CAAC,MAAM,EAAE,GAAG,EAAE,cAAc,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IAKxE,WAAW,IAAI,MAAM;CAGtB;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,eAAe,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,GAAG,GAAG,CA4B5E"}
|
|
@@ -10,9 +10,9 @@ class AnthropicInterceptor extends base_1.BaseInterceptor {
|
|
|
10
10
|
canHandle(aiCall) {
|
|
11
11
|
// Check if this looks like an Anthropic call
|
|
12
12
|
const callString = aiCall.toString();
|
|
13
|
-
return callString.includes('anthropic') ||
|
|
13
|
+
return (callString.includes('anthropic') ||
|
|
14
14
|
callString.includes('claude') ||
|
|
15
|
-
callString.includes('messages.create');
|
|
15
|
+
callString.includes('messages.create'));
|
|
16
16
|
}
|
|
17
17
|
extractRequest(aiCall) {
|
|
18
18
|
// Try to extract Anthropic-specific details
|
|
@@ -31,7 +31,7 @@ class AnthropicInterceptor extends base_1.BaseInterceptor {
|
|
|
31
31
|
prompt: callString,
|
|
32
32
|
parameters: {
|
|
33
33
|
// Would extract max_tokens, temperature, etc. in production
|
|
34
|
-
}
|
|
34
|
+
},
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
37
|
executeWithModifications(aiCall, _modifications) {
|
|
@@ -64,11 +64,11 @@ function wrapAnthropicClient(anthropicClient, axonflow) {
|
|
|
64
64
|
};
|
|
65
65
|
}
|
|
66
66
|
return messagesOriginal;
|
|
67
|
-
}
|
|
67
|
+
},
|
|
68
68
|
});
|
|
69
69
|
}
|
|
70
70
|
return original;
|
|
71
|
-
}
|
|
71
|
+
},
|
|
72
72
|
});
|
|
73
73
|
}
|
|
74
74
|
//# sourceMappingURL=anthropic.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anthropic.js","sourceRoot":"","sources":["../../../src/interceptors/anthropic.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"anthropic.js","sourceRoot":"","sources":["../../../src/interceptors/anthropic.ts"],"names":[],"mappings":";;;AAoDA,kDA4BC;AAhFD,iCAAyC;AAGzC;;GAEG;AACH,MAAa,oBAAqB,SAAQ,sBAAe;IACvD,SAAS,CAAC,MAAW;QACnB,6CAA6C;QAC7C,MAAM,UAAU,GAAG,MAAM,CAAC,QAAQ,EAAE,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,cAAc,EAAE,YAAY;wBAC9B,MAAM,gBAAgB,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,YAAY,CAAC,CAAC;wBAEnE,4BAA4B;wBAC5B,IAAI,YAAY,KAAK,QAAQ,IAAI,OAAO,gBAAgB,KAAK,UAAU,EAAE,CAAC;4BACxE,OAAO,KAAK,EAAE,GAAG,IAAW,EAAE,EAAE;gCAC9B,iCAAiC;gCACjC,OAAO,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,gBAAgB,CAAC,KAAK,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC,CAAC;4BAC9E,CAAC,CAAC;wBACJ,CAAC;wBAED,OAAO,gBAAgB,CAAC;oBAC1B,CAAC;iBACF,CAAC,CAAC;YACL,CAAC;YAED,OAAO,QAAQ,CAAC;QAClB,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1 +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;
|
|
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;IAW/B,cAAc,CAAC,MAAM,EAAE,GAAG,GAAG,SAAS;IAuBtC,wBAAwB,CAAC,MAAM,EAAE,GAAG,EAAE,cAAc,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IAMxE,WAAW,IAAI,MAAM;CAGtB;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,GAAG,GAAG,CAyBtE"}
|
|
@@ -10,10 +10,10 @@ class OpenAIInterceptor extends base_1.BaseInterceptor {
|
|
|
10
10
|
canHandle(aiCall) {
|
|
11
11
|
// Check if this looks like an OpenAI call
|
|
12
12
|
const callString = aiCall.toString();
|
|
13
|
-
return callString.includes('openai') ||
|
|
13
|
+
return (callString.includes('openai') ||
|
|
14
14
|
callString.includes('createCompletion') ||
|
|
15
15
|
callString.includes('createChatCompletion') ||
|
|
16
|
-
callString.includes('gpt');
|
|
16
|
+
callString.includes('gpt'));
|
|
17
17
|
}
|
|
18
18
|
extractRequest(aiCall) {
|
|
19
19
|
// Try to extract OpenAI-specific details
|
|
@@ -33,7 +33,7 @@ class OpenAIInterceptor extends base_1.BaseInterceptor {
|
|
|
33
33
|
prompt: callString,
|
|
34
34
|
parameters: {
|
|
35
35
|
// Would extract temperature, max_tokens, etc. in production
|
|
36
|
-
}
|
|
36
|
+
},
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
39
|
executeWithModifications(aiCall, _modifications) {
|
|
@@ -67,7 +67,7 @@ function wrapOpenAIClient(openaiClient, axonflow) {
|
|
|
67
67
|
return wrapOpenAIClient(original, axonflow);
|
|
68
68
|
}
|
|
69
69
|
return original;
|
|
70
|
-
}
|
|
70
|
+
},
|
|
71
71
|
});
|
|
72
72
|
}
|
|
73
73
|
//# sourceMappingURL=openai.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai.js","sourceRoot":"","sources":["../../../src/interceptors/openai.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"openai.js","sourceRoot":"","sources":["../../../src/interceptors/openai.ts"],"names":[],"mappings":";;;AAuDA,4CAyBC;AAhFD,iCAAyC;AA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AO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;YAErD,0CAA0C;YAC1C,IACE,OAAO,QAAQ,KAAK,UAAU;gBAC9B,CAAC,kBAAkB,EAAE,sBAAsB,EAAE,YAAY,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,EACpF,CAAC;gBACD,OAAO,KAAK,EAAE,GAAG,IAAW,EAAE,EAAE;oBAC9B,iCAAiC;oBACjC,OAAO,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;gBAC9D,CAAC,CAAC;YACJ,CAAC;YAED,oDAAoD;YACpD,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;gBACtD,OAAO,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;YAC9C,CAAC;YAED,OAAO,QAAQ,CAAC;QAClB,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gateway Mode Types
|
|
3
|
+
*
|
|
4
|
+
* Gateway Mode enables direct LLM calls with AxonFlow governance.
|
|
5
|
+
* Pre-check policies before calling your LLM, then audit the call afterward.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Token usage information for audit logging
|
|
9
|
+
*/
|
|
10
|
+
export interface TokenUsage {
|
|
11
|
+
promptTokens: number;
|
|
12
|
+
completionTokens: number;
|
|
13
|
+
totalTokens: number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Rate limit information returned from pre-check
|
|
17
|
+
*/
|
|
18
|
+
export interface RateLimitInfo {
|
|
19
|
+
limit: number;
|
|
20
|
+
remaining: number;
|
|
21
|
+
resetAt: Date;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Result from policy pre-check in Gateway Mode
|
|
25
|
+
*/
|
|
26
|
+
export interface PolicyApprovalResult {
|
|
27
|
+
/** Unique context ID for correlating pre-check with audit */
|
|
28
|
+
contextId: string;
|
|
29
|
+
/** Whether the request was approved */
|
|
30
|
+
approved: boolean;
|
|
31
|
+
/** Filtered/approved data to send to LLM */
|
|
32
|
+
approvedData: Record<string, unknown>;
|
|
33
|
+
/** List of policies that were evaluated */
|
|
34
|
+
policies: string[];
|
|
35
|
+
/** Rate limit information (if applicable) */
|
|
36
|
+
rateLimitInfo?: RateLimitInfo;
|
|
37
|
+
/** When this approval expires */
|
|
38
|
+
expiresAt: Date;
|
|
39
|
+
/** Reason for blocking (if not approved) */
|
|
40
|
+
blockReason?: string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Options for getting policy approval context
|
|
44
|
+
*/
|
|
45
|
+
export interface PolicyApprovalOptions {
|
|
46
|
+
/** User authentication token */
|
|
47
|
+
userToken: string;
|
|
48
|
+
/** The query/prompt to be sent to LLM */
|
|
49
|
+
query: string;
|
|
50
|
+
/** Data sources being accessed (for connector-based queries) */
|
|
51
|
+
dataSources?: string[];
|
|
52
|
+
/** Additional context for policy evaluation */
|
|
53
|
+
context?: Record<string, unknown>;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Result from audit logging in Gateway Mode
|
|
57
|
+
*/
|
|
58
|
+
export interface AuditResult {
|
|
59
|
+
/** Whether the audit was logged successfully */
|
|
60
|
+
success: boolean;
|
|
61
|
+
/** Unique audit ID for reference */
|
|
62
|
+
auditId: string;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Options for auditing an LLM call
|
|
66
|
+
*/
|
|
67
|
+
export interface AuditOptions {
|
|
68
|
+
/** Context ID from pre-check */
|
|
69
|
+
contextId: string;
|
|
70
|
+
/** Summary of LLM response (for compliance logging) */
|
|
71
|
+
responseSummary: string;
|
|
72
|
+
/** LLM provider (e.g., "openai", "anthropic", "bedrock") */
|
|
73
|
+
provider: string;
|
|
74
|
+
/** Model used (e.g., "gpt-4", "claude-3-opus") */
|
|
75
|
+
model: string;
|
|
76
|
+
/** Token usage from the LLM call */
|
|
77
|
+
tokenUsage: TokenUsage;
|
|
78
|
+
/** Latency in milliseconds */
|
|
79
|
+
latencyMs: number;
|
|
80
|
+
/** Additional metadata */
|
|
81
|
+
metadata?: Record<string, unknown>;
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=gateway.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gateway.d.ts","sourceRoot":"","sources":["../../../src/types/gateway.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,IAAI,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,6DAA6D;IAC7D,SAAS,EAAE,MAAM,CAAC;IAClB,uCAAuC;IACvC,QAAQ,EAAE,OAAO,CAAC;IAClB,4CAA4C;IAC5C,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtC,2CAA2C;IAC3C,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,6CAA6C;IAC7C,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,iCAAiC;IACjC,SAAS,EAAE,IAAI,CAAC;IAChB,4CAA4C;IAC5C,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,gCAAgC;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,yCAAyC;IACzC,KAAK,EAAE,MAAM,CAAC;IACd,gEAAgE;IAChE,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,+CAA+C;IAC/C,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,gDAAgD;IAChD,OAAO,EAAE,OAAO,CAAC;IACjB,oCAAoC;IACpC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,gCAAgC;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,uDAAuD;IACvD,eAAe,EAAE,MAAM,CAAC;IACxB,4DAA4D;IAC5D,QAAQ,EAAE,MAAM,CAAC;IACjB,kDAAkD;IAClD,KAAK,EAAE,MAAM,CAAC;IACd,oCAAoC;IACpC,UAAU,EAAE,UAAU,CAAC;IACvB,8BAA8B;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,0BAA0B;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Gateway Mode Types
|
|
4
|
+
*
|
|
5
|
+
* Gateway Mode enables direct LLM calls with AxonFlow governance.
|
|
6
|
+
* Pre-check policies before calling your LLM, then audit the call afterward.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
//# sourceMappingURL=gateway.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gateway.js","sourceRoot":"","sources":["../../../src/types/gateway.ts"],"names":[],"mappings":";AAAA;;;;;GAKG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC"}
|
package/dist/cjs/types/index.js
CHANGED
|
@@ -20,4 +20,5 @@ __exportStar(require("./response"), exports);
|
|
|
20
20
|
__exportStar(require("./policy"), exports);
|
|
21
21
|
__exportStar(require("./connector"), exports);
|
|
22
22
|
__exportStar(require("./planning"), exports);
|
|
23
|
+
__exportStar(require("./gateway"), exports);
|
|
23
24
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,4CAA0B;AAC1B,6CAA2B;AAC3B,2CAAyB;AACzB,8CAA4B;AAC5B,6CAA2B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,4CAA0B;AAC1B,6CAA2B;AAC3B,2CAAyB;AACzB,8CAA4B;AAC5B,6CAA2B;AAC3B,4CAA0B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/utils/helpers.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,IAAI,CAE1D;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE/C;AAED;;GAEG;AACH,wBAAgB,SAAS,IAAI,OAAO,CAEnC;AAED;;GAEG;AACH,wBAAgB,MAAM,IAAI,OAAO,
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/utils/helpers.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,IAAI,CAE1D;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE/C;AAED;;GAEG;AACH,wBAAgB,SAAS,IAAI,OAAO,CAEnC;AAED;;GAEG;AACH,wBAAgB,MAAM,IAAI,OAAO,CAMhC;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,CAW9C"}
|
|
@@ -34,7 +34,9 @@ function isBrowser() {
|
|
|
34
34
|
* Check if running in Node.js
|
|
35
35
|
*/
|
|
36
36
|
function isNode() {
|
|
37
|
-
return typeof process !== 'undefined' &&
|
|
37
|
+
return (typeof process !== 'undefined' &&
|
|
38
|
+
process.versions !== undefined &&
|
|
39
|
+
process.versions.node !== undefined);
|
|
38
40
|
}
|
|
39
41
|
/**
|
|
40
42
|
* Safe JSON stringify that handles circular references
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/utils/helpers.ts"],"names":[],"mappings":";;AAGA,8CAEC;AAKD,4BAEC;AAKD,sBAEC;AAKD,8BAEC;AAKD,
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/utils/helpers.ts"],"names":[],"mappings":";;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,EAAE,CAAC;YAChD,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;gBACpB,OAAO,YAAY,CAAC;YACtB,CAAC;YACD,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAClB,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/esm/client.d.ts
CHANGED
|
@@ -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
|
package/dist/esm/client.d.ts.map
CHANGED
|
@@ -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,
|
|
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,oBAAoB,EACpB,qBAAqB,EACrB,WAAW,EACX,YAAY,EACb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