@amitdeshmukh/ax-crew 3.11.1 → 3.11.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.
@@ -2,7 +2,8 @@ import fs from 'fs';
2
2
  // Import all the providers
3
3
  import { AxAIAnthropic, AxAIOpenAI, AxAIAzureOpenAI, AxAICohere, AxAIDeepSeek, AxAIGoogleGemini, AxAIGroq, AxAIHuggingFace, AxAIMistral, AxAIOllama, AxAITogether, AxAIReka, AxAIGrok } from '@ax-llm/ax';
4
4
  // Import the MCP client and transports
5
- import { AxMCPClient, AxMCPStdioTransport, AxMCPHTTPSSETransport, AxMCPStreambleHTTPTransport } from '@ax-llm/ax';
5
+ import { AxMCPClient, AxMCPHTTPSSETransport, AxMCPStreambleHTTPTransport } from '@ax-llm/ax';
6
+ import { AxMCPStdioTransport } from '@ax-llm/ax-tools';
6
7
  import { PROVIDER_API_KEYS } from '../config/index.js';
7
8
  // Define a mapping from provider names to their respective constructors
8
9
  const AIConstructors = {
@@ -101,13 +102,12 @@ const initializeMCPServers = async (agentConfigData) => {
101
102
  env: mcpServerConfig.env
102
103
  });
103
104
  }
104
- else if (isStreambleHTTPTransport(mcpServerConfig)) {
105
- transport = new AxMCPStreambleHTTPTransport(mcpServerConfig.mcpEndpoint, mcpServerConfig.options);
106
- }
107
105
  else if (isHTTPSSETransport(mcpServerConfig)) {
108
- // This handles both new SSE transport and legacy HTTP transport (both use sseUrl)
109
106
  transport = new AxMCPHTTPSSETransport(mcpServerConfig.sseUrl);
110
107
  }
108
+ else if (isStreambleHTTPTransport(mcpServerConfig)) {
109
+ transport = new AxMCPStreambleHTTPTransport(mcpServerConfig.mcpEndpoint, mcpServerConfig.options);
110
+ }
111
111
  else {
112
112
  throw new Error(`Unsupported transport type: ${JSON.stringify(mcpServerConfig)}`);
113
113
  }
