(value: unknown)
| 56 | } |
| 57 | |
| 58 | function extractCodexText(value: unknown): string { |
| 59 | if (typeof value === 'string') { |
| 60 | return value.trim(); |
| 61 | } |
| 62 | if (Array.isArray(value)) { |
| 63 | return value |
| 64 | .map((item) => { |
| 65 | const record = asRecord(item); |
| 66 | if (record?.type === 'input_text' && typeof record.text === 'string') return record.text; |
| 67 | if (record?.type === 'output_text' && typeof record.text === 'string') return record.text; |
| 68 | if (record?.type === 'text' && typeof record.text === 'string') return record.text; |
| 69 | return null; |
| 70 | }) |
| 71 | .filter((part): part is string => Boolean(part)) |
| 72 | .join(' ') |
| 73 | .trim(); |
| 74 | } |
| 75 | const record = asRecord(value); |
| 76 | if (record?.type === 'input_text' && typeof record.text === 'string') return record.text.trim(); |
| 77 | if (record?.type === 'output_text' && typeof record.text === 'string') return record.text.trim(); |
| 78 | if (record?.type === 'text' && typeof record.text === 'string') return record.text.trim(); |
| 79 | return ''; |
| 80 | } |
| 81 | |
| 82 | function parseArguments(value: unknown): unknown { |
| 83 | if (typeof value !== 'string') { |
no test coverage detected