@amitdeshmukh/ax-crew 8.7.3 → 9.0.1
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 +40 -0
- package/README.md +9 -9
- package/dist/agents/agentConfig.d.ts +3 -0
- package/dist/agents/agentConfig.js +12 -4
- package/dist/agents/crew.d.ts +59 -0
- package/dist/agents/crew.js +356 -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 +97 -0
- package/dist/agents/statefulAgent.js +478 -0
- package/dist/index.d.ts +2 -2
- package/dist/types.d.ts +18 -1
- package/examples/graphjin-database-agent.ts +85 -64
- package/examples/write-post-and-publish-to-wordpress.ts +1 -1
- package/package.json +1 -1
- package/src/agents/agentConfig.ts +15 -8
- package/src/agents/crew.ts +444 -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 +668 -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,95 @@
|
|
|
1
|
+
import { AxSignature as AxSignatureClass } from "@ax-llm/ax";
|
|
2
|
+
import type { AxFunction } from "@ax-llm/ax";
|
|
3
|
+
import type { AxCrewConfig } from "../types.js";
|
|
4
|
+
import type { StatefulAxAgent } from "./statefulAgent.js";
|
|
5
|
+
import { parseCrewConfig } from "./agentConfig.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Lightweight proxy that stands in for a real agent in the crew's agent map.
|
|
9
|
+
* It exposes the same `getFunction()` interface (built from the crew config)
|
|
10
|
+
* but defers the expensive `createAgent()` call — and therefore MCP server
|
|
11
|
+
* startup — until the Manager actually delegates to it.
|
|
12
|
+
*
|
|
13
|
+
* Usage: `crew.addLazyAgent("CreateChart")` instead of `crew.addAgent("CreateChart")`
|
|
14
|
+
*/
|
|
15
|
+
class LazyStatefulAxAgent {
|
|
16
|
+
private realAgent: StatefulAxAgent | null = null;
|
|
17
|
+
private crewRef: any; // AxCrew — forward-declared to avoid circular ref
|
|
18
|
+
private agentName: string;
|
|
19
|
+
private description: string;
|
|
20
|
+
private signatureStr: string;
|
|
21
|
+
private func: AxFunction;
|
|
22
|
+
private _id: string = "lazy";
|
|
23
|
+
|
|
24
|
+
constructor(crewRef: any, agentName: string, crewConfig: AxCrewConfig) {
|
|
25
|
+
this.crewRef = crewRef;
|
|
26
|
+
this.agentName = agentName;
|
|
27
|
+
|
|
28
|
+
const agentDef = parseCrewConfig(crewConfig).crew.find(
|
|
29
|
+
(a) => a.name === agentName
|
|
30
|
+
);
|
|
31
|
+
if (!agentDef) {
|
|
32
|
+
throw new Error(`Agent "${agentName}" not found in crew config`);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
this.description = agentDef.description;
|
|
36
|
+
this.signatureStr = agentDef.signature as string;
|
|
37
|
+
|
|
38
|
+
// Build the tool schema from the signature's input fields
|
|
39
|
+
const sig = new AxSignatureClass(this.signatureStr);
|
|
40
|
+
const parameters = sig.toInputJSONSchema();
|
|
41
|
+
|
|
42
|
+
this.func = {
|
|
43
|
+
name: agentName.replace(/[^a-zA-Z0-9_]/g, "_").toLowerCase(),
|
|
44
|
+
description: this.description,
|
|
45
|
+
parameters,
|
|
46
|
+
func: async (args?: any) => {
|
|
47
|
+
const agent = await this.resolve();
|
|
48
|
+
return agent.forward(args);
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
private async resolve(): Promise<StatefulAxAgent> {
|
|
54
|
+
if (!this.realAgent) {
|
|
55
|
+
const agent = await this.crewRef.createAgent(this.agentName) as StatefulAxAgent;
|
|
56
|
+
agent.setId(this._id);
|
|
57
|
+
this.realAgent = agent;
|
|
58
|
+
}
|
|
59
|
+
return this.realAgent!;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// AxAgentic interface
|
|
63
|
+
getFunction(): AxFunction {
|
|
64
|
+
return this.func;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
getSignature() {
|
|
68
|
+
return new AxSignatureClass(this.signatureStr);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// AxProgrammable / AxTunable stubs
|
|
72
|
+
getId(): string { return this._id; }
|
|
73
|
+
setId(id: string): void { this._id = id; }
|
|
74
|
+
getTraces(): any[] { return this.realAgent?.getTraces() ?? []; }
|
|
75
|
+
setDemos(): void { /* no-op until resolved */ }
|
|
76
|
+
getUsage(): any[] { return this.realAgent?.getUsage() ?? []; }
|
|
77
|
+
resetUsage(): void { this.realAgent?.resetUsage(); }
|
|
78
|
+
|
|
79
|
+
// Forward / streaming — resolve on demand
|
|
80
|
+
async forward(...args: any[]): Promise<any> {
|
|
81
|
+
const agent = await this.resolve();
|
|
82
|
+
return (agent as any).forward(...args);
|
|
83
|
+
}
|
|
84
|
+
streamingForward(...args: any[]): any {
|
|
85
|
+
// Must be sync to match the interface, so we wrap in an async generator
|
|
86
|
+
const self = this;
|
|
87
|
+
async function* lazyStream() {
|
|
88
|
+
const agent = await self.resolve();
|
|
89
|
+
yield* (agent as any).streamingForward(...args);
|
|
90
|
+
}
|
|
91
|
+
return lazyStream();
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export { LazyStatefulAxAgent };
|