web-agent-bridge 1.1.1 → 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 -94
  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 -181
  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 -329
  48. package/server/routes/license.js +240 -240
  49. package/server/routes/noscript.js +543 -543
  50. package/server/routes/wab-api.js +476 -476
  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 -555
  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
package/bin/cli.js CHANGED
@@ -1,80 +1,80 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * Web Agent Bridge CLI
5
- * Usage: npx web-agent-bridge [command]
6
- */
7
-
8
- const path = require('path');
9
- const fs = require('fs');
10
-
11
- const args = process.argv.slice(2);
12
- const command = args[0] || 'start';
13
-
14
- function printHelp() {
15
- console.log(`
16
- Web Agent Bridge CLI
17
-
18
- Usage:
19
- npx web-agent-bridge <command> [options]
20
-
21
- Commands:
22
- start Start the WAB server (default)
23
- init Create .env file from template
24
- help Show this help message
25
-
26
- Options:
27
- --port, -p Set server port (default: 3000)
28
-
29
- Examples:
30
- npx web-agent-bridge start
31
- npx web-agent-bridge start --port 4000
32
- npx web-agent-bridge init
33
- `);
34
- }
35
-
36
- switch (command) {
37
- case 'start': {
38
- const portIdx = args.indexOf('--port') !== -1 ? args.indexOf('--port') : args.indexOf('-p');
39
- if (portIdx !== -1 && args[portIdx + 1]) {
40
- process.env.PORT = args[portIdx + 1];
41
- }
42
-
43
- const envPath = path.join(process.cwd(), '.env');
44
- if (fs.existsSync(envPath)) {
45
- require('dotenv').config({ path: envPath });
46
- }
47
-
48
- require('../server/index.js');
49
- break;
50
- }
51
-
52
- case 'init': {
53
- const envExample = path.join(__dirname, '..', '.env.example');
54
- const envTarget = path.join(process.cwd(), '.env');
55
-
56
- if (fs.existsSync(envTarget)) {
57
- console.log(' .env file already exists. Skipping.');
58
- } else if (fs.existsSync(envExample)) {
59
- fs.copyFileSync(envExample, envTarget);
60
- console.log(' Created .env file from template.');
61
- console.log(' Edit .env to set your JWT_SECRET before starting.');
62
- } else {
63
- const defaultEnv = 'PORT=3000\nJWT_SECRET=change-this-to-a-strong-random-secret-in-production\nNODE_ENV=development\n';
64
- fs.writeFileSync(envTarget, defaultEnv);
65
- console.log(' Created default .env file.');
66
- }
67
- break;
68
- }
69
-
70
- case 'help':
71
- case '--help':
72
- case '-h':
73
- printHelp();
74
- break;
75
-
76
- default:
77
- console.error(` Unknown command: ${command}`);
78
- printHelp();
79
- process.exit(1);
80
- }
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Web Agent Bridge CLI
5
+ * Usage: npx web-agent-bridge [command]
6
+ */
7
+
8
+ const path = require('path');
9
+ const fs = require('fs');
10
+
11
+ const args = process.argv.slice(2);
12
+ const command = args[0] || 'start';
13
+
14
+ function printHelp() {
15
+ console.log(`
16
+ Web Agent Bridge CLI
17
+
18
+ Usage:
19
+ npx web-agent-bridge <command> [options]
20
+
21
+ Commands:
22
+ start Start the WAB server (default)
23
+ init Create .env file from template
24
+ help Show this help message
25
+
26
+ Options:
27
+ --port, -p Set server port (default: 3000)
28
+
29
+ Examples:
30
+ npx web-agent-bridge start
31
+ npx web-agent-bridge start --port 4000
32
+ npx web-agent-bridge init
33
+ `);
34
+ }
35
+
36
+ switch (command) {
37
+ case 'start': {
38
+ const portIdx = args.indexOf('--port') !== -1 ? args.indexOf('--port') : args.indexOf('-p');
39
+ if (portIdx !== -1 && args[portIdx + 1]) {
40
+ process.env.PORT = args[portIdx + 1];
41
+ }
42
+
43
+ const envPath = path.join(process.cwd(), '.env');
44
+ if (fs.existsSync(envPath)) {
45
+ require('dotenv').config({ path: envPath });
46
+ }
47
+
48
+ require('../server/index.js');
49
+ break;
50
+ }
51
+
52
+ case 'init': {
53
+ const envExample = path.join(__dirname, '..', '.env.example');
54
+ const envTarget = path.join(process.cwd(), '.env');
55
+
56
+ if (fs.existsSync(envTarget)) {
57
+ console.log(' .env file already exists. Skipping.');
58
+ } else if (fs.existsSync(envExample)) {
59
+ fs.copyFileSync(envExample, envTarget);
60
+ console.log(' Created .env file from template.');
61
+ console.log(' Edit .env to set your JWT_SECRET before starting.');
62
+ } else {
63
+ const defaultEnv = 'PORT=3000\nJWT_SECRET=change-this-to-a-strong-random-secret-in-production\nNODE_ENV=development\n';
64
+ fs.writeFileSync(envTarget, defaultEnv);
65
+ console.log(' Created default .env file.');
66
+ }
67
+ break;
68
+ }
69
+
70
+ case 'help':
71
+ case '--help':
72
+ case '-h':
73
+ printHelp();
74
+ break;
75
+
76
+ default:
77
+ console.error(` Unknown command: ${command}`);
78
+ printHelp();
79
+ process.exit(1);
80
+ }
package/bin/wab.js CHANGED
@@ -1,80 +1,80 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * Web Agent Bridge CLI
5
- * Usage: npx web-agent-bridge [command]
6
- */
7
-
8
- const path = require('path');
9
- const fs = require('fs');
10
-
11
- const args = process.argv.slice(2);
12
- const command = args[0] || 'start';
13
-
14
- function printHelp() {
15
- console.log(`
16
- Web Agent Bridge CLI
17
-
18
- Usage:
19
- npx web-agent-bridge <command> [options]
20
-
21
- Commands:
22
- start Start the WAB server (default)
23
- init Create .env file from template
24
- help Show this help message
25
-
26
- Options:
27
- --port, -p Set server port (default: 3000)
28
-
29
- Examples:
30
- npx web-agent-bridge start
31
- npx web-agent-bridge start --port 4000
32
- npx web-agent-bridge init
33
- `);
34
- }
35
-
36
- switch (command) {
37
- case 'start': {
38
- const portIdx = args.indexOf('--port') !== -1 ? args.indexOf('--port') : args.indexOf('-p');
39
- if (portIdx !== -1 && args[portIdx + 1]) {
40
- process.env.PORT = args[portIdx + 1];
41
- }
42
-
43
- const envPath = path.join(process.cwd(), '.env');
44
- if (fs.existsSync(envPath)) {
45
- require('dotenv').config({ path: envPath });
46
- }
47
-
48
- require('../server/index.js');
49
- break;
50
- }
51
-
52
- case 'init': {
53
- const envExample = path.join(__dirname, '..', '.env.example');
54
- const envTarget = path.join(process.cwd(), '.env');
55
-
56
- if (fs.existsSync(envTarget)) {
57
- console.log(' .env file already exists. Skipping.');
58
- } else if (fs.existsSync(envExample)) {
59
- fs.copyFileSync(envExample, envTarget);
60
- console.log(' Created .env file from template.');
61
- console.log(' Edit .env to set your JWT_SECRET before starting.');
62
- } else {
63
- const defaultEnv = 'PORT=3000\nJWT_SECRET=change-this-to-a-strong-random-secret-in-production\nNODE_ENV=development\n';
64
- fs.writeFileSync(envTarget, defaultEnv);
65
- console.log(' Created default .env file.');
66
- }
67
- break;
68
- }
69
-
70
- case 'help':
71
- case '--help':
72
- case '-h':
73
- printHelp();
74
- break;
75
-
76
- default:
77
- console.error(` Unknown command: ${command}`);
78
- printHelp();
79
- process.exit(1);
80
- }
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Web Agent Bridge CLI
5
+ * Usage: npx web-agent-bridge [command]
6
+ */
7
+
8
+ const path = require('path');
9
+ const fs = require('fs');
10
+
11
+ const args = process.argv.slice(2);
12
+ const command = args[0] || 'start';
13
+
14
+ function printHelp() {
15
+ console.log(`
16
+ Web Agent Bridge CLI
17
+
18
+ Usage:
19
+ npx web-agent-bridge <command> [options]
20
+
21
+ Commands:
22
+ start Start the WAB server (default)
23
+ init Create .env file from template
24
+ help Show this help message
25
+
26
+ Options:
27
+ --port, -p Set server port (default: 3000)
28
+
29
+ Examples:
30
+ npx web-agent-bridge start
31
+ npx web-agent-bridge start --port 4000
32
+ npx web-agent-bridge init
33
+ `);
34
+ }
35
+
36
+ switch (command) {
37
+ case 'start': {
38
+ const portIdx = args.indexOf('--port') !== -1 ? args.indexOf('--port') : args.indexOf('-p');
39
+ if (portIdx !== -1 && args[portIdx + 1]) {
40
+ process.env.PORT = args[portIdx + 1];
41
+ }
42
+
43
+ const envPath = path.join(process.cwd(), '.env');
44
+ if (fs.existsSync(envPath)) {
45
+ require('dotenv').config({ path: envPath });
46
+ }
47
+
48
+ require('../server/index.js');
49
+ break;
50
+ }
51
+
52
+ case 'init': {
53
+ const envExample = path.join(__dirname, '..', '.env.example');
54
+ const envTarget = path.join(process.cwd(), '.env');
55
+
56
+ if (fs.existsSync(envTarget)) {
57
+ console.log(' .env file already exists. Skipping.');
58
+ } else if (fs.existsSync(envExample)) {
59
+ fs.copyFileSync(envExample, envTarget);
60
+ console.log(' Created .env file from template.');
61
+ console.log(' Edit .env to set your JWT_SECRET before starting.');
62
+ } else {
63
+ const defaultEnv = 'PORT=3000\nJWT_SECRET=change-this-to-a-strong-random-secret-in-production\nNODE_ENV=development\n';
64
+ fs.writeFileSync(envTarget, defaultEnv);
65
+ console.log(' Created default .env file.');
66
+ }
67
+ break;
68
+ }
69
+
70
+ case 'help':
71
+ case '--help':
72
+ case '-h':
73
+ printHelp();
74
+ break;
75
+
76
+ default:
77
+ console.error(` Unknown command: ${command}`);
78
+ printHelp();
79
+ process.exit(1);
80
+ }
package/docs/DEPLOY.md CHANGED
@@ -1,118 +1,118 @@
1
- # Deploying Web Agent Bridge to your server
2
-
3
- The code is on GitHub (`master`). **You** deploy by SSH-ing into your VPS and pulling + restarting the app.
4
-
5
- ## Prerequisites
6
-
7
- - Ubuntu/Debian (or similar) with Docker **or** Node.js 20+
8
- - Firewall: open port **3000** (or your reverse proxy port 80/443)
9
- - Strong `JWT_SECRET` and `JWT_SECRET_ADMIN` in production (never commit them)
10
-
11
- ---
12
-
13
- ## Option A — Docker Compose (recommended)
14
-
15
- On the server, first time:
16
-
17
- ```bash
18
- cd /opt # or your preferred path
19
- git clone https://github.com/abokenan444/web-agent-bridge.git
20
- cd web-agent-bridge
21
- cp .env.example .env # if present; else create .env with secrets and PORT
22
- # Edit .env: JWT_SECRET=... JWT_SECRET_ADMIN=... PORT=3000
23
- docker compose up -d --build
24
- ```
25
-
26
- Updates:
27
-
28
- ```bash
29
- cd /path/to/web-agent-bridge
30
- git pull origin master
31
- docker compose up -d --build
32
- ```
33
-
34
- Data persists in the Docker volume `wab-data` (SQLite under `/app/data` in the container).
35
-
36
- ---
37
-
38
- ## Option B — Node.js (no Docker)
39
-
40
- ```bash
41
- cd /path/to/web-agent-bridge
42
- git pull origin master
43
- npm ci --production
44
- export NODE_ENV=production
45
- export JWT_SECRET="your-long-random-secret"
46
- export JWT_SECRET_ADMIN="your-different-long-random-secret"
47
- export PORT=3000
48
- node server/index.js
49
- ```
50
-
51
- Use **systemd**, **PM2**, or **screen/tmux** to keep the process running.
52
-
53
- Example **PM2**:
54
-
55
- ```bash
56
- npm ci --production
57
- pm2 start server/index.js --name wab
58
- pm2 save
59
- ```
60
-
61
- After `git pull`:
62
-
63
- ```bash
64
- npm ci --production
65
- pm2 restart wab
66
- ```
67
-
68
- ---
69
-
70
- ## Reverse proxy (HTTPS)
71
-
72
- Put **Nginx** or **Caddy** in front of `127.0.0.1:3000` and obtain TLS certificates (Let’s Encrypt).
73
-
74
- Example Nginx location:
75
-
76
- ```nginx
77
- location / {
78
- proxy_pass http://127.0.0.1:3000;
79
- proxy_http_version 1.1;
80
- proxy_set_header Host $host;
81
- proxy_set_header X-Real-IP $remote_addr;
82
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
83
- proxy_set_header X-Forwarded-Proto $scheme;
84
- }
85
- ```
86
-
87
- ---
88
-
89
- ## WordPress plugin
90
-
91
- Upload `web-agent-bridge-wordpress/` to the WordPress server (`wp-content/plugins/`) or sync via SFTP/rsync. Point **WAB API base URL** to your public URL (e.g. `https://wab.example.com`).
92
-
93
- ---
94
-
95
- ## Why we do **not** recommend auto-deploy from this public repo
96
-
97
- This project is **open source**. Wiring GitHub Actions (or similar) so that every push to `main`/`master` deploys to your production server is **high risk**:
98
-
99
- | Risk | Why it matters |
100
- |------|----------------|
101
- | **Supply chain** | Anyone who can merge code (or bypass reviews) can change what runs on your server. |
102
- | **Fork / PR abuse** | CI that builds untrusted PRs with secrets in scope has led to credential theft. |
103
- | **Secret leakage** | Deploy keys and SSH keys in CI are juicy targets; misconfiguration exposes them in logs or artifacts. |
104
- | **Public visibility** | Attackers see your pipeline definition and know exactly how prod is updated. |
105
-
106
- **Recommended for operators:** deploy **manually** after you review changes (SSH → `git pull` → rebuild), or use a **private** deployment path (e.g. internal CI, private mirror, or release artifacts you promote by hand).
107
-
108
- **If you must automate** (enterprise, private fork only): use a **private** repo or private runners, **branch protection**, required reviews, **deploy only from signed tags** or approved releases—not raw `main`—and never store production SSH keys in workflows reachable from public PR builds.
109
-
110
- This repository intentionally does **not** ship a “deploy to production on push” workflow.
111
-
112
- ---
113
-
114
- ## Checklist after deploy
115
-
116
- - [ ] `curl -s https://your-domain/api/license/verify` returns JSON (POST with body) or app responds on `/`
117
- - [ ] `https://your-domain/script/ai-agent-bridge.js` loads
118
- - [ ] `.env` / `JWT_SECRET` / `JWT_SECRET_ADMIN` not exposed in git
1
+ # Deploying Web Agent Bridge to your server
2
+
3
+ The code is on GitHub (`master`). **You** deploy by SSH-ing into your VPS and pulling + restarting the app.
4
+
5
+ ## Prerequisites
6
+
7
+ - Ubuntu/Debian (or similar) with Docker **or** Node.js 20+
8
+ - Firewall: open port **3000** (or your reverse proxy port 80/443)
9
+ - Strong `JWT_SECRET` and `JWT_SECRET_ADMIN` in production (never commit them)
10
+
11
+ ---
12
+
13
+ ## Option A — Docker Compose (recommended)
14
+
15
+ On the server, first time:
16
+
17
+ ```bash
18
+ cd /opt # or your preferred path
19
+ git clone https://github.com/abokenan444/web-agent-bridge.git
20
+ cd web-agent-bridge
21
+ cp .env.example .env # if present; else create .env with secrets and PORT
22
+ # Edit .env: JWT_SECRET=... JWT_SECRET_ADMIN=... PORT=3000
23
+ docker compose up -d --build
24
+ ```
25
+
26
+ Updates:
27
+
28
+ ```bash
29
+ cd /path/to/web-agent-bridge
30
+ git pull origin master
31
+ docker compose up -d --build
32
+ ```
33
+
34
+ Data persists in the Docker volume `wab-data` (SQLite under `/app/data` in the container).
35
+
36
+ ---
37
+
38
+ ## Option B — Node.js (no Docker)
39
+
40
+ ```bash
41
+ cd /path/to/web-agent-bridge
42
+ git pull origin master
43
+ npm ci --production
44
+ export NODE_ENV=production
45
+ export JWT_SECRET="your-long-random-secret"
46
+ export JWT_SECRET_ADMIN="your-different-long-random-secret"
47
+ export PORT=3000
48
+ node server/index.js
49
+ ```
50
+
51
+ Use **systemd**, **PM2**, or **screen/tmux** to keep the process running.
52
+
53
+ Example **PM2**:
54
+
55
+ ```bash
56
+ npm ci --production
57
+ pm2 start server/index.js --name wab
58
+ pm2 save
59
+ ```
60
+
61
+ After `git pull`:
62
+
63
+ ```bash
64
+ npm ci --production
65
+ pm2 restart wab
66
+ ```
67
+
68
+ ---
69
+
70
+ ## Reverse proxy (HTTPS)
71
+
72
+ Put **Nginx** or **Caddy** in front of `127.0.0.1:3000` and obtain TLS certificates (Let’s Encrypt).
73
+
74
+ Example Nginx location:
75
+
76
+ ```nginx
77
+ location / {
78
+ proxy_pass http://127.0.0.1:3000;
79
+ proxy_http_version 1.1;
80
+ proxy_set_header Host $host;
81
+ proxy_set_header X-Real-IP $remote_addr;
82
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
83
+ proxy_set_header X-Forwarded-Proto $scheme;
84
+ }
85
+ ```
86
+
87
+ ---
88
+
89
+ ## WordPress plugin
90
+
91
+ Upload `web-agent-bridge-wordpress/` to the WordPress server (`wp-content/plugins/`) or sync via SFTP/rsync. Point **WAB API base URL** to your public URL (e.g. `https://wab.example.com`).
92
+
93
+ ---
94
+
95
+ ## Why we do **not** recommend auto-deploy from this public repo
96
+
97
+ This project is **open source**. Wiring GitHub Actions (or similar) so that every push to `main`/`master` deploys to your production server is **high risk**:
98
+
99
+ | Risk | Why it matters |
100
+ |------|----------------|
101
+ | **Supply chain** | Anyone who can merge code (or bypass reviews) can change what runs on your server. |
102
+ | **Fork / PR abuse** | CI that builds untrusted PRs with secrets in scope has led to credential theft. |
103
+ | **Secret leakage** | Deploy keys and SSH keys in CI are juicy targets; misconfiguration exposes them in logs or artifacts. |
104
+ | **Public visibility** | Attackers see your pipeline definition and know exactly how prod is updated. |
105
+
106
+ **Recommended for operators:** deploy **manually** after you review changes (SSH → `git pull` → rebuild), or use a **private** deployment path (e.g. internal CI, private mirror, or release artifacts you promote by hand).
107
+
108
+ **If you must automate** (enterprise, private fork only): use a **private** repo or private runners, **branch protection**, required reviews, **deploy only from signed tags** or approved releases—not raw `main`—and never store production SSH keys in workflows reachable from public PR builds.
109
+
110
+ This repository intentionally does **not** ship a “deploy to production on push” workflow.
111
+
112
+ ---
113
+
114
+ ## Checklist after deploy
115
+
116
+ - [ ] `curl -s https://your-domain/api/license/verify` returns JSON (POST with body) or app responds on `/`
117
+ - [ ] `https://your-domain/script/ai-agent-bridge.js` loads
118
+ - [ ] `.env` / `JWT_SECRET` / `JWT_SECRET_ADMIN` not exposed in git