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).
- Read
REPO_MASTER_GUIDE.mdfor complete architecture, feature ownership, API map, deploy model, and troubleshooting. - Read
OWNER_COMPLETE_SETUP_GUIDE.mdfor owner-only local/deploy/env/agent operations checklist.
- 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).
- 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)
- 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
.
├── 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
- Node.js
>=22.0.0 - npm
- Python 3.10+ (recommended if using Python workers)
- Ollama (only if running local Ollama models)
- 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.
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.
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 scanLatest status in this repo snapshot:
npm run lint✅ passed (no ESLint errors).npm run validate:all✅ passed static checks.npm run validate:deploy-readinessnow also validatespackage-lock.jsonsync withpackage.json(name + dependencies) to catch install-time failures early.npm run validate:strictruns the full validation bundle in strict mode (fails CI on warnings/failures).- JS/MJS syntax scan ✅ no
node --checkfailures.
Still pending (environment/runtime only):
- Install runtime deps:
express,ws,axios,cors,multer. - Configure
AGENT_TOKENand optionalBASE_URLfor live backend checks.
npm installOptional Python dependencies (needed for transcription/search/image worker flows):
pip install numpy openai-whisper torch requests beautifulsoup4 duckduckgo-search diffusers transformers acceleratenpm run devThis runs:
- Frontend (Vite):
http://localhost:5173 - Backend (Express):
http://localhost:3001
VITE_API_BASE_URL- backend base URL (recommended:https://divya-ai.onrender.com)VITE_BACKEND_URL/VITE_SERVER_URL-VITE_API_BASE_URLke 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(orVITE_DEFAULT_BACKEND_BASE_URL) explicitly for split deployments. VITE_OLLAMA_BASE_URL- optional override for Ollama proxy endpoint
PORT- backend port (default:3001)DIVYA_DATA_DIR(orDATA_DIR) - persistent storage directory- Vercel par set na ho to runtime fallback
/tmp/divya-ai/datause hota hai (ephemeral). Persistent data ke liye Supabase ya external storage use karein.
- Vercel par set na ho to runtime fallback
PYTHON_BIN(orPYTHON) - Python executable name/pathSUPABASE_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 endpointsGEMINI_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 badlehttps://domain.comuse karo).
- Example (your setup):
- Start Ollama.
- Pull a model:
ollama pull gemma3:12b- Verify:
ollama listAdd 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
/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]
/precheckor/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
/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...
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.
- In app settings, choose Execution Mode: Agent Bridge.
- Set a shared
AGENT_TOKENin app settings and local agent env. - 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.jsHelper scripts:
python scripts/setup_agent.py
python scripts/start_agent.pyIs 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)".
npm install
npm run validate:all
npm run devLocal URLs:
- Frontend:
http://localhost:5173 - Backend:
http://localhost:3001
- Supabase project banao.
- SQL Editor me run karo:
supabase/schema.sqlsupabase/production_setup.sql
- Values note karo:
SUPABASE_URLSUPABASE_SERVICE_ROLE_KEY(backend secret)
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-dataPYTHON_BIN=python3ALLOW_LOCAL_INTEGRATIONS=true(sirf controlled use cases)GEMINI_API_KEY=<key>(/read-imageke liye)AI_AGENT_PROVIDER,AI_AGENT_MODEL(default routing override)
Deploy ke baad check (same domain):
GET https://<your-app-domain>/api/healthGET https://<your-app-domain>/api/adminsGET https://<your-app-domain>/api/app-keys
Single project mode me frontend + backend same origin pe hain, isliye:
VITE_API_BASE_URLset 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.
Agar frontend Vercel par hai aur backend Render par deploy karna hai, ye minimal setup use karo:
- Render par backend service create karo (repo root).
- Build command:
npm install - Start command:
node server.js - Render env vars set karo:
SUPABASE_URLSUPABASE_SERVICE_ROLE_KEYCORS_ALLOWED_ORIGINS=https://<your-frontend>.vercel.app,https://<custom-domain>- Optional:
SUPABASE_SYNC_INTERVAL_MS=600000
- 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
/apihit karega (jo aksar frontend project me available nahi hota).
- Verify endpoints:
GET https://divya-ai.onrender.com/api/healthGET https://divya-ai.onrender.com/api/supabase/status
- Supabase project create karo.
- SQL Editor me run karo:
supabase/schema.sqlsupabase/production_setup.sql
- Backend env (Render) me set karo:
SUPABASE_URL=https://<your-project-ref>.supabase.coSUPABASE_SERVICE_ROLE_KEY=<service-role-key>- Optional:
SUPABASE_SYNC_INTERVAL_MS=600000
- 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
- Health check:
GET https://divya-ai.onrender.com/api/supabase/statusGET https://divya-ai.onrender.com/api/health
Repo me sample render.yaml bhi add hai jise Render Blueprint deploy me use kar sakte ho.
Ye mode aapke case ke liye hai: frontend domain alag, backend domain alag.
- Same repo connect karo.
- Build command:
npm run build(frontend build irrelevant but harmless), runtime APIsapi/index.jsse serve hongi. - Backend env vars set karo:
SUPABASE_URLSUPABASE_SERVICE_ROLE_KEY- Optional:
SUPABASE_SYNC_INTERVAL_MS=600000 - Optional:
AI_AGENT_PROVIDER,AI_AGENT_MODEL,GEMINI_API_KEY,AGENT_TOKEN
- Deploy karo.
- Verify backend endpoints directly backend domain pe:
https://<backend-domain>/api/healthhttps://<backend-domain>/api/runtime/confighttps://<backend-domain>/api/sync/supabase/status
# 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 .- Same repo connect karo (Vite app).
- Frontend env var must set karo:
VITE_API_BASE_URL=https://<backend-domain>- Optional aliases also supported:
VITE_BACKEND_URL,VITE_SERVER_URL.
- Deploy karo.
# 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 --prodFrontend open karke:
- Settings → General → API Base URL check karo (owner account).
- API Base URL exactly backend domain rakho (
https://<backend-domain>). - Settings save karo.
- 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()- Device A pe owner settings me koi change karo (e.g. tab toggles/internal flags).
- Device B pe same owner login se settings open karo.
- 1-2 refresh me same state appear hona chahiye.
- Agar delay ho to backend pe force flush:
POST https://<backend-domain>/api/sync/supabase/flushGET https://<backend-domain>/api/sync/supabase/statusse 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 .Backend project env (required):
SUPABASE_URL=https://<project>.supabase.coSUPABASE_SERVICE_ROLE_KEY=<service-role-key>
Backend project env (recommended):
SUPABASE_SYNC_INTERVAL_MS=600000AI_AGENT_PROVIDER=groqAI_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>
- Frontend ka API base blank chhod diya -> calls frontend domain pe jayengi.
- One device pe stale
divya_api_base_urllocalStorage 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).
Important: Vercel backend खुद local OS actions execute nahi kar sakta. System tasks ke liye local agent process chalana padega.
- Settings → System Control me Execution Mode = Agent Bridge set karo.
- Strong random
AGENT_TOKENset karo. - Optional:
GET /api/agent/setup-guidehit karke exact runtime commands lo (download links + ws URL + installer).
Use either method:
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.jsset 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.jsYe installer:
~/.divya-agent/me sirf required files download karega (agent_client.js,systemActions.js)npm installkarke 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.
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)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.jsOptional helper:
python scripts/setup_agent.py
python scripts/start_agent.py- Token mismatch? app token aur local
AGENT_TOKENexact same hona chahiye. GET /api/agent/status?token=<token>me:connected(WS mode) ya queued HTTP activity check karosessionsarray me active session dikhe
- Long actions fail ho to allowlists verify karo:
AGENT_ALLOWED_PATHSAGENT_ALLOWED_DOMAINS
Non-strict (dev):
npm run validate:all
npm run validate:deploy-readinessStrict (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/api/healthgives 404 on frontend domain- Galat domain hit ho raha hai. Backend domain use karo.
- Frontend deploy hua but API fail
VITE_API_BASE_URLcheck karo.
- Data persist nahi ho raha
- Backend env me
SUPABASE_URL+SUPABASE_SERVICE_ROLE_KEYmissing/incorrect.
- Backend env me
- System tasks deploy pe kaam nahi kar rahe
agent_client.jslocal machine par running hona chahiye.
- Heavy Python endpoints timeout
- Serverless limits ke कारण heavy jobs ko external worker/VPS pe shift karo.
- Single Vercel project live (frontend + backend)
- Backend env: Supabase keys set
- Agent token strong and matched
- Agent allowlists minimal/safe
-
npm run validate:allsuccessful -
GET /api/healthandGET /api/runtime/configverified
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_URLSUPABASE_SERVICE_ROLE_KEY
- Owner changes in
ownerSettingsare shared and apply across users/admin sessions through shared owner profile sync. - Admin/User can open normal settings only when owner grants
canAccessSettingspermission. - Owner panel remains separately gated by
canAccessOwnerSettings(owner-only controls).
- 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.
- Ensure Ollama is running.
- Check Ollama port
11434is available. - Verify model name exists in
ollama list.
- Ensure Execution Mode is Agent Bridge.
- Verify app token matches local
AGENT_TOKEN. - Keep
node agent_client.jsrunning on the same machine where action should execute.
- 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.
npm run dev- start frontend + backendnpm run build- build frontendnpm run lint- lint projectnpm run preview- preview production buildnpm run validate:agent-handoff- syntax checks for server/agent handoff scriptsnpm run validate:deploy-readiness- dependency/env/backend readiness reportnpm run validate:all- combined validation bundlenpm run validate:strict- strict mode validation bundle (CI-friendly)
GET /api/healthreturns backend/storage status and AI agent default provider/model.GET /api/healthalso includes Supabase background-sync telemetry (supabaseSync) and configured sync interval (storage.supabaseSyncIntervalMs).GET /api/runtime/configreturns safe runtime flags (no raw secrets), including configured provider/model defaults and whether provider keys are present.GET /api/diagnostics/preflightprovides an environment doctor report (deps/env/agent connectivity + recommended actions) for deployment troubleshooting.GET /api/diagnostics/preflightalso 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/healsupports controlled healing (reclaim-expiredorrequeue-all-leases) with optionaldryRunpreview.POST /api/agent/policyevaluates 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/feedbackrecords outcome feedback signals for adaptive policy tuning.GET /api/agent/learning/profile?token=<agentToken>&limit=100returns adaptive learning profile + recommendations.POST /api/agent/checkpointscreates manual human-in-the-loop checkpoints for risky operations.POST /api/agent/checkpoints/:id/decisionapproves/rejects checkpoint decisions with signed audit logging.GET /api/agent/checkpoints?token=<agentToken>&limit=20lists recent checkpoints for operator review.GET /api/agent/audit?token=<agentToken>&limit=20returns recent signed policy/heal governance audit trail events.GET /api/sync/supabase/statusreturns pending local->Supabase queue counts and last flush runtime.GET /api/supabase/status?refresh=1forces a fresh Supabase probe (bypasses short status cache).POST /api/sync/supabase/flushtriggers immediate Supabase flush for queued local changes.
-
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 (
ownerSettingsunder profile state) also follow the same immediate flush path. -
If
/api/healthreturns404 NOT_FOUNDon Vercel, you are usually hitting the wrong project/domain (frontend domain instead of backend domain) or stale backend URL. Update appapiBaseUrlto your backend project domain and redeploy backend once.
If Vercel backend build shows:
Error: No entrypoint found. Searched for app/index/server ...
Use these fixes:
- Keep a root entrypoint file (
index.js) that exports the Express app. - Keep
api/index.jsas Vercel function wrapper (export default app). - Redeploy backend project after clearing cache.
This repo already includes both:
index.js(root entrypoint)api/index.js(Vercel serverless entrypoint)