web-agent-bridge 2.3.0 → 2.4.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 (66) hide show
  1. package/README.ar.md +506 -31
  2. package/README.md +574 -47
  3. package/bin/agent-runner.js +10 -1
  4. package/package.json +12 -4
  5. package/public/agent-workspace.html +347 -0
  6. package/public/browser.html +484 -0
  7. package/public/commander-dashboard.html +243 -0
  8. package/public/css/agent-workspace.css +1713 -0
  9. package/public/css/premium.css +317 -317
  10. package/public/demo.html +259 -259
  11. package/public/index.html +738 -644
  12. package/public/js/agent-workspace.js +1740 -0
  13. package/public/mesh-dashboard.html +309 -382
  14. package/public/premium-dashboard.html +2487 -2487
  15. package/public/premium.html +791 -791
  16. package/public/script/wab.min.js +124 -87
  17. package/script/ai-agent-bridge.js +154 -84
  18. package/sdk/agent-mesh.js +287 -171
  19. package/sdk/commander.js +262 -0
  20. package/sdk/index.d.ts +83 -0
  21. package/sdk/index.js +374 -260
  22. package/sdk/package.json +1 -1
  23. package/server/config/secrets.js +13 -5
  24. package/server/index.js +191 -5
  25. package/server/middleware/adminAuth.js +6 -1
  26. package/server/middleware/auth.js +11 -2
  27. package/server/middleware/rateLimits.js +78 -2
  28. package/server/migrations/002_premium_features.sql +418 -418
  29. package/server/migrations/003_ads_integer_cents.sql +33 -0
  30. package/server/models/db.js +121 -1
  31. package/server/routes/admin-premium.js +671 -671
  32. package/server/routes/admin.js +16 -2
  33. package/server/routes/ads.js +130 -0
  34. package/server/routes/agent-workspace.js +378 -0
  35. package/server/routes/api.js +21 -2
  36. package/server/routes/auth.js +26 -6
  37. package/server/routes/commander.js +316 -0
  38. package/server/routes/mesh.js +370 -201
  39. package/server/routes/premium-v2.js +686 -686
  40. package/server/routes/premium.js +724 -724
  41. package/server/routes/sovereign.js +78 -0
  42. package/server/routes/universal.js +177 -0
  43. package/server/routes/wab-api.js +20 -5
  44. package/server/services/agent-chat.js +506 -0
  45. package/server/services/agent-learning.js +230 -77
  46. package/server/services/agent-memory.js +625 -625
  47. package/server/services/agent-mesh.js +260 -67
  48. package/server/services/agent-symphony.js +553 -517
  49. package/server/services/agent-tasks.js +1807 -0
  50. package/server/services/commander.js +738 -0
  51. package/server/services/edge-compute.js +440 -0
  52. package/server/services/fairness-engine.js +409 -0
  53. package/server/services/local-ai.js +389 -0
  54. package/server/services/plugins.js +771 -747
  55. package/server/services/price-intelligence.js +565 -0
  56. package/server/services/price-shield.js +1137 -0
  57. package/server/services/search-engine.js +357 -0
  58. package/server/services/security.js +513 -0
  59. package/server/services/self-healing.js +843 -843
  60. package/server/services/swarm.js +788 -788
  61. package/server/services/universal-scraper.js +661 -0
  62. package/server/services/vision.js +871 -871
  63. package/server/ws.js +61 -1
  64. package/public/admin/dashboard.html +0 -848
  65. package/public/admin/login.html +0 -84
  66. package/public/video/tutorial.mp4 +0 -0
