@amitdeshmukh/ax-crew 6.0.0 → 8.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 +35 -0
- package/README.md +240 -0
- package/dist/agents/ace.d.ts +134 -0
- package/dist/agents/ace.js +477 -0
- package/dist/agents/agentConfig.d.ts +3 -2
- package/dist/agents/agentConfig.js +6 -2
- package/dist/agents/index.d.ts +86 -2
- package/dist/agents/index.js +364 -6
- package/dist/index.d.ts +3 -3
- package/dist/types.d.ts +52 -1
- package/examples/README.md +46 -8
- package/examples/ace-customer-support.ts +480 -0
- package/examples/ace-flight-finder.ts +329 -0
- package/examples/telemetry-demo.ts +165 -0
- package/package.json +3 -2
- package/plan.md +255 -0
- package/playbooks/customer-support.json +32 -0
- package/playbooks/flight-assistant.json +23 -0
- package/src/agents/ace.ts +594 -0
- package/src/agents/agentConfig.ts +8 -2
- package/src/agents/index.ts +416 -8
- package/src/index.ts +14 -2
- package/src/types.ts +67 -1
- package/tests/telemetry.test.ts +81 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
|
|
2
|
+
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
3
|
+
import { AxCrew } from '../src/index.js';
|
|
4
|
+
import type { AxCrewConfig } from '../src/types.js';
|
|
5
|
+
import * as axModule from '@ax-llm/ax';
|
|
6
|
+
|
|
7
|
+
// Mock the entire @ax-llm/ax module
|
|
8
|
+
vi.mock('@ax-llm/ax', async (importOriginal) => {
|
|
9
|
+
const actual = await importOriginal() as typeof axModule;
|
|
10
|
+
return {
|
|
11
|
+
...actual,
|
|
12
|
+
// Spy on the ai factory function
|
|
13
|
+
ai: vi.fn().mockImplementation((args) => {
|
|
14
|
+
// Return a dummy object that mimics enough of AxAI to satisfy AxCrew
|
|
15
|
+
return {
|
|
16
|
+
getName: () => args.name,
|
|
17
|
+
chat: vi.fn(),
|
|
18
|
+
defaults: { model: args.config?.model },
|
|
19
|
+
options: args.options // Store options so we can potentially inspect if needed, though we rely on the spy
|
|
20
|
+
};
|
|
21
|
+
}),
|
|
22
|
+
// We need to keep other exports working if they are used
|
|
23
|
+
AxAgent: actual.AxAgent,
|
|
24
|
+
AxAI: actual.AxAI,
|
|
25
|
+
AxDefaultCostTracker: actual.AxDefaultCostTracker
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
describe('AxCrew Telemetry', () => {
|
|
30
|
+
beforeEach(() => {
|
|
31
|
+
vi.clearAllMocks();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('should pass telemetry options to the underlying AxAI factory', async () => {
|
|
35
|
+
const mockTracer = { isMockTracer: true };
|
|
36
|
+
const mockMeter = { isMockMeter: true };
|
|
37
|
+
|
|
38
|
+
const crewConfig: AxCrewConfig = {
|
|
39
|
+
crew: [
|
|
40
|
+
{
|
|
41
|
+
name: "telemetry-agent",
|
|
42
|
+
description: "An agent for testing telemetry propagation",
|
|
43
|
+
signature: "in:string -> out:string",
|
|
44
|
+
provider: "openai",
|
|
45
|
+
providerKeyName: "OPENAI_API_KEY",
|
|
46
|
+
ai: { model: "gpt-4o-mini" }
|
|
47
|
+
}
|
|
48
|
+
]
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
// Set dummy key
|
|
52
|
+
process.env.OPENAI_API_KEY = 'dummy-key';
|
|
53
|
+
|
|
54
|
+
const options = {
|
|
55
|
+
telemetry: {
|
|
56
|
+
tracer: mockTracer,
|
|
57
|
+
meter: mockMeter
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
// Initialize Crew with telemetry options (3rd argument now)
|
|
62
|
+
const crew = new AxCrew(crewConfig, {}, options as any);
|
|
63
|
+
|
|
64
|
+
// Create the agent
|
|
65
|
+
await crew.addAgent("telemetry-agent");
|
|
66
|
+
|
|
67
|
+
// Check if the 'ai' mock was called with the expected arguments
|
|
68
|
+
expect(axModule.ai).toHaveBeenCalled();
|
|
69
|
+
|
|
70
|
+
// Get the arguments of the first call to ai()
|
|
71
|
+
const callArgs = vi.mocked(axModule.ai).mock.calls[0][0];
|
|
72
|
+
|
|
73
|
+
// Verify the structure
|
|
74
|
+
expect(callArgs).toBeDefined();
|
|
75
|
+
expect(callArgs.options).toBeDefined();
|
|
76
|
+
|
|
77
|
+
// Assert tracer and meter were passed correctly
|
|
78
|
+
expect(callArgs.options.tracer).toBe(mockTracer);
|
|
79
|
+
expect(callArgs.options.meter).toBe(mockMeter);
|
|
80
|
+
});
|
|
81
|
+
});
|