web-agent-bridge 2.0.0 → 2.2.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.
package/public/index.html CHANGED
@@ -25,6 +25,7 @@
25
25
  <li><a href="#integrations">Integrations</a></li>
26
26
  <li><a href="#how-it-works">How It Works</a></li>
27
27
  <li><a href="#pricing">Pricing</a></li>
28
+ <li><a href="#v2-features">v2.0</a></li>
28
29
  <li><a href="/docs">Docs</a></li>
29
30
  </ul>
30
31
  <div class="navbar-actions">
@@ -146,6 +147,101 @@
146
147
  </div>
147
148
  </section>
148
149
 
150
+ <!-- ═══════════ V2 FEATURES ═══════════ -->
151
+ <section class="section" id="v2-features" style="background: var(--bg-secondary);">
152
+ <div class="container">
153
+ <div class="section-header">
154
+ <span class="label">v2.0 — Digital Fortress</span>
155
+ <h2>Internet Sovereignty Features</h2>
156
+ <p>WAB v2.0 goes beyond bridging — it protects users with negotiation, verification, and decentralized trust.</p>
157
+ </div>
158
+
159
+ <div class="grid-3">
160
+ <div class="card fade-in" style="border-left: 3px solid #f59e0b;">
161
+ <div class="card-icon orange">💰</div>
162
+ <h3>Real-time Negotiation Engine</h3>
163
+ <p>AI agents negotiate prices directly with WAB-enabled sites. Site owners define negotiation rules (bulk discounts, loyalty rewards, time-based offers). Agents submit counter-offers in multi-round sessions — no middleman, no hidden fees.</p>
164
+ <ul style="margin-top:12px;font-size:0.85rem;color:var(--text-secondary);list-style:disc;padding-left:20px;">
165
+ <li>8 condition types (bulk, loyalty, time, first-buy...)</li>
166
+ <li>4 discount types (percentage, fixed, free shipping, bundle)</li>
167
+ <li>Multi-round negotiation with counter-offers</li>
168
+ <li>Savings tracking per agent</li>
169
+ </ul>
170
+ </div>
171
+ <div class="card fade-in fade-in-delay-1" style="border-left: 3px solid #ef4444;">
172
+ <div class="card-icon pink">🛡️</div>
173
+ <h3>Anti-Hallucination Shield</h3>
174
+ <p>Cross-verification engine that catches AI lies before they reach users. Compares DOM values against vision screenshots, validates prices against market benchmarks, and checks temporal consistency across sessions.</p>
175
+ <ul style="margin-top:12px;font-size:0.85rem;color:var(--text-secondary);list-style:disc;padding-left:20px;">
176
+ <li>DOM vs Vision verification</li>
177
+ <li>Market benchmark price validation</li>
178
+ <li>Temporal consistency checks</li>
179
+ <li>Text similarity scoring (Levenshtein)</li>
180
+ </ul>
181
+ </div>
182
+ <div class="card fade-in fade-in-delay-2" style="border-left: 3px solid #10b981;">
183
+ <div class="card-icon green">⭐</div>
184
+ <h3>Decentralized Reputation</h3>
185
+ <p>Agents and sites build trust through cryptographic attestations. Every interaction gets scored — purchase success, data accuracy, delivery fulfillment. Scores are aggregated into transparent reputation profiles visible to all agents.</p>
186
+ <ul style="margin-top:12px;font-size:0.85rem;color:var(--text-secondary);list-style:disc;padding-left:20px;">
187
+ <li>Trust attestations from agent network</li>
188
+ <li>Weighted scoring by interaction type</li>
189
+ <li>Trust levels: emerging → verified → exemplary</li>
190
+ <li>Global leaderboard</li>
191
+ </ul>
192
+ </div>
193
+ <div class="card fade-in" style="border-left: 3px solid #3b82f6;">
194
+ <div class="card-icon blue">🏰</div>
195
+ <h3>Sovereign Dashboard</h3>
196
+ <p>A real-time command center showing your digital fortress status — protected sites, fairness radar, privacy shield, negotiation logs, and verification checks all in one beautiful dark-mode dashboard.</p>
197
+ <ul style="margin-top:12px;font-size:0.85rem;color:var(--text-secondary);list-style:disc;padding-left:20px;">
198
+ <li>Live fairness radar with safety scoring</li>
199
+ <li>Privacy shield metrics</li>
200
+ <li>AI model switcher (Llama, GPT-4, Claude...)</li>
201
+ <li>Protected sites table with trust levels</li>
202
+ </ul>
203
+ </div>
204
+ <div class="card fade-in fade-in-delay-1" style="border-left: 3px solid #8b5cf6;">
205
+ <div class="card-icon purple">📦</div>
206
+ <h3>Community Agent Hub</h3>
207
+ <p>Pre-built YAML agent templates for common use cases — hotel booking, grocery comparison, artisan marketplace, flight deals. Run any template with a single CLI command: <code>npx wab-agent run template.yaml</code>.</p>
208
+ <ul style="margin-top:12px;font-size:0.85rem;color:var(--text-secondary);list-style:disc;padding-left:20px;">
209
+ <li>11 production-ready templates</li>
210
+ <li>CLI runner with variable substitution</li>
211
+ <li>Fairness rules built into every template</li>
212
+ <li>Supports negotiation + verification</li>
213
+ </ul>
214
+ </div>
215
+ <div class="card fade-in fade-in-delay-2" style="border-left: 3px solid #0ea5e9;">
216
+ <div class="card-icon cyan">🌐</div>
217
+ <h3>Cross-Site Agent Orchestration</h3>
218
+ <p>One agent manages multiple WAB-enabled sites simultaneously. Compare prices across stores, aggregate product data, run parallel actions — all from a single <code>WABMultiAgent</code> instance in the SDK.</p>
219
+ <ul style="margin-top:12px;font-size:0.85rem;color:var(--text-secondary);list-style:disc;padding-left:20px;">
220
+ <li>Parallel multi-site browser sessions</li>
221
+ <li>comparePrices() with cheapest-deal finder</li>
222
+ <li>Schema.org + WAB action price extraction</li>
223
+ <li>Cross-site screenshots for vision verification</li>
224
+ </ul>
225
+ </div>
226
+ <div class="card fade-in" style="border-left: 3px solid #06b6d4;">
227
+ <div class="card-icon cyan">🔄</div>
228
+ <h3>AI Brain Swapping</h3>
229
+ <p>WAB is the bridge — the AI model is your choice. Switch between Llama 3, GPT-4, Claude, Gemini, Mistral, or run fully local with Ollama. Your data, your model, your sovereignty.</p>
230
+ <ul style="margin-top:12px;font-size:0.85rem;color:var(--text-secondary);list-style:disc;padding-left:20px;">
231
+ <li>6 supported AI engines</li>
232
+ <li>Local-first with Ollama support</li>
233
+ <li>Hot-swap without reconfiguration</li>
234
+ <li>Your data never leaves your machine</li>
235
+ </ul>
236
+ </div>
237
+ </div>
238
+
239
+ <div style="text-align:center; margin-top:32px;">
240
+ <a href="/sovereign" class="btn btn-primary btn-lg">Open Sovereign Dashboard</a>
241
+ </div>
242
+ </div>
243
+ </section>
244
+
149
245
  <!-- ═══════════ HOW IT WORKS ═══════════ -->
