async function estimateWorkflowCost(steps: Array<{ route: string; calls: number }>) {
const registry = await fetchRegistry('org_clx1abc123');
const byRoute = Object.fromEntries(registry.map(r => [r.route, r]));
let totalCost = 0;
for (const step of steps) {
const route = byRoute[step.route];
if (!route) throw new Error(`Route ${step.route} not in registry`);
totalCost += parseFloat(route.price) * step.calls;
}
return {
totalCost,
currency: 'USDC',
steps: steps.map(s => ({
...s,
pricePerCall: parseFloat(byRoute[s.route].price),
totalForStep: parseFloat(byRoute[s.route].price) * s.calls,
})),
};
}