diff --git a/.claude/settings.local.json b/.claude/settings.local.json deleted file mode 100644 index f108593d..00000000 --- a/.claude/settings.local.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "permissions": { - "allow": [ - "Bash(find:*)", - "Bash(du -sh \"C:\\\\Users\\\\Timothy Lin\\\\Projects\\\\pdr_ai_v2\\\\node_modules\\\\.pnpm\\\\@huggingface+transformers\"*)", - "Bash(cd:*)", - "Bash(npm ls:*)", - "Bash(pnpm build:*)", - "Bash(findstr:*)", - "Bash(pnpm why:*)", - "Bash(git add:*)", - "Bash(git commit:*)", - "Bash(git push)", - "Bash(ls:*)", - "Bash(git -C /Users/timothylin/knowledge-base-redesign log --oneline --all)", - "Bash(git -C /Users/timothylin/knowledge-base-redesign branch -a)", - "Bash(npx drizzle-kit:*)", - "Bash(npm install:*)", - "Bash(npx tsc:*)", - "Bash(npm run build:*)", - "Bash(node --check:*)", - "Bash(mkdir:*)" - ] - } -} diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..353f21c5 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,47 @@ +# Dependencies +node_modules +.pnp +.pnp.js + +# Build output +.next +out +build + +# Generated assets (created by postinstall from node_modules) +public/vad + +# Git +.git +.gitignore + +# Testing +coverage +__tests__ +*.test.ts +*.test.tsx +*.spec.ts +*.spec.tsx +jest.config.js +jest.babel.config.cjs + +.env +.env*.local + +# IDE and misc +.DS_Store +.idea +*.md +!README.md + +# Vercel +.vercel + +# Debug +npm-debug.log* +yarn-debug.log* +yarn-error.log* +.pnpm-debug.log* + +# TypeScript +*.tsbuildinfo diff --git a/.env.example b/.env.example index 142b80f4..201eb03f 100644 --- a/.env.example +++ b/.env.example @@ -12,6 +12,9 @@ # Database DATABASE_URL="postgresql://postgres:password@localhost:5432/pdr_ai_v2" +# Docker Compose: password for PostgreSQL (used by db service) +# POSTGRES_PASSWORD=password + # Clerk Authentication (get from https://clerk.com/) NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY="your_clerk_publishable_key" CLERK_SECRET_KEY="your_clerk_secret_key" @@ -27,5 +30,16 @@ UPLOADTHING_APP_ID="your_uploadthing_app_id" # Required only if you want to enable OCR processing for scanned documents DATALAB_API_KEY="your_datalab_api_key" -# Environment -NODE_ENV="development" +# Landing.AI OCR API (optional - get from https://www.landing.ai/) +LANDING_AI_API_KEY="your_landing_ai_api_key" + +# Tavily API (optional - get from https://www.tavily.com/) +TAVILY_API_KEY="your_tavily_api_key" + +# Azure Document Intelligence OCR API (optional - get from https://learn.microsoft.com/en-us/azure/applied-ai-services/document-intelligence/quickstarts/get-started-with-rest-api?pivots=programming-language-rest-api) +AZURE_DOC_INTELLIGENCE_ENDPOINT="your_azure_doc_intelligence_endpoint" +AZURE_DOC_INTELLIGENCE_KEY="your_azure_doc_intelligence_key" + +# Inngest (required for background document processing - https://inngest.com/) +INNGEST_EVENT_KEY="your_inngest_event_key" +INNGEST_SIGNING_KEY="signkey-dev-xxxxx" diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 74ace567..f6ded82d 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -34,7 +34,8 @@ jobs: DATABASE_URL_UNPOOLED: ${{ secrets.DATABASE_URL_UNPOOLED }} POSTGRES_PRISMA_URL: ${{ secrets.POSTGRES_PRISMA_URL}} POSTGRES_URL: ${{ secrets.POSTGRES_URL }} - + INNGEST_EVENT_KEY: ${{ secrets.INNGEST_EVENT_KEY }} + steps: - name: Checkout code uses: actions/checkout@v4 @@ -52,9 +53,6 @@ jobs: - name: pnpm install run: pnpm install --frozen-lockfile - - name: Generate Drizzle client - run: pnpm db:generate - - name: Push database schema run: pnpm db:push @@ -88,7 +86,8 @@ jobs: DATABASE_URL_UNPOOLED: ${{ secrets.DATABASE_URL_UNPOOLED }} POSTGRES_PRISMA_URL: ${{ secrets.POSTGRES_PRISMA_URL}} POSTGRES_URL: ${{ secrets.POSTGRES_URL }} - + INNGEST_EVENT_KEY: ${{ secrets.INNGEST_EVENT_KEY }} + steps: - name: Checkout code uses: actions/checkout@v4 @@ -106,9 +105,6 @@ jobs: - name: pnpm install run: pnpm install --frozen-lockfile - - name: Generate Drizzle client - run: pnpm db:generate - - name: Build application run: pnpm build diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..0da76e2b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,66 @@ +# Installing dependencies +FROM node:20-alpine AS deps +RUN npm install -g pnpm@10.15.1 +WORKDIR /app + +COPY package.json pnpm-lock.yaml ./ +# scripts currently only include vad-web assets. +COPY scripts ./scripts +RUN pnpm install --frozen-lockfile + +# Builder +FROM node:20-alpine AS builder +RUN npm install -g pnpm@10.15.1 +WORKDIR /app + +COPY --from=deps /app/node_modules ./node_modules +COPY . . +# public/vad is excluded from context; copy from deps (created by postinstall) +COPY --from=deps /app/public/vad ./public/vad + +# Build env validation runs at import time; skip during Docker build +ENV SKIP_ENV_VALIDATION=1 +ENV NEXT_TELEMETRY_DISABLED=1 + +# Build args from docker-compose (passed via --env-file .env) +ARG NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY +ARG OPENAI_API_KEY +ENV NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=${NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY} +ENV OPENAI_API_KEY=${OPENAI_API_KEY} + +RUN pnpm build + +# Schema sync +FROM node:20-alpine AS migrate +RUN npm install -g pnpm@10.15.1 +WORKDIR /app +COPY --from=builder /app/package.json ./package.json +COPY --from=builder /app/pnpm-lock.yaml ./pnpm-lock.yaml +RUN pnpm install --frozen-lockfile --ignore-scripts +COPY --from=builder /app/drizzle.config.ts ./drizzle.config.ts +COPY --from=builder /app/src ./src +COPY --from=builder /app/scripts ./scripts + +CMD ["sh", "-c", "node scripts/ensure-pgvector.mjs && pnpm db:push"] + +# Runner +FROM node:20-alpine AS runner +WORKDIR /app + +ENV NEXT_TELEMETRY_DISABLED=1 + +RUN addgroup --system --gid 1001 nodejs +RUN adduser --system --uid 1001 nextjs + +COPY --from=builder /app/public ./public +COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ +COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static + +USER nextjs + +EXPOSE 3000 + +ENV PORT=3000 +ENV HOSTNAME="0.0.0.0" + +CMD ["node", "server.js"] diff --git a/README.md b/README.md index 6dc7fa61..310e5a75 100644 --- a/README.md +++ b/README.md @@ -1,1104 +1,170 @@ # PDR AI - Professional Document Reader AI -A Next.js application that uses advanced AI technology to analyze, interpret, and extract insights from professional documents. Features employee/employer authentication, document upload and management, AI-powered chat, and **comprehensive predictive document analysis** that identifies missing documents, provides recommendations, and suggests related content. +PDR AI is a Next.js platform for role-based document management, AI-assisted Q&A, and predictive document analysis. It combines document upload, optional OCR, embeddings, and retrieval to help teams find gaps and act faster. + +## โœจ Core Features + +- Clerk-based Employer/Employee authentication with role-aware middleware. +- Document upload pipeline with optional OCR for scanned PDFs. +- PostgreSQL + pgvector semantic retrieval for RAG workflows. +- AI chat and predictive document analysis over uploaded content. +- Optional web-enriched analysis with Tavily. +- Optional reliability/observability via Inngest and LangSmith. ## ๐Ÿ›  Tech Stack -- **Framework**: [Next.js 15](https://nextjs.org/) with TypeScript -- **Authentication**: [Clerk](https://clerk.com/) -- **Database**: PostgreSQL with [Drizzle ORM](https://orm.drizzle.team/) -- **AI Integration**: [OpenAI](https://openai.com/) + [LangChain](https://langchain.com/) -- **OCR Processing**: [Datalab Marker API](https://www.datalab.to/) (optional) -- **File Upload**: [UploadThing](https://uploadthing.com/) -- **Styling**: [Tailwind CSS](https://tailwindcss.com/) -- **Package Manager**: [pnpm](https://pnpm.io/) +- Next.js 15 + TypeScript +- PostgreSQL + Drizzle ORM + pgvector +- Clerk authentication +- OpenAI + LangChain +- UploadThing + optional OCR providers +- Tailwind CSS ## ๐Ÿ“‹ Prerequisites -Before you begin, ensure you have the following installed: - -- **Node.js** (version 18.0 or higher) -- **pnpm** (recommended) or npm -- **Docker** (for local database) -- **Git** +- Node.js 18+ +- pnpm +- Docker + Docker Compose (recommended for local DB/full stack) +- Git -## ๐Ÿ”ง Installation & Setup +## โšก Quick Start -### 1. Clone the Repository +### 1) Clone and install ```bash git clone cd pdr_ai_v2-2 -``` - -### 2. Install Dependencies - -```bash pnpm install ``` -### 3. Environment Configuration - -Create a `.env` file in the root directory with the following variables: - -```env -# ============================================================================= -# DATABASE -# ============================================================================= -# Format: postgresql://[user]:[password]@[host]:[port]/[database] -# For local development using Docker: postgresql://postgres:password@localhost:5432/pdr_ai_v2 -# For production: Use your production PostgreSQL connection string -DATABASE_URL="postgresql://postgres:password@localhost:5432/pdr_ai_v2" - -# ============================================================================= -# AUTHENTICATION (Clerk) -# ============================================================================= -# Get from https://clerk.com/ -# Post-auth redirects are handled automatically by middleware based on user role -NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=your_clerk_publishable_key -CLERK_SECRET_KEY=your_clerk_secret_key - -# ============================================================================= -# AI & EMBEDDINGS -# ============================================================================= -# OpenAI API (get from https://platform.openai.com/) -# Required for AI features: document analysis, embeddings, chat functionality -OPENAI_API_KEY=your_openai_api_key - -# Tavily Search API (get from https://tavily.com/) -# Required for web search capabilities in document analysis -TAVILY_API_KEY=your_tavily_api_key +### 2) Configure environment -# ============================================================================= -# FILE UPLOADS -# ============================================================================= -# UploadThing (get from https://uploadthing.com/) -# Required for file uploads (PDF documents) -UPLOADTHING_TOKEN=your_uploadthing_token +Create `.env` from `.env.example` and fill required values: -# ============================================================================= -# OCR PROVIDERS (Optional) -# ============================================================================= -# Azure Document Intelligence (primary OCR provider) -# Get from https://azure.microsoft.com/en-us/products/ai-services/ai-document-intelligence -AZURE_DOC_INTELLIGENCE_ENDPOINT=https://your-resource.cognitiveservices.azure.com/ -AZURE_DOC_INTELLIGENCE_KEY=your_azure_key +- `DATABASE_URL` +- `NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY` +- `CLERK_SECRET_KEY` +- `OPENAI_API_KEY` +- `UPLOADTHING_TOKEN` -# Landing.AI (fallback for complex/handwritten documents) -# Get from https://landing.ai/ -LANDING_AI_API_KEY=your_landing_ai_key +Optional integrations: -# Datalab Marker API (legacy OCR option) -# Get from https://www.datalab.to/ -DATALAB_API_KEY=your_datalab_api_key +- `TAVILY_API_KEY` +- `INNGEST_EVENT_KEY`, `INNGEST_SIGNING_KEY` +- `AZURE_DOC_INTELLIGENCE_ENDPOINT`, `AZURE_DOC_INTELLIGENCE_KEY` +- `LANDING_AI_API_KEY`, `DATALAB_API_KEY` +- `LANGCHAIN_TRACING_V2`, `LANGCHAIN_API_KEY`, `LANGCHAIN_PROJECT` -# ============================================================================= -# BACKGROUND JOBS (Optional - enables reliable document processing) -# ============================================================================= -# Inngest provides automatic retries, observability, and step-based execution -# Without Inngest, document processing runs synchronously (fire-and-forget) -# Get from https://www.inngest.com/ or use Vercel integration -# INNGEST_EVENT_KEY=your_inngest_event_key -# INNGEST_SIGNING_KEY=your_inngest_signing_key - -# ============================================================================= -# OBSERVABILITY (Optional) -# ============================================================================= -# LangChain/LangSmith (get from https://smith.langchain.com/) -LANGCHAIN_TRACING_V2=true -LANGCHAIN_API_KEY=your_langchain_api_key -LANGCHAIN_PROJECT=pdr-ai-production - -# ============================================================================= -# ENVIRONMENT -# ============================================================================= -# Options: development, test, production -NODE_ENV=development - -# Optional: Skip environment validation (useful for Docker builds) -# SKIP_ENV_VALIDATION=false -``` - -### 4. Database Setup - -#### Start Local PostgreSQL Database +### 3) Start database and apply schema ```bash -# Make the script executable chmod +x start-database.sh - -# Start the database container -./start-database.sh +pnpm db:push ``` -This will: -- Create a Docker container with PostgreSQL -- Set up the database with proper credentials -- Generate a secure password if using default settings - -#### Run Database Migrations +### 4) Run app ```bash -# Generate migration files -pnpm db:generate - -# Apply migrations to database -pnpm db:migrate - -# Alternative: Push schema directly (for development) -pnpm db:push +pnpm run dev ``` -### 5. Set Up External Services +Open `http://localhost:3000`. -#### Clerk Authentication -1. Create account at [Clerk](https://clerk.com/) -2. Create a new application -3. Copy the publishable and secret keys to your `.env` file -4. Configure sign-in/sign-up methods as needed -5. Post-authentication redirects are handled automatically by the middleware based on user role +## ๐Ÿณ Docker Deployment Methods -#### OpenAI API -1. Create account at [OpenAI](https://platform.openai.com/) -2. Generate an API key -3. Add the key to your `.env` file +### Method 1: Full stack (recommended) -#### LangChain (LangSmith) - Optional -1. Create account at [LangSmith](https://smith.langchain.com/) -2. Generate an API key from your account settings -3. Set `LANGCHAIN_TRACING_V2=true` and add `LANGCHAIN_API_KEY` to your `.env` file -4. This enables tracing and monitoring of LangChain operations for debugging and observability - -#### Tavily Search API - Optional -1. Create account at [Tavily](https://tavily.com/) -2. Generate an API key from your dashboard -3. Add `TAVILY_API_KEY` to your `.env` file -4. Used for enhanced web search capabilities in document analysis features - -#### Datalab Marker API - Optional -1. Create account at [Datalab](https://www.datalab.to/) -2. Navigate to the API section and generate an API key -3. Add `DATALAB_API_KEY` to your `.env` file -4. Enables advanced OCR processing for scanned documents and images in PDFs -5. When configured, an OCR checkbox will appear in the document upload interface - -#### UploadThing -1. Create account at [UploadThing](https://uploadthing.com/) -2. Create a new app -3. Copy the secret and app ID to your `.env` file - -## ๐Ÿš€ Running the Application - -### Development Mode +Runs `db` + `migrate` + `app` via Compose: ```bash -pnpm dev +docker compose --env-file .env --profile dev up ``` -The application will be available at `http://localhost:3000` - -### Production Build +Detached mode: ```bash -# Build the application -pnpm build - -# Start production server -pnpm start -``` - -## ๐Ÿš€ Deployment Guide - -### Prerequisites for Production - -Before deploying, ensure you have: -- โœ… All environment variables configured -- โœ… Production database set up (PostgreSQL with pgvector extension) -- โœ… API keys for all external services -- โœ… Domain name configured (if using custom domain) - -### Deployment Options - -#### 1. Vercel (Recommended for Next.js) - -Vercel is the recommended platform for Next.js applications: - -**Steps:** - -1. **Push your code to GitHub** - ```bash - git push origin main - ``` - -2. **Import repository on Vercel** - - Go to [vercel.com](https://vercel.com) and sign in - - Click "Add New Project" - - Import your GitHub repository - -3. **Set up Database and Environment Variables** - - **Database Setup:** - - **Option A: Using Vercel Postgres (Recommended)** - - In Vercel dashboard, go to Storage โ†’ Create Database โ†’ Postgres - - Choose a region and create the database - - Vercel will automatically create the `DATABASE_URL` environment variable - - Enable pgvector extension: Connect to your database and run `CREATE EXTENSION IF NOT EXISTS vector;` - - **Option B: Using Neon Database (Recommended for pgvector support)** - - Create a Neon account at [neon.tech](https://neon.tech) if you don't have one - - Create a new project in Neon dashboard - - Choose PostgreSQL version 14 or higher - - In Vercel dashboard, go to your project โ†’ Storage tab - - Click "Create Database" or "Browse Marketplace" - - Select "Neon" from the integrations - - Click "Connect" or "Add Integration" - - Authenticate with your Neon account - - Select your Neon project and branch - - Vercel will automatically create the `DATABASE_URL` environment variable from Neon - - You may also see additional Neon-related variables like: - - `POSTGRES_URL` - - `POSTGRES_PRISMA_URL` - - `POSTGRES_URL_NON_POOLING` - - Your application uses `DATABASE_URL`, so ensure this is set correctly - - Enable pgvector extension in Neon: - - Go to Neon dashboard โ†’ SQL Editor - - Run: `CREATE EXTENSION IF NOT EXISTS vector;` - - Or use Neon's SQL editor to enable the extension - - **Option C: Using External Database (Manual Setup)** - - In Vercel dashboard, go to Settings โ†’ Environment Variables - - Click "Add New" - - Key: `DATABASE_URL` - - Value: Your PostgreSQL connection string (e.g., `postgresql://user:password@host:port/database`) - - Select environments: Production, Preview, Development (as needed) - - Click "Save" - - **Add Other Environment Variables:** - - In Vercel dashboard, go to Settings โ†’ Environment Variables - - Add all required environment variables: - - `NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY` - - `CLERK_SECRET_KEY` - - `OPENAI_API_KEY` - - `UPLOADTHING_SECRET` - - `UPLOADTHING_APP_ID` - - `NODE_ENV=production` - - `LANGCHAIN_TRACING_V2=true` (optional, for LangSmith tracing) - - `LANGCHAIN_API_KEY` (optional, required if `LANGCHAIN_TRACING_V2=true`) - - `TAVILY_API_KEY` (optional, for enhanced web search) - - `DATALAB_API_KEY` (optional, for OCR processing) - -4. **Configure build settings** - - Build Command: `pnpm build` - - Output Directory: `.next` (default) - - Install Command: `pnpm install` - -5. **Deploy** - - Click "Deploy" - - Vercel will automatically deploy on every push to your main branch - -**Post-Deployment:** - -1. **Enable pgvector Extension** (Required for vector search) - - **For Vercel Postgres**: Connect to your database using Vercel's database connection tool or SQL editor in the Storage dashboard - - **For Neon**: Go to Neon dashboard โ†’ SQL Editor and run the command - - **For External Database**: Connect using your preferred PostgreSQL client - - Run: `CREATE EXTENSION IF NOT EXISTS vector;` - -2. **Run Database Migrations** - - After deployment, run migrations using one of these methods: - ```bash - # Option 1: Using Vercel CLI locally - vercel env pull .env.local - pnpm db:migrate - - # Option 2: Using direct connection (set DATABASE_URL locally) - DATABASE_URL="your_production_db_url" pnpm db:migrate - - # Option 3: Using Drizzle Studio with production URL - DATABASE_URL="your_production_db_url" pnpm db:studio - ``` - -3. **(Optional) Set up Inngest Integration** for reliable background processing - - Go to Vercel โ†’ Integrations โ†’ Browse Marketplace - - Search for "Inngest" and click Add Integration - - Connect your Inngest account (create one at [inngest.com](https://www.inngest.com)) - - The integration automatically sets `INNGEST_EVENT_KEY` and `INNGEST_SIGNING_KEY` - - **Benefits**: Automatic retries, step-based execution, observability dashboard - - **Without Inngest**: Document processing runs synchronously (fire-and-forget) - -4. **Set up Clerk webhooks** (if needed) - - Configure webhook URL in Clerk dashboard - - URL format: `https://your-domain.com/api/webhooks/clerk` - -5. **Configure UploadThing** - - Add your production domain to UploadThing allowed origins - - Configure CORS settings in UploadThing dashboard - -#### 2. Self-Hosted VPS Deployment - -**Prerequisites:** -- VPS with Node.js 18+ installed -- PostgreSQL database (with pgvector extension) -- Nginx (for reverse proxy) -- PM2 or similar process manager - -**Steps:** - -1. **Clone and install dependencies** - ```bash - git clone - cd pdr_ai_v2-2 - pnpm install - ``` - -2. **Configure environment variables** - ```bash - # Create .env file - nano .env - # Add all production environment variables - ``` - -3. **Build the application** - ```bash - pnpm build - ``` - -4. **Set up PM2** - ```bash - # Install PM2 globally - npm install -g pm2 - - # Start the application - pm2 start pnpm --name "pdr-ai" -- start - - # Save PM2 configuration - pm2 save - pm2 startup - ``` - -5. **Configure Nginx** - ```nginx - server { - listen 80; - server_name your-domain.com; - - location / { - proxy_pass http://localhost:3000; - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection 'upgrade'; - proxy_set_header Host $host; - proxy_cache_bypass $http_upgrade; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; - } - } - ``` - -6. **Set up SSL with Let's Encrypt** - ```bash - sudo apt-get install certbot python3-certbot-nginx - sudo certbot --nginx -d your-domain.com - ``` - -7. **Run database migrations** - ```bash - pnpm db:migrate - ``` - -### Production Database Setup - -**Important:** Your production database must have the `pgvector` extension enabled: - -```sql --- Connect to your PostgreSQL database -CREATE EXTENSION IF NOT EXISTS vector; +docker compose --env-file .env --profile dev up -d ``` -**Database Connection:** - -For production, use a managed PostgreSQL service (recommended): -- **Neon**: Fully serverless PostgreSQL with pgvector support -- **Supabase**: PostgreSQL with pgvector extension -- **AWS RDS**: Managed PostgreSQL (requires manual pgvector installation) -- **Railway**: Simple PostgreSQL hosting - -**Example Neon connection string:** -``` -DATABASE_URL="postgresql://user:password@ep-xxx.us-east-2.aws.neon.tech/dbname?sslmode=require" -``` +### Method 2: App container only (external DB) -### Post-Deployment Checklist - -- [ ] Verify all environment variables are set correctly -- [ ] Database migrations have been run -- [ ] Database has pgvector extension enabled -- [ ] Clerk authentication is working -- [ ] File uploads are working (UploadThing) -- [ ] AI features are functioning (OpenAI API) -- [ ] Document processing is working (uploads and vectorization) -- [ ] (Optional) Inngest integration connected for reliable background jobs -- [ ] SSL certificate is configured (if using custom domain) -- [ ] Monitoring and logging are set up -- [ ] Backup strategy is in place - -### Monitoring and Maintenance - -**Health Checks:** -- Monitor application uptime -- Check database connection health -- Monitor API usage (OpenAI, UploadThing) -- Track error rates - -**Backup Strategy:** -- Set up automated database backups -- Configure backup retention policy -- Test restore procedures regularly - -**Scaling Considerations:** -- Database connection pooling (use PgBouncer or similar) -- CDN for static assets (Vercel handles this automatically) -- Rate limiting for API endpoints -- Caching strategy for frequently accessed data - -### Other Useful Scripts +Use this when your database is managed externally. ```bash -# Database management -pnpm db:studio # Open Drizzle Studio (database GUI) -pnpm db:generate # Generate new migrations -pnpm db:migrate # Apply migrations -pnpm db:push # Push schema changes directly - -# Code quality -pnpm lint # Run ESLint -pnpm lint:fix # Fix ESLint issues -pnpm typecheck # Run TypeScript type checking -pnpm format:write # Format code with Prettier -pnpm format:check # Check code formatting - -# Development -pnpm check # Run linting and type checking -pnpm preview # Build and start production preview +docker build -t pdr-ai-app . +docker run --rm -p 3000:3000 \ + -e DATABASE_URL="$DATABASE_URL" \ + -e CLERK_SECRET_KEY="$CLERK_SECRET_KEY" \ + -e NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY="$NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY" \ + -e OPENAI_API_KEY="$OPENAI_API_KEY" \ + pdr-ai-app ``` ---- - -## ๐Ÿงญ End-to-end workflow (how the features connect) - -PDR AI is designed as one connected loop: **capture documents โ†’ make them searchable โ†’ ask questions โ†’ spot gaps โ†’ act โ†’ learn**. - -1. **Authenticate & pick a workspace (Employer / Employee)** - Clerk handles auth and role-based access so employers can manage documents + employees, while employees can view assigned materials. - -2. **Upload documents (optionally OCR)** - Documents are uploaded via UploadThing. If a PDF is scanned/image-based, you can enable **OCR** (Datalab Marker API) to extract clean text. - -3. **Index & store for retrieval** - The backend chunks the extracted text and generates embeddings, storing everything in PostgreSQL (+ pgvector) so downstream AI features can retrieve the right passages. - -4. **Interact with documents (RAG chat + viewer)** - Users open a document in the viewer and ask questions. The AI uses **RAG** over your indexed chunks to answer with document-grounded context, and chat history persists per document/session. - -5. **Run Predictive Document Analysis (find gaps and next steps)** - When you need completeness and compliance help, the predictive analyzer highlights **missing documents**, **broken references**, priority/urgency, and recommended actions (see deep dive below). - -6. **Study Agent: StudyBuddy + AI Teacher (learn from your own documents)** - Turn uploaded PDFs into a guided study experience. The Study Agent reuses the same ingestion + indexing pipeline so both modes can answer questions with **RAG grounded in your uploaded documents**. - - **StudyBuddy mode**: a friendly coach that helps you stay consistent (plan, notes, timer, quick Q&A) - - **AI Teacher mode**: a structured instructor with multiple teaching surfaces (view/edit/draw) for lessons - -7. **Close the loop** - Use insights from chat + predictive analysis + StudyBuddy sessions to upload missing docs, update categories, and keep your organization's knowledge base complete and actionable. - -## Web Search Agent Workflow -Screenshot 2025-11-16 at 2 53 18 PM - -## ๐ŸŽ“ Study Agent (StudyBuddy + AI Teacher) - -The Study Agent is the "learn it" layer on top of the same document ingestion + RAG stack. - -### How sessions work (shared foundation) - -1. **Upload or select your study documents** (same documents used for document Q&A / analysis) -2. **Start onboarding** at `/employer/studyAgent/onboarding` -3. **Choose mode**: **StudyBuddy** or **AI Teacher** -4. **Create a study session**: - - A new session is created and you're redirected with `?sessionId=...` - - Your **profile** (name/grade/gender/field of study) and **preferences** (selected docs, AI personality) are stored - - An initial **study plan** is generated from the documents you selected -5. **Resume anytime**: session data is loaded using `sessionId` so conversations and study progress persist - -### StudyBuddy (friendly coach) +### Method 3: DB container only (host app) -StudyBuddy is optimized for momentum and daily studying while staying grounded in your documents. - -- **Document-grounded help (RAG)**: ask questions about your selected PDFs, and the agent retrieves relevant chunks to answer. -- **Voice chat**: - - Speech-to-text via the browser's Web Speech API - - Optional text-to-speech via ElevenLabs (if configured) - - Messages are persisted to your session so you can continue later -- **Study Plan (Goals)**: - - Create/edit/delete goals - - Mark goals complete/incomplete and track progress - - Attach "materials" (documents) to each goal and one-click "pull up" the doc in the viewer -- **Notes**: - - Create/update/delete notes tied to your study session - - Tag notes and keep them organized while you study -- **Pomodoro timer**: - - Run focus sessions alongside your plan/notes - - Timer state can be synced to your session -- **AI Query tab**: - - A fast Q&A surface for questions while you keep your call / plan visible - -### AI Teacher (structured instructor) - -AI Teacher is optimized for guided instruction and "teaching by doing" across multiple views. - -- **Voice-led teaching + study plan tracking**: - - Voice chat for interactive lessons - - A persistent study plan with material links (click to open the relevant doc) -- **Three teaching surfaces (switchable in-session)**: - - **View**: document viewer for reading/teaching directly from the selected PDF - - **Edit**: a collaborative docs editor where you and the AI can build structured notes/explanations and download the result - - **Draw**: a whiteboard for visual explanations (pen/eraser, undo/redo, clear, export as PNG) -- **AI Query tab**: - - Ask targeted questions without interrupting the lesson flow - -### Persistence & sync (what's saved) - -Per `sessionId`, the Study Agent persists: -- **messages** (StudyBuddy/Teacher conversations) -- **study goals** (plan items + completion state + attached materials) -- **notes** (StudyBuddy notes + updates) -- **preferences/profile** (selected documents and learner context) - -Key API surfaces used by the Study Agent: -- `POST /api/study-agent/me/session` (create session) -- `GET /api/study-agent/me?sessionId=...` (load session data) -- `POST /api/study-agent/chat` (RAG chat + optional agentic tools for notes/tasks/timer) -- `POST /api/study-agent/me/messages` (persist chat messages) -- `POST/PUT/DELETE /api/study-agent/me/study-goals` (plan CRUD) -- `POST /api/study-agent/sync/notes` (notes sync) - -## ๐Ÿ“š Improved Knowledge Base Formation - -PDR AI uses a sophisticated **Hybrid Retrieval-Augmented Generation (RAG)** architecture that combines multiple retrieval strategies for optimal document search and Q&A accuracy. - -### Knowledge Base Architecture - -``` -โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” -โ”‚ DOCUMENT INGESTION PIPELINE โ”‚ -โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค -โ”‚ Upload โ†’ OCR/Parse โ†’ Intelligent Chunking โ†’ Vectorization โ”‚ -โ”‚ โ†“ โ”‚ -โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ -โ”‚ โ”‚ PostgreSQL + pgvector โ”‚ โ”‚ -โ”‚ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ โ”‚ -โ”‚ โ”‚ โ”‚ Documents โ”‚ โ”‚ PDF Chunks โ”‚ โ”‚ Embeddings โ”‚ โ”‚ โ”‚ -โ”‚ โ”‚ โ”‚ (metadata) โ”‚ โ”‚ (content) โ”‚ โ”‚ (1536-dim) โ”‚ โ”‚ โ”‚ -โ”‚ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”‚ -โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ -โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ - -โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” -โ”‚ ENSEMBLE RETRIEVAL SYSTEM โ”‚ -โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค -โ”‚ Query โ”‚ -โ”‚ โ†“ โ”‚ -โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ -โ”‚ โ”‚ BM25 Retriever โ”‚ โ”‚ Vector Retriever โ”‚ โ”‚ -โ”‚ โ”‚ (Keyword/Lexical)โ”‚ โ”‚ (Semantic/ANN) โ”‚ โ”‚ -โ”‚ โ”‚ Weight: 0.4 โ”‚ โ”‚ Weight: 0.6 โ”‚ โ”‚ -โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ -โ”‚ โ”‚ โ”‚ โ”‚ -โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ -โ”‚ โ†“ โ”‚ -โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ -โ”‚ โ”‚ Reciprocal Rank Fusion โ”‚ โ”‚ -โ”‚ โ”‚ (RRF Merge) โ”‚ โ”‚ -โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ -โ”‚ โ†“ โ”‚ -โ”‚ Ranked Results โ”‚ -โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ -``` - -### Retrieval Components - -| Component | Description | Strength | -|-----------|-------------|----------| -| **BM25 Retriever** | Keyword-based lexical search using TF-IDF scoring | Exact term matching, acronyms, proper nouns | -| **Vector Retriever** | Semantic search using OpenAI `text-embedding-3-small` embeddings (1536 dimensions) | Conceptual similarity, paraphrasing, synonyms | -| **Ensemble Retriever** | Combines BM25 + Vector with Reciprocal Rank Fusion | Best of both approaches | - -### Search Scopes - -The retrieval system supports three search scopes: - -- **Document Scope**: Search within a single document for focused Q&A -- **Company Scope**: Search across all documents in a company's knowledge base -- **Multi-Document Scope**: Search across a selected subset of documents (used by Study Agent) - -### Chunking Strategy - -Documents are intelligently chunked using the following configuration: - -```typescript -{ - maxTokens: 500, // ~2000 characters per chunk - overlapTokens: 50, // ~200 characters overlap for context continuity - charsPerToken: 4, // Character-to-token ratio - includePageContext: true // Preserve page metadata -} -``` - -**Chunk Types:** -- **Text Chunks**: Prose content split at sentence boundaries with overlap -- **Table Chunks**: Structured data preserved as markdown with semantic descriptions - -### Data Storage Schema - -```sql --- PDF Chunks table with vector embeddings -CREATE TABLE pdr_ai_v2_pdf_chunks ( - id SERIAL PRIMARY KEY, - document_id BIGINT REFERENCES document(id), - page INTEGER NOT NULL, - chunk_index INTEGER NOT NULL, - content TEXT NOT NULL, - embedding VECTOR(1536) -- pgvector type -); - --- Indexes for fast retrieval -CREATE INDEX ON pdf_chunks (document_id); -CREATE INDEX ON pdf_chunks (document_id, page, chunk_index); -``` - -### Fallback Mechanisms - -The system includes automatic fallback: -1. **Primary**: Ensemble (BM25 + Vector) retrieval -2. **Fallback**: BM25-only retrieval if vector search fails -3. **Graceful degradation**: Returns empty results rather than errors - -## ๐Ÿ” Predictive Document Analysis Deep Dive - -The **Predictive Document Analysis** feature is the cornerstone of PDR AI, providing intelligent document management and compliance assistance: - -### How It Works -1. **Document Upload**: Upload your professional documents (PDFs, contracts, manuals, etc.) -2. **AI Analysis**: Our advanced AI scans through the document content and structure -3. **Missing Document Detection**: Identifies references to documents that should be present but aren't -4. **Priority Classification**: Automatically categorizes findings by importance and urgency -5. **Smart Recommendations**: Provides specific, actionable recommendations for document management -6. **Related Content**: Suggests relevant external resources and related documents - -### Key Benefits -- **Compliance Assurance**: Never miss critical documents required for compliance -- **Workflow Optimization**: Streamline document management with AI-powered insights -- **Risk Mitigation**: Identify potential gaps in documentation before they become issues -- **Time Savings**: Automated analysis saves hours of manual document review -- **Proactive Management**: Stay ahead of document requirements and deadlines - -### Analysis Output -The system provides comprehensive analysis including: -- **Missing Documents Count**: Total number of missing documents identified -- **High Priority Items**: Critical documents requiring immediate attention -- **Recommendations**: Specific actions to improve document organization -- **Suggested Related Documents**: External resources and related content -- **Page References**: Exact page numbers where missing documents are mentioned - -## ๐Ÿ“– Usage Examples - -### OCR Processing for Scanned Documents - -PDR AI includes optional advanced OCR (Optical Character Recognition) capabilities for processing scanned documents, images, and PDFs with poor text extraction: - -#### When to Use OCR -- **Scanned Documents**: Physical documents that have been scanned to PDF -- **Image-based PDFs**: PDFs that contain images of text rather than actual text -- **Poor Quality Documents**: Documents with low-quality text that standard extraction can't read -- **Handwritten Content**: Documents with handwritten notes or forms (with AI assistance) -- **Mixed Content**: Documents combining text, images, tables, and diagrams - -#### How It Works - -**Backend Infrastructure:** -1. **Environment Configuration**: Set `DATALAB_API_KEY` in your `.env` file (optional) -2. **Database Schema**: Tracks OCR status with fields: - - `ocrEnabled`: Boolean flag indicating if OCR was requested - - `ocrProcessed`: Boolean flag indicating if OCR completed successfully - - `ocrMetadata`: JSON field storing OCR processing details (page count, processing time, etc.) - -3. **OCR Service Module** (`src/app/api/services/ocrService.ts`): - - Complete Datalab Marker API integration - - Asynchronous submission and polling architecture - - Configurable processing options (force_ocr, use_llm, output_format) - - Comprehensive error handling and retry logic - - Timeout management (5 minutes default) - -4. **Upload API Enhancement** (`src/app/api/uploadDocument/route.ts`): - - **Dual-path processing**: - - OCR Path: Uses Datalab Marker API when `enableOCR=true` - - Standard Path: Uses traditional PDFLoader for regular PDFs - - Unified chunking and embedding pipeline - - Stores OCR metadata with document records - -**Frontend Integration:** -1. **Upload Form UI**: OCR checkbox appears when `DATALAB_API_KEY` is configured -2. **Form Validation**: Schema validates `enableOCR` field -3. **User Guidance**: Help text explains when to use OCR -4. **Dark Theme Support**: Custom checkbox styling for both light and dark modes - -#### Processing Flow - -```typescript -// Standard PDF Upload (enableOCR: false or not set) -1. Download PDF from URL -2. Extract text using PDFLoader -3. Split into chunks -4. Generate embeddings -5. Store in database - -// OCR-Enhanced Upload (enableOCR: true) -1. Download PDF from URL -2. Submit to Datalab Marker API -3. Poll for completion (up to 5 minutes) -4. Receive markdown/HTML/JSON output -5. Split into chunks -6. Generate embeddings -7. Store in database with OCR metadata -``` - -#### OCR Configuration Options - -```typescript -interface OCROptions { - force_ocr?: boolean; // Force OCR even if text exists - use_llm?: boolean; // Use AI for better accuracy - output_format?: 'markdown' | 'json' | 'html'; // Output format - strip_existing_ocr?: boolean; // Remove existing OCR layer -} -``` - -#### Using the OCR Feature - -1. **Configure API Key** (one-time setup): - ```env - DATALAB_API_KEY=your_datalab_api_key - ``` - -2. **Upload Document with OCR**: - - Navigate to the employer upload page - - Select your document - - Check the "Enable OCR Processing" checkbox - - Upload the document - - System will process with OCR and notify when complete - -3. **Monitor Processing**: - - OCR processing typically takes 1-3 minutes - - Progress is tracked in backend logs - - Document becomes available once processing completes - -#### OCR vs Standard Processing - -| Feature | Standard Processing | OCR Processing | -|---------|-------------------|----------------| -| **Best For** | Digital PDFs with embedded text | Scanned documents, images | -| **Processing Time** | < 10 seconds | 1-3 minutes | -| **Accuracy** | High for digital text | High for scanned/image text | -| **Cost** | Free (OpenAI embeddings only) | Requires Datalab API credits | -| **Handwriting Support** | No | Yes (with AI assistance) | -| **Table Extraction** | Basic | Advanced | -| **Image Analysis** | No | Yes | - -#### Error Handling - -The OCR system includes comprehensive error handling: -- API connection failures -- Timeout management (5-minute limit) -- Retry logic for transient errors -- Graceful fallback messages -- Detailed error logging - -### Predictive Document Analysis - -The predictive analysis feature automatically scans uploaded documents and provides comprehensive insights: - -#### Example Analysis Response -```json -{ - "success": true, - "documentId": 123, - "analysisType": "predictive", - "summary": { - "totalMissingDocuments": 5, - "highPriorityItems": 2, - "totalRecommendations": 3, - "totalSuggestedRelated": 4, - "analysisTimestamp": "2024-01-15T10:30:00Z" - }, - "analysis": { - "missingDocuments": [ - { - "documentName": "Employee Handbook", - "documentType": "Policy Document", - "reason": "Referenced in section 2.1 but not found in uploaded documents", - "page": 15, - "priority": "high", - "suggestedLinks": [ - { - "title": "Sample Employee Handbook Template", - "link": "https://example.com/handbook-template", - "snippet": "Comprehensive employee handbook template..." - } - ] - } - ], - "recommendations": [ - "Consider implementing a document version control system", - "Review document retention policies for compliance", - "Establish regular document audit procedures" - ], - "suggestedRelatedDocuments": [ - { - "title": "Document Management Best Practices", - "link": "https://example.com/best-practices", - "snippet": "Industry standards for document organization..." - } - ] - } -} -``` - -#### Using the Analysis in Your Workflow -1. **Upload Documents**: Use the employer dashboard to upload your documents -2. **Run Analysis**: Click the "Predictive Analysis" tab in the document viewer -3. **Review Results**: Examine missing documents, recommendations, and suggestions -4. **Take Action**: Follow the provided recommendations and suggested links -5. **Track Progress**: Re-run analysis to verify improvements - -### AI Chat Integration - -Ask questions about your documents and get AI-powered responses: - -```typescript -// Example API call for document Q&A -const response = await fetch('/api/LangChain', { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ - question: "What are the key compliance requirements mentioned?", - documentId: 123, - style: "professional" // or "casual", "technical", "summary" - }) -}); +```bash +docker compose --env-file .env up -d db +pnpm dev ``` -## ๐ŸŽฏ Use Cases & Benefits - -### Industries That Benefit Most +For host DB tools, use `localhost:5433`. -#### Legal & Compliance -- **Contract Management**: Identify missing clauses, attachments, and referenced documents -- **Regulatory Compliance**: Ensure all required documentation is present and up-to-date -- **Due Diligence**: Comprehensive document review for mergers and acquisitions -- **Risk Assessment**: Identify potential legal risks from missing documentation +## ๐Ÿงฉ How Docker Supports Platform Features -#### Human Resources -- **Employee Documentation**: Ensure all required employee documents are collected -- **Policy Compliance**: Verify policy documents are complete and current -- **Onboarding Process**: Streamline new employee documentation requirements -- **Audit Preparation**: Prepare for HR audits with confidence +- `app` service runs auth, upload, OCR integration, RAG chat, and predictive analysis. +- `db` service provides pgvector-backed storage/retrieval for embeddings. +- `migrate` service ensures schema readiness before app startup. +- Optional providers (Inngest, Tavily, OCR, LangSmith) are enabled by env vars in the same runtime. -#### Finance & Accounting -- **Financial Reporting**: Ensure all supporting documents are included -- **Audit Trail**: Maintain complete documentation for financial audits -- **Compliance Reporting**: Meet regulatory requirements for document retention -- **Process Documentation**: Streamline financial process documentation +## ๐Ÿ“š Documentation -#### Healthcare -- **Patient Records**: Ensure complete patient documentation -- **Regulatory Compliance**: Meet healthcare documentation requirements -- **Quality Assurance**: Maintain high standards for medical documentation -- **Risk Management**: Identify potential documentation gaps +- Deployment details (Docker, Vercel, VPS): `docs/deployment.md` +- Feature workflows and architecture: `docs/feature-workflows.md` +- Usage and API examples: `docs/usage-examples.md` +- Observability and metrics: `docs/observability.md` +- **Manual testing (dev, post-PR):** [docs/manual-testing-guide.md](docs/manual-testing-guide.md) -### Business Benefits +## ๐Ÿ”Œ API Endpoints (high-level) -#### Time Savings -- **Automated Analysis**: Reduce manual document review time by 80% -- **Instant Insights**: Get immediate feedback on document completeness -- **Proactive Management**: Address issues before they become problems +- `POST /api/uploadDocument` - upload and process document (OCR optional) +- `POST /api/LangChain` - document-grounded Q&A +- `POST /api/agents/predictive-document-analysis` - detect gaps and recommendations +- `GET /api/metrics` - Prometheus metrics stream -#### Risk Reduction -- **Compliance Assurance**: Never miss critical required documents -- **Error Prevention**: Catch documentation gaps before they cause issues -- **Audit Readiness**: Always be prepared for regulatory audits +## ๐Ÿ” User Roles -#### Process Improvement -- **Standardized Workflows**: Establish consistent document management processes -- **Quality Control**: Maintain high standards for document organization -- **Continuous Improvement**: Use AI insights to optimize processes +- **Employee**: view assigned documents, use AI chat/analysis. +- **Employer**: upload/manage documents, categories, and employee access. -### ROI Metrics -- **Document Review Time**: 80% reduction in manual review time -- **Compliance Risk**: 95% reduction in missing document incidents -- **Audit Preparation**: 90% faster audit preparation time -- **Process Efficiency**: 70% improvement in document management workflows +## ๐Ÿงช Useful Scripts -## ๐Ÿ“ Project Structure - -``` -src/ -โ”œโ”€โ”€ app/ # Next.js App Router -โ”‚ โ”œโ”€โ”€ api/ # API routes -โ”‚ โ”‚ โ”œโ”€โ”€ agents/ -โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ predictive-document-analysis/ # Predictive analysis endpoints -โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ route.ts # Main analysis API -โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ agent.ts # AI analysis agent -โ”‚ โ”‚ โ”œโ”€โ”€ services/ # Backend services -โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ ocrService.ts # OCR processing service -โ”‚ โ”‚ โ”œโ”€โ”€ uploadDocument/ # Document upload endpoint -โ”‚ โ”‚ โ”œโ”€โ”€ LangChain/ # AI chat functionality -โ”‚ โ”‚ โ””โ”€โ”€ ... # Other API endpoints -โ”‚ โ”œโ”€โ”€ employee/ # Employee dashboard pages -โ”‚ โ”œโ”€โ”€ employer/ # Employer dashboard pages -โ”‚ โ”‚ โ”œโ”€โ”€ documents/ # Document viewer with predictive analysis -โ”‚ โ”‚ โ””โ”€โ”€ upload/ # Document upload with OCR option -โ”‚ โ”œโ”€โ”€ signup/ # Authentication pages -โ”‚ โ””โ”€โ”€ _components/ # Shared components -โ”œโ”€โ”€ server/ -โ”‚ โ””โ”€โ”€ db/ # Database configuration and schema -โ”œโ”€โ”€ styles/ # CSS modules and global styles -โ””โ”€โ”€ env.js # Environment validation - -Key directories: -- `/employee` - Employee interface for document viewing and chat -- `/employer` - Employer interface for management and uploads -- `/api/agents/predictive-document-analysis` - Core predictive analysis functionality -- `/api/services` - Reusable backend services (OCR, etc.) -- `/api/uploadDocument` - Document upload with OCR support -- `/api` - Backend API endpoints for all functionality -- `/server/db` - Database schema and configuration +```bash +pnpm db:studio +pnpm db:push +pnpm check +pnpm lint +pnpm typecheck +pnpm build +pnpm start ``` -## ๐Ÿ”Œ API Endpoints - -### Predictive Document Analysis -- `POST /api/agents/predictive-document-analysis` - Analyze documents for missing content and recommendations -- `GET /api/fetchDocument` - Retrieve document content for analysis - -### Document Upload & Processing -- `POST /api/uploadDocument` - Upload documents for processing (supports OCR via `enableOCR` parameter) - - Standard path: Uses PDFLoader for digital PDFs - - OCR path: Uses Datalab Marker API for scanned documents - - Returns document metadata including OCR processing status - -### AI Chat & Q&A -- `POST /api/LangChain` - AI-powered document Q&A -- `GET /api/Questions/fetch` - Retrieve Q&A history -- `POST /api/Questions/add` - Add new questions - -### Document Management -- `GET /api/fetchCompany` - Get company documents -- `POST /api/deleteDocument` - Remove documents -- `GET /api/Categories/GetCategories` - Get document categories - -### Observability -- `GET /api/metrics` - Prometheus-compatible metrics stream (see `docs/observability.md` for dashboard ideas) - -## ๐Ÿ” User Roles & Permissions - -### Employee -- View assigned documents -- Chat with AI about documents -- Access document analysis and insights -- Pending approval flow for new employees - -### Employer -- Upload and manage documents -- Manage employee access and approvals -- View analytics and statistics -- Configure document categories -- Employee management dashboard - -## ๐Ÿ›ก๏ธ Environment Variables Reference - -| Variable | Description | Required | Example | -|----------|-------------|----------|---------| -| `DATABASE_URL` | PostgreSQL connection string with pgvector extension | โœ… | `postgresql://postgres:password@localhost:5432/pdr_ai_v2` | -| `NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY` | Clerk publishable key (client-side) | โœ… | `pk_test_...` | -| `CLERK_SECRET_KEY` | Clerk secret key (server-side) | โœ… | `sk_test_...` | -| `OPENAI_API_KEY` | OpenAI API key for AI features (embeddings, chat, analysis) | โœ… | `sk-...` | -| `TAVILY_API_KEY` | Tavily Search API for web search in document analysis | โœ… | `tvly-...` | -| `UPLOADTHING_TOKEN` | UploadThing token for file uploads | โœ… | `your_uploadthing_token` | -| `INNGEST_EVENT_KEY` | Inngest event key for reliable background jobs | โŒ | `your_inngest_event_key` | -| `INNGEST_SIGNING_KEY` | Inngest signing key for webhook verification | โŒ | `signkey-...` | -| `AZURE_DOC_INTELLIGENCE_ENDPOINT` | Azure Document Intelligence endpoint for OCR | โŒ | `https://your-resource.cognitiveservices.azure.com/` | -| `AZURE_DOC_INTELLIGENCE_KEY` | Azure Document Intelligence API key | โŒ | `your_azure_key` | -| `LANDING_AI_API_KEY` | Landing.AI API key for complex/handwritten document OCR | โŒ | `your_landing_ai_key` | -| `DATALAB_API_KEY` | Datalab Marker API key (legacy OCR option) | โŒ | `your_datalab_key` | -| `LANGCHAIN_TRACING_V2` | Enable LangSmith tracing (`true`/`false`) | โŒ | `true` | -| `LANGCHAIN_API_KEY` | LangSmith API key for tracing | โŒ | `lsv2_...` | -| `LANGCHAIN_PROJECT` | LangSmith project name | โŒ | `pdr-ai-production` | -| `ELEVENLABS_API_KEY` | ElevenLabs API key for StudyBuddy voice | โŒ | `your_elevenlabs_key` | -| `ELEVENLABS_VOICE_ID` | Default ElevenLabs voice ID | โŒ | `21m00Tcm4TlvDq8ikWAM` | -| `NODE_ENV` | Environment mode (`development`, `test`, `production`) | โœ… | `development` | -| `SKIP_ENV_VALIDATION` | Skip environment validation during build | โŒ | `true` | - -### Environment Variables by Feature - -- **Authentication**: `NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY`, `CLERK_SECRET_KEY` (redirects handled by middleware) -- **Database**: `DATABASE_URL` (PostgreSQL with pgvector) -- **AI & Embeddings**: `OPENAI_API_KEY`, `TAVILY_API_KEY` -- **Background Jobs (Optional)**: `INNGEST_EVENT_KEY`, `INNGEST_SIGNING_KEY` โ€” enables automatic retries, step isolation, and observability. Without these, document processing runs synchronously. -- **File Uploads**: `UPLOADTHING_TOKEN` -- **OCR Processing**: `AZURE_DOC_INTELLIGENCE_ENDPOINT`, `AZURE_DOC_INTELLIGENCE_KEY`, `LANDING_AI_API_KEY`, `DATALAB_API_KEY` -- **Observability**: `LANGCHAIN_TRACING_V2`, `LANGCHAIN_API_KEY`, `LANGCHAIN_PROJECT` -- **Study Agent Voice**: `ELEVENLABS_API_KEY`, `ELEVENLABS_VOICE_ID` -- **Build Configuration**: `NODE_ENV`, `SKIP_ENV_VALIDATION` - ## ๐Ÿ› Troubleshooting -### Database Issues -- Ensure Docker is running before starting the database -- Check if the database container is running: `docker ps` -- Restart the database: `docker restart pdr_ai_v2-postgres` - -### Environment Issues -- Verify all required environment variables are set -- Check `.env` file formatting (no spaces around `=`) -- Ensure API keys are valid and have proper permissions - -### Build Issues -- Clear Next.js cache: `rm -rf .next` -- Reinstall dependencies: `rm -rf node_modules && pnpm install` -- Check TypeScript errors: `pnpm typecheck` - -### OCR Processing Issues -- **OCR checkbox not appearing**: Verify `DATALAB_API_KEY` is set in your `.env` file -- **OCR processing timeout**: Documents taking longer than 5 minutes will timeout; try with smaller documents first -- **OCR processing failed**: Check API key validity and Datalab service status -- **Poor OCR quality**: Enable `use_llm: true` option in OCR configuration for AI-enhanced accuracy -- **Cost concerns**: OCR uses Datalab API credits; use only for scanned/image-based documents +- Confirm Docker is running before DB startup. +- If build issues occur: remove `.next` and reinstall dependencies. +- If OCR UI is missing: verify OCR provider keys are configured. +- If Docker image pull/build is corrupted: remove image and rebuild with `--no-cache`. ## ๐Ÿค Contributing -1. Fork the repository -2. Create a feature branch: `git checkout -b feature-name` -3. Make your changes -4. Run tests and linting: `pnpm check` -5. Commit your changes: `git commit -m 'Add feature'` -6. Push to the branch: `git push origin feature-name` -7. Submit a pull request +1. Create a feature branch. +2. Make changes and run `pnpm check`. +3. Open a pull request with test notes. ## ๐Ÿ“ License -This project is private and proprietary. +Private and proprietary. ## ๐Ÿ“ž Support -For support or questions, contact the development team or create an issue in the repository. +Open an issue in this repository or contact the development team. diff --git a/__tests__/lib/ocr/chunker.test.ts b/__tests__/lib/ocr/chunker.test.ts deleted file mode 100644 index 2da0d93f..00000000 --- a/__tests__/lib/ocr/chunker.test.ts +++ /dev/null @@ -1,632 +0,0 @@ -import { - chunkDocument, - estimateTokens, - getTotalChunkSize, - prepareForEmbedding, - mergeWithEmbeddings, - type ChunkingConfig, -} from "~/lib/ocr/chunker"; -import type { PageContent, DocumentChunk, ExtractedTable } from "~/lib/ocr/types"; - -describe("OCR Chunker Module", () => { - // Helper to create mock page content - const createMockPage = ( - pageNumber: number, - textBlocks: string[] = [], - tables: ExtractedTable[] = [] - ): PageContent => ({ - pageNumber, - textBlocks, - tables, - }); - - // Helper to create mock table - const createMockTable = ( - rows: string[][], - markdown: string - ): ExtractedTable => ({ - rows, - markdown, - rowCount: rows.length, - columnCount: rows[0]?.length ?? 0, - }); - - describe("chunkDocument", () => { - it("should return empty array for empty pages", () => { - const result = chunkDocument([]); - expect(result).toEqual([]); - }); - - it("should return empty array for page with no content", () => { - const pages = [createMockPage(1, [], [])]; - const result = chunkDocument(pages); - expect(result).toEqual([]); - }); - - it("should create text chunks from text blocks", () => { - const pages = [ - createMockPage(1, ["This is some sample text.", "Another paragraph."]), - ]; - const result = chunkDocument(pages); - - expect(result.length).toBeGreaterThan(0); - expect(result[0]?.type).toBe("text"); - expect(result[0]?.metadata.pageNumber).toBe(1); - expect(result[0]?.metadata.isTable).toBe(false); - }); - - it("should create table chunks from tables", () => { - const table = createMockTable( - [ - ["Name", "Age"], - ["Alice", "30"], - ["Bob", "25"], - ], - "| Name | Age |\n|------|-----|\n| Alice | 30 |\n| Bob | 25 |" - ); - const pages = [createMockPage(1, [], [table])]; - const result = chunkDocument(pages); - - expect(result.length).toBe(1); - expect(result[0]?.type).toBe("table"); - expect(result[0]?.metadata.isTable).toBe(true); - expect(result[0]?.metadata.tableIndex).toBe(0); - }); - - it("should handle mixed text and table content", () => { - const table = createMockTable( - [["Header"]], - "| Header |\n|--------|\n" - ); - const pages = [createMockPage(1, ["Some text content"], [table])]; - const result = chunkDocument(pages); - - const textChunks = result.filter((c) => c.type === "text"); - const tableChunks = result.filter((c) => c.type === "table"); - - expect(textChunks.length).toBeGreaterThanOrEqual(1); - expect(tableChunks.length).toBe(1); - }); - - it("should assign unique IDs to each chunk", () => { - const pages = [ - createMockPage(1, ["Text on page 1"]), - createMockPage(2, ["Text on page 2"]), - ]; - const result = chunkDocument(pages); - - const ids = result.map((c) => c.id); - const uniqueIds = new Set(ids); - expect(uniqueIds.size).toBe(ids.length); - }); - - it("should maintain correct page numbers across multiple pages", () => { - const pages = [ - createMockPage(1, ["Page 1 content"]), - createMockPage(2, ["Page 2 content"]), - createMockPage(3, ["Page 3 content"]), - ]; - const result = chunkDocument(pages); - - const pageNumbers = result.map((c) => c.metadata.pageNumber); - expect(pageNumbers).toContain(1); - expect(pageNumbers).toContain(2); - expect(pageNumbers).toContain(3); - }); - - it("should respect custom chunking configuration", () => { - const longText = "A".repeat(5000); - const pages = [createMockPage(1, [longText])]; - - const smallConfig: ChunkingConfig = { - maxTokens: 100, - overlapTokens: 10, - charsPerToken: 4, - }; - - const largeConfig: ChunkingConfig = { - maxTokens: 2000, - overlapTokens: 50, - charsPerToken: 4, - }; - - const smallChunks = chunkDocument(pages, smallConfig); - const largeChunks = chunkDocument(pages, largeConfig); - - // Smaller max tokens should result in more chunks - expect(smallChunks.length).toBeGreaterThan(largeChunks.length); - }); - - it("should increment global chunk index across pages", () => { - const pages = [ - createMockPage(1, ["Text 1"]), - createMockPage(2, ["Text 2"]), - ]; - const result = chunkDocument(pages); - - const chunkIndices = result.map((c) => c.metadata.chunkIndex); - // Check that indices are sequential - for (let i = 0; i < chunkIndices.length; i++) { - expect(chunkIndices[i]).toBe(i); - } - }); - - it("should generate table descriptions based on header content", () => { - const financialTable = createMockTable( - [ - ["Item", "Price", "Amount"], - ["Widget", "$10", "5"], - ], - "| Item | Price | Amount |" - ); - const pages = [createMockPage(1, [], [financialTable])]; - const result = chunkDocument(pages); - - expect(result[0]?.content).toContain("Table from Page 1"); - expect(result[0]?.metadata.tableDescription).toBeDefined(); - }); - }); - - describe("estimateTokens", () => { - it("should estimate tokens based on character count", () => { - const text = "Hello world"; // 11 characters - const tokens = estimateTokens(text); - // Default is 4 chars per token: ceil(11/4) = 3 - expect(tokens).toBe(3); - }); - - it("should return 0 for empty string", () => { - expect(estimateTokens("")).toBe(0); - }); - - it("should use custom chars per token when provided", () => { - const text = "Hello world"; // 11 characters - const tokens = estimateTokens(text, 2); - // 2 chars per token: ceil(11/2) = 6 - expect(tokens).toBe(6); - }); - - it("should handle long text correctly", () => { - const text = "A".repeat(1000); - const tokens = estimateTokens(text, 4); - expect(tokens).toBe(250); - }); - - it("should round up for partial tokens", () => { - const text = "ABC"; // 3 characters - const tokens = estimateTokens(text, 4); - // ceil(3/4) = 1 - expect(tokens).toBe(1); - }); - }); - - describe("getTotalChunkSize", () => { - it("should return zeros for empty chunk array", () => { - const result = getTotalChunkSize([]); - expect(result.totalChunks).toBe(0); - expect(result.textChunks).toBe(0); - expect(result.tableChunks).toBe(0); - expect(result.totalCharacters).toBe(0); - }); - - it("should count text and table chunks separately", () => { - const chunks: DocumentChunk[] = [ - { - id: "1", - content: "Text content", - type: "text", - metadata: { - pageNumber: 1, - chunkIndex: 0, - totalChunksInPage: 2, - isTable: false, - }, - }, - { - id: "2", - content: "Table content", - type: "table", - metadata: { - pageNumber: 1, - chunkIndex: 1, - totalChunksInPage: 2, - isTable: true, - }, - }, - ]; - - const result = getTotalChunkSize(chunks); - expect(result.totalChunks).toBe(2); - expect(result.textChunks).toBe(1); - expect(result.tableChunks).toBe(1); - }); - - it("should calculate total characters correctly", () => { - const chunks: DocumentChunk[] = [ - { - id: "1", - content: "12345", - type: "text", - metadata: { - pageNumber: 1, - chunkIndex: 0, - totalChunksInPage: 1, - isTable: false, - }, - }, - { - id: "2", - content: "67890", - type: "text", - metadata: { - pageNumber: 1, - chunkIndex: 1, - totalChunksInPage: 1, - isTable: false, - }, - }, - ]; - - const result = getTotalChunkSize(chunks); - expect(result.totalCharacters).toBe(10); - }); - - it("should estimate tokens from total characters", () => { - const chunks: DocumentChunk[] = [ - { - id: "1", - content: "A".repeat(100), - type: "text", - metadata: { - pageNumber: 1, - chunkIndex: 0, - totalChunksInPage: 1, - isTable: false, - }, - }, - ]; - - const result = getTotalChunkSize(chunks); - expect(result.totalCharacters).toBe(100); - expect(result.estimatedTokens).toBeGreaterThan(0); - }); - }); - - describe("prepareForEmbedding", () => { - it("should extract content from chunks", () => { - const chunks: DocumentChunk[] = [ - { - id: "1", - content: "First content", - type: "text", - metadata: { - pageNumber: 1, - chunkIndex: 0, - totalChunksInPage: 1, - isTable: false, - }, - }, - { - id: "2", - content: "Second content", - type: "text", - metadata: { - pageNumber: 1, - chunkIndex: 1, - totalChunksInPage: 1, - isTable: false, - }, - }, - ]; - - const result = prepareForEmbedding(chunks); - expect(result).toEqual(["First content", "Second content"]); - }); - - it("should return empty array for empty chunks", () => { - const result = prepareForEmbedding([]); - expect(result).toEqual([]); - }); - - it("should preserve content order", () => { - const chunks: DocumentChunk[] = [ - { - id: "1", - content: "A", - type: "text", - metadata: { pageNumber: 1, chunkIndex: 0, totalChunksInPage: 1, isTable: false }, - }, - { - id: "2", - content: "B", - type: "text", - metadata: { pageNumber: 1, chunkIndex: 1, totalChunksInPage: 1, isTable: false }, - }, - { - id: "3", - content: "C", - type: "text", - metadata: { pageNumber: 1, chunkIndex: 2, totalChunksInPage: 1, isTable: false }, - }, - ]; - - const result = prepareForEmbedding(chunks); - expect(result).toEqual(["A", "B", "C"]); - }); - }); - - describe("mergeWithEmbeddings", () => { - it("should merge chunks with embeddings correctly", () => { - const chunks: DocumentChunk[] = [ - { - id: "1", - content: "Content 1", - type: "text", - metadata: { - pageNumber: 1, - chunkIndex: 0, - totalChunksInPage: 1, - isTable: false, - }, - }, - ]; - const embeddings = [[0.1, 0.2, 0.3]]; - - const result = mergeWithEmbeddings(chunks, embeddings); - - expect(result.length).toBe(1); - expect(result[0]?.content).toBe("Content 1"); - expect(result[0]?.vector).toEqual([0.1, 0.2, 0.3]); - expect(result[0]?.metadata.pageNumber).toBe(1); - }); - - it("should throw error when chunk and embedding counts mismatch", () => { - const chunks: DocumentChunk[] = [ - { - id: "1", - content: "Content", - type: "text", - metadata: { pageNumber: 1, chunkIndex: 0, totalChunksInPage: 1, isTable: false }, - }, - { - id: "2", - content: "Content 2", - type: "text", - metadata: { pageNumber: 1, chunkIndex: 1, totalChunksInPage: 1, isTable: false }, - }, - ]; - const embeddings = [[0.1, 0.2]]; // Only 1 embedding for 2 chunks - - expect(() => mergeWithEmbeddings(chunks, embeddings)).toThrow( - "Mismatch: 2 chunks but 1 embeddings" - ); - }); - - it("should handle empty inputs", () => { - const result = mergeWithEmbeddings([], []); - expect(result).toEqual([]); - }); - - it("should preserve all metadata fields", () => { - const chunks: DocumentChunk[] = [ - { - id: "test-id", - content: "Test content", - type: "table", - metadata: { - pageNumber: 5, - chunkIndex: 3, - totalChunksInPage: 10, - isTable: true, - tableIndex: 2, - tableDescription: "Financial data table", - }, - }, - ]; - const embeddings = [[1, 2, 3, 4, 5]]; - - const result = mergeWithEmbeddings(chunks, embeddings); - - expect(result[0]?.metadata).toEqual({ - pageNumber: 5, - chunkIndex: 3, - totalChunksInPage: 10, - isTable: true, - tableIndex: 2, - tableDescription: "Financial data table", - }); - }); - }); - - describe("Text Splitting with Overlap", () => { - it("should not split short text", () => { - const pages = [createMockPage(1, ["Short text"])]; - const result = chunkDocument(pages, { - maxTokens: 1000, - overlapTokens: 50, - }); - - expect(result.length).toBe(1); - expect(result[0]?.content).toBe("Short text"); - }); - - it("should split long text into multiple chunks", () => { - // Create text that exceeds default max (500 tokens * 4 chars = 2000 chars) - const longText = "A".repeat(3000); - const pages = [createMockPage(1, [longText])]; - const result = chunkDocument(pages); - - expect(result.length).toBeGreaterThan(1); - }); - - it("should handle text with sentence boundaries", () => { - const text = "First sentence. Second sentence. Third sentence. Fourth sentence."; - const pages = [createMockPage(1, [text])]; - const result = chunkDocument(pages, { - maxTokens: 10, - overlapTokens: 2, - charsPerToken: 4, - }); - - // Should create multiple chunks - expect(result.length).toBeGreaterThan(0); - // Each chunk should be non-empty - result.forEach((chunk) => { - expect(chunk.content.length).toBeGreaterThan(0); - }); - }); - - it("should handle text without proper sentence boundaries", () => { - const text = "word ".repeat(500); - const pages = [createMockPage(1, [text.trim()])]; - const result = chunkDocument(pages, { - maxTokens: 50, - overlapTokens: 5, - charsPerToken: 4, - }); - - expect(result.length).toBeGreaterThan(1); - }); - }); - - describe("Table Description Generation", () => { - it("should identify financial tables", () => { - const table = createMockTable( - [ - ["Product", "Price", "Cost"], - ["Widget", "$100", "$50"], - ], - "| Product | Price | Cost |" - ); - const pages = [createMockPage(1, [], [table])]; - const result = chunkDocument(pages); - - expect(result[0]?.metadata.tableDescription).toContain( - "financial or pricing data" - ); - }); - - it("should identify time-series tables", () => { - const table = createMockTable( - [ - ["Date", "Value"], - ["2024-01-01", "100"], - ], - "| Date | Value |" - ); - const pages = [createMockPage(1, [], [table])]; - const result = chunkDocument(pages); - - expect(result[0]?.metadata.tableDescription).toContain( - "time-series or dated information" - ); - }); - - it("should identify personnel tables", () => { - const table = createMockTable( - [ - ["Name", "Role", "Department"], - ["John", "Engineer", "Tech"], - ], - "| Name | Role | Department |" - ); - const pages = [createMockPage(1, [], [table])]; - const result = chunkDocument(pages); - - expect(result[0]?.metadata.tableDescription).toContain( - "personnel or organizational information" - ); - }); - - it("should identify inventory tables", () => { - const table = createMockTable( - [ - ["SKU", "Product", "Quantity"], - ["001", "Widget", "50"], - ], - "| SKU | Product | Quantity |" - ); - const pages = [createMockPage(1, [], [table])]; - const result = chunkDocument(pages); - - expect(result[0]?.metadata.tableDescription).toContain( - "inventory or product listing" - ); - }); - - it("should identify procedural tables", () => { - const table = createMockTable( - [ - ["Step", "Action", "Notes"], - ["1", "Initialize", "Required"], - ], - "| Step | Action | Notes |" - ); - const pages = [createMockPage(1, [], [table])]; - const result = chunkDocument(pages); - - expect(result[0]?.metadata.tableDescription).toContain( - "procedural steps or instructions" - ); - }); - - it("should include table dimensions in description", () => { - const table = createMockTable( - [ - ["A", "B", "C"], - ["1", "2", "3"], - ["4", "5", "6"], - ], - "| A | B | C |" - ); - const pages = [createMockPage(1, [], [table])]; - const result = chunkDocument(pages); - - expect(result[0]?.metadata.tableDescription).toContain("3 rows"); - expect(result[0]?.metadata.tableDescription).toContain("3 columns"); - }); - }); - - describe("Edge Cases", () => { - it("should handle page with only whitespace text", () => { - const pages = [createMockPage(1, [" ", "\n\n", "\t"])]; - const result = chunkDocument(pages); - // Whitespace-only content should result in empty or whitespace chunks - expect(result.length).toBeLessThanOrEqual(1); - }); - - it("should handle table with empty rows", () => { - const table = createMockTable([], ""); - const pages = [createMockPage(1, [], [table])]; - const result = chunkDocument(pages); - // Should still create a chunk for the table - expect(result.length).toBe(1); - }); - - it("should handle very large page numbers", () => { - const pages = [createMockPage(9999, ["Content"])]; - const result = chunkDocument(pages); - expect(result[0]?.metadata.pageNumber).toBe(9999); - }); - - it("should handle unicode content", () => { - const pages = [createMockPage(1, ["Unicode: \u4e2d\u6587 \u65e5\u672c\u8a9e \ud83d\ude00"])]; - const result = chunkDocument(pages); - expect(result[0]?.content).toContain("\u4e2d\u6587"); - }); - - it("should handle multiple tables on same page", () => { - const table1 = createMockTable([["A"]], "| A |"); - const table2 = createMockTable([["B"]], "| B |"); - const table3 = createMockTable([["C"]], "| C |"); - const pages = [createMockPage(1, [], [table1, table2, table3])]; - const result = chunkDocument(pages); - - const tableChunks = result.filter((c) => c.type === "table"); - expect(tableChunks.length).toBe(3); - expect(tableChunks[0]?.metadata.tableIndex).toBe(0); - expect(tableChunks[1]?.metadata.tableIndex).toBe(1); - expect(tableChunks[2]?.metadata.tableIndex).toBe(2); - }); - }); -}); diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..fe2dfec3 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,125 @@ +# Pass env file as argument: docker compose --env-file .env up +# +# Profiles: +# default (no flag) โ€” db + migrate + app + sidecar +# --profile dev โ€” adds Inngest dev server (local dashboard at :8288) +# --profile minimal โ€” db only (for local Next.js dev with `pnpm dev`) +# +# Examples: +# docker compose --env-file .env up # production-like +# docker compose --env-file .env --profile dev up # with Inngest dev server +# docker compose --env-file .env --profile minimal up db # just the database + +services: + db: + image: pgvector/pgvector:pg16 + container_name: pdr_ai_v2-postgres + restart: unless-stopped + environment: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-password} + POSTGRES_DB: pdr_ai_v2 + volumes: + - postgres_data:/var/lib/postgresql/data + - ./docker/init-db.sql:/docker-entrypoint-initdb.d/init-db.sql:ro + ports: + - "5433:5432" # host:container โ€” use 5433 to avoid conflict with local Postgres on 5432 + healthcheck: + test: ["CMD-SHELL", "pg_isready -U postgres -d pdr_ai_v2"] + interval: 5s + timeout: 5s + retries: 5 + + # Applies schema with db:push (no migration files). Use this for fresh DBs. + migrate: + build: + context: . + dockerfile: Dockerfile + target: migrate + args: + NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY: ${NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY} + depends_on: + db: + condition: service_healthy + environment: + DATABASE_URL: postgresql://postgres:${POSTGRES_PASSWORD:-password}@db:5432/pdr_ai_v2 + SKIP_ENV_VALIDATION: "1" + restart: "no" + + app: + build: + context: . + dockerfile: Dockerfile + target: runner + args: + NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY: ${NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY} + container_name: pdr_ai_v2-app + restart: unless-stopped + depends_on: + migrate: + condition: service_completed_successfully + environment: + DATABASE_URL: postgresql://postgres:${POSTGRES_PASSWORD:-password}@db:5432/pdr_ai_v2 + # Pass through from .env (user must set these) + OPENAI_API_KEY: ${OPENAI_API_KEY} + CLERK_SECRET_KEY: ${CLERK_SECRET_KEY} + NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY: ${NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY} + UPLOADTHING_TOKEN: ${UPLOADTHING_TOKEN:-} + NEXT_PUBLIC_UPLOADTHING_ENABLED: ${NEXT_PUBLIC_UPLOADTHING_ENABLED:-} + # Inngest โ€” required in production for background job processing + INNGEST_EVENT_KEY: ${INNGEST_EVENT_KEY} + TAVILY_API_KEY: ${TAVILY_API_KEY:-} + DATALAB_API_KEY: ${DATALAB_API_KEY:-} + AZURE_DOC_INTELLIGENCE_ENDPOINT: ${AZURE_DOC_INTELLIGENCE_ENDPOINT:-} + AZURE_DOC_INTELLIGENCE_KEY: ${AZURE_DOC_INTELLIGENCE_KEY:-} + LANDING_AI_API_KEY: ${LANDING_AI_API_KEY:-} + # Sidecar โ€” Graph RAG auto-enables when this is set + SIDECAR_URL: ${SIDECAR_URL:-http://sidecar:8000} + ports: + - "3000:3000" + + # FastAPI sidecar โ€” local ML compute (embeddings, reranking, NER / Graph RAG) + sidecar: + build: + context: ./sidecar + dockerfile: Dockerfile + container_name: pdr_ai_v2-sidecar + restart: unless-stopped + environment: + DEVICE: ${SIDECAR_DEVICE:-cpu} + EMBEDDING_MODEL: ${EMBEDDING_MODEL:-BAAI/bge-large-en-v1.5} + RERANKER_MODEL: ${RERANKER_MODEL:-cross-encoder/ms-marco-MiniLM-L-12-v2} + NER_MODEL: ${NER_MODEL:-dslim/bert-base-NER} + volumes: + - model_cache:/app/model-cache + ports: + - "8000:8000" + deploy: + resources: + limits: + memory: 4G + healthcheck: + test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 120s + + # Inngest dev server โ€” local dashboard & event processing for development + # Start with: docker compose --profile dev up + # Dashboard: http://localhost:8288 + inngest-dev: + image: inngest/inngest:latest + container_name: pdr_ai_v2-inngest + restart: unless-stopped + ports: + - "8288:8288" + command: inngest dev -u http://app:3000/api/inngest + depends_on: + - app + profiles: + - dev + +volumes: + postgres_data: + model_cache: diff --git a/docker/init-db.sql b/docker/init-db.sql new file mode 100644 index 00000000..ff4b5e0d --- /dev/null +++ b/docker/init-db.sql @@ -0,0 +1,19 @@ +-- Enable pgvector extension on first database initialisation. +-- This file is mounted into /docker-entrypoint-initdb.d/ and only +-- runs when PostgreSQL creates a fresh data directory. +CREATE EXTENSION IF NOT EXISTS vector; + +CREATE INDEX IF NOT EXISTS doc_sections_embedding_hnsw_idx +ON pdr_ai_v2_document_sections +USING hnsw (embedding vector_cosine_ops) +WITH (m = 16, ef_construction = 64); + +CREATE INDEX IF NOT EXISTS doc_metadata_summary_embedding_hnsw_idx +ON pdr_ai_v2_document_metadata +USING hnsw (summary_embedding vector_cosine_ops) +WITH (m = 16, ef_construction = 64); + +CREATE INDEX IF NOT EXISTS doc_previews_embedding_hnsw_idx +ON pdr_ai_v2_document_previews +USING hnsw (embedding vector_cosine_ops) +WITH (m = 16, ef_construction = 64); diff --git a/docs/deployment.md b/docs/deployment.md new file mode 100644 index 00000000..dda49d9a --- /dev/null +++ b/docs/deployment.md @@ -0,0 +1,125 @@ +# Deployment Guide + +This document covers deployment options for PDR AI. + +## Prerequisites + +- Required environment variables configured +- PostgreSQL with `pgvector` enabled +- API keys for enabled integrations + +Enable pgvector: + +```sql +CREATE EXTENSION IF NOT EXISTS vector; +``` + +## Option 1: Docker Compose (full stack) + +Recommended for local and self-hosted deployments. + +```bash +docker compose --env-file .env up +``` + +**Services:** + +- `db` โ€” PostgreSQL + pgvector +- `migrate` โ€” schema setup via `db:push` +- `app` โ€” Next.js runtime +- `sidecar` โ€” FastAPI ML service (embeddings, reranking, entity extraction) + +Rebuild stack: + +```bash +docker compose --env-file .env up --build +``` + +**Profiles:** + +- **default** โ€” all services (db, migrate, app, sidecar) +- `--profile dev` โ€” adds Inngest dev server (dashboard at `http://localhost:8288`) +- `--profile minimal` โ€” db only (for local `pnpm dev`) + +Example with Inngest dev server: + +```bash +docker compose --env-file .env --profile dev up +``` + +## Option 2: Vercel + managed PostgreSQL + +1. Import repository into Vercel. +2. Configure managed PostgreSQL (Vercel Postgres, Neon, Supabase, etc.). +3. Set `DATABASE_URL` and app environment variables. +4. Deploy with Vercel defaults. +5. Apply schema once: + +```bash +DATABASE_URL="your_production_db_url" pnpm db:push +``` + +Optional integrations: + +- Inngest for background document processing +- LangSmith for tracing +- Sidecar (deploy separately and set `SIDECAR_URL`) + +## Option 3: VPS self-hosted (Node + reverse proxy) + +1. Install Node.js 18+, pnpm, Nginx, and PostgreSQL with pgvector. +2. Clone repo and install dependencies. +3. Configure `.env`. +4. Build and run with PM2/systemd. +5. Reverse proxy traffic via Nginx and enable TLS (Let's Encrypt). +6. Apply schema: + +```bash +pnpm db:push +``` + +Optional: Run the sidecar separately and point `SIDECAR_URL` to it. + +## Environment Variables Summary + +| Variable | Required | Description | +|----------|----------|-------------| +| `DATABASE_URL` | Yes | PostgreSQL connection string | +| `NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY` | Yes | Clerk publishable key | +| `CLERK_SECRET_KEY` | Yes | Clerk secret key | +| `OPENAI_API_KEY` | Yes | OpenAI API key | +| `INNGEST_EVENT_KEY` | Yes (prod) | Inngest event key for background jobs | +| `UPLOADTHING_TOKEN` | Optional | UploadThing for cloud storage | +| `SIDECAR_URL` | Optional | Sidecar URL for reranking and Graph RAG | +| `TAVILY_API_KEY` | Optional | Web search for analysis | +| `AZURE_DOC_INTELLIGENCE_*` | Optional | OCR for scanned PDFs | +| `DATALAB_API_KEY` | Optional | Alternative OCR | +| `LANDING_AI_API_KEY` | Optional | Fallback OCR | +| `JOB_RUNNER` | Optional | `inngest` (default) or `trigger-dev` | + +## Post-deployment Checklist + +- [ ] Environment variables set for all enabled features +- [ ] `DATABASE_URL` points to production DB +- [ ] `vector` extension enabled on PostgreSQL +- [ ] Schema applied (`pnpm db:push`) +- [ ] Clerk, UploadThing, and OpenAI integrations validated +- [ ] OCR providers validated if OCR is enabled +- [ ] Inngest validated if background processing is used +- [ ] Sidecar validated if `SIDECAR_URL` is set + +## Troubleshooting + +### Corrupted Docker image + +```bash +docker rmi pdr_ai_v2-migrate --force +docker compose --env-file .env build --no-cache migrate +docker compose --env-file .env up +``` + +If another image fails, remove it and rebuild with `--no-cache`. + +### Sidecar startup timeout + +The sidecar loads ML models at startup (~2 minutes). Increase `start_period` in `docker-compose.yml` if needed, or wait longer before health checks pass. diff --git a/docs/feature-workflows.md b/docs/feature-workflows.md new file mode 100644 index 00000000..e03d6619 --- /dev/null +++ b/docs/feature-workflows.md @@ -0,0 +1,115 @@ +# Feature Workflows and Architecture + +This document explains how major PDR AI features connect end to end. + +## End-to-end workflow + +PDR AI follows this loop: + +1. Authenticate user with role context (Employer/Employee) +2. Upload document (cloud or database storage) +3. **Ingest** โ€” unified ingestion layer extracts text from PDF, DOCX, XLSX, PPTX, images, etc. +4. **OCR** (optional) โ€” for scanned PDFs via Azure Document Intelligence, Datalab, or Landing.AI +5. **Chunk** โ€” split content into sections +6. **Embed** โ€” generate embeddings (OpenAI or sidecar) +7. **Store** โ€” vectors in PostgreSQL (pgvector), chunks for BM25, optional knowledge graph +8. **Retrieve** โ€” ensemble search (vector + BM25, optional graph retriever + reranking) +9. Use retrieval for AI chat and predictive analysis +10. Persist chat/session context for continuity + +## Knowledge base architecture + +```text +Upload -> Ingest (unified adapters) -> Chunk -> Embed -> Store (pgvector + optional graph) -> Retrieve (ensemble + optional rerank) +``` + +### Core areas in codebase + +| Area | Path | Purpose | +|------|------|---------| +| Upload API | `src/app/api/uploadDocument/route.ts` | Ingestion entrypoint (cloud or DB storage) | +| Local upload | `src/app/api/upload-local/route.ts` | Direct upload to database | +| Unified ingestion | `src/lib/ingestion/` | Adapters for PDF, DOCX, XLSX, PPTX, images, etc. | +| OCR pipeline | `src/lib/ocr/` | Azure, Datalab, Landing.AI adapters; processor and trigger | +| Job dispatcher | `src/lib/jobs/` | Inngest (default) or Trigger.dev for background processing | +| RAG retrieval | `src/server/rag/` | Vector, BM25, graph retrievers; ensemble search | +| Document Q&A | `src/app/api/agents/documentQ&A/` | RAG-backed chat and query | +| Predictive analysis | `src/app/api/agents/predictive-document-analysis/` | Gap detection and recommendations | +| Database | `src/server/db/` | Schema, migrations, knowledge graph tables | + +## Unified ingestion layer + +The ingestion layer (`src/lib/ingestion/`) provides a single API to convert documents into a standardized format: + +- **Supported types:** PDF, DOCX, XLSX, PPTX, images, CSV, text, HTML, Markdown +- **Providers:** Native text/PDF, Mammoth (DOCX), SheetJS (XLSX/CSV), Cheerio (HTML), Azure OCR, Tesseract, sidecar +- **Output:** `StandardizedDocument` with pages, text blocks, tables, and metadata + +## Knowledge graph (Graph RAG) + +When `SIDECAR_URL` is set: + +1. **Entity extraction** โ€” Sidecar `/extract-entities` runs NER on chunks +2. **Graph storage** โ€” Entities and relationships stored in `kg_entities`, `kg_entity_mentions`, `kg_relationships` +3. **Graph retrieval** โ€” `GraphRetriever` finds entities matching the query, traverses 1โ€“2 hops, returns related sections +4. **Ensemble use** โ€” Graph retriever can be combined with vector and BM25 in ensemble search + +Relevant code: + +- `src/lib/ingestion/entity-extraction.ts` โ€” calls sidecar and writes to graph tables +- `src/server/rag/retrievers/graph-retriever.ts` โ€” LangChain retriever for graph traversal +- `src/server/db/schema/knowledge-graph.ts` โ€” graph schema + +## Sidecar (optional ML compute) + +The sidecar is a FastAPI service that provides: + +| Endpoint | Purpose | +|----------|---------| +| `/embed` | Local embeddings (sentence-transformers) | +| `/rerank` | Cross-encoder reranking of search results | +| `/extract-entities` | NER for knowledge graph entity extraction | +| `/health` | Health check | + +Configure via `SIDECAR_URL`. When set: + +- Ensemble search uses the sidecar for reranking (graceful fallback if unavailable) +- Document processing can use the sidecar for entity extraction and graph population + +## Document viewers + +- **PDF** โ€” PDF.js via iframe or native viewer +- **Images** โ€” Direct image display +- **DOCX** โ€” Mammoth-based `DocxViewer` +- **XLSX** โ€” SheetJS-based `XlsxViewer` +- **PPTX** โ€” Custom `PptxViewer` + +Viewers live in `src/app/employer/documents/components/`. + +## Predictive document analysis + +Flow: + +1. Parse available document set and metadata +2. Identify expected-but-missing documents +3. Score urgency/confidence +4. Return prioritized recommendations + +Benefits: reduced manual review, better compliance readiness, faster audit preparation. + +## Study workflows + +Study flows reuse the same retrieval foundation: + +- StudyBuddy mode โ€” conversational coaching +- AI Teacher mode โ€” structured instruction + +Both rely on persisted session state and document-grounded retrieval. + +## Search scopes + +- Document-scoped retrieval +- Category-scoped retrieval +- Company-scoped retrieval +- Multi-document retrieval +- Optional web-enriched retrieval (Tavily) when configured diff --git a/docs/manual-testing-guide.md b/docs/manual-testing-guide.md new file mode 100644 index 00000000..80253373 --- /dev/null +++ b/docs/manual-testing-guide.md @@ -0,0 +1,199 @@ +# Manual Testing Guide (Dev) + +Use this guide to **exhaustively manually test the website in development** after each PR. It covers all user-facing routes, auth flows, and major features so nothing is missed. + +## Running the tests: two passes required + +**Run the same test suite twice:** + +1. **Run 1 โ€” Local dev:** App and DB run on your machine (Next.js dev server + local or Docker DB). +2. **Run 2 โ€” Docker:** Full stack runs via Docker Compose (app + DB + migrate, and optional services). + +Use the **same checklist** (sections 1โ€“5, and optionally 6) for both passes. This catches environment-specific issues (paths, env loading, build vs dev server, etc.). + +--- + +## Run 1: Local dev setup + +Before the first pass: + +1. **Environment** + - Copy `.env.example` to `.env` and fill required keys (see [README](../README.md) Quick Start). + - Set `DATABASE_URL` for a local PostgreSQL (e.g. `localhost:5433` if using Docker for DB only). + ```bash + pnpm db:install + ``` + +2. **Database** + ```bash + pnpm db:push + ``` + +3. **Enable Inngest** (required for background document processing) + - Set `INNGEST_EVENT_KEY=placeholder` in `.env`. + - In a **separate terminal**, run the Inngest dev server: + ```bash + pnpm inngest:dev + ``` + Dashboard: **http://localhost:8288**. Keep this running while testing. + +4. **Run dev server** + ```bash + pnpm run dev + ``` + Open **http://localhost:3000**. + +5. **Test accounts** + - Have at least one **Employer** (or Owner) account. + - Optionally have one **pending** employer and one **pending** employee for approval flows. + +Complete sections 1โ€“5 (and 6 if desired), then proceed to Run 2. + +--- + +## Run 2: Docker setup + +Before the second pass: + +1. **Environment** + - Use the same `.env` (or a copy) with keys valid for the Docker run (e.g. `DATABASE_URL` for the Compose `db` service). + +2. **Start full stack (with Inngest)** + - Ensure `INNGEST_EVENT_KEY` (and optionally `INNGEST_SIGNING_KEY`) is set in `.env`. + - Use the `dev` profile so the Inngest dev server runs (required for document upload/processing): + ```bash + docker compose --env-file .env --profile dev up + ``` + Wait until the app and Inngest are ready (migrate completes, app listens). Open **http://localhost:3000**; Inngest dashboard at **http://localhost:8288**. + +3. **Test accounts** + - Reuse the same Employer/Employee accounts (Clerk and DB are shared if you point to the same DB) or create fresh ones. + +Run the **same checklist** (sections 1โ€“5, and optionally 6) again. Note any differences from Run 1 (e.g. upload paths, API base URL, env-only features). + +--- + +## 1. Public pages (Only needs to be tested if working on the main landing page) + +| # | Check | Route | Expected | +|---|--------|--------|----------| +| 1.1 | Landing page loads | `/` | +| 1.2 | Sign up link | Click โ€œStart Free Trialโ€ / `/signup` | Navigates to signup. | +| 1.3 | Sign in link | Nav or `/signin` | Sign-in form (Clerk). | +| 1.4 | Contact | `/contact` | Contact page loads. | +| 1.5 | About | `/about` | About page loads. | +| 1.6 | Pricing | `/pricing` | Pricing page loads. | +| 1.7 | Deployment (public) | `/deployment` | Deployment/setup guide loads (no auth). | +--- + +## 2. Authentication flows (Only needed if working on authentication) + +### 2.1 Sign up + +| # | Check | Steps | Expected | +|---|--------|--------|----------| +| 2.1.1 | New employer signup | Go to `/signup`, complete Clerk signup, choose Employer, submit. | User created in DB as employer (or owner), then redirected to `/employer/home` or `/employer/pending-approval` depending on approval flow. | +| 2.1.2 | New employee signup | Go to `/signup`, complete Clerk signup, choose Employee, submit. | User created as employee, redirected to `/employee/documents` or `/employee/pending-approval`. | +| 2.1.3 | Already in DB | Sign up with email that already exists in DB (with role). | Appropriate error or redirect (no duplicate role flip). | + +### 2.2 Sign in & redirects + +| # | Check | Steps | Expected | +|---|--------|--------|----------| +| 2.2.1 | Employer sign in | Sign in as verified employer. Visit `/` or `/signin`. | Redirect to `/employer/home`. | +| 2.2.2 | Employee sign in | Sign in as verified employee. Visit `/` or `/signin`. | Redirect to `/employee/documents`. | +| 2.2.3 | Protected route unauthenticated | Log out, visit `/employer/home` or `/employee/documents`. | Redirect to `/signin`. | +| 2.2.4 | Wrong role | Sign in as employee, manually go to `/employer/home`. | Rejected or redirected (employer-only). | + +### 2.3 Pending approval + +| # | Check | Steps | Expected | +|---|--------|--------|----------| +| 2.3.1 | Pending employer | Sign in as employer with `status !== 'verified'`. | Redirect to `/employer/pending-approval`; message about waiting for approval. | +| 2.3.2 | Pending employee | Sign in as employee with `status !== 'verified'`. | Redirect to `/employee/pending-approval`; same idea. | + +--- + +## 3. Employer flows + +### 3.1 Upload (`/employer/upload`) + +| # | Check | Expected | +|---|--------|----------| +| 3.2.1 | Upload page | Form to upload file(s); optional category/settings if present. | +| 3.2.2 | Upload PDF | Select a PDF, submit; success feedback and document appears in list or documents page. | +| 3.2.3 | Upload DOCX/XLSX/PPTX | Same for other supported types; no client/server crash. | +| 3.2.4 | Validation | Invalid or oversized file shows clear error. | +| 3.2.5 | OCR (if configured) | With OCR provider keys set, option to run OCR on scanned PDF; processing completes or fails gracefully. | + +### 3.2 Documents (`/employer/documents`) + +| # | Check | Expected | +|---|--------|----------| +| 3.3.1 | List loads | Document list (or sidebar) loads; can select a document. | +| 3.3.2 | Document viewer | Selecting a document opens viewer (PDF/DOCX/XLSX/PPTX as applicable). | +| 3.3.3 | PDF viewer | PDF renders in iframe or native viewer; scroll/zoom ok. | +| 3.3.4 | DOCX/XLSX/PPTX | Respective viewers render content without crash. | +| 3.3.5 | AI chat / Q&A | Chat or Q&A panel sends query; response returned (RAG); no 500. | +| 3.3.6 | Document generator (if present) | Outline/citation/grammar/research/export panels open and behave; export works or shows clear state. | +| 3.3.7 | Simple query / Agent chat | Query panel or agent chat returns answers; no infinite loading. | + +### 3.3 Statistics (`/employer/statistics`) + +| # | Check | Expected | +|---|--------|----------| +| 3.4.1 | Page loads | Charts and tables load (employee activity, document stats). | +| 3.4.2 | Data | Numbers and trends match backend; document details sheet or drill-down works if present. | + +### 3.4 Manage employees (`/employer/employees`) (Only if working on authentication) + +| # | Check | Expected | +|---|--------|----------| +| 3.5.1 | List | Employee list loads. | +| 3.5.2 | Approve/deny (if applicable) | Pending employees can be approved/denied; list updates. | +| 3.5.3 | Invite / add (if applicable) | Invite or add employee flow works; no 500. | + +### 3.6 Settings (`/employer/settings`) (Only if working on settings) + +| # | Check | Expected | +|---|--------|----------| +| 3.6.1 | Page loads | Settings form (profile, preferences, etc.) loads. | +| 3.6.2 | Save | Changing and saving updates without error. | + +### 3.7 Contact support (`/employer/contact`) (Only if working on support) + +| # | Check | Expected | +|---|--------|----------| +| 3.7.1 | Page loads | Contact/support form or info loads. | + +### 3.9 Pending approval (`/employer/pending-approval`) (Only if working on authentication) + +| # | Check | Expected | +|---|--------|----------| +| 3.9.1 | Message | Clear โ€œpending approvalโ€ message; no employer actions that require verification. | +--- + +## 4. Employee flows (Employers and employees share the same document screen. So only need to test this if employee sepcific features are touched) + +### 4.1 Employee home (`/employee/home`) + +| # | Check | Expected | +|---|--------|----------| +| 4.1.1 | Page loads | Dashboard with โ€œView Documentsโ€ and any other employee menu items. | +| 4.1.2 | Nav | Nav and profile present; theme toggle works. | + +### 4.2 Employee documents (`/employee/documents`) + +| # | Check | Expected | +|---|--------|----------| +| 4.2.1 | List | Only documents assigned/visible to employee are shown. | +| 4.2.2 | Viewer | Opening a document shows viewer (PDF/DOCX/etc.). | +| 4.2.3 | AI Q&A | Chat/Q&A over documents works; answers are scoped to allowed content. | + +### 4.4 Profile & sign out + +| # | Check | Expected | +|---|--------|----------| +| 4.4.1 | Sign out | Same as employer; clean redirect after sign out. | + +--- \ No newline at end of file diff --git a/docs/observability.md b/docs/observability.md index 87ecf52f..96513ef2 100644 --- a/docs/observability.md +++ b/docs/observability.md @@ -1,30 +1,30 @@ # Observability & Metrics -The PDR AI backend now exposes Prometheus-compatible metrics so you can track request health, cache efficiency, and search fallbacks in real time. +The PDR AI backend exposes Prometheus-compatible metrics for request health, cache efficiency, and search behavior. ## Available Metrics | Metric | Type | Description | |--------|------|-------------| -| `pdr_predictive_analysis_duration_seconds` | Histogram | End-to-end latency for predictive document analysis requests, labeled by `result` and `cached`. | -| `pdr_predictive_analysis_requests_total` | Counter | Request totals labeled by success/error and cache usage. | -| `pdr_predictive_analysis_cache_hits_total` | Counter | Number of times cached analysis results were returned. | -| `pdr_predictive_analysis_ai_calls` | Histogram | Distribution of GPT call counts per analysis (estimates cost/latency pressure). | -| `pdr_qa_request_duration_seconds` | Histogram | Latency for `/api/AIAssistant` requests labeled by `result` and retrieval strategy. | -| `pdr_qa_requests_total` | Counter | Total Q&A requests split by result (`success`, `empty`, `error`). | +| `pdr_predictive_analysis_duration_seconds` | Histogram | End-to-end latency for predictive document analysis, labeled by `result` and `cached` | +| `pdr_predictive_analysis_requests_total` | Counter | Request totals labeled by success/error and cache usage | +| `pdr_predictive_analysis_cache_hits_total` | Counter | Number of cached analysis results returned | +| `pdr_predictive_analysis_ai_calls` | Histogram | GPT call counts per analysis (cost/latency) | +| `pdr_qa_request_duration_seconds` | Histogram | Latency for Q&A requests labeled by `result` and retrieval strategy | +| `pdr_qa_requests_total` | Counter | Total Q&A requests split by `result` (`success`, `empty`, `error`) | -All metrics live under the `pdr_` prefix alongside `prom-client` default process metrics. +All metrics use the `pdr_` prefix alongside `prom-client` default process metrics. ## Scraping the Endpoint -1. Run the application (`pnpm dev`). +1. Run the application (`pnpm dev` or Docker). 2. Scrape `http://localhost:3000/api/metrics`: ```bash curl -s http://localhost:3000/api/metrics ``` -3. Wire Prometheus by adding a scrape config: +3. Configure Prometheus: ```yaml scrape_configs: @@ -42,7 +42,7 @@ scrape_configs: - GPT call histogram: `histogram_quantile(0.95, sum(rate(pdr_predictive_analysis_ai_calls_bucket[5m])) by (le))` - **Q&A Reliability** - - Latency (P95) split by retrieval: `histogram_quantile(0.95, sum(rate(pdr_qa_request_duration_seconds_bucket[5m])) by (le,retrieval))` + - Latency (P95) by retrieval: `histogram_quantile(0.95, sum(rate(pdr_qa_request_duration_seconds_bucket[5m])) by (le,retrieval))` - Fallback ratio: `rate(pdr_qa_requests_total{retrieval="ann_fallback"}[5m]) / rate(pdr_qa_requests_total[5m])` -With these dashboards you can quickly spot cache regressions, surging GPT usage, or ensemble search failures long before end users notice. +These dashboards help spot cache regressions, GPT usage spikes, or ensemble search issues before users are affected. diff --git a/docs/usage-examples.md b/docs/usage-examples.md new file mode 100644 index 00000000..9b748296 --- /dev/null +++ b/docs/usage-examples.md @@ -0,0 +1,91 @@ +# Usage Examples + +## Document upload (cloud or database storage) + +Upload and process a document via `uploadDocument`. Supports both cloud URLs (UploadThing) and database paths (`/api/files/...`). + +```typescript +const response = await fetch("/api/uploadDocument", { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ + userId: "user_xxx", + documentUrl: "https://utfs.io/f/xxx", // or /api/files/123 for DB storage + documentName: "report.pdf", + category: "Compliance", + storageType: "cloud", // or "database" + mimeType: "application/pdf", + preferredProvider: "azure", // optional: azure, datalab, landing_ai + }), +}); + +const result = await response.json(); +``` + +## Local upload (database storage) + +For direct upload to database storage: + +```typescript +const formData = new FormData(); +formData.append("file", file); +formData.append("userId", userId); +formData.append("documentName", file.name); +formData.append("categoryId", categoryId); + +const response = await fetch("/api/upload-local", { + method: "POST", + body: formData, +}); + +const result = await response.json(); +``` + +## Document Q&A + +```typescript +const response = await fetch("/api/agents/documentQ&A/AIQueryRLM", { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ + documentId: "123", + message: "What are the key compliance requirements?", + categoryId: "456", + }), +}); + +const answer = await response.json(); +``` + +## Predictive analysis + +```typescript +const response = await fetch("/api/agents/predictive-document-analysis", { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ + documentId: "123", + categoryId: "456", + }), +}); + +const analysis = await response.json(); +``` + +## Supported document types (ingestion) + +The unified ingestion layer supports: + +- **PDF** โ€” native extraction or OCR for scanned +- **DOCX** โ€” Mammoth +- **XLSX** โ€” SheetJS +- **PPTX** โ€” custom adapter +- **Images** โ€” OCR (Azure, Tesseract, etc.) +- **CSV, text, HTML, Markdown** โ€” native or Cheerio + +## OCR provider notes + +- OCR behavior is controlled via provider keys in environment variables. +- If OCR UI options are not visible, verify OCR keys are present. +- Use OCR for scanned/image-based PDFs; digital PDFs usually do not need it. +- `preferredProvider` can be `azure`, `datalab`, or `landing_ai` when multiple are configured. diff --git a/drizzle.config.ts b/drizzle.config.ts index 752f1818..fd389dcb 100644 --- a/drizzle.config.ts +++ b/drizzle.config.ts @@ -4,8 +4,12 @@ import { type Config } from "drizzle-kit"; export default { schema: "./src/server/db/schema.ts", dialect: "postgresql", + out: "./drizzle", dbCredentials: { url: process.env.DATABASE_URL, }, tablesFilter: ["pdr_ai_v2_*"], + migrations: { + schema: "public", + }, } as Config; diff --git a/drizzle/0000_sweet_havok.sql b/drizzle/0000_sweet_havok.sql deleted file mode 100644 index 41b558bc..00000000 --- a/drizzle/0000_sweet_havok.sql +++ /dev/null @@ -1,8 +0,0 @@ -CREATE TABLE IF NOT EXISTS "pdr_ai_v2_post" ( - "id" integer PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (sequence name "pdr_ai_v2_post_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1), - "name" varchar(256), - "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "updated_at" timestamp with time zone -); ---> statement-breakpoint -CREATE INDEX IF NOT EXISTS "name_idx" ON "pdr_ai_v2_post" USING btree ("name"); \ No newline at end of file diff --git a/drizzle/0001_talented_the_watchers.sql b/drizzle/0001_talented_the_watchers.sql deleted file mode 100644 index 156e4174..00000000 --- a/drizzle/0001_talented_the_watchers.sql +++ /dev/null @@ -1,61 +0,0 @@ -CREATE TABLE IF NOT EXISTS "pdr_ai_v2_category" ( - "id" serial PRIMARY KEY NOT NULL, - "name" varchar(256) NOT NULL, - "company id" varchar(256) NOT NULL, - "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "updated_at" timestamp with time zone -); ---> statement-breakpoint -CREATE TABLE IF NOT EXISTS "pdr_ai_v2_company" ( - "id" serial PRIMARY KEY NOT NULL, - "name" varchar(256) NOT NULL, - "employerPasskey" varchar(256) NOT NULL, - "employeePasskey" varchar(256) NOT NULL, - "numberOfEmployees" varchar(256) NOT NULL, - "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "updated_at" timestamp with time zone -); ---> statement-breakpoint -CREATE TABLE IF NOT EXISTS "pdr_ai_v2_document" ( - "id" serial PRIMARY KEY NOT NULL, - "url" varchar(256) NOT NULL, - "category" varchar(256) NOT NULL, - "title" varchar(256) NOT NULL, - "company id" varchar(256) NOT NULL, - "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "updated_at" timestamp with time zone -); ---> statement-breakpoint -CREATE TABLE IF NOT EXISTS "pdr_ai_v2_pdf_chunks" ( - "id" serial PRIMARY KEY NOT NULL, - "document_id" integer NOT NULL, - "page" integer NOT NULL, - "content" text NOT NULL, - "embedding" vector(1536) -); ---> statement-breakpoint -CREATE TABLE IF NOT EXISTS "pdr_ai_v2_users" ( - "id" serial PRIMARY KEY NOT NULL, - "name" varchar(256) NOT NULL, - "email" varchar(256) NOT NULL, - "userId" varchar(256) NOT NULL, - "companyId" varchar(256) NOT NULL, - "role" varchar(256) NOT NULL, - "status" varchar(256) NOT NULL, - "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "updated_at" timestamp with time zone -); ---> statement-breakpoint -ALTER TABLE "pdr_ai_v2_post" RENAME TO "pdr_ai_v2_chatHistory";--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_chatHistory" RENAME COLUMN "name" TO "question";--> statement-breakpoint -DROP INDEX IF EXISTS "name_idx";--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_chatHistory" ALTER COLUMN "id" SET DATA TYPE serial;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_chatHistory" ALTER COLUMN "id" DROP IDENTITY;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_chatHistory" ALTER COLUMN "question" SET NOT NULL;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_chatHistory" ADD COLUMN "company id" varchar(256) NOT NULL;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_chatHistory" ADD COLUMN "response" varchar(1024) NOT NULL;--> statement-breakpoint -DO $$ BEGIN - ALTER TABLE "pdr_ai_v2_pdf_chunks" ADD CONSTRAINT "pdr_ai_v2_pdf_chunks_document_id_pdr_ai_v2_document_id_fk" FOREIGN KEY ("document_id") REFERENCES "public"."pdr_ai_v2_document"("id") ON DELETE cascade ON UPDATE no action; -EXCEPTION - WHEN duplicate_object THEN null; -END $$; diff --git a/drizzle/0001_tranquil_hitman.sql b/drizzle/0001_tranquil_hitman.sql deleted file mode 100644 index 0b998757..00000000 --- a/drizzle/0001_tranquil_hitman.sql +++ /dev/null @@ -1,25 +0,0 @@ -CREATE TABLE "pdr_ai_v2_document_reference_resolutions" ( - "id" serial PRIMARY KEY NOT NULL, - "company_id" integer NOT NULL, - "reference_name" varchar(256) NOT NULL, - "resolved_in_document_id" integer, - "resolution_details" jsonb, - "created_at" timestamp with time zone DEFAULT now() NOT NULL -); ---> statement-breakpoint -CREATE TABLE "pdr_ai_v2_predictive_document_analysis_results" ( - "id" serial PRIMARY KEY NOT NULL, - "document_id" integer NOT NULL, - "analysis_type" varchar(256) NOT NULL, - "include_related_docs" boolean DEFAULT false, - "result_json" jsonb NOT NULL, - "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL -); ---> statement-breakpoint -ALTER TABLE "pdr_ai_v2_chatHistory" ALTER COLUMN "response" SET DATA TYPE text;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_chatHistory" ADD COLUMN "document id" varchar(256) NOT NULL;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_chatHistory" ADD COLUMN "document title" varchar(256) NOT NULL;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_chatHistory" ADD COLUMN "pages" integer[] NOT NULL;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_document_reference_resolutions" ADD CONSTRAINT "pdr_ai_v2_document_reference_resolutions_company_id_pdr_ai_v2_company_id_fk" FOREIGN KEY ("company_id") REFERENCES "public"."pdr_ai_v2_company"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_predictive_document_analysis_results" ADD CONSTRAINT "pdr_ai_v2_predictive_document_analysis_results_document_id_pdr_ai_v2_document_id_fk" FOREIGN KEY ("document_id") REFERENCES "public"."pdr_ai_v2_document"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -CREATE INDEX "document_reference_resolutions_company_ref_idx" ON "pdr_ai_v2_document_reference_resolutions" USING btree ("company_id"); \ No newline at end of file diff --git a/drizzle/0002_small_crusher_hogan.sql b/drizzle/0002_small_crusher_hogan.sql deleted file mode 100644 index 94a1e431..00000000 --- a/drizzle/0002_small_crusher_hogan.sql +++ /dev/null @@ -1,3 +0,0 @@ -ALTER TABLE "pdr_ai_v2_document" ADD COLUMN "ocr_enabled" boolean DEFAULT false;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_document" ADD COLUMN "ocr_processed" boolean DEFAULT false;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_document" ADD COLUMN "ocr_metadata" jsonb; \ No newline at end of file diff --git a/drizzle/0003_thin_cloak.sql b/drizzle/0003_thin_cloak.sql deleted file mode 100644 index 7e7a496e..00000000 --- a/drizzle/0003_thin_cloak.sql +++ /dev/null @@ -1,55 +0,0 @@ -CREATE TABLE "pdr_ai_v2_ai_chatbot_chat" ( - "id" varchar(256) PRIMARY KEY NOT NULL, - "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "title" text NOT NULL, - "user_id" varchar(256) NOT NULL, - "visibility" varchar(20) DEFAULT 'private' NOT NULL -); ---> statement-breakpoint -CREATE TABLE "pdr_ai_v2_ai_chatbot_document" ( - "id" varchar(256) NOT NULL, - "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "title" text NOT NULL, - "content" text, - "kind" varchar(20) DEFAULT 'text' NOT NULL, - "user_id" varchar(256) NOT NULL, - CONSTRAINT "pdr_ai_v2_ai_chatbot_document_id_created_at_pk" PRIMARY KEY("id","created_at") -); ---> statement-breakpoint -CREATE TABLE "pdr_ai_v2_ai_chatbot_message" ( - "id" varchar(256) PRIMARY KEY NOT NULL, - "chat_id" varchar(256) NOT NULL, - "role" varchar(50) NOT NULL, - "content" jsonb NOT NULL, - "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL -); ---> statement-breakpoint -CREATE TABLE "pdr_ai_v2_ai_chatbot_suggestion" ( - "id" varchar(256) PRIMARY KEY NOT NULL, - "document_id" varchar(256) NOT NULL, - "document_created_at" timestamp with time zone NOT NULL, - "original_text" text NOT NULL, - "suggested_text" text NOT NULL, - "description" text, - "is_resolved" boolean DEFAULT false NOT NULL, - "user_id" varchar(256) NOT NULL, - "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL -); ---> statement-breakpoint -CREATE TABLE "pdr_ai_v2_ai_chatbot_vote" ( - "chat_id" varchar(256) NOT NULL, - "message_id" varchar(256) NOT NULL, - "is_upvoted" boolean NOT NULL, - "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - CONSTRAINT "pdr_ai_v2_ai_chatbot_vote_chat_id_message_id_pk" PRIMARY KEY("chat_id","message_id") -); ---> statement-breakpoint -ALTER TABLE "pdr_ai_v2_chatHistory" ADD COLUMN "query_type" varchar(20) DEFAULT 'simple' NOT NULL;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_chatHistory" ADD COLUMN "chat_id" varchar(256);--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_ai_chatbot_chat" ADD CONSTRAINT "pdr_ai_v2_ai_chatbot_chat_user_id_pdr_ai_v2_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."pdr_ai_v2_users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_ai_chatbot_document" ADD CONSTRAINT "pdr_ai_v2_ai_chatbot_document_user_id_pdr_ai_v2_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."pdr_ai_v2_users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_ai_chatbot_message" ADD CONSTRAINT "pdr_ai_v2_ai_chatbot_message_chat_id_pdr_ai_v2_ai_chatbot_chat_id_fk" FOREIGN KEY ("chat_id") REFERENCES "public"."pdr_ai_v2_ai_chatbot_chat"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_ai_chatbot_suggestion" ADD CONSTRAINT "pdr_ai_v2_ai_chatbot_suggestion_user_id_pdr_ai_v2_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."pdr_ai_v2_users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_ai_chatbot_suggestion" ADD CONSTRAINT "pdr_ai_v2_ai_chatbot_suggestion_document_id_document_created_at_pdr_ai_v2_ai_chatbot_document_id_created_at_fk" FOREIGN KEY ("document_id","document_created_at") REFERENCES "public"."pdr_ai_v2_ai_chatbot_document"("id","created_at") ON DELETE no action ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_ai_chatbot_vote" ADD CONSTRAINT "pdr_ai_v2_ai_chatbot_vote_chat_id_pdr_ai_v2_ai_chatbot_chat_id_fk" FOREIGN KEY ("chat_id") REFERENCES "public"."pdr_ai_v2_ai_chatbot_chat"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_ai_chatbot_vote" ADD CONSTRAINT "pdr_ai_v2_ai_chatbot_vote_message_id_pdr_ai_v2_ai_chatbot_message_id_fk" FOREIGN KEY ("message_id") REFERENCES "public"."pdr_ai_v2_ai_chatbot_message"("id") ON DELETE cascade ON UPDATE no action; \ No newline at end of file diff --git a/drizzle/0004_lazy_the_spike.sql b/drizzle/0004_lazy_the_spike.sql deleted file mode 100644 index 1f9baa28..00000000 --- a/drizzle/0004_lazy_the_spike.sql +++ /dev/null @@ -1,12 +0,0 @@ -ALTER TABLE "pdr_ai_v2_ai_chatbot_chat" DROP CONSTRAINT "pdr_ai_v2_ai_chatbot_chat_user_id_pdr_ai_v2_users_id_fk"; ---> statement-breakpoint -ALTER TABLE "pdr_ai_v2_ai_chatbot_document" DROP CONSTRAINT "pdr_ai_v2_ai_chatbot_document_user_id_pdr_ai_v2_users_id_fk"; ---> statement-breakpoint -ALTER TABLE "pdr_ai_v2_ai_chatbot_suggestion" DROP CONSTRAINT "pdr_ai_v2_ai_chatbot_suggestion_user_id_pdr_ai_v2_users_id_fk"; ---> statement-breakpoint -ALTER TABLE "pdr_ai_v2_chatHistory" DROP COLUMN "query_type";--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_chatHistory" DROP COLUMN "chat_id";--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_users" ADD CONSTRAINT "pdr_ai_v2_users_userId_unique" UNIQUE("userId");--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_ai_chatbot_chat" ADD CONSTRAINT "pdr_ai_v2_ai_chatbot_chat_user_id_pdr_ai_v2_users_userId_fk" FOREIGN KEY ("user_id") REFERENCES "public"."pdr_ai_v2_users"("userId") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_ai_chatbot_document" ADD CONSTRAINT "pdr_ai_v2_ai_chatbot_document_user_id_pdr_ai_v2_users_userId_fk" FOREIGN KEY ("user_id") REFERENCES "public"."pdr_ai_v2_users"("userId") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_ai_chatbot_suggestion" ADD CONSTRAINT "pdr_ai_v2_ai_chatbot_suggestion_user_id_pdr_ai_v2_users_userId_fk" FOREIGN KEY ("user_id") REFERENCES "public"."pdr_ai_v2_users"("userId") ON DELETE cascade ON UPDATE no action; \ No newline at end of file diff --git a/drizzle/0005_quick_silver_sable.sql b/drizzle/0005_quick_silver_sable.sql deleted file mode 100644 index fc87fbb2..00000000 --- a/drizzle/0005_quick_silver_sable.sql +++ /dev/null @@ -1,153 +0,0 @@ -CREATE TABLE "pdr_ai_v2_agent_ai_chatbot_chat" ( - "id" varchar(256) PRIMARY KEY NOT NULL, - "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "title" text NOT NULL, - "user_id" varchar(256) NOT NULL, - "visibility" varchar(20) DEFAULT 'private' NOT NULL, - "agent_mode" varchar(50) DEFAULT 'interactive' NOT NULL, - "status" varchar(50) DEFAULT 'active' NOT NULL, - "updated_at" timestamp with time zone -); ---> statement-breakpoint -CREATE TABLE "pdr_ai_v2_agent_ai_chatbot_document" ( - "id" varchar(256) NOT NULL, - "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "title" text NOT NULL, - "content" text, - "kind" varchar(20) DEFAULT 'text' NOT NULL, - "user_id" varchar(256) NOT NULL, - "chat_id" varchar(256), - "task_id" varchar(256), - CONSTRAINT "pdr_ai_v2_agent_ai_chatbot_document_id_created_at_pk" PRIMARY KEY("id","created_at") -); ---> statement-breakpoint -CREATE TABLE "pdr_ai_v2_agent_ai_chatbot_execution_step" ( - "id" varchar(256) PRIMARY KEY NOT NULL, - "task_id" varchar(256) NOT NULL, - "step_number" integer NOT NULL, - "step_type" varchar(50) NOT NULL, - "description" text NOT NULL, - "reasoning" text, - "input" jsonb, - "output" jsonb, - "status" varchar(50) DEFAULT 'pending' NOT NULL, - "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "completed_at" timestamp with time zone -); ---> statement-breakpoint -CREATE TABLE "pdr_ai_v2_agent_ai_chatbot_memory" ( - "id" varchar(256) PRIMARY KEY NOT NULL, - "chat_id" varchar(256) NOT NULL, - "memory_type" varchar(50) NOT NULL, - "key" varchar(256) NOT NULL, - "value" jsonb NOT NULL, - "importance" integer DEFAULT 5 NOT NULL, - "embedding" vector(1536), - "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "accessed_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "expires_at" timestamp with time zone -); ---> statement-breakpoint -CREATE TABLE "pdr_ai_v2_agent_ai_chatbot_message" ( - "id" varchar(256) PRIMARY KEY NOT NULL, - "chat_id" varchar(256) NOT NULL, - "role" varchar(50) NOT NULL, - "content" jsonb NOT NULL, - "message_type" varchar(50) DEFAULT 'text' NOT NULL, - "parent_message_id" varchar(256), - "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL -); ---> statement-breakpoint -CREATE TABLE "pdr_ai_v2_agent_ai_chatbot_suggestion" ( - "id" varchar(256) PRIMARY KEY NOT NULL, - "document_id" varchar(256) NOT NULL, - "document_created_at" timestamp with time zone NOT NULL, - "original_text" text NOT NULL, - "suggested_text" text NOT NULL, - "description" text, - "is_resolved" boolean DEFAULT false NOT NULL, - "user_id" varchar(256) NOT NULL, - "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL -); ---> statement-breakpoint -CREATE TABLE "pdr_ai_v2_agent_ai_chatbot_task" ( - "id" varchar(256) PRIMARY KEY NOT NULL, - "chat_id" varchar(256) NOT NULL, - "description" text NOT NULL, - "objective" text NOT NULL, - "status" varchar(50) DEFAULT 'pending' NOT NULL, - "priority" integer DEFAULT 0 NOT NULL, - "result" jsonb, - "metadata" jsonb, - "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "completed_at" timestamp with time zone, - "updated_at" timestamp with time zone -); ---> statement-breakpoint -CREATE TABLE "pdr_ai_v2_agent_ai_chatbot_tool_call" ( - "id" varchar(256) PRIMARY KEY NOT NULL, - "message_id" varchar(256) NOT NULL, - "task_id" varchar(256), - "tool_name" varchar(256) NOT NULL, - "tool_input" jsonb NOT NULL, - "tool_output" jsonb, - "status" varchar(50) DEFAULT 'pending' NOT NULL, - "error_message" text, - "execution_time_ms" integer, - "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "completed_at" timestamp with time zone -); ---> statement-breakpoint -CREATE TABLE "pdr_ai_v2_agent_ai_chatbot_tool_registry" ( - "id" varchar(256) PRIMARY KEY NOT NULL, - "name" varchar(256) NOT NULL, - "description" text NOT NULL, - "category" varchar(100) NOT NULL, - "schema" jsonb NOT NULL, - "is_enabled" boolean DEFAULT true NOT NULL, - "required_permissions" jsonb, - "rate_limit" integer, - "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "updated_at" timestamp with time zone, - CONSTRAINT "pdr_ai_v2_agent_ai_chatbot_tool_registry_name_unique" UNIQUE("name") -); ---> statement-breakpoint -CREATE TABLE "pdr_ai_v2_agent_ai_chatbot_vote" ( - "chat_id" varchar(256) NOT NULL, - "message_id" varchar(256) NOT NULL, - "is_upvoted" boolean NOT NULL, - "feedback" text, - "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - CONSTRAINT "pdr_ai_v2_agent_ai_chatbot_vote_chat_id_message_id_pk" PRIMARY KEY("chat_id","message_id") -); ---> statement-breakpoint -ALTER TABLE "pdr_ai_v2_ai_chatbot_chat" DISABLE ROW LEVEL SECURITY;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_ai_chatbot_document" DISABLE ROW LEVEL SECURITY;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_ai_chatbot_message" DISABLE ROW LEVEL SECURITY;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_ai_chatbot_suggestion" DISABLE ROW LEVEL SECURITY;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_ai_chatbot_vote" DISABLE ROW LEVEL SECURITY;--> statement-breakpoint -DROP TABLE "pdr_ai_v2_ai_chatbot_chat" CASCADE;--> statement-breakpoint -DROP TABLE "pdr_ai_v2_ai_chatbot_document" CASCADE;--> statement-breakpoint -DROP TABLE "pdr_ai_v2_ai_chatbot_message" CASCADE;--> statement-breakpoint -DROP TABLE "pdr_ai_v2_ai_chatbot_suggestion" CASCADE;--> statement-breakpoint -DROP TABLE "pdr_ai_v2_ai_chatbot_vote" CASCADE;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_chatHistory" ADD COLUMN "chat_id" varchar(256);--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_chatHistory" ADD COLUMN "query_type" varchar(20) DEFAULT 'simple';--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_agent_ai_chatbot_chat" ADD CONSTRAINT "pdr_ai_v2_agent_ai_chatbot_chat_user_id_pdr_ai_v2_users_userId_fk" FOREIGN KEY ("user_id") REFERENCES "public"."pdr_ai_v2_users"("userId") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_agent_ai_chatbot_document" ADD CONSTRAINT "pdr_ai_v2_agent_ai_chatbot_document_user_id_pdr_ai_v2_users_userId_fk" FOREIGN KEY ("user_id") REFERENCES "public"."pdr_ai_v2_users"("userId") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_agent_ai_chatbot_document" ADD CONSTRAINT "pdr_ai_v2_agent_ai_chatbot_document_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk" FOREIGN KEY ("chat_id") REFERENCES "public"."pdr_ai_v2_agent_ai_chatbot_chat"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_agent_ai_chatbot_document" ADD CONSTRAINT "pdr_ai_v2_agent_ai_chatbot_document_task_id_pdr_ai_v2_agent_ai_chatbot_task_id_fk" FOREIGN KEY ("task_id") REFERENCES "public"."pdr_ai_v2_agent_ai_chatbot_task"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_agent_ai_chatbot_execution_step" ADD CONSTRAINT "pdr_ai_v2_agent_ai_chatbot_execution_step_task_id_pdr_ai_v2_agent_ai_chatbot_task_id_fk" FOREIGN KEY ("task_id") REFERENCES "public"."pdr_ai_v2_agent_ai_chatbot_task"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_agent_ai_chatbot_memory" ADD CONSTRAINT "pdr_ai_v2_agent_ai_chatbot_memory_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk" FOREIGN KEY ("chat_id") REFERENCES "public"."pdr_ai_v2_agent_ai_chatbot_chat"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_agent_ai_chatbot_message" ADD CONSTRAINT "pdr_ai_v2_agent_ai_chatbot_message_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk" FOREIGN KEY ("chat_id") REFERENCES "public"."pdr_ai_v2_agent_ai_chatbot_chat"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_agent_ai_chatbot_suggestion" ADD CONSTRAINT "pdr_ai_v2_agent_ai_chatbot_suggestion_user_id_pdr_ai_v2_users_userId_fk" FOREIGN KEY ("user_id") REFERENCES "public"."pdr_ai_v2_users"("userId") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_agent_ai_chatbot_suggestion" ADD CONSTRAINT "pdr_ai_v2_agent_ai_chatbot_suggestion_document_id_document_created_at_pdr_ai_v2_agent_ai_chatbot_document_id_created_at_fk" FOREIGN KEY ("document_id","document_created_at") REFERENCES "public"."pdr_ai_v2_agent_ai_chatbot_document"("id","created_at") ON DELETE no action ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_agent_ai_chatbot_task" ADD CONSTRAINT "pdr_ai_v2_agent_ai_chatbot_task_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk" FOREIGN KEY ("chat_id") REFERENCES "public"."pdr_ai_v2_agent_ai_chatbot_chat"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_agent_ai_chatbot_tool_call" ADD CONSTRAINT "pdr_ai_v2_agent_ai_chatbot_tool_call_message_id_pdr_ai_v2_agent_ai_chatbot_message_id_fk" FOREIGN KEY ("message_id") REFERENCES "public"."pdr_ai_v2_agent_ai_chatbot_message"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_agent_ai_chatbot_tool_call" ADD CONSTRAINT "pdr_ai_v2_agent_ai_chatbot_tool_call_task_id_pdr_ai_v2_agent_ai_chatbot_task_id_fk" FOREIGN KEY ("task_id") REFERENCES "public"."pdr_ai_v2_agent_ai_chatbot_task"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_agent_ai_chatbot_vote" ADD CONSTRAINT "pdr_ai_v2_agent_ai_chatbot_vote_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk" FOREIGN KEY ("chat_id") REFERENCES "public"."pdr_ai_v2_agent_ai_chatbot_chat"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_agent_ai_chatbot_vote" ADD CONSTRAINT "pdr_ai_v2_agent_ai_chatbot_vote_message_id_pdr_ai_v2_agent_ai_chatbot_message_id_fk" FOREIGN KEY ("message_id") REFERENCES "public"."pdr_ai_v2_agent_ai_chatbot_message"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -CREATE INDEX "agent_execution_step_task_step_idx" ON "pdr_ai_v2_agent_ai_chatbot_execution_step" USING btree ("task_id","step_number");--> statement-breakpoint -CREATE INDEX "agent_memory_chat_idx" ON "pdr_ai_v2_agent_ai_chatbot_memory" USING btree ("chat_id");--> statement-breakpoint -CREATE INDEX "agent_memory_chat_type_idx" ON "pdr_ai_v2_agent_ai_chatbot_memory" USING btree ("chat_id","memory_type");--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_users" ADD CONSTRAINT "pdr_ai_v2_users_id_unique" UNIQUE("id"); \ No newline at end of file diff --git a/drizzle/0006_daily_joseph.sql b/drizzle/0006_daily_joseph.sql deleted file mode 100644 index 20f747f1..00000000 --- a/drizzle/0006_daily_joseph.sql +++ /dev/null @@ -1,246 +0,0 @@ -CREATE TABLE "pdr_ai_v2_chatHistory" ( - "id" serial PRIMARY KEY NOT NULL, - "user_id" varchar(256) NOT NULL, - "document_id" bigint NOT NULL, - "document_title" varchar(256) NOT NULL, - "question" text NOT NULL, - "response" text NOT NULL, - "chat_id" varchar(256), - "query_type" varchar(20) DEFAULT 'simple', - "pages" integer[] NOT NULL, - "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "updated_at" timestamp with time zone -); ---> statement-breakpoint -CREATE TABLE "pdr_ai_v2_category" ( - "id" serial PRIMARY KEY NOT NULL, - "name" varchar(256) NOT NULL, - "company_id" bigint NOT NULL, - "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "updated_at" timestamp with time zone -); ---> statement-breakpoint -CREATE TABLE "pdr_ai_v2_company" ( - "id" serial PRIMARY KEY NOT NULL, - "name" varchar(256) NOT NULL, - "employerPasskey" varchar(256) NOT NULL, - "employeePasskey" varchar(256) NOT NULL, - "numberOfEmployees" varchar(256) NOT NULL, - "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "updated_at" timestamp with time zone -); ---> statement-breakpoint -CREATE TABLE "pdr_ai_v2_document" ( - "id" serial PRIMARY KEY NOT NULL, - "url" varchar(256) NOT NULL, - "category" varchar(256) NOT NULL, - "title" varchar(256) NOT NULL, - "company_id" bigint NOT NULL, - "ocr_enabled" boolean DEFAULT false, - "ocr_processed" boolean DEFAULT false, - "ocr_metadata" jsonb, - "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "updated_at" timestamp with time zone -); ---> statement-breakpoint -CREATE TABLE "pdr_ai_v2_document_reference_resolutions" ( - "id" serial PRIMARY KEY NOT NULL, - "company_id" bigint NOT NULL, - "reference_name" varchar(256) NOT NULL, - "resolved_in_document_id" integer, - "resolution_details" jsonb, - "created_at" timestamp with time zone DEFAULT now() NOT NULL -); ---> statement-breakpoint -CREATE TABLE "pdr_ai_v2_pdf_chunks" ( - "id" serial PRIMARY KEY NOT NULL, - "document_id" bigint NOT NULL, - "page" integer NOT NULL, - "chunk_index" integer DEFAULT 0 NOT NULL, - "content" text NOT NULL, - "embedding" vector(1536) -); ---> statement-breakpoint -CREATE TABLE "pdr_ai_v2_predictive_document_analysis_results" ( - "id" serial PRIMARY KEY NOT NULL, - "document_id" bigint NOT NULL, - "analysis_type" varchar(256) NOT NULL, - "include_related_docs" boolean DEFAULT false, - "result_json" jsonb NOT NULL, - "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL -); ---> statement-breakpoint -CREATE TABLE "pdr_ai_v2_users" ( - "id" serial PRIMARY KEY NOT NULL, - "name" varchar(256) NOT NULL, - "email" varchar(256) NOT NULL, - "userId" varchar(256) NOT NULL, - "company_id" bigint NOT NULL, - "role" varchar(256) NOT NULL, - "status" varchar(256) NOT NULL, - "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "updated_at" timestamp with time zone, - CONSTRAINT "pdr_ai_v2_users_id_unique" UNIQUE("id"), - CONSTRAINT "pdr_ai_v2_users_userId_unique" UNIQUE("userId") -); ---> statement-breakpoint -CREATE TABLE "pdr_ai_v2_agent_ai_chatbot_chat" ( - "id" varchar(256) PRIMARY KEY NOT NULL, - "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "title" text NOT NULL, - "user_id" varchar(256) NOT NULL, - "visibility" varchar(20) DEFAULT 'private' NOT NULL, - "agent_mode" varchar(50) DEFAULT 'interactive' NOT NULL, - "status" varchar(50) DEFAULT 'active' NOT NULL, - "ai_style" varchar(50) DEFAULT 'concise', - "ai_persona" varchar(50) DEFAULT 'general', - "updated_at" timestamp with time zone -); ---> statement-breakpoint -CREATE TABLE "pdr_ai_v2_agent_ai_chatbot_document" ( - "id" varchar(256) NOT NULL, - "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "title" text NOT NULL, - "content" text, - "kind" varchar(20) DEFAULT 'text' NOT NULL, - "user_id" varchar(256) NOT NULL, - "chat_id" varchar(256), - "task_id" varchar(256), - CONSTRAINT "pdr_ai_v2_agent_ai_chatbot_document_id_created_at_pk" PRIMARY KEY("id","created_at") -); ---> statement-breakpoint -CREATE TABLE "pdr_ai_v2_agent_ai_chatbot_execution_step" ( - "id" varchar(256) PRIMARY KEY NOT NULL, - "task_id" varchar(256) NOT NULL, - "step_number" integer NOT NULL, - "step_type" varchar(50) NOT NULL, - "description" text NOT NULL, - "reasoning" text, - "input" jsonb, - "output" jsonb, - "status" varchar(50) DEFAULT 'pending' NOT NULL, - "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "completed_at" timestamp with time zone -); ---> statement-breakpoint -CREATE TABLE "pdr_ai_v2_agent_ai_chatbot_memory" ( - "id" varchar(256) PRIMARY KEY NOT NULL, - "chat_id" varchar(256) NOT NULL, - "memory_type" varchar(50) NOT NULL, - "key" varchar(256) NOT NULL, - "value" jsonb NOT NULL, - "importance" integer DEFAULT 5 NOT NULL, - "embedding" vector(1536), - "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "accessed_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "expires_at" timestamp with time zone -); ---> statement-breakpoint -CREATE TABLE "pdr_ai_v2_agent_ai_chatbot_message" ( - "id" varchar(256) PRIMARY KEY NOT NULL, - "chat_id" varchar(256) NOT NULL, - "role" varchar(50) NOT NULL, - "content" jsonb NOT NULL, - "message_type" varchar(50) DEFAULT 'text' NOT NULL, - "parent_message_id" varchar(256), - "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL -); ---> statement-breakpoint -CREATE TABLE "pdr_ai_v2_agent_ai_chatbot_suggestion" ( - "id" varchar(256) PRIMARY KEY NOT NULL, - "document_id" varchar(256) NOT NULL, - "document_created_at" timestamp with time zone NOT NULL, - "original_text" text NOT NULL, - "suggested_text" text NOT NULL, - "description" text, - "is_resolved" boolean DEFAULT false NOT NULL, - "user_id" varchar(256) NOT NULL, - "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL -); ---> statement-breakpoint -CREATE TABLE "pdr_ai_v2_agent_ai_chatbot_task" ( - "id" varchar(256) PRIMARY KEY NOT NULL, - "chat_id" varchar(256) NOT NULL, - "description" text NOT NULL, - "objective" text NOT NULL, - "status" varchar(50) DEFAULT 'pending' NOT NULL, - "priority" integer DEFAULT 0 NOT NULL, - "result" jsonb, - "metadata" jsonb, - "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "completed_at" timestamp with time zone, - "updated_at" timestamp with time zone -); ---> statement-breakpoint -CREATE TABLE "pdr_ai_v2_agent_ai_chatbot_tool_call" ( - "id" varchar(256) PRIMARY KEY NOT NULL, - "message_id" varchar(256) NOT NULL, - "task_id" varchar(256), - "tool_name" varchar(256) NOT NULL, - "tool_input" jsonb NOT NULL, - "tool_output" jsonb, - "status" varchar(50) DEFAULT 'pending' NOT NULL, - "error_message" text, - "execution_time_ms" integer, - "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "completed_at" timestamp with time zone -); ---> statement-breakpoint -CREATE TABLE "pdr_ai_v2_agent_ai_chatbot_tool_registry" ( - "id" varchar(256) PRIMARY KEY NOT NULL, - "name" varchar(256) NOT NULL, - "description" text NOT NULL, - "category" varchar(100) NOT NULL, - "schema" jsonb NOT NULL, - "is_enabled" boolean DEFAULT true NOT NULL, - "required_permissions" jsonb, - "rate_limit" integer, - "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "updated_at" timestamp with time zone, - CONSTRAINT "pdr_ai_v2_agent_ai_chatbot_tool_registry_name_unique" UNIQUE("name") -); ---> statement-breakpoint -CREATE TABLE "pdr_ai_v2_agent_ai_chatbot_vote" ( - "chat_id" varchar(256) NOT NULL, - "message_id" varchar(256) NOT NULL, - "is_upvoted" boolean NOT NULL, - "feedback" text, - "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - CONSTRAINT "pdr_ai_v2_agent_ai_chatbot_vote_chat_id_message_id_pk" PRIMARY KEY("chat_id","message_id") -); ---> statement-breakpoint -ALTER TABLE "pdr_ai_v2_chatHistory" ADD CONSTRAINT "pdr_ai_v2_chatHistory_document_id_pdr_ai_v2_document_id_fk" FOREIGN KEY ("document_id") REFERENCES "public"."pdr_ai_v2_document"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_category" ADD CONSTRAINT "pdr_ai_v2_category_company_id_pdr_ai_v2_company_id_fk" FOREIGN KEY ("company_id") REFERENCES "public"."pdr_ai_v2_company"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_document" ADD CONSTRAINT "pdr_ai_v2_document_company_id_pdr_ai_v2_company_id_fk" FOREIGN KEY ("company_id") REFERENCES "public"."pdr_ai_v2_company"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_document_reference_resolutions" ADD CONSTRAINT "pdr_ai_v2_document_reference_resolutions_company_id_pdr_ai_v2_company_id_fk" FOREIGN KEY ("company_id") REFERENCES "public"."pdr_ai_v2_company"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_pdf_chunks" ADD CONSTRAINT "pdr_ai_v2_pdf_chunks_document_id_pdr_ai_v2_document_id_fk" FOREIGN KEY ("document_id") REFERENCES "public"."pdr_ai_v2_document"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_predictive_document_analysis_results" ADD CONSTRAINT "pdr_ai_v2_predictive_document_analysis_results_document_id_pdr_ai_v2_document_id_fk" FOREIGN KEY ("document_id") REFERENCES "public"."pdr_ai_v2_document"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_users" ADD CONSTRAINT "pdr_ai_v2_users_company_id_pdr_ai_v2_company_id_fk" FOREIGN KEY ("company_id") REFERENCES "public"."pdr_ai_v2_company"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_agent_ai_chatbot_document" ADD CONSTRAINT "pdr_ai_v2_agent_ai_chatbot_document_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk" FOREIGN KEY ("chat_id") REFERENCES "public"."pdr_ai_v2_agent_ai_chatbot_chat"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_agent_ai_chatbot_document" ADD CONSTRAINT "pdr_ai_v2_agent_ai_chatbot_document_task_id_pdr_ai_v2_agent_ai_chatbot_task_id_fk" FOREIGN KEY ("task_id") REFERENCES "public"."pdr_ai_v2_agent_ai_chatbot_task"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_agent_ai_chatbot_execution_step" ADD CONSTRAINT "pdr_ai_v2_agent_ai_chatbot_execution_step_task_id_pdr_ai_v2_agent_ai_chatbot_task_id_fk" FOREIGN KEY ("task_id") REFERENCES "public"."pdr_ai_v2_agent_ai_chatbot_task"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_agent_ai_chatbot_memory" ADD CONSTRAINT "pdr_ai_v2_agent_ai_chatbot_memory_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk" FOREIGN KEY ("chat_id") REFERENCES "public"."pdr_ai_v2_agent_ai_chatbot_chat"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_agent_ai_chatbot_message" ADD CONSTRAINT "pdr_ai_v2_agent_ai_chatbot_message_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk" FOREIGN KEY ("chat_id") REFERENCES "public"."pdr_ai_v2_agent_ai_chatbot_chat"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_agent_ai_chatbot_suggestion" ADD CONSTRAINT "pdr_ai_v2_agent_ai_chatbot_suggestion_document_id_document_created_at_pdr_ai_v2_agent_ai_chatbot_document_id_created_at_fk" FOREIGN KEY ("document_id","document_created_at") REFERENCES "public"."pdr_ai_v2_agent_ai_chatbot_document"("id","created_at") ON DELETE no action ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_agent_ai_chatbot_task" ADD CONSTRAINT "pdr_ai_v2_agent_ai_chatbot_task_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk" FOREIGN KEY ("chat_id") REFERENCES "public"."pdr_ai_v2_agent_ai_chatbot_chat"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_agent_ai_chatbot_tool_call" ADD CONSTRAINT "pdr_ai_v2_agent_ai_chatbot_tool_call_message_id_pdr_ai_v2_agent_ai_chatbot_message_id_fk" FOREIGN KEY ("message_id") REFERENCES "public"."pdr_ai_v2_agent_ai_chatbot_message"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_agent_ai_chatbot_tool_call" ADD CONSTRAINT "pdr_ai_v2_agent_ai_chatbot_tool_call_task_id_pdr_ai_v2_agent_ai_chatbot_task_id_fk" FOREIGN KEY ("task_id") REFERENCES "public"."pdr_ai_v2_agent_ai_chatbot_task"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_agent_ai_chatbot_vote" ADD CONSTRAINT "pdr_ai_v2_agent_ai_chatbot_vote_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk" FOREIGN KEY ("chat_id") REFERENCES "public"."pdr_ai_v2_agent_ai_chatbot_chat"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_agent_ai_chatbot_vote" ADD CONSTRAINT "pdr_ai_v2_agent_ai_chatbot_vote_message_id_pdr_ai_v2_agent_ai_chatbot_message_id_fk" FOREIGN KEY ("message_id") REFERENCES "public"."pdr_ai_v2_agent_ai_chatbot_message"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -CREATE INDEX "chat_history_user_id_idx" ON "pdr_ai_v2_chatHistory" USING btree ("user_id");--> statement-breakpoint -CREATE INDEX "chat_history_user_id_created_at_idx" ON "pdr_ai_v2_chatHistory" USING btree ("user_id","created_at");--> statement-breakpoint -CREATE INDEX "chat_history_document_id_idx" ON "pdr_ai_v2_chatHistory" USING btree ("document_id");--> statement-breakpoint -CREATE INDEX "category_company_id_idx" ON "pdr_ai_v2_category" USING btree ("company_id");--> statement-breakpoint -CREATE INDEX "document_company_id_idx" ON "pdr_ai_v2_document" USING btree ("company_id");--> statement-breakpoint -CREATE INDEX "document_company_id_id_idx" ON "pdr_ai_v2_document" USING btree ("company_id","id");--> statement-breakpoint -CREATE INDEX "document_company_id_category_idx" ON "pdr_ai_v2_document" USING btree ("company_id","category");--> statement-breakpoint -CREATE INDEX "document_reference_resolutions_company_ref_idx" ON "pdr_ai_v2_document_reference_resolutions" USING btree ("company_id");--> statement-breakpoint -CREATE INDEX "pdf_chunks_document_id_idx" ON "pdr_ai_v2_pdf_chunks" USING btree ("document_id");--> statement-breakpoint -CREATE INDEX "pdf_chunks_document_id_page_idx" ON "pdr_ai_v2_pdf_chunks" USING btree ("document_id","page");--> statement-breakpoint -CREATE INDEX "pdf_chunks_document_id_page_chunk_idx" ON "pdr_ai_v2_pdf_chunks" USING btree ("document_id","page","chunk_index");--> statement-breakpoint -CREATE INDEX "predictive_analysis_document_id_idx" ON "pdr_ai_v2_predictive_document_analysis_results" USING btree ("document_id");--> statement-breakpoint -CREATE INDEX "users_company_id_idx" ON "pdr_ai_v2_users" USING btree ("company_id");--> statement-breakpoint -CREATE INDEX "users_user_id_idx" ON "pdr_ai_v2_users" USING btree ("userId");--> statement-breakpoint -CREATE INDEX "agent_execution_step_task_step_idx" ON "pdr_ai_v2_agent_ai_chatbot_execution_step" USING btree ("task_id","step_number");--> statement-breakpoint -CREATE INDEX "agent_memory_chat_idx" ON "pdr_ai_v2_agent_ai_chatbot_memory" USING btree ("chat_id");--> statement-breakpoint -CREATE INDEX "agent_memory_chat_type_idx" ON "pdr_ai_v2_agent_ai_chatbot_memory" USING btree ("chat_id","memory_type"); \ No newline at end of file diff --git a/drizzle/0007_plain_leader.sql b/drizzle/0007_plain_leader.sql deleted file mode 100644 index 2d500b02..00000000 --- a/drizzle/0007_plain_leader.sql +++ /dev/null @@ -1,19 +0,0 @@ -CREATE TABLE "pdr_ai_v2_chat_history" ( - "id" serial PRIMARY KEY NOT NULL, - "user_id" varchar(256) NOT NULL, - "document_id" bigint NOT NULL, - "document_title" varchar(256) NOT NULL, - "question" text NOT NULL, - "response" text NOT NULL, - "chat_id" varchar(256), - "query_type" varchar(20) DEFAULT 'simple', - "pages" integer[] NOT NULL, - "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "updated_at" timestamp with time zone -); ---> statement-breakpoint -DROP TABLE "pdr_ai_v2_chatHistory" CASCADE;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_chat_history" ADD CONSTRAINT "pdr_ai_v2_chat_history_document_id_pdr_ai_v2_document_id_fk" FOREIGN KEY ("document_id") REFERENCES "public"."pdr_ai_v2_document"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -CREATE INDEX "chat_history_user_id_idx" ON "pdr_ai_v2_chat_history" USING btree ("user_id");--> statement-breakpoint -CREATE INDEX "chat_history_user_id_created_at_idx" ON "pdr_ai_v2_chat_history" USING btree ("user_id","created_at");--> statement-breakpoint -CREATE INDEX "chat_history_document_id_idx" ON "pdr_ai_v2_chat_history" USING btree ("document_id"); \ No newline at end of file diff --git a/drizzle/0008_nappy_mandarin.sql b/drizzle/0008_nappy_mandarin.sql deleted file mode 100644 index 32c0a035..00000000 --- a/drizzle/0008_nappy_mandarin.sql +++ /dev/null @@ -1,84 +0,0 @@ -CREATE TABLE "pdr_ai_v2_study_agent_goals" ( - "id" serial PRIMARY KEY NOT NULL, - "user_id" varchar(256) NOT NULL, - "session_id" bigint NOT NULL, - "title" text NOT NULL, - "description" text, - "materials" text[] DEFAULT '{}', - "completed" boolean DEFAULT false NOT NULL, - "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "updated_at" timestamp with time zone -); ---> statement-breakpoint -CREATE TABLE "pdr_ai_v2_study_agent_notes" ( - "id" serial PRIMARY KEY NOT NULL, - "user_id" varchar(256) NOT NULL, - "session_id" bigint NOT NULL, - "title" text, - "content" text, - "tags" text[] DEFAULT '{}', - "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "updated_at" timestamp with time zone -); ---> statement-breakpoint -CREATE TABLE "pdr_ai_v2_study_agent_pomodoro_settings" ( - "id" serial PRIMARY KEY NOT NULL, - "user_id" varchar(256) NOT NULL, - "session_id" bigint NOT NULL, - "focus_minutes" integer DEFAULT 25 NOT NULL, - "short_break_minutes" integer DEFAULT 5 NOT NULL, - "long_break_minutes" integer DEFAULT 15 NOT NULL, - "remaining_time" integer DEFAULT 0 NOT NULL, - "sessions_before_long_break" integer DEFAULT 4 NOT NULL, - "auto_start_breaks" boolean DEFAULT false NOT NULL, - "auto_start_pomodoros" boolean DEFAULT false NOT NULL, - "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "updated_at" timestamp with time zone -); ---> statement-breakpoint -CREATE TABLE "pdr_ai_v2_study_agent_preferences" ( - "id" serial PRIMARY KEY NOT NULL, - "user_id" varchar(256) NOT NULL, - "session_id" bigint NOT NULL, - "preferences" jsonb DEFAULT '{}'::jsonb NOT NULL, - "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "updated_at" timestamp with time zone -); ---> statement-breakpoint -CREATE TABLE "pdr_ai_v2_study_agent_profile" ( - "id" serial PRIMARY KEY NOT NULL, - "user_id" varchar(256) NOT NULL, - "session_id" bigint NOT NULL, - "name" text, - "grade" text, - "gender" text, - "field_of_study" text, - "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "updated_at" timestamp with time zone -); ---> statement-breakpoint -CREATE TABLE "pdr_ai_v2_study_agent_sessions" ( - "id" serial PRIMARY KEY NOT NULL, - "user_id" varchar(256) NOT NULL, - "name" text DEFAULT 'Default Session' NOT NULL, - "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "updated_at" timestamp with time zone -); ---> statement-breakpoint -ALTER TABLE "pdr_ai_v2_users" DROP CONSTRAINT "pdr_ai_v2_users_id_unique";--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_study_agent_goals" ADD CONSTRAINT "pdr_ai_v2_study_agent_goals_session_id_pdr_ai_v2_study_agent_sessions_id_fk" FOREIGN KEY ("session_id") REFERENCES "public"."pdr_ai_v2_study_agent_sessions"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_study_agent_notes" ADD CONSTRAINT "pdr_ai_v2_study_agent_notes_session_id_pdr_ai_v2_study_agent_sessions_id_fk" FOREIGN KEY ("session_id") REFERENCES "public"."pdr_ai_v2_study_agent_sessions"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_study_agent_pomodoro_settings" ADD CONSTRAINT "pdr_ai_v2_study_agent_pomodoro_settings_session_id_pdr_ai_v2_study_agent_sessions_id_fk" FOREIGN KEY ("session_id") REFERENCES "public"."pdr_ai_v2_study_agent_sessions"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_study_agent_preferences" ADD CONSTRAINT "pdr_ai_v2_study_agent_preferences_session_id_pdr_ai_v2_study_agent_sessions_id_fk" FOREIGN KEY ("session_id") REFERENCES "public"."pdr_ai_v2_study_agent_sessions"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_study_agent_profile" ADD CONSTRAINT "pdr_ai_v2_study_agent_profile_session_id_pdr_ai_v2_study_agent_sessions_id_fk" FOREIGN KEY ("session_id") REFERENCES "public"."pdr_ai_v2_study_agent_sessions"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -CREATE INDEX "study_agent_goals_user_idx" ON "pdr_ai_v2_study_agent_goals" USING btree ("user_id");--> statement-breakpoint -CREATE INDEX "study_agent_goals_session_idx" ON "pdr_ai_v2_study_agent_goals" USING btree ("session_id");--> statement-breakpoint -CREATE INDEX "study_agent_notes_user_idx" ON "pdr_ai_v2_study_agent_notes" USING btree ("user_id");--> statement-breakpoint -CREATE INDEX "study_agent_notes_session_idx" ON "pdr_ai_v2_study_agent_notes" USING btree ("session_id");--> statement-breakpoint -CREATE INDEX "study_agent_pomodoro_settings_user_idx" ON "pdr_ai_v2_study_agent_pomodoro_settings" USING btree ("user_id");--> statement-breakpoint -CREATE INDEX "study_agent_pomodoro_settings_session_idx" ON "pdr_ai_v2_study_agent_pomodoro_settings" USING btree ("session_id");--> statement-breakpoint -CREATE INDEX "study_agent_preferences_user_idx" ON "pdr_ai_v2_study_agent_preferences" USING btree ("user_id");--> statement-breakpoint -CREATE INDEX "study_agent_preferences_session_idx" ON "pdr_ai_v2_study_agent_preferences" USING btree ("session_id");--> statement-breakpoint -CREATE INDEX "study_agent_profile_user_idx" ON "pdr_ai_v2_study_agent_profile" USING btree ("user_id");--> statement-breakpoint -CREATE INDEX "study_agent_profile_session_idx" ON "pdr_ai_v2_study_agent_profile" USING btree ("session_id");--> statement-breakpoint -CREATE INDEX "study_agent_sessions_user_idx" ON "pdr_ai_v2_study_agent_sessions" USING btree ("user_id"); \ No newline at end of file diff --git a/drizzle/0009_public_warstar.sql b/drizzle/0009_public_warstar.sql deleted file mode 100644 index 607626a0..00000000 --- a/drizzle/0009_public_warstar.sql +++ /dev/null @@ -1,18 +0,0 @@ -CREATE TABLE "pdr_ai_v2_study_agent_messages" ( - "id" serial PRIMARY KEY NOT NULL, - "original_id" varchar(64), - "user_id" varchar(256) NOT NULL, - "session_id" bigint NOT NULL, - "role" varchar(32) NOT NULL, - "content" text NOT NULL, - "tts_content" text, - "attached_document" text, - "attached_document_id" text, - "attached_document_url" text, - "is_voice" boolean DEFAULT false, - "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL -); ---> statement-breakpoint -ALTER TABLE "pdr_ai_v2_study_agent_messages" ADD CONSTRAINT "pdr_ai_v2_study_agent_messages_session_id_pdr_ai_v2_study_agent_sessions_id_fk" FOREIGN KEY ("session_id") REFERENCES "public"."pdr_ai_v2_study_agent_sessions"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -CREATE INDEX "study_agent_messages_user_id_idx" ON "pdr_ai_v2_study_agent_messages" USING btree ("user_id");--> statement-breakpoint -CREATE INDEX "study_agent_messages_session_id_idx" ON "pdr_ai_v2_study_agent_messages" USING btree ("session_id"); \ No newline at end of file diff --git a/drizzle/0010_add_session_mode.sql b/drizzle/0010_add_session_mode.sql deleted file mode 100644 index b4874acf..00000000 --- a/drizzle/0010_add_session_mode.sql +++ /dev/null @@ -1,3 +0,0 @@ --- Add mode column to study_agent_sessions table -ALTER TABLE "study_agent_sessions" ADD COLUMN "mode" varchar(32) NOT NULL DEFAULT 'teacher'; - diff --git a/drizzle/0011_large_pet_avengers.sql b/drizzle/0011_large_pet_avengers.sql deleted file mode 100644 index 62be118d..00000000 --- a/drizzle/0011_large_pet_avengers.sql +++ /dev/null @@ -1,17 +0,0 @@ -ALTER TABLE "pdr_ai_v2_study_agent_preferences" ADD COLUMN "selected_documents" text[] DEFAULT '{}' NOT NULL;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_study_agent_preferences" ADD COLUMN "user_name" text;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_study_agent_preferences" ADD COLUMN "user_grade" text;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_study_agent_preferences" ADD COLUMN "user_gender" text;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_study_agent_preferences" ADD COLUMN "field_of_study" text;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_study_agent_profile" ADD COLUMN "ai_name" text;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_study_agent_profile" ADD COLUMN "ai_gender" text;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_study_agent_profile" ADD COLUMN "ai_extroversion" integer;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_study_agent_profile" ADD COLUMN "ai_intuition" integer;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_study_agent_profile" ADD COLUMN "ai_thinking" integer;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_study_agent_profile" ADD COLUMN "ai_judging" integer;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_study_agent_sessions" ADD COLUMN "mode" varchar(32) DEFAULT 'teacher' NOT NULL;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_study_agent_preferences" DROP COLUMN "preferences";--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_study_agent_profile" DROP COLUMN "name";--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_study_agent_profile" DROP COLUMN "grade";--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_study_agent_profile" DROP COLUMN "gender";--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_study_agent_profile" DROP COLUMN "field_of_study"; \ No newline at end of file diff --git a/drizzle/0012_foamy_the_phantom.sql b/drizzle/0012_foamy_the_phantom.sql deleted file mode 100644 index 65b12e8e..00000000 --- a/drizzle/0012_foamy_the_phantom.sql +++ /dev/null @@ -1,206 +0,0 @@ -CREATE TABLE "pdr_ai_v2_ocr_cost_tracking" ( - "id" serial PRIMARY KEY NOT NULL, - "company_id" bigint NOT NULL, - "provider" varchar(50) NOT NULL, - "month" varchar(7) NOT NULL, - "total_jobs" integer DEFAULT 0 NOT NULL, - "total_pages" integer DEFAULT 0 NOT NULL, - "total_cost_cents" integer DEFAULT 0 NOT NULL, - "average_cost_per_page" integer DEFAULT 0 NOT NULL, - "average_confidence_score" integer DEFAULT 0 NOT NULL, - "updated_at" timestamp with time zone -); ---> statement-breakpoint -CREATE TABLE "pdr_ai_v2_ocr_jobs" ( - "id" varchar(256) PRIMARY KEY NOT NULL, - "document_id" bigint, - "company_id" bigint NOT NULL, - "user_id" varchar(256) NOT NULL, - "status" varchar(50) DEFAULT 'queued' NOT NULL, - "document_url" varchar(1024) NOT NULL, - "document_name" varchar(256) NOT NULL, - "page_count" integer, - "file_size_bytes" bigint, - "complexity_score" integer, - "document_type" varchar(50), - "primary_provider" varchar(50), - "actual_provider" varchar(50), - "estimated_cost_cents" integer, - "actual_cost_cents" integer, - "confidence_score" integer, - "quality_flags" jsonb, - "requires_review" boolean DEFAULT false, - "started_at" timestamp with time zone, - "completed_at" timestamp with time zone, - "processing_duration_ms" integer, - "ocr_result" jsonb, - "error_message" text, - "retry_count" integer DEFAULT 0, - "webhook_url" varchar(1024), - "webhook_status" varchar(20), - "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "updated_at" timestamp with time zone -); ---> statement-breakpoint -CREATE TABLE "pdr_ai_v2_ocr_processing_steps" ( - "id" varchar(256) PRIMARY KEY NOT NULL, - "job_id" varchar(256) NOT NULL, - "step_number" integer NOT NULL, - "step_type" varchar(50) NOT NULL, - "status" varchar(20) DEFAULT 'pending' NOT NULL, - "input" jsonb, - "output" jsonb, - "error_message" text, - "duration_ms" integer, - "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL -); ---> statement-breakpoint -CREATE TABLE "pdr_ai_v2_document_metadata" ( - "id" serial PRIMARY KEY NOT NULL, - "document_id" bigint NOT NULL, - "total_tokens" integer DEFAULT 0, - "total_sections" integer DEFAULT 0, - "total_tables" integer DEFAULT 0, - "total_figures" integer DEFAULT 0, - "total_pages" integer DEFAULT 0, - "max_section_depth" integer DEFAULT 0, - "topic_tags" jsonb, - "summary" text, - "outline" jsonb, - "complexity_score" integer, - "document_class" varchar(50), - "entities" jsonb, - "summary_embedding" vector(1536), - "date_range_start" timestamp with time zone, - "date_range_end" timestamp with time zone, - "language" varchar(10) DEFAULT 'en', - "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "updated_at" timestamp with time zone -); ---> statement-breakpoint -CREATE TABLE "pdr_ai_v2_document_previews" ( - "id" serial PRIMARY KEY NOT NULL, - "document_id" bigint NOT NULL, - "section_id" bigint, - "structure_id" bigint, - "preview_type" varchar(50) NOT NULL, - "content" text NOT NULL, - "token_count" integer DEFAULT 0 NOT NULL, - "embedding" vector(1536), - "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL -); ---> statement-breakpoint -CREATE TABLE "pdr_ai_v2_document_sections" ( - "id" serial PRIMARY KEY NOT NULL, - "document_id" bigint NOT NULL, - "structure_id" bigint, - "content" text NOT NULL, - "token_count" integer DEFAULT 0 NOT NULL, - "char_count" integer DEFAULT 0 NOT NULL, - "embedding" vector(1536), - "content_hash" varchar(64), - "semantic_type" varchar(50), - "page_number" integer, - "line_start" integer, - "line_end" integer, - "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "updated_at" timestamp with time zone -); ---> statement-breakpoint -CREATE TABLE "pdr_ai_v2_document_structure" ( - "id" serial PRIMARY KEY NOT NULL, - "document_id" bigint NOT NULL, - "parent_id" bigint, - "level" integer DEFAULT 0 NOT NULL, - "ordering" integer DEFAULT 0 NOT NULL, - "title" text, - "content_type" varchar(50) DEFAULT 'section' NOT NULL, - "path" varchar(256), - "start_page" integer, - "end_page" integer, - "child_count" integer DEFAULT 0 NOT NULL, - "token_count" integer DEFAULT 0, - "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "updated_at" timestamp with time zone -); ---> statement-breakpoint -CREATE TABLE "pdr_ai_v2_workspace_results" ( - "id" serial PRIMARY KEY NOT NULL, - "session_id" varchar(256) NOT NULL, - "user_id" varchar(256) NOT NULL, - "company_id" bigint NOT NULL, - "document_id" bigint, - "section_id" bigint, - "structure_id" bigint, - "result_type" varchar(50) NOT NULL, - "content" text NOT NULL, - "metadata" jsonb, - "status" varchar(20) DEFAULT 'pending' NOT NULL, - "parent_result_id" bigint, - "expires_at" timestamp with time zone, - "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, - "updated_at" timestamp with time zone -); ---> statement-breakpoint -ALTER TABLE "pdr_ai_v2_document" ADD COLUMN "ocr_job_id" varchar(256);--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_document" ADD COLUMN "ocr_provider" varchar(50);--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_document" ADD COLUMN "ocr_confidence_score" integer;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_document" ADD COLUMN "ocr_cost_cents" integer;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_study_agent_pomodoro_settings" ADD COLUMN "phase" text DEFAULT 'idle' NOT NULL;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_study_agent_pomodoro_settings" ADD COLUMN "is_running" boolean DEFAULT false NOT NULL;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_study_agent_pomodoro_settings" ADD COLUMN "is_paused" boolean DEFAULT false NOT NULL;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_study_agent_pomodoro_settings" ADD COLUMN "started_at" timestamp with time zone;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_study_agent_pomodoro_settings" ADD COLUMN "paused_at" timestamp with time zone;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_study_agent_pomodoro_settings" ADD COLUMN "ends_at" timestamp with time zone;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_study_agent_pomodoro_settings" ADD COLUMN "completed_pomodoros" integer DEFAULT 0 NOT NULL;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_study_agent_pomodoro_settings" ADD COLUMN "total_work_minutes" integer DEFAULT 0 NOT NULL;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_study_agent_pomodoro_settings" ADD COLUMN "current_task_id" text;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_study_agent_profile" ADD COLUMN "ai_avatar_url" text;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_ocr_cost_tracking" ADD CONSTRAINT "pdr_ai_v2_ocr_cost_tracking_company_id_pdr_ai_v2_company_id_fk" FOREIGN KEY ("company_id") REFERENCES "public"."pdr_ai_v2_company"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_ocr_jobs" ADD CONSTRAINT "pdr_ai_v2_ocr_jobs_document_id_pdr_ai_v2_document_id_fk" FOREIGN KEY ("document_id") REFERENCES "public"."pdr_ai_v2_document"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_ocr_jobs" ADD CONSTRAINT "pdr_ai_v2_ocr_jobs_company_id_pdr_ai_v2_company_id_fk" FOREIGN KEY ("company_id") REFERENCES "public"."pdr_ai_v2_company"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_ocr_processing_steps" ADD CONSTRAINT "pdr_ai_v2_ocr_processing_steps_job_id_pdr_ai_v2_ocr_jobs_id_fk" FOREIGN KEY ("job_id") REFERENCES "public"."pdr_ai_v2_ocr_jobs"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_document_metadata" ADD CONSTRAINT "pdr_ai_v2_document_metadata_document_id_pdr_ai_v2_document_id_fk" FOREIGN KEY ("document_id") REFERENCES "public"."pdr_ai_v2_document"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_document_previews" ADD CONSTRAINT "pdr_ai_v2_document_previews_document_id_pdr_ai_v2_document_id_fk" FOREIGN KEY ("document_id") REFERENCES "public"."pdr_ai_v2_document"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_document_previews" ADD CONSTRAINT "pdr_ai_v2_document_previews_section_id_pdr_ai_v2_document_sections_id_fk" FOREIGN KEY ("section_id") REFERENCES "public"."pdr_ai_v2_document_sections"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_document_previews" ADD CONSTRAINT "pdr_ai_v2_document_previews_structure_id_pdr_ai_v2_document_structure_id_fk" FOREIGN KEY ("structure_id") REFERENCES "public"."pdr_ai_v2_document_structure"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_document_sections" ADD CONSTRAINT "pdr_ai_v2_document_sections_document_id_pdr_ai_v2_document_id_fk" FOREIGN KEY ("document_id") REFERENCES "public"."pdr_ai_v2_document"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_document_sections" ADD CONSTRAINT "pdr_ai_v2_document_sections_structure_id_pdr_ai_v2_document_structure_id_fk" FOREIGN KEY ("structure_id") REFERENCES "public"."pdr_ai_v2_document_structure"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_document_structure" ADD CONSTRAINT "pdr_ai_v2_document_structure_document_id_pdr_ai_v2_document_id_fk" FOREIGN KEY ("document_id") REFERENCES "public"."pdr_ai_v2_document"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_workspace_results" ADD CONSTRAINT "pdr_ai_v2_workspace_results_company_id_pdr_ai_v2_company_id_fk" FOREIGN KEY ("company_id") REFERENCES "public"."pdr_ai_v2_company"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_workspace_results" ADD CONSTRAINT "pdr_ai_v2_workspace_results_document_id_pdr_ai_v2_document_id_fk" FOREIGN KEY ("document_id") REFERENCES "public"."pdr_ai_v2_document"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_workspace_results" ADD CONSTRAINT "pdr_ai_v2_workspace_results_section_id_pdr_ai_v2_document_sections_id_fk" FOREIGN KEY ("section_id") REFERENCES "public"."pdr_ai_v2_document_sections"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -ALTER TABLE "pdr_ai_v2_workspace_results" ADD CONSTRAINT "pdr_ai_v2_workspace_results_structure_id_pdr_ai_v2_document_structure_id_fk" FOREIGN KEY ("structure_id") REFERENCES "public"."pdr_ai_v2_document_structure"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint -CREATE INDEX "ocr_cost_tracking_company_provider_month_idx" ON "pdr_ai_v2_ocr_cost_tracking" USING btree ("company_id","provider","month");--> statement-breakpoint -CREATE INDEX "ocr_jobs_company_id_idx" ON "pdr_ai_v2_ocr_jobs" USING btree ("company_id");--> statement-breakpoint -CREATE INDEX "ocr_jobs_user_id_idx" ON "pdr_ai_v2_ocr_jobs" USING btree ("user_id");--> statement-breakpoint -CREATE INDEX "ocr_jobs_status_idx" ON "pdr_ai_v2_ocr_jobs" USING btree ("status");--> statement-breakpoint -CREATE INDEX "ocr_jobs_created_at_idx" ON "pdr_ai_v2_ocr_jobs" USING btree ("created_at");--> statement-breakpoint -CREATE INDEX "ocr_jobs_company_status_idx" ON "pdr_ai_v2_ocr_jobs" USING btree ("company_id","status");--> statement-breakpoint -CREATE INDEX "ocr_processing_steps_job_id_idx" ON "pdr_ai_v2_ocr_processing_steps" USING btree ("job_id");--> statement-breakpoint -CREATE INDEX "ocr_processing_steps_job_id_step_idx" ON "pdr_ai_v2_ocr_processing_steps" USING btree ("job_id","step_number");--> statement-breakpoint -CREATE UNIQUE INDEX "doc_metadata_document_id_unique" ON "pdr_ai_v2_document_metadata" USING btree ("document_id");--> statement-breakpoint -CREATE INDEX "doc_metadata_complexity_idx" ON "pdr_ai_v2_document_metadata" USING btree ("complexity_score");--> statement-breakpoint -CREATE INDEX "doc_metadata_class_idx" ON "pdr_ai_v2_document_metadata" USING btree ("document_class");--> statement-breakpoint -CREATE INDEX "doc_metadata_total_tokens_idx" ON "pdr_ai_v2_document_metadata" USING btree ("total_tokens");--> statement-breakpoint -CREATE INDEX "doc_previews_document_id_idx" ON "pdr_ai_v2_document_previews" USING btree ("document_id");--> statement-breakpoint -CREATE INDEX "doc_previews_section_id_idx" ON "pdr_ai_v2_document_previews" USING btree ("section_id");--> statement-breakpoint -CREATE INDEX "doc_previews_document_type_idx" ON "pdr_ai_v2_document_previews" USING btree ("document_id","preview_type");--> statement-breakpoint -CREATE INDEX "doc_sections_document_id_idx" ON "pdr_ai_v2_document_sections" USING btree ("document_id");--> statement-breakpoint -CREATE INDEX "doc_sections_structure_id_idx" ON "pdr_ai_v2_document_sections" USING btree ("structure_id");--> statement-breakpoint -CREATE INDEX "doc_sections_document_page_idx" ON "pdr_ai_v2_document_sections" USING btree ("document_id","page_number");--> statement-breakpoint -CREATE INDEX "doc_sections_content_hash_idx" ON "pdr_ai_v2_document_sections" USING btree ("content_hash");--> statement-breakpoint -CREATE INDEX "doc_sections_semantic_type_idx" ON "pdr_ai_v2_document_sections" USING btree ("document_id","semantic_type");--> statement-breakpoint -CREATE INDEX "doc_structure_document_id_idx" ON "pdr_ai_v2_document_structure" USING btree ("document_id");--> statement-breakpoint -CREATE INDEX "doc_structure_parent_id_idx" ON "pdr_ai_v2_document_structure" USING btree ("parent_id");--> statement-breakpoint -CREATE INDEX "doc_structure_document_level_idx" ON "pdr_ai_v2_document_structure" USING btree ("document_id","level");--> statement-breakpoint -CREATE INDEX "doc_structure_document_path_idx" ON "pdr_ai_v2_document_structure" USING btree ("document_id","path");--> statement-breakpoint -CREATE INDEX "doc_structure_document_ordering_idx" ON "pdr_ai_v2_document_structure" USING btree ("document_id","parent_id","ordering");--> statement-breakpoint -CREATE INDEX "workspace_session_id_idx" ON "pdr_ai_v2_workspace_results" USING btree ("session_id");--> statement-breakpoint -CREATE INDEX "workspace_user_id_idx" ON "pdr_ai_v2_workspace_results" USING btree ("user_id");--> statement-breakpoint -CREATE INDEX "workspace_company_id_idx" ON "pdr_ai_v2_workspace_results" USING btree ("company_id");--> statement-breakpoint -CREATE INDEX "workspace_document_id_idx" ON "pdr_ai_v2_workspace_results" USING btree ("document_id");--> statement-breakpoint -CREATE INDEX "workspace_session_type_idx" ON "pdr_ai_v2_workspace_results" USING btree ("session_id","result_type");--> statement-breakpoint -CREATE INDEX "workspace_status_idx" ON "pdr_ai_v2_workspace_results" USING btree ("status");--> statement-breakpoint -CREATE INDEX "workspace_expires_at_idx" ON "pdr_ai_v2_workspace_results" USING btree ("expires_at");--> statement-breakpoint -CREATE INDEX "workspace_parent_result_idx" ON "pdr_ai_v2_workspace_results" USING btree ("parent_result_id"); \ No newline at end of file diff --git a/drizzle/0013_file_uploads.sql b/drizzle/0013_file_uploads.sql deleted file mode 100644 index 71183868..00000000 --- a/drizzle/0013_file_uploads.sql +++ /dev/null @@ -1,16 +0,0 @@ --- Migration: Add file_uploads table for local file storage when UploadThing is disabled --- This table stores uploaded files as base64-encoded text data in the database - -CREATE TABLE IF NOT EXISTS "file_uploads" ( - "id" SERIAL PRIMARY KEY, - "user_id" VARCHAR(256) NOT NULL, - "filename" VARCHAR(256) NOT NULL, - "mime_type" VARCHAR(128) NOT NULL, - "file_data" TEXT NOT NULL, - "file_size" INTEGER NOT NULL, - "created_at" TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP NOT NULL -); - --- Index for faster lookups by user -CREATE INDEX IF NOT EXISTS "file_uploads_user_id_idx" ON "file_uploads" ("user_id"); - diff --git a/drizzle/0014_company_upload_preference.sql b/drizzle/0014_company_upload_preference.sql deleted file mode 100644 index 05327216..00000000 --- a/drizzle/0014_company_upload_preference.sql +++ /dev/null @@ -1,5 +0,0 @@ --- Migration: Add use_uploadthing column to company table --- This allows per-company configuration of upload storage method - -ALTER TABLE "company" ADD COLUMN IF NOT EXISTS "use_uploadthing" BOOLEAN NOT NULL DEFAULT true; - diff --git a/drizzle/0015_generated_documents.sql b/drizzle/0015_generated_documents.sql deleted file mode 100644 index d76ef91f..00000000 --- a/drizzle/0015_generated_documents.sql +++ /dev/null @@ -1,20 +0,0 @@ --- Migration: Add generated_documents table for Document Generator feature --- This table stores AI-generated documents with their metadata and citations - -CREATE TABLE IF NOT EXISTS "pdr_ai_v2_generated_documents" ( - "id" SERIAL PRIMARY KEY, - "user_id" VARCHAR(256) NOT NULL, - "company_id" BIGINT NOT NULL REFERENCES "pdr_ai_v2_company"("id") ON DELETE CASCADE, - "title" VARCHAR(512) NOT NULL, - "content" TEXT NOT NULL, - "template_id" VARCHAR(64), - "metadata" JSONB, - "citations" JSONB, - "created_at" TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL, - "updated_at" TIMESTAMP WITH TIME ZONE -); - --- Create indexes for efficient queries -CREATE INDEX IF NOT EXISTS "generated_documents_user_id_idx" ON "pdr_ai_v2_generated_documents" ("user_id"); -CREATE INDEX IF NOT EXISTS "generated_documents_company_id_idx" ON "pdr_ai_v2_generated_documents" ("company_id"); -CREATE INDEX IF NOT EXISTS "generated_documents_company_user_idx" ON "pdr_ai_v2_generated_documents" ("company_id", "user_id"); diff --git a/drizzle/meta/0006_snapshot.json b/drizzle/meta/0006_snapshot.json deleted file mode 100644 index 4d4760bd..00000000 --- a/drizzle/meta/0006_snapshot.json +++ /dev/null @@ -1,1804 +0,0 @@ -{ - "id": "a3e3b8e3-0c8c-47d7-9a8e-0ce0f5b9e59c", - "prevId": "00000000-0000-0000-0000-000000000000", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.pdr_ai_v2_chatHistory": { - "name": "pdr_ai_v2_chatHistory", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "document_id": { - "name": "document_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "document_title": { - "name": "document_title", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "question": { - "name": "question", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "response": { - "name": "response", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "chat_id": { - "name": "chat_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": false - }, - "query_type": { - "name": "query_type", - "type": "varchar(20)", - "primaryKey": false, - "notNull": false, - "default": "'simple'" - }, - "pages": { - "name": "pages", - "type": "integer[]", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "chat_history_user_id_idx": { - "name": "chat_history_user_id_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "chat_history_user_id_created_at_idx": { - "name": "chat_history_user_id_created_at_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "chat_history_document_id_idx": { - "name": "chat_history_document_id_idx", - "columns": [ - { - "expression": "document_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_chatHistory_document_id_pdr_ai_v2_document_id_fk": { - "name": "pdr_ai_v2_chatHistory_document_id_pdr_ai_v2_document_id_fk", - "tableFrom": "pdr_ai_v2_chatHistory", - "tableTo": "pdr_ai_v2_document", - "columnsFrom": [ - "document_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_category": { - "name": "pdr_ai_v2_category", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "company_id": { - "name": "company_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "category_company_id_idx": { - "name": "category_company_id_idx", - "columns": [ - { - "expression": "company_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_category_company_id_pdr_ai_v2_company_id_fk": { - "name": "pdr_ai_v2_category_company_id_pdr_ai_v2_company_id_fk", - "tableFrom": "pdr_ai_v2_category", - "tableTo": "pdr_ai_v2_company", - "columnsFrom": [ - "company_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_company": { - "name": "pdr_ai_v2_company", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "employerPasskey": { - "name": "employerPasskey", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "employeePasskey": { - "name": "employeePasskey", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "numberOfEmployees": { - "name": "numberOfEmployees", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_document": { - "name": "pdr_ai_v2_document", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "url": { - "name": "url", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "company_id": { - "name": "company_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "ocr_enabled": { - "name": "ocr_enabled", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "default": false - }, - "ocr_processed": { - "name": "ocr_processed", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "default": false - }, - "ocr_metadata": { - "name": "ocr_metadata", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "document_company_id_idx": { - "name": "document_company_id_idx", - "columns": [ - { - "expression": "company_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "document_company_id_id_idx": { - "name": "document_company_id_id_idx", - "columns": [ - { - "expression": "company_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "document_company_id_category_idx": { - "name": "document_company_id_category_idx", - "columns": [ - { - "expression": "company_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "category", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_document_company_id_pdr_ai_v2_company_id_fk": { - "name": "pdr_ai_v2_document_company_id_pdr_ai_v2_company_id_fk", - "tableFrom": "pdr_ai_v2_document", - "tableTo": "pdr_ai_v2_company", - "columnsFrom": [ - "company_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_document_reference_resolutions": { - "name": "pdr_ai_v2_document_reference_resolutions", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "company_id": { - "name": "company_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "reference_name": { - "name": "reference_name", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "resolved_in_document_id": { - "name": "resolved_in_document_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "resolution_details": { - "name": "resolution_details", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "document_reference_resolutions_company_ref_idx": { - "name": "document_reference_resolutions_company_ref_idx", - "columns": [ - { - "expression": "company_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_document_reference_resolutions_company_id_pdr_ai_v2_company_id_fk": { - "name": "pdr_ai_v2_document_reference_resolutions_company_id_pdr_ai_v2_company_id_fk", - "tableFrom": "pdr_ai_v2_document_reference_resolutions", - "tableTo": "pdr_ai_v2_company", - "columnsFrom": [ - "company_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_pdf_chunks": { - "name": "pdr_ai_v2_pdf_chunks", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "document_id": { - "name": "document_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "page": { - "name": "page", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "chunk_index": { - "name": "chunk_index", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "content": { - "name": "content", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "embedding": { - "name": "embedding", - "type": "vector(1536)", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "pdf_chunks_document_id_idx": { - "name": "pdf_chunks_document_id_idx", - "columns": [ - { - "expression": "document_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "pdf_chunks_document_id_page_idx": { - "name": "pdf_chunks_document_id_page_idx", - "columns": [ - { - "expression": "document_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "page", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "pdf_chunks_document_id_page_chunk_idx": { - "name": "pdf_chunks_document_id_page_chunk_idx", - "columns": [ - { - "expression": "document_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "page", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "chunk_index", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_pdf_chunks_document_id_pdr_ai_v2_document_id_fk": { - "name": "pdr_ai_v2_pdf_chunks_document_id_pdr_ai_v2_document_id_fk", - "tableFrom": "pdr_ai_v2_pdf_chunks", - "tableTo": "pdr_ai_v2_document", - "columnsFrom": [ - "document_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_predictive_document_analysis_results": { - "name": "pdr_ai_v2_predictive_document_analysis_results", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "document_id": { - "name": "document_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "analysis_type": { - "name": "analysis_type", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "include_related_docs": { - "name": "include_related_docs", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "default": false - }, - "result_json": { - "name": "result_json", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - } - }, - "indexes": { - "predictive_analysis_document_id_idx": { - "name": "predictive_analysis_document_id_idx", - "columns": [ - { - "expression": "document_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_predictive_document_analysis_results_document_id_pdr_ai_v2_document_id_fk": { - "name": "pdr_ai_v2_predictive_document_analysis_results_document_id_pdr_ai_v2_document_id_fk", - "tableFrom": "pdr_ai_v2_predictive_document_analysis_results", - "tableTo": "pdr_ai_v2_document", - "columnsFrom": [ - "document_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_users": { - "name": "pdr_ai_v2_users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "userId": { - "name": "userId", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "company_id": { - "name": "company_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "role": { - "name": "role", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "users_company_id_idx": { - "name": "users_company_id_idx", - "columns": [ - { - "expression": "company_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "users_user_id_idx": { - "name": "users_user_id_idx", - "columns": [ - { - "expression": "userId", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_users_company_id_pdr_ai_v2_company_id_fk": { - "name": "pdr_ai_v2_users_company_id_pdr_ai_v2_company_id_fk", - "tableFrom": "pdr_ai_v2_users", - "tableTo": "pdr_ai_v2_company", - "columnsFrom": [ - "company_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "pdr_ai_v2_users_id_unique": { - "name": "pdr_ai_v2_users_id_unique", - "nullsNotDistinct": false, - "columns": [ - "id" - ] - }, - "pdr_ai_v2_users_userId_unique": { - "name": "pdr_ai_v2_users_userId_unique", - "nullsNotDistinct": false, - "columns": [ - "userId" - ] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_agent_ai_chatbot_chat": { - "name": "pdr_ai_v2_agent_ai_chatbot_chat", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar(256)", - "primaryKey": true, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "visibility": { - "name": "visibility", - "type": "varchar(20)", - "primaryKey": false, - "notNull": true, - "default": "'private'" - }, - "agent_mode": { - "name": "agent_mode", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true, - "default": "'interactive'" - }, - "status": { - "name": "status", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true, - "default": "'active'" - }, - "ai_style": { - "name": "ai_style", - "type": "varchar(50)", - "primaryKey": false, - "notNull": false, - "default": "'concise'" - }, - "ai_persona": { - "name": "ai_persona", - "type": "varchar(50)", - "primaryKey": false, - "notNull": false, - "default": "'general'" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_agent_ai_chatbot_document": { - "name": "pdr_ai_v2_agent_ai_chatbot_document", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "content": { - "name": "content", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "kind": { - "name": "kind", - "type": "varchar(20)", - "primaryKey": false, - "notNull": true, - "default": "'text'" - }, - "user_id": { - "name": "user_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "chat_id": { - "name": "chat_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": false - }, - "task_id": { - "name": "task_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "pdr_ai_v2_agent_ai_chatbot_document_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk": { - "name": "pdr_ai_v2_agent_ai_chatbot_document_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk", - "tableFrom": "pdr_ai_v2_agent_ai_chatbot_document", - "tableTo": "pdr_ai_v2_agent_ai_chatbot_chat", - "columnsFrom": [ - "chat_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "pdr_ai_v2_agent_ai_chatbot_document_task_id_pdr_ai_v2_agent_ai_chatbot_task_id_fk": { - "name": "pdr_ai_v2_agent_ai_chatbot_document_task_id_pdr_ai_v2_agent_ai_chatbot_task_id_fk", - "tableFrom": "pdr_ai_v2_agent_ai_chatbot_document", - "tableTo": "pdr_ai_v2_agent_ai_chatbot_task", - "columnsFrom": [ - "task_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "pdr_ai_v2_agent_ai_chatbot_document_id_created_at_pk": { - "name": "pdr_ai_v2_agent_ai_chatbot_document_id_created_at_pk", - "columns": [ - "id", - "created_at" - ] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_agent_ai_chatbot_execution_step": { - "name": "pdr_ai_v2_agent_ai_chatbot_execution_step", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar(256)", - "primaryKey": true, - "notNull": true - }, - "task_id": { - "name": "task_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "step_number": { - "name": "step_number", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "step_type": { - "name": "step_type", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "reasoning": { - "name": "reasoning", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "input": { - "name": "input", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "output": { - "name": "output", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true, - "default": "'pending'" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "completed_at": { - "name": "completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "agent_execution_step_task_step_idx": { - "name": "agent_execution_step_task_step_idx", - "columns": [ - { - "expression": "task_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "step_number", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_agent_ai_chatbot_execution_step_task_id_pdr_ai_v2_agent_ai_chatbot_task_id_fk": { - "name": "pdr_ai_v2_agent_ai_chatbot_execution_step_task_id_pdr_ai_v2_agent_ai_chatbot_task_id_fk", - "tableFrom": "pdr_ai_v2_agent_ai_chatbot_execution_step", - "tableTo": "pdr_ai_v2_agent_ai_chatbot_task", - "columnsFrom": [ - "task_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_agent_ai_chatbot_memory": { - "name": "pdr_ai_v2_agent_ai_chatbot_memory", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar(256)", - "primaryKey": true, - "notNull": true - }, - "chat_id": { - "name": "chat_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "memory_type": { - "name": "memory_type", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true - }, - "key": { - "name": "key", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "value": { - "name": "value", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "importance": { - "name": "importance", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 5 - }, - "embedding": { - "name": "embedding", - "type": "vector(1536)", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "accessed_at": { - "name": "accessed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "agent_memory_chat_idx": { - "name": "agent_memory_chat_idx", - "columns": [ - { - "expression": "chat_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "agent_memory_chat_type_idx": { - "name": "agent_memory_chat_type_idx", - "columns": [ - { - "expression": "chat_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "memory_type", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_agent_ai_chatbot_memory_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk": { - "name": "pdr_ai_v2_agent_ai_chatbot_memory_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk", - "tableFrom": "pdr_ai_v2_agent_ai_chatbot_memory", - "tableTo": "pdr_ai_v2_agent_ai_chatbot_chat", - "columnsFrom": [ - "chat_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_agent_ai_chatbot_message": { - "name": "pdr_ai_v2_agent_ai_chatbot_message", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar(256)", - "primaryKey": true, - "notNull": true - }, - "chat_id": { - "name": "chat_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "role": { - "name": "role", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true - }, - "content": { - "name": "content", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "message_type": { - "name": "message_type", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true, - "default": "'text'" - }, - "parent_message_id": { - "name": "parent_message_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - } - }, - "indexes": {}, - "foreignKeys": { - "pdr_ai_v2_agent_ai_chatbot_message_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk": { - "name": "pdr_ai_v2_agent_ai_chatbot_message_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk", - "tableFrom": "pdr_ai_v2_agent_ai_chatbot_message", - "tableTo": "pdr_ai_v2_agent_ai_chatbot_chat", - "columnsFrom": [ - "chat_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_agent_ai_chatbot_suggestion": { - "name": "pdr_ai_v2_agent_ai_chatbot_suggestion", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar(256)", - "primaryKey": true, - "notNull": true - }, - "document_id": { - "name": "document_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "document_created_at": { - "name": "document_created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "original_text": { - "name": "original_text", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "suggested_text": { - "name": "suggested_text", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_resolved": { - "name": "is_resolved", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "user_id": { - "name": "user_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - } - }, - "indexes": {}, - "foreignKeys": { - "pdr_ai_v2_agent_ai_chatbot_suggestion_document_id_document_created_at_pdr_ai_v2_agent_ai_chatbot_document_id_created_at_fk": { - "name": "pdr_ai_v2_agent_ai_chatbot_suggestion_document_id_document_created_at_pdr_ai_v2_agent_ai_chatbot_document_id_created_at_fk", - "tableFrom": "pdr_ai_v2_agent_ai_chatbot_suggestion", - "tableTo": "pdr_ai_v2_agent_ai_chatbot_document", - "columnsFrom": [ - "document_id", - "document_created_at" - ], - "columnsTo": [ - "id", - "created_at" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_agent_ai_chatbot_task": { - "name": "pdr_ai_v2_agent_ai_chatbot_task", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar(256)", - "primaryKey": true, - "notNull": true - }, - "chat_id": { - "name": "chat_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "objective": { - "name": "objective", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true, - "default": "'pending'" - }, - "priority": { - "name": "priority", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "result": { - "name": "result", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "metadata": { - "name": "metadata", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "completed_at": { - "name": "completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "pdr_ai_v2_agent_ai_chatbot_task_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk": { - "name": "pdr_ai_v2_agent_ai_chatbot_task_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk", - "tableFrom": "pdr_ai_v2_agent_ai_chatbot_task", - "tableTo": "pdr_ai_v2_agent_ai_chatbot_chat", - "columnsFrom": [ - "chat_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_agent_ai_chatbot_tool_call": { - "name": "pdr_ai_v2_agent_ai_chatbot_tool_call", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar(256)", - "primaryKey": true, - "notNull": true - }, - "message_id": { - "name": "message_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "task_id": { - "name": "task_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": false - }, - "tool_name": { - "name": "tool_name", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "tool_input": { - "name": "tool_input", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "tool_output": { - "name": "tool_output", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true, - "default": "'pending'" - }, - "error_message": { - "name": "error_message", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "execution_time_ms": { - "name": "execution_time_ms", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "completed_at": { - "name": "completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "pdr_ai_v2_agent_ai_chatbot_tool_call_message_id_pdr_ai_v2_agent_ai_chatbot_message_id_fk": { - "name": "pdr_ai_v2_agent_ai_chatbot_tool_call_message_id_pdr_ai_v2_agent_ai_chatbot_message_id_fk", - "tableFrom": "pdr_ai_v2_agent_ai_chatbot_tool_call", - "tableTo": "pdr_ai_v2_agent_ai_chatbot_message", - "columnsFrom": [ - "message_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "pdr_ai_v2_agent_ai_chatbot_tool_call_task_id_pdr_ai_v2_agent_ai_chatbot_task_id_fk": { - "name": "pdr_ai_v2_agent_ai_chatbot_tool_call_task_id_pdr_ai_v2_agent_ai_chatbot_task_id_fk", - "tableFrom": "pdr_ai_v2_agent_ai_chatbot_tool_call", - "tableTo": "pdr_ai_v2_agent_ai_chatbot_task", - "columnsFrom": [ - "task_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_agent_ai_chatbot_tool_registry": { - "name": "pdr_ai_v2_agent_ai_chatbot_tool_registry", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar(256)", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "varchar(100)", - "primaryKey": false, - "notNull": true - }, - "schema": { - "name": "schema", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "is_enabled": { - "name": "is_enabled", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "required_permissions": { - "name": "required_permissions", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "rate_limit": { - "name": "rate_limit", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "pdr_ai_v2_agent_ai_chatbot_tool_registry_name_unique": { - "name": "pdr_ai_v2_agent_ai_chatbot_tool_registry_name_unique", - "nullsNotDistinct": false, - "columns": [ - "name" - ] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_agent_ai_chatbot_vote": { - "name": "pdr_ai_v2_agent_ai_chatbot_vote", - "schema": "", - "columns": { - "chat_id": { - "name": "chat_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "message_id": { - "name": "message_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "is_upvoted": { - "name": "is_upvoted", - "type": "boolean", - "primaryKey": false, - "notNull": true - }, - "feedback": { - "name": "feedback", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - } - }, - "indexes": {}, - "foreignKeys": { - "pdr_ai_v2_agent_ai_chatbot_vote_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk": { - "name": "pdr_ai_v2_agent_ai_chatbot_vote_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk", - "tableFrom": "pdr_ai_v2_agent_ai_chatbot_vote", - "tableTo": "pdr_ai_v2_agent_ai_chatbot_chat", - "columnsFrom": [ - "chat_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "pdr_ai_v2_agent_ai_chatbot_vote_message_id_pdr_ai_v2_agent_ai_chatbot_message_id_fk": { - "name": "pdr_ai_v2_agent_ai_chatbot_vote_message_id_pdr_ai_v2_agent_ai_chatbot_message_id_fk", - "tableFrom": "pdr_ai_v2_agent_ai_chatbot_vote", - "tableTo": "pdr_ai_v2_agent_ai_chatbot_message", - "columnsFrom": [ - "message_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "pdr_ai_v2_agent_ai_chatbot_vote_chat_id_message_id_pk": { - "name": "pdr_ai_v2_agent_ai_chatbot_vote_chat_id_message_id_pk", - "columns": [ - "chat_id", - "message_id" - ] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": {}, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/drizzle/meta/0007_snapshot.json b/drizzle/meta/0007_snapshot.json deleted file mode 100644 index 9271d27c..00000000 --- a/drizzle/meta/0007_snapshot.json +++ /dev/null @@ -1,1804 +0,0 @@ -{ - "id": "5b20a218-05b8-4210-ad22-98388975e85c", - "prevId": "a3e3b8e3-0c8c-47d7-9a8e-0ce0f5b9e59c", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.pdr_ai_v2_chat_history": { - "name": "pdr_ai_v2_chat_history", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "document_id": { - "name": "document_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "document_title": { - "name": "document_title", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "question": { - "name": "question", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "response": { - "name": "response", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "chat_id": { - "name": "chat_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": false - }, - "query_type": { - "name": "query_type", - "type": "varchar(20)", - "primaryKey": false, - "notNull": false, - "default": "'simple'" - }, - "pages": { - "name": "pages", - "type": "integer[]", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "chat_history_user_id_idx": { - "name": "chat_history_user_id_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "chat_history_user_id_created_at_idx": { - "name": "chat_history_user_id_created_at_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "chat_history_document_id_idx": { - "name": "chat_history_document_id_idx", - "columns": [ - { - "expression": "document_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_chat_history_document_id_pdr_ai_v2_document_id_fk": { - "name": "pdr_ai_v2_chat_history_document_id_pdr_ai_v2_document_id_fk", - "tableFrom": "pdr_ai_v2_chat_history", - "tableTo": "pdr_ai_v2_document", - "columnsFrom": [ - "document_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_category": { - "name": "pdr_ai_v2_category", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "company_id": { - "name": "company_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "category_company_id_idx": { - "name": "category_company_id_idx", - "columns": [ - { - "expression": "company_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_category_company_id_pdr_ai_v2_company_id_fk": { - "name": "pdr_ai_v2_category_company_id_pdr_ai_v2_company_id_fk", - "tableFrom": "pdr_ai_v2_category", - "tableTo": "pdr_ai_v2_company", - "columnsFrom": [ - "company_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_company": { - "name": "pdr_ai_v2_company", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "employerPasskey": { - "name": "employerPasskey", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "employeePasskey": { - "name": "employeePasskey", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "numberOfEmployees": { - "name": "numberOfEmployees", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_document": { - "name": "pdr_ai_v2_document", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "url": { - "name": "url", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "company_id": { - "name": "company_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "ocr_enabled": { - "name": "ocr_enabled", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "default": false - }, - "ocr_processed": { - "name": "ocr_processed", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "default": false - }, - "ocr_metadata": { - "name": "ocr_metadata", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "document_company_id_idx": { - "name": "document_company_id_idx", - "columns": [ - { - "expression": "company_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "document_company_id_id_idx": { - "name": "document_company_id_id_idx", - "columns": [ - { - "expression": "company_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "document_company_id_category_idx": { - "name": "document_company_id_category_idx", - "columns": [ - { - "expression": "company_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "category", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_document_company_id_pdr_ai_v2_company_id_fk": { - "name": "pdr_ai_v2_document_company_id_pdr_ai_v2_company_id_fk", - "tableFrom": "pdr_ai_v2_document", - "tableTo": "pdr_ai_v2_company", - "columnsFrom": [ - "company_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_document_reference_resolutions": { - "name": "pdr_ai_v2_document_reference_resolutions", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "company_id": { - "name": "company_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "reference_name": { - "name": "reference_name", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "resolved_in_document_id": { - "name": "resolved_in_document_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "resolution_details": { - "name": "resolution_details", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "document_reference_resolutions_company_ref_idx": { - "name": "document_reference_resolutions_company_ref_idx", - "columns": [ - { - "expression": "company_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_document_reference_resolutions_company_id_pdr_ai_v2_company_id_fk": { - "name": "pdr_ai_v2_document_reference_resolutions_company_id_pdr_ai_v2_company_id_fk", - "tableFrom": "pdr_ai_v2_document_reference_resolutions", - "tableTo": "pdr_ai_v2_company", - "columnsFrom": [ - "company_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_pdf_chunks": { - "name": "pdr_ai_v2_pdf_chunks", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "document_id": { - "name": "document_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "page": { - "name": "page", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "chunk_index": { - "name": "chunk_index", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "content": { - "name": "content", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "embedding": { - "name": "embedding", - "type": "vector(1536)", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "pdf_chunks_document_id_idx": { - "name": "pdf_chunks_document_id_idx", - "columns": [ - { - "expression": "document_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "pdf_chunks_document_id_page_idx": { - "name": "pdf_chunks_document_id_page_idx", - "columns": [ - { - "expression": "document_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "page", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "pdf_chunks_document_id_page_chunk_idx": { - "name": "pdf_chunks_document_id_page_chunk_idx", - "columns": [ - { - "expression": "document_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "page", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "chunk_index", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_pdf_chunks_document_id_pdr_ai_v2_document_id_fk": { - "name": "pdr_ai_v2_pdf_chunks_document_id_pdr_ai_v2_document_id_fk", - "tableFrom": "pdr_ai_v2_pdf_chunks", - "tableTo": "pdr_ai_v2_document", - "columnsFrom": [ - "document_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_predictive_document_analysis_results": { - "name": "pdr_ai_v2_predictive_document_analysis_results", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "document_id": { - "name": "document_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "analysis_type": { - "name": "analysis_type", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "include_related_docs": { - "name": "include_related_docs", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "default": false - }, - "result_json": { - "name": "result_json", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - } - }, - "indexes": { - "predictive_analysis_document_id_idx": { - "name": "predictive_analysis_document_id_idx", - "columns": [ - { - "expression": "document_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_predictive_document_analysis_results_document_id_pdr_ai_v2_document_id_fk": { - "name": "pdr_ai_v2_predictive_document_analysis_results_document_id_pdr_ai_v2_document_id_fk", - "tableFrom": "pdr_ai_v2_predictive_document_analysis_results", - "tableTo": "pdr_ai_v2_document", - "columnsFrom": [ - "document_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_users": { - "name": "pdr_ai_v2_users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "userId": { - "name": "userId", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "company_id": { - "name": "company_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "role": { - "name": "role", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "users_company_id_idx": { - "name": "users_company_id_idx", - "columns": [ - { - "expression": "company_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "users_user_id_idx": { - "name": "users_user_id_idx", - "columns": [ - { - "expression": "userId", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_users_company_id_pdr_ai_v2_company_id_fk": { - "name": "pdr_ai_v2_users_company_id_pdr_ai_v2_company_id_fk", - "tableFrom": "pdr_ai_v2_users", - "tableTo": "pdr_ai_v2_company", - "columnsFrom": [ - "company_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "pdr_ai_v2_users_id_unique": { - "name": "pdr_ai_v2_users_id_unique", - "nullsNotDistinct": false, - "columns": [ - "id" - ] - }, - "pdr_ai_v2_users_userId_unique": { - "name": "pdr_ai_v2_users_userId_unique", - "nullsNotDistinct": false, - "columns": [ - "userId" - ] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_agent_ai_chatbot_chat": { - "name": "pdr_ai_v2_agent_ai_chatbot_chat", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar(256)", - "primaryKey": true, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "visibility": { - "name": "visibility", - "type": "varchar(20)", - "primaryKey": false, - "notNull": true, - "default": "'private'" - }, - "agent_mode": { - "name": "agent_mode", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true, - "default": "'interactive'" - }, - "status": { - "name": "status", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true, - "default": "'active'" - }, - "ai_style": { - "name": "ai_style", - "type": "varchar(50)", - "primaryKey": false, - "notNull": false, - "default": "'concise'" - }, - "ai_persona": { - "name": "ai_persona", - "type": "varchar(50)", - "primaryKey": false, - "notNull": false, - "default": "'general'" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_agent_ai_chatbot_document": { - "name": "pdr_ai_v2_agent_ai_chatbot_document", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "content": { - "name": "content", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "kind": { - "name": "kind", - "type": "varchar(20)", - "primaryKey": false, - "notNull": true, - "default": "'text'" - }, - "user_id": { - "name": "user_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "chat_id": { - "name": "chat_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": false - }, - "task_id": { - "name": "task_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "pdr_ai_v2_agent_ai_chatbot_document_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk": { - "name": "pdr_ai_v2_agent_ai_chatbot_document_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk", - "tableFrom": "pdr_ai_v2_agent_ai_chatbot_document", - "tableTo": "pdr_ai_v2_agent_ai_chatbot_chat", - "columnsFrom": [ - "chat_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "pdr_ai_v2_agent_ai_chatbot_document_task_id_pdr_ai_v2_agent_ai_chatbot_task_id_fk": { - "name": "pdr_ai_v2_agent_ai_chatbot_document_task_id_pdr_ai_v2_agent_ai_chatbot_task_id_fk", - "tableFrom": "pdr_ai_v2_agent_ai_chatbot_document", - "tableTo": "pdr_ai_v2_agent_ai_chatbot_task", - "columnsFrom": [ - "task_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "pdr_ai_v2_agent_ai_chatbot_document_id_created_at_pk": { - "name": "pdr_ai_v2_agent_ai_chatbot_document_id_created_at_pk", - "columns": [ - "id", - "created_at" - ] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_agent_ai_chatbot_execution_step": { - "name": "pdr_ai_v2_agent_ai_chatbot_execution_step", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar(256)", - "primaryKey": true, - "notNull": true - }, - "task_id": { - "name": "task_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "step_number": { - "name": "step_number", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "step_type": { - "name": "step_type", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "reasoning": { - "name": "reasoning", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "input": { - "name": "input", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "output": { - "name": "output", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true, - "default": "'pending'" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "completed_at": { - "name": "completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "agent_execution_step_task_step_idx": { - "name": "agent_execution_step_task_step_idx", - "columns": [ - { - "expression": "task_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "step_number", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_agent_ai_chatbot_execution_step_task_id_pdr_ai_v2_agent_ai_chatbot_task_id_fk": { - "name": "pdr_ai_v2_agent_ai_chatbot_execution_step_task_id_pdr_ai_v2_agent_ai_chatbot_task_id_fk", - "tableFrom": "pdr_ai_v2_agent_ai_chatbot_execution_step", - "tableTo": "pdr_ai_v2_agent_ai_chatbot_task", - "columnsFrom": [ - "task_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_agent_ai_chatbot_memory": { - "name": "pdr_ai_v2_agent_ai_chatbot_memory", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar(256)", - "primaryKey": true, - "notNull": true - }, - "chat_id": { - "name": "chat_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "memory_type": { - "name": "memory_type", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true - }, - "key": { - "name": "key", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "value": { - "name": "value", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "importance": { - "name": "importance", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 5 - }, - "embedding": { - "name": "embedding", - "type": "vector(1536)", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "accessed_at": { - "name": "accessed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "agent_memory_chat_idx": { - "name": "agent_memory_chat_idx", - "columns": [ - { - "expression": "chat_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "agent_memory_chat_type_idx": { - "name": "agent_memory_chat_type_idx", - "columns": [ - { - "expression": "chat_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "memory_type", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_agent_ai_chatbot_memory_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk": { - "name": "pdr_ai_v2_agent_ai_chatbot_memory_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk", - "tableFrom": "pdr_ai_v2_agent_ai_chatbot_memory", - "tableTo": "pdr_ai_v2_agent_ai_chatbot_chat", - "columnsFrom": [ - "chat_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_agent_ai_chatbot_message": { - "name": "pdr_ai_v2_agent_ai_chatbot_message", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar(256)", - "primaryKey": true, - "notNull": true - }, - "chat_id": { - "name": "chat_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "role": { - "name": "role", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true - }, - "content": { - "name": "content", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "message_type": { - "name": "message_type", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true, - "default": "'text'" - }, - "parent_message_id": { - "name": "parent_message_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - } - }, - "indexes": {}, - "foreignKeys": { - "pdr_ai_v2_agent_ai_chatbot_message_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk": { - "name": "pdr_ai_v2_agent_ai_chatbot_message_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk", - "tableFrom": "pdr_ai_v2_agent_ai_chatbot_message", - "tableTo": "pdr_ai_v2_agent_ai_chatbot_chat", - "columnsFrom": [ - "chat_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_agent_ai_chatbot_suggestion": { - "name": "pdr_ai_v2_agent_ai_chatbot_suggestion", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar(256)", - "primaryKey": true, - "notNull": true - }, - "document_id": { - "name": "document_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "document_created_at": { - "name": "document_created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "original_text": { - "name": "original_text", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "suggested_text": { - "name": "suggested_text", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_resolved": { - "name": "is_resolved", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "user_id": { - "name": "user_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - } - }, - "indexes": {}, - "foreignKeys": { - "pdr_ai_v2_agent_ai_chatbot_suggestion_document_id_document_created_at_pdr_ai_v2_agent_ai_chatbot_document_id_created_at_fk": { - "name": "pdr_ai_v2_agent_ai_chatbot_suggestion_document_id_document_created_at_pdr_ai_v2_agent_ai_chatbot_document_id_created_at_fk", - "tableFrom": "pdr_ai_v2_agent_ai_chatbot_suggestion", - "tableTo": "pdr_ai_v2_agent_ai_chatbot_document", - "columnsFrom": [ - "document_id", - "document_created_at" - ], - "columnsTo": [ - "id", - "created_at" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_agent_ai_chatbot_task": { - "name": "pdr_ai_v2_agent_ai_chatbot_task", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar(256)", - "primaryKey": true, - "notNull": true - }, - "chat_id": { - "name": "chat_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "objective": { - "name": "objective", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true, - "default": "'pending'" - }, - "priority": { - "name": "priority", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "result": { - "name": "result", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "metadata": { - "name": "metadata", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "completed_at": { - "name": "completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "pdr_ai_v2_agent_ai_chatbot_task_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk": { - "name": "pdr_ai_v2_agent_ai_chatbot_task_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk", - "tableFrom": "pdr_ai_v2_agent_ai_chatbot_task", - "tableTo": "pdr_ai_v2_agent_ai_chatbot_chat", - "columnsFrom": [ - "chat_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_agent_ai_chatbot_tool_call": { - "name": "pdr_ai_v2_agent_ai_chatbot_tool_call", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar(256)", - "primaryKey": true, - "notNull": true - }, - "message_id": { - "name": "message_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "task_id": { - "name": "task_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": false - }, - "tool_name": { - "name": "tool_name", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "tool_input": { - "name": "tool_input", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "tool_output": { - "name": "tool_output", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true, - "default": "'pending'" - }, - "error_message": { - "name": "error_message", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "execution_time_ms": { - "name": "execution_time_ms", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "completed_at": { - "name": "completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "pdr_ai_v2_agent_ai_chatbot_tool_call_message_id_pdr_ai_v2_agent_ai_chatbot_message_id_fk": { - "name": "pdr_ai_v2_agent_ai_chatbot_tool_call_message_id_pdr_ai_v2_agent_ai_chatbot_message_id_fk", - "tableFrom": "pdr_ai_v2_agent_ai_chatbot_tool_call", - "tableTo": "pdr_ai_v2_agent_ai_chatbot_message", - "columnsFrom": [ - "message_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "pdr_ai_v2_agent_ai_chatbot_tool_call_task_id_pdr_ai_v2_agent_ai_chatbot_task_id_fk": { - "name": "pdr_ai_v2_agent_ai_chatbot_tool_call_task_id_pdr_ai_v2_agent_ai_chatbot_task_id_fk", - "tableFrom": "pdr_ai_v2_agent_ai_chatbot_tool_call", - "tableTo": "pdr_ai_v2_agent_ai_chatbot_task", - "columnsFrom": [ - "task_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_agent_ai_chatbot_tool_registry": { - "name": "pdr_ai_v2_agent_ai_chatbot_tool_registry", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar(256)", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "varchar(100)", - "primaryKey": false, - "notNull": true - }, - "schema": { - "name": "schema", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "is_enabled": { - "name": "is_enabled", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "required_permissions": { - "name": "required_permissions", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "rate_limit": { - "name": "rate_limit", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "pdr_ai_v2_agent_ai_chatbot_tool_registry_name_unique": { - "name": "pdr_ai_v2_agent_ai_chatbot_tool_registry_name_unique", - "nullsNotDistinct": false, - "columns": [ - "name" - ] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_agent_ai_chatbot_vote": { - "name": "pdr_ai_v2_agent_ai_chatbot_vote", - "schema": "", - "columns": { - "chat_id": { - "name": "chat_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "message_id": { - "name": "message_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "is_upvoted": { - "name": "is_upvoted", - "type": "boolean", - "primaryKey": false, - "notNull": true - }, - "feedback": { - "name": "feedback", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - } - }, - "indexes": {}, - "foreignKeys": { - "pdr_ai_v2_agent_ai_chatbot_vote_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk": { - "name": "pdr_ai_v2_agent_ai_chatbot_vote_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk", - "tableFrom": "pdr_ai_v2_agent_ai_chatbot_vote", - "tableTo": "pdr_ai_v2_agent_ai_chatbot_chat", - "columnsFrom": [ - "chat_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "pdr_ai_v2_agent_ai_chatbot_vote_message_id_pdr_ai_v2_agent_ai_chatbot_message_id_fk": { - "name": "pdr_ai_v2_agent_ai_chatbot_vote_message_id_pdr_ai_v2_agent_ai_chatbot_message_id_fk", - "tableFrom": "pdr_ai_v2_agent_ai_chatbot_vote", - "tableTo": "pdr_ai_v2_agent_ai_chatbot_message", - "columnsFrom": [ - "message_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "pdr_ai_v2_agent_ai_chatbot_vote_chat_id_message_id_pk": { - "name": "pdr_ai_v2_agent_ai_chatbot_vote_chat_id_message_id_pk", - "columns": [ - "chat_id", - "message_id" - ] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": {}, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/drizzle/meta/0008_snapshot.json b/drizzle/meta/0008_snapshot.json deleted file mode 100644 index 28a51b0c..00000000 --- a/drizzle/meta/0008_snapshot.json +++ /dev/null @@ -1,2428 +0,0 @@ -{ - "id": "0a5473c6-5c14-4514-95d0-2e0e3b73bfab", - "prevId": "5b20a218-05b8-4210-ad22-98388975e85c", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.pdr_ai_v2_chat_history": { - "name": "pdr_ai_v2_chat_history", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "document_id": { - "name": "document_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "document_title": { - "name": "document_title", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "question": { - "name": "question", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "response": { - "name": "response", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "chat_id": { - "name": "chat_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": false - }, - "query_type": { - "name": "query_type", - "type": "varchar(20)", - "primaryKey": false, - "notNull": false, - "default": "'simple'" - }, - "pages": { - "name": "pages", - "type": "integer[]", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "chat_history_user_id_idx": { - "name": "chat_history_user_id_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "chat_history_user_id_created_at_idx": { - "name": "chat_history_user_id_created_at_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "chat_history_document_id_idx": { - "name": "chat_history_document_id_idx", - "columns": [ - { - "expression": "document_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_chat_history_document_id_pdr_ai_v2_document_id_fk": { - "name": "pdr_ai_v2_chat_history_document_id_pdr_ai_v2_document_id_fk", - "tableFrom": "pdr_ai_v2_chat_history", - "tableTo": "pdr_ai_v2_document", - "columnsFrom": [ - "document_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_category": { - "name": "pdr_ai_v2_category", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "company_id": { - "name": "company_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "category_company_id_idx": { - "name": "category_company_id_idx", - "columns": [ - { - "expression": "company_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_category_company_id_pdr_ai_v2_company_id_fk": { - "name": "pdr_ai_v2_category_company_id_pdr_ai_v2_company_id_fk", - "tableFrom": "pdr_ai_v2_category", - "tableTo": "pdr_ai_v2_company", - "columnsFrom": [ - "company_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_company": { - "name": "pdr_ai_v2_company", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "employerPasskey": { - "name": "employerPasskey", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "employeePasskey": { - "name": "employeePasskey", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "numberOfEmployees": { - "name": "numberOfEmployees", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_document": { - "name": "pdr_ai_v2_document", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "url": { - "name": "url", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "company_id": { - "name": "company_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "ocr_enabled": { - "name": "ocr_enabled", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "default": false - }, - "ocr_processed": { - "name": "ocr_processed", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "default": false - }, - "ocr_metadata": { - "name": "ocr_metadata", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "document_company_id_idx": { - "name": "document_company_id_idx", - "columns": [ - { - "expression": "company_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "document_company_id_id_idx": { - "name": "document_company_id_id_idx", - "columns": [ - { - "expression": "company_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "document_company_id_category_idx": { - "name": "document_company_id_category_idx", - "columns": [ - { - "expression": "company_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "category", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_document_company_id_pdr_ai_v2_company_id_fk": { - "name": "pdr_ai_v2_document_company_id_pdr_ai_v2_company_id_fk", - "tableFrom": "pdr_ai_v2_document", - "tableTo": "pdr_ai_v2_company", - "columnsFrom": [ - "company_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_document_reference_resolutions": { - "name": "pdr_ai_v2_document_reference_resolutions", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "company_id": { - "name": "company_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "reference_name": { - "name": "reference_name", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "resolved_in_document_id": { - "name": "resolved_in_document_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "resolution_details": { - "name": "resolution_details", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "document_reference_resolutions_company_ref_idx": { - "name": "document_reference_resolutions_company_ref_idx", - "columns": [ - { - "expression": "company_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_document_reference_resolutions_company_id_pdr_ai_v2_company_id_fk": { - "name": "pdr_ai_v2_document_reference_resolutions_company_id_pdr_ai_v2_company_id_fk", - "tableFrom": "pdr_ai_v2_document_reference_resolutions", - "tableTo": "pdr_ai_v2_company", - "columnsFrom": [ - "company_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_pdf_chunks": { - "name": "pdr_ai_v2_pdf_chunks", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "document_id": { - "name": "document_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "page": { - "name": "page", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "chunk_index": { - "name": "chunk_index", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "content": { - "name": "content", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "embedding": { - "name": "embedding", - "type": "vector(1536)", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "pdf_chunks_document_id_idx": { - "name": "pdf_chunks_document_id_idx", - "columns": [ - { - "expression": "document_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "pdf_chunks_document_id_page_idx": { - "name": "pdf_chunks_document_id_page_idx", - "columns": [ - { - "expression": "document_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "page", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "pdf_chunks_document_id_page_chunk_idx": { - "name": "pdf_chunks_document_id_page_chunk_idx", - "columns": [ - { - "expression": "document_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "page", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "chunk_index", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_pdf_chunks_document_id_pdr_ai_v2_document_id_fk": { - "name": "pdr_ai_v2_pdf_chunks_document_id_pdr_ai_v2_document_id_fk", - "tableFrom": "pdr_ai_v2_pdf_chunks", - "tableTo": "pdr_ai_v2_document", - "columnsFrom": [ - "document_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_predictive_document_analysis_results": { - "name": "pdr_ai_v2_predictive_document_analysis_results", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "document_id": { - "name": "document_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "analysis_type": { - "name": "analysis_type", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "include_related_docs": { - "name": "include_related_docs", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "default": false - }, - "result_json": { - "name": "result_json", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - } - }, - "indexes": { - "predictive_analysis_document_id_idx": { - "name": "predictive_analysis_document_id_idx", - "columns": [ - { - "expression": "document_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_predictive_document_analysis_results_document_id_pdr_ai_v2_document_id_fk": { - "name": "pdr_ai_v2_predictive_document_analysis_results_document_id_pdr_ai_v2_document_id_fk", - "tableFrom": "pdr_ai_v2_predictive_document_analysis_results", - "tableTo": "pdr_ai_v2_document", - "columnsFrom": [ - "document_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_users": { - "name": "pdr_ai_v2_users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "userId": { - "name": "userId", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "company_id": { - "name": "company_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "role": { - "name": "role", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "users_company_id_idx": { - "name": "users_company_id_idx", - "columns": [ - { - "expression": "company_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "users_user_id_idx": { - "name": "users_user_id_idx", - "columns": [ - { - "expression": "userId", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_users_company_id_pdr_ai_v2_company_id_fk": { - "name": "pdr_ai_v2_users_company_id_pdr_ai_v2_company_id_fk", - "tableFrom": "pdr_ai_v2_users", - "tableTo": "pdr_ai_v2_company", - "columnsFrom": [ - "company_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "pdr_ai_v2_users_userId_unique": { - "name": "pdr_ai_v2_users_userId_unique", - "nullsNotDistinct": false, - "columns": [ - "userId" - ] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_agent_ai_chatbot_chat": { - "name": "pdr_ai_v2_agent_ai_chatbot_chat", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar(256)", - "primaryKey": true, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "visibility": { - "name": "visibility", - "type": "varchar(20)", - "primaryKey": false, - "notNull": true, - "default": "'private'" - }, - "agent_mode": { - "name": "agent_mode", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true, - "default": "'interactive'" - }, - "status": { - "name": "status", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true, - "default": "'active'" - }, - "ai_style": { - "name": "ai_style", - "type": "varchar(50)", - "primaryKey": false, - "notNull": false, - "default": "'concise'" - }, - "ai_persona": { - "name": "ai_persona", - "type": "varchar(50)", - "primaryKey": false, - "notNull": false, - "default": "'general'" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_agent_ai_chatbot_document": { - "name": "pdr_ai_v2_agent_ai_chatbot_document", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "content": { - "name": "content", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "kind": { - "name": "kind", - "type": "varchar(20)", - "primaryKey": false, - "notNull": true, - "default": "'text'" - }, - "user_id": { - "name": "user_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "chat_id": { - "name": "chat_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": false - }, - "task_id": { - "name": "task_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "pdr_ai_v2_agent_ai_chatbot_document_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk": { - "name": "pdr_ai_v2_agent_ai_chatbot_document_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk", - "tableFrom": "pdr_ai_v2_agent_ai_chatbot_document", - "tableTo": "pdr_ai_v2_agent_ai_chatbot_chat", - "columnsFrom": [ - "chat_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "pdr_ai_v2_agent_ai_chatbot_document_task_id_pdr_ai_v2_agent_ai_chatbot_task_id_fk": { - "name": "pdr_ai_v2_agent_ai_chatbot_document_task_id_pdr_ai_v2_agent_ai_chatbot_task_id_fk", - "tableFrom": "pdr_ai_v2_agent_ai_chatbot_document", - "tableTo": "pdr_ai_v2_agent_ai_chatbot_task", - "columnsFrom": [ - "task_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "pdr_ai_v2_agent_ai_chatbot_document_id_created_at_pk": { - "name": "pdr_ai_v2_agent_ai_chatbot_document_id_created_at_pk", - "columns": [ - "id", - "created_at" - ] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_agent_ai_chatbot_execution_step": { - "name": "pdr_ai_v2_agent_ai_chatbot_execution_step", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar(256)", - "primaryKey": true, - "notNull": true - }, - "task_id": { - "name": "task_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "step_number": { - "name": "step_number", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "step_type": { - "name": "step_type", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "reasoning": { - "name": "reasoning", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "input": { - "name": "input", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "output": { - "name": "output", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true, - "default": "'pending'" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "completed_at": { - "name": "completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "agent_execution_step_task_step_idx": { - "name": "agent_execution_step_task_step_idx", - "columns": [ - { - "expression": "task_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "step_number", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_agent_ai_chatbot_execution_step_task_id_pdr_ai_v2_agent_ai_chatbot_task_id_fk": { - "name": "pdr_ai_v2_agent_ai_chatbot_execution_step_task_id_pdr_ai_v2_agent_ai_chatbot_task_id_fk", - "tableFrom": "pdr_ai_v2_agent_ai_chatbot_execution_step", - "tableTo": "pdr_ai_v2_agent_ai_chatbot_task", - "columnsFrom": [ - "task_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_agent_ai_chatbot_memory": { - "name": "pdr_ai_v2_agent_ai_chatbot_memory", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar(256)", - "primaryKey": true, - "notNull": true - }, - "chat_id": { - "name": "chat_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "memory_type": { - "name": "memory_type", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true - }, - "key": { - "name": "key", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "value": { - "name": "value", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "importance": { - "name": "importance", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 5 - }, - "embedding": { - "name": "embedding", - "type": "vector(1536)", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "accessed_at": { - "name": "accessed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "agent_memory_chat_idx": { - "name": "agent_memory_chat_idx", - "columns": [ - { - "expression": "chat_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "agent_memory_chat_type_idx": { - "name": "agent_memory_chat_type_idx", - "columns": [ - { - "expression": "chat_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "memory_type", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_agent_ai_chatbot_memory_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk": { - "name": "pdr_ai_v2_agent_ai_chatbot_memory_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk", - "tableFrom": "pdr_ai_v2_agent_ai_chatbot_memory", - "tableTo": "pdr_ai_v2_agent_ai_chatbot_chat", - "columnsFrom": [ - "chat_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_agent_ai_chatbot_message": { - "name": "pdr_ai_v2_agent_ai_chatbot_message", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar(256)", - "primaryKey": true, - "notNull": true - }, - "chat_id": { - "name": "chat_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "role": { - "name": "role", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true - }, - "content": { - "name": "content", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "message_type": { - "name": "message_type", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true, - "default": "'text'" - }, - "parent_message_id": { - "name": "parent_message_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - } - }, - "indexes": {}, - "foreignKeys": { - "pdr_ai_v2_agent_ai_chatbot_message_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk": { - "name": "pdr_ai_v2_agent_ai_chatbot_message_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk", - "tableFrom": "pdr_ai_v2_agent_ai_chatbot_message", - "tableTo": "pdr_ai_v2_agent_ai_chatbot_chat", - "columnsFrom": [ - "chat_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_agent_ai_chatbot_suggestion": { - "name": "pdr_ai_v2_agent_ai_chatbot_suggestion", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar(256)", - "primaryKey": true, - "notNull": true - }, - "document_id": { - "name": "document_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "document_created_at": { - "name": "document_created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "original_text": { - "name": "original_text", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "suggested_text": { - "name": "suggested_text", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_resolved": { - "name": "is_resolved", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "user_id": { - "name": "user_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - } - }, - "indexes": {}, - "foreignKeys": { - "pdr_ai_v2_agent_ai_chatbot_suggestion_document_id_document_created_at_pdr_ai_v2_agent_ai_chatbot_document_id_created_at_fk": { - "name": "pdr_ai_v2_agent_ai_chatbot_suggestion_document_id_document_created_at_pdr_ai_v2_agent_ai_chatbot_document_id_created_at_fk", - "tableFrom": "pdr_ai_v2_agent_ai_chatbot_suggestion", - "tableTo": "pdr_ai_v2_agent_ai_chatbot_document", - "columnsFrom": [ - "document_id", - "document_created_at" - ], - "columnsTo": [ - "id", - "created_at" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_agent_ai_chatbot_task": { - "name": "pdr_ai_v2_agent_ai_chatbot_task", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar(256)", - "primaryKey": true, - "notNull": true - }, - "chat_id": { - "name": "chat_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "objective": { - "name": "objective", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true, - "default": "'pending'" - }, - "priority": { - "name": "priority", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "result": { - "name": "result", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "metadata": { - "name": "metadata", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "completed_at": { - "name": "completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "pdr_ai_v2_agent_ai_chatbot_task_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk": { - "name": "pdr_ai_v2_agent_ai_chatbot_task_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk", - "tableFrom": "pdr_ai_v2_agent_ai_chatbot_task", - "tableTo": "pdr_ai_v2_agent_ai_chatbot_chat", - "columnsFrom": [ - "chat_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_agent_ai_chatbot_tool_call": { - "name": "pdr_ai_v2_agent_ai_chatbot_tool_call", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar(256)", - "primaryKey": true, - "notNull": true - }, - "message_id": { - "name": "message_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "task_id": { - "name": "task_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": false - }, - "tool_name": { - "name": "tool_name", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "tool_input": { - "name": "tool_input", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "tool_output": { - "name": "tool_output", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true, - "default": "'pending'" - }, - "error_message": { - "name": "error_message", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "execution_time_ms": { - "name": "execution_time_ms", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "completed_at": { - "name": "completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "pdr_ai_v2_agent_ai_chatbot_tool_call_message_id_pdr_ai_v2_agent_ai_chatbot_message_id_fk": { - "name": "pdr_ai_v2_agent_ai_chatbot_tool_call_message_id_pdr_ai_v2_agent_ai_chatbot_message_id_fk", - "tableFrom": "pdr_ai_v2_agent_ai_chatbot_tool_call", - "tableTo": "pdr_ai_v2_agent_ai_chatbot_message", - "columnsFrom": [ - "message_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "pdr_ai_v2_agent_ai_chatbot_tool_call_task_id_pdr_ai_v2_agent_ai_chatbot_task_id_fk": { - "name": "pdr_ai_v2_agent_ai_chatbot_tool_call_task_id_pdr_ai_v2_agent_ai_chatbot_task_id_fk", - "tableFrom": "pdr_ai_v2_agent_ai_chatbot_tool_call", - "tableTo": "pdr_ai_v2_agent_ai_chatbot_task", - "columnsFrom": [ - "task_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_agent_ai_chatbot_tool_registry": { - "name": "pdr_ai_v2_agent_ai_chatbot_tool_registry", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar(256)", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "varchar(100)", - "primaryKey": false, - "notNull": true - }, - "schema": { - "name": "schema", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "is_enabled": { - "name": "is_enabled", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "required_permissions": { - "name": "required_permissions", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "rate_limit": { - "name": "rate_limit", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "pdr_ai_v2_agent_ai_chatbot_tool_registry_name_unique": { - "name": "pdr_ai_v2_agent_ai_chatbot_tool_registry_name_unique", - "nullsNotDistinct": false, - "columns": [ - "name" - ] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_agent_ai_chatbot_vote": { - "name": "pdr_ai_v2_agent_ai_chatbot_vote", - "schema": "", - "columns": { - "chat_id": { - "name": "chat_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "message_id": { - "name": "message_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "is_upvoted": { - "name": "is_upvoted", - "type": "boolean", - "primaryKey": false, - "notNull": true - }, - "feedback": { - "name": "feedback", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - } - }, - "indexes": {}, - "foreignKeys": { - "pdr_ai_v2_agent_ai_chatbot_vote_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk": { - "name": "pdr_ai_v2_agent_ai_chatbot_vote_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk", - "tableFrom": "pdr_ai_v2_agent_ai_chatbot_vote", - "tableTo": "pdr_ai_v2_agent_ai_chatbot_chat", - "columnsFrom": [ - "chat_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "pdr_ai_v2_agent_ai_chatbot_vote_message_id_pdr_ai_v2_agent_ai_chatbot_message_id_fk": { - "name": "pdr_ai_v2_agent_ai_chatbot_vote_message_id_pdr_ai_v2_agent_ai_chatbot_message_id_fk", - "tableFrom": "pdr_ai_v2_agent_ai_chatbot_vote", - "tableTo": "pdr_ai_v2_agent_ai_chatbot_message", - "columnsFrom": [ - "message_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "pdr_ai_v2_agent_ai_chatbot_vote_chat_id_message_id_pk": { - "name": "pdr_ai_v2_agent_ai_chatbot_vote_chat_id_message_id_pk", - "columns": [ - "chat_id", - "message_id" - ] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_study_agent_goals": { - "name": "pdr_ai_v2_study_agent_goals", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "session_id": { - "name": "session_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "materials": { - "name": "materials", - "type": "text[]", - "primaryKey": false, - "notNull": false, - "default": "'{}'" - }, - "completed": { - "name": "completed", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "study_agent_goals_user_idx": { - "name": "study_agent_goals_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "study_agent_goals_session_idx": { - "name": "study_agent_goals_session_idx", - "columns": [ - { - "expression": "session_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_study_agent_goals_session_id_pdr_ai_v2_study_agent_sessions_id_fk": { - "name": "pdr_ai_v2_study_agent_goals_session_id_pdr_ai_v2_study_agent_sessions_id_fk", - "tableFrom": "pdr_ai_v2_study_agent_goals", - "tableTo": "pdr_ai_v2_study_agent_sessions", - "columnsFrom": [ - "session_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_study_agent_notes": { - "name": "pdr_ai_v2_study_agent_notes", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "session_id": { - "name": "session_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "content": { - "name": "content", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "tags": { - "name": "tags", - "type": "text[]", - "primaryKey": false, - "notNull": false, - "default": "'{}'" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "study_agent_notes_user_idx": { - "name": "study_agent_notes_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "study_agent_notes_session_idx": { - "name": "study_agent_notes_session_idx", - "columns": [ - { - "expression": "session_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_study_agent_notes_session_id_pdr_ai_v2_study_agent_sessions_id_fk": { - "name": "pdr_ai_v2_study_agent_notes_session_id_pdr_ai_v2_study_agent_sessions_id_fk", - "tableFrom": "pdr_ai_v2_study_agent_notes", - "tableTo": "pdr_ai_v2_study_agent_sessions", - "columnsFrom": [ - "session_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_study_agent_pomodoro_settings": { - "name": "pdr_ai_v2_study_agent_pomodoro_settings", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "session_id": { - "name": "session_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "focus_minutes": { - "name": "focus_minutes", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 25 - }, - "short_break_minutes": { - "name": "short_break_minutes", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 5 - }, - "long_break_minutes": { - "name": "long_break_minutes", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 15 - }, - "remaining_time": { - "name": "remaining_time", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "sessions_before_long_break": { - "name": "sessions_before_long_break", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 4 - }, - "auto_start_breaks": { - "name": "auto_start_breaks", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "auto_start_pomodoros": { - "name": "auto_start_pomodoros", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "study_agent_pomodoro_settings_user_idx": { - "name": "study_agent_pomodoro_settings_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "study_agent_pomodoro_settings_session_idx": { - "name": "study_agent_pomodoro_settings_session_idx", - "columns": [ - { - "expression": "session_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_study_agent_pomodoro_settings_session_id_pdr_ai_v2_study_agent_sessions_id_fk": { - "name": "pdr_ai_v2_study_agent_pomodoro_settings_session_id_pdr_ai_v2_study_agent_sessions_id_fk", - "tableFrom": "pdr_ai_v2_study_agent_pomodoro_settings", - "tableTo": "pdr_ai_v2_study_agent_sessions", - "columnsFrom": [ - "session_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_study_agent_preferences": { - "name": "pdr_ai_v2_study_agent_preferences", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "session_id": { - "name": "session_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "preferences": { - "name": "preferences", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "study_agent_preferences_user_idx": { - "name": "study_agent_preferences_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "study_agent_preferences_session_idx": { - "name": "study_agent_preferences_session_idx", - "columns": [ - { - "expression": "session_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_study_agent_preferences_session_id_pdr_ai_v2_study_agent_sessions_id_fk": { - "name": "pdr_ai_v2_study_agent_preferences_session_id_pdr_ai_v2_study_agent_sessions_id_fk", - "tableFrom": "pdr_ai_v2_study_agent_preferences", - "tableTo": "pdr_ai_v2_study_agent_sessions", - "columnsFrom": [ - "session_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_study_agent_profile": { - "name": "pdr_ai_v2_study_agent_profile", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "session_id": { - "name": "session_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "grade": { - "name": "grade", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "gender": { - "name": "gender", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "field_of_study": { - "name": "field_of_study", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "study_agent_profile_user_idx": { - "name": "study_agent_profile_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "study_agent_profile_session_idx": { - "name": "study_agent_profile_session_idx", - "columns": [ - { - "expression": "session_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_study_agent_profile_session_id_pdr_ai_v2_study_agent_sessions_id_fk": { - "name": "pdr_ai_v2_study_agent_profile_session_id_pdr_ai_v2_study_agent_sessions_id_fk", - "tableFrom": "pdr_ai_v2_study_agent_profile", - "tableTo": "pdr_ai_v2_study_agent_sessions", - "columnsFrom": [ - "session_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_study_agent_sessions": { - "name": "pdr_ai_v2_study_agent_sessions", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'Default Session'" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "study_agent_sessions_user_idx": { - "name": "study_agent_sessions_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": {}, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/drizzle/meta/0009_snapshot.json b/drizzle/meta/0009_snapshot.json deleted file mode 100644 index e521ec78..00000000 --- a/drizzle/meta/0009_snapshot.json +++ /dev/null @@ -1,2560 +0,0 @@ -{ - "id": "1a40c530-99e7-4bc3-b04e-2f4a303c1ebf", - "prevId": "0a5473c6-5c14-4514-95d0-2e0e3b73bfab", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.pdr_ai_v2_chat_history": { - "name": "pdr_ai_v2_chat_history", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "document_id": { - "name": "document_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "document_title": { - "name": "document_title", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "question": { - "name": "question", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "response": { - "name": "response", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "chat_id": { - "name": "chat_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": false - }, - "query_type": { - "name": "query_type", - "type": "varchar(20)", - "primaryKey": false, - "notNull": false, - "default": "'simple'" - }, - "pages": { - "name": "pages", - "type": "integer[]", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "chat_history_user_id_idx": { - "name": "chat_history_user_id_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "chat_history_user_id_created_at_idx": { - "name": "chat_history_user_id_created_at_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "chat_history_document_id_idx": { - "name": "chat_history_document_id_idx", - "columns": [ - { - "expression": "document_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_chat_history_document_id_pdr_ai_v2_document_id_fk": { - "name": "pdr_ai_v2_chat_history_document_id_pdr_ai_v2_document_id_fk", - "tableFrom": "pdr_ai_v2_chat_history", - "tableTo": "pdr_ai_v2_document", - "columnsFrom": [ - "document_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_category": { - "name": "pdr_ai_v2_category", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "company_id": { - "name": "company_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "category_company_id_idx": { - "name": "category_company_id_idx", - "columns": [ - { - "expression": "company_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_category_company_id_pdr_ai_v2_company_id_fk": { - "name": "pdr_ai_v2_category_company_id_pdr_ai_v2_company_id_fk", - "tableFrom": "pdr_ai_v2_category", - "tableTo": "pdr_ai_v2_company", - "columnsFrom": [ - "company_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_company": { - "name": "pdr_ai_v2_company", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "employerPasskey": { - "name": "employerPasskey", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "employeePasskey": { - "name": "employeePasskey", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "numberOfEmployees": { - "name": "numberOfEmployees", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_document": { - "name": "pdr_ai_v2_document", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "url": { - "name": "url", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "company_id": { - "name": "company_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "ocr_enabled": { - "name": "ocr_enabled", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "default": false - }, - "ocr_processed": { - "name": "ocr_processed", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "default": false - }, - "ocr_metadata": { - "name": "ocr_metadata", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "document_company_id_idx": { - "name": "document_company_id_idx", - "columns": [ - { - "expression": "company_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "document_company_id_id_idx": { - "name": "document_company_id_id_idx", - "columns": [ - { - "expression": "company_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "document_company_id_category_idx": { - "name": "document_company_id_category_idx", - "columns": [ - { - "expression": "company_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "category", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_document_company_id_pdr_ai_v2_company_id_fk": { - "name": "pdr_ai_v2_document_company_id_pdr_ai_v2_company_id_fk", - "tableFrom": "pdr_ai_v2_document", - "tableTo": "pdr_ai_v2_company", - "columnsFrom": [ - "company_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_document_reference_resolutions": { - "name": "pdr_ai_v2_document_reference_resolutions", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "company_id": { - "name": "company_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "reference_name": { - "name": "reference_name", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "resolved_in_document_id": { - "name": "resolved_in_document_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "resolution_details": { - "name": "resolution_details", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "document_reference_resolutions_company_ref_idx": { - "name": "document_reference_resolutions_company_ref_idx", - "columns": [ - { - "expression": "company_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_document_reference_resolutions_company_id_pdr_ai_v2_company_id_fk": { - "name": "pdr_ai_v2_document_reference_resolutions_company_id_pdr_ai_v2_company_id_fk", - "tableFrom": "pdr_ai_v2_document_reference_resolutions", - "tableTo": "pdr_ai_v2_company", - "columnsFrom": [ - "company_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_pdf_chunks": { - "name": "pdr_ai_v2_pdf_chunks", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "document_id": { - "name": "document_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "page": { - "name": "page", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "chunk_index": { - "name": "chunk_index", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "content": { - "name": "content", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "embedding": { - "name": "embedding", - "type": "vector(1536)", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "pdf_chunks_document_id_idx": { - "name": "pdf_chunks_document_id_idx", - "columns": [ - { - "expression": "document_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "pdf_chunks_document_id_page_idx": { - "name": "pdf_chunks_document_id_page_idx", - "columns": [ - { - "expression": "document_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "page", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "pdf_chunks_document_id_page_chunk_idx": { - "name": "pdf_chunks_document_id_page_chunk_idx", - "columns": [ - { - "expression": "document_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "page", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "chunk_index", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_pdf_chunks_document_id_pdr_ai_v2_document_id_fk": { - "name": "pdr_ai_v2_pdf_chunks_document_id_pdr_ai_v2_document_id_fk", - "tableFrom": "pdr_ai_v2_pdf_chunks", - "tableTo": "pdr_ai_v2_document", - "columnsFrom": [ - "document_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_predictive_document_analysis_results": { - "name": "pdr_ai_v2_predictive_document_analysis_results", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "document_id": { - "name": "document_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "analysis_type": { - "name": "analysis_type", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "include_related_docs": { - "name": "include_related_docs", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "default": false - }, - "result_json": { - "name": "result_json", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - } - }, - "indexes": { - "predictive_analysis_document_id_idx": { - "name": "predictive_analysis_document_id_idx", - "columns": [ - { - "expression": "document_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_predictive_document_analysis_results_document_id_pdr_ai_v2_document_id_fk": { - "name": "pdr_ai_v2_predictive_document_analysis_results_document_id_pdr_ai_v2_document_id_fk", - "tableFrom": "pdr_ai_v2_predictive_document_analysis_results", - "tableTo": "pdr_ai_v2_document", - "columnsFrom": [ - "document_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_users": { - "name": "pdr_ai_v2_users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "userId": { - "name": "userId", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "company_id": { - "name": "company_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "role": { - "name": "role", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "users_company_id_idx": { - "name": "users_company_id_idx", - "columns": [ - { - "expression": "company_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "users_user_id_idx": { - "name": "users_user_id_idx", - "columns": [ - { - "expression": "userId", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_users_company_id_pdr_ai_v2_company_id_fk": { - "name": "pdr_ai_v2_users_company_id_pdr_ai_v2_company_id_fk", - "tableFrom": "pdr_ai_v2_users", - "tableTo": "pdr_ai_v2_company", - "columnsFrom": [ - "company_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "pdr_ai_v2_users_userId_unique": { - "name": "pdr_ai_v2_users_userId_unique", - "nullsNotDistinct": false, - "columns": [ - "userId" - ] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_agent_ai_chatbot_chat": { - "name": "pdr_ai_v2_agent_ai_chatbot_chat", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar(256)", - "primaryKey": true, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "visibility": { - "name": "visibility", - "type": "varchar(20)", - "primaryKey": false, - "notNull": true, - "default": "'private'" - }, - "agent_mode": { - "name": "agent_mode", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true, - "default": "'interactive'" - }, - "status": { - "name": "status", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true, - "default": "'active'" - }, - "ai_style": { - "name": "ai_style", - "type": "varchar(50)", - "primaryKey": false, - "notNull": false, - "default": "'concise'" - }, - "ai_persona": { - "name": "ai_persona", - "type": "varchar(50)", - "primaryKey": false, - "notNull": false, - "default": "'general'" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_agent_ai_chatbot_document": { - "name": "pdr_ai_v2_agent_ai_chatbot_document", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "content": { - "name": "content", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "kind": { - "name": "kind", - "type": "varchar(20)", - "primaryKey": false, - "notNull": true, - "default": "'text'" - }, - "user_id": { - "name": "user_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "chat_id": { - "name": "chat_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": false - }, - "task_id": { - "name": "task_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "pdr_ai_v2_agent_ai_chatbot_document_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk": { - "name": "pdr_ai_v2_agent_ai_chatbot_document_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk", - "tableFrom": "pdr_ai_v2_agent_ai_chatbot_document", - "tableTo": "pdr_ai_v2_agent_ai_chatbot_chat", - "columnsFrom": [ - "chat_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "pdr_ai_v2_agent_ai_chatbot_document_task_id_pdr_ai_v2_agent_ai_chatbot_task_id_fk": { - "name": "pdr_ai_v2_agent_ai_chatbot_document_task_id_pdr_ai_v2_agent_ai_chatbot_task_id_fk", - "tableFrom": "pdr_ai_v2_agent_ai_chatbot_document", - "tableTo": "pdr_ai_v2_agent_ai_chatbot_task", - "columnsFrom": [ - "task_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "pdr_ai_v2_agent_ai_chatbot_document_id_created_at_pk": { - "name": "pdr_ai_v2_agent_ai_chatbot_document_id_created_at_pk", - "columns": [ - "id", - "created_at" - ] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_agent_ai_chatbot_execution_step": { - "name": "pdr_ai_v2_agent_ai_chatbot_execution_step", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar(256)", - "primaryKey": true, - "notNull": true - }, - "task_id": { - "name": "task_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "step_number": { - "name": "step_number", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "step_type": { - "name": "step_type", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "reasoning": { - "name": "reasoning", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "input": { - "name": "input", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "output": { - "name": "output", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true, - "default": "'pending'" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "completed_at": { - "name": "completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "agent_execution_step_task_step_idx": { - "name": "agent_execution_step_task_step_idx", - "columns": [ - { - "expression": "task_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "step_number", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_agent_ai_chatbot_execution_step_task_id_pdr_ai_v2_agent_ai_chatbot_task_id_fk": { - "name": "pdr_ai_v2_agent_ai_chatbot_execution_step_task_id_pdr_ai_v2_agent_ai_chatbot_task_id_fk", - "tableFrom": "pdr_ai_v2_agent_ai_chatbot_execution_step", - "tableTo": "pdr_ai_v2_agent_ai_chatbot_task", - "columnsFrom": [ - "task_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_agent_ai_chatbot_memory": { - "name": "pdr_ai_v2_agent_ai_chatbot_memory", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar(256)", - "primaryKey": true, - "notNull": true - }, - "chat_id": { - "name": "chat_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "memory_type": { - "name": "memory_type", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true - }, - "key": { - "name": "key", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "value": { - "name": "value", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "importance": { - "name": "importance", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 5 - }, - "embedding": { - "name": "embedding", - "type": "vector(1536)", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "accessed_at": { - "name": "accessed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "agent_memory_chat_idx": { - "name": "agent_memory_chat_idx", - "columns": [ - { - "expression": "chat_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "agent_memory_chat_type_idx": { - "name": "agent_memory_chat_type_idx", - "columns": [ - { - "expression": "chat_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "memory_type", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_agent_ai_chatbot_memory_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk": { - "name": "pdr_ai_v2_agent_ai_chatbot_memory_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk", - "tableFrom": "pdr_ai_v2_agent_ai_chatbot_memory", - "tableTo": "pdr_ai_v2_agent_ai_chatbot_chat", - "columnsFrom": [ - "chat_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_agent_ai_chatbot_message": { - "name": "pdr_ai_v2_agent_ai_chatbot_message", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar(256)", - "primaryKey": true, - "notNull": true - }, - "chat_id": { - "name": "chat_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "role": { - "name": "role", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true - }, - "content": { - "name": "content", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "message_type": { - "name": "message_type", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true, - "default": "'text'" - }, - "parent_message_id": { - "name": "parent_message_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - } - }, - "indexes": {}, - "foreignKeys": { - "pdr_ai_v2_agent_ai_chatbot_message_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk": { - "name": "pdr_ai_v2_agent_ai_chatbot_message_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk", - "tableFrom": "pdr_ai_v2_agent_ai_chatbot_message", - "tableTo": "pdr_ai_v2_agent_ai_chatbot_chat", - "columnsFrom": [ - "chat_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_agent_ai_chatbot_suggestion": { - "name": "pdr_ai_v2_agent_ai_chatbot_suggestion", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar(256)", - "primaryKey": true, - "notNull": true - }, - "document_id": { - "name": "document_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "document_created_at": { - "name": "document_created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "original_text": { - "name": "original_text", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "suggested_text": { - "name": "suggested_text", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_resolved": { - "name": "is_resolved", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "user_id": { - "name": "user_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - } - }, - "indexes": {}, - "foreignKeys": { - "pdr_ai_v2_agent_ai_chatbot_suggestion_document_id_document_created_at_pdr_ai_v2_agent_ai_chatbot_document_id_created_at_fk": { - "name": "pdr_ai_v2_agent_ai_chatbot_suggestion_document_id_document_created_at_pdr_ai_v2_agent_ai_chatbot_document_id_created_at_fk", - "tableFrom": "pdr_ai_v2_agent_ai_chatbot_suggestion", - "tableTo": "pdr_ai_v2_agent_ai_chatbot_document", - "columnsFrom": [ - "document_id", - "document_created_at" - ], - "columnsTo": [ - "id", - "created_at" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_agent_ai_chatbot_task": { - "name": "pdr_ai_v2_agent_ai_chatbot_task", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar(256)", - "primaryKey": true, - "notNull": true - }, - "chat_id": { - "name": "chat_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "objective": { - "name": "objective", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true, - "default": "'pending'" - }, - "priority": { - "name": "priority", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "result": { - "name": "result", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "metadata": { - "name": "metadata", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "completed_at": { - "name": "completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "pdr_ai_v2_agent_ai_chatbot_task_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk": { - "name": "pdr_ai_v2_agent_ai_chatbot_task_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk", - "tableFrom": "pdr_ai_v2_agent_ai_chatbot_task", - "tableTo": "pdr_ai_v2_agent_ai_chatbot_chat", - "columnsFrom": [ - "chat_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_agent_ai_chatbot_tool_call": { - "name": "pdr_ai_v2_agent_ai_chatbot_tool_call", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar(256)", - "primaryKey": true, - "notNull": true - }, - "message_id": { - "name": "message_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "task_id": { - "name": "task_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": false - }, - "tool_name": { - "name": "tool_name", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "tool_input": { - "name": "tool_input", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "tool_output": { - "name": "tool_output", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true, - "default": "'pending'" - }, - "error_message": { - "name": "error_message", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "execution_time_ms": { - "name": "execution_time_ms", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "completed_at": { - "name": "completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "pdr_ai_v2_agent_ai_chatbot_tool_call_message_id_pdr_ai_v2_agent_ai_chatbot_message_id_fk": { - "name": "pdr_ai_v2_agent_ai_chatbot_tool_call_message_id_pdr_ai_v2_agent_ai_chatbot_message_id_fk", - "tableFrom": "pdr_ai_v2_agent_ai_chatbot_tool_call", - "tableTo": "pdr_ai_v2_agent_ai_chatbot_message", - "columnsFrom": [ - "message_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "pdr_ai_v2_agent_ai_chatbot_tool_call_task_id_pdr_ai_v2_agent_ai_chatbot_task_id_fk": { - "name": "pdr_ai_v2_agent_ai_chatbot_tool_call_task_id_pdr_ai_v2_agent_ai_chatbot_task_id_fk", - "tableFrom": "pdr_ai_v2_agent_ai_chatbot_tool_call", - "tableTo": "pdr_ai_v2_agent_ai_chatbot_task", - "columnsFrom": [ - "task_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_agent_ai_chatbot_tool_registry": { - "name": "pdr_ai_v2_agent_ai_chatbot_tool_registry", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar(256)", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "varchar(100)", - "primaryKey": false, - "notNull": true - }, - "schema": { - "name": "schema", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "is_enabled": { - "name": "is_enabled", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "required_permissions": { - "name": "required_permissions", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "rate_limit": { - "name": "rate_limit", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "pdr_ai_v2_agent_ai_chatbot_tool_registry_name_unique": { - "name": "pdr_ai_v2_agent_ai_chatbot_tool_registry_name_unique", - "nullsNotDistinct": false, - "columns": [ - "name" - ] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_agent_ai_chatbot_vote": { - "name": "pdr_ai_v2_agent_ai_chatbot_vote", - "schema": "", - "columns": { - "chat_id": { - "name": "chat_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "message_id": { - "name": "message_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "is_upvoted": { - "name": "is_upvoted", - "type": "boolean", - "primaryKey": false, - "notNull": true - }, - "feedback": { - "name": "feedback", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - } - }, - "indexes": {}, - "foreignKeys": { - "pdr_ai_v2_agent_ai_chatbot_vote_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk": { - "name": "pdr_ai_v2_agent_ai_chatbot_vote_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk", - "tableFrom": "pdr_ai_v2_agent_ai_chatbot_vote", - "tableTo": "pdr_ai_v2_agent_ai_chatbot_chat", - "columnsFrom": [ - "chat_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "pdr_ai_v2_agent_ai_chatbot_vote_message_id_pdr_ai_v2_agent_ai_chatbot_message_id_fk": { - "name": "pdr_ai_v2_agent_ai_chatbot_vote_message_id_pdr_ai_v2_agent_ai_chatbot_message_id_fk", - "tableFrom": "pdr_ai_v2_agent_ai_chatbot_vote", - "tableTo": "pdr_ai_v2_agent_ai_chatbot_message", - "columnsFrom": [ - "message_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "pdr_ai_v2_agent_ai_chatbot_vote_chat_id_message_id_pk": { - "name": "pdr_ai_v2_agent_ai_chatbot_vote_chat_id_message_id_pk", - "columns": [ - "chat_id", - "message_id" - ] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_study_agent_goals": { - "name": "pdr_ai_v2_study_agent_goals", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "session_id": { - "name": "session_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "materials": { - "name": "materials", - "type": "text[]", - "primaryKey": false, - "notNull": false, - "default": "'{}'" - }, - "completed": { - "name": "completed", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "study_agent_goals_user_idx": { - "name": "study_agent_goals_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "study_agent_goals_session_idx": { - "name": "study_agent_goals_session_idx", - "columns": [ - { - "expression": "session_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_study_agent_goals_session_id_pdr_ai_v2_study_agent_sessions_id_fk": { - "name": "pdr_ai_v2_study_agent_goals_session_id_pdr_ai_v2_study_agent_sessions_id_fk", - "tableFrom": "pdr_ai_v2_study_agent_goals", - "tableTo": "pdr_ai_v2_study_agent_sessions", - "columnsFrom": [ - "session_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_study_agent_messages": { - "name": "pdr_ai_v2_study_agent_messages", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "original_id": { - "name": "original_id", - "type": "varchar(64)", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "session_id": { - "name": "session_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "role": { - "name": "role", - "type": "varchar(32)", - "primaryKey": false, - "notNull": true - }, - "content": { - "name": "content", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "tts_content": { - "name": "tts_content", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "attached_document": { - "name": "attached_document", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "attached_document_id": { - "name": "attached_document_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "attached_document_url": { - "name": "attached_document_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_voice": { - "name": "is_voice", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "default": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - } - }, - "indexes": { - "study_agent_messages_user_id_idx": { - "name": "study_agent_messages_user_id_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "study_agent_messages_session_id_idx": { - "name": "study_agent_messages_session_id_idx", - "columns": [ - { - "expression": "session_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_study_agent_messages_session_id_pdr_ai_v2_study_agent_sessions_id_fk": { - "name": "pdr_ai_v2_study_agent_messages_session_id_pdr_ai_v2_study_agent_sessions_id_fk", - "tableFrom": "pdr_ai_v2_study_agent_messages", - "tableTo": "pdr_ai_v2_study_agent_sessions", - "columnsFrom": [ - "session_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_study_agent_notes": { - "name": "pdr_ai_v2_study_agent_notes", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "session_id": { - "name": "session_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "content": { - "name": "content", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "tags": { - "name": "tags", - "type": "text[]", - "primaryKey": false, - "notNull": false, - "default": "'{}'" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "study_agent_notes_user_idx": { - "name": "study_agent_notes_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "study_agent_notes_session_idx": { - "name": "study_agent_notes_session_idx", - "columns": [ - { - "expression": "session_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_study_agent_notes_session_id_pdr_ai_v2_study_agent_sessions_id_fk": { - "name": "pdr_ai_v2_study_agent_notes_session_id_pdr_ai_v2_study_agent_sessions_id_fk", - "tableFrom": "pdr_ai_v2_study_agent_notes", - "tableTo": "pdr_ai_v2_study_agent_sessions", - "columnsFrom": [ - "session_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_study_agent_pomodoro_settings": { - "name": "pdr_ai_v2_study_agent_pomodoro_settings", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "session_id": { - "name": "session_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "focus_minutes": { - "name": "focus_minutes", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 25 - }, - "short_break_minutes": { - "name": "short_break_minutes", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 5 - }, - "long_break_minutes": { - "name": "long_break_minutes", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 15 - }, - "remaining_time": { - "name": "remaining_time", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "sessions_before_long_break": { - "name": "sessions_before_long_break", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 4 - }, - "auto_start_breaks": { - "name": "auto_start_breaks", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "auto_start_pomodoros": { - "name": "auto_start_pomodoros", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "study_agent_pomodoro_settings_user_idx": { - "name": "study_agent_pomodoro_settings_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "study_agent_pomodoro_settings_session_idx": { - "name": "study_agent_pomodoro_settings_session_idx", - "columns": [ - { - "expression": "session_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_study_agent_pomodoro_settings_session_id_pdr_ai_v2_study_agent_sessions_id_fk": { - "name": "pdr_ai_v2_study_agent_pomodoro_settings_session_id_pdr_ai_v2_study_agent_sessions_id_fk", - "tableFrom": "pdr_ai_v2_study_agent_pomodoro_settings", - "tableTo": "pdr_ai_v2_study_agent_sessions", - "columnsFrom": [ - "session_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_study_agent_preferences": { - "name": "pdr_ai_v2_study_agent_preferences", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "session_id": { - "name": "session_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "preferences": { - "name": "preferences", - "type": "jsonb", - "primaryKey": false, - "notNull": true, - "default": "'{}'::jsonb" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "study_agent_preferences_user_idx": { - "name": "study_agent_preferences_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "study_agent_preferences_session_idx": { - "name": "study_agent_preferences_session_idx", - "columns": [ - { - "expression": "session_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_study_agent_preferences_session_id_pdr_ai_v2_study_agent_sessions_id_fk": { - "name": "pdr_ai_v2_study_agent_preferences_session_id_pdr_ai_v2_study_agent_sessions_id_fk", - "tableFrom": "pdr_ai_v2_study_agent_preferences", - "tableTo": "pdr_ai_v2_study_agent_sessions", - "columnsFrom": [ - "session_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_study_agent_profile": { - "name": "pdr_ai_v2_study_agent_profile", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "session_id": { - "name": "session_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "grade": { - "name": "grade", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "gender": { - "name": "gender", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "field_of_study": { - "name": "field_of_study", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "study_agent_profile_user_idx": { - "name": "study_agent_profile_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "study_agent_profile_session_idx": { - "name": "study_agent_profile_session_idx", - "columns": [ - { - "expression": "session_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_study_agent_profile_session_id_pdr_ai_v2_study_agent_sessions_id_fk": { - "name": "pdr_ai_v2_study_agent_profile_session_id_pdr_ai_v2_study_agent_sessions_id_fk", - "tableFrom": "pdr_ai_v2_study_agent_profile", - "tableTo": "pdr_ai_v2_study_agent_sessions", - "columnsFrom": [ - "session_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_study_agent_sessions": { - "name": "pdr_ai_v2_study_agent_sessions", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'Default Session'" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "study_agent_sessions_user_idx": { - "name": "study_agent_sessions_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": {}, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/drizzle/meta/0011_snapshot.json b/drizzle/meta/0011_snapshot.json deleted file mode 100644 index 465f0c5e..00000000 --- a/drizzle/meta/0011_snapshot.json +++ /dev/null @@ -1,2603 +0,0 @@ -{ - "id": "e8e1c54d-e410-49f6-b1f7-05b857de5265", - "prevId": "1a40c530-99e7-4bc3-b04e-2f4a303c1ebf", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.pdr_ai_v2_study_agent_messages": { - "name": "pdr_ai_v2_study_agent_messages", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "original_id": { - "name": "original_id", - "type": "varchar(64)", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "session_id": { - "name": "session_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "role": { - "name": "role", - "type": "varchar(32)", - "primaryKey": false, - "notNull": true - }, - "content": { - "name": "content", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "tts_content": { - "name": "tts_content", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "attached_document": { - "name": "attached_document", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "attached_document_id": { - "name": "attached_document_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "attached_document_url": { - "name": "attached_document_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_voice": { - "name": "is_voice", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "default": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - } - }, - "indexes": { - "study_agent_messages_user_id_idx": { - "name": "study_agent_messages_user_id_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "study_agent_messages_session_id_idx": { - "name": "study_agent_messages_session_id_idx", - "columns": [ - { - "expression": "session_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_study_agent_messages_session_id_pdr_ai_v2_study_agent_sessions_id_fk": { - "name": "pdr_ai_v2_study_agent_messages_session_id_pdr_ai_v2_study_agent_sessions_id_fk", - "tableFrom": "pdr_ai_v2_study_agent_messages", - "tableTo": "pdr_ai_v2_study_agent_sessions", - "columnsFrom": [ - "session_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_chat_history": { - "name": "pdr_ai_v2_chat_history", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "document_id": { - "name": "document_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "document_title": { - "name": "document_title", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "question": { - "name": "question", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "response": { - "name": "response", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "chat_id": { - "name": "chat_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": false - }, - "query_type": { - "name": "query_type", - "type": "varchar(20)", - "primaryKey": false, - "notNull": false, - "default": "'simple'" - }, - "pages": { - "name": "pages", - "type": "integer[]", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "chat_history_user_id_idx": { - "name": "chat_history_user_id_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "chat_history_user_id_created_at_idx": { - "name": "chat_history_user_id_created_at_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "chat_history_document_id_idx": { - "name": "chat_history_document_id_idx", - "columns": [ - { - "expression": "document_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_chat_history_document_id_pdr_ai_v2_document_id_fk": { - "name": "pdr_ai_v2_chat_history_document_id_pdr_ai_v2_document_id_fk", - "tableFrom": "pdr_ai_v2_chat_history", - "tableTo": "pdr_ai_v2_document", - "columnsFrom": [ - "document_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_category": { - "name": "pdr_ai_v2_category", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "company_id": { - "name": "company_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "category_company_id_idx": { - "name": "category_company_id_idx", - "columns": [ - { - "expression": "company_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_category_company_id_pdr_ai_v2_company_id_fk": { - "name": "pdr_ai_v2_category_company_id_pdr_ai_v2_company_id_fk", - "tableFrom": "pdr_ai_v2_category", - "tableTo": "pdr_ai_v2_company", - "columnsFrom": [ - "company_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_company": { - "name": "pdr_ai_v2_company", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "employerPasskey": { - "name": "employerPasskey", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "employeePasskey": { - "name": "employeePasskey", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "numberOfEmployees": { - "name": "numberOfEmployees", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_document": { - "name": "pdr_ai_v2_document", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "url": { - "name": "url", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "company_id": { - "name": "company_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "ocr_enabled": { - "name": "ocr_enabled", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "default": false - }, - "ocr_processed": { - "name": "ocr_processed", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "default": false - }, - "ocr_metadata": { - "name": "ocr_metadata", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "document_company_id_idx": { - "name": "document_company_id_idx", - "columns": [ - { - "expression": "company_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "document_company_id_id_idx": { - "name": "document_company_id_id_idx", - "columns": [ - { - "expression": "company_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "document_company_id_category_idx": { - "name": "document_company_id_category_idx", - "columns": [ - { - "expression": "company_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "category", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_document_company_id_pdr_ai_v2_company_id_fk": { - "name": "pdr_ai_v2_document_company_id_pdr_ai_v2_company_id_fk", - "tableFrom": "pdr_ai_v2_document", - "tableTo": "pdr_ai_v2_company", - "columnsFrom": [ - "company_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_document_reference_resolutions": { - "name": "pdr_ai_v2_document_reference_resolutions", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "company_id": { - "name": "company_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "reference_name": { - "name": "reference_name", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "resolved_in_document_id": { - "name": "resolved_in_document_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "resolution_details": { - "name": "resolution_details", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "document_reference_resolutions_company_ref_idx": { - "name": "document_reference_resolutions_company_ref_idx", - "columns": [ - { - "expression": "company_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_document_reference_resolutions_company_id_pdr_ai_v2_company_id_fk": { - "name": "pdr_ai_v2_document_reference_resolutions_company_id_pdr_ai_v2_company_id_fk", - "tableFrom": "pdr_ai_v2_document_reference_resolutions", - "tableTo": "pdr_ai_v2_company", - "columnsFrom": [ - "company_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_pdf_chunks": { - "name": "pdr_ai_v2_pdf_chunks", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "document_id": { - "name": "document_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "page": { - "name": "page", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "chunk_index": { - "name": "chunk_index", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "content": { - "name": "content", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "embedding": { - "name": "embedding", - "type": "vector(1536)", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "pdf_chunks_document_id_idx": { - "name": "pdf_chunks_document_id_idx", - "columns": [ - { - "expression": "document_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "pdf_chunks_document_id_page_idx": { - "name": "pdf_chunks_document_id_page_idx", - "columns": [ - { - "expression": "document_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "page", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "pdf_chunks_document_id_page_chunk_idx": { - "name": "pdf_chunks_document_id_page_chunk_idx", - "columns": [ - { - "expression": "document_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "page", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "chunk_index", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_pdf_chunks_document_id_pdr_ai_v2_document_id_fk": { - "name": "pdr_ai_v2_pdf_chunks_document_id_pdr_ai_v2_document_id_fk", - "tableFrom": "pdr_ai_v2_pdf_chunks", - "tableTo": "pdr_ai_v2_document", - "columnsFrom": [ - "document_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_predictive_document_analysis_results": { - "name": "pdr_ai_v2_predictive_document_analysis_results", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "document_id": { - "name": "document_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "analysis_type": { - "name": "analysis_type", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "include_related_docs": { - "name": "include_related_docs", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "default": false - }, - "result_json": { - "name": "result_json", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - } - }, - "indexes": { - "predictive_analysis_document_id_idx": { - "name": "predictive_analysis_document_id_idx", - "columns": [ - { - "expression": "document_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_predictive_document_analysis_results_document_id_pdr_ai_v2_document_id_fk": { - "name": "pdr_ai_v2_predictive_document_analysis_results_document_id_pdr_ai_v2_document_id_fk", - "tableFrom": "pdr_ai_v2_predictive_document_analysis_results", - "tableTo": "pdr_ai_v2_document", - "columnsFrom": [ - "document_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_users": { - "name": "pdr_ai_v2_users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "userId": { - "name": "userId", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "company_id": { - "name": "company_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "role": { - "name": "role", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "users_company_id_idx": { - "name": "users_company_id_idx", - "columns": [ - { - "expression": "company_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "users_user_id_idx": { - "name": "users_user_id_idx", - "columns": [ - { - "expression": "userId", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_users_company_id_pdr_ai_v2_company_id_fk": { - "name": "pdr_ai_v2_users_company_id_pdr_ai_v2_company_id_fk", - "tableFrom": "pdr_ai_v2_users", - "tableTo": "pdr_ai_v2_company", - "columnsFrom": [ - "company_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "pdr_ai_v2_users_userId_unique": { - "name": "pdr_ai_v2_users_userId_unique", - "nullsNotDistinct": false, - "columns": [ - "userId" - ] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_agent_ai_chatbot_chat": { - "name": "pdr_ai_v2_agent_ai_chatbot_chat", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar(256)", - "primaryKey": true, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "visibility": { - "name": "visibility", - "type": "varchar(20)", - "primaryKey": false, - "notNull": true, - "default": "'private'" - }, - "agent_mode": { - "name": "agent_mode", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true, - "default": "'interactive'" - }, - "status": { - "name": "status", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true, - "default": "'active'" - }, - "ai_style": { - "name": "ai_style", - "type": "varchar(50)", - "primaryKey": false, - "notNull": false, - "default": "'concise'" - }, - "ai_persona": { - "name": "ai_persona", - "type": "varchar(50)", - "primaryKey": false, - "notNull": false, - "default": "'general'" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_agent_ai_chatbot_document": { - "name": "pdr_ai_v2_agent_ai_chatbot_document", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "content": { - "name": "content", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "kind": { - "name": "kind", - "type": "varchar(20)", - "primaryKey": false, - "notNull": true, - "default": "'text'" - }, - "user_id": { - "name": "user_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "chat_id": { - "name": "chat_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": false - }, - "task_id": { - "name": "task_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "pdr_ai_v2_agent_ai_chatbot_document_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk": { - "name": "pdr_ai_v2_agent_ai_chatbot_document_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk", - "tableFrom": "pdr_ai_v2_agent_ai_chatbot_document", - "tableTo": "pdr_ai_v2_agent_ai_chatbot_chat", - "columnsFrom": [ - "chat_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "pdr_ai_v2_agent_ai_chatbot_document_task_id_pdr_ai_v2_agent_ai_chatbot_task_id_fk": { - "name": "pdr_ai_v2_agent_ai_chatbot_document_task_id_pdr_ai_v2_agent_ai_chatbot_task_id_fk", - "tableFrom": "pdr_ai_v2_agent_ai_chatbot_document", - "tableTo": "pdr_ai_v2_agent_ai_chatbot_task", - "columnsFrom": [ - "task_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "pdr_ai_v2_agent_ai_chatbot_document_id_created_at_pk": { - "name": "pdr_ai_v2_agent_ai_chatbot_document_id_created_at_pk", - "columns": [ - "id", - "created_at" - ] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_agent_ai_chatbot_execution_step": { - "name": "pdr_ai_v2_agent_ai_chatbot_execution_step", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar(256)", - "primaryKey": true, - "notNull": true - }, - "task_id": { - "name": "task_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "step_number": { - "name": "step_number", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "step_type": { - "name": "step_type", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "reasoning": { - "name": "reasoning", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "input": { - "name": "input", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "output": { - "name": "output", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true, - "default": "'pending'" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "completed_at": { - "name": "completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "agent_execution_step_task_step_idx": { - "name": "agent_execution_step_task_step_idx", - "columns": [ - { - "expression": "task_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "step_number", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_agent_ai_chatbot_execution_step_task_id_pdr_ai_v2_agent_ai_chatbot_task_id_fk": { - "name": "pdr_ai_v2_agent_ai_chatbot_execution_step_task_id_pdr_ai_v2_agent_ai_chatbot_task_id_fk", - "tableFrom": "pdr_ai_v2_agent_ai_chatbot_execution_step", - "tableTo": "pdr_ai_v2_agent_ai_chatbot_task", - "columnsFrom": [ - "task_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_agent_ai_chatbot_memory": { - "name": "pdr_ai_v2_agent_ai_chatbot_memory", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar(256)", - "primaryKey": true, - "notNull": true - }, - "chat_id": { - "name": "chat_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "memory_type": { - "name": "memory_type", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true - }, - "key": { - "name": "key", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "value": { - "name": "value", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "importance": { - "name": "importance", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 5 - }, - "embedding": { - "name": "embedding", - "type": "vector(1536)", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "accessed_at": { - "name": "accessed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "agent_memory_chat_idx": { - "name": "agent_memory_chat_idx", - "columns": [ - { - "expression": "chat_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "agent_memory_chat_type_idx": { - "name": "agent_memory_chat_type_idx", - "columns": [ - { - "expression": "chat_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "memory_type", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_agent_ai_chatbot_memory_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk": { - "name": "pdr_ai_v2_agent_ai_chatbot_memory_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk", - "tableFrom": "pdr_ai_v2_agent_ai_chatbot_memory", - "tableTo": "pdr_ai_v2_agent_ai_chatbot_chat", - "columnsFrom": [ - "chat_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_agent_ai_chatbot_message": { - "name": "pdr_ai_v2_agent_ai_chatbot_message", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar(256)", - "primaryKey": true, - "notNull": true - }, - "chat_id": { - "name": "chat_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "role": { - "name": "role", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true - }, - "content": { - "name": "content", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "message_type": { - "name": "message_type", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true, - "default": "'text'" - }, - "parent_message_id": { - "name": "parent_message_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - } - }, - "indexes": {}, - "foreignKeys": { - "pdr_ai_v2_agent_ai_chatbot_message_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk": { - "name": "pdr_ai_v2_agent_ai_chatbot_message_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk", - "tableFrom": "pdr_ai_v2_agent_ai_chatbot_message", - "tableTo": "pdr_ai_v2_agent_ai_chatbot_chat", - "columnsFrom": [ - "chat_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_agent_ai_chatbot_suggestion": { - "name": "pdr_ai_v2_agent_ai_chatbot_suggestion", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar(256)", - "primaryKey": true, - "notNull": true - }, - "document_id": { - "name": "document_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "document_created_at": { - "name": "document_created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "original_text": { - "name": "original_text", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "suggested_text": { - "name": "suggested_text", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_resolved": { - "name": "is_resolved", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "user_id": { - "name": "user_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - } - }, - "indexes": {}, - "foreignKeys": { - "pdr_ai_v2_agent_ai_chatbot_suggestion_document_id_document_created_at_pdr_ai_v2_agent_ai_chatbot_document_id_created_at_fk": { - "name": "pdr_ai_v2_agent_ai_chatbot_suggestion_document_id_document_created_at_pdr_ai_v2_agent_ai_chatbot_document_id_created_at_fk", - "tableFrom": "pdr_ai_v2_agent_ai_chatbot_suggestion", - "tableTo": "pdr_ai_v2_agent_ai_chatbot_document", - "columnsFrom": [ - "document_id", - "document_created_at" - ], - "columnsTo": [ - "id", - "created_at" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_agent_ai_chatbot_task": { - "name": "pdr_ai_v2_agent_ai_chatbot_task", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar(256)", - "primaryKey": true, - "notNull": true - }, - "chat_id": { - "name": "chat_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "objective": { - "name": "objective", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true, - "default": "'pending'" - }, - "priority": { - "name": "priority", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "result": { - "name": "result", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "metadata": { - "name": "metadata", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "completed_at": { - "name": "completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "pdr_ai_v2_agent_ai_chatbot_task_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk": { - "name": "pdr_ai_v2_agent_ai_chatbot_task_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk", - "tableFrom": "pdr_ai_v2_agent_ai_chatbot_task", - "tableTo": "pdr_ai_v2_agent_ai_chatbot_chat", - "columnsFrom": [ - "chat_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_agent_ai_chatbot_tool_call": { - "name": "pdr_ai_v2_agent_ai_chatbot_tool_call", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar(256)", - "primaryKey": true, - "notNull": true - }, - "message_id": { - "name": "message_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "task_id": { - "name": "task_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": false - }, - "tool_name": { - "name": "tool_name", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "tool_input": { - "name": "tool_input", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "tool_output": { - "name": "tool_output", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true, - "default": "'pending'" - }, - "error_message": { - "name": "error_message", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "execution_time_ms": { - "name": "execution_time_ms", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "completed_at": { - "name": "completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "pdr_ai_v2_agent_ai_chatbot_tool_call_message_id_pdr_ai_v2_agent_ai_chatbot_message_id_fk": { - "name": "pdr_ai_v2_agent_ai_chatbot_tool_call_message_id_pdr_ai_v2_agent_ai_chatbot_message_id_fk", - "tableFrom": "pdr_ai_v2_agent_ai_chatbot_tool_call", - "tableTo": "pdr_ai_v2_agent_ai_chatbot_message", - "columnsFrom": [ - "message_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "pdr_ai_v2_agent_ai_chatbot_tool_call_task_id_pdr_ai_v2_agent_ai_chatbot_task_id_fk": { - "name": "pdr_ai_v2_agent_ai_chatbot_tool_call_task_id_pdr_ai_v2_agent_ai_chatbot_task_id_fk", - "tableFrom": "pdr_ai_v2_agent_ai_chatbot_tool_call", - "tableTo": "pdr_ai_v2_agent_ai_chatbot_task", - "columnsFrom": [ - "task_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_agent_ai_chatbot_tool_registry": { - "name": "pdr_ai_v2_agent_ai_chatbot_tool_registry", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar(256)", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "varchar(100)", - "primaryKey": false, - "notNull": true - }, - "schema": { - "name": "schema", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "is_enabled": { - "name": "is_enabled", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "required_permissions": { - "name": "required_permissions", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "rate_limit": { - "name": "rate_limit", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "pdr_ai_v2_agent_ai_chatbot_tool_registry_name_unique": { - "name": "pdr_ai_v2_agent_ai_chatbot_tool_registry_name_unique", - "nullsNotDistinct": false, - "columns": [ - "name" - ] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_agent_ai_chatbot_vote": { - "name": "pdr_ai_v2_agent_ai_chatbot_vote", - "schema": "", - "columns": { - "chat_id": { - "name": "chat_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "message_id": { - "name": "message_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "is_upvoted": { - "name": "is_upvoted", - "type": "boolean", - "primaryKey": false, - "notNull": true - }, - "feedback": { - "name": "feedback", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - } - }, - "indexes": {}, - "foreignKeys": { - "pdr_ai_v2_agent_ai_chatbot_vote_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk": { - "name": "pdr_ai_v2_agent_ai_chatbot_vote_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk", - "tableFrom": "pdr_ai_v2_agent_ai_chatbot_vote", - "tableTo": "pdr_ai_v2_agent_ai_chatbot_chat", - "columnsFrom": [ - "chat_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "pdr_ai_v2_agent_ai_chatbot_vote_message_id_pdr_ai_v2_agent_ai_chatbot_message_id_fk": { - "name": "pdr_ai_v2_agent_ai_chatbot_vote_message_id_pdr_ai_v2_agent_ai_chatbot_message_id_fk", - "tableFrom": "pdr_ai_v2_agent_ai_chatbot_vote", - "tableTo": "pdr_ai_v2_agent_ai_chatbot_message", - "columnsFrom": [ - "message_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "pdr_ai_v2_agent_ai_chatbot_vote_chat_id_message_id_pk": { - "name": "pdr_ai_v2_agent_ai_chatbot_vote_chat_id_message_id_pk", - "columns": [ - "chat_id", - "message_id" - ] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_study_agent_goals": { - "name": "pdr_ai_v2_study_agent_goals", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "session_id": { - "name": "session_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "materials": { - "name": "materials", - "type": "text[]", - "primaryKey": false, - "notNull": false, - "default": "'{}'" - }, - "completed": { - "name": "completed", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "study_agent_goals_user_idx": { - "name": "study_agent_goals_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "study_agent_goals_session_idx": { - "name": "study_agent_goals_session_idx", - "columns": [ - { - "expression": "session_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_study_agent_goals_session_id_pdr_ai_v2_study_agent_sessions_id_fk": { - "name": "pdr_ai_v2_study_agent_goals_session_id_pdr_ai_v2_study_agent_sessions_id_fk", - "tableFrom": "pdr_ai_v2_study_agent_goals", - "tableTo": "pdr_ai_v2_study_agent_sessions", - "columnsFrom": [ - "session_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_study_agent_notes": { - "name": "pdr_ai_v2_study_agent_notes", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "session_id": { - "name": "session_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "content": { - "name": "content", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "tags": { - "name": "tags", - "type": "text[]", - "primaryKey": false, - "notNull": false, - "default": "'{}'" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "study_agent_notes_user_idx": { - "name": "study_agent_notes_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "study_agent_notes_session_idx": { - "name": "study_agent_notes_session_idx", - "columns": [ - { - "expression": "session_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_study_agent_notes_session_id_pdr_ai_v2_study_agent_sessions_id_fk": { - "name": "pdr_ai_v2_study_agent_notes_session_id_pdr_ai_v2_study_agent_sessions_id_fk", - "tableFrom": "pdr_ai_v2_study_agent_notes", - "tableTo": "pdr_ai_v2_study_agent_sessions", - "columnsFrom": [ - "session_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_study_agent_pomodoro_settings": { - "name": "pdr_ai_v2_study_agent_pomodoro_settings", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "session_id": { - "name": "session_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "focus_minutes": { - "name": "focus_minutes", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 25 - }, - "short_break_minutes": { - "name": "short_break_minutes", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 5 - }, - "long_break_minutes": { - "name": "long_break_minutes", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 15 - }, - "remaining_time": { - "name": "remaining_time", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "sessions_before_long_break": { - "name": "sessions_before_long_break", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 4 - }, - "auto_start_breaks": { - "name": "auto_start_breaks", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "auto_start_pomodoros": { - "name": "auto_start_pomodoros", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "study_agent_pomodoro_settings_user_idx": { - "name": "study_agent_pomodoro_settings_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "study_agent_pomodoro_settings_session_idx": { - "name": "study_agent_pomodoro_settings_session_idx", - "columns": [ - { - "expression": "session_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_study_agent_pomodoro_settings_session_id_pdr_ai_v2_study_agent_sessions_id_fk": { - "name": "pdr_ai_v2_study_agent_pomodoro_settings_session_id_pdr_ai_v2_study_agent_sessions_id_fk", - "tableFrom": "pdr_ai_v2_study_agent_pomodoro_settings", - "tableTo": "pdr_ai_v2_study_agent_sessions", - "columnsFrom": [ - "session_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_study_agent_preferences": { - "name": "pdr_ai_v2_study_agent_preferences", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "session_id": { - "name": "session_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "selected_documents": { - "name": "selected_documents", - "type": "text[]", - "primaryKey": false, - "notNull": true, - "default": "'{}'" - }, - "user_name": { - "name": "user_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "user_grade": { - "name": "user_grade", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "user_gender": { - "name": "user_gender", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "field_of_study": { - "name": "field_of_study", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "study_agent_preferences_user_idx": { - "name": "study_agent_preferences_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "study_agent_preferences_session_idx": { - "name": "study_agent_preferences_session_idx", - "columns": [ - { - "expression": "session_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_study_agent_preferences_session_id_pdr_ai_v2_study_agent_sessions_id_fk": { - "name": "pdr_ai_v2_study_agent_preferences_session_id_pdr_ai_v2_study_agent_sessions_id_fk", - "tableFrom": "pdr_ai_v2_study_agent_preferences", - "tableTo": "pdr_ai_v2_study_agent_sessions", - "columnsFrom": [ - "session_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_study_agent_profile": { - "name": "pdr_ai_v2_study_agent_profile", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "session_id": { - "name": "session_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "ai_name": { - "name": "ai_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "ai_gender": { - "name": "ai_gender", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "ai_extroversion": { - "name": "ai_extroversion", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "ai_intuition": { - "name": "ai_intuition", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "ai_thinking": { - "name": "ai_thinking", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "ai_judging": { - "name": "ai_judging", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "study_agent_profile_user_idx": { - "name": "study_agent_profile_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "study_agent_profile_session_idx": { - "name": "study_agent_profile_session_idx", - "columns": [ - { - "expression": "session_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_study_agent_profile_session_id_pdr_ai_v2_study_agent_sessions_id_fk": { - "name": "pdr_ai_v2_study_agent_profile_session_id_pdr_ai_v2_study_agent_sessions_id_fk", - "tableFrom": "pdr_ai_v2_study_agent_profile", - "tableTo": "pdr_ai_v2_study_agent_sessions", - "columnsFrom": [ - "session_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_study_agent_sessions": { - "name": "pdr_ai_v2_study_agent_sessions", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'Default Session'" - }, - "mode": { - "name": "mode", - "type": "varchar(32)", - "primaryKey": false, - "notNull": true, - "default": "'teacher'" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "study_agent_sessions_user_idx": { - "name": "study_agent_sessions_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": {}, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/drizzle/meta/0012_snapshot.json b/drizzle/meta/0012_snapshot.json deleted file mode 100644 index 35c40468..00000000 --- a/drizzle/meta/0012_snapshot.json +++ /dev/null @@ -1,4326 +0,0 @@ -{ - "id": "4de9fceb-ea1b-4a46-825d-f0d81b816956", - "prevId": "e8e1c54d-e410-49f6-b1f7-05b857de5265", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.pdr_ai_v2_study_agent_messages": { - "name": "pdr_ai_v2_study_agent_messages", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "original_id": { - "name": "original_id", - "type": "varchar(64)", - "primaryKey": false, - "notNull": false - }, - "user_id": { - "name": "user_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "session_id": { - "name": "session_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "role": { - "name": "role", - "type": "varchar(32)", - "primaryKey": false, - "notNull": true - }, - "content": { - "name": "content", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "tts_content": { - "name": "tts_content", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "attached_document": { - "name": "attached_document", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "attached_document_id": { - "name": "attached_document_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "attached_document_url": { - "name": "attached_document_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_voice": { - "name": "is_voice", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "default": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - } - }, - "indexes": { - "study_agent_messages_user_id_idx": { - "name": "study_agent_messages_user_id_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "study_agent_messages_session_id_idx": { - "name": "study_agent_messages_session_id_idx", - "columns": [ - { - "expression": "session_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_study_agent_messages_session_id_pdr_ai_v2_study_agent_sessions_id_fk": { - "name": "pdr_ai_v2_study_agent_messages_session_id_pdr_ai_v2_study_agent_sessions_id_fk", - "tableFrom": "pdr_ai_v2_study_agent_messages", - "tableTo": "pdr_ai_v2_study_agent_sessions", - "columnsFrom": [ - "session_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_chat_history": { - "name": "pdr_ai_v2_chat_history", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "document_id": { - "name": "document_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "document_title": { - "name": "document_title", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "question": { - "name": "question", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "response": { - "name": "response", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "chat_id": { - "name": "chat_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": false - }, - "query_type": { - "name": "query_type", - "type": "varchar(20)", - "primaryKey": false, - "notNull": false, - "default": "'simple'" - }, - "pages": { - "name": "pages", - "type": "integer[]", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "chat_history_user_id_idx": { - "name": "chat_history_user_id_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "chat_history_user_id_created_at_idx": { - "name": "chat_history_user_id_created_at_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "chat_history_document_id_idx": { - "name": "chat_history_document_id_idx", - "columns": [ - { - "expression": "document_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_chat_history_document_id_pdr_ai_v2_document_id_fk": { - "name": "pdr_ai_v2_chat_history_document_id_pdr_ai_v2_document_id_fk", - "tableFrom": "pdr_ai_v2_chat_history", - "tableTo": "pdr_ai_v2_document", - "columnsFrom": [ - "document_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_category": { - "name": "pdr_ai_v2_category", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "company_id": { - "name": "company_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "category_company_id_idx": { - "name": "category_company_id_idx", - "columns": [ - { - "expression": "company_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_category_company_id_pdr_ai_v2_company_id_fk": { - "name": "pdr_ai_v2_category_company_id_pdr_ai_v2_company_id_fk", - "tableFrom": "pdr_ai_v2_category", - "tableTo": "pdr_ai_v2_company", - "columnsFrom": [ - "company_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_company": { - "name": "pdr_ai_v2_company", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "employerPasskey": { - "name": "employerPasskey", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "employeePasskey": { - "name": "employeePasskey", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "numberOfEmployees": { - "name": "numberOfEmployees", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_document": { - "name": "pdr_ai_v2_document", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "url": { - "name": "url", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "company_id": { - "name": "company_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "ocr_enabled": { - "name": "ocr_enabled", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "default": false - }, - "ocr_processed": { - "name": "ocr_processed", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "default": false - }, - "ocr_metadata": { - "name": "ocr_metadata", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "ocr_job_id": { - "name": "ocr_job_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": false - }, - "ocr_provider": { - "name": "ocr_provider", - "type": "varchar(50)", - "primaryKey": false, - "notNull": false - }, - "ocr_confidence_score": { - "name": "ocr_confidence_score", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "ocr_cost_cents": { - "name": "ocr_cost_cents", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "document_company_id_idx": { - "name": "document_company_id_idx", - "columns": [ - { - "expression": "company_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "document_company_id_id_idx": { - "name": "document_company_id_id_idx", - "columns": [ - { - "expression": "company_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "document_company_id_category_idx": { - "name": "document_company_id_category_idx", - "columns": [ - { - "expression": "company_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "category", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_document_company_id_pdr_ai_v2_company_id_fk": { - "name": "pdr_ai_v2_document_company_id_pdr_ai_v2_company_id_fk", - "tableFrom": "pdr_ai_v2_document", - "tableTo": "pdr_ai_v2_company", - "columnsFrom": [ - "company_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_document_reference_resolutions": { - "name": "pdr_ai_v2_document_reference_resolutions", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "company_id": { - "name": "company_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "reference_name": { - "name": "reference_name", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "resolved_in_document_id": { - "name": "resolved_in_document_id", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "resolution_details": { - "name": "resolution_details", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "now()" - } - }, - "indexes": { - "document_reference_resolutions_company_ref_idx": { - "name": "document_reference_resolutions_company_ref_idx", - "columns": [ - { - "expression": "company_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_document_reference_resolutions_company_id_pdr_ai_v2_company_id_fk": { - "name": "pdr_ai_v2_document_reference_resolutions_company_id_pdr_ai_v2_company_id_fk", - "tableFrom": "pdr_ai_v2_document_reference_resolutions", - "tableTo": "pdr_ai_v2_company", - "columnsFrom": [ - "company_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_ocr_cost_tracking": { - "name": "pdr_ai_v2_ocr_cost_tracking", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "company_id": { - "name": "company_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "provider": { - "name": "provider", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true - }, - "month": { - "name": "month", - "type": "varchar(7)", - "primaryKey": false, - "notNull": true - }, - "total_jobs": { - "name": "total_jobs", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "total_pages": { - "name": "total_pages", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "total_cost_cents": { - "name": "total_cost_cents", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "average_cost_per_page": { - "name": "average_cost_per_page", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "average_confidence_score": { - "name": "average_confidence_score", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "ocr_cost_tracking_company_provider_month_idx": { - "name": "ocr_cost_tracking_company_provider_month_idx", - "columns": [ - { - "expression": "company_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "provider", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "month", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_ocr_cost_tracking_company_id_pdr_ai_v2_company_id_fk": { - "name": "pdr_ai_v2_ocr_cost_tracking_company_id_pdr_ai_v2_company_id_fk", - "tableFrom": "pdr_ai_v2_ocr_cost_tracking", - "tableTo": "pdr_ai_v2_company", - "columnsFrom": [ - "company_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_ocr_jobs": { - "name": "pdr_ai_v2_ocr_jobs", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar(256)", - "primaryKey": true, - "notNull": true - }, - "document_id": { - "name": "document_id", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "company_id": { - "name": "company_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true, - "default": "'queued'" - }, - "document_url": { - "name": "document_url", - "type": "varchar(1024)", - "primaryKey": false, - "notNull": true - }, - "document_name": { - "name": "document_name", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "page_count": { - "name": "page_count", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "file_size_bytes": { - "name": "file_size_bytes", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "complexity_score": { - "name": "complexity_score", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "document_type": { - "name": "document_type", - "type": "varchar(50)", - "primaryKey": false, - "notNull": false - }, - "primary_provider": { - "name": "primary_provider", - "type": "varchar(50)", - "primaryKey": false, - "notNull": false - }, - "actual_provider": { - "name": "actual_provider", - "type": "varchar(50)", - "primaryKey": false, - "notNull": false - }, - "estimated_cost_cents": { - "name": "estimated_cost_cents", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "actual_cost_cents": { - "name": "actual_cost_cents", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "confidence_score": { - "name": "confidence_score", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "quality_flags": { - "name": "quality_flags", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "requires_review": { - "name": "requires_review", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "default": false - }, - "started_at": { - "name": "started_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "completed_at": { - "name": "completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "processing_duration_ms": { - "name": "processing_duration_ms", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "ocr_result": { - "name": "ocr_result", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "error_message": { - "name": "error_message", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "retry_count": { - "name": "retry_count", - "type": "integer", - "primaryKey": false, - "notNull": false, - "default": 0 - }, - "webhook_url": { - "name": "webhook_url", - "type": "varchar(1024)", - "primaryKey": false, - "notNull": false - }, - "webhook_status": { - "name": "webhook_status", - "type": "varchar(20)", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "ocr_jobs_company_id_idx": { - "name": "ocr_jobs_company_id_idx", - "columns": [ - { - "expression": "company_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "ocr_jobs_user_id_idx": { - "name": "ocr_jobs_user_id_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "ocr_jobs_status_idx": { - "name": "ocr_jobs_status_idx", - "columns": [ - { - "expression": "status", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "ocr_jobs_created_at_idx": { - "name": "ocr_jobs_created_at_idx", - "columns": [ - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "ocr_jobs_company_status_idx": { - "name": "ocr_jobs_company_status_idx", - "columns": [ - { - "expression": "company_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "status", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_ocr_jobs_document_id_pdr_ai_v2_document_id_fk": { - "name": "pdr_ai_v2_ocr_jobs_document_id_pdr_ai_v2_document_id_fk", - "tableFrom": "pdr_ai_v2_ocr_jobs", - "tableTo": "pdr_ai_v2_document", - "columnsFrom": [ - "document_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - }, - "pdr_ai_v2_ocr_jobs_company_id_pdr_ai_v2_company_id_fk": { - "name": "pdr_ai_v2_ocr_jobs_company_id_pdr_ai_v2_company_id_fk", - "tableFrom": "pdr_ai_v2_ocr_jobs", - "tableTo": "pdr_ai_v2_company", - "columnsFrom": [ - "company_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_ocr_processing_steps": { - "name": "pdr_ai_v2_ocr_processing_steps", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar(256)", - "primaryKey": true, - "notNull": true - }, - "job_id": { - "name": "job_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "step_number": { - "name": "step_number", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "step_type": { - "name": "step_type", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "varchar(20)", - "primaryKey": false, - "notNull": true, - "default": "'pending'" - }, - "input": { - "name": "input", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "output": { - "name": "output", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "error_message": { - "name": "error_message", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "duration_ms": { - "name": "duration_ms", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - } - }, - "indexes": { - "ocr_processing_steps_job_id_idx": { - "name": "ocr_processing_steps_job_id_idx", - "columns": [ - { - "expression": "job_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "ocr_processing_steps_job_id_step_idx": { - "name": "ocr_processing_steps_job_id_step_idx", - "columns": [ - { - "expression": "job_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "step_number", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_ocr_processing_steps_job_id_pdr_ai_v2_ocr_jobs_id_fk": { - "name": "pdr_ai_v2_ocr_processing_steps_job_id_pdr_ai_v2_ocr_jobs_id_fk", - "tableFrom": "pdr_ai_v2_ocr_processing_steps", - "tableTo": "pdr_ai_v2_ocr_jobs", - "columnsFrom": [ - "job_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_pdf_chunks": { - "name": "pdr_ai_v2_pdf_chunks", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "document_id": { - "name": "document_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "page": { - "name": "page", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "chunk_index": { - "name": "chunk_index", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "content": { - "name": "content", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "embedding": { - "name": "embedding", - "type": "vector(1536)", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "pdf_chunks_document_id_idx": { - "name": "pdf_chunks_document_id_idx", - "columns": [ - { - "expression": "document_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "pdf_chunks_document_id_page_idx": { - "name": "pdf_chunks_document_id_page_idx", - "columns": [ - { - "expression": "document_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "page", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "pdf_chunks_document_id_page_chunk_idx": { - "name": "pdf_chunks_document_id_page_chunk_idx", - "columns": [ - { - "expression": "document_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "page", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "chunk_index", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_pdf_chunks_document_id_pdr_ai_v2_document_id_fk": { - "name": "pdr_ai_v2_pdf_chunks_document_id_pdr_ai_v2_document_id_fk", - "tableFrom": "pdr_ai_v2_pdf_chunks", - "tableTo": "pdr_ai_v2_document", - "columnsFrom": [ - "document_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_predictive_document_analysis_results": { - "name": "pdr_ai_v2_predictive_document_analysis_results", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "document_id": { - "name": "document_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "analysis_type": { - "name": "analysis_type", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "include_related_docs": { - "name": "include_related_docs", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "default": false - }, - "result_json": { - "name": "result_json", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - } - }, - "indexes": { - "predictive_analysis_document_id_idx": { - "name": "predictive_analysis_document_id_idx", - "columns": [ - { - "expression": "document_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_predictive_document_analysis_results_document_id_pdr_ai_v2_document_id_fk": { - "name": "pdr_ai_v2_predictive_document_analysis_results_document_id_pdr_ai_v2_document_id_fk", - "tableFrom": "pdr_ai_v2_predictive_document_analysis_results", - "tableTo": "pdr_ai_v2_document", - "columnsFrom": [ - "document_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_users": { - "name": "pdr_ai_v2_users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "email": { - "name": "email", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "userId": { - "name": "userId", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "company_id": { - "name": "company_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "role": { - "name": "role", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "users_company_id_idx": { - "name": "users_company_id_idx", - "columns": [ - { - "expression": "company_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "users_user_id_idx": { - "name": "users_user_id_idx", - "columns": [ - { - "expression": "userId", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_users_company_id_pdr_ai_v2_company_id_fk": { - "name": "pdr_ai_v2_users_company_id_pdr_ai_v2_company_id_fk", - "tableFrom": "pdr_ai_v2_users", - "tableTo": "pdr_ai_v2_company", - "columnsFrom": [ - "company_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "pdr_ai_v2_users_userId_unique": { - "name": "pdr_ai_v2_users_userId_unique", - "nullsNotDistinct": false, - "columns": [ - "userId" - ] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_agent_ai_chatbot_chat": { - "name": "pdr_ai_v2_agent_ai_chatbot_chat", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar(256)", - "primaryKey": true, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "visibility": { - "name": "visibility", - "type": "varchar(20)", - "primaryKey": false, - "notNull": true, - "default": "'private'" - }, - "agent_mode": { - "name": "agent_mode", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true, - "default": "'interactive'" - }, - "status": { - "name": "status", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true, - "default": "'active'" - }, - "ai_style": { - "name": "ai_style", - "type": "varchar(50)", - "primaryKey": false, - "notNull": false, - "default": "'concise'" - }, - "ai_persona": { - "name": "ai_persona", - "type": "varchar(50)", - "primaryKey": false, - "notNull": false, - "default": "'general'" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_agent_ai_chatbot_document": { - "name": "pdr_ai_v2_agent_ai_chatbot_document", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "content": { - "name": "content", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "kind": { - "name": "kind", - "type": "varchar(20)", - "primaryKey": false, - "notNull": true, - "default": "'text'" - }, - "user_id": { - "name": "user_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "chat_id": { - "name": "chat_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": false - }, - "task_id": { - "name": "task_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "pdr_ai_v2_agent_ai_chatbot_document_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk": { - "name": "pdr_ai_v2_agent_ai_chatbot_document_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk", - "tableFrom": "pdr_ai_v2_agent_ai_chatbot_document", - "tableTo": "pdr_ai_v2_agent_ai_chatbot_chat", - "columnsFrom": [ - "chat_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "pdr_ai_v2_agent_ai_chatbot_document_task_id_pdr_ai_v2_agent_ai_chatbot_task_id_fk": { - "name": "pdr_ai_v2_agent_ai_chatbot_document_task_id_pdr_ai_v2_agent_ai_chatbot_task_id_fk", - "tableFrom": "pdr_ai_v2_agent_ai_chatbot_document", - "tableTo": "pdr_ai_v2_agent_ai_chatbot_task", - "columnsFrom": [ - "task_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "set null", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "pdr_ai_v2_agent_ai_chatbot_document_id_created_at_pk": { - "name": "pdr_ai_v2_agent_ai_chatbot_document_id_created_at_pk", - "columns": [ - "id", - "created_at" - ] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_agent_ai_chatbot_execution_step": { - "name": "pdr_ai_v2_agent_ai_chatbot_execution_step", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar(256)", - "primaryKey": true, - "notNull": true - }, - "task_id": { - "name": "task_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "step_number": { - "name": "step_number", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "step_type": { - "name": "step_type", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "reasoning": { - "name": "reasoning", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "input": { - "name": "input", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "output": { - "name": "output", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true, - "default": "'pending'" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "completed_at": { - "name": "completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "agent_execution_step_task_step_idx": { - "name": "agent_execution_step_task_step_idx", - "columns": [ - { - "expression": "task_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "step_number", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_agent_ai_chatbot_execution_step_task_id_pdr_ai_v2_agent_ai_chatbot_task_id_fk": { - "name": "pdr_ai_v2_agent_ai_chatbot_execution_step_task_id_pdr_ai_v2_agent_ai_chatbot_task_id_fk", - "tableFrom": "pdr_ai_v2_agent_ai_chatbot_execution_step", - "tableTo": "pdr_ai_v2_agent_ai_chatbot_task", - "columnsFrom": [ - "task_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_agent_ai_chatbot_memory": { - "name": "pdr_ai_v2_agent_ai_chatbot_memory", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar(256)", - "primaryKey": true, - "notNull": true - }, - "chat_id": { - "name": "chat_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "memory_type": { - "name": "memory_type", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true - }, - "key": { - "name": "key", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "value": { - "name": "value", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "importance": { - "name": "importance", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 5 - }, - "embedding": { - "name": "embedding", - "type": "vector(1536)", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "accessed_at": { - "name": "accessed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "agent_memory_chat_idx": { - "name": "agent_memory_chat_idx", - "columns": [ - { - "expression": "chat_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "agent_memory_chat_type_idx": { - "name": "agent_memory_chat_type_idx", - "columns": [ - { - "expression": "chat_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "memory_type", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_agent_ai_chatbot_memory_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk": { - "name": "pdr_ai_v2_agent_ai_chatbot_memory_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk", - "tableFrom": "pdr_ai_v2_agent_ai_chatbot_memory", - "tableTo": "pdr_ai_v2_agent_ai_chatbot_chat", - "columnsFrom": [ - "chat_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_agent_ai_chatbot_message": { - "name": "pdr_ai_v2_agent_ai_chatbot_message", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar(256)", - "primaryKey": true, - "notNull": true - }, - "chat_id": { - "name": "chat_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "role": { - "name": "role", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true - }, - "content": { - "name": "content", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "message_type": { - "name": "message_type", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true, - "default": "'text'" - }, - "parent_message_id": { - "name": "parent_message_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - } - }, - "indexes": {}, - "foreignKeys": { - "pdr_ai_v2_agent_ai_chatbot_message_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk": { - "name": "pdr_ai_v2_agent_ai_chatbot_message_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk", - "tableFrom": "pdr_ai_v2_agent_ai_chatbot_message", - "tableTo": "pdr_ai_v2_agent_ai_chatbot_chat", - "columnsFrom": [ - "chat_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_agent_ai_chatbot_suggestion": { - "name": "pdr_ai_v2_agent_ai_chatbot_suggestion", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar(256)", - "primaryKey": true, - "notNull": true - }, - "document_id": { - "name": "document_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "document_created_at": { - "name": "document_created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true - }, - "original_text": { - "name": "original_text", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "suggested_text": { - "name": "suggested_text", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_resolved": { - "name": "is_resolved", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "user_id": { - "name": "user_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - } - }, - "indexes": {}, - "foreignKeys": { - "pdr_ai_v2_agent_ai_chatbot_suggestion_document_id_document_created_at_pdr_ai_v2_agent_ai_chatbot_document_id_created_at_fk": { - "name": "pdr_ai_v2_agent_ai_chatbot_suggestion_document_id_document_created_at_pdr_ai_v2_agent_ai_chatbot_document_id_created_at_fk", - "tableFrom": "pdr_ai_v2_agent_ai_chatbot_suggestion", - "tableTo": "pdr_ai_v2_agent_ai_chatbot_document", - "columnsFrom": [ - "document_id", - "document_created_at" - ], - "columnsTo": [ - "id", - "created_at" - ], - "onDelete": "no action", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_agent_ai_chatbot_task": { - "name": "pdr_ai_v2_agent_ai_chatbot_task", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar(256)", - "primaryKey": true, - "notNull": true - }, - "chat_id": { - "name": "chat_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "objective": { - "name": "objective", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "status": { - "name": "status", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true, - "default": "'pending'" - }, - "priority": { - "name": "priority", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "result": { - "name": "result", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "metadata": { - "name": "metadata", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "completed_at": { - "name": "completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "pdr_ai_v2_agent_ai_chatbot_task_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk": { - "name": "pdr_ai_v2_agent_ai_chatbot_task_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk", - "tableFrom": "pdr_ai_v2_agent_ai_chatbot_task", - "tableTo": "pdr_ai_v2_agent_ai_chatbot_chat", - "columnsFrom": [ - "chat_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_agent_ai_chatbot_tool_call": { - "name": "pdr_ai_v2_agent_ai_chatbot_tool_call", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar(256)", - "primaryKey": true, - "notNull": true - }, - "message_id": { - "name": "message_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "task_id": { - "name": "task_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": false - }, - "tool_name": { - "name": "tool_name", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "tool_input": { - "name": "tool_input", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "tool_output": { - "name": "tool_output", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true, - "default": "'pending'" - }, - "error_message": { - "name": "error_message", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "execution_time_ms": { - "name": "execution_time_ms", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "completed_at": { - "name": "completed_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": { - "pdr_ai_v2_agent_ai_chatbot_tool_call_message_id_pdr_ai_v2_agent_ai_chatbot_message_id_fk": { - "name": "pdr_ai_v2_agent_ai_chatbot_tool_call_message_id_pdr_ai_v2_agent_ai_chatbot_message_id_fk", - "tableFrom": "pdr_ai_v2_agent_ai_chatbot_tool_call", - "tableTo": "pdr_ai_v2_agent_ai_chatbot_message", - "columnsFrom": [ - "message_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "pdr_ai_v2_agent_ai_chatbot_tool_call_task_id_pdr_ai_v2_agent_ai_chatbot_task_id_fk": { - "name": "pdr_ai_v2_agent_ai_chatbot_tool_call_task_id_pdr_ai_v2_agent_ai_chatbot_task_id_fk", - "tableFrom": "pdr_ai_v2_agent_ai_chatbot_tool_call", - "tableTo": "pdr_ai_v2_agent_ai_chatbot_task", - "columnsFrom": [ - "task_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_agent_ai_chatbot_tool_registry": { - "name": "pdr_ai_v2_agent_ai_chatbot_tool_registry", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "varchar(256)", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "category": { - "name": "category", - "type": "varchar(100)", - "primaryKey": false, - "notNull": true - }, - "schema": { - "name": "schema", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "is_enabled": { - "name": "is_enabled", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "required_permissions": { - "name": "required_permissions", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "rate_limit": { - "name": "rate_limit", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": { - "pdr_ai_v2_agent_ai_chatbot_tool_registry_name_unique": { - "name": "pdr_ai_v2_agent_ai_chatbot_tool_registry_name_unique", - "nullsNotDistinct": false, - "columns": [ - "name" - ] - } - }, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_agent_ai_chatbot_vote": { - "name": "pdr_ai_v2_agent_ai_chatbot_vote", - "schema": "", - "columns": { - "chat_id": { - "name": "chat_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "message_id": { - "name": "message_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "is_upvoted": { - "name": "is_upvoted", - "type": "boolean", - "primaryKey": false, - "notNull": true - }, - "feedback": { - "name": "feedback", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - } - }, - "indexes": {}, - "foreignKeys": { - "pdr_ai_v2_agent_ai_chatbot_vote_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk": { - "name": "pdr_ai_v2_agent_ai_chatbot_vote_chat_id_pdr_ai_v2_agent_ai_chatbot_chat_id_fk", - "tableFrom": "pdr_ai_v2_agent_ai_chatbot_vote", - "tableTo": "pdr_ai_v2_agent_ai_chatbot_chat", - "columnsFrom": [ - "chat_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "pdr_ai_v2_agent_ai_chatbot_vote_message_id_pdr_ai_v2_agent_ai_chatbot_message_id_fk": { - "name": "pdr_ai_v2_agent_ai_chatbot_vote_message_id_pdr_ai_v2_agent_ai_chatbot_message_id_fk", - "tableFrom": "pdr_ai_v2_agent_ai_chatbot_vote", - "tableTo": "pdr_ai_v2_agent_ai_chatbot_message", - "columnsFrom": [ - "message_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": { - "pdr_ai_v2_agent_ai_chatbot_vote_chat_id_message_id_pk": { - "name": "pdr_ai_v2_agent_ai_chatbot_vote_chat_id_message_id_pk", - "columns": [ - "chat_id", - "message_id" - ] - } - }, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_study_agent_goals": { - "name": "pdr_ai_v2_study_agent_goals", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "session_id": { - "name": "session_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "materials": { - "name": "materials", - "type": "text[]", - "primaryKey": false, - "notNull": false, - "default": "'{}'" - }, - "completed": { - "name": "completed", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "study_agent_goals_user_idx": { - "name": "study_agent_goals_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "study_agent_goals_session_idx": { - "name": "study_agent_goals_session_idx", - "columns": [ - { - "expression": "session_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_study_agent_goals_session_id_pdr_ai_v2_study_agent_sessions_id_fk": { - "name": "pdr_ai_v2_study_agent_goals_session_id_pdr_ai_v2_study_agent_sessions_id_fk", - "tableFrom": "pdr_ai_v2_study_agent_goals", - "tableTo": "pdr_ai_v2_study_agent_sessions", - "columnsFrom": [ - "session_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_study_agent_notes": { - "name": "pdr_ai_v2_study_agent_notes", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "session_id": { - "name": "session_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "content": { - "name": "content", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "tags": { - "name": "tags", - "type": "text[]", - "primaryKey": false, - "notNull": false, - "default": "'{}'" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "study_agent_notes_user_idx": { - "name": "study_agent_notes_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "study_agent_notes_session_idx": { - "name": "study_agent_notes_session_idx", - "columns": [ - { - "expression": "session_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_study_agent_notes_session_id_pdr_ai_v2_study_agent_sessions_id_fk": { - "name": "pdr_ai_v2_study_agent_notes_session_id_pdr_ai_v2_study_agent_sessions_id_fk", - "tableFrom": "pdr_ai_v2_study_agent_notes", - "tableTo": "pdr_ai_v2_study_agent_sessions", - "columnsFrom": [ - "session_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_study_agent_pomodoro_settings": { - "name": "pdr_ai_v2_study_agent_pomodoro_settings", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "session_id": { - "name": "session_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "focus_minutes": { - "name": "focus_minutes", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 25 - }, - "short_break_minutes": { - "name": "short_break_minutes", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 5 - }, - "long_break_minutes": { - "name": "long_break_minutes", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 15 - }, - "remaining_time": { - "name": "remaining_time", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "sessions_before_long_break": { - "name": "sessions_before_long_break", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 4 - }, - "auto_start_breaks": { - "name": "auto_start_breaks", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "auto_start_pomodoros": { - "name": "auto_start_pomodoros", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "phase": { - "name": "phase", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'idle'" - }, - "is_running": { - "name": "is_running", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "is_paused": { - "name": "is_paused", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "started_at": { - "name": "started_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "paused_at": { - "name": "paused_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "ends_at": { - "name": "ends_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "completed_pomodoros": { - "name": "completed_pomodoros", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "total_work_minutes": { - "name": "total_work_minutes", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "current_task_id": { - "name": "current_task_id", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "study_agent_pomodoro_settings_user_idx": { - "name": "study_agent_pomodoro_settings_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "study_agent_pomodoro_settings_session_idx": { - "name": "study_agent_pomodoro_settings_session_idx", - "columns": [ - { - "expression": "session_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_study_agent_pomodoro_settings_session_id_pdr_ai_v2_study_agent_sessions_id_fk": { - "name": "pdr_ai_v2_study_agent_pomodoro_settings_session_id_pdr_ai_v2_study_agent_sessions_id_fk", - "tableFrom": "pdr_ai_v2_study_agent_pomodoro_settings", - "tableTo": "pdr_ai_v2_study_agent_sessions", - "columnsFrom": [ - "session_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_study_agent_preferences": { - "name": "pdr_ai_v2_study_agent_preferences", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "session_id": { - "name": "session_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "selected_documents": { - "name": "selected_documents", - "type": "text[]", - "primaryKey": false, - "notNull": true, - "default": "'{}'" - }, - "user_name": { - "name": "user_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "user_grade": { - "name": "user_grade", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "user_gender": { - "name": "user_gender", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "field_of_study": { - "name": "field_of_study", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "study_agent_preferences_user_idx": { - "name": "study_agent_preferences_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "study_agent_preferences_session_idx": { - "name": "study_agent_preferences_session_idx", - "columns": [ - { - "expression": "session_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_study_agent_preferences_session_id_pdr_ai_v2_study_agent_sessions_id_fk": { - "name": "pdr_ai_v2_study_agent_preferences_session_id_pdr_ai_v2_study_agent_sessions_id_fk", - "tableFrom": "pdr_ai_v2_study_agent_preferences", - "tableTo": "pdr_ai_v2_study_agent_sessions", - "columnsFrom": [ - "session_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_study_agent_profile": { - "name": "pdr_ai_v2_study_agent_profile", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "session_id": { - "name": "session_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "ai_name": { - "name": "ai_name", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "ai_gender": { - "name": "ai_gender", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "ai_avatar_url": { - "name": "ai_avatar_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "ai_extroversion": { - "name": "ai_extroversion", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "ai_intuition": { - "name": "ai_intuition", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "ai_thinking": { - "name": "ai_thinking", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "ai_judging": { - "name": "ai_judging", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "study_agent_profile_user_idx": { - "name": "study_agent_profile_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "study_agent_profile_session_idx": { - "name": "study_agent_profile_session_idx", - "columns": [ - { - "expression": "session_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_study_agent_profile_session_id_pdr_ai_v2_study_agent_sessions_id_fk": { - "name": "pdr_ai_v2_study_agent_profile_session_id_pdr_ai_v2_study_agent_sessions_id_fk", - "tableFrom": "pdr_ai_v2_study_agent_profile", - "tableTo": "pdr_ai_v2_study_agent_sessions", - "columnsFrom": [ - "session_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_study_agent_sessions": { - "name": "pdr_ai_v2_study_agent_sessions", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "text", - "primaryKey": false, - "notNull": true, - "default": "'Default Session'" - }, - "mode": { - "name": "mode", - "type": "varchar(32)", - "primaryKey": false, - "notNull": true, - "default": "'teacher'" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "study_agent_sessions_user_idx": { - "name": "study_agent_sessions_user_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_document_metadata": { - "name": "pdr_ai_v2_document_metadata", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "document_id": { - "name": "document_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "total_tokens": { - "name": "total_tokens", - "type": "integer", - "primaryKey": false, - "notNull": false, - "default": 0 - }, - "total_sections": { - "name": "total_sections", - "type": "integer", - "primaryKey": false, - "notNull": false, - "default": 0 - }, - "total_tables": { - "name": "total_tables", - "type": "integer", - "primaryKey": false, - "notNull": false, - "default": 0 - }, - "total_figures": { - "name": "total_figures", - "type": "integer", - "primaryKey": false, - "notNull": false, - "default": 0 - }, - "total_pages": { - "name": "total_pages", - "type": "integer", - "primaryKey": false, - "notNull": false, - "default": 0 - }, - "max_section_depth": { - "name": "max_section_depth", - "type": "integer", - "primaryKey": false, - "notNull": false, - "default": 0 - }, - "topic_tags": { - "name": "topic_tags", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "summary": { - "name": "summary", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "outline": { - "name": "outline", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "complexity_score": { - "name": "complexity_score", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "document_class": { - "name": "document_class", - "type": "varchar(50)", - "primaryKey": false, - "notNull": false - }, - "entities": { - "name": "entities", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "summary_embedding": { - "name": "summary_embedding", - "type": "vector(1536)", - "primaryKey": false, - "notNull": false - }, - "date_range_start": { - "name": "date_range_start", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "date_range_end": { - "name": "date_range_end", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "language": { - "name": "language", - "type": "varchar(10)", - "primaryKey": false, - "notNull": false, - "default": "'en'" - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "doc_metadata_document_id_unique": { - "name": "doc_metadata_document_id_unique", - "columns": [ - { - "expression": "document_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "doc_metadata_complexity_idx": { - "name": "doc_metadata_complexity_idx", - "columns": [ - { - "expression": "complexity_score", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "doc_metadata_class_idx": { - "name": "doc_metadata_class_idx", - "columns": [ - { - "expression": "document_class", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "doc_metadata_total_tokens_idx": { - "name": "doc_metadata_total_tokens_idx", - "columns": [ - { - "expression": "total_tokens", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_document_metadata_document_id_pdr_ai_v2_document_id_fk": { - "name": "pdr_ai_v2_document_metadata_document_id_pdr_ai_v2_document_id_fk", - "tableFrom": "pdr_ai_v2_document_metadata", - "tableTo": "pdr_ai_v2_document", - "columnsFrom": [ - "document_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_document_previews": { - "name": "pdr_ai_v2_document_previews", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "document_id": { - "name": "document_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "section_id": { - "name": "section_id", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "structure_id": { - "name": "structure_id", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "preview_type": { - "name": "preview_type", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true - }, - "content": { - "name": "content", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "token_count": { - "name": "token_count", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "embedding": { - "name": "embedding", - "type": "vector(1536)", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - } - }, - "indexes": { - "doc_previews_document_id_idx": { - "name": "doc_previews_document_id_idx", - "columns": [ - { - "expression": "document_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "doc_previews_section_id_idx": { - "name": "doc_previews_section_id_idx", - "columns": [ - { - "expression": "section_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "doc_previews_document_type_idx": { - "name": "doc_previews_document_type_idx", - "columns": [ - { - "expression": "document_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "preview_type", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_document_previews_document_id_pdr_ai_v2_document_id_fk": { - "name": "pdr_ai_v2_document_previews_document_id_pdr_ai_v2_document_id_fk", - "tableFrom": "pdr_ai_v2_document_previews", - "tableTo": "pdr_ai_v2_document", - "columnsFrom": [ - "document_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "pdr_ai_v2_document_previews_section_id_pdr_ai_v2_document_sections_id_fk": { - "name": "pdr_ai_v2_document_previews_section_id_pdr_ai_v2_document_sections_id_fk", - "tableFrom": "pdr_ai_v2_document_previews", - "tableTo": "pdr_ai_v2_document_sections", - "columnsFrom": [ - "section_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "pdr_ai_v2_document_previews_structure_id_pdr_ai_v2_document_structure_id_fk": { - "name": "pdr_ai_v2_document_previews_structure_id_pdr_ai_v2_document_structure_id_fk", - "tableFrom": "pdr_ai_v2_document_previews", - "tableTo": "pdr_ai_v2_document_structure", - "columnsFrom": [ - "structure_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_document_sections": { - "name": "pdr_ai_v2_document_sections", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "document_id": { - "name": "document_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "structure_id": { - "name": "structure_id", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "content": { - "name": "content", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "token_count": { - "name": "token_count", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "char_count": { - "name": "char_count", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "embedding": { - "name": "embedding", - "type": "vector(1536)", - "primaryKey": false, - "notNull": false - }, - "content_hash": { - "name": "content_hash", - "type": "varchar(64)", - "primaryKey": false, - "notNull": false - }, - "semantic_type": { - "name": "semantic_type", - "type": "varchar(50)", - "primaryKey": false, - "notNull": false - }, - "page_number": { - "name": "page_number", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "line_start": { - "name": "line_start", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "line_end": { - "name": "line_end", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "doc_sections_document_id_idx": { - "name": "doc_sections_document_id_idx", - "columns": [ - { - "expression": "document_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "doc_sections_structure_id_idx": { - "name": "doc_sections_structure_id_idx", - "columns": [ - { - "expression": "structure_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "doc_sections_document_page_idx": { - "name": "doc_sections_document_page_idx", - "columns": [ - { - "expression": "document_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "page_number", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "doc_sections_content_hash_idx": { - "name": "doc_sections_content_hash_idx", - "columns": [ - { - "expression": "content_hash", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "doc_sections_semantic_type_idx": { - "name": "doc_sections_semantic_type_idx", - "columns": [ - { - "expression": "document_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "semantic_type", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_document_sections_document_id_pdr_ai_v2_document_id_fk": { - "name": "pdr_ai_v2_document_sections_document_id_pdr_ai_v2_document_id_fk", - "tableFrom": "pdr_ai_v2_document_sections", - "tableTo": "pdr_ai_v2_document", - "columnsFrom": [ - "document_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "pdr_ai_v2_document_sections_structure_id_pdr_ai_v2_document_structure_id_fk": { - "name": "pdr_ai_v2_document_sections_structure_id_pdr_ai_v2_document_structure_id_fk", - "tableFrom": "pdr_ai_v2_document_sections", - "tableTo": "pdr_ai_v2_document_structure", - "columnsFrom": [ - "structure_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_document_structure": { - "name": "pdr_ai_v2_document_structure", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "document_id": { - "name": "document_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "parent_id": { - "name": "parent_id", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "level": { - "name": "level", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "ordering": { - "name": "ordering", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "title": { - "name": "title", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "content_type": { - "name": "content_type", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true, - "default": "'section'" - }, - "path": { - "name": "path", - "type": "varchar(256)", - "primaryKey": false, - "notNull": false - }, - "start_page": { - "name": "start_page", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "end_page": { - "name": "end_page", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "child_count": { - "name": "child_count", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "token_count": { - "name": "token_count", - "type": "integer", - "primaryKey": false, - "notNull": false, - "default": 0 - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "doc_structure_document_id_idx": { - "name": "doc_structure_document_id_idx", - "columns": [ - { - "expression": "document_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "doc_structure_parent_id_idx": { - "name": "doc_structure_parent_id_idx", - "columns": [ - { - "expression": "parent_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "doc_structure_document_level_idx": { - "name": "doc_structure_document_level_idx", - "columns": [ - { - "expression": "document_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "level", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "doc_structure_document_path_idx": { - "name": "doc_structure_document_path_idx", - "columns": [ - { - "expression": "document_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "path", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "doc_structure_document_ordering_idx": { - "name": "doc_structure_document_ordering_idx", - "columns": [ - { - "expression": "document_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "parent_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "ordering", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_document_structure_document_id_pdr_ai_v2_document_id_fk": { - "name": "pdr_ai_v2_document_structure_document_id_pdr_ai_v2_document_id_fk", - "tableFrom": "pdr_ai_v2_document_structure", - "tableTo": "pdr_ai_v2_document", - "columnsFrom": [ - "document_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.pdr_ai_v2_workspace_results": { - "name": "pdr_ai_v2_workspace_results", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "session_id": { - "name": "session_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true - }, - "company_id": { - "name": "company_id", - "type": "bigint", - "primaryKey": false, - "notNull": true - }, - "document_id": { - "name": "document_id", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "section_id": { - "name": "section_id", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "structure_id": { - "name": "structure_id", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "result_type": { - "name": "result_type", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true - }, - "content": { - "name": "content", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "metadata": { - "name": "metadata", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "status": { - "name": "status", - "type": "varchar(20)", - "primaryKey": false, - "notNull": true, - "default": "'pending'" - }, - "parent_result_id": { - "name": "parent_result_id", - "type": "bigint", - "primaryKey": false, - "notNull": false - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": true, - "default": "CURRENT_TIMESTAMP" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "workspace_session_id_idx": { - "name": "workspace_session_id_idx", - "columns": [ - { - "expression": "session_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "workspace_user_id_idx": { - "name": "workspace_user_id_idx", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "workspace_company_id_idx": { - "name": "workspace_company_id_idx", - "columns": [ - { - "expression": "company_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "workspace_document_id_idx": { - "name": "workspace_document_id_idx", - "columns": [ - { - "expression": "document_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "workspace_session_type_idx": { - "name": "workspace_session_type_idx", - "columns": [ - { - "expression": "session_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "result_type", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "workspace_status_idx": { - "name": "workspace_status_idx", - "columns": [ - { - "expression": "status", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "workspace_expires_at_idx": { - "name": "workspace_expires_at_idx", - "columns": [ - { - "expression": "expires_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "workspace_parent_result_idx": { - "name": "workspace_parent_result_idx", - "columns": [ - { - "expression": "parent_result_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": { - "pdr_ai_v2_workspace_results_company_id_pdr_ai_v2_company_id_fk": { - "name": "pdr_ai_v2_workspace_results_company_id_pdr_ai_v2_company_id_fk", - "tableFrom": "pdr_ai_v2_workspace_results", - "tableTo": "pdr_ai_v2_company", - "columnsFrom": [ - "company_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "pdr_ai_v2_workspace_results_document_id_pdr_ai_v2_document_id_fk": { - "name": "pdr_ai_v2_workspace_results_document_id_pdr_ai_v2_document_id_fk", - "tableFrom": "pdr_ai_v2_workspace_results", - "tableTo": "pdr_ai_v2_document", - "columnsFrom": [ - "document_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "pdr_ai_v2_workspace_results_section_id_pdr_ai_v2_document_sections_id_fk": { - "name": "pdr_ai_v2_workspace_results_section_id_pdr_ai_v2_document_sections_id_fk", - "tableFrom": "pdr_ai_v2_workspace_results", - "tableTo": "pdr_ai_v2_document_sections", - "columnsFrom": [ - "section_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - }, - "pdr_ai_v2_workspace_results_structure_id_pdr_ai_v2_document_structure_id_fk": { - "name": "pdr_ai_v2_workspace_results_structure_id_pdr_ai_v2_document_structure_id_fk", - "tableFrom": "pdr_ai_v2_workspace_results", - "tableTo": "pdr_ai_v2_document_structure", - "columnsFrom": [ - "structure_id" - ], - "columnsTo": [ - "id" - ], - "onDelete": "cascade", - "onUpdate": "no action" - } - }, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": {}, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/drizzle/meta/_journal.json b/drizzle/meta/_journal.json deleted file mode 100644 index 83a45153..00000000 --- a/drizzle/meta/_journal.json +++ /dev/null @@ -1,97 +0,0 @@ -{ - "version": "7", - "dialect": "postgresql", - "entries": [ - { - "idx": 0, - "version": "7", - "when": 1735783699618, - "tag": "0000_sweet_havok", - "breakpoints": true - }, - { - "idx": 1, - "version": "7", - "when": 1757887612378, - "tag": "0001_tranquil_hitman", - "breakpoints": true - }, - { - "idx": 2, - "version": "7", - "when": 1762754878176, - "tag": "0002_small_crusher_hogan", - "breakpoints": true - }, - { - "idx": 3, - "version": "7", - "when": 1762932480003, - "tag": "0003_thin_cloak", - "breakpoints": true - }, - { - "idx": 4, - "version": "7", - "when": 1762934025389, - "tag": "0004_lazy_the_spike", - "breakpoints": true - }, - { - "idx": 5, - "version": "7", - "when": 1762936213317, - "tag": "0005_quick_silver_sable", - "breakpoints": true - }, - { - "idx": 6, - "version": "7", - "when": 1766084648263, - "tag": "0006_daily_joseph", - "breakpoints": true - }, - { - "idx": 7, - "version": "7", - "when": 1766085738027, - "tag": "0007_plain_leader", - "breakpoints": true - }, - { - "idx": 8, - "version": "7", - "when": 1766262374297, - "tag": "0008_nappy_mandarin", - "breakpoints": true - }, - { - "idx": 9, - "version": "7", - "when": 1766263036187, - "tag": "0009_public_warstar", - "breakpoints": true - }, - { - "idx": 10, - "version": "7", - "when": 1735084800000, - "tag": "0010_add_session_mode", - "breakpoints": true - }, - { - "idx": 11, - "version": "7", - "when": 1767510691773, - "tag": "0011_large_pet_avengers", - "breakpoints": true - }, - { - "idx": 12, - "version": "7", - "when": 1769617086407, - "tag": "0012_foamy_the_phantom", - "breakpoints": true - } - ] -} \ No newline at end of file diff --git a/next.config.ts b/next.config.ts index 4bfa4448..592e84fe 100644 --- a/next.config.ts +++ b/next.config.ts @@ -2,7 +2,15 @@ import type { NextConfig } from "next"; import "./src/env"; +// Standalone uses symlinks when copying traced deps; Windows often lacks permission (EPERM). +// Use standalone only on non-Windows, or when STANDALONE_BUILD=1 (e.g. CI/Docker or Windows with Developer Mode). +const useStandalone = + process.env.STANDALONE_BUILD === "1" || process.platform !== "win32"; + const config: NextConfig = { + // Standalone output for Docker deployment (smaller production image) + output: useStandalone ? "standalone" : undefined, + // Force HuggingFace Transformers to use web backend (WASM) instead of Node.js (onnxruntime-node) // This prevents the 404MB onnxruntime-node package from being required env: { @@ -11,17 +19,22 @@ const config: NextConfig = { ONNX_EXECUTION_PROVIDERS: "wasm", }, - // Webpack config to completely ignore onnxruntime-node + // Webpack config: externals for optional / heavy packages // eslint-disable-next-line @typescript-eslint/no-explicit-any webpack: (webpackConfig: any, { isServer }: { isServer: boolean }) => { if (isServer) { - // Mark onnxruntime-node as external - never bundle it // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access webpackConfig.externals = webpackConfig.externals ?? []; + // Mark onnxruntime-node as external - never bundle it // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access webpackConfig.externals.push({ "onnxruntime-node": "commonjs onnxruntime-node", }); + // Optional: Trigger.dev SDK โ€” only needed when JOB_RUNNER=trigger-dev + // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access + webpackConfig.externals.push({ + "@trigger.dev/sdk/v3": "commonjs @trigger.dev/sdk/v3", + }); } // eslint-disable-next-line @typescript-eslint/no-unsafe-return return webpackConfig; diff --git a/package.json b/package.json index 0ea23921..c215ca14 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,6 @@ "scripts": { "build": "next build", "check": "eslint . && tsc --noEmit", - "db:generate": "drizzle-kit generate", - "db:migrate": "drizzle-kit migrate", "db:push": "drizzle-kit push", "db:studio": "drizzle-kit studio", "dev": "next dev", @@ -19,7 +17,8 @@ "typecheck": "tsc --noEmit", "format:write": "prettier --write \"**/*.{ts,tsx,js,jsx,mdx}\" --cache", "format:check": "prettier --check \"**/*.{ts,tsx,js,jsx,mdx}\" --cache", - "postinstall": "node scripts/copy-vad-assets.mjs" + "postinstall": "node scripts/copy-vad-assets.mjs", + "inngest:dev": "pnpm dlx inngest-cli@latest dev -u http://localhost:3000/api/inngest" }, "dependencies": { "@clerk/nextjs": "^6.31.9", @@ -67,6 +66,7 @@ "@ricky0123/vad-web": "^0.0.30", "@uploadthing/react": "^7.3.3", "@vercel/analytics": "^1.6.1", + "cheerio": "^1.2.0", "class-variance-authority": "^0.7.1", "clsx": "*", "cmdk": "^1.1.1", @@ -79,9 +79,11 @@ "geist": "^1.5.1", "inngest": "^3.49.3", "input-otp": "^1.4.2", + "jszip": "^3.10.1", "katex": "^0.16.25", "langchain": "^0.3.33", "lucide-react": "^0.487.0", + "mammoth": "^1.11.0", "motion": "^12.29.2", "next": "^15.5.7", "next-themes": "^0.4.6", @@ -110,10 +112,12 @@ "sonner": "^2.0.3", "string-similarity-js": "^2.1.4", "tailwind-merge": "*", + "tesseract.js": "^7.0.0", "tsx": "^4.20.5", "uploadthing": "^7.7.4", "uuid": "^11.1.0", "vaul": "^1.1.2", + "xlsx": "^0.18.5", "zod": "^3.23.8" }, "devDependencies": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8aa3bb34..1b0e6f57 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -34,7 +34,7 @@ importers: version: 1.3.3(@langchain/core@0.3.74(@opentelemetry/api@1.9.0)(@opentelemetry/exporter-trace-otlp-proto@0.210.0(@opentelemetry/api@1.9.0))(@opentelemetry/sdk-trace-base@2.5.0(@opentelemetry/api@1.9.0))(openai@4.104.0(ws@8.19.0)(zod@3.25.76))) '@langchain/community': specifier: ^0.3.54 - version: 0.3.54(b1e5c811be26b6393c340b5dcd0ebb02) + version: 0.3.54(287b5c5618b08f82035f6fa3c686e8ca) '@langchain/core': specifier: ^0.3.74 version: 0.3.74(@opentelemetry/api@1.9.0)(@opentelemetry/exporter-trace-otlp-proto@0.210.0(@opentelemetry/api@1.9.0))(@opentelemetry/sdk-trace-base@2.5.0(@opentelemetry/api@1.9.0))(openai@4.104.0(ws@8.19.0)(zod@3.25.76)) @@ -143,6 +143,9 @@ importers: '@vercel/analytics': specifier: ^1.6.1 version: 1.6.1(next@15.5.7(@babel/core@7.28.5)(@opentelemetry/api@1.9.0)(@playwright/test@1.55.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react@18.3.1) + cheerio: + specifier: ^1.2.0 + version: 1.2.0 class-variance-authority: specifier: ^0.7.1 version: 0.7.1 @@ -179,15 +182,21 @@ importers: input-otp: specifier: ^1.4.2 version: 1.4.2(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + jszip: + specifier: ^3.10.1 + version: 3.10.1 katex: specifier: ^0.16.25 version: 0.16.25 langchain: specifier: ^0.3.33 - version: 0.3.33(@langchain/anthropic@1.3.3(@langchain/core@0.3.74(@opentelemetry/api@1.9.0)(@opentelemetry/exporter-trace-otlp-proto@0.210.0(@opentelemetry/api@1.9.0))(@opentelemetry/sdk-trace-base@2.5.0(@opentelemetry/api@1.9.0))(openai@4.104.0(ws@8.19.0)(zod@3.25.76))))(@langchain/core@0.3.74(@opentelemetry/api@1.9.0)(@opentelemetry/exporter-trace-otlp-proto@0.210.0(@opentelemetry/api@1.9.0))(@opentelemetry/sdk-trace-base@2.5.0(@opentelemetry/api@1.9.0))(openai@4.104.0(ws@8.19.0)(zod@3.25.76)))(@langchain/google-genai@2.1.3(@langchain/core@0.3.74(@opentelemetry/api@1.9.0)(@opentelemetry/exporter-trace-otlp-proto@0.210.0(@opentelemetry/api@1.9.0))(@opentelemetry/sdk-trace-base@2.5.0(@opentelemetry/api@1.9.0))(openai@4.104.0(ws@8.19.0)(zod@3.25.76))))(@opentelemetry/api@1.9.0)(@opentelemetry/exporter-trace-otlp-proto@0.210.0(@opentelemetry/api@1.9.0))(@opentelemetry/sdk-trace-base@2.5.0(@opentelemetry/api@1.9.0))(axios@1.7.4)(handlebars@4.7.8)(openai@4.104.0(ws@8.19.0)(zod@3.25.76))(ws@8.19.0) + version: 0.3.33(4c63b96815301c04536f0c3ba2bb9f23) lucide-react: specifier: ^0.487.0 version: 0.487.0(react@18.3.1) + mammoth: + specifier: ^1.11.0 + version: 1.11.0 motion: specifier: ^12.29.2 version: 12.29.2(react-dom@18.3.1(react@18.3.1))(react@18.3.1) @@ -272,6 +281,9 @@ importers: tailwind-merge: specifier: '*' version: 3.4.0 + tesseract.js: + specifier: ^7.0.0 + version: 7.0.0 tsx: specifier: ^4.20.5 version: 4.20.5 @@ -284,6 +296,9 @@ importers: vaul: specifier: ^1.1.2 version: 1.1.2(@types/react-dom@19.1.9(@types/react@19.1.12))(@types/react@19.1.12)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + xlsx: + specifier: ^0.18.5 + version: 0.18.5 zod: specifier: ^3.23.8 version: 3.25.76 @@ -4183,6 +4198,10 @@ packages: vue-router: optional: true + '@xmldom/xmldom@0.8.11': + resolution: {integrity: sha512-cQzWCtO6C8TQiYl1ruKNn2U6Ao4o4WBBcbL61yJl84x+j5sOWWFU9X7DpND8XZG3daDppSsigMdfAIl2upQBRw==} + engines: {node: '>=10.0.0'} + abort-controller-x@0.4.3: resolution: {integrity: sha512-VtUwTNU8fpMwvWGn4xE93ywbogTYsuT+AUxAXOeelbXuQVIwNmC5YLeho9sH4vZ4ITW8414TTAOG1nW6uIVHCA==} @@ -4205,6 +4224,10 @@ packages: engines: {node: '>=0.4.0'} hasBin: true + adler-32@1.3.1: + resolution: {integrity: sha512-ynZ4w/nUUv5rrsR8UUGoe1VC9hZj6V5hU9Qw1HlMDJGEJw5S7TfTErWTjMys6M7vr0YWcPqs3qAr4ss0nDfP+A==} + engines: {node: '>=0.8'} + agent-base@7.1.4: resolution: {integrity: sha512-MnA+YT8fwfJPgBx3m60MNqakm30XOkyIoH1y6huTQvC0PwZG7ki8NacLBcrPbNoo8vEZy7Jpuk7+jMO+CUovTQ==} engines: {node: '>= 14'} @@ -4404,6 +4427,15 @@ packages: bintrees@1.0.2: resolution: {integrity: sha512-VOMgTMwjAaUG580SXn3LacVgjurrbMme7ZZNYGSSV7mmtY6QQRh0Eg3pwIcntQ77DErK1L0NxkbetjcoXzVwKw==} + bluebird@3.4.7: + resolution: {integrity: sha512-iD3898SR7sWVRHbiQv+sHUtHnMvC1o3nW5rAcqnq3uOn07DSAppZYUkIGslDz6gXC7HfunPe7YVBgoEJASPcHA==} + + bmp-js@0.1.0: + resolution: {integrity: sha512-vHdS19CnY3hwiNdkaqk93DvjVLfbEcI8mys4UjuWrlX1haDmroo8o4xCzh4wD6DGV6HxRCyauwhHRqMTfERtjw==} + + boolbase@1.0.0: + resolution: {integrity: sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==} + boolean@3.2.0: resolution: {integrity: sha512-d0II/GO9uf9lfUHH2BQsjxzRJZBdsjgsBiW4BvhWk/3qoKwQFjIDVN19PfX8F2D/r9PCMTtLWjYVCFrpeYUzsw==} deprecated: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info. @@ -4477,6 +4509,10 @@ packages: ccount@2.0.1: resolution: {integrity: sha512-eyrF0jiFpY+3drT6383f1qhkbGsLSifNAjA61IUjZjmLCWjItY6LB9ft9YhoDgwfmclB2zhu51Lc7+95b8NRAg==} + cfb@1.2.2: + resolution: {integrity: sha512-KfdUZsSOw19/ObEWasvBP/Ac4reZvAGauZhs6S/gqNhXhI7cKwvlH7ulj+dOEYnca4bm4SGo8C1bTAQvnTjgQA==} + engines: {node: '>=0.8'} + chalk@4.1.2: resolution: {integrity: sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==} engines: {node: '>=10'} @@ -4497,6 +4533,13 @@ packages: character-reference-invalid@2.0.1: resolution: {integrity: sha512-iBZ4F4wRbyORVsu0jPV7gXkOsGYjGHPmAyv+HiHG8gi5PtC9KI2j1+v8/tlibRvjoWX027ypmG/n0HtO5t7unw==} + cheerio-select@2.1.0: + resolution: {integrity: sha512-9v9kG0LvzrlcungtnJtpGNxY+fzECQKhK4EGJX2vByejiMX84MFNQw4UxPJl3bFbTMw+Dfs37XaIkCwTZfLh4g==} + + cheerio@1.2.0: + resolution: {integrity: sha512-WDrybc/gKFpTYQutKIK6UvfcuxijIZfMfXaYm8NMsPQxSYvf+13fXUJ4rztGGbJcBQ/GF55gvrZ0Bc0bj/mqvg==} + engines: {node: '>=20.18.1'} + chokidar@3.6.0: resolution: {integrity: sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==} engines: {node: '>= 8.10.0'} @@ -4539,6 +4582,10 @@ packages: resolution: {integrity: sha512-QVb0dM5HvG+uaxitm8wONl7jltx8dqhfU33DcqtOZcLSVIKSDDLDi7+0LbAKiyI8hD9u42m2YxXSkMGWThaecQ==} engines: {iojs: '>= 1.0.0', node: '>= 0.12.0'} + codepage@1.15.0: + resolution: {integrity: sha512-3g6NUTPd/YtuuGrhMnOMRjFc+LJw/bnMp3+0r/Wcz3IXUuCosKRJvMphm5+Q+bvTVGcJJuRvVLuYba+WojaFaA==} + engines: {node: '>=0.8'} + collect-v8-coverage@1.0.3: resolution: {integrity: sha512-1L5aqIkwPfiodaMgQunkF1zRhNqifHBmtbbbxcr6yVxxBnliw4TDOW6NxpO8DJLgJ16OT+Y4ztZqP6p/FtXnAw==} @@ -4590,6 +4637,14 @@ packages: core-js-compat@3.46.0: resolution: {integrity: sha512-p9hObIIEENxSV8xIu+V68JjSeARg6UVMG5mR+JEUguG3sI6MsiS1njz2jHmyJDvA+8jX/sytkBHup6kxhM9law==} + core-util-is@1.0.3: + resolution: {integrity: sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==} + + crc-32@1.2.2: + resolution: {integrity: sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ==} + engines: {node: '>=0.8'} + hasBin: true + cross-fetch@3.2.0: resolution: {integrity: sha512-Q+xVJLoGOeIMXZmbUK4HYk+69cQH6LudR0Vu/pRm2YlU/hDV9CiS0gKUMaWY5f2NeUH9C1nV3bsTlCo0FsTV1Q==} @@ -4603,6 +4658,13 @@ packages: crypto-js@4.2.0: resolution: {integrity: sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q==} + css-select@5.2.2: + resolution: {integrity: sha512-TizTzUddG/xYLA3NXodFM0fSbNizXjOKhqiQQwvhlspadZokn1KDy0NZFS0wuEubIYAV5/c1/lAr0TaaFXEXzw==} + + css-what@6.2.2: + resolution: {integrity: sha512-u/O3vwbptzhMs3L1fQE82ZSLHQQfto5gyZzwteVIEyeaY5Fc7R4dapF/BvRoSYFeqfBk4m0V1Vafq5Pjv25wvA==} + engines: {node: '>= 6'} + css.escape@1.5.1: resolution: {integrity: sha512-YUifsXXuknHlUsmlgyY0PKzgPOr7/FjCePfHNt0jxm83wHZi44VDMQ7/fGNkjY3/jV1MC+1CmZbaHzugyeRtpg==} @@ -4785,6 +4847,9 @@ packages: didyoumean@1.2.2: resolution: {integrity: sha512-gxtyfqMg7GKyhQmb056K7M3xszy/myH8w+B4RT+QXBQsvAOdc3XymqDDPHx1BgPgsdAA5SIifona89YtRATDzw==} + dingbat-to-unicode@1.0.1: + resolution: {integrity: sha512-98l0sW87ZT58pU4i61wa2OHwxbiYSbuxsCBozaVnYX2iCnr3bLM3fIes1/ej7h1YdOKuKt/MLs706TVnALA65w==} + dlv@1.1.3: resolution: {integrity: sha512-+HlytyjlPKnIG8XuRG8WvmBP8xs8P71y+SKKS6ZXWoEgLuePxtDoUEiH7WkdePWrQ5JBpE6aoVqfZfJUQkjXwA==} @@ -4801,6 +4866,19 @@ packages: dom-helpers@5.2.1: resolution: {integrity: sha512-nRCa7CK3VTrM2NmGkIy4cbK7IZlgBE/PYMn55rrXefr5xXDP0LdtfPnblFDoVdcAfslJ7or6iqAUnx0CCGIWQA==} + dom-serializer@2.0.0: + resolution: {integrity: sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==} + + domelementtype@2.3.0: + resolution: {integrity: sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==} + + domhandler@5.0.3: + resolution: {integrity: sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w==} + engines: {node: '>= 4'} + + domutils@3.2.2: + resolution: {integrity: sha512-6kZKyUajlDuqlHKVX1w7gyslj9MPIXzIFiz/rGu35uC1wMi+kMhQwGhl4lt9unC9Vb9INnY9Z3/ZA3+FhASLaw==} + dotenv@16.6.1: resolution: {integrity: sha512-uBq4egWHTcTt33a72vpSG0z3HnPuIl6NqYcTrKEg2azoEyl2hpW0zqlxysq2pK9HlDIHyHyakeYaYnSAwd8bow==} engines: {node: '>=12'} @@ -4904,6 +4982,9 @@ packages: duck-duck-scrape@2.2.7: resolution: {integrity: sha512-BEcglwnfx5puJl90KQfX+Q2q5vCguqyMpZcSRPBWk8OY55qWwV93+E+7DbIkrGDW4qkqPfUvtOUdi0lXz6lEMQ==} + duck@0.1.12: + resolution: {integrity: sha512-wkctla1O6VfP89gQ+J/yDesM0S7B7XLXjKGzXxMDVFg7uEn706niAtyYovKbyq1oT9YwDcly721/iUWoc8MVRg==} + dunder-proto@1.0.1: resolution: {integrity: sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==} engines: {node: '>= 0.4'} @@ -4946,10 +5027,21 @@ packages: emoji-regex@9.2.2: resolution: {integrity: sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==} + encoding-sniffer@0.2.1: + resolution: {integrity: sha512-5gvq20T6vfpekVtqrYQsSCFZ1wEg5+wW0/QaZMWkFr6BqD3NfKs0rLCx4rrVlSWJeZb5NBJgVLswK/w2MWU+Gw==} + + entities@4.5.0: + resolution: {integrity: sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==} + engines: {node: '>=0.12'} + entities@6.0.1: resolution: {integrity: sha512-aN97NXWF6AWBTahfVOIrB/NShkzi5H7F9r1s9mD3cDj4Ko5f2qhhVoYMibXF7GlLveb/D2ioWay8lxI97Ven3g==} engines: {node: '>=0.12'} + entities@7.0.1: + resolution: {integrity: sha512-TWrgLOFUQTH994YUyl1yT4uyavY5nNB5muff+RtWaqNVCAK408b5ZnnbNAUEWLTCpum9w6arT70i1XdQ4UeOPA==} + engines: {node: '>=0.12'} + error-ex@1.3.4: resolution: {integrity: sha512-sqQamAnR14VgCr1A618A3sGrygcpK+HEbenA/HiEAkkUwcZIIB/tgWqHFxWgOyDh4nB4JCRimh79dR5Ywc9MDQ==} @@ -5308,6 +5400,10 @@ packages: forwarded-parse@2.1.2: resolution: {integrity: sha512-alTFZZQDKMporBH77856pXgzhEzaUVmLCDk+egLgIgHst3Tpndzz8MnKe+GzRJRfvVdn69HhpW7cmXzvtLvJAw==} + frac@1.1.2: + resolution: {integrity: sha512-w/XBfkibaTl3YDqASwfDUqkna4Z2p9cFSr1aHDt0WoMTECnRfBOv2WArlZILlqgWlmdIlALXGpM2AOhEk5W3IA==} + engines: {node: '>=0.8'} + fraction.js@4.3.7: resolution: {integrity: sha512-ZsDfxO51wGAXREY55a7la9LScWpwv9RxIrYABrlvOFBlH/ShPnrtsXeuUIfXKKOVicNxQ+o8JTbJvjS4M89yew==} @@ -5536,6 +5632,9 @@ packages: html-url-attributes@3.0.1: resolution: {integrity: sha512-ol6UPyBWqsrO6EJySPz2O7ZSr856WDrEzM5zMqp+FJJLGMW35cLYmmZnl0vztAZxRUoNZJFTCohfjuIJ8I4QBQ==} + htmlparser2@10.1.0: + resolution: {integrity: sha512-VTZkM9GWRAtEpveh7MSF6SjjrpNVNNVJfFup7xTY3UpFtm67foy9HDVXneLtFVt4pMz5kZtgNcvCniNFb1hlEQ==} + http-proxy-agent@7.0.2: resolution: {integrity: sha512-T1gkAiYYDWYx3V5Bmyu7HcfcvL7mUrTWiM6yOfa3PIphViJ/gFPbvidQ+veqSOHci/PxBcDabeUNCzpOODJZig==} engines: {node: '>= 14'} @@ -5559,6 +5658,9 @@ packages: resolution: {integrity: sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==} engines: {node: '>=0.10.0'} + idb-keyval@6.2.2: + resolution: {integrity: sha512-yjD9nARJ/jb1g+CvD0tlhUHOrJ9Sy0P8T9MF3YaLlHnSRpwPfpTX0XIvpmw3gAJUmEu3FiICLBDPXVwyEvrleg==} + ieee754@1.2.1: resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==} @@ -5570,6 +5672,9 @@ packages: resolution: {integrity: sha512-Hs59xBNfUIunMFgWAbGX5cq6893IbWg4KnrjbYwX3tx0ztorVgTDA6B2sxf8ejHJ4wz8BqGUMYlnzNBer5NvGg==} engines: {node: '>= 4'} + immediate@3.0.6: + resolution: {integrity: sha512-XXOFtyqDjNDAQxVfYxuF7g9Il/IbWmmlQg2MYKOH8ExIT1qg6xc4zyS3HaEEATgs1btfzxq15ciUiY7gjSXRGQ==} + import-fresh@3.3.1: resolution: {integrity: sha512-TR3KfrTZTYLPB6jUjfx6MF9WcWrHL9su5TObK4ZkYgBdWKPOFoSoQIdEuTuR82pmtxH2spWG9h6etwfr1pLBqQ==} engines: {node: '>=6'} @@ -5783,6 +5888,9 @@ packages: resolution: {integrity: sha512-p3EcsicXjit7SaskXHs1hA91QxgTw46Fv6EFKKGS5DRFLD8yKnohjF3hxoju94b/OcMZoQukzpPpBE9uLVKzgQ==} engines: {node: '>= 0.4'} + is-url@1.2.4: + resolution: {integrity: sha512-ITvGim8FhRiYe4IQ5uHSkj7pVaPDrCTkNd3yq3cV7iZAcJdHTUMPMEHcqSOy9xZ9qFenQCvi+2wjH9a1nXqHww==} + is-weakmap@2.0.2: resolution: {integrity: sha512-K5pXYOm9wqY1RgjpL3YTkF39tni1XajUIkawTLUo9EZEVUFga5gSQJF8nNS7ZwJQ02y+1YCNYcMh+HIf1ZqE+w==} engines: {node: '>= 0.4'} @@ -5795,6 +5903,9 @@ packages: resolution: {integrity: sha512-mfcwb6IzQyOKTs84CQMrOwW4gQcaTOAWJ0zzJCl2WSPDrWk/OzDaImWFH3djXhb24g4eudZfLRozAvPGw4d9hQ==} engines: {node: '>= 0.4'} + isarray@1.0.0: + resolution: {integrity: sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==} + isarray@2.0.5: resolution: {integrity: sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==} @@ -6051,6 +6162,9 @@ packages: resolution: {integrity: sha512-ZZow9HBI5O6EPgSJLUb8n2NKgmVWTwCvHGwFuJlMjvLFqlGG6pjirPhtdsseaLZjSibD8eegzmYpUZwoIlj2cQ==} engines: {node: '>=4.0'} + jszip@3.10.1: + resolution: {integrity: sha512-xXDvecyTpGLrqFrvkrUSoxxfJI5AH7U8zxxtVclpsUtMCq4JQ290LY8AW5c7Ggnr/Y/oK+bQMbqK2qmtk3pN4g==} + jwa@2.0.1: resolution: {integrity: sha512-hRF04fqJIP8Abbkq5NKGN0Bbr3JxlQ+qhZufXVr0DvujKy93ZCbXZMHDL4EOtodSbCWxOqR8MS1tXA5hwqCXDg==} @@ -6154,6 +6268,9 @@ packages: resolution: {integrity: sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==} engines: {node: '>= 0.8.0'} + lie@3.3.0: + resolution: {integrity: sha512-UaiMJzeWRlEujzAuw5LokY1L5ecNQYZKfmyZ9L7wDHb/p5etKaxXhohBcrw0EYby+G/NA52vRSN4N39dxHAIwQ==} + lilconfig@3.1.3: resolution: {integrity: sha512-/vlFKAoH5Cgt3Ie+JLhRbwOsCQePABiU3tJ1egGvyQ+33R/vcwM2Zl2QR/LzjsBeItPt3oSVXapn+m4nQDvpzw==} engines: {node: '>=14'} @@ -6212,6 +6329,9 @@ packages: resolution: {integrity: sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==} hasBin: true + lop@0.4.2: + resolution: {integrity: sha512-RefILVDQ4DKoRZsJ4Pj22TxE3omDO47yFpkIBoDKzkqPRISs5U1cnAdg/5583YPkWPaLIYHOKRMQSvjFsO26cw==} + lru-cache@10.4.3: resolution: {integrity: sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==} @@ -6234,6 +6354,11 @@ packages: makeerror@1.0.12: resolution: {integrity: sha512-JmqCvUhmt43madlpFzG4BQzG2Z3m6tvQDNKdClZnO3VbIudJYmxsT0FNJMeiB2+JTSlTQTSbU8QdesVmwJcmLg==} + mammoth@1.11.0: + resolution: {integrity: sha512-BcEqqY/BOwIcI1iR5tqyVlqc3KIaMRa4egSoK83YAVrBf6+yqdAAbtUcFDCWX8Zef8/fgNZ6rl4VUv+vVX8ddQ==} + engines: {node: '>=12.0.0'} + hasBin: true + markdown-table@3.0.4: resolution: {integrity: sha512-wiYz4+JrLyb/DqW2hkFJxP7Vd7JuTDm77fvbM8VfEQdmSMqcImWeeRbHwZjBjIFki/VaMK2BhFi7oUUZeM5bqw==} @@ -6574,6 +6699,9 @@ packages: resolution: {integrity: sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==} engines: {node: '>=8'} + nth-check@2.1.1: + resolution: {integrity: sha512-lqjrjmaOoAnWfMmBPL+XNnynZh2+swxiX3WUE0s4yEHI6m+AwrK2UZOimIRl3X/4QctVqS8AiZjFqyOGrMXb/w==} + nwsapi@2.2.22: resolution: {integrity: sha512-ujSMe1OWVn55euT1ihwCI1ZcAaAU3nxUiDwfDQldc51ZXaB9m2AyOn6/jh1BLe2t/G8xd6uKG1UBF2aZJeg2SQ==} @@ -6669,6 +6797,13 @@ packages: openapi-types@12.1.3: resolution: {integrity: sha512-N4YtSYJqghVu4iek2ZUvcN/0aqH1kRDuNqzcycDxhOUpg7GdvLa2F3DgS6yBNhInhv2r/6I0Flkn7CqL8+nIcw==} + opencollective-postinstall@2.0.3: + resolution: {integrity: sha512-8AV/sCtuzUeTo8gQK5qDZzARrulB3egtLzFgteqB2tcT4Mw7B8Kt7JcDHmltjz6FOAHsvTevk70gZEbhM4ZS9Q==} + hasBin: true + + option@0.2.4: + resolution: {integrity: sha512-pkEqbDyl8ou5cpq+VsnQbe/WlEy5qS7xPzMS1U55OCG9KPvwFD46zDbxQIj3egJSFc3D+XhYOPUzz49zQAVy7A==} + optionator@0.9.4: resolution: {integrity: sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==} engines: {node: '>= 0.8.0'} @@ -6734,6 +6869,12 @@ packages: resolution: {integrity: sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==} engines: {node: '>=8'} + parse5-htmlparser2-tree-adapter@7.1.0: + resolution: {integrity: sha512-ruw5xyKs6lrpo9x9rCZqZZnIUntICjQAd0Wsmp396Ul9lN/h+ifgVV1x1gZHi8euej6wTfpqX8j+BFQxF0NS/g==} + + parse5-parser-stream@7.1.2: + resolution: {integrity: sha512-JyeQc9iwFLn5TbvvqACIF/VXG6abODeB3Fwmv/TGdLk2LfbWkaySGY72at4+Ty7EkPZj854u4CrICqNk2qIbow==} + parse5@7.3.0: resolution: {integrity: sha512-IInvU7fabl34qmi9gY8XOVxhYyMyuH2xUNpb2q8/Y+7552KlejkRvqvD19nMoUW/uQGGbqNpA6Tufu5FL5BZgw==} @@ -6969,6 +7110,9 @@ packages: resolution: {integrity: sha512-9uBdv/B4EefsuAL+pWqueZyZS2Ba+LxfFeQ9DN14HU4bN8bhaxKdkpjpB6fs9+pSjIBu+FXQHImEg8j/Lw0+vA==} engines: {node: ^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0} + process-nextick-args@2.0.1: + resolution: {integrity: sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==} + process@0.11.10: resolution: {integrity: sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==} engines: {node: '>= 0.6.0'} @@ -7106,6 +7250,9 @@ packages: read-cache@1.0.0: resolution: {integrity: sha512-Owdv/Ft7IjOgm/i0xvNDZ1LrRANRfew4b2prF3OWMQLxLfu3bS8FVhCsrSCMK4lR56Y9ya+AThoTpDCTxCmpRA==} + readable-stream@2.3.8: + resolution: {integrity: sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==} + readable-stream@4.7.0: resolution: {integrity: sha512-oIGGmcpTLwPga8Bn6/Z75SVaH1z5dUut2ibSyAMVhmUggWpmDn2dapB0n7f8nwaSiRtepAsfJyfXIO5DCVAODg==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -7143,6 +7290,9 @@ packages: regenerate@1.4.2: resolution: {integrity: sha512-zrceR/XhGYU/d/opr2EKO7aRHUeiBI8qjtfHqADTwZd6Szfy16la6kqD0MIUs5z5hx6AaKa+PixpPrR289+I0A==} + regenerator-runtime@0.13.11: + resolution: {integrity: sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==} + regexp.prototype.flags@1.5.4: resolution: {integrity: sha512-dYqgNSZbDwkaJ2ceRd9ojCGjBq+mOm9LmtXnAnEGyHhN/5R7iDW2TRw3h+o/jCFxus3P2LfWIIiwowAjANm7IA==} engines: {node: '>= 0.4'} @@ -7239,6 +7389,9 @@ packages: resolution: {integrity: sha512-AURm5f0jYEOydBj7VQlVvDrjeFgthDdEF5H1dP+6mNpoXOMo1quQqJ4wvJDyRZ9+pO3kGWoOdmV08cSv2aJV6Q==} engines: {node: '>=0.4'} + safe-buffer@5.1.2: + resolution: {integrity: sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==} + safe-buffer@5.2.1: resolution: {integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==} @@ -7303,6 +7456,9 @@ packages: resolution: {integrity: sha512-RJRdvCo6IAnPdsvP/7m6bsQqNnn1FCBX5ZNtFL98MmFF/4xAIJTIg1YbHW5DC2W5SKZanrC6i4HsJqlajw/dZw==} engines: {node: '>= 0.4'} + setimmediate@1.0.5: + resolution: {integrity: sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA==} + sharp@0.33.5: resolution: {integrity: sha512-haPVm1EkS9pgvHrQ/F3Xy+hgcuMV0Wm9vfIBSiwZ05k+xgb0PkBQpGsAA/oWdDobNaZTH5ppvHtzCFbnSEwHVw==} engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} @@ -7384,6 +7540,10 @@ packages: sqids@0.3.0: resolution: {integrity: sha512-lOQK1ucVg+W6n3FhRwwSeUijxe93b51Bfz5PMRMihVf1iVkl82ePQG7V5vwrhzB11v0NtsR25PSZRGiSomJaJw==} + ssf@0.11.2: + resolution: {integrity: sha512-+idbmIXoYET47hH+d7dfm2epdOMUDjqcB4648sTZ+t2JwoyBFL/insLfB/racrDmsKB3diwsDA696pZMieAC5g==} + engines: {node: '>=0.8'} + stable-hash@0.0.5: resolution: {integrity: sha512-+L3ccpzibovGXFK+Ap/f8LOS0ahMrHTf3xu7mMLSpEGU0EO9ucaysSylKo9eRDFNhWve/y275iPmIZ4z39a9iA==} @@ -7439,6 +7599,9 @@ packages: resolution: {integrity: sha512-UXSH262CSZY1tfu3G3Secr6uGLCFVPMhIqHjlgCUtCCcgihYc/xKs9djMTMUOb2j1mVSeU8EU6NWc/iQKU6Gfg==} engines: {node: '>= 0.4'} + string_decoder@1.1.1: + resolution: {integrity: sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==} + string_decoder@1.3.0: resolution: {integrity: sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==} @@ -7550,6 +7713,12 @@ packages: temporal-spec@0.2.4: resolution: {integrity: sha512-lDMFv4nKQrSjlkHKAlHVqKrBG4DyFfa9F74cmBZ3Iy3ed8yvWnlWSIdi4IKfSqwmazAohBNwiN64qGx4y5Q3IQ==} + tesseract.js-core@7.0.0: + resolution: {integrity: sha512-WnNH518NzmbSq9zgTPeoF8c+xmilS8rFIl1YKbk/ptuuc7p6cLNELNuPAzcmsYw450ca6bLa8j3t0VAtq435Vw==} + + tesseract.js@7.0.0: + resolution: {integrity: sha512-exPBkd+z+wM1BuMkx/Bjv43OeLBxhL5kKWsz/9JY+DXcXdiBjiAch0V49QR3oAJqCaL5qURE0vx9Eo+G5YE7mA==} + test-exclude@6.0.0: resolution: {integrity: sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==} engines: {node: '>=8'} @@ -7686,6 +7855,9 @@ packages: resolution: {integrity: sha512-nWJ91DjeOkej/TA8pXQ3myruKpKEYgqvpw9lz4OPHj/NWFNluYrjbz9j01CJ8yKQd2g4jFoOkINCTW2I5LEEyw==} engines: {node: '>= 0.4'} + underscore@1.13.7: + resolution: {integrity: sha512-GMXzWtsc57XAtguZgaQViUOzs0KTkk8ojr3/xAxXLITqf/3EMwxC0inyETfDFjH/Krbhuep0HNbbjI9i/q3F3g==} + undici-types@5.26.5: resolution: {integrity: sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==} @@ -7695,6 +7867,10 @@ packages: undici-types@7.10.0: resolution: {integrity: sha512-t5Fy/nfn+14LuOc2KNYg75vZqClpAiqscVvMygNnlsHBFpSXdJaYtXMcdNLpl/Qvc3P2cB3s6lOV51nqsFq4ag==} + undici@7.22.0: + resolution: {integrity: sha512-RqslV2Us5BrllB+JeiZnK4peryVTndy9Dnqq62S3yYRRTj0tFQCwEniUy2167skdGOy3vqRzEvl1Dm4sV2ReDg==} + engines: {node: '>=20.18.1'} + unicode-canonical-property-names-ecmascript@2.0.1: resolution: {integrity: sha512-dA8WbNeb2a6oQzAQ55YlT5vQAWGV9WXOsi3SskE3bcCdM0P4SDd+24zS/OCacdRq5BkdsRj9q3Pg6YyQoxIGqg==} engines: {node: '>=4'} @@ -7850,6 +8026,9 @@ packages: walker@1.0.8: resolution: {integrity: sha512-ts/8E8l5b7kY0vlWLewOkDXMmPdLcVV4GmOQLyxuSswIJsweeFZtAsMF7k1Nszz+TYBQrlYRmzOnr398y1JemQ==} + wasm-feature-detect@1.8.0: + resolution: {integrity: sha512-zksaLKM2fVlnB5jQQDqKXXwYHLQUVH9es+5TOOHwGOVJOCeRBCiPjwSg+3tN2AdTCzjgli4jijCH290kXb/zWQ==} + weaviate-client@3.8.1: resolution: {integrity: sha512-/bH5SO31gGGiI5RhvOEwQBs2DtORsssVjenWxdOQzGToAdmqRC4Oo9HZLIITX5BdFD0IqKDnY81nOZlJlHzn+g==} engines: {node: '>=18.0.0'} @@ -7908,10 +8087,18 @@ packages: engines: {node: '>= 8'} hasBin: true + wmf@1.0.2: + resolution: {integrity: sha512-/p9K7bEh0Dj6WbXg4JG0xvLQmIadrner1bi45VMJTfnbVHsc7yIajZyoSoK60/dtVBs12Fm6WkUI5/3WAVsNMw==} + engines: {node: '>=0.8'} + word-wrap@1.2.5: resolution: {integrity: sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==} engines: {node: '>=0.10.0'} + word@0.3.0: + resolution: {integrity: sha512-OELeY0Q61OXpdUfTp+oweA/vtLVg5VDOXh+3he3PNzLGG/y0oylSOC1xRVj0+l4vQ3tj/bB1HVHv1ocXkQceFA==} + engines: {node: '>=0.8'} + wordwrap@1.0.0: resolution: {integrity: sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q==} @@ -7954,10 +8141,19 @@ packages: utf-8-validate: optional: true + xlsx@0.18.5: + resolution: {integrity: sha512-dmg3LCjBPHZnQp5/F/+nnTa+miPJxUXB6vtk42YjBBKayDNagxGEeIdWApkYPOf3Z3pm3k62Knjzp7lMeTEtFQ==} + engines: {node: '>=0.8'} + hasBin: true + xml-name-validator@5.0.0: resolution: {integrity: sha512-EvGK8EJ3DhaHfbRlETOWAS5pO9MZITeauHKJyb8wyajUfQUenkIg2MvLDTZ4T/TgIcm3HU0TFBgWWboAZ30UHg==} engines: {node: '>=18'} + xmlbuilder@10.1.1: + resolution: {integrity: sha512-OyzrcFLL/nb6fMGHbiRDuPup9ljBycsdCypwuyg5AAHvyWzGfChJpCXMG88AGTIMFhGZ9RccFN1e6lhg3hkwKg==} + engines: {node: '>=4.0'} + xmlchars@2.2.0: resolution: {integrity: sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==} @@ -7997,6 +8193,9 @@ packages: resolution: {integrity: sha512-AyeEbWOu/TAXdxlV9wmGcR0+yh2j3vYPGOECcIj2S7MkrLyC7ne+oye2BKTItt0ii2PHk4cDy+95+LshzbXnGg==} engines: {node: '>=12.20'} + zlibjs@0.3.1: + resolution: {integrity: sha512-+J9RrgTKOmlxFSDHo0pI1xM6BLVUv+o0ZT9ANtCxGkjIVCCUdx9alUF8Gm+dGLKbkkkidWIHFDZHDMpfITt4+w==} + zod-to-json-schema@3.24.6: resolution: {integrity: sha512-h/z3PKvcTcTetyjl1fkj79MHNEjm+HpD6NXheWjzOekY7kV+lwDYnHw+ivHkijnCSMz1yJaWBD9vu/Fcmk+vEg==} peerDependencies: @@ -9675,7 +9874,7 @@ snapshots: '@langchain/core': 0.3.74(@opentelemetry/api@1.9.0)(@opentelemetry/exporter-trace-otlp-proto@0.210.0(@opentelemetry/api@1.9.0))(@opentelemetry/sdk-trace-base@2.5.0(@opentelemetry/api@1.9.0))(openai@4.104.0(ws@8.19.0)(zod@3.25.76)) zod: 3.25.76 - '@langchain/community@0.3.54(b1e5c811be26b6393c340b5dcd0ebb02)': + '@langchain/community@0.3.54(287b5c5618b08f82035f6fa3c686e8ca)': dependencies: '@browserbasehq/stagehand': 1.9.0(@playwright/test@1.55.0)(deepmerge@4.3.1)(dotenv@16.6.1)(openai@4.104.0(ws@8.19.0)(zod@3.25.76))(zod@3.25.76) '@ibm-cloud/watsonx-ai': 1.3.1 @@ -9687,7 +9886,7 @@ snapshots: flat: 5.0.2 ibm-cloud-sdk-core: 5.1.0 js-yaml: 4.1.0 - langchain: 0.3.33(@langchain/anthropic@1.3.3(@langchain/core@0.3.74(@opentelemetry/api@1.9.0)(@opentelemetry/exporter-trace-otlp-proto@0.210.0(@opentelemetry/api@1.9.0))(@opentelemetry/sdk-trace-base@2.5.0(@opentelemetry/api@1.9.0))(openai@4.104.0(ws@8.19.0)(zod@3.25.76))))(@langchain/core@0.3.74(@opentelemetry/api@1.9.0)(@opentelemetry/exporter-trace-otlp-proto@0.210.0(@opentelemetry/api@1.9.0))(@opentelemetry/sdk-trace-base@2.5.0(@opentelemetry/api@1.9.0))(openai@4.104.0(ws@8.19.0)(zod@3.25.76)))(@langchain/google-genai@2.1.3(@langchain/core@0.3.74(@opentelemetry/api@1.9.0)(@opentelemetry/exporter-trace-otlp-proto@0.210.0(@opentelemetry/api@1.9.0))(@opentelemetry/sdk-trace-base@2.5.0(@opentelemetry/api@1.9.0))(openai@4.104.0(ws@8.19.0)(zod@3.25.76))))(@opentelemetry/api@1.9.0)(@opentelemetry/exporter-trace-otlp-proto@0.210.0(@opentelemetry/api@1.9.0))(@opentelemetry/sdk-trace-base@2.5.0(@opentelemetry/api@1.9.0))(axios@1.7.4)(handlebars@4.7.8)(openai@4.104.0(ws@8.19.0)(zod@3.25.76))(ws@8.19.0) + langchain: 0.3.33(4c63b96815301c04536f0c3ba2bb9f23) langsmith: 0.3.67(@opentelemetry/api@1.9.0)(@opentelemetry/exporter-trace-otlp-proto@0.210.0(@opentelemetry/api@1.9.0))(@opentelemetry/sdk-trace-base@2.5.0(@opentelemetry/api@1.9.0))(openai@4.104.0(ws@8.19.0)(zod@3.25.76)) openai: 4.104.0(ws@8.19.0)(zod@3.25.76) uuid: 10.0.0 @@ -9696,12 +9895,14 @@ snapshots: '@browserbasehq/sdk': 2.6.0 '@huggingface/transformers': 3.8.1 '@neondatabase/serverless': 1.0.1 + cheerio: 1.2.0 crypto-js: 4.2.0 duck-duck-scrape: 2.2.7 ignore: 5.3.2 jsdom: 26.1.0 jsonwebtoken: 9.0.3 lodash: 4.17.21 + mammoth: 1.11.0 pdf-parse: 1.1.1 playwright: 1.55.0 weaviate-client: 3.8.1 @@ -11833,6 +12034,8 @@ snapshots: next: 15.5.7(@babel/core@7.28.5)(@opentelemetry/api@1.9.0)(@playwright/test@1.55.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) react: 18.3.1 + '@xmldom/xmldom@0.8.11': {} + abort-controller-x@0.4.3: {} abort-controller@3.0.0: @@ -11849,6 +12052,8 @@ snapshots: acorn@8.15.0: {} + adler-32@1.3.1: {} + agent-base@7.1.4: {} agentkeepalive@4.6.0: @@ -12001,7 +12206,7 @@ snapshots: axios@1.7.4(debug@4.4.3): dependencies: follow-redirects: 1.15.11(debug@4.4.3) - form-data: 4.0.0 + form-data: 4.0.4 proxy-from-env: 1.1.0 transitivePeerDependencies: - debug @@ -12098,6 +12303,12 @@ snapshots: bintrees@1.0.2: {} + bluebird@3.4.7: {} + + bmp-js@0.1.0: {} + + boolbase@1.0.0: {} + boolean@3.2.0: {} brace-expansion@1.1.12: @@ -12172,6 +12383,11 @@ snapshots: ccount@2.0.1: {} + cfb@1.2.2: + dependencies: + adler-32: 1.3.1 + crc-32: 1.2.2 + chalk@4.1.2: dependencies: ansi-styles: 4.3.0 @@ -12187,6 +12403,29 @@ snapshots: character-reference-invalid@2.0.1: {} + cheerio-select@2.1.0: + dependencies: + boolbase: 1.0.0 + css-select: 5.2.2 + css-what: 6.2.2 + domelementtype: 2.3.0 + domhandler: 5.0.3 + domutils: 3.2.2 + + cheerio@1.2.0: + dependencies: + cheerio-select: 2.1.0 + dom-serializer: 2.0.0 + domhandler: 5.0.3 + domutils: 3.2.2 + encoding-sniffer: 0.2.1 + htmlparser2: 10.1.0 + parse5: 7.3.0 + parse5-htmlparser2-tree-adapter: 7.1.0 + parse5-parser-stream: 7.1.2 + undici: 7.22.0 + whatwg-mimetype: 4.0.0 + chokidar@3.6.0: dependencies: anymatch: 3.1.3 @@ -12235,6 +12474,8 @@ snapshots: co@4.6.0: {} + codepage@1.15.0: {} + collect-v8-coverage@1.0.3: {} color-convert@2.0.1: @@ -12279,6 +12520,10 @@ snapshots: dependencies: browserslist: 4.27.0 + core-util-is@1.0.3: {} + + crc-32@1.2.2: {} + cross-fetch@3.2.0: dependencies: node-fetch: 2.7.0 @@ -12300,6 +12545,16 @@ snapshots: crypto-js@4.2.0: optional: true + css-select@5.2.2: + dependencies: + boolbase: 1.0.0 + css-what: 6.2.2 + domhandler: 5.0.3 + domutils: 3.2.2 + nth-check: 2.1.1 + + css-what@6.2.2: {} + css.escape@1.5.1: {} cssesc@3.0.0: {} @@ -12440,6 +12695,8 @@ snapshots: didyoumean@1.2.2: {} + dingbat-to-unicode@1.0.1: {} + dlv@1.1.3: {} doctrine@2.1.0: @@ -12455,6 +12712,24 @@ snapshots: '@babel/runtime': 7.28.4 csstype: 3.1.3 + dom-serializer@2.0.0: + dependencies: + domelementtype: 2.3.0 + domhandler: 5.0.3 + entities: 4.5.0 + + domelementtype@2.3.0: {} + + domhandler@5.0.3: + dependencies: + domelementtype: 2.3.0 + + domutils@3.2.2: + dependencies: + dom-serializer: 2.0.0 + domelementtype: 2.3.0 + domhandler: 5.0.3 + dotenv@16.6.1: {} drizzle-kit@0.31.8: @@ -12478,6 +12753,10 @@ snapshots: html-entities: 2.6.0 needle: 3.3.1 + duck@0.1.12: + dependencies: + underscore: 1.13.7 + dunder-proto@1.0.1: dependencies: call-bind-apply-helpers: 1.0.2 @@ -12517,8 +12796,17 @@ snapshots: emoji-regex@9.2.2: {} + encoding-sniffer@0.2.1: + dependencies: + iconv-lite: 0.6.3 + whatwg-encoding: 3.1.1 + + entities@4.5.0: {} + entities@6.0.1: {} + entities@7.0.1: {} + error-ex@1.3.4: dependencies: is-arrayish: 0.2.1 @@ -13063,6 +13351,8 @@ snapshots: forwarded-parse@2.1.2: {} + frac@1.1.2: {} + fraction.js@4.3.7: {} framer-motion@12.29.2(react-dom@18.3.1(react@18.3.1))(react@18.3.1): @@ -13357,6 +13647,13 @@ snapshots: html-url-attributes@3.0.1: {} + htmlparser2@10.1.0: + dependencies: + domelementtype: 2.3.0 + domhandler: 5.0.3 + domutils: 3.2.2 + entities: 7.0.1 + http-proxy-agent@7.0.2: dependencies: agent-base: 7.1.4 @@ -13401,12 +13698,16 @@ snapshots: dependencies: safer-buffer: 2.1.2 + idb-keyval@6.2.2: {} + ieee754@1.2.1: {} ignore@5.3.2: {} ignore@7.0.5: {} + immediate@3.0.6: {} + import-fresh@3.3.1: dependencies: parent-module: 1.0.1 @@ -13614,6 +13915,8 @@ snapshots: dependencies: which-typed-array: 1.1.19 + is-url@1.2.4: {} + is-weakmap@2.0.2: {} is-weakref@1.1.1: @@ -13625,6 +13928,8 @@ snapshots: call-bound: 1.0.4 get-intrinsic: 1.3.0 + isarray@1.0.0: {} + isarray@2.0.5: {} isexe@2.0.0: {} @@ -14099,6 +14404,13 @@ snapshots: object.assign: 4.1.7 object.values: 1.2.1 + jszip@3.10.1: + dependencies: + lie: 3.3.0 + pako: 1.0.11 + readable-stream: 2.3.8 + setimmediate: 1.0.5 + jwa@2.0.1: dependencies: buffer-equal-constant-time: 1.0.1 @@ -14118,7 +14430,7 @@ snapshots: dependencies: json-buffer: 3.0.1 - langchain@0.3.33(@langchain/anthropic@1.3.3(@langchain/core@0.3.74(@opentelemetry/api@1.9.0)(@opentelemetry/exporter-trace-otlp-proto@0.210.0(@opentelemetry/api@1.9.0))(@opentelemetry/sdk-trace-base@2.5.0(@opentelemetry/api@1.9.0))(openai@4.104.0(ws@8.19.0)(zod@3.25.76))))(@langchain/core@0.3.74(@opentelemetry/api@1.9.0)(@opentelemetry/exporter-trace-otlp-proto@0.210.0(@opentelemetry/api@1.9.0))(@opentelemetry/sdk-trace-base@2.5.0(@opentelemetry/api@1.9.0))(openai@4.104.0(ws@8.19.0)(zod@3.25.76)))(@langchain/google-genai@2.1.3(@langchain/core@0.3.74(@opentelemetry/api@1.9.0)(@opentelemetry/exporter-trace-otlp-proto@0.210.0(@opentelemetry/api@1.9.0))(@opentelemetry/sdk-trace-base@2.5.0(@opentelemetry/api@1.9.0))(openai@4.104.0(ws@8.19.0)(zod@3.25.76))))(@opentelemetry/api@1.9.0)(@opentelemetry/exporter-trace-otlp-proto@0.210.0(@opentelemetry/api@1.9.0))(@opentelemetry/sdk-trace-base@2.5.0(@opentelemetry/api@1.9.0))(axios@1.7.4)(handlebars@4.7.8)(openai@4.104.0(ws@8.19.0)(zod@3.25.76))(ws@8.19.0): + langchain@0.3.33(4c63b96815301c04536f0c3ba2bb9f23): dependencies: '@langchain/core': 0.3.74(@opentelemetry/api@1.9.0)(@opentelemetry/exporter-trace-otlp-proto@0.210.0(@opentelemetry/api@1.9.0))(@opentelemetry/sdk-trace-base@2.5.0(@opentelemetry/api@1.9.0))(openai@4.104.0(ws@8.19.0)(zod@3.25.76)) '@langchain/openai': 0.6.11(@langchain/core@0.3.74(@opentelemetry/api@1.9.0)(@opentelemetry/exporter-trace-otlp-proto@0.210.0(@opentelemetry/api@1.9.0))(@opentelemetry/sdk-trace-base@2.5.0(@opentelemetry/api@1.9.0))(openai@4.104.0(ws@8.19.0)(zod@3.25.76)))(ws@8.19.0) @@ -14136,6 +14448,7 @@ snapshots: '@langchain/anthropic': 1.3.3(@langchain/core@0.3.74(@opentelemetry/api@1.9.0)(@opentelemetry/exporter-trace-otlp-proto@0.210.0(@opentelemetry/api@1.9.0))(@opentelemetry/sdk-trace-base@2.5.0(@opentelemetry/api@1.9.0))(openai@4.104.0(ws@8.19.0)(zod@3.25.76))) '@langchain/google-genai': 2.1.3(@langchain/core@0.3.74(@opentelemetry/api@1.9.0)(@opentelemetry/exporter-trace-otlp-proto@0.210.0(@opentelemetry/api@1.9.0))(@opentelemetry/sdk-trace-base@2.5.0(@opentelemetry/api@1.9.0))(openai@4.104.0(ws@8.19.0)(zod@3.25.76))) axios: 1.7.4(debug@4.4.3) + cheerio: 1.2.0 handlebars: 4.7.8 transitivePeerDependencies: - '@opentelemetry/api' @@ -14172,6 +14485,10 @@ snapshots: prelude-ls: 1.2.1 type-check: 0.4.0 + lie@3.3.0: + dependencies: + immediate: 3.0.6 + lilconfig@3.1.3: {} lines-and-columns@1.2.4: {} @@ -14214,6 +14531,12 @@ snapshots: dependencies: js-tokens: 4.0.0 + lop@0.4.2: + dependencies: + duck: 0.1.12 + option: 0.2.4 + underscore: 1.13.7 + lru-cache@10.4.3: {} lru-cache@5.1.1: @@ -14234,6 +14557,19 @@ snapshots: dependencies: tmpl: 1.0.5 + mammoth@1.11.0: + dependencies: + '@xmldom/xmldom': 0.8.11 + argparse: 1.0.10 + base64-js: 1.5.1 + bluebird: 3.4.7 + dingbat-to-unicode: 1.0.1 + jszip: 3.10.1 + lop: 0.4.2 + path-is-absolute: 1.0.1 + underscore: 1.13.7 + xmlbuilder: 10.1.1 + markdown-table@3.0.4: {} matcher@3.0.0: @@ -14781,6 +15117,10 @@ snapshots: dependencies: path-key: 3.1.1 + nth-check@2.1.1: + dependencies: + boolbase: 1.0.0 + nwsapi@2.2.22: {} object-assign@4.1.1: {} @@ -14889,6 +15229,10 @@ snapshots: openapi-types@12.1.3: {} + opencollective-postinstall@2.0.3: {} + + option@0.2.4: {} + optionator@0.9.4: dependencies: deep-is: 0.1.4 @@ -14967,6 +15311,15 @@ snapshots: json-parse-even-better-errors: 2.3.1 lines-and-columns: 1.2.4 + parse5-htmlparser2-tree-adapter@7.1.0: + dependencies: + domhandler: 5.0.3 + parse5: 7.3.0 + + parse5-parser-stream@7.1.2: + dependencies: + parse5: 7.3.0 + parse5@7.3.0: dependencies: entities: 6.0.1 @@ -15123,6 +15476,8 @@ snapshots: ansi-styles: 5.2.0 react-is: 18.3.1 + process-nextick-args@2.0.1: {} + process@0.11.10: {} prom-client@15.1.3: @@ -15285,6 +15640,16 @@ snapshots: dependencies: pify: 2.3.0 + readable-stream@2.3.8: + dependencies: + core-util-is: 1.0.3 + inherits: 2.0.4 + isarray: 1.0.0 + process-nextick-args: 2.0.1 + safe-buffer: 5.1.2 + string_decoder: 1.1.1 + util-deprecate: 1.0.2 + readable-stream@4.7.0: dependencies: abort-controller: 3.0.0 @@ -15340,6 +15705,8 @@ snapshots: regenerate@1.4.2: {} + regenerator-runtime@0.13.11: {} + regexp.prototype.flags@1.5.4: dependencies: call-bind: 1.0.8 @@ -15481,6 +15848,8 @@ snapshots: has-symbols: 1.1.0 isarray: 2.0.5 + safe-buffer@5.1.2: {} + safe-buffer@5.2.1: {} safe-push-apply@1.0.0: @@ -15544,6 +15913,8 @@ snapshots: es-errors: 1.3.0 es-object-atoms: 1.1.1 + setimmediate@1.0.5: {} + sharp@0.33.5: dependencies: color: 4.2.3 @@ -15672,6 +16043,10 @@ snapshots: sqids@0.3.0: {} + ssf@0.11.2: + dependencies: + frac: 1.1.2 + stable-hash@0.0.5: {} stack-utils@2.0.6: @@ -15759,6 +16134,10 @@ snapshots: define-properties: 1.2.1 es-object-atoms: 1.1.1 + string_decoder@1.1.1: + dependencies: + safe-buffer: 5.1.2 + string_decoder@1.3.0: dependencies: safe-buffer: 5.2.1 @@ -15891,6 +16270,22 @@ snapshots: temporal-spec@0.2.4: {} + tesseract.js-core@7.0.0: {} + + tesseract.js@7.0.0: + dependencies: + bmp-js: 0.1.0 + idb-keyval: 6.2.2 + is-url: 1.2.4 + node-fetch: 2.7.0 + opencollective-postinstall: 2.0.3 + regenerator-runtime: 0.13.11 + tesseract.js-core: 7.0.0 + wasm-feature-detect: 1.8.0 + zlibjs: 0.3.1 + transitivePeerDependencies: + - encoding + test-exclude@6.0.0: dependencies: '@istanbuljs/schema': 0.1.3 @@ -16035,12 +16430,16 @@ snapshots: has-symbols: 1.1.0 which-boxed-primitive: 1.1.1 + underscore@1.13.7: {} + undici-types@5.26.5: {} undici-types@6.21.0: {} undici-types@7.10.0: {} + undici@7.22.0: {} + unicode-canonical-property-names-ecmascript@2.0.1: {} unicode-match-property-ecmascript@2.0.0: @@ -16235,6 +16634,8 @@ snapshots: dependencies: makeerror: 1.0.12 + wasm-feature-detect@1.8.0: {} + weaviate-client@3.8.1: dependencies: abort-controller-x: 0.4.3 @@ -16319,8 +16720,12 @@ snapshots: dependencies: isexe: 2.0.0 + wmf@1.0.2: {} + word-wrap@1.2.5: {} + word@0.3.0: {} + wordwrap@1.0.0: optional: true @@ -16347,8 +16752,20 @@ snapshots: ws@8.19.0: {} + xlsx@0.18.5: + dependencies: + adler-32: 1.3.1 + cfb: 1.2.2 + codepage: 1.15.0 + crc-32: 1.2.2 + ssf: 0.11.2 + wmf: 1.0.2 + word: 0.3.0 + xml-name-validator@5.0.0: {} + xmlbuilder@10.1.1: {} + xmlchars@2.2.0: {} xtend@4.0.2: {} @@ -16377,6 +16794,8 @@ snapshots: yocto-queue@1.2.1: {} + zlibjs@0.3.1: {} + zod-to-json-schema@3.24.6(zod@3.25.76): dependencies: zod: 3.25.76 diff --git a/scripts/ensure-pgvector.mjs b/scripts/ensure-pgvector.mjs new file mode 100644 index 00000000..69f4486b --- /dev/null +++ b/scripts/ensure-pgvector.mjs @@ -0,0 +1,36 @@ +import postgres from "postgres"; + +const url = process.env.DATABASE_URL; +if (!url) { + console.error("[ensure-pgvector] DATABASE_URL is required"); + process.exit(1); +} + +console.log("[ensure-pgvector] Connecting to databaseโ€ฆ"); + +const sql = postgres(url, { max: 1 }); +try { + await sql`CREATE EXTENSION IF NOT EXISTS vector`; + const [row] = await sql` + SELECT installed_version + FROM pg_available_extensions + WHERE name = 'vector' + `; + + if (row?.installed_version) { + console.log( + `[ensure-pgvector] pgvector ${row.installed_version} is ready`, + ); + } else { + console.error( + "[ensure-pgvector] Extension 'vector' is not installed in this PostgreSQL server. " + + "Make sure you are using the pgvector/pgvector Docker image.", + ); + process.exit(1); + } +} catch (err) { + console.error("[ensure-pgvector] Failed to enable pgvector:", err.message); + process.exit(1); +} finally { + await sql.end(); +} diff --git a/sidecar/Dockerfile b/sidecar/Dockerfile new file mode 100644 index 00000000..386cda58 --- /dev/null +++ b/sidecar/Dockerfile @@ -0,0 +1,21 @@ +FROM python:3.12-slim + +WORKDIR /app + +# Install system dependencies (for sentence-transformers / torch) +RUN apt-get update && apt-get install -y --no-install-recommends \ + build-essential \ + && rm -rf /var/lib/apt/lists/* + +COPY requirements.txt . +RUN pip install --no-cache-dir -r requirements.txt + +COPY app/ ./app/ + +# Model cache volume โ€” avoids re-downloading on every restart +ENV TRANSFORMERS_CACHE=/app/model-cache +ENV HF_HOME=/app/model-cache + +EXPOSE 8000 + +CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"] diff --git a/sidecar/app/__init__.py b/sidecar/app/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/sidecar/app/main.py b/sidecar/app/main.py new file mode 100644 index 00000000..5cfefb75 --- /dev/null +++ b/sidecar/app/main.py @@ -0,0 +1,53 @@ +""" +FastAPI Sidecar โ€” The Muscle +Provides /embed, /rerank, and /extract-entities endpoints +powered by local ML models (sentence-transformers, cross-encoders). +""" + +from contextlib import asynccontextmanager + +from fastapi import FastAPI + +from app.models.embedder import Embedder +from app.models.reranker import Reranker +from app.models.ner import EntityExtractor +from app.routes.embed import router as embed_router +from app.routes.rerank import router as rerank_router +from app.routes.entities import router as entities_router + + +# --------------------------------------------------------------------------- +# Lifespan โ€” warm up models once at startup +# --------------------------------------------------------------------------- + +@asynccontextmanager +async def lifespan(app: FastAPI): + """Load heavy ML models once and share them for the app lifetime.""" + app.state.embedder = Embedder() + app.state.reranker = Reranker() + app.state.entity_extractor = EntityExtractor() + + print("[Sidecar] Models loaded โ€” ready to serve.") + yield + print("[Sidecar] Shutting down.") + + +# --------------------------------------------------------------------------- +# App +# --------------------------------------------------------------------------- + +app = FastAPI( + title="PDR AI Sidecar", + description="Local ML compute for embedding, reranking, and entity extraction.", + version="0.1.0", + lifespan=lifespan, +) + +app.include_router(embed_router) +app.include_router(rerank_router) +app.include_router(entities_router) + + +@app.get("/health") +async def health(): + return {"status": "ok"} diff --git a/sidecar/app/models/__init__.py b/sidecar/app/models/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/sidecar/app/models/embedder.py b/sidecar/app/models/embedder.py new file mode 100644 index 00000000..798652a4 --- /dev/null +++ b/sidecar/app/models/embedder.py @@ -0,0 +1,39 @@ +""" +Embedding model wrapper. +Uses sentence-transformers to produce embeddings locally, +replacing OpenAI API calls to reduce cost. +""" + +import os +from sentence_transformers import SentenceTransformer + + +DEFAULT_MODEL = os.getenv("EMBEDDING_MODEL", "BAAI/bge-large-en-v1.5") +DEFAULT_DEVICE = os.getenv("DEVICE", "cpu") + + +class Embedder: + """Wraps a sentence-transformer model for local embedding generation.""" + + def __init__( + self, + model_name: str = DEFAULT_MODEL, + device: str = DEFAULT_DEVICE, + ): + print(f"[Embedder] Loading model {model_name} on {device}...") + self.model = SentenceTransformer(model_name, device=device) + self.dimension = self.model.get_sentence_embedding_dimension() + print(f"[Embedder] Ready โ€” dimension={self.dimension}") + + def embed(self, texts: list[str]) -> list[list[float]]: + """ + Generate embeddings for a list of texts. + Returns a list of float vectors. + """ + embeddings = self.model.encode( + texts, + convert_to_numpy=True, + normalize_embeddings=True, + show_progress_bar=False, + ) + return embeddings.tolist() diff --git a/sidecar/app/models/ner.py b/sidecar/app/models/ner.py new file mode 100644 index 00000000..ac0251d6 --- /dev/null +++ b/sidecar/app/models/ner.py @@ -0,0 +1,82 @@ +""" +Entity extraction model wrapper. +Uses a transformer-based NER model to extract entities and relationships +from text chunks for the Graph RAG pipeline. +""" + +import os +import re +from transformers import pipeline, Pipeline + + +DEFAULT_MODEL = os.getenv("NER_MODEL", "dslim/bert-base-NER") +DEFAULT_DEVICE = os.getenv("DEVICE", "cpu") + +# Map device string to transformers device index +DEVICE_MAP = {"cpu": -1, "cuda": 0, "cuda:0": 0, "cuda:1": 1} + + +class EntityExtractor: + """Wraps a token-classification (NER) pipeline.""" + + def __init__( + self, + model_name: str = DEFAULT_MODEL, + device: str = DEFAULT_DEVICE, + ): + print(f"[EntityExtractor] Loading model {model_name} on {device}...") + device_idx = DEVICE_MAP.get(device, -1) + self.pipe: Pipeline = pipeline( + "ner", + model=model_name, + aggregation_strategy="simple", + device=device_idx, + ) + print("[EntityExtractor] Ready.") + + def extract(self, texts: list[str]) -> list[dict]: + """ + Extract entities from a list of text chunks. + + Returns a list of dicts per chunk: + { + "text": "", + "entities": [ + {"text": "Microsoft", "label": "ORG", "score": 0.99}, + ... + ] + } + """ + results: list[dict] = [] + + for text in texts: + # Truncate very long texts to avoid OOM + truncated = text[:2048] + raw = self.pipe(truncated) + + entities: list[dict] = [] + seen: set[str] = set() + + for ent in raw: + word = ent["word"].strip() + # Clean up sub-word tokens + word = re.sub(r"^##", "", word).strip() + if not word or len(word) < 2: + continue + + key = f"{word.lower()}|{ent['entity_group']}" + if key in seen: + continue + seen.add(key) + + entities.append( + { + "text": word, + "label": ent["entity_group"], + "score": round(float(ent["score"]), 4), + } + ) + + results.append({"text": truncated, "entities": entities}) + + return results diff --git a/sidecar/app/models/reranker.py b/sidecar/app/models/reranker.py new file mode 100644 index 00000000..ac2883d4 --- /dev/null +++ b/sidecar/app/models/reranker.py @@ -0,0 +1,42 @@ +""" +Reranker model wrapper. +Uses a cross-encoder to rescore query-document pairs. +""" + +import os +from sentence_transformers import CrossEncoder + + +DEFAULT_MODEL = os.getenv( + "RERANKER_MODEL", "cross-encoder/ms-marco-MiniLM-L-12-v2" +) +DEFAULT_DEVICE = os.getenv("DEVICE", "cpu") + + +class Reranker: + """Wraps a cross-encoder for reranking retrieved documents.""" + + def __init__( + self, + model_name: str = DEFAULT_MODEL, + device: str = DEFAULT_DEVICE, + ): + print(f"[Reranker] Loading model {model_name} on {device}...") + self.model = CrossEncoder(model_name, device=device) + print("[Reranker] Ready.") + + def rerank( + self, + query: str, + documents: list[str], + ) -> list[float]: + """ + Score each document against the query. + Returns a list of relevance scores (higher = more relevant). + """ + if not documents: + return [] + + pairs = [(query, doc) for doc in documents] + scores = self.model.predict(pairs, show_progress_bar=False) + return scores.tolist() diff --git a/sidecar/app/routes/__init__.py b/sidecar/app/routes/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/sidecar/app/routes/embed.py b/sidecar/app/routes/embed.py new file mode 100644 index 00000000..c9fd95ad --- /dev/null +++ b/sidecar/app/routes/embed.py @@ -0,0 +1,33 @@ +""" +POST /embed โ€” Generate embeddings for a batch of text chunks. +Replaces OpenAI API calls with local inference to reduce cost. +""" + +from fastapi import APIRouter, Request +from pydantic import BaseModel, Field + + +router = APIRouter() + + +class EmbedRequest(BaseModel): + texts: list[str] = Field(..., min_length=1, description="Text chunks to embed") + + +class EmbedResponse(BaseModel): + embeddings: list[list[float]] + dimension: int + count: int + + +@router.post("/embed", response_model=EmbedResponse) +async def embed(req: EmbedRequest, request: Request): + """Generate embeddings for the provided text chunks.""" + embedder = request.app.state.embedder + vectors = embedder.embed(req.texts) + + return EmbedResponse( + embeddings=vectors, + dimension=embedder.dimension, + count=len(vectors), + ) diff --git a/sidecar/app/routes/entities.py b/sidecar/app/routes/entities.py new file mode 100644 index 00000000..747739f7 --- /dev/null +++ b/sidecar/app/routes/entities.py @@ -0,0 +1,51 @@ +""" +POST /extract-entities โ€” Extract named entities from text chunks. +Used by the Graph RAG pipeline to build the knowledge graph. +""" + +from fastapi import APIRouter, Request +from pydantic import BaseModel, Field + + +router = APIRouter() + + +class Entity(BaseModel): + text: str + label: str + score: float + + +class ChunkEntities(BaseModel): + text: str + entities: list[Entity] + + +class ExtractEntitiesRequest(BaseModel): + chunks: list[str] = Field( + ..., min_length=1, description="Text chunks to extract entities from" + ) + + +class ExtractEntitiesResponse(BaseModel): + results: list[ChunkEntities] + total_entities: int + + +@router.post("/extract-entities", response_model=ExtractEntitiesResponse) +async def extract_entities(req: ExtractEntitiesRequest, request: Request): + """Extract named entities from the provided text chunks.""" + extractor = request.app.state.entity_extractor + raw_results = extractor.extract(req.chunks) + + results = [] + total = 0 + for item in raw_results: + entities = [ + Entity(text=e["text"], label=e["label"], score=e["score"]) + for e in item["entities"] + ] + total += len(entities) + results.append(ChunkEntities(text=item["text"], entities=entities)) + + return ExtractEntitiesResponse(results=results, total_entities=total) diff --git a/sidecar/app/routes/rerank.py b/sidecar/app/routes/rerank.py new file mode 100644 index 00000000..588c22ed --- /dev/null +++ b/sidecar/app/routes/rerank.py @@ -0,0 +1,34 @@ +""" +POST /rerank โ€” Rescore retrieved documents against a query +using a cross-encoder model. +""" + +from fastapi import APIRouter, Request +from pydantic import BaseModel, Field + + +router = APIRouter() + + +class RerankRequest(BaseModel): + query: str = Field(..., min_length=1, description="The search query") + documents: list[str] = Field( + ..., min_length=1, description="Candidate document chunks to rerank" + ) + + +class RerankResponse(BaseModel): + scores: list[float] + count: int + + +@router.post("/rerank", response_model=RerankResponse) +async def rerank(req: RerankRequest, request: Request): + """Rerank candidate documents against the query.""" + reranker = request.app.state.reranker + scores = reranker.rerank(req.query, req.documents) + + return RerankResponse( + scores=scores, + count=len(scores), + ) diff --git a/sidecar/requirements.txt b/sidecar/requirements.txt new file mode 100644 index 00000000..0f65cc86 --- /dev/null +++ b/sidecar/requirements.txt @@ -0,0 +1,7 @@ +fastapi>=0.115.0 +uvicorn[standard]>=0.34.0 +sentence-transformers>=3.3.0 +torch>=2.5.0 +transformers>=4.47.0 +numpy>=1.26.0 +pydantic>=2.10.0 diff --git a/src/app/_components/SignupNavbar.tsx b/src/app/_components/SignupNavbar.tsx index d8ae6f60..a73d892a 100644 --- a/src/app/_components/SignupNavbar.tsx +++ b/src/app/_components/SignupNavbar.tsx @@ -3,10 +3,14 @@ import Link from "next/link"; import React from 'react'; import { Brain } from 'lucide-react'; +import { useAuth, useUser, UserButton } from '@clerk/nextjs'; import styles from '../../styles/navbar.module.css'; import { ThemeToggle } from './ThemeToggle'; export function SignupNavbar() { + const { isLoaded, isSignedIn } = useAuth(); + const { user } = useUser(); + return (