# Support AI Agent Copilot — Chrome MV3 Sidepanel + Bundle Optimizer — Complete AI & LLM Reference Corpus (`llms-full.txt`) - Repository: https://github.com/mohan-n-swamy/agent-copilot-public - Web Discovery URL: https://mohan-n-swamy.github.io/repos/agent-copilot-public/ - License: MIT - Keywords: chrome-extension, ai-copilot, customer-support, helpdesk, chatwoot, zendesk, manifest-v3, typescript, agent-assist, rag --- ## File: `AI-README.md` — AI-README.md --- repo: "mohan-n-swamy/agent-copilot-public" title: "Support AI Agent Copilot — Chrome MV3 Sidepanel + Bundle Optimizer" license: "MIT" keywords: [chrome-extension, ai-copilot, customer-support, helpdesk, chatwoot, zendesk, manifest-v3, typescript, agent-assist, rag] capabilities: - "**Manifest V3 Chrome Sidepanel Extension (`src/extension/`):** Ephemeral-worker-safe `background.js`, virtual-scroll-aware `content.js`, network UUID `interceptor.js`, and `sidepanel.html`." - "**Declarative Multi-Helpdesk Selector Profiles (`config/selectors.json`):** Ready-to-use DOM mappings for Chatwoot, Freshchat, Zendesk, plus `demo/mock-helpdesk.html`." - "**Deterministic Set-Cover Bundle Optimizer (`src/server/matching/`):** Synonym canonicalization, condition-watchlist filtering, <=20% bonus-item cap, and minimum-price combination solver." - "**SOP Guidebook & Analytics Dashboard (`src/web/dashboard.html`):** Real-time SOP search plus quote-to-booking outcome attribution." - "**23 Automated Vitest Suites / 295 Tests (`tests/matching/`):** Comprehensive regression tests for optimizer math, synonym collisions, quantity scaling, and reconciliation." when_to_use: - "A Manifest V3 Chrome Sidepanel Extension and TypeScript/Express backend copilot for live customer support and inside-sales agents across Chatwoot, Freshchat, and Zendesk — combining active-conversation extraction, deterministic minimum-cost SKU/bundle optimization, SOP guidebook lookup, and quote-to-booking analytics." - "Live chat agents lose minutes per conversation switching tabs between the helpdesk, product catalog spreadsheets, SOP wikis, and order systems — and generic 'draft a reply' browser extensions hallucinate prices and bundle contents. `agent-copilot-public` pins a fast, zero-client-secret Chrome sidepanel next to the inbox that extracts what the customer asked for, computes the exact lowest-price SKU/bundle combination in deterministic TypeScript, surfaces SOP guidance, and measures conversion lift." inputs_required: - "PORT: HTTP port for the Express copilot backend and analytics dashboard" - "HELPDESK_ORIGIN: Origin URL of your Chatwoot, Freshchat, or Zendesk workspace" - "COPILOT_JWT_SECRET: HMAC secret signing agent session cookies/tokens" - "CATALOG_API_URL: Product/service SKU & bundle catalog endpoint (or local `data/sample-catalog.json`)" - "OMS_API_URL: Order Management endpoint for booking verification & reconciliation" - "ANTHROPIC_API_KEY: Backend-only LLM key for unstructured chat item extraction" quickstart: - "npm install" - "npm run configure:manifest # injects HELPDESK_ORIGIN into src/extension/manifest.json" - "npm test # runs all 23 Vitest matching & optimizer suites (295 tests)" - "npm run dev # starts backend + dashboard on http://localhost:3002" - "# Load src/extension/ via chrome://extensions -> Developer Mode -> Load unpacked" --- # Support AI Agent Copilot — Chrome MV3 Sidepanel + Bundle Optimizer — Machine-Readable Agent Guide A Manifest V3 Chrome Sidepanel Extension and TypeScript/Express backend copilot for live customer support and inside-sales agents across Chatwoot, Freshchat, and Zendesk — combining active-conversation extraction, deterministic minimum-cost SKU/bundle optimization, SOP guidebook lookup, and quote-to-booking analytics. Live chat agents lose minutes per conversation switching tabs between the helpdesk, product catalog spreadsheets, SOP wikis, and order systems — and generic 'draft a reply' browser extensions hallucinate prices and bundle contents. `agent-copilot-public` pins a fast, zero-client-secret Chrome sidepanel next to the inbox that extracts what the customer asked for, computes the exact lowest-price SKU/bundle combination in deterministic TypeScript, surfaces SOP guidance, and measures conversion lift. Key modules and entry points in this repository: - `src/extension/`: Manifest V3 service worker, content script, network UUID bridge, sidepanel UI, and generated icons - `config/selectors.json`: Declarative conversation URL and message-pane CSS selectors for Chatwoot, Freshchat, Zendesk, and mock demo - `src/server/matching/optimizer.ts`: Minimum-cost set-cover solver with <=20% bonus cap and exclusion watchlists - `src/server/matching/normalize.ts & scoring.ts`: Fuzzy alias canonicalization and collision-safe token scoring - `src/server/routes/`: Express routes for `/api/conversation`, `/api/search`, `/api/guide`, `/api/events`, and `/api/reports` - `demo/mock-helpdesk.html`: Standalone local inbox page for testing DOM extraction without a live SaaS login - `tests/matching/`: 23 Vitest test suites (295 tests) covering optimizer correctness, edge cases, and outcome reconciliation Every organization-specific value enters through `.env` (copied from `.env.example`) or external adapter files. No source edit is needed to change organization names, endpoints, database URLs, webhook secrets, or thresholds. When a human asks an AI coding agent to deploy or adapt `agent-copilot-public` into their stack: 1. Replace `data/sample-catalog.json` (or point `CATALOG_API_URL`) with your own SKUs, component features/parameters, and bundle prices. 2. Set `HELPDESK_ORIGIN` in `.env` and run `npm run configure:manifest` to authorize your Chatwoot, Freshchat, or Zendesk domain. 3. Run `npm test` to verify all 23 optimizer and matching test suites pass, then load `src/extension/` in `chrome://extensions`. - Product Requirements: `docs/PRD.md` - Working-Backwards PR-FAQ: `docs/PR-FAQ.md` - High-Level Architecture: `docs/HLD.md` - Low-Level Interfaces & Runbook: `docs/LLD.md` - Coding Agent Rules: `AGENTS.md` --- ## File: `.env.example` — Environment Contract (.env.example) ```ini # agent-copilot-public — Manifest V3 Sidepanel Extension + Backend AI Copilot PORT=3002 NODE_ENV=development HELPDESK_ORIGIN=http://localhost:3000 COPILOT_JWT_SECRET=replace_with_32_char_random_secret CATALOG_API_URL=http://localhost:3002/api/mock-catalog CRM_API_URL=http://localhost:3002/api/mock-crm OMS_API_URL=http://localhost:3002/api/mock-oms ANTHROPIC_API_KEY=replace_with_llm_api_key ``` --- ## File: `AGENTS.md` — AGENTS.md # AGENTS.md — Support AI Agent Copilot — Chrome MV3 Sidepanel + Bundle Optimizer Read this file first before modifying `agent-copilot-public`. ## Purpose A Manifest V3 Chrome Sidepanel Extension and TypeScript/Express backend copilot for live customer support and inside-sales agents across Chatwoot, Freshchat, and Zendesk — combining active-conversation extraction, deterministic minimum-cost SKU/bundle optimization, SOP guidebook lookup, and quote-to-booking analytics. ## Commands ```bash npm install npm run configure:manifest # injects HELPDESK_ORIGIN into src/extension/manifest.json npm test # runs all 23 Vitest matching & optimizer suites (295 tests) npm run dev # starts backend + dashboard on http://localhost:3002 # Load src/extension/ via chrome://extensions -> Developer Mode -> Load unpacked ``` ## Module Map - `src/extension/`: Manifest V3 service worker, content script, network UUID bridge, sidepanel UI, and generated icons - `config/selectors.json`: Declarative conversation URL and message-pane CSS selectors for Chatwoot, Freshchat, Zendesk, and mock demo - `src/server/matching/optimizer.ts`: Minimum-cost set-cover solver with <=20% bonus cap and exclusion watchlists - `src/server/matching/normalize.ts & scoring.ts`: Fuzzy alias canonicalization and collision-safe token scoring - `src/server/routes/`: Express routes for `/api/conversation`, `/api/search`, `/api/guide`, `/api/events`, and `/api/reports` - `demo/mock-helpdesk.html`: Standalone local inbox page for testing DOM extraction without a live SaaS login - `tests/matching/`: 23 Vitest test suites (295 tests) covering optimizer correctness, edge cases, and outcome reconciliation ## Invariants 1. Keep all organization names, credentials, domains, and thresholds in `.env` or external config files. Never hardcode company names, host IPs, or secrets in source files. 2. Deterministic business logic belongs in code and lookup tables, not inside LLM prompts. 3. Update `docs/HLD.md`, `docs/LLD.md`, and `.env.example` in the same commit whenever an interface or environment variable changes. 4. Run the repository smoke check and secret scan before opening a pull request. --- ## File: `docs/PRD.md` — Product Requirements Document (docs/PRD.md) # Product Requirements Document — Support AI Agent Copilot — Chrome MV3 Sidepanel + Bundle Optimizer A Manifest V3 Chrome Sidepanel Extension and TypeScript/Express backend copilot for live customer support and inside-sales agents across Chatwoot, Freshchat, and Zendesk — combining active-conversation extraction, deterministic minimum-cost SKU/bundle optimization, SOP guidebook lookup, and quote-to-booking analytics. ## 1. Problem Live chat agents lose minutes per conversation switching tabs between the helpdesk, product catalog spreadsheets, SOP wikis, and order systems — and generic 'draft a reply' browser extensions hallucinate prices and bundle contents. `agent-copilot-public` pins a fast, zero-client-secret Chrome sidepanel next to the inbox that extracts what the customer asked for, computes the exact lowest-price SKU/bundle combination in deterministic TypeScript, surfaces SOP guidance, and measures conversion lift. ## 2. Users and Jobs-to-be-Done | Persona | Job-to-be-Done | |---|---| | Live Support / Inside-Sales Agent | See extracted customer requests, exact best-value bundle pricing, and 1-click reply drafts inside a persistent Chrome sidepanel. | | Support Operations / Catalog Owner | Update SKU catalogs, synonyms, and SOP guides via JSON/Sheets without redeploying extension code, and track quote-to-order conversion on `/dashboard.html`. | | Platform Engineer | Point `config/selectors.json` and `HELPDESK_ORIGIN` at self-hosted Chatwoot (`chatwoot-public`), Freshchat, or Zendesk with zero secrets inside the browser bundle. | ## 3. Core Capabilities - **Manifest V3 Chrome Sidepanel Extension (`src/extension/`):** Ephemeral-worker-safe `background.js`, virtual-scroll-aware `content.js`, network UUID `interceptor.js`, and `sidepanel.html`. - **Declarative Multi-Helpdesk Selector Profiles (`config/selectors.json`):** Ready-to-use DOM mappings for Chatwoot, Freshchat, Zendesk, plus `demo/mock-helpdesk.html`. - **Deterministic Set-Cover Bundle Optimizer (`src/server/matching/`):** Synonym canonicalization, condition-watchlist filtering, <=20% bonus-item cap, and minimum-price combination solver. - **SOP Guidebook & Analytics Dashboard (`src/web/dashboard.html`):** Real-time SOP search plus quote-to-booking outcome attribution. - **23 Automated Vitest Suites / 295 Tests (`tests/matching/`):** Comprehensive regression tests for optimizer math, synonym collisions, quantity scaling, and reconciliation. ## 4. Configurable Inputs Adopters configure the system for their own organization without editing core application logic: | Variable | Default / Example | Purpose | |---|---|---| | `PORT` | `3002` | HTTP port for the Express copilot backend and analytics dashboard | | `HELPDESK_ORIGIN` | `http://localhost:3000` | Origin URL of your Chatwoot, Freshchat, or Zendesk workspace | | `COPILOT_JWT_SECRET` | `replace_me` | HMAC secret signing agent session cookies/tokens | | `CATALOG_API_URL` | `http://localhost:3002/api/mock-catalog` | Product/service SKU & bundle catalog endpoint (or local `data/sample-catalog.json`) | | `OMS_API_URL` | `http://localhost:3002/api/mock-oms` | Order Management endpoint for booking verification & reconciliation | | `ANTHROPIC_API_KEY` | `sk-ant-...` | Backend-only LLM key for unstructured chat item extraction | ## 5. Phasing and Stability Exit Criteria 1. **Phase 1 (Local Synthetic Run):** Clone the repository, copy `.env.example` to `.env`, and run the quickstart commands against synthetic seed data. Exit criterion: smoke checks pass with zero external credentials. 2. **Phase 2 (Read-Only Shadow Wiring):** Connect read-only credentials or webhook listeners in shadow/dry-run mode. Exit criterion: 100 consecutive events or queries reconcile cleanly against source records. 3. **Phase 3 (Production Cutover):** Enable live writes, alerts, or routing behind bounded retry and idempotency guards. ## 6. Non-Goals - Shipping organization-specific business rules hardcoded in application source. - Storing credentials, personal customer records, or tenant URLs inside version control. - Replacing deterministic validation or arithmetic with unconstrained model prompts. --- ## File: `docs/PR-FAQ.md` — Working-Backwards PR-FAQ (docs/PR-FAQ.md) # Working-Backwards PR-FAQ — Support AI Agent Copilot — Chrome MV3 Sidepanel + Bundle Optimizer **Release Summary:** `agent-copilot-public` gives engineering and operations teams a self-hosted, open-source implementation of Support AI Agent Copilot — Chrome MV3 Sidepanel + Bundle Optimizer that configures via `.env` and runs on standard infrastructure in minutes. ## Press Release Operations and engineering teams often rebuild the same internal workflows behind closed doors or pay per-seat SaaS markups for rigid tools that cannot match their field reality. `agent-copilot-public` open-sources a battle-tested implementation of Support AI Agent Copilot — Chrome MV3 Sidepanel + Bundle Optimizer, stripped of all single-company assumptions and packaged with clear adapter boundaries, synthetic demo data, and machine-readable agent documentation. Any team can fork `agent-copilot-public`, supply their own `.env` inputs and taxonomy config, and deploy locally or in production with Docker, Python, or Node. AI coding assistants such as Claude Code, Codex, and Cursor can read `AI-README.md` and `llms.txt` to wire custom ERP, CRM, or warehouse adapters in a single session. ## External Adopter FAQ **Q1: How long does it take to run locally after cloning?** Under five minutes. Copy `.env.example` to `.env` and run the quickstart commands in `README.md`. Synthetic fixtures let you inspect the workflow before connecting live credentials. **Q2: Do I need to rewrite source files to use my own company name, channels, or rules?** No. Organization names, endpoints, thresholds, and credentials sit in `.env` and declarative config files. External system specifics live behind narrow adapter modules documented in `docs/LLD.md`. **Q3: What license governs this repository?** MIT License. You can fork, modify, self-host, and use it commercially without restriction. ## Internal Engineering & Security FAQ **Q4: How do we prevent tenant or employer data from ever entering a public fork?** The repository starts from a clean git history, excludes raw exports and binary dumps, validates every commit through `gitleaks`, and ships only synthetic fixtures. **Q5: What happens when an upstream API or model provider is slow or unavailable?** Inbound webhooks persist raw payloads before processing, outbound writes carry idempotency keys with bounded exponential backoff, and model-backed paths fail open to deterministic rules or explicit human queues. --- ## File: `docs/HLD.md` — High-Level Design (docs/HLD.md) # High-Level Design (HLD) — Support AI Agent Copilot — Chrome MV3 Sidepanel + Bundle Optimizer A Manifest V3 Chrome Sidepanel Extension and TypeScript/Express backend copilot for live customer support and inside-sales agents across Chatwoot, Freshchat, and Zendesk — combining active-conversation extraction, deterministic minimum-cost SKU/bundle optimization, SOP guidebook lookup, and quote-to-booking analytics. ## 1. System Topology ```mermaid flowchart LR Inbox["Chatwoot / Freshchat / Zendesk DOM"] --> Content["MV3 content.js"] Content --> Sidepanel["Chrome Sidepanel UI"] Sidepanel -->|"JWT + transcript"| API["Express TypeScript Server (:3002)"] API --> Extract["LLM Entity Extractor"] Extract --> Solver["Deterministic Set-Cover Optimizer"] Catalog["data/sample-catalog.json / API"] --> Solver Solver -->|"exact quote + SOPs"| Sidepanel ``` ## 2. Architectural Decisions and Rejected Alternatives | Decision | Why It Holds | Rejected Alternative | |---|---|---| | LLM extracts entities; TypeScript solves pricing (`optimizer.ts`) | Eliminates arithmetic and bundle-inclusion hallucinations completely while handling messy natural-language requests. | Prompting an LLM to calculate bundle totals | | Zero credentials in `src/extension/` | Unpacking the Chrome extension reveals only the backend URL; all LLM, CRM, and catalog keys stay server-side. | Direct browser-to-OpenAI/Anthropic BYOK calls for multi-agent teams | | Declarative `config/selectors.json` + `scripts/configure-manifest.mjs` | Lets teams adopt the extension on self-hosted Chatwoot, Freshchat, or Zendesk in minutes. | Hardcoding one SaaS vendor's URL and CSS classes | ## 3. Data Flow and Failure Boundaries 1. **Configuration Boundary:** Startup validates `.env` variables and declarative config schemas before accepting traffic or running scheduled jobs. 2. **Adapter Boundary:** External services (databases, chat channels, HRMS, warehouses, or LLM providers) sit behind explicit adapter modules so failures stay isolated and testable with local mocks. 3. **Observability and Audit:** State transitions and job executions emit structured logs and deterministic status records rather than mutating state silently. ## 4. Scaling Notes - **1x to 10x load:** Single-node Docker Compose or process supervisor handles standard team workloads with indexed database queries and bounded worker concurrency. - **First bottleneck at 10x+:** High-frequency webhook or batch ingestion queues; mitigate by separating the stateless HTTP receiver from background worker processes sharing Redis or PostgreSQL locks. --- ## File: `docs/LLD.md` — Low-Level Design & Runbook (docs/LLD.md) # Low-Level Design (LLD) & Operations Runbook — Support AI Agent Copilot — Chrome MV3 Sidepanel + Bundle Optimizer This document defines the module responsibilities, environment contract, and operational procedures for `agent-copilot-public`. ## 1. Module and File Inventory | Path | Responsibility | |---|---| | `src/extension/` | Manifest V3 service worker, content script, network UUID bridge, sidepanel UI, and generated icons | | `config/selectors.json` | Declarative conversation URL and message-pane CSS selectors for Chatwoot, Freshchat, Zendesk, and mock demo | | `src/server/matching/optimizer.ts` | Minimum-cost set-cover solver with <=20% bonus cap and exclusion watchlists | | `src/server/matching/normalize.ts & scoring.ts` | Fuzzy alias canonicalization and collision-safe token scoring | | `src/server/routes/` | Express routes for `/api/conversation`, `/api/search`, `/api/guide`, `/api/events`, and `/api/reports` | | `demo/mock-helpdesk.html` | Standalone local inbox page for testing DOM extraction without a live SaaS login | | `tests/matching/` | 23 Vitest test suites (295 tests) covering optimizer correctness, edge cases, and outcome reconciliation | ## 2. Environment Variable Contract | Variable | Default / Example | Required | Description | |---|---|---|---| | `PORT` | `3002` | Yes | HTTP port for the Express copilot backend and analytics dashboard | | `HELPDESK_ORIGIN` | `http://localhost:3000` | Yes | Origin URL of your Chatwoot, Freshchat, or Zendesk workspace | | `COPILOT_JWT_SECRET` | `replace_me` | Yes | HMAC secret signing agent session cookies/tokens | | `CATALOG_API_URL` | `http://localhost:3002/api/mock-catalog` | Yes | Product/service SKU & bundle catalog endpoint (or local `data/sample-catalog.json`) | | `OMS_API_URL` | `http://localhost:3002/api/mock-oms` | Yes | Order Management endpoint for booking verification & reconciliation | | `ANTHROPIC_API_KEY` | `sk-ant-...` | Yes | Backend-only LLM key for unstructured chat item extraction | ## 3. Extension Recipe 1. Replace `data/sample-catalog.json` (or point `CATALOG_API_URL`) with your own SKUs, component features/parameters, and bundle prices. 2. Set `HELPDESK_ORIGIN` in `.env` and run `npm run configure:manifest` to authorize your Chatwoot, Freshchat, or Zendesk domain. 3. Run `npm test` to verify all 23 optimizer and matching test suites pass, then load `src/extension/` in `chrome://extensions`. ## 4. Operations Runbook ### 1. Run the 23 Vitest unit suites (295 tests) ```bash npm test ``` ### 2. Add your self-hosted Chatwoot domain to MV3 host_permissions ```bash HELPDESK_ORIGIN=https://support.example.org npm run configure:manifest ``` ### 3. Package unpacked extension zip for internal Chrome Enterprise rollout ```bash bash ops/pack-extension.sh ``` --- ## File: `docs/RESEARCH-2026.md` — 2026 Research & Landscape Notes (docs/RESEARCH-2026.md) # 2026 Chrome Manifest V3 Support Copilot Research & Design Notes ## 1. Browser Sidepanel Architecture in 2026 Following Chrome's full transition to **Manifest V3**, production helpdesk copilots rely on `chrome.sidePanel` rather than injected floating iframes: - **Zero Host-Page CSS Collisions:** Rendering inside Chrome's native sidepanel isolates UI styles from Chatwoot, Freshchat, or Zendesk React/Vue/Ember upgrades. - **Strict Backend Secret Boundary:** Because `.crx` / unpacked extensions are readable by any end-user device, LLM provider keys (`ANTHROPIC_API_KEY`, `OPENAI_API_KEY`) and CRM/OMS tokens must remain exclusively on the Express backend (`src/server/`), authenticated via short-lived session JWTs. - **Hybrid Extraction + Deterministic Pricing (`A1`):** Using an LLM to sum prices or pick multi-item bundles causes arithmetic hallucinations. `agent-copilot-public` restricts the model to **entity/intent extraction**, then runs a deterministic TypeScript set-cover optimizer (`src/server/matching/optimizer.ts`) verified by 23 Vitest suites (295 unit tests).