System Knowledge & Documentation Ingestion
Relevant source files
The following files were used as context for generating this wiki page:
- packages/core/api/systems-documentation.ts
- packages/core/documentation/documentation-search.ts
- packages/core/documentation/documentation-utils.ts
- packages/core/documentation/strategies/fetching-playwright.ts
- packages/core/systems/system-manager.ts
- packages/web/src/lib/agent/skills/content/systems-handling.md
The System Knowledge and Documentation Ingestion module manages the acquisition, processing, and retrieval of technical documentation for external integrations. It enables the superglue platform to understand API structures, authentication requirements, and endpoint behaviors by ingesting OpenAPI/Swagger specifications, scraping web documentation, or processing uploaded files.
This system provides a searchable knowledge base that the superglue agent uses to build and debug tools. It supports automated discovery via sitemaps, headless browser scraping for single-page applications, and specific keyword-based relevance scoring to extract the most pertinent information for a given task.
Sources: packages/core/documentation/documentation-search.ts, packages/web/src/lib/agent/skills/content/systems-handling.md
Ingestion Architecture
Documentation ingestion occurs through three primary channels: URL scraping, direct OpenAPI specification fetching, and manual file uploads.
Documentation Types and Sources
| Source Type | Actor / Trigger | Description |
|---|---|---|
documentationUrl | create_system | Triggers a one-time background scrape of a documentation website. |
openApiUrl | create_system | Fetches a JSON/YAML OpenAPI spec and stores it as a file reference. |
files | User Upload | Processes PDF, text, or markdown files uploaded by the user. |
| System Knowledge | Internal Templates | Auto-populates URLs and metadata from pre-defined system templates. |
Sources: packages/web/src/lib/agent/skills/content/systems-handling.md:92-101, packages/core/api/systems-documentation.ts:413-460
Ingestion Data Flow
The following diagram illustrates how the system processes a documentation URL into a searchable knowledge base:
The ingestion process prioritizes sitemap discovery for comprehensive coverage before falling back to iterative link crawling.
Sources: packages/core/documentation/strategies/fetching-playwright.ts:250-320, packages/core/api/systems-documentation.ts:46-86
Web Scraping & Discovery
The PlaywrightFetchingStrategy uses a headless browser to ingest web-based documentation. It manages complex sites by identifying sitemaps and ranking links based on their likelihood of containing technical reference material.
Discovery Strategies
- Sitemap Discovery: The system searches for
sitemap.xmlorsitemap_index.xmlat the base URL and parent paths. It recursively processes nested sitemaps up to a maximum depth of 3. - Iterative Crawling: If no sitemap is found, the system extracts links from the starting page. It filters these links using an exclusion list (e.g., pricing, login, blog) and ranks them using a weighted keyword algorithm.
- Deduplication: To prevent redundant storage, the system calculates the Jaccard similarity and Dice coefficient between page contents. It skips pages that exceed the similarity threshold (default 80%).
Sources: packages/core/documentation/strategies/fetching-playwright.ts:250-400, packages/core/documentation/strategies/fetching-playwright.ts:16-30
Link Ranking Logic
The system ranks discovered items by scoring the URL path and link text against technical keywords like "api", "endpoints", "authentication", and "developer". It applies a length penalty to URLs to prefer shorter, more direct paths.
Sources: packages/core/documentation/documentation-utils.ts:133-170
Documentation Search & Relevance
The DocumentationSearch class extracts the most relevant sections of stored documentation to satisfy a specific user query or tool-building instruction.
Search Algorithm
The search engine processes content in three distinct layers:
- Security Extraction: If the query contains keywords like "auth" or "token", the system extracts security schemes from the OpenAPI schema.
- OpenAPI Operation Scoring: The system identifies specific API endpoints by matching the query against
operationId,summary,description, andparameters. - Textual Content Ranking: For general documentation, the system splits text into chunks (default 2000 characters) and scores them based on keyword density. Exact matches are weighted 3x higher than partial matches.
Sources: packages/core/documentation/documentation-search.ts:60-120, packages/core/documentation/documentation-search.ts:136-155
This flow ensures the agent only receives the documentation necessary for the current task, staying within LLM context limits.
Sources: packages/core/systems/system-manager.ts:145-180, packages/core/documentation/documentation-search.ts:40-60
Configuration & Constraints
The documentation system is governed by several limits to ensure performance and prevent excessive resource consumption.
| Parameter | Default Value | Description |
|---|---|---|
MAX_FETCHED_LINKS | 10 | Maximum number of individual pages to fetch per scrape job. |
MAX_TOTAL_CONTENT_SIZE | 10MB | Combined byte limit for all ingested pages in one system. |
SECTION_SIZE | 2000 chars | The size of chunks used during documentation search. |
TIMEOUT_PLAYWRIGHT | 30,000ms | Timeout for headless browser page loads. |
SIMILARITY_THRESHOLD | 80% | Threshold for deduplicating similar documentation pages. |
Sources: packages/core/documentation/strategies/fetching-playwright.ts:33-36, packages/core/documentation/documentation-search.ts:51-52, packages/core/documentation/strategies/fetching-playwright.ts:430-440
OpenAPI Handling
The system treats OpenAPI specifications as high-priority structured knowledge. When a documentation scrape is triggered, the system automatically attempts to detect OpenAPI endpoints hidden in the HTML of the page.
Detection Strategies
- Swagger UI Settings: Inspects
<script id="swagger-settings">for spec URLs. - JSON/YAML Patterns: Scans for strings matching
openapi.json,swagger.yaml, or similar patterns in the HTML source. - Strategy-based Fetching: Uses specific strategies like
SwaggerHubStrategyorSwaggerUIStrategyto resolve specifications from common hosting platforms.
Sources: packages/core/api/systems-documentation.ts:100-140, packages/core/documentation/documentation-utils.ts:380-410
Conclusion
System Knowledge and Documentation Ingestion acts as the "brain" for superglue integrations. By combining automated web discovery with structured API analysis, it transforms raw technical documentation into actionable context. This ensures that the platform can remain up-to-date with external API changes while providing the agent with precise, relevant information for building deterministic workflows.