| 49 | |
| 50 | const allowed_tools = build_allowed_tools(tool_groups, custom_tools); |
| 51 | function parse_rate_limit(rate_limit_str) { |
| 52 | if (!rate_limit_str) |
| 53 | return null; |
| 54 | |
| 55 | const match = rate_limit_str.match(/^(\d+)\/(\d+)([mhs])$/); |
| 56 | if (!match) |
| 57 | throw new Error('Invalid RATE_LIMIT format. Use: 100/1h or 50/30m'); |
| 58 | |
| 59 | const [, limit, time, unit] = match; |
| 60 | const multiplier = unit==='h' ? 3600 : unit==='m' ? 60 : 1; |
| 61 | |
| 62 | return { |
| 63 | limit: parseInt(limit), |
| 64 | window: parseInt(time) * multiplier * 1000, |
| 65 | display: rate_limit_str |
| 66 | }; |
| 67 | } |
| 68 | |
| 69 | const rate_limit_config = parse_rate_limit(process.env.RATE_LIMIT); |
| 70 | |