web-agent-bridge 1.1.0 → 1.1.2

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 (66) hide show
  1. package/LICENSE +21 -21
  2. package/README.ar.md +446 -446
  3. package/README.md +844 -844
  4. package/bin/cli.js +80 -80
  5. package/bin/wab.js +80 -80
  6. package/docs/DEPLOY.md +118 -118
  7. package/docs/SPEC.md +1540 -1540
  8. package/examples/bidi-agent.js +119 -119
  9. package/examples/mcp-agent.js +94 -85
  10. package/examples/puppeteer-agent.js +108 -108
  11. package/examples/vision-agent.js +171 -171
  12. package/package.json +78 -78
  13. package/public/admin/dashboard.html +848 -848
  14. package/public/admin/login.html +84 -84
  15. package/public/cookies.html +208 -208
  16. package/public/css/styles.css +1235 -1235
  17. package/public/dashboard.html +704 -704
  18. package/public/docs.html +585 -585
  19. package/public/index.html +332 -332
  20. package/public/js/auth-nav.js +31 -31
  21. package/public/js/auth-redirect.js +12 -12
  22. package/public/js/cookie-consent.js +56 -56
  23. package/public/js/ws-client.js +74 -74
  24. package/public/login.html +83 -83
  25. package/public/privacy.html +295 -295
  26. package/public/register.html +103 -103
  27. package/public/terms.html +254 -254
  28. package/script/ai-agent-bridge.js +1513 -1513
  29. package/sdk/README.md +55 -55
  30. package/sdk/index.js +203 -203
  31. package/sdk/package.json +14 -14
  32. package/server/config/secrets.js +92 -92
  33. package/server/index.js +181 -179
  34. package/server/middleware/adminAuth.js +30 -30
  35. package/server/middleware/auth.js +41 -41
  36. package/server/middleware/rateLimits.js +24 -24
  37. package/server/migrations/001_add_analytics_indexes.sql +7 -7
  38. package/server/models/adapters/index.js +33 -33
  39. package/server/models/adapters/mysql.js +183 -183
  40. package/server/models/adapters/postgresql.js +172 -172
  41. package/server/models/adapters/sqlite.js +7 -7
  42. package/server/models/db.js +561 -561
  43. package/server/routes/admin.js +247 -247
  44. package/server/routes/api.js +138 -138
  45. package/server/routes/auth.js +51 -51
  46. package/server/routes/billing.js +45 -45
  47. package/server/routes/discovery.js +329 -324
  48. package/server/routes/license.js +240 -240
  49. package/server/routes/noscript.js +543 -543
  50. package/server/routes/wab-api.js +476 -0
  51. package/server/services/email.js +204 -204
  52. package/server/services/fairness.js +420 -420
  53. package/server/services/stripe.js +192 -192
  54. package/server/utils/cache.js +125 -125
  55. package/server/utils/migrate.js +81 -81
  56. package/server/utils/secureFields.js +50 -50
  57. package/server/ws.js +101 -101
  58. package/wab-mcp-adapter/README.md +136 -136
  59. package/wab-mcp-adapter/index.js +555 -528
  60. package/wab-mcp-adapter/package.json +17 -17
  61. package/public/css/premium.css +0 -317
  62. package/public/premium-dashboard.html +0 -2075
  63. package/public/premium.html +0 -791
  64. package/server/migrations/002_premium_features.sql +0 -418
  65. package/server/routes/premium.js +0 -724
  66. package/server/services/premium.js +0 -1680
