Skip to content

anurag162008/Divya-AI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

642 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Divya AI

Divya AI is a full-stack assistant platform with a React frontend, an Express backend, and optional Python workers for transcription/search/image tasks. It supports both local model runtimes (Ollama, LM Studio, Jan, LocalAI) and cloud providers (OpenAI, OpenRouter, Gemini, Hugging Face, Groq).

Master repo map

  • Read REPO_MASTER_GUIDE.md for complete architecture, feature ownership, API map, deploy model, and troubleshooting.
  • Read OWNER_COMPLETE_SETUP_GUIDE.md for owner-only local/deploy/env/agent operations checklist.

What this repo includes

  • Frontend: Vite + React chat app with markdown rendering, attachments, settings, gallery, and voice toggles.
  • Backend: Express API for provider routing, transcription/search/image/video endpoints, automation APIs, persistence, and system actions.
  • Local agent bridge: WebSocket client (agent_client.js) for running OS-level actions safely from a deployed backend.
  • Python workers: scripts for transcription (transcribe.py), web search (web_search.py), and local image generation (generate_image.py).

Tech stack

  • Frontend: React 19, Vite 7
  • Backend: Express 5, Axios, WS
  • Optional AI providers: Ollama, OpenAI, OpenRouter, Gemini, Hugging Face, Groq, LM Studio/Jan/LocalAI
  • Optional data sync: Supabase REST (service role from backend)

Core features

  • Multi-provider chat routing with streaming support
  • Rich chat UI (markdown, code, tables, media cards)
  • File attachments (image, PDF, text/code, audio)
  • Voice input + optional TTS replies
  • System tools with allowlists and confirmation gates
  • Automation endpoints (/precheck, workflows, integration calls, model session preferences)
  • Local persistence + optional backend/Supabase sync
  • Pre-login Contact Us CTA with direct Gmail compose redirect for access/support requests

Repository structure

.
├── src/
│   ├── components/        # Sidebar, ChatWindow, InputArea, Settings, Camera modal, gallery
│   ├── services/          # API wrappers, provider routing, automation/system/memory/reminder helpers
│   ├── App.jsx            # Main app orchestration
│   └── main.jsx
├── server.js              # Express backend and API routes
├── systemActions.js       # Local OS/system action executor
├── agent_client.js        # WebSocket bridge client for deployed mode
├── transcribe.py          # Whisper transcription worker
├── web_search.py          # Search/scrape worker
├── generate_image.py      # Local image generation worker
├── supabase/
│   ├── schema.sql
│   └── production_setup.sql
└── README.md

Getting started

Prerequisites

  • Node.js >=22.0.0
  • npm
  • Python 3.10+ (recommended if using Python workers)
  • Ollama (only if running local Ollama models)

User login (API key + password)

  • First-time user login: enter name + app API key, optionally set a password in the same login step.
  • Returning user login: leave API key blank and login with name + password.
  • Password change is available in Settings → General → Change Login Password.
  • User password hashes are stored in backend app-key metadata and sync through backend storage/Supabase app state.
  • Admin/User default permissions: all feature toggles ON by default except owner-only controls (Owner Settings access, Users Management, API Base URL Edit). Owner can grant/revoke from Users Management.
  • Supabase privacy toggle: Settings → General → Supabase chat + memory sync is ON by default. User can turn it OFF to stop only chat/memory syncing to Supabase; settings/app-key persistence stays ON.

Seeded demo accounts (default)

Beginner quick-start ke liye app me default seeded entries hain:

  • Admin: Yash / password: yash
  • User name: Prem
  • User App API key: prem-user-key-2026

Production me first login ke baad inhe rotate/change karna strongly recommended hai.

Repo error scan status (latest)

Run these checks:

npm run lint
npm run validate:all
npm run validate:deploy-readiness
python scripts/syntax_scan_report.py  # optional, file-wise JS/MJS syntax scan

