Skill: imran-siddique/agentmesh-governance (version 1.0.0)

--- name: agentmesh-governance description: > AI agent governance, trust scoring, and policy enforcement powered by AgentMesh. Activate when: (1) user wants to enforce token limits, tool restrictions, or content policies on agent actions, (2) checking an agent's trust score before delegation or collaboration, (3) verifying agent identity with Ed25519 cryptographic DIDs, (4) auditing agent actions with tamper-evident Merkle chain logs, (5) user asks about agent safety, governance, compliance, or trust. Enterprise-grade: 1,600+ tests, merged into Dify (65K★), LlamaIndex (47K★), Microsoft Agent-Lightning (15K★). version: 1.0.0 metadata: openclaw: requires: bins: - python3 - pip emoji: "🛡️" homepage: https://github.com/imran-siddique/agentmesh-integrations/tree/master/openclaw-skill --- # AgentMesh Governance — Trust & Policy for OpenClaw Agents Zero-trust governance layer for OpenClaw agents. Enforce policies, verify identities, score trust, and maintain tamper-evident audit logs — all from your agent's command line. ## Setup Install the AgentMesh governance CLI: ```bash pip install agentmesh-governance ``` > If `agentmesh-governance` is not yet on PyPI, install directly from source: > ```bash > pip install "agentmesh @ git+https://github.com/imran-siddique/agent-mesh.git" > ``` ## Scripts All scripts are in `scripts/`. They wrap the governance engine and output JSON results. ### Check Policy Compliance Evaluate an action against a governance policy before execution: ```bash scripts/check-policy.sh --action "web_search" --tokens 1500 --policy policy.yaml ``` Returns JSON with `allowed: true/false`, any violations, and recommendations. Use this **before** executing any tool call to enforce limits. ### Get Trust Score Check an agent's current trust score (0.0 – 1.0): ```bash scripts/trust-score.sh --agent "research-agent" ``` Returns the composite trust score with breakdown across 5 dimensions: policy compliance, resource efficiency, output quality, security posture, collaboration health. ### Verify Agent Identity Verify an agent's Ed25519 cryptographic identity before trusting its output: ```bash scripts/verify-identity.sh --did "did:agentmesh:abc123" --message "hello" --signature "base64sig" ``` Returns `verified: true/false`. Use when receiving data from another agent. ### Record Interaction Update trust scores after collaborating with another agent: ```bash scripts/record-interaction.sh --agent "writer-agent" --outcome success scripts/record-interaction.sh --agent "writer-agent" --outcome failure --severity 0.1 ``` Success adds +0.01 to trust score. Failure subtracts the severity value. Agents dropping below the minimum threshold (default 0.5) are auto-blocked. ### Audit Log View tamper-evident audit trail with Merkle chain verification: ```bash scripts/audit-log.sh --last 20 scripts/audit-log.sh --agent "research-agent" --verify ``` The `--verify` flag checks Merkle chain integrity — any tampering is detected. ### Generate Identity Create a new Ed25519 cryptographic identity (DID) for your agent: ```bash scripts/generate-identity.sh --name "my-agent" --capabilities "search,summarize,write" ``` Returns your agent's DID, public key, and capability manifest. ## Policy File Format Create a `policy.yaml` to define governance rules: ```yaml name: production-policy max_tokens: 4096 max_tool_calls: 10 allowed_tools: - web_search - file_read - summarize blocked_tools: - shell_exec - file_delete blocked_patterns: - "rm -rf" - "DROP TABLE" - "BEGIN CERTIFICATE" confidence_threshold: 0.7 require_human_approval: false ``` ## When to Use This Skill - **Before tool execution**: Run `check-policy.sh` to enforce limits - **Before trusting another agent's output**: Run `verify-identity.sh` - **After collaboration**: Run `record-interaction.sh` to update trust - **Before delegation**: Check `trust-score.sh` — don't delegate to agents below 0.5 - **For compliance**: Run `audit-log.sh --verify` to prove execution integrity - **On setup**: Run `generate-identity.sh` to create your agent's DID ## What It Enforces | Policy | Description | |--------|-------------| | Token limits | Cap per-action and per-session token usage | | Tool allowlists | Only explicitly permitted tools can execute | | Tool blocklists | Dangerous tools are blocked regardless | | Content patterns | Block regex patterns (secrets, destructive commands, PII) | | Trust thresholds | Minimum trust score required for delegation | | Human approval | Gate critical actions behind human confirmation | ## Architecture This skill bridges the OpenClaw agent runtime with the [AgentMesh](https://github.com/imran-siddique/agent-mesh) governance engine: ``` OpenClaw Agent → SKILL.md scripts → AgentMesh Engine ├── GovernancePolicy (enforcement) ├── TrustEngine (5-dimension scoring) ├── AgentIdentity (Ed25519 DIDs) └── MerkleAuditChain (tamper-evident logs) ``` Part of the [Agent Ecosystem](https://imran-siddique.github.io): [AgentMesh](https://github.com/imran-siddique/agent-mesh) · [Agent OS](https://github.com/imran-siddique/agent-os) · [Agent SRE](https://github.com/imran-siddique/agent-sre)