@@ -1,171 +1,171 @@
1
- /**
2
- * Example: Vision-based AI Agent using WAB
3
- *
4
- * This agent demonstrates how a "vision" or "natural language" AI agent
5
- * (like OpenAI Operator, Claude Computer Use, etc.) can interact with
6
- * WAB using descriptive intent instead of explicit action names.
7
- *
8
- * The agent describes what it wants to do in natural language,
9
- * and the IntentResolver matches it to available WAB actions.
10
- *
11
- * HOW IT WORKS:
12
- * The IntentResolver is a LOCAL, keyword-based NLP mapper — it does NOT
13
- * call any external AI/ML API. It scores WAB actions against the intent
14
- * string using word overlap, category bonuses, and synonym matching.
15
- * This keeps the example dependency-free and easy to understand.
16
- *
17
- * To integrate a real LLM (e.g., OpenAI, Claude), replace the
18
- * IntentResolver.resolve() method with an API call that returns the
19
- * best-matching action name from the available actions list.
20
- *
21
- * Prerequisites:
22
- * npm install puppeteer
23
- *
24
- * Usage:
25
- * node examples/vision-agent.js <url>
26
- */
27
-
28
- const puppeteer = require('puppeteer');
29
-
30
- const TARGET_URL = process.argv[2] || 'http://localhost:3000';
31
-
32
- // ─── Intent Resolver: maps natural language to WAB actions ────────────
33
- // This is a lightweight LOCAL resolver (no external API calls).
34
- // It uses keyword matching, synonym expansion, and category heuristics.
35
- class IntentResolver {
36
- constructor(actions) {
37
- this.actions = actions;
38
- }
39
-
40
- /**
41
- * Find the best matching action for a natural language intent.
42
- * Uses keyword matching and description similarity.
43
- * @param {string} intent — Natural language description (e.g., "sign up for an account")
44
- * @returns {{ action: object, confidence: number } | null}
45
- */
46
- resolve(intent) {
47
- const intentLower = intent.toLowerCase();
48
- const intentWords = intentLower.split(/\s+/);
49
- let bestMatch = null;
50
- let bestScore = 0;
51
-
52
- for (const action of this.actions) {
53
- const descLower = (action.description + ' ' + action.name).toLowerCase();
54
- let score = 0;
55
-
56
- // Exact name match
57
- if (intentLower.includes(action.name.replace(/_/g, ' '))) {
58
- score += 5;
59
- }
60
-
61
- // Word overlap scoring
62
- for (const word of intentWords) {
63
- if (word.length < 3) continue;
64
- if (descLower.includes(word)) score += 1;
65
- }
66
-
67
- // Category bonus
68
- if (action.category === 'navigation' && /navigate|go to|open|visit/i.test(intent)) score += 2;
69
- if (action.trigger === 'fill_and_submit' && /fill|submit|sign up|register|login|form/i.test(intent)) score += 2;
70
- if (action.trigger === 'click' && /click|press|tap|select|button/i.test(intent)) score += 1;
71
-
72
- // Synonym matching
73
- const synonyms = {
74
- 'sign up': ['register', 'create account', 'signup'],
75
- 'log in': ['login', 'sign in', 'signin'],
76
- 'search': ['find', 'look for', 'query'],
77
- 'submit': ['send', 'post', 'confirm'],
78
- 'navigate': ['go to', 'open', 'visit']
79
- };
80
-
81
- for (const [key, syns] of Object.entries(synonyms)) {
82
- if (syns.some(s => intentLower.includes(s)) && descLower.includes(key)) score += 3;
83
- if (intentLower.includes(key) && syns.some(s => descLower.includes(s))) score += 3;
84
- }
85
-
86
- if (score > bestScore) {
87
- bestScore = score;
88
- bestMatch = action;
89
- }
90
- }
91
-
92
- if (!bestMatch || bestScore < 1) return null;
93
-
94
- const confidence = Math.min(1, bestScore / 10);
95
- return { action: bestMatch, confidence };
96
- }
97
- }
98
-
99
- // ─── Vision Agent ─────────────────────────────────────────────────────
100
- async function main() {
101
- console.log(`\n👁️ WAB Vision Agent`);
102
- console.log(` Target: ${TARGET_URL}\n`);
103
-
104
- const browser = await puppeteer.launch({ headless: true });
105
- const page = await browser.newPage();
106
-
107
- await page.goto(TARGET_URL, { waitUntil: 'networkidle2' });
108
- console.log(`✓ Page loaded: ${await page.title()}`);
109
-
110
- // Wait for bridge
111
- await page.waitForFunction(() => typeof window.AICommands !== 'undefined', { timeout: 10000 });
112
- console.log('✓ WAB bridge detected\n');
113
-
114
- // Get available actions
115
- const actions = await page.evaluate(() => window.AICommands.getActions());
116
- const resolver = new IntentResolver(actions);
117
-
118
- console.log(`📋 Available actions: ${actions.length}`);
119
- actions.forEach(a => console.log(` • ${a.name} — ${a.description}`));
120
-
121
- // ── Simulate vision agent intents ─────────────────────────────────
122
- const intents = [
123
- 'I want to create a new account',
124
- 'Take me to the documentation page',
125
- 'Click the login button',
126
- 'Show me the dashboard'
127
- ];
128
-
129
- console.log('\n🧠 Resolving natural language intents:\n');
130
-
131
- for (const intent of intents) {
132
- const match = resolver.resolve(intent);
133
-
134
- if (match) {
135
- console.log(` Intent: "${intent}"`);
136
- console.log(` → Action: ${match.action.name} (${match.action.trigger})`);
137
- console.log(` → Confidence: ${(match.confidence * 100).toFixed(0)}%`);
138
- console.log(` → Description: ${match.action.description}`);
139
-
140
- // Execute if confidence is high enough
141
- if (match.confidence >= 0.3) {
142
- const result = await page.evaluate(
143
- (name) => window.AICommands.execute(name),
144
- match.action.name
145
- );
146
- console.log(` → Executed: ${result.success ? '✓' : '✗ ' + result.error}`);
147
- } else {
148
- console.log(` → Skipped: confidence too low`);
149
- }
150
- } else {
151
- console.log(` Intent: "${intent}"`);
152
- console.log(` → No matching action found`);
153
- }
154
- console.log('');
155
- }
156
-
157
- // ── Demonstrate page info with security context ───────────────────
158
- const pageInfo = await page.evaluate(() => window.AICommands.getPageInfo());
159
- console.log('📊 Page Info:');
160
- console.log(` Security sandbox: ${pageInfo.security.sandboxActive ? '✓ Active' : '✗ Inactive'}`);
161
- console.log(` Self-healing: ${pageInfo.selfHealing.tracked} tracked, ${pageInfo.selfHealing.healed} healed`);
162
- console.log(` Stealth mode: ${pageInfo.stealthMode ? 'Enabled' : 'Disabled'}`);
163
-
164
- console.log('\n✓ Vision agent session complete.');
165
- await browser.close();
166
- }
167
-
168
- main().catch((err) => {
169
- console.error('Agent error:', err.message);
170
- process.exit(1);
171
- });
1
+ /**
2
+ * Example: Vision-based AI Agent using WAB
3
+ *
4
+ * This agent demonstrates how a "vision" or "natural language" AI agent
5
+ * (like OpenAI Operator, Claude Computer Use, etc.) can interact with
6
+ * WAB using descriptive intent instead of explicit action names.
7
+ *
8
+ * The agent describes what it wants to do in natural language,
9
+ * and the IntentResolver matches it to available WAB actions.
10
+ *
11
+ * HOW IT WORKS:
12
+ * The IntentResolver is a LOCAL, keyword-based NLP mapper — it does NOT
13
+ * call any external AI/ML API. It scores WAB actions against the intent
14
+ * string using word overlap, category bonuses, and synonym matching.
15
+ * This keeps the example dependency-free and easy to understand.
16
+ *
17
+ * To integrate a real LLM (e.g., OpenAI, Claude), replace the
18
+ * IntentResolver.resolve() method with an API call that returns the
19
+ * best-matching action name from the available actions list.
20
+ *
21
+ * Prerequisites:
22
+ * npm install puppeteer
23
+ *
24
+ * Usage:
25
+ * node examples/vision-agent.js <url>
26
+ */
27
+
28
+ const puppeteer = require('puppeteer');
29
+
30
+ const TARGET_URL = process.argv[2] || 'http://localhost:3000';
31
+
32
+ // ─── Intent Resolver: maps natural language to WAB actions ────────────
33
+ // This is a lightweight LOCAL resolver (no external API calls).
34
+ // It uses keyword matching, synonym expansion, and category heuristics.
35
+ class IntentResolver {
36
+ constructor(actions) {
37
+ this.actions = actions;
38
+ }
39
+
40
+ /**
41
+ * Find the best matching action for a natural language intent.
42
+ * Uses keyword matching and description similarity.
43
+ * @param {string} intent — Natural language description (e.g., "sign up for an account")
44
+ * @returns {{ action: object, confidence: number } | null}
45
+ */
46
+ resolve(intent) {
47
+ const intentLower = intent.toLowerCase();
48
+ const intentWords = intentLower.split(/\s+/);
49
+ let bestMatch = null;
50
+ let bestScore = 0;
51
+
52
+ for (const action of this.actions) {
53
+ const descLower = (action.description + ' ' + action.name).toLowerCase();
54
+ let score = 0;
55
+
56
+ // Exact name match
57
+ if (intentLower.includes(action.name.replace(/_/g, ' '))) {
58
+ score += 5;
59
+ }
60
+
61
+ // Word overlap scoring
62
+ for (const word of intentWords) {
63
+ if (word.length < 3) continue;
64
+ if (descLower.includes(word)) score += 1;
65
+ }
66
+
67
+ // Category bonus
68
+ if (action.category === 'navigation' && /navigate|go to|open|visit/i.test(intent)) score += 2;
69
+ if (action.trigger === 'fill_and_submit' && /fill|submit|sign up|register|login|form/i.test(intent)) score += 2;
70
+ if (action.trigger === 'click' && /click|press|tap|select|button/i.test(intent)) score += 1;
71
+
72
+ // Synonym matching
73
+ const synonyms = {
74
+ 'sign up': ['register', 'create account', 'signup'],
75
+ 'log in': ['login', 'sign in', 'signin'],
76
+ 'search': ['find', 'look for', 'query'],
77
+ 'submit': ['send', 'post', 'confirm'],
78
+ 'navigate': ['go to', 'open', 'visit']
79
+ };
80
+
81
+ for (const [key, syns] of Object.entries(synonyms)) {
82
+ if (syns.some(s => intentLower.includes(s)) && descLower.includes(key)) score += 3;
83
+ if (intentLower.includes(key) && syns.some(s => descLower.includes(s))) score += 3;
84
+ }
85
+
86
+ if (score > bestScore) {
87
+ bestScore = score;
88
+ bestMatch = action;
89
+ }
90
+ }
91
+
92
+ if (!bestMatch || bestScore < 1) return null;
93
+
94
+ const confidence = Math.min(1, bestScore / 10);
95
+ return { action: bestMatch, confidence };
96
+ }
97
+ }
98
+
99
+ // ─── Vision Agent ─────────────────────────────────────────────────────
100
+ async function main() {
101
+ console.log(`\n👁️ WAB Vision Agent`);
102
+ console.log(` Target: ${TARGET_URL}\n`);
103
+
104
+ const browser = await puppeteer.launch({ headless: true });
105
+ const page = await browser.newPage();
106
+
107
+ await page.goto(TARGET_URL, { waitUntil: 'networkidle2' });
108
+ console.log(`✓ Page loaded: ${await page.title()}`);
109
+
110
+ // Wait for bridge
111
+ await page.waitForFunction(() => typeof window.AICommands !== 'undefined', { timeout: 10000 });
112
+ console.log('✓ WAB bridge detected\n');
113
+
114
+ // Get available actions
115
+ const actions = await page.evaluate(() => window.AICommands.getActions());
116
+ const resolver = new IntentResolver(actions);
117
+
118
+ console.log(`📋 Available actions: ${actions.length}`);
119
+ actions.forEach(a => console.log(` • ${a.name} — ${a.description}`));
120
+
121
+ // ── Simulate vision agent intents ─────────────────────────────────
122
+ const intents = [
123
+ 'I want to create a new account',
124
+ 'Take me to the documentation page',
125
+ 'Click the login button',
126
+ 'Show me the dashboard'
127
+ ];
128
+
129
+ console.log('\n🧠 Resolving natural language intents:\n');
130
+
131
+ for (const intent of intents) {
132
+ const match = resolver.resolve(intent);
133
+
134
+ if (match) {
135
+ console.log(` Intent: "${intent}"`);
136
+ console.log(` → Action: ${match.action.name} (${match.action.trigger})`);
137
+ console.log(` → Confidence: ${(match.confidence * 100).toFixed(0)}%`);
138
+ console.log(` → Description: ${match.action.description}`);
139
+
140
+ // Execute if confidence is high enough
141
+ if (match.confidence >= 0.3) {
142
+ const result = await page.evaluate(
143
+ (name) => window.AICommands.execute(name),
144
+ match.action.name
145
+ );
146
+ console.log(` → Executed: ${result.success ? '✓' : '✗ ' + result.error}`);
147
+ } else {
148
+ console.log(` → Skipped: confidence too low`);
149
+ }
150
+ } else {
151
+ console.log(` Intent: "${intent}"`);
152
+ console.log(` → No matching action found`);
153
+ }
154
+ console.log('');
155
+ }
156
+
157
+ // ── Demonstrate page info with security context ───────────────────
158
+ const pageInfo = await page.evaluate(() => window.AICommands.getPageInfo());
159
+ console.log('📊 Page Info:');
160
+ console.log(` Security sandbox: ${pageInfo.security.sandboxActive ? '✓ Active' : '✗ Inactive'}`);
161
+ console.log(` Self-healing: ${pageInfo.selfHealing.tracked} tracked, ${pageInfo.selfHealing.healed} healed`);
162
+ console.log(` Stealth mode: ${pageInfo.stealthMode ? 'Enabled' : 'Disabled'}`);
163
+
164
+ console.log('\n✓ Vision agent session complete.');
165
+ await browser.close();
166
+ }
167
+
168
+ main().catch((err) => {
169
+ console.error('Agent error:', err.message);
170
+ process.exit(1);
171
+ });
package/package.json CHANGED
@@ -1,78 +1,78 @@
1
- {
2
- "name": "web-agent-bridge",
3
- "version": "1.1.0",
4
- "description": "Open protocol and runtime for AI agents to interact with websites — standardized discovery, commands, and fairness layer for the Agentic Web",
5
- "main": "server/index.js",
6
- "bin": {
7
- "web-agent-bridge": "./bin/cli.js",
8
- "wab": "./bin/cli.js"
9
- },
10
- "scripts": {
11
- "start": "node server/index.js",
12
- "dev": "node server/index.js",
13
- "test": "jest --forceExit --detectOpenHandles",
14
- "build:script": "node scripts/build.js",
15
- "prepublishOnly": "npm test"
16
- },
17
- "keywords": [
18
- "ai",
19
- "agent",
20
- "bridge",
21
- "protocol",
22
- "web-standard",
23
- "mcp",
24
- "automation",
25
- "web",
26
- "middleware",
27
- "ai-agent",
28
- "browser-automation",
29
- "webdriver-bidi",
30
- "fairness",
31
- "discovery",
32
- "agentic-web",
33
- "model-context-protocol"
34
- ],
35
- "repository": {
36
- "type": "git",
37
- "url": "git+https://github.com/abokenan444/web-agent-bridge.git"
38
- },
39
- "homepage": "https://github.com/abokenan444/web-agent-bridge#readme",
40
- "bugs": {
41
- "url": "https://github.com/abokenan444/web-agent-bridge/issues"
42
- },
43
- "files": [
44
- "bin/",
45
- "server/",
46
- "public/",
47
- "script/",
48
- "sdk/",
49
- "wab-mcp-adapter/",
50
- "docs/",
51
- "examples/",
52
- "README.md",
53
- "README.ar.md",
54
- "LICENSE"
55
- ],
56
- "engines": {
57
- "node": ">=18.0.0"
58
- },
59
- "license": "MIT",
60
- "dependencies": {
61
- "bcryptjs": "^2.4.3",
62
- "better-sqlite3": "^11.6.0",
63
- "cors": "^2.8.5",
64
- "dotenv": "^16.4.5",
65
- "express": "^4.21.0",
66
- "express-rate-limit": "^7.4.1",
67
- "helmet": "^8.0.0",
68
- "jsonwebtoken": "^9.0.2",
69
- "nodemailer": "^8.0.3",
70
- "stripe": "^20.4.1",
71
- "uuid": "^10.0.0",
72
- "ws": "^8.19.0"
73
- },
74
- "devDependencies": {
75
- "jest": "^30.3.0",
76
- "supertest": "^7.2.2"
77
- }
78
- }
1
+ {
2
+ "name": "web-agent-bridge",
3
+ "version": "1.1.2",
4
+ "description": "Open protocol and runtime for AI agents to interact with websites — standardized discovery, commands, and fairness layer for the Agentic Web",
5
+ "main": "server/index.js",
6
+ "bin": {
7
+ "web-agent-bridge": "./bin/cli.js",
8
+ "wab": "./bin/cli.js"
9
+ },
10
+ "scripts": {
11
+ "start": "node server/index.js",
12
+ "dev": "node server/index.js",
13
+ "test": "jest --forceExit --detectOpenHandles",
14
+ "build:script": "node scripts/build.js",
15
+ "prepublishOnly": "npm test"
16
+ },
17
+ "keywords": [
18
+ "ai",
19
+ "agent",
20
+ "bridge",
21
+ "protocol",
22
+ "web-standard",
23
+ "mcp",
24
+ "automation",
25
+ "web",
26
+ "middleware",
27
+ "ai-agent",
28
+ "browser-automation",
29
+ "webdriver-bidi",
30
+ "fairness",
31
+ "discovery",
32
+ "agentic-web",
33
+ "model-context-protocol"
34
+ ],
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "git+https://github.com/abokenan444/web-agent-bridge.git"
38
+ },
39
+ "homepage": "https://github.com/abokenan444/web-agent-bridge#readme",
40
+ "bugs": {
41
+ "url": "https://github.com/abokenan444/web-agent-bridge/issues"
42
+ },
43
+ "files": [
44
+ "bin/",
45
+ "server/",
46
+ "public/",
47
+ "script/",
48
+ "sdk/",
49
+ "wab-mcp-adapter/",
50
+ "docs/",
51
+ "examples/",
52
+ "README.md",
53
+ "README.ar.md",
54
+ "LICENSE"
55
+ ],
56
+ "engines": {
57
+ "node": ">=18.0.0"
58
+ },
59
+ "license": "MIT",
60
+ "dependencies": {
61
+ "bcryptjs": "^2.4.3",
62
+ "better-sqlite3": "^11.6.0",
63
+ "cors": "^2.8.5",
64
+ "dotenv": "^16.4.5",
65
+ "express": "^4.21.0",
66
+ "express-rate-limit": "^7.4.1",
67
+ "helmet": "^8.0.0",
68
+ "jsonwebtoken": "^9.0.2",
69
+ "nodemailer": "^8.0.3",
70
+ "stripe": "^20.4.1",
71
+ "uuid": "^10.0.0",
72
+ "ws": "^8.19.0"
73
+ },
74
+ "devDependencies": {
75
+ "jest": "^30.3.0",
76
+ "supertest": "^7.2.2"
77
+ }
78
+ }