// @bun
var E=Object.defineProperty;var F=(z)=>z;function G(z,A){this[z]=F.bind(null,A)}var I=(z,A)=>{for(var B in A)E(z,B,{get:A[B],enumerable:!0,configurable:!0,set:G.bind(A,B)})};var J=(z,A)=>()=>(z&&(A=z(z=0)),A);import D from"@contractspec/lib.ui-link";import{ChevronRight as H}from"lucide-react";import{jsx as q,jsxs as y}from"react/jsx-runtime";function P(){return y("div",{className:"space-y-8",children:[y("div",{className:"space-y-4",children:[q("h1",{className:"font-bold text-4xl",children:"Knowledge Sources"}),y("p",{className:"text-muted-foreground",children:["A ",q("strong",{children:"KnowledgeSourceConfig"})," connects a tenant's data sources (Notion, Gmail, uploads, databases) to knowledge spaces. Each source is synced, chunked, embedded, and indexed according to the space's configuration."]})]}),y("div",{className:"space-y-4",children:[q("h2",{className:"font-bold text-2xl",children:"KnowledgeSourceConfig"}),q("div",{className:"overflow-x-auto rounded-lg border border-border bg-background/50 p-4 font-mono text-muted-foreground text-sm",children:q("pre",{children:`type KnowledgeSourceConfig = {
  id: string;
  tenantId: string;
  spaceId: string;
  
  // Source type and location
  kind: "uploaded-document" | "url" | "email" 
        | "notion" | "database-query" | "raw-text"
        | "slack" | "confluence" | "google-drive";
  location: string;
  
  // Sync configuration
  syncPolicy: {
    interval?: string;  // e.g., "1h", "24h"
    webhook?: boolean;
    manual?: boolean;
  };
  
  // State
  status: "active" | "paused" | "error";
  lastSyncedAt?: string;
  lastErrorMessage?: string;
  
  // Metadata
  metadata?: Record<string, unknown>;
  createdAt: string;
  updatedAt: string;
};`})})]}),y("div",{className:"space-y-4",children:[q("h2",{className:"font-bold text-2xl",children:"Source types"}),y("div",{className:"space-y-6",children:[y("div",{className:"card-subtle p-4",children:[q("h3",{className:"mb-2 font-semibold text-lg",children:"Uploaded Documents"}),q("div",{className:"overflow-x-auto rounded border border-border bg-background/50 p-3 font-mono text-muted-foreground text-xs",children:q("pre",{children:`{
  kind: "uploaded-document",
  location: "s3://bucket/tenant-123/docs/product-spec.pdf",
  syncPolicy: { manual: true }
}`})}),q("p",{className:"mt-2 text-muted-foreground text-sm",children:"PDFs, Word docs, presentations uploaded by users"})]}),y("div",{className:"card-subtle p-4",children:[q("h3",{className:"mb-2 font-semibold text-lg",children:"Notion"}),q("div",{className:"overflow-x-auto rounded border border-border bg-background/50 p-3 font-mono text-muted-foreground text-xs",children:q("pre",{children:`{
  kind: "notion",
  location: "https://notion.so/workspace/product-docs",
  syncPolicy: { interval: "1h", webhook: true }
}`})}),q("p",{className:"mt-2 text-muted-foreground text-sm",children:"Notion pages and databases with real-time webhook updates"})]}),y("div",{className:"card-subtle p-4",children:[q("h3",{className:"mb-2 font-semibold text-lg",children:"Gmail / Email"}),q("div",{className:"overflow-x-auto rounded border border-border bg-background/50 p-3 font-mono text-muted-foreground text-xs",children:q("pre",{children:`{
  kind: "email",
  location: "support@company.com",
  syncPolicy: { webhook: true }
}`})}),q("p",{className:"mt-2 text-muted-foreground text-sm",children:"Email threads from Gmail or other providers"})]}),y("div",{className:"card-subtle p-4",children:[q("h3",{className:"mb-2 font-semibold text-lg",children:"Database Query"}),q("div",{className:"overflow-x-auto rounded border border-border bg-background/50 p-3 font-mono text-muted-foreground text-xs",children:q("pre",{children:`{
  kind: "database-query",
  location: "SELECT * FROM products WHERE active = true",
  syncPolicy: { interval: "24h" }
}`})}),q("p",{className:"mt-2 text-muted-foreground text-sm",children:"Structured data from application databases"})]}),y("div",{className:"card-subtle p-4",children:[q("h3",{className:"mb-2 font-semibold text-lg",children:"URL / Web Scraping"}),q("div",{className:"overflow-x-auto rounded border border-border bg-background/50 p-3 font-mono text-muted-foreground text-xs",children:q("pre",{children:`{
  kind: "url",
  location: "https://stripe.com/docs",
  syncPolicy: { interval: "24h" }
}`})}),q("p",{className:"mt-2 text-muted-foreground text-sm",children:"External documentation and web content"})]})]})]}),y("div",{className:"space-y-4",children:[q("h2",{className:"font-bold text-2xl",children:"Sync strategies"}),q("div",{className:"overflow-x-auto rounded-lg border border-border/50",children:y("table",{className:"w-full text-left text-sm",children:[q("thead",{className:"bg-card/50",children:y("tr",{className:"border-border/50 border-b",children:[q("th",{className:"px-4 py-3 font-semibold",children:"Strategy"}),q("th",{className:"px-4 py-3 font-semibold",children:"When to Use"}),q("th",{className:"px-4 py-3 font-semibold",children:"Latency"})]})}),y("tbody",{className:"divide-y divide-border/50",children:[y("tr",{children:[q("td",{className:"px-4 py-3 font-mono text-xs",children:"webhook"}),q("td",{className:"px-4 py-3",children:"Real-time updates (Notion, Gmail, Slack)"}),q("td",{className:"px-4 py-3",children:"Seconds"})]}),y("tr",{children:[q("td",{className:"px-4 py-3 font-mono text-xs",children:"interval"}),q("td",{className:"px-4 py-3",children:"Periodic sync (databases, URLs)"}),q("td",{className:"px-4 py-3",children:"Minutes to hours"})]}),y("tr",{children:[q("td",{className:"px-4 py-3 font-mono text-xs",children:"manual"}),q("td",{className:"px-4 py-3",children:"User-triggered (uploads, one-time imports)"}),q("td",{className:"px-4 py-3",children:"On-demand"})]})]})]})})]}),y("div",{className:"space-y-4",children:[q("h2",{className:"font-bold text-2xl",children:"Example: Multi-source space"}),q("p",{className:"text-muted-foreground",children:"A single knowledge space can be fed by multiple sources:"}),q("div",{className:"overflow-x-auto rounded-lg border border-border bg-background/50 p-4 font-mono text-muted-foreground text-sm",children:q("pre",{children:`// Product Canon space with multiple sources
{
  spaceId: "product-canon",
  sources: [
    {
      id: "src_database_schema",
      kind: "database-query",
      location: "SELECT * FROM schema_definitions",
      syncPolicy: { interval: "1h" }
    },
    {
      id: "src_notion_product_docs",
      kind: "notion",
      location: "https://notion.so/product-docs",
      syncPolicy: { interval: "1h", webhook: true }
    },
    {
      id: "src_uploaded_specs",
      kind: "uploaded-document",
      location: "s3://bucket/specs/",
      syncPolicy: { manual: true }
    }
  ]
}`})})]}),y("div",{className:"space-y-4",children:[q("h2",{className:"font-bold text-2xl",children:"Processing pipeline"}),q("p",{className:"text-muted-foreground",children:"When a source is synced, ContractSpec processes it through several stages:"}),y("ol",{className:"list-inside list-decimal space-y-3 text-muted-foreground",children:[y("li",{children:[q("strong",{children:"Fetch"})," - Retrieve content from source (API, database, file)"]}),y("li",{children:[q("strong",{children:"Parse"})," - Extract text from documents (PDF, Word, HTML)"]}),y("li",{children:[q("strong",{children:"Chunk"})," - Split into semantic chunks (paragraphs, sections)"]}),y("li",{children:[q("strong",{children:"Embed"})," - Generate vector embeddings (OpenAI, Cohere)"]}),y("li",{children:[q("strong",{children:"Index"})," - Store in vector database (Qdrant) or search engine"]}),y("li",{children:[q("strong",{children:"Audit"})," - Log sync operation and results"]})]})]}),y("div",{className:"space-y-4",children:[q("h2",{className:"font-bold text-2xl",children:"Best practices"}),y("ul",{className:"list-inside list-disc space-y-2 text-muted-foreground",children:[q("li",{children:"Use webhooks for real-time sources (Notion, Gmail) to minimize latency"}),q("li",{children:"Set appropriate sync intervals - hourly for active docs, daily for stable content"}),q("li",{children:"Monitor sync failures and set up alerts for critical sources"}),q("li",{children:"Test sources in sandbox before enabling in production"}),q("li",{children:"Document the purpose and ownership of each source for your team"}),q("li",{children:"Use manual sync for sensitive or infrequently updated content"})]})]}),y("div",{className:"flex items-center gap-4 pt-4",children:[q(D,{href:"/docs/knowledge/spaces",className:"btn-ghost",children:"Previous: Spaces"}),y(D,{href:"/docs/knowledge/examples",className:"btn-primary",children:["Examples ",q(H,{size:16})]})]})]})}export{P as KnowledgeSourcesPage};
