agent-passport

TotalClaw 作者 totalclaw v2.4.0

代理时代的 OAuth。所有敏感代理操作的同意门控。超过 75 个数据驱动的威胁定义,具有自动更新功能(如防病毒签名)。包括技能扫描器、注入屏蔽、SSRF 屏蔽、路径遍历防护、支出上限、速率限制、允许列表、TTL 到期、审计跟踪和 KYA 元数据。专业级每 6 小时添加实时威胁定义更新。

安装 / 下载方式

TotalClaw CLI推荐
totalclaw skills install shop:totalclaw:totalclaw~markneville-agent-passport
cURL直接下载,无需登录
curl -fsSL https://skills.taituai.com/api/skills/totalclaw%3Atotalclaw~markneville-agent-passport/file -o markneville-agent-passport.md
## 概述(中文)

代理时代的 OAuth。所有敏感代理操作的同意门控。超过 75 个数据驱动的威胁定义,具有自动更新功能(如防病毒签名)。包括技能扫描器、注入屏蔽、SSRF 屏蔽、路径遍历防护、支出上限、速率限制、允许列表、TTL 到期、审计跟踪和 KYA 元数据。专业级每 6 小时添加实时威胁定义更新。

## 原文

# Agent Passport (OpenClaw)

## 30-Second Setup

```bash
# Initialize and register your agent
./mandate-ledger.sh init agent:my-assistant "Your Name" "personal assistant" "openclaw"

# Grant dev tool access (git, npm, docker, etc.)
./mandate-ledger.sh create-from-template dev-tools

# That's it! The agent will now check permissions before sensitive actions.
```

> **Templates available:** `dev-tools` · `email-team <domain>` · `file-ops <path>` · `web-research` · `safe-browsing` · `coding` · `email-assistant` · `read-only` · `full-auto`
> Run `./mandate-ledger.sh templates` to see all options.

---

## ⚡ Agent Behavioral Contract

**If you are an agent reading this skill, these are your rules. Follow them.**

### When to Check

Before performing ANY of these actions, you MUST call `check-action` first:

| Action | Category | Example target |
|--------|----------|----------------|
| Running a shell command | `system` | `"git pull"`, `"npm install"` |
| Sending a message/email | `communication` | `"bob@company.com"` |
| Writing/deleting a file | `data` | `"/path/to/file.txt"` |
| Making an API call with side effects | `external_api` | `"api.github.com"` |
| Spending money | `financial` | `"merchant_amazon"` with amount |
| Acting publicly as the user | `identity` | `"twitter_post"` |

**You do NOT need to check:** reading files, web searches, internal reasoning, or anything with no side effects.

### How to Check

```bash
SCRIPT_DIR="$HOME/.openclaw/skills/agent-passport/scripts"

result=$($SCRIPT_DIR/mandate-ledger.sh check-action "<your_agent_id>" "<category>" "<target>" [amount])
```

Parse the result:
- `authorized: true` → proceed, then log the action afterward
- `authorized: false` → **STOP. Ask the user.**
- If response includes `kill_switch: true` or reason `Kill switch engaged` → **STOP immediately** and ask user to run `mandate-ledger.sh unlock`

### The Flow

```
1. You want to do something sensitive
2. Call check-action
3. IF authorized:
   a. Do the thing
   b. Log it: mandate-ledger.sh log-action <mandate_id> <amount> "<description>"
4. IF denied:
   a. Tell the user what you want to do and why
   b. Suggest a mandate (show scope, duration, constraints)
   c. Wait for approval
   d. If approved, create the mandate, then proceed
```

### How to Ask for Permission

When denied, present it clearly and concisely:

```
I need to [ACTION] but don't have a mandate for it.

📋 [CATEGORY]: [what you want to do]
🎯 Target: [specific target]
⏰ Suggested duration: [reasonable TTL]

Want me to set this up? I can also create a broader mandate if you'd
prefer (e.g., all emails to @company.com for 30 days).
```

**DO NOT:**
- Bypass the check and do it anyway
- Ask repeatedly for the same thing if denied
- Create mandates yourself without user approval
- Pretend you checked when you didn't

**DO:**
- Suggest templates when appropriate ("Want me to set up `dev-tools`?")
- Batch similar requests ("I'll need to run several git commands — want a dev-tools mandate?")
- Log every action after completion
- Mention remaining limits when relevant ("3/20 daily emails used")

### First-Time Setup

If `check-action` returns `"hint": "templates"`, the ledger is empty. Guide the user:

