import type { PersistedContextFile } from "./details.js"; type TextContent = { type: "text"; text: string }; function escapeXml(value: string): string { return value .replaceAll("&", "&") .replaceAll('"', """) .replaceAll("<", "<") .replaceAll(">", ">"); } export function appendAgentsContext( content: TContent[], files: PersistedContextFile[], ): Array { if (!files.length) return content; const appendix = [ "", ...files.map( (file) => `\n${escapeXml(file.content)}\n`, ), "", ].join("\n"); return [...content, { type: "text", text: appendix }]; }