-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathpricing.config.js
More file actions
115 lines (107 loc) · 3.08 KB
/
Copy pathpricing.config.js
File metadata and controls
115 lines (107 loc) · 3.08 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
106
107
108
109
110
111
112
113
114
115
/**
* Centralized Pricing Configuration for StellarMind Premium Endpoints
*
* This is the single source of truth for all premium endpoint pricing.
* Changes here automatically propagate to:
* - x402 payment middleware configuration
* - Status endpoint output
* - Broadcast events
* - Integration tests
*
* Price format: "$X.XX" (USD equivalent in USDC)
*/
export const pricingConfig = {
// Premium agent endpoints with x402 payment requirements
endpoints: {
'GET /api/premium/research': {
price: '$0.01',
agent: 'research-bot',
description: 'Research Agent - Web research and information gathering',
emoji: '🔬',
},
'GET /api/premium/summarize': {
price: '$0.01',
agent: 'summary-bot',
description: 'Summary Agent - Text summarization and condensing',
emoji: '📝',
},
'GET /api/premium/analyze': {
price: '$0.05',
agent: 'analyst-bot',
description: 'Analysis Agent - Deep analysis and insights',
emoji: '📊',
},
'GET /api/premium/code': {
price: '$0.03',
agent: 'code-bot',
description: 'Code Agent - Code generation and debugging',
emoji: '💻',
},
},
// Pricing map for easy lookup by endpoint or agent
byEndpoint: {},
byAgent: {},
byPrice: {},
/**
* Get price for a specific endpoint
* @param {string} endpoint - e.g., 'GET /api/premium/research'
* @returns {string} Price in format '$X.XX'
*/
getPrice(endpoint) {
return this.endpoints[endpoint]?.price
},
/**
* Get all premium endpoints
* @returns {Array} Array of endpoint paths
*/
getPremiumEndpoints() {
return Object.keys(this.endpoints)
},
/**
* Get pricing info for an endpoint
* @param {string} endpoint - e.g., 'GET /api/premium/research'
* @returns {Object} Pricing info object
*/
getEndpointInfo(endpoint) {
return this.endpoints[endpoint]
},
/**
* Get all pricing info as array (for status endpoint)
* @returns {Array} Array of pricing info objects
*/
getAllPricingInfo() {
return Object.entries(this.endpoints).map(([endpoint, info]) => ({
endpoint,
...info,
}))
},
/**
* Get pricing map for x402 middleware configuration
* @param {Object} config - Network config with network and payTo address
* @returns {Object} x402 middleware pricing configuration
*/
getX402Config(config) {
const x402Config = {}
for (const [endpoint, info] of Object.entries(this.endpoints)) {
x402Config[endpoint] = {
accepts: {
scheme: 'exact',
price: info.price,
network: config.network,
payTo: config.payTo,
},
}
}
return x402Config
},
}
// Build lookup maps for fast access
Object.entries(pricingConfig.endpoints).forEach(([endpoint, info]) => {
pricingConfig.byEndpoint[endpoint] = info
pricingConfig.byAgent[info.agent] = { endpoint, ...info }
const priceKey = info.price
if (!pricingConfig.byPrice[priceKey]) {
pricingConfig.byPrice[priceKey] = []
}
pricingConfig.byPrice[priceKey].push({ endpoint, agent: info.agent })
})