Overview
Port: 4005 The Knowledge Service handles the RAG pipeline including document processing, content connectors, multimodal vector embeddings, knowledge graph extraction, and unified search across multiple knowledge bases.Endpoints
Knowledge Base CRUD
A request with no
x-org-role header is decided as a viewer, never a member (C-191).
Documents
Search
Knowledge Graph
Graph Optimization
These endpoints are unchanged, and still back the Issues queue’s Generate / AI review / Approve / Reject / Apply actions. For reading what the graph flagged, preferGET /knowledge/kb/:id/graph/issues above — the suggestions list knows nothing about orphaned or low-confidence entities.
Agent Links
Link and unlink gate
edit on the knowledge base (knowledge_base) and edit on the agent (bot), branching on each verdict. An agent or KB in another organization answers 404, and a cross-organization link is refused with 409 even for a superadmin; a superadmin may unlink one. Both write an audit entry under the KB’s organization. See Link Agent to KB.
Utilities
RAG Pipeline
Indexing Flow
Pipeline steps:- Upload — Document, URL, or social media source
- Load — LlamaParse (PDF/docx) or LangChain fallback loaders
- Chunk — 1000 characters, 200 overlap
- Extract Media — Vision text extraction for images/PDFs, transcription for audio/video
- Embed — Gemini Embedding 2 (3072 dimensions, multimodal)
- Store — Pinecone (production) or ChromaDB (local)
- Graph Extract — Entity seeding from existing KB entities + LLM extraction
- Summarize — Per-document summaries for KB map
Graph Enhancement
After document-level extraction, an optional enhance-graph pass runs:1
Entity Resolution
LLM-confirmed duplicate detection via name similarity (Levenshtein, substring, abbreviation matching). Merged entities consolidate relationships, aliases, and mention counts.
2
Cross-Document Inference
Discovers relationships between entities appearing in different documents but never explicitly connected in any single document.
Unified Search Flow
Content Connectors
All KB source ingestion flows through a unified pipeline built on the ContentConnector pattern.NormalizedContent
All connectors produceNormalizedContent[] with:
externalId(dedup key),contentHash(change detection via SHA-256)title,textContent,media[](image/video/audio attachments)sourcemetadata (connector name, URL, platform, author, publishedAt)- Optional:
thumbnailUrl,engagementMetrics,mediaType
Core Services
Database Tables
External Integrations
Critical Patterns
Billing
Billing
All external calls MUST log costs via
record_external_cost_event().Vector Store Abstraction
Vector Store Abstraction
Use
vectorStoreService abstraction — never call Pinecone or Chroma directly.Async Processing
Async Processing
BullMQ for async processing: max 5 concurrent jobs, 3 retries.
Multimodal Chunks
Multimodal Chunks
Chunks are tagged with
embeddingType: "text" | "image" | "video" | "audio" | "transcript".Authentication
Authentication
request.user.organizationId from JWT middleware, never raw headers.RBAC
RBAC
checkResourceAccess() before all KB operations.
