@amitdeshmukh/ax-crew 5.0.0 → 7.0.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/.claude/settings.local.json +7 -0
- package/CHANGELOG.md +40 -0
- package/README.md +143 -59
- package/dist/agents/agentConfig.d.ts +6 -6
- package/dist/agents/agentConfig.js +46 -124
- package/dist/agents/compose.d.ts +15 -0
- package/dist/agents/compose.js +58 -0
- package/dist/agents/index.d.ts +22 -4
- package/dist/agents/index.js +24 -5
- package/dist/functions/index.d.ts +11 -0
- package/dist/functions/index.js +11 -1
- package/dist/index.d.ts +25 -8
- package/dist/index.js +26 -1
- package/dist/types.d.ts +53 -6
- package/examples/basic-researcher-writer.ts +5 -3
- package/examples/mcp-agent.ts +20 -43
- package/examples/perplexityDeepSearch.ts +6 -5
- package/examples/providerArgs.ts +2 -1
- package/examples/search-tweets.ts +5 -4
- package/examples/solve-math-problem.ts +7 -5
- package/examples/streaming.ts +2 -2
- package/examples/telemetry-demo.ts +166 -0
- package/package.json +5 -4
- package/src/agents/agentConfig.ts +53 -142
- package/src/agents/compose.ts +80 -0
- package/src/agents/index.ts +30 -8
- package/src/functions/index.ts +11 -1
- package/src/index.ts +25 -11
- package/src/types.ts +59 -21
- package/tests/telemetry.test.ts +81 -0
- package/dist/config/index.d.ts +0 -5
- package/dist/config/index.js +0 -30
- package/src/config/index.ts +0 -40
package/dist/agents/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AxAgent, AxAI } from "@ax-llm/ax";
|
|
2
2
|
import type { AxSignature, AxAgentic, AxFunction, AxProgramForwardOptions, AxProgramStreamingForwardOptions, AxGenStreamingOut } from "@ax-llm/ax";
|
|
3
|
-
import type { StateInstance, FunctionRegistryType, UsageCost,
|
|
3
|
+
import type { StateInstance, FunctionRegistryType, UsageCost, AxCrewConfig, AxCrewOptions, MCPTransportConfig } from "../types.js";
|
|
4
4
|
declare class StatefulAxAgent extends AxAgent<any, any> {
|
|
5
5
|
state: StateInstance;
|
|
6
6
|
axai: any;
|
|
@@ -39,21 +39,39 @@ declare class StatefulAxAgent extends AxAgent<any, any> {
|
|
|
39
39
|
resetMetrics(): void;
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
|
-
*
|
|
42
|
+
* AxCrew orchestrates a set of Ax agents that share state,
|
|
43
|
+
* tools (functions), optional MCP servers, streaming, and a built-in metrics
|
|
44
|
+
* registry for tokens, requests, and estimated cost.
|
|
45
|
+
*
|
|
46
|
+
* Typical usage:
|
|
47
|
+
* const crew = new AxCrew(config, AxCrewFunctions)
|
|
48
|
+
* await crew.addAllAgents()
|
|
49
|
+
* const planner = crew.agents?.get("Planner")
|
|
50
|
+
* const res = await planner?.forward({ task: "Plan something" })
|
|
51
|
+
*
|
|
52
|
+
* Key behaviors:
|
|
53
|
+
* - Validates and instantiates agents from a config-first model
|
|
54
|
+
* - Shares a mutable state object across all agents in the crew
|
|
55
|
+
* - Supports sub-agents and a function registry per agent
|
|
56
|
+
* - Tracks per-agent and crew-level metrics via MetricsRegistry
|
|
57
|
+
* - Provides helpers to add agents (individually, a subset, or all) and
|
|
58
|
+
* to reset metrics/costs when needed
|
|
43
59
|
*/
|
|
44
60
|
declare class AxCrew {
|
|
45
61
|
private crewConfig;
|
|
62
|
+
private options?;
|
|
46
63
|
functionsRegistry: FunctionRegistryType;
|
|
47
64
|
crewId: string;
|
|
48
65
|
agents: Map<string, StatefulAxAgent> | null;
|
|
49
66
|
state: StateInstance;
|
|
50
67
|
/**
|
|
51
68
|
* Creates an instance of AxCrew.
|
|
52
|
-
* @param {
|
|
69
|
+
* @param {AxCrewConfig} crewConfig - JSON object with crew configuration.
|
|
53
70
|
* @param {FunctionRegistryType} [functionsRegistry={}] - The registry of functions to use in the crew.
|
|
71
|
+
* @param {AxCrewOptions} [options] - Optional settings for the crew (e.g., telemetry).
|
|
54
72
|
* @param {string} [crewId=uuidv4()] - The unique identifier for the crew.
|
|
55
73
|
*/
|
|
56
|
-
constructor(crewConfig:
|
|
74
|
+
constructor(crewConfig: AxCrewConfig, functionsRegistry?: FunctionRegistryType, options?: AxCrewOptions, crewId?: string);
|
|
57
75
|
/**
|
|
58
76
|
* Factory function for creating an agent.
|
|
59
77
|
* @param {string} agentName - The name of the agent to create.
|
package/dist/agents/index.js
CHANGED
|
@@ -176,27 +176,45 @@ class StatefulAxAgent extends AxAgent {
|
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
178
|
/**
|
|
179
|
-
*
|
|
179
|
+
* AxCrew orchestrates a set of Ax agents that share state,
|
|
180
|
+
* tools (functions), optional MCP servers, streaming, and a built-in metrics
|
|
181
|
+
* registry for tokens, requests, and estimated cost.
|
|
182
|
+
*
|
|
183
|
+
* Typical usage:
|
|
184
|
+
* const crew = new AxCrew(config, AxCrewFunctions)
|
|
185
|
+
* await crew.addAllAgents()
|
|
186
|
+
* const planner = crew.agents?.get("Planner")
|
|
187
|
+
* const res = await planner?.forward({ task: "Plan something" })
|
|
188
|
+
*
|
|
189
|
+
* Key behaviors:
|
|
190
|
+
* - Validates and instantiates agents from a config-first model
|
|
191
|
+
* - Shares a mutable state object across all agents in the crew
|
|
192
|
+
* - Supports sub-agents and a function registry per agent
|
|
193
|
+
* - Tracks per-agent and crew-level metrics via MetricsRegistry
|
|
194
|
+
* - Provides helpers to add agents (individually, a subset, or all) and
|
|
195
|
+
* to reset metrics/costs when needed
|
|
180
196
|
*/
|
|
181
197
|
class AxCrew {
|
|
182
198
|
crewConfig;
|
|
199
|
+
options;
|
|
183
200
|
functionsRegistry = {};
|
|
184
201
|
crewId;
|
|
185
202
|
agents;
|
|
186
203
|
state;
|
|
187
204
|
/**
|
|
188
205
|
* Creates an instance of AxCrew.
|
|
189
|
-
* @param {
|
|
206
|
+
* @param {AxCrewConfig} crewConfig - JSON object with crew configuration.
|
|
190
207
|
* @param {FunctionRegistryType} [functionsRegistry={}] - The registry of functions to use in the crew.
|
|
208
|
+
* @param {AxCrewOptions} [options] - Optional settings for the crew (e.g., telemetry).
|
|
191
209
|
* @param {string} [crewId=uuidv4()] - The unique identifier for the crew.
|
|
192
210
|
*/
|
|
193
|
-
constructor(crewConfig, functionsRegistry = {}, crewId = uuidv4()) {
|
|
211
|
+
constructor(crewConfig, functionsRegistry = {}, options, crewId = uuidv4()) {
|
|
194
212
|
// Basic validation of crew configuration
|
|
195
213
|
if (!crewConfig || typeof crewConfig !== 'object' || !('crew' in crewConfig)) {
|
|
196
214
|
throw new Error('Invalid crew configuration');
|
|
197
215
|
}
|
|
198
216
|
// Validate each agent in the crew
|
|
199
|
-
crewConfig.crew.forEach(agent => {
|
|
217
|
+
crewConfig.crew.forEach((agent) => {
|
|
200
218
|
if (!agent.name || agent.name.trim() === '') {
|
|
201
219
|
throw new Error('Agent name cannot be empty');
|
|
202
220
|
}
|
|
@@ -204,6 +222,7 @@ class AxCrew {
|
|
|
204
222
|
this.crewConfig = crewConfig;
|
|
205
223
|
this.functionsRegistry = functionsRegistry;
|
|
206
224
|
this.crewId = crewId;
|
|
225
|
+
this.options = options;
|
|
207
226
|
this.agents = new Map();
|
|
208
227
|
this.state = createState(crewId);
|
|
209
228
|
// Make crewId discoverable to metrics
|
|
@@ -217,7 +236,7 @@ class AxCrew {
|
|
|
217
236
|
*/
|
|
218
237
|
createAgent = async (agentName) => {
|
|
219
238
|
try {
|
|
220
|
-
const agentConfig = await parseAgentConfig(agentName, this.crewConfig, this.functionsRegistry, this.state);
|
|
239
|
+
const agentConfig = await parseAgentConfig(agentName, this.crewConfig, this.functionsRegistry, this.state, this.options);
|
|
221
240
|
// Destructure with type assertion
|
|
222
241
|
const { ai, name, description, signature, functions, subAgentNames, examples, tracker } = agentConfig;
|
|
223
242
|
// Get subagents for the AI agent
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in function registry for AxCrew agents.
|
|
3
|
+
*
|
|
4
|
+
* Contains common utility tools/functions that can be referenced by name from
|
|
5
|
+
* agent configs (e.g., "functions": ["CurrentDateTime", "DaysBetweenDates"]).
|
|
6
|
+
* You can pass this object to the AxCrew constructor or merge with your
|
|
7
|
+
* own registry.
|
|
8
|
+
* Example:
|
|
9
|
+
* const crew = new AxCrew(config, AxCrewFunctions); or
|
|
10
|
+
* const crew = new AxCrew(config, { ...AxCrewFunctions, ...myFunctions });
|
|
11
|
+
*/
|
|
1
12
|
declare const AxCrewFunctions: {
|
|
2
13
|
CurrentDateTime: import("@ax-llm/ax").AxFunction;
|
|
3
14
|
DaysBetweenDates: import("@ax-llm/ax").AxFunction;
|
package/dist/functions/index.js
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
import { CurrentDateTime, DaysBetweenDates } from './dateTime.js';
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Built-in function registry for AxCrew agents.
|
|
4
|
+
*
|
|
5
|
+
* Contains common utility tools/functions that can be referenced by name from
|
|
6
|
+
* agent configs (e.g., "functions": ["CurrentDateTime", "DaysBetweenDates"]).
|
|
7
|
+
* You can pass this object to the AxCrew constructor or merge with your
|
|
8
|
+
* own registry.
|
|
9
|
+
* Example:
|
|
10
|
+
* const crew = new AxCrew(config, AxCrewFunctions); or
|
|
11
|
+
* const crew = new AxCrew(config, { ...AxCrewFunctions, ...myFunctions });
|
|
12
|
+
*/
|
|
3
13
|
const AxCrewFunctions = {
|
|
4
14
|
CurrentDateTime,
|
|
5
15
|
DaysBetweenDates
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,32 @@
|
|
|
1
1
|
import { AxCrew } from './agents/index.js';
|
|
2
2
|
import { AxCrewFunctions } from './functions/index.js';
|
|
3
|
-
import type {
|
|
3
|
+
import type { AxCrewConfig, AgentConfig } from './types.js';
|
|
4
4
|
import type { UsageCost, AggregatedMetrics, AggregatedCosts, StateInstance, FunctionRegistryType } from './types.js';
|
|
5
|
+
/**
|
|
6
|
+
* Metrics types and helpers for request counts, token usage, and estimated cost.
|
|
7
|
+
*
|
|
8
|
+
* Re-exports the metrics module for convenience:
|
|
9
|
+
* - Types: TokenUsage, MetricsSnapshot, etc.
|
|
10
|
+
* - Namespace: MetricsRegistry (record/snapshot/reset helpers)
|
|
11
|
+
*/
|
|
5
12
|
export * from './metrics/index.js';
|
|
13
|
+
/**
|
|
14
|
+
* MetricsRegistry provides functions to record requests, tokens, and cost,
|
|
15
|
+
* and to snapshot/reset metrics at agent or crew granularity.
|
|
16
|
+
*/
|
|
6
17
|
export { MetricsRegistry } from './metrics/index.js';
|
|
7
18
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
|
|
19
|
+
* Create and manage a crew of Ax agents that share state and metrics.
|
|
20
|
+
* See the `AxCrew` class for full documentation.
|
|
21
|
+
*/
|
|
22
|
+
declare const _AxCrew: typeof AxCrew;
|
|
23
|
+
/**
|
|
24
|
+
* Built-in function registry with common tools that can be referenced by name
|
|
25
|
+
* from agent configs, or extended with your own functions.
|
|
11
26
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
27
|
+
declare const _AxCrewFunctions: typeof AxCrewFunctions;
|
|
28
|
+
export {
|
|
29
|
+
/** See class JSDoc on the `AxCrew` implementation. */
|
|
30
|
+
_AxCrew as AxCrew,
|
|
31
|
+
/** Built-in function registry; see file docs in `src/functions/index.ts`. */
|
|
32
|
+
_AxCrewFunctions as AxCrewFunctions, FunctionRegistryType, type AggregatedMetrics, type AggregatedCosts, type AgentConfig, type AxCrewConfig, type StateInstance, type UsageCost, };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
import { AxCrew } from './agents/index.js';
|
|
2
2
|
import { AxCrewFunctions } from './functions/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Metrics types and helpers for request counts, token usage, and estimated cost.
|
|
5
|
+
*
|
|
6
|
+
* Re-exports the metrics module for convenience:
|
|
7
|
+
* - Types: TokenUsage, MetricsSnapshot, etc.
|
|
8
|
+
* - Namespace: MetricsRegistry (record/snapshot/reset helpers)
|
|
9
|
+
*/
|
|
3
10
|
export * from './metrics/index.js';
|
|
11
|
+
/**
|
|
12
|
+
* MetricsRegistry provides functions to record requests, tokens, and cost,
|
|
13
|
+
* and to snapshot/reset metrics at agent or crew granularity.
|
|
14
|
+
*/
|
|
4
15
|
export { MetricsRegistry } from './metrics/index.js';
|
|
5
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Create and manage a crew of Ax agents that share state and metrics.
|
|
18
|
+
* See the `AxCrew` class for full documentation.
|
|
19
|
+
*/
|
|
20
|
+
const _AxCrew = AxCrew;
|
|
21
|
+
/**
|
|
22
|
+
* Built-in function registry with common tools that can be referenced by name
|
|
23
|
+
* from agent configs, or extended with your own functions.
|
|
24
|
+
*/
|
|
25
|
+
const _AxCrewFunctions = AxCrewFunctions;
|
|
26
|
+
export {
|
|
27
|
+
/** See class JSDoc on the `AxCrew` implementation. */
|
|
28
|
+
_AxCrew as AxCrew,
|
|
29
|
+
/** Built-in function registry; see file docs in `src/functions/index.ts`. */
|
|
30
|
+
_AxCrewFunctions as AxCrewFunctions, };
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { AxFunction, AxSignature, AxModelConfig, AxMCPStreamableHTTPTransportOptions, AxProgramForwardOptions } from '@ax-llm/ax';
|
|
2
|
-
export type Provider = '
|
|
1
|
+
import type { AxFunction, AxSignature, AxModelConfig, AxMCPStreamableHTTPTransportOptions, AxProgramForwardOptions, AxAIArgs } from '@ax-llm/ax';
|
|
2
|
+
export type Provider = AxAIArgs<any>['name'];
|
|
3
3
|
/**
|
|
4
4
|
* A state instance that is shared between agents.
|
|
5
5
|
* This can be used to store data that becomes available to all agents and functions in an out-of-band manner.
|
|
@@ -177,9 +177,56 @@ interface AgentConfig {
|
|
|
177
177
|
mcpServers?: Record<string, MCPTransportConfig>;
|
|
178
178
|
}
|
|
179
179
|
/**
|
|
180
|
-
* The
|
|
180
|
+
* The configuration object for an AxCrew instance.
|
|
181
|
+
*
|
|
182
|
+
* @property {AgentConfig[]} crew - The agents that make up the crew.
|
|
183
|
+
* @example
|
|
184
|
+
* const config: AxCrewConfig = {
|
|
185
|
+
* crew: [
|
|
186
|
+
* {
|
|
187
|
+
* name: "Agent1",
|
|
188
|
+
* description: "Agent 1 description",
|
|
189
|
+
* signature: "signature",
|
|
190
|
+
* provider: "provider",
|
|
191
|
+
* providerKeyName: "providerKeyName",
|
|
192
|
+
* ai: {
|
|
193
|
+
* model: "model",
|
|
194
|
+
* temperature: 0,
|
|
195
|
+
* },
|
|
196
|
+
* options: {
|
|
197
|
+
* debug: true,
|
|
198
|
+
* },
|
|
199
|
+
* functions: ["function1", "function2"],
|
|
200
|
+
* agents: ["agent2"],
|
|
201
|
+
* },
|
|
202
|
+
* {
|
|
203
|
+
* name: "Agent2",
|
|
204
|
+
* description: "Agent 2 description",
|
|
205
|
+
* signature: "signature",
|
|
206
|
+
* provider: "provider",
|
|
207
|
+
* providerKeyName: "providerKeyName",
|
|
208
|
+
* ai: {
|
|
209
|
+
* model: "model",
|
|
210
|
+
* temperature: 0,
|
|
211
|
+
* }
|
|
212
|
+
* ]
|
|
213
|
+
* }
|
|
214
|
+
* const crew = new AxCrew(config);
|
|
181
215
|
*/
|
|
182
|
-
|
|
216
|
+
interface AxCrewConfig {
|
|
183
217
|
crew: AgentConfig[];
|
|
184
|
-
}
|
|
185
|
-
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Options for the AxCrew instance, specifically allowing optional OpenTelemetry injection.
|
|
221
|
+
*
|
|
222
|
+
* @property {Object} [telemetry] - Telemetry configuration.
|
|
223
|
+
* @property {any} [telemetry.tracer] - OpenTelemetry Tracer instance.
|
|
224
|
+
* @property {any} [telemetry.meter] - OpenTelemetry Meter instance.
|
|
225
|
+
*/
|
|
226
|
+
interface AxCrewOptions {
|
|
227
|
+
telemetry?: {
|
|
228
|
+
tracer?: any;
|
|
229
|
+
meter?: any;
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
export { type AgentConfig, type AxCrewConfig, type AxCrewOptions, type AggregatedMetrics, type StateInstance, type FunctionRegistryType, type MCPStdioTransportConfig, type MCPHTTPSSETransportConfig, type MCPStreamableHTTPTransportConfig, type MCPTransportConfig, type ModelUsage, type ModelInfo, type UsageCost, type AggregatedCosts };
|
|
@@ -2,6 +2,8 @@ import { AxCrew } from "../dist/index.js";
|
|
|
2
2
|
import { AxCrewFunctions } from "../dist/functions/index.js";
|
|
3
3
|
import type { AxCrewConfig } from "../dist/index.js";
|
|
4
4
|
import type { Provider } from "../dist/types.js";
|
|
5
|
+
import dotenv from "dotenv";
|
|
6
|
+
dotenv.config();
|
|
5
7
|
|
|
6
8
|
// Example agent configuration
|
|
7
9
|
const agentConfig: AxCrewConfig = {
|
|
@@ -26,10 +28,10 @@ const agentConfig: AxCrewConfig = {
|
|
|
26
28
|
name: "writer",
|
|
27
29
|
description: "A writing agent that creates content",
|
|
28
30
|
signature: "topic:string -> article:string",
|
|
29
|
-
provider: "
|
|
30
|
-
providerKeyName: "
|
|
31
|
+
provider: "google-gemini" as Provider,
|
|
32
|
+
providerKeyName: "GEMINI_API_KEY",
|
|
31
33
|
ai: {
|
|
32
|
-
model: "
|
|
34
|
+
model: "gemini-2.5-flash-lite",
|
|
33
35
|
maxTokens: 4000,
|
|
34
36
|
stream: true
|
|
35
37
|
},
|
package/examples/mcp-agent.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { AxCrew
|
|
1
|
+
import { AxCrew } from "../dist/index.js";
|
|
2
|
+
import type { AxCrewConfig } from "../dist/types.js";
|
|
2
3
|
|
|
3
4
|
import dotenv from "dotenv";
|
|
4
5
|
dotenv.config();
|
|
@@ -7,31 +8,23 @@ dotenv.config();
|
|
|
7
8
|
const config = {
|
|
8
9
|
crew: [
|
|
9
10
|
{
|
|
10
|
-
name: "
|
|
11
|
-
description: "A specialized agent with access to
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
providerKeyName: "ANTHROPIC_API_KEY",
|
|
11
|
+
name: "Context7DocsAgent",
|
|
12
|
+
description: "A specialized agent with access to Context7 Docs APIs that can: search for and get details about API docs",
|
|
13
|
+
signature: 'apiDocQuery:string "a question to be answered" -> apiDocAnswer:string "the answer to the question"',
|
|
14
|
+
provider: "google-gemini",
|
|
15
|
+
providerKeyName: "GEMINI_API_KEY",
|
|
16
16
|
ai: {
|
|
17
|
-
model: "
|
|
17
|
+
model: "gemini-2.5-pro",
|
|
18
18
|
temperature: 0,
|
|
19
|
-
|
|
20
|
-
stream: true
|
|
19
|
+
stream: false
|
|
21
20
|
},
|
|
22
21
|
options: {
|
|
23
22
|
debug: true
|
|
24
23
|
},
|
|
25
24
|
"mcpServers": {
|
|
26
|
-
"
|
|
25
|
+
"context7": {
|
|
27
26
|
"command": "npx",
|
|
28
|
-
"args": [
|
|
29
|
-
"-y",
|
|
30
|
-
"@modelcontextprotocol/server-google-maps"
|
|
31
|
-
],
|
|
32
|
-
"env": {
|
|
33
|
-
"GOOGLE_MAPS_API_KEY": process.env.GOOGLE_MAPS_API_KEY
|
|
34
|
-
}
|
|
27
|
+
"args": ["-y", "@upstash/context7-mcp", "--api-key", process.env.CONTEXT7_API_KEY]
|
|
35
28
|
}
|
|
36
29
|
},
|
|
37
30
|
},
|
|
@@ -41,35 +34,19 @@ const config = {
|
|
|
41
34
|
prompt: "You are a manager agent that orchestrates tools and sub-agents. Read the user's objective, optionally produce a short plan, then call the MapsAgent when geospatial knowledge is needed. Keep answers direct and avoid extraneous commentary.",
|
|
42
35
|
signature:
|
|
43
36
|
'question:string "a question to be answered" -> answer:string "the answer to the question"',
|
|
44
|
-
provider: "
|
|
45
|
-
providerKeyName: "
|
|
37
|
+
provider: "google-gemini",
|
|
38
|
+
providerKeyName: "GEMINI_API_KEY",
|
|
46
39
|
ai: {
|
|
47
|
-
model: "
|
|
40
|
+
model: "gemini-2.5-pro",
|
|
48
41
|
maxTokens: 1000,
|
|
49
42
|
temperature: 0,
|
|
50
|
-
stream:
|
|
43
|
+
stream: false
|
|
51
44
|
},
|
|
52
45
|
options: {
|
|
53
46
|
debug: true,
|
|
54
47
|
},
|
|
55
|
-
agents: ["
|
|
56
|
-
}
|
|
57
|
-
{
|
|
58
|
-
name: "MathAgent",
|
|
59
|
-
description: "Solves math problems",
|
|
60
|
-
signature:
|
|
61
|
-
'mathProblem:string "a sentence describing a math problem to be solved using Python code" -> solution:string "the answer to the math problem"',
|
|
62
|
-
provider: "google-gemini",
|
|
63
|
-
providerKeyName: "GEMINI_API_KEY",
|
|
64
|
-
ai: {
|
|
65
|
-
model: "gemini-1.5-pro",
|
|
66
|
-
temperature: 0,
|
|
67
|
-
stream: true
|
|
68
|
-
},
|
|
69
|
-
options: {
|
|
70
|
-
debug: false,
|
|
71
|
-
},
|
|
72
|
-
},
|
|
48
|
+
agents: ["Context7DocsAgent"]
|
|
49
|
+
}
|
|
73
50
|
],
|
|
74
51
|
};
|
|
75
52
|
|
|
@@ -81,9 +58,9 @@ await crew.addAllAgents();
|
|
|
81
58
|
|
|
82
59
|
// Get agent instances
|
|
83
60
|
const managerAgent = crew.agents?.get("ManagerAgent");
|
|
84
|
-
const
|
|
61
|
+
const context7DocsAgent = crew.agents?.get("Context7DocsAgent");
|
|
85
62
|
|
|
86
|
-
const userQuery: string = "
|
|
63
|
+
const userQuery: string = "How do i create an agent in the @amitdeshmukh/ax-crew framework and configure it to use an MCP server? Give me a concrete example.";
|
|
87
64
|
|
|
88
65
|
console.log(`\n\nQuestion: ${userQuery}`);
|
|
89
66
|
|
|
@@ -97,7 +74,7 @@ const main = async (): Promise<void> => {
|
|
|
97
74
|
// Print metrics
|
|
98
75
|
console.log("\nMetrics:\n+++++++++++++++++++++++++++++++++");
|
|
99
76
|
console.log("Manager Agent Metrics:", JSON.stringify((managerAgent as any)?.getMetrics?.(), null, 2));
|
|
100
|
-
console.log("
|
|
77
|
+
console.log("Context7 Docs Agent Metrics:", JSON.stringify((context7DocsAgent as any)?.getMetrics?.(), null, 2));
|
|
101
78
|
console.log("Crew Metrics:", JSON.stringify((crew as any)?.getCrewMetrics?.(), null, 2));
|
|
102
79
|
};
|
|
103
80
|
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import { AxCrew } from "../dist/index.js";
|
|
2
|
+
import type { AxCrewConfig } from "../dist/types.js";
|
|
2
3
|
|
|
3
4
|
import dotenv from "dotenv";
|
|
4
5
|
dotenv.config();
|
|
5
6
|
|
|
6
7
|
// Define the crew configuration
|
|
7
|
-
const config = {
|
|
8
|
+
const config: AxCrewConfig = {
|
|
8
9
|
crew: [
|
|
9
10
|
{
|
|
10
11
|
name: "DeepResearchAgent",
|
|
11
12
|
description: "A specialized agent that performs deep research using perplexity",
|
|
12
|
-
signature: 'researchTopic:string "a topic of interest" ->
|
|
13
|
-
provider: "
|
|
14
|
-
providerKeyName: "
|
|
13
|
+
signature: 'researchTopic:string "a topic of interest" -> researchResult:string "The result of the research"',
|
|
14
|
+
provider: "google-gemini",
|
|
15
|
+
providerKeyName: "GEMINI_API_KEY",
|
|
15
16
|
ai: {
|
|
16
|
-
model: "
|
|
17
|
+
model: "gemini-2.5-flash-lite",
|
|
17
18
|
temperature: 0.1,
|
|
18
19
|
},
|
|
19
20
|
options: {
|
package/examples/providerArgs.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { AxCrew } from "../dist/index.js";
|
|
2
|
+
import type { AxCrewConfig } from "../dist/types.js";
|
|
2
3
|
|
|
3
4
|
import dotenv from "dotenv";
|
|
4
5
|
dotenv.config();
|
|
5
6
|
|
|
6
7
|
// Define the crew configuration
|
|
7
|
-
const config = {
|
|
8
|
+
const config: AxCrewConfig = {
|
|
8
9
|
crew: [
|
|
9
10
|
{
|
|
10
11
|
name: "XSearchAgent",
|
|
11
12
|
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" ->
|
|
13
|
+
signature: 'searchQuery:string "a search query" -> searchResults:string "the response to the user query citing relevant sources including X posts and other web sources"',
|
|
13
14
|
provider: "grok",
|
|
14
15
|
providerKeyName: "GROK_API_KEY",
|
|
15
16
|
ai: {
|
|
@@ -55,8 +56,8 @@ const main = async (): Promise<void> => {
|
|
|
55
56
|
if (response) {
|
|
56
57
|
try {
|
|
57
58
|
for await (const chunk of response) {
|
|
58
|
-
if (chunk.delta && typeof chunk.delta === 'object' && '
|
|
59
|
-
process.stdout.write(chunk.delta.
|
|
59
|
+
if (chunk.delta && typeof chunk.delta === 'object' && 'searchResults' in chunk.delta) {
|
|
60
|
+
process.stdout.write(chunk.delta.searchResults);
|
|
60
61
|
}
|
|
61
62
|
}
|
|
62
63
|
console.log('\n');
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { AxCrew } from "../dist/index.js";
|
|
2
2
|
import type { AxCrewConfig } from "../src/index.js";
|
|
3
|
+
import dotenv from "dotenv";
|
|
4
|
+
dotenv.config();
|
|
3
5
|
|
|
4
6
|
// Define the crew configuration
|
|
5
7
|
const config: AxCrewConfig = {
|
|
@@ -12,11 +14,11 @@ const config: AxCrewConfig = {
|
|
|
12
14
|
provider: "google-gemini",
|
|
13
15
|
providerKeyName: "GEMINI_API_KEY",
|
|
14
16
|
ai: {
|
|
15
|
-
model: "gemini-
|
|
17
|
+
model: "gemini-2.5-flash-lite",
|
|
16
18
|
temperature: 0,
|
|
17
19
|
},
|
|
18
20
|
options: {
|
|
19
|
-
debug:
|
|
21
|
+
debug: true,
|
|
20
22
|
codeExecution: true,
|
|
21
23
|
},
|
|
22
24
|
},
|
|
@@ -25,10 +27,10 @@ const config: AxCrewConfig = {
|
|
|
25
27
|
description: "Completes a user specified task",
|
|
26
28
|
signature:
|
|
27
29
|
'question:string "a question to be answered" -> answer:string "the answer to the question"',
|
|
28
|
-
provider: "
|
|
29
|
-
providerKeyName: "
|
|
30
|
+
provider: "google-gemini",
|
|
31
|
+
providerKeyName: "GEMINI_API_KEY",
|
|
30
32
|
ai: {
|
|
31
|
-
model: "
|
|
33
|
+
model: "gemini-2.5-flash-lite",
|
|
32
34
|
maxTokens: 1000,
|
|
33
35
|
temperature: 0,
|
|
34
36
|
},
|
package/examples/streaming.ts
CHANGED
|
@@ -15,7 +15,7 @@ const config: AxCrewConfig = {
|
|
|
15
15
|
provider: "google-gemini",
|
|
16
16
|
providerKeyName: "GEMINI_API_KEY",
|
|
17
17
|
ai: {
|
|
18
|
-
model: "gemini-2.
|
|
18
|
+
model: "gemini-2.5-flash",
|
|
19
19
|
maxTokens: 1000,
|
|
20
20
|
temperature: 0,
|
|
21
21
|
},
|
|
@@ -33,7 +33,7 @@ const config: AxCrewConfig = {
|
|
|
33
33
|
provider: "google-gemini",
|
|
34
34
|
providerKeyName: "GEMINI_API_KEY",
|
|
35
35
|
ai: {
|
|
36
|
-
model: "gemini-
|
|
36
|
+
model: "gemini-2.5-pro",
|
|
37
37
|
temperature: 0,
|
|
38
38
|
},
|
|
39
39
|
options: {
|