```
Agent Passport isn't set up yet. It takes 30 seconds:

  mandate-ledger.sh init agent:me "Your Name" "assistant" "openclaw"
  mandate-ledger.sh create-from-template dev-tools

Want me to run this for you?
```

### Logging Actions

After every authorized action, log it:

```bash
$SCRIPT_DIR/mandate-ledger.sh log-action "<mandate_id>" <amount> "<description>"
```

- For financial: amount = dollars spent
- For everything else: amount = 1
- Description should be human-readable: "Sent email to bob@company.com re: Q1 report"

### Kill Switch Behavior

If the user engages the kill switch, all operations are frozen until unlocked.

```bash
./mandate-ledger.sh kill "user requested freeze"
./mandate-ledger.sh unlock
```

Agent behavior when kill switch is active:
- Do not attempt sensitive actions
- Do not retry `check-action` in a loop
- Tell user operations are blocked and request explicit `unlock`

---

## Overview

Agent Passport provides a consent layer for agent autonomy. Instead of all-or-nothing permissions, users grant **mandates** with specific constraints:

```
"I authorize this agent to [ACTION] with [CONSTRAINTS] until [EXPIRY]"
```

This isn't just about purchases — it's consent-gating for **all sensitive actions**.

## Action Categories

| Category | Examples | Typical Constraints |
|----------|----------|---------------------|
| `financial` | Purchases, transfers, subscriptions | Spending cap, merchant allowlist |
| `communication` | Emails, messages, tweets, posts | Recipient allowlist, rate limit |
| `data` | Delete files, edit docs, DB writes | Path allowlist, require backup |
| `system` | Shell commands, installs, configs | Command allowlist, no sudo |
| `external_api` | Third-party API calls | Service allowlist, rate limit |
| `identity` | Public actions "as" the user | Human review required |

## Wildcard Patterns

Allowlists and deny lists support three wildcard styles:

| Pattern | Matches | Example |
|---------|---------|---------|
| `prefix *` | Anything starting with prefix | `git *` → `git pull`, `git status` |
| `*.suffix` | Anything ending with suffix | `*.env` → `config.env`, `.env` |
| `*middle*` | Anything containing middle | `*/.git/*` → `repo/.git/config` |
| `*@domain` | Email domain match | `*@company.com` → `bob@company.com` |
| `exact` | Exact match only | `api.github.com` |

## Modes

- **Local mode** (default): Mandates stored in `~/.openclaw/agent-passport/`. Free tier is fully offline. Pro tier makes periodic API calls to `api.agentpassportai.com` for license validation and threat definition updates.
- **Preview mode:** No storage, no network. Generates validated payloads and curl templates.
- **Live mode (roadmap):** Future connection to Agent Bridge backend for multi-agent sync and compliance. Not yet implemented.

## Quick Start Commands

```bash
# Initialize with identity
./mandate-ledger.sh init <agent_id> <principal> [scope] [provider]

# Templates (auto-detects agent if registered)
./mandate-ledger.sh templates
./mandate-ledger.sh create-from-template dev-tools
./mandate-ledger.sh create-from-template email-team <domain>
./mandate-ledger.sh create-from-template file-ops <path>
./mandate-ledger.sh create-from-template web-research
./mandate-ledger.sh create-from-template safe-browsing
./mandate-ledger.sh create-from-template coding
./mandate-ledger.sh create-from-template email-assistant
./mandate-ledger.sh create-from-template read-only
./mandate-ledger.sh create-from-template full-auto

# Quick create (human-friendly durations: 7d, 24h, 30m)
./mandate-ledger.sh create-quick <type> <agent_id> <allowlist_csv> <duration> [amount_cap]

# Check & log
./mandate-ledger.sh check-action <agent> <type> <target> [amount]
./mandate-ledger.sh log-action <mandate_id> <amount> "<description>"

# Audit
./mandate-ledger.sh audit [limit]
./mandate-ledger.sh summary

# Threat definitions
./mandate-ledger.sh init-definitions
./mandate-ledger.sh update-definitions
./mandate-ledger.sh definitions-status
```

## Commands Reference

### Quick Start
```bash
init [agent_id] [principal] [scope] [provider]
                           # Initialize ledger, optionally register agent
templates                  # List available templates
create-from-template <t>   # Create mandate from template
  [agent_id] [args...]
create-quick <type>        # Create with positional args
  <agent_id> <allowlist>
  <duration> [amount_cap]
```

### Mandate Lifecycle
```bash
create <json>              # Create mandate (include action_type)
create-with-kya <json>     # Create with auto-attached agent KYA
get <mandate_id>           #