( value: string | undefined, )
| 15 | } from './ToolDefinition.js'; |
| 16 | |
| 17 | function headerStringTransform( |
| 18 | value: string | undefined, |
| 19 | ): Record<string, string> | undefined { |
| 20 | if (value === undefined) { |
| 21 | return undefined; |
| 22 | } |
| 23 | if (value === '') { |
| 24 | return {}; |
| 25 | } |
| 26 | try { |
| 27 | const parsed = JSON.parse(value); |
| 28 | if ( |
| 29 | typeof parsed !== 'object' || |
| 30 | parsed === null || |
| 31 | Array.isArray(parsed) |
| 32 | ) { |
| 33 | throw new Error('Headers must be a JSON object'); |
| 34 | } |
| 35 | return parsed as Record<string, string>; |
| 36 | } catch (error) { |
| 37 | throw new Error( |
| 38 | `Invalid JSON for headers: ${error instanceof Error ? error.message : String(error)}`, |
| 39 | ); |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | const throttlingOptions: [string, ...string[]] = [ |
| 44 | 'Offline', |
nothing calls this directly
no outgoing calls
no test coverage detected