@amitdeshmukh/ax-crew 3.8.1 → 3.9.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.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,16 @@ This Changelog format is based on [Keep a Changelog]
5
5
  adheres to [Semantic Versioning](https://semver.org/spec/
6
6
  v2.0.0.html).
7
7
 
8
+ ## [3.9.0] - 2025-01-27
9
+
10
+ ### Fixed
11
+ - Updated @ax-llm/ax package to 11.0.47
12
+ - Updated TypeScript target from ES2020 to ES2022 to resolve `ErrorOptions` type compatibility issue with @ax-llm/ax package
13
+ - Improved build process compatibility with latest TypeScript type definitions
14
+
15
+ ### Changed
16
+ - Enhanced TypeScript configuration for better compatibility with modern type definitions
17
+
8
18
  ## [3.8.1] - 2024-03-28
9
19
 
10
20
  ### Added
@@ -4,6 +4,7 @@ import { Decimal } from 'decimal.js';
4
4
  *
5
5
  */
6
6
  export class StateFulAxAgentUsage {
7
+ static STATE_KEY_PREFIX = 'agent_usage_';
7
8
  static calculateCost(modelUsage, modelInfo) {
8
9
  // Handle both direct properties and nested tokens structure
9
10
  const promptTokens = modelUsage.tokens?.promptTokens ?? modelUsage.promptTokens;
@@ -116,4 +117,3 @@ export class StateFulAxAgentUsage {
116
117
  });
117
118
  }
118
119
  }
119
- StateFulAxAgentUsage.STATE_KEY_PREFIX = 'agent_usage_';
@@ -5,6 +5,9 @@ import { parseCrewConfig, parseAgentConfig } from "./agentConfig.js";
5
5
  import { StateFulAxAgentUsage } from "./agentUseCosts.js";
6
6
  // Extend the AxAgent class from ax-llm
7
7
  class StatefulAxAgent extends AxAgent {
8
+ state;
9
+ axai;
10
+ agentName;
8
11
  constructor(ai, options, state) {
9
12
  const { examples, ...restOptions } = options;
10
13
  const formattedOptions = {
@@ -91,6 +94,11 @@ class StatefulAxAgent extends AxAgent {
91
94
  * Represents a crew of agents with shared state functionality.
92
95
  */
93
96
  class AxCrew {
97
+ crewConfig;
98
+ functionsRegistry = {};
99
+ crewId;
100
+ agents;
101
+ state;
94
102
  /**
95
103
  * Creates an instance of AxCrew.
96
104
  * @param {CrewConfigInput} crewConfig - Either a path to the agent config file or a JSON object with crew configuration.
@@ -98,40 +106,6 @@ class AxCrew {
98
106
  * @param {string} [crewId=uuidv4()] - The unique identifier for the crew.
99
107
  */
100
108
  constructor(crewConfig, functionsRegistry = {}, crewId = uuidv4()) {
101
- this.functionsRegistry = {};
102
- /**
103
- * Factory function for creating an agent.
104
- * @param {string} agentName - The name of the agent to create.
105
- * @returns {StatefulAxAgent} The created StatefulAxAgent instance.
106
- * @throws Will throw an error if the agent creation fails.
107
- */
108
- this.createAgent = async (agentName) => {
109
- try {
110
- const agentConfig = await parseAgentConfig(agentName, this.crewConfig, this.functionsRegistry, this.state);
111
- // Destructure with type assertion
112
- const { ai, name, description, signature, functions, subAgentNames, examples } = agentConfig;
113
- // Get subagents for the AI agent
114
- const subAgents = subAgentNames.map((subAgentName) => {
115
- if (!this.agents?.get(subAgentName)) {
116
- throw new Error(`Sub-agent '${subAgentName}' does not exist in available agents.`);
117
- }
118
- return this.agents?.get(subAgentName);
119
- });
120
- // Create an instance of StatefulAxAgent
121
- const agent = new StatefulAxAgent(ai, {
122
- name,
123
- description,
124
- signature,
125
- functions: functions.filter((fn) => fn !== undefined),
126
- agents: subAgents.filter((agent) => agent !== undefined),
127
- examples,
128
- }, this.state);
129
- return agent;
130
- }
131
- catch (error) {
132
- throw error;
133
- }
134
- };
135
109
  // Basic validation of crew configuration
136
110
  if (!crewConfig || typeof crewConfig !== 'object' || !('crew' in crewConfig)) {
137
111
  throw new Error('Invalid crew configuration');
@@ -148,6 +122,39 @@ class AxCrew {
148
122
  this.agents = new Map();
149
123
  this.state = createState(crewId);
150
124
  }
125
+ /**
126
+ * Factory function for creating an agent.
127
+ * @param {string} agentName - The name of the agent to create.
128
+ * @returns {StatefulAxAgent} The created StatefulAxAgent instance.
129
+ * @throws Will throw an error if the agent creation fails.
130
+ */
131
+ createAgent = async (agentName) => {
132
+ try {
133
+ const agentConfig = await parseAgentConfig(agentName, this.crewConfig, this.functionsRegistry, this.state);
134
+ // Destructure with type assertion
135
+ const { ai, name, description, signature, functions, subAgentNames, examples } = agentConfig;
136
+ // Get subagents for the AI agent
137
+ const subAgents = subAgentNames.map((subAgentName) => {
138
+ if (!this.agents?.get(subAgentName)) {
139
+ throw new Error(`Sub-agent '${subAgentName}' does not exist in available agents.`);
140
+ }
141
+ return this.agents?.get(subAgentName);
142
+ });
143
+ // Create an instance of StatefulAxAgent
144
+ const agent = new StatefulAxAgent(ai, {
145
+ name,
146
+ description,
147
+ signature,
148
+ functions: functions.filter((fn) => fn !== undefined),
149
+ agents: subAgents.filter((agent) => agent !== undefined),
150
+ examples,
151
+ }, this.state);
152
+ return agent;
153
+ }
154
+ catch (error) {
155
+ throw error;
156
+ }
157
+ };
151
158
  /**
152
159
  * Adds an agent to the crew by name.
153
160
  * @param {string} agentName - The name of the agent to add.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@amitdeshmukh/ax-crew",
4
- "version": "3.8.1",
4
+ "version": "3.9.0",
5
5
  "description": "Build and launch a crew of AI agents with shared state. Built with axllm.dev",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -23,7 +23,7 @@
23
23
  "uuid": "^10.0.0"
24
24
  },
25
25
  "peerDependencies": {
26
- "@ax-llm/ax": "^11.0.27"
26
+ "@ax-llm/ax": "^11.0.47"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@testing-library/jest-dom": "^6.6.3",
package/tsconfig.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "compilerOptions": {
3
3
  "declaration": true,
4
4
  "module": "ESNext",
5
- "target": "ES2020",
5
+ "target": "ES2022",
6
6
  "moduleResolution": "node",
7
7
  "esModuleInterop": true,
8
8
  "allowSyntheticDefaultImports": true,