web-agent-bridge 2.3.1 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/README.ar.md +506 -31
  2. package/README.md +574 -47
  3. package/bin/agent-runner.js +10 -1
  4. package/package.json +1 -1
  5. package/public/agent-workspace.html +347 -0
  6. package/public/browser.html +484 -0
  7. package/public/css/agent-workspace.css +1713 -0
  8. package/public/index.html +94 -0
  9. package/public/js/agent-workspace.js +1740 -0
  10. package/sdk/index.d.ts +83 -0
  11. package/sdk/index.js +115 -1
  12. package/sdk/package.json +1 -1
  13. package/server/config/secrets.js +13 -5
  14. package/server/index.js +183 -4
  15. package/server/middleware/adminAuth.js +6 -1
  16. package/server/middleware/auth.js +11 -2
  17. package/server/middleware/rateLimits.js +78 -2
  18. package/server/migrations/003_ads_integer_cents.sql +33 -0
  19. package/server/models/db.js +126 -25
  20. package/server/routes/admin.js +16 -2
  21. package/server/routes/ads.js +130 -0
  22. package/server/routes/agent-workspace.js +378 -0
  23. package/server/routes/api.js +21 -2
  24. package/server/routes/auth.js +26 -6
  25. package/server/routes/sovereign.js +78 -0
  26. package/server/routes/universal.js +177 -0
  27. package/server/routes/wab-api.js +20 -5
  28. package/server/services/agent-chat.js +506 -0
  29. package/server/services/agent-symphony.js +6 -0
  30. package/server/services/agent-tasks.js +1807 -0
  31. package/server/services/fairness-engine.js +409 -0
  32. package/server/services/plugins.js +27 -3
  33. package/server/services/price-intelligence.js +565 -0
  34. package/server/services/price-shield.js +1137 -0
  35. package/server/services/search-engine.js +357 -0
  36. package/server/services/security.js +513 -0
  37. package/server/services/universal-scraper.js +661 -0
  38. package/server/ws.js +61 -1
package/README.md CHANGED
@@ -9,6 +9,8 @@
9
9
 
10
10
  > **robots.txt told bots what NOT to do. WAB tells AI agents what they CAN do.**
11
11
 
