MCPcopy Create free account
hub / github.com/Noumena-Network/code / appendSourceReferences

Function appendSourceReferences

src/tools/WebFetchTool/sourceProvenance.ts:196–210  ·  view source on GitHub ↗
(
  text: string,
  sources: readonly WebFetchSourceMetadata[],
)

Source from the content-addressed store, hash-verified

194}
195
196function 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
212export function repairWebFetchProvenanceInText(
213 text: string,

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected