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/README.ar.md CHANGED
@@ -33,6 +33,16 @@
33
33
  - **قواعد بيانات متعددة** — SQLite + PostgreSQL + MySQL عبر محوّلات قابلة للتبديل
34
34
  - **SDK للوكلاء** — حزمة أدوات جاهزة لبناء وكلاء ذكاء اصطناعي
35
35
 
36
+ ### الإصدار 2.0 — ميزات الحصن الرقمي
37
+
38
+ - **محرك التفاوض اللحظي** — يتفاوض وكيل الذكاء الاصطناعي على الأسعار مباشرة مع المواقع عبر جلسات متعددة الجولات، ٨ أنواع شروط، و٤ أنواع خصومات
39
+ - **درع مقاومة التزييف** — محرك تحقق متقاطع يقارن DOM مع لقطات الشاشة، يتحقق من الأسعار مقابل المعايير السوقية، يفحص الاتساق الزمني، ويقيس تشابه النصوص
40
+ - **نظام السمعة اللامركزي** — شهادات ثقة مشفرة من شبكة الوكلاء مع تقييم مرجح، مستويات ثقة (ناشئ ← موثق ← نموذجي)، ولوحة متصدرين عالمية
41
+ - **لوحة السيادة** — مركز قيادة لحظي يعرض رادار العدالة، درع الخصوصية، سجل التفاوض، فحوصات التحقق، ومبدّل نماذج الذكاء الاصطناعي
42
+ - **متجر قوالب الوكلاء** — ١١ قالب YAML جاهز (حجز فنادق، مقارنة بقالة، سوق حرفيين، صفقات طيران، إلخ) مع تشغيل من سطر الأوامر: `npx wab-agent run template.yaml`
43
+ - **تبديل عقل الوكيل** — بدّل بين Llama 3، GPT-4، Claude، Gemini، Mistral، أو Ollama (محلي) بدون إعادة إعداد
44
+ - **تنسيق الوكيل عبر المواقع** — وكيل واحد يدير عدة مواقع WAB في نفس الوقت عبر `WABMultiAgent`. قارن الأسعار بين المتاجر، اجمع البيانات، نفّذ إجراءات متوازية، واعثر على أفضل صفقة تلقائياً
45
+
36
46
  ---
37
47
 
38
48
  ## 🚀 البدء السريع
@@ -145,6 +155,22 @@ web-agent-bridge/
145
155
  | `/api/license/verify` | POST | التحقق من مفتاح الترخيص |
146
156
  | `/api/license/track` | POST | تسجيل حدث تحليلي |
147
157
 
158
+ ### واجهات السيادة (الإصدار 2.0)
159
+ | النقطة | الطريقة | الوصف |
160
+ |---|---|---|
161
+ | `/api/sovereign/reputation/agents` | POST | تسجيل وكيل جديد |
162
+ | `/api/sovereign/reputation/attestations` | POST | إرسال شهادة ثقة |
163
+ | `/api/sovereign/reputation/sites/:siteId` | GET | سمعة الموقع |
164
+ | `/api/sovereign/reputation/leaderboard` | GET | لوحة المتصدرين |
165
+ | `/api/sovereign/negotiation/rules` | POST | إنشاء قاعدة تفاوض |
166
+ | `/api/sovereign/negotiation/sessions` | POST | فتح جلسة تفاوض |
167
+ | `/api/sovereign/negotiation/sessions/:id/propose` | POST | تقديم عرض مضاد |
168
+ | `/api/sovereign/negotiation/sessions/:id/confirm` | POST | تأكيد الصفقة |
169
+ | `/api/sovereign/verify/price` | POST | التحقق من السعر |
170
+ | `/api/sovereign/verify/text` | POST | التحقق من النص |
171
+ | `/api/sovereign/verify/page` | POST | التحقق الشامل للصفحة |
172
+ | `/api/sovereign/dashboard/sovereign` | GET | بيانات لوحة السيادة |
173
+
148
174
  ### WebSocket
149
175
  | النقطة | الوصف |
150
176
  |---|---|
@@ -433,6 +459,107 @@ window.AIBridgeConfig = { stealth: { enabled: true } };
433
459
 
434
460
  ---
435
461
 