12
+ 🌐 **Live Website:** [https://webagentbridge.com](https://webagentbridge.com) — Try the Agent Workspace, dashboards, and many more features live.
13
+
12
14
  **English** | **[العربية](README.ar.md)**
13
15
 
14
16
  WAB is an open-source middleware layer that bridges AI agents and websites — like **OpenAPI for human-facing pages**. Website owners embed a script that exposes a standardized `window.AICommands` interface. AI agents discover available actions, execute commands, and interact with sites accurately — no DOM parsing, no scraping, no guesswork.
@@ -56,24 +58,51 @@ WAB is an open-source middleware layer that bridges AI agents and websites — l
56
58
  - **GDPR/CCPA Consent** — Optional `wab-consent.js` banner with `WABConsent.showBanner()` and `hasConsent()` gate
57
59
  - **Admin Dashboard** — User management, tier grants, system analytics
58
60
  - **Stripe Integration** — Payment processing with customer portal
61
+ - **Plugin Architecture** — Dynamic plugin system with hook-based execution, per-site installation, priority ordering, ratings, and audit logging
62
+ - **Vision Analysis Service** — Multi-provider screenshot analysis (local Moondream, OpenAI, Anthropic, Ollama) with interactive element detection, bounding box extraction, and AES-256-GCM encrypted API keys
63
+ - **Fairness Engine** — Neutrality layer ensuring AI agents give equal opportunity to small and large sites with fairness-weighted search, commission transparency tracking, and trust signature validation
64
+ - **Agent Memory System** — Persistent behavioral memory with 4 memory types, 5 categories, semantic associations, importance scoring, and TTL-based expiration
65
+ - **Premium Traffic Intelligence** — Advanced bot detection (30+ agent types), behavioral profiling, anomaly/spike detection, security exploit detection (SQLi, XSS), and webhook alerting
66
+ - **E-Mail Service** — SMTP-based transactional emails (welcome, registration, password reset, contact) with branded HTML templates
67
+ - **NoScript Fallback** — 1×1 tracking pixel endpoint for analytics collection when JavaScript is unavailable
68
+ - **WAB-MCP Adapter** — Expose WAB site capabilities as MCP tools for Claude, GPT, Gemini, and other MCP-compatible AI agents
69
+ - **WordPress Plugin** — Native WordPress plugin with settings page, per-page action meta boxes, discovery document generation, and dashboard widget
70
+ - **WAB Browser (Desktop)** — Standalone Electron desktop browser with built-in ad blocker (80+ domains), scam shield, fairness ranking, agent chat, bookmarks, history, and WAB protocol support. *Desktop source is maintained in a separate private build pipeline (`wab-browser/`); the PWA source below is fully open.*
71
+ - **PWA Browser (Mobile)** — Progressive Web App browser for Android/iOS with ad blocking (80+ domains), WAB Search engine, scam detection, fairness ranking, real AI agent chat, and offline-first service worker. Full source at `public/pwa/`.
72
+ - **Schema Discovery SDK** — Server-side extraction of schema.org JSON-LD Product nodes from HTML with automatic WAB action hint generation
59
73
 
60
74
  ### v2.0 — Digital Fortress Features
61
75
 
62
- - **Real-time Negotiation Engine** — AI agents negotiate prices directly with WAB-enabled sites using multi-round sessions, 8 condition types, and 4 discount types
63
- - **Anti-Hallucination Shield** — Cross-verification engine comparing DOM vs vision screenshots, market benchmark validation, temporal consistency checks, and Levenshtein text similarity scoring
64
- - **Decentralized Reputation System** — Cryptographic trust attestations from the agent network with weighted scoring, trust levels (emergingverified exemplary), and global leaderboard
65
- - **Sovereign Dashboard** — Real-time command center with fairness radar, privacy shield, negotiation logs, verification checks, and AI model switcher
76
+ - **Real-time Negotiation Engine** — AI agents negotiate prices directly with WAB-enabled sites using multi-round sessions. 8 condition types (bulk, loyalty, time-based, first-purchase, cart-value, seasonal, membership, referral) and 4 discount types (percentage, fixed, free-shipping, bonus-item). Includes daily usage limits, minimum order values, and full audit trail of all offers
77
+ - **Anti-Hallucination Shield** — Cross-verification engine comparing DOM vs vision screenshots, market benchmark validation, temporal consistency checks, and Levenshtein text similarity scoring. 4 severity levels (minor → fraud) and 5 response actions (warn, halt, confirm-human, auto-correct, block)
78
+ - **Decentralized Reputation System** — HMAC-signed trust attestations from the agent network covering 6 attestation types (purchase, booking, query, form, navigation, verification). 7 trust levels (unknownblacklisted), temporal decay, Sybil resistance, global leaderboard, and challenge/dispute system
79
+ - **Sovereign Dashboard** — Real-time command center with fairness radar, privacy shield, negotiation logs, verification checks, and AI model switcher. Exposes `/api/sovereign/dashboard/sovereign` aggregate endpoint
66
80
  - **Community Agent Hub** — 11 pre-built YAML agent templates (hotel booking, grocery comparison, artisan marketplace, flight deals, etc.) with CLI runner: `npx wab-agent run template.yaml`
67
- - **AI Brain Swapping** — Switch between Llama 3, GPT-4, Claude, Gemini, Mistral, or Ollama (local) without reconfiguration
81
+ - **AI Brain Swapping** — Local AI runtime that auto-discovers Ollama and llama.cpp endpoints plus custom OpenAI-compatible APIs. Model capability tracking for text/vision, context window management, latency-based routing, and inference logging with token metrics
68
82
  - **Cross-Site Agent Orchestration** — One agent manages multiple WAB-enabled sites simultaneously via `WABMultiAgent`. Compare prices across stores, aggregate data, run parallel actions, and find the best deal automatically
69
83
 
70
84
  ### v2.3 — Private Agent Mesh (Distributed Mind)
71
85
 
72
- - **Inter-Agent Protocol** — Agents communicate through a private mesh with 5 built-in channels (alerts, discoveries, tactics, negotiations, votes). Real-time knowledge sharing with confidence scoring and auto-expiring messages
73
- - **Local Reinforcement Learning** — Agents learn from every user decision using UCB1 multi-armed bandit action selection, gradient-descent policy updates, and behavioral pattern mining. Zero external API calls — all learning is local
74
- - **Symphony Orchestrator** — Four specialized agents (Researcher, Analyst, Negotiator, Guardian) collaborate autonomously through rule-based engines. 5 templates, 6-phase pipeline, Guardian veto for safety, weighted consensus. No external LLM dependency
86
+ - **Inter-Agent Protocol** — Agents communicate through a private mesh with 5 built-in channels (alerts, discoveries, tactics, negotiations, votes). 6 message types with confidence scoring, auto-expiring stale agents via heartbeat, peer verification of shared knowledge. All communication stays local — no external transmission
87
+ - **Local Reinforcement Learning** — Agents learn from every user decision using UCB1 multi-armed bandit action selection, gradient-descent policy updates with sigmoid activation, temporal discounting, and sequential pattern mining. Zero external API calls — all learning is local
88
+ - **Symphony Orchestrator** — Four specialized agents (Researcher, Analyst, Negotiator, Guardian) collaborate autonomously through rule-based engines. 5 templates, 6-phase pipeline (analyze → research → negotiate → guard → synthesize → decide), Guardian veto for safety, weighted consensus. Full phase logging with duration tracking. No external LLM dependency
75
89
  - **Agent Mesh Dashboard** — Real-time visualization of your agent mesh: active agents, communication channels, shared knowledge base, symphony compositions, and learning performance metrics
76
90
 
91
+ ### v2.4 — Commander & Edge Intelligence
92
+
93
+ - **Commander Agent System** — Local-first mission orchestration engine that decomposes high-level goals into task DAGs. Agent registry with capabilities tracking, parallel execution engine, learning integration for outcome feedback, and edge coordination for distributed work
94
+ - **Edge Compute System** — Transforms every user device into a sovereign AI node. Hardware profiling (CPU, RAM, GPU), AES-256-GCM encrypted inter-node communication, weighted load balancing, heartbeat-based health monitoring with auto-failover, and swarm formation with capability-based clustering
95
+ - **Swarm Execution Engine** — Launch multiple agents in parallel to solve a single task. Configurable strategies (parallel, sequential, hybrid), result merging with best-score selection, role specialization, fairness-weighted aggregation, and per-agent confidence scoring
96
+
97
+ ### v2.5 — Agent Workspace & Multilingual AI
98
+
99
+ - **Agent Workspace** — Premium 4-panel workspace for non-technical users: embedded browser, smart agent chat, real-time negotiation monitor, and results panel. Subscription tiers (Free/Starter/Pro/Enterprise), deal tracking, and admin management. Live at [webagentbridge.com/workspace](https://webagentbridge.com/workspace)
100
+ - **Bilingual UI (AR/EN)** — Full Arabic/English interface with auto-detection from browser language. Toggle instantly between languages. RTL/LTR layout support
101
+ - **Multilingual Agent** — The smart agent understands and responds in any language the user writes in — Arabic, English, French, Spanish, Turkish, and more. No restrictions on input style, dialect, or format
102
+ - **Dynamic Pricing Shield** — Detects price manipulation by websites that change prices based on device type, geolocation, cookies, browsing history, referral source, or repeat visits. The agent probes the same page with 12 distinct identity personas (clean desktop, mobile, Mac premium, EU/MENA/SEA geo, repeat visitor, Google/social/comparison referral, privacy-focused, bot-like) and uses statistical analysis (coefficient of variation, z-score outliers) to expose hidden pricing. Includes manipulation scoring (0–100), actionable tips, historical trend detection, and a strategy builder that recommends the best identity for the lowest price. Full API at `/api/sovereign/price-shield/`
103
+
104
+ > **Many more features** are available on the live website that aren't listed here — dashboards, analytics, admin tools, and more. Visit [webagentbridge.com](https://webagentbridge.com) to explore.
105
+
77
106
  ---
78
107
 
79
108
  ## Quick Start
@@ -136,51 +165,119 @@ const info = bridge.getPageInfo(); // get page metadata
136
165
 
137
166
  ```
138
167
  web-agent-bridge/
139
- ├── server/ # Express.js backend
140
- │ ├── index.js # Server entry point
168
+ ├── server/ # Express.js backend
169
+ │ ├── index.js # Server entry point
170
+ │ ├── ws.js # WebSocket server (live analytics)
141
171
  │ ├── routes/
142
- │ │ ├── auth.js # Authentication (register/login)
143
- │ │ ├── api.js # Sites, config, analytics API
144
- │ │ ├── license.js # License verification, token exchange & tracking
145
- │ │ ├── admin.js # Admin dashboard API
146
- │ │ ├── billing.js # Stripe billing integration
147
- │ │ └── sovereign.js # v2.0: negotiation, reputation, verification
172
+ │ │ ├── auth.js # Authentication (register/login)
173
+ │ │ ├── api.js # Sites, config, analytics API
174
+ │ │ ├── license.js # License verification, token exchange & tracking
175
+ │ │ ├── admin.js # Admin dashboard API
176
+ │ │ ├── admin-premium.js # Admin premium analytics (memory, vision, swarm, plugins)
177
+ │ │ ├── billing.js # Stripe billing integration
178
+ │ │ ├── sovereign.js # v2.0: negotiation, reputation, verification, dashboard
179
+ │ │ ├── mesh.js # v2.3: agent mesh protocol routes
180
+ │ │ ├── commander.js # v2.4: mission orchestration routes
181
+ │ │ ├── premium.js # Premium features
182
+ │ │ ├── premium-v2.js # v2 premium (memory, vision, healing, swarm, plugins)
183
+ │ │ ├── discovery.js # WAB discovery + fairness-weighted search
184
+ │ │ ├── wab-api.js # WAB HTTP transport (alternative to JS/WS)
185
+ │ │ └── noscript.js # NoScript tracking pixel fallback
148
186
  │ ├── services/
149
- │ │ ├── negotiation.js # Real-time negotiation engine
150
- │ │ ├── verification.js # Anti-hallucination shield
151
- │ │ └── reputation.js # Decentralized reputation system
187
+ │ │ ├── negotiation.js # Real-time negotiation engine
188
+ │ │ ├── verification.js # Anti-hallucination shield
189
+ │ │ ├── reputation.js # Decentralized reputation system
190
+ │ │ ├── agent-mesh.js # Inter-agent protocol (mesh)
191
+ │ │ ├── agent-learning.js # Local reinforcement learning (UCB1)
192
+ │ │ ├── agent-symphony.js # Symphony orchestrator (4 roles, 6 phases)
193
+ │ │ ├── agent-memory.js # Persistent agent memory with associations
194
+ │ │ ├── commander.js # Mission orchestration & task DAGs
195
+ │ │ ├── edge-compute.js # Edge computing / sovereign AI nodes
196
+ │ │ ├── swarm.js # Swarm execution engine
197
+ │ │ ├── fairness.js # Fairness & neutrality engine
198
+ │ │ ├── vision.js # Vision analysis (multi-provider)
199
+ │ │ ├── self-healing.js # Self-healing selector corrections
200
+ │ │ ├── local-ai.js # Local AI model runtime
201
+ │ │ ├── plugins.js # Plugin architecture (hooks, registry)
202
+ │ │ ├── premium.js # Premium traffic intelligence & bot detection
203
+ │ │ ├── email.js # SMTP email service
204
+ │ │ └── stripe.js # Stripe payment integration
152
205
  │ ├── middleware/
153
- │ │ └── auth.js # JWT authentication middleware
206
+ │ │ ├── auth.js # JWT authentication middleware
207
+ │ │ ├── adminAuth.js # Admin authentication
208
+ │ │ └── rateLimits.js # Multi-layer rate limiting
154
209
  │ ├── models/
155
- │ │ └── db.js # SQLite database & operations
156
- ├── migrations/ # Numbered SQL migrations
210
+ │ │ ├── db.js # Database operations
211
+ │ └── adapters/ # SQLite, PostgreSQL, MySQL adapters
212
+ │ ├── migrations/ # Numbered SQL migrations
157
213
  │ └── utils/
158
- │ ├── cache.js # In-memory cache + analytics queue
159
- └── migrate.js # Migration runner
160
- ├── public/ # Frontend
161
- ├── index.html # Landing page
162
- │ ├── dashboard.html # Management dashboard
163
- │ ├── docs.html # Documentation
164
- │ ├── login.html # Sign in
165
- │ ├── register.html # Sign up
166
- │ ├── admin/ # Admin panel
167
- │ ├── js/
168
- │ └── ws-client.js # WebSocket client with auto-reconnect
169
- └── css/styles.css # Design system
214
+ │ ├── cache.js # In-memory TTL cache + analytics queue
215
+ ├── migrate.js # Migration runner
216
+ │ └── secureFields.js # Field-level encryption utilities
217
+ ├── public/ # Frontend
218
+ │ ├── index.html # Landing page
219
+ │ ├── dashboard.html # Management dashboard
220
+ │ ├── premium-dashboard.html # Premium analytics dashboard
221
+ │ ├── docs.html # Documentation
222
+ │ ├── login.html / register.html # Auth pages
223
+ │ ├── admin/ # Admin panel
224
+ ├── pwa/ # Progressive Web App (mobile browser)
225
+ │ ├── manifest.json # PWA manifest
226
+ │ │ ├── sw.js # Service worker (offline-first)
227
+ │ │ ├── index.html # Mobile browser UI
228
+ │ │ ├── app.js # Ad blocker, scam shield, fairness
229
+ │ │ ├── app.css # Mobile-optimized dark theme
230
+ │ │ └── icons/ # PWA icons (192x192, 512x512)
231
+ │ ├── script/
232
+ │ │ ├── wab.min.js # Minified WAB client library
233
+ │ │ ├── wab-consent.js # GDPR/CCPA consent banner
234
+ │ │ ├── wab-schema.js # Schema.org discovery
235
+ │ │ ├── wab.d.ts # TypeScript definitions
236
+ │ │ └── wab-consent.d.ts # Consent TypeScript definitions
237
+ │ ├── js/ # Dashboard frontend JS
238
+ │ └── css/ # Stylesheets
170
239
  ├── script/
171
- │ └── ai-agent-bridge.js # The bridge script (embed in websites)
172
- ├── examples/ # Agent examples (Puppeteer, BiDi, Vision)
173
- ├── packages/ # Framework wrappers
174
- │ ├── react/ # @web-agent-bridge/react
175
- │ ├── vue/ # @web-agent-bridge/vue
176
- │ ├── svelte/ # @web-agent-bridge/svelte
177
- └── langchain/ # @web-agent-bridge/langchain
178
- ├── sdk/ # Agent SDK for Puppeteer/Playwright
240
+ │ └── ai-agent-bridge.js # The bridge script (embed in websites)
241
+ ├── examples/ # Agent examples
242
+ ├── puppeteer-agent.js # Puppeteer + window.AICommands
243
+ │ ├── bidi-agent.js # WebDriver BiDi protocol
244
+ │ ├── vision-agent.js # Vision/NLP intent resolution
245
+ │ ├── mcp-agent.js # MCP adapter usage for Claude/GPT
246
+ ├── cross-site-agent.js # Multi-domain orchestration
247
+ ├── next-app-router/ # Next.js App Router integration
248
+ │ ├── shopify-hydrogen/ # Shopify Hydrogen storefront
249
+ │ ├── wordpress-elementor/ # WordPress + Elementor setup
250
+ │ └── saas-dashboard/ # SaaS dashboard actions
251
+ ├── packages/ # Framework wrappers
252
+ │ ├── react/ # @web-agent-bridge/react
253
+ │ ├── vue/ # @web-agent-bridge/vue
254
+ │ ├── svelte/ # @web-agent-bridge/svelte
255
+ │ └── langchain/ # @web-agent-bridge/langchain
256
+ ├── sdk/ # Agent SDK
257
+ │ ├── index.js # WABAgent for Puppeteer/Playwright
258
+ │ └── schema-discovery.js # Server-side schema.org extraction
259
+ ├── wab-mcp-adapter/ # MCP adapter for Claude/GPT/Gemini
260
+ │ ├── index.js # MCP tool definitions
261
+ │ └── package.json
262
+ ├── wab-browser/ # Electron desktop browser
263
+ │ ├── main.js # Electron main process
264
+ │ ├── preload.js # Bridge preload
265
+ │ └── package.json
266
+ ├── web-agent-bridge-wordpress/ # WordPress plugin
267
+ │ ├── web-agent-bridge.php # Plugin entry point
268
+ │ ├── includes/ # PHP classes (API, Actions, Dashboard)
269
+ │ └── assets/ # Plugin CSS/JS
179
270
  ├── bin/
180
- │ ├── cli.js # CLI entry point (wab-agent)
181
- │ └── agent-runner.js # YAML template runner
182
- ├── templates/ # Community Agent Hub YAML templates
183
- ├── .env # Environment variables
271
+ │ ├── cli.js # CLI entry point (wab-agent)
272
+ │ └── wab.js # Agent runner
273
+ ├── templates/ # 11 Community Agent Hub YAML templates
274
+ ├── docs/
275
+ │ ├── SPEC.md # WAB Protocol Specification
276
+ │ └── DEPLOY.md # Deployment guide
277
+ ├── demo-store/ # Demo store for testing
278
+ ├── deploy/ # Nginx configs
279
+ ├── tests/ # Jest + Supertest test suite
280
+ ├── .env # Environment variables
184
281
  └── package.json
185
282
  ```
186
283
 
@@ -213,7 +310,7 @@ web-agent-bridge/
213
310
  | `/api/license/verify` | POST | Verify license key for domain (cached) |
214
311
  | `/api/license/token` | POST | Exchange `siteId` (Origin must match domain) or `licenseKey` for session token |
215
312
  | `/api/license/session` | POST | Validate session token (domain-locked) |
216
- | `/api/license/track` | POST | Record analytics (`sessionToken` + Origin; legacy `licenseKey` only if `ALLOW_LEGACY_LICENSE_TRACK`) |
313
+ | `/api/license/track` | POST | Record analytics (`sessionToken` + Origin) |
217
314
 
218
315
  ### Sovereign (v2.0)
219
316
  | Endpoint | Method | Description |
@@ -232,6 +329,72 @@ web-agent-bridge/
232
329
  | `/api/sovereign/verify/page` | POST | Full page verification |
233
330
  | `/api/sovereign/dashboard/sovereign` | GET | Dashboard aggregate data |
234
331
 
332
+ ### Agent Mesh (v2.3)
333
+ | Endpoint | Method | Description |
334
+ |---|---|---|
335
+ | `/api/mesh/agents` | POST | Register agent in mesh |
336
+ | `/api/mesh/agents` | GET | List mesh agents |
337
+ | `/api/mesh/channels` | GET | List communication channels |
338
+ | `/api/mesh/messages` | POST | Publish message to channel |
339
+ | `/api/mesh/messages/:channel` | GET | Get messages from channel |
340
+ | `/api/mesh/knowledge` | POST | Share knowledge to mesh |
341
+ | `/api/mesh/knowledge` | GET | Query knowledge base |
342
+ | `/api/mesh/votes` | POST | Start a vote |
343
+ | `/api/mesh/votes/:id/cast` | POST | Cast a vote |
344
+ | `/api/mesh/votes/:id/tally` | GET | Get vote results |
345
+
346
+ ### Commander (v2.4)
347
+ | Endpoint | Method | Description |
348
+ |---|---|---|
349
+ | `/api/commander/missions` | POST | Create a new mission |
350
+ | `/api/commander/missions/:id/launch` | POST | Launch mission execution |
351
+ | `/api/commander/missions/:id` | GET | Get mission status |
352
+ | `/api/commander/missions` | GET | List all missions |
353
+ | `/api/commander/agents` | POST | Register an agent |
354
+ | `/api/commander/agents` | GET | List registered agents |
355
+ | `/api/commander/edge/nodes` | POST | Register edge node |
356
+ | `/api/commander/edge/nodes` | GET | List edge nodes |
357
+ | `/api/commander/ai/models` | GET | Discover local AI models |
358
+ | `/api/commander/ai/infer` | POST | Run local AI inference |
359
+ | `/api/commander/stats` | GET | Unified platform statistics |
360
+
361
+ ### Premium v2
362
+ | Endpoint | Method | Description |
363
+ |---|---|---|
364
+ | `/api/premium/v2/memory` | POST | Store agent memory |
365
+ | `/api/premium/v2/memory/:agentId` | GET | Recall agent memories |
366
+ | `/api/premium/v2/memory/associate` | POST | Create memory association |
367
+ | `/api/premium/v2/memory/:id` | DELETE | Forget a memory |
368
+ | `/api/premium/v2/memory/consolidate` | POST | Consolidate old memories |
369
+ | `/api/premium/v2/vision/analyze` | POST | Analyze screenshot |
370
+ | `/api/premium/v2/vision/elements` | POST | Extract interactive elements |
371
+ | `/api/premium/v2/healing/corrections` | POST | Register selector correction |
372
+ | `/api/premium/v2/healing/resolve` | POST | Resolve broken selector |
373
+ | `/api/premium/v2/swarm/execute` | POST | Launch swarm task |
374
+ | `/api/premium/v2/swarm/:id` | GET | Get swarm results |
375
+ | `/api/premium/v2/plugins` | GET | List available plugins |
376
+ | `/api/premium/v2/plugins/:id/install` | POST | Install plugin for site |
377
+ | `/api/premium/v2/plugins/:id/hooks` | POST | Execute plugin hook |
378
+
379
+ ### Discovery & Fairness
380
+ | Endpoint | Method | Description |
381
+ |---|---|---|
382
+ | `/api/discovery` | GET | WAB discovery document |
383
+ | `/api/discovery/search` | GET | Fairness-weighted site search |
384
+ | `/api/discovery/register` | POST | Register site in WAB directory |
385
+
386
+ ### WAB Protocol (HTTP Transport)
387
+ | Endpoint | Method | Description |
388
+ |---|---|---|
389
+ | `/api/wab/session` | POST | Exchange session token |
390
+ | `/api/wab/actions` | GET | Get available actions |
391
+ | `/api/wab/execute` | POST | Execute action via HTTP |
392
+
393
+ ### NoScript Fallback
394
+ | Endpoint | Method | Description |
395
+ |---|---|---|
396
+ | `/noscript/pixel.gif` | GET | 1×1 tracking pixel for non-JS environments |
397
+
235
398
  ---
236
399
 
237
400
  ## Bridge Script API
@@ -603,6 +766,8 @@ Ready-to-run agent examples in the [`examples/`](examples/) directory:
603
766
  | `puppeteer-agent.js` | Basic agent using Puppeteer + `window.AICommands` |
604
767
  | `bidi-agent.js` | Agent using WebDriver BiDi protocol via `window.__wab_bidi` |
605
768
  | `vision-agent.js` | Vision/NLP agent — resolves natural language intents to actions using a local keyword-based resolver (no external API) |
769
+ | `mcp-agent.js` | MCP adapter usage for Claude and GPT with tool discovery and execution |
770
+ | `cross-site-agent.js` | Multi-domain orchestration — compare prices across stores, aggregate data, find best deals |
606
771
 
607
772
  ## Framework + CMS Examples
608
773
 
@@ -971,6 +1136,368 @@ fairness_rules:
971
1136
 
972
1137
  ---
973
1138
 
1139
+ ## Commander Agent System
1140
+
1141
+ The Commander is a local-first mission orchestration engine that decomposes high-level goals into task DAGs and distributes work across specialized agents:
1142
+
1143
+ ```javascript
1144
+ // Create a mission
1145
+ const mission = await fetch('/api/commander/missions', {
1146
+ method: 'POST',
1147
+ headers: { 'Authorization': 'Bearer ' + token, 'Content-Type': 'application/json' },
1148
+ body: JSON.stringify({
1149
+ goal: 'Find the cheapest olive oil across 5 stores',
1150
+ strategy: 'parallel',
1151
+ agents: ['researcher-1', 'analyst-1', 'negotiator-1']
1152
+ })
1153
+ }).then(r => r.json());
1154
+
1155
+ // Launch mission
1156
+ await fetch(`/api/commander/missions/${mission.id}/launch`, { method: 'POST', headers: { 'Authorization': 'Bearer ' + token } });
1157
+
1158
+ // Check status
1159
+ const status = await fetch(`/api/commander/missions/${mission.id}`, { headers: { 'Authorization': 'Bearer ' + token } }).then(r => r.json());
1160
+ // → { status: 'completed', tasks: [...], result: { bestPrice: 12.99, store: 'farm-direct' } }
1161
+ ```
1162
+
1163
+ ### Commander Capabilities
1164
+ | Feature | Description |
1165
+ |---|---|
1166
+ | **Mission Decomposition** | Breaks high-level goals into task DAGs with dependency tracking |
1167
+ | **Agent Registry** | Tracks agent capabilities, availability, and performance history |
1168
+ | **Parallel Execution** | Runs independent tasks concurrently across multiple agents |
1169
+ | **Learning Integration** | Records outcomes for reinforcement learning feedback |
1170
+ | **Edge Coordination** | Distributes compute-heavy tasks to edge nodes |
1171
+
1172
+ ---
1173
+
1174
+ ## Edge Compute System
1175
+
1176
+ Transform every user device into a sovereign AI node — no central cloud required:
1177
+
1178
+ ```javascript
1179
+ // Register a device as an edge node
1180
+ const node = await fetch('/api/commander/edge/nodes', {
1181
+ method: 'POST',
1182
+ headers: { 'Authorization': 'Bearer ' + token, 'Content-Type': 'application/json' },
1183
+ body: JSON.stringify({
1184
+ name: 'my-laptop',
1185
+ capabilities: { cpu: 8, ram: 16384, gpu: true },
1186
+ supportedTasks: ['text-inference', 'vision-analysis', 'price-comparison']
1187
+ })
1188
+ }).then(r => r.json());
1189
+
1190
+ // List available edge nodes
1191
+ const nodes = await fetch('/api/commander/edge/nodes', { headers: { 'Authorization': 'Bearer ' + token } }).then(r => r.json());
1192
+ ```
1193
+
1194
+ | Feature | Description |
1195
+ |---|---|
1196
+ | **Hardware Profiling** | Detects CPU, RAM, GPU capabilities per node |
1197
+ | **AES-256-GCM Encryption** | All inter-node data is encrypted end-to-end |
1198
+ | **Weighted Load Balancing** | Routes tasks based on hardware + availability scores |
1199
+ | **Heartbeat Health Monitoring** | Auto-failover when nodes become unresponsive |
1200
+ | **Swarm Formation** | Capability-based clustering of nodes for distributed tasks |
1201
+
1202
+ ---
1203
+
1204
+ ## Swarm Execution Engine
1205
+
1206
+ Launch multiple agents in parallel to solve a single task, then intelligently merge their outputs:
1207
+
1208
+ ```javascript
1209
+ // Launch a swarm task
1210
+ const swarm = await fetch('/api/premium/v2/swarm/execute', {
1211
+ method: 'POST',
1212
+ headers: { 'Authorization': 'Bearer ' + token, 'Content-Type': 'application/json' },
1213
+ body: JSON.stringify({
1214
+ task: 'Find best laptop deals under $1000',
1215
+ strategy: 'parallel', // parallel | sequential | hybrid
1216
+ agentCount: 4,
1217
+ roles: ['researcher', 'analyst', 'price-checker', 'reviewer'],
1218
+ mergeStrategy: 'best-score' // best-score | fairness-weighted | consensus
1219
+ })
1220
+ }).then(r => r.json());
1221
+ // → { swarmId: '...', agents: 4, status: 'running' }
1222
+
1223
+ // Get merged results
1224
+ const results = await fetch(`/api/premium/v2/swarm/${swarm.swarmId}`, {
1225
+ headers: { 'Authorization': 'Bearer ' + token }
1226
+ }).then(r => r.json());
1227
+ // → { status: 'completed', merged: { bestDeal: {...}, confidence: 0.94 } }
1228
+ ```
1229
+
1230
+ ---
1231
+
1232
+ ## Fairness Engine
1233
+
1234
+ A neutrality layer ensuring AI agents give equal opportunity to small and large sites, preventing monopolistic concentration of agent traffic:
1235
+
1236
+ ```javascript
1237
+ // Fairness-weighted search (instead of pure relevance)
1238
+ const results = await fetch('/api/discovery/search?q=olive+oil&fairness=true', {
1239
+ headers: { 'Authorization': 'Bearer ' + token }
1240
+ }).then(r => r.json());
1241
+ // Small farms ranked alongside Amazon — weighted by neutrality score, not just SEO
1242
+
1243
+ // Register site in WAB directory
1244
+ await fetch('/api/discovery/register', {
1245
+ method: 'POST',
1246
+ headers: { 'Authorization': 'Bearer ' + token, 'Content-Type': 'application/json' },
1247
+ body: JSON.stringify({
1248
+ domain: 'small-farm.example.com',
1249
+ category: 'food',
1250
+ commissionRate: 0, // Direct — no middleman
1251
+ independentSeller: true
1252
+ })
1253
+ }).then(r => r.json());
1254
+ ```
1255
+
1256
+ ### How Neutrality Scoring Works
1257
+ | Factor | Weight | Description |
1258
+ |---|---|---|
1259
+ | **Configuration completeness** | 25% | How well the site has configured WAB |
1260
+ | **Trust score** | 25% | Reputation attestations from the agent network |
1261
+ | **Transparency** | 25% | Commission disclosure, pricing clarity |
1262
+ | **Responsiveness** | 25% | API response time, uptime, action success rate |
1263
+
1264
+ Small independent sites with good WAB configuration can outrank large platforms on fairness-weighted searches.
1265
+
1266
+ ---
1267
+
1268
+ ## Agent Memory System
1269
+
1270
+ Persistent behavioral memory allowing agents to remember user preferences, learn patterns, and build associations:
1271
+
1272
+ ```javascript
1273
+ // Store a memory
1274
+ await fetch('/api/premium/v2/memory', {
1275
+ method: 'POST',
1276
+ headers: { 'Authorization': 'Bearer ' + token, 'Content-Type': 'application/json' },
1277
+ body: JSON.stringify({
1278
+ agentId: 'agent-1',
1279
+ type: 'preference', // preference | interaction | correction | pattern
1280
+ category: 'purchase', // navigation | purchase | search | form | custom
1281
+ key: 'preferred-brand',
1282
+ value: 'organic-only',
1283
+ importance: 0.9
1284
+ })
1285
+ }).then(r => r.json());
1286
+
1287
+ // Recall memories
1288
+ const memories = await fetch('/api/premium/v2/memory/agent-1?category=purchase&limit=10', {
1289
+ headers: { 'Authorization': 'Bearer ' + token }
1290
+ }).then(r => r.json());
1291
+
1292
+ // Create associations
1293
+ await fetch('/api/premium/v2/memory/associate', {
1294
+ method: 'POST',
1295
+ headers: { 'Authorization': 'Bearer ' + token, 'Content-Type': 'application/json' },
1296
+ body: JSON.stringify({
1297
+ sourceId: 'memory-1',
1298
+ targetId: 'memory-2',
1299
+ relationship: 'leads_to' // leads_to | similar_to | replaces | depends_on
1300
+ })
1301
+ }).then(r => r.json());
1302
+ ```
1303
+
1304
+ ---
1305
+
1306
+ ## Vision Analysis Service
1307
+
1308
+ Multi-provider screenshot analysis for interactive element detection and data extraction:
1309
+
1310
+ ```javascript
1311
+ // Analyze a screenshot
1312
+ const analysis = await fetch('/api/premium/v2/vision/analyze', {
1313
+ method: 'POST',
1314
+ headers: { 'Authorization': 'Bearer ' + token, 'Content-Type': 'application/json' },
1315
+ body: JSON.stringify({
1316
+ screenshot: 'base64-encoded-image...',
1317
+ provider: 'auto', // auto | local | openai | anthropic | ollama
1318
+ extractElements: true
1319
+ })
1320
+ }).then(r => r.json());
1321
+ // → { elements: [{ type: 'button', text: 'Add to Cart', selector: '#add-btn', confidence: 0.95, bbox: [120, 340, 200, 40] }] }
1322
+
1323
+ // Extract interactive elements only
1324
+ const elements = await fetch('/api/premium/v2/vision/elements', {
1325
+ method: 'POST',
1326
+ headers: { 'Authorization': 'Bearer ' + token, 'Content-Type': 'application/json' },
1327
+ body: JSON.stringify({ screenshot: 'base64...', types: ['button', 'input', 'link'] })
1328
+ }).then(r => r.json());
1329
+ ```
1330
+
1331
+ ### Supported Vision Providers
1332
+ | Provider | Local? | Description |
1333
+ |---|---|---|
1334
+ | **Moondream** | ✅ | Lightweight local vision model |
1335
+ | **Ollama** | ✅ | Local models via Ollama (llava, bakllava) |
1336
+ | **OpenAI** | ❌ | GPT-4 Vision |
1337
+ | **Anthropic** | ❌ | Claude Vision |
1338
+
1339
+ ---
1340
+
1341
+ ## Plugin Architecture
1342
+
1343
+ Dynamic plugin system allowing third-party extensions:
1344
+
1345
+ ```javascript
1346
+ // List available plugins
1347
+ const plugins = await fetch('/api/premium/v2/plugins', {
1348
+ headers: { 'Authorization': 'Bearer ' + token }
1349
+ }).then(r => r.json());
1350
+
1351
+ // Install a plugin for your site
1352
+ await fetch('/api/premium/v2/plugins/price-alert/install', {
1353
+ method: 'POST',
1354
+ headers: { 'Authorization': 'Bearer ' + token, 'Content-Type': 'application/json' },
1355
+ body: JSON.stringify({ siteId: 'site-uuid', config: { threshold: 10 } })
1356
+ }).then(r => r.json());
1357
+
1358
+ // Execute a plugin hook
1359
+ await fetch('/api/premium/v2/plugins/price-alert/hooks', {
1360
+ method: 'POST',
1361
+ headers: { 'Authorization': 'Bearer ' + token, 'Content-Type': 'application/json' },
1362
+ body: JSON.stringify({ hook: 'onPriceChange', data: { oldPrice: 49.99, newPrice: 39.99 } })
1363
+ }).then(r => r.json());
1364
+ ```
1365
+
1366
+ ---
1367
+
1368
+ ## Premium Traffic Intelligence
1369
+
1370
+ Advanced bot detection and traffic profiling for premium sites:
1371
+
1372
+ | Capability | Description |
1373
+ |---|---|
1374
+ | **30+ Bot Types** | Detects Google, Bing, ChatGPT, Claude, Perplexity, and more |
1375
+ | **Behavioral Profiling** | Classifies agent behavior by signature, platform, and type |
1376
+ | **Anomaly Detection** | Spike detection and pattern analysis for unusual traffic |
1377
+ | **Security Exploit Detection** | Flags SQL injection, XSS patterns, and rate anomalies |
1378
+ | **Webhook Alerting** | Triggers webhooks on suspicious activity |
1379
+ | **Compliance Audit Logging** | Full audit trail for regulatory compliance |
1380
+
1381
+ ---
1382
+
1383
+ ## WAB-MCP Adapter
1384
+
1385
+ Expose WAB site capabilities as [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) tools for Claude, GPT, Gemini, and other MCP-compatible AI agents:
1386
+
1387
+ ```javascript
1388
+ const { WABMCPAdapter } = require('wab-mcp-adapter');
1389
+
1390
+ // Create adapter for a WAB-enabled site
1391
+ const adapter = new WABMCPAdapter({
1392
+ siteUrl: 'https://shop.example.com',
1393
+ transport: 'http' // http | websocket | direct
1394
+ });
1395
+
1396
+ // Get MCP tool definitions
1397
+ const tools = await adapter.getTools();
1398
+ // → [{ name: 'discover', description: '...', inputSchema: {...} }, ...]
1399
+
1400
+ // Execute via MCP
1401
+ const result = await adapter.executeTool('execute_action', {
1402
+ name: 'addToCart',
1403
+ params: { sku: 'ABC123' }
1404
+ });
1405
+ ```
1406
+
1407
+ ### Built-in MCP Tools
1408
+ | Tool | Description |
1409
+ |---|---|
1410
+ | `discover` | Auto-discover available actions on a WAB site |
1411
+ | `get_actions` | Get list of all actions with parameters |
1412
+ | `execute_action` | Execute a specific action |
1413
+ | `read_content` | Read content from the page |
1414
+ | `get_page_info` | Get page metadata |
1415
+ | `fairness_search` | Search the WAB directory with fairness weighting |
1416
+ | `authenticate` | Authenticate an agent with the site |
1417
+
1418
+ ---
1419
+
1420
+ ## WAB Browser (Desktop)
1421
+
1422
+ Standalone Electron desktop browser with built-in privacy and fairness features:
1423
+
1424
+ - **Ad Blocker** — 80+ blocked ad domains + URL pattern matching + cosmetic CSS rules
1425
+ - **Scam Shield** — Detects suspicious TLDs and brand-name spoofing in URLs
1426
+ - **Fairness Ranking** — Prioritizes independent sites, flags big-tech concentration
1427
+ - **Agent Chat** — Built-in AI assistant panel for browsing help
1428
+ - **Notifications** — Page analysis with safety and fairness alerts
1429
+ - **Ghost Mode** — Privacy-first browsing with no tracking
1430
+ - **Smart Search** — WAB Search integration for independent search
1431
+ - **Desktop/Mobile Toggle** — Switch user-agent for responsive testing
1432
+
1433
+ ```bash
1434
+ # Run the WAB Browser
1435
+ cd wab-browser
1436
+ npm install
1437
+ npx electron .
1438
+
1439
+ # Build installer (Windows NSIS)
1440
+ npm run build:win
1441
+ ```
1442
+
1443
+ ---
1444
+
1445
+ ## PWA Browser (Mobile)
1446
+
1447
+ Progressive Web App browser for Android and iOS — installable from any mobile browser:
1448
+
1449
+ - **Ad Blocker** — 80+ ad domain blacklist + URL pattern matching
1450
+ - **Scam Detection** — Suspicious TLD alerts and brand-name spoofing checks
1451
+ - **Fairness Mode** — Filters big-tech sites to promote independent alternatives
1452
+ - **Offline-First** — Service worker caches shell assets for offline launch
1453
+ - **WAB Search** — Independent search engine with multi-source aggregation, autocomplete, and trending
1454
+ - **AI Agent Chat** — Real AI agent (OpenAI / local Ollama / smart fallback) with conversation memory, web search, and security analysis
1455
+
1456
+ Install at: `https://yourserver.com/pwa/`
1457
+
1458
+ ---
1459
+
1460
+ ## WordPress Plugin
1461
+
1462
+ Native WordPress plugin for adding WAB support to any WordPress site:
1463
+
1464
+ ```bash
1465
+ # Install
1466
+ cp -r web-agent-bridge-wordpress/ /wp-content/plugins/web-agent-bridge/
1467
+ ```
1468
+
1469
+ | Feature | Description |
1470
+ |---|---|
1471
+ | **Settings Page** | Configure API base URL, site ID, permissions |
1472
+ | **Per-Page Actions** | Meta box for adding custom WAB actions per page/post |
1473
+ | **Discovery Document** | Auto-generates WAB discovery endpoint |
1474
+ | **Dashboard Widget** | Shows WAB status and agent interaction stats |
1475
+ | **Shortcode** | `[wab_bridge]` shortcode for embedding WAB on specific pages |
1476
+ | **Hooks API** | `wab_before_action` / `wab_after_action` for custom logic |
1477
+
1478
+ See [`web-agent-bridge-wordpress/README.md`](web-agent-bridge-wordpress/README.md) for full documentation.
1479
+
1480
+ ---
1481
+
1482
+ ## WAB Protocol Specification
1483
+
1484
+ The full normative specification is available at [`docs/SPEC.md`](docs/SPEC.md):
1485
+
1486
+ | Layer | Description |
1487
+ |---|---|
1488
+ | **Protocol Layer** | Discovery document format, command protocol, fairness protocol |
1489
+ | **Runtime Layer** | `window.AICommands` interface, auto-discovery engine, security sandbox |
1490
+ | **Transport Layer** | JavaScript global, WebSocket, HTTP, WebDriver BiDi, MCP |
1491
+
1492
+ ### 5-Phase Lifecycle
1493
+ 1. **Discover** — Agent finds WAB discovery document (`.well-known/wab.json` or script tag)
1494
+ 2. **Authenticate** — Agent exchanges `siteId` for session token
1495
+ 3. **Plan** — Agent reads available actions and page metadata
1496
+ 4. **Execute** — Agent runs actions through the bridge
1497
+ 5. **Confirm** — Results are verified via Anti-Hallucination Shield
1498
+
1499
+ ---
1500
+
974
1501
  ## License
975
1502
 
976
1503
  MIT — Free to use, modify, and distribute.