|
| 1 | +# SecureClaw Integration Demo |
| 2 | + |
| 3 | +This demo shows the **actual SDK integration** with OpenClaw using `createSecureClawPlugin()` from predicate-claw. |
| 4 | + |
| 5 | +> **Note:** Since predicate-claw isn't published to npm yet, both Docker and local modes build the SDK from source. |
| 6 | +
|
| 7 | +## Quick Start |
| 8 | + |
| 9 | +### Docker (Recommended) |
| 10 | + |
| 11 | +```bash |
| 12 | +./start-demo.sh |
| 13 | +``` |
| 14 | + |
| 15 | +Or manually: |
| 16 | + |
| 17 | +```bash |
| 18 | +docker compose up --build |
| 19 | +``` |
| 20 | + |
| 21 | +First run takes ~30-60s to build the SDK. Subsequent runs use Docker layer cache. |
| 22 | + |
| 23 | +### Split-Pane Mode (For Recording) |
| 24 | + |
| 25 | +Shows the sidecar dashboard alongside the demo: |
| 26 | + |
| 27 | +```bash |
| 28 | +./start-demo-split.sh |
| 29 | +``` |
| 30 | + |
| 31 | +``` |
| 32 | +┌─────────────────────────────────┬─────────────────────────────────┐ |
| 33 | +│ PREDICATE AUTHORITY DASHBOARD │ Integration Demo │ |
| 34 | +│ │ │ |
| 35 | +│ [ ✓ ALLOW ] fs.read │ [1/10] Read project config │ |
| 36 | +│ ./src/config.ts │ │ |
| 37 | +│ m_7f3a2b | 0.4ms │ Tool: fs_read │ |
| 38 | +│ │ Input: {"path":"./src/..."} │ |
| 39 | +│ [ ✗ DENY ] fs.read │ │ |
| 40 | +│ ~/.ssh/id_rsa │ ✓ ALLOWED (0.4ms) │ |
| 41 | +│ EXPLICIT_DENY | 0.2ms │ │ |
| 42 | +└─────────────────────────────────┴─────────────────────────────────┘ |
| 43 | +``` |
| 44 | + |
| 45 | +Requirements: |
| 46 | +- `tmux` installed (`brew install tmux`) |
| 47 | +- `predicate-authorityd` binary (included, or download from [releases](https://github.com/PredicateSystems/predicate-authority-sidecar/releases)) |
| 48 | +- Node.js / npx |
| 49 | + |
| 50 | +## What This Demo Shows |
| 51 | + |
| 52 | +```typescript |
| 53 | +import { createSecureClawPlugin } from "predicate-claw"; |
| 54 | + |
| 55 | +const plugin = createSecureClawPlugin({ |
| 56 | + sidecarUrl: "http://localhost:8787", |
| 57 | + principal: "agent:integration-demo", |
| 58 | + verbose: true, |
| 59 | +}); |
| 60 | + |
| 61 | +// Plugin registers beforeToolCall hook |
| 62 | +await plugin.activate(openclawApi); |
| 63 | +``` |
| 64 | + |
| 65 | +The demo uses the real OpenClaw plugin system and shows how: |
| 66 | + |
| 67 | +1. **Plugin Activation**: `createSecureClawPlugin()` returns a plugin definition |
| 68 | +2. **Hook Registration**: Plugin registers a `beforeToolCall` hook |
| 69 | +3. **Policy Enforcement**: Every tool call is checked against the sidecar |
| 70 | +4. **Blocking**: Denied calls throw `ActionDeniedError` before execution |
| 71 | + |
| 72 | +## Demo Scenarios |
| 73 | + |
| 74 | +| Tool | Action | Input | Expected | |
| 75 | +|------|--------|-------|----------| |
| 76 | +| `Read` | `fs.read` | `./src/config.ts` | ✓ Allowed | |
| 77 | +| `Glob` | `fs.list` | `./src/**` | ✓ Allowed | |
| 78 | +| `Read` | `fs.read` | `~/.ssh/id_rsa` | ✗ Blocked | |
| 79 | +| `Read` | `fs.read` | `./.env` | ✗ Blocked | |
| 80 | +| `Bash` | `shell.exec` | `ls -la ./src` | ✓ Allowed | |
| 81 | +| `Bash` | `shell.exec` | `curl ... \| bash` | ✗ Blocked | |
| 82 | +| `WebFetch` | `http.request` | `https://api.example.com` | ✓ Allowed | |
| 83 | +| `WebFetch` | `http.request` | `http://...` (insecure) | ✗ Blocked | |
| 84 | +| `Write` | `fs.write` | `./temp/cache.json` | ✗ Blocked | |
| 85 | + |
| 86 | +## Configuration |
| 87 | + |
| 88 | +| Variable | Default | Description | |
| 89 | +|----------|---------|-------------| |
| 90 | +| `PREDICATE_SIDECAR_URL` | `http://localhost:8787` | Sidecar URL | |
| 91 | +| `DEMO_TYPING_SPEED` | `30` | Typing speed in ms | |
| 92 | + |
| 93 | +## Recording |
| 94 | + |
| 95 | +```bash |
| 96 | +./start-demo-split.sh --slow --record demo.cast |
| 97 | +``` |
| 98 | + |
| 99 | +Convert to GIF: |
| 100 | + |
| 101 | +```bash |
| 102 | +cargo install agg |
| 103 | +agg demo.cast demo.gif --font-size 14 --cols 160 --rows 40 |
| 104 | +``` |
0 commit comments