* Parse a tRPC JSON-RPC envelope and return `result.data`, throwing on * non-200 responses or unexpected shapes.
( url: string, headers: Record<string, string>, body: unknown, procedure: string )
| 213 | 'paid model', |
| 214 | 'add credits', |
| 215 | 'credits required', |
| 216 | 'credit balance is too low', |
| 217 | 'insufficient funds', |
| 218 | 'payment required', |
| 219 | ] as const; |
| 220 | |
| 221 | export function isCloudAgentNextBillingErrorBody(body: string): boolean { |
| 222 | const normalizedBody = body.toLowerCase(); |
| 223 | |
| 224 | return CLOUD_AGENT_NEXT_BILLING_ERROR_PATTERNS.some(pattern => normalizedBody.includes(pattern)); |
| 225 | } |
| 226 | |
| 227 | function isCloudAgentSandboxStatus(value: unknown): value is CloudAgentSandboxStatus { |
| 228 | return ( |
| 229 | value === 'healthy' || value === 'destroyed' || value === 'unreachable' || value === 'unknown' |
| 230 | ); |
| 231 | } |
| 232 | |
| 233 | function isCloudAgentSessionExecutionHealth( |
| 234 | value: unknown |
| 235 | ): value is CloudAgentSessionExecutionHealth { |
| 236 | return value === 'healthy' || value === 'unknown' || value === 'stale' || value === 'none'; |
| 237 | } |
| 238 | |
| 239 | function isCloudAgentActiveExecutionStatus( |
| 240 | value: unknown |
| 241 | ): value is CloudAgentActiveExecutionStatus { |
| 242 | return ( |
| 243 | value === 'pending' || |
| 244 | value === 'running' || |
| 245 | value === 'completed' || |
| 246 | value === 'failed' || |
no test coverage detected