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