462
+ ## 💰 محرك التفاوض اللحظي
463
+
464
+ يحدد أصحاب المواقع قواعد التفاوض. يتفاوض وكيل الذكاء الاصطناعي على الأسعار في جلسات متعددة الجولات:
465
+
466
+ ```javascript
467
+ // فتح جلسة تفاوض
468
+ const session = await fetch('/api/sovereign/negotiation/sessions', {
469
+ method: 'POST',
470
+ headers: { 'Authorization': 'Bearer ' + token, 'Content-Type': 'application/json' },
471
+ body: JSON.stringify({
472
+ siteId: 'site-uuid',
473
+ agentId: 'agent-id',
474
+ originalPrice: 49.99,
475
+ itemId: 'product-123',
476
+ itemName: 'زيت زيتون ١ لتر'
477
+ })
478
+ }).then(r => r.json());
479
+
480
+ // تقديم عرض مضاد
481
+ const counter = await fetch(`/api/sovereign/negotiation/sessions/${session.sessionId}/propose`, {
482
+ method: 'POST',
483
+ headers: { 'Authorization': 'Bearer ' + token, 'Content-Type': 'application/json' },
484
+ body: JSON.stringify({ agentId: 'agent-id', proposedPrice: 39.99 })
485
+ }).then(r => r.json());
486
+ // → { status: 'accepted', finalPrice: 42.49, message: 'صفقة! ...' }
487
+ ```
488
+
489
+ ### أنواع الشروط
490
+ | الشرط | الوصف |
491
+ |---|---|
492
+ | `bulk_quantity` | خصم على الكميات الكبيرة |
493
+ | `loyalty` | مكافأة للعملاء المتكررين |
494
+ | `time_based` | عروض الساعة السعيدة |
495
+ | `first_purchase` | خصم ترحيبي للمشترين الجدد |
496
+ | `cart_value` | حد أدنى لقيمة السلة |
497
+ | `seasonal` | عروض موسمية بتواريخ محددة |
498
+ | `membership` | أسعار خاصة للأعضاء |
499
+ | `referral` | خصومات الإحالة |
500
+
501
+ ---
502
+
503
+ ## 🛡️ درع مقاومة التزييف (Anti-Hallucination Shield)
504
+
505
+ محرك تحقق متقاطع يكتشف أكاذيب الذكاء الاصطناعي قبل وصولها للمستخدم:
506
+
507
+ ```javascript
508
+ // التحقق من سعر
509
+ const result = await fetch('/api/sovereign/verify/price', {
510
+ method: 'POST',
511
+ headers: { 'Authorization': 'Bearer ' + token, 'Content-Type': 'application/json' },
512
+ body: JSON.stringify({
513
+ siteId: 'site-uuid',
514
+ domValue: 29.99,
515
+ visionValue: 29.99,
516
+ category: 'electronics',
517
+ itemName: 'كابل USB'
518
+ })
519
+ }).then(r => r.json());
520
+ // → { verified: true, confidence: 0.98, severity: 'none' }
521
+ ```
522
+
523
+ ### طبقات التحقق
524
+ ١. **DOM مقابل الرؤية** — يقارن السعر المستخرج من DOM مع قراءة لقطة الشاشة
525
+ ٢. **المعيار السوقي** — يتحقق من السعر مقابل البيانات التاريخية للفئة
526
+ ٣. **الاتساق الزمني** — يفحص هل تغير السعر بشكل مريب منذ آخر تحقق
527
+ ٤. **النتيجة المركبة** — مزيج مرجح من جميع الطبقات مع تصنيف الخطورة
528
+
529
+ ---
530
+
531
+ ## 📦 متجر قوالب الوكلاء (Community Agent Hub)
532
+
533
+ قوالب YAML جاهزة لحالات الاستخدام الشائعة. شغّل أي قالب من سطر الأوامر:
534
+
535
+ ```bash
536
+ # عرض القوالب المتاحة
537
+ npx wab-agent templates
538
+
539
+ # تشغيل قالب
540
+ npx wab-agent run olive-oil-tunisia --budget 50 --region tunis
541
+
542
+ # تشغيل مع خادم مخصص
543
+ npx wab-agent run hotel-direct-booking --server https://yourserver.com
544
+ ```
545
+
546
+ ### القوالب المتاحة
547
+ | القالب | الوصف |
548
+ |---|---|
549
+ | `olive-oil-tunisia` | زيت زيتون من مزارع تونسية صغيرة |
550
+ | `hotel-direct-booking` | حجز فنادق مباشر بدون وسطاء |
551
+ | `artisan-marketplace` | منتجات يدوية من حرفيين مستقلين |
552
+ | `grocery-price-compare` | مقارنة أسعار البقالة بين المتاجر المحلية |
553
+ | `freelancer-direct` | مستقلون بدون رسوم منصات |
554
+ | `restaurant-direct` | مطاعم بدون تطبيقات توصيل |
555
+ | `book-price-scout` | كتب من مكتبات مستقلة |
556
+ | `flight-deal-hunter` | رحلات مباشرة من شركات الطيران |
557
+ | `electronics-price-tracker` | تتبع أسعار الإلكترونيات |
558
+ | `local-services` | مزودي خدمات محليين |
559
+ | `organic-farm-fresh` | منتجات عضوية مباشرة من المزارع |
560
+
561
+ ---
562
+
436
563
  ## 🤝 المساهمة