path: scripts/audit-log.sh
content: #!/usr/bin/env bash
# View and verify Merkle audit log
set -euo pipefail

LAST="10" AGENT="" VERIFY=""
while [[ $# -gt 0 ]]; do
  case "$1" in
    --last)   LAST="$2"; shift 2;;
    --agent)  AGENT="$2"; shift 2;;
    --verify) VERIFY="true"; shift;;
    *) echo "Unknown arg: $1" >&2; exit 1;;
  esac
done

python3 -c "
import json
try:
    from agentmesh.audit import MerkleAuditChain
    chain = MerkleAuditChain()
    entries = chain.get_entries(agent='$AGENT' or None, last=int('$LAST'))
    if '$VERIFY' == 'true':
        valid = chain.verify_integrity()
        print(json.dumps({'integrity': 'valid' if valid else 'TAMPERED', 'entries': len(entries)}, indent=2))
    else:
        print(json.dumps([e.to_dict() for e in entries], indent=2))
except ImportError:
    result = {
        'entries': [],
        'note': 'Install agentmesh for audit logging: pip install agentmesh'
    }
    print(json.dumps(result, indent=2))
"


path: scripts/check-policy.sh
content: #!/usr/bin/env bash
# Check action against governance policy
set -euo pipefail

ACTION="" TOKENS="" POLICY="policy.yaml"
while [[ $# -gt 0 ]]; do
  case "$1" in
    --action)  ACTION="$2"; shift 2;;
    --tokens)  TOKENS="$2"; shift 2;;
    --policy)  POLICY="$2"; shift 2;;
    *) echo "Unknown arg: $1" >&2; exit 1;;
  esac
done

python3 -c "
import json, yaml, re, sys

with open('$POLICY') as f:
    p = yaml.safe_load(f)

violations = []
action = '$ACTION'
tokens = int('${TOKENS:-0}' or '0')

if p.get('max_tokens') and tokens > p['max_tokens']:
    violations.append(f'Token limit exceeded: {tokens} > {p[\"max_tokens\"]}')

if p.get('allowed_tools') and action and action not in p['allowed_tools']:
    violations.append(f'Tool not in allowlist: {action}')

if p.get('blocked_tools') and action in p['blocked_tools']:
    violations.append(f'Tool is blocked: {action}')

if p.get('blocked_patterns'):
    for pat in p['blocked_patterns']:
        if re.search(pat, action, re.IGNORECASE):
            violations.append(f'Blocked pattern matched: {pat}')

result = {
    'allowed': len(violations) == 0,
    'action': action,
    'tokens': tokens,
    'violations': violations,
    'policy': p.get('name', 'unnamed'),
    'require_human_approval': p.get('require_human_approval', False)
}
print(json.dumps(result, indent=2))
sys.exit(0 if result['allowed'] else 1)
"


path: scripts/generate-identity.sh
content: #!/usr/bin/env bash
# Generate Ed25519 cryptographic identity (DID)
set -euo pipefail

NAME="" CAPABILITIES=""
while [[ $# -gt 0 ]]; do
  case "$1" in
    --name)         NAME="$2"; shift 2;;
    --capabilities) CAPABILITIES="$2"; shift 2;;
    *) echo "Unknown arg: $1" >&2; exit 1;;
  esac
done

python3 -c "
import json, hashlib, base64
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey
from cryptography.hazmat.primitives.serialization import Encoding, PublicFormat, PrivateFormat, NoEncryption