150
246
  <section class="section" id="how-it-works" style="background: var(--bg-secondary);">
151
247
  <div class="container">
@@ -454,6 +550,7 @@ console.<span class="fn">log</span>(actions);
454
550
  <li><a href="#integrations">Agent Integrations</a></li>
455
551
  <li><a href="#pricing">Pricing</a></li>
456
552
  <li><a href="/docs">Documentation</a></li>
553
+ <li><a href="/sovereign">Sovereign Dashboard</a></li>
457
554
  <li data-wab-auth="signed-in" style="display:none"><a href="/dashboard">Dashboard</a></li>
458
555
  </ul>
459
556
  </div>
@@ -26,7 +26,7 @@
26
26
  (function(global) {
27
27
  'use strict';
28
28
 
29
- var VERSION = '2.0.0';
29
+ var VERSION = '2.2.0';
30
30
 
31
31
  // ── WAB Instance ──────────────────────────────────────────────────
32
32
  function WABInstance(config) {
@@ -72,8 +72,17 @@
72
72
  transport: ['javascript', 'http'],
73
73
  ready: true,
74
74
  discover: function() { return self.discover(); },
75
- execute: function(name, params) { return self.execute(name, params); }
75
+ execute: function(name, params) { return self.execute(name, params); },
76
+ negotiate: function(agentId, proposal) { return self.negotiate(agentId, proposal); },
77
+ getReputation: function(siteId) { return self.getReputation(siteId); },
78
+ verifyPrice: function(productId, domPrice, visionPrice) { return self.verifyPrice(productId, domPrice, visionPrice); }
76
79
  };
80
+
81
+ // Also expose on window.AICommands for broad compatibility
82
+ global.AICommands = global.AICommands || {};
83
+ global.AICommands.negotiate = function(agentId, proposal) { return self.negotiate(agentId, proposal); };
84
+ global.AICommands.getReputation = function(siteId) { return self.getReputation(siteId); };
85
+ global.AICommands.verifyPrice = function(productId, domP, visP) { return self.verifyPrice(productId, domP, visP); };
77
86
  };
78
87
 
79
88
  // Cross-frame communication for embedded demos
@@ -97,6 +106,12 @@
97
106
  e.source.postMessage({ source: 'wab-store', type: 'execute-response', action: e.data.action, detail: result }, '*');
98
107
  });