437
564
 
438
565
  نرحب بالمساهمات! اقرأ [دليل المساهمة](CONTRIBUTING.md) للبدء.
package/README.md CHANGED
@@ -57,6 +57,16 @@ WAB is an open-source middleware layer that bridges AI agents and websites — l
57
57
  - **Admin Dashboard** — User management, tier grants, system analytics
58
58
  - **Stripe Integration** — Payment processing with customer portal
59
59
 
60
+ ### v2.0 — Digital Fortress Features
61
+
62
+ - **Real-time Negotiation Engine** — AI agents negotiate prices directly with WAB-enabled sites using multi-round sessions, 8 condition types, and 4 discount types
63
+ - **Anti-Hallucination Shield** — Cross-verification engine comparing DOM vs vision screenshots, market benchmark validation, temporal consistency checks, and Levenshtein text similarity scoring
64
+ - **Decentralized Reputation System** — Cryptographic trust attestations from the agent network with weighted scoring, trust levels (emerging → verified → exemplary), and global leaderboard
65
+ - **Sovereign Dashboard** — Real-time command center with fairness radar, privacy shield, negotiation logs, verification checks, and AI model switcher
66
+ - **Community Agent Hub** — 11 pre-built YAML agent templates (hotel booking, grocery comparison, artisan marketplace, flight deals, etc.) with CLI runner: `npx wab-agent run template.yaml`
67
+ - **AI Brain Swapping** — Switch between Llama 3, GPT-4, Claude, Gemini, Mistral, or Ollama (local) without reconfiguration
68
+ - **Cross-Site Agent Orchestration** — One agent manages multiple WAB-enabled sites simultaneously via `WABMultiAgent`. Compare prices across stores, aggregate data, run parallel actions, and find the best deal automatically
69
+
60
70
  ---
61
71
 
62
72
  ## Quick Start
@@ -126,7 +136,12 @@ web-agent-bridge/
126
136
  │ │ ├── api.js # Sites, config, analytics API
127
137
  │ │ ├── license.js # License verification, token exchange & tracking
128
138
  │ │ ├── admin.js # Admin dashboard API
129
- │ │ └── billing.js # Stripe billing integration
139
+ │ │ ├── billing.js # Stripe billing integration
140
+ │ │ └── sovereign.js # v2.0: negotiation, reputation, verification
141
+ │ ├── services/
142
+ │ │ ├── negotiation.js # Real-time negotiation engine
143
+ │ │ ├── verification.js # Anti-hallucination shield
144
+ │ │ └── reputation.js # Decentralized reputation system
130
145
  │ ├── middleware/
131
146
  │ │ └── auth.js # JWT authentication middleware
132
147
  │ ├── models/
@@ -154,6 +169,10 @@ web-agent-bridge/
154
169
  │ ├── svelte/ # @web-agent-bridge/svelte
155
170
  │ └── langchain/ # @web-agent-bridge/langchain
156
171
  ├── sdk/ # Agent SDK for Puppeteer/Playwright
172
+ ├── bin/
173
+ │ ├── cli.js # CLI entry point (wab-agent)
174
+ │ └── agent-runner.js # YAML template runner
175
+ ├── templates/ # Community Agent Hub YAML templates
157
176
  ├── .env # Environment variables
