(value: unknown)
| 118 | } |
| 119 | |
| 120 | export function parseJsonishValue(value: unknown): unknown { |
| 121 | if (typeof value !== 'string') return value |
| 122 | |
| 123 | const trimmed = value.trim() |
| 124 | if (!trimmed) return value |
| 125 | if (!trimmed.startsWith('{') && !trimmed.startsWith('[')) return value |
| 126 | |
| 127 | try { |
| 128 | return JSON.parse(trimmed) |
| 129 | } catch { |
| 130 | return value |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | export function structuredOutputJsonItems( |
| 135 | source: StructuredOutputJsonSource, |
no test coverage detected