@amitdeshmukh/ax-crew 8.6.0 → 8.7.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.
@@ -0,0 +1,124 @@
1
+ ---
2
+ name: ax-crew
3
+ version: __VERSION__
4
+ description: "AxCrew - multi-agent orchestration: crew, agents, addAgent, addAllAgents, addAgentsToCrew, forward, streaming, sub-agents"
5
+ ---
6
+
7
+ # AxCrew
8
+
9
+ Multi-agent orchestration built on [ax-llm/ax](https://github.com/ax-llm/ax). Config-driven crew of agents sharing state, functions, and metrics.
10
+
11
+ ## Use These Defaults
12
+
13
+ ```ts
14
+ import { AxCrew, AxCrewFunctions } from '@amitdeshmukh/ax-crew';
15
+ import type { AxCrewConfig } from '@amitdeshmukh/ax-crew';
16
+ ```
17
+
18
+ Always call `addAllAgents()` or `addAgentsToCrew([...names])` before using agents. Retrieve agents via `crew.agents.get("AgentName")`.
19
+
20
+ ## Canonical Pattern
21
+
22
+ ```ts
23
+ import { AxCrew, AxCrewFunctions } from '@amitdeshmukh/ax-crew';
24
+ import type { AxCrewConfig } from '@amitdeshmukh/ax-crew';
25
+ import dotenv from 'dotenv';
26
+ dotenv.config();
27
+
28
+ const config: AxCrewConfig = {
29
+ crew: [
30
+ {
31
+ name: "researcher",
32
+ description: "A research agent that finds information",
33
+ signature: "query:string -> research:string",
34
+ provider: "google-gemini",
35
+ providerKeyName: "GEMINI_API_KEY",
36
+ ai: { model: "gemini-2.5-flash-lite", maxTokens: 4000, stream: true },
37
+ options: { debug: true },
38
+ functions: ["CurrentDateTime"]
39
+ },
40
+ {
41
+ name: "writer",
42
+ description: "A writing agent that creates content",
43
+ signature: "topic:string -> article:string",
44
+ provider: "google-gemini",
45
+ providerKeyName: "GEMINI_API_KEY",
46
+ ai: { model: "gemini-2.5-flash-lite", maxTokens: 4000, stream: true },
47
+ options: { debug: true },
48
+ agents: ["researcher"] // sub-agent
49
+ }
50
+ ]
51
+ };
52
+
53
+ async function main() {
54
+ const crew = new AxCrew(config, AxCrewFunctions);
55
+
56
+ // Add agents (resolves dependency order automatically)
57
+ await crew.addAllAgents();
58
+
59
+ const writer = crew.agents?.get("writer");
60
+ if (!writer) throw new Error("Failed to initialize writer");
61
+
62
+ try {
63
+ const { article } = await writer.forward({
64
+ topic: "Quantum Computing Benefits",
65
+ });
66
+ console.log("Article:", article);
67
+
68
+ // Metrics
69
+ console.log("Writer Metrics:", JSON.stringify(writer.getMetrics?.(), null, 2));
70
+ console.log("Crew Metrics:", JSON.stringify(crew.getCrewMetrics?.(), null, 2));
71
+ } finally {
72
+ crew.destroy();
73
+ }
74
+ }
75
+
76
+ main().catch(console.error);
77
+ ```
78
+
79
+ ## AxCrew Constructor
80
+
81
+ ```ts
82
+ new AxCrew(crewConfig: AxCrewConfig, functionsRegistry?: FunctionRegistryType, options?: AxCrewOptions, crewId?: string)
83
+ ```
84
+
85
+ - `crewConfig` -- `{ crew: AgentConfig[] }`. See skill `ax-crew-agent-config`.
86
+ - `functionsRegistry` -- map of function name to `AxFunction` or class-based function. See skill `ax-crew-functions`.
87
+ - `options` -- `{ debug?: boolean, telemetry?: { tracer?: any, meter?: any } }`.
88
+ - `crewId` -- auto-generated UUID if omitted.
89
+
90
+ ## Agent Lifecycle
91
+
92
+ | Method | Description |
93
+ |---|---|
94
+ | `await crew.addAllAgents()` | Add all agents from config (resolves dependency order) |
95
+ | `await crew.addAgentsToCrew(["A", "B"])` | Add a subset by name |
96
+ | `await crew.addAgent("A")` | Add a single agent |
97
+ | `crew.addLazyAgent("A")` | Defer expensive init until first use |
98
+ | `crew.agents?.get("A")` | Retrieve a `StatefulAxAgent` |
99
+ | `await agent.forward({ key: "value" })` | Run the agent |
100
+ | `agent.streamingForward({ key: "value" })` | Stream output chunks |
101
+ | `crew.state` | Shared `StateInstance` across all agents |
102
+ | `crew.resetCosts()` | Reset usage/metrics for all agents |
103
+ | `crew.getCrewMetrics()` | Aggregate metrics snapshot |
104
+ | `crew.destroy()` | Clean up agents, state, execution history |
105
+
106
+ ## Related Skills
107
+
108
+ - `ax-crew-agent-config` -- AgentConfig fields, provider setup, executionMode
109
+ - `ax-crew-functions` -- Function registry, custom tools, class-based functions
110
+ - `ax-crew-state` -- Shared state API, accessing state from functions
111
+
112
+ ## Do Not Generate
113
+
114
+ - Do NOT instantiate `AxAgent` or `AxGen` directly; use `AxCrew` which wraps them as `StatefulAxAgent`.
115
+ - Do NOT call `agent.forward()` before calling `addAllAgents()` or `addAgentsToCrew()`.
116
+ - Do NOT import from `@ax-llm/ax` for crew orchestration; import from `@amitdeshmukh/ax-crew`.
117
+ - Do NOT use `crew.createAgent()` directly; use `addAgent()` or `addAllAgents()`.
118
+ - Do NOT forget to call `crew.destroy()` to clean up resources.
119
+
120
+ ## References
121
+
122
+ - [basic-researcher-writer.ts](https://github.com/amitdeshmukh/ax-crew/blob/main/examples/basic-researcher-writer.ts)
123
+ - [write-post-and-publish-to-wordpress.ts](https://github.com/amitdeshmukh/ax-crew/blob/main/examples/write-post-and-publish-to-wordpress.ts)
124
+ - [providerArgs.ts](https://github.com/amitdeshmukh/ax-crew/blob/main/examples/providerArgs.ts)