158
177
  └── package.json
159
178
  ```
@@ -189,6 +208,23 @@ web-agent-bridge/
189
208
  | `/api/license/session` | POST | Validate session token (domain-locked) |
190
209
  | `/api/license/track` | POST | Record analytics (`sessionToken` + Origin; legacy `licenseKey` only if `ALLOW_LEGACY_LICENSE_TRACK`) |
191
210
 
211
+ ### Sovereign (v2.0)
212
+ | Endpoint | Method | Description |
213
+ |---|---|---|
214
+ | `/api/sovereign/reputation/agents` | POST | Register a new agent |
215
+ | `/api/sovereign/reputation/attestations` | POST | Submit a trust attestation |
216
+ | `/api/sovereign/reputation/sites/:siteId` | GET | Get site reputation |
217
+ | `/api/sovereign/reputation/leaderboard` | GET | Get reputation leaderboard |
218
+ | `/api/sovereign/negotiation/rules` | POST | Create negotiation rule |
219
+ | `/api/sovereign/negotiation/rules/:siteId` | GET | Get rules for a site |
220
+ | `/api/sovereign/negotiation/sessions` | POST | Open negotiation session |
221
+ | `/api/sovereign/negotiation/sessions/:id/propose` | POST | Submit counter-offer |
222
+ | `/api/sovereign/negotiation/sessions/:id/confirm` | POST | Confirm a deal |
223
+ | `/api/sovereign/verify/price` | POST | Verify price (DOM vs vision) |
224
+ | `/api/sovereign/verify/text` | POST | Verify text accuracy |
225
+ | `/api/sovereign/verify/page` | POST | Full page verification |
226
+ | `/api/sovereign/dashboard/sovereign` | GET | Dashboard aggregate data |
227
+
192
228
  ---
193
229
 
194
230
  ## Bridge Script API
@@ -775,6 +811,159 @@ First admin: set `BOOTSTRAP_ADMIN_EMAIL` / `BOOTSTRAP_ADMIN_PASSWORD` when the `
775
811
 
776
812
  ---
777
813
 
