---
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.

<problem_patterns>
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.
</problem_patterns>

<architecture_map>
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
</architecture_map>

<inputs_and_configuration>
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.
</inputs_and_configuration>

<adaptation_playbook>
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`.
</adaptation_playbook>

<reference_docs>
- 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`
</reference_docs>
