web-agent-bridge 1.2.0 → 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 -933
  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
package/sdk/README.md CHANGED
@@ -1,55 +1,55 @@
1
- # WAB Agent SDK
2
-
3
- SDK for building AI agents that interact with [Web Agent Bridge](https://github.com/abokenan444/web-agent-bridge).
4
-
5
- ## Quick Start
6
-
7
- ```javascript
8
- const puppeteer = require('puppeteer');
9
- const { WABAgent } = require('web-agent-bridge/sdk');
10
-
11
- const browser = await puppeteer.launch();
12
- const page = await browser.newPage();
13
-
14
- const agent = new WABAgent(page);
15
- await agent.navigateAndWait('https://example.com');
16
-
17
- // Discover available actions
18
- const actions = await agent.getActions();
19
- console.log(actions);
20
-
21
- // Execute an action
22
- const result = await agent.execute('signup', { email: 'user@example.com' });
23
-
24
- // Read page content
25
- const content = await agent.readContent('h1');
26
-
27
- await browser.close();
28
- ```
29
-
30
- ## BiDi Mode
31
-
32
- ```javascript
33
- const agent = new WABAgent(page, { useBiDi: true });
34
- await agent.waitForBridge();
35
-
36
- const context = await agent.getBiDiContext();
37
- const actions = await agent.getActions();
38
- await agent.execute('click-login');
39
- ```
40
-
41
- ## API
42
-
43
- | Method | Description |
44
- |---|---|
45
- | `waitForBridge()` | Wait for WAB to load on the page |
46
- | `hasBridge()` | Check if WAB is available |
47
- | `getActions(category?)` | List available actions |
48
- | `getAction(name)` | Get a specific action |
49
- | `execute(name, params?)` | Execute an action |
50
- | `readContent(selector)` | Read element text content |
51
- | `getPageInfo()` | Get page metadata |
52
- | `authenticate(apiKey, meta?)` | Authenticate the agent |
53
- | `navigateAndWait(url)` | Navigate and wait for bridge |
54
- | `executeSteps(steps)` | Execute multiple actions in sequence |
55
- | `getBiDiContext()` | Get BiDi context (BiDi mode only) |
1
+ # WAB Agent SDK
2
+
3
+ SDK for building AI agents that interact with [Web Agent Bridge](https://github.com/abokenan444/web-agent-bridge).
4
+
5
+ ## Quick Start
6
+
7
+ ```javascript
8
+ const puppeteer = require('puppeteer');
9
+ const { WABAgent } = require('web-agent-bridge/sdk');
10
+
11
+ const browser = await puppeteer.launch();
12
+ const page = await browser.newPage();
13
+
14
+ const agent = new WABAgent(page);
15
+ await agent.navigateAndWait('https://example.com');
16
+
17
+ // Discover available actions
18
+ const actions = await agent.getActions();
19
+ console.log(actions);
20
+
21
+ // Execute an action
22
+ const result = await agent.execute('signup', { email: 'user@example.com' });
23
+
24
+ // Read page content
25
+ const content = await agent.readContent('h1');
26
+
27
+ await browser.close();
28
+ ```
29
+
30
+ ## BiDi Mode
31
+
32
+ ```javascript
33
+ const agent = new WABAgent(page, { useBiDi: true });
34
+ await agent.waitForBridge();
35
+
36
+ const context = await agent.getBiDiContext();
37
+ const actions = await agent.getActions();
38
+ await agent.execute('click-login');
39
+ ```
40
+
41
+ ## API
42
+
43
+ | Method | Description |
44
+ |---|---|
45
+ | `waitForBridge()` | Wait for WAB to load on the page |
46
+ | `hasBridge()` | Check if WAB is available |
47
+ | `getActions(category?)` | List available actions |
48
+ | `getAction(name)` | Get a specific action |
49
+ | `execute(name, params?)` | Execute an action |
50
+ | `readContent(selector)` | Read element text content |
51
+ | `getPageInfo()` | Get page metadata |
52
+ | `authenticate(apiKey, meta?)` | Authenticate the agent |
53
+ | `navigateAndWait(url)` | Navigate and wait for bridge |
54
+ | `executeSteps(steps)` | Execute multiple actions in sequence |
55
+ | `getBiDiContext()` | Get BiDi context (BiDi mode only) |
package/sdk/index.d.ts ADDED
@@ -0,0 +1,118 @@
1
+ /**
2
+ * WAB Agent SDK — TypeScript definitions.
3
+ */
4
+
5
+ export interface WABAgentOptions {
6
+ /** Default timeout in ms (default 10000). */
7
+ timeout?: number;
8
+ /** Use BiDi interface instead of AICommands. */
9
+ useBiDi?: boolean;
10
+ }
11
+
12
+ export interface WABActionDescriptor {
13
+ name: string;
14
+ description?: string;
15
+ category?: string;
16
+ params?: Array<{
17
+ name: string;
18
+ type?: string;
19
+ required?: boolean;
20
+ description?: string;
21
+ label?: string;
22
+ }>;
23
+ [key: string]: unknown;
24
+ }
25
+
26
+ export interface WABExecuteResult {
27
+ ok: boolean;
28
+ action?: string;
29
+ status?: string;
30
+ data?: unknown;
31
+ [key: string]: unknown;
32
+ }
33
+
34
+ export interface WABPageInfo {
35
+ title?: string;
36
+ url?: string;
37
+ bridgeVersion?: string;
38
+ [key: string]: unknown;
39
+ }
40
+
41
+ export interface PipelineStep {
42
+ name: string;
43
+ params?: Record<string, unknown>;
44
+ }
45
+
46
+ export interface PipelineResult {
47
+ name: string;
48
+ ok: boolean;
49
+ result?: any;
50
+ error?: string;
51
+ }
52
+
53
+ export interface ParallelResult {
54
+ name: string;
55
+ status: 'fulfilled' | 'rejected';
56
+ value?: any;
57
+ reason?: string;
58
+ }
59
+
60
+ export interface RunPipelineOptions {
61
+ /** Stop on first error (default true). */
62
+ stopOnError?: boolean;
63
+ }
64
+
65
+ export declare class WABAgent {
66
+ constructor(page: any, options?: WABAgentOptions);
67
+
68
+ /** Wait for the WAB bridge to be ready on the page. */
69
+ waitForBridge(): Promise<boolean>;
70
+
71
+ /** Check if the bridge is loaded on the current page. */
72
+ hasBridge(): Promise<boolean>;
73
+
74
+ /** Get all available actions, optionally filtered by category. */
75
+ getActions(category?: string): Promise<WABActionDescriptor[]>;
76
+
77
+ /** Get a single action by name. */
78
+ getAction(name: string): Promise<WABActionDescriptor | null>;
79
+
80
+ /** Execute an action by name. */
81
+ execute(name: string, params?: Record<string, unknown>): Promise<WABExecuteResult>;
82
+
83
+ /** Read text content of an element. */
84
+ readContent(selector: string): Promise<{ text: string; [key: string]: unknown }>;
85
+
86
+ /** Get page info and bridge metadata. */
87
+ getPageInfo(): Promise<WABPageInfo>;
88
+
89
+ /** Authenticate an agent with the bridge. */
90
+ authenticate(apiKey: string, meta?: Record<string, unknown>): Promise<any>;
91
+
92
+ /** Navigate to a URL and wait for the bridge. */
93
+ navigateAndWait(url: string): Promise<void>;
94
+
95
+ /** Execute multiple actions in sequence. */
96
+ executeSteps(steps: PipelineStep[]): Promise<any[]>;
97
+
98
+ /** Get BiDi context (only available when useBiDi is true). */
99
+ getBiDiContext(): Promise<any>;
100
+
101
+ /** Check if the page has granted consent for agent interactions. */
102
+ hasConsent(): Promise<boolean>;
103
+
104
+ /** Wait until consent is granted (blocks until user clicks Allow). */
105
+ waitForConsent(pollMs?: number): Promise<boolean>;
106
+
107
+ /** Discover the page and return the list of actions. */
108
+ discover(): Promise<{ actions: WABActionDescriptor[]; meta?: WABPageInfo }>;
109
+
110
+ /** Run a sequence of actions, stopping on the first failure by default. */
111
+ runPipeline(steps: PipelineStep[], options?: RunPipelineOptions): Promise<PipelineResult[]>;
112
+
113
+ /** Execute multiple actions in parallel. */
114
+ executeParallel(actions: PipelineStep[]): Promise<ParallelResult[]>;
115
+
116
+ /** Take a screenshot and return as base64. */
117
+ screenshot(opts?: { fullPage?: boolean }): Promise<string>;
118
+ }