814
+ ## Real-time Negotiation Engine
815
+
816
+ Site owners define negotiation rules. AI agents negotiate prices in multi-round sessions:
817
+
818
+ ```javascript
819
+ // Agent opens a negotiation session
820
+ const session = await fetch('/api/sovereign/negotiation/sessions', {
821
+ method: 'POST',
822
+ headers: { 'Authorization': 'Bearer ' + token, 'Content-Type': 'application/json' },
823
+ body: JSON.stringify({
824
+ siteId: 'site-uuid',
825
+ agentId: 'agent-id',
826
+ originalPrice: 49.99,
827
+ itemId: 'product-123',
828
+ itemName: 'Olive Oil 1L'
829
+ })
830
+ }).then(r => r.json());
831
+
832
+ // Agent makes a counter-offer
833
+ const counter = await fetch(`/api/sovereign/negotiation/sessions/${session.sessionId}/propose`, {
834
+ method: 'POST',
835
+ headers: { 'Authorization': 'Bearer ' + token, 'Content-Type': 'application/json' },
836
+ body: JSON.stringify({
837
+ agentId: 'agent-id',
838
+ proposedPrice: 39.99
839
+ })
840
+ }).then(r => r.json());
841
+ // → { status: 'accepted', finalPrice: 42.49, message: 'Deal! ...' }
842
+ ```
843
+
844
+ ### Condition Types
845
+ | Condition | Description |
846
+ |---|---|
847
+ | `bulk_quantity` | Discounts based on order quantity |
848
+ | `loyalty` | Rewards for repeat customers |
849
+ | `time_based` | Happy hour / flash sale windows |
850
+ | `first_purchase` | Welcome discount for new buyers |
851
+ | `cart_value` | Minimum cart value threshold |
852
+ | `seasonal` | Date-range seasonal promotions |
853
+ | `membership` | Member-only pricing |
854
+ | `referral` | Referral-based discounts |
855
+
856
+ ---
857
+
858
+ ## Anti-Hallucination Shield
859
+
860
+ Cross-verification engine that catches AI hallucinations before they reach users:
861
+
862
+ ```javascript
863
+ // Verify a price
864
+ const result = await fetch('/api/sovereign/verify/price', {
865
+ method: 'POST',
866
+ headers: { 'Authorization': 'Bearer ' + token, 'Content-Type': 'application/json' },
867
+ body: JSON.stringify({
868
+ siteId: 'site-uuid',
869
+ domValue: 29.99,
870
+ visionValue: 29.99,
871
+ category: 'electronics',
872
+ itemName: 'USB Cable'
873
+ })
874
+ }).then(r => r.json());
875
+ // → { verified: true, confidence: 0.98, severity: 'none', layers: { dom_vision: { match: true }, ... } }
876
+
877
+ // Verify text content
878
+ const textResult = await fetch('/api/sovereign/verify/text', {
879
+ method: 'POST',
880
+ headers: { 'Authorization': 'Bearer ' + token, 'Content-Type': 'application/json' },
881
+ body: JSON.stringify({
882
+ siteId: 'site-uuid',
883
+ source: 'dom',
884
+ value: 'Free shipping on orders over $50',
885
+ expected: 'Free shipping on orders over $50'
886
+ })
887
+ }).then(r => r.json());
888
+ // → { verified: true, similarity: 1.0 }
889
+ ```
890
+
891
+ ### Verification Layers
892
+ 1. **DOM vs Vision** — Compares DOM-extracted price with screenshot OCR value
893
+ 2. **Market Benchmark** — Validates against historical price benchmarks for the category
894
+ 3. **Temporal Consistency** — Checks if price changed suspiciously since last verification
895
+ 4. **Composite Score** — Weighted combination of all layers with severity classification
896
+
897
+ ---
898
+
899
+ ## Community Agent Hub
900
+
901
+ Pre-built YAML agent templates for common use cases. Run any template from the CLI:
902
+
903
+ ```bash
904
+ # List available templates
905
+ npx wab-agent templates
906
+
907
+ # Run a template
908
+ npx wab-agent run olive-oil-tunisia --budget 50 --region tunis
909
+
910
+ # Run with custom server
911
+ npx wab-agent run hotel-direct-booking --server https://yourserver.com --checkin 2025-01-15
912
+ ```
913
+
914
+ ### Available Templates
915
+ | Template | Description |
916
+ |---|---|
917
+ | `olive-oil-tunisia` | Find olive oil from small Tunisian farms |
918
+ | `hotel-direct-booking` | Book hotels directly, bypass aggregators |
919
+ | `artisan-marketplace` | Handmade products from independent artisans |
920
+ | `grocery-price-compare` | Compare grocery prices across local stores |
921
+ | `freelancer-direct` | Find freelancers without platform fees |
922
+ | `restaurant-direct` | Order from restaurants without delivery apps |
923
+ | `book-price-scout` | Find books from indie bookstores |
924
+ | `flight-deal-hunter` | Find flights direct from airlines |
925
+ | `electronics-price-tracker` | Track electronics prices with history |
926
+ | `local-services` | Find local service providers |
927
+ | `organic-farm-fresh` | Organic produce direct from farms |
928
+
929
+ ### Create Your Own Template
930
+
931
+ ```yaml
932
+ name: my-custom-agent
933
+ description: My custom agent template
934
+ goal: Find the best deals on custom products
935
+ version: "1.0"
936
+ target_sites:
937
+ - https://example.com
938
+ parameters:
939
+ budget:
940
+ type: number
941
+ default: 100
942
+ description: Maximum budget
943
+ actions:
944
+ - name: discover
945
+ wab_action: discover
946
+ - name: search
947
+ wab_action: execute
948
+ action_name: search
949
+ params:
950
+ query: "{{keyword}}"
951
+ - name: negotiate
952
+ wab_action: negotiate
953
+ params:
954
+ item_id: "{{item_id}}"
955
+ max_price: "{{budget}}"
956
+ negotiation:
957
+ enabled: true
958
+ max_rounds: 3
959
+ accept_threshold: 0.85
960
+ fairness_rules:
961
+ - Prefer independent sellers over large platforms
962
+ - Verify all prices before purchase
963
+ ```
964
+
965
+ ---
966
+
778
967
  ## License
779
968
 
780
969
  MIT — Free to use, modify, and distribute.