Latest status in this repo snapshot:

  • npm run lint ✅ passed (no ESLint errors).
  • npm run validate:all ✅ passed static checks.
  • npm run validate:deploy-readiness now also validates package-lock.json sync with package.json (name + dependencies) to catch install-time failures early.
  • npm run validate:strict runs the full validation bundle in strict mode (fails CI on warnings/failures).
  • JS/MJS syntax scan ✅ no node --check failures.

Still pending (environment/runtime only):

  • Install runtime deps: express, ws, axios, cors, multer.
  • Configure AGENT_TOKEN and optional BASE_URL for live backend checks.

Install

npm install

Optional Python dependencies (needed for transcription/search/image worker flows):

pip install numpy openai-whisper torch requests beautifulsoup4 duckduckgo-search diffusers transformers accelerate

Run locally

npm run dev

This runs:

  • Frontend (Vite): http://localhost:5173
  • Backend (Express): http://localhost:3001

Environment variables

Frontend

  • VITE_API_BASE_URL - backend base URL (recommended: https://divya-ai.onrender.com)
  • VITE_BACKEND_URL / VITE_SERVER_URL - VITE_API_BASE_URL ke aliases (agar hosting panel me aapne ye naam se env set kiya ho to ab auto-pick ho jayega).
  • Optional: VITE_DEFAULT_BACKEND_BASE_URL - fallback backend URL (recommended when frontend is on Vercel and backend is on Render). Recommended value: https://divya-ai.onrender.com.
  • Note: hardcoded backend fallback removed; set VITE_API_BASE_URL (or VITE_DEFAULT_BACKEND_BASE_URL) explicitly for split deployments.
  • VITE_OLLAMA_BASE_URL - optional override for Ollama proxy endpoint

Backend

  • PORT - backend port (default: 3001)
  • DIVYA_DATA_DIR (or DATA_DIR) - persistent storage directory
    • Vercel par set na ho to runtime fallback /tmp/divya-ai/data use hota hai (ephemeral). Persistent data ke liye Supabase ya external storage use karein.
  • PYTHON_BIN (or PYTHON) - Python executable name/path
  • SUPABASE_URL - Supabase project URL (https://<project-ref>.supabase.co). If you accidentally paste /rest/v1, backend now auto-normalizes it.
  • SUPABASE_SERVICE_ROLE_KEY - Supabase service role key (backend only)
    • Important: Render/Vercel env value paste karte time quotes include mat karo.
  • SUPABASE_REQUEST_TIMEOUT_MS - Supabase request timeout in ms for fast health/status checks (default: 3500)
  • ALLOW_LOCAL_INTEGRATIONS=true - allow localhost integration URLs for automation endpoints
  • GEMINI_API_KEY - optional backend key for image/screenshot OCR (/read-image)
  • CORS_ALLOWED_ORIGINS - comma-separated allowlist for browser origins (example: https://your-frontend.vercel.app,https://www.your-frontend.vercel.app,*.vercel.app).
    • Example (your setup): CORS_ALLOWED_ORIGINS=https://divya-ai.vercel.app
    • Backend has safe fallback allow for official frontend origin https://divya-ai.vercel.app, but env var set karna still recommended for strict control.
    • Example (frontend + custom domain): CORS_ALLOWED_ORIGINS=https://divya-ai.vercel.app,https://app.yourdomain.com
    • Important: value me extra quotes ya trailing slash mat do (e.g. "https://..." avoid, https://domain.com/ ke badle https://domain.com use karo).

Model setup

Option A: Ollama (local)

  1. Start Ollama.
  2. Pull a model:
ollama pull gemma3:12b
  1. Verify:
ollama list

Option B: Cloud providers

Add keys in Settings → API Keys, then select provider/model in Settings → AI Model.

Supported examples:

  • OpenAI: gpt-4o-mini
  • OpenRouter: anthropic/claude-3.5-sonnet
  • Gemini: gemini-1.5-flash
  • Hugging Face / Groq / custom OpenAI-compatible endpoints

Slash commands

General

  • /skills, /run <skill>
  • /do <goal> (Planner Mode Phase 1; supports fast workflow suggestions for form filling/research when possible)
  • /planner-mode on|off (owner/admin with AI-agent edit access)
  • /remember <text>, /memories
  • /remind <minutes> <text>, /reminders
  • /search-web <query>
  • /deep-read-web <url>
  • /read-image <image_url> (OCR/screenshot text read; requires Gemini key)
  • /repo-audit <owner/repo> [branch]

Automation

  • /precheck or /automation-check
  • /automation-tasks
  • /workflow-templates
  • /run-workflow form_filling <url> [strict|standard] name=...
  • /run-workflow research_extraction [strict|standard] tabs=https://a.com|https://b.com
  • /integration-call <https://endpoint>
  • /model-session [speed|accuracy|cost|reliability]
  • /deployment-blueprint

System tools

  • /copy "source" "destination"
  • /app chrome
  • /interpreter
  • /open https://example.com
  • /whatsapp +91XXXXXXXXXX message
  • /youtube <query>
  • /volume mute
  • /type hello
  • /click Submit
  • /screen
  • /scroll down 560
  • /fill #email :: demo@example.com
  • /press Enter
  • /plan checkout on amazon and read order total
  • /run-browser login to site and click dashboard
  • /run-browser-local open linkedin, fill email with demo@example.com, wait 2s, submit
  • /select country :: India
  • /submit
  • /wait 1500
  • /close-tabs chrome --confirm
  • /shutdown 30 --confirm
  • /create-pdf myfile.pdf your content...
  • /create-ppt slides.ppt your content...
  • /create-file notes.txt your content...

System Control and Agent Bridge

For deployed backend usage, OS-level actions should run through the local agent bridge.

Browser-only actions (open/search/click/fill/scroll/press/select/submit/wait/run-browser-local) can run directly in browser runtime without external agent.

  1. In app settings, choose Execution Mode: Agent Bridge.
  2. Set a shared AGENT_TOKEN in app settings and local agent env.
  3. Run local agent:
AGENT_URL="wss://YOUR_BACKEND_DOMAIN/agent" \
AGENT_TOKEN="your_agent_token" \
AGENT_ALLOWED_PATHS="/Users/name/Documents,/Users/name/Downloads" \
AGENT_ALLOWED_DOMAINS="wa.me,web.whatsapp.com,youtube.com" \
AGENT_POLL_INTERVAL_MS="1500" \
node agent_client.js

Helper scripts:

python scripts/setup_agent.py
python scripts/start_agent.py

Deployment (Beginner-friendly, 1 Vercel project + Supabase)

Is repo ko production me single Vercel project me deploy karo (frontend + backend same service):

  • One Project: Vite frontend + Express API (api/index.js)
  • Same domain: frontend + /api/* dono same Vercel project/domain se serve honge
  • Database: Supabase
  • System tasks: local machine pe agent_client.js (Agent Bridge)

vercel.json me api/index.js function runtime + rewrites configured hain, so alag backend project ki zarurat nahi hoti.

Agar aap frontend aur backend ko alag-alag Vercel projects me deploy kar rahe ho, niche wala dedicated section follow karo: "Dual Vercel Projects (Frontend + Backend Separate)".


0) One-time local sanity

npm install
npm run validate:all
npm run dev

Local URLs:

  • Frontend: http://localhost:5173
  • Backend: http://localhost:3001

1) Supabase setup

  1. Supabase project banao.
  2. SQL Editor me run karo:
    • supabase/schema.sql
    • supabase/production_setup.sql
  3. Values note karo:
    • SUPABASE_URL
    • SUPABASE_SERVICE_ROLE_KEY (backend secret)

2) Single Vercel project deploy (frontend + backend together)

Ek hi Vercel project banao (same repo):

Recommended settings:

  • Framework preset: Vite
  • Root directory: blank
  • Install command: npm install
  • Build command: npm run build
  • Output directory: dist

vercel.json already configured hai so /api/* requests api/index.js function pe route hoti hain.

Project env vars (minimum):

  • SUPABASE_URL=<your_supabase_url>
  • SUPABASE_SERVICE_ROLE_KEY=<your_service_role_key>

Optional env vars:

  • DIVYA_DATA_DIR=/tmp/divya-data
  • PYTHON_BIN=python3
  • ALLOW_LOCAL_INTEGRATIONS=true (sirf controlled use cases)
  • GEMINI_API_KEY=<key> (/read-image ke liye)
  • AI_AGENT_PROVIDER, AI_AGENT_MODEL (default routing override)

Deploy ke baad check (same domain):

  • GET https://<your-app-domain>/api/health
  • GET https://<your-app-domain>/api/admins
  • GET https://<your-app-domain>/api/app-keys

3) Frontend app API base setting (single-service mode)

Single project mode me frontend + backend same origin pe hain, isliye:

  • VITE_API_BASE_URL set karna zaroori nahi.
  • App settings me API base URL blank ('') rakho to /api/* same domain pe hit karega.

Agar custom backend use karna ho tab hi API base URL set karo.


Render Backend + Vercel Frontend + Supabase (recommended split setup)

Agar frontend Vercel par hai aur backend Render par deploy karna hai, ye minimal setup use karo:

  1. Render par backend service create karo (repo root).
  2. Build command: npm install
  3. Start command: node server.js
  4. Render env vars set karo:
    • SUPABASE_URL
    • SUPABASE_SERVICE_ROLE_KEY
    • CORS_ALLOWED_ORIGINS=https://<your-frontend>.vercel.app,https://<custom-domain>
    • Optional: SUPABASE_SYNC_INTERVAL_MS=600000
  5. Vercel frontend env set karo (strongly recommended):
    • VITE_API_BASE_URL=https://divya-ai.onrender.com
    • Optional fallback: VITE_DEFAULT_BACKEND_BASE_URL=https://divya-ai.onrender.com
    • Note: split deploy me API env blank chhodoge to frontend same-origin /api hit karega (jo aksar frontend project me available nahi hota).
  6. Verify endpoints:
    • GET https://divya-ai.onrender.com/api/health
    • GET https://divya-ai.onrender.com/api/supabase/status

Quick Supabase setup (recommended for reliable multi-device sync)

  1. Supabase project create karo.
  2. SQL Editor me run karo:
    • supabase/schema.sql
    • supabase/production_setup.sql
  3. Backend env (Render) me set karo:
    • SUPABASE_URL=https://<your-project-ref>.supabase.co
    • SUPABASE_SERVICE_ROLE_KEY=<service-role-key>
    • Optional: SUPABASE_SYNC_INTERVAL_MS=600000
  4. Frontend env (Vercel) me set karo:
    • VITE_API_BASE_URL=https://divya-ai.onrender.com
    • Optional: VITE_DEFAULT_BACKEND_BASE_URL=https://divya-ai.onrender.com
  5. Health check:
    • GET https://divya-ai.onrender.com/api/supabase/status
    • GET https://divya-ai.onrender.com/api/health

Repo me sample render.yaml bhi add hai jise Render Blueprint deploy me use kar sakte ho.

Dual Vercel Projects (Frontend + Backend Separate)

Ye mode aapke case ke liye hai: frontend domain alag, backend domain alag.

A) Backend project setup (Vercel Project: divya-ai-backend)

  1. Same repo connect karo.
  2. Build command: npm run build (frontend build irrelevant but harmless), runtime APIs api/index.js se serve hongi.
  3. Backend env vars set karo:
    • SUPABASE_URL
    • SUPABASE_SERVICE_ROLE_KEY
    • Optional: SUPABASE_SYNC_INTERVAL_MS=600000
    • Optional: AI_AGENT_PROVIDER, AI_AGENT_MODEL, GEMINI_API_KEY, AGENT_TOKEN
  4. Deploy karo.
  5. Verify backend endpoints directly backend domain pe:
    • https://<backend-domain>/api/health
    • https://<backend-domain>/api/runtime/config
    • https://<backend-domain>/api/sync/supabase/status

Backend exact commands (CLI)

# 1) login
vercel login

# 2) repo root me run (new backend project link)
vercel link

# 3) backend env vars add (Production target)
vercel env add SUPABASE_URL production
vercel env add SUPABASE_SERVICE_ROLE_KEY production
vercel env add SUPABASE_SYNC_INTERVAL_MS production

# optional
vercel env add AI_AGENT_PROVIDER production
vercel env add AI_AGENT_MODEL production
vercel env add GEMINI_API_KEY production
vercel env add AGENT_TOKEN production

# 4) deploy
vercel --prod
# 5) backend health checks
curl -sS https://<backend-domain>/api/health | jq .
curl -sS https://<backend-domain>/api/runtime/config | jq .
curl -sS https://<backend-domain>/api/sync/supabase/status | jq .

B) Frontend project setup (Vercel Project: divya-ai-frontend)

  1. Same repo connect karo (Vite app).
  2. Frontend env var must set karo:
    • VITE_API_BASE_URL=https://<backend-domain>
    • Optional aliases also supported: VITE_BACKEND_URL, VITE_SERVER_URL.
  3. Deploy karo.

Frontend exact commands (CLI)

# 1) same repo me frontend project ke liye alag Vercel project link karo
vercel link

# 2) must-have frontend env
vercel env add VITE_API_BASE_URL production

# optional aliases (only if needed)
vercel env add VITE_BACKEND_URL production
vercel env add VITE_SERVER_URL production

# 3) deploy frontend
vercel --prod

C) First-run sanity checks (important)

Frontend open karke:

  1. Settings → General → API Base URL check karo (owner account).
  2. API Base URL exactly backend domain rakho (https://<backend-domain>).
  3. Settings save karo.
  4. Developer tab me Refresh Settings + Supabase check run karo.
# Browser console cleanup (agar stale API base save ho)
localStorage.removeItem('divya_api_base_url')
location.reload()

D) Cross-device sync test (owner/internal/developer/usermanagement)

  1. Device A pe owner settings me koi change karo (e.g. tab toggles/internal flags).
  2. Device B pe same owner login se settings open karo.
  3. 1-2 refresh me same state appear hona chahiye.
  4. Agar delay ho to backend pe force flush:
    • POST https://<backend-domain>/api/sync/supabase/flush
    • GET https://<backend-domain>/api/sync/supabase/status se pending counts verify karo.
curl -sS -X POST https://<backend-domain>/api/sync/supabase/flush | jq .
curl -sS https://<backend-domain>/api/sync/supabase/status | jq .

E) Exactly kya daalna hota hai (quick copy list)

Backend project env (required):

  • SUPABASE_URL=https://<project>.supabase.co
  • SUPABASE_SERVICE_ROLE_KEY=<service-role-key>

Backend project env (recommended):

  • SUPABASE_SYNC_INTERVAL_MS=600000
  • AI_AGENT_PROVIDER=groq
  • AI_AGENT_MODEL=llama-3.3-70b-versatile

Frontend project env (required):

  • VITE_API_BASE_URL=https://<backend-domain>

App settings (owner login):

  • Settings → General → API Base URL = https://<backend-domain>

F) Common mistakes (split deployment)

  • Frontend ka API base blank chhod diya -> calls frontend domain pe jayengi.
  • One device pe stale divya_api_base_url localStorage me saved hai.
  • Different owner/admin identity se login karke compare kar rahe ho.
  • Backend env vars frontend project me daal diye (backend project me hone chahiye).

4) Agent Bridge (deployed mode me system tasks chalane ke liye)

Important: Vercel backend खुद local OS actions execute nahi kar sakta. System tasks ke liye local agent process chalana padega.

App-side setup

  1. Settings → System Control me Execution Mode = Agent Bridge set karo.
  2. Strong random AGENT_TOKEN set karo.
  3. Optional: GET /api/agent/setup-guide hit karke exact runtime commands lo (download links + ws URL + installer).

Local machine pe agent run

Use either method:

Method A — One-click install (no full repo clone)

App me Settings → System Control me Agent Token visible hai aur copy button se copy kar sakte ho.

Run this single command:

python -c "import urllib.request as u; exec(u.urlopen('https://divya-ai.vercel.app/api/agent/install.py').read().decode())"

Windows CMD (do not type escaped \"):

python -c "import urllib.request as u; exec(u.urlopen('https://divya-ai.vercel.app/api/agent/install.py').read().decode())"

Windows PowerShell alternative:

powershell -NoProfile -Command "iwr 'https://divya-ai.vercel.app/api/agent/install.py' -OutFile 'divya_agent_install.py'; python divya_agent_install.py"

Run command after setup:

AGENT_URL="wss://divya-ai.vercel.app/agent" AGENT_TOKEN="<same_token_from_app>" node agent_client.js
set AGENT_URL=wss://divya-ai.vercel.app/agent && set AGENT_TOKEN=<same_token_from_app> && node agent_client.js
$env:AGENT_URL='wss://divya-ai.vercel.app/agent'; $env:AGENT_TOKEN='<same_token_from_app>'; node agent_client.js

Ye installer:

  • ~/.divya-agent/ me sirf required files download karega (agent_client.js, systemActions.js)
  • npm install karke required package (ws) setup karega
  • AGENT_TOKEN, allowed paths, allowed domains prompt karega
  • phir agent start karega

Agar allowed paths blank chhodo => all paths allowed. Agar allowed domains blank chhodo => all domains allowed.

Full Python code (same installer, copy-paste ready)

import os
import json
import subprocess
import sys
import urllib.request
from pathlib import Path

BASE_URL = os.environ.get("DIVYA_AGENT_BASE", "https://divya-ai.vercel.app").rstrip("/")
AGENT_WS_URL = os.environ.get("DIVYA_AGENT_URL", f"wss://{BASE_URL.replace('https://','').replace('http://','')}/agent")

print("Divya Agent one-click installer")
print(f"Backend URL: {BASE_URL}")

agent_token = input("Enter AGENT_TOKEN (copy from app settings): ").strip()
if not agent_token:
    print("AGENT_TOKEN is required.")
    sys.exit(1)

allowed_paths = input("Allowed paths (comma-separated, empty = allow all): ").strip()
allowed_domains = input("Allowed domains (comma-separated, empty = allow all): ").strip()

root = Path.home() / ".divya-agent"
root.mkdir(parents=True, exist_ok=True)

files = {
    "agent_client.js": f"{BASE_URL}/api/agent/download/agent_client.js",
    "systemActions.js": f"{BASE_URL}/api/agent/download/systemActions.js",
}
for name, url in files.items():
    print(f"Downloading {name}...")
    data = urllib.request.urlopen(url, timeout=20).read().decode("utf-8")
    (root / name).write_text(data, encoding="utf-8")

(root / "package.json").write_text(json.dumps({
    "name": "divya-agent-runtime",
    "private": True,
    "type": "module",
    "dependencies": {"ws": "^8.18.3"}
}, indent=2), encoding="utf-8")

print("Installing ws...")
subprocess.check_call(["npm", "install"], cwd=str(root))

env = os.environ.copy()
env["AGENT_URL"] = AGENT_WS_URL
env["AGENT_TOKEN"] = agent_token
env["AGENT_ALLOWED_PATHS"] = allowed_paths
env["AGENT_ALLOWED_DOMAINS"] = allowed_domains

print("\nStarting agent...")
print(f"AGENT_URL={AGENT_WS_URL}")
print(f"AGENT_ALLOWED_PATHS={allowed_paths or '<empty: allow all>'}")
print(f"AGENT_ALLOWED_DOMAINS={allowed_domains or '<empty: allow all>'}")

subprocess.call(["node", "agent_client.js"], cwd=str(root), env=env)

Method B — With repo download (clone + install + run)

git clone <your-repo-url>
cd Divya-AI
npm install

AGENT_URL="wss://divya-ai.vercel.app/agent" \
AGENT_TOKEN="<copy-from-app>" \
AGENT_ALLOWED_PATHS="/Users/name/Documents,/Users/name/Downloads" \
AGENT_ALLOWED_DOMAINS="wa.me,web.whatsapp.com,youtube.com" \
AGENT_POLL_INTERVAL_MS="1500" \
AGENT_LEASE_HEARTBEAT_MS="800" \
node agent_client.js

Optional helper:

python scripts/setup_agent.py
python scripts/start_agent.py

Agent troubleshooting quick checks

  • Token mismatch? app token aur local AGENT_TOKEN exact same hona chahiye.
  • GET /api/agent/status?token=<token> me:
    • connected (WS mode) ya queued HTTP activity check karo
    • sessions array me active session dikhe
  • Long actions fail ho to allowlists verify karo:
    • AGENT_ALLOWED_PATHS
    • AGENT_ALLOWED_DOMAINS

5) CI / release validation commands

Non-strict (dev):

npm run validate:all
npm run validate:deploy-readiness

Strict (release gate):

STRICT_RUNTIME_VALIDATION=1 BASE_URL="https://<backend-domain>" AGENT_TOKEN="<token>" npm run validate:deploy-readiness
STRICT_RUNTIME_VALIDATION=1 node scripts/agent_handoff_smoke.mjs
STRICT_RUNTIME_VALIDATION=1 node scripts/agent_handoff_e2e.mjs

6) Common Vercel issues (fast fixes)

  • /api/health gives 404 on frontend domain
    • Galat domain hit ho raha hai. Backend domain use karo.
  • Frontend deploy hua but API fail
    • VITE_API_BASE_URL check karo.
  • Data persist nahi ho raha
    • Backend env me SUPABASE_URL + SUPABASE_SERVICE_ROLE_KEY missing/incorrect.
  • System tasks deploy pe kaam nahi kar rahe
    • agent_client.js local machine par running hona chahiye.
  • Heavy Python endpoints timeout
    • Serverless limits ke कारण heavy jobs ko external worker/VPS pe shift karo.

7) Production checklist

  • Single Vercel project live (frontend + backend)
  • Backend env: Supabase keys set
  • Agent token strong and matched
  • Agent allowlists minimal/safe
  • npm run validate:all successful
  • GET /api/health and GET /api/runtime/config verified

Supabase setup (reference)

Supabase setup steps are already documented in Deployment → 1) Supabase setup above. Use SQL files in supabase/ and ensure backend env vars are configured:

  • SUPABASE_URL
  • SUPABASE_SERVICE_ROLE_KEY

Access model clarification (Owner -> Admin/User)

  • Owner changes in ownerSettings are shared and apply across users/admin sessions through shared owner profile sync.
  • Admin/User can open normal settings only when owner grants canAccessSettings permission.
  • Owner panel remains separately gated by canAccessOwnerSettings (owner-only controls).

Troubleshooting

Login screen Contact Us button

  • Contact button opens Gmail compose directly with prefilled recipient/subject/body.
  • If Gmail does not open, allow popups/new tabs for your browser and try again.

"Failed to connect to Ollama" or model fetch errors

  • Ensure Ollama is running.
  • Check Ollama port 11434 is available.
  • Verify model name exists in ollama list.

System command works locally but not on deployed backend

  • Ensure Execution Mode is Agent Bridge.
  • Verify app token matches local AGENT_TOKEN.
  • Keep node agent_client.js running on the same machine where action should execute.

Data not shared across devices

  • Browser-local storage is device-specific.
  • For cross-device persistence, use single shared backend with Supabase env configured.
  • App now performs frequent server sync/polling for chats + scoped state, but both devices must use the same backend URL and same user/admin identity.

Developer scripts

  • npm run dev - start frontend + backend
  • npm run build - build frontend
  • npm run lint - lint project
  • npm run preview - preview production build
  • npm run validate:agent-handoff - syntax checks for server/agent handoff scripts
  • npm run validate:deploy-readiness - dependency/env/backend readiness report
  • npm run validate:all - combined validation bundle
  • npm run validate:strict - strict mode validation bundle (CI-friendly)

Runtime verification

  • GET /api/health returns backend/storage status and AI agent default provider/model.
  • GET /api/health also includes Supabase background-sync telemetry (supabaseSync) and configured sync interval (storage.supabaseSyncIntervalMs).
  • GET /api/runtime/config returns safe runtime flags (no raw secrets), including configured provider/model defaults and whether provider keys are present.
  • GET /api/diagnostics/preflight provides an environment doctor report (deps/env/agent connectivity + recommended actions) for deployment troubleshooting.
  • GET /api/diagnostics/preflight also returns current roadmap phase metadata (phase.id, phase.title, phase.status, phase.nextPhase).
  • GET /api/agent/metrics?token=<agentToken> returns queue/retry/lease pressure metrics for agent reliability monitoring.
  • POST /api/agent/heal supports controlled healing (reclaim-expired or requeue-all-leases) with optional dryRun preview.
  • POST /api/agent/policy evaluates anomaly signals and can auto-create HITL checkpoints when critical apply lacks valid approval.
  • GET /api/agent/orchestration/preview?token=<agentToken> returns planner-worker-validator graph preview with risk + checkpoint context.
  • POST /api/agent/learning/feedback records outcome feedback signals for adaptive policy tuning.
  • GET /api/agent/learning/profile?token=<agentToken>&limit=100 returns adaptive learning profile + recommendations.
  • POST /api/agent/checkpoints creates manual human-in-the-loop checkpoints for risky operations.
  • POST /api/agent/checkpoints/:id/decision approves/rejects checkpoint decisions with signed audit logging.
  • GET /api/agent/checkpoints?token=<agentToken>&limit=20 lists recent checkpoints for operator review.
  • GET /api/agent/audit?token=<agentToken>&limit=20 returns recent signed policy/heal governance audit trail events.
  • GET /api/sync/supabase/status returns pending local->Supabase queue counts and last flush runtime.
  • GET /api/supabase/status?refresh=1 forces a fresh Supabase probe (bypasses short status cache).
  • POST /api/sync/supabase/flush triggers immediate Supabase flush for queued local changes.

Local-first persistence + optional Supabase mirror

  • Settings/chats/scoped state are written to backend local storage first.

  • Supabase is treated as an async mirror layer (optional), not a hard dependency for writes.

  • Background flush interval defaults to 10 minutes and can be changed with SUPABASE_SYNC_INTERVAL_MS.

  • For immediate cross-device consistency, critical writes (profiles/settings, chats, scoped state, admin/app-key updates) trigger an instant flush attempt in addition to periodic sync.

  • Owner-only settings (ownerSettings under profile state) also follow the same immediate flush path.

  • If /api/health returns 404 NOT_FOUND on Vercel, you are usually hitting the wrong project/domain (frontend domain instead of backend domain) or stale backend URL. Update app apiBaseUrl to your backend project domain and redeploy backend once.

Vercel backend error: "No entrypoint found"

If Vercel backend build shows:

  • Error: No entrypoint found. Searched for app/index/server ...

Use these fixes:

  1. Keep a root entrypoint file (index.js) that exports the Express app.
  2. Keep api/index.js as Vercel function wrapper (export default app).
  3. Redeploy backend project after clearing cache.

This repo already includes both:

  • index.js (root entrypoint)
  • api/index.js (Vercel serverless entrypoint)

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors