web-agent-bridge 1.1.2 → 2.0.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 (94) hide show
  1. package/LICENSE +21 -21
  2. package/README.ar.md +446 -446
  3. package/README.md +780 -844
  4. package/bin/cli.js +80 -80
  5. package/bin/wab.js +80 -80
  6. package/examples/bidi-agent.js +119 -119
  7. package/examples/mcp-agent.js +94 -94
  8. package/examples/next-app-router/README.md +44 -0
  9. package/examples/puppeteer-agent.js +108 -108
  10. package/examples/saas-dashboard/README.md +55 -0
  11. package/examples/shopify-hydrogen/README.md +74 -0
  12. package/examples/vision-agent.js +171 -171
  13. package/examples/wordpress-elementor/README.md +77 -0
  14. package/package.json +69 -78
  15. package/public/.well-known/ai-assets.json +59 -0
  16. package/public/admin/login.html +84 -84
  17. package/public/ai.html +196 -0
  18. package/public/cookies.html +208 -208
  19. package/public/css/premium.css +317 -0
  20. package/public/css/styles.css +1235 -1235
  21. package/public/dashboard.html +704 -704
  22. package/public/demo.html +259 -0
  23. package/public/docs.html +585 -585
  24. package/public/feed.xml +89 -0
  25. package/public/index.html +495 -332
  26. package/public/js/auth-nav.js +31 -31
  27. package/public/js/auth-redirect.js +12 -12
  28. package/public/js/cookie-consent.js +56 -56
  29. package/public/js/wab-demo-page.js +721 -0
  30. package/public/js/ws-client.js +74 -74
  31. package/public/llms-full.txt +309 -0
  32. package/public/llms.txt +85 -0
  33. package/public/login.html +83 -83
  34. package/public/openapi.json +580 -0
  35. package/public/premium-dashboard.html +2487 -0
  36. package/public/premium.html +791 -0
  37. package/public/privacy.html +295 -295
  38. package/public/register.html +103 -103
  39. package/public/robots.txt +87 -0
  40. package/public/script/wab-consent.d.ts +36 -0
  41. package/public/script/wab-consent.js +104 -0
  42. package/public/script/wab-schema.js +131 -0
  43. package/public/script/wab.d.ts +108 -0
  44. package/public/script/wab.min.js +234 -0
  45. package/public/sitemap.xml +93 -0
  46. package/public/terms.html +254 -254
  47. package/public/video/tutorial.mp4 +0 -0
  48. package/script/ai-agent-bridge.js +1558 -1513
  49. package/sdk/README.md +55 -55
  50. package/sdk/index.d.ts +118 -0
  51. package/sdk/index.js +257 -203
  52. package/sdk/package.json +14 -14
  53. package/sdk/schema-discovery.js +83 -0
  54. package/server/config/secrets.js +94 -92
  55. package/server/index.js +0 -9
  56. package/server/middleware/adminAuth.js +30 -30
  57. package/server/middleware/auth.js +41 -41
  58. package/server/middleware/rateLimits.js +24 -24
  59. package/server/migrations/001_add_analytics_indexes.sql +7 -7
  60. package/server/migrations/002_premium_features.sql +418 -0
  61. package/server/models/adapters/index.js +33 -33
  62. package/server/models/adapters/mysql.js +183 -183
  63. package/server/models/adapters/postgresql.js +172 -172
  64. package/server/models/adapters/sqlite.js +7 -7
  65. package/server/models/db.js +561 -561
  66. package/server/routes/admin-premium.js +671 -0
  67. package/server/routes/admin.js +247 -247
  68. package/server/routes/api.js +131 -138
  69. package/server/routes/auth.js +51 -51
  70. package/server/routes/billing.js +45 -45
  71. package/server/routes/discovery.js +406 -329
  72. package/server/routes/license.js +240 -240
  73. package/server/routes/noscript.js +543 -543
  74. package/server/routes/premium-v2.js +686 -0
  75. package/server/routes/premium.js +724 -0
  76. package/server/routes/wab-api.js +476 -476
  77. package/server/services/agent-memory.js +625 -0
  78. package/server/services/email.js +204 -204
  79. package/server/services/fairness.js +420 -420
  80. package/server/services/plugins.js +747 -0
  81. package/server/services/premium.js +1883 -0
  82. package/server/services/self-healing.js +843 -0
  83. package/server/services/stripe.js +192 -192
  84. package/server/services/swarm.js +788 -0
  85. package/server/services/vision.js +871 -0
  86. package/server/utils/cache.js +125 -125
  87. package/server/utils/migrate.js +81 -81
  88. package/server/utils/secureFields.js +50 -50
  89. package/server/ws.js +101 -101
  90. package/docs/DEPLOY.md +0 -118
  91. package/docs/SPEC.md +0 -1540
  92. package/wab-mcp-adapter/README.md +0 -136
  93. package/wab-mcp-adapter/index.js +0 -555
  94. package/wab-mcp-adapter/package.json +0 -17
