@amitdeshmukh/ax-crew 3.11.3 → 4.0.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/CHANGELOG.md +24 -0
- package/README.md +31 -62
- package/dist/agents/agentConfig.d.ts +6 -6
- package/dist/agents/agentConfig.js +39 -32
- package/dist/agents/index.d.ts +13 -10
- package/dist/agents/index.js +154 -40
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/metrics/index.d.ts +2 -0
- package/dist/metrics/index.js +2 -0
- package/dist/metrics/registry.d.ts +9 -0
- package/dist/metrics/registry.js +138 -0
- package/dist/metrics/types.d.ts +40 -0
- package/dist/metrics/types.js +1 -0
- package/dist/types.d.ts +6 -6
- package/examples/basic-researcher-writer.ts +18 -13
- package/examples/mcp-agent.ts +12 -8
- package/examples/solve-math-problem.ts +7 -5
- package/examples/streaming.ts +7 -6
- package/package.json +5 -3
- package/src/agents/agentConfig.ts +44 -38
- package/src/agents/index.ts +168 -59
- package/src/index.ts +2 -0
- package/src/metrics/index.ts +4 -0
- package/src/metrics/registry.ts +167 -0
- package/src/metrics/types.ts +48 -0
- package/src/types.ts +23 -7
- package/tests/AxCrew.test.ts +22 -18
package/tests/AxCrew.test.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { describe, test, expect, beforeEach } from 'vitest';
|
|
2
2
|
import { AxCrew } from '../src/agents';
|
|
3
3
|
import { AxCrewFunctions } from '../src/functions';
|
|
4
|
+
import type { AxCrewConfig } from '../src/index.js';
|
|
5
|
+
|
|
6
|
+
// Provide dummy API key for tests
|
|
7
|
+
process.env.ANTHROPIC_API_KEY = process.env.ANTHROPIC_API_KEY || 'test';
|
|
4
8
|
|
|
5
9
|
describe('AxCrew', () => {
|
|
6
10
|
// Basic initialization tests
|
|
@@ -10,7 +14,7 @@ describe('AxCrew', () => {
|
|
|
10
14
|
crew: [{
|
|
11
15
|
name: "ResearchAgent",
|
|
12
16
|
description: "A research agent that can search the web for information and provide detailed analysis of search results with proper citations",
|
|
13
|
-
signature: "
|
|
17
|
+
signature: "query:string -> queryResponse:string",
|
|
14
18
|
provider: "anthropic",
|
|
15
19
|
providerKeyName: "ANTHROPIC_API_KEY",
|
|
16
20
|
ai: {
|
|
@@ -19,7 +23,7 @@ describe('AxCrew', () => {
|
|
|
19
23
|
}]
|
|
20
24
|
};
|
|
21
25
|
|
|
22
|
-
const crew = new AxCrew(config, AxCrewFunctions);
|
|
26
|
+
const crew = new AxCrew(config as AxCrewConfig, AxCrewFunctions);
|
|
23
27
|
expect(crew).toBeInstanceOf(AxCrew);
|
|
24
28
|
});
|
|
25
29
|
|
|
@@ -36,7 +40,7 @@ describe('AxCrew', () => {
|
|
|
36
40
|
}
|
|
37
41
|
}]
|
|
38
42
|
};
|
|
39
|
-
expect(() => new AxCrew(invalidConfig, AxCrewFunctions))
|
|
43
|
+
expect(() => new AxCrew(invalidConfig as AxCrewConfig, AxCrewFunctions))
|
|
40
44
|
.toThrowError('Agent name cannot be empty');
|
|
41
45
|
});
|
|
42
46
|
});
|
|
@@ -50,8 +54,8 @@ describe('AxCrew', () => {
|
|
|
50
54
|
crew: [
|
|
51
55
|
{
|
|
52
56
|
name: "agent1",
|
|
53
|
-
description: "A sophisticated agent that processes text
|
|
54
|
-
signature: "
|
|
57
|
+
description: "A sophisticated agent that processes text query and generates structured analysis with detailed explanations and recommendations",
|
|
58
|
+
signature: "query:string -> queryResponse:string",
|
|
55
59
|
provider: "anthropic",
|
|
56
60
|
providerKeyName: "ANTHROPIC_API_KEY",
|
|
57
61
|
ai: { model: "claude-3-haiku-20240307" }
|
|
@@ -59,7 +63,7 @@ describe('AxCrew', () => {
|
|
|
59
63
|
{
|
|
60
64
|
name: "agent2",
|
|
61
65
|
description: "An advanced processing agent that builds upon agent1's output to provide deeper insights and actionable intelligence",
|
|
62
|
-
signature: "
|
|
66
|
+
signature: "query:string -> queryResponse:string",
|
|
63
67
|
provider: "anthropic",
|
|
64
68
|
providerKeyName: "ANTHROPIC_API_KEY",
|
|
65
69
|
ai: { model: "claude-3-haiku-20240307" },
|
|
@@ -94,7 +98,7 @@ describe('AxCrew', () => {
|
|
|
94
98
|
crew: [{
|
|
95
99
|
name: "testAgent",
|
|
96
100
|
description: "A comprehensive testing agent that validates inputs, processes data, and ensures output quality through multiple verification steps",
|
|
97
|
-
signature: "
|
|
101
|
+
signature: "query:string -> queryResponse:string",
|
|
98
102
|
provider: "anthropic",
|
|
99
103
|
providerKeyName: "ANTHROPIC_API_KEY",
|
|
100
104
|
ai: { model: "claude-3-haiku-20240307" }
|
|
@@ -104,19 +108,19 @@ describe('AxCrew', () => {
|
|
|
104
108
|
await crew.addAgent('testAgent');
|
|
105
109
|
});
|
|
106
110
|
|
|
107
|
-
test('should track costs correctly', async () => {
|
|
108
|
-
const
|
|
109
|
-
expect(
|
|
110
|
-
expect(
|
|
111
|
-
expect(typeof
|
|
111
|
+
test('should track costs correctly (metrics)', async () => {
|
|
112
|
+
const metrics = crew.getCrewMetrics();
|
|
113
|
+
expect(metrics).toBeDefined();
|
|
114
|
+
expect(metrics).toHaveProperty('estimatedCostUSD');
|
|
115
|
+
expect(typeof metrics.estimatedCostUSD).toBe('number');
|
|
112
116
|
});
|
|
113
117
|
|
|
114
|
-
test('should reset costs', () => {
|
|
118
|
+
test('should reset costs (metrics)', () => {
|
|
115
119
|
crew.resetCosts();
|
|
116
|
-
const
|
|
117
|
-
expect(
|
|
118
|
-
expect(
|
|
119
|
-
expect(
|
|
120
|
+
const metrics = crew.getCrewMetrics();
|
|
121
|
+
expect(metrics).toBeDefined();
|
|
122
|
+
expect(metrics).toHaveProperty('estimatedCostUSD');
|
|
123
|
+
expect(metrics.estimatedCostUSD).toBe(0);
|
|
120
124
|
});
|
|
121
125
|
});
|
|
122
126
|
|
|
@@ -127,7 +131,7 @@ describe('AxCrew', () => {
|
|
|
127
131
|
crew: [{
|
|
128
132
|
name: "testAgent",
|
|
129
133
|
description: "A comprehensive testing agent that validates inputs, processes data, and ensures output quality through multiple verification steps",
|
|
130
|
-
signature: "
|
|
134
|
+
signature: "query:string -> queryResponse:string",
|
|
131
135
|
provider: "anthropic",
|
|
132
136
|
providerKeyName: "ANTHROPIC_API_KEY",
|
|
133
137
|
ai: { model: "claude-3-haiku-20240307" }
|