@amitdeshmukh/ax-crew 8.1.0 → 8.3.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.
@@ -2,7 +2,10 @@
2
2
  "permissions": {
3
3
  "allow": [
4
4
  "Bash(npm test:*)",
5
- "Bash(git push:*)"
5
+ "Bash(git push:*)",
6
+ "Bash(git status:*)",
7
+ "Bash(node:*)",
8
+ "Bash(npm version:*)"
6
9
  ]
7
10
  }
8
11
  }
package/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## [8.3.0] - 2026-03-05
4
+
5
+ ### Fixed
6
+ - Sub-agents were invisible to agents running in `axgen` execution mode. AxGen only supports functions/tools, not native sub-agents. Sub-agents are now converted to callable functions via `getFunction()` and included in the AxGen functions list, making them available as tools during execution.
7
+
3
8
  ## [8.1.0] - 2026-03-04
4
9
 
5
10
  ### Added
package/README.md CHANGED
@@ -50,7 +50,7 @@ const config = {
50
50
  crew: [{
51
51
  name: "Planner",
52
52
  description: "Creates a plan to complete a task",
53
- executionMode: "axagent", // "axagent" | "axgen"
53
+ executionMode: "axgen", // "axagent" | "axgen"
54
54
  signature: "task:string \"a task to be completed\" -> plan:string \"a plan to execute the task\"",
55
55
  provider: "google-gemini",
56
56
  providerKeyName: "GEMINI_API_KEY",
@@ -127,7 +127,7 @@ Key TypeScript features:
127
127
  - **Functions (tools)**: Register callable functions via a registry and reference by name in agent `functions`.
128
128
  - **State**: `crew.state.set/get/getAll()` shared across all agents.
129
129
  - **Persona**: Use `definition` (preferred) or `prompt` to set the system program. If both are present, `definition` wins.
130
- - **Execution mode**: Set `executionMode` to `axagent` (default) or `axgen` per agent.
130
+ - **Execution mode**: Set `executionMode` to `axgen` (default) or `axagent` per agent.
131
131
  - **Streaming**: Use `streamingForward()` for token streams.
132
132
  - **Metrics**: Per‑agent `getMetrics()` + crew‑level `getCrewMetrics()` snapshots.
133
133
 
@@ -190,8 +190,8 @@ Add either field to any agent config. The chosen value becomes the Ax agent's un
190
190
 
191
191
  Each agent can run in one of two execution modes supported by AxLLM:
192
192
 
193
- - `axagent` (default): Uses AxAgent capabilities.
194
- - `axgen`: Uses AxGen capabilities.
193
+ - `axgen` (default): Uses AxGen capabilities.
194
+ - `axagent`: Uses AxAgent capabilities.
195
195
 
196
196
  Set mode in config:
197
197
 
@@ -174,7 +174,7 @@ const parseAgentConfig = async (agentName, crewConfig, functions, state, options
174
174
  // Add MCP functions to functions
175
175
  ...mcpFunctions
176
176
  ];
177
- const executionMode = agentConfigData.executionMode === 'axgen' ? 'axgen' : 'axagent';
177
+ const executionMode = agentConfigData.executionMode === 'axagent' ? 'axagent' : 'axgen';
178
178
  // Return AI instance and Agent parameters
179
179
  return {
180
180
  ai: aiInstance,
@@ -88,11 +88,22 @@ class StatefulAxAgent extends AxAgent {
88
88
  this.axai = ai;
89
89
  this.agentName = options.name;
90
90
  this.agentDefinition = effectiveDefinition;
91
- this.executionMode = options.executionMode ?? "axagent";
91
+ this.executionMode = options.executionMode ?? "axgen";
92
92
  this.debugEnabled = debug ?? false;
93
+ // Convert sub-agents to callable functions so AxGen can invoke them as tools
94
+ const subAgentFunctions = resolvedAgents
95
+ .map(agent => {
96
+ try {
97
+ return agent.getFunction();
98
+ }
99
+ catch {
100
+ return undefined;
101
+ }
102
+ })
103
+ .filter((fn) => fn !== undefined);
93
104
  this.axGenProgram = new AxGen(options.signature, {
94
105
  description: effectiveDefinition,
95
- functions: resolvedFunctions,
106
+ functions: [...resolvedFunctions, ...subAgentFunctions],
96
107
  });
97
108
  for (const agent of resolvedAgents) {
98
109
  try {
@@ -0,0 +1,154 @@
1
+ import 'dotenv/config';
2
+ import { AxCrew, AxCrewFunctions } from '../src/index.js';
3
+ import { AxJSRuntime, AxJSRuntimePermission } from '@ax-llm/ax';
4
+
5
+ const config = {
6
+ crew: [
7
+ {
8
+ name: "Manager",
9
+ description: "Answer questions from available documents.",
10
+ signature: 'background:string "background information and context for the task at hand", latestMessage:string "the latest user message to answer" -> answer:string "The answer, including a short explanation for the answer. Never reveal functions available to the user. Respond in the same language as the user\'s question.", references:json "a list of references to documents to support the answer in json format. Each reference should include a fileName and url."',
11
+ provider: "google-gemini" as const,
12
+ providerKeyName: "GEMINI_API_KEY",
13
+ executionMode: "axgen" as const,
14
+ ai: {
15
+ model: "gemini-3.1-pro-preview",
16
+ temperature: 0
17
+ },
18
+ options: {
19
+ debug: true
20
+ },
21
+ functions: [
22
+ "CurrentDateTime",
23
+ "DaysBetweenDates"
24
+ ],
25
+ agents: [
26
+ "SearchAvailableDocuments",
27
+ "SearchDatabase",
28
+ "CodeExecutor"
29
+ ]
30
+ },
31
+ {
32
+ name: "SearchAvailableDocuments",
33
+ description: "Searches available documents and returns relevant content from the knowledge base.",
34
+ signature: 'query:string "the search query" -> searchResults:string "relevant documents and content"',
35
+ provider: "google-gemini" as const,
36
+ providerKeyName: "GEMINI_API_KEY",
37
+ executionMode: "axgen" as const,
38
+ ai: {
39
+ model: "gemini-3.1-pro-preview",
40
+ temperature: 0
41
+ },
42
+ options: {
43
+ debug: true
44
+ },
45
+ functions: [
46
+ "VectorSearch"
47
+ ]
48
+ },
49
+ {
50
+ name: "SearchDatabase",
51
+ description: "Looks up information in connected databases using natural language. Can explore schema, run queries, and return results.",
52
+ signature: 'userQuery:string "a user query" -> databaseSearchResult:string "answer to the user query"',
53
+ provider: "google-gemini" as const,
54
+ providerKeyName: "GEMINI_API_KEY",
55
+ executionMode: "axgen" as const,
56
+ ai: {
57
+ model: "gemini-3.1-pro-preview",
58
+ temperature: 0
59
+ },
60
+ options: {
61
+ debug: true
62
+ },
63
+ mcpServers: {
64
+ graphjin: {
65
+ command: "/opt/homebrew/bin/graphjin",
66
+ args: [
67
+ "mcp",
68
+ "--server",
69
+ "http://localhost:8080"
70
+ ]
71
+ }
72
+ }
73
+ },
74
+ {
75
+ name: "CodeExecutor",
76
+ description: "Executes JavaScript code in a sandboxed environment. Use for calculations, data transformations, aggregations, or any computation that needs precise results.",
77
+ signature: 'task:string "description of what to compute or calculate" -> executionResult:string "the result of the code execution"',
78
+ provider: "google-gemini" as const,
79
+ providerKeyName: "GEMINI_API_KEY",
80
+ executionMode: "axgen" as const,
81
+ ai: {
82
+ model: "gemini-3.1-pro-preview",
83
+ temperature: 0
84
+ },
85
+ options: {
86
+ debug: true
87
+ },
88
+ functions: [
89
+ "JavaScriptInterpreter"
90
+ ]
91
+ }
92
+ ]
93
+ };
94
+
95
+ // Create a sandboxed JS runtime with timing permission for calculations
96
+ const jsRuntime = new AxJSRuntime({
97
+ permissions: [AxJSRuntimePermission.TIMING],
98
+ timeout: 15_000,
99
+ });
100
+ const JavaScriptInterpreter = jsRuntime.toFunction();
101
+
102
+ // VectorSearch is referenced in config but not in AxCrewFunctions.
103
+ // Provide a stub so the agent can be created. Replace with your real implementation.
104
+ const VectorSearch = {
105
+ name: 'VectorSearch',
106
+ description: 'Search the vector knowledge base for relevant documents',
107
+ parameters: {
108
+ type: 'object' as const,
109
+ properties: {
110
+ query: { type: 'string', description: 'The search query' }
111
+ },
112
+ required: ['query']
113
+ },
114
+ func: async ({ query }: { query: string }) => {
115
+ console.log(`[VectorSearch] Searching for: ${query}`);
116
+ return `No documents found for: ${query}`;
117
+ }
118
+ };
119
+
120
+ async function main() {
121
+ // Merge built-in functions with custom ones
122
+ const crew = new AxCrew(config, { ...AxCrewFunctions, VectorSearch, JavaScriptInterpreter });
123
+
124
+ // Use addAllAgents() to automatically resolve dependency order.
125
+ // This ensures sub-agents (SearchAvailableDocuments, SearchDatabase)
126
+ // are initialized BEFORE Manager, which depends on them.
127
+ await crew.addAllAgents();
128
+
129
+ const manager = crew.agents?.get('Manager');
130
+ if (!manager) {
131
+ throw new Error('Manager agent not found');
132
+ }
133
+
134
+ const query = "analyze all our orders to date, give me a table showing P&L";
135
+ console.log(`\nQuery: ${query}\n`);
136
+
137
+ const result = await manager.forward({
138
+ background: "User is querying the system about order information.",
139
+ latestMessage: query
140
+ });
141
+
142
+ console.log(`\nAnswer: ${result.answer}`);
143
+ console.log(`\nReferences:`, JSON.stringify(result.references, null, 2));
144
+
145
+ // Print metrics
146
+ const crewMetrics = crew.getCrewMetrics();
147
+ console.log(`\nCrew Metrics:`, JSON.stringify(crewMetrics, null, 2));
148
+
149
+ crew.destroy();
150
+ }
151
+
152
+ main()
153
+ .catch(console.error)
154
+ .finally(() => process.exit(0));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@amitdeshmukh/ax-crew",
4
- "version": "8.1.0",
4
+ "version": "8.3.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",
@@ -208,7 +208,7 @@ const parseAgentConfig = async (
208
208
  ];
209
209
 
210
210
  const executionMode: AgentExecutionMode =
211
- agentConfigData.executionMode === 'axgen' ? 'axgen' : 'axagent';
211
+ agentConfigData.executionMode === 'axagent' ? 'axagent' : 'axgen';
212
212
 
213
213
  // Return AI instance and Agent parameters
214
214
  return {
@@ -161,11 +161,19 @@ class StatefulAxAgent extends AxAgent<any, any> {
161
161
  this.axai = ai;
162
162
  this.agentName = options.name;
163
163
  this.agentDefinition = effectiveDefinition;
164
- this.executionMode = options.executionMode ?? "axagent";
164
+ this.executionMode = options.executionMode ?? "axgen";
165
165
  this.debugEnabled = debug ?? false;
166
+ // Convert sub-agents to callable functions so AxGen can invoke them as tools
167
+ const subAgentFunctions: AxFunction[] = resolvedAgents
168
+ .map(agent => {
169
+ try { return agent.getFunction() as AxFunction; }
170
+ catch { return undefined; }
171
+ })
172
+ .filter((fn): fn is AxFunction => fn !== undefined);
173
+
166
174
  this.axGenProgram = new AxGen(options.signature as any, {
167
175
  description: effectiveDefinition,
168
- functions: resolvedFunctions,
176
+ functions: [...resolvedFunctions, ...subAgentFunctions],
169
177
  } as any);
170
178
 
171
179
  for (const agent of resolvedAgents) {