(args: string)
| 142 | } |
| 143 | |
| 144 | function handleSetSession(args: string): string { |
| 145 | const parts = args.trim().split(/\s+/) |
| 146 | const amount = parseFloat(parts[1] ?? '') |
| 147 | |
| 148 | if (isNaN(amount) || amount <= 0) { |
| 149 | return 'Usage: /x402 set-session <amount>\nAmount must be a positive number (USD).\nExample: /x402 set-session 10.00' |
| 150 | } |
| 151 | |
| 152 | try { |
| 153 | setX402MaxSessionSpend(amount) |
| 154 | return `Max session spend set to $${amount.toFixed(2)}` |
| 155 | } catch (err) { |
| 156 | return `Error: ${err instanceof Error ? err.message : String(err)}` |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | function handleNetwork(args: string): string { |
| 161 | const parts = args.trim().split(/\s+/) |
no test coverage detected