MCPcopy
hub / github.com/firecrawl/firecrawl / buildPromptWithWebsiteStructure

Function buildPromptWithWebsiteStructure

apps/api/src/lib/map-utils.ts:369–425  ·  view source on GitHub ↗
({
  basePrompt,
  url,
  teamId,
  flags,
  logger,
  limit = 50,
  includeSubdomains = true,
  allowExternalLinks = false,
  useIndex = true,
  maxFireEngineResults = 500,
}: {
  basePrompt: string;
  url: string;
  teamId: string;
  flags: TeamFlags | null;
  logger: Logger;
  limit?: number;
  includeSubdomains?: boolean;
  allowExternalLinks?: boolean;
  useIndex?: boolean;
  maxFireEngineResults?: number;
})

Source from the content-addressed store, hash-verified

367}
368
369export async function buildPromptWithWebsiteStructure({
370 basePrompt,
371 url,
372 teamId,
373 flags,
374 logger,
375 limit = 50,
376 includeSubdomains = true,
377 allowExternalLinks = false,
378 useIndex = true,
379 maxFireEngineResults = 500,
380}: {
381 basePrompt: string;
382 url: string;
383 teamId: string;
384 flags: TeamFlags | null;
385 logger: Logger;
386 limit?: number;
387 includeSubdomains?: boolean;
388 allowExternalLinks?: boolean;
389 useIndex?: boolean;
390 maxFireEngineResults?: number;
391}): Promise<{ prompt: string; websiteUrls: string[] }> {
392 try {
393 logger.debug("Getting website structure for prompt enhancement");
394 const mapResult = await getMapResults({
395 url,
396 limit,
397 includeSubdomains,
398 crawlerOptions: { sitemap: "include" },
399 teamId,
400 flags,
401 allowExternalLinks,
402 filterByPath: false,
403 useIndex,
404 maxFireEngineResults,
405 });
406
407 const websiteUrls = mapResult.mapResults.map(doc => doc.url);
408 logger.debug("Found website URLs for prompt enhancement", {
409 urlCount: websiteUrls.length,
410 sampleUrls: websiteUrls.slice(0, 5),
411 });
412
413 const prompt = `${basePrompt}\n\n--- WEBSITE STRUCTURE ---\nThe website has the following URL structure (${websiteUrls.length} URLs found, here is a sample of the first ${Math.min(
414 120,
415 websiteUrls.length,
416 )} URLs):\n${websiteUrls.slice(0, 120).join("\n")}\n\nBased on this structure and the user's request, generate appropriate crawler options.`;
417
418 return { prompt, websiteUrls };
419 } catch (e) {
420 logger.warn("Failed to get website structure for prompt enhancement", {
421 error: (e as any)?.message ?? e,
422 });
423 return { prompt: basePrompt, websiteUrls: [] };
424 }
425}

Callers 2

crawlControllerFunction · 0.90

Calls 2

getMapResultsFunction · 0.70
mapMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…