Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
fix(docs): add error handling to getLLMText for llms.txt
- Check if getText is available before calling it - Try 'processed' mode first (works in serverless), then 'raw' (works locally) - Fall back to description if both fail Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sushmithamallesh committed
Jan 27, 2026 at 23:52 UTC
c3e4824b973567823a1fb8a5f7c1a67dc52c9f44
1 file changed
+27
-1
docs/lib/source.ts
+27
-1
@@ -177,7 +177,33 @@ function mdxToCleanMarkdown(content: string): string {
177
}
178
179
export async function getLLMText(page: InferPageType<typeof source>) {
180
- const content = await page.data.getText('raw');
180
+ // Fall back to description if getText is not available
181
+ if (typeof page.data.getText !== 'function') {
182
+ return `# ${page.data.title} (${page.url})
183
+
184
+${page.data.description || ''}`;
185
+ }
186
+
187
+ // Try 'processed' mode first (works in serverless), then 'raw' (works locally)
188
+ // Both can fail in different environments, so handle gracefully
189
+ let content: string | null = null;
190
+
191
+ try {
192
+ content = await page.data.getText('processed');
193
+ } catch {
194
+ try {
195
+ content = await page.data.getText('raw');
196
+ } catch {
197
+ // Both failed, fall back to description
198
+ }
199
+ }
200
+
201
+ if (!content) {
202
+ return `# ${page.data.title} (${page.url})
203
+
204
+${page.data.description || ''}`;
205
+ }
206
+
207
const cleanContent = mdxToCleanMarkdown(content);
208
209
return `# ${page.data.title} (${page.url})