@@ -10,7 +10,7 @@ declare class StatefulAxAgent extends AxAgent<any, any> {
10
10
  name: string;
11
11
  description: string;
12
12
  signature: string | AxSignature;
13
- agents?: AxAgentic[] | undefined;
13
+ agents?: AxAgentic<any, any>[] | undefined;
14
14
  functions?: (AxFunction | (() => AxFunction))[] | undefined;
15
15
  examples?: Array<Record<string, any>> | undefined;
16
16
  mcpServers?: Record<string, MCPTransportConfig> | undefined;
package/dist/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { AxFunction, AxSignature, AxModelConfig, AxMCPStreamableHTTPTransportOptions } from '@ax-llm/ax';
1
+ import type { AxFunction, AxSignature, AxModelConfig, AxMCPStreamableHTTPTransportOptions, AxProgramForwardOptions } from '@ax-llm/ax';
2
2
  import type { Provider } from './agents/agentConfig.js';
3
3
  /**
4
4
  * A state instance that is shared between agents.
@@ -138,7 +138,7 @@ type MCPTransportConfig = MCPStdioTransportConfig | MCPHTTPSSETransportConfig |
138
138
  * @property {AxModelConfig & { model: string }} ai - The AI model configuration to be passed to the agent.
139
139
  * @property {boolean} debug - Whether to enable debug mode.
140
140
  * @property {string} apiURL - Set this if you are using a custom API URL e.g. ollama on localhost.
141
- * @property {Record<string, any>} options - Agent options. Refer to the Ax documentation for more details.
141
+ * @property {Partial<AxProgramForwardOptions>} options - Agent options including thinkingTokenBudget, showThoughts, etc. Refer to the Ax documentation for more details.
142
142
  * @property {string[]} functions - Function names to be used by the agent.
143
143
  * @property {string[]} agents - Sub-agent available to the agent.
144
144
  * @property {Record<string, any>[]} examples - DSPy examples for the agent to learn from.
@@ -155,7 +155,7 @@ interface AgentConfig {
155
155
  };
156
156
  debug?: boolean;
157
157
  apiURL?: string;
158
- options?: Record<string, any>;
158
+ options?: Partial<AxProgramForwardOptions>;
159
159
  functions?: string[];
160
160
  agents?: string[];
161
161
  examples?: Array<Record<string, any>>;
@@ -0,0 +1,89 @@
1
+ import { AxCrew } from "../dist/index.js";
2
+
3
+ import dotenv from "dotenv";
4
+ dotenv.config();
5
+
6
+ // Define the crew configuration
7
+ const config = {
8
+ crew: [
9
+ {
10
+ name: "DeepResearchAgent",
11
+ description: "A specialized agent that performs deep research using perplexity",
12
+ signature: 'researchTopic:string "a topic of interest" -> result:string "The result of the research"',
13
+ provider: "openai",
14
+ providerKeyName: "OPENAI_API_KEY",
15
+ ai: {
16
+ model: "gpt-4.1",
17
+ temperature: 0.1,
18
+ },
19
+ options: {
20
+ stream: true,
21
+ debug: true,
22
+ },
23
+ mcpServers: {
24
+ "perplexity-mcp": {
25
+ "env": {
26
+ "PERPLEXITY_API_KEY": process.env.PERPLEXITY_API_KEY,
27
+ "PERPLEXITY_MODEL": "sonar-deep-research"
28
+ },
29
+ "command": "uvx",
30
+ "args": [
31
+ "perplexity-mcp"
32
+ ]
33
+ }
34
+ }
35
+ }
36
+ ]
37
+ };
38
+
39
+ // Create a new instance of AxCrew with the config
40
+ const crew = new AxCrew(config);
41
+
42
+ // Add the agents to the crew
43
+ await crew.addAllAgents();
44
+
45
+ // Get agent instances
46
+ const researchAgent = crew.agents?.get("DeepResearchAgent");
47
+
48
+ const userQuery: string = "You are a Research assistant. Your task is to analyse the company SpaceX, its origins, current team members, customer profile and any news worthy happenings. Prepare a detailed report.";
49
+
50
+ console.log(`\n\nUser Query: ${userQuery}`);
51
+
52
+ const main = async (): Promise<void> => {
53
+ // Start timing
54
+ const startTime = Date.now();
55
+ console.log(`\nšŸ• Starting research task at: ${new Date(startTime).toLocaleTimeString()}`);
56
+
57
+ const response = await researchAgent?.streamingForward({
58
+ researchTopic: userQuery,
59
+ });
60
+
61
+ if (response) {
62
+ try {
63
+ for await (const chunk of response) {
64
+ if (chunk.delta && typeof chunk.delta === 'object' && 'results' in chunk.delta) {
65
+ process.stdout.write(chunk.delta.results);
66
+ }
67
+ }
68
+ console.log('\n');
69
+ } catch (error) {
70
+ console.error('Error processing stream:', error);
71
+ }
72
+ }
73
+
74
+ // End timing and calculate duration
75
+ const endTime = Date.now();
76
+ const duration = endTime - startTime;
77
+ const durationInSeconds = (duration / 1000).toFixed(2);
78
+ const durationInMinutes = (duration / 60000).toFixed(2);
79
+
80
+ console.log(`\nā±ļø Task completed at: ${new Date(endTime).toLocaleTimeString()}`);
81
+ console.log(`ā±ļø Total time taken: ${duration}ms (${durationInSeconds}s / ${durationInMinutes}min)`);
82
+ };
83
+
84
+ main()
85
+ .then(() => {
86
+ console.log("Done");
87
+ process.exit(0);
88
+ })
89
+ .catch(console.error);
@@ -0,0 +1,74 @@
1
+ import { AxCrew } from "../dist/index.js";
2
+
3
+ import dotenv from "dotenv";
4
+ dotenv.config();
5
+
6
+ // Define the crew configuration
7
+ const config = {
8
+ crew: [
9
+ {
10
+ name: "XSearchAgent",
11
+ description: "A specialized agent that can search X (Twitter) posts for the latest news and updates about specific topics, people, or events. It can find trending posts, recent tweets, and real-time information from X platform.",
12
+ signature: 'searchQuery:string "a search query" -> result:string "the response to the user query citing relevant sources including X posts and other web sources"',
13
+ provider: "grok",
14
+ providerKeyName: "GROK_API_KEY",
15
+ ai: {
16
+ model: "grok-3-latest",
17
+ temperature: 0.1,
18
+ },
19
+ options: {
20
+ stream: true,
21
+ debug: true,
22
+ searchParameters: {
23
+ mode: 'on',
24
+ returnCitations: true,
25
+ maxSearchResults: 10,
26
+ sources: [
27
+ { type: 'x' },
28
+ { type: 'web' },
29
+ { type: 'news' }
30
+ ]
31
+ }
32
+ }
33
+ }
34
+ ]
35
+ };
36
+
37
+ // Create a new instance of AxCrew with the config
38
+ const crew = new AxCrew(config);
39
+
40
+ // Add the agents to the crew
41
+ await crew.addAllAgents();
42
+
43
+ // Get agent instances
44
+ const xSearchAgent = crew.agents?.get("XSearchAgent");
45
+
46
+ const userQuery: string = "when is the next ISRO launch date and what is the launch vehicle and payload";
47
+
48
+ console.log(`\n\nUser Query: ${userQuery}`);
49
+
50
+ const main = async (): Promise<void> => {
51
+ const response = await xSearchAgent?.streamingForward({
52
+ searchQuery: userQuery,
53
+ });
54
+
55
+ if (response) {
56
+ try {
57
+ for await (const chunk of response) {
58
+ if (chunk.delta && typeof chunk.delta === 'object' && 'results' in chunk.delta) {
59
+ process.stdout.write(chunk.delta.results);
60
+ }
61
+ }
62
+ console.log('\n');
63
+ } catch (error) {
64
+ console.error('Error processing stream:', error);
65
+ }
66
+ }
67
+ };
68
+
69
+ main()
70
+ .then(() => {
71
+ console.log("Done");
72
+ process.exit(0);
73
+ })
74
+ .catch(console.error);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@amitdeshmukh/ax-crew",
4
- "version": "3.11.1",
4
+ "version": "3.11.3",
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",
@@ -17,12 +17,15 @@
17
17
  "test:ui": "vitest --ui"
18
18
  },
19
19
  "dependencies": {
20
- "@ax-llm/ax": "^11.0.50",
21
20
  "decimal.js": "^10.5.0",
22
21
  "dotenv": "^16.4.5",
23
22
  "upgrade": "^1.1.0",
24
23
  "uuid": "^10.0.0"
25
24
  },
25
+ "peerDependencies": {
26
+ "@ax-llm/ax": "^13.0.8",
27
+ "@ax-llm/ax-tools": "^13.0.8"
28
+ },
26
29
  "devDependencies": {
27
30
  "@testing-library/jest-dom": "^6.6.3",
28
31
  "@types/node": "^20.14.9",
@@ -4,7 +4,8 @@ import { AxAIAnthropic, AxAIOpenAI, AxAIAzureOpenAI, AxAICohere, AxAIDeepSeek, A
4
4
  // Import Ax types
5
5
  import type { AxFunction } from '@ax-llm/ax';
6
6
  // Import the MCP client and transports
7
- import { AxMCPClient, AxMCPStdioTransport, AxMCPHTTPSSETransport, AxMCPStreambleHTTPTransport } from '@ax-llm/ax'
7
+ import { AxMCPClient, AxMCPHTTPSSETransport, AxMCPStreambleHTTPTransport } from '@ax-llm/ax'
8
+ import { AxMCPStdioTransport } from '@ax-llm/ax-tools'
8
9
  import { PROVIDER_API_KEYS } from '../config/index.js';
9
10
  import type {
10
11
  AgentConfig,
@@ -128,11 +129,10 @@ const initializeMCPServers = async (agentConfigData: AgentConfig): Promise<AxFun
128
129
  args: mcpServerConfig.args,
129
130
  env: mcpServerConfig.env
130
131
  });
131
- } else if (isStreambleHTTPTransport(mcpServerConfig)) {
132
- transport = new AxMCPStreambleHTTPTransport(mcpServerConfig.mcpEndpoint, mcpServerConfig.options);
133
132
  } else if (isHTTPSSETransport(mcpServerConfig)) {
134
- // This handles both new SSE transport and legacy HTTP transport (both use sseUrl)
135
133
  transport = new AxMCPHTTPSSETransport(mcpServerConfig.sseUrl);
134
+ } else if (isStreambleHTTPTransport(mcpServerConfig)) {
135
+ transport = new AxMCPStreambleHTTPTransport(mcpServerConfig.mcpEndpoint, mcpServerConfig.options);
136
136
  } else {
137
137
  throw new Error(`Unsupported transport type: ${JSON.stringify(mcpServerConfig)}`);
138
138
  }
@@ -50,7 +50,7 @@ class StatefulAxAgent extends AxAgent<any, any> {
50
50
  name: string;
51
51
  description: string;
52
52
  signature: string | AxSignature;
53
- agents?: AxAgentic[] | undefined;
53
+ agents?: AxAgentic<any, any>[] | undefined;
54
54
  functions?: (AxFunction | (() => AxFunction))[] | undefined;
55
55
  examples?: Array<Record<string, any>> | undefined;
56
56
  mcpServers?: Record<string, MCPTransportConfig> | undefined;
package/src/types.ts CHANGED
@@ -2,7 +2,8 @@ import type {
2
2
  AxFunction,
3
3
  AxSignature,
4
4
  AxModelConfig,
5
- AxMCPStreamableHTTPTransportOptions
5
+ AxMCPStreamableHTTPTransportOptions,
6
+ AxProgramForwardOptions
6
7
  } from '@ax-llm/ax';
7
8
 
8
9
  import type { Provider } from './agents/agentConfig.js';
@@ -154,7 +155,7 @@ type MCPTransportConfig = MCPStdioTransportConfig | MCPHTTPSSETransportConfig |
154
155
  * @property {AxModelConfig & { model: string }} ai - The AI model configuration to be passed to the agent.
155
156
  * @property {boolean} debug - Whether to enable debug mode.
156
157
  * @property {string} apiURL - Set this if you are using a custom API URL e.g. ollama on localhost.
157
- * @property {Record<string, any>} options - Agent options. Refer to the Ax documentation for more details.
158
+ * @property {Partial<AxProgramForwardOptions>} options - Agent options including thinkingTokenBudget, showThoughts, etc. Refer to the Ax documentation for more details.
158
159
  * @property {string[]} functions - Function names to be used by the agent.
159
160
  * @property {string[]} agents - Sub-agent available to the agent.
160
161
  * @property {Record<string, any>[]} examples - DSPy examples for the agent to learn from.
@@ -169,7 +170,7 @@ interface AgentConfig {
169
170
  ai: AxModelConfig & { model: string };
170
171
  debug?: boolean;
171
172
  apiURL?: string;
172
- options?: Record<string, any>;
173
+ options?: Partial<AxProgramForwardOptions>;
173
174
  functions?: string[];
174
175
  agents?: string[];
175
176
  examples?: Array<Record<string, any>>;