Skip to content

VibeTechnologies/webagent

Repository files navigation

@vibetechnologies/webagent

Embeddable GenAI-powered web chat widget with client-side agent loop, tool calling, WebMCP support, and Cloudflare Workers backend.

CI npm

Features

  • πŸ€– Client-side AI agent loop (Vercel AI SDK)
  • πŸ”§ 5 built-in tools: web_fetch, skill, todo, send_email, escalate_to_human
  • πŸ“š TF-IDF knowledge base search
  • πŸ’Ύ Session persistence (IndexedDB / localStorage)
  • 🌐 WebMCP support (Chrome 146+) β€” provider + consumer
  • 🎨 Shadow DOM isolation β€” works on any website
  • ☁️ Cloudflare Workers backend (D1, KV, Queues; R2 optional)
  • πŸ”‘ Hybrid API keys: BYOK + managed

Quick Start

CDN (Recommended)

<script src="https://unpkg.com/@vibetechnologies/webagent/dist/webagent.min.js"></script>
<script>
  WebAgent.init({
    apiBase: 'https://your-worker.workers.dev',
    apiKey: 'wa_your_managed_key',
    welcomeMessage: 'Hi! How can I help you today?',
  });
</script>

npm

npm install @vibetechnologies/webagent
import { WebAgent } from '@vibetechnologies/webagent';

const agent = WebAgent.init({
  apiBase: 'https://your-worker.workers.dev',
  apiKey: 'wa_your_managed_key',
  welcomeMessage: 'Hi! How can I help?',
  theme: 'dark',
  position: 'bottom-right',
  persistence: 'indexeddb',
  sessionTtlDays: 7,
});

// Later: agent.destroy();

Configuration

Option Type Default Description
apiBase string required Backend worker URL
apiKey string undefined API key (BYOK sk-... or managed wa_...)
systemPrompt string 'You are a helpful support agent.' System prompt
skills Skill[] [] API skills for tool calling
knowledgeBaseUrl string undefined URL to knowledge base JSON
theme 'light' | 'dark' | 'auto' | ThemeConfig 'light' Theme
position 'bottom-right' | 'bottom-left' 'bottom-right' FAB position
welcomeMessage string undefined Initial greeting
persistence 'indexeddb' | 'localStorage' | 'none' 'indexeddb' Session storage
maxSteps number 10 Max tool-calling steps
model string 'gpt-4o-mini' LLM model name
supportEmail string 'support@example.com' Escalation recipient
sessionTtlDays number 7 Session TTL in days
onEscalation (ticket) => void undefined Escalation callback
onMessage (message) => void undefined Message callback

Skills

See the Skill Authoring Guide for full documentation on creating and registering API skills.

Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Host Website              β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚  Shadow DOM             β”‚ β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚ β”‚
β”‚  β”‚  β”‚  Chat Widget UI   β”‚  β”‚ β”‚
β”‚  β”‚  β”‚  (Preact)         β”‚  β”‚ β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚ β”‚
β”‚  β”‚           β”‚             β”‚ β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚ β”‚
β”‚  β”‚  β”‚  Agent Loop       β”‚  β”‚ β”‚
β”‚  β”‚  β”‚  (Vercel AI SDK)  β”‚  β”‚ β”‚
β”‚  β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚  β”‚ β”‚
β”‚  β”‚  β”‚  β”‚ Tools        β”‚  β”‚  β”‚ β”‚
β”‚  β”‚  β”‚  β”‚ β€’ web_fetch  β”‚  β”‚  β”‚ β”‚
β”‚  β”‚  β”‚  β”‚ β€’ skill      β”‚  β”‚  β”‚ β”‚
β”‚  β”‚  β”‚  β”‚ β€’ todo       β”‚  β”‚  β”‚ β”‚
β”‚  β”‚  β”‚  β”‚ β€’ send_email β”‚  β”‚  β”‚ β”‚
β”‚  β”‚  β”‚  β”‚ β€’ escalate   β”‚  β”‚  β”‚ β”‚
β”‚  β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚  β”‚ β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
               β”‚ HTTPS
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Cloudflare Workers          β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚ LLM     β”‚ β”‚ Fetch     β”‚  β”‚
β”‚  β”‚ Proxy   β”‚ β”‚ Proxy     β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚ Email   β”‚ β”‚ Escalate  β”‚  β”‚
β”‚  β”‚ Queue   β”‚ β”‚ Tickets   β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚ KB (KV/R2)β”‚ β”‚ Admin    β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚  D1 Β· KV Β· Queues (R2 opt.) β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

WebMCP Support

The widget supports the WebMCP standard (Chrome 146+):

As Provider

Skills registered with the widget are automatically exposed via navigator.modelContext.registerTool(), making them available to browser-level AI agents.

As Consumer

The widget can discover and use tools registered by the host page or other extensions via the WebMCP API.

Declarative Forms

<form toolname="search-products" tooldescription="Search the product catalog">
  <input name="query" toolparamdescription="Search query" />
  <button type="submit">Search</button>
</form>

Packages

Package Description
@vibetechnologies/webagent Client-side chat widget
@vibetechnologies/webagent-backend Cloudflare Workers backend

Examples

  • examples/basic/index.html β€” minimal static embed example
  • examples/ecommerce/index.html β€” e-commerce flavored static demo
  • examples/docs-site/index.html β€” docs-focused static demo
  • examples/config-assistant/index.html β€” Cloudflare-hostable widget configuration assistant with live preview and copy-paste embed generation

Development

pnpm install
pnpm typecheck    # Type-check all packages
pnpm build        # Build all packages
pnpm test         # Run tests
pnpm dev          # Dev mode (all packages)
pnpm --filter @vibetechnologies/webagent-backend dev:azure  # Backend with ~/.env.d/azure-dev.env

License

MIT

About

Embeddable GenAI-powered web chat widget with client-side agent loop, tool calling, WebMCP support, and Cloudflare Workers backend

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors