|
| 1 | +# Running the Web4 Demos |
| 2 | + |
| 3 | +This guide shows how to run the **Store Demo** (merchant) and the **Delegation Manager UI** together, and how to exercise the trust and approval flows. |
| 4 | + |
| 5 | +## 1. Prerequisites |
| 6 | + |
| 7 | +- Python 3.10+ installed and on PATH. |
| 8 | +- `pip` available for installing dependencies. |
| 9 | +- (Recommended) A virtual environment for this repo. |
| 10 | + |
| 11 | +From the repo root: |
| 12 | + |
| 13 | +```bash |
| 14 | +cd demo/store |
| 15 | +pip install -r requirements.txt |
| 16 | + |
| 17 | +cd ../delegation-ui |
| 18 | +pip install -r requirements.txt |
| 19 | +``` |
| 20 | + |
| 21 | +> If `cryptography` prints messages about Rust, it is trying to compile from source. On most Windows setups the prebuilt wheels will be used; if not, installing Rust from https://rustup.rs may be required. |
| 22 | +
|
| 23 | +--- |
| 24 | + |
| 25 | +## 2. Start the Delegation Manager UI |
| 26 | + |
| 27 | +From the repo root: |
| 28 | + |
| 29 | +```bash |
| 30 | +cd demo/delegation-ui |
| 31 | +python app.py |
| 32 | +``` |
| 33 | + |
| 34 | +Then open: |
| 35 | + |
| 36 | +- http://localhost:8001 |
| 37 | + |
| 38 | +What you can do here: |
| 39 | + |
| 40 | +- **Create delegations** for agents (e.g. `agent-claude-demo`). |
| 41 | +- Set spending limits and allowed resources. |
| 42 | +- See **pending approvals** for high-value purchases. |
| 43 | +- View **activity** and **T3 trust scores** for agents. |
| 44 | + |
| 45 | +--- |
| 46 | + |
| 47 | +## 3. Start the Store Demo (Merchant) |
| 48 | + |
| 49 | +In a second terminal, from the repo root: |
| 50 | + |
| 51 | +```bash |
| 52 | +cd demo/store |
| 53 | +python app.py |
| 54 | +``` |
| 55 | + |
| 56 | +Then open: |
| 57 | + |
| 58 | +- Store home: http://localhost:8000 |
| 59 | +- Store dashboard: http://localhost:8000/dashboard |
| 60 | + |
| 61 | +The store exposes a simple product catalog with an "🤖 Agent Purchase" button for each item. Purchases are executed by a demo agent (`agent-claude-demo`) using the Web4 authorization stack. |
| 62 | + |
| 63 | +--- |
| 64 | + |
| 65 | +## 4. Walkthrough: Trust and Approvals in Action |
| 66 | + |
| 67 | +### Step 1 – Create a delegation |
| 68 | + |
| 69 | +1. Go to **Delegation Manager**: http://localhost:8001 |
| 70 | +2. On the **Create Delegation** tab: |
| 71 | + - Set **Agent Name** to something like `Claude (demo)`. |
| 72 | + - Set **Agent ID** to `agent-claude-demo`. |
| 73 | + - Leave budgets at defaults or adjust as you like. |
| 74 | + - Choose allowed resources (e.g. books and music). |
| 75 | + - Click **Create Delegation**. |
| 76 | +3. Switch to **Manage Delegations** to see the new entry and its T3 trust section. |
| 77 | + |
| 78 | +### Step 2 – Normal purchases and trust evolution |
| 79 | + |
| 80 | +1. Go to the **Store**: http://localhost:8000 |
| 81 | +2. Click **🤖 Agent Purchase** on lower-priced items (e.g. books/music under $75). |
| 82 | +3. After a successful purchase, visit the **Store Dashboard**: |
| 83 | + - http://localhost:8000/dashboard |
| 84 | +4. Observe: |
| 85 | + - **Daily Budget** usage. |
| 86 | + - **ATP Budget**. |
| 87 | + - **Agent Trust (T3)**: talent, training, temperament, composite, and transaction stats. |
| 88 | + - Recent purchases in **Activity**. |
| 89 | + |
| 90 | +Each successful, in-constraint purchase updates the agent’s T3 profile via the `T3Tracker`. |
| 91 | + |
| 92 | +### Step 3 – Low-trust, high-value gate |
| 93 | + |
| 94 | +The store enforces a demo-local policy: |
| 95 | + |
| 96 | +- If **composite T3 trust < 0.30** and |
| 97 | +- The product price is **≥ $75.00**, |
| 98 | +- Then the purchase is denied and routed to the Delegation Manager for approval. |
| 99 | + |
| 100 | +To see this: |
| 101 | + |
| 102 | +1. From the **Store**, attempt to buy a high-priced item (e.g. `Introduction to Machine Learning`). |
| 103 | +2. If the agent’s trust is still low, you will see a message like: |
| 104 | + |
| 105 | + > Agent trust too low for high-value purchase. Trust X.XX < 0.30 for items over $75.00. Approval request created. Open the Delegation Manager to review (ID: app-...). |
| 106 | +
|
| 107 | +3. Go to **Delegation Manager → Pending Approvals**: |
| 108 | + - http://localhost:8001 |
| 109 | + - You should see a card for the high-value purchase request. |
| 110 | +4. Approve or deny the request. |
| 111 | +5. Check **Activity** to see the approval response logged. |
| 112 | + |
| 113 | +At this point you have: |
| 114 | + |
| 115 | +- Verified end-to-end Web4 authorization for normal purchases. |
| 116 | +- Seen **T3 trust** update based on outcomes. |
| 117 | +- Triggered a **human approval requirement** driven by low trust for high-value items. |
| 118 | + |
| 119 | +--- |
| 120 | + |
| 121 | +## 5. Trust Visualizer Example |
| 122 | + |
| 123 | +The trust visualizer is a separate static example that shows simplified trust dynamics over time. |
| 124 | + |
| 125 | +From the repo root: |
| 126 | + |
| 127 | +1. Open the file directly in a browser: |
| 128 | + |
| 129 | + ``` |
| 130 | + c:\projects\ai-agents\web4\examples\trust-visualizer\index.html |
| 131 | + ``` |
| 132 | + |
| 133 | +2. Or serve via a simple static server (example): |
| 134 | + |
| 135 | + ```bash |
| 136 | + cd examples/trust-visualizer |
| 137 | + python -m http.server 8080 |
| 138 | + # then visit http://localhost:8080/index.html |
| 139 | + ``` |
| 140 | + |
| 141 | +Use the **Positive / Negative / Neutral / Random** buttons to see the trust line and uncertainty band evolve. |
| 142 | + |
| 143 | +--- |
| 144 | + |
| 145 | +This document is intentionally minimal; for deeper architectural context, see the root `README.md`, `WINDSURF_QUICKSTART.md`, and `DEMO_SCRIPT.md`. |
0 commit comments