()
| 1639 | |
| 1640 | private ensureDefaults(): void { |
| 1641 | const cfg = this.currentConfig; |
| 1642 | |
| 1643 | if (!cfg.configs || typeof cfg.configs !== "object") { |
| 1644 | cfg.configs = {}; |
| 1645 | } else { |
| 1646 | for (const provider of Object.values(cfg.configs)) { |
| 1647 | provider.type = normalizeProviderType(provider.type); |
| 1648 | if (typeof provider.stream !== "boolean") provider.stream = false; |
| 1649 | if (typeof provider.responses !== "boolean") provider.responses = false; |
| 1650 | } |
| 1651 | } |
| 1652 | |
| 1653 | if (!cfg.currentSearchTag && cfg.currentChatTag) |
| 1654 | cfg.currentSearchTag = cfg.currentChatTag; |
| 1655 | if (!cfg.currentSearchModel && cfg.currentChatModel) |
| 1656 | cfg.currentSearchModel = cfg.currentChatModel; |
| 1657 | if (!cfg.currentImageTag && cfg.currentChatTag) |
| 1658 | cfg.currentImageTag = cfg.currentChatTag; |
| 1659 | if (!cfg.currentImageModel && cfg.currentChatModel) |
| 1660 | cfg.currentImageModel = cfg.currentChatModel; |
| 1661 | if (!cfg.currentVideoTag && cfg.currentChatTag) |
| 1662 | cfg.currentVideoTag = cfg.currentChatTag; |
| 1663 | if (!cfg.currentVideoModel && cfg.currentChatModel) |
| 1664 | cfg.currentVideoModel = cfg.currentChatModel; |
| 1665 | |
| 1666 | if (typeof cfg.imagePreview !== "boolean") cfg.imagePreview = true; |
| 1667 | if (typeof cfg.videoPreview !== "boolean") cfg.videoPreview = true; |
| 1668 | if (typeof cfg.videoAudio !== "boolean") cfg.videoAudio = false; |
| 1669 | if ( |
| 1670 | typeof cfg.videoDuration !== "number" || |
| 1671 | !Number.isFinite(cfg.videoDuration) |
| 1672 | ) |
| 1673 | cfg.videoDuration = 5; |
| 1674 | if (cfg.videoDuration < 5 || cfg.videoDuration > 20) cfg.videoDuration = 5; |
| 1675 | if (typeof cfg.collapse !== "boolean") cfg.collapse = true; |
| 1676 | if ( |
| 1677 | typeof cfg.timeout !== "number" || |
| 1678 | !Number.isFinite(cfg.timeout) || |
| 1679 | cfg.timeout <= 0 |
| 1680 | ) { |
| 1681 | cfg.timeout = 30; |
| 1682 | } |
| 1683 | |
| 1684 | if (!cfg.telegraph || typeof cfg.telegraph !== "object") { |
| 1685 | cfg.telegraph = { enabled: false, limit: 5, list: [] }; |
| 1686 | } else { |
| 1687 | if (typeof cfg.telegraph.enabled !== "boolean") |
| 1688 | cfg.telegraph.enabled = false; |
| 1689 | if (typeof cfg.telegraph.limit !== "number" || cfg.telegraph.limit <= 0) |
| 1690 | cfg.telegraph.limit = 5; |
| 1691 | if (!Array.isArray(cfg.telegraph.list)) { |
| 1692 | cfg.telegraph.list = []; |
| 1693 | } else { |
| 1694 | cfg.telegraph.list = cfg.telegraph.list.filter( |
| 1695 | (item): item is TelegraphItem => |
| 1696 | !!item && |
| 1697 | typeof item.url === "string" && |
| 1698 | typeof item.title === "string" && |
no test coverage detected