package/sdk/index.js CHANGED
@@ -1,260 +1,374 @@
1
- /**
2
- * WAB Agent SDK
3
- *
4
- * Helpers for building AI agents that interact with Web Agent Bridge.
5
- * Works with Puppeteer, Playwright, or any browser automation tool.
6
- *
7
- * Usage:
8
- * const { WABAgent } = require('./sdk');
9
- * const agent = new WABAgent(page);
10
- * await agent.waitForBridge();
11
- * const actions = await agent.getActions();
12
- * await agent.execute('signup', { email: 'test@example.com' });
13
- */
14
-
15
- class WABAgent {
16
- /**
17
- * @param {object} page — A Puppeteer or Playwright page object
18
- * @param {object} [options]
19
- * @param {number} [options.timeout=10000] — Default timeout in ms
20
- * @param {boolean} [options.useBiDi=false] — Use BiDi interface instead of AICommands
21
- */
22
- constructor(page, options = {}) {
23
- this.page = page;
24
- this.timeout = options.timeout || 10000;
25
- this.useBiDi = options.useBiDi || false;
26
- this._biDiId = 0;
27
- }
28
-
29
- /**
30
- * Wait for the WAB bridge to be ready on the page.
31
- * @returns {Promise<boolean>}
32
- */
33
- async waitForBridge() {
34
- const iface = this.useBiDi ? '__wab_bidi' : 'AICommands';
35
- await this.page.waitForFunction(
36
- (name) => typeof window[name] !== 'undefined',
37
- { timeout: this.timeout },
38
- iface
39
- );
40
- return true;
41
- }
42
-
43
- /**
44
- * Check if the bridge is loaded on the current page.
45
- * @returns {Promise<boolean>}
46
- */
47
- async hasBridge() {
48
- const iface = this.useBiDi ? '__wab_bidi' : 'AICommands';
49
- return this.page.evaluate((name) => typeof window[name] !== 'undefined', iface);
50
- }
51
-
52
- /**
53
- * Get all available actions.
54
- * @param {string} [category] — Optional category filter
55
- * @returns {Promise<Array>}
56
- */
57
- async getActions(category) {
58
- if (this.useBiDi) {
59
- const result = await this._bidiSend('wab.getActions', category ? { category } : {});
60
- return result.result || [];
61
- }
62
- return this.page.evaluate((cat) => window.AICommands.getActions(cat), category);
63
- }
64
-
65
- /**
66
- * Get a single action by name.
67
- * @param {string} name
68
- * @returns {Promise<object|null>}
69
- */
70
- async getAction(name) {
71
- return this.page.evaluate((n) => window.AICommands.getAction(n), name);
72
- }
73
-
74
- /**
75
- * Execute an action by name.
76
- * @param {string} name — Action name
77
- * @param {object} [params] — Action parameters
78
- * @returns {Promise<object>}
79
- */
80
- async execute(name, params) {
81
- if (this.useBiDi) {
82
- const result = await this._bidiSend('wab.executeAction', { name, data: params || {} });
83
- return result.result || result;
84
- }
85
- return this.page.evaluate(
86
- (n, p) => window.AICommands.execute(n, p),
87
- name, params
88
- );
89
- }
90
-
91
- /**
92
- * Read text content of an element.
93
- * @param {string} selector — CSS selector
94
- * @returns {Promise<object>}
95
- */
96
- async readContent(selector) {
97
- if (this.useBiDi) {
98
- const result = await this._bidiSend('wab.readContent', { selector });
99
- return result.result || result;
100
- }
101
- return this.page.evaluate((sel) => window.AICommands.readContent(sel), selector);
102
- }
103
-
104
- /**
105
- * Get page info and bridge metadata.
106
- * @returns {Promise<object>}
107
- */
108
- async getPageInfo() {
109
- if (this.useBiDi) {
110
- const result = await this._bidiSend('wab.getPageInfo');
111
- return result.result || result;
112
- }
113
- return this.page.evaluate(() => window.AICommands.getPageInfo());
114
- }
115
-
116
- /**
117
- * Authenticate an agent with the bridge.
118
- * @param {string} apiKey
119
- * @param {object} [meta] — Agent metadata
120
- * @returns {Promise<object>}
121
- */
122
- async authenticate(apiKey, meta) {
123
- return this.page.evaluate(
124
- (key, m) => window.AICommands.authenticate(key, m),
125
- apiKey, meta
126
- );
127
- }
128
-
129
- /**
130
- * Navigate to a URL and wait for the bridge.
131
- * @param {string} url
132
- * @returns {Promise<void>}
133
- */
134
- async navigateAndWait(url) {
135
- await this.page.goto(url, { waitUntil: 'networkidle2' });
136
- await this.waitForBridge();
137
- }
138
-
139
- /**
140
- * Execute multiple actions in sequence.
141
- * @param {Array<{name: string, params?: object}>} steps
142
- * @returns {Promise<Array>}
143
- */
144
- async executeSteps(steps) {
145
- const results = [];
146
- for (const step of steps) {
147
- results.push(await this.execute(step.name, step.params));
148
- }
149
- return results;
150
- }
151
-
152
- /**
153
- * Get BiDi context (only available when useBiDi is true).
154
- * @returns {Promise<object>}
155
- */
156
- async getBiDiContext() {
157
- return this.page.evaluate(() => window.__wab_bidi.getContext());
158
- }
159
-
160
- /**
161
- * Check if the page has granted consent for agent interactions.
162
- * @returns {Promise<boolean>}
163
- */
164
- async hasConsent() {
165
- return this.page.evaluate(() => {
166
- if (typeof window.WABConsent !== 'undefined') return window.WABConsent.hasConsent();
167
- // If no consent script, treat as allowed
168
- return true;
169
- });
170
- }
171
-
172
- /**
173
- * Wait until consent is granted (blocks until user clicks Allow).
174
- * @param {number} [pollMs=500]
175
- * @returns {Promise<boolean>}
176
- */
177
- async waitForConsent(pollMs = 500) {
178
- return this.page.waitForFunction(
179
- () => {
180
- if (typeof window.WABConsent === 'undefined') return true;
181
- return window.WABConsent.hasConsent();
182
- },
183
- { timeout: this.timeout, polling: pollMs }
184
- ).then(() => true);
185
- }
186
-
187
- /**
188
- * Discover the page and return the list of actions.
189
- * Combines bridge discovery with runtime getActions().
190
- * @returns {Promise<object>}
191
- */
192
- async discover() {
193
- return this.page.evaluate(() => {
194
- if (window.WAB && typeof window.WAB.discover === 'function') return window.WAB.discover();
195
- if (window.AICommands && typeof window.AICommands.getActions === 'function') {
196
- return { actions: window.AICommands.getActions(), meta: window.AICommands.getPageInfo ? window.AICommands.getPageInfo() : {} };
197
- }
198
- return { actions: [] };
199
- });
200
- }
201
-
202
- /**
203
- * Run a sequence of actions, stopping on the first failure.
204
- * @param {Array<{name: string, params?: object}>} steps
205
- * @param {{ stopOnError?: boolean }} [options]
206
- * @returns {Promise<Array<{ name: string, ok: boolean, result?: any, error?: string }>>}
207
- */
208
- async runPipeline(steps, options = {}) {
209
- const stopOnError = options.stopOnError !== false;
210
- const results = [];
211
- for (const step of steps) {
212
- try {
213
- const res = await this.execute(step.name, step.params);
214
- results.push({ name: step.name, ok: true, result: res });
215
- } catch (err) {
216
- results.push({ name: step.name, ok: false, error: err.message || String(err) });
217
- if (stopOnError) break;
218
- }
219
- }
220
- return results;
221
- }
222
-
223
- /**
224
- * Execute multiple actions in parallel.
225
- * @param {Array<{name: string, params?: object}>} actions
226
- * @returns {Promise<Array<{ name: string, status: string, value?: any, reason?: string }>>}
227
- */
228
- async executeParallel(actions) {
229
- const promises = actions.map((a) =>
230
- this.execute(a.name, a.params)
231
- .then((value) => ({ name: a.name, status: 'fulfilled', value }))
232
- .catch((err) => ({ name: a.name, status: 'rejected', reason: err.message || String(err) }))
233
- );
234
- return Promise.all(promises);
235
- }
236
-
237
- /**
238
- * Take a screenshot and return as base64 (useful for vision agents).
239
- * @param {{ fullPage?: boolean }} [opts]
240
- * @returns {Promise<string>}
241
- */
242
- async screenshot(opts = {}) {
243
- const buf = await this.page.screenshot({
244
- encoding: 'base64',
245
- fullPage: opts.fullPage || false
246
- });
247
- return buf;
248
- }
249
-
250
- /** @private */
251
- async _bidiSend(method, params = {}) {
252
- const cmd = { id: ++this._biDiId, method, params };
253
- return this.page.evaluate((c) => window.__wab_bidi.send(c), cmd);
254
- }
255
- }
256
-
257
- const { WABMultiAgent } = require('./multi-agent');
258
- const { WABAgentMesh } = require('./agent-mesh');
259
-
260
- module.exports = { WABAgent, WABMultiAgent, WABAgentMesh };
1
+ /**
2
+ * WAB Agent SDK
3
+ *
4
+ * Helpers for building AI agents that interact with Web Agent Bridge.
5
+ * Works with Puppeteer, Playwright, or any browser automation tool.
6
+ *
7
+ * Usage:
8
+ * const { WABAgent } = require('./sdk');
9
+ * const agent = new WABAgent(page);
10
+ * await agent.waitForBridge();
11
+ * const actions = await agent.getActions();
12
+ * await agent.execute('signup', { email: 'test@example.com' });
13
+ */
14
+
15
+ class WABAgent {
16
+ /**
17
+ * @param {object} page — A Puppeteer or Playwright page object
18
+ * @param {object} [options]
19
+ * @param {number} [options.timeout=10000] — Default timeout in ms
20
+ * @param {boolean} [options.useBiDi=false] — Use BiDi interface instead of AICommands
21
+ */
22
+ constructor(page, options = {}) {
23
+ this.page = page;
24
+ this.timeout = options.timeout || 10000;
25
+ this.useBiDi = options.useBiDi || false;
26
+ this._biDiId = 0;
27
+ }
28
+
29
+ /**
30
+ * Wait for the WAB bridge to be ready on the page.
31
+ * @returns {Promise<boolean>}
32
+ */
33
+ async waitForBridge() {
34
+ const iface = this.useBiDi ? '__wab_bidi' : 'AICommands';
35
+ await this.page.waitForFunction(
36
+ (name) => typeof window[name] !== 'undefined',
37
+ { timeout: this.timeout },
38
+ iface
39
+ );
40
+ return true;
41
+ }
42
+
43
+ /**
44
+ * Check if the bridge is loaded on the current page.
45
+ * @returns {Promise<boolean>}
46
+ */
47
+ async hasBridge() {
48
+ const iface = this.useBiDi ? '__wab_bidi' : 'AICommands';
49
+ return this.page.evaluate((name) => typeof window[name] !== 'undefined', iface);
50
+ }
51
+
52
+ /**
53
+ * Get all available actions.
54
+ * @param {string} [category] — Optional category filter
55
+ * @returns {Promise<Array>}
56
+ */
57
+ async getActions(category) {
58
+ if (this.useBiDi) {
59
+ const result = await this._bidiSend('wab.getActions', category ? { category } : {});
60
+ return result.result || [];
61
+ }
62
+ return this.page.evaluate((cat) => window.AICommands.getActions(cat), category);
63
+ }
64
+
65
+ /**
66
+ * Get a single action by name.
67
+ * @param {string} name
68
+ * @returns {Promise<object|null>}
69
+ */
70
+ async getAction(name) {
71
+ return this.page.evaluate((n) => window.AICommands.getAction(n), name);
72
+ }
73
+
74
+ /**
75
+ * Execute an action by name.
76
+ * @param {string} name — Action name
77
+ * @param {object} [params] — Action parameters
78
+ * @returns {Promise<object>}
79
+ */
80
+ async execute(name, params) {
81
+ if (this.useBiDi) {
82
+ const result = await this._bidiSend('wab.executeAction', { name, data: params || {} });
83
+ return result.result || result;
84
+ }
85
+ return this.page.evaluate(
86
+ (n, p) => window.AICommands.execute(n, p),
87
+ name, params
88
+ );
89
+ }
90
+
91
+ /**
92
+ * Read text content of an element.
93
+ * @param {string} selector — CSS selector
94
+ * @returns {Promise<object>}
95
+ */
96
+ async readContent(selector) {
97
+ if (this.useBiDi) {
98
+ const result = await this._bidiSend('wab.readContent', { selector });
99
+ return result.result || result;
100
+ }
101
+ return this.page.evaluate((sel) => window.AICommands.readContent(sel), selector);
102
+ }
103
+
104
+ /**
105
+ * Get page info and bridge metadata.
106
+ * @returns {Promise<object>}
107
+ */
108
+ async getPageInfo() {
109
+ if (this.useBiDi) {
110
+ const result = await this._bidiSend('wab.getPageInfo');
111
+ return result.result || result;
112
+ }
113
+ return this.page.evaluate(() => window.AICommands.getPageInfo());
114
+ }
115
+
116
+ /**
117
+ * Authenticate an agent with the bridge.
118
+ * @param {string} apiKey
119
+ * @param {object} [meta] — Agent metadata
120
+ * @returns {Promise<object>}
121
+ */
122
+ async authenticate(apiKey, meta) {
123
+ return this.page.evaluate(
124
+ (key, m) => window.AICommands.authenticate(key, m),
125
+ apiKey, meta
126
+ );
127
+ }
128
+
129
+ /**
130
+ * Navigate to a URL and wait for the bridge.
131
+ * @param {string} url
132
+ * @returns {Promise<void>}
133
+ */
134
+ async navigateAndWait(url) {
135
+ await this.page.goto(url, { waitUntil: 'networkidle2' });
136
+ await this.waitForBridge();
137
+ }
138
+
139
+ /**
140
+ * Execute multiple actions in sequence.
141
+ * @param {Array<{name: string, params?: object}>} steps
142
+ * @returns {Promise<Array>}
143
+ */
144
+ async executeSteps(steps) {
145
+ const results = [];
146
+ for (const step of steps) {
147
+ results.push(await this.execute(step.name, step.params));
148
+ }
149
+ return results;
150
+ }
151
+
152
+ /**
153
+ * Get BiDi context (only available when useBiDi is true).
154
+ * @returns {Promise<object>}
155
+ */
156
+ async getBiDiContext() {
157
+ return this.page.evaluate(() => window.__wab_bidi.getContext());
158
+ }
159
+
160
+ /**
161
+ * Check if the page has granted consent for agent interactions.
162
+ * @returns {Promise<boolean>}
163
+ */
164
+ async hasConsent() {
165
+ return this.page.evaluate(() => {
166
+ if (typeof window.WABConsent !== 'undefined') return window.WABConsent.hasConsent();
167
+ // If no consent script, treat as allowed
168
+ return true;
169
+ });
170
+ }
171
+
172
+ /**
173
+ * Wait until consent is granted (blocks until user clicks Allow).
174
+ * @param {number} [pollMs=500]
175
+ * @returns {Promise<boolean>}
176
+ */
177
+ async waitForConsent(pollMs = 500) {
178
+ return this.page.waitForFunction(
179
+ () => {
180
+ if (typeof window.WABConsent === 'undefined') return true;
181
+ return window.WABConsent.hasConsent();
182
+ },
183
+ { timeout: this.timeout, polling: pollMs }
184
+ ).then(() => true);
185
+ }
186
+
187
+ /**
188
+ * Discover the page and return the list of actions.
189
+ * Combines bridge discovery with runtime getActions().
190
+ * @returns {Promise<object>}
191
+ */
192
+ async discover() {
193
+ return this.page.evaluate(() => {
194
+ if (window.WAB && typeof window.WAB.discover === 'function') return window.WAB.discover();
195
+ if (window.AICommands && typeof window.AICommands.getActions === 'function') {
196
+ return { actions: window.AICommands.getActions(), meta: window.AICommands.getPageInfo ? window.AICommands.getPageInfo() : {} };
197
+ }
198
+ return { actions: [] };
199
+ });
200
+ }
201
+
202
+ /**
203
+ * Run a sequence of actions, stopping on the first failure.
204
+ * @param {Array<{name: string, params?: object}>} steps
205
+ * @param {{ stopOnError?: boolean }} [options]
206
+ * @returns {Promise<Array<{ name: string, ok: boolean, result?: any, error?: string }>>}
207
+ */
208
+ async runPipeline(steps, options = {}) {
209
+ const stopOnError = options.stopOnError !== false;
210
+ const results = [];
211
+ for (const step of steps) {
212
+ try {
213
+ const res = await this.execute(step.name, step.params);
214
+ results.push({ name: step.name, ok: true, result: res });
215
+ } catch (err) {
216
+ results.push({ name: step.name, ok: false, error: err.message || String(err) });
217
+ if (stopOnError) break;
218
+ }
219
+ }
220
+ return results;
221
+ }
222
+
223
+ /**
224
+ * Execute multiple actions in parallel.
225
+ * @param {Array<{name: string, params?: object}>} actions
226
+ * @returns {Promise<Array<{ name: string, status: string, value?: any, reason?: string }>>}
227
+ */
228
+ async executeParallel(actions) {
229
+ const promises = actions.map((a) =>
230
+ this.execute(a.name, a.params)
231
+ .then((value) => ({ name: a.name, status: 'fulfilled', value }))
232
+ .catch((err) => ({ name: a.name, status: 'rejected', reason: err.message || String(err) }))
233
+ );
234
+ return Promise.all(promises);
235
+ }
236
+
237
+ /**
238
+ * Take a screenshot and return as base64 (useful for vision agents).
239
+ * @param {{ fullPage?: boolean }} [opts]
240
+ * @returns {Promise<string>}
241
+ */
242
+ async screenshot(opts = {}) {
243
+ const buf = await this.page.screenshot({
244
+ encoding: 'base64',
245
+ fullPage: opts.fullPage || false
246
+ });
247
+ return buf;
248
+ }
249
+
250
+ /** @private */
251
+ async _bidiSend(method, params = {}) {
252
+ const cmd = { id: ++this._biDiId, method, params };
253
+ return this.page.evaluate((c) => window.__wab_bidi.send(c), cmd);
254
+ }
255
+ }
256
+
257
+ /**
258
+ * WABUniversalAgent Works on ANY page, no bridge script needed.
259
+ * Uses server-side extraction, analysis, and comparison APIs.
260
+ */
261
+ class WABUniversalAgent {
262
+ /**
263
+ * @param {string} [serverUrl='http://localhost:3000'] — WAB server URL
264
+ */
265
+ constructor(serverUrl = 'http://localhost:3000') {
266
+ this.serverUrl = serverUrl.replace(/\/$/, '');
267
+ }
268
+
269
+ /** @private */
270
+ async _post(path, body) {
271
+ const res = await fetch(`${this.serverUrl}${path}`, {
272
+ method: 'POST',
273
+ headers: { 'Content-Type': 'application/json' },
274
+ body: JSON.stringify(body),
275
+ });
276
+ if (!res.ok) throw new Error(`WAB API error ${res.status}: ${await res.text()}`);
277
+ return res.json();
278
+ }
279
+
280
+ /** @private */
281
+ async _get(path) {
282
+ const res = await fetch(`${this.serverUrl}${path}`);
283
+ if (!res.ok) throw new Error(`WAB API error ${res.status}: ${await res.text()}`);
284
+ return res.json();
285
+ }
286
+
287
+ /**
288
+ * Extract products, prices, and metadata from any URL.
289
+ * @param {string} url
290
+ * @returns {Promise<object>}
291
+ */
292
+ async extract(url) {
293
+ return this._post('/api/universal/extract', { url });
294
+ }
295
+
296
+ /**
297
+ * Full analysis: extract + fairness + fraud detection + dark patterns.
298
+ * @param {string} url
299
+ * @returns {Promise<object>}
300
+ */
301
+ async analyze(url) {
302
+ return this._post('/api/universal/analyze', { url });
303
+ }
304
+
305
+ /**
306
+ * Compare prices across multiple sources.
307
+ * @param {string} query — Product or service to search for
308
+ * @param {string} [category='product'] — 'product', 'hotel', 'flight'
309
+ * @returns {Promise<object>}
310
+ */
311
+ async compare(query, category = 'product') {
312
+ return this._post('/api/universal/compare', { query, category });
313
+ }
314
+
315
+ /**
316
+ * Find and rank the best deals with fairness scoring.
317
+ * @param {string} query
318
+ * @param {string} [category='product']
319
+ * @param {string} [lang='en']
320
+ * @returns {Promise<object>}
321
+ */
322
+ async deals(query, category = 'product', lang = 'en') {
323
+ return this._post('/api/universal/deals', { query, category, lang });
324
+ }
325
+
326
+ /**
327
+ * Get fairness score for a domain.
328
+ * @param {string} domain
329
+ * @returns {Promise<object>}
330
+ */
331
+ async fairness(domain) {
332
+ return this._post('/api/universal/fairness', { domain });
333
+ }
334
+
335
+ /**
336
+ * Detect dark patterns on a URL.
337
+ * @param {string} url
338
+ * @returns {Promise<object>}
339
+ */
340
+ async darkPatterns(url) {
341
+ return this._post('/api/universal/dark-patterns', { url });
342
+ }
343
+
344
+ /**
345
+ * Get price history for a domain.
346
+ * @param {string} domain
347
+ * @returns {Promise<object>}
348
+ */
349
+ async priceHistory(domain) {
350
+ return this._get(`/api/universal/history?domain=${encodeURIComponent(domain)}`);
351
+ }
352
+
353
+ /**
354
+ * Get top fairness-scored sites.
355
+ * @param {number} [limit=20]
356
+ * @returns {Promise<object>}
357
+ */
358
+ async topFair(limit = 20) {
359
+ return this._get(`/api/universal/top-fair?limit=${limit}`);
360
+ }
361
+
362
+ /**
363
+ * Get all known competing sources.
364
+ * @returns {Promise<object>}
365
+ */
366
+ async sources() {
367
+ return this._get('/api/universal/sources');
368
+ }
369
+ }
370
+
371
+ const { WABMultiAgent } = require('./multi-agent');
372
+ const { WABAgentMesh } = require('./agent-mesh');
373
+
374
+ module.exports = { WABAgent, WABUniversalAgent, WABMultiAgent, WABAgentMesh };
package/sdk/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "web-agent-bridge-sdk",
3
- "version": "2.3.0",
3
+ "version": "2.4.0",
4
4
  "description": "SDK for building AI agents that interact with Web Agent Bridge (WAB)",
