web-agent-bridge 1.0.0 → 1.1.1
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.
- package/README.ar.md +1 -1
- package/README.md +336 -36
- package/docs/DEPLOY.md +118 -0
- package/docs/SPEC.md +1540 -0
- package/examples/mcp-agent.js +94 -0
- package/examples/vision-agent.js +12 -0
- package/package.json +14 -3
- package/public/admin/dashboard.html +848 -0
- package/public/admin/login.html +84 -0
- package/public/cookies.html +208 -0
- package/public/css/premium.css +317 -0
- package/public/dashboard.html +138 -0
- package/public/docs.html +5 -2
- package/public/index.html +54 -28
- package/public/js/auth-nav.js +31 -0
- package/public/js/auth-redirect.js +12 -0
- package/public/js/cookie-consent.js +56 -0
- package/public/js/ws-client.js +74 -0
- package/public/login.html +4 -2
- package/public/premium-dashboard.html +2075 -0
- package/public/premium.html +791 -0
- package/public/privacy.html +295 -0
- package/public/register.html +11 -2
- package/public/terms.html +254 -0
- package/script/ai-agent-bridge.js +253 -22
- package/sdk/index.js +36 -0
- package/server/config/secrets.js +92 -0
- package/server/index.js +102 -26
- package/server/middleware/adminAuth.js +30 -0
- package/server/middleware/auth.js +4 -7
- package/server/middleware/rateLimits.js +24 -0
- package/server/migrations/001_add_analytics_indexes.sql +7 -0
- package/server/migrations/002_premium_features.sql +418 -0
- package/server/models/db.js +360 -4
- package/server/routes/admin.js +247 -0
- package/server/routes/api.js +26 -9
- package/server/routes/billing.js +45 -0
- package/server/routes/discovery.js +329 -0
- package/server/routes/license.js +200 -11
- package/server/routes/noscript.js +543 -0
- package/server/routes/premium.js +724 -0
- package/server/routes/wab-api.js +476 -0
- package/server/services/email.js +204 -0
- package/server/services/fairness.js +420 -0
- package/server/services/premium.js +1680 -0
- package/server/services/stripe.js +192 -0
- package/server/utils/cache.js +125 -0
- package/server/utils/migrate.js +81 -0
- package/server/utils/secureFields.js +50 -0
- package/server/ws.js +33 -13
- package/wab-mcp-adapter/README.md +136 -0
- package/wab-mcp-adapter/index.js +555 -0
- package/wab-mcp-adapter/package.json +17 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Example: Using WAB sites via the MCP adapter
|
|
3
|
+
*
|
|
4
|
+
* The WAB-MCP adapter exposes every WAB site action as an MCP tool,
|
|
5
|
+
* so any MCP-compatible AI agent (Claude, GPT, etc.) can interact
|
|
6
|
+
* with WAB-enabled websites through a uniform tool interface.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* node examples/mcp-agent.js <site-url>
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
const { WABMCPAdapter } = require('../wab-mcp-adapter');
|
|
13
|
+
|
|
14
|
+
const TARGET = process.argv[2] || 'http://localhost:3000';
|
|
15
|
+
|
|
16
|
+
async function main() {
|
|
17
|
+
console.log('\n WAB → MCP Adapter Demo');
|
|
18
|
+
console.log(` Target: ${TARGET}\n`);
|
|
19
|
+
|
|
20
|
+
const adapter = new WABMCPAdapter({
|
|
21
|
+
siteUrl: TARGET,
|
|
22
|
+
transport: 'http'
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
// Step 1: Discover site capabilities
|
|
26
|
+
console.log('1. Discovering WAB capabilities...');
|
|
27
|
+
const discovery = await adapter.discover();
|
|
28
|
+
if (discovery) {
|
|
29
|
+
console.log(` Provider: ${discovery.provider?.name || 'unknown'}`);
|
|
30
|
+
console.log(` Domain: ${discovery.provider?.domain || 'unknown'}`);
|
|
31
|
+
console.log(` Tier: ${discovery.capabilities?.tier || 'free'}`);
|
|
32
|
+
console.log(` Features: ${(discovery.capabilities?.features || []).join(', ')}`);
|
|
33
|
+
if (discovery.fairness) {
|
|
34
|
+
console.log(` Fairness: score=${discovery.fairness.neutrality_score}, independent=${discovery.fairness.is_independent}`);
|
|
35
|
+
}
|
|
36
|
+
} else {
|
|
37
|
+
console.log(' No discovery document found (site may not have WAB configured)');
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Step 2: List MCP tools
|
|
41
|
+
console.log('\n2. Available MCP tools:');
|
|
42
|
+
const tools = await adapter.getTools();
|
|
43
|
+
tools.forEach(tool => {
|
|
44
|
+
const params = tool.input_schema?.properties
|
|
45
|
+
? Object.keys(tool.input_schema.properties).join(', ')
|
|
46
|
+
: 'none';
|
|
47
|
+
console.log(` - ${tool.name}: ${tool.description} (params: ${params})`);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// Step 3: Execute built-in tools
|
|
51
|
+
console.log('\n3. Executing wab_get_page_info...');
|
|
52
|
+
try {
|
|
53
|
+
const infoResult = await adapter.executeTool('wab_get_page_info', {});
|
|
54
|
+
const info = infoResult.content;
|
|
55
|
+
if (infoResult.is_error) {
|
|
56
|
+
console.log(` Error: ${info.error}`);
|
|
57
|
+
} else {
|
|
58
|
+
console.log(` Title: ${info.title || 'N/A'}`);
|
|
59
|
+
console.log(` Version: ${info.bridgeVersion || 'N/A'}`);
|
|
60
|
+
console.log(` Domain: ${info.domain || 'N/A'}`);
|
|
61
|
+
}
|
|
62
|
+
} catch (err) {
|
|
63
|
+
console.log(` Error: ${err.message}`);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Step 4: Search the fairness registry
|
|
67
|
+
console.log('\n4. Fairness-weighted search (demo):');
|
|
68
|
+
try {
|
|
69
|
+
const searchResult = await adapter.executeTool('wab_fairness_search', {
|
|
70
|
+
query: 'e-commerce',
|
|
71
|
+
limit: 5
|
|
72
|
+
});
|
|
73
|
+
const search = searchResult.content;
|
|
74
|
+
if (searchResult.is_error) {
|
|
75
|
+
console.log(` Error: ${search.error}`);
|
|
76
|
+
} else if (search.results?.length) {
|
|
77
|
+
search.results.forEach(r => {
|
|
78
|
+
console.log(` - ${r.name} (${r.domain}) — score: ${r.final_score}`);
|
|
79
|
+
});
|
|
80
|
+
} else {
|
|
81
|
+
console.log(' No sites registered in directory yet.');
|
|
82
|
+
}
|
|
83
|
+
} catch (err) {
|
|
84
|
+
console.log(` Registry not available: ${err.message}`);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
console.log('\nDone. In a real MCP integration, these tools would be');
|
|
88
|
+
console.log('exposed to Claude/GPT via the MCP tool-use protocol.\n');
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
main().catch(err => {
|
|
92
|
+
console.error('Error:', err.message);
|
|
93
|
+
process.exit(1);
|
|
94
|
+
});
|
package/examples/vision-agent.js
CHANGED
|
@@ -8,6 +8,16 @@
|
|
|
8
8
|
* The agent describes what it wants to do in natural language,
|
|
9
9
|
* and the IntentResolver matches it to available WAB actions.
|
|
10
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
|
+
*
|
|
11
21
|
* Prerequisites:
|
|
12
22
|
* npm install puppeteer
|
|
13
23
|
*
|
|
@@ -20,6 +30,8 @@ const puppeteer = require('puppeteer');
|
|
|
20
30
|
const TARGET_URL = process.argv[2] || 'http://localhost:3000';
|
|
21
31
|
|
|
22
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.
|
|
23
35
|
class IntentResolver {
|
|
24
36
|
constructor(actions) {
|
|
25
37
|
this.actions = actions;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "web-agent-bridge",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "Open
|
|
3
|
+
"version": "1.1.1",
|
|
4
|
+
"description": "Open protocol and runtime for AI agents to interact with websites — standardized discovery, commands, and fairness layer for the Agentic Web",
|
|
5
5
|
"main": "server/index.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"web-agent-bridge": "./bin/cli.js",
|
|
@@ -18,12 +18,19 @@
|
|
|
18
18
|
"ai",
|
|
19
19
|
"agent",
|
|
20
20
|
"bridge",
|
|
21
|
+
"protocol",
|
|
22
|
+
"web-standard",
|
|
23
|
+
"mcp",
|
|
21
24
|
"automation",
|
|
22
25
|
"web",
|
|
23
26
|
"middleware",
|
|
24
27
|
"ai-agent",
|
|
25
28
|
"browser-automation",
|
|
26
|
-
"webdriver-bidi"
|
|
29
|
+
"webdriver-bidi",
|
|
30
|
+
"fairness",
|
|
31
|
+
"discovery",
|
|
32
|
+
"agentic-web",
|
|
33
|
+
"model-context-protocol"
|
|
27
34
|
],
|
|
28
35
|
"repository": {
|
|
29
36
|
"type": "git",
|
|
@@ -39,6 +46,8 @@
|
|
|
39
46
|
"public/",
|
|
40
47
|
"script/",
|
|
41
48
|
"sdk/",
|
|
49
|
+
"wab-mcp-adapter/",
|
|
50
|
+
"docs/",
|
|
42
51
|
"examples/",
|
|
43
52
|
"README.md",
|
|
44
53
|
"README.ar.md",
|
|
@@ -57,6 +66,8 @@
|
|
|
57
66
|
"express-rate-limit": "^7.4.1",
|
|
58
67
|
"helmet": "^8.0.0",
|
|
59
68
|
"jsonwebtoken": "^9.0.2",
|
|
69
|
+
"nodemailer": "^8.0.3",
|
|
70
|
+
"stripe": "^20.4.1",
|
|
60
71
|
"uuid": "^10.0.0",
|
|
61
72
|
"ws": "^8.19.0"
|
|
62
73
|
},
|