99
108
  }
109
+ // Negotiation protocol via postMessage
110
+ if (e.data.source === 'wab-agent' && e.data.type === 'negotiate') {
111
+ self.negotiate(e.data.agentId, e.data.proposal).then(function(result) {
112
+ e.source.postMessage({ source: 'wab-store', type: 'negotiate-response', detail: result }, '*');
113
+ });
114
+ }
100
115
  });
101
116
 
102
117
  // Notify parent that store is ready
@@ -200,6 +215,147 @@
200
215
  return this._auditLog.slice();
201
216
  };
202
217
 
218
+ // ── Negotiation Support ─────────────────────────────────────────
219
+ // Sites can define negotiation rules; agents can open sessions and propose
220
+
221
+ WABInstance.prototype.setNegotiationRules = function(rules) {
222
+ this._negotiationRules = rules || {};
223
+ // Expose in protocol
224
+ if (global.__wab_protocol) {
225
+ global.__wab_protocol.negotiation = { available: true, rules: Object.keys(rules) };
226
+ }
227
+ return this;
228
+ };
229
+
230
+ WABInstance.prototype.negotiate = function(agentId, proposal) {
231
+ var self = this;
232
+ // Support in-browser negotiation rules (no server needed)
233
+ if (this._negotiationRules && !this.serverUrl) {
234
+ return this._handleLocalNegotiation(agentId, proposal);
235
+ }
236
+ if (!this.serverUrl) {
237
+ return Promise.resolve({ error: 'Negotiation requires a server URL or local rules' });
238
+ }
239
+ return fetch(this.serverUrl + '/api/sovereign/negotiation/sessions', {
240
+ method: 'POST',
241
+ headers: { 'Content-Type': 'application/json' },
242
+ body: JSON.stringify({
243
+ siteId: self.name,
244
+ agentId: agentId,
245
+ itemId: proposal.itemId || null,
246
+ itemName: proposal.itemName || 'item',
247
+ originalPrice: proposal.originalPrice || 0
248
+ })
249
+ }).then(function(r) { return r.json(); })
250
+ .then(function(session) {
251
+ if (!session.sessionId) return session;
252
+ return fetch(self.serverUrl + '/api/sovereign/negotiation/sessions/' + session.sessionId + '/propose', {
253
+ method: 'POST',
254
+ headers: { 'Content-Type': 'application/json' },
255
+ body: JSON.stringify({
256
+ strategy: proposal.strategy || 'instant_payment',
257
+ proposedDiscount: proposal.proposedDiscount || 5,
258
+ arguments: proposal.arguments || []
259
+ })
260
+ }).then(function(r) { return r.json(); });
261
+ });
262
+ };
263
+
264
+ // Local in-browser negotiation (no server required)
265
+ WABInstance.prototype._handleLocalNegotiation = function(agentId, proposal) {
266
+ var rules = this._negotiationRules;
267
+ var strategy = proposal.strategy || 'custom';
268
+ var rule = rules[strategy];
269
+ if (!rule) {
270
+ return Promise.resolve({
271
+ status: 'rejected',
272
+ reason: 'no_applicable_rule',
273
+ message: 'No rule matches strategy: ' + strategy
274
+ });
275
+ }
276
+ var requested = proposal.proposedDiscount || 0;
277
+ var maxAllowed = rule.maxDiscount || 20;
278
+ var offered = rule.discount || 0;
279
+ var actual = Math.min(requested, maxAllowed, offered);
280
+ var originalPrice = proposal.originalPrice || 0;
281
+ var finalPrice = Math.round(originalPrice * (1 - actual / 100) * 100) / 100;
282
+
283
+ if (requested <= offered) {
284
+ this._emit('negotiation', { status: 'accepted', agentId: agentId, discount: actual, finalPrice: finalPrice });
285
+ return Promise.resolve({
286
+ status: 'agreed',
287
+ discount: actual,
288
+ originalPrice: originalPrice,
289
+ finalPrice: finalPrice,
290
+ message: 'Deal accepted! ' + actual + '% off. Price: $' + finalPrice
291
+ });
292
+ }
293
+ // Counter-offer
294
+ this._emit('negotiation', { status: 'counter', agentId: agentId, counterDiscount: offered });
295
+ return Promise.resolve({
296
+ status: 'counter_offer',
297
+ counterDiscount: offered,
298
+ counterPrice: Math.round(originalPrice * (1 - offered / 100) * 100) / 100,
299
+ message: 'We can offer ' + offered + '% off for ' + strategy.replace(/_/g, ' ')
300
+ });
301
+ };
302
+
303
+ // ── Reputation Support ────────────────────────────────────────────
304
+
305
+ WABInstance.prototype.submitAttestation = function(agentId, targetSiteId, interactionType, outcome, extras) {
306
+ if (!this.serverUrl) {
307
+ return Promise.resolve({ error: 'Reputation requires a server URL' });
308
+ }
309
+ var body = {
310
+ siteId: targetSiteId,
311
+ agentId: agentId,
312
+ interactionType: interactionType || 'purchase',
313
+ outcome: outcome || 'success'
314
+ };
315
+ if (extras) {
316
+ if (extras.priceAccuracy != null) body.priceAccuracy = extras.priceAccuracy;
317
+ if (extras.responseTimeMs != null) body.responseTimeMs = extras.responseTimeMs;
318
+ if (extras.dataIntegrity != null) body.dataIntegrity = extras.dataIntegrity;
319
+ if (extras.visionVerified != null) body.visionVerified = extras.visionVerified;
320
+ if (extras.details) body.details = extras.details;
321
+ }
322
+ return fetch(this.serverUrl + '/api/sovereign/reputation/attestations', {
323
+ method: 'POST',
324
+ headers: { 'Content-Type': 'application/json' },
325
+ body: JSON.stringify(body)
326
+ }).then(function(r) { return r.json(); });
327
+ };
328
+
329
+ WABInstance.prototype.getReputation = function(siteId) {
330
+ if (!this.serverUrl) {
331
+ return Promise.resolve({ error: 'Reputation requires a server URL' });
332
+ }
333
+ return fetch(this.serverUrl + '/api/sovereign/reputation/sites/' + encodeURIComponent(siteId))
334
+ .then(function(r) { return r.json(); });
335
+ };
336
+
337
+ // ── Verification Support ──────────────────────────────────────────
338
+
339
+ WABInstance.prototype.verifyPrice = function(opts) {
340
+ if (!this.serverUrl) {
341
+ return Promise.resolve({ error: 'Verification requires a server URL' });
342
+ }
343
+ var body = {
344
+ siteId: opts.siteId || this.name,
345
+ agentId: opts.agentId || null,
346
+ url: opts.url || null,
347
+ domValue: opts.domValue || opts.domPrice,
348
+ visionValue: opts.visionValue || opts.visionPrice,
349
+ category: opts.category || null,
350
+ itemName: opts.itemName || null
351
+ };
352
+ return fetch(this.serverUrl + '/api/sovereign/verify/price', {
353
+ method: 'POST',
354
+ headers: { 'Content-Type': 'application/json' },
355
+ body: JSON.stringify(body)
356
+ }).then(function(r) { return r.json(); });
357
+ };
358
+
203
359
  // ── Static API ────────────────────────────────────────────────────
204
360
 
205
361
  var WAB = {
@@ -226,6 +382,21 @@
226
382
  return Promise.resolve({ error: 'WAB not initialized. Call WAB.init() first.' });
227
383
  },
228
384
 
385
+ negotiate: function(agentId, proposal) {
386
+ if (WAB._instance) return WAB._instance.negotiate(agentId, proposal);
387
+ return Promise.resolve({ error: 'WAB not initialized' });
388
+ },
389
+
390
+ getReputation: function(siteId) {
391
+ if (WAB._instance) return WAB._instance.getReputation(siteId);
392
+ return Promise.resolve({ error: 'WAB not initialized' });
393
+ },
394
+
395
+ verifyPrice: function(opts) {
396
+ if (WAB._instance) return WAB._instance.verifyPrice(opts);
397
+ return Promise.resolve({ error: 'WAB not initialized' });
398
+ },
399
+
229
400
  _instance: null
230
401
  };
231
402