(value: unknown)
| 144 | }; |
| 145 | } |
| 146 | |
| 147 | function normalizeDataConfig(value: unknown): DataConfig { |
| 148 | if (!value || typeof value !== "object") { |
| 149 | return {}; |
| 150 | } |
| 151 | |
| 152 | const raw = value as Record<string, unknown>; |
| 153 | const normalized: DataConfig = {}; |
| 154 | |
| 155 | if (typeof raw.apiKey === "string") { |
| 156 | normalized.apiKey = raw.apiKey; |
| 157 | } |
| 158 | if (typeof raw.provider === "string") { |
| 159 | normalized.provider = raw.provider; |
| 160 | } |
| 161 | if (typeof raw.baseUrl === "string") { |
| 162 | normalized.baseUrl = raw.baseUrl; |
| 163 | } |
| 164 | if (typeof raw.modelId === "string") { |
| 165 | normalized.modelId = raw.modelId; |
| 166 | } |
| 167 | if ( |
| 168 | raw.apiProtocol === "openai-responses" || |
| 169 | raw.apiProtocol === "openai-completions" |
| 170 | ) { |
| 171 | normalized.apiProtocol = raw.apiProtocol; |
| 172 | } |
| 173 | if (typeof raw.reasoning === "boolean") { |
| 174 | normalized.reasoning = raw.reasoning; |
| 175 | } |
| 176 | if (raw.adapters && typeof raw.adapters === "object" && !Array.isArray(raw.adapters)) { |
| 177 | const rawAdapters = raw.adapters as Record<string, unknown>; |
| 178 | const adapters = { ...rawAdapters } as NonNullable<DataConfig["adapters"]>; |
| 179 | const feishu = normalizeFeishuAdapterConfig(rawAdapters.feishu); |
| 180 | if (feishu) { |
| 181 | adapters.feishu = feishu; |
| 182 | } |
| 183 | normalized.adapters = adapters; |
| 184 | } |
| 185 | if (raw._auth && typeof raw._auth === "object" && !Array.isArray(raw._auth)) { |
| 186 | normalized._auth = raw._auth as Record<string, unknown>; |
| 187 | } |
| 188 | |
| 189 | return normalized; |
| 190 | } |
| 191 | |
| 192 | export function resolveRuntimeConfig( |
no test coverage detected