(value: unknown, maxLen = MAX_TEXT_LEN)
| 14 | const MAX_CONTEXT_MESSAGES = 4; |
| 15 | |
| 16 | function shortText(value: unknown, maxLen = MAX_TEXT_LEN): string { |
| 17 | let text = ""; |
| 18 | if (typeof value === "string") text = value; |
| 19 | else { |
| 20 | try { |
| 21 | text = JSON.stringify(value); |
| 22 | } catch { |
| 23 | text = String(value); |
| 24 | } |
| 25 | } |
| 26 | text = text.replace(/\s+/g, " ").trim(); |
| 27 | return text.length > maxLen ? `${text.slice(0, maxLen - 3)}...` : text; |
| 28 | } |
| 29 | |
| 30 | function asMessage(value: unknown): Record<string, unknown> | null { |
| 31 | if (!value || typeof value !== "object") return null; |
no outgoing calls
no test coverage detected