@@ -0,0 +1,234 @@
1
+ /**
2
+ * WAB Client v2.0.0 — Add this script to make any website AI-agent-ready
3
+ * https://webagentbridge.com
4
+ *
5
+ * Usage (zero setup):
6
+ * <script src="https://webagentbridge.com/script/wab.min.js"></script>
7
+ * <script>
8
+ * WAB.init({
9
+ * name: "My Store",
10
+ * actions: {
11
+ * buy: { description: "Buy product", run: () => { ... } },
12
+ * getPrice: { description: "Get price", run: () => ({ price: "$49" }) }
13
+ * }
14
+ * });
15
+ * </script>
16
+ *
17
+ * That's it. Your site now supports:
18
+ * - In-browser agent access via window.__wab_protocol
19
+ * - Discovery via WAB.discover()
20
+ * - Execution via WAB.execute("actionName", params)
21
+ * - Cross-frame sync (postMessage) for embedded demos
22
+ * - Auto-connection to WAB server endpoints if available
23
+ *
24
+ * License: MIT
25
+ */
26
+ (function(global) {
27
+ 'use strict';
28
+
29
+ var VERSION = '2.0.0';
30
+
31
+ // ── WAB Instance ──────────────────────────────────────────────────
32
+ function WABInstance(config) {
33
+ this.name = config.name || document.title || 'WAB Site';
34
+ this.serverUrl = config.serverUrl || '';
35
+ this.actions = {};
36
+ this._auditLog = [];
37
+ this._listeners = {};
38
+ this._ready = false;
39
+
40
+ if (config.actions) {
41
+ for (var key in config.actions) {
42
+ if (!config.actions.hasOwnProperty(key)) continue;
43
+ var action = config.actions[key];
44
+ if (typeof action === 'function') {
45
+ this.actions[key] = { description: key, params: [], run: action };
46
+ } else {
47
+ this.actions[key] = {
48
+ description: action.description || key,
49
+ params: action.params || [],
50
+ run: action.run || action.handler || function() { return { error: 'no handler' }; }
51
+ };
52
+ }
53
+ }
54
+ }
55
+
56
+ this._exposeProtocol();
57
+ this._setupCrossFrame();
58
+ this._ready = true;
59
+ this._emit('ready', { name: this.name, actions: Object.keys(this.actions) });
60
+ }
61
+
62
+ // Expose window.__wab_protocol for in-browser agents
63
+ WABInstance.prototype._exposeProtocol = function() {
64
+ var self = this;
65
+ global.__wab_protocol = {
66
+ version: VERSION,
67
+ protocol: '1.0',
68
+ name: this.name,
69
+ actions: Object.keys(this.actions).map(function(k) {
70
+ return { name: k, description: self.actions[k].description, params: self.actions[k].params };
71
+ }),
72
+ transport: ['javascript', 'http'],
73
+ ready: true,
74
+ discover: function() { return self.discover(); },
75
+ execute: function(name, params) { return self.execute(name, params); }
76
+ };
77
+ };
78
+
79
+ // Cross-frame communication for embedded demos
80
+ WABInstance.prototype._setupCrossFrame = function() {
81
+ var self = this;
82
+
83
+ global.addEventListener('message', function(e) {
84
+ if (!e.data || e.data.source === 'wab-store') return;
85
+
86
+ // Handle requests from parent (agent demo page)
87
+ if (e.data.source === 'wab-agent' && e.data.type === 'refresh') {
88
+ self._emit('refresh');
89
+ }
90
+ if (e.data.source === 'wab-agent' && e.data.type === 'discover') {
91
+ self.discover().then(function(doc) {
92
+ e.source.postMessage({ source: 'wab-store', type: 'discover-response', detail: doc }, '*');
93
+ });
94
+ }
95
+ if (e.data.source === 'wab-agent' && e.data.type === 'execute') {
96
+ self.execute(e.data.action, e.data.params).then(function(result) {
97
+ e.source.postMessage({ source: 'wab-store', type: 'execute-response', action: e.data.action, detail: result }, '*');
98
+ });
99
+ }
100
+ });
101
+
102
+ // Notify parent that store is ready
103
+ this._notifyParent('store-ready', { name: this.name, actions: Object.keys(this.actions) });
104
+ };
105
+
106
+ WABInstance.prototype._notifyParent = function(type, detail) {
107
+ try {
108
+ if (global.parent !== global) {
109
+ global.parent.postMessage({ source: 'wab-store', type: type, detail: detail }, '*');
110
+ }
111
+ } catch(e) {}
112
+ };
113
+
114
+ // Event system
115
+ WABInstance.prototype.on = function(event, fn) {
116
+ if (!this._listeners[event]) this._listeners[event] = [];
117
+ this._listeners[event].push(fn);
118
+ return this;
119
+ };
120
+
121
+ WABInstance.prototype._emit = function(event, data) {
122
+ var fns = this._listeners[event] || [];
123
+ for (var i = 0; i < fns.length; i++) {
124
+ try { fns[i](data); } catch(e) {}
125
+ }
126
+ };
127
+
128
+ // ── Core API ──────────────────────────────────────────────────────
129
+
130
+ WABInstance.prototype.discover = function() {
131
+ var self = this;
132
+ var actionList = [];
133
+ for (var key in this.actions) {
134
+ if (this.actions.hasOwnProperty(key)) {
135
+ actionList.push({ name: key, description: this.actions[key].description, params: this.actions[key].params });
136
+ }
137
+ }
138
+
139
+ // If server URL is configured, fetch from server for authoritative discovery
140
+ if (this.serverUrl) {
141
+ return fetch(this.serverUrl + '/.well-known/wab.json')
142
+ .then(function(r) { return r.json(); })
143
+ .catch(function() {
144
+ return { wab_version: VERSION, protocol: '1.0', name: self.name, actions: actionList, transport: ['javascript'] };
145
+ });
146
+ }
147
+
148
+ return Promise.resolve({
149
+ wab_version: VERSION,
150
+ protocol: '1.0',
151
+ name: this.name,
152
+ actions: actionList,
153
+ transport: ['javascript', 'http']
154
+ });
155
+ };
156
+
157
+ WABInstance.prototype.execute = function(actionName, params) {
158
+ var self = this;
159
+ var action = this.actions[actionName];
160
+ params = params || {};
161
+
162
+ // If server URL configured and action not local, proxy to server
163
+ if (!action && this.serverUrl) {
164
+ return fetch(this.serverUrl + '/wab/execute', {
165
+ method: 'POST',
166
+ headers: { 'Content-Type': 'application/json' },
167
+ body: JSON.stringify({ action: actionName, params: params })
168
+ }).then(function(r) { return r.json(); });
169
+ }
170
+
171
+ if (!action) {
172
+ return Promise.resolve({ success: false, error: 'Action not found: ' + actionName });
173
+ }
174
+
175
+ var start = Date.now();
176
+ try {
177
+ var result = action.run(params);
178
+ var handleResult = function(res) {
179
+ var duration = Date.now() - start;
180
+ self._auditLog.push({ action: actionName, params: params, result: res, duration_ms: duration, timestamp: new Date().toISOString() });
181
+ if (self._auditLog.length > 200) self._auditLog.shift();
182
+ self._notifyParent('action-executed', { action: actionName, result: res, duration_ms: duration });
183
+ self._emit('execute', { action: actionName, params: params, result: res, duration_ms: duration });
184
+ return res;
185
+ };
186
+ if (result && typeof result.then === 'function') {
187
+ return result.then(handleResult);
188
+ }
189
+ return Promise.resolve(handleResult(result));
190
+ } catch (e) {
191
+ return Promise.resolve({ success: false, error: e.message });
192
+ }
193
+ };
194
+
195
+ WABInstance.prototype.getActions = function() {
196
+ return Object.keys(this.actions);
197
+ };
198
+
199
+ WABInstance.prototype.getAuditLog = function() {
200
+ return this._auditLog.slice();
201
+ };
202
+
203
+ // ── Static API ────────────────────────────────────────────────────
204
+
205
+ var WAB = {
206
+ version: VERSION,
207
+
208
+ init: function(config) {
209
+ var instance = new WABInstance(config || {});
210
+ WAB._instance = instance;
211
+ return instance;
212
+ },
213
+
214
+ // Connect to a remote WAB server (for client pages that don't define actions)
215
+ connect: function(serverUrl) {
216
+ return new WABInstance({ name: 'WAB Client', serverUrl: serverUrl });
217
+ },
218
+
219
+ discover: function() {
220
+ if (WAB._instance) return WAB._instance.discover();
221
+ return Promise.resolve({ error: 'WAB not initialized. Call WAB.init() first.' });
222
+ },
223
+
224
+ execute: function(actionName, params) {
225
+ if (WAB._instance) return WAB._instance.execute(actionName, params);
226
+ return Promise.resolve({ error: 'WAB not initialized. Call WAB.init() first.' });
227
+ },
228
+
229
+ _instance: null
230
+ };
231
+
232
+ global.WAB = WAB;
233
+
234
+ })(typeof window !== 'undefined' ? window : this);
@@ -0,0 +1,93 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
3
+ <url>
4
+ <loc>https://webagentbridge.com/</loc>
5
+ <lastmod>2026-03-28</lastmod>
6
+ <changefreq>weekly</changefreq>
7
+ <priority>1.0</priority>
8
+ </url>
9
+ <url>
10
+ <loc>https://webagentbridge.com/docs</loc>
11
+ <lastmod>2026-03-28</lastmod>
12
+ <changefreq>weekly</changefreq>
13
+ <priority>0.9</priority>
14
+ </url>
15
+ <url>
16
+ <loc>https://webagentbridge.com/premium</loc>
17
+ <lastmod>2026-03-28</lastmod>
18
+ <changefreq>monthly</changefreq>
19
+ <priority>0.8</priority>
20
+ </url>
21
+ <url>
22
+ <loc>https://webagentbridge.com/register</loc>
23
+ <lastmod>2026-03-28</lastmod>
24
+ <changefreq>monthly</changefreq>
25
+ <priority>0.7</priority>
26
+ </url>
27
+ <url>
28
+ <loc>https://webagentbridge.com/login</loc>
29
+ <lastmod>2026-03-28</lastmod>
30
+ <changefreq>monthly</changefreq>
31
+ <priority>0.5</priority>
32
+ </url>
33
+ <url>
34
+ <loc>https://webagentbridge.com/privacy</loc>
35
+ <lastmod>2026-03-28</lastmod>
36
+ <changefreq>yearly</changefreq>
37
+ <priority>0.3</priority>
38
+ </url>
39
+ <url>
40
+ <loc>https://webagentbridge.com/terms</loc>
41
+ <lastmod>2026-03-28</lastmod>
42
+ <changefreq>yearly</changefreq>
43
+ <priority>0.3</priority>
44
+ </url>
45
+ <url>
46
+ <loc>https://webagentbridge.com/cookies</loc>
47
+ <lastmod>2026-03-28</lastmod>
48
+ <changefreq>yearly</changefreq>
49
+ <priority>0.2</priority>
50
+ </url>
51
+ <url>
52
+ <loc>https://webagentbridge.com/llms.txt</loc>
53
+ <lastmod>2026-03-28</lastmod>
54
+ <changefreq>monthly</changefreq>
55
+ <priority>0.6</priority>
56
+ </url>
57
+ <url>
58
+ <loc>https://webagentbridge.com/llms-full.txt</loc>
59
+ <lastmod>2026-03-28</lastmod>
60
+ <changefreq>monthly</changefreq>
61
+ <priority>0.6</priority>
62
+ </url>
63
+ <url>
64
+ <loc>https://webagentbridge.com/agent-bridge.json</loc>
65
+ <lastmod>2026-03-28</lastmod>
66
+ <changefreq>monthly</changefreq>
67
+ <priority>0.7</priority>
68
+ </url>
69
+ <url>
70
+ <loc>https://webagentbridge.com/demo</loc>
71
+ <lastmod>2026-03-28</lastmod>
72
+ <changefreq>weekly</changefreq>
73
+ <priority>0.9</priority>
74
+ </url>
75
+ <url>
76
+ <loc>https://webagentbridge.com/ai</loc>
77
+ <lastmod>2026-03-28</lastmod>
78
+ <changefreq>weekly</changefreq>
79
+ <priority>0.8</priority>
80
+ </url>
81
+ <url>
82
+ <loc>https://webagentbridge.com/openapi.json</loc>
83
+ <lastmod>2026-03-28</lastmod>
84
+ <changefreq>monthly</changefreq>
85
+ <priority>0.6</priority>
86
+ </url>
87
+ <url>
88
+ <loc>https://webagentbridge.com/feed.xml</loc>
89
+ <lastmod>2026-03-28</lastmod>
90
+ <changefreq>weekly</changefreq>
91
+ <priority>0.5</priority>
92
+ </url>
93
+ </urlset>