(parsed, knownNames)
| 186 | // Filters out entries that don't reference a known tool, when we have a |
| 187 | // known-tool list. Without a list, accepts anything name-shaped. |
| 188 | function _normalize(parsed, knownNames) { |
| 189 | if (!parsed) return []; |
| 190 | const items = Array.isArray(parsed) ? parsed : [parsed]; |
| 191 | const out = []; |
| 192 | for (const item of items) { |
| 193 | if (!item || typeof item !== 'object') continue; |
| 194 | const tc = _coerceOne(item); |
| 195 | if (!tc) continue; |
| 196 | if (knownNames.size > 0 && !knownNames.has(tc.name)) continue; |
| 197 | out.push(tc); |
| 198 | } |
| 199 | return out; |
| 200 | } |
| 201 | |
| 202 | function _coerceOne(item) { |
| 203 | // Form A: { name, arguments } |
no test coverage detected