key = Ed25519PrivateKey.generate()
pub = key.public_key()
pub_bytes = pub.public_bytes(Encoding.Raw, PublicFormat.Raw)
did = 'did:agentmesh:' + hashlib.sha256(pub_bytes).hexdigest()[:16]

caps = [c.strip() for c in '${CAPABILITIES}'.split(',') if c.strip()]

result = {
    'name': '$NAME',
    'did': did,
    'public_key': base64.b64encode(pub_bytes).decode(),
    'capabilities': caps,
    'key_type': 'Ed25519',
    'note': 'Store your private key securely. Share only the DID and public key.'
}
print(json.dumps(result, indent=2))
"


path: scripts/record-interaction.sh
content: #!/usr/bin/env bash
# Record interaction outcome and update trust score
set -euo pipefail

AGENT="" OUTCOME="" SEVERITY="0.05"
while [[ $# -gt 0 ]]; do
  case "$1" in
    --agent)    AGENT="$2"; shift 2;;
    --outcome)  OUTCOME="$2"; shift 2;;
    --severity) SEVERITY="$2"; shift 2;;
    *) echo "Unknown arg: $1" >&2; exit 1;;
  esac
done

python3 -c "
import json, datetime
try:
    from agentmesh.trust import RewardEngine
    engine = RewardEngine()
    if '$OUTCOME' == 'success':
        engine.record_success('$AGENT')
    else:
        engine.record_failure('$AGENT', severity=float('$SEVERITY'))
    score = engine.get_score('$AGENT')
    print(json.dumps(score, indent=2))
except ImportError:
    delta = 0.01 if '$OUTCOME' == 'success' else -float('$SEVERITY')
    result = {
        'agent': '$AGENT',
        'outcome': '$OUTCOME',
        'score_delta': delta,
        'timestamp': datetime.datetime.utcnow().isoformat() + 'Z',
        'note': 'Install agentmesh for persistent scoring: pip install agentmesh'
    }
    print(json.dumps(result, indent=2))
"


path: scripts/trust-score.sh
content: #!/usr/bin/env bash
# Get agent trust score
set -euo pipefail

AGENT=""
while [[ $# -gt 0 ]]; do
  case "$1" in
    --agent) AGENT="$2"; shift 2;;
    *) echo "Unknown arg: $1" >&2; exit 1;;
  esac
done

python3 -c "
import json
try:
    from agentmesh.trust import RewardEngine
    engine = RewardEngine()
    score = engine.get_score('$AGENT')
    print(json.dumps(score, indent=2))
except ImportError:
    # Standalone mode — return baseline trust info
    result = {
        'agent': '$AGENT',
        'trust_score': 0.5,
        'dimensions': {
            'policy_compliance': 0.5,
            'resource_efficiency': 0.5,
            'output_quality': 0.5,
            'security_posture': 0.5,
            'collaboration_health': 0.5
        },
        'status': 'baseline',
        'note': 'Install agentmesh for full trust scoring: pip install agentmesh'
    }
    print(json.dumps(result, indent=2))
"


path: scripts/verify-identity.sh
content: #!/usr/bin/env bash
# Verify agent Ed25519 identity
set -euo pipefail

DID="" MESSAGE="" SIGNATURE=""
while [[ $# -gt 0 ]]; do
  case "$1" in
    --did)       DID="$2"; shift 2;;
    --message)   MESSAGE="$2"; shift 2;;
    --signature) SIGNATURE="$2"; shift 2;;
    *) echo "Unknown arg: $1" >&2; exit 1;;
  esac
done

python3 -c "
import json
try:
    from agentmesh.identity import AgentIdentity
    identity = AgentIdentity.from_did('$DID')
    verified = identity.verify(b'$MESSAGE', '$SIGNATURE')
    print(json.dumps({'did': '$DID', 'verified': verified}, indent=2))
except ImportError:
    from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PublicKey
    import base64
    print(json.dumps({
        'did': '$DID',
        'verified': False,
        'note': 'Install agentmesh for full verification: pip install agentmesh'
    }, indent=2))
"


Security scan verdicts — ClawScan: suspicious | static analysis: clean | VirusTotal: suspicious | SkillSpector: clean (LOW)