( text: string, sources: readonly WebFetchSourceMetadata[], )
| 194 | } |
| 195 | |
| 196 | function appendSourceReferences( |
| 197 | text: string, |
| 198 | sources: readonly WebFetchSourceMetadata[], |
| 199 | ): string { |
| 200 | const referenced = sources.filter(source => text.includes(source.source_id)) |
| 201 | if (referenced.length === 0) { |
| 202 | return text |
| 203 | } |
| 204 | const missing = referenced.filter(source => !text.includes(source.final_url)) |
| 205 | if (missing.length === 0) { |
| 206 | return text |
| 207 | } |
| 208 | const lines = missing.map(source => `- ${source.source_id}: ${source.final_url}`) |
| 209 | return `${text.trimEnd()}\n\nSources:\n${lines.join('\n')}` |
| 210 | } |
| 211 | |
| 212 | export function repairWebFetchProvenanceInText( |
| 213 | text: string, |
no outgoing calls
no test coverage detected