@amitdeshmukh/ax-crew 8.7.3 → 9.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/CHANGELOG.md +34 -0
- package/README.md +9 -9
- package/dist/agents/agentConfig.d.ts +2 -0
- package/dist/agents/agentConfig.js +11 -4
- package/dist/agents/crew.d.ts +59 -0
- package/dist/agents/crew.js +355 -0
- package/dist/agents/deferredTools.d.ts +49 -0
- package/dist/agents/deferredTools.js +237 -0
- package/dist/agents/index.d.ts +4 -266
- package/dist/agents/index.js +3 -1014
- package/dist/agents/lazyAgent.d.ts +33 -0
- package/dist/agents/lazyAgent.js +78 -0
- package/dist/agents/statefulAgent.d.ts +93 -0
- package/dist/agents/statefulAgent.js +473 -0
- package/dist/index.d.ts +2 -2
- package/dist/types.d.ts +18 -1
- package/examples/graphjin-database-agent.ts +68 -57
- package/examples/write-post-and-publish-to-wordpress.ts +1 -1
- package/package.json +1 -1
- package/src/agents/agentConfig.ts +14 -8
- package/src/agents/crew.ts +443 -0
- package/src/agents/deferredTools.ts +275 -0
- package/src/agents/index.ts +4 -1281
- package/src/agents/lazyAgent.ts +95 -0
- package/src/agents/statefulAgent.ts +659 -0
- package/src/index.ts +7 -4
- package/src/skills/axcrew-functions.md +2 -2
- package/src/skills/axcrew-mcp.md +41 -1
- package/src/skills/axcrew-patterns.md +48 -4
- package/src/skills/axcrew-state.md +16 -16
- package/src/skills/axcrew.md +14 -1
- package/src/types.ts +19 -0
- package/.claude/settings.local.json +0 -13
- package/.claude/skills/ax-crew/SKILL.md +0 -466
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
const DEFAULT_THRESHOLD = 20;
|
|
2
|
+
const DEFAULT_MAX_RESULTS = 10;
|
|
3
|
+
/**
|
|
4
|
+
* Manages deferred tool loading for agents with many tools.
|
|
5
|
+
*
|
|
6
|
+
* When tool count exceeds a threshold, only core tools + a `search_tools`
|
|
7
|
+
* meta-function are visible to the LLM. The LLM calls `search_tools` to
|
|
8
|
+
* discover and activate deferred tools, which are injected via ax-llm
|
|
9
|
+
* step hooks for subsequent turns.
|
|
10
|
+
*/
|
|
11
|
+
export class DeferredToolManager {
|
|
12
|
+
registry;
|
|
13
|
+
deferredNames;
|
|
14
|
+
activatedNames;
|
|
15
|
+
coreNames;
|
|
16
|
+
maxSearchResults;
|
|
17
|
+
_isActive;
|
|
18
|
+
resourceCache;
|
|
19
|
+
constructor(allFunctions, mcpFunctionNames, config) {
|
|
20
|
+
const threshold = config?.threshold ?? DEFAULT_THRESHOLD;
|
|
21
|
+
this.maxSearchResults = config?.maxSearchResults ?? DEFAULT_MAX_RESULTS;
|
|
22
|
+
this.activatedNames = new Set();
|
|
23
|
+
this.resourceCache = new Map();
|
|
24
|
+
// Build full registry
|
|
25
|
+
this.registry = new Map();
|
|
26
|
+
for (const fn of allFunctions) {
|
|
27
|
+
this.registry.set(fn.name, fn);
|
|
28
|
+
}
|
|
29
|
+
// Determine if we should activate deferred mode
|
|
30
|
+
const explicitEnabled = config?.enabled;
|
|
31
|
+
this._isActive = explicitEnabled !== undefined
|
|
32
|
+
? explicitEnabled
|
|
33
|
+
: allFunctions.length > threshold;
|
|
34
|
+
// Classify core vs deferred
|
|
35
|
+
const explicitCore = new Set(config?.coreTools ?? []);
|
|
36
|
+
this.coreNames = new Set();
|
|
37
|
+
this.deferredNames = new Set();
|
|
38
|
+
if (this._isActive) {
|
|
39
|
+
for (const fn of allFunctions) {
|
|
40
|
+
const isMcp = mcpFunctionNames.has(fn.name);
|
|
41
|
+
const isResource = fn.name.startsWith('resource_');
|
|
42
|
+
const isExplicitCore = explicitCore.has(fn.name);
|
|
43
|
+
if (isExplicitCore || isResource || !isMcp) {
|
|
44
|
+
this.coreNames.add(fn.name);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
this.deferredNames.add(fn.name);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
for (const fn of allFunctions) {
|
|
53
|
+
this.coreNames.add(fn.name);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/** Whether deferred mode is active */
|
|
58
|
+
get isActive() {
|
|
59
|
+
return this._isActive;
|
|
60
|
+
}
|
|
61
|
+
/** Get the initial function set (core tools + search_tools) */
|
|
62
|
+
getInitialFunctions() {
|
|
63
|
+
const initial = [];
|
|
64
|
+
for (const name of this.coreNames) {
|
|
65
|
+
const fn = this.registry.get(name);
|
|
66
|
+
if (fn)
|
|
67
|
+
initial.push(fn.name.startsWith('resource_') ? this.wrapWithCache(fn) : fn);
|
|
68
|
+
}
|
|
69
|
+
if (this._isActive) {
|
|
70
|
+
initial.push(this.createSearchToolFunction());
|
|
71
|
+
}
|
|
72
|
+
return initial;
|
|
73
|
+
}
|
|
74
|
+
/** Wrap a resource function so repeated calls return cached results */
|
|
75
|
+
wrapWithCache(fn) {
|
|
76
|
+
const cache = this.resourceCache;
|
|
77
|
+
const originalFunc = fn.func;
|
|
78
|
+
if (!originalFunc)
|
|
79
|
+
return fn;
|
|
80
|
+
return {
|
|
81
|
+
...fn,
|
|
82
|
+
func: async (args) => {
|
|
83
|
+
const cached = cache.get(fn.name);
|
|
84
|
+
if (cached !== undefined)
|
|
85
|
+
return cached;
|
|
86
|
+
const result = await originalFunc(args);
|
|
87
|
+
cache.set(fn.name, result);
|
|
88
|
+
return result;
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Get step hooks for dynamic tool activation.
|
|
94
|
+
* - beforeStep: re-injects previously activated tools at the start of each
|
|
95
|
+
* forward() call so tools discovered in earlier calls persist.
|
|
96
|
+
* - afterFunctionExecution: injects newly discovered tools after search_tools
|
|
97
|
+
* runs, and auto-activates tools mentioned in function results.
|
|
98
|
+
*/
|
|
99
|
+
getStepHooks() {
|
|
100
|
+
const injectedNames = new Set();
|
|
101
|
+
const injectActivated = (ctx) => {
|
|
102
|
+
const toInject = [];
|
|
103
|
+
for (const name of this.activatedNames) {
|
|
104
|
+
if (!this.coreNames.has(name) && !injectedNames.has(name)) {
|
|
105
|
+
const fn = this.registry.get(name);
|
|
106
|
+
if (fn) {
|
|
107
|
+
toInject.push(fn);
|
|
108
|
+
injectedNames.add(name);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
if (toInject.length > 0) {
|
|
113
|
+
ctx.addFunctions(toInject);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
return {
|
|
117
|
+
beforeStep: async (ctx) => {
|
|
118
|
+
if (this.activatedNames.size > 0) {
|
|
119
|
+
injectActivated(ctx);
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
afterFunctionExecution: async (ctx) => {
|
|
123
|
+
if (ctx.functionsExecuted.has('search_tools')) {
|
|
124
|
+
injectActivated(ctx);
|
|
125
|
+
}
|
|
126
|
+
// Auto-activate deferred tools mentioned in function results.
|
|
127
|
+
// Handles cases where a tool error suggests using another tool
|
|
128
|
+
// (e.g., GraphJin's "recommended_tool": "fix_query_error").
|
|
129
|
+
this.autoActivateFromResults(ctx.lastFunctionCalls);
|
|
130
|
+
injectActivated(ctx);
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
/** Scan function results for mentions of deferred tool names and auto-activate them. */
|
|
135
|
+
autoActivateFromResults(functionCalls) {
|
|
136
|
+
if (!functionCalls || functionCalls.length === 0 || this.deferredNames.size === 0)
|
|
137
|
+
return;
|
|
138
|
+
for (const call of functionCalls) {
|
|
139
|
+
const resultText = typeof call.result === 'string'
|
|
140
|
+
? call.result
|
|
141
|
+
: JSON.stringify(call.result ?? '');
|
|
142
|
+
if (!resultText)
|
|
143
|
+
continue;
|
|
144
|
+
for (const name of this.deferredNames) {
|
|
145
|
+
if (!this.activatedNames.has(name) && resultText.includes(name)) {
|
|
146
|
+
this.activatedNames.add(name);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
/** Search deferred tools by keyword matching on name + description */
|
|
152
|
+
search(query) {
|
|
153
|
+
const queryLower = query.toLowerCase();
|
|
154
|
+
const terms = queryLower.split(/[\s_\-./]+/).filter(t => t.length > 1);
|
|
155
|
+
const scored = [];
|
|
156
|
+
for (const name of this.deferredNames) {
|
|
157
|
+
const fn = this.registry.get(name);
|
|
158
|
+
if (!fn)
|
|
159
|
+
continue;
|
|
160
|
+
const searchText = `${fn.name} ${fn.description ?? ''}`.toLowerCase();
|
|
161
|
+
let score = 0;
|
|
162
|
+
for (const term of terms) {
|
|
163
|
+
if (fn.name.toLowerCase().includes(term))
|
|
164
|
+
score += 3;
|
|
165
|
+
if ((fn.description ?? '').toLowerCase().includes(term))
|
|
166
|
+
score += 1;
|
|
167
|
+
}
|
|
168
|
+
if (searchText.includes(queryLower))
|
|
169
|
+
score += 2;
|
|
170
|
+
if (score > 0) {
|
|
171
|
+
scored.push({ name, score });
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
scored.sort((a, b) => b.score - a.score);
|
|
175
|
+
const matchedNames = scored.slice(0, this.maxSearchResults).map(s => s.name);
|
|
176
|
+
if (matchedNames.length === 0) {
|
|
177
|
+
const names = Array.from(this.deferredNames).slice(0, 30);
|
|
178
|
+
return `No tools found matching "${query}". Available tools: ${names.join(', ')}${this.deferredNames.size > 30 ? '...' : ''}`;
|
|
179
|
+
}
|
|
180
|
+
// Separate newly activated from already-active
|
|
181
|
+
const newlyActivated = [];
|
|
182
|
+
const alreadyActive = [];
|
|
183
|
+
for (const name of matchedNames) {
|
|
184
|
+
if (this.activatedNames.has(name)) {
|
|
185
|
+
alreadyActive.push(name);
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
this.activatedNames.add(name);
|
|
189
|
+
const fn = this.registry.get(name);
|
|
190
|
+
if (fn)
|
|
191
|
+
newlyActivated.push(fn);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
if (newlyActivated.length === 0) {
|
|
195
|
+
return `All ${alreadyActive.length} matching tools are already active: ${alreadyActive.join(', ')}. Call them directly.`;
|
|
196
|
+
}
|
|
197
|
+
const lines = newlyActivated.map((fn) => {
|
|
198
|
+
const params = fn.parameters?.properties
|
|
199
|
+
? Object.keys(fn.parameters.properties).join(', ')
|
|
200
|
+
: 'none';
|
|
201
|
+
return `- **${fn.name}**: ${fn.description ?? 'No description'} (params: ${params})`;
|
|
202
|
+
});
|
|
203
|
+
const parts = [
|
|
204
|
+
`Found ${newlyActivated.length} new tool(s) matching "${query}":`,
|
|
205
|
+
'',
|
|
206
|
+
...lines,
|
|
207
|
+
'',
|
|
208
|
+
'These tools are now available. Call them directly.',
|
|
209
|
+
];
|
|
210
|
+
if (alreadyActive.length > 0) {
|
|
211
|
+
parts.push(`Also already active: ${alreadyActive.join(', ')}`);
|
|
212
|
+
}
|
|
213
|
+
return parts.join('\n');
|
|
214
|
+
}
|
|
215
|
+
/** Create the search_tools meta-function */
|
|
216
|
+
createSearchToolFunction() {
|
|
217
|
+
return {
|
|
218
|
+
name: 'search_tools',
|
|
219
|
+
description: 'Search for available tools by describing what you need. This agent has additional specialized tools not shown by default. ' +
|
|
220
|
+
'Describe the task (e.g., "query database tables" or "list available schemas") and matching tools will be activated. ' +
|
|
221
|
+
'Call this ONCE to discover tools, then use them directly. Do NOT call search_tools again for already discovered tools.',
|
|
222
|
+
parameters: {
|
|
223
|
+
type: 'object',
|
|
224
|
+
properties: {
|
|
225
|
+
query: {
|
|
226
|
+
type: 'string',
|
|
227
|
+
description: 'Describe what you need to do (e.g., "query database", "list tables", "execute graphql")',
|
|
228
|
+
},
|
|
229
|
+
},
|
|
230
|
+
required: ['query'],
|
|
231
|
+
},
|
|
232
|
+
func: async (args) => {
|
|
233
|
+
return this.search(args.query);
|
|
234
|
+
},
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
}
|
package/dist/agents/index.d.ts
CHANGED
|
@@ -1,266 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
state: StateInstance;
|
|
6
|
-
axai: any;
|
|
7
|
-
private agentName;
|
|
8
|
-
private agentDefinition;
|
|
9
|
-
private executionMode;
|
|
10
|
-
private axGenProgram;
|
|
11
|
-
private costTracker?;
|
|
12
|
-
private debugEnabled;
|
|
13
|
-
private static readonly modernAxAgentRuntime;
|
|
14
|
-
private aceConfig?;
|
|
15
|
-
private aceOptimizer?;
|
|
16
|
-
private acePlaybook?;
|
|
17
|
-
private aceBaseInstruction?;
|
|
18
|
-
private isAxAIService;
|
|
19
|
-
constructor(ai: AxAI, options: Readonly<{
|
|
20
|
-
name: string;
|
|
21
|
-
description: string;
|
|
22
|
-
executionMode?: AgentExecutionMode;
|
|
23
|
-
axAgentOptions?: AxCrewAxAgentOptions;
|
|
24
|
-
definition?: string;
|
|
25
|
-
signature: string | AxSignature;
|
|
26
|
-
agents?: AxAgentic<any, any>[] | undefined;
|
|
27
|
-
functions?: (AxFunction | (() => AxFunction))[] | undefined;
|
|
28
|
-
examples?: Array<Record<string, any>> | undefined;
|
|
29
|
-
mcpServers?: Record<string, MCPTransportConfig> | undefined;
|
|
30
|
-
debug?: boolean;
|
|
31
|
-
}>, state: StateInstance);
|
|
32
|
-
/**
|
|
33
|
-
* @deprecated Use setExamplesCompat() to avoid Ax runtime version coupling.
|
|
34
|
-
*/
|
|
35
|
-
setExamples(examples: Readonly<Array<Record<string, any>>>): void;
|
|
36
|
-
setExamplesCompat(examples: Readonly<Array<Record<string, any>>>): void;
|
|
37
|
-
/**
|
|
38
|
-
* @deprecated Use setDescriptionCompat() to avoid Ax runtime version coupling.
|
|
39
|
-
*/
|
|
40
|
-
setDescription(description: string): void;
|
|
41
|
-
setDescriptionCompat(description: string): void;
|
|
42
|
-
getUsage(): (import("@ax-llm/ax").AxModelUsage & {
|
|
43
|
-
ai: string;
|
|
44
|
-
model: string;
|
|
45
|
-
})[];
|
|
46
|
-
resetUsage(): void;
|
|
47
|
-
private resolveInvocationArgs;
|
|
48
|
-
private executeForwardByMode;
|
|
49
|
-
private recordUsageMetrics;
|
|
50
|
-
private runForwardInvocation;
|
|
51
|
-
forward(values: Record<string, any>, options?: Readonly<AxProgramForwardOptions<any>>): Promise<Record<string, any>>;
|
|
52
|
-
forward(ai: AxAI, values: Record<string, any>, options?: Readonly<AxProgramForwardOptions<any>>): Promise<Record<string, any>>;
|
|
53
|
-
private runStreamingInvocation;
|
|
54
|
-
streamingForward(values: Record<string, any>, options?: Readonly<AxProgramStreamingForwardOptions<any>>): AxGenStreamingOut<any>;
|
|
55
|
-
streamingForward(ai: AxAI, values: Record<string, any>, options?: Readonly<AxProgramStreamingForwardOptions<any>>): AxGenStreamingOut<any>;
|
|
56
|
-
getLastUsageCost(): UsageCost | null;
|
|
57
|
-
getAccumulatedCosts(): UsageCost | null;
|
|
58
|
-
/**
|
|
59
|
-
* Get the current metrics snapshot for this agent.
|
|
60
|
-
* Includes request counts, error rates, token usage, estimated USD cost, and function call stats.
|
|
61
|
-
*
|
|
62
|
-
* @returns A metrics snapshot scoped to this agent within its crew.
|
|
63
|
-
*/
|
|
64
|
-
getMetrics(): import("../metrics/types.js").MetricsSnapshot;
|
|
65
|
-
/**
|
|
66
|
-
* Reset all tracked metrics for this agent (does not affect other agents).
|
|
67
|
-
* Call this to start fresh measurement windows for the agent.
|
|
68
|
-
*/
|
|
69
|
-
resetMetrics(): void;
|
|
70
|
-
/**
|
|
71
|
-
* Initialize ACE (Agentic Context Engineering) for this agent.
|
|
72
|
-
* Builds the optimizer and loads any initial playbook from persistence.
|
|
73
|
-
* Sets up the optimizer for online-only mode if compileOnStart is false.
|
|
74
|
-
*/
|
|
75
|
-
initACE(ace?: ACEConfig): Promise<void>;
|
|
76
|
-
/**
|
|
77
|
-
* Run offline ACE compilation with examples and metric.
|
|
78
|
-
* Compiles the playbook based on training examples.
|
|
79
|
-
*/
|
|
80
|
-
optimizeOffline(params?: {
|
|
81
|
-
metric?: any;
|
|
82
|
-
examples?: any[];
|
|
83
|
-
}): Promise<void>;
|
|
84
|
-
/**
|
|
85
|
-
* Apply online ACE update based on user feedback.
|
|
86
|
-
*
|
|
87
|
-
* For preference-based feedback (e.g., "only show flights between 9am-12pm"),
|
|
88
|
-
* we use our own feedback analyzer that preserves specificity.
|
|
89
|
-
*
|
|
90
|
-
* Note: AxACE's built-in curator is designed for error correction (severity mismatches)
|
|
91
|
-
* and tends to over-abstract preference feedback into generic guidelines.
|
|
92
|
-
* We bypass it and directly use our feedback analyzer for better results.
|
|
93
|
-
*/
|
|
94
|
-
applyOnlineUpdate(params: {
|
|
95
|
-
example: any;
|
|
96
|
-
prediction: any;
|
|
97
|
-
feedback?: string;
|
|
98
|
-
}): Promise<void>;
|
|
99
|
-
/**
|
|
100
|
-
* Get the current ACE playbook for this agent.
|
|
101
|
-
*/
|
|
102
|
-
getPlaybook(): any | undefined;
|
|
103
|
-
/**
|
|
104
|
-
* Apply an ACE playbook to this agent.
|
|
105
|
-
* Stores the playbook for use in next forward() call.
|
|
106
|
-
* Note: Playbook is composed into instruction BEFORE each forward(), mirroring AxACE.compile behavior.
|
|
107
|
-
*/
|
|
108
|
-
applyPlaybook(pb: any): void;
|
|
109
|
-
/**
|
|
110
|
-
* Compose instruction with current playbook and set on agent.
|
|
111
|
-
* This mirrors what AxACE does internally before each forward() during compile().
|
|
112
|
-
* Should be called BEFORE forward() to ensure playbook is in the prompt.
|
|
113
|
-
*/
|
|
114
|
-
private composeInstructionWithPlaybook;
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Lightweight proxy that stands in for a real agent in the crew's agent map.
|
|
118
|
-
* It exposes the same `getFunction()` interface (built from the crew config)
|
|
119
|
-
* but defers the expensive `createAgent()` call — and therefore MCP server
|
|
120
|
-
* startup — until the Manager actually delegates to it.
|
|
121
|
-
*
|
|
122
|
-
* Usage: `crew.addLazyAgent("CreateChart")` instead of `crew.addAgent("CreateChart")`
|
|
123
|
-
*/
|
|
124
|
-
declare class LazyStatefulAxAgent {
|
|
125
|
-
private realAgent;
|
|
126
|
-
private crewRef;
|
|
127
|
-
private agentName;
|
|
128
|
-
private description;
|
|
129
|
-
private signatureStr;
|
|
130
|
-
private func;
|
|
131
|
-
private _id;
|
|
132
|
-
constructor(crewRef: any, agentName: string, crewConfig: AxCrewConfig);
|
|
133
|
-
private resolve;
|
|
134
|
-
getFunction(): AxFunction;
|
|
135
|
-
getSignature(): AxSignatureClass<Record<string, any>, Record<string, any>>;
|
|
136
|
-
getId(): string;
|
|
137
|
-
setId(id: string): void;
|
|
138
|
-
getTraces(): any[];
|
|
139
|
-
setDemos(): void;
|
|
140
|
-
getUsage(): any[];
|
|
141
|
-
resetUsage(): void;
|
|
142
|
-
forward(...args: any[]): Promise<any>;
|
|
143
|
-
streamingForward(...args: any[]): any;
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* AxCrew orchestrates a set of Ax agents that share state,
|
|
147
|
-
* tools (functions), optional MCP servers, streaming, and a built-in metrics
|
|
148
|
-
* registry for tokens, requests, and estimated cost.
|
|
149
|
-
*
|
|
150
|
-
* Typical usage:
|
|
151
|
-
* const crew = new AxCrew(config, AxCrewFunctions)
|
|
152
|
-
* await crew.addAllAgents()
|
|
153
|
-
* const planner = crew.agents?.get("Planner")
|
|
154
|
-
* const res = await planner?.forward({ task: "Plan something" })
|
|
155
|
-
*
|
|
156
|
-
* Key behaviors:
|
|
157
|
-
* - Validates and instantiates agents from a config-first model
|
|
158
|
-
* - Shares a mutable state object across all agents in the crew
|
|
159
|
-
* - Supports sub-agents and a function registry per agent
|
|
160
|
-
* - Tracks per-agent and crew-level metrics via MetricsRegistry
|
|
161
|
-
* - Provides helpers to add agents (individually, a subset, or all) and
|
|
162
|
-
* to reset metrics/costs when needed
|
|
163
|
-
*/
|
|
164
|
-
declare class AxCrew {
|
|
165
|
-
private crewConfig;
|
|
166
|
-
private options?;
|
|
167
|
-
functionsRegistry: FunctionRegistryType;
|
|
168
|
-
crewId: string;
|
|
169
|
-
agents: Map<string, StatefulAxAgent> | null;
|
|
170
|
-
state: StateInstance;
|
|
171
|
-
private executionHistory;
|
|
172
|
-
/**
|
|
173
|
-
* Creates an instance of AxCrew.
|
|
174
|
-
* @param {AxCrewConfig} crewConfig - JSON object with crew configuration.
|
|
175
|
-
* @param {FunctionRegistryType} [functionsRegistry={}] - The registry of functions to use in the crew.
|
|
176
|
-
* @param {AxCrewOptions} [options] - Optional settings for the crew (e.g., telemetry).
|
|
177
|
-
* @param {string} [crewId=uuidv4()] - The unique identifier for the crew.
|
|
178
|
-
*/
|
|
179
|
-
constructor(crewConfig: AxCrewConfig, functionsRegistry?: FunctionRegistryType, options?: AxCrewOptions, crewId?: string);
|
|
180
|
-
/**
|
|
181
|
-
* Factory function for creating an agent.
|
|
182
|
-
* @param {string} agentName - The name of the agent to create.
|
|
183
|
-
* @returns {StatefulAxAgent} The created StatefulAxAgent instance.
|
|
184
|
-
* @throws Will throw an error if the agent creation fails.
|
|
185
|
-
*/
|
|
186
|
-
createAgent: (agentName: string) => Promise<StatefulAxAgent>;
|
|
187
|
-
/**
|
|
188
|
-
* Adds an agent to the crew by name.
|
|
189
|
-
* @param {string} agentName - The name of the agent to add.
|
|
190
|
-
*/
|
|
191
|
-
addAgent(agentName: string): Promise<void>;
|
|
192
|
-
/**
|
|
193
|
-
* Adds a lazy agent to the crew by name.
|
|
194
|
-
* The agent's tool schema is built immediately from the crew config,
|
|
195
|
-
* but the expensive initialization (MCP servers, AI client, etc.) is
|
|
196
|
-
* deferred until the Manager actually delegates to this agent.
|
|
197
|
-
*
|
|
198
|
-
* Use this for sub-agents that may not be needed on every request
|
|
199
|
-
* (e.g., agents with stdio MCP servers that spawn a process).
|
|
200
|
-
*
|
|
201
|
-
* @param {string} agentName - The name of the agent to add lazily.
|
|
202
|
-
*/
|
|
203
|
-
addLazyAgent(agentName: string): void;
|
|
204
|
-
/**
|
|
205
|
-
* Sets up agents in the crew by name.
|
|
206
|
-
* For an array of Agent names provided, it adds
|
|
207
|
-
* the agent to the crew if not already present.
|
|
208
|
-
* @param {string[]} agentNames - An array of agent names to configure.
|
|
209
|
-
* @returns {Map<string, StatefulAxAgent> | null} A map of agent names to their corresponding instances.
|
|
210
|
-
*/
|
|
211
|
-
addAgentsToCrew(agentNames: string[]): Promise<Map<string, StatefulAxAgent> | null>;
|
|
212
|
-
addAllAgents(): Promise<Map<string, StatefulAxAgent> | null>;
|
|
213
|
-
/**
|
|
214
|
-
* Track agent execution for ACE feedback routing
|
|
215
|
-
*/
|
|
216
|
-
trackAgentExecution(taskId: string, agentName: string, input: any): void;
|
|
217
|
-
/**
|
|
218
|
-
* Record agent result for ACE feedback routing
|
|
219
|
-
*/
|
|
220
|
-
recordAgentResult(taskId: string, agentName: string, result: any): void;
|
|
221
|
-
/**
|
|
222
|
-
* Get agent involvement for a task (used for ACE feedback routing)
|
|
223
|
-
*/
|
|
224
|
-
getTaskAgentInvolvement(taskId: string): {
|
|
225
|
-
rootAgent: string;
|
|
226
|
-
involvedAgents: string[];
|
|
227
|
-
taskInput: any;
|
|
228
|
-
agentResults: Map<string, any>;
|
|
229
|
-
duration?: number;
|
|
230
|
-
} | null;
|
|
231
|
-
/**
|
|
232
|
-
* Apply feedback to agents involved in a task for ACE online learning
|
|
233
|
-
*/
|
|
234
|
-
applyTaskFeedback(params: {
|
|
235
|
-
taskId: string;
|
|
236
|
-
feedback: string;
|
|
237
|
-
strategy?: 'all' | 'primary' | 'weighted';
|
|
238
|
-
}): Promise<void>;
|
|
239
|
-
/**
|
|
240
|
-
* Clean up old execution history (call periodically to prevent memory leaks)
|
|
241
|
-
*/
|
|
242
|
-
cleanupOldExecutions(maxAgeMs?: number): void;
|
|
243
|
-
/**
|
|
244
|
-
* Cleans up the crew by dereferencing agents and resetting the state.
|
|
245
|
-
*/
|
|
246
|
-
destroy(): void;
|
|
247
|
-
/**
|
|
248
|
-
* Resets all cost and usage tracking for the entire crew.
|
|
249
|
-
* Also calls each agent's `resetUsage` (if available) and clears crew-level metrics.
|
|
250
|
-
*/
|
|
251
|
-
resetCosts(): void;
|
|
252
|
-
/**
|
|
253
|
-
* Get an aggregate metrics snapshot for the entire crew.
|
|
254
|
-
* Sums requests, errors, tokens, and estimated cost across all agents in the crew.
|
|
255
|
-
*
|
|
256
|
-
* @returns Crew-level metrics snapshot.
|
|
257
|
-
*/
|
|
258
|
-
getCrewMetrics(): import("../metrics/types.js").MetricsSnapshot;
|
|
259
|
-
/**
|
|
260
|
-
* Reset all tracked metrics for the entire crew.
|
|
261
|
-
* Use to clear totals before a new measurement period.
|
|
262
|
-
*/
|
|
263
|
-
resetCrewMetrics(): void;
|
|
264
|
-
}
|
|
265
|
-
export { AxCrew, LazyStatefulAxAgent };
|
|
266
|
-
export type { StatefulAxAgent };
|
|
1
|
+
export { StatefulAxAgent } from './statefulAgent.js';
|
|
2
|
+
export type { ParsedAgentConfig } from './statefulAgent.js';
|
|
3
|
+
export { LazyStatefulAxAgent } from './lazyAgent.js';
|
|
4
|
+
export { AxCrew } from './crew.js';
|