* Normalize poll options into a trimmed string array. Accepts an array, a JSON * array string, or a newline-separated string (the `json`-typed param can arrive * in any of these forms from block inputs or agent tool-calls).
(value: unknown)
| 13 | * in any of these forms from block inputs or agent tool-calls). |
| 14 | */ |
| 15 | function normalizePollOptions(value: unknown): string[] { |
| 16 | let items: unknown[] = [] |
| 17 | if (Array.isArray(value)) { |
| 18 | items = value |
| 19 | } else if (typeof value === 'string') { |
| 20 | const trimmed = value.trim() |
| 21 | try { |
| 22 | const parsed = JSON.parse(trimmed) |
| 23 | items = Array.isArray(parsed) ? parsed : trimmed.split('\n') |
| 24 | } catch { |
| 25 | items = trimmed.split('\n') |
| 26 | } |
| 27 | } |
| 28 | return items.map((item) => String(item).trim()).filter(Boolean) |
| 29 | } |
| 30 | |
| 31 | export const telegramSendPollTool: ToolConfig<TelegramSendPollParams, TelegramSendMessageResponse> = |
| 32 | { |