-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-media-agent.ts
More file actions
105 lines (91 loc) · 2.89 KB
/
test-media-agent.ts
File metadata and controls
105 lines (91 loc) · 2.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/usr/bin/env ts-node
/**
* Manual test script for Simple Media Agent
*
* This tests the media agent by calling its tools directly (not via MCP)
*
* Usage:
* SCOPE3_API_KEY=your_key npx ts-node test-media-agent.ts
*/
import { PlatformClient } from './src/platform-client';
import { getProposedTactics } from './src/simple-media-agent/get-proposed-tactics';
import { manageTactic } from './src/simple-media-agent/manage-tactic';
async function testMediaAgent() {
const apiKey = process.env.SCOPE3_API_KEY;
if (!apiKey) {
console.error('Error: SCOPE3_API_KEY environment variable is required');
process.exit(1);
}
const scope3 = new PlatformClient({
apiKey,
baseUrl: 'https://api.agentic.scope3.com',
});
console.log('🧪 Testing Simple Media Agent\n');
// Test 1: Get Proposed Tactics
console.log('📋 Test 1: get_proposed_tactics');
console.log('------------------------------------');
try {
const proposals = await getProposedTactics(scope3, {
campaignId: 'test-campaign-123',
budgetRange: {
min: 10000,
max: 50000,
currency: 'USD',
},
seatId: 'test-seat-123',
});
console.log('✅ Success!');
console.log('Proposed Tactics:', JSON.stringify(proposals, null, 2));
console.log('');
// Test 2: Manage Tactic
if (proposals.proposedTactics.length > 0) {
console.log('📋 Test 2: manage_tactic');
console.log('------------------------------------');
const tacticAllocations = new Map();
try {
const result = await manageTactic(
scope3,
100, // minDailyBudget
40, // overallocationPercent
tacticAllocations,
{
tacticId: proposals.proposedTactics[0].tacticId,
tacticContext: {
budget: 25000, // budget is a number, not an object
},
brandAgentId: 'test-brand-agent-123',
seatId: 'test-seat-123',
}
);
console.log('✅ Success!');
console.log('Result:', JSON.stringify(result, null, 2));
if (result.acknowledged) {
console.log('');
console.log('📊 Summary:');
console.log(`- Tactic acknowledged: ${result.acknowledged}`);
console.log(`- Original budget: $25,000`);
console.log(`- Overallocation: 40%`);
console.log(`- Expected total allocated: $35,000`);
} else {
console.log(`- Reason: ${result.reason}`);
}
} catch (error) {
console.error('❌ Error:', error);
}
}
} catch (error) {
console.error('❌ Error:', error);
await scope3.disconnect();
process.exit(1);
}
await scope3.disconnect();
}
testMediaAgent()
.then(() => {
console.log('\n✅ All tests completed');
process.exit(0);
})
.catch((error) => {
console.error('\n❌ Test failed:', error);
process.exit(1);
});