@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.
@@ -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: "input:string -> output:string",
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 input and generates structured analysis with detailed explanations and recommendations",
54
- signature: "input:string -> output:string",
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: "input:string -> output:string",
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: "input:string -> output:string",
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 costs = crew.getAggregatedCosts();
109
- expect(costs).toBeDefined();
110
- expect(costs).toHaveProperty('totalCost');
111
- expect(typeof costs.totalCost).toBe('string');
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 costs = crew.getAggregatedCosts();
117
- expect(costs).toBeDefined();
118
- expect(costs).toHaveProperty('totalCost');
119
- expect(costs.totalCost).toBe('0'); // Updated to match actual format
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: "input:string -> output:string",
134
+ signature: "query:string -> queryResponse:string",
131
135
  provider: "anthropic",
132
136
  providerKeyName: "ANTHROPIC_API_KEY",
133
137
  ai: { model: "claude-3-haiku-20240307" }