import { getFromCache, decodeContentHandle } from "../lib/cache.js";
export async function fetchFullContent(params) {
const { contentHandle, outputFormat = "markdown" } = params;
const url = decodeContentHandle(contentHandle);
if (!url) {
return {
url: "",
title: "",
error: "Invalid contentHandle format. Ensure it was generated by rag() tool.",
};
}
const cached = getFromCache(url);
if (!cached) {
return {
url,
title: "",
error: `Content not found in cache. Cache TTL is 1 hour. Please run rag() again to re-fetch and cache the content.`,
};
}
const result = {
url: cached.url,
title: cached.title,
cached: true,
contentLength: outputFormat === "markdown"
? cached.markdown.length
: cached.content.length,
};
if (outputFormat === "markdown") {
result.markdown = cached.markdown;
}
else if (outputFormat === "text") {
result.text = cached.content;
}
else if (outputFormat === "html") {
result.html = cached.content;
}
return result;
}
//# sourceMappingURL=fetch.js.map