Nostr CLI for Cobot agents - keygen, DMs, identity management
  • Python 99.6%
  • Shell 0.4%
Find a file
2026-02-22 19:42:07 +00:00
bin Initial commit: Nostr CLI for Cobot agents 2026-02-19 20:06:45 +00:00
.gitignore feat: add timestamped logging for DM receipt and wake calls 2026-02-22 19:38:51 +00:00
nostr_cli.py feat: add timestamped logging for DM receipt and wake calls 2026-02-22 19:38:51 +00:00
README.md Integrate local DeBERTa prompt-guard service 2026-02-20 08:28:54 +00:00
requirements.txt Initial commit: Nostr CLI for Cobot agents 2026-02-19 20:06:45 +00:00
test_nostr_cli.py feat: add 34 unit tests covering crypto, injection shield, wake, and key handling 2026-02-22 19:42:07 +00:00

Nostr CLI

Command-line tool for Nostr identity management and encrypted DMs (NIP-04).

Features:

  • 🔑 Key generation (nsec/npub)
  • 📨 Send & receive encrypted DMs
  • 🛡️ Prompt injection shield (blocks malicious messages)
  • Wake mechanism (alert agents on new DMs)

Installation

# Create venv and install deps
python3 -m venv venv
./venv/bin/pip install -r requirements.txt

# Make CLI executable
chmod +x bin/nostr

# Add to PATH (optional)
export PATH="$PATH:$(pwd)/bin"

Commands

Generate Keypair

nostr keygen

Show Identity

export NOSTR_NSEC="nsec1..."
nostr whoami

Listen for DMs

nostr listen

With wake notifications:

nostr listen --wake-url http://localhost:18793/hooks/wake --wake-token filedrop-wake-olymp

Disable injection shield (not recommended):

nostr listen --no-shield

Send DM

nostr send npub1abc... "Hello!"

Test Wake

nostr wake --url http://localhost:18793/hooks/wake "Test message"

Environment Variables

Variable Description
NOSTR_NSEC Private key (nsec1... or hex)
NOSTR_WAKE_URL Wake endpoint URL
NOSTR_WAKE_TOKEN Wake auth token
NOSTR_AGENT_NAME Agent name (for registry lookup)
NOSTR_REGISTRY Path to agents.json

Security Features

Injection Shield (Two Layers)

Incoming DMs are scanned for prompt injection:

Layer 1: Regex (fast, ~80%)

  • Instruction override attempts
  • System prompt injection
  • Roleplay jailbreaks
  • Credential extraction
  • Tool abuse attempts

Layer 2: Local DeBERTa Model (~99%, multilingual)

  • Uses protectai/deberta-v3-base-prompt-injection-v2
  • Runs on olymp at http://localhost:8080
  • Catches obfuscated attacks, language switching, etc.

Disable local model with --no-local-shield (regex only). Disable entirely with --no-shield.

Wake Mechanism

When a DM arrives, the CLI can notify an agent via webhook:

POST /hooks/wake
Authorization: Bearer <token>
{"text": "Nostr DM from npub1...: message preview", "mode": "now"}

Compatible with OpenClaw hooks and filedrop wake system.

Integration with agents.json

The CLI can read wake config from /olymp/agents.json:

{
  "agents": {
    "Hermes": {
      "wake": {
        "method": "hooks",
        "url": "http://localhost:18793/hooks/wake",
        "token": "filedrop-wake-olymp"
      }
    }
  }
}

Set NOSTR_AGENT_NAME=Hermes to use this config.

Credits

  • Original listener script by noopsec
  • Refactored with shield + wake by Hermes 🪽