5
5
  "main": "index.js",
6
6
  "license": "MIT",
@@ -33,10 +33,12 @@ function isProd() {
33
33
  function assertSecretsAtStartup() {
34
34
  if (isTest()) return;
35
35
  if (isProd() && !process.env.JWT_SECRET) {
36
- _autoUserSecret = generateAutoSecret('JWT_SECRET');
36
+ console.error('[WAB] FATAL: JWT_SECRET is not set in production. Refusing to start with insecure defaults.');
37
+ process.exit(1);
37
38
  }
38
39
  if (isProd() && !process.env.JWT_SECRET_ADMIN) {
39
- _autoAdminSecret = generateAutoSecret('JWT_SECRET_ADMIN');
40
+ console.error('[WAB] FATAL: JWT_SECRET_ADMIN is not set in production. Refusing to start with insecure defaults.');
41
+ process.exit(1);
40
42
  }
41
43
  }
42
44
 
@@ -44,14 +46,20 @@ function getJwtUserSecret() {
44
46
  if (isTest()) {
45
47
  return process.env.JWT_SECRET || 'test-secret-key-for-testing';
46
48
  }
47
- return process.env.JWT_SECRET || _autoUserSecret || 'dev-user-secret-change-in-development';
49
+ if (process.env.JWT_SECRET) return process.env.JWT_SECRET;
50
+ // Dev mode: generate ephemeral secret per process (not hardcoded)
51
+ if (!_autoUserSecret) _autoUserSecret = generateAutoSecret('JWT_SECRET');
52
+ return _autoUserSecret;
48
53
  }
49
54
 
50
55
  function getJwtAdminSecret() {
51
56
  if (isTest()) {
52
- return process.env.JWT_SECRET_ADMIN || process.env.JWT_SECRET || 'test-secret-key-for-testing-admin';
57
+ return process.env.JWT_SECRET_ADMIN || 'test-secret-key-for-testing-admin';
53
58
  }
54
- return process.env.JWT_SECRET_ADMIN || process.env.JWT_SECRET || _autoAdminSecret || _autoUserSecret || 'dev-admin-secret-change-in-development';
59
+ if (process.env.JWT_SECRET_ADMIN) return process.env.JWT_SECRET_ADMIN;
60
+ // Dev mode: generate separate ephemeral secret (never share with user secret)
61
+ if (!_autoAdminSecret) _autoAdminSecret = generateAutoSecret('JWT_SECRET_ADMIN');
62
+ return _autoAdminSecret;
55
63
  }
56
64
 
57
65
  function signUserToken(payload, options = {}) {