@memorilabs/axon 0.1.3-beta → 0.1.3
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 +82 -67
- package/dist/core/axon.d.ts +39 -9
- package/dist/core/axon.d.ts.map +1 -1
- package/dist/core/axon.js +22 -12
- package/dist/core/axon.js.map +1 -1
- package/dist/errors/hook-error.d.ts.map +1 -1
- package/dist/errors/hook-error.js +1 -1
- package/dist/errors/hook-error.js.map +1 -1
- package/dist/errors/unsupported-provider-error.d.ts.map +1 -1
- package/dist/errors/unsupported-provider-error.js +2 -1
- package/dist/errors/unsupported-provider-error.js.map +1 -1
- package/dist/hooks/pipeline.d.ts +27 -0
- package/dist/hooks/pipeline.d.ts.map +1 -0
- package/dist/hooks/{registry.js → pipeline.js} +11 -9
- package/dist/hooks/pipeline.js.map +1 -0
- package/dist/llm/registry.d.ts +10 -4
- package/dist/llm/registry.d.ts.map +1 -1
- package/dist/llm/registry.js +9 -2
- package/dist/llm/registry.js.map +1 -1
- package/dist/providers/anthropic/common.d.ts.map +1 -1
- package/dist/providers/anthropic/common.js +4 -1
- package/dist/providers/anthropic/common.js.map +1 -1
- package/dist/providers/anthropic/detect.d.ts +5 -0
- package/dist/providers/anthropic/detect.d.ts.map +1 -1
- package/dist/providers/anthropic/detect.js +5 -0
- package/dist/providers/anthropic/detect.js.map +1 -1
- package/dist/providers/anthropic/proxy.d.ts.map +1 -1
- package/dist/providers/anthropic/proxy.js +17 -4
- package/dist/providers/anthropic/proxy.js.map +1 -1
- package/dist/providers/anthropic/responses.d.ts +22 -0
- package/dist/providers/anthropic/responses.d.ts.map +1 -0
- package/dist/providers/anthropic/responses.js +2 -0
- package/dist/providers/anthropic/responses.js.map +1 -0
- package/dist/providers/anthropic/types.d.ts +11 -27
- package/dist/providers/anthropic/types.d.ts.map +1 -1
- package/dist/providers/gemini/common.d.ts +8 -0
- package/dist/providers/gemini/common.d.ts.map +1 -0
- package/dist/providers/gemini/common.js +48 -0
- package/dist/providers/gemini/common.js.map +1 -0
- package/dist/providers/gemini/detect.d.ts +7 -0
- package/dist/providers/gemini/detect.d.ts.map +1 -0
- package/dist/providers/gemini/detect.js +12 -0
- package/dist/providers/gemini/detect.js.map +1 -0
- package/dist/providers/gemini/index.d.ts +5 -0
- package/dist/providers/gemini/index.d.ts.map +1 -0
- package/dist/providers/gemini/index.js +10 -0
- package/dist/providers/gemini/index.js.map +1 -0
- package/dist/providers/gemini/proxy.d.ts +3 -0
- package/dist/providers/gemini/proxy.d.ts.map +1 -0
- package/dist/providers/gemini/proxy.js +103 -0
- package/dist/providers/gemini/proxy.js.map +1 -0
- package/dist/providers/gemini/responses.d.ts +17 -0
- package/dist/providers/gemini/responses.d.ts.map +1 -0
- package/dist/providers/gemini/responses.js +2 -0
- package/dist/providers/gemini/responses.js.map +1 -0
- package/dist/providers/gemini/types.d.ts +31 -0
- package/dist/providers/gemini/types.d.ts.map +1 -0
- package/dist/providers/gemini/types.js +2 -0
- package/dist/providers/gemini/types.js.map +1 -0
- package/dist/providers/index.d.ts +1 -0
- package/dist/providers/index.d.ts.map +1 -1
- package/dist/providers/index.js +1 -0
- package/dist/providers/index.js.map +1 -1
- package/dist/providers/openai/detect.d.ts +5 -0
- package/dist/providers/openai/detect.d.ts.map +1 -1
- package/dist/providers/openai/detect.js +5 -0
- package/dist/providers/openai/detect.js.map +1 -1
- package/dist/providers/openai/proxy.d.ts.map +1 -1
- package/dist/providers/openai/proxy.js +7 -2
- package/dist/providers/openai/proxy.js.map +1 -1
- package/dist/providers/openai/responses.d.ts +9 -9
- package/dist/providers/openai/responses.d.ts.map +1 -1
- package/dist/providers/openai/types.d.ts +5 -0
- package/dist/providers/openai/types.d.ts.map +1 -1
- package/dist/providers/patcher.d.ts.map +1 -1
- package/dist/providers/patcher.js +2 -9
- package/dist/providers/patcher.js.map +1 -1
- package/dist/providers/telemetry.d.ts.map +1 -1
- package/dist/providers/telemetry.js +3 -0
- package/dist/providers/telemetry.js.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +1 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/llm.d.ts +15 -0
- package/dist/types/llm.d.ts.map +1 -1
- package/dist/types/registry.d.ts +14 -0
- package/dist/types/registry.d.ts.map +1 -0
- package/dist/types/registry.js +2 -0
- package/dist/types/registry.js.map +1 -0
- package/dist/utils/constants.d.ts +19 -0
- package/dist/utils/constants.d.ts.map +1 -0
- package/dist/utils/constants.js +14 -0
- package/dist/utils/constants.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +13 -5
- package/dist/hooks/registry.d.ts +0 -28
- package/dist/hooks/registry.d.ts.map +0 -1
- package/dist/hooks/registry.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,99 +1,114 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
[](https://memorilabs.ai/)
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<strong>The universal LLM interceptor and hook registry</strong>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<i>Axon plugs into the official LLM SDKs you already use. It allows you to seamlessly intercept, modify, and monitor LLM requests and responses through a unified hook system without changing your underlying application code.</i>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<a href="https://www.npmjs.com/package/@memorilabs/axon">
|
|
13
|
+
<img src="https://img.shields.io/npm/v/@memorilabs/axon.svg" alt="NPM version">
|
|
14
|
+
</a>
|
|
15
|
+
<a href="https://www.npmjs.com/package/@memorilabs/axon">
|
|
16
|
+
<img src="https://img.shields.io/npm/dm/@memorilabs/axon.svg" alt="NPM Downloads">
|
|
17
|
+
</a>
|
|
18
|
+
<a href="https://opensource.org/license/apache-2-0">
|
|
19
|
+
<img src="https://img.shields.io/badge/license-Apache%202.0-blue" alt="License">
|
|
20
|
+
</a>
|
|
21
|
+
<a href="https://discord.gg/abD4eGym6v">
|
|
22
|
+
<img src="https://img.shields.io/discord/1042405378304004156?logo=discord" alt="Discord">
|
|
23
|
+
</a>
|
|
24
|
+
</p>
|
|
4
25
|
|
|
5
26
|
---
|
|
6
27
|
|
|
7
|
-
##
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
# Install dependencies
|
|
11
|
-
npm install
|
|
12
|
-
|
|
13
|
-
# Format existing code
|
|
14
|
-
npm run format
|
|
28
|
+
## Getting Started
|
|
15
29
|
|
|
16
|
-
|
|
17
|
-
npm run typecheck
|
|
30
|
+
Install the Axon SDK and your preferred LLM client using your package manager of choice:
|
|
18
31
|
|
|
19
|
-
|
|
20
|
-
npm
|
|
32
|
+
```bash
|
|
33
|
+
npm install @memorilabs/axon
|
|
21
34
|
```
|
|
22
35
|
|
|
23
|
-
|
|
36
|
+
_(Note: Axon supports `openai`, `@anthropic-ai/sdk`, and `@google/genai` as optional peer dependencies)._
|
|
24
37
|
|
|
25
|
-
##
|
|
38
|
+
## Quickstart Example
|
|
26
39
|
|
|
27
|
-
|
|
40
|
+
```typescript
|
|
41
|
+
import 'dotenv/config';
|
|
42
|
+
import { OpenAI } from 'openai';
|
|
43
|
+
import { Axon } from '@memorilabs/axon';
|
|
28
44
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
| `npm run build` | Compile TypeScript to `dist/` |
|
|
32
|
-
| `npm run example` | Build and run example script |
|
|
45
|
+
// 1. Initialize the LLM Client
|
|
46
|
+
const client = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
|
|
33
47
|
|
|
34
|
-
|
|
48
|
+
// 2. Initialize Axon and Register the Client
|
|
49
|
+
const axon = new Axon();
|
|
50
|
+
axon.llm.register(client);
|
|
35
51
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
52
|
+
// 3. Register a Before Hook (e.g., logging or modifying prompts)
|
|
53
|
+
axon.hook.before((req, ctx) => {
|
|
54
|
+
console.log(`[${ctx.traceId}] Intercepted request to model: ${req.model}`);
|
|
55
|
+
// You can modify the request here before it hits the provider
|
|
56
|
+
return req;
|
|
57
|
+
});
|
|
40
58
|
|
|
41
|
-
|
|
59
|
+
// 4. Register an After Hook (e.g., token usage tracking)
|
|
60
|
+
axon.hook.after((req, res, ctx) => {
|
|
61
|
+
console.log(`[${ctx.traceId}] Received response. Tokens used: ${res.usage?.totalTokens}`);
|
|
62
|
+
});
|
|
42
63
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
| `npm run lint` | Check for linting issues |
|
|
46
|
-
| `npm run lint:fix` | Auto-fix linting issues |
|
|
47
|
-
| `npm run format` | Format all files with Prettier |
|
|
48
|
-
| `npm run format:check` | Check formatting without modifying files |
|
|
49
|
-
| `npm run typecheck` | Run TypeScript type checking (no build) |
|
|
64
|
+
async function main() {
|
|
65
|
+
console.log('Sending standard LLM request...');
|
|
50
66
|
|
|
51
|
-
|
|
67
|
+
// 5. Use your client exactly as you normally would!
|
|
68
|
+
// Axon intercepts this call in the background.
|
|
69
|
+
const response = await client.chat.completions.create({
|
|
70
|
+
model: 'gpt-4o',
|
|
71
|
+
messages: [{ role: 'user', content: 'What is the speed of light?' }],
|
|
72
|
+
});
|
|
52
73
|
|
|
53
|
-
|
|
74
|
+
console.log(`AI: ${response.choices[0].message.content}`);
|
|
75
|
+
}
|
|
54
76
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
### Pre-commit Hook
|
|
77
|
+
main().catch(console.error);
|
|
78
|
+
```
|
|
58
79
|
|
|
59
|
-
|
|
80
|
+
## Key Features
|
|
60
81
|
|
|
61
|
-
-
|
|
62
|
-
-
|
|
63
|
-
-
|
|
82
|
+
- **Universal LLM Support:** Works natively with OpenAI, Anthropic Claude, and Google Gemini SDKs.
|
|
83
|
+
- **Unified Hook System:** Write your logic once. Axon normalizes requests and responses across all providers so your hooks work universally.
|
|
84
|
+
- **Zero Overhead:** Plugs directly into your existing client initialization. No need to rewrite your agent or application logic.
|
|
85
|
+
- **Streaming Support:** Seamlessly handles and aggregates asynchronous streaming responses.
|
|
86
|
+
- **Type-Safe:** Written in strict TypeScript with comprehensive definitions for all provider payloads.
|
|
64
87
|
|
|
65
|
-
|
|
88
|
+
## Supported LLMs
|
|
66
89
|
|
|
67
|
-
|
|
90
|
+
- OpenAI (`openai`)
|
|
91
|
+
- Anthropic Claude (`@anthropic-ai/sdk`)
|
|
92
|
+
- Google Gemini (`@google/genai`)
|
|
68
93
|
|
|
69
|
-
|
|
94
|
+
## Contributing
|
|
70
95
|
|
|
71
|
-
|
|
96
|
+
We welcome contributions from the community! Please see our [Contributing Guidelines](https://github.com/MemoriLabs/axon/blob/main/CONTRIBUTING.md) for details on:
|
|
72
97
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
98
|
+
- Setting up your development environment
|
|
99
|
+
- Code style and standards
|
|
100
|
+
- Submitting pull requests
|
|
101
|
+
- Reporting issues
|
|
77
102
|
|
|
78
103
|
---
|
|
79
104
|
|
|
80
|
-
##
|
|
105
|
+
## Support
|
|
81
106
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
├── src/ # Source code
|
|
85
|
-
├── tests/ # Test files
|
|
86
|
-
├── examples/ # Example scripts
|
|
87
|
-
├── dist/ # Compiled output (generated)
|
|
88
|
-
└── ...config files
|
|
89
|
-
```
|
|
107
|
+
- **Discord**: [https://discord.gg/abD4eGym6v](https://discord.gg/abD4eGym6v)
|
|
108
|
+
- **Issues**: [GitHub Issues](https://github.com/MemoriLabs/axon/issues)
|
|
90
109
|
|
|
91
110
|
---
|
|
92
111
|
|
|
93
|
-
##
|
|
112
|
+
## License
|
|
94
113
|
|
|
95
|
-
|
|
96
|
-
2. Run `npm run lint:fix` to auto-fix issues
|
|
97
|
-
3. Run `npm run typecheck` to verify types
|
|
98
|
-
4. Commit your changes (hooks run automatically)
|
|
99
|
-
5. Push to remote (type check runs automatically)
|
|
114
|
+
Apache 2.0 - see [LICENSE](https://github.com/MemoriLabs/axon/blob/main/LICENSE)
|
package/dist/core/axon.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { HookRegistry } from '../hooks/registry.js';
|
|
2
1
|
import { LLMRegistry } from '../llm/registry.js';
|
|
3
|
-
import { CallContext, LLMRequest, LLMResponse } from '../types/index.js';
|
|
2
|
+
import { AfterHook, BeforeHook, CallContext, LLMRequest, LLMResponse } from '../types/index.js';
|
|
4
3
|
/**
|
|
5
4
|
* The central hub for the Axon SDK.
|
|
6
5
|
*
|
|
@@ -9,7 +8,7 @@ import { CallContext, LLMRequest, LLMResponse } from '../types/index.js';
|
|
|
9
8
|
* - Hook execution (before/after calls).
|
|
10
9
|
* @example
|
|
11
10
|
* ```ts
|
|
12
|
-
* import { Axon } from 'axon';
|
|
11
|
+
* import { Axon } from '@memorilabs/axon';
|
|
13
12
|
* import { OpenAI } from 'openai';
|
|
14
13
|
*
|
|
15
14
|
* const axon = new Axon();
|
|
@@ -19,8 +18,8 @@ import { CallContext, LLMRequest, LLMResponse } from '../types/index.js';
|
|
|
19
18
|
* axon.llm.register(client);
|
|
20
19
|
*
|
|
21
20
|
* // 2. Add hooks
|
|
22
|
-
* axon.before
|
|
23
|
-
* console.log(
|
|
21
|
+
* axon.hook.before((req, ctx) => {
|
|
22
|
+
* console.log(`[${ctx.traceId}] Sending to: ${req.model}`);
|
|
24
23
|
* return req;
|
|
25
24
|
* });
|
|
26
25
|
*
|
|
@@ -31,10 +30,41 @@ import { CallContext, LLMRequest, LLMResponse } from '../types/index.js';
|
|
|
31
30
|
export declare class Axon {
|
|
32
31
|
/** Registry for managing third-party LLM providers. */
|
|
33
32
|
readonly llm: LLMRegistry;
|
|
34
|
-
/**
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
readonly
|
|
33
|
+
/** * Namespace for registering LLM lifecycle hooks.
|
|
34
|
+
* Hooks allow you to intercept, observe, and modify requests and responses.
|
|
35
|
+
*/
|
|
36
|
+
readonly hook: {
|
|
37
|
+
/**
|
|
38
|
+
* Registers a hook function to run *before* the LLM call is executed.
|
|
39
|
+
* Hooks are executed sequentially in the order they are added.
|
|
40
|
+
*
|
|
41
|
+
* @param fn - The hook function to execute. It can optionally return a modified request, or a Promise resolving to one.
|
|
42
|
+
* @example
|
|
43
|
+
* ```ts
|
|
44
|
+
* axon.hook.before((req, ctx) => {
|
|
45
|
+
* console.log(`[${ctx.traceId}] Sending prompt to ${req.model}`);
|
|
46
|
+
* return req;
|
|
47
|
+
* });
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
before: (fn: BeforeHook) => void;
|
|
51
|
+
/**
|
|
52
|
+
* Registers a hook function to run *after* the LLM call completes or streams.
|
|
53
|
+
* Hooks are executed sequentially in the order they are added.
|
|
54
|
+
*
|
|
55
|
+
* @param fn - The hook function to execute. It can optionally return a modified response, or a Promise resolving to one.
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* axon.hook.after((req, res, ctx) => {
|
|
59
|
+
* console.log(`[${ctx.traceId}] Received ${res.usage?.totalTokens} tokens`);
|
|
60
|
+
* console.log(`[${ctx.traceId}] AI Response: ${res.content}`);
|
|
61
|
+
* });
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
after: (fn: AfterHook) => void;
|
|
65
|
+
};
|
|
66
|
+
private readonly beforePipeline;
|
|
67
|
+
private readonly afterPipeline;
|
|
38
68
|
/**
|
|
39
69
|
* Creates a new Axon instance.
|
|
40
70
|
*/
|
package/dist/core/axon.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"axon.d.ts","sourceRoot":"","sources":["../../src/core/axon.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"axon.d.ts","sourceRoot":"","sources":["../../src/core/axon.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhG;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,qBAAa,IAAI;IACf,uDAAuD;IACvD,SAAgB,GAAG,EAAE,WAAW,CAAC;IAEjC;;OAEG;IACH,SAAgB,IAAI,EAAE;QACpB;;;;;;;;;;;;WAYG;QACH,MAAM,EAAE,CAAC,EAAE,EAAE,UAAU,KAAK,IAAI,CAAC;QAEjC;;;;;;;;;;;;WAYG;QACH,KAAK,EAAE,CAAC,EAAE,EAAE,SAAS,KAAK,IAAI,CAAC;KAChC,CAAC;IAEF,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAyB;IACxD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAwB;IAEtD;;OAEG;;IAgBH;;;OAGG;IACG,SAAS,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC;IAI3E;;;OAGG;IACG,QAAQ,CACZ,OAAO,EAAE,UAAU,EACnB,QAAQ,EAAE,WAAW,EACrB,GAAG,EAAE,WAAW,GACf,OAAO,CAAC,WAAW,CAAC;CAGxB"}
|
package/dist/core/axon.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HookPipeline } from '../hooks/pipeline.js';
|
|
2
2
|
import { LLMRegistry } from '../llm/registry.js';
|
|
3
3
|
/**
|
|
4
4
|
* The central hub for the Axon SDK.
|
|
@@ -8,7 +8,7 @@ import { LLMRegistry } from '../llm/registry.js';
|
|
|
8
8
|
* - Hook execution (before/after calls).
|
|
9
9
|
* @example
|
|
10
10
|
* ```ts
|
|
11
|
-
* import { Axon } from 'axon';
|
|
11
|
+
* import { Axon } from '@memorilabs/axon';
|
|
12
12
|
* import { OpenAI } from 'openai';
|
|
13
13
|
*
|
|
14
14
|
* const axon = new Axon();
|
|
@@ -18,8 +18,8 @@ import { LLMRegistry } from '../llm/registry.js';
|
|
|
18
18
|
* axon.llm.register(client);
|
|
19
19
|
*
|
|
20
20
|
* // 2. Add hooks
|
|
21
|
-
* axon.before
|
|
22
|
-
* console.log(
|
|
21
|
+
* axon.hook.before((req, ctx) => {
|
|
22
|
+
* console.log(`[${ctx.traceId}] Sending to: ${req.model}`);
|
|
23
23
|
* return req;
|
|
24
24
|
* });
|
|
25
25
|
*
|
|
@@ -30,31 +30,41 @@ import { LLMRegistry } from '../llm/registry.js';
|
|
|
30
30
|
export class Axon {
|
|
31
31
|
/** Registry for managing third-party LLM providers. */
|
|
32
32
|
llm;
|
|
33
|
-
/**
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
/** * Namespace for registering LLM lifecycle hooks.
|
|
34
|
+
* Hooks allow you to intercept, observe, and modify requests and responses.
|
|
35
|
+
*/
|
|
36
|
+
hook;
|
|
37
|
+
beforePipeline;
|
|
38
|
+
afterPipeline;
|
|
37
39
|
/**
|
|
38
40
|
* Creates a new Axon instance.
|
|
39
41
|
*/
|
|
40
42
|
constructor() {
|
|
41
43
|
this.llm = new LLMRegistry(this);
|
|
42
|
-
this.
|
|
43
|
-
this.
|
|
44
|
+
this.beforePipeline = new HookPipeline('before');
|
|
45
|
+
this.afterPipeline = new HookPipeline('after');
|
|
46
|
+
this.hook = {
|
|
47
|
+
before: (fn) => {
|
|
48
|
+
this.beforePipeline.add(fn);
|
|
49
|
+
},
|
|
50
|
+
after: (fn) => {
|
|
51
|
+
this.afterPipeline.add(fn);
|
|
52
|
+
},
|
|
53
|
+
};
|
|
44
54
|
}
|
|
45
55
|
/**
|
|
46
56
|
* Executes the 'before' hook pipeline.
|
|
47
57
|
* @internal
|
|
48
58
|
*/
|
|
49
59
|
async runBefore(request, ctx) {
|
|
50
|
-
return (await this.
|
|
60
|
+
return (await this.beforePipeline.execute(request, ctx));
|
|
51
61
|
}
|
|
52
62
|
/**
|
|
53
63
|
* Executes the 'after' hook pipeline.
|
|
54
64
|
* @internal
|
|
55
65
|
*/
|
|
56
66
|
async runAfter(request, response, ctx) {
|
|
57
|
-
return (await this.
|
|
67
|
+
return (await this.afterPipeline.execute(request, response, ctx));
|
|
58
68
|
}
|
|
59
69
|
}
|
|
60
70
|
//# sourceMappingURL=axon.js.map
|
package/dist/core/axon.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"axon.js","sourceRoot":"","sources":["../../src/core/axon.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAGjD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,OAAO,IAAI;IACf,uDAAuD;IACvC,GAAG,CAAc;
|
|
1
|
+
{"version":3,"file":"axon.js","sourceRoot":"","sources":["../../src/core/axon.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAGjD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,OAAO,IAAI;IACf,uDAAuD;IACvC,GAAG,CAAc;IAEjC;;OAEG;IACa,IAAI,CA8BlB;IAEe,cAAc,CAAyB;IACvC,aAAa,CAAwB;IAEtD;;OAEG;IACH;QACE,IAAI,CAAC,GAAG,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC;QACjC,IAAI,CAAC,cAAc,GAAG,IAAI,YAAY,CAAC,QAAQ,CAAC,CAAC;QACjD,IAAI,CAAC,aAAa,GAAG,IAAI,YAAY,CAAC,OAAO,CAAC,CAAC;QAE/C,IAAI,CAAC,IAAI,GAAG;YACV,MAAM,EAAE,CAAC,EAAc,EAAE,EAAE;gBACzB,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAC9B,CAAC;YACD,KAAK,EAAE,CAAC,EAAa,EAAE,EAAE;gBACvB,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAC7B,CAAC;SACF,CAAC;IACJ,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,SAAS,CAAC,OAAmB,EAAE,GAAgB;QACnD,OAAO,CAAC,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAe,CAAC;IACzE,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,QAAQ,CACZ,OAAmB,EACnB,QAAqB,EACrB,GAAgB;QAEhB,OAAO,CAAC,MAAM,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,OAAO,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAgB,CAAC;IACnF,CAAC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hook-error.d.ts","sourceRoot":"","sources":["../../src/errors/hook-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C;;GAEG;AACH,qBAAa,aAAc,SAAQ,SAAS;IAC1C,SAAgB,IAAI,EAAE,aAAa,GAAG,YAAY,CAAC;IACnD,SAAgB,KAAK,EAAE,OAAO,CAAC;gBAEnB,IAAI,EAAE;QAAE,IAAI,EAAE,aAAa,GAAG,YAAY,CAAC;QAAC,KAAK,EAAE,OAAO,CAAA;KAAE;
|
|
1
|
+
{"version":3,"file":"hook-error.d.ts","sourceRoot":"","sources":["../../src/errors/hook-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C;;GAEG;AACH,qBAAa,aAAc,SAAQ,SAAS;IAC1C,SAAgB,IAAI,EAAE,aAAa,GAAG,YAAY,CAAC;IACnD,SAAgB,KAAK,EAAE,OAAO,CAAC;gBAEnB,IAAI,EAAE;QAAE,IAAI,EAAE,aAAa,GAAG,YAAY,CAAC;QAAC,KAAK,EAAE,OAAO,CAAA;KAAE;CAQzE"}
|
|
@@ -6,7 +6,7 @@ export class AxonHookError extends AxonError {
|
|
|
6
6
|
hook;
|
|
7
7
|
cause;
|
|
8
8
|
constructor(opts) {
|
|
9
|
-
super(
|
|
9
|
+
super(`Axon '${opts.hook}' hook failed during execution. Check your registered hook implementation. Underlying cause: ${String(opts.cause)}`);
|
|
10
10
|
this.name = 'AxonHookError';
|
|
11
11
|
this.hook = opts.hook;
|
|
12
12
|
this.cause = opts.cause;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hook-error.js","sourceRoot":"","sources":["../../src/errors/hook-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C;;GAEG;AACH,MAAM,OAAO,aAAc,SAAQ,SAAS;IAC1B,IAAI,CAA+B;IACnC,KAAK,CAAU;IAE/B,YAAY,IAA4D;QACtE,KAAK,
|
|
1
|
+
{"version":3,"file":"hook-error.js","sourceRoot":"","sources":["../../src/errors/hook-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C;;GAEG;AACH,MAAM,OAAO,aAAc,SAAQ,SAAS;IAC1B,IAAI,CAA+B;IACnC,KAAK,CAAU;IAE/B,YAAY,IAA4D;QACtE,KAAK,CACH,SAAS,IAAI,CAAC,IAAI,gGAAgG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CACvI,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;QAC5B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACtB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;IAC1B,CAAC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unsupported-provider-error.d.ts","sourceRoot":"","sources":["../../src/errors/unsupported-provider-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"unsupported-provider-error.d.ts","sourceRoot":"","sources":["../../src/errors/unsupported-provider-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C;;GAEG;AACH,qBAAa,2BAA4B,SAAQ,SAAS;IACxD,SAAgB,QAAQ,EAAE,MAAM,CAAC;gBAErB,QAAQ,EAAE,MAAM;CAO7B"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { AxonError } from './axon-error.js';
|
|
2
|
+
import { SUPPORTED_PROVIDERS } from '../utils/constants.js';
|
|
2
3
|
/**
|
|
3
4
|
* Thrown when attempting to register a client that Axon does not recognize.
|
|
4
5
|
*/
|
|
5
6
|
export class UnsupportedLLMProviderError extends AxonError {
|
|
6
7
|
provider;
|
|
7
8
|
constructor(provider) {
|
|
8
|
-
super(`Unsupported LLM provider: ${provider}
|
|
9
|
+
super(`Unsupported LLM provider: '${provider}'. Axon currently supports patching: ${SUPPORTED_PROVIDERS.join(', ')}. Ensure you are passing an initialized client instance.`);
|
|
9
10
|
this.name = 'UnsupportedLLMProviderError';
|
|
10
11
|
this.provider = provider;
|
|
11
12
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unsupported-provider-error.js","sourceRoot":"","sources":["../../src/errors/unsupported-provider-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"unsupported-provider-error.js","sourceRoot":"","sources":["../../src/errors/unsupported-provider-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D;;GAEG;AACH,MAAM,OAAO,2BAA4B,SAAQ,SAAS;IACxC,QAAQ,CAAS;IAEjC,YAAY,QAAgB;QAC1B,KAAK,CACH,8BAA8B,QAAQ,wCAAwC,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,0DAA0D,CACvK,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,6BAA6B,CAAC;QAC1C,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;CACF"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { AfterHook, BeforeHook } from '../types/index.js';
|
|
2
|
+
export type HookType<P> = P extends 'before' ? BeforeHook : AfterHook;
|
|
3
|
+
/**
|
|
4
|
+
* Manages and executes a sequential pipeline of lifecycle hooks.
|
|
5
|
+
* This is an internal execution engine for `axon.hooks`.
|
|
6
|
+
*
|
|
7
|
+
* @typeParam P - The lifecycle phase this pipeline manages ('before' or 'after').
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export declare class HookPipeline<P extends 'before' | 'after'> {
|
|
11
|
+
private readonly phase;
|
|
12
|
+
private hooks;
|
|
13
|
+
constructor(phase: P);
|
|
14
|
+
/**
|
|
15
|
+
* Adds a new hook function to the pipeline.
|
|
16
|
+
* Hooks are executed sequentially in the order they are added.
|
|
17
|
+
*
|
|
18
|
+
* @param fn - The hook function to add to the pipeline.
|
|
19
|
+
*/
|
|
20
|
+
add(fn: HookType<P>): void;
|
|
21
|
+
/**
|
|
22
|
+
* Executes the pipeline of hooks in sequence.
|
|
23
|
+
* @internal
|
|
24
|
+
*/
|
|
25
|
+
execute(...args: unknown[]): Promise<unknown>;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=pipeline.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../src/hooks/pipeline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAwC,MAAM,mBAAmB,CAAC;AAEhG,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI,CAAC,SAAS,QAAQ,GAAG,UAAU,GAAG,SAAS,CAAC;AAEtE;;;;;;GAMG;AACH,qBAAa,YAAY,CAAC,CAAC,SAAS,QAAQ,GAAG,OAAO;IAGxC,OAAO,CAAC,QAAQ,CAAC,KAAK;IAFlC,OAAO,CAAC,KAAK,CAA0B;gBAEV,KAAK,EAAE,CAAC;IAErC;;;;;OAKG;IACH,GAAG,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI;IAI1B;;;OAGG;IACG,OAAO,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;CAyBpD"}
|
|
@@ -1,25 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Manages a
|
|
2
|
+
* Manages and executes a sequential pipeline of lifecycle hooks.
|
|
3
|
+
* This is an internal execution engine for `axon.hooks`.
|
|
3
4
|
*
|
|
4
|
-
* @
|
|
5
|
+
* @typeParam P - The lifecycle phase this pipeline manages ('before' or 'after').
|
|
6
|
+
* @internal
|
|
5
7
|
*/
|
|
6
|
-
export class
|
|
8
|
+
export class HookPipeline {
|
|
7
9
|
phase;
|
|
8
10
|
hooks = [];
|
|
9
11
|
constructor(phase) {
|
|
10
12
|
this.phase = phase;
|
|
11
13
|
}
|
|
12
14
|
/**
|
|
13
|
-
*
|
|
14
|
-
* Hooks are executed sequentially in the order they are
|
|
15
|
+
* Adds a new hook function to the pipeline.
|
|
16
|
+
* Hooks are executed sequentially in the order they are added.
|
|
15
17
|
*
|
|
16
|
-
* @param fn - The hook function to
|
|
18
|
+
* @param fn - The hook function to add to the pipeline.
|
|
17
19
|
*/
|
|
18
|
-
|
|
20
|
+
add(fn) {
|
|
19
21
|
this.hooks.push(fn);
|
|
20
22
|
}
|
|
21
23
|
/**
|
|
22
|
-
* Executes
|
|
24
|
+
* Executes the pipeline of hooks in sequence.
|
|
23
25
|
* @internal
|
|
24
26
|
*/
|
|
25
27
|
async execute(...args) {
|
|
@@ -47,4 +49,4 @@ export class HookRegistry {
|
|
|
47
49
|
return undefined;
|
|
48
50
|
}
|
|
49
51
|
}
|
|
50
|
-
//# sourceMappingURL=
|
|
52
|
+
//# sourceMappingURL=pipeline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline.js","sourceRoot":"","sources":["../../src/hooks/pipeline.ts"],"names":[],"mappings":"AAIA;;;;;;GAMG;AACH,MAAM,OAAO,YAAY;IAGM;IAFrB,KAAK,GAAuB,EAAE,CAAC;IAEvC,YAA6B,KAAQ;QAAR,UAAK,GAAL,KAAK,CAAG;IAAG,CAAC;IAEzC;;;;;OAKG;IACH,GAAG,CAAC,EAAe;QACjB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACtB,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,OAAO,CAAC,GAAG,IAAe;QAC9B,IAAI,IAAI,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC5B,IAAI,UAAU,GAAG,IAAI,CAAC,CAAC,CAAe,CAAC;YACvC,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAgB,CAAC;YAEnC,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAqB,EAAE,CAAC;gBAC9C,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;gBAC3C,IAAI,MAAM;oBAAE,UAAU,GAAG,MAAM,CAAC;YAClC,CAAC;YACD,OAAO,UAAU,CAAC;QACpB,CAAC;QAED,IAAI,IAAI,CAAC,KAAK,KAAK,OAAO,EAAE,CAAC;YAC3B,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAe,CAAC;YAClC,IAAI,UAAU,GAAG,IAAI,CAAC,CAAC,CAAgB,CAAC;YACxC,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAgB,CAAC;YAEnC,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAoB,EAAE,CAAC;gBAC7C,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,EAAE,UAAU,EAAE,GAAG,CAAC,CAAC;gBAChD,IAAI,MAAM;oBAAE,UAAU,GAAG,MAAM,CAAC;YAClC,CAAC;YACD,OAAO,UAAU,CAAC;QACpB,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;CACF"}
|
package/dist/llm/registry.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { Axon } from '../core/axon.js';
|
|
2
|
-
|
|
3
|
-
export type ClientPatcher = (client: unknown, axon: Axon) => void;
|
|
2
|
+
import { ClientMatcher, ClientPatcher } from '@/types/registry.js';
|
|
4
3
|
/**
|
|
5
4
|
* Manages the detection and patching of third-party LLM clients.
|
|
6
5
|
* This registry acts as the bridge between Axon and libraries like `openai`, `anthropic`, etc.
|
|
@@ -20,9 +19,16 @@ export declare class LLMRegistry {
|
|
|
20
19
|
/**
|
|
21
20
|
* Patches a third-party client instance to route calls through Axon.
|
|
22
21
|
*
|
|
23
|
-
* @param client - The initialized LLM client instance
|
|
22
|
+
* @param client - The initialized LLM client instance.
|
|
24
23
|
* @returns The Axon instance for method chaining.
|
|
25
|
-
* @throws
|
|
24
|
+
* @throws UnsupportedLLMProviderError If the provided client is not supported or recognized.
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* const axon = new Axon();
|
|
28
|
+
* const openai = new OpenAI({ apiKey: '...' });
|
|
29
|
+
* * // Patch the client
|
|
30
|
+
* axon.llm.register(openai);
|
|
31
|
+
* ```
|
|
26
32
|
*/
|
|
27
33
|
register(client: unknown): Axon;
|
|
28
34
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/llm/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/llm/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAQnE;;;GAGG;AACH,qBAAa,WAAW;IAGV,OAAO,CAAC,QAAQ,CAAC,IAAI;IAFjC,OAAO,CAAC,MAAM,CAAC,mBAAmB,CAA8B;gBAEnC,IAAI,EAAE,IAAI;IAEvC;;;;;;OAMG;IACH,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,aAAa,GAAG,IAAI;IAI7E;;;;;;;;;;;;;OAaG;IACH,QAAQ,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI;CAahC"}
|
package/dist/llm/registry.js
CHANGED
|
@@ -22,9 +22,16 @@ export class LLMRegistry {
|
|
|
22
22
|
/**
|
|
23
23
|
* Patches a third-party client instance to route calls through Axon.
|
|
24
24
|
*
|
|
25
|
-
* @param client - The initialized LLM client instance
|
|
25
|
+
* @param client - The initialized LLM client instance.
|
|
26
26
|
* @returns The Axon instance for method chaining.
|
|
27
|
-
* @throws
|
|
27
|
+
* @throws UnsupportedLLMProviderError If the provided client is not supported or recognized.
|
|
28
|
+
* @example
|
|
29
|
+
* ```ts
|
|
30
|
+
* const axon = new Axon();
|
|
31
|
+
* const openai = new OpenAI({ apiKey: '...' });
|
|
32
|
+
* * // Patch the client
|
|
33
|
+
* axon.llm.register(openai);
|
|
34
|
+
* ```
|
|
28
35
|
*/
|
|
29
36
|
register(client) {
|
|
30
37
|
for (const reg of LLMRegistry.globalRegistrations) {
|
package/dist/llm/registry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/llm/registry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/llm/registry.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AAOjE;;;GAGG;AACH,MAAM,OAAO,WAAW;IAGO;IAFrB,MAAM,CAAC,mBAAmB,GAA2B,EAAE,CAAC;IAEhE,YAA6B,IAAU;QAAV,SAAI,GAAJ,IAAI,CAAM;IAAG,CAAC;IAE3C;;;;;;OAMG;IACH,MAAM,CAAC,gBAAgB,CAAC,OAAsB,EAAE,OAAsB;QACpE,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;IACtD,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,QAAQ,CAAC,MAAe;QACtB,KAAK,MAAM,GAAG,IAAI,WAAW,CAAC,mBAAmB,EAAE,CAAC;YAClD,IAAI,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;gBACxB,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;gBAC/B,OAAO,IAAI,CAAC,IAAI,CAAC;YACnB,CAAC;QACH,CAAC;QAED,6DAA6D;QAC7D,MAAM,UAAU,GACb,MAAqD,EAAE,WAAW,EAAE,IAAI,IAAI,OAAO,MAAM,CAAC;QAC7F,MAAM,IAAI,2BAA2B,CAAC,UAAU,CAAC,CAAC;IACpD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/providers/anthropic/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,EAAE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/providers/anthropic/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAG9C,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,EAAE,CAgBlE;AAED,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,UAAU,GAAG,gBAAgB,EAAE,CAQhF;AAED,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,OAAO,GAAG,MAAM,CAS9D;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,OAAO,GAAG,KAAK,GAAG,SAAS,CASvE;AAED,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,GAAG,IAAI,CAYjF"}
|
|
@@ -17,7 +17,10 @@ export function anthropicInputToMessages(input) {
|
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
19
|
export function messagesToAnthropicInput(request) {
|
|
20
|
-
|
|
20
|
+
// Filter out system messages, they'll be handled separately
|
|
21
|
+
return request.messages
|
|
22
|
+
.filter((m) => m.role !== 'system')
|
|
23
|
+
.map((m) => ({
|
|
21
24
|
role: m.role,
|
|
22
25
|
content: m.content,
|
|
23
26
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/providers/anthropic/common.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/providers/anthropic/common.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,2 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Detects if the provided object is an initialized Anthropic client instance.
|
|
3
|
+
* @param client - The object to inspect.
|
|
4
|
+
* @returns True if it matches the Anthropic client shape.
|
|
5
|
+
*/
|
|
1
6
|
export declare function isAnthropicClient(client: unknown): boolean;
|
|
2
7
|
//# sourceMappingURL=detect.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detect.d.ts","sourceRoot":"","sources":["../../../src/providers/anthropic/detect.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"detect.d.ts","sourceRoot":"","sources":["../../../src/providers/anthropic/detect.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAK1D"}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Detects if the provided object is an initialized Anthropic client instance.
|
|
3
|
+
* @param client - The object to inspect.
|
|
4
|
+
* @returns True if it matches the Anthropic client shape.
|
|
5
|
+
*/
|
|
1
6
|
export function isAnthropicClient(client) {
|
|
2
7
|
if (!client || typeof client !== 'object')
|
|
3
8
|
return false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detect.js","sourceRoot":"","sources":["../../../src/providers/anthropic/detect.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"detect.js","sourceRoot":"","sources":["../../../src/providers/anthropic/detect.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAe;IAC/C,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IACxD,MAAM,GAAG,GAAG,MAAyB,CAAC;IAEtC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,IAAI,OAAO,GAAG,CAAC,QAAQ,CAAC,MAAM,KAAK,UAAU,CAAC,CAAC;AACvE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxy.d.ts","sourceRoot":"","sources":["../../../src/providers/anthropic/proxy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"proxy.d.ts","sourceRoot":"","sources":["../../../src/providers/anthropic/proxy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAqE/C;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